DxilConstants.h 52 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // //
  3. // DxilConstants.h //
  4. // Copyright (C) Microsoft Corporation. All rights reserved. //
  5. // This file is distributed under the University of Illinois Open Source //
  6. // License. See LICENSE.TXT for details. //
  7. // //
  8. // Essential DXIL constants. //
  9. // //
  10. ///////////////////////////////////////////////////////////////////////////////
  11. #pragma once
  12. #include <stdint.h>
  13. namespace hlsl {
  14. /* <py>
  15. import hctdb_instrhelp
  16. </py> */
  17. // TODO:
  18. // 2. get rid of DXIL namespace.
  19. // 3. use class enum for shader flags.
  20. // 4. use class enum for address spaces.
  21. namespace DXIL {
  22. // DXIL version.
  23. const unsigned kDxilMajor = 1;
  24. /* <py::lines('VALRULE-TEXT')>hctdb_instrhelp.get_dxil_version_minor()</py>*/
  25. // VALRULE-TEXT:BEGIN
  26. const unsigned kDxilMinor = 6;
  27. // VALRULE-TEXT:END
  28. inline unsigned MakeDxilVersion(unsigned DxilMajor, unsigned DxilMinor) {
  29. return 0 | (DxilMajor << 8) | (DxilMinor);
  30. }
  31. inline unsigned GetCurrentDxilVersion() { return MakeDxilVersion(kDxilMajor, kDxilMinor); }
  32. inline unsigned GetDxilVersionMajor(unsigned DxilVersion) { return (DxilVersion >> 8) & 0xFF; }
  33. inline unsigned GetDxilVersionMinor(unsigned DxilVersion) { return DxilVersion & 0xFF; }
  34. // Return positive if v1 > v2, negative if v1 < v2, zero if equal
  35. inline int CompareVersions(unsigned Major1, unsigned Minor1, unsigned Major2, unsigned Minor2) {
  36. if (Major1 != Major2) {
  37. // Special case for Major == 0 (latest/unbound)
  38. if (Major1 == 0 || Major2 == 0) return Major1 > 0 ? -1 : 1;
  39. return Major1 < Major2 ? -1 : 1;
  40. }
  41. if (Minor1 < Minor2) return -1;
  42. if (Minor1 > Minor2) return 1;
  43. return 0;
  44. }
  45. // Shader flags.
  46. const unsigned kDisableOptimizations = 0x00000001; // D3D11_1_SB_GLOBAL_FLAG_SKIP_OPTIMIZATION
  47. const unsigned kDisableMathRefactoring = 0x00000002; //~D3D10_SB_GLOBAL_FLAG_REFACTORING_ALLOWED
  48. const unsigned kEnableDoublePrecision = 0x00000004; // D3D11_SB_GLOBAL_FLAG_ENABLE_DOUBLE_PRECISION_FLOAT_OPS
  49. const unsigned kForceEarlyDepthStencil = 0x00000008; // D3D11_SB_GLOBAL_FLAG_FORCE_EARLY_DEPTH_STENCIL
  50. const unsigned kEnableRawAndStructuredBuffers = 0x00000010; // D3D11_SB_GLOBAL_FLAG_ENABLE_RAW_AND_STRUCTURED_BUFFERS
  51. const unsigned kEnableMinPrecision = 0x00000020; // D3D11_1_SB_GLOBAL_FLAG_ENABLE_MINIMUM_PRECISION
  52. const unsigned kEnableDoubleExtensions = 0x00000040; // D3D11_1_SB_GLOBAL_FLAG_ENABLE_DOUBLE_EXTENSIONS
  53. const unsigned kEnableMSAD = 0x00000080; // D3D11_1_SB_GLOBAL_FLAG_ENABLE_SHADER_EXTENSIONS
  54. const unsigned kAllResourcesBound = 0x00000100; // D3D12_SB_GLOBAL_FLAG_ALL_RESOURCES_BOUND
  55. const unsigned kNumOutputStreams = 4;
  56. const unsigned kNumClipPlanes = 6;
  57. // TODO: move these to appropriate places (ShaderModel.cpp?)
  58. const unsigned kMaxTempRegCount = 4096; // DXBC only
  59. const unsigned kMaxCBufferSize = 4096;
  60. const unsigned kMaxStructBufferStride = 2048;
  61. const unsigned kMaxHSOutputControlPointsTotalScalars = 3968;
  62. const unsigned kMaxHSOutputPatchConstantTotalScalars = 32*4;
  63. const unsigned kMaxSignatureTotalVectors = 32;
  64. const unsigned kMaxOutputTotalScalars = kMaxSignatureTotalVectors * 4;
  65. const unsigned kMaxInputTotalScalars = kMaxSignatureTotalVectors * 4;
  66. const unsigned kMaxClipOrCullDistanceElementCount = 2;
  67. const unsigned kMaxClipOrCullDistanceCount = 2 * 4;
  68. const unsigned kMaxGSOutputVertexCount = 1024;
  69. const unsigned kMaxGSInstanceCount = 32;
  70. const unsigned kMaxIAPatchControlPointCount = 32;
  71. const float kHSMaxTessFactorLowerBound = 1.0f;
  72. const float kHSMaxTessFactorUpperBound = 64.0f;
  73. const unsigned kHSDefaultInputControlPointCount = 1;
  74. const unsigned kMaxCSThreadsPerGroup = 1024;
  75. const unsigned kMaxCSThreadGroupX = 1024;
  76. const unsigned kMaxCSThreadGroupY = 1024;
  77. const unsigned kMaxCSThreadGroupZ = 64;
  78. const unsigned kMinCSThreadGroupX = 1;
  79. const unsigned kMinCSThreadGroupY = 1;
  80. const unsigned kMinCSThreadGroupZ = 1;
  81. const unsigned kMaxCS4XThreadsPerGroup = 768;
  82. const unsigned kMaxCS4XThreadGroupX = 768;
  83. const unsigned kMaxCS4XThreadGroupY = 768;
  84. const unsigned kMaxTGSMSize = 8192*4;
  85. const unsigned kMaxGSOutputTotalScalars = 1024;
  86. const unsigned kMaxMSASThreadsPerGroup = 128;
  87. const unsigned kMaxMSASThreadGroupX = 128;
  88. const unsigned kMaxMSASThreadGroupY = 128;
  89. const unsigned kMaxMSASThreadGroupZ = 128;
  90. const unsigned kMinMSASThreadGroupX = 1;
  91. const unsigned kMinMSASThreadGroupY = 1;
  92. const unsigned kMinMSASThreadGroupZ = 1;
  93. const unsigned kMaxMSASPayloadBytes = 1024 * 16;
  94. const unsigned kMaxMSOutputPrimitiveCount = 256;
  95. const unsigned kMaxMSOutputVertexCount = 256;
  96. const unsigned kMaxMSOutputTotalBytes = 1024 * 32;
  97. const unsigned kMaxMSInputOutputTotalBytes = 1024 * 47;
  98. const unsigned kMaxMSVSigRows = 32;
  99. const unsigned kMaxMSPSigRows = 32;
  100. const unsigned kMaxMSTotalSigRows = 32;
  101. const unsigned kMaxMSSMSize = 1024 * 28;
  102. const float kMaxMipLodBias = 15.99f;
  103. const float kMinMipLodBias = -16.0f;
  104. const unsigned kResRetStatusIndex = 4;
  105. enum class ComponentType : uint32_t {
  106. Invalid = 0,
  107. I1, I16, U16, I32, U32, I64, U64,
  108. F16, F32, F64,
  109. SNormF16, UNormF16, SNormF32, UNormF32, SNormF64, UNormF64,
  110. LastEntry };
  111. // Must match D3D_INTERPOLATION_MODE
  112. enum class InterpolationMode : uint8_t {
  113. Undefined = 0,
  114. Constant = 1,
  115. Linear = 2,
  116. LinearCentroid = 3,
  117. LinearNoperspective = 4,
  118. LinearNoperspectiveCentroid = 5,
  119. LinearSample = 6,
  120. LinearNoperspectiveSample = 7,
  121. Invalid = 8
  122. };
  123. // size of each scalar type in signature element in bits
  124. enum class SignatureDataWidth : uint8_t {
  125. Undefined = 0,
  126. Bits16 = 16,
  127. Bits32 = 32,
  128. };
  129. enum class SignatureKind {
  130. Invalid = 0,
  131. Input,
  132. Output,
  133. PatchConstOrPrim,
  134. };
  135. // Must match D3D11_SHADER_VERSION_TYPE
  136. enum class ShaderKind {
  137. Pixel = 0,
  138. Vertex,
  139. Geometry,
  140. Hull,
  141. Domain,
  142. Compute,
  143. Library,
  144. RayGeneration,
  145. Intersection,
  146. AnyHit,
  147. ClosestHit,
  148. Miss,
  149. Callable,
  150. Mesh,
  151. Amplification,
  152. Invalid,
  153. };
  154. /* <py::lines('SemanticKind-ENUM')>hctdb_instrhelp.get_enum_decl("SemanticKind", hide_val=True, sort_val=False)</py>*/
  155. // SemanticKind-ENUM:BEGIN
  156. // Semantic kind; Arbitrary or specific system value.
  157. enum class SemanticKind : unsigned {
  158. Arbitrary,
  159. VertexID,
  160. InstanceID,
  161. Position,
  162. RenderTargetArrayIndex,
  163. ViewPortArrayIndex,
  164. ClipDistance,
  165. CullDistance,
  166. OutputControlPointID,
  167. DomainLocation,
  168. PrimitiveID,
  169. GSInstanceID,
  170. SampleIndex,
  171. IsFrontFace,
  172. Coverage,
  173. InnerCoverage,
  174. Target,
  175. Depth,
  176. DepthLessEqual,
  177. DepthGreaterEqual,
  178. StencilRef,
  179. DispatchThreadID,
  180. GroupID,
  181. GroupIndex,
  182. GroupThreadID,
  183. TessFactor,
  184. InsideTessFactor,
  185. ViewID,
  186. Barycentrics,
  187. ShadingRate,
  188. CullPrimitive,
  189. Invalid,
  190. };
  191. // SemanticKind-ENUM:END
  192. /* <py::lines('SigPointKind-ENUM')>hctdb_instrhelp.get_enum_decl("SigPointKind", hide_val=True, sort_val=False)</py>*/
  193. // SigPointKind-ENUM:BEGIN
  194. // Signature Point is more specific than shader stage or signature as it is unique in both stage and item dimensionality or frequency.
  195. enum class SigPointKind : unsigned {
  196. VSIn, // Ordinary Vertex Shader input from Input Assembler
  197. VSOut, // Ordinary Vertex Shader output that may feed Rasterizer
  198. PCIn, // Patch Constant function non-patch inputs
  199. HSIn, // Hull Shader function non-patch inputs
  200. HSCPIn, // Hull Shader patch inputs - Control Points
  201. HSCPOut, // Hull Shader function output - Control Point
  202. PCOut, // Patch Constant function output - Patch Constant data passed to Domain Shader
  203. DSIn, // Domain Shader regular input - Patch Constant data plus system values
  204. DSCPIn, // Domain Shader patch input - Control Points
  205. DSOut, // Domain Shader output - vertex data that may feed Rasterizer
  206. GSVIn, // Geometry Shader vertex input - qualified with primitive type
  207. GSIn, // Geometry Shader non-vertex inputs (system values)
  208. GSOut, // Geometry Shader output - vertex data that may feed Rasterizer
  209. PSIn, // Pixel Shader input
  210. PSOut, // Pixel Shader output
  211. CSIn, // Compute Shader input
  212. MSIn, // Mesh Shader input
  213. MSOut, // Mesh Shader vertices output
  214. MSPOut, // Mesh Shader primitives output
  215. ASIn, // Amplification Shader input
  216. Invalid,
  217. };
  218. // SigPointKind-ENUM:END
  219. /* <py::lines('SemanticInterpretationKind-ENUM')>hctdb_instrhelp.get_enum_decl("SemanticInterpretationKind", hide_val=True, sort_val=False)</py>*/
  220. // SemanticInterpretationKind-ENUM:BEGIN
  221. // Defines how a semantic is interpreted at a particular SignaturePoint
  222. enum class SemanticInterpretationKind : unsigned {
  223. NA, // Not Available
  224. SV, // Normal System Value
  225. SGV, // System Generated Value (sorted last)
  226. Arb, // Treated as Arbitrary
  227. NotInSig, // Not included in signature (intrinsic access)
  228. NotPacked, // Included in signature, but does not contribute to packing
  229. Target, // Special handling for SV_Target
  230. TessFactor, // Special handling for tessellation factors
  231. Shadow, // Shadow element must be added to a signature for compatibility
  232. ClipCull, // Special packing rules for SV_ClipDistance or SV_CullDistance
  233. Invalid,
  234. };
  235. // SemanticInterpretationKind-ENUM:END
  236. /* <py::lines('PackingKind-ENUM')>hctdb_instrhelp.get_enum_decl("PackingKind", hide_val=True, sort_val=False)</py>*/
  237. // PackingKind-ENUM:BEGIN
  238. // Kind of signature point
  239. enum class PackingKind : unsigned {
  240. None, // No packing should be performed
  241. InputAssembler, // Vertex Shader input from Input Assembler
  242. Vertex, // Vertex that may feed the Rasterizer
  243. PatchConstant, // Patch constant signature
  244. Target, // Render Target (Pixel Shader Output)
  245. Invalid,
  246. };
  247. // PackingKind-ENUM:END
  248. /* <py::lines('FPDenormMode-ENUM')>hctdb_instrhelp.get_enum_decl("Float32DenormMode", hide_val=False, sort_val=False)</py>*/
  249. // FPDenormMode-ENUM:BEGIN
  250. // float32 denorm behavior
  251. enum class Float32DenormMode : unsigned {
  252. Any = 0, // Undefined behavior for denormal numbers
  253. Preserve = 1, // Preserve both input and output
  254. FTZ = 2, // Preserve denormal inputs. Flush denorm outputs
  255. Reserve3 = 3, // Reserved Value. Not used for now
  256. Reserve4 = 4, // Reserved Value. Not used for now
  257. Reserve5 = 5, // Reserved Value. Not used for now
  258. Reserve6 = 6, // Reserved Value. Not used for now
  259. Reserve7 = 7, // Reserved Value. Not used for now
  260. };
  261. // FPDenormMode-ENUM:END
  262. enum class PackingStrategy : unsigned {
  263. Default = 0, // Choose default packing algorithm based on target (currently PrefixStable)
  264. PrefixStable, // Maintain assumption that all elements are packed in order and stable as new elements are added.
  265. Optimized, // Optimize packing of all elements together (all elements must be present, in the same order, for identical placement of any individual element)
  266. Invalid,
  267. };
  268. enum class DefaultLinkage : unsigned {
  269. Default = 0,
  270. Internal = 1,
  271. External = 2,
  272. };
  273. enum class SamplerKind : unsigned {
  274. Default = 0,
  275. Comparison,
  276. Mono,
  277. Invalid,
  278. };
  279. enum class ResourceClass {
  280. SRV = 0,
  281. UAV,
  282. CBuffer,
  283. Sampler,
  284. Invalid
  285. };
  286. enum class ResourceKind : unsigned {
  287. Invalid = 0,
  288. Texture1D,
  289. Texture2D,
  290. Texture2DMS,
  291. Texture3D,
  292. TextureCube,
  293. Texture1DArray,
  294. Texture2DArray,
  295. Texture2DMSArray,
  296. TextureCubeArray,
  297. TypedBuffer,
  298. RawBuffer,
  299. StructuredBuffer,
  300. CBuffer,
  301. Sampler,
  302. TBuffer,
  303. RTAccelerationStructure,
  304. FeedbackTexture2D,
  305. FeedbackTexture2DArray,
  306. StructuredBufferWithCounter,
  307. SamplerComparison,
  308. NumEntries,
  309. };
  310. inline bool IsAnyTexture(DXIL::ResourceKind ResourceKind) {
  311. return DXIL::ResourceKind::Texture1D <= ResourceKind &&
  312. ResourceKind <= DXIL::ResourceKind::TextureCubeArray;
  313. }
  314. inline bool IsStructuredBuffer(DXIL::ResourceKind ResourceKind) {
  315. return ResourceKind == DXIL::ResourceKind::StructuredBuffer ||
  316. ResourceKind == DXIL::ResourceKind::StructuredBufferWithCounter;
  317. }
  318. inline bool IsTypedBuffer(DXIL::ResourceKind ResourceKind) {
  319. return ResourceKind == DXIL::ResourceKind::TypedBuffer;
  320. }
  321. inline bool IsTyped(DXIL::ResourceKind ResourceKind) {
  322. return IsTypedBuffer(ResourceKind) || IsAnyTexture(ResourceKind);
  323. }
  324. inline bool IsRawBuffer(DXIL::ResourceKind ResourceKind) {
  325. return ResourceKind == DXIL::ResourceKind::RawBuffer;
  326. }
  327. inline bool IsTBuffer(DXIL::ResourceKind ResourceKind) {
  328. return ResourceKind == DXIL::ResourceKind::TBuffer;
  329. }
  330. inline bool IsFeedbackTexture(DXIL::ResourceKind ResourceKind) {
  331. return ResourceKind == DXIL::ResourceKind::FeedbackTexture2D ||
  332. ResourceKind == DXIL::ResourceKind::FeedbackTexture2DArray;
  333. }
  334. // TODO: change opcodes.
  335. /* <py::lines('OPCODE-ENUM')>hctdb_instrhelp.get_enum_decl("OpCode")</py>*/
  336. // OPCODE-ENUM:BEGIN
  337. // Enumeration for operations specified by DXIL
  338. enum class OpCode : unsigned {
  339. // Amplification shader instructions
  340. DispatchMesh = 173, // Amplification shader intrinsic DispatchMesh
  341. // AnyHit Terminals
  342. AcceptHitAndEndSearch = 156, // Used in an any hit shader to abort the ray query and the intersection shader (if any). The current hit is committed and execution passes to the closest hit shader with the closest hit recorded so far
  343. IgnoreHit = 155, // Used in an any hit shader to reject an intersection and terminate the shader
  344. // Binary float
  345. FMax = 35, // returns a if a >= b, else b
  346. FMin = 36, // returns a if a < b, else b
  347. // Binary int with two outputs
  348. IMul = 41, // multiply of 32-bit operands to produce the correct full 64-bit result.
  349. // Binary int
  350. IMax = 37, // IMax(a,b) returns a if a > b, else b
  351. IMin = 38, // IMin(a,b) returns a if a < b, else b
  352. // Binary uint with carry or borrow
  353. UAddc = 44, // unsigned add of 32-bit operand with the carry
  354. USubb = 45, // unsigned subtract of 32-bit operands with the borrow
  355. // Binary uint with two outputs
  356. UDiv = 43, // unsigned divide of the 32-bit operand src0 by the 32-bit operand src1.
  357. UMul = 42, // multiply of 32-bit operands to produce the correct full 64-bit result.
  358. // Binary uint
  359. UMax = 39, // unsigned integer maximum. UMax(a,b) = a > b ? a : b
  360. UMin = 40, // unsigned integer minimum. UMin(a,b) = a < b ? a : b
  361. // Bitcasts with different sizes
  362. BitcastF16toI16 = 125, // bitcast between different sizes
  363. BitcastF32toI32 = 127, // bitcast between different sizes
  364. BitcastF64toI64 = 129, // bitcast between different sizes
  365. BitcastI16toF16 = 124, // bitcast between different sizes
  366. BitcastI32toF32 = 126, // bitcast between different sizes
  367. BitcastI64toF64 = 128, // bitcast between different sizes
  368. // Compute/Mesh/Amplification shader
  369. FlattenedThreadIdInGroup = 96, // provides a flattened index for a given thread within a given group (SV_GroupIndex)
  370. GroupId = 94, // reads the group ID (SV_GroupID)
  371. ThreadId = 93, // reads the thread ID
  372. ThreadIdInGroup = 95, // reads the thread ID within the group (SV_GroupThreadID)
  373. // Domain and hull shader
  374. LoadOutputControlPoint = 103, // LoadOutputControlPoint
  375. LoadPatchConstant = 104, // LoadPatchConstant
  376. // Domain shader
  377. DomainLocation = 105, // DomainLocation
  378. // Dot product with accumulate
  379. Dot2AddHalf = 162, // 2D half dot product with accumulate to float
  380. Dot4AddI8Packed = 163, // signed dot product of 4 x i8 vectors packed into i32, with accumulate to i32
  381. Dot4AddU8Packed = 164, // unsigned dot product of 4 x u8 vectors packed into i32, with accumulate to i32
  382. // Dot
  383. Dot2 = 54, // Two-dimensional vector dot-product
  384. Dot3 = 55, // Three-dimensional vector dot-product
  385. Dot4 = 56, // Four-dimensional vector dot-product
  386. // Double precision
  387. LegacyDoubleToFloat = 132, // legacy fuction to convert double to float
  388. LegacyDoubleToSInt32 = 133, // legacy fuction to convert double to int32
  389. LegacyDoubleToUInt32 = 134, // legacy fuction to convert double to uint32
  390. MakeDouble = 101, // creates a double value
  391. SplitDouble = 102, // splits a double into low and high parts
  392. // Geometry shader
  393. CutStream = 98, // completes the current primitive topology at the specified stream
  394. EmitStream = 97, // emits a vertex to a given stream
  395. EmitThenCutStream = 99, // equivalent to an EmitStream followed by a CutStream
  396. GSInstanceID = 100, // GSInstanceID
  397. // Get handle from heap
  398. AnnotateHandle = 217, // annotate handle with resource properties
  399. CreateHandleFromHeap = 216, // create resource handle from heap
  400. // Graphics shader
  401. ViewID = 138, // returns the view index
  402. // Hull shader
  403. OutputControlPointID = 107, // OutputControlPointID
  404. StorePatchConstant = 106, // StorePatchConstant
  405. // Hull, Domain and Geometry shaders
  406. PrimitiveID = 108, // PrimitiveID
  407. // Indirect Shader Invocation
  408. CallShader = 159, // Call a shader in the callable shader table supplied through the DispatchRays() API
  409. ReportHit = 158, // returns true if hit was accepted
  410. TraceRay = 157, // initiates raytrace
  411. // Inline Ray Query
  412. AllocateRayQuery = 178, // allocates space for RayQuery and return handle
  413. RayQuery_Abort = 181, // aborts a ray query
  414. RayQuery_CandidateGeometryIndex = 203, // returns candidate hit geometry index
  415. RayQuery_CandidateInstanceContributionToHitGroupIndex = 214, // returns candidate hit InstanceContributionToHitGroupIndex
  416. RayQuery_CandidateInstanceID = 202, // returns candidate hit instance ID
  417. RayQuery_CandidateInstanceIndex = 201, // returns candidate hit instance index
  418. RayQuery_CandidateObjectRayDirection = 206, // returns candidate object ray direction
  419. RayQuery_CandidateObjectRayOrigin = 205, // returns candidate hit object ray origin
  420. RayQuery_CandidateObjectToWorld3x4 = 186, // returns matrix for transforming from object-space to world-space for a candidate hit.
  421. RayQuery_CandidatePrimitiveIndex = 204, // returns candidate hit geometry index
  422. RayQuery_CandidateProceduralPrimitiveNonOpaque = 190, // returns if current candidate procedural primitive is non opaque
  423. RayQuery_CandidateTriangleBarycentrics = 193, // returns candidate triangle hit barycentrics
  424. RayQuery_CandidateTriangleFrontFace = 191, // returns if current candidate triangle is front facing
  425. RayQuery_CandidateTriangleRayT = 199, // returns float representing the parametric point on the ray for the current candidate triangle hit.
  426. RayQuery_CandidateType = 185, // returns uint candidate type (CANDIDATE_TYPE) of the current hit candidate in a ray query, after Proceed() has returned true
  427. RayQuery_CandidateWorldToObject3x4 = 187, // returns matrix for transforming from world-space to object-space for a candidate hit.
  428. RayQuery_CommitNonOpaqueTriangleHit = 182, // commits a non opaque triangle hit
  429. RayQuery_CommitProceduralPrimitiveHit = 183, // commits a procedural primitive hit
  430. RayQuery_CommittedGeometryIndex = 209, // returns committed hit geometry index
  431. RayQuery_CommittedInstanceContributionToHitGroupIndex = 215, // returns committed hit InstanceContributionToHitGroupIndex
  432. RayQuery_CommittedInstanceID = 208, // returns committed hit instance ID
  433. RayQuery_CommittedInstanceIndex = 207, // returns committed hit instance index
  434. RayQuery_CommittedObjectRayDirection = 212, // returns committed object ray direction
  435. RayQuery_CommittedObjectRayOrigin = 211, // returns committed hit object ray origin
  436. RayQuery_CommittedObjectToWorld3x4 = 188, // returns matrix for transforming from object-space to world-space for a Committed hit.
  437. RayQuery_CommittedPrimitiveIndex = 210, // returns committed hit geometry index
  438. RayQuery_CommittedRayT = 200, // returns float representing the parametric point on the ray for the current committed hit.
  439. RayQuery_CommittedStatus = 184, // returns uint status (COMMITTED_STATUS) of the committed hit in a ray query
  440. RayQuery_CommittedTriangleBarycentrics = 194, // returns committed triangle hit barycentrics
  441. RayQuery_CommittedTriangleFrontFace = 192, // returns if current committed triangle is front facing
  442. RayQuery_CommittedWorldToObject3x4 = 189, // returns matrix for transforming from world-space to object-space for a Committed hit.
  443. RayQuery_Proceed = 180, // advances a ray query
  444. RayQuery_RayFlags = 195, // returns ray flags
  445. RayQuery_RayTMin = 198, // returns float representing the parametric starting point for the ray.
  446. RayQuery_TraceRayInline = 179, // initializes RayQuery for raytrace
  447. RayQuery_WorldRayDirection = 197, // returns world ray direction
  448. RayQuery_WorldRayOrigin = 196, // returns world ray origin
  449. // Legacy floating-point
  450. LegacyF16ToF32 = 131, // legacy fuction to convert half (f16) to float (f32) (this is not related to min-precision)
  451. LegacyF32ToF16 = 130, // legacy fuction to convert float (f32) to half (f16) (this is not related to min-precision)
  452. // Library create handle from resource struct (like HL intrinsic)
  453. CreateHandleForLib = 160, // create resource handle from resource struct for library
  454. // Mesh shader instructions
  455. EmitIndices = 169, // emit a primitive's vertex indices in a mesh shader
  456. GetMeshPayload = 170, // get the mesh payload which is from amplification shader
  457. SetMeshOutputCounts = 168, // Mesh shader intrinsic SetMeshOutputCounts
  458. StorePrimitiveOutput = 172, // stores the value to mesh shader primitive output
  459. StoreVertexOutput = 171, // stores the value to mesh shader vertex output
  460. // Other
  461. CycleCounterLegacy = 109, // CycleCounterLegacy
  462. // Pixel shader
  463. AttributeAtVertex = 137, // returns the values of the attributes at the vertex.
  464. CalculateLOD = 81, // calculates the level of detail
  465. Coverage = 91, // returns the coverage mask input in a pixel shader
  466. DerivCoarseX = 83, // computes the rate of change per stamp in x direction.
  467. DerivCoarseY = 84, // computes the rate of change per stamp in y direction.
  468. DerivFineX = 85, // computes the rate of change per pixel in x direction.
  469. DerivFineY = 86, // computes the rate of change per pixel in y direction.
  470. Discard = 82, // discard the current pixel
  471. EvalCentroid = 89, // evaluates an input attribute at pixel center
  472. EvalSampleIndex = 88, // evaluates an input attribute at a sample location
  473. EvalSnapped = 87, // evaluates an input attribute at pixel center with an offset
  474. InnerCoverage = 92, // returns underestimated coverage input from conservative rasterization in a pixel shader
  475. SampleIndex = 90, // returns the sample index in a sample-frequency pixel shader
  476. // Quad Wave Ops
  477. QuadOp = 123, // returns the result of a quad-level operation
  478. QuadReadLaneAt = 122, // reads from a lane in the quad
  479. // Quaternary
  480. Bfi = 53, // Given a bit range from the LSB of a number, places that number of bits in another number at any offset
  481. // Ray Dispatch Arguments
  482. DispatchRaysDimensions = 146, // The Width and Height values from the D3D12_DISPATCH_RAYS_DESC structure provided to the originating DispatchRays() call.
  483. DispatchRaysIndex = 145, // The current x and y location within the Width and Height
  484. // Ray Transforms
  485. ObjectToWorld = 151, // Matrix for transforming from object-space to world-space.
  486. WorldToObject = 152, // Matrix for transforming from world-space to object-space.
  487. // Ray Vectors
  488. WorldRayDirection = 148, // The world-space direction for the current ray.
  489. WorldRayOrigin = 147, // The world-space origin for the current ray.
  490. // Ray object space Vectors
  491. ObjectRayDirection = 150, // Object-space direction for the current ray.
  492. ObjectRayOrigin = 149, // Object-space origin for the current ray.
  493. // RayT
  494. RayTCurrent = 154, // float representing the current parametric ending point for the ray
  495. RayTMin = 153, // float representing the parametric starting point for the ray.
  496. // Raytracing hit uint System Values
  497. HitKind = 143, // Returns the value passed as HitKind in ReportIntersection(). If intersection was reported by fixed-function triangle intersection, HitKind will be one of HIT_KIND_TRIANGLE_FRONT_FACE or HIT_KIND_TRIANGLE_BACK_FACE.
  498. // Raytracing object space uint System Values, raytracing tier 1.1
  499. GeometryIndex = 213, // The autogenerated index of the current geometry in the bottom-level structure
  500. // Raytracing object space uint System Values
  501. InstanceID = 141, // The user-provided InstanceID on the bottom-level acceleration structure instance within the top-level structure
  502. InstanceIndex = 142, // The autogenerated index of the current instance in the top-level structure
  503. PrimitiveIndex = 161, // PrimitiveIndex for raytracing shaders
  504. // Raytracing uint System Values
  505. RayFlags = 144, // uint containing the current ray flags.
  506. // Resources - gather
  507. TextureGather = 73, // gathers the four texels that would be used in a bi-linear filtering operation
  508. TextureGatherCmp = 74, // same as TextureGather, except this instrution performs comparison on texels, similar to SampleCmp
  509. // Resources - sample
  510. RenderTargetGetSampleCount = 77, // gets the number of samples for a render target
  511. RenderTargetGetSamplePosition = 76, // gets the position of the specified sample
  512. Sample = 60, // samples a texture
  513. SampleBias = 61, // samples a texture after applying the input bias to the mipmap level
  514. SampleCmp = 64, // samples a texture and compares a single component against the specified comparison value
  515. SampleCmpLevelZero = 65, // samples a texture and compares a single component against the specified comparison value
  516. SampleGrad = 63, // samples a texture using a gradient to influence the way the sample location is calculated
  517. SampleLevel = 62, // samples a texture using a mipmap-level offset
  518. Texture2DMSGetSamplePosition = 75, // gets the position of the specified sample
  519. // Resources
  520. BufferLoad = 68, // reads from a TypedBuffer
  521. BufferStore = 69, // writes to a RWTypedBuffer
  522. BufferUpdateCounter = 70, // atomically increments/decrements the hidden 32-bit counter stored with a Count or Append UAV
  523. CBufferLoad = 58, // loads a value from a constant buffer resource
  524. CBufferLoadLegacy = 59, // loads a value from a constant buffer resource
  525. CheckAccessFullyMapped = 71, // determines whether all values from a Sample, Gather, or Load operation accessed mapped tiles in a tiled resource
  526. CreateHandle = 57, // creates the handle to a resource
  527. GetDimensions = 72, // gets texture size information
  528. RawBufferLoad = 139, // reads from a raw buffer and structured buffer
  529. RawBufferStore = 140, // writes to a RWByteAddressBuffer or RWStructuredBuffer
  530. TextureLoad = 66, // reads texel data without any filtering or sampling
  531. TextureStore = 67, // reads texel data without any filtering or sampling
  532. // Sampler Feedback
  533. WriteSamplerFeedback = 174, // updates a feedback texture for a sampling operation
  534. WriteSamplerFeedbackBias = 175, // updates a feedback texture for a sampling operation with a bias on the mipmap level
  535. WriteSamplerFeedbackGrad = 177, // updates a feedback texture for a sampling operation with explicit gradients
  536. WriteSamplerFeedbackLevel = 176, // updates a feedback texture for a sampling operation with a mipmap-level offset
  537. // Synchronization
  538. AtomicBinOp = 78, // performs an atomic operation on two operands
  539. AtomicCompareExchange = 79, // atomic compare and exchange to memory
  540. Barrier = 80, // inserts a memory barrier in the shader
  541. // Temporary, indexable, input, output registers
  542. LoadInput = 4, // Loads the value from shader input
  543. MinPrecXRegLoad = 2, // Helper load operation for minprecision
  544. MinPrecXRegStore = 3, // Helper store operation for minprecision
  545. StoreOutput = 5, // Stores the value to shader output
  546. TempRegLoad = 0, // Helper load operation
  547. TempRegStore = 1, // Helper store operation
  548. // Tertiary float
  549. FMad = 46, // floating point multiply & add
  550. Fma = 47, // fused multiply-add
  551. // Tertiary int
  552. IMad = 48, // Signed integer multiply & add
  553. Ibfe = 51, // Integer bitfield extract
  554. Msad = 50, // masked Sum of Absolute Differences.
  555. // Tertiary uint
  556. UMad = 49, // Unsigned integer multiply & add
  557. Ubfe = 52, // Unsigned integer bitfield extract
  558. // Unary float - rounding
  559. Round_ne = 26, // floating-point round to integral float.
  560. Round_ni = 27, // floating-point round to integral float.
  561. Round_pi = 28, // floating-point round to integral float.
  562. Round_z = 29, // floating-point round to integral float.
  563. // Unary float
  564. Acos = 15, // Returns the arccosine of the specified value. Input should be a floating-point value within the range of -1 to 1.
  565. Asin = 16, // Returns the arccosine of the specified value. Input should be a floating-point value within the range of -1 to 1
  566. Atan = 17, // Returns the arctangent of the specified value. The return value is within the range of -PI/2 to PI/2.
  567. Cos = 12, // returns cosine(theta) for theta in radians.
  568. Exp = 21, // returns 2^exponent
  569. FAbs = 6, // returns the absolute value of the input value.
  570. Frc = 22, // extract fracitonal component.
  571. Hcos = 18, // returns the hyperbolic cosine of the specified value.
  572. Hsin = 19, // returns the hyperbolic sine of the specified value.
  573. Htan = 20, // returns the hyperbolic tangent of the specified value.
  574. IsFinite = 10, // Returns true if x is finite, false otherwise.
  575. IsInf = 9, // Returns true if x is +INF or -INF, false otherwise.
  576. IsNaN = 8, // Returns true if x is NAN or QNAN, false otherwise.
  577. IsNormal = 11, // returns IsNormal
  578. Log = 23, // returns log base 2.
  579. Rsqrt = 25, // returns reciprocal square root (1 / sqrt(src)
  580. Saturate = 7, // clamps the result of a single or double precision floating point value to [0.0f...1.0f]
  581. Sin = 13, // returns sine(theta) for theta in radians.
  582. Sqrt = 24, // returns square root
  583. Tan = 14, // returns tan(theta) for theta in radians.
  584. // Unary int
  585. Bfrev = 30, // Reverses the order of the bits.
  586. Countbits = 31, // Counts the number of bits in the input integer.
  587. FirstbitLo = 32, // Returns the location of the first set bit starting from the lowest order bit and working upward.
  588. FirstbitSHi = 34, // Returns the location of the first set bit from the highest order bit based on the sign.
  589. // Unary uint
  590. FirstbitHi = 33, // Returns the location of the first set bit starting from the highest order bit and working downward.
  591. // Wave
  592. WaveActiveAllEqual = 115, // returns 1 if all the lanes have the same value
  593. WaveActiveBallot = 116, // returns a struct with a bit set for each lane where the condition is true
  594. WaveActiveBit = 120, // returns the result of the operation across all lanes
  595. WaveActiveOp = 119, // returns the result the operation across waves
  596. WaveAllBitCount = 135, // returns the count of bits set to 1 across the wave
  597. WaveAllTrue = 114, // returns 1 if all the lanes evaluate the value to true
  598. WaveAnyTrue = 113, // returns 1 if any of the lane evaluates the value to true
  599. WaveGetLaneCount = 112, // returns the number of lanes in the wave
  600. WaveGetLaneIndex = 111, // returns the index of the current lane in the wave
  601. WaveIsFirstLane = 110, // returns 1 for the first lane in the wave
  602. WaveMatch = 165, // returns the bitmask of active lanes that have the same value
  603. WaveMultiPrefixBitCount = 167, // returns the count of bits set to 1 on groups of lanes identified by a bitmask
  604. WaveMultiPrefixOp = 166, // returns the result of the operation on groups of lanes identified by a bitmask
  605. WavePrefixBitCount = 136, // returns the count of bits set to 1 on prior lanes
  606. WavePrefixOp = 121, // returns the result of the operation on prior lanes
  607. WaveReadLaneAt = 117, // returns the value from the specified lane
  608. WaveReadLaneFirst = 118, // returns the value from the first lane
  609. NumOpCodes_Dxil_1_0 = 137,
  610. NumOpCodes_Dxil_1_1 = 139,
  611. NumOpCodes_Dxil_1_2 = 141,
  612. NumOpCodes_Dxil_1_3 = 162,
  613. NumOpCodes_Dxil_1_4 = 165,
  614. NumOpCodes_Dxil_1_5 = 216,
  615. NumOpCodes_Dxil_1_6 = 218,
  616. NumOpCodes = 218 // exclusive last value of enumeration
  617. };
  618. // OPCODE-ENUM:END
  619. /* <py::lines('OPCODECLASS-ENUM')>hctdb_instrhelp.get_enum_decl("OpCodeClass")</py>*/
  620. // OPCODECLASS-ENUM:BEGIN
  621. // Groups for DXIL operations with equivalent function templates
  622. enum class OpCodeClass : unsigned {
  623. // Amplification shader instructions
  624. DispatchMesh,
  625. // AnyHit Terminals
  626. AcceptHitAndEndSearch,
  627. IgnoreHit,
  628. // Binary uint with carry or borrow
  629. BinaryWithCarryOrBorrow,
  630. // Binary uint with two outputs
  631. BinaryWithTwoOuts,
  632. // Binary uint
  633. Binary,
  634. // Bitcasts with different sizes
  635. BitcastF16toI16,
  636. BitcastF32toI32,
  637. BitcastF64toI64,
  638. BitcastI16toF16,
  639. BitcastI32toF32,
  640. BitcastI64toF64,
  641. // Compute/Mesh/Amplification shader
  642. FlattenedThreadIdInGroup,
  643. GroupId,
  644. ThreadId,
  645. ThreadIdInGroup,
  646. // Domain and hull shader
  647. LoadOutputControlPoint,
  648. LoadPatchConstant,
  649. // Domain shader
  650. DomainLocation,
  651. // Dot product with accumulate
  652. Dot2AddHalf,
  653. Dot4AddPacked,
  654. // Dot
  655. Dot2,
  656. Dot3,
  657. Dot4,
  658. // Double precision
  659. LegacyDoubleToFloat,
  660. LegacyDoubleToSInt32,
  661. LegacyDoubleToUInt32,
  662. MakeDouble,
  663. SplitDouble,
  664. // Geometry shader
  665. CutStream,
  666. EmitStream,
  667. EmitThenCutStream,
  668. GSInstanceID,
  669. // Get handle from heap
  670. AnnotateHandle,
  671. CreateHandleFromHeap,
  672. // Graphics shader
  673. ViewID,
  674. // Hull shader
  675. OutputControlPointID,
  676. StorePatchConstant,
  677. // Hull, Domain and Geometry shaders
  678. PrimitiveID,
  679. // Indirect Shader Invocation
  680. CallShader,
  681. ReportHit,
  682. TraceRay,
  683. // Inline Ray Query
  684. AllocateRayQuery,
  685. RayQuery_Abort,
  686. RayQuery_CommitNonOpaqueTriangleHit,
  687. RayQuery_CommitProceduralPrimitiveHit,
  688. RayQuery_Proceed,
  689. RayQuery_StateMatrix,
  690. RayQuery_StateScalar,
  691. RayQuery_StateVector,
  692. RayQuery_TraceRayInline,
  693. // LLVM Instructions
  694. LlvmInst,
  695. // Legacy floating-point
  696. LegacyF16ToF32,
  697. LegacyF32ToF16,
  698. // Library create handle from resource struct (like HL intrinsic)
  699. CreateHandleForLib,
  700. // Mesh shader instructions
  701. EmitIndices,
  702. GetMeshPayload,
  703. SetMeshOutputCounts,
  704. StorePrimitiveOutput,
  705. StoreVertexOutput,
  706. // Other
  707. CycleCounterLegacy,
  708. // Pixel shader
  709. AttributeAtVertex,
  710. CalculateLOD,
  711. Coverage,
  712. Discard,
  713. EvalCentroid,
  714. EvalSampleIndex,
  715. EvalSnapped,
  716. InnerCoverage,
  717. SampleIndex,
  718. Unary,
  719. // Quad Wave Ops
  720. QuadOp,
  721. QuadReadLaneAt,
  722. // Quaternary
  723. Quaternary,
  724. // Ray Dispatch Arguments
  725. DispatchRaysDimensions,
  726. DispatchRaysIndex,
  727. // Ray Transforms
  728. ObjectToWorld,
  729. WorldToObject,
  730. // Ray Vectors
  731. WorldRayDirection,
  732. WorldRayOrigin,
  733. // Ray object space Vectors
  734. ObjectRayDirection,
  735. ObjectRayOrigin,
  736. // RayT
  737. RayTCurrent,
  738. RayTMin,
  739. // Raytracing hit uint System Values
  740. HitKind,
  741. // Raytracing object space uint System Values, raytracing tier 1.1
  742. GeometryIndex,
  743. // Raytracing object space uint System Values
  744. InstanceID,
  745. InstanceIndex,
  746. PrimitiveIndex,
  747. // Raytracing uint System Values
  748. RayFlags,
  749. // Resources - gather
  750. TextureGather,
  751. TextureGatherCmp,
  752. // Resources - sample
  753. RenderTargetGetSampleCount,
  754. RenderTargetGetSamplePosition,
  755. Sample,
  756. SampleBias,
  757. SampleCmp,
  758. SampleCmpLevelZero,
  759. SampleGrad,
  760. SampleLevel,
  761. Texture2DMSGetSamplePosition,
  762. // Resources
  763. BufferLoad,
  764. BufferStore,
  765. BufferUpdateCounter,
  766. CBufferLoad,
  767. CBufferLoadLegacy,
  768. CheckAccessFullyMapped,
  769. CreateHandle,
  770. GetDimensions,
  771. RawBufferLoad,
  772. RawBufferStore,
  773. TextureLoad,
  774. TextureStore,
  775. // Sampler Feedback
  776. WriteSamplerFeedback,
  777. WriteSamplerFeedbackBias,
  778. WriteSamplerFeedbackGrad,
  779. WriteSamplerFeedbackLevel,
  780. // Synchronization
  781. AtomicBinOp,
  782. AtomicCompareExchange,
  783. Barrier,
  784. // Temporary, indexable, input, output registers
  785. LoadInput,
  786. MinPrecXRegLoad,
  787. MinPrecXRegStore,
  788. StoreOutput,
  789. TempRegLoad,
  790. TempRegStore,
  791. // Tertiary uint
  792. Tertiary,
  793. // Unary float
  794. IsSpecialFloat,
  795. // Unary int
  796. UnaryBits,
  797. // Wave
  798. WaveActiveAllEqual,
  799. WaveActiveBallot,
  800. WaveActiveBit,
  801. WaveActiveOp,
  802. WaveAllOp,
  803. WaveAllTrue,
  804. WaveAnyTrue,
  805. WaveGetLaneCount,
  806. WaveGetLaneIndex,
  807. WaveIsFirstLane,
  808. WaveMatch,
  809. WaveMultiPrefixBitCount,
  810. WaveMultiPrefixOp,
  811. WavePrefixOp,
  812. WaveReadLaneAt,
  813. WaveReadLaneFirst,
  814. NumOpClasses_Dxil_1_0 = 93,
  815. NumOpClasses_Dxil_1_1 = 95,
  816. NumOpClasses_Dxil_1_2 = 97,
  817. NumOpClasses_Dxil_1_3 = 118,
  818. NumOpClasses_Dxil_1_4 = 120,
  819. NumOpClasses_Dxil_1_5 = 143,
  820. NumOpClasses_Dxil_1_6 = 145,
  821. NumOpClasses = 145 // exclusive last value of enumeration
  822. };
  823. // OPCODECLASS-ENUM:END
  824. // Operand Index for every OpCodeClass.
  825. namespace OperandIndex {
  826. // Opcode is always operand 0.
  827. const unsigned kOpcodeIdx = 0;
  828. // Unary operators.
  829. const unsigned kUnarySrc0OpIdx = 1;
  830. // Binary operators.
  831. const unsigned kBinarySrc0OpIdx = 1;
  832. const unsigned kBinarySrc1OpIdx = 2;
  833. // Trinary operators.
  834. const unsigned kTrinarySrc0OpIdx = 1;
  835. const unsigned kTrinarySrc1OpIdx = 2;
  836. const unsigned kTrinarySrc2OpIdx = 3;
  837. // LoadInput.
  838. const unsigned kLoadInputIDOpIdx = 1;
  839. const unsigned kLoadInputRowOpIdx = 2;
  840. const unsigned kLoadInputColOpIdx = 3;
  841. const unsigned kLoadInputVertexIDOpIdx = 4;
  842. // StoreOutput, StoreVertexOutput, StorePrimitiveOutput
  843. const unsigned kStoreOutputIDOpIdx = 1;
  844. const unsigned kStoreOutputRowOpIdx = 2;
  845. const unsigned kStoreOutputColOpIdx = 3;
  846. const unsigned kStoreOutputValOpIdx = 4;
  847. const unsigned kStoreOutputVPIDOpIdx = 5;
  848. // DomainLocation.
  849. const unsigned kDomainLocationColOpIdx = 1;
  850. // BufferLoad.
  851. const unsigned kBufferLoadHandleOpIdx = 1;
  852. const unsigned kBufferLoadCoord0OpIdx = 2;
  853. const unsigned kBufferLoadCoord1OpIdx = 3;
  854. // BufferStore.
  855. const unsigned kBufferStoreHandleOpIdx = 1;
  856. const unsigned kBufferStoreCoord0OpIdx = 2;
  857. const unsigned kBufferStoreCoord1OpIdx = 3;
  858. const unsigned kBufferStoreVal0OpIdx = 4;
  859. const unsigned kBufferStoreVal1OpIdx = 5;
  860. const unsigned kBufferStoreVal2OpIdx = 6;
  861. const unsigned kBufferStoreVal3OpIdx = 7;
  862. const unsigned kBufferStoreMaskOpIdx = 8;
  863. // RawBufferLoad.
  864. const unsigned kRawBufferLoadHandleOpIdx = 1;
  865. const unsigned kRawBufferLoadIndexOpIdx = 2;
  866. const unsigned kRawBufferLoadElementOffsetOpIdx = 3;
  867. const unsigned kRawBufferLoadMaskOpIdx = 4;
  868. const unsigned kRawBufferLoadAlignmentOpIdx = 5;
  869. // RawBufferStore
  870. const unsigned kRawBufferStoreHandleOpIdx = 1;
  871. const unsigned kRawBufferStoreIndexOpIdx = 2;
  872. const unsigned kRawBufferStoreElementOffsetOpIdx = 3;
  873. const unsigned kRawBufferStoreVal0OpIdx = 4;
  874. const unsigned kRawBufferStoreVal1OpIdx = 5;
  875. const unsigned kRawBufferStoreVal2OpIdx = 6;
  876. const unsigned kRawBufferStoreVal3OpIdx = 7;
  877. const unsigned kRawBufferStoreMaskOpIdx = 8;
  878. const unsigned kRawBufferStoreAlignmentOpIdx = 8;
  879. // TextureStore.
  880. const unsigned kTextureStoreHandleOpIdx = 1;
  881. const unsigned kTextureStoreCoord0OpIdx = 2;
  882. const unsigned kTextureStoreCoord1OpIdx = 3;
  883. const unsigned kTextureStoreCoord2OpIdx = 4;
  884. const unsigned kTextureStoreVal0OpIdx = 5;
  885. const unsigned kTextureStoreVal1OpIdx = 6;
  886. const unsigned kTextureStoreVal2OpIdx = 7;
  887. const unsigned kTextureStoreVal3OpIdx = 8;
  888. const unsigned kTextureStoreMaskOpIdx = 9;
  889. // TextureGather.
  890. const unsigned kTextureGatherTexHandleOpIdx = 1;
  891. const unsigned kTextureGatherSamplerHandleOpIdx = 2;
  892. const unsigned kTextureGatherCoord0OpIdx = 3;
  893. const unsigned kTextureGatherCoord1OpIdx = 4;
  894. const unsigned kTextureGatherCoord2OpIdx = 5;
  895. const unsigned kTextureGatherCoord3OpIdx = 6;
  896. const unsigned kTextureGatherOffset0OpIdx = 7;
  897. const unsigned kTextureGatherOffset1OpIdx = 8;
  898. const unsigned kTextureGatherOffset2OpIdx = 9;
  899. const unsigned kTextureGatherChannelOpIdx = 10;
  900. // TextureGatherCmp.
  901. const unsigned kTextureGatherCmpCmpValOpIdx = 11;
  902. // TextureSample.
  903. const unsigned kTextureSampleTexHandleOpIdx = 1;
  904. const unsigned kTextureSampleSamplerHandleOpIdx = 2;
  905. const unsigned kTextureSampleCoord0OpIdx = 3;
  906. const unsigned kTextureSampleCoord1OpIdx = 4;
  907. const unsigned kTextureSampleCoord2OpIdx = 5;
  908. const unsigned kTextureSampleCoord3OpIdx = 6;
  909. const unsigned kTextureSampleOffset0OpIdx = 7;
  910. const unsigned kTextureSampleOffset1OpIdx = 8;
  911. const unsigned kTextureSampleOffset2OpIdx = 9;
  912. const unsigned kTextureSampleClampOpIdx = 10;
  913. // AtomicBinOp.
  914. const unsigned kAtomicBinOpCoord0OpIdx = 3;
  915. const unsigned kAtomicBinOpCoord1OpIdx = 4;
  916. const unsigned kAtomicBinOpCoord2OpIdx = 5;
  917. // AtomicCmpExchange.
  918. const unsigned kAtomicCmpExchangeCoord0OpIdx = 2;
  919. const unsigned kAtomicCmpExchangeCoord1OpIdx = 3;
  920. const unsigned kAtomicCmpExchangeCoord2OpIdx = 4;
  921. // CreateHandle
  922. const unsigned kCreateHandleResClassOpIdx = 1;
  923. const unsigned kCreateHandleResIDOpIdx = 2;
  924. const unsigned kCreateHandleResIndexOpIdx = 3;
  925. const unsigned kCreateHandleIsUniformOpIdx = 4;
  926. // CreateHandleFromResource
  927. const unsigned kCreateHandleForLibResOpIdx = 1;
  928. // TraceRay
  929. const unsigned kTraceRayRayDescOpIdx = 7;
  930. const unsigned kTraceRayPayloadOpIdx = 15;
  931. const unsigned kTraceRayNumOp = 16;
  932. // TraceRayInline
  933. const unsigned kTraceRayInlineRayDescOpIdx = 5;
  934. const unsigned kTraceRayInlineNumOp = 13;
  935. // Emit/Cut
  936. const unsigned kStreamEmitCutIDOpIdx = 1;
  937. // StoreVectorOutput/StorePrimitiveOutput.
  938. const unsigned kMSStoreOutputIDOpIdx = 1;
  939. const unsigned kMSStoreOutputRowOpIdx = 2;
  940. const unsigned kMSStoreOutputColOpIdx = 3;
  941. const unsigned kMSStoreOutputVIdxOpIdx = 4;
  942. const unsigned kMSStoreOutputValOpIdx = 5;
  943. // TODO: add operand index for all the OpCodeClass.
  944. }
  945. // Atomic binary operation kind.
  946. enum class AtomicBinOpCode : unsigned {
  947. Add,
  948. And,
  949. Or,
  950. Xor,
  951. IMin,
  952. IMax,
  953. UMin,
  954. UMax,
  955. Exchange,
  956. Invalid // Must be last.
  957. };
  958. // Barrier/fence modes.
  959. enum class BarrierMode : unsigned {
  960. SyncThreadGroup = 0x00000001,
  961. UAVFenceGlobal = 0x00000002,
  962. UAVFenceThreadGroup = 0x00000004,
  963. TGSMFence = 0x00000008,
  964. };
  965. // Address space.
  966. const unsigned kDefaultAddrSpace = 0;
  967. const unsigned kDeviceMemoryAddrSpace = 1;
  968. const unsigned kCBufferAddrSpace = 2;
  969. const unsigned kTGSMAddrSpace = 3;
  970. const unsigned kGenericPointerAddrSpace = 4;
  971. const unsigned kImmediateCBufferAddrSpace = 5;
  972. // Input primitive, must match D3D_PRIMITIVE
  973. enum class InputPrimitive : unsigned {
  974. Undefined = 0,
  975. Point = 1,
  976. Line = 2,
  977. Triangle = 3,
  978. Reserved4 = 4,
  979. Reserved5 = 5,
  980. LineWithAdjacency = 6,
  981. TriangleWithAdjacency = 7,
  982. ControlPointPatch1 = 8,
  983. ControlPointPatch2 = 9,
  984. ControlPointPatch3 = 10,
  985. ControlPointPatch4 = 11,
  986. ControlPointPatch5 = 12,
  987. ControlPointPatch6 = 13,
  988. ControlPointPatch7 = 14,
  989. ControlPointPatch8 = 15,
  990. ControlPointPatch9 = 16,
  991. ControlPointPatch10 = 17,
  992. ControlPointPatch11 = 18,
  993. ControlPointPatch12 = 19,
  994. ControlPointPatch13 = 20,
  995. ControlPointPatch14 = 21,
  996. ControlPointPatch15 = 22,
  997. ControlPointPatch16 = 23,
  998. ControlPointPatch17 = 24,
  999. ControlPointPatch18 = 25,
  1000. ControlPointPatch19 = 26,
  1001. ControlPointPatch20 = 27,
  1002. ControlPointPatch21 = 28,
  1003. ControlPointPatch22 = 29,
  1004. ControlPointPatch23 = 30,
  1005. ControlPointPatch24 = 31,
  1006. ControlPointPatch25 = 32,
  1007. ControlPointPatch26 = 33,
  1008. ControlPointPatch27 = 34,
  1009. ControlPointPatch28 = 35,
  1010. ControlPointPatch29 = 36,
  1011. ControlPointPatch30 = 37,
  1012. ControlPointPatch31 = 38,
  1013. ControlPointPatch32 = 39,
  1014. LastEntry,
  1015. };
  1016. // Primitive topology, must match D3D_PRIMITIVE_TOPOLOGY
  1017. enum class PrimitiveTopology : unsigned {
  1018. Undefined = 0,
  1019. PointList = 1,
  1020. LineList = 2,
  1021. LineStrip = 3,
  1022. TriangleList = 4,
  1023. TriangleStrip = 5,
  1024. LastEntry,
  1025. };
  1026. // Must match D3D_TESSELLATOR_DOMAIN
  1027. enum class TessellatorDomain
  1028. {
  1029. Undefined = 0,
  1030. IsoLine = 1,
  1031. Tri = 2,
  1032. Quad = 3,
  1033. LastEntry,
  1034. };
  1035. // Must match D3D_TESSELLATOR_OUTPUT_PRIMITIVE
  1036. enum class TessellatorOutputPrimitive
  1037. {
  1038. Undefined = 0,
  1039. Point = 1,
  1040. Line = 2,
  1041. TriangleCW = 3,
  1042. TriangleCCW = 4,
  1043. LastEntry,
  1044. };
  1045. enum class MeshOutputTopology
  1046. {
  1047. Undefined = 0,
  1048. Line = 1,
  1049. Triangle = 2,
  1050. LastEntry,
  1051. };
  1052. // Tessellator partitioning, must match D3D_TESSELLATOR_PARTITIONING
  1053. enum class TessellatorPartitioning : unsigned {
  1054. Undefined = 0,
  1055. Integer,
  1056. Pow2,
  1057. FractionalOdd,
  1058. FractionalEven,
  1059. LastEntry,
  1060. };
  1061. // Kind of quad-level operation
  1062. enum class QuadOpKind {
  1063. ReadAcrossX = 0, // returns the value from the other lane in the quad in the horizontal direction
  1064. ReadAcrossY = 1, // returns the value from the other lane in the quad in the vertical direction
  1065. ReadAcrossDiagonal = 2, // returns the value from the lane across the quad in horizontal and vertical direction
  1066. };
  1067. /* <py::lines('WAVEBITOPKIND-ENUM')>hctdb_instrhelp.get_enum_decl("WaveBitOpKind")</py>*/
  1068. // WAVEBITOPKIND-ENUM:BEGIN
  1069. // Kind of bitwise cross-lane operation
  1070. enum class WaveBitOpKind : unsigned {
  1071. And = 0, // bitwise and of values
  1072. Or = 1, // bitwise or of values
  1073. Xor = 2, // bitwise xor of values
  1074. };
  1075. // WAVEBITOPKIND-ENUM:END
  1076. /* <py::lines('WAVEOPKIND-ENUM')>hctdb_instrhelp.get_enum_decl("WaveOpKind")</py>*/
  1077. // WAVEOPKIND-ENUM:BEGIN
  1078. // Kind of cross-lane operation
  1079. enum class WaveOpKind : unsigned {
  1080. Max = 3, // maximum value
  1081. Min = 2, // minimum value
  1082. Product = 1, // product of values
  1083. Sum = 0, // sum of values
  1084. };
  1085. // WAVEOPKIND-ENUM:END
  1086. /* <py::lines('WAVEMULTIPREFIXOPKIND-ENUM')>hctdb_instrhelp.get_enum_decl("WaveMultiPrefixOpKind")</py>*/
  1087. // WAVEMULTIPREFIXOPKIND-ENUM:BEGIN
  1088. // Kind of cross-lane for multi-prefix operation
  1089. enum class WaveMultiPrefixOpKind : unsigned {
  1090. And = 1, // bitwise and of values
  1091. Or = 2, // bitwise or of values
  1092. Product = 4, // product of values
  1093. Sum = 0, // sum of values
  1094. Xor = 3, // bitwise xor of values
  1095. };
  1096. // WAVEMULTIPREFIXOPKIND-ENUM:END
  1097. /* <py::lines('SIGNEDOPKIND-ENUM')>hctdb_instrhelp.get_enum_decl("SignedOpKind")</py>*/
  1098. // SIGNEDOPKIND-ENUM:BEGIN
  1099. // Sign vs. unsigned operands for operation
  1100. enum class SignedOpKind : unsigned {
  1101. Signed = 0, // signed integer or floating-point operands
  1102. Unsigned = 1, // unsigned integer operands
  1103. };
  1104. // SIGNEDOPKIND-ENUM:END
  1105. // Kind of control flow hint
  1106. enum class ControlFlowHint : unsigned {
  1107. Undefined = 0,
  1108. Branch = 1,
  1109. Flatten = 2,
  1110. FastOpt = 3,
  1111. AllowUavCondition = 4,
  1112. ForceCase = 5,
  1113. Call = 6,
  1114. // Loop and Unroll is using llvm.loop.unroll Metadata.
  1115. LastEntry,
  1116. };
  1117. // XYZW component mask.
  1118. const uint8_t kCompMask_X = 0x1;
  1119. const uint8_t kCompMask_Y = 0x2;
  1120. const uint8_t kCompMask_Z = 0x4;
  1121. const uint8_t kCompMask_W = 0x8;
  1122. const uint8_t kCompMask_All = 0xF;
  1123. enum class LowPrecisionMode {
  1124. Undefined = 0,
  1125. UseMinPrecision,
  1126. UseNativeLowPrecision
  1127. };
  1128. // Corresponds to RAY_FLAG_* in HLSL
  1129. enum class RayFlag : uint32_t {
  1130. None = 0x00,
  1131. ForceOpaque = 0x01,
  1132. ForceNonOpaque = 0x02,
  1133. AcceptFirstHitAndEndSearch = 0x04,
  1134. SkipClosestHitShader = 0x08,
  1135. CullBackFacingTriangles = 0x10,
  1136. CullFrontFacingTriangles = 0x20,
  1137. CullOpaque = 0x40,
  1138. CullNonOpaque = 0x80,
  1139. SkipTriangles = 0x100,
  1140. SkipProceduralPrimitives = 0x200,
  1141. };
  1142. // Corresponds to HIT_KIND_* in HLSL
  1143. enum class HitKind : uint8_t {
  1144. None = 0x00,
  1145. TriangleFrontFace = 0xFE,
  1146. TriangleBackFace = 0xFF,
  1147. };
  1148. enum class SamplerFeedbackType : uint8_t {
  1149. MinMip = 0,
  1150. MipRegionUsed = 1,
  1151. LastEntry = 2
  1152. };
  1153. // Constant for Container.
  1154. const uint8_t DxilProgramSigMaskX = 1;
  1155. const uint8_t DxilProgramSigMaskY = 2;
  1156. const uint8_t DxilProgramSigMaskZ = 4;
  1157. const uint8_t DxilProgramSigMaskW = 8;
  1158. // DFCC_FeatureInfo is a uint64_t value with these flags.
  1159. const uint64_t ShaderFeatureInfo_Doubles = 0x0001;
  1160. const uint64_t
  1161. ShaderFeatureInfo_ComputeShadersPlusRawAndStructuredBuffersViaShader4X =
  1162. 0x0002;
  1163. const uint64_t ShaderFeatureInfo_UAVsAtEveryStage = 0x0004;
  1164. const uint64_t ShaderFeatureInfo_64UAVs = 0x0008;
  1165. const uint64_t ShaderFeatureInfo_MinimumPrecision = 0x0010;
  1166. const uint64_t ShaderFeatureInfo_11_1_DoubleExtensions = 0x0020;
  1167. const uint64_t ShaderFeatureInfo_11_1_ShaderExtensions = 0x0040;
  1168. const uint64_t ShaderFeatureInfo_LEVEL9ComparisonFiltering = 0x0080;
  1169. const uint64_t ShaderFeatureInfo_TiledResources = 0x0100;
  1170. const uint64_t ShaderFeatureInfo_StencilRef = 0x0200;
  1171. const uint64_t ShaderFeatureInfo_InnerCoverage = 0x0400;
  1172. const uint64_t ShaderFeatureInfo_TypedUAVLoadAdditionalFormats = 0x0800;
  1173. const uint64_t ShaderFeatureInfo_ROVs = 0x1000;
  1174. const uint64_t
  1175. ShaderFeatureInfo_ViewportAndRTArrayIndexFromAnyShaderFeedingRasterizer =
  1176. 0x2000;
  1177. const uint64_t ShaderFeatureInfo_WaveOps = 0x4000;
  1178. const uint64_t ShaderFeatureInfo_Int64Ops = 0x8000;
  1179. const uint64_t ShaderFeatureInfo_ViewID = 0x10000;
  1180. const uint64_t ShaderFeatureInfo_Barycentrics = 0x20000;
  1181. const uint64_t ShaderFeatureInfo_NativeLowPrecision = 0x40000;
  1182. const uint64_t ShaderFeatureInfo_ShadingRate = 0x80000;
  1183. const uint64_t ShaderFeatureInfo_Raytracing_Tier_1_1 = 0x100000;
  1184. const uint64_t ShaderFeatureInfo_SamplerFeedback = 0x200000;
  1185. const unsigned ShaderFeatureInfoCount = 22;
  1186. // DxilSubobjectType must match D3D12_STATE_SUBOBJECT_TYPE, with
  1187. // certain values reserved, since they cannot be used from Dxil.
  1188. enum class SubobjectKind : uint32_t {
  1189. StateObjectConfig = 0,
  1190. GlobalRootSignature = 1,
  1191. LocalRootSignature = 2,
  1192. // 3-7 are reserved (not supported in Dxil)
  1193. SubobjectToExportsAssociation = 8,
  1194. RaytracingShaderConfig = 9,
  1195. RaytracingPipelineConfig = 10,
  1196. HitGroup = 11,
  1197. RaytracingPipelineConfig1 = 12,
  1198. NumKinds // aka D3D12_STATE_SUBOBJECT_TYPE_MAX_VALID
  1199. };
  1200. inline bool IsValidSubobjectKind(SubobjectKind kind) {
  1201. return (kind < SubobjectKind::NumKinds &&
  1202. ( kind <= SubobjectKind::LocalRootSignature ||
  1203. kind >= SubobjectKind::SubobjectToExportsAssociation));
  1204. }
  1205. enum class StateObjectFlags : uint32_t {
  1206. AllowLocalDependenciesOnExternalDefinitions = 0x1,
  1207. AllowExternalDependenciesOnLocalDefinitions = 0x2,
  1208. AllowStateObjectAdditions = 0x4,
  1209. ValidMask_1_4 = 0x3,
  1210. ValidMask = 0x7,
  1211. };
  1212. enum class HitGroupType : uint32_t {
  1213. Triangle = 0x0,
  1214. ProceduralPrimitive = 0x1,
  1215. LastEntry,
  1216. };
  1217. enum class RaytracingPipelineFlags : uint32_t {
  1218. None = 0x0,
  1219. SkipTriangles = 0x100,
  1220. SkipProceduralPrimitives = 0x200,
  1221. ValidMask = 0x300,
  1222. };
  1223. enum class CommittedStatus : uint32_t {
  1224. CommittedNothing = 0,
  1225. CommittedTriangleHit = 1,
  1226. CommittedProceduralPrimitiveHit = 2,
  1227. };
  1228. enum class CandidateType : uint32_t {
  1229. CandidateNonOpaqueTriangle = 0,
  1230. CandidateProceduralPrimitive = 1,
  1231. };
  1232. inline bool IsValidHitGroupType(HitGroupType type) {
  1233. return (type >= HitGroupType::Triangle && type < HitGroupType::LastEntry);
  1234. }
  1235. extern const char* kLegacyLayoutString;
  1236. extern const char* kNewLayoutString;
  1237. extern const char* kFP32DenormKindString;
  1238. extern const char* kFP32DenormValueAnyString;
  1239. extern const char* kFP32DenormValuePreserveString;
  1240. extern const char* kFP32DenormValueFtzString;
  1241. static const char *kDxBreakFuncName = "dx.break";
  1242. static const char *kDxBreakCondName = "dx.break.cond";
  1243. } // namespace DXIL
  1244. } // namespace hlsl