From 31485cb3450bf51d5d496e139c9b5236dc2cbf49 Mon Sep 17 00:00:00 2001 From: Rahul Gupta Date: Wed, 24 Feb 2021 00:14:40 -0600 Subject: [PATCH] Updated the manual and Added Destroy Macro --- TracyD3D11.hpp | 2 ++ manual/tracy.tex | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/TracyD3D11.hpp b/TracyD3D11.hpp index d7a06eb9..8afa5534 100644 --- a/TracyD3D11.hpp +++ b/TracyD3D11.hpp @@ -6,6 +6,7 @@ #if !defined TRACY_ENABLE || !defined _WIN32 #define TracyD3D11Context(x,y) +#define TracyD3D11Destroy(x) #define TracyD3D11NamedZone(x,y,z) #define TracyD3D11NamedZoneC(x,y,z,w) #define TracyD3D11Zone(x,y) @@ -339,6 +340,7 @@ static inline void DestroyD3D11Context( D3D11Ctx* ctx ) using TracyD3D11Ctx = tracy::D3D11Ctx*; #define TracyD3D11Context( device, devicectx ) tracy::CreateD3D11Context( device, devicectx ); +#define TracyD3D11Destroy( devicectx ) tracy::DestroyD3D11Context( devicectx ); #define TracyD3D11NamedZone( ctx, varname, name, active ) static const tracy::SourceLocationData TracyConcat(__tracy_gpu_source_location,__LINE__) { name, __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 }; tracy::D3D11CtxScope varname( ctx, &TracyConcat(__tracy_gpu_source_location,__LINE__), active ); #define TracyD3D11NamedZoneC( ctx, varname, name, color, active ) static const tracy::SourceLocationData TracyConcat(__tracy_gpu_source_location,__LINE__) { name, __FUNCTION__, __FILE__, (uint32_t)__LINE__, color }; tracy::D3D11CtxScope varname( ctx, &TracyConcat(__tracy_gpu_source_location,__LINE__), active ); #define TracyD3D11Zone( ctx, name ) TracyD3D11NamedZone( ctx, ___tracy_gpu_zone, name, true ) diff --git a/manual/tracy.tex b/manual/tracy.tex index 5b3e9a9f..05d29da3 100644 --- a/manual/tracy.tex +++ b/manual/tracy.tex @@ -137,7 +137,7 @@ There's much more Tracy can do, which can be explored by carefully reading this \section{A quick look at Tracy Profiler} \label{quicklook} -Tracy is a real-time, nanosecond resolution \emph{hybrid frame and sampling profiler} that can be used for remote or embedded telemetry of games and other applications. It can profile CPU (C, C++11, Lua), GPU (OpenGL, Vulkan, Direct3D 12, OpenCL) and memory. It also can monitor locks held by threads and show where contention does happen. +Tracy is a real-time, nanosecond resolution \emph{hybrid frame and sampling profiler} that can be used for remote or embedded telemetry of games and other applications. It can profile CPU (C, C++11, Lua), GPU (OpenGL, Vulkan, Direct3D 12, Direct3D 11, OpenCL) and memory. It also can monitor locks held by threads and show where contention does happen. While Tracy can perform statistical analysis of sampled call stack data, just like other \emph{statistical profilers} (such as VTune, perf or Very Sleepy), it mainly focuses on manual markup of the source code, which allows frame-by-frame inspection of the program execution. You will be able to see exactly which functions are called, how much time is spent in them, and how do they interact with each other in a multi-threaded environment. In contrast, the statistical analysis may show you the hot spots in your code, but it is unable to accurately pinpoint the underlying cause for semi-random frame stutter that may occur every couple of seconds. @@ -1356,6 +1356,14 @@ logo=\bcattention \end{itemize} \end{bclogo} +\subsubsection{Direct3D 11} + +Similar to OpenGL to enable Direct3D 11 support, include the \texttt{tracy/TracyD3D11.hpp} header file. To start profiling for Direct3D 11 , where a \texttt{TracyD3D11Ctx} is returned from a call to \texttt{TracyD3D11Context(device,ctx)}, which should be later cleaned up with the \texttt{TracyD3D11Destroy(ctx)} macro. + +To mark a GPU zone use the \texttt{TracyD3D11Zone(ctx,name)} macro, where \texttt{name} is a string literal name of the zone. Alternatively you may use \texttt{TracyD3D11ZoneC(ctx,name,color)} to specify zone color. + +You also need to periodically collect the GPU events similar to the OpenGL using the \texttt{TracyD3D11Collect(ctx)} macro. Recommended place to do it is after the swap buffers function call or end of a frame. + \subsubsection{Vulkan} Similarly, for Vulkan support you should include the \texttt{tracy/TracyVulkan.hpp} header file. Tracing Vulkan devices and queues is a bit more involved, and the Vulkan initialization macro \texttt{TracyVkContext(physdev, device, queue, cmdbuf)} returns an instance of \texttt{TracyVkCtx} object, which tracks an associated Vulkan queue. Cleanup is performed using the \texttt{TracyVkDestroy(ctx)} macro. You may create multiple Vulkan contexts.