diff --git a/CMakeLists.txt b/CMakeLists.txt index 3bad68827..49455a44c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -126,8 +126,6 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") endif() endif() -add_definitions(-DRENDERDOC_PLATFORM_POSIX) - if(ANDROID) add_definitions(-DRENDERDOC_PLATFORM_ANDROID) elseif(APPLE) diff --git a/renderdoc/api/replay/renderdoc_replay.h b/renderdoc/api/replay/renderdoc_replay.h index 47be61035..60e1c6636 100644 --- a/renderdoc/api/replay/renderdoc_replay.h +++ b/renderdoc/api/replay/renderdoc_replay.h @@ -39,7 +39,8 @@ typedef uint32_t bool32; #endif #define RENDERDOC_CC __cdecl -#elif defined(RENDERDOC_PLATFORM_POSIX) +#elif defined(RENDERDOC_PLATFORM_LINUX) || defined(RENDERDOC_PLATFORM_APPLE) || \ + defined(RENDERDOC_PLATFORM_ANDROID) #ifdef RENDERDOC_EXPORTS #define RENDERDOC_API __attribute__((visibility("default"))) diff --git a/renderdoc/common/common.cpp b/renderdoc/common/common.cpp index 6ea495a1d..518adb6cf 100644 --- a/renderdoc/common/common.cpp +++ b/renderdoc/common/common.cpp @@ -111,7 +111,7 @@ bool Vec16NotEqual(void *a, void *b) } return false; -#elif defined(WIN64) +#elif ENABLED(RDOC_X64) uint64_t *a64 = (uint64_t *)a; uint64_t *b64 = (uint64_t *)b; @@ -244,7 +244,7 @@ uint32_t Log2Floor(uint32_t value) return 31 - Bits::CountLeadingZeroes(value); } -#if RDC64BIT +#if ENABLED(RDOC_X64) uint64_t Log2Floor(uint64_t value) { RDCASSERT(value > 0); @@ -312,20 +312,20 @@ void rdclogprint_int(LogType type, const char *fullMsg, const char *msg) SCOPED_LOCK(lock); -#if defined(OUTPUT_LOG_TO_DEBUG_OUT) +#if ENABLED(OUTPUT_LOG_TO_DEBUG_OUT) OSUtility::WriteOutput(OSUtility::Output_DebugMon, fullMsg); #endif -#if defined(OUTPUT_LOG_TO_STDOUT) +#if ENABLED(OUTPUT_LOG_TO_STDOUT) // don't output debug messages to stdout/stderr if(type != RDCLog_Debug && log_output_enabled) OSUtility::WriteOutput(OSUtility::Output_StdOut, msg); #endif -#if defined(OUTPUT_LOG_TO_STDERR) +#if ENABLED(OUTPUT_LOG_TO_STDERR) // don't output debug messages to stdout/stderr if(type != RDCLog_Debug && log_output_enabled) OSUtility::WriteOutput(OSUtility::Output_StdErr, msg); #endif -#if defined(OUTPUT_LOG_TO_DISK) +#if ENABLED(OUTPUT_LOG_TO_DISK) if(logfileHandle) { // strlen used as byte length - str is UTF-8 so this is NOT number of characters @@ -350,12 +350,12 @@ void rdclog_int(LogType type, const char *project, const char *file, unsigned in va_start(args, fmt); char timestamp[64] = {0}; -#if defined(INCLUDE_TIMESTAMP_IN_LOG) +#if ENABLED(INCLUDE_TIMESTAMP_IN_LOG) StringFormat::sntimef(timestamp, 63, "[%H:%M:%S] "); #endif char location[64] = {0}; -#if defined(INCLUDE_LOCATION_IN_LOG) +#if ENABLED(INCLUDE_LOCATION_IN_LOG) string loc; loc = basename(string(file)); StringFormat::snprintf(location, 63, "% 20s(%4d) - ", loc.c_str(), line); diff --git a/renderdoc/common/common.h b/renderdoc/common/common.h index 0bd42cf3c..a3a76214a 100644 --- a/renderdoc/common/common.h +++ b/renderdoc/common/common.h @@ -158,7 +158,7 @@ bool FindDiffRange(void *a, void *b, size_t bufSize, size_t &diffStart, size_t & uint32_t CalcNumMips(int Width, int Height, int Depth); uint32_t Log2Floor(uint32_t value); -#if RDC64BIT +#if ENABLED(RDOC_X64) uint64_t Log2Floor(uint64_t value); #endif @@ -171,7 +171,7 @@ uint64_t Log2Floor(uint64_t value); OSUtility::ForceCrash(); \ } while((void)0, 0) -#if !defined(RELEASE) || defined(FORCE_DEBUGBREAK) +#if ENABLED(RDOC_DEVEL) || ENABLED(FORCE_DEBUGBREAK) #define RDCBREAK() \ do \ { \ @@ -207,7 +207,7 @@ enum LogType RDCLog_NumTypes, }; -#if defined(STRIP_LOG) +#if ENABLED(STRIP_LOG) #define RDCLOGFILE(fn) \ do \ { \ @@ -274,7 +274,7 @@ void rdclog_closelog(); #define RDCLOGOUTPUT() rdclog_enableoutput() #define RDCSTOPLOGGING() rdclog_closelog() -#if(!defined(RELEASE) || defined(FORCE_DEBUG_LOGS)) && !defined(STRIP_DEBUG_LOGS) +#if(ENABLED(RDOC_DEVEL) || ENABLED(FORCE_DEBUG_LOGS)) && DISABLED(STRIP_DEBUG_LOGS) #define RDCDEBUG(...) rdclog(RDCLog_Debug, __VA_ARGS__) #else #define RDCDEBUG(...) \ @@ -286,7 +286,7 @@ void rdclog_closelog(); #define RDCLOG(...) rdclog(RDCLog_Comment, __VA_ARGS__) #define RDCWARN(...) rdclog(RDCLog_Warning, __VA_ARGS__) -#if defined(DEBUGBREAK_ON_ERROR_LOG) +#if ENABLED(DEBUGBREAK_ON_ERROR_LOG) #define RDCERR(...) \ do \ { \ @@ -320,7 +320,7 @@ void rdclog_closelog(); // Assert // -#if !defined(RELEASE) || defined(FORCE_ASSERTS) +#if ENABLED(RDOC_DEVEL) || ENABLED(FORCE_ASSERTS) void rdcassert(const char *msg, const char *file, unsigned int line, const char *func); // this defines the root macro, RDCASSERTMSG(msg, cond, ...) @@ -344,7 +344,7 @@ void rdcassert(const char *msg, const char *file, unsigned int line, const char // Compile asserts // -#if defined(STRIP_COMPILE_ASSERTS) +#if ENABLED(STRIP_COMPILE_ASSERTS) #define RDCCOMPILE_ASSERT(condition, message) \ do \ { \ diff --git a/renderdoc/common/custom_assert.h b/renderdoc/common/custom_assert.h index f57b64062..b43073ef1 100644 --- a/renderdoc/common/custom_assert.h +++ b/renderdoc/common/custom_assert.h @@ -82,7 +82,7 @@ #define RDCASSERT_GETCOND(cond, ...) cond -#ifdef _MSC_VER +#if ENABLED(RDOC_MSVS) // only needed on VC++, but unfortunately breaks on g++/clang++ #define RDCASSERT_FAILMSG_INVOKE(macro, args) macro args diff --git a/renderdoc/common/globalconfig.h b/renderdoc/common/globalconfig.h index 52862c126..1094835cd 100644 --- a/renderdoc/common/globalconfig.h +++ b/renderdoc/common/globalconfig.h @@ -25,11 +25,88 @@ #pragma once +///////////////////////////////////////////////// +// Option macros +// From: http://www.codersnotes.com/notes/easy-preprocessor-defines/ + +#define OPTION_ON + +#define OPTION_OFF - +#define ENABLED(opt) ((1 opt 1) == 2) +#define DISABLED(opt) ((1 opt 1) == 0) + ///////////////////////////////////////////////// // Build/machine configuration #if defined(__LP64__) || defined(_WIN64) || defined(__x86_64__) || defined(_M_X64) || \ defined(__ia64) || defined(_M_IA64) || defined(__aarch64__) || defined(__powerpc64__) -#define RDC64BIT 1 +#define RDOC_X64 OPTION_ON +#else +#define RDOC_X64 OPTION_OFF +#endif + +#if defined(RELEASE) || defined(_RELEASE) +#define RDOC_RELEASE OPTION_ON +#define RDOC_DEVEL OPTION_OFF +#else +#define RDOC_RELEASE OPTION_OFF +#define RDOC_DEVEL OPTION_ON +#endif + +#if defined(_MSC_VER) +#define RDOC_MSVS OPTION_ON +#else +#define RDOC_MSVS OPTION_OFF +#endif + +// translate from build system defines, so they don't have to be defined to anything in +// particular +#if defined(RENDERDOC_PLATFORM_WIN32) + +#define RDOC_WIN32 OPTION_ON +#define RDOC_ANDROID OPTION_OFF +#define RDOC_LINUX OPTION_OFF +#define RDOC_APPLE OPTION_OFF +#define RDOC_POSIX OPTION_OFF + +#elif defined(RENDERDOC_PLATFORM_ANDROID) + +#define RDOC_WIN32 OPTION_OFF +#define RDOC_ANDROID OPTION_ON +#define RDOC_LINUX OPTION_OFF +#define RDOC_APPLE OPTION_OFF +#define RDOC_POSIX OPTION_ON + +#elif defined(RENDERDOC_PLATFORM_LINUX) + +#define RDOC_WIN32 OPTION_OFF +#define RDOC_ANDROID OPTION_OFF +#define RDOC_LINUX OPTION_ON +#define RDOC_APPLE OPTION_OFF +#define RDOC_POSIX OPTION_ON + +#elif defined(RENDERDOC_PLATFORM_APPLE) + +#define RDOC_WIN32 OPTION_OFF +#define RDOC_ANDROID OPTION_OFF +#define RDOC_LINUX OPTION_OFF +#define RDOC_APPLE OPTION_ON +#define RDOC_POSIX OPTION_ON + +#else + +#error "No platform configured in build system" + +#endif + +#if defined(RENDERDOC_WINDOWING_XLIB) +#define RDOC_XLIB OPTION_ON +#else +#define RDOC_XLIB OPTION_OFF +#endif + +#if defined(RENDERDOC_WINDOWING_XCB) +#define RDOC_XCB OPTION_ON +#else +#define RDOC_XCB OPTION_OFF #endif ///////////////////////////////////////////////// @@ -46,55 +123,51 @@ enum // Debugging features configuration // remove all logging code -//#define STRIP_LOG +#define STRIP_LOG OPTION_OFF // remove all compile time asserts. Normally done even in release // but this would speed up compilation -//#define STRIP_COMPILE_ASSERTS +#define STRIP_COMPILE_ASSERTS OPTION_OFF // force asserts regardless of debug/release mode -#define FORCE_ASSERTS +#define FORCE_ASSERTS OPTION_ON // force debugbreaks regardless of debug/release mode -//#define FORCE_DEBUGBREAK +#define FORCE_DEBUGBREAK OPTION_OFF ///////////////////////////////////////////////// // Logging configuration // error logs trigger a breakpoint -#define DEBUGBREAK_ON_ERROR_LOG +#define DEBUGBREAK_ON_ERROR_LOG OPTION_ON // whether to include timestamp on log lines -#define INCLUDE_TIMESTAMP_IN_LOG +#define INCLUDE_TIMESTAMP_IN_LOG OPTION_ON // whether to include file and line on log lines -#define INCLUDE_LOCATION_IN_LOG +#define INCLUDE_LOCATION_IN_LOG OPTION_ON -#if !defined(RENDERDOC_PLATFORM_WIN32) // logs go to stdout/stderr -#define OUTPUT_LOG_TO_STDOUT -//#define OUTPUT_LOG_TO_STDERR +#if ENABLED(RDOC_WIN32) + +#define OUTPUT_LOG_TO_STDOUT OPTION_OFF +#define OUTPUT_LOG_TO_STDERR OPTION_OFF + +#else + +#define OUTPUT_LOG_TO_STDOUT OPTION_ON +#define OUTPUT_LOG_TO_STDERR OPTION_OFF + #endif // logs go to debug output (visual studio output window) -#define OUTPUT_LOG_TO_DEBUG_OUT +#define OUTPUT_LOG_TO_DEBUG_OUT OPTION_ON // logs go to disk -#define OUTPUT_LOG_TO_DISK +#define OUTPUT_LOG_TO_DISK OPTION_ON // normally only in a debug build do we // include debug logs. This prints them all the time -//#define FORCE_DEBUG_LOGS +#define FORCE_DEBUG_LOGS OPTION_OFF // this strips them completely -//#define STRIP_DEBUG_LOGS - -///////////////////////////////////////////////// -// optional features - -#if defined(NVIDIA_PERFKIT_DIR) -#define ENABLE_NVIDIA_PERFKIT -#endif - -#if defined(AMD_PERFAPI_DIR) -#define ENABLE_AMD_PERFAPI -#endif +#define STRIP_DEBUG_LOGS OPTION_OFF diff --git a/renderdoc/common/wrapped_pool.h b/renderdoc/common/wrapped_pool.h index 3a8792f5a..6689e5e49 100644 --- a/renderdoc/common/wrapped_pool.h +++ b/renderdoc/common/wrapped_pool.h @@ -30,11 +30,9 @@ #include "common.h" #include "threading.h" -#if !defined(_RELEASE) -#define INCLUDE_TYPE_NAMES -#endif +#define INCLUDE_TYPE_NAMES RDOC_DEVEL -#ifdef INCLUDE_TYPE_NAMES +#if ENABLED(INCLUDE_TYPE_NAMES) template class GetTypeName { @@ -73,7 +71,7 @@ public: } // warn when we need to allocate an additional pool -#ifdef INCLUDE_TYPE_NAMES +#if ENABLED(INCLUDE_TYPE_NAMES) RDCWARN("Ran out of free slots in %s pool!", GetTypeName::Name()); #else RDCWARN("Ran out of free slots in pool 0x%p!", &m_ImmediatePool.items[0]); @@ -82,7 +80,7 @@ public: // allocate a new additional pool and use that to allocate from m_AdditionalPools.push_back(new ItemPool()); -#ifdef INCLUDE_TYPE_NAMES +#if ENABLED(INCLUDE_TYPE_NAMES) RDCDEBUG("WrappingPool[%d]<%s>: %p -> %p", (uint32_t)m_AdditionalPools.size() - 1, GetTypeName::Name(), &m_AdditionalPools.back()->items[0], &m_AdditionalPools.back()->items[AllocCount - 1]); @@ -135,7 +133,7 @@ public: } // this is an error - deleting an object that we don't recognise -#ifdef INCLUDE_TYPE_NAMES +#if ENABLED(INCLUDE_TYPE_NAMES) RDCERR("Resource being deleted through wrong pool - 0x%p not a member of %s", p, GetTypeName::Name()); #else @@ -151,7 +149,7 @@ public: private: WrappingPool() { -#ifdef INCLUDE_TYPE_NAMES +#if ENABLED(INCLUDE_TYPE_NAMES) // hack - print in kB because float printing relies on statics that might not be initialised // yet in loading order. Ugly :( RDCDEBUG("WrappingPool<%s> %d in %dkB: %p -> %p", GetTypeName::Name(), PoolCount, @@ -201,7 +199,7 @@ private: void *ret = (void *)&items[lastAlloc]; allocated[lastAlloc] = true; -#if !defined(RELEASE) +#if ENABLED(RDOC_DEVEL) memset(ret, 0xb0, AllocByteSize); #endif @@ -214,7 +212,7 @@ private: { RDCASSERT(IsAlloc(p)); -#if !defined(RELEASE) +#if ENABLED(RDOC_DEVEL) if(!IsAlloc(p)) { RDCERR("Resource being deleted through wrong pool - 0x%p not a memory of 0x%p", p, &items[0]); @@ -226,7 +224,7 @@ private: allocated[idx] = false; -#if !defined(RELEASE) +#if ENABLED(RDOC_DEVEL) memset(p, 0xfe, DebugClear ? AllocByteSize : 0); #endif } @@ -258,7 +256,7 @@ private: void *operator new(size_t sz) { return m_Pool.Allocate(); } \ void operator delete(void *p) { m_Pool.Deallocate(p); } \ static bool IsAlloc(void *p) { return m_Pool.IsAlloc(p); } -#ifdef INCLUDE_TYPE_NAMES +#if ENABLED(INCLUDE_TYPE_NAMES) #define DECL_TYPENAME(a) \ template <> \ const char *GetTypeName::Name() \ diff --git a/renderdoc/core/core.cpp b/renderdoc/core/core.cpp index 8b8969214..540436fbd 100644 --- a/renderdoc/core/core.cpp +++ b/renderdoc/core/core.cpp @@ -26,6 +26,7 @@ #include "core/core.h" #include #include +#include "common/common.h" #include "common/dds_readwrite.h" #include "data/version.h" #include "hooks/hooks.h" @@ -191,7 +192,7 @@ void RenderDoc::RecreateCrashHandler() { UnloadCrashHandler(); -#ifdef CRASH_HANDLER_ENABLED +#if ENABLED(RDOC_CRASH_HANDLER) m_ExHandler = new CrashHandler(m_ExHandler); #endif @@ -626,7 +627,7 @@ string RenderDoc::GetOverlayText(RDCDriver driver, uint32_t frameNumber, int fla } } -#if !defined(RELEASE) +#if ENABLED(RDOC_DEVEL) overlayText += StringFormat::Fmt("%llu chunks - %.2f MB\n", Chunk::NumLiveChunks(), float(Chunk::TotalMem()) / 1024.0f / 1024.0f); #endif @@ -691,7 +692,7 @@ Serialiser *RenderDoc::OpenWriteSerialiser(uint32_t frameNum, RDCInitParams *par { RDCASSERT(m_CurrentDriver != RDC_Unknown); -#if defined(RELEASE) +#if ENABLED(RDOC_RELEASE) const bool debugSerialiser = false; #else const bool debugSerialiser = true; diff --git a/renderdoc/core/crash_handler.h b/renderdoc/core/crash_handler.h index 6ff0c7f52..8af97b653 100644 --- a/renderdoc/core/crash_handler.h +++ b/renderdoc/core/crash_handler.h @@ -25,7 +25,7 @@ #if USE_BREAKPAD && defined(RENDERDOC_OFFICIAL_BUILD) -#define CRASH_HANDLER_ENABLED +#define RDOC_CRASH_HANDLER OPTION_ON // breakpad #include "breakpad/client/windows/common/ipc_protocol.h" @@ -142,4 +142,8 @@ private: google_breakpad::ExceptionHandler *m_ExHandler; }; +#else + +#define RDOC_CRASH_HANDLER OPTION_OFF + #endif diff --git a/renderdoc/core/replay_proxy.cpp b/renderdoc/core/replay_proxy.cpp index ce23e51ae..8c1a8649b 100644 --- a/renderdoc/core/replay_proxy.cpp +++ b/renderdoc/core/replay_proxy.cpp @@ -35,7 +35,7 @@ // Win32 to try and hide less padding with the larger alignment requirement // of 8-byte pointers. -#if defined(RENDERDOC_PLATFORM_WIN32) && defined(RDC64BIT) +#if ENABLED(RDOC_WIN32) && ENABLED(RDOC_X64) template class oversized { diff --git a/renderdoc/driver/d3d11/d3d11_analyse.cpp b/renderdoc/driver/d3d11/d3d11_analyse.cpp index 72f70b954..fa0a3e544 100644 --- a/renderdoc/driver/d3d11/d3d11_analyse.cpp +++ b/renderdoc/driver/d3d11/d3d11_analyse.cpp @@ -6985,7 +6985,7 @@ vector D3D11DebugManager::PixelHistory(vector eve } } -#if !defined(RELEASE) +#if ENABLED(RDOC_DEVEL) for(size_t h = 0; h < history.size(); h++) { PixelModification &hs = history[h]; diff --git a/renderdoc/driver/d3d11/d3d11_context.cpp b/renderdoc/driver/d3d11/d3d11_context.cpp index c62836212..db8a29825 100644 --- a/renderdoc/driver/d3d11/d3d11_context.cpp +++ b/renderdoc/driver/d3d11/d3d11_context.cpp @@ -104,7 +104,7 @@ WrappedID3D11DeviceContext::WrappedID3D11DeviceContext(WrappedID3D11Device *real m_pRealContext3 = NULL; m_pRealContext->QueryInterface(__uuidof(ID3D11DeviceContext3), (void **)&m_pRealContext3); -#if defined(RELEASE) +#if ENABLED(RDOC_RELEASE) const bool debugSerialiser = false; #else const bool debugSerialiser = true; diff --git a/renderdoc/driver/d3d11/d3d11_counters.cpp b/renderdoc/driver/d3d11/d3d11_counters.cpp index 656f8556d..ea0747fa2 100644 --- a/renderdoc/driver/d3d11/d3d11_counters.cpp +++ b/renderdoc/driver/d3d11/d3d11_counters.cpp @@ -27,74 +27,12 @@ #include "d3d11_debug.h" #include "d3d11_device.h" -#if defined(ENABLE_NVIDIA_PERFKIT) -#define NVPM_INITGUID -#include STRINGIZE(CONCAT(NVIDIA_PERFKIT_DIR, inc\\NvPmApi.h)) - -NvPmApi *nvAPI = NULL; - -int enumFunc(NVPMCounterID id, const char *name) -{ - RDCLOG("(% 4d): %s", id, name); - - return NVPM_OK; -} -#endif - void D3D11DebugManager::PreDeviceInitCounters() { } void D3D11DebugManager::PostDeviceInitCounters() { -#if defined(ENABLE_NVIDIA_PERFKIT) - HMODULE nvapi = - LoadLibraryA(STRINGIZE(CONCAT(NVIDIA_PERFKIT_DIR, bin\\win7_x86\\NvPmApi.Core.dll))); - if(nvapi == NULL) - { - RDCERR("Couldn't load perfkit"); - return; - } - - NVPMGetExportTable_Pfn NVPMGetExportTable = - (NVPMGetExportTable_Pfn)GetProcAddress(nvapi, "NVPMGetExportTable"); - if(NVPMGetExportTable == NULL) - { - RDCERR("Couldn't Get Symbol 'NVPMGetExportTable'"); - return; - } - - NVPMRESULT nvResult = NVPMGetExportTable(&ETID_NvPmApi, (void **)&nvAPI); - if(nvResult != NVPM_OK) - { - RDCERR("Couldn't NVPMGetExportTable"); - return; - } - - nvResult = nvAPI->Init(); - - if(nvResult != NVPM_OK) - { - RDCERR("Couldn't nvAPI->Init"); - return; - } - - NVPMContext context(0); - nvResult = nvAPI->CreateContextFromD3D11Device(m_pDevice, &context); - - if(nvResult != NVPM_OK) - { - RDCERR("Couldn't nvAPI->CreateContextFromD3D11Device"); - return; - } - - nvAPI->EnumCountersByContext(context, &enumFunc); - - nvAPI->DestroyContext(context); - nvAPI->Shutdown(); - nvAPI = NULL; - FreeLibrary(nvapi); -#endif } void D3D11DebugManager::PreDeviceShutdownCounters() diff --git a/renderdoc/driver/d3d11/d3d11_device.cpp b/renderdoc/driver/d3d11/d3d11_device.cpp index bc228789f..bf4ddabf7 100644 --- a/renderdoc/driver/d3d11/d3d11_device.cpp +++ b/renderdoc/driver/d3d11/d3d11_device.cpp @@ -297,7 +297,7 @@ void WrappedID3D11Device::NewSwapchainBuffer(IUnknown *backbuffer) void WrappedID3D11Device::SetLogFile(const char *logfile) { -#if defined(RELEASE) +#if ENABLED(RDOC_RELEASE) const bool debugSerialiser = false; #else const bool debugSerialiser = true; @@ -353,7 +353,7 @@ WrappedID3D11Device::WrappedID3D11Device(ID3D11Device *realDevice, D3D11InitPara m_AppControlledCapture = false; -#if defined(RELEASE) +#if ENABLED(RDOC_RELEASE) const bool debugSerialiser = false; #else const bool debugSerialiser = true; @@ -1163,7 +1163,7 @@ void WrappedID3D11Device::ReadLogInitialisation() SetupDrawcallPointers(&m_Drawcalls, m_FrameRecord.drawcallList, NULL, NULL); -#if !defined(RELEASE) +#if ENABLED(RDOC_DEVEL) for(auto it = chunkInfos.begin(); it != chunkInfos.end(); ++it) { double dcount = double(it->second.count); diff --git a/renderdoc/driver/d3d11/d3d11_hooks.cpp b/renderdoc/driver/d3d11/d3d11_hooks.cpp index ca7608b41..5b921a64f 100644 --- a/renderdoc/driver/d3d11/d3d11_hooks.cpp +++ b/renderdoc/driver/d3d11/d3d11_hooks.cpp @@ -68,7 +68,7 @@ public: // these are not required for success, but opportunistic to prevent AMD extensions from // activating and causing later crashes when not replayed correctly -#if defined(RDC64BIT) +#if ENABLED(RDOC_X64) AmdCreate11.Initialize("AmdDxExtCreate11", "atidxx64.dll", AmdCreate11_hook); #else AmdCreate11.Initialize("AmdDxExtCreate11", "atidxx32.dll", AmdCreate11_hook); diff --git a/renderdoc/driver/d3d11/d3d11_manager.h b/renderdoc/driver/d3d11/d3d11_manager.h index f45486e64..ccce0a9b6 100644 --- a/renderdoc/driver/d3d11/d3d11_manager.h +++ b/renderdoc/driver/d3d11/d3d11_manager.h @@ -200,7 +200,7 @@ private: template typename Dest::InnerType *Unwrap(typename Dest::InnerType *obj) { -#if !defined(RELEASE) +#if ENABLED(RDOC_DEVEL) if(obj && !Dest::IsAlloc(obj)) { RDCERR("Trying to unwrap invalid type"); diff --git a/renderdoc/driver/d3d11/d3d11_resources.h b/renderdoc/driver/d3d11/d3d11_resources.h index b79527de6..993e24adb 100644 --- a/renderdoc/driver/d3d11/d3d11_resources.h +++ b/renderdoc/driver/d3d11/d3d11_resources.h @@ -322,14 +322,14 @@ private: unsigned int m_ViewRefcount; // refcount from views (invisible to the end-user) protected: -#if !defined(RELEASE) +#if ENABLED(RDOC_DEVEL) DescType m_Desc; #endif WrappedResource11(NestedType *real, WrappedID3D11Device *device) : WrappedDeviceChild11(real, device), m_ViewRefcount(0) { -#if !defined(RELEASE) +#if ENABLED(RDOC_DEVEL) real->GetDesc(&m_Desc); #endif diff --git a/renderdoc/driver/d3d12/d3d12_command_list_wrap.cpp b/renderdoc/driver/d3d12/d3d12_command_list_wrap.cpp index 00c7bc4fb..cfbacb2b4 100644 --- a/renderdoc/driver/d3d12/d3d12_command_list_wrap.cpp +++ b/renderdoc/driver/d3d12/d3d12_command_list_wrap.cpp @@ -59,7 +59,7 @@ bool WrappedID3D12GraphicsCommandList::Serialise_Close() if(m_Cmd->ShouldRerecordCmd(CommandList)) { ID3D12GraphicsCommandList *list = m_Cmd->RerecordCmdList(CommandList); -#ifdef VERBOSE_PARTIAL_REPLAY +#if ENABLED(VERBOSE_PARTIAL_REPLAY) RDCDEBUG("Ending partial command list for %llu baked to %llu", CommandList, bakeId); #endif @@ -170,7 +170,7 @@ bool WrappedID3D12GraphicsCommandList::Serialise_Reset(ID3D12CommandAllocator *p { if(*it <= m_Cmd->m_LastEventID && m_Cmd->m_LastEventID < (*it + length)) { -#ifdef VERBOSE_PARTIAL_REPLAY +#if ENABLED(VERBOSE_PARTIAL_REPLAY) RDCDEBUG("Reset - partial detected %u < %u < %u, %llu -> %llu", *it, m_Cmd->m_LastEventID, *it + length, CommandList, bakeId); #endif diff --git a/renderdoc/driver/d3d12/d3d12_command_queue_wrap.cpp b/renderdoc/driver/d3d12/d3d12_command_queue_wrap.cpp index 53ae687b0..09829afe7 100644 --- a/renderdoc/driver/d3d12/d3d12_command_queue_wrap.cpp +++ b/renderdoc/driver/d3d12/d3d12_command_queue_wrap.cpp @@ -134,7 +134,7 @@ bool WrappedID3D12CommandQueue::Serialise_ExecuteCommandLists(UINT NumCommandLis { ID3D12CommandList *list = Unwrap(cmds[i]); real->ExecuteCommandLists(1, &list); -#if defined(SINGLE_FLUSH_VALIDATE) +#if ENABLED(SINGLE_FLUSH_VALIDATE) m_pDevice->GPUSync(); #endif } @@ -158,7 +158,7 @@ bool WrappedID3D12CommandQueue::Serialise_ExecuteCommandLists(UINT NumCommandLis real->ExecuteCommandLists(1, &list); } -#if defined(SINGLE_FLUSH_VALIDATE) +#if ENABLED(SINGLE_FLUSH_VALIDATE) m_pDevice->GPUSync(); #endif } @@ -255,13 +255,13 @@ bool WrappedID3D12CommandQueue::Serialise_ExecuteCommandLists(UINT NumCommandLis } else if(m_Cmd.m_LastEventID <= startEID) { -#ifdef VERBOSE_PARTIAL_REPLAY +#if ENABLED(VERBOSE_PARTIAL_REPLAY) RDCDEBUG("Queue Submit no replay %u == %u", m_Cmd.m_LastEventID, startEID); #endif } else if(m_Cmd.m_DrawcallCallback && m_Cmd.m_DrawcallCallback->RecordAllCmds()) { -#ifdef VERBOSE_PARTIAL_REPLAY +#if ENABLED(VERBOSE_PARTIAL_REPLAY) RDCDEBUG("Queue Submit re-recording from %u", m_Cmd.m_RootEventID); #endif @@ -271,7 +271,7 @@ bool WrappedID3D12CommandQueue::Serialise_ExecuteCommandLists(UINT NumCommandLis { ID3D12CommandList *cmd = m_Cmd.RerecordCmdList(cmdIds[c]); ResourceId rerecord = GetResID(cmd); -#ifdef VERBOSE_PARTIAL_REPLAY +#if ENABLED(VERBOSE_PARTIAL_REPLAY) RDCDEBUG("Queue Submit fully re-recorded replay of %llu, using %llu", cmdIds[c], rerecord); #endif rerecordedCmds.push_back(Unwrap(cmd)); @@ -279,7 +279,7 @@ bool WrappedID3D12CommandQueue::Serialise_ExecuteCommandLists(UINT NumCommandLis m_pDevice->ApplyBarriers(m_Cmd.m_BakedCmdListInfo[rerecord].barriers); } -#if defined(SINGLE_FLUSH_VALIDATE) +#if ENABLED(SINGLE_FLUSH_VALIDATE) for(size_t i = 0; i < rerecordedCmds.size(); i++) { real->ExecuteCommandLists(1, &rerecordedCmds[i]); @@ -291,7 +291,7 @@ bool WrappedID3D12CommandQueue::Serialise_ExecuteCommandLists(UINT NumCommandLis } else if(m_Cmd.m_LastEventID > startEID && m_Cmd.m_LastEventID < m_Cmd.m_RootEventID) { -#ifdef VERBOSE_PARTIAL_REPLAY +#if ENABLED(VERBOSE_PARTIAL_REPLAY) RDCDEBUG("Queue Submit partial replay %u < %u", m_Cmd.m_LastEventID, m_Cmd.m_RootEventID); #endif @@ -313,7 +313,7 @@ bool WrappedID3D12CommandQueue::Serialise_ExecuteCommandLists(UINT NumCommandLis ID3D12GraphicsCommandList *list = m_Cmd.RerecordCmdList(cmdIds[c], D3D12CommandData::Primary); ResourceId partial = GetResID(list); -#ifdef VERBOSE_PARTIAL_REPLAY +#if ENABLED(VERBOSE_PARTIAL_REPLAY) RDCDEBUG("Queue Submit partial replay of %llu at %u, using %llu", cmdIds[c], eid, partial); #endif trimmedCmdIds.push_back(partial); @@ -321,7 +321,7 @@ bool WrappedID3D12CommandQueue::Serialise_ExecuteCommandLists(UINT NumCommandLis } else if(m_Cmd.m_LastEventID >= end) { -#ifdef VERBOSE_PARTIAL_REPLAY +#if ENABLED(VERBOSE_PARTIAL_REPLAY) RDCDEBUG("Queue Submit full replay %llu", cmdIds[c]); #endif trimmedCmdIds.push_back(cmdIds[c]); @@ -329,7 +329,7 @@ bool WrappedID3D12CommandQueue::Serialise_ExecuteCommandLists(UINT NumCommandLis } else { -#ifdef VERBOSE_PARTIAL_REPLAY +#if ENABLED(VERBOSE_PARTIAL_REPLAY) RDCDEBUG("Queue not submitting %llu", cmdIds[c]); #endif } @@ -341,7 +341,7 @@ bool WrappedID3D12CommandQueue::Serialise_ExecuteCommandLists(UINT NumCommandLis RDCASSERT(trimmedCmds.size() > 0); -#if defined(SINGLE_FLUSH_VALIDATE) +#if ENABLED(SINGLE_FLUSH_VALIDATE) for(size_t i = 0; i < trimmedCmds.size(); i++) { real->ExecuteCommandLists(1, &trimmedCmds[i]); @@ -359,7 +359,7 @@ bool WrappedID3D12CommandQueue::Serialise_ExecuteCommandLists(UINT NumCommandLis } else { -#ifdef VERBOSE_PARTIAL_REPLAY +#if ENABLED(VERBOSE_PARTIAL_REPLAY) RDCDEBUG("Queue Submit full replay %u >= %u", m_Cmd.m_LastEventID, m_Cmd.m_RootEventID); #endif @@ -367,7 +367,7 @@ bool WrappedID3D12CommandQueue::Serialise_ExecuteCommandLists(UINT NumCommandLis for(uint32_t i = 0; i < numCmds; i++) unwrapped[i] = Unwrap(cmds[i]); -#if defined(SINGLE_FLUSH_VALIDATE) +#if ENABLED(SINGLE_FLUSH_VALIDATE) for(UINT i = 0; i < numCmds; i++) { real->ExecuteCommandLists(1, &unwrapped[i]); diff --git a/renderdoc/driver/d3d12/d3d12_commands.cpp b/renderdoc/driver/d3d12/d3d12_commands.cpp index 2bb772fea..204c24104 100644 --- a/renderdoc/driver/d3d12/d3d12_commands.cpp +++ b/renderdoc/driver/d3d12/d3d12_commands.cpp @@ -146,7 +146,7 @@ WrappedID3D12CommandQueue::WrappedID3D12CommandQueue(ID3D12CommandQueue *real, m_pReal->QueryInterface(__uuidof(ID3D12DebugCommandQueue), (void **)&m_WrappedDebug.m_pReal); -#if defined(RELEASE) +#if ENABLED(RDOC_RELEASE) const bool debugSerialiser = false; #else const bool debugSerialiser = true; @@ -590,7 +590,7 @@ WrappedID3D12GraphicsCommandList::WrappedID3D12GraphicsCommandList(ID3D12Graphic if(m_pReal) m_pReal->QueryInterface(__uuidof(ID3D12DebugCommandList), (void **)&m_WrappedDebug.m_pReal); -#if defined(RELEASE) +#if ENABLED(RDOC_RELEASE) const bool debugSerialiser = false; #else const bool debugSerialiser = true; diff --git a/renderdoc/driver/d3d12/d3d12_common.h b/renderdoc/driver/d3d12/d3d12_common.h index cbfca203d..829238430 100644 --- a/renderdoc/driver/d3d12/d3d12_common.h +++ b/renderdoc/driver/d3d12/d3d12_common.h @@ -51,11 +51,11 @@ void MakeShaderReflection(DXBC::DXBCFile *dxbc, ShaderReflection *refl, // uncomment this to cause every internal ExecuteCommandLists to immediately call // FlushLists(), and to only submit one command list at once to narrow // down the cause of device lost errors -//#define SINGLE_FLUSH_VALIDATE +#define SINGLE_FLUSH_VALIDATE OPTION_OFF // uncomment this to get verbose debugging about when/where/why partial command // buffer replay is happening -#define VERBOSE_PARTIAL_REPLAY +#define VERBOSE_PARTIAL_REPLAY OPTION_ON ShaderStageBits ConvertVisibility(D3D12_SHADER_VISIBILITY ShaderVisibility); UINT GetNumSubresources(ID3D12Device *dev, const D3D12_RESOURCE_DESC *desc); diff --git a/renderdoc/driver/d3d12/d3d12_debug.cpp b/renderdoc/driver/d3d12/d3d12_debug.cpp index 497bef7d9..24d684621 100644 --- a/renderdoc/driver/d3d12/d3d12_debug.cpp +++ b/renderdoc/driver/d3d12/d3d12_debug.cpp @@ -1872,7 +1872,7 @@ void D3D12DebugManager::GetBufferData(ID3D12Resource *buffer, uint64_t offset, u length = RDCMIN(length, desc.Width - offset); } -#ifndef RDC64BIT +#if DISABLED(RDOC_X64) if(offset + length > 0xfffffff) { RDCERR("Trying to read back too much data on 32-bit build. Try running on 64-bit."); diff --git a/renderdoc/driver/d3d12/d3d12_device.cpp b/renderdoc/driver/d3d12/d3d12_device.cpp index 33bdb8637..d273d6a3e 100644 --- a/renderdoc/driver/d3d12/d3d12_device.cpp +++ b/renderdoc/driver/d3d12/d3d12_device.cpp @@ -208,7 +208,7 @@ WrappedID3D12Device::WrappedID3D12Device(ID3D12Device *realDevice, D3D12InitPara m_GPUSyncHandle = NULL; m_GPUSyncCounter = 0; -#if defined(RELEASE) +#if ENABLED(RDOC_RELEASE) const bool debugSerialiser = false; #else const bool debugSerialiser = true; @@ -1817,7 +1817,7 @@ Serialiser *WrappedID3D12Device::GetThreadSerialiser() // slow path, but rare -#if defined(RELEASE) +#if ENABLED(RDOC_RELEASE) const bool debugSerialiser = false; #else const bool debugSerialiser = true; @@ -2158,7 +2158,7 @@ void WrappedID3D12Device::ReadLogInitialisation() SAFE_RELEASE(it->second); } -#if !defined(RELEASE) +#if ENABLED(RDOC_DEVEL) for(auto it = chunkInfos.begin(); it != chunkInfos.end(); ++it) { double dcount = double(it->second.count); @@ -2270,7 +2270,7 @@ void WrappedID3D12Device::ReplayLog(uint32_t startEventID, uint32_t endEventID, cmd.m_Partial[D3D12CommandData::Primary].outsideCmdList = NULL; } -#if defined(SINGLE_FLUSH_VALIDATE) +#if ENABLED(SINGLE_FLUSH_VALIDATE) FlushLists(true); #endif } diff --git a/renderdoc/driver/d3d12/d3d12_manager.cpp b/renderdoc/driver/d3d12/d3d12_manager.cpp index d82d9103d..033dbc440 100644 --- a/renderdoc/driver/d3d12/d3d12_manager.cpp +++ b/renderdoc/driver/d3d12/d3d12_manager.cpp @@ -1257,7 +1257,7 @@ void D3D12ResourceManager::Apply_InitialState(ID3D12DeviceChild *live, InitialCo list->Close(); -#if defined(SINGLE_FLUSH_VALIDATE) +#if ENABLED(SINGLE_FLUSH_VALIDATE) m_Device->ExecuteLists(); m_Device->FlushLists(true); #endif diff --git a/renderdoc/driver/gl/gl_common.h b/renderdoc/driver/gl/gl_common.h index 8fa7b7d35..9ecad79c7 100644 --- a/renderdoc/driver/gl/gl_common.h +++ b/renderdoc/driver/gl/gl_common.h @@ -25,6 +25,8 @@ #pragma once +#include "common/common.h" + // typed enum so that templates will pick up specialisations // header must be included before the official headers, so we/ // separate it out to avoid clang-format sorting them differently @@ -35,7 +37,7 @@ #include "official/glcorearb.h" #include "official/glext.h" -#if defined(RENDERDOC_PLATFORM_WIN32) +#if ENABLED(RDOC_WIN32) #include "official/wglext.h" struct GLWindowingData @@ -53,7 +55,7 @@ struct GLWindowingData HWND wnd; }; -#elif defined(RENDERDOC_PLATFORM_LINUX) +#elif ENABLED(RDOC_LINUX) // cheeky way to prevent GL/gl.h from being included, as we want to use // glcorearb.h from above #define __gl_h_ @@ -75,7 +77,7 @@ struct GLWindowingData GLXDrawable wnd; }; -#elif defined(RENDERDOC_PLATFORM_APPLE) +#elif ENABLED(RDOC_APPLE) struct GLWindowingData { @@ -90,7 +92,7 @@ struct GLWindowingData void *wnd; }; -#elif defined(RENDERDOC_PLATFORM_ANDROID) +#elif ENABLED(RDOC_ANDROID) #include "EGL/egl.h" #include "EGL/eglext.h" @@ -113,7 +115,7 @@ struct GLWindowingData #endif // define stubs so other platforms can define these functions, but empty -#if !defined(RENDERDOC_PLATFORM_WIN32) +#if DISABLED(RDOC_WIN32) typedef void *HANDLE; typedef long BOOL; @@ -130,6 +132,10 @@ typedef BOOL(APIENTRYP *PFNWGLDXUNLOCKOBJECTSNVPROC)(HANDLE hDevice, GLint count #include "api/replay/renderdoc_replay.h" +// define this if you e.g. haven't compiled the D3D modules and want to disable +// interop capture support. +#define RENDERDOC_DX_GL_INTEROP OPTION_ON + // 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_driver.cpp b/renderdoc/driver/gl/gl_driver.cpp index 41b89ca00..03fa36913 100644 --- a/renderdoc/driver/gl/gl_driver.cpp +++ b/renderdoc/driver/gl/gl_driver.cpp @@ -760,7 +760,7 @@ WrappedOpenGL::WrappedOpenGL(const char *logfile, const GLHookSet &funcs) : m_Re if(m_Real.glDebugMessageCallback) { m_Real.glDebugMessageCallback(&DebugSnoopStatic, this); -#if !defined(RELEASE) +#if ENABLED(RDOC_DEVEL) m_Real.glEnable(eGL_DEBUG_OUTPUT_SYNCHRONOUS); #endif } @@ -3102,7 +3102,7 @@ void WrappedOpenGL::ReadLogInitialisation() break; } -#if !defined(RELEASE) +#if ENABLED(RDOC_DEVEL) for(auto it = chunkInfos.begin(); it != chunkInfos.end(); ++it) { double dcount = double(it->second.count); diff --git a/renderdoc/driver/gl/gl_replay_linux.cpp b/renderdoc/driver/gl/gl_replay_linux.cpp index bb2761c37..f92eddf45 100644 --- a/renderdoc/driver/gl/gl_replay_linux.cpp +++ b/renderdoc/driver/gl/gl_replay_linux.cpp @@ -75,7 +75,7 @@ uint64_t GLReplay::MakeOutputWindow(WindowingSystem system, void *data, bool dep if(system == eWindowingSystem_Xlib) { -#if defined(RENDERDOC_WINDOWING_XLIB) +#if ENABLED(RDOC_XLIB) XlibWindowData *xlib = (XlibWindowData *)data; dpy = xlib->display; @@ -152,10 +152,10 @@ uint64_t GLReplay::MakeOutputWindow(WindowingSystem system, void *data, bool dep attribs[i++] = GLX_CONTEXT_MINOR_VERSION_ARB; attribs[i++] = 3; attribs[i++] = GLX_CONTEXT_FLAGS_ARB; -#if defined(_RELEASE) - attribs[i++] = 0; -#else +#if ENABLED(RDOC_DEVEL) attribs[i++] = GLX_CONTEXT_DEBUG_BIT_ARB; +#else + attribs[i++] = 0; #endif attribs[i++] = GLX_CONTEXT_PROFILE_MASK_ARB; attribs[i++] = GLX_CONTEXT_CORE_PROFILE_BIT_ARB; @@ -306,10 +306,10 @@ ReplayCreateStatus GL_CreateReplayDevice(const char *logfile, IReplayDriver **dr attribs[i++] = GLX_CONTEXT_MINOR_VERSION_ARB; attribs[i++] = 3; attribs[i++] = GLX_CONTEXT_FLAGS_ARB; -#if defined(_RELEASE) - attribs[i++] = 0; -#else +#if ENABLED(RDOC_DEVEL) attribs[i++] = GLX_CONTEXT_DEBUG_BIT_ARB; +#else + attribs[i++] = 0; #endif attribs[i++] = GLX_CONTEXT_PROFILE_MASK_ARB; attribs[i++] = GLX_CONTEXT_CORE_PROFILE_BIT_ARB; diff --git a/renderdoc/driver/gl/gl_replay_win32.cpp b/renderdoc/driver/gl/gl_replay_win32.cpp index e422134fb..5a27cf4a6 100644 --- a/renderdoc/driver/gl/gl_replay_win32.cpp +++ b/renderdoc/driver/gl/gl_replay_win32.cpp @@ -169,10 +169,10 @@ uint64_t GLReplay::MakeOutputWindow(WindowingSystem system, void *data, bool dep attribs[i++] = WGL_CONTEXT_MINOR_VERSION_ARB; attribs[i++] = 3; attribs[i++] = WGL_CONTEXT_FLAGS_ARB; -#if defined(_RELEASE) - attribs[i++] = 0; -#else +#if ENABLED(RDOC_DEVEL) attribs[i++] = WGL_CONTEXT_DEBUG_BIT_ARB; +#else + attribs[i++] = 0; #endif attribs[i++] = WGL_CONTEXT_PROFILE_MASK_ARB; attribs[i++] = WGL_CONTEXT_CORE_PROFILE_BIT_ARB; @@ -406,10 +406,10 @@ ReplayCreateStatus GL_CreateReplayDevice(const char *logfile, IReplayDriver **dr attribs[i++] = WGL_CONTEXT_MINOR_VERSION_ARB; attribs[i++] = 3; attribs[i++] = WGL_CONTEXT_FLAGS_ARB; -#if defined(_RELEASE) - attribs[i++] = 0; -#else +#if ENABLED(RDOC_DEVEL) attribs[i++] = WGL_CONTEXT_DEBUG_BIT_ARB; +#else + attribs[i++] = 0; #endif attribs[i++] = WGL_CONTEXT_PROFILE_MASK_ARB; attribs[i++] = WGL_CONTEXT_CORE_PROFILE_BIT_ARB; diff --git a/renderdoc/driver/gl/gl_resources.h b/renderdoc/driver/gl/gl_resources.h index e236ed9ad..66ec53854 100644 --- a/renderdoc/driver/gl/gl_resources.h +++ b/renderdoc/driver/gl/gl_resources.h @@ -244,7 +244,7 @@ struct GLResourceRecord : public ResourceRecord void VerifyDataType(GLenum target) { -#if !defined(RELEASE) +#if ENABLED(RDOC_DEVEL) if(target == eGL_NONE) return; // target == GL_NONE means ARB_dsa, target was omitted if(datatype == eGL_NONE) diff --git a/renderdoc/driver/gl/gl_shader_refl.cpp b/renderdoc/driver/gl/gl_shader_refl.cpp index a3821eff0..a2fe9a978 100644 --- a/renderdoc/driver/gl/gl_shader_refl.cpp +++ b/renderdoc/driver/gl/gl_shader_refl.cpp @@ -1931,7 +1931,7 @@ void GetBindpointMapping(const GLHookSet &gl, GLuint curProg, int shadIdx, Shade // in case of bugs, we readback into this array instead of GLint dummyReadback[32]; -#if !defined(RELEASE) +#if ENABLED(RDOC_DEVEL) for(size_t i = 1; i < ARRAY_COUNT(dummyReadback); i++) dummyReadback[i] = 0x6c7b8a9d; #endif @@ -2191,7 +2191,7 @@ void GetBindpointMapping(const GLHookSet &gl, GLuint curProg, int shadIdx, Shade } } -#if !defined(RELEASE) +#if ENABLED(RDOC_DEVEL) for(size_t i = 1; i < ARRAY_COUNT(dummyReadback); i++) if(dummyReadback[i] != 0x6c7b8a9d) RDCERR("Invalid uniform readback - data beyond first element modified!"); diff --git a/renderdoc/driver/gl/wrappers/gl_interop_funcs.cpp b/renderdoc/driver/gl/wrappers/gl_interop_funcs.cpp index a65156b69..55a95c2a6 100644 --- a/renderdoc/driver/gl/wrappers/gl_interop_funcs.cpp +++ b/renderdoc/driver/gl/wrappers/gl_interop_funcs.cpp @@ -26,11 +26,7 @@ #include "common/common.h" #include "serialise/string_utils.h" -// define this if you e.g. haven't compiled the D3D modules and want to disable -// interop capture support. -#define RENDERDOC_DX_GL_INTEROP 1 - -#if defined(RENDERDOC_PLATFORM_WIN32) && RENDERDOC_DX_GL_INTEROP +#if ENABLED(RDOC_WIN32) && ENABLED(RENDERDOC_DX_GL_INTEROP) struct ID3D11Resource; @@ -245,7 +241,7 @@ bool WrappedOpenGL::Serialise_wglDXRegisterObjectNV(GLResource res, GLenum type, if(m_State >= WRITING) { ResourceFormat format; -#if defined(RENDERDOC_PLATFORM_WIN32) && RENDERDOC_DX_GL_INTEROP +#if ENABLED(RDOC_WIN32) && ENABLED(RENDERDOC_DX_GL_INTEROP) GetDXTextureProperties(dxObject, format, width, height, depth, mips, layers, samples); internalFormat = MakeGLFormat(*this, format); #else diff --git a/renderdoc/driver/shaders/dxbc/dxbc_disassemble.cpp b/renderdoc/driver/shaders/dxbc/dxbc_disassemble.cpp index 3b6dbd9b5..b0300a4cd 100644 --- a/renderdoc/driver/shaders/dxbc/dxbc_disassemble.cpp +++ b/renderdoc/driver/shaders/dxbc/dxbc_disassemble.cpp @@ -2289,7 +2289,7 @@ bool DXBCFile::ExtractOperation(uint32_t *&tokenStream, ASMOperation &retOp) retOp.str += retOp.operands[i].toString(); } -#if !defined(RELEASE) +#if ENABLED(RDOC_DEVEL) if((uint32_t)(tokenStream - begin) > retOp.length) { RDCERR("Consumed too many tokens for %d!", retOp.operation); diff --git a/renderdoc/driver/shaders/spirv/spirv_common.cpp b/renderdoc/driver/shaders/spirv/spirv_common.cpp index 70c311e82..eb49e12c2 100644 --- a/renderdoc/driver/shaders/spirv/spirv_common.cpp +++ b/renderdoc/driver/shaders/spirv/spirv_common.cpp @@ -23,11 +23,12 @@ ******************************************************************************/ #include "spirv_common.h" +#include "common/common.h" #undef min #undef max -#ifdef _MSC_VER +#if ENABLED(RDOC_MSVS) #pragma warning(disable : 4481) // nonstandard extension used: override specifier 'override' #endif diff --git a/renderdoc/driver/shaders/spirv/spirv_compile.cpp b/renderdoc/driver/shaders/spirv/spirv_compile.cpp index dc0898580..ea20501e5 100644 --- a/renderdoc/driver/shaders/spirv/spirv_compile.cpp +++ b/renderdoc/driver/shaders/spirv/spirv_compile.cpp @@ -28,7 +28,7 @@ #undef min #undef max -#ifdef _MSC_VER +#if ENABLED(RDOC_MSVS) #pragma warning(disable : 4481) // nonstandard extension used: override specifier 'override' #endif diff --git a/renderdoc/driver/shaders/spirv/spirv_disassemble.cpp b/renderdoc/driver/shaders/spirv/spirv_disassemble.cpp index e04c42ded..28ce6470a 100644 --- a/renderdoc/driver/shaders/spirv/spirv_disassemble.cpp +++ b/renderdoc/driver/shaders/spirv/spirv_disassemble.cpp @@ -36,7 +36,7 @@ using std::make_pair; #undef min #undef max -#ifdef _MSC_VER +#if ENABLED(RDOC_MSVS) #pragma warning(disable : 4481) // nonstandard extension used: override specifier 'override' #endif diff --git a/renderdoc/driver/vulkan/vk_common.h b/renderdoc/driver/vulkan/vk_common.h index aea3a5249..1e92f3921 100644 --- a/renderdoc/driver/vulkan/vk_common.h +++ b/renderdoc/driver/vulkan/vk_common.h @@ -44,11 +44,15 @@ // uncomment this to cause every internal QueueSubmit to immediately call // DeviceWaitIdle(), and to only submit one command buffer at once to narrow // down the cause of device lost errors -//#define SINGLE_FLUSH_VALIDATE +#define SINGLE_FLUSH_VALIDATE OPTION_OFF // uncomment this to get verbose debugging about when/where/why partial command // buffer replay is happening -//#define VERBOSE_PARTIAL_REPLAY +#define VERBOSE_PARTIAL_REPLAY OPTION_OFF + +// uncomment this to enable validation layers on replay, useful for debugging +// problems with new replay code +#define FORCE_VALIDATION_LAYERS OPTION_OFF ResourceFormat MakeResourceFormat(VkFormat fmt); VkFormat MakeVkFormat(ResourceFormat fmt); diff --git a/renderdoc/driver/vulkan/vk_core.cpp b/renderdoc/driver/vulkan/vk_core.cpp index e231474a6..b73178df4 100644 --- a/renderdoc/driver/vulkan/vk_core.cpp +++ b/renderdoc/driver/vulkan/vk_core.cpp @@ -235,7 +235,7 @@ void VkInitParams::Set(const VkInstanceCreateInfo *pCreateInfo, ResourceId inst) WrappedVulkan::WrappedVulkan(const char *logFilename) : m_RenderState(&m_CreationInfo) { -#if defined(RELEASE) +#if ENABLED(RDOC_RELEASE) const bool debugSerialiser = false; #else const bool debugSerialiser = true; @@ -424,7 +424,7 @@ void WrappedVulkan::SubmitCmds() RDCASSERTEQUAL(vkr, VK_SUCCESS); } -#if defined(SINGLE_FLUSH_VALIDATE) +#if ENABLED(SINGLE_FLUSH_VALIDATE) FlushQ(); #endif @@ -487,7 +487,7 @@ void WrappedVulkan::FlushQ() ObjDisp(m_Queue)->QueueWaitIdle(Unwrap(m_Queue)); } -#if defined(SINGLE_FLUSH_VALIDATE) +#if ENABLED(SINGLE_FLUSH_VALIDATE) { ObjDisp(m_Queue)->DeviceWaitIdle(Unwrap(m_Device)); VkResult vkr = ObjDisp(m_Queue)->DeviceWaitIdle(Unwrap(m_Device)); @@ -624,7 +624,7 @@ Serialiser *WrappedVulkan::GetThreadSerialiser() // slow path, but rare -#if defined(RELEASE) +#if ENABLED(RDOC_RELEASE) const bool debugSerialiser = false; #else const bool debugSerialiser = true; @@ -889,7 +889,7 @@ bool WrappedVulkan::Serialise_BeginCaptureFrame(bool applyInitialState) VkCommandBufferBeginInfo beginInfo = {VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, NULL, VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT}; -#if defined(SINGLE_FLUSH_VALIDATE) +#if ENABLED(SINGLE_FLUSH_VALIDATE) for(size_t i = 0; i < imgBarriers.size(); i++) { VkCommandBuffer cmd = GetNextCmd(); @@ -1489,7 +1489,7 @@ void WrappedVulkan::ReadLogInitialisation() } } -#if !defined(RELEASE) +#if ENABLED(RDOC_DEVEL) for(auto it = chunkInfos.begin(); it != chunkInfos.end(); ++it) { double dcount = double(it->second.count); @@ -1713,7 +1713,7 @@ void WrappedVulkan::ApplyInitialContents() vkr = ObjDisp(cmd)->EndCommandBuffer(Unwrap(cmd)); RDCASSERTEQUAL(vkr, VK_SUCCESS); -#if defined(SINGLE_FLUSH_VALIDATE) +#if ENABLED(SINGLE_FLUSH_VALIDATE) SubmitCmds(); #endif } @@ -2246,7 +2246,7 @@ void WrappedVulkan::ReplayLog(uint32_t startEventID, uint32_t endEventID, Replay m_Partial[Primary].outsideCmdBuffer = VK_NULL_HANDLE; } -#if defined(SINGLE_FLUSH_VALIDATE) +#if ENABLED(SINGLE_FLUSH_VALIDATE) SubmitCmds(); #endif } diff --git a/renderdoc/driver/vulkan/vk_counters.cpp b/renderdoc/driver/vulkan/vk_counters.cpp index 782133ccf..40ea083d0 100644 --- a/renderdoc/driver/vulkan/vk_counters.cpp +++ b/renderdoc/driver/vulkan/vk_counters.cpp @@ -144,7 +144,7 @@ vector VulkanReplay::FetchCounters(const vector &counte vkr = ObjDisp(dev)->EndCommandBuffer(Unwrap(cmd)); RDCASSERTEQUAL(vkr, VK_SUCCESS); -#if defined(SINGLE_FLUSH_VALIDATE) +#if ENABLED(SINGLE_FLUSH_VALIDATE) m_pDriver->SubmitCmds(); #endif diff --git a/renderdoc/driver/vulkan/vk_debug.cpp b/renderdoc/driver/vulkan/vk_debug.cpp index de4ff11cd..68f9edaed 100644 --- a/renderdoc/driver/vulkan/vk_debug.cpp +++ b/renderdoc/driver/vulkan/vk_debug.cpp @@ -1000,7 +1000,7 @@ VulkanDebugManager::VulkanDebugManager(WrappedVulkan *driver, VkDevice dev) attState.srcColorBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA; attState.dstColorBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA; - VkShaderModule ms2arrayModule, array2msModule; + VkShaderModule ms2arrayModule = VK_NULL_HANDLE, array2msModule = VK_NULL_HANDLE; for(size_t i = 0; i < 2; i++) { @@ -2944,7 +2944,7 @@ void VulkanDebugManager::CreateCustomShaderTex(uint32_t width, uint32_t height, vkr = ObjDisp(dev)->EndCommandBuffer(Unwrap(cmd)); RDCASSERTEQUAL(vkr, VK_SUCCESS); -#if defined(SINGLE_FLUSH_VALIDATE) +#if ENABLED(SINGLE_FLUSH_VALIDATE) m_pDriver->SubmitCmds(); #endif @@ -4250,7 +4250,7 @@ uint32_t VulkanDebugManager::PickVertex(uint32_t eventID, const MeshDisplay &cfg VkResult vkr = vt->EndCommandBuffer(Unwrap(cmd)); RDCASSERTEQUAL(vkr, VK_SUCCESS); -#if defined(SINGLE_FLUSH_VALIDATE) +#if ENABLED(SINGLE_FLUSH_VALIDATE) m_pDriver->SubmitCmds(); #endif @@ -4401,7 +4401,7 @@ void VulkanDebugManager::GetBufferData(ResourceId buff, uint64_t offset, uint64_ vkr = vt->EndCommandBuffer(Unwrap(cmd)); RDCASSERTEQUAL(vkr, VK_SUCCESS); -#if defined(SINGLE_FLUSH_VALIDATE) +#if ENABLED(SINGLE_FLUSH_VALIDATE) m_pDriver->SubmitCmds(); #endif @@ -5956,7 +5956,7 @@ ResourceId VulkanDebugManager::RenderOverlay(ResourceId texid, TextureDisplayOve vkr = vt->EndCommandBuffer(Unwrap(cmd)); RDCASSERTEQUAL(vkr, VK_SUCCESS); -#if defined(SINGLE_FLUSH_VALIDATE) +#if ENABLED(SINGLE_FLUSH_VALIDATE) m_pDriver->SubmitCmds(); #endif @@ -6188,7 +6188,7 @@ ResourceId VulkanDebugManager::RenderOverlay(ResourceId texid, TextureDisplayOve vkr = vt->EndCommandBuffer(Unwrap(cmd)); RDCASSERTEQUAL(vkr, VK_SUCCESS); -#if defined(SINGLE_FLUSH_VALIDATE) +#if ENABLED(SINGLE_FLUSH_VALIDATE) m_pDriver->SubmitCmds(); #endif @@ -6300,7 +6300,7 @@ ResourceId VulkanDebugManager::RenderOverlay(ResourceId texid, TextureDisplayOve vkr = vt->EndCommandBuffer(Unwrap(cmd)); RDCASSERTEQUAL(vkr, VK_SUCCESS); -#if defined(SINGLE_FLUSH_VALIDATE) +#if ENABLED(SINGLE_FLUSH_VALIDATE) m_pDriver->SubmitCmds(); #endif @@ -6692,7 +6692,7 @@ ResourceId VulkanDebugManager::RenderOverlay(ResourceId texid, TextureDisplayOve vkr = vt->EndCommandBuffer(Unwrap(cmd)); RDCASSERTEQUAL(vkr, VK_SUCCESS); -#if defined(SINGLE_FLUSH_VALIDATE) +#if ENABLED(SINGLE_FLUSH_VALIDATE) m_pDriver->SubmitCmds(); #endif diff --git a/renderdoc/driver/vulkan/vk_dispatchtables.h b/renderdoc/driver/vulkan/vk_dispatchtables.h index 354975d43..de4542785 100644 --- a/renderdoc/driver/vulkan/vk_dispatchtables.h +++ b/renderdoc/driver/vulkan/vk_dispatchtables.h @@ -26,7 +26,7 @@ // layer includes -#if defined(RENDERDOC_PLATFORM_WIN32) +#if ENABLED(RDOC_WIN32) // undefined clashing windows #defines #undef CreateEvent #undef CreateSemaphore diff --git a/renderdoc/driver/vulkan/vk_initstate.cpp b/renderdoc/driver/vulkan/vk_initstate.cpp index 0a42cb5d8..0657d8134 100644 --- a/renderdoc/driver/vulkan/vk_initstate.cpp +++ b/renderdoc/driver/vulkan/vk_initstate.cpp @@ -2141,7 +2141,7 @@ void WrappedVulkan::Apply_InitialState(WrappedVkRes *live, vkr = ObjDisp(cmd)->EndCommandBuffer(Unwrap(cmd)); RDCASSERTEQUAL(vkr, VK_SUCCESS); -#if defined(SINGLE_FLUSH_VALIDATE) +#if ENABLED(SINGLE_FLUSH_VALIDATE) SubmitCmds(); #endif return; @@ -2215,7 +2215,7 @@ void WrappedVulkan::Apply_InitialState(WrappedVkRes *live, vkr = ObjDisp(cmd)->EndCommandBuffer(Unwrap(cmd)); RDCASSERTEQUAL(vkr, VK_SUCCESS); -#if defined(SINGLE_FLUSH_VALIDATE) +#if ENABLED(SINGLE_FLUSH_VALIDATE) SubmitCmds(); #endif } @@ -2275,7 +2275,7 @@ void WrappedVulkan::Apply_InitialState(WrappedVkRes *live, vkr = ObjDisp(cmd)->EndCommandBuffer(Unwrap(cmd)); RDCASSERTEQUAL(vkr, VK_SUCCESS); -#if defined(SINGLE_FLUSH_VALIDATE) +#if ENABLED(SINGLE_FLUSH_VALIDATE) SubmitCmds(); #endif } @@ -2414,7 +2414,7 @@ void WrappedVulkan::Apply_InitialState(WrappedVkRes *live, vkr = ObjDisp(cmd)->EndCommandBuffer(Unwrap(cmd)); RDCASSERTEQUAL(vkr, VK_SUCCESS); -#if defined(SINGLE_FLUSH_VALIDATE) +#if ENABLED(SINGLE_FLUSH_VALIDATE) SubmitCmds(); #endif } @@ -2443,7 +2443,7 @@ void WrappedVulkan::Apply_InitialState(WrappedVkRes *live, vkr = ObjDisp(cmd)->EndCommandBuffer(Unwrap(cmd)); RDCASSERTEQUAL(vkr, VK_SUCCESS); -#if defined(SINGLE_FLUSH_VALIDATE) +#if ENABLED(SINGLE_FLUSH_VALIDATE) SubmitCmds(); #endif } diff --git a/renderdoc/driver/vulkan/vk_linux.cpp b/renderdoc/driver/vulkan/vk_linux.cpp index cd3ccf77e..52229db9c 100644 --- a/renderdoc/driver/vulkan/vk_linux.cpp +++ b/renderdoc/driver/vulkan/vk_linux.cpp @@ -31,7 +31,7 @@ void VulkanReplay::OutputWindow::SetWindowHandle(WindowingSystem system, void *d { m_WindowSystem = system; -#if defined(RENDERDOC_WINDOWING_XLIB) +#if ENABLED(RDOC_XLIB) if(system == eWindowingSystem_Xlib) { XlibWindowData *xdata = (XlibWindowData *)data; @@ -41,7 +41,7 @@ void VulkanReplay::OutputWindow::SetWindowHandle(WindowingSystem system, void *d } #endif -#if defined(RENDERDOC_WINDOWING_XCB) +#if ENABLED(RDOC_XCB) if(system == eWindowingSystem_XCB) { XCBWindowData *xdata = (XCBWindowData *)data; @@ -56,7 +56,7 @@ void VulkanReplay::OutputWindow::SetWindowHandle(WindowingSystem system, void *d void VulkanReplay::OutputWindow::CreateSurface(VkInstance inst) { -#if defined(RENDERDOC_WINDOWING_XLIB) +#if ENABLED(RDOC_XLIB) if(m_WindowSystem == eWindowingSystem_Xlib) { VkXlibSurfaceCreateInfoKHR createInfo; @@ -74,7 +74,7 @@ void VulkanReplay::OutputWindow::CreateSurface(VkInstance inst) } #endif -#if defined(RENDERDOC_WINDOWING_XCB) +#if ENABLED(RDOC_XCB) if(m_WindowSystem == eWindowingSystem_XCB) { VkXcbSurfaceCreateInfoKHR createInfo; @@ -102,7 +102,7 @@ void VulkanReplay::GetOutputWindowDimensions(uint64_t id, int32_t &w, int32_t &h OutputWindow &outw = m_OutputWindows[id]; -#if defined(RENDERDOC_WINDOWING_XLIB) +#if ENABLED(RDOC_XLIB) if(outw.m_WindowSystem == eWindowingSystem_Xlib) { XWindowAttributes attr = {}; @@ -115,7 +115,7 @@ void VulkanReplay::GetOutputWindowDimensions(uint64_t id, int32_t &w, int32_t &h } #endif -#if defined(RENDERDOC_WINDOWING_XCB) +#if ENABLED(RDOC_XCB) if(outw.m_WindowSystem == eWindowingSystem_XCB) { xcb_get_geometry_cookie_t geomCookie = diff --git a/renderdoc/driver/vulkan/vk_replay.cpp b/renderdoc/driver/vulkan/vk_replay.cpp index df92fb48d..0320751ff 100644 --- a/renderdoc/driver/vulkan/vk_replay.cpp +++ b/renderdoc/driver/vulkan/vk_replay.cpp @@ -1426,7 +1426,7 @@ bool VulkanReplay::RenderTextureInternal(TextureDisplay cfg, VkRenderPassBeginIn vt->EndCommandBuffer(Unwrap(cmd)); -#if defined(SINGLE_FLUSH_VALIDATE) +#if ENABLED(SINGLE_FLUSH_VALIDATE) m_pDriver->SubmitCmds(); #endif @@ -1567,7 +1567,7 @@ void VulkanReplay::RenderCheckerboard(Vec3f light, Vec3f dark) vkr = vt->EndCommandBuffer(Unwrap(cmd)); RDCASSERTEQUAL(vkr, VK_SUCCESS); -#if defined(SINGLE_FLUSH_VALIDATE) +#if ENABLED(SINGLE_FLUSH_VALIDATE) m_pDriver->SubmitCmds(); #endif } @@ -1668,7 +1668,7 @@ void VulkanReplay::RenderHighlightBox(float w, float h, float scale) vkr = vt->EndCommandBuffer(Unwrap(cmd)); RDCASSERTEQUAL(vkr, VK_SUCCESS); -#if defined(SINGLE_FLUSH_VALIDATE) +#if ENABLED(SINGLE_FLUSH_VALIDATE) m_pDriver->SubmitCmds(); #endif } @@ -2186,7 +2186,7 @@ void VulkanReplay::RenderMesh(uint32_t eventID, const vector &second vkr = vt->EndCommandBuffer(Unwrap(cmd)); RDCASSERTEQUAL(vkr, VK_SUCCESS); -#if defined(SINGLE_FLUSH_VALIDATE) +#if ENABLED(SINGLE_FLUSH_VALIDATE) m_pDriver->SubmitCmds(); #endif @@ -2752,7 +2752,7 @@ void VulkanReplay::RenderMesh(uint32_t eventID, const vector &second vkr = vt->EndCommandBuffer(Unwrap(cmd)); RDCASSERTEQUAL(vkr, VK_SUCCESS); -#if defined(SINGLE_FLUSH_VALIDATE) +#if ENABLED(SINGLE_FLUSH_VALIDATE) m_pDriver->SubmitCmds(); #endif } @@ -2891,7 +2891,7 @@ void VulkanReplay::BindOutputWindow(uint64_t id, bool depth) vt->EndCommandBuffer(Unwrap(cmd)); -#if defined(SINGLE_FLUSH_VALIDATE) +#if ENABLED(SINGLE_FLUSH_VALIDATE) m_pDriver->SubmitCmds(); #endif } @@ -2941,7 +2941,7 @@ void VulkanReplay::ClearOutputWindowColour(uint64_t id, float col[4]) vt->EndCommandBuffer(Unwrap(cmd)); -#if defined(SINGLE_FLUSH_VALIDATE) +#if ENABLED(SINGLE_FLUSH_VALIDATE) m_pDriver->SubmitCmds(); #endif } @@ -2994,7 +2994,7 @@ void VulkanReplay::ClearOutputWindowDepth(uint64_t id, float depth, uint8_t sten vt->EndCommandBuffer(Unwrap(cmd)); -#if defined(SINGLE_FLUSH_VALIDATE) +#if ENABLED(SINGLE_FLUSH_VALIDATE) m_pDriver->SubmitCmds(); #endif } @@ -3043,7 +3043,7 @@ void VulkanReplay::FlipOutputWindow(uint64_t id) }, }; -#if MSAA_MESH_VIEW +#if ENABLED(MSAA_MESH_VIEW) VkImageResolve resolve = { {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1}, {0, 0, 0}, {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1}, {0, 0, 0}, @@ -4704,7 +4704,7 @@ byte *VulkanReplay::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t m // ordering vt->EndCommandBuffer(Unwrap(cmd)); -#if defined(SINGLE_FLUSH_VALIDATE) +#if ENABLED(SINGLE_FLUSH_VALIDATE) m_pDriver->SubmitCmds(); #endif diff --git a/renderdoc/driver/vulkan/vk_replay.h b/renderdoc/driver/vulkan/vk_replay.h index f737ed154..88694780e 100644 --- a/renderdoc/driver/vulkan/vk_replay.h +++ b/renderdoc/driver/vulkan/vk_replay.h @@ -30,20 +30,20 @@ #include "vk_common.h" #include "vk_info.h" -#if defined(RENDERDOC_PLATFORM_WIN32) +#if ENABLED(RDOC_WIN32) #include #define WINDOW_HANDLE_DECL HWND wnd; #define WINDOW_HANDLE_INIT wnd = NULL; -#elif defined(RENDERDOC_PLATFORM_ANDROID) +#elif ENABLED(RDOC_ANDROID) #define WINDOW_HANDLE_DECL ANativeWindow *wnd; #define WINDOW_HANDLE_INIT wnd = NULL; -#elif defined(RENDERDOC_PLATFORM_LINUX) +#elif ENABLED(RDOC_LINUX) -#if defined(RENDERDOC_WINDOWING_XLIB) +#if ENABLED(RDOC_XLIB) #define WINDOW_HANDLE_XLIB \ struct \ @@ -61,7 +61,7 @@ #endif -#if defined(RENDERDOC_WINDOWING_XCB) +#if ENABLED(RDOC_XCB) #define WINDOW_HANDLE_XCB \ struct \ @@ -107,9 +107,9 @@ using std::map; msgprinted = true; \ } while((void)0, 0) -#define MSAA_MESH_VIEW 1 +#define MSAA_MESH_VIEW OPTION_ON -#if MSAA_MESH_VIEW +#if ENABLED(MSAA_MESH_VIEW) #define VULKAN_MESH_VIEW_SAMPLES VK_SAMPLE_COUNT_4_BIT #else #define VULKAN_MESH_VIEW_SAMPLES VK_SAMPLE_COUNT_1_BIT diff --git a/renderdoc/driver/vulkan/vk_tracelayer.cpp b/renderdoc/driver/vulkan/vk_tracelayer.cpp index 0992c9a78..878323b60 100644 --- a/renderdoc/driver/vulkan/vk_tracelayer.cpp +++ b/renderdoc/driver/vulkan/vk_tracelayer.cpp @@ -37,7 +37,7 @@ #include "vk_resources.h" // this should be in the vulkan definition header -#if defined(RENDERDOC_PLATFORM_WIN32) +#if ENABLED(RDOC_WIN32) #undef VK_LAYER_EXPORT #define VK_LAYER_EXPORT extern "C" __declspec(dllexport) #endif @@ -176,7 +176,7 @@ void VKAPI_CALL hooked_vkDestroyInstance(VkInstance instance, const VkAllocation // Layer Intercepts -#if defined(RENDERDOC_PLATFORM_WIN32) && !defined(RDC64BIT) +#if ENABLED(RDOC_WIN32) && DISABLED(RDOC_X64) // Win32 __stdcall will still mangle even with extern "C", set up aliases diff --git a/renderdoc/driver/vulkan/vk_tracelayer_android.cpp b/renderdoc/driver/vulkan/vk_tracelayer_android.cpp index 678898fb5..af2fdfe45 100644 --- a/renderdoc/driver/vulkan/vk_tracelayer_android.cpp +++ b/renderdoc/driver/vulkan/vk_tracelayer_android.cpp @@ -37,7 +37,7 @@ // to be exported with the precise canonical names. We just forward them to the // layer-named functions -#if !defined(RENDERDOC_PLATFORM_ANDROID) +#if DISABLED(RDOC_ANDROID) #error "This file should only be compiled on android!" #endif diff --git a/renderdoc/driver/vulkan/wrappers/vk_cmd_funcs.cpp b/renderdoc/driver/vulkan/wrappers/vk_cmd_funcs.cpp index f893390bb..80621e303 100644 --- a/renderdoc/driver/vulkan/wrappers/vk_cmd_funcs.cpp +++ b/renderdoc/driver/vulkan/wrappers/vk_cmd_funcs.cpp @@ -489,7 +489,7 @@ bool WrappedVulkan::Serialise_vkBeginCommandBuffer(Serialiser *localSerialiser, { if(*it <= m_LastEventID && m_LastEventID < (*it + length)) { -#ifdef VERBOSE_PARTIAL_REPLAY +#if ENABLED(VERBOSE_PARTIAL_REPLAY) RDCDEBUG("vkBegin - partial detected %u < %u < %u, %llu -> %llu", *it, m_LastEventID, *it + length, cmdId, bakeId); #endif @@ -678,7 +678,7 @@ bool WrappedVulkan::Serialise_vkEndCommandBuffer(Serialiser *localSerialiser, if(ShouldRerecordCmd(cmdid)) { commandBuffer = RerecordCmdBuf(cmdid); -#ifdef VERBOSE_PARTIAL_REPLAY +#if ENABLED(VERBOSE_PARTIAL_REPLAY) RDCDEBUG("Ending partial command buffer for %llu baked to %llu", cmdid, bakeId); #endif @@ -2432,13 +2432,13 @@ bool WrappedVulkan::Serialise_vkCmdExecuteCommands(Serialiser *localSerialiser, } else if(m_LastEventID <= startEID) { -#ifdef VERBOSE_PARTIAL_REPLAY +#if ENABLED(VERBOSE_PARTIAL_REPLAY) RDCDEBUG("ExecuteCommands no replay %u == %u", m_LastEventID, startEID); #endif } else if(m_DrawcallCallback && m_DrawcallCallback->RecordAllCmds()) { -#ifdef VERBOSE_PARTIAL_REPLAY +#if ENABLED(VERBOSE_PARTIAL_REPLAY) RDCDEBUG("ExecuteCommands re-recording from %u", startEID); #endif @@ -2448,7 +2448,7 @@ bool WrappedVulkan::Serialise_vkCmdExecuteCommands(Serialiser *localSerialiser, { VkCommandBuffer cmd = RerecordCmdBuf(cmdids[c]); ResourceId rerecord = GetResID(cmd); -#ifdef VERBOSE_PARTIAL_REPLAY +#if ENABLED(VERBOSE_PARTIAL_REPLAY) RDCDEBUG("ExecuteCommands fully re-recorded replay of %llu, using %llu", cmdids[c], rerecord); #endif @@ -2463,7 +2463,7 @@ bool WrappedVulkan::Serialise_vkCmdExecuteCommands(Serialiser *localSerialiser, else if(m_LastEventID > startEID && m_LastEventID < parentCmdBufInfo.curEventID + m_Partial[Primary].baseEvent) { -#ifdef VERBOSE_PARTIAL_REPLAY +#if ENABLED(VERBOSE_PARTIAL_REPLAY) RDCDEBUG("ExecuteCommands partial replay %u < %u", m_LastEventID, parentCmdBufInfo.curEventID + m_Partial[Primary].baseEvent); #endif @@ -2484,7 +2484,7 @@ bool WrappedVulkan::Serialise_vkCmdExecuteCommands(Serialiser *localSerialiser, if(eid == m_Partial[Secondary].baseEvent) { ResourceId partial = GetResID(RerecordCmdBuf(cmdids[c], Secondary)); -#ifdef VERBOSE_PARTIAL_REPLAY +#if ENABLED(VERBOSE_PARTIAL_REPLAY) RDCDEBUG("ExecuteCommands partial replay of %llu at %u, using %llu", cmdids[c], eid, partial); #endif @@ -2493,7 +2493,7 @@ bool WrappedVulkan::Serialise_vkCmdExecuteCommands(Serialiser *localSerialiser, } else if(m_LastEventID >= end) { -#ifdef VERBOSE_PARTIAL_REPLAY +#if ENABLED(VERBOSE_PARTIAL_REPLAY) RDCDEBUG("ExecuteCommands full replay %llu", cmdids[c]); #endif trimmedCmdIds.push_back(cmdids[c]); @@ -2502,7 +2502,7 @@ bool WrappedVulkan::Serialise_vkCmdExecuteCommands(Serialiser *localSerialiser, } else { -#ifdef VERBOSE_PARTIAL_REPLAY +#if ENABLED(VERBOSE_PARTIAL_REPLAY) RDCDEBUG("not executing %llu", cmdids[c]); #endif } @@ -2525,7 +2525,7 @@ bool WrappedVulkan::Serialise_vkCmdExecuteCommands(Serialiser *localSerialiser, } else { -#ifdef VERBOSE_PARTIAL_REPLAY +#if ENABLED(VERBOSE_PARTIAL_REPLAY) RDCDEBUG("ExecuteCommands full replay %u >= %u", m_LastEventID, parentCmdBufInfo.curEventID + m_Partial[Primary].baseEvent); #endif diff --git a/renderdoc/driver/vulkan/wrappers/vk_device_funcs.cpp b/renderdoc/driver/vulkan/wrappers/vk_device_funcs.cpp index db6697652..e705897e1 100644 --- a/renderdoc/driver/vulkan/wrappers/vk_device_funcs.cpp +++ b/renderdoc/driver/vulkan/wrappers/vk_device_funcs.cpp @@ -47,8 +47,6 @@ void InitInstanceTable(VkInstance inst, PFN_vkGetInstanceProcAddr gpa); // and // instance are destroyed. We only clean up after our own objects. -//#define FORCE_VALIDATION_LAYERS - static void StripUnwantedLayers(vector &Layers) { for(auto it = Layers.begin(); it != Layers.end();) @@ -95,7 +93,7 @@ ReplayCreateStatus WrappedVulkan::Initialise(VkInitParams ¶ms) // PORTABILITY verify that layers/extensions are available StripUnwantedLayers(params.Layers); -#if defined(FORCE_VALIDATION_LAYERS) +#if ENABLED(FORCE_VALIDATION_LAYERS) params.Layers.push_back("VK_LAYER_LUNARG_standard_validation"); params.Extensions.push_back("VK_EXT_debug_report"); @@ -790,7 +788,7 @@ bool WrappedVulkan::Serialise_vkCreateDevice(Serialiser *localSerialiser, AddRequiredExtensions(false, Extensions, supportedExtensions); -#if defined(FORCE_VALIDATION_LAYERS) +#if ENABLED(FORCE_VALIDATION_LAYERS) Layers.push_back("VK_LAYER_LUNARG_standard_validation"); #endif diff --git a/renderdoc/driver/vulkan/wrappers/vk_queue_funcs.cpp b/renderdoc/driver/vulkan/wrappers/vk_queue_funcs.cpp index 53123348e..11b4999e3 100644 --- a/renderdoc/driver/vulkan/wrappers/vk_queue_funcs.cpp +++ b/renderdoc/driver/vulkan/wrappers/vk_queue_funcs.cpp @@ -283,13 +283,13 @@ bool WrappedVulkan::Serialise_vkQueueSubmit(Serialiser *localSerialiser, VkQueue } else if(m_LastEventID <= startEID) { -#ifdef VERBOSE_PARTIAL_REPLAY +#if ENABLED(VERBOSE_PARTIAL_REPLAY) RDCDEBUG("Queue Submit no replay %u == %u", m_LastEventID, startEID); #endif } else if(m_DrawcallCallback && m_DrawcallCallback->RecordAllCmds()) { -#ifdef VERBOSE_PARTIAL_REPLAY +#if ENABLED(VERBOSE_PARTIAL_REPLAY) RDCDEBUG("Queue Submit re-recording from %u", m_RootEventID); #endif @@ -299,7 +299,7 @@ bool WrappedVulkan::Serialise_vkQueueSubmit(Serialiser *localSerialiser, VkQueue { VkCommandBuffer cmd = RerecordCmdBuf(cmdIds[c]); ResourceId rerecord = GetResID(cmd); -#ifdef VERBOSE_PARTIAL_REPLAY +#if ENABLED(VERBOSE_PARTIAL_REPLAY) RDCDEBUG("Queue Submit fully re-recorded replay of %llu, using %llu", cmdIds[c], rerecord); #endif rerecordedCmds.push_back(Unwrap(cmd)); @@ -316,7 +316,7 @@ bool WrappedVulkan::Serialise_vkQueueSubmit(Serialiser *localSerialiser, VkQueue } else if(m_LastEventID > startEID && m_LastEventID < m_RootEventID) { -#ifdef VERBOSE_PARTIAL_REPLAY +#if ENABLED(VERBOSE_PARTIAL_REPLAY) RDCDEBUG("Queue Submit partial replay %u < %u", m_LastEventID, m_RootEventID); #endif @@ -336,7 +336,7 @@ bool WrappedVulkan::Serialise_vkQueueSubmit(Serialiser *localSerialiser, VkQueue if(eid == m_Partial[Primary].baseEvent) { ResourceId partial = GetResID(RerecordCmdBuf(cmdIds[c], Primary)); -#ifdef VERBOSE_PARTIAL_REPLAY +#if ENABLED(VERBOSE_PARTIAL_REPLAY) RDCDEBUG("Queue Submit partial replay of %llu at %u, using %llu", cmdIds[c], eid, partial); #endif trimmedCmdIds.push_back(partial); @@ -344,7 +344,7 @@ bool WrappedVulkan::Serialise_vkQueueSubmit(Serialiser *localSerialiser, VkQueue } else if(m_LastEventID >= end) { -#ifdef VERBOSE_PARTIAL_REPLAY +#if ENABLED(VERBOSE_PARTIAL_REPLAY) RDCDEBUG("Queue Submit full replay %llu", cmdIds[c]); #endif trimmedCmdIds.push_back(cmdIds[c]); @@ -353,7 +353,7 @@ bool WrappedVulkan::Serialise_vkQueueSubmit(Serialiser *localSerialiser, VkQueue } else { -#ifdef VERBOSE_PARTIAL_REPLAY +#if ENABLED(VERBOSE_PARTIAL_REPLAY) RDCDEBUG("Queue not submitting %llu", cmdIds[c]); #endif } @@ -379,7 +379,7 @@ bool WrappedVulkan::Serialise_vkQueueSubmit(Serialiser *localSerialiser, VkQueue } else { -#ifdef VERBOSE_PARTIAL_REPLAY +#if ENABLED(VERBOSE_PARTIAL_REPLAY) RDCDEBUG("Queue Submit full replay %u >= %u", m_LastEventID, m_RootEventID); #endif diff --git a/renderdoc/hooks/hooks.h b/renderdoc/hooks/hooks.h index b171eaef8..f8f47b163 100644 --- a/renderdoc/hooks/hooks.h +++ b/renderdoc/hooks/hooks.h @@ -32,7 +32,7 @@ using std::map; // include os-specific hooking mechanisms here -#if defined(RENDERDOC_PLATFORM_WIN32) +#if ENABLED(RDOC_WIN32) #include "os/win32/win32_hook.h" @@ -59,7 +59,7 @@ private: #define HOOKS_END() Win32_IAT_EndHooks() #define HOOKS_REMOVE() Win32_IAT_RemoveHooks() -#elif defined(RENDERDOC_PLATFORM_POSIX) +#elif ENABLED(RDOC_POSIX) #include "os/posix/posix_hook.h" diff --git a/renderdoc/os/os_specific.h b/renderdoc/os/os_specific.h index 0d99074c2..b55cd9603 100644 --- a/renderdoc/os/os_specific.h +++ b/renderdoc/os/os_specific.h @@ -430,7 +430,7 @@ string MakeMachineIdentString(uint64_t ident); namespace Bits { inline uint32_t CountLeadingZeroes(uint32_t value); -#if RDC64BIT +#if ENABLED(RDOC_X64) inline uint64_t CountLeadingZeroes(uint64_t value); #endif }; @@ -442,9 +442,9 @@ inline uint64_t CountLeadingZeroes(uint64_t value); // OS_DEBUG_BREAK() - instruction that debugbreaks the debugger - define instead of function to // preserve callstacks -#if defined(RENDERDOC_PLATFORM_WIN32) +#if ENABLED(RDOC_WIN32) #include "win32/win32_specific.h" -#elif defined(RENDERDOC_PLATFORM_POSIX) +#elif ENABLED(RDOC_POSIX) #include "posix/posix_specific.h" #else #error Undefined Platform! diff --git a/renderdoc/os/posix/android/android_stringio.cpp b/renderdoc/os/posix/android/android_stringio.cpp index ba96f4e64..c94a011fe 100644 --- a/renderdoc/os/posix/android/android_stringio.cpp +++ b/renderdoc/os/posix/android/android_stringio.cpp @@ -119,7 +119,7 @@ uint64_t GetMachineIdent() ret |= MachineIdent_Arch_x86; #endif -#if defined(RDC64BIT) +#if ENABLED(RDOC_X64) ret |= MachineIdent_64bit; #else ret |= MachineIdent_32bit; diff --git a/renderdoc/os/posix/apple/apple_process.cpp b/renderdoc/os/posix/apple/apple_process.cpp index 3fb4a1b50..c6cbec826 100644 --- a/renderdoc/os/posix/apple/apple_process.cpp +++ b/renderdoc/os/posix/apple/apple_process.cpp @@ -143,7 +143,7 @@ void CacheDebuggerPresent() bool OSUtility::DebuggerPresent() { // apple requires that this only be called in debug builds -#if defined(RELEASE) +#if ENABLED(RDOC_RELEASE) return false; #else int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PID, getpid()}; diff --git a/renderdoc/os/posix/linux/linux_stringio.cpp b/renderdoc/os/posix/linux/linux_stringio.cpp index 0ba64f953..abd7fb9e3 100644 --- a/renderdoc/os/posix/linux/linux_stringio.cpp +++ b/renderdoc/os/posix/linux/linux_stringio.cpp @@ -22,15 +22,6 @@ * THE SOFTWARE. ******************************************************************************/ -#if defined(RENDERDOC_WINDOWING_XLIB) -#include -#include -#endif - -#if defined(RENDERDOC_WINDOWING_XCB) -#include -#endif - #include #include #include @@ -45,6 +36,15 @@ #include "os/os_specific.h" #include "serialise/string_utils.h" +#if ENABLED(RDOC_XLIB) +#include +#include +#endif + +#if ENABLED(RDOC_XCB) +#include +#endif + using std::string; namespace Keyboard @@ -55,14 +55,14 @@ void Init() bool PlatformHasKeyInput() { -#if defined(RENDERDOC_WINDOWING_XCB) || defined(RENDERDOC_WINDOWING_XLIB) +#if ENABLED(RDOC_XCB) || ENABLED(RDOC_XLIB) return true; #else return false; #endif } -#if defined(RENDERDOC_WINDOWING_XLIB) +#if ENABLED(RDOC_XLIB) Display *CurrentXDisplay = NULL; @@ -135,7 +135,7 @@ bool GetXlibKeyState(int key) #else -// if RENDERDOC_WINDOWING_XLIB is not defined +// if RENDERDOC_WINDOWING_XLIB is not enabled bool GetXlibKeyState(int key) { @@ -144,7 +144,7 @@ bool GetXlibKeyState(int key) #endif -#if defined(RENDERDOC_WINDOWING_XCB) +#if ENABLED(RDOC_XCB) xcb_connection_t *connection; xcb_key_symbols_t *symbols; @@ -227,7 +227,7 @@ bool GetXCBKeyState(int key) #else -// if RENDERDOC_WINDOWING_XCB is not defined +// if RENDERDOC_WINDOWING_XCB is not enabled bool GetXCBKeyState(int key) { @@ -324,7 +324,7 @@ string Wide2UTF8(const std::wstring &s) if(ret == (size_t)-1) { -#if !defined(_RELEASE) +#if ENABLED(RDOC_DEVEL) RDCWARN("Failed to convert wstring"); #endif return ""; @@ -357,7 +357,7 @@ uint64_t GetMachineIdent() ret |= MachineIdent_Arch_x86; #endif -#if defined(RDC64BIT) +#if ENABLED(RDOC_X64) ret |= MachineIdent_64bit; #else ret |= MachineIdent_32bit; diff --git a/renderdoc/os/posix/posix_specific.h b/renderdoc/os/posix/posix_specific.h index cc618d521..77429d299 100644 --- a/renderdoc/os/posix/posix_specific.h +++ b/renderdoc/os/posix/posix_specific.h @@ -67,7 +67,7 @@ inline uint32_t CountLeadingZeroes(uint32_t value) return __builtin_clz(value); } -#if RDC64BIT +#if ENABLED(RDOC_X64) inline uint64_t CountLeadingZeroes(uint64_t value) { return __builtin_clzl(value); diff --git a/renderdoc/os/win32/win32_callstack.cpp b/renderdoc/os/win32/win32_callstack.cpp index 7632657b3..e2debc849 100644 --- a/renderdoc/os/win32/win32_callstack.cpp +++ b/renderdoc/os/win32/win32_callstack.cpp @@ -169,7 +169,7 @@ static bool InitDbgHelp() *slash = 0; } -#if defined(WIN64) +#if ENABLED(RDOC_X64) wcscat_s(path, L"/pdblocate/x64/dbghelp.dll"); #else wcscat_s(path, L"/pdblocate/x86/dbghelp.dll"); diff --git a/renderdoc/os/win32/win32_hook.cpp b/renderdoc/os/win32/win32_hook.cpp index fad40c21e..9592707b6 100644 --- a/renderdoc/os/win32/win32_hook.cpp +++ b/renderdoc/os/win32/win32_hook.cpp @@ -267,7 +267,7 @@ struct CachedHookData } }; -#ifdef WIN64 +#if ENABLED(RDOC_X64) if(IMAGE_SNAP_BY_ORDINAL64(origFirst->u1.AddressOfData)) #else if(IMAGE_SNAP_BY_ORDINAL32(origFirst->u1.AddressOfData)) diff --git a/renderdoc/os/win32/win32_process.cpp b/renderdoc/os/win32/win32_process.cpp index 3091c9f58..c21e9bd00 100644 --- a/renderdoc/os/win32/win32_process.cpp +++ b/renderdoc/os/win32/win32_process.cpp @@ -535,7 +535,7 @@ uint32_t Process::InjectIntoProcess(uint32_t pid, EnvironmentModification *env, return 0; } -#if !defined(WIN64) +#if DISABLED(RDOC_X64) BOOL selfWow64 = FALSE; HANDLE hSelfProcess = GetCurrentProcess(); @@ -903,7 +903,7 @@ void Process::StartGlobalHook(const char *pathmatch, const char *logfile, const CloseHandle(pi.hThread); CloseHandle(pi.hProcess); -#if defined(WIN64) +#if ENABLED(RDOC_X64) *slash = 0; wcscat_s(renderdocPath, L"\\x86\\renderdoccmd.exe"); diff --git a/renderdoc/os/win32/win32_specific.h b/renderdoc/os/win32/win32_specific.h index d8ee384c2..e74e149ed 100644 --- a/renderdoc/os/win32/win32_specific.h +++ b/renderdoc/os/win32/win32_specific.h @@ -73,7 +73,7 @@ inline uint32_t CountLeadingZeroes(uint32_t value) return (result == TRUE) ? (index ^ 31) : 32; } -#if RDC64BIT +#if ENABLED(RDOC_X64) inline uint64_t CountLeadingZeroes(uint64_t value) { DWORD index; diff --git a/renderdoc/os/win32/win32_stringio.cpp b/renderdoc/os/win32/win32_stringio.cpp index 1846a0790..90fc66489 100644 --- a/renderdoc/os/win32/win32_stringio.cpp +++ b/renderdoc/os/win32/win32_stringio.cpp @@ -594,7 +594,7 @@ string Wide2UTF8(const wstring &s) if(res == 0) { -#if !defined(_RELEASE) +#if ENABLED(RDOC_DEVEL) RDCWARN("Failed to convert wstring"); // can't pass string through as this would infinitely // recurse #endif @@ -621,7 +621,7 @@ wstring UTF82Wide(const string &s) if(res == 0) { -#if !defined(_RELEASE) +#if ENABLED(RDOC_DEVEL) RDCWARN("Failed to convert utf-8 string"); // can't pass string through as this would // infinitely recurse #endif @@ -656,7 +656,7 @@ uint64_t GetMachineIdent() ret |= MachineIdent_Arch_x86; #endif -#if defined(RDC64BIT) +#if ENABLED(RDOC_X64) ret |= MachineIdent_64bit; #else ret |= MachineIdent_32bit; diff --git a/renderdoc/replay/replay_output.cpp b/renderdoc/replay/replay_output.cpp index f4118afef..6612ecadd 100644 --- a/renderdoc/replay/replay_output.cpp +++ b/renderdoc/replay/replay_output.cpp @@ -30,11 +30,11 @@ static uint64_t GetHandle(WindowingSystem system, void *data) { -#if defined(RENDERDOC_PLATFORM_LINUX) +#if ENABLED(RDOC_LINUX) if(system == eWindowingSystem_Xlib) { -#if defined(RENDERDOC_WINDOWING_XLIB) +#if ENABLED(RDOC_XLIB) return (uint64_t)((XlibWindowData *)data)->window; #else RDCERR("Xlib windowing system data passed in, but support is not compiled in"); @@ -43,7 +43,7 @@ static uint64_t GetHandle(WindowingSystem system, void *data) if(system == eWindowingSystem_XCB) { -#if defined(RENDERDOC_WINDOWING_XCB) +#if ENABLED(RDOC_XCB) return (uint64_t)((XCBWindowData *)data)->window; #else RDCERR("XCB windowing system data passed in, but support is not compiled in"); @@ -54,12 +54,12 @@ static uint64_t GetHandle(WindowingSystem system, void *data) return 0; -#elif defined(RENDERDOC_PLATFORM_WIN32) +#elif ENABLED(RDOC_WIN32) RDCASSERT(system == eWindowingSystem_Win32); return (uint64_t)data; // HWND -#elif defined(RENDERDOC_PLATFORM_ANDROID) +#elif ENABLED(RDOC_ANDROID) RDCASSERT(system == eWindowingSystem_Android); return (uint64_t)data; // ANativeWindow * diff --git a/renderdoc/serialise/serialiser.cpp b/renderdoc/serialise/serialiser.cpp index 00f69d680..02c46fdab 100644 --- a/renderdoc/serialise/serialiser.cpp +++ b/renderdoc/serialise/serialiser.cpp @@ -30,13 +30,13 @@ #include "core/core.h" #include "serialise/string_utils.h" -#ifdef _MSC_VER -#pragma warning( \ - disable : 4422) // warning C4422: 'snprintf' : too many arguments passed for format string - // false positive as VS is trying to parse renderdoc's custom format strings +#if ENABLED(RDOC_MSVS) +// warning C4422: 'snprintf' : too many arguments passed for format string +// false positive as VS is trying to parse renderdoc's custom format strings +#pragma warning(disable : 4422) #endif -#if !defined(RELEASE) +#if ENABLED(RDOC_DEVEL) int64_t Chunk::m_LiveChunks = 0; int64_t Chunk::m_TotalMem = 0; @@ -265,7 +265,7 @@ Chunk::Chunk(Serialiser *ser, uint32_t chunkType, bool temporary) ser->Rewind(); -#if !defined(RELEASE) +#if ENABLED(RDOC_DEVEL) int64_t newval = Atomic::Inc64(&m_LiveChunks); Atomic::ExchAdd64(&m_TotalMem, m_Length); @@ -295,7 +295,7 @@ Chunk *Chunk::Duplicate() memcpy(ret->m_Data, m_Data, m_Length); -#if !defined(RELEASE) +#if ENABLED(RDOC_DEVEL) int64_t newval = Atomic::Inc64(&m_LiveChunks); Atomic::ExchAdd64(&m_TotalMem, m_Length); @@ -313,7 +313,7 @@ Chunk *Chunk::Duplicate() Chunk::~Chunk() { -#if !defined(RELEASE) +#if ENABLED(RDOC_DEVEL) Atomic::Dec64(&m_LiveChunks); Atomic::ExchAdd64(&m_TotalMem, -int64_t(m_Length)); #endif @@ -1979,7 +1979,7 @@ string ToStrHelper::Get(const int64_t &el) // platforms size_t is typedef'd in such a way that the uint32_t or // uint64_t specialisation will kick in. On apple, we need a // specific size_t overload -#if defined(RENDERDOC_PLATFORM_APPLE) +#if ENABLED(RDOC_APPLE) template <> string ToStrHelper::Get(const size_t &el) { diff --git a/renderdoc/serialise/serialiser.h b/renderdoc/serialise/serialiser.h index 051ed5583..304ca32b0 100644 --- a/renderdoc/serialise/serialiser.h +++ b/renderdoc/serialise/serialiser.h @@ -102,7 +102,7 @@ public: uint32_t GetChunkType() { return m_ChunkType; } bool IsAligned() { return m_AlignedData; } bool IsTemporary() { return m_Temporary; } -#if !defined(RELEASE) +#if ENABLED(RDOC_DEVEL) static uint64_t NumLiveChunks() { return m_LiveChunks; } static uint64_t TotalMem() { return m_TotalMem; } #else @@ -132,7 +132,7 @@ private: byte *m_Data; string m_DebugStr; -#if !defined(RELEASE) +#if ENABLED(RDOC_DEVEL) static int64_t m_LiveChunks, m_MaxChunks, m_TotalMem; #endif };