Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FrameID-labeled Present/Vsync Queue, Vulkan fixes, plus other improvements #196

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
89873d8
Clear threadTLS on thread exit and fix OPTICK_SET_MEMORY_ALLOCATOR st…
SRSaunders Feb 15, 2024
c4d47e1
Improve Vulkan GPU profiler clock sync to reduce offset errors and drift
SRSaunders Feb 15, 2024
196354d
Resolve delayed GPU timestamps before dumping data on stop capture
SRSaunders Feb 15, 2024
ed9e453
Add profiler support for Vulkan Present / VSync queue via VK_GOOGLE_d…
SRSaunders Feb 16, 2024
5def5e0
Add profiler support for labeling D3D12 Present / VSync queue with fr…
SRSaunders Feb 16, 2024
01feb9b
Extend GPUContextScope() with typeless prototype for runtime selectio…
SRSaunders Feb 16, 2024
0585e1f
Add support for: a) disabling static and b) enabling dynamic Vulkan f…
SRSaunders Feb 16, 2024
8e77240
Add support for reporting runtime errors with text descriptions
SRSaunders Feb 16, 2024
66b06ff
Fix clang warnings for vsprintf() and type mismatches on non-windows …
SRSaunders Feb 18, 2024
2a1b010
Change OPTICK_VERIFY to print error and continue, also fix unreachabl…
SRSaunders Feb 19, 2024
a697a00
Improve Optick error reporting to debugger and to console stderr for …
SRSaunders Feb 20, 2024
3f19a66
Eliminate need for blocking sleep wait at start of Vulkan clock sync
SRSaunders Mar 8, 2024
9fce16b
Add support for data tags on custom storage events
SRSaunders Mar 22, 2024
6befba1
Enable vkResetQueryPoolEXT as fallback if vkResetQueryPool not available
SRSaunders May 23, 2024
69bdc64
Discover and assign dynamic VulkanFunctions for each device/node vs. …
SRSaunders May 24, 2024
03a44ba
Check for nullptr before overwriting vkResetQueryPool and vkGetPastPr…
SRSaunders May 24, 2024
1f2d6bd
Replace UNICODE test with TEXT() macro in optick_common.h
SRSaunders May 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/optick.config.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,12 @@
#if defined(_MSC_VER)
#define OPTICK_ENABLE_GPU_VULKAN (OPTICK_ENABLE_GPU /*&& 0*/)
#else
#define OPTICK_ENABLE_GPU_VULKAN (0)
#define OPTICK_ENABLE_GPU_VULKAN (OPTICK_ENABLE_GPU /*&& 0*/)
#endif
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Vulkan Functions - static+dynamic (1) or dynamic linking only (0)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#if !defined(OPTICK_STATIC_VULKAN_FUNCTIONS)
#define OPTICK_STATIC_VULKAN_FUNCTIONS (1)
#endif
#endif

73 changes: 61 additions & 12 deletions src/optick.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,21 @@

// Vulkan Forward Declarations
#define OPTICK_DEFINE_HANDLE(object) typedef struct object##_T *object;
OPTICK_DEFINE_HANDLE(VkInstance);
OPTICK_DEFINE_HANDLE(VkDevice);
OPTICK_DEFINE_HANDLE(VkPhysicalDevice);
OPTICK_DEFINE_HANDLE(VkQueue);
OPTICK_DEFINE_HANDLE(VkCommandBuffer);
OPTICK_DEFINE_HANDLE(VkQueryPool);
OPTICK_DEFINE_HANDLE(VkCommandPool);
OPTICK_DEFINE_HANDLE(VkFence);
OPTICK_DEFINE_HANDLE(VkEvent);

struct VkPhysicalDeviceProperties;
struct VkQueryPoolCreateInfo;
struct VkAllocationCallbacks;
struct VkCommandPoolCreateInfo;
struct VkEventCreateInfo;
struct VkCommandBufferAllocateInfo;
struct VkFenceCreateInfo;
struct VkSubmitInfo;
Expand All @@ -123,12 +126,18 @@ struct VkCommandBufferBeginInfo;
#endif
#endif

