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

Add a shutdown D3D12 function to correctly free the D3D12 resources #167

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions src/optick.h
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,7 @@ 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 ShutdownGpuD3D12();
OPTICK_API void GpuFlip(void* swapChain);
OPTICK_API GPUContext SetGpuContext(GPUContext context);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -1025,6 +1026,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_SHUTDOWN_D3D12() ::Optick::ShutdownGpuD3D12();

// Setup GPU context:
// Params:
Expand Down Expand Up @@ -1100,6 +1102,7 @@ struct OptickApp
#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_SHUTDOWN_D3D12()
#define OPTICK_GPU_CONTEXT(...)
#define OPTICK_GPU_EVENT(NAME)
#define OPTICK_GPU_FLIP(SWAP_CHAIN)
Expand Down
9 changes: 8 additions & 1 deletion src/optick_gpu.d3d12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,20 @@ namespace Optick
}
}

GPUProfilerD3D12* gpuProfiler = nullptr;

void InitGpuD3D12(ID3D12Device* device, ID3D12CommandQueue** cmdQueues, uint32_t numQueues)
{
GPUProfilerD3D12* gpuProfiler = Memory::New<GPUProfilerD3D12>();
gpuProfiler = Memory::New<GPUProfilerD3D12>();
gpuProfiler->InitDevice(device, cmdQueues, numQueues);
Core::Get().InitGPUProfiler(gpuProfiler);
}

void ShutdownGpuD3D12()
{
Memory::Delete<GPUProfilerD3D12>(gpuProfiler);
}

GPUProfilerD3D12::GPUProfilerD3D12() : queryBuffer(nullptr), device(nullptr)
{
prevFrameStatistics = { 0 };
Expand Down