VR-Vantage 3.0 API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TracyVulkan.hpp
Go to the documentation of this file.
1 #ifndef __TRACYVULKAN_HPP__
2 #define __TRACYVULKAN_HPP__
3 
4 #if !defined TRACY_ENABLE
5 
6 #define TracyVkContext(x,y,z,w) nullptr
7 #define TracyVkContextCalibrated(x,y,z,w,a,b) nullptr
8 #define TracyVkDestroy(x)
9 #define TracyVkContextName(c,x,y)
10 #define TracyVkNamedZone(c,x,y,z,w)
11 #define TracyVkNamedZoneC(c,x,y,z,w,a)
12 #define TracyVkZone(c,x,y)
13 #define TracyVkZoneC(c,x,y,z)
14 #define TracyVkZoneTransient(c,x,y,z,w)
15 #define TracyVkCollect(c,x)
16 
17 #define TracyVkNamedZoneS(c,x,y,z,w,a)
18 #define TracyVkNamedZoneCS(c,x,y,z,w,v,a)
19 #define TracyVkZoneS(c,x,y,z)
20 #define TracyVkZoneCS(c,x,y,z,w)
21 #define TracyVkZoneTransientS(c,x,y,z,w,a)
22 
23 namespace tracy
24 {
25 class VkCtxScope {};
26 }
27 
28 using TracyVkCtx = void*;
29 
30 #else
31 
32 #include <assert.h>
33 #include <stdlib.h>
34 #include <vulkan/vulkan.h>
35 #include "Tracy.hpp"
36 #include "client/TracyProfiler.hpp"
38 
39 namespace tracy
40 {
41 
42 class VkCtx
43 {
44  friend class VkCtxScope;
45 
46  enum { QueryCount = 64 * 1024 };
47 
48 public:
49  VkCtx( VkPhysicalDevice physdev, VkDevice device, VkQueue queue, VkCommandBuffer cmdbuf, PFN_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT _vkGetPhysicalDeviceCalibrateableTimeDomainsEXT, PFN_vkGetCalibratedTimestampsEXT _vkGetCalibratedTimestampsEXT )
50  : m_device( device )
51  , m_timeDomain( VK_TIME_DOMAIN_DEVICE_EXT )
52  , m_context( GetGpuCtxCounter().fetch_add( 1, std::memory_order_relaxed ) )
53  , m_head( 0 )
54  , m_tail( 0 )
55  , m_oldCnt( 0 )
56  , m_queryCount( QueryCount )
57  , m_vkGetCalibratedTimestampsEXT( _vkGetCalibratedTimestampsEXT )
58  {
59  assert( m_context != 255 );
60 
61  if( _vkGetPhysicalDeviceCalibrateableTimeDomainsEXT && _vkGetCalibratedTimestampsEXT )
62  {
63  uint32_t num;
64  _vkGetPhysicalDeviceCalibrateableTimeDomainsEXT( physdev, &num, nullptr );
65  if( num > 4 ) num = 4;
66  VkTimeDomainEXT data[4];
67  _vkGetPhysicalDeviceCalibrateableTimeDomainsEXT( physdev, &num, data );
68  for( uint32_t i=0; i<num; i++ )
69  {
70  // TODO VK_TIME_DOMAIN_CLOCK_MONOTONIC_RAW_EXT
71  if( data[i] == VK_TIME_DOMAIN_QUERY_PERFORMANCE_COUNTER_EXT )
72  {
73  m_timeDomain = data[i];
74  break;
75  }
76  }
77  }
78 
79  VkPhysicalDeviceProperties prop;
80  vkGetPhysicalDeviceProperties( physdev, &prop );
81  const float period = prop.limits.timestampPeriod;
82 
83  VkQueryPoolCreateInfo poolInfo = {};
84  poolInfo.sType = VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO;
85  poolInfo.queryCount = m_queryCount;
86  poolInfo.queryType = VK_QUERY_TYPE_TIMESTAMP;
87  while( vkCreateQueryPool( device, &poolInfo, nullptr, &m_query ) != VK_SUCCESS )
88  {
89  m_queryCount /= 2;
90  poolInfo.queryCount = m_queryCount;
91  }
92 
93  VkCommandBufferBeginInfo beginInfo = {};
94  beginInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
95  beginInfo.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
96 
97  VkSubmitInfo submitInfo = {};
98  submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
99  submitInfo.commandBufferCount = 1;
100  submitInfo.pCommandBuffers = &cmdbuf;
101 
102  vkBeginCommandBuffer( cmdbuf, &beginInfo );
103  vkCmdResetQueryPool( cmdbuf, m_query, 0, m_queryCount );
104  vkEndCommandBuffer( cmdbuf );
105  vkQueueSubmit( queue, 1, &submitInfo, VK_NULL_HANDLE );
106  vkQueueWaitIdle( queue );
107 
108  int64_t tcpu, tgpu;
109  if( m_timeDomain == VK_TIME_DOMAIN_DEVICE_EXT )
110  {
111  vkBeginCommandBuffer( cmdbuf, &beginInfo );
112  vkCmdWriteTimestamp( cmdbuf, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, m_query, 0 );
113  vkEndCommandBuffer( cmdbuf );
114  vkQueueSubmit( queue, 1, &submitInfo, VK_NULL_HANDLE );
115  vkQueueWaitIdle( queue );
116 
117  tcpu = Profiler::GetTime();
118  vkGetQueryPoolResults( device, m_query, 0, 1, sizeof( tgpu ), &tgpu, sizeof( tgpu ), VK_QUERY_RESULT_64_BIT | VK_QUERY_RESULT_WAIT_BIT );
119 
120  vkBeginCommandBuffer( cmdbuf, &beginInfo );
121  vkCmdResetQueryPool( cmdbuf, m_query, 0, 1 );
122  vkEndCommandBuffer( cmdbuf );
123  vkQueueSubmit( queue, 1, &submitInfo, VK_NULL_HANDLE );
124  vkQueueWaitIdle( queue );
125  }
126  else
127  {
128  enum { NumProbes = 32 };
129 
130  VkCalibratedTimestampInfoEXT spec[2] = {
131  { VK_STRUCTURE_TYPE_CALIBRATED_TIMESTAMP_INFO_EXT, nullptr, VK_TIME_DOMAIN_DEVICE_EXT },
132  { VK_STRUCTURE_TYPE_CALIBRATED_TIMESTAMP_INFO_EXT, nullptr, m_timeDomain },
133  };
134  uint64_t ts[2];
135  uint64_t deviation[NumProbes];
136  for( int i=0; i<NumProbes; i++ )
137  {
138  _vkGetCalibratedTimestampsEXT( device, 2, spec, ts, deviation+i );
139  }
140  uint64_t minDeviation = deviation[0];
141  for( int i=1; i<NumProbes; i++ )
142  {
143  if( minDeviation > deviation[i] )
144  {
145  minDeviation = deviation[i];
146  }
147  }
148  m_deviation = minDeviation * 3 / 2;
149 
150  m_qpcToNs = int64_t( 1000000000. / GetFrequencyQpc() );
151 
152  Calibrate( device, m_prevCalibration, tgpu );
153  tcpu = Profiler::GetTime();
154  }
155 
156  uint8_t flags = 0;
157  if( m_timeDomain != VK_TIME_DOMAIN_DEVICE_EXT ) flags |= GpuContextCalibration;
158 
159  auto item = Profiler::QueueSerial();
160  MemWrite( &item->hdr.type, QueueType::GpuNewContext );
161  MemWrite( &item->gpuNewContext.cpuTime, tcpu );
162  MemWrite( &item->gpuNewContext.gpuTime, tgpu );
163  memset( &item->gpuNewContext.thread, 0, sizeof( item->gpuNewContext.thread ) );
164  MemWrite( &item->gpuNewContext.period, period );
165  MemWrite( &item->gpuNewContext.context, m_context );
166  MemWrite( &item->gpuNewContext.flags, flags );
167  MemWrite( &item->gpuNewContext.type, GpuContextType::Vulkan );
168 
169 #ifdef TRACY_ON_DEMAND
170  GetProfiler().DeferItem( *item );
171 #endif
173 
174  m_res = (int64_t*)tracy_malloc( sizeof( int64_t ) * m_queryCount );
175  }
176 
177  ~VkCtx()
178  {
179  tracy_free( m_res );
180  vkDestroyQueryPool( m_device, m_query, nullptr );
181  }
182 
183  void Name( const char* name, uint16_t len )
184  {
185  auto ptr = (char*)tracy_malloc( len );
186  memcpy( ptr, name, len );
187 
188  auto item = Profiler::QueueSerial();
189  MemWrite( &item->hdr.type, QueueType::GpuContextName );
190  MemWrite( &item->gpuContextNameFat.context, m_context );
191  MemWrite( &item->gpuContextNameFat.ptr, (uint64_t)ptr );
192  MemWrite( &item->gpuContextNameFat.size, len );
193 #ifdef TRACY_ON_DEMAND
194  GetProfiler().DeferItem( *item );
195 #endif
197  }
198 
199  void Collect( VkCommandBuffer cmdbuf )
200  {
202 
203  if( m_tail == m_head ) return;
204 
205 #ifdef TRACY_ON_DEMAND
206  if( !GetProfiler().IsConnected() )
207  {
208  vkCmdResetQueryPool( cmdbuf, m_query, 0, m_queryCount );
209  m_head = m_tail = 0;
210  int64_t tgpu;
211  if( m_timeDomain != VK_TIME_DOMAIN_DEVICE_EXT ) Calibrate( m_device, m_prevCalibration, tgpu );
212  return;
213  }
214 #endif
215 
216  unsigned int cnt;
217  if( m_oldCnt != 0 )
218  {
219  cnt = m_oldCnt;
220  m_oldCnt = 0;
221  }
222  else
223  {
224  cnt = m_head < m_tail ? m_queryCount - m_tail : m_head - m_tail;
225  }
226 
227  if( vkGetQueryPoolResults( m_device, m_query, m_tail, cnt, sizeof( int64_t ) * m_queryCount, m_res, sizeof( int64_t ), VK_QUERY_RESULT_64_BIT ) == VK_NOT_READY )
228  {
229  m_oldCnt = cnt;
230  return;
231  }
232 
233  for( unsigned int idx=0; idx<cnt; idx++ )
234  {
235  auto item = Profiler::QueueSerial();
236  MemWrite( &item->hdr.type, QueueType::GpuTime );
237  MemWrite( &item->gpuTime.gpuTime, m_res[idx] );
238  MemWrite( &item->gpuTime.queryId, uint16_t( m_tail + idx ) );
239  MemWrite( &item->gpuTime.context, m_context );
241  }
242 
243  if( m_timeDomain != VK_TIME_DOMAIN_DEVICE_EXT )
244  {
245  int64_t tgpu, tcpu;
246  Calibrate( m_device, tcpu, tgpu );
247  const auto refCpu = Profiler::GetTime();
248  const auto delta = tcpu - m_prevCalibration;
249  if( delta > 0 )
250  {
251  m_prevCalibration = tcpu;
252  auto item = Profiler::QueueSerial();
253  MemWrite( &item->hdr.type, QueueType::GpuCalibration );
254  MemWrite( &item->gpuCalibration.gpuTime, tgpu );
255  MemWrite( &item->gpuCalibration.cpuTime, refCpu );
256  MemWrite( &item->gpuCalibration.cpuDelta, delta );
257  MemWrite( &item->gpuCalibration.context, m_context );
259  }
260  }
261 
262  vkCmdResetQueryPool( cmdbuf, m_query, m_tail, cnt );
263 
264  m_tail += cnt;
265  if( m_tail == m_queryCount ) m_tail = 0;
266  }
267 
268 private:
269  tracy_force_inline unsigned int NextQueryId()
270  {
271  const auto id = m_head;
272  m_head = ( m_head + 1 ) % m_queryCount;
273  assert( m_head != m_tail );
274  return id;
275  }
276 
277  tracy_force_inline uint8_t GetId() const
278  {
279  return m_context;
280  }
281 
282  tracy_force_inline void Calibrate( VkDevice device, int64_t& tCpu, int64_t& tGpu )
283  {
284  assert( m_timeDomain != VK_TIME_DOMAIN_DEVICE_EXT );
285  VkCalibratedTimestampInfoEXT spec[2] = {
286  { VK_STRUCTURE_TYPE_CALIBRATED_TIMESTAMP_INFO_EXT, nullptr, VK_TIME_DOMAIN_DEVICE_EXT },
287  { VK_STRUCTURE_TYPE_CALIBRATED_TIMESTAMP_INFO_EXT, nullptr, m_timeDomain },
288  };
289  uint64_t ts[2];
290  uint64_t deviation;
291  do
292  {
293  m_vkGetCalibratedTimestampsEXT( device, 2, spec, ts, &deviation );
294  }
295  while( deviation > m_deviation );
296 
297 #if defined _WIN32 || defined __CYGWIN__
298  tGpu = ts[0];
299  tCpu = ts[1] * m_qpcToNs;
300 #else
301  assert( false );
302 #endif
303  }
304 
305  VkDevice m_device;
306  VkQueryPool m_query;
307  VkTimeDomainEXT m_timeDomain;
308  uint64_t m_deviation;
309  int64_t m_qpcToNs;
310  int64_t m_prevCalibration;
311  uint8_t m_context;
312 
313  unsigned int m_head;
314  unsigned int m_tail;
315  unsigned int m_oldCnt;
316  unsigned int m_queryCount;
317 
318  int64_t* m_res;
319 
320  PFN_vkGetCalibratedTimestampsEXT m_vkGetCalibratedTimestampsEXT;
321 };
322 
323 class VkCtxScope
324 {
325 public:
326  tracy_force_inline VkCtxScope( VkCtx* ctx, const SourceLocationData* srcloc, VkCommandBuffer cmdbuf, bool is_active )
327 #ifdef TRACY_ON_DEMAND
328  : m_active( is_active && GetProfiler().IsConnected() )
329 #else
330  : m_active( is_active )
331 #endif
332  {
333  if( !m_active ) return;
334  m_cmdbuf = cmdbuf;
335  m_ctx = ctx;
336 
337  const auto queryId = ctx->NextQueryId();
338  vkCmdWriteTimestamp( cmdbuf, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, ctx->m_query, queryId );
339 
340  auto item = Profiler::QueueSerial();
341  MemWrite( &item->hdr.type, QueueType::GpuZoneBeginSerial );
342  MemWrite( &item->gpuZoneBegin.cpuTime, Profiler::GetTime() );
343  MemWrite( &item->gpuZoneBegin.srcloc, (uint64_t)srcloc );
344  MemWrite( &item->gpuZoneBegin.thread, GetThreadHandle() );
345  MemWrite( &item->gpuZoneBegin.queryId, uint16_t( queryId ) );
346  MemWrite( &item->gpuZoneBegin.context, ctx->GetId() );
348  }
349 
350  tracy_force_inline VkCtxScope( VkCtx* ctx, const SourceLocationData* srcloc, VkCommandBuffer cmdbuf, int depth, bool is_active )
351 #ifdef TRACY_ON_DEMAND
352  : m_active( is_active && GetProfiler().IsConnected() )
353 #else
354  : m_active( is_active )
355 #endif
356  {
357  if( !m_active ) return;
358  m_cmdbuf = cmdbuf;
359  m_ctx = ctx;
360 
361  const auto queryId = ctx->NextQueryId();
362  vkCmdWriteTimestamp( cmdbuf, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, ctx->m_query, queryId );
363 
364  auto item = Profiler::QueueSerialCallstack( Callstack( depth ) );
365  MemWrite( &item->hdr.type, QueueType::GpuZoneBeginCallstackSerial );
366  MemWrite( &item->gpuZoneBegin.cpuTime, Profiler::GetTime() );
367  MemWrite( &item->gpuZoneBegin.srcloc, (uint64_t)srcloc );
368  MemWrite( &item->gpuZoneBegin.thread, GetThreadHandle() );
369  MemWrite( &item->gpuZoneBegin.queryId, uint16_t( queryId ) );
370  MemWrite( &item->gpuZoneBegin.context, ctx->GetId() );
372  }
373 
374  tracy_force_inline VkCtxScope( VkCtx* ctx, uint32_t line, const char* source, size_t sourceSz, const char* function, size_t functionSz, const char* name, size_t nameSz, VkCommandBuffer cmdbuf, bool is_active )
375 #ifdef TRACY_ON_DEMAND
376  : m_active( is_active && GetProfiler().IsConnected() )
377 #else
378  : m_active( is_active )
379 #endif
380  {
381  if( !m_active ) return;
382  m_cmdbuf = cmdbuf;
383  m_ctx = ctx;
384 
385  const auto queryId = ctx->NextQueryId();
386  vkCmdWriteTimestamp( cmdbuf, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, ctx->m_query, queryId );
387 
388  const auto srcloc = Profiler::AllocSourceLocation( line, source, sourceSz, function, functionSz, name, nameSz );
389  auto item = Profiler::QueueSerial();
390  MemWrite( &item->hdr.type, QueueType::GpuZoneBeginAllocSrcLocSerial );
391  MemWrite( &item->gpuZoneBegin.cpuTime, Profiler::GetTime() );
392  MemWrite( &item->gpuZoneBegin.srcloc, srcloc );
393  MemWrite( &item->gpuZoneBegin.thread, GetThreadHandle() );
394  MemWrite( &item->gpuZoneBegin.queryId, uint16_t( queryId ) );
395  MemWrite( &item->gpuZoneBegin.context, ctx->GetId() );
397  }
398 
399  tracy_force_inline VkCtxScope( VkCtx* ctx, uint32_t line, const char* source, size_t sourceSz, const char* function, size_t functionSz, const char* name, size_t nameSz, VkCommandBuffer cmdbuf, int depth, bool is_active )
400 #ifdef TRACY_ON_DEMAND
401  : m_active( is_active && GetProfiler().IsConnected() )
402 #else
403  : m_active( is_active )
404 #endif
405  {
406  if( !m_active ) return;
407  m_cmdbuf = cmdbuf;
408  m_ctx = ctx;
409 
410  const auto queryId = ctx->NextQueryId();
411  vkCmdWriteTimestamp( cmdbuf, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, ctx->m_query, queryId );
412 
413  const auto srcloc = Profiler::AllocSourceLocation( line, source, sourceSz, function, functionSz, name, nameSz );
414  auto item = Profiler::QueueSerialCallstack( Callstack( depth ) );
415  MemWrite( &item->hdr.type, QueueType::GpuZoneBeginAllocSrcLocCallstackSerial );
416  MemWrite( &item->gpuZoneBegin.cpuTime, Profiler::GetTime() );
417  MemWrite( &item->gpuZoneBegin.srcloc, srcloc );
418  MemWrite( &item->gpuZoneBegin.thread, GetThreadHandle() );
419  MemWrite( &item->gpuZoneBegin.queryId, uint16_t( queryId ) );
420  MemWrite( &item->gpuZoneBegin.context, ctx->GetId() );
422  }
423 
424  tracy_force_inline ~VkCtxScope()
425  {
426  if( !m_active ) return;
427 
428  const auto queryId = m_ctx->NextQueryId();
429  vkCmdWriteTimestamp( m_cmdbuf, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, m_ctx->m_query, queryId );
430 
431  auto item = Profiler::QueueSerial();
432  MemWrite( &item->hdr.type, QueueType::GpuZoneEndSerial );
433  MemWrite( &item->gpuZoneEnd.cpuTime, Profiler::GetTime() );
434  MemWrite( &item->gpuZoneEnd.thread, GetThreadHandle() );
435  MemWrite( &item->gpuZoneEnd.queryId, uint16_t( queryId ) );
436  MemWrite( &item->gpuZoneEnd.context, m_ctx->GetId() );
438  }
439 
440 private:
441  const bool m_active;
442 
443  VkCommandBuffer m_cmdbuf;
444  VkCtx* m_ctx;
445 };
446 
447 static inline VkCtx* CreateVkContext( VkPhysicalDevice physdev, VkDevice device, VkQueue queue, VkCommandBuffer cmdbuf, PFN_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT gpdctd, PFN_vkGetCalibratedTimestampsEXT gct )
448 {
450  auto ctx = (VkCtx*)tracy_malloc( sizeof( VkCtx ) );
451  new(ctx) VkCtx( physdev, device, queue, cmdbuf, gpdctd, gct );
452  return ctx;
453 }
454 
455 static inline void DestroyVkContext( VkCtx* ctx )
456 {
457  ctx->~VkCtx();
458  tracy_free( ctx );
459 }
460 
461 }
462 
463 using TracyVkCtx = tracy::VkCtx*;
464 
465 #define TracyVkContext( physdev, device, queue, cmdbuf ) tracy::CreateVkContext( physdev, device, queue, cmdbuf, nullptr, nullptr );
466 #define TracyVkContextCalibrated( physdev, device, queue, cmdbuf, gpdctd, gct ) tracy::CreateVkContext( physdev, device, queue, cmdbuf, gpdctd, gct );
467 #define TracyVkDestroy( ctx ) tracy::DestroyVkContext( ctx );
468 #define TracyVkContextName( ctx, name, size ) ctx->Name( name, size );
469 #if defined TRACY_HAS_CALLSTACK && defined TRACY_CALLSTACK
470 # define TracyVkNamedZone( ctx, varname, cmdbuf, name, active ) static constexpr tracy::SourceLocationData TracyConcat(__tracy_gpu_source_location,__LINE__) { name, __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 }; tracy::VkCtxScope varname( ctx, &TracyConcat(__tracy_gpu_source_location,__LINE__), cmdbuf, TRACY_CALLSTACK, active );
471 # define TracyVkNamedZoneC( ctx, varname, cmdbuf, name, color, active ) static constexpr tracy::SourceLocationData TracyConcat(__tracy_gpu_source_location,__LINE__) { name, __FUNCTION__, __FILE__, (uint32_t)__LINE__, color }; tracy::VkCtxScope varname( ctx, &TracyConcat(__tracy_gpu_source_location,__LINE__), cmdbuf, TRACY_CALLSTACK, active );
472 # define TracyVkZone( ctx, cmdbuf, name ) TracyVkNamedZoneS( ctx, ___tracy_gpu_zone, cmdbuf, name, TRACY_CALLSTACK, true )
473 # define TracyVkZoneC( ctx, cmdbuf, name, color ) TracyVkNamedZoneCS( ctx, ___tracy_gpu_zone, cmdbuf, name, color, TRACY_CALLSTACK, true )
474 # define TracyVkZoneTransient( ctx, varname, cmdbuf, name, active ) TracyVkZoneTransientS( ctx, varname, cmdbuf, name, TRACY_CALLSTACK, active )
475 #else
476 # define TracyVkNamedZone( ctx, varname, cmdbuf, name, active ) static constexpr tracy::SourceLocationData TracyConcat(__tracy_gpu_source_location,__LINE__) { name, __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 }; tracy::VkCtxScope varname( ctx, &TracyConcat(__tracy_gpu_source_location,__LINE__), cmdbuf, active );
477 # define TracyVkNamedZoneC( ctx, varname, cmdbuf, name, color, active ) static constexpr tracy::SourceLocationData TracyConcat(__tracy_gpu_source_location,__LINE__) { name, __FUNCTION__, __FILE__, (uint32_t)__LINE__, color }; tracy::VkCtxScope varname( ctx, &TracyConcat(__tracy_gpu_source_location,__LINE__), cmdbuf, active );
478 # define TracyVkZone( ctx, cmdbuf, name ) TracyVkNamedZone( ctx, ___tracy_gpu_zone, cmdbuf, name, true )
479 # define TracyVkZoneC( ctx, cmdbuf, name, color ) TracyVkNamedZoneC( ctx, ___tracy_gpu_zone, cmdbuf, name, color, true )
480 # define TracyVkZoneTransient( ctx, varname, cmdbuf, name, active ) tracy::VkCtxScope varname( ctx, __LINE__, __FILE__, strlen( __FILE__ ), __FUNCTION__, strlen( __FUNCTION__ ), name, strlen( name ), cmdbuf, active );
481 #endif
482 #define TracyVkCollect( ctx, cmdbuf ) ctx->Collect( cmdbuf );
483 
484 #ifdef TRACY_HAS_CALLSTACK
485 # define TracyVkNamedZoneS( ctx, varname, cmdbuf, name, depth, active ) static constexpr tracy::SourceLocationData TracyConcat(__tracy_gpu_source_location,__LINE__) { name, __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 }; tracy::VkCtxScope varname( ctx, &TracyConcat(__tracy_gpu_source_location,__LINE__), cmdbuf, depth, active );
486 # define TracyVkNamedZoneCS( ctx, varname, cmdbuf, name, color, depth, active ) static constexpr tracy::SourceLocationData TracyConcat(__tracy_gpu_source_location,__LINE__) { name, __FUNCTION__, __FILE__, (uint32_t)__LINE__, color }; tracy::VkCtxScope varname( ctx, &TracyConcat(__tracy_gpu_source_location,__LINE__), cmdbuf, depth, active );
487 # define TracyVkZoneS( ctx, cmdbuf, name, depth ) TracyVkNamedZoneS( ctx, ___tracy_gpu_zone, cmdbuf, name, depth, true )
488 # define TracyVkZoneCS( ctx, cmdbuf, name, color, depth ) TracyVkNamedZoneCS( ctx, ___tracy_gpu_zone, cmdbuf, name, color, depth, true )
489 # define TracyVkZoneTransientS( ctx, varname, cmdbuf, name, depth, active ) tracy::VkCtxScope varname( ctx, __LINE__, __FILE__, strlen( __FILE__ ), __FUNCTION__, strlen( __FUNCTION__ ), name, strlen( name ), cmdbuf, depth, active );
490 #else
491 # define TracyVkNamedZoneS( ctx, varname, cmdbuf, name, depth, active ) TracyVkNamedZone( ctx, varname, cmdbuf, name, active )
492 # define TracyVkNamedZoneCS( ctx, varname, cmdbuf, name, color, depth, active ) TracyVkNamedZoneC( ctx, varname, cmdbuf, name, color, active )
493 # define TracyVkZoneS( ctx, cmdbuf, name, depth ) TracyVkZone( ctx, cmdbuf, name )
494 # define TracyVkZoneCS( ctx, cmdbuf, name, color, depth ) TracyVkZoneC( ctx, cmdbuf, name, color )
495 # define TracyVkZoneTransientS( ctx, varname, cmdbuf, name, depth, active ) TracyVkZoneTransient( ctx, varname, cmdbuf, name, active )
496 #endif
497 
498 #endif
499 
500 #endif


Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)