diff --git a/renderdoc/Makefile b/renderdoc/Makefile index a80ca713b..7939a352c 100644 --- a/renderdoc/Makefile +++ b/renderdoc/Makefile @@ -12,7 +12,7 @@ OBJDIR=.obj OBJECTS=replay/replay_output.o \ replay/replay_renderer.o \ replay/entry_points.o \ -replay/basic_types.o \ +replay/type_helpers.o \ hooks/hooks.o \ hooks/gl_linux_hooks.o \ serialise/serialiser.o \ @@ -88,7 +88,12 @@ $(OBJDIR)/%.frago: %.frag cd $$(dirname $<) && objcopy --input binary --output elf64-x86-64 --binary-architecture i386 $$(basename $<) $$(basename $@) @mv $$(dirname $<)/$$(basename $@) $@ -librenderdoc.so: $(addprefix $(OBJDIR)/, $(SHADERS) $(OBJECTS)) +OBJDIR_OBJECTS=$(addprefix $(OBJDIR)/, $(OBJECTS)) +OBJDIR_SHADERS=$(addprefix $(OBJDIR)/, $(SHADERS)) + +-include $(OBJDIR_OBJECTS:.o=.d) + +librenderdoc.so: $(OBJDIR_OBJECTS) $(OBJDIR_SHADERS) g++ -o librenderdoc.so $^ $(LDFLAGS) .PHONY: clean diff --git a/renderdoc/api/README.md b/renderdoc/api/README.md new file mode 100644 index 000000000..8079a104d --- /dev/null +++ b/renderdoc/api/README.md @@ -0,0 +1,6 @@ +This folder can be extracted out and placed into your source tree if you want to use RenderDoc. + +* If you want to access RenderDoc while it's injected into your program, the app/ folder is what you want. This also contains functions for injecting RenderDoc into existing or new processes. +* If you want to write a program that utilises RenderDoc's replay and analysis capabilities (e.g. writing a new UI, or an auto-testing/offline analysis tool), the replay/ folder is what you want. + +You will need both folders if you want to launch processes with RenderDoc injected. diff --git a/renderdoc/api/app/renderdoc_app.h b/renderdoc/api/app/renderdoc_app.h new file mode 100644 index 000000000..f17528f81 --- /dev/null +++ b/renderdoc/api/app/renderdoc_app.h @@ -0,0 +1,186 @@ +/****************************************************************************** + * The MIT License (MIT) + * + * Copyright (c) 2014 Crytek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + ******************************************************************************/ + + +#pragma once + +#include + +typedef uint8_t byte; +typedef uint32_t bool32; + +#ifdef WIN32 + +#ifdef RENDERDOC_EXPORTS +#define RENDERDOC_API __declspec(dllexport) +#else +#define RENDERDOC_API __declspec(dllimport) +#endif +#define RENDERDOC_CC __cdecl + +#elif defined(LINUX) + +#ifdef RENDERDOC_EXPORTS +#define RENDERDOC_API __attribute__ ((visibility ("default"))) +#else +#define RENDERDOC_API +#endif + +#define RENDERDOC_CC + +#else + +#error "Unknown platform" + +#endif + +#include +#include // istringstream/ostringstream used to avoid other dependencies + +struct CaptureOptions +{ + CaptureOptions() + : AllowVSync(true), + AllowFullscreen(true), + DebugDeviceMode(false), + CaptureCallstacks(false), + CaptureCallstacksOnlyDraws(false), + DelayForDebugger(0), + CacheStateObjects(true), + HookIntoChildren(false), + RefAllResources(false), + SaveAllInitials(false), + CaptureAllCmdLists(false) + {} + + bool32 AllowVSync; + bool32 AllowFullscreen; + bool32 DebugDeviceMode; + bool32 CaptureCallstacks; + bool32 CaptureCallstacksOnlyDraws; + uint32_t DelayForDebugger; + bool32 CacheStateObjects; + bool32 HookIntoChildren; + bool32 RefAllResources; + bool32 SaveAllInitials; + bool32 CaptureAllCmdLists; + +#ifdef __cplusplus + void FromString(std::string str) + { + std::istringstream iss(str); + + iss >> AllowFullscreen + >> AllowVSync + >> DebugDeviceMode + >> CaptureCallstacks + >> CaptureCallstacksOnlyDraws + >> DelayForDebugger + >> CacheStateObjects + >> HookIntoChildren + >> RefAllResources + >> SaveAllInitials + >> CaptureAllCmdLists; + } + + std::string ToString() const + { + std::ostringstream oss; + + oss << AllowFullscreen << " " + << AllowVSync << " " + << DebugDeviceMode << " " + << CaptureCallstacks << " " + << CaptureCallstacksOnlyDraws << " " + << DelayForDebugger << " " + << CacheStateObjects << " " + << HookIntoChildren << " " + << RefAllResources << " " + << SaveAllInitials << " " + << CaptureAllCmdLists << " "; + + return oss.str(); + } +#endif +}; + +enum InAppOverlay +{ + eOverlay_Enabled = 0x1, + eOverlay_FrameRate = 0x2, + eOverlay_FrameNumber = 0x4, + eOverlay_CaptureList = 0x8, + + eOverlay_Default = (eOverlay_Enabled|eOverlay_FrameRate|eOverlay_FrameNumber|eOverlay_CaptureList), + eOverlay_All = ~0U, + eOverlay_None = 0, +}; + +#define RENDERDOC_API_VERSION 1 + +////////////////////////////////////////////////////////////////////////// +// In-program functions +////////////////////////////////////////////////////////////////////////// + +extern "C" RENDERDOC_API int RENDERDOC_CC RENDERDOC_GetAPIVersion(); +typedef int (RENDERDOC_CC *pRENDERDOC_GetAPIVersion)(); + +extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_SetLogFile(const wchar_t *logfile); +typedef void (RENDERDOC_CC *pRENDERDOC_SetLogFile)(const wchar_t *logfile); + +extern "C" RENDERDOC_API const wchar_t* RENDERDOC_CC RENDERDOC_GetLogFile(); +typedef const wchar_t* (RENDERDOC_CC *pRENDERDOC_GetLogFile)(); + +extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_SetCaptureOptions(const CaptureOptions *opts); +typedef void (RENDERDOC_CC *pRENDERDOC_SetCaptureOptions)(const CaptureOptions *opts); + +extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_SetActiveWindow(void *wndHandle); +typedef void (RENDERDOC_CC *pRENDERDOC_SetActiveWindow)(void *wndHandle); + +extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_TriggerCapture(); +typedef void (RENDERDOC_CC *pRENDERDOC_TriggerCapture)(); + +extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_StartFrameCapture(void *wndHandle); +typedef void (RENDERDOC_CC *pRENDERDOC_StartFrameCapture)(void *wndHandle); + +extern "C" RENDERDOC_API bool RENDERDOC_CC RENDERDOC_EndFrameCapture(void *wndHandle); +typedef bool (RENDERDOC_CC *pRENDERDOC_EndFrameCapture)(void *wndHandle); + +extern "C" RENDERDOC_API uint32_t RENDERDOC_CC RENDERDOC_GetOverlayBits(); +typedef uint32_t (RENDERDOC_CC *pRENDERDOC_GetOverlayBits)(); + +extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_MaskOverlayBits(uint32_t And, uint32_t Or); +typedef void (RENDERDOC_CC *pRENDERDOC_MaskOverlayBits)(uint32_t And, uint32_t Or); + +////////////////////////////////////////////////////////////////////////// +// Injection/execution capture functions. +////////////////////////////////////////////////////////////////////////// + +extern "C" RENDERDOC_API uint32_t RENDERDOC_CC RENDERDOC_ExecuteAndInject(const wchar_t *app, const wchar_t *workingDir, const wchar_t *cmdLine, + const wchar_t *logfile, const CaptureOptions *opts, bool waitForExit); +typedef uint32_t (RENDERDOC_CC *pRENDERDOC_ExecuteAndInject)(const wchar_t *app, const wchar_t *workingDir, const wchar_t *cmdLine, + const wchar_t *logfile, const CaptureOptions *opts, bool waitForExit); + +extern "C" RENDERDOC_API uint32_t RENDERDOC_CC RENDERDOC_InjectIntoProcess(uint32_t pid, const wchar_t *logfile, const CaptureOptions *opts, bool waitForExit); +typedef uint32_t (RENDERDOC_CC *pRENDERDOC_InjectIntoProcess)(uint32_t pid, const wchar_t *logfile, const CaptureOptions *opts, bool waitForExit); diff --git a/renderdoc/replay/basic_types.h b/renderdoc/api/replay/basic_types.h similarity index 99% rename from renderdoc/replay/basic_types.h rename to renderdoc/api/replay/basic_types.h index 22808d9fe..6c54fd6d2 100644 --- a/renderdoc/replay/basic_types.h +++ b/renderdoc/api/replay/basic_types.h @@ -168,4 +168,4 @@ struct wstr : public rdctype::array } }; -}; // namespace rdctype \ No newline at end of file +}; // namespace rdctype diff --git a/renderdoc/replay/control_types.h b/renderdoc/api/replay/control_types.h similarity index 100% rename from renderdoc/replay/control_types.h rename to renderdoc/api/replay/control_types.h diff --git a/renderdoc/replay/d3d11_pipestate.h b/renderdoc/api/replay/d3d11_pipestate.h similarity index 100% rename from renderdoc/replay/d3d11_pipestate.h rename to renderdoc/api/replay/d3d11_pipestate.h diff --git a/renderdoc/replay/data_types.h b/renderdoc/api/replay/data_types.h similarity index 100% rename from renderdoc/replay/data_types.h rename to renderdoc/api/replay/data_types.h diff --git a/renderdoc/replay/gl_pipestate.h b/renderdoc/api/replay/gl_pipestate.h similarity index 100% rename from renderdoc/replay/gl_pipestate.h rename to renderdoc/api/replay/gl_pipestate.h diff --git a/renderdoc/replay/renderdoc.h b/renderdoc/api/replay/renderdoc_replay.h similarity index 80% rename from renderdoc/replay/renderdoc.h rename to renderdoc/api/replay/renderdoc_replay.h index 6af0a23f8..1ad3d15f8 100644 --- a/renderdoc/replay/renderdoc.h +++ b/renderdoc/api/replay/renderdoc_replay.h @@ -26,7 +26,9 @@ #pragma once #include -#include + +typedef uint8_t byte; +typedef uint32_t bool32; #include "basic_types.h" @@ -55,7 +57,34 @@ #endif -#include "capture_options.h" +// We give every resource a globally unique ID so that we can differentiate +// between two textures allocated in the same memory (after the first is freed) +// +// it's a struct around a uint64_t to aid in template selection +struct ResourceId +{ + uint64_t id; + +#ifdef __cplusplus + ResourceId() : id() {} + ResourceId(uint64_t val, bool) { id = val; } + + bool operator ==(const ResourceId u) const + { + return id == u.id; + } + + bool operator !=(const ResourceId u) const + { + return id != u.id; + } + + bool operator <(const ResourceId u) const + { + return id < u.id; + } +#endif +}; #include "replay_enums.h" @@ -194,59 +223,6 @@ typedef bool (RENDERDOC_CC *pRENDERDOC_SupportLocalReplay)(const wchar_t *logfil extern "C" RENDERDOC_API ReplayCreateStatus RENDERDOC_CC RENDERDOC_CreateReplayRenderer(const wchar_t *logfile, float *progress, ReplayRenderer **rend); typedef ReplayCreateStatus (RENDERDOC_CC *pRENDERDOC_CreateReplayRenderer)(const wchar_t *logfile, float *progress, ReplayRenderer **rend); -////////////////////////////////////////////////////////////////////////// -// Injection/voluntary capture functions. -// -// InjectAndExecute takes an exe path, destination filename and capture options. -// It will launch the exe and then call... -// -// InjectIntoProcess will inject RenderDoc and its dependent dlls into the target process -// if it's able to, and pass in the given options. NOTE: RenderDoc automatically hooks -// any app the dll is loaded into, except where explicitly disallowed or disabled. -// -// SetLogfile and SetCaptureOptions will set the destination filename of any capture -// and the configuration options, respectively. -// -// Takes the filename of the log. Returns NULL in the case of any error. -////////////////////////////////////////////////////////////////////////// - -#define RENDERDOC_API_VERSION 1 - -extern "C" RENDERDOC_API int RENDERDOC_CC RENDERDOC_GetAPIVersion(); -typedef int (RENDERDOC_CC *pRENDERDOC_GetAPIVersion)(); - -extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_SetLogFile(const wchar_t *logfile); -typedef void (RENDERDOC_CC *pRENDERDOC_SetLogFile)(const wchar_t *logfile); - -extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_SetCaptureOptions(const CaptureOptions *opts); -typedef void (RENDERDOC_CC *pRENDERDOC_SetCaptureOptions)(const CaptureOptions *opts); - -extern "C" RENDERDOC_API uint32_t RENDERDOC_CC RENDERDOC_ExecuteAndInject(const wchar_t *app, const wchar_t *workingDir, const wchar_t *cmdLine, - const wchar_t *logfile, const CaptureOptions *opts, bool waitForExit); -typedef uint32_t (RENDERDOC_CC *pRENDERDOC_ExecuteAndInject)(const wchar_t *app, const wchar_t *workingDir, const wchar_t *cmdLine, - const wchar_t *logfile, const CaptureOptions *opts, bool waitForExit); - -extern "C" RENDERDOC_API uint32_t RENDERDOC_CC RENDERDOC_InjectIntoProcess(uint32_t pid, const wchar_t *logfile, const CaptureOptions *opts, bool waitForExit); -typedef uint32_t (RENDERDOC_CC *pRENDERDOC_InjectIntoProcess)(uint32_t pid, const wchar_t *logfile, const CaptureOptions *opts, bool waitForExit); - -extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_SetActiveWindow(void *wndHandle); -typedef void (RENDERDOC_CC *pRENDERDOC_SetActiveWindow)(void *wndHandle); - -extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_TriggerCapture(); -typedef void (RENDERDOC_CC *pRENDERDOC_TriggerCapture)(); - -extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_StartFrameCapture(void *wndHandle); -typedef void (RENDERDOC_CC *pRENDERDOC_StartFrameCapture)(void *wndHandle); - -extern "C" RENDERDOC_API bool RENDERDOC_CC RENDERDOC_EndFrameCapture(void *wndHandle); -typedef bool (RENDERDOC_CC *pRENDERDOC_EndFrameCapture)(void *wndHandle); - -extern "C" RENDERDOC_API uint32_t RENDERDOC_CC RENDERDOC_GetOverlayBits(); -typedef uint32_t (RENDERDOC_CC *pRENDERDOC_GetOverlayBits)(); - -extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_MaskOverlayBits(uint32_t And, uint32_t Or); -typedef void (RENDERDOC_CC *pRENDERDOC_MaskOverlayBits)(uint32_t And, uint32_t Or); - ////////////////////////////////////////////////////////////////////////// // Remote access and control ////////////////////////////////////////////////////////////////////////// @@ -276,9 +252,6 @@ typedef void (RENDERDOC_CC *pRENDERDOC_TriggerExceptionHandler)(void *exceptionP extern "C" RENDERDOC_API void RENDERDOC_CC RENDERDOC_LogText(const wchar_t *text); typedef void (RENDERDOC_CC *pRENDERDOC_LogText)(const wchar_t *text); -extern "C" RENDERDOC_API const wchar_t* RENDERDOC_CC RENDERDOC_GetLogFilename(); -typedef const wchar_t* (RENDERDOC_CC *pRENDERDOC_GetLogFilename)(); - extern "C" RENDERDOC_API bool RENDERDOC_CC RENDERDOC_GetThumbnail(const wchar_t *filename, byte *buf, uint32_t &len); typedef bool (RENDERDOC_CC *pRENDERDOC_GetThumbnail)(const wchar_t *filename, byte *buf, uint32_t &len); diff --git a/renderdoc/replay/replay_enums.h b/renderdoc/api/replay/replay_enums.h similarity index 100% rename from renderdoc/replay/replay_enums.h rename to renderdoc/api/replay/replay_enums.h diff --git a/renderdoc/replay/shader_types.h b/renderdoc/api/replay/shader_types.h similarity index 100% rename from renderdoc/replay/shader_types.h rename to renderdoc/api/replay/shader_types.h diff --git a/renderdoc/core/core.h b/renderdoc/core/core.h index 231f2f5af..21792680e 100644 --- a/renderdoc/core/core.h +++ b/renderdoc/core/core.h @@ -39,8 +39,8 @@ using std::set; class Serialiser; class Chunk; -#include "replay/capture_options.h" -#include "replay/replay_enums.h" +#include "api/app/renderdoc_app.h" +#include "api/replay/replay_enums.h" #include "os/os_specific.h" #include "common/threading.h" @@ -104,18 +104,6 @@ enum RDCDriver RDC_Custom9, }; -enum InAppOverlay -{ - eOverlay_Enabled = 0x1, - eOverlay_FrameRate = 0x2, - eOverlay_FrameNumber = 0x4, - eOverlay_CaptureList = 0x8, - - eOverlay_Default = (eOverlay_Enabled|eOverlay_FrameRate|eOverlay_FrameNumber|eOverlay_CaptureList), - eOverlay_All = ~0U, - eOverlay_None = 0, -}; - namespace DXBC { class DXBCFile; } namespace Callstack { class StackResolver; } diff --git a/renderdoc/core/remote_access.cpp b/renderdoc/core/remote_access.cpp index be193a5d1..59915641a 100644 --- a/renderdoc/core/remote_access.cpp +++ b/renderdoc/core/remote_access.cpp @@ -23,8 +23,8 @@ ******************************************************************************/ +#include "api/replay/renderdoc_replay.h" #include "replay/type_helpers.h" -#include "replay/renderdoc.h" #include "core/core.h" #include "os/os_specific.h" #include "serialise/serialiser.h" diff --git a/renderdoc/core/remote_replay.cpp b/renderdoc/core/remote_replay.cpp index d00527d5e..0a86809eb 100644 --- a/renderdoc/core/remote_replay.cpp +++ b/renderdoc/core/remote_replay.cpp @@ -23,7 +23,7 @@ ******************************************************************************/ -#include "replay/renderdoc.h" +#include "api/replay/renderdoc_replay.h" #include "replay/replay_renderer.h" #include "core/core.h" #include "os/os_specific.h" diff --git a/renderdoc/core/resource_manager.h b/renderdoc/core/resource_manager.h index 3491a8872..95c6a346e 100644 --- a/renderdoc/core/resource_manager.h +++ b/renderdoc/core/resource_manager.h @@ -27,6 +27,8 @@ #include "core/core.h" +#include "api/replay/renderdoc_replay.h" + #include "os/os_specific.h" #include "serialise/serialiser.h" diff --git a/renderdoc/driver/d3d11/d3d11_common.h b/renderdoc/driver/d3d11/d3d11_common.h index 4e03bc2c7..355b5c700 100644 --- a/renderdoc/driver/d3d11/d3d11_common.h +++ b/renderdoc/driver/d3d11/d3d11_common.h @@ -33,7 +33,7 @@ #include #include -#include "replay/renderdoc.h" +#include "api/replay/renderdoc_replay.h" #include "core/core.h" class WrappedID3D11Device; diff --git a/renderdoc/driver/d3d11/d3d11_context.h b/renderdoc/driver/d3d11/d3d11_context.h index 12323f864..dfe6dff5d 100644 --- a/renderdoc/driver/d3d11/d3d11_context.h +++ b/renderdoc/driver/d3d11/d3d11_context.h @@ -26,7 +26,7 @@ #pragma once #include "core/core.h" -#include "replay/renderdoc.h" +#include "api/replay/renderdoc_replay.h" #if defined(INCLUDE_D3D_11_1) #include diff --git a/renderdoc/driver/d3d11/d3d11_debug.h b/renderdoc/driver/d3d11/d3d11_debug.h index 6f08c4a92..9007d232b 100644 --- a/renderdoc/driver/d3d11/d3d11_debug.h +++ b/renderdoc/driver/d3d11/d3d11_debug.h @@ -29,7 +29,7 @@ using std::pair; -#include "replay/renderdoc.h" +#include "api/replay/renderdoc_replay.h" #include "driver/d3d11/shaders/dxbc_debug.h" diff --git a/renderdoc/driver/d3d11/d3d11_device.h b/renderdoc/driver/d3d11/d3d11_device.h index 9ca5c0c36..3bdab873d 100644 --- a/renderdoc/driver/d3d11/d3d11_device.h +++ b/renderdoc/driver/d3d11/d3d11_device.h @@ -31,7 +31,7 @@ #include "common/timing.h" #include "core/core.h" -#include "replay/renderdoc.h" +#include "api/replay/renderdoc_replay.h" #if defined(INCLUDE_D3D_11_1) #include diff --git a/renderdoc/driver/d3d11/d3d11_manager.h b/renderdoc/driver/d3d11/d3d11_manager.h index 6853a960a..9e66d3d02 100644 --- a/renderdoc/driver/d3d11/d3d11_manager.h +++ b/renderdoc/driver/d3d11/d3d11_manager.h @@ -33,7 +33,7 @@ #include "driver/d3d11/d3d11_common.h" #include "core/core.h" -#include "replay/renderdoc.h" +#include "api/replay/renderdoc_replay.h" #include "serialise/serialiser.h" #include "common/wrapped_pool.h" diff --git a/renderdoc/driver/d3d11/d3d11_replay.h b/renderdoc/driver/d3d11/d3d11_replay.h index 1f63f3566..86b8ef5eb 100644 --- a/renderdoc/driver/d3d11/d3d11_replay.h +++ b/renderdoc/driver/d3d11/d3d11_replay.h @@ -25,7 +25,7 @@ #pragma once -#include "replay/renderdoc.h" +#include "api/replay/renderdoc_replay.h" #include "replay/replay_driver.h" #include "core/core.h" diff --git a/renderdoc/driver/d3d11/shaders/dxbc_debug.cpp b/renderdoc/driver/d3d11/shaders/dxbc_debug.cpp index 17a4731a7..8e815b2f1 100644 --- a/renderdoc/driver/d3d11/shaders/dxbc_debug.cpp +++ b/renderdoc/driver/d3d11/shaders/dxbc_debug.cpp @@ -34,7 +34,7 @@ #include "dxbc_debug.h" #include "dxbc_inspect.h" -#include "replay/renderdoc.h" +#include "api/replay/renderdoc_replay.h" using namespace DXBC; diff --git a/renderdoc/driver/d3d11/shaders/dxbc_inspect.h b/renderdoc/driver/d3d11/shaders/dxbc_inspect.h index f545649d4..a4207df6c 100644 --- a/renderdoc/driver/d3d11/shaders/dxbc_inspect.h +++ b/renderdoc/driver/d3d11/shaders/dxbc_inspect.h @@ -35,7 +35,7 @@ using std::map; #pragma once #include "common/common.h" -#include "replay/renderdoc.h" +#include "api/replay/renderdoc_replay.h" #include "dxbc_disassemble.h" diff --git a/renderdoc/driver/gl/gl_common.h b/renderdoc/driver/gl/gl_common.h index 37dde47a5..f547c8e26 100644 --- a/renderdoc/driver/gl/gl_common.h +++ b/renderdoc/driver/gl/gl_common.h @@ -62,7 +62,7 @@ struct GLWindowingData #error "Unknown platform" #endif -#include "replay/renderdoc.h" +#include "api/replay/renderdoc_replay.h" // similar to RDCUNIMPLEMENTED but for things that are hit often so we don't want to fire the debugbreak. #define GLNOTIMP(...) RDCDEBUG("OpenGL not implemented - " __VA_ARGS__) diff --git a/renderdoc/driver/gl/gl_replay.h b/renderdoc/driver/gl/gl_replay.h index a4eca4aff..5d143a0da 100644 --- a/renderdoc/driver/gl/gl_replay.h +++ b/renderdoc/driver/gl/gl_replay.h @@ -26,7 +26,7 @@ #pragma once #include "gl_common.h" -#include "replay/renderdoc.h" +#include "api/replay/renderdoc_replay.h" #include "replay/replay_driver.h" #include "core/core.h" diff --git a/renderdoc/hooks/sys_win32_hooks.cpp b/renderdoc/hooks/sys_win32_hooks.cpp index fe3ffd9e7..d49954d67 100644 --- a/renderdoc/hooks/sys_win32_hooks.cpp +++ b/renderdoc/hooks/sys_win32_hooks.cpp @@ -24,7 +24,7 @@ #include "core/core.h" -#include "replay/renderdoc.h" +#include "api/replay/renderdoc_replay.h" #include "hooks.h" diff --git a/renderdoc/renderdoc.vcxproj b/renderdoc/renderdoc.vcxproj index b8830c0c7..d7c826336 100644 --- a/renderdoc/renderdoc.vcxproj +++ b/renderdoc/renderdoc.vcxproj @@ -230,6 +230,16 @@ + + + + + + + + + + @@ -281,17 +291,8 @@ - - - - - - - - - @@ -369,7 +370,6 @@ - diff --git a/renderdoc/renderdoc.vcxproj.filters b/renderdoc/renderdoc.vcxproj.filters index 868d5090e..1e2376f2b 100644 --- a/renderdoc/renderdoc.vcxproj.filters +++ b/renderdoc/renderdoc.vcxproj.filters @@ -64,9 +64,6 @@ {911d2076-eaea-4783-b0c3-789e5b6eff1f} - - {e2f5b1f2-ae41-4e3c-999e-5ade627a91d1} - {0ecdcd74-a30b-457e-8b22-92bd58405c56} @@ -79,6 +76,15 @@ {f22a6629-346c-400d-9706-7f999d539f6b} + + {7d6b0f22-1180-4767-b284-cc87f54ec012} + + + {4e047f61-a78b-4a09-abbb-6c839a4fe177} + + + {188b97fd-b9d4-47a6-a51a-48bc00e6fc5c} + @@ -234,30 +240,9 @@ Drivers\OpenGL - - Replay\external interface - - - Replay\external interface - - - Replay\external interface - Replay - - Replay\external interface - - - Replay\external interface - - - Replay\external interface - - - Replay\external interface - Replay @@ -273,9 +258,6 @@ Common\Maths - - Replay\external interface - Common @@ -285,9 +267,6 @@ Resources\hlsl - - Replay\external interface - Drivers\OpenGL @@ -306,6 +285,36 @@ Resources + + API\Replay + + + API\Replay + + + API\Replay + + + API\Replay + + + API\Replay + + + API\Replay + + + API\Replay + + + API\Replay + + + API\In-App + + + API\Replay + @@ -458,9 +467,6 @@ Replay - - Replay - Replay diff --git a/renderdoc/replay/basic_types.cpp b/renderdoc/replay/basic_types.cpp deleted file mode 100644 index 3ce058304..000000000 --- a/renderdoc/replay/basic_types.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/****************************************************************************** - * The MIT License (MIT) - * - * Copyright (c) 2014 Crytek - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - ******************************************************************************/ - -#include "basic_types.h" - -namespace rdctype -{ - -wstr &wstr::operator =(const std::wstring &in) -{ - Delete(); - count = (int32_t)in.size(); - if(count == 0) - { - elems = (wchar_t*)allocate(sizeof(wchar_t)); - elems[0] = 0; - } - else - { - elems = (wchar_t*)allocate(sizeof(wchar_t)*(count+1)); - memcpy(elems, &in[0], sizeof(wchar_t)*in.size()); - elems[count] = 0; - } - return *this; -} - -str &str::operator =(const std::string &in) -{ - Delete(); - count = (int32_t)in.size(); - if(count == 0) - { - elems = (char*)allocate(sizeof(char)); - elems[0] = 0; - } - else - { - elems = (char*)allocate(sizeof(char)*(count+1)); - memcpy(elems, &in[0], sizeof(char)*in.size()); - elems[count] = 0; - } - return *this; -} - -wstr &wstr::operator =(const wchar_t *const in) -{ - Delete(); - count = (int32_t)wcslen(in); - if(count == 0) - { - elems = (wchar_t*)allocate(sizeof(wchar_t)); - elems[0] = 0; - } - else - { - elems = (wchar_t*)allocate(sizeof(wchar_t)*(count+1)); - memcpy(elems, &in[0], sizeof(wchar_t)*count); - elems[count] = 0; - } - return *this; -} - -str &str::operator =(const char *const in) -{ - Delete(); - count = (int32_t)strlen(in); - if(count == 0) - { - elems = (char*)allocate(sizeof(char)); - elems[0] = 0; - } - else - { - elems = (char*)allocate(sizeof(char)*(count+1)); - memcpy(elems, &in[0], sizeof(char)*count); - elems[count] = 0; - } - return *this; -} - -}; // namespace rdctype diff --git a/renderdoc/replay/capture_options.h b/renderdoc/replay/capture_options.h deleted file mode 100644 index 849daf407..000000000 --- a/renderdoc/replay/capture_options.h +++ /dev/null @@ -1,128 +0,0 @@ -/****************************************************************************** - * The MIT License (MIT) - * - * Copyright (c) 2014 Crytek - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - ******************************************************************************/ - - -#pragma once - -#include -#include // istringstream/ostringstream used to avoid other dependencies - -typedef uint8_t byte; -typedef uint32_t bool32; - -// We give every resource a globally unique ID so that we can differentiate -// between two textures allocated in the same memory (after the first is freed) -// -// it's a struct around a uint64_t to aid in template selection -struct ResourceId -{ - ResourceId() : id() {} - ResourceId(uint64_t val, bool) { id = val; } - - bool operator ==(const ResourceId u) const - { - return id == u.id; - } - - bool operator !=(const ResourceId u) const - { - return id != u.id; - } - - bool operator <(const ResourceId u) const - { - return id < u.id; - } - - uint64_t id; -}; - -struct CaptureOptions -{ - CaptureOptions() - : AllowVSync(true), - AllowFullscreen(true), - DebugDeviceMode(false), - CaptureCallstacks(false), - CaptureCallstacksOnlyDraws(false), - DelayForDebugger(0), - CacheStateObjects(true), - HookIntoChildren(false), - RefAllResources(false), - SaveAllInitials(false), - CaptureAllCmdLists(false) - {} - - bool32 AllowVSync; - bool32 AllowFullscreen; - bool32 DebugDeviceMode; - bool32 CaptureCallstacks; - bool32 CaptureCallstacksOnlyDraws; - uint32_t DelayForDebugger; - bool32 CacheStateObjects; - bool32 HookIntoChildren; - bool32 RefAllResources; - bool32 SaveAllInitials; - bool32 CaptureAllCmdLists; - -#ifdef __cplusplus - void FromString(std::string str) - { - std::istringstream iss(str); - - iss >> AllowFullscreen - >> AllowVSync - >> DebugDeviceMode - >> CaptureCallstacks - >> CaptureCallstacksOnlyDraws - >> DelayForDebugger - >> CacheStateObjects - >> HookIntoChildren - >> RefAllResources - >> SaveAllInitials - >> CaptureAllCmdLists; - } - - std::string ToString() const - { - std::ostringstream oss; - - oss << AllowFullscreen << " " - << AllowVSync << " " - << DebugDeviceMode << " " - << CaptureCallstacks << " " - << CaptureCallstacksOnlyDraws << " " - << DelayForDebugger << " " - << CacheStateObjects << " " - << HookIntoChildren << " " - << RefAllResources << " " - << SaveAllInitials << " " - << CaptureAllCmdLists << " "; - - return oss.str(); - } -#endif -}; - - diff --git a/renderdoc/replay/entry_points.cpp b/renderdoc/replay/entry_points.cpp index 42072ab25..faf058def 100644 --- a/renderdoc/replay/entry_points.cpp +++ b/renderdoc/replay/entry_points.cpp @@ -28,7 +28,7 @@ #include "serialise/serialiser.h" #include "core/core.h" #include "replay/replay_renderer.h" -#include "replay/renderdoc.h" +#include "api/replay/renderdoc_replay.h" extern "C" RENDERDOC_API float RENDERDOC_CC Maths_HalfToFloat(uint16_t half) { @@ -97,7 +97,7 @@ void RENDERDOC_CC RENDERDOC_LogText(const wchar_t *text) } extern "C" RENDERDOC_API -const wchar_t* RENDERDOC_CC RENDERDOC_GetLogFilename() +const wchar_t* RENDERDOC_CC RENDERDOC_GetLogFile() { return RDCGETLOGFILE(); } diff --git a/renderdoc/replay/replay_driver.h b/renderdoc/replay/replay_driver.h index 8e0dce1a0..4b6259f3d 100644 --- a/renderdoc/replay/replay_driver.h +++ b/renderdoc/replay/replay_driver.h @@ -26,7 +26,7 @@ #pragma once #include "maths/vec.h" -#include "replay/renderdoc.h" +#include "api/replay/renderdoc_replay.h" #include "replay/replay_driver.h" #include "core/core.h" diff --git a/renderdoc/replay/replay_renderer.h b/renderdoc/replay/replay_renderer.h index e8043d7d0..5a4fb4bc2 100644 --- a/renderdoc/replay/replay_renderer.h +++ b/renderdoc/replay/replay_renderer.h @@ -27,7 +27,7 @@ #include "common/common.h" #include "core/core.h" -#include "replay/renderdoc.h" +#include "api/replay/renderdoc_replay.h" #include "replay/replay_driver.h" #include diff --git a/renderdoc/replay/type_helpers.cpp b/renderdoc/replay/type_helpers.cpp index b92418c88..f1c315e3b 100644 --- a/renderdoc/replay/type_helpers.cpp +++ b/renderdoc/replay/type_helpers.cpp @@ -24,6 +24,8 @@ #include "type_helpers.h" +#include "api/replay/renderdoc_replay.h" + #include #include #include "serialise/serialiser.h" @@ -40,3 +42,90 @@ string ToStrHelper::Get(const rdctype::wstr &el) { return narrow(wstring(el.elems, el.elems+el.count)); } + +template<> +string ToStrHelper::Get(const ResourceId &el) +{ + char tostrBuf[256] = {0}; + + StringFormat::snprintf(tostrBuf, 255, "Resource ID %llu", el.id); + + return tostrBuf; +} + +namespace rdctype +{ + +wstr &wstr::operator =(const std::wstring &in) +{ + Delete(); + count = (int32_t)in.size(); + if(count == 0) + { + elems = (wchar_t*)allocate(sizeof(wchar_t)); + elems[0] = 0; + } + else + { + elems = (wchar_t*)allocate(sizeof(wchar_t)*(count+1)); + memcpy(elems, &in[0], sizeof(wchar_t)*in.size()); + elems[count] = 0; + } + return *this; +} + +str &str::operator =(const std::string &in) +{ + Delete(); + count = (int32_t)in.size(); + if(count == 0) + { + elems = (char*)allocate(sizeof(char)); + elems[0] = 0; + } + else + { + elems = (char*)allocate(sizeof(char)*(count+1)); + memcpy(elems, &in[0], sizeof(char)*in.size()); + elems[count] = 0; + } + return *this; +} + +wstr &wstr::operator =(const wchar_t *const in) +{ + Delete(); + count = (int32_t)wcslen(in); + if(count == 0) + { + elems = (wchar_t*)allocate(sizeof(wchar_t)); + elems[0] = 0; + } + else + { + elems = (wchar_t*)allocate(sizeof(wchar_t)*(count+1)); + memcpy(elems, &in[0], sizeof(wchar_t)*count); + elems[count] = 0; + } + return *this; +} + +str &str::operator =(const char *const in) +{ + Delete(); + count = (int32_t)strlen(in); + if(count == 0) + { + elems = (char*)allocate(sizeof(char)); + elems[0] = 0; + } + else + { + elems = (char*)allocate(sizeof(char)*(count+1)); + memcpy(elems, &in[0], sizeof(char)*count); + elems[count] = 0; + } + return *this; +} + +}; // namespace rdctype diff --git a/renderdoc/replay/type_helpers.h b/renderdoc/replay/type_helpers.h index 2235ca2ff..fd3910840 100644 --- a/renderdoc/replay/type_helpers.h +++ b/renderdoc/replay/type_helpers.h @@ -24,7 +24,7 @@ #pragma once -#include "basic_types.h" +#include "api/replay/basic_types.h" #include diff --git a/renderdoc/serialise/serialiser.cpp b/renderdoc/serialise/serialiser.cpp index 9e8988093..c03008bcd 100644 --- a/renderdoc/serialise/serialiser.cpp +++ b/renderdoc/serialise/serialiser.cpp @@ -1052,16 +1052,6 @@ string ToStrHelper::Get(void* const &el) return tostrBuf; } -template<> -string ToStrHelper::Get(const ResourceId &el) -{ - char tostrBuf[256] = {0}; - - StringFormat::snprintf(tostrBuf, 255, "Resource ID %llu", el.id); - - return tostrBuf; -} - template<> string ToStrHelper::Get(const uint64_t &el) { diff --git a/renderdoc/serialise/serialiser.h b/renderdoc/serialise/serialiser.h index 9acf6d6d5..2c6935edb 100644 --- a/renderdoc/serialise/serialiser.h +++ b/renderdoc/serialise/serialiser.h @@ -27,7 +27,7 @@ #include "common/common.h" #include "os/os_specific.h" -#include "replay/basic_types.h" +#include "api/replay/basic_types.h" #include "replay/type_helpers.h" diff --git a/renderdoccmd/Makefile b/renderdoccmd/Makefile index f9e9e5817..5472383d3 100644 --- a/renderdoccmd/Makefile +++ b/renderdoccmd/Makefile @@ -5,9 +5,9 @@ MACROS=-DLINUX \ -DRENDERDOC_PLATFORM=linux \ -DRENDERDOC_EXPORTS \ -DGIT_COMMIT_HASH="\"$(COMMIT)\"" -CFLAGS=-c -Wall -Werror -fPIC $(MACROS) -I../renderdoc/ +CFLAGS=-c -Wall -Werror -fPIC $(MACROS) -I../renderdoc/api/ CPPFLAGS=-std=c++11 -g -Wno-unused -Wno-unknown-pragmas -Wno-reorder -LDFLAGS=-L../renderdoc -lrenderdoc -lGL +LDFLAGS=-L../renderdoc/ -lrenderdoc -lGL OBJDIR=.obj OBJECTS=renderdoccmd.o renderdoccmd_linux.o @@ -24,7 +24,9 @@ $(OBJDIR)/%.o: %.c $(CC) $(CFLAGS) -c -o $@ $< @$(CC) $(CFLAGS) -MM -MT $(OBJDIR)/$*.o $*.c > $(OBJDIR)/$*.d -OBJDIR_OBJECTS=$(addprefix $(OBJDIR)/, $(SHADERS) $(OBJECTS)) +OBJDIR_OBJECTS=$(addprefix $(OBJDIR)/, $(OBJECTS)) + +-include $(OBJDIR_OBJECTS:.o=.d) bin/renderdoccmd: $(OBJDIR_OBJECTS) ../renderdoc/librenderdoc.so mkdir -p bin/ diff --git a/renderdoccmd/renderdoccmd.cpp b/renderdoccmd/renderdoccmd.cpp index ed5e62864..58a49323f 100644 --- a/renderdoccmd/renderdoccmd.cpp +++ b/renderdoccmd/renderdoccmd.cpp @@ -24,7 +24,8 @@ #include -#include +#include +#include using std::string; using std::wstring; diff --git a/renderdoccmd/renderdoccmd.vcxproj b/renderdoccmd/renderdoccmd.vcxproj index 876745664..9d23312c2 100644 --- a/renderdoccmd/renderdoccmd.vcxproj +++ b/renderdoccmd/renderdoccmd.vcxproj @@ -93,7 +93,7 @@ Level3 Disabled WIN32;RENDERDOC_PLATFORM=win32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - ..\renderdoc\ + ..\renderdoc\api\ MultiThreadedDLL true @@ -110,7 +110,7 @@ Level3 Disabled WIN32;RENDERDOC_PLATFORM=win32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - ..\renderdoc\ + ..\renderdoc\api\ MultiThreadedDLL true @@ -129,7 +129,7 @@ true true WIN32;RENDERDOC_PLATFORM=win32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - ..\renderdoc\ + ..\renderdoc\api\ true @@ -149,7 +149,7 @@ true true WIN32;RENDERDOC_PLATFORM=win32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - ..\renderdoc\ + ..\renderdoc\api\ true diff --git a/renderdoccmd/renderdoccmd_linux.cpp b/renderdoccmd/renderdoccmd_linux.cpp index fbc1980a9..300a9d6d2 100644 --- a/renderdoccmd/renderdoccmd_linux.cpp +++ b/renderdoccmd/renderdoccmd_linux.cpp @@ -30,7 +30,7 @@ #include -#include +#include using std::wstring; diff --git a/renderdoccmd/renderdoccmd_win32.cpp b/renderdoccmd/renderdoccmd_win32.cpp index 83a7f3e7f..d824a31f6 100644 --- a/renderdoccmd/renderdoccmd_win32.cpp +++ b/renderdoccmd/renderdoccmd_win32.cpp @@ -26,7 +26,8 @@ #include #include -#include +#include +#include #include "resource.h" diff --git a/renderdocui/Interop/StaticExports.cs b/renderdocui/Interop/StaticExports.cs index 4dcf43fc9..50d55e13b 100644 --- a/renderdocui/Interop/StaticExports.cs +++ b/renderdocui/Interop/StaticExports.cs @@ -62,7 +62,7 @@ namespace renderdoc private static extern void RENDERDOC_LogText(string text); [DllImport("renderdoc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)] - private static extern IntPtr RENDERDOC_GetLogFilename(); + private static extern IntPtr RENDERDOC_GetLogFile(); [DllImport("renderdoc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)] private static extern bool RENDERDOC_GetThumbnail(string filename, byte[] outmem, ref UInt32 len); @@ -165,7 +165,7 @@ namespace renderdoc public static string GetLogFilename() { - return Marshal.PtrToStringUni(RENDERDOC_GetLogFilename()); + return Marshal.PtrToStringUni(RENDERDOC_GetLogFile()); } public static byte[] GetThumbnail(string filename)