Skip to content

Commit

Permalink
DX12:Support for timestamps in the copy queue
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasmr committed Oct 9, 2024
1 parent 96c9aab commit ff01aa6
Show file tree
Hide file tree
Showing 6 changed files with 159 additions and 38 deletions.
10 changes: 9 additions & 1 deletion demo/d3d12/d3d12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
//hack to make it work with the weird object oriented design of the sample
ID3D12Device* g_pDevice = 0;
ID3D12CommandQueue* g_pCommandQueue = 0;
ID3D12CommandQueue* g_pCopyQueue = 0;
int g_QueueGraphics = -1;


Expand Down Expand Up @@ -213,7 +214,7 @@ int DXSample::Run(HINSTANCE hInstance, int nCmdShow)
MicroProfileSetEnableAllGroups(true);
MicroProfileSetForceMetaCounters(true);
MICROPROFILE_CONDITIONAL(g_QueueGraphics = MICROPROFILE_GPU_INIT_QUEUE("GPU-Graphics-Queue"));
MicroProfileGpuInitD3D12(g_pDevice, 1, (void**)&g_pCommandQueue);
MicroProfileGpuInitD3D12(g_pDevice, 1, (void**)&g_pCommandQueue, (void**)&g_pCopyQueue);
MicroProfileSetCurrentNodeD3D12(0);
//MICROPROFILE_GPU_BEGIN(0, MicroProfileGetGlobalGpuThreadLog());

Expand Down Expand Up @@ -446,6 +447,13 @@ void D3D12HelloTriangle::LoadPipeline()
ThrowIfFailed(m_device->CreateCommandQueue(&queueDesc, IID_PPV_ARGS(&m_commandQueue)));
g_pCommandQueue = m_commandQueue.Get();

queueDesc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE;
queueDesc.Type = D3D12_COMMAND_LIST_TYPE_COPY;

ThrowIfFailed(m_device->CreateCommandQueue(&queueDesc, IID_PPV_ARGS(&g_pCopyQueue)));



// Describe and create the swap chain.
DXGI_SWAP_CHAIN_DESC swapChainDesc = {};
swapChainDesc.BufferCount = FrameCount;
Expand Down
4 changes: 2 additions & 2 deletions demo/d3d12/d3d12.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>MICROPROFILE_GPU_TIMERS_D3D12=1;MICROPROFILE_ENABLED=1;MICROPROFILE_GPU_TIMERS_MULTITHREADED=1;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>MICROPROFILE_GPU_TIMERS_D3D12=1;MICROPROFILE_ENABLED=1;MICROPROFILE_GPU_TIMERS_MULTITHREADED=1;MICROPROFILE_GPU_TIMERS=1;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\..</AdditionalIncludeDirectories>
</ClCompile>
<Link>
Expand Down Expand Up @@ -147,7 +147,7 @@
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>MICROPROFILE_GPU_TIMERS_D3D12=1;MICROPROFILE_ENABLED=1;MICROPROFILE_GPU_TIMERS_MULTITHREADED=1;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>MICROPROFILE_GPU_TIMERS_D3D12=1;MICROPROFILE_ENABLED=1;MICROPROFILE_GPU_TIMERS_MULTITHREADED=1;MICROPROFILE_GPU_TIMERS=1;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\..</AdditionalIncludeDirectories>
</ClCompile>
<Link>
Expand Down
7 changes: 6 additions & 1 deletion demo/d3d12_multithreading/d3d12_multithreading.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ static const int CommandListPost = 2;
#include "microprofile.h"

ID3D12Device* g_pDevice = 0;
ID3D12CommandQueue* g_pCopyQueue = 0;
ID3D12CommandQueue* g_pCommandQueue = 0;
ID3D12CommandQueue* g_pComputeQueue = 0;
int g_QueueGraphics = -1;
Expand Down Expand Up @@ -532,7 +533,7 @@ int DXSample::Run(HINSTANCE hInstance, int nCmdShow)
snprintf(frame, sizeof(frame) - 1, "Compute-Write-%d", i);
g_TokenGpuComputeFrameIndex[i] = MicroProfileGetToken("GPU", frame, (uint32_t)-1, MicroProfileTokenTypeGpu, 0);
}
MicroProfileGpuInitD3D12(g_pDevice, 1, (void**)&g_pCommandQueue);
MicroProfileGpuInitD3D12(g_pDevice, 1, (void**)&g_pCommandQueue, (void**)&g_pCopyQueue);
MicroProfileSetCurrentNodeD3D12(0);


Expand Down Expand Up @@ -931,6 +932,10 @@ void D3D12Multithreading::LoadPipeline()

ThrowIfFailed(m_device->CreateCommandQueue(&queueDesc, IID_PPV_ARGS(&g_pComputeQueue)));

queueDesc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE;
queueDesc.Type = D3D12_COMMAND_LIST_TYPE_COPY;
ThrowIfFailed(m_device->CreateCommandQueue(&queueDesc, IID_PPV_ARGS(&g_pCopyQueue)));

// Describe and create the swap chain.
DXGI_SWAP_CHAIN_DESC swapChainDesc = {};
swapChainDesc.BufferCount = FrameCount;
Expand Down
4 changes: 2 additions & 2 deletions demo/d3d12_multithreading/d3d12_multithreading.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>MICROPROFILE_GPU_FRAME_DELAY=5;MICROPROFILE_GPU_TIMERS_D3D12=1;MICROPROFILE_ENABLED=1;MICROPROFILE_GPU_TIMERS_MULTITHREADED=1;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>MICROPROFILE_GPU_FRAME_DELAY=5;MICROPROFILE_GPU_TIMERS_D3D12=1;MICROPROFILE_ENABLED=1;MICROPROFILE_GPU_TIMERS_MULTITHREADED=1;MICROPROFILE_GPU_TIMERS=1;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\..</AdditionalIncludeDirectories>
</ClCompile>
<Link>
Expand Down Expand Up @@ -161,7 +161,7 @@
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>MICROPROFILE_GPU_FRAME_DELAY=5;MICROPROFILE_GPU_TIMERS_D3D12=1;MICROPROFILE_ENABLED=1;MICROPROFILE_GPU_TIMERS_MULTITHREADED=1;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>MICROPROFILE_GPU_FRAME_DELAY=5;MICROPROFILE_GPU_TIMERS_D3D12=1;MICROPROFILE_ENABLED=1;MICROPROFILE_GPU_TIMERS_MULTITHREADED=1;MICROPROFILE_GPU_TIMERS=1;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\..</AdditionalIncludeDirectories>
</ClCompile>
<Link>
Expand Down
Loading

0 comments on commit ff01aa6

Please sign in to comment.