typedef void* (VKAPI_PTR *PFN_vkGetInstanceProcAddr_)(VkInstance instance, const char* pName);
typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceProperties_)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties* pProperties);
typedef int32_t (VKAPI_PTR *PFN_vkCreateQueryPool_)(VkDevice device, const VkQueryPoolCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkQueryPool* pQueryPool);
typedef int32_t (VKAPI_PTR *PFN_vkCreateCommandPool_)(VkDevice device, const VkCommandPoolCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkCommandPool* pCommandPool);
typedef int32_t (VKAPI_PTR *PFN_vkCreateEvent_)(VkDevice device, const VkEventCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkEvent* pEvent);
typedef int32_t (VKAPI_PTR *PFN_vkAllocateCommandBuffers_)(VkDevice device, const VkCommandBufferAllocateInfo* pAllocateInfo, VkCommandBuffer* pCommandBuffers);
typedef int32_t (VKAPI_PTR *PFN_vkCreateFence_)(VkDevice device, const VkFenceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkFence* pFence);
typedef void (VKAPI_PTR *PFN_vkCmdResetQueryPool_)(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount);
typedef void (VKAPI_PTR *PFN_vkResetQueryPool_)(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount);
typedef void (VKAPI_PTR *PFN_vkCmdWaitEvents_)(VkCommandBuffer commandBuffer, uint32_t eventCount, const VkEvent* pEvents, uint32_t srcStageMask, uint32_t dstStageMask, uint32_t memoryBarrierCount, const void* pMemoryBarriers, uint32_t bufferMemoryBarrierCount, const void* pBufferMemoryBarriers, uint32_t imageMemoryBarrierCount, const void* pImageMemoryBarriers);
typedef int32_t (VKAPI_PTR *PFN_vkResetEvent_)(VkDevice device, VkEvent event);
typedef int32_t (VKAPI_PTR *PFN_vkSetEvent_)(VkDevice device, VkEvent event);
typedef int32_t (VKAPI_PTR *PFN_vkQueueSubmit_)(VkQueue queue, uint32_t submitCount, const VkSubmitInfo* pSubmits, VkFence fence);
typedef int32_t (VKAPI_PTR *PFN_vkWaitForFences_)(VkDevice device, uint32_t fenceCount, const VkFence* pFences, uint32_t waitAll, uint64_t timeout);
typedef int32_t (VKAPI_PTR *PFN_vkResetCommandBuffer_)(VkCommandBuffer commandBuffer, uint32_t flags);
Expand All @@ -139,8 +148,10 @@ typedef int32_t (VKAPI_PTR *PFN_vkEndCommandBuffer_)(VkCommandBuffer commandBuff
typedef int32_t (VKAPI_PTR *PFN_vkResetFences_)(VkDevice device, uint32_t fenceCount, const VkFence* pFences);
typedef void (VKAPI_PTR *PFN_vkDestroyCommandPool_)(VkDevice device, VkCommandPool commandPool, const VkAllocationCallbacks* pAllocator);
typedef void (VKAPI_PTR *PFN_vkDestroyQueryPool_)(VkDevice device, VkQueryPool queryPool, const VkAllocationCallbacks* pAllocator);
typedef void (VKAPI_PTR *PFN_vkDestroyEvent_)(VkDevice device, VkEvent event, const VkAllocationCallbacks* pAllocator);
typedef void (VKAPI_PTR *PFN_vkDestroyFence_)(VkDevice device, VkFence fence, const VkAllocationCallbacks* pAllocator);
typedef void (VKAPI_PTR *PFN_vkFreeCommandBuffers_)(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount, const VkCommandBuffer* pCommandBuffers);
typedef int32_t (VKAPI_PTR *PFN_vkGetPastPresentationTimingGOOGLE_)(VkDevice device, void* swapchain, uint32_t* pPresentationTimingCount, void* pPresentationTimings);

#if OPTICK_VKAPI_PTR_DEFINED
#undef VKAPI_PTR
Expand All @@ -156,12 +167,18 @@ namespace Optick
{
struct OPTICK_API VulkanFunctions
{
PFN_vkGetInstanceProcAddr_ vkGetInstanceProcAddr;
PFN_vkGetPhysicalDeviceProperties_ vkGetPhysicalDeviceProperties;
PFN_vkCreateQueryPool_ vkCreateQueryPool;
PFN_vkCreateCommandPool_ vkCreateCommandPool;
PFN_vkCreateEvent_ vkCreateEvent;
PFN_vkAllocateCommandBuffers_ vkAllocateCommandBuffers;
PFN_vkCreateFence_ vkCreateFence;
PFN_vkCmdResetQueryPool_ vkCmdResetQueryPool;
PFN_vkResetQueryPool_ vkResetQueryPool;
PFN_vkCmdWaitEvents_ vkCmdWaitEvents;
PFN_vkResetEvent_ vkResetEvent;
PFN_vkSetEvent_ vkSetEvent;
PFN_vkQueueSubmit_ vkQueueSubmit;
PFN_vkWaitForFences_ vkWaitForFences;
PFN_vkResetCommandBuffer_ vkResetCommandBuffer;
Expand All @@ -172,8 +189,10 @@ namespace Optick
PFN_vkResetFences_ vkResetFences;
PFN_vkDestroyCommandPool_ vkDestroyCommandPool;
PFN_vkDestroyQueryPool_ vkDestroyQueryPool;
PFN_vkDestroyEvent_ vkDestroyEvent;
PFN_vkDestroyFence_ vkDestroyFence;
PFN_vkFreeCommandBuffers_ vkFreeCommandBuffers;
PFN_vkGetPastPresentationTimingGOOGLE_ vkGetPastPresentationTimingGOOGLE;
};

// Source: http://msdn.microsoft.com/en-us/library/system.windows.media.colors(v=vs.110).aspx
Expand Down Expand Up @@ -639,8 +658,8 @@ struct OPTICK_API EventDescription
uint32_t filter;
uint8_t flags;

static EventDescription* Create(const char* eventName, const char* fileName, const unsigned long fileLine, const unsigned long eventColor = Color::Null, const unsigned long filter = 0, const uint8_t eventFlags = 0);
static EventDescription* CreateShared(const char* eventName, const char* fileName = nullptr, const unsigned long fileLine = 0, const unsigned long eventColor = Color::Null, const unsigned long filter = 0);
static EventDescription* Create(const char* eventName, const char* fileName, const uint32_t fileLine, const uint32_t eventColor = Color::Null, const uint32_t filter = 0, const uint8_t eventFlags = 0);
static EventDescription* CreateShared(const char* eventName, const char* fileName = nullptr, const uint32_t fileLine = 0, const uint32_t eventColor = Color::Null, const uint32_t filter = 0);

EventDescription();
private:
Expand Down Expand Up @@ -681,11 +700,11 @@ OPTICK_INLINE Optick::EventDescription* CreateDescription(const char* functionNa
if (eventName != nullptr)
flags |= ::Optick::EventDescription::IS_CUSTOM_NAME;

return ::Optick::EventDescription::Create(eventName != nullptr ? eventName : functionName, fileName, (unsigned long)fileLine, ::Optick::Category::GetColor(category), ::Optick::Category::GetMask(category), flags);
return ::Optick::EventDescription::Create(eventName != nullptr ? eventName : functionName, fileName, (uint32_t)fileLine, ::Optick::Category::GetColor(category), ::Optick::Category::GetMask(category), flags);
}
OPTICK_INLINE Optick::EventDescription* CreateDescription(const char* functionName, const char* fileName, int fileLine, const ::Optick::Category::Type category)
{
return ::Optick::EventDescription::Create(functionName, fileName, (unsigned long)fileLine, ::Optick::Category::GetColor(category), ::Optick::Category::GetMask(category));
return ::Optick::EventDescription::Create(functionName, fileName, (uint32_t)fileLine, ::Optick::Category::GetColor(category), ::Optick::Category::GetMask(category));
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
struct OPTICK_API GPUEvent
Expand Down Expand Up @@ -717,11 +736,22 @@ struct OPTICK_API Tag
static void Attach(const EventDescription& description, const char* val);
static void Attach(const EventDescription& description, const char* val, uint16_t length);

static void Attach(EventStorage* storage, int64_t timestamp, const EventDescription& description, float val);
static void Attach(EventStorage* storage, int64_t timestamp, const EventDescription& description, int32_t val);
static void Attach(EventStorage* storage, int64_t timestamp, const EventDescription& description, uint32_t val);
static void Attach(EventStorage* storage, int64_t timestamp, const EventDescription& description, uint64_t val);
static void Attach(EventStorage* storage, int64_t timestamp, const EventDescription& description, float val[3]);
static void Attach(EventStorage* storage, int64_t timestamp, const EventDescription& description, const char* val);

// Derived
static void Attach(const EventDescription& description, float x, float y, float z)
{
float p[3] = { x, y, z }; Attach(description, p);
}
static void Attach(EventStorage* storage, int64_t timestamp, const EventDescription& description, float x, float y, float z)
{
float p[3] = { x, y, z }; Attach(storage, timestamp, description, p);
}

};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -762,8 +792,8 @@ struct OPTICK_API GPUContext
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
OPTICK_API void InitGpuD3D12(ID3D12Device* device, ID3D12CommandQueue** cmdQueues, uint32_t numQueues);
OPTICK_API void InitGpuVulkan(VkDevice* vkDevices, VkPhysicalDevice* vkPhysicalDevices, VkQueue* vkQueues, uint32_t* cmdQueuesFamily, uint32_t numQueues, const VulkanFunctions* functions);
OPTICK_API void GpuFlip(void* swapChain);
OPTICK_API void InitGpuVulkan(VkInstance vkInstance, VkDevice* vkDevices, VkPhysicalDevice* vkPhysicalDevices, VkQueue* vkQueues, uint32_t* cmdQueuesFamily, uint32_t numQueues, const VulkanFunctions* functions);
OPTICK_API void GpuFlip(void* swapChain, uint32_t frameID = 0);
OPTICK_API GPUContext SetGpuContext(GPUContext context);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
struct OPTICK_API GPUContextScope
Expand All @@ -780,6 +810,12 @@ struct OPTICK_API GPUContextScope
prevContext = SetGpuContext(GPUContext(cmdBuffer, queue, node));
}

// SRS - add typeless void* commandHandle prototype to support runtime selection of graphics API
GPUContextScope(void* commandHandle, GPUQueueType queue = GPU_QUEUE_GRAPHICS, int node = 0)
{
prevContext = SetGpuContext(GPUContext(commandHandle, queue, node));
}

~GPUContextScope()
{
SetGpuContext(prevContext);
Expand Down Expand Up @@ -923,7 +959,7 @@ struct OptickApp
#define OPTICK_STOP_THREAD() ::Optick::UnRegisterThread(false);

// Attaches a custom data-tag.
// Supported types: int32, uint32, uint64, vec3, string (cut to 32 characters)
// Supported types: float, int32, uint32, uint64, vec3, string (cut to 32 characters)
// Example:
// OPTICK_TAG("PlayerName", name[index]);
// OPTICK_TAG("Health", 100);
Expand Down Expand Up @@ -1000,6 +1036,18 @@ struct OptickApp
#define OPTICK_STORAGE_PUSH(STORAGE, DESCRIPTION, CPU_TIMESTAMP_START) if (::Optick::IsActive()) { ::Optick::Event::Push(STORAGE, DESCRIPTION, CPU_TIMESTAMP_START); }
#define OPTICK_STORAGE_POP(STORAGE, CPU_TIMESTAMP_FINISH) if (::Optick::IsActive()) { ::Optick::Event::Pop(STORAGE, CPU_TIMESTAMP_FINISH); }

// Attaches a custom data-tag to the custom storage.
// Supported types: float, int32, uint32, uint64, vec3, string (cut to 32 characters)
// Example:
// OPTICK_STORAGE_TAG(IOStorage, cpuTimestamp, "PlayerName", name[index]);
// OPTICK_STORAGE_TAG(IOStorage, cpuTimestamp, "Health", 100);
// OPTICK_STORAGE_TAG(IOStorage, cpuTimestamp, "Score", 0x80000000u);
// OPTICK_STORAGE_TAG(IOStorage, cpuTimestamp, "Height(cm)", 176.3f);
// OPTICK_STORAGE_TAG(IOStorage, cpuTimestamp, "Address", (uint64)*this);
// OPTICK_STORAGE_TAG(IOStorage, cpuTimestamp, "Position", 123.0f, 456.0f, 789.0f);
#define OPTICK_STORAGE_TAG(STORAGE, CPU_TIMESTAMP, NAME, ...) static ::Optick::EventDescription* OPTICK_CONCAT(autogen_tag_, __LINE__) = nullptr; \
if (OPTICK_CONCAT(autogen_tag_, __LINE__) == nullptr) OPTICK_CONCAT(autogen_tag_, __LINE__) = ::Optick::EventDescription::Create( NAME, __FILE__, __LINE__ ); \
::Optick::Tag::Attach(STORAGE, CPU_TIMESTAMP, *OPTICK_CONCAT(autogen_tag_, __LINE__), __VA_ARGS__); \

// Registers state change callback
// If callback returns false - the call is repeated the next frame
Expand All @@ -1024,7 +1072,7 @@ struct OptickApp

// GPU events
#define OPTICK_GPU_INIT_D3D12(DEVICE, CMD_QUEUES, NUM_CMD_QUEUS) ::Optick::InitGpuD3D12(DEVICE, CMD_QUEUES, NUM_CMD_QUEUS);
#define OPTICK_GPU_INIT_VULKAN(DEVICES, PHYSICAL_DEVICES, CMD_QUEUES, CMD_QUEUES_FAMILY, NUM_CMD_QUEUS, FUNCTIONS) ::Optick::InitGpuVulkan(DEVICES, PHYSICAL_DEVICES, CMD_QUEUES, CMD_QUEUES_FAMILY, NUM_CMD_QUEUS, FUNCTIONS);
#define OPTICK_GPU_INIT_VULKAN(INSTANCE, DEVICES, PHYSICAL_DEVICES, CMD_QUEUES, CMD_QUEUES_FAMILY, NUM_CMD_QUEUS, FUNCTIONS) ::Optick::InitGpuVulkan(INSTANCE, DEVICES, PHYSICAL_DEVICES, CMD_QUEUES, CMD_QUEUES_FAMILY, NUM_CMD_QUEUS, FUNCTIONS);

// Setup GPU context:
// Params:
Expand All @@ -1041,7 +1089,7 @@ struct OptickApp
if (OPTICK_CONCAT(gpu_autogen_description_, __LINE__) == nullptr) OPTICK_CONCAT(gpu_autogen_description_, __LINE__) = ::Optick::EventDescription::Create( NAME, __FILE__, __LINE__ ); \
::Optick::GPUEvent OPTICK_CONCAT(gpu_autogen_event_, __LINE__)( *(OPTICK_CONCAT(gpu_autogen_description_, __LINE__)) ); \

#define OPTICK_GPU_FLIP(SWAP_CHAIN) ::Optick::GpuFlip(SWAP_CHAIN);
#define OPTICK_GPU_FLIP(...) ::Optick::GpuFlip(__VA_ARGS__);

/////////////////////////////////////////////////////////////////////////////////
// [Automation][Startup]
Expand Down Expand Up @@ -1095,14 +1143,15 @@ struct OptickApp
#define OPTICK_STORAGE_EVENT(STORAGE, DESCRIPTION, CPU_TIMESTAMP_START, CPU_TIMESTAMP_FINISH)
#define OPTICK_STORAGE_PUSH(STORAGE, DESCRIPTION, CPU_TIMESTAMP_START)
#define OPTICK_STORAGE_POP(STORAGE, CPU_TIMESTAMP_FINISH)
#define OPTICK_STORAGE_TAG(STORAGE, CPU_TIMESTAMP, NAME, ...)
#define OPTICK_SET_STATE_CHANGED_CALLBACK(CALLBACK)
#define OPTICK_SET_MEMORY_ALLOCATOR(ALLOCATE_FUNCTION, DEALLOCATE_FUNCTION)
#define OPTICK_SET_MEMORY_ALLOCATOR(ALLOCATE_FUNCTION, DEALLOCATE_FUNCTION, INIT_THREAD_CALLBACK)
#define OPTICK_SHUTDOWN()
#define OPTICK_GPU_INIT_D3D12(DEVICE, CMD_QUEUES, NUM_CMD_QUEUS)
#define OPTICK_GPU_INIT_VULKAN(DEVICES, PHYSICAL_DEVICES, CMD_QUEUES, CMD_QUEUES_FAMILY, NUM_CMD_QUEUS, FUNCTIONS)
#define OPTICK_GPU_INIT_VULKAN(INSTANCE, DEVICES, PHYSICAL_DEVICES, CMD_QUEUES, CMD_QUEUES_FAMILY, NUM_CMD_QUEUS, FUNCTIONS)
#define OPTICK_GPU_CONTEXT(...)
#define OPTICK_GPU_EVENT(NAME)
#define OPTICK_GPU_FLIP(SWAP_CHAIN)
#define OPTICK_GPU_FLIP(...)
#define OPTICK_UPDATE()
#define OPTICK_FRAME_FLIP(...)
#define OPTICK_FRAME_EVENT(FRAME_TYPE, ...)
Expand Down
23 changes: 15 additions & 8 deletions src/optick_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@
#include "optick.h"

#include <cstdio>
#include <iostream>
#include <stdarg.h>
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdexcept>

#if defined(OPTICK_MSVC)

Expand Down Expand Up @@ -133,21 +135,26 @@ static const ProcessID INVALID_PROCESS_ID = (ProcessID)-1;
// Asserts
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#if defined(OPTICK_MSVC)
#define OPTICK_DEBUG_BREAK __debugbreak()
#define OPTICK_DEBUG_BREAK(description) OutputDebugString(TEXT("Optick ERROR: ") description TEXT("\n")); __debugbreak()
#elif defined(OPTICK_GCC)
#define OPTICK_DEBUG_BREAK __builtin_trap()
#if __has_builtin(__builtin_debugtrap)
#define OPTICK_DEBUG_BREAK(description) std::cerr << "Optick ERROR: " << description << std::endl; __builtin_debugtrap()
#else
#define OPTICK_DEBUG_BREAK(description) std::cerr << "Optick ERROR: " << description << std::endl; __builtin_trap()
#endif
#else
#error Can not define OPTICK_DEBUG_BREAK. Unknown platform.
#endif
#define OPTICK_UNUSED(x) (void)(x)
#ifdef _DEBUG
#define OPTICK_ASSERT(arg, description) if (!(arg)) { OPTICK_DEBUG_BREAK; }
#define OPTICK_FAILED(description) { OPTICK_DEBUG_BREAK; }
#define OPTICK_ASSERT(arg, description) if (!(arg)) { OPTICK_DEBUG_BREAK(description); }
#define OPTICK_FAILED(description) { OPTICK_DEBUG_BREAK(description); }
#define OPTICK_VERIFY(arg, description, operation) if (!(arg)) { OPTICK_DEBUG_BREAK(description); operation; }
#else
#define OPTICK_ASSERT(arg, description)
#define OPTICK_FAILED(description)
#define OPTICK_FAILED(description) { std::cerr << "Optick FATAL ERROR: " << description << std::endl; throw std::runtime_error("Optick FAILED"); }
#define OPTICK_VERIFY(arg, description, operation) if (!(arg)) { std::cerr << "Optick ERROR: " << description << std::endl; operation; }
#endif
#define OPTICK_VERIFY(arg, description, operation) if (!(arg)) { OPTICK_DEBUG_BREAK; operation; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand All @@ -168,15 +175,15 @@ inline int sprintf_s(char(&buffer)[sizeOfBuffer], const char* format, ...)
#if defined(OPTICK_GCC)
#include <string.h>
template<size_t sizeOfBuffer>
inline int wcstombs_s(char(&buffer)[sizeOfBuffer], const wchar_t* src, size_t maxCount)
inline size_t wcstombs_s(char(&buffer)[sizeOfBuffer], const wchar_t* src, size_t maxCount)
{
return wcstombs(buffer, src, maxCount);
}
#endif

#if defined(OPTICK_MSVC)
template<size_t sizeOfBuffer>
inline int wcstombs_s(char(&buffer)[sizeOfBuffer], const wchar_t* src, size_t maxCount)
inline size_t wcstombs_s(char(&buffer)[sizeOfBuffer], const wchar_t* src, size_t maxCount)
{
size_t converted = 0;
return ::wcstombs_s(&converted, buffer, src, maxCount);
Expand Down
Loading