From 3f2d0bbf6ec6a495e059c62aaee8a190ef7ea0d4 Mon Sep 17 00:00:00 2001 From: David Farrell Date: Sat, 1 May 2021 17:29:27 -0700 Subject: [PATCH] The ToyPathTracer example uses the D3D11 GPU zones --- examples/ToyPathTracer/Windows/TestWin.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/examples/ToyPathTracer/Windows/TestWin.cpp b/examples/ToyPathTracer/Windows/TestWin.cpp index 7acc8595..c6796b90 100644 --- a/examples/ToyPathTracer/Windows/TestWin.cpp +++ b/examples/ToyPathTracer/Windows/TestWin.cpp @@ -16,6 +16,7 @@ #include "CompiledPixelShader.h" #include "../../../Tracy.hpp" +#include "../../../TracyD3D11.hpp" static HINSTANCE g_HInstance; static HWND g_Wnd; @@ -44,6 +45,7 @@ static ID3D11UnorderedAccessView *g_BackbufferUAV, *g_BackbufferUAV2; static ID3D11SamplerState* g_SamplerLinear; static ID3D11RasterizerState* g_RasterState; static int g_BackbufferIndex; +static tracy::D3D11Ctx *g_tracyCtx; #if DO_COMPUTE_GPU @@ -215,6 +217,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE, _In_ LPWSTR, else { RenderFrame(); + TracyD3D11Collect(g_tracyCtx); if( --framesLeft == 0 ) break; } } @@ -271,6 +274,7 @@ static int s_FrameCount = 0; static void RenderFrame() { ZoneScoped; + TracyD3D11Zone(g_tracyCtx, "RenderFrame"); LARGE_INTEGER time1; @@ -541,6 +545,10 @@ static HRESULT InitD3DDevice() vp.TopLeftY = 0; g_D3D11Ctx->RSSetViewports(1, &vp); + g_tracyCtx = TracyD3D11Context(g_D3D11Device, g_D3D11Ctx); + const char* tracyD3D11CtxName = "D3D11"; + TracyD3D11ContextName(g_tracyCtx, tracyD3D11CtxName, (uint16_t)strlen(tracyD3D11CtxName)); + return S_OK; } @@ -548,6 +556,8 @@ static void ShutdownD3DDevice() { ZoneScoped; + if (g_tracyCtx) TracyD3D11Destroy(g_tracyCtx); + if (g_D3D11Ctx) g_D3D11Ctx->ClearState(); if (g_D3D11RenderTarget) g_D3D11RenderTarget->Release();