PIXEventsCommon.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  1. // Copyright (c) Microsoft Corporation.
  2. // Licensed under the MIT License.
  3. // Don't include this file directly - use pix3.h
  4. #pragma once
  5. #ifndef _PIXEventsCommon_H_
  6. #define _PIXEventsCommon_H_
  7. //
  8. // The PIXBeginEvent and PIXSetMarker functions have an optimized path for
  9. // copying strings that work by copying 128-bit or 64-bits at a time. In some
  10. // circumstances this may result in PIX logging the remaining memory after the
  11. // null terminator.
  12. //
  13. // By default this optimization is enabled unless Address Sanitizer is enabled,
  14. // since this optimization can trigger a global-buffer-overflow when copying
  15. // string literals.
  16. //
  17. // The PIX_ENABLE_BLOCK_ARGUMENT_COPY controls whether or not this optimization
  18. // is enabled. Applications may also explicitly set this macro to 0 to disable
  19. // the optimization if necessary.
  20. //
  21. // Check for Address Sanitizer on either Clang or MSVC
  22. #if defined(__has_feature)
  23. #if __has_feature(address_sanitizer)
  24. #define PIX_ASAN_ENABLED
  25. #endif
  26. #elif defined(__SANITIZE_ADDRESS__)
  27. #define PIX_ASAN_ENABLED
  28. #endif
  29. #if defined(PIX_ENABLE_BLOCK_ARGUMENT_COPY)
  30. // Previously set values override everything
  31. # define PIX_ENABLE_BLOCK_ARGUMENT_COPY_SET 0
  32. #elif defined(PIX_ASAN_ENABLED)
  33. // Disable block argument copy when address sanitizer is enabled
  34. #define PIX_ENABLE_BLOCK_ARGUMENT_COPY 0
  35. #define PIX_ENABLE_BLOCK_ARGUMENT_COPY_SET 1
  36. #endif
  37. #if !defined(PIX_ENABLE_BLOCK_ARGUMENT_COPY)
  38. // Default to enabled.
  39. #define PIX_ENABLE_BLOCK_ARGUMENT_COPY 1
  40. #define PIX_ENABLE_BLOCK_ARGUMENT_COPY_SET 1
  41. #endif
  42. struct PIXEventsBlockInfo;
  43. struct PIXEventsThreadInfo
  44. {
  45. PIXEventsBlockInfo* block;
  46. UINT64* biasedLimit;
  47. UINT64* destination;
  48. };
  49. extern "C" UINT64 WINAPI PIXEventsReplaceBlock(PIXEventsThreadInfo * threadInfo, bool getEarliestTime) noexcept;
  50. #define PIX_EVENT_METADATA_NONE 0x0
  51. #define PIX_EVENT_METADATA_ON_CONTEXT 0x1
  52. #define PIX_EVENT_METADATA_STRING_IS_ANSI 0x2
  53. #define PIX_EVENT_METADATA_HAS_COLOR 0xF0
  54. #ifndef PIX_GAMING_XBOX
  55. #include "PIXEventsLegacy.h"
  56. #endif
  57. enum PIXEventType : UINT8
  58. {
  59. PIXEvent_EndEvent = 0x00,
  60. PIXEvent_BeginEvent = 0x01,
  61. PIXEvent_SetMarker = 0x02,
  62. };
  63. static const UINT64 PIXEventsReservedRecordSpaceQwords = 64;
  64. //this is used to make sure SSE string copy always will end 16-byte write in the current block
  65. //this way only a check if destination < limit can be performed, instead of destination < limit - 1
  66. //since both these are UINT64* and SSE writes in 16 byte chunks, 8 bytes are kept in reserve
  67. //so even if SSE overwrites 8-15 extra bytes, those will still belong to the correct block
  68. //on next iteration check destination will be greater than limit
  69. //this is used as well for fixed size UMD events and PIXEndEvent since these require less space
  70. //than other variable length user events and do not need big reserved space
  71. static const UINT64 PIXEventsReservedTailSpaceQwords = 2;
  72. static const UINT64 PIXEventsSafeFastCopySpaceQwords = PIXEventsReservedRecordSpaceQwords - PIXEventsReservedTailSpaceQwords;
  73. static const UINT64 PIXEventsGraphicsRecordSpaceQwords = 64;
  74. //Bits 7-19 (13 bits)
  75. static const UINT64 PIXEventsBlockEndMarker = 0x00000000000FFF80;
  76. // V2 events
  77. // Bits 00..06 (7 bits) - Size in QWORDS
  78. static const UINT64 PIXEventsSizeWriteMask = 0x000000000000007F;
  79. static const UINT64 PIXEventsSizeBitShift = 0;
  80. static const UINT64 PIXEventsSizeReadMask = PIXEventsSizeWriteMask << PIXEventsSizeBitShift;
  81. static const UINT64 PIXEventsSizeMax = (1ull << 7) - 1ull;
  82. // Bits 07..11 (5 bits) - Event Type
  83. static const UINT64 PIXEventsTypeWriteMask = 0x000000000000001F;
  84. static const UINT64 PIXEventsTypeBitShift = 7;
  85. static const UINT64 PIXEventsTypeReadMask = PIXEventsTypeWriteMask << PIXEventsTypeBitShift;
  86. // Bits 12..19 (8 bits) - Event Specific Metadata
  87. static const UINT64 PIXEventsMetadataWriteMask = 0x00000000000000FF;
  88. static const UINT64 PIXEventsMetadataBitShift = 12;
  89. static const UINT64 PIXEventsMetadataReadMask = PIXEventsMetadataWriteMask << PIXEventsMetadataBitShift;
  90. // Buts 20..63 (44 bits) - Timestamp
  91. static const UINT64 PIXEventsTimestampWriteMask = 0x00000FFFFFFFFFFF;
  92. static const UINT64 PIXEventsTimestampBitShift = 20;
  93. static const UINT64 PIXEventsTimestampReadMask = PIXEventsTimestampWriteMask << PIXEventsTimestampBitShift;
  94. inline UINT64 PIXEncodeEventInfo(UINT64 timestamp, PIXEventType eventType, UINT8 eventSize, UINT8 eventMetadata)
  95. {
  96. return
  97. ((timestamp & PIXEventsTimestampWriteMask) << PIXEventsTimestampBitShift) |
  98. (((UINT64)eventType & PIXEventsTypeWriteMask) << PIXEventsTypeBitShift) |
  99. (((UINT64)eventMetadata & PIXEventsMetadataWriteMask) << PIXEventsMetadataBitShift) |
  100. (((UINT64)eventSize & PIXEventsSizeWriteMask) << PIXEventsSizeBitShift);
  101. }
  102. inline UINT8 PIXEncodeIndexColor(UINT8 color)
  103. {
  104. // There are 8 index colors, indexed 0 (default) to 7
  105. return (color & 0x7) << 4;
  106. }
  107. //Bits 60-63 (4)
  108. static const UINT64 PIXEventsStringAlignmentWriteMask = 0x000000000000000F;
  109. static const UINT64 PIXEventsStringAlignmentReadMask = 0xF000000000000000;
  110. static const UINT64 PIXEventsStringAlignmentBitShift = 60;
  111. //Bits 55-59 (5)
  112. static const UINT64 PIXEventsStringCopyChunkSizeWriteMask = 0x000000000000001F;
  113. static const UINT64 PIXEventsStringCopyChunkSizeReadMask = 0x0F80000000000000;
  114. static const UINT64 PIXEventsStringCopyChunkSizeBitShift = 55;
  115. //Bit 54
  116. static const UINT64 PIXEventsStringIsANSIWriteMask = 0x0000000000000001;
  117. static const UINT64 PIXEventsStringIsANSIReadMask = 0x0040000000000000;
  118. static const UINT64 PIXEventsStringIsANSIBitShift = 54;
  119. //Bit 53
  120. static const UINT64 PIXEventsStringIsShortcutWriteMask = 0x0000000000000001;
  121. static const UINT64 PIXEventsStringIsShortcutReadMask = 0x0020000000000000;
  122. static const UINT64 PIXEventsStringIsShortcutBitShift = 53;
  123. inline void PIXEncodeStringInfo(UINT64*& destination, BOOL isANSI)
  124. {
  125. const UINT64 encodedStringInfo =
  126. ((sizeof(UINT64) & PIXEventsStringCopyChunkSizeWriteMask) << PIXEventsStringCopyChunkSizeBitShift) |
  127. (((UINT64)isANSI & PIXEventsStringIsANSIWriteMask) << PIXEventsStringIsANSIBitShift);
  128. *destination++ = encodedStringInfo;
  129. }
  130. template<UINT alignment, class T>
  131. inline bool PIXIsPointerAligned(T* pointer)
  132. {
  133. return !(((UINT64)pointer) & (alignment - 1));
  134. }
  135. // Generic template version slower because of the additional clear write
  136. template<class T>
  137. inline void PIXCopyEventArgument(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, T argument)
  138. {
  139. if (destination < limit)
  140. {
  141. *destination = 0ull;
  142. *((T*)destination) = argument;
  143. ++destination;
  144. }
  145. }
  146. // int32 specialization to avoid slower double memory writes
  147. template<>
  148. inline void PIXCopyEventArgument<INT32>(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, INT32 argument)
  149. {
  150. if (destination < limit)
  151. {
  152. *reinterpret_cast<INT64*>(destination) = static_cast<INT64>(argument);
  153. ++destination;
  154. }
  155. }
  156. // unsigned int32 specialization to avoid slower double memory writes
  157. template<>
  158. inline void PIXCopyEventArgument<UINT32>(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, UINT32 argument)
  159. {
  160. if (destination < limit)
  161. {
  162. *destination = static_cast<UINT64>(argument);
  163. ++destination;
  164. }
  165. }
  166. // int64 specialization to avoid slower double memory writes
  167. template<>
  168. inline void PIXCopyEventArgument<INT64>(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, INT64 argument)
  169. {
  170. if (destination < limit)
  171. {
  172. *reinterpret_cast<INT64*>(destination) = argument;
  173. ++destination;
  174. }
  175. }
  176. // unsigned int64 specialization to avoid slower double memory writes
  177. template<>
  178. inline void PIXCopyEventArgument<UINT64>(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, UINT64 argument)
  179. {
  180. if (destination < limit)
  181. {
  182. *destination = argument;
  183. ++destination;
  184. }
  185. }
  186. //floats must be cast to double during writing the data to be properly printed later when reading the data
  187. //this is needed because when float is passed to varargs function it's cast to double
  188. template<>
  189. inline void PIXCopyEventArgument<float>(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, float argument)
  190. {
  191. if (destination < limit)
  192. {
  193. *reinterpret_cast<double*>(destination) = static_cast<double>(argument);
  194. ++destination;
  195. }
  196. }
  197. //char has to be cast to a longer signed integer type
  198. //this is due to printf not ignoring correctly the upper bits of unsigned long long for a char format specifier
  199. template<>
  200. inline void PIXCopyEventArgument<char>(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, char argument)
  201. {
  202. if (destination < limit)
  203. {
  204. *reinterpret_cast<INT64*>(destination) = static_cast<INT64>(argument);
  205. ++destination;
  206. }
  207. }
  208. //UINT8 has to be cast to a longer unsigned integer type
  209. //this is due to printf not ignoring correctly the upper bits of unsigned long long for a char format specifier
  210. template<>
  211. inline void PIXCopyEventArgument<UINT8>(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, UINT8 argument)
  212. {
  213. if (destination < limit)
  214. {
  215. *destination = static_cast<UINT64>(argument);
  216. ++destination;
  217. }
  218. }
  219. //bool has to be cast to an integer since it's not explicitly supported by string format routines
  220. //there's no format specifier for bool type, but it should work with integer format specifiers
  221. template<>
  222. inline void PIXCopyEventArgument<bool>(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, bool argument)
  223. {
  224. if (destination < limit)
  225. {
  226. *destination = static_cast<UINT64>(argument);
  227. ++destination;
  228. }
  229. }
  230. inline void PIXCopyEventStringArgumentSlow(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, _In_ PCSTR argument)
  231. {
  232. while (destination < limit)
  233. {
  234. UINT64 c = static_cast<UINT8>(argument[0]);
  235. if (!c)
  236. {
  237. *destination++ = 0;
  238. return;
  239. }
  240. UINT64 x = c;
  241. c = static_cast<UINT8>(argument[1]);
  242. if (!c)
  243. {
  244. *destination++ = x;
  245. return;
  246. }
  247. x |= c << 8;
  248. c = static_cast<UINT8>(argument[2]);
  249. if (!c)
  250. {
  251. *destination++ = x;
  252. return;
  253. }
  254. x |= c << 16;
  255. c = static_cast<UINT8>(argument[3]);
  256. if (!c)
  257. {
  258. *destination++ = x;
  259. return;
  260. }
  261. x |= c << 24;
  262. c = static_cast<UINT8>(argument[4]);
  263. if (!c)
  264. {
  265. *destination++ = x;
  266. return;
  267. }
  268. x |= c << 32;
  269. c = static_cast<UINT8>(argument[5]);
  270. if (!c)
  271. {
  272. *destination++ = x;
  273. return;
  274. }
  275. x |= c << 40;
  276. c = static_cast<UINT8>(argument[6]);
  277. if (!c)
  278. {
  279. *destination++ = x;
  280. return;
  281. }
  282. x |= c << 48;
  283. c = static_cast<UINT8>(argument[7]);
  284. if (!c)
  285. {
  286. *destination++ = x;
  287. return;
  288. }
  289. x |= c << 56;
  290. *destination++ = x;
  291. argument += 8;
  292. }
  293. }
  294. template<bool>
  295. inline void PIXCopyEventArgumentSlow(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, _In_ PCSTR argument)
  296. {
  297. PIXEncodeStringInfo(destination, TRUE);
  298. PIXCopyEventStringArgumentSlow(destination, limit, argument);
  299. }
  300. template<>
  301. inline void PIXCopyEventArgumentSlow<false>(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, _In_ PCSTR argument)
  302. {
  303. PIXCopyEventStringArgumentSlow(destination, limit, argument);
  304. }
  305. #if (defined(_M_X64) || defined(_M_IX86)) && PIX_ENABLE_BLOCK_ARGUMENT_COPY
  306. inline void PIXCopyEventStringArgumentFast(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, _In_ PCSTR argument)
  307. {
  308. constexpr UINT64 mask1 = 0x0101010101010101ULL;
  309. constexpr UINT64 mask2 = 0x8080808080808080ULL;
  310. UINT64* source = (UINT64*)argument;
  311. while (destination < limit)
  312. {
  313. UINT64 qword = *source++;
  314. *destination++ = qword;
  315. //check if any of the characters is a terminating zero
  316. UINT64 isTerminated = (qword - mask1) & (~qword & mask2);
  317. if (isTerminated)
  318. {
  319. break;
  320. }
  321. }
  322. }
  323. #endif
  324. template<>
  325. inline void PIXCopyEventArgument<PCSTR>(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, _In_ PCSTR argument)
  326. {
  327. if (destination < limit)
  328. {
  329. if (argument != nullptr)
  330. {
  331. #if (defined(_M_X64) || defined(_M_IX86)) && PIX_ENABLE_BLOCK_ARGUMENT_COPY
  332. if (PIXIsPointerAligned<8>(argument))
  333. {
  334. PIXEncodeStringInfo(destination, TRUE);
  335. PIXCopyEventStringArgumentFast(destination, limit, argument);
  336. }
  337. else
  338. #endif // (defined(_M_X64) || defined(_M_IX86)) && PIX_ENABLE_BLOCK_ARGUMENT_COPY
  339. {
  340. PIXCopyEventArgumentSlow<true>(destination, limit, argument);
  341. }
  342. }
  343. else
  344. {
  345. *destination++ = 0ull;
  346. }
  347. }
  348. }
  349. inline void PIXCopyStringArgument(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, _In_ PCSTR argument)
  350. {
  351. if (argument != nullptr)
  352. {
  353. #if (defined(_M_X64) || defined(_M_IX86)) && PIX_ENABLE_BLOCK_ARGUMENT_COPY
  354. if (PIXIsPointerAligned<8>(argument))
  355. {
  356. PIXCopyEventStringArgumentFast(destination, limit, argument);
  357. }
  358. else
  359. #endif // (defined(_M_X64) || defined(_M_IX86)) && PIX_ENABLE_BLOCK_ARGUMENT_COPY
  360. {
  361. PIXCopyEventArgumentSlow<false>(destination, limit, argument);
  362. }
  363. }
  364. else
  365. {
  366. *destination++ = 0ull;
  367. }
  368. }
  369. template<>
  370. inline void PIXCopyEventArgument<PSTR>(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, _In_ PSTR argument)
  371. {
  372. PIXCopyEventArgument(destination, limit, (PCSTR)argument);
  373. }
  374. inline void PIXCopyStringArgument(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, _In_ PSTR argument)
  375. {
  376. PIXCopyStringArgument(destination, limit, (PCSTR)argument);
  377. }
  378. inline void PIXCopyEventStringArgumentSlow(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, _In_ PCWSTR argument)
  379. {
  380. while (destination < limit)
  381. {
  382. UINT64 c = static_cast<UINT16>(argument[0]);
  383. if (!c)
  384. {
  385. *destination++ = 0;
  386. return;
  387. }
  388. UINT64 x = c;
  389. c = static_cast<UINT16>(argument[1]);
  390. if (!c)
  391. {
  392. *destination++ = x;
  393. return;
  394. }
  395. x |= c << 16;
  396. c = static_cast<UINT16>(argument[2]);
  397. if (!c)
  398. {
  399. *destination++ = x;
  400. return;
  401. }
  402. x |= c << 32;
  403. c = static_cast<UINT16>(argument[3]);
  404. if (!c)
  405. {
  406. *destination++ = x;
  407. return;
  408. }
  409. x |= c << 48;
  410. *destination++ = x;
  411. argument += 4;
  412. }
  413. }
  414. template<bool>
  415. inline void PIXCopyEventArgumentSlow(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, _In_ PCWSTR argument)
  416. {
  417. PIXEncodeStringInfo(destination, FALSE);
  418. PIXCopyEventStringArgumentSlow(destination, limit, argument);
  419. }
  420. template<>
  421. inline void PIXCopyEventArgumentSlow<false>(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, _In_ PCWSTR argument)
  422. {
  423. PIXCopyEventStringArgumentSlow(destination, limit, argument);
  424. }
  425. #if (defined(_M_X64) || defined(_M_IX86)) && PIX_ENABLE_BLOCK_ARGUMENT_COPY
  426. inline void PIXCopyEventStringArgumentFast(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, _In_ PCWSTR argument)
  427. {
  428. UINT64* source = (UINT64*)argument;
  429. while (destination < limit)
  430. {
  431. UINT64 qword = *source++;
  432. *destination++ = qword;
  433. //check if any of the characters is a terminating zero
  434. //TODO: check if reversed condition is faster
  435. if (!((qword & 0xFFFF000000000000) &&
  436. (qword & 0xFFFF00000000) &&
  437. (qword & 0xFFFF0000) &&
  438. (qword & 0xFFFF)))
  439. {
  440. break;
  441. }
  442. }
  443. }
  444. #endif
  445. template<>
  446. inline void PIXCopyEventArgument<PCWSTR>(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, _In_ PCWSTR argument)
  447. {
  448. if (destination < limit)
  449. {
  450. if (argument != nullptr)
  451. {
  452. #if (defined(_M_X64) || defined(_M_IX86)) && PIX_ENABLE_BLOCK_ARGUMENT_COPY
  453. if (PIXIsPointerAligned<8>(argument))
  454. {
  455. PIXEncodeStringInfo(destination, FALSE);
  456. PIXCopyEventStringArgumentFast(destination, limit, argument);
  457. }
  458. else
  459. #endif // (defined(_M_X64) || defined(_M_IX86)) && PIX_ENABLE_BLOCK_ARGUMENT_COPY
  460. {
  461. PIXCopyEventArgumentSlow<true>(destination, limit, argument);
  462. }
  463. }
  464. else
  465. {
  466. *destination++ = 0ull;
  467. }
  468. }
  469. }
  470. inline void PIXCopyStringArgument(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, _In_ PCWSTR argument)
  471. {
  472. if (argument != nullptr)
  473. {
  474. #if (defined(_M_X64) || defined(_M_IX86)) && PIX_ENABLE_BLOCK_ARGUMENT_COPY
  475. if (PIXIsPointerAligned<8>(argument))
  476. {
  477. PIXCopyEventStringArgumentFast(destination, limit, argument);
  478. }
  479. else
  480. #endif // (defined(_M_X64) || defined(_M_IX86)) && PIX_ENABLE_BLOCK_ARGUMENT_COPY
  481. {
  482. PIXCopyEventArgumentSlow<false>(destination, limit, argument);
  483. }
  484. }
  485. else
  486. {
  487. *destination++ = 0ull;
  488. }
  489. }
  490. template<>
  491. inline void PIXCopyEventArgument<PWSTR>(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, _In_ PWSTR argument)
  492. {
  493. PIXCopyEventArgument(destination, limit, (PCWSTR)argument);
  494. };
  495. inline void PIXCopyStringArgument(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, _In_ PWSTR argument)
  496. {
  497. PIXCopyStringArgument(destination, limit, (PCWSTR)argument);
  498. };
  499. #if defined(__d3d12_x_h__) || defined(__d3d12_xs_h__) || defined(__d3d12_h__)
  500. inline void PIXSetGPUMarkerOnContext(_In_ ID3D12GraphicsCommandList* commandList, _In_reads_bytes_(size) void* data, UINT size)
  501. {
  502. commandList->SetMarker(D3D12_EVENT_METADATA, data, size);
  503. }
  504. inline void PIXSetGPUMarkerOnContext(_In_ ID3D12CommandQueue* commandQueue, _In_reads_bytes_(size) void* data, UINT size)
  505. {
  506. commandQueue->SetMarker(D3D12_EVENT_METADATA, data, size);
  507. }
  508. inline void PIXBeginGPUEventOnContext(_In_ ID3D12GraphicsCommandList* commandList, _In_reads_bytes_(size) void* data, UINT size)
  509. {
  510. commandList->BeginEvent(D3D12_EVENT_METADATA, data, size);
  511. }
  512. inline void PIXBeginGPUEventOnContext(_In_ ID3D12CommandQueue* commandQueue, _In_reads_bytes_(size) void* data, UINT size)
  513. {
  514. commandQueue->BeginEvent(D3D12_EVENT_METADATA, data, size);
  515. }
  516. inline void PIXEndGPUEventOnContext(_In_ ID3D12GraphicsCommandList* commandList)
  517. {
  518. commandList->EndEvent();
  519. }
  520. inline void PIXEndGPUEventOnContext(_In_ ID3D12CommandQueue* commandQueue)
  521. {
  522. commandQueue->EndEvent();
  523. }
  524. #endif //__d3d12_h__
  525. template<class T> struct PIXInferScopedEventType { typedef T Type; };
  526. template<class T> struct PIXInferScopedEventType<const T> { typedef T Type; };
  527. template<class T> struct PIXInferScopedEventType<T*> { typedef T Type; };
  528. template<class T> struct PIXInferScopedEventType<T* const> { typedef T Type; };
  529. template<> struct PIXInferScopedEventType<UINT64> { typedef void Type; };
  530. template<> struct PIXInferScopedEventType<const UINT64> { typedef void Type; };
  531. template<> struct PIXInferScopedEventType<INT64> { typedef void Type; };
  532. template<> struct PIXInferScopedEventType<const INT64> { typedef void Type; };
  533. template<> struct PIXInferScopedEventType<UINT> { typedef void Type; };
  534. template<> struct PIXInferScopedEventType<const UINT> { typedef void Type; };
  535. template<> struct PIXInferScopedEventType<INT> { typedef void Type; };
  536. template<> struct PIXInferScopedEventType<const INT> { typedef void Type; };
  537. template<> struct PIXInferScopedEventType<UINT8> { typedef void Type; };
  538. template<> struct PIXInferScopedEventType<const UINT8> { typedef void Type; };
  539. template<> struct PIXInferScopedEventType<INT8> { typedef void Type; };
  540. template<> struct PIXInferScopedEventType<const INT8> { typedef void Type; };
  541. #endif //_PIXEventsCommon_H_