DxilConstants.h 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985
  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. const unsigned kDxilMinor = 2;
  25. inline unsigned MakeDxilVersion(unsigned DxilMajor, unsigned DxilMinor) {
  26. return 0 | (DxilMajor << 8) | (DxilMinor);
  27. }
  28. inline unsigned GetCurrentDxilVersion() { return MakeDxilVersion(kDxilMajor, kDxilMinor); }
  29. inline unsigned GetDxilVersionMajor(unsigned DxilVersion) { return (DxilVersion >> 8) & 0xFF; }
  30. inline unsigned GetDxilVersionMinor(unsigned DxilVersion) { return DxilVersion & 0xFF; }
  31. // Shader flags.
  32. const unsigned kDisableOptimizations = 0x00000001; // D3D11_1_SB_GLOBAL_FLAG_SKIP_OPTIMIZATION
  33. const unsigned kDisableMathRefactoring = 0x00000002; //~D3D10_SB_GLOBAL_FLAG_REFACTORING_ALLOWED
  34. const unsigned kEnableDoublePrecision = 0x00000004; // D3D11_SB_GLOBAL_FLAG_ENABLE_DOUBLE_PRECISION_FLOAT_OPS
  35. const unsigned kForceEarlyDepthStencil = 0x00000008; // D3D11_SB_GLOBAL_FLAG_FORCE_EARLY_DEPTH_STENCIL
  36. const unsigned kEnableRawAndStructuredBuffers = 0x00000010; // D3D11_SB_GLOBAL_FLAG_ENABLE_RAW_AND_STRUCTURED_BUFFERS
  37. const unsigned kEnableMinPrecision = 0x00000020; // D3D11_1_SB_GLOBAL_FLAG_ENABLE_MINIMUM_PRECISION
  38. const unsigned kEnableDoubleExtensions = 0x00000040; // D3D11_1_SB_GLOBAL_FLAG_ENABLE_DOUBLE_EXTENSIONS
  39. const unsigned kEnableMSAD = 0x00000080; // D3D11_1_SB_GLOBAL_FLAG_ENABLE_SHADER_EXTENSIONS
  40. const unsigned kAllResourcesBound = 0x00000100; // D3D12_SB_GLOBAL_FLAG_ALL_RESOURCES_BOUND
  41. const unsigned kNumOutputStreams = 4;
  42. const unsigned kNumClipPlanes = 6;
  43. // TODO: move these to appropriate places (ShaderModel.cpp?)
  44. const unsigned kMaxTempRegCount = 4096; // DXBC only
  45. const unsigned kMaxCBufferSize = 4096;
  46. const unsigned kMaxStructBufferStride = 2048;
  47. const unsigned kMaxHSOutputControlPointsTotalScalars = 3968;
  48. const unsigned kMaxHSOutputPatchConstantTotalScalars = 32*4;
  49. const unsigned kMaxOutputTotalScalars = 32*4;
  50. const unsigned kMaxInputTotalScalars = 32*4;
  51. const unsigned kMaxClipOrCullDistanceElementCount = 2;
  52. const unsigned kMaxClipOrCullDistanceCount = 2 * 4;
  53. const unsigned kMaxGSOutputVertexCount = 1024;
  54. const unsigned kMaxGSInstanceCount = 32;
  55. const unsigned kMaxIAPatchControlPointCount = 32;
  56. const float kHSMaxTessFactorLowerBound = 1.0f;
  57. const float kHSMaxTessFactorUpperBound = 64.0f;
  58. const unsigned kMaxCSThreadsPerGroup = 1024;
  59. const unsigned kMaxCSThreadGroupX = 1024;
  60. const unsigned kMaxCSThreadGroupY = 1024;
  61. const unsigned kMaxCSThreadGroupZ = 64;
  62. const unsigned kMinCSThreadGroupX = 1;
  63. const unsigned kMinCSThreadGroupY = 1;
  64. const unsigned kMinCSThreadGroupZ = 1;
  65. const unsigned kMaxCS4XThreadsPerGroup = 768;
  66. const unsigned kMaxCS4XThreadGroupX = 768;
  67. const unsigned kMaxCS4XThreadGroupY = 768;
  68. const unsigned kMaxTGSMSize = 8192*4;
  69. const unsigned kMaxGSOutputTotalScalars = 1024;
  70. const float kMaxMipLodBias = 15.99f;
  71. const float kMinMipLodBias = -16.0f;
  72. const unsigned kResRetStatusIndex = 4;
  73. enum class ComponentType : uint8_t {
  74. Invalid = 0,
  75. I1, I16, U16, I32, U32, I64, U64,
  76. F16, F32, F64,
  77. SNormF16, UNormF16, SNormF32, UNormF32, SNormF64, UNormF64,
  78. LastEntry };
  79. enum class InterpolationMode : uint8_t {
  80. Undefined = 0,
  81. Constant = 1,
  82. Linear = 2,
  83. LinearCentroid = 3,
  84. LinearNoperspective = 4,
  85. LinearNoperspectiveCentroid = 5,
  86. LinearSample = 6,
  87. LinearNoperspectiveSample = 7,
  88. Invalid = 8
  89. };
  90. // size of each scalar type in signature element in bits
  91. enum class SignatureDataWidth : uint8_t {
  92. Undefined = 0,
  93. Bits16 = 16,
  94. Bits32 = 32,
  95. };
  96. enum class SignatureKind {
  97. Invalid = 0,
  98. Input,
  99. Output,
  100. PatchConstant,
  101. };
  102. enum class ShaderKind {
  103. Pixel = 0,
  104. Vertex,
  105. Geometry,
  106. Hull,
  107. Domain,
  108. Compute,
  109. Library,
  110. Invalid,
  111. };
  112. /* <py::lines('SemanticKind-ENUM')>hctdb_instrhelp.get_enum_decl("SemanticKind", hide_val=True, sort_val=False)</py>*/
  113. // SemanticKind-ENUM:BEGIN
  114. // Semantic kind; Arbitrary or specific system value.
  115. enum class SemanticKind : unsigned {
  116. Arbitrary,
  117. VertexID,
  118. InstanceID,
  119. Position,
  120. RenderTargetArrayIndex,
  121. ViewPortArrayIndex,
  122. ClipDistance,
  123. CullDistance,
  124. OutputControlPointID,
  125. DomainLocation,
  126. PrimitiveID,
  127. GSInstanceID,
  128. SampleIndex,
  129. IsFrontFace,
  130. Coverage,
  131. InnerCoverage,
  132. Target,
  133. Depth,
  134. DepthLessEqual,
  135. DepthGreaterEqual,
  136. StencilRef,
  137. DispatchThreadID,
  138. GroupID,
  139. GroupIndex,
  140. GroupThreadID,
  141. TessFactor,
  142. InsideTessFactor,
  143. ViewID,
  144. Barycentrics,
  145. Invalid,
  146. };
  147. // SemanticKind-ENUM:END
  148. /* <py::lines('SigPointKind-ENUM')>hctdb_instrhelp.get_enum_decl("SigPointKind", hide_val=True, sort_val=False)</py>*/
  149. // SigPointKind-ENUM:BEGIN
  150. // Signature Point is more specific than shader stage or signature as it is unique in both stage and item dimensionality or frequency.
  151. enum class SigPointKind : unsigned {
  152. VSIn, // Ordinary Vertex Shader input from Input Assembler
  153. VSOut, // Ordinary Vertex Shader output that may feed Rasterizer
  154. PCIn, // Patch Constant function non-patch inputs
  155. HSIn, // Hull Shader function non-patch inputs
  156. HSCPIn, // Hull Shader patch inputs - Control Points
  157. HSCPOut, // Hull Shader function output - Control Point
  158. PCOut, // Patch Constant function output - Patch Constant data passed to Domain Shader
  159. DSIn, // Domain Shader regular input - Patch Constant data plus system values
  160. DSCPIn, // Domain Shader patch input - Control Points
  161. DSOut, // Domain Shader output - vertex data that may feed Rasterizer
  162. GSVIn, // Geometry Shader vertex input - qualified with primitive type
  163. GSIn, // Geometry Shader non-vertex inputs (system values)
  164. GSOut, // Geometry Shader output - vertex data that may feed Rasterizer
  165. PSIn, // Pixel Shader input
  166. PSOut, // Pixel Shader output
  167. CSIn, // Compute Shader input
  168. Invalid,
  169. };
  170. // SigPointKind-ENUM:END
  171. /* <py::lines('SemanticInterpretationKind-ENUM')>hctdb_instrhelp.get_enum_decl("SemanticInterpretationKind", hide_val=True, sort_val=False)</py>*/
  172. // SemanticInterpretationKind-ENUM:BEGIN
  173. // Defines how a semantic is interpreted at a particular SignaturePoint
  174. enum class SemanticInterpretationKind : unsigned {
  175. NA, // Not Available
  176. SV, // Normal System Value
  177. SGV, // System Generated Value (sorted last)
  178. Arb, // Treated as Arbitrary
  179. NotInSig, // Not included in signature (intrinsic access)
  180. NotPacked, // Included in signature, but does not contribute to packing
  181. Target, // Special handling for SV_Target
  182. TessFactor, // Special handling for tessellation factors
  183. Shadow, // Shadow element must be added to a signature for compatibility
  184. Invalid,
  185. };
  186. // SemanticInterpretationKind-ENUM:END
  187. /* <py::lines('PackingKind-ENUM')>hctdb_instrhelp.get_enum_decl("PackingKind", hide_val=True, sort_val=False)</py>*/
  188. // PackingKind-ENUM:BEGIN
  189. // Kind of signature point
  190. enum class PackingKind : unsigned {
  191. None, // No packing should be performed
  192. InputAssembler, // Vertex Shader input from Input Assembler
  193. Vertex, // Vertex that may feed the Rasterizer
  194. PatchConstant, // Patch constant signature
  195. Target, // Render Target (Pixel Shader Output)
  196. Invalid,
  197. };
  198. // PackingKind-ENUM:END
  199. /* <py::lines('FPDenormMode-ENUM')>hctdb_instrhelp.get_enum_decl("Float32DenormMode", hide_val=False, sort_val=False)</py>*/
  200. // FPDenormMode-ENUM:BEGIN
  201. // float32 denorm behavior
  202. enum class Float32DenormMode : unsigned {
  203. Any = 0, // Undefined behavior for denormal numbers
  204. Preserve = 1, // Preserve both input and output
  205. FTZ = 2, // Preserve denormal inputs. Flush denorm outputs
  206. Reserve3 = 3, // Reserved Value. Not used for now
  207. Reserve4 = 4, // Reserved Value. Not used for now
  208. Reserve5 = 5, // Reserved Value. Not used for now
  209. Reserve6 = 6, // Reserved Value. Not used for now
  210. Reserve7 = 7, // Reserved Value. Not used for now
  211. };
  212. // FPDenormMode-ENUM:END
  213. enum class PackingStrategy : unsigned {
  214. Default = 0, // Choose default packing algorithm based on target (currently PrefixStable)
  215. PrefixStable, // Maintain assumption that all elements are packed in order and stable as new elements are added.
  216. Optimized, // Optimize packing of all elements together (all elements must be present, in the same order, for identical placement of any individual element)
  217. Invalid,
  218. };
  219. enum class SamplerKind : unsigned {
  220. Default = 0,
  221. Comparison,
  222. Mono,
  223. Invalid,
  224. };
  225. enum class ResourceClass {
  226. SRV = 0,
  227. UAV,
  228. CBuffer,
  229. Sampler,
  230. Invalid
  231. };
  232. enum class ResourceKind : unsigned {
  233. Invalid = 0,
  234. Texture1D,
  235. Texture2D,
  236. Texture2DMS,
  237. Texture3D,
  238. TextureCube,
  239. Texture1DArray,
  240. Texture2DArray,
  241. Texture2DMSArray,
  242. TextureCubeArray,
  243. TypedBuffer,
  244. RawBuffer,
  245. StructuredBuffer,
  246. CBuffer,
  247. Sampler,
  248. TBuffer,
  249. NumEntries,
  250. };
  251. // TODO: change opcodes.
  252. /* <py::lines('OPCODE-ENUM')>hctdb_instrhelp.get_enum_decl("OpCode")</py>*/
  253. // OPCODE-ENUM:BEGIN
  254. // Enumeration for operations specified by DXIL
  255. enum class OpCode : unsigned {
  256. // Binary float
  257. FMax = 35, // returns a if a >= b, else b
  258. FMin = 36, // returns a if a < b, else b
  259. // Binary int with two outputs
  260. IMul = 41, // multiply of 32-bit operands to produce the correct full 64-bit result.
  261. // Binary int
  262. IMax = 37, // IMax(a,b) returns a if a > b, else b
  263. IMin = 38, // IMin(a,b) returns a if a < b, else b
  264. // Binary uint with carry or borrow
  265. UAddc = 44, // unsigned add of 32-bit operand with the carry
  266. USubb = 45, // unsigned subtract of 32-bit operands with the borrow
  267. // Binary uint with two outputs
  268. UDiv = 43, // unsigned divide of the 32-bit operand src0 by the 32-bit operand src1.
  269. UMul = 42, // multiply of 32-bit operands to produce the correct full 64-bit result.
  270. // Binary uint
  271. UMax = 39, // unsigned integer maximum. UMax(a,b) = a > b ? a : b
  272. UMin = 40, // unsigned integer minimum. UMin(a,b) = a < b ? a : b
  273. // Bitcasts with different sizes
  274. BitcastF16toI16 = 125, // bitcast between different sizes
  275. BitcastF32toI32 = 127, // bitcast between different sizes
  276. BitcastF64toI64 = 129, // bitcast between different sizes
  277. BitcastI16toF16 = 124, // bitcast between different sizes
  278. BitcastI32toF32 = 126, // bitcast between different sizes
  279. BitcastI64toF64 = 128, // bitcast between different sizes
  280. // Compute shader
  281. FlattenedThreadIdInGroup = 96, // provides a flattened index for a given thread within a given group (SV_GroupIndex)
  282. GroupId = 94, // reads the group ID (SV_GroupID)
  283. ThreadId = 93, // reads the thread ID
  284. ThreadIdInGroup = 95, // reads the thread ID within the group (SV_GroupThreadID)
  285. // Domain and hull shader
  286. LoadOutputControlPoint = 103, // LoadOutputControlPoint
  287. LoadPatchConstant = 104, // LoadPatchConstant
  288. // Domain shader
  289. DomainLocation = 105, // DomainLocation
  290. // Dot
  291. Dot2 = 54, // Two-dimensional vector dot-product
  292. Dot3 = 55, // Three-dimensional vector dot-product
  293. Dot4 = 56, // Four-dimensional vector dot-product
  294. // Double precision
  295. LegacyDoubleToFloat = 132, // legacy fuction to convert double to float
  296. LegacyDoubleToSInt32 = 133, // legacy fuction to convert double to int32
  297. LegacyDoubleToUInt32 = 134, // legacy fuction to convert double to uint32
  298. MakeDouble = 101, // creates a double value
  299. SplitDouble = 102, // splits a double into low and high parts
  300. // Geometry shader
  301. CutStream = 98, // completes the current primitive topology at the specified stream
  302. EmitStream = 97, // emits a vertex to a given stream
  303. EmitThenCutStream = 99, // equivalent to an EmitStream followed by a CutStream
  304. GSInstanceID = 100, // GSInstanceID
  305. // Graphics shader
  306. ViewID = 138, // returns the view index
  307. // Hull shader
  308. OutputControlPointID = 107, // OutputControlPointID
  309. PrimitiveID = 108, // PrimitiveID
  310. StorePatchConstant = 106, // StorePatchConstant
  311. // Legacy floating-point
  312. LegacyF16ToF32 = 131, // legacy fuction to convert half (f16) to float (f32) (this is not related to min-precision)
  313. LegacyF32ToF16 = 130, // legacy fuction to convert float (f32) to half (f16) (this is not related to min-precision)
  314. // Other
  315. CycleCounterLegacy = 109, // CycleCounterLegacy
  316. // Pixel shader
  317. AttributeAtVertex = 137, // returns the values of the attributes at the vertex.
  318. CalculateLOD = 81, // calculates the level of detail
  319. Coverage = 91, // returns the coverage mask input in a pixel shader
  320. DerivCoarseX = 83, // computes the rate of change per stamp in x direction.
  321. DerivCoarseY = 84, // computes the rate of change per stamp in y direction.
  322. DerivFineX = 85, // computes the rate of change per pixel in x direction.
  323. DerivFineY = 86, // computes the rate of change per pixel in y direction.
  324. Discard = 82, // discard the current pixel
  325. EvalCentroid = 89, // evaluates an input attribute at pixel center
  326. EvalSampleIndex = 88, // evaluates an input attribute at a sample location
  327. EvalSnapped = 87, // evaluates an input attribute at pixel center with an offset
  328. InnerCoverage = 92, // returns underestimated coverage input from conservative rasterization in a pixel shader
  329. SampleIndex = 90, // returns the sample index in a sample-frequency pixel shader
  330. // Quaternary
  331. Bfi = 53, // Given a bit range from the LSB of a number, places that number of bits in another number at any offset
  332. // Resources - gather
  333. TextureGather = 73, // gathers the four texels that would be used in a bi-linear filtering operation
  334. TextureGatherCmp = 74, // same as TextureGather, except this instrution performs comparison on texels, similar to SampleCmp
  335. // Resources - sample
  336. RenderTargetGetSampleCount = 77, // gets the number of samples for a render target
  337. RenderTargetGetSamplePosition = 76, // gets the position of the specified sample
  338. Sample = 60, // samples a texture
  339. SampleBias = 61, // samples a texture after applying the input bias to the mipmap level
  340. SampleCmp = 64, // samples a texture and compares a single component against the specified comparison value
  341. SampleCmpLevelZero = 65, // samples a texture and compares a single component against the specified comparison value
  342. SampleGrad = 63, // samples a texture using a gradient to influence the way the sample location is calculated
  343. SampleLevel = 62, // samples a texture using a mipmap-level offset
  344. Texture2DMSGetSamplePosition = 75, // gets the position of the specified sample
  345. // Resources
  346. BufferLoad = 68, // reads from a TypedBuffer
  347. BufferStore = 69, // writes to a RWTypedBuffer
  348. BufferUpdateCounter = 70, // atomically increments/decrements the hidden 32-bit counter stored with a Count or Append UAV
  349. CBufferLoad = 58, // loads a value from a constant buffer resource
  350. CBufferLoadLegacy = 59, // loads a value from a constant buffer resource
  351. CheckAccessFullyMapped = 71, // determines whether all values from a Sample, Gather, or Load operation accessed mapped tiles in a tiled resource
  352. CreateHandle = 57, // creates the handle to a resource
  353. GetDimensions = 72, // gets texture size information
  354. RawBufferLoad = 139, // reads from a raw buffer and structured buffer
  355. RawBufferStore = 140, // writes to a RWByteAddressBuffer or RWStructuredBuffer
  356. TextureLoad = 66, // reads texel data without any filtering or sampling
  357. TextureStore = 67, // reads texel data without any filtering or sampling
  358. // Synchronization
  359. AtomicBinOp = 78, // performs an atomic operation on two operands
  360. AtomicCompareExchange = 79, // atomic compare and exchange to memory
  361. Barrier = 80, // inserts a memory barrier in the shader
  362. // Temporary, indexable, input, output registers
  363. LoadInput = 4, // Loads the value from shader input
  364. MinPrecXRegLoad = 2, // Helper load operation for minprecision
  365. MinPrecXRegStore = 3, // Helper store operation for minprecision
  366. StoreOutput = 5, // Stores the value to shader output
  367. TempRegLoad = 0, // Helper load operation
  368. TempRegStore = 1, // Helper store operation
  369. // Tertiary float
  370. FMad = 46, // floating point multiply & add
  371. Fma = 47, // fused multiply-add
  372. // Tertiary int
  373. IMad = 48, // Signed integer multiply & add
  374. Ibfe = 51, // Integer bitfield extract
  375. Msad = 50, // masked Sum of Absolute Differences.
  376. // Tertiary uint
  377. UMad = 49, // Unsigned integer multiply & add
  378. Ubfe = 52, // Unsigned integer bitfield extract
  379. // Unary float - rounding
  380. Round_ne = 26, // floating-point round to integral float.
  381. Round_ni = 27, // floating-point round to integral float.
  382. Round_pi = 28, // floating-point round to integral float.
  383. Round_z = 29, // floating-point round to integral float.
  384. // Unary float
  385. Acos = 15, // Returns the arccosine of the specified value. Input should be a floating-point value within the range of -1 to 1.
  386. Asin = 16, // Returns the arccosine of the specified value. Input should be a floating-point value within the range of -1 to 1
  387. Atan = 17, // Returns the arctangent of the specified value. The return value is within the range of -PI/2 to PI/2.
  388. Cos = 12, // returns cosine(theta) for theta in radians.
  389. Exp = 21, // returns 2^exponent
  390. FAbs = 6, // returns the absolute value of the input value.
  391. Frc = 22, // extract fracitonal component.
  392. Hcos = 18, // returns the hyperbolic cosine of the specified value.
  393. Hsin = 19, // returns the hyperbolic sine of the specified value.
  394. Htan = 20, // returns the hyperbolic tangent of the specified value.
  395. IsFinite = 10, // Returns true if x is finite, false otherwise.
  396. IsInf = 9, // Returns true if x is +INF or -INF, false otherwise.
  397. IsNaN = 8, // Returns true if x is NAN or QNAN, false otherwise.
  398. IsNormal = 11, // returns IsNormal
  399. Log = 23, // returns log base 2.
  400. Rsqrt = 25, // returns reciprocal square root (1 / sqrt(src)
  401. Saturate = 7, // clamps the result of a single or double precision floating point value to [0.0f...1.0f]
  402. Sin = 13, // returns sine(theta) for theta in radians.
  403. Sqrt = 24, // returns square root
  404. Tan = 14, // returns tan(theta) for theta in radians.
  405. // Unary int
  406. Bfrev = 30, // Reverses the order of the bits.
  407. Countbits = 31, // Counts the number of bits in the input integer.
  408. FirstbitLo = 32, // Returns the location of the first set bit starting from the lowest order bit and working upward.
  409. FirstbitSHi = 34, // Returns the location of the first set bit from the highest order bit based on the sign.
  410. // Unary uint
  411. FirstbitHi = 33, // Returns the location of the first set bit starting from the highest order bit and working downward.
  412. // Wave
  413. QuadOp = 123, // returns the result of a quad-level operation
  414. QuadReadLaneAt = 122, // reads from a lane in the quad
  415. WaveActiveAllEqual = 115, // returns 1 if all the lanes have the same value
  416. WaveActiveBallot = 116, // returns a struct with a bit set for each lane where the condition is true
  417. WaveActiveBit = 120, // returns the result of the operation across all lanes
  418. WaveActiveOp = 119, // returns the result the operation across waves
  419. WaveAllBitCount = 135, // returns the count of bits set to 1 across the wave
  420. WaveAllTrue = 114, // returns 1 if all the lanes evaluate the value to true
  421. WaveAnyTrue = 113, // returns 1 if any of the lane evaluates the value to true
  422. WaveGetLaneCount = 112, // returns the number of lanes in the wave
  423. WaveGetLaneIndex = 111, // returns the index of the current lane in the wave
  424. WaveIsFirstLane = 110, // returns 1 for the first lane in the wave
  425. WavePrefixBitCount = 136, // returns the count of bits set to 1 on prior lanes
  426. WavePrefixOp = 121, // returns the result of the operation on prior lanes
  427. WaveReadLaneAt = 117, // returns the value from the specified lane
  428. WaveReadLaneFirst = 118, // returns the value from the first lane
  429. NumOpCodes_Dxil_1_0 = 137,
  430. NumOpCodes_Dxil_1_1 = 139,
  431. NumOpCodes_Dxil_1_2 = 141,
  432. NumOpCodes = 141 // exclusive last value of enumeration
  433. };
  434. // OPCODE-ENUM:END
  435. /* <py::lines('OPCODECLASS-ENUM')>hctdb_instrhelp.get_enum_decl("OpCodeClass")</py>*/
  436. // OPCODECLASS-ENUM:BEGIN
  437. // Groups for DXIL operations with equivalent function templates
  438. enum class OpCodeClass : unsigned {
  439. // Binary uint with carry or borrow
  440. BinaryWithCarryOrBorrow,
  441. // Binary uint with two outputs
  442. BinaryWithTwoOuts,
  443. // Binary uint
  444. Binary,
  445. // Bitcasts with different sizes
  446. BitcastF16toI16,
  447. BitcastF32toI32,
  448. BitcastF64toI64,
  449. BitcastI16toF16,
  450. BitcastI32toF32,
  451. BitcastI64toF64,
  452. // Compute shader
  453. FlattenedThreadIdInGroup,
  454. GroupId,
  455. ThreadId,
  456. ThreadIdInGroup,
  457. // Domain and hull shader
  458. LoadOutputControlPoint,
  459. LoadPatchConstant,
  460. // Domain shader
  461. DomainLocation,
  462. // Dot
  463. Dot2,
  464. Dot3,
  465. Dot4,
  466. // Double precision
  467. LegacyDoubleToFloat,
  468. LegacyDoubleToSInt32,
  469. LegacyDoubleToUInt32,
  470. MakeDouble,
  471. SplitDouble,
  472. // Geometry shader
  473. CutStream,
  474. EmitStream,
  475. EmitThenCutStream,
  476. GSInstanceID,
  477. // Graphics shader
  478. ViewID,
  479. // Hull shader
  480. OutputControlPointID,
  481. PrimitiveID,
  482. StorePatchConstant,
  483. // LLVM Instructions
  484. LlvmInst,
  485. // Legacy floating-point
  486. LegacyF16ToF32,
  487. LegacyF32ToF16,
  488. // Other
  489. CycleCounterLegacy,
  490. // Pixel shader
  491. AttributeAtVertex,
  492. CalculateLOD,
  493. Coverage,
  494. Discard,
  495. EvalCentroid,
  496. EvalSampleIndex,
  497. EvalSnapped,
  498. InnerCoverage,
  499. SampleIndex,
  500. Unary,
  501. // Quaternary
  502. Quaternary,
  503. // Resources - gather
  504. TextureGather,
  505. TextureGatherCmp,
  506. // Resources - sample
  507. RenderTargetGetSampleCount,
  508. RenderTargetGetSamplePosition,
  509. Sample,
  510. SampleBias,
  511. SampleCmp,
  512. SampleCmpLevelZero,
  513. SampleGrad,
  514. SampleLevel,
  515. Texture2DMSGetSamplePosition,
  516. // Resources
  517. BufferLoad,
  518. BufferStore,
  519. BufferUpdateCounter,
  520. CBufferLoad,
  521. CBufferLoadLegacy,
  522. CheckAccessFullyMapped,
  523. CreateHandle,
  524. GetDimensions,
  525. RawBufferLoad,
  526. RawBufferStore,
  527. TextureLoad,
  528. TextureStore,
  529. // Synchronization
  530. AtomicBinOp,
  531. AtomicCompareExchange,
  532. Barrier,
  533. // Temporary, indexable, input, output registers
  534. LoadInput,
  535. MinPrecXRegLoad,
  536. MinPrecXRegStore,
  537. StoreOutput,
  538. TempRegLoad,
  539. TempRegStore,
  540. // Tertiary uint
  541. Tertiary,
  542. // Unary float
  543. IsSpecialFloat,
  544. // Unary int
  545. UnaryBits,
  546. // Wave
  547. QuadOp,
  548. QuadReadLaneAt,
  549. WaveActiveAllEqual,
  550. WaveActiveBallot,
  551. WaveActiveBit,
  552. WaveActiveOp,
  553. WaveAllOp,
  554. WaveAllTrue,
  555. WaveAnyTrue,
  556. WaveGetLaneCount,
  557. WaveGetLaneIndex,
  558. WaveIsFirstLane,
  559. WavePrefixOp,
  560. WaveReadLaneAt,
  561. WaveReadLaneFirst,
  562. NumOpClasses_Dxil_1_0 = 93,
  563. NumOpClasses_Dxil_1_1 = 95,
  564. NumOpClasses_Dxil_1_2 = 97,
  565. NumOpClasses = 97 // exclusive last value of enumeration
  566. };
  567. // OPCODECLASS-ENUM:END
  568. // Operand Index for every OpCodeClass.
  569. namespace OperandIndex {
  570. // Opcode is always operand 0.
  571. const unsigned kOpcodeIdx = 0;
  572. // Unary operators.
  573. const unsigned kUnarySrc0OpIdx = 1;
  574. // Binary operators.
  575. const unsigned kBinarySrc0OpIdx = 1;
  576. const unsigned kBinarySrc1OpIdx = 2;
  577. // Trinary operators.
  578. const unsigned kTrinarySrc0OpIdx = 1;
  579. const unsigned kTrinarySrc1OpIdx = 2;
  580. const unsigned kTrinarySrc2OpIdx = 3;
  581. // LoadInput.
  582. const unsigned kLoadInputIDOpIdx = 1;
  583. const unsigned kLoadInputRowOpIdx = 2;
  584. const unsigned kLoadInputColOpIdx = 3;
  585. const unsigned kLoadInputVertexIDOpIdx = 4;
  586. // StoreOutput.
  587. const unsigned kStoreOutputIDOpIdx = 1;
  588. const unsigned kStoreOutputRowOpIdx = 2;
  589. const unsigned kStoreOutputColOpIdx = 3;
  590. const unsigned kStoreOutputValOpIdx = 4;
  591. // DomainLocation.
  592. const unsigned kDomainLocationColOpIdx = 1;
  593. // BufferLoad.
  594. const unsigned kBufferLoadHandleOpIdx = 1;
  595. const unsigned kBufferLoadCoord0OpIdx = 2;
  596. const unsigned kBufferLoadCoord1OpIdx = 3;
  597. // BufferStore.
  598. const unsigned kBufferStoreHandleOpIdx = 1;
  599. const unsigned kBufferStoreCoord0OpIdx = 2;
  600. const unsigned kBufferStoreCoord1OpIdx = 3;
  601. const unsigned kBufferStoreVal0OpIdx = 4;
  602. const unsigned kBufferStoreVal1OpIdx = 5;
  603. const unsigned kBufferStoreVal2OpIdx = 6;
  604. const unsigned kBufferStoreVal3OpIdx = 7;
  605. const unsigned kBufferStoreMaskOpIdx = 8;
  606. // RawBufferLoad.
  607. const unsigned kRawBufferLoadHandleOpIdx = 1;
  608. const unsigned kRawBufferLoadIndexOpIdx = 2;
  609. const unsigned kRawBufferLoadElementOffsetOpIdx = 3;
  610. const unsigned kRawBufferLoadMaskOpIdx = 4;
  611. const unsigned kRawBufferLoadAlignmentOpIdx = 5;
  612. // RawBufferStore
  613. const unsigned kRawBufferStoreHandleOpIdx = 1;
  614. const unsigned kRawBufferStoreIndexOpIdx = 2;
  615. const unsigned kRawBufferStoreElementOffsetOpIdx = 3;
  616. const unsigned kRawBufferStoreVal0OpIdx = 4;
  617. const unsigned kRawBufferStoreVal1OpIdx = 5;
  618. const unsigned kRawBufferStoreVal2OpIdx = 6;
  619. const unsigned kRawBufferStoreVal3OpIdx = 7;
  620. const unsigned kRawBufferStoreMaskOpIdx = 8;
  621. const unsigned kRawBufferStoreAlignmentOpIdx = 8;
  622. // TextureStore.
  623. const unsigned kTextureStoreHandleOpIdx = 1;
  624. const unsigned kTextureStoreCoord0OpIdx = 2;
  625. const unsigned kTextureStoreCoord1OpIdx = 3;
  626. const unsigned kTextureStoreCoord2OpIdx = 4;
  627. const unsigned kTextureStoreVal0OpIdx = 5;
  628. const unsigned kTextureStoreVal1OpIdx = 6;
  629. const unsigned kTextureStoreVal2OpIdx = 7;
  630. const unsigned kTextureStoreVal3OpIdx = 8;
  631. const unsigned kTextureStoreMaskOpIdx = 9;
  632. // TextureGather.
  633. const unsigned kTextureGatherTexHandleOpIdx = 1;
  634. const unsigned kTextureGatherSamplerHandleOpIdx = 2;
  635. const unsigned kTextureGatherCoord0OpIdx = 3;
  636. const unsigned kTextureGatherCoord1OpIdx = 4;
  637. const unsigned kTextureGatherCoord2OpIdx = 5;
  638. const unsigned kTextureGatherCoord3OpIdx = 6;
  639. const unsigned kTextureGatherOffset0OpIdx = 7;
  640. const unsigned kTextureGatherOffset1OpIdx = 8;
  641. const unsigned kTextureGatherOffset2OpIdx = 9;
  642. const unsigned kTextureGatherChannelOpIdx = 10;
  643. // TextureGatherCmp.
  644. const unsigned kTextureGatherCmpCmpValOpIdx = 11;
  645. // TextureSample.
  646. const unsigned kTextureSampleTexHandleOpIdx = 1;
  647. const unsigned kTextureSampleSamplerHandleOpIdx = 2;
  648. const unsigned kTextureSampleCoord0OpIdx = 3;
  649. const unsigned kTextureSampleCoord1OpIdx = 4;
  650. const unsigned kTextureSampleCoord2OpIdx = 5;
  651. const unsigned kTextureSampleCoord3OpIdx = 6;
  652. const unsigned kTextureSampleOffset0OpIdx = 7;
  653. const unsigned kTextureSampleOffset1OpIdx = 8;
  654. const unsigned kTextureSampleOffset2OpIdx = 9;
  655. const unsigned kTextureSampleClampOpIdx = 10;
  656. // AtomicBinOp.
  657. const unsigned kAtomicBinOpCoord0OpIdx = 3;
  658. const unsigned kAtomicBinOpCoord1OpIdx = 4;
  659. const unsigned kAtomicBinOpCoord2OpIdx = 5;
  660. // AtomicCmpExchange.
  661. const unsigned kAtomicCmpExchangeCoord0OpIdx = 2;
  662. const unsigned kAtomicCmpExchangeCoord1OpIdx = 3;
  663. const unsigned kAtomicCmpExchangeCoord2OpIdx = 4;
  664. // CreateHandle
  665. const unsigned kCreateHandleResClassOpIdx = 1;
  666. const unsigned kCreateHandleResIDOpIdx = 2;
  667. const unsigned kCreateHandleResIndexOpIdx = 3;
  668. const unsigned kCreateHandleIsUniformOpIdx = 4;
  669. // Emit/Cut
  670. const unsigned kStreamEmitCutIDOpIdx = 1;
  671. // TODO: add operand index for all the OpCodeClass.
  672. }
  673. // Atomic binary operation kind.
  674. enum class AtomicBinOpCode : unsigned {
  675. Add,
  676. And,
  677. Or,
  678. Xor,
  679. IMin,
  680. IMax,
  681. UMin,
  682. UMax,
  683. Exchange,
  684. Invalid // Must be last.
  685. };
  686. // Barrier/fence modes.
  687. enum class BarrierMode : unsigned {
  688. SyncThreadGroup = 0x00000001,
  689. UAVFenceGlobal = 0x00000002,
  690. UAVFenceThreadGroup = 0x00000004,
  691. TGSMFence = 0x00000008,
  692. };
  693. // Address space.
  694. const unsigned kDefaultAddrSpace = 0;
  695. const unsigned kDeviceMemoryAddrSpace = 1;
  696. const unsigned kCBufferAddrSpace = 2;
  697. const unsigned kTGSMAddrSpace = 3;
  698. const unsigned kGenericPointerAddrSpace = 4;
  699. const unsigned kImmediateCBufferAddrSpace = 5;
  700. // Input primitive.
  701. enum class InputPrimitive : unsigned {
  702. Undefined = 0,
  703. Point = 1,
  704. Line = 2,
  705. Triangle = 3,
  706. Reserved4 = 4,
  707. Reserved5 = 5,
  708. LineWithAdjacency = 6,
  709. TriangleWithAdjacency = 7,
  710. ControlPointPatch1 = 8,
  711. ControlPointPatch2 = 9,
  712. ControlPointPatch3 = 10,
  713. ControlPointPatch4 = 11,
  714. ControlPointPatch5 = 12,
  715. ControlPointPatch6 = 13,
  716. ControlPointPatch7 = 14,
  717. ControlPointPatch8 = 15,
  718. ControlPointPatch9 = 16,
  719. ControlPointPatch10 = 17,
  720. ControlPointPatch11 = 18,
  721. ControlPointPatch12 = 19,
  722. ControlPointPatch13 = 20,
  723. ControlPointPatch14 = 21,
  724. ControlPointPatch15 = 22,
  725. ControlPointPatch16 = 23,
  726. ControlPointPatch17 = 24,
  727. ControlPointPatch18 = 25,
  728. ControlPointPatch19 = 26,
  729. ControlPointPatch20 = 27,
  730. ControlPointPatch21 = 28,
  731. ControlPointPatch22 = 29,
  732. ControlPointPatch23 = 30,
  733. ControlPointPatch24 = 31,
  734. ControlPointPatch25 = 32,
  735. ControlPointPatch26 = 33,
  736. ControlPointPatch27 = 34,
  737. ControlPointPatch28 = 35,
  738. ControlPointPatch29 = 36,
  739. ControlPointPatch30 = 37,
  740. ControlPointPatch31 = 38,
  741. ControlPointPatch32 = 39,
  742. LastEntry,
  743. };
  744. // Primitive topology.
  745. enum class PrimitiveTopology : unsigned {
  746. Undefined = 0,
  747. PointList = 1,
  748. LineList = 2,
  749. LineStrip = 3,
  750. TriangleList = 4,
  751. TriangleStrip = 5,
  752. LastEntry,
  753. };
  754. enum class TessellatorDomain
  755. {
  756. Undefined = 0,
  757. IsoLine = 1,
  758. Tri = 2,
  759. Quad = 3,
  760. LastEntry,
  761. };
  762. enum class TessellatorOutputPrimitive
  763. {
  764. Undefined = 0,
  765. Point = 1,
  766. Line = 2,
  767. TriangleCW = 3,
  768. TriangleCCW = 4,
  769. LastEntry,
  770. };
  771. // Tessellator partitioning.
  772. enum class TessellatorPartitioning : unsigned {
  773. Undefined = 0,
  774. Integer,
  775. Pow2,
  776. FractionalOdd,
  777. FractionalEven,
  778. LastEntry,
  779. };
  780. // Kind of quad-level operation
  781. enum class QuadOpKind {
  782. ReadAcrossX = 0, // returns the value from the other lane in the quad in the horizontal direction
  783. ReadAcrossY = 1, // returns the value from the other lane in the quad in the vertical direction
  784. ReadAcrossDiagonal = 2, // returns the value from the lane across the quad in horizontal and vertical direction
  785. };
  786. /* <py::lines('WAVEBITOPKIND-ENUM')>hctdb_instrhelp.get_enum_decl("WaveBitOpKind")</py>*/
  787. // WAVEBITOPKIND-ENUM:BEGIN
  788. // Kind of bitwise cross-lane operation
  789. enum class WaveBitOpKind : unsigned {
  790. And = 0, // bitwise and of values
  791. Or = 1, // bitwise or of values
  792. Xor = 2, // bitwise xor of values
  793. };
  794. // WAVEBITOPKIND-ENUM:END
  795. /* <py::lines('WAVEOPKIND-ENUM')>hctdb_instrhelp.get_enum_decl("WaveOpKind")</py>*/
  796. // WAVEOPKIND-ENUM:BEGIN
  797. // Kind of cross-lane operation
  798. enum class WaveOpKind : unsigned {
  799. Max = 3, // maximum value
  800. Min = 2, // minimum value
  801. Product = 1, // product of values
  802. Sum = 0, // sum of values
  803. };
  804. // WAVEOPKIND-ENUM:END
  805. /* <py::lines('SIGNEDOPKIND-ENUM')>hctdb_instrhelp.get_enum_decl("SignedOpKind")</py>*/
  806. // SIGNEDOPKIND-ENUM:BEGIN
  807. // Sign vs. unsigned operands for operation
  808. enum class SignedOpKind : unsigned {
  809. Signed = 0, // signed integer or floating-point operands
  810. Unsigned = 1, // unsigned integer operands
  811. };
  812. // SIGNEDOPKIND-ENUM:END
  813. // Kind of control flow hint
  814. enum class ControlFlowHint : unsigned {
  815. Undefined = 0,
  816. Branch = 1,
  817. Flatten = 2,
  818. FastOpt = 3,
  819. AllowUavCondition = 4,
  820. ForceCase = 5,
  821. Call = 6,
  822. // Loop and Unroll is using llvm.loop.unroll Metadata.
  823. LastEntry,
  824. };
  825. // XYZW component mask.
  826. const uint8_t kCompMask_X = 0x1;
  827. const uint8_t kCompMask_Y = 0x2;
  828. const uint8_t kCompMask_Z = 0x4;
  829. const uint8_t kCompMask_W = 0x8;
  830. const uint8_t kCompMask_All = 0xF;
  831. enum class LowPrecisionMode {
  832. Undefined = 0,
  833. UseMinPrecision,
  834. UseNativeLowPrecision
  835. };
  836. // TODO: revisit data layout descriptions for the following:
  837. // - x64 pointers?
  838. // - Keep elf manging(m:e)?
  839. // For legacy data layout, everything less than 32 align to 32.
  840. static const char* kLegacyLayoutString = "e-m:e-p:32:32-i1:32-i8:32-i16:32-i32:32-i64:64-f16:32-f32:32-f:64:64-n8:16:32:64";
  841. // New data layout with native low precision types
  842. static const char* kNewLayoutString = "e-m:e-p:32:32-i1:32-i8:8-i16:16-i32:32-i64:64-f16:16-f32:32-f64:64-n8:16:32:64";
  843. // Function Attributes
  844. // TODO: consider generating attributes from hctdb
  845. static const char* kFP32DenormKindString = "fp32-denorm-mode";
  846. static const char* kFP32DenormValueAnyString = "any";
  847. static const char* kFP32DenormValuePreserveString = "preserve";
  848. static const char* kFP32DenormValueFtzString = "ftz";
  849. } // namespace DXIL
  850. } // namespace hlsl