d3d12TokenizedProgramFormat.hpp 128 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634
  1. #pragma once
  2. ///////////////////////////////////////////////////////////////////////////////
  3. // //
  4. // d3d12TokenizedProgramFormat.hpp //
  5. // Copyright (C) Microsoft Corporation. All rights reserved. //
  6. // This file is distributed under the University of Illinois Open Source //
  7. // License. See LICENSE.TXT for details. //
  8. // //
  9. // Provides declarations for the DirectX Tokenized Program Format. //
  10. // //
  11. ///////////////////////////////////////////////////////////////////////////////
  12. // ----------------------------------------------------------------------------
  13. //
  14. // High Level Goals
  15. //
  16. // - Serve as the runtime/DDI representation for all D3D11 tokenized code,
  17. // for all classes of programs, including pixel program, vertex program,
  18. // geometry program, etc.
  19. //
  20. // - Any information that HLSL needs to give to drivers is encoded in
  21. // this token format in some form.
  22. //
  23. // - Enable common tools and source code for managing all tokenizable
  24. // program formats.
  25. //
  26. // - Support extensible token definitions, allowing full customizations for
  27. // specific program classes, while maintaining general conventions for all
  28. // program models.
  29. //
  30. // - Binary backwards compatible with D3D10. Any token name that was originally
  31. // defined with "D3D10" in it is unchanged; D3D11 only adds new tokens.
  32. //
  33. // ----------------------------------------------------------------------------
  34. //
  35. // Low Level Feature Summary
  36. //
  37. // - DWORD based tokens always, for simplicity
  38. // - Opcode token is generally a single DWORD, though there is a bit indicating
  39. // if extended information (extra DWORD(s)) are present
  40. // - Operand tokens are a completely self contained, extensible format,
  41. // with scalar and 4-vector data types as first class citizens, but
  42. // allowance for extension to n-component vectors.
  43. // - Initial operand token identifies register type, register file
  44. // structure/dimensionality and mode of indexing for each dimension,
  45. // and choice of component selection mechanism (i.e. mask vs. swizzle etc).
  46. // - Optional additional extended operand tokens can defined things like
  47. // modifiers (which are not needed by default).
  48. // - Operand's immediate index value(s), if needed, appear as subsequent DWORD
  49. // values, and if relative addressing is specified, an additional completely
  50. // self contained operand definition appears nested in the token sequence.
  51. //
  52. // ----------------------------------------------------------------------------
  53. #include <winapifamily.h>
  54. #pragma region Application Family
  55. #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_GAMES)
  56. // ----------------------------------------------------------------------------
  57. // Version Token (VerTok)
  58. //
  59. // [07:00] minor version number (0-255)
  60. // [15:08] major version number (0-255)
  61. // [31:16] D3D10_SB_TOKENIZED_PROGRAM_TYPE
  62. //
  63. // ----------------------------------------------------------------------------
  64. typedef enum D3D10_SB_TOKENIZED_PROGRAM_TYPE
  65. {
  66. D3D10_SB_PIXEL_SHADER = 0,
  67. D3D10_SB_VERTEX_SHADER = 1,
  68. D3D10_SB_GEOMETRY_SHADER = 2,
  69. // D3D11 Shaders
  70. D3D11_SB_HULL_SHADER = 3,
  71. D3D11_SB_DOMAIN_SHADER = 4,
  72. D3D11_SB_COMPUTE_SHADER = 5,
  73. // Subset of D3D12 Shaders where this field is referenced by runtime
  74. // Entries from 6-12 are unique to state objects
  75. // (e.g. library, callable and raytracing shaders)
  76. D3D12_SB_MESH_SHADER = 13,
  77. D3D12_SB_AMPLIFICATION_SHADER = 14,
  78. D3D11_SB_RESERVED0 = 0xFFF0
  79. } D3D10_SB_TOKENIZED_PROGRAM_TYPE;
  80. #define D3D10_SB_TOKENIZED_PROGRAM_TYPE_MASK 0xffff0000
  81. #define D3D10_SB_TOKENIZED_PROGRAM_TYPE_SHIFT 16
  82. // DECODER MACRO: Retrieve program type from version token
  83. #define DECODE_D3D10_SB_TOKENIZED_PROGRAM_TYPE(VerTok) ((D3D10_SB_TOKENIZED_PROGRAM_TYPE)(((VerTok)&D3D10_SB_TOKENIZED_PROGRAM_TYPE_MASK)>>D3D10_SB_TOKENIZED_PROGRAM_TYPE_SHIFT))
  84. #define D3D10_SB_TOKENIZED_PROGRAM_MAJOR_VERSION_MASK 0x000000f0
  85. #define D3D10_SB_TOKENIZED_PROGRAM_MAJOR_VERSION_SHIFT 4
  86. #define D3D10_SB_TOKENIZED_PROGRAM_MINOR_VERSION_MASK 0x0000000f
  87. // DECODER MACRO: Retrieve major version # from version token
  88. #define DECODE_D3D10_SB_TOKENIZED_PROGRAM_MAJOR_VERSION(VerTok) (((VerTok)&D3D10_SB_TOKENIZED_PROGRAM_MAJOR_VERSION_MASK)>>D3D10_SB_TOKENIZED_PROGRAM_MAJOR_VERSION_SHIFT)
  89. // DECODER MACRO: Retrieve minor version # from version token
  90. #define DECODE_D3D10_SB_TOKENIZED_PROGRAM_MINOR_VERSION(VerTok) ((VerTok)&D3D10_SB_TOKENIZED_PROGRAM_MINOR_VERSION_MASK)
  91. // ENCODER MACRO: Create complete VerTok
  92. #define ENCODE_D3D10_SB_TOKENIZED_PROGRAM_VERSION_TOKEN(ProgType,MajorVer,MinorVer) ((((ProgType)<<D3D10_SB_TOKENIZED_PROGRAM_TYPE_SHIFT)&D3D10_SB_TOKENIZED_PROGRAM_TYPE_MASK)|\
  93. ((((MajorVer)<<D3D10_SB_TOKENIZED_PROGRAM_MAJOR_VERSION_SHIFT)&D3D10_SB_TOKENIZED_PROGRAM_MAJOR_VERSION_MASK))|\
  94. ((MinorVer)&D3D10_SB_TOKENIZED_PROGRAM_MINOR_VERSION_MASK))
  95. // ----------------------------------------------------------------------------
  96. // Length Token (LenTok)
  97. //
  98. // Always follows VerTok
  99. //
  100. // [31:00] Unsigned integer count of number of
  101. // DWORDs in program code, including version
  102. // and length tokens. So the minimum value
  103. // is 0x00000002 (if an empty program is ever
  104. // valid).
  105. //
  106. // ----------------------------------------------------------------------------
  107. // DECODER MACRO: Retrieve program length
  108. #define DECODE_D3D10_SB_TOKENIZED_PROGRAM_LENGTH(LenTok) (LenTok)
  109. // ENCODER MACRO: Create complete LenTok
  110. #define ENCODE_D3D10_SB_TOKENIZED_PROGRAM_LENGTH(Length) (Length)
  111. #define MAX_D3D10_SB_TOKENIZED_PROGRAM_LENGTH (0xffffffff)
  112. // ----------------------------------------------------------------------------
  113. // Opcode Format (OpcodeToken0)
  114. //
  115. // [10:00] D3D10_SB_OPCODE_TYPE
  116. // if( [10:00] == D3D10_SB_OPCODE_CUSTOMDATA )
  117. // {
  118. // Token starts a custom-data block. See "Custom-Data Block Format".
  119. // }
  120. // else // standard opcode token
  121. // {
  122. // [23:11] Opcode-Specific Controls
  123. // [30:24] Instruction length in DWORDs including the opcode token.
  124. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD
  125. // contains extended opcode token.
  126. // }
  127. //
  128. // ----------------------------------------------------------------------------
  129. typedef enum D3D10_SB_OPCODE_TYPE {
  130. D3D10_SB_OPCODE_ADD ,
  131. D3D10_SB_OPCODE_AND ,
  132. D3D10_SB_OPCODE_BREAK ,
  133. D3D10_SB_OPCODE_BREAKC ,
  134. D3D10_SB_OPCODE_CALL ,
  135. D3D10_SB_OPCODE_CALLC ,
  136. D3D10_SB_OPCODE_CASE ,
  137. D3D10_SB_OPCODE_CONTINUE ,
  138. D3D10_SB_OPCODE_CONTINUEC ,
  139. D3D10_SB_OPCODE_CUT ,
  140. D3D10_SB_OPCODE_DEFAULT ,
  141. D3D10_SB_OPCODE_DERIV_RTX ,
  142. D3D10_SB_OPCODE_DERIV_RTY ,
  143. D3D10_SB_OPCODE_DISCARD ,
  144. D3D10_SB_OPCODE_DIV ,
  145. D3D10_SB_OPCODE_DP2 ,
  146. D3D10_SB_OPCODE_DP3 ,
  147. D3D10_SB_OPCODE_DP4 ,
  148. D3D10_SB_OPCODE_ELSE ,
  149. D3D10_SB_OPCODE_EMIT ,
  150. D3D10_SB_OPCODE_EMITTHENCUT ,
  151. D3D10_SB_OPCODE_ENDIF ,
  152. D3D10_SB_OPCODE_ENDLOOP ,
  153. D3D10_SB_OPCODE_ENDSWITCH ,
  154. D3D10_SB_OPCODE_EQ ,
  155. D3D10_SB_OPCODE_EXP ,
  156. D3D10_SB_OPCODE_FRC ,
  157. D3D10_SB_OPCODE_FTOI ,
  158. D3D10_SB_OPCODE_FTOU ,
  159. D3D10_SB_OPCODE_GE ,
  160. D3D10_SB_OPCODE_IADD ,
  161. D3D10_SB_OPCODE_IF ,
  162. D3D10_SB_OPCODE_IEQ ,
  163. D3D10_SB_OPCODE_IGE ,
  164. D3D10_SB_OPCODE_ILT ,
  165. D3D10_SB_OPCODE_IMAD ,
  166. D3D10_SB_OPCODE_IMAX ,
  167. D3D10_SB_OPCODE_IMIN ,
  168. D3D10_SB_OPCODE_IMUL ,
  169. D3D10_SB_OPCODE_INE ,
  170. D3D10_SB_OPCODE_INEG ,
  171. D3D10_SB_OPCODE_ISHL ,
  172. D3D10_SB_OPCODE_ISHR ,
  173. D3D10_SB_OPCODE_ITOF ,
  174. D3D10_SB_OPCODE_LABEL ,
  175. D3D10_SB_OPCODE_LD ,
  176. D3D10_SB_OPCODE_LD_MS ,
  177. D3D10_SB_OPCODE_LOG ,
  178. D3D10_SB_OPCODE_LOOP ,
  179. D3D10_SB_OPCODE_LT ,
  180. D3D10_SB_OPCODE_MAD ,
  181. D3D10_SB_OPCODE_MIN ,
  182. D3D10_SB_OPCODE_MAX ,
  183. D3D10_SB_OPCODE_CUSTOMDATA ,
  184. D3D10_SB_OPCODE_MOV ,
  185. D3D10_SB_OPCODE_MOVC ,
  186. D3D10_SB_OPCODE_MUL ,
  187. D3D10_SB_OPCODE_NE ,
  188. D3D10_SB_OPCODE_NOP ,
  189. D3D10_SB_OPCODE_NOT ,
  190. D3D10_SB_OPCODE_OR ,
  191. D3D10_SB_OPCODE_RESINFO ,
  192. D3D10_SB_OPCODE_RET ,
  193. D3D10_SB_OPCODE_RETC ,
  194. D3D10_SB_OPCODE_ROUND_NE ,
  195. D3D10_SB_OPCODE_ROUND_NI ,
  196. D3D10_SB_OPCODE_ROUND_PI ,
  197. D3D10_SB_OPCODE_ROUND_Z ,
  198. D3D10_SB_OPCODE_RSQ ,
  199. D3D10_SB_OPCODE_SAMPLE ,
  200. D3D10_SB_OPCODE_SAMPLE_C ,
  201. D3D10_SB_OPCODE_SAMPLE_C_LZ ,
  202. D3D10_SB_OPCODE_SAMPLE_L ,
  203. D3D10_SB_OPCODE_SAMPLE_D ,
  204. D3D10_SB_OPCODE_SAMPLE_B ,
  205. D3D10_SB_OPCODE_SQRT ,
  206. D3D10_SB_OPCODE_SWITCH ,
  207. D3D10_SB_OPCODE_SINCOS ,
  208. D3D10_SB_OPCODE_UDIV ,
  209. D3D10_SB_OPCODE_ULT ,
  210. D3D10_SB_OPCODE_UGE ,
  211. D3D10_SB_OPCODE_UMUL ,
  212. D3D10_SB_OPCODE_UMAD ,
  213. D3D10_SB_OPCODE_UMAX ,
  214. D3D10_SB_OPCODE_UMIN ,
  215. D3D10_SB_OPCODE_USHR ,
  216. D3D10_SB_OPCODE_UTOF ,
  217. D3D10_SB_OPCODE_XOR ,
  218. D3D10_SB_OPCODE_DCL_RESOURCE , // DCL* opcodes have
  219. D3D10_SB_OPCODE_DCL_CONSTANT_BUFFER , // custom operand formats.
  220. D3D10_SB_OPCODE_DCL_SAMPLER ,
  221. D3D10_SB_OPCODE_DCL_INDEX_RANGE ,
  222. D3D10_SB_OPCODE_DCL_GS_OUTPUT_PRIMITIVE_TOPOLOGY ,
  223. D3D10_SB_OPCODE_DCL_GS_INPUT_PRIMITIVE ,
  224. D3D10_SB_OPCODE_DCL_MAX_OUTPUT_VERTEX_COUNT ,
  225. D3D10_SB_OPCODE_DCL_INPUT ,
  226. D3D10_SB_OPCODE_DCL_INPUT_SGV ,
  227. D3D10_SB_OPCODE_DCL_INPUT_SIV ,
  228. D3D10_SB_OPCODE_DCL_INPUT_PS ,
  229. D3D10_SB_OPCODE_DCL_INPUT_PS_SGV ,
  230. D3D10_SB_OPCODE_DCL_INPUT_PS_SIV ,
  231. D3D10_SB_OPCODE_DCL_OUTPUT ,
  232. D3D10_SB_OPCODE_DCL_OUTPUT_SGV ,
  233. D3D10_SB_OPCODE_DCL_OUTPUT_SIV ,
  234. D3D10_SB_OPCODE_DCL_TEMPS ,
  235. D3D10_SB_OPCODE_DCL_INDEXABLE_TEMP ,
  236. D3D10_SB_OPCODE_DCL_GLOBAL_FLAGS ,
  237. // -----------------------------------------------
  238. // This marks the end of D3D10.0 opcodes
  239. D3D10_SB_OPCODE_RESERVED0,
  240. // ---------- DX 10.1 op codes---------------------
  241. D3D10_1_SB_OPCODE_LOD,
  242. D3D10_1_SB_OPCODE_GATHER4,
  243. D3D10_1_SB_OPCODE_SAMPLE_POS,
  244. D3D10_1_SB_OPCODE_SAMPLE_INFO,
  245. // -----------------------------------------------
  246. // This marks the end of D3D10.1 opcodes
  247. D3D10_1_SB_OPCODE_RESERVED1,
  248. // ---------- DX 11 op codes---------------------
  249. D3D11_SB_OPCODE_HS_DECLS , // token marks beginning of HS sub-shader
  250. D3D11_SB_OPCODE_HS_CONTROL_POINT_PHASE , // token marks beginning of HS sub-shader
  251. D3D11_SB_OPCODE_HS_FORK_PHASE , // token marks beginning of HS sub-shader
  252. D3D11_SB_OPCODE_HS_JOIN_PHASE , // token marks beginning of HS sub-shader
  253. D3D11_SB_OPCODE_EMIT_STREAM ,
  254. D3D11_SB_OPCODE_CUT_STREAM ,
  255. D3D11_SB_OPCODE_EMITTHENCUT_STREAM ,
  256. D3D11_SB_OPCODE_INTERFACE_CALL ,
  257. D3D11_SB_OPCODE_BUFINFO ,
  258. D3D11_SB_OPCODE_DERIV_RTX_COARSE ,
  259. D3D11_SB_OPCODE_DERIV_RTX_FINE ,
  260. D3D11_SB_OPCODE_DERIV_RTY_COARSE ,
  261. D3D11_SB_OPCODE_DERIV_RTY_FINE ,
  262. D3D11_SB_OPCODE_GATHER4_C ,
  263. D3D11_SB_OPCODE_GATHER4_PO ,
  264. D3D11_SB_OPCODE_GATHER4_PO_C ,
  265. D3D11_SB_OPCODE_RCP ,
  266. D3D11_SB_OPCODE_F32TOF16 ,
  267. D3D11_SB_OPCODE_F16TOF32 ,
  268. D3D11_SB_OPCODE_UADDC ,
  269. D3D11_SB_OPCODE_USUBB ,
  270. D3D11_SB_OPCODE_COUNTBITS ,
  271. D3D11_SB_OPCODE_FIRSTBIT_HI ,
  272. D3D11_SB_OPCODE_FIRSTBIT_LO ,
  273. D3D11_SB_OPCODE_FIRSTBIT_SHI ,
  274. D3D11_SB_OPCODE_UBFE ,
  275. D3D11_SB_OPCODE_IBFE ,
  276. D3D11_SB_OPCODE_BFI ,
  277. D3D11_SB_OPCODE_BFREV ,
  278. D3D11_SB_OPCODE_SWAPC ,
  279. D3D11_SB_OPCODE_DCL_STREAM ,
  280. D3D11_SB_OPCODE_DCL_FUNCTION_BODY ,
  281. D3D11_SB_OPCODE_DCL_FUNCTION_TABLE ,
  282. D3D11_SB_OPCODE_DCL_INTERFACE ,
  283. D3D11_SB_OPCODE_DCL_INPUT_CONTROL_POINT_COUNT ,
  284. D3D11_SB_OPCODE_DCL_OUTPUT_CONTROL_POINT_COUNT ,
  285. D3D11_SB_OPCODE_DCL_TESS_DOMAIN ,
  286. D3D11_SB_OPCODE_DCL_TESS_PARTITIONING ,
  287. D3D11_SB_OPCODE_DCL_TESS_OUTPUT_PRIMITIVE ,
  288. D3D11_SB_OPCODE_DCL_HS_MAX_TESSFACTOR ,
  289. D3D11_SB_OPCODE_DCL_HS_FORK_PHASE_INSTANCE_COUNT ,
  290. D3D11_SB_OPCODE_DCL_HS_JOIN_PHASE_INSTANCE_COUNT ,
  291. D3D11_SB_OPCODE_DCL_THREAD_GROUP ,
  292. D3D11_SB_OPCODE_DCL_UNORDERED_ACCESS_VIEW_TYPED ,
  293. D3D11_SB_OPCODE_DCL_UNORDERED_ACCESS_VIEW_RAW ,
  294. D3D11_SB_OPCODE_DCL_UNORDERED_ACCESS_VIEW_STRUCTURED,
  295. D3D11_SB_OPCODE_DCL_THREAD_GROUP_SHARED_MEMORY_RAW,
  296. D3D11_SB_OPCODE_DCL_THREAD_GROUP_SHARED_MEMORY_STRUCTURED,
  297. D3D11_SB_OPCODE_DCL_RESOURCE_RAW ,
  298. D3D11_SB_OPCODE_DCL_RESOURCE_STRUCTURED ,
  299. D3D11_SB_OPCODE_LD_UAV_TYPED ,
  300. D3D11_SB_OPCODE_STORE_UAV_TYPED ,
  301. D3D11_SB_OPCODE_LD_RAW ,
  302. D3D11_SB_OPCODE_STORE_RAW ,
  303. D3D11_SB_OPCODE_LD_STRUCTURED ,
  304. D3D11_SB_OPCODE_STORE_STRUCTURED ,
  305. D3D11_SB_OPCODE_ATOMIC_AND ,
  306. D3D11_SB_OPCODE_ATOMIC_OR ,
  307. D3D11_SB_OPCODE_ATOMIC_XOR ,
  308. D3D11_SB_OPCODE_ATOMIC_CMP_STORE ,
  309. D3D11_SB_OPCODE_ATOMIC_IADD ,
  310. D3D11_SB_OPCODE_ATOMIC_IMAX ,
  311. D3D11_SB_OPCODE_ATOMIC_IMIN ,
  312. D3D11_SB_OPCODE_ATOMIC_UMAX ,
  313. D3D11_SB_OPCODE_ATOMIC_UMIN ,
  314. D3D11_SB_OPCODE_IMM_ATOMIC_ALLOC ,
  315. D3D11_SB_OPCODE_IMM_ATOMIC_CONSUME ,
  316. D3D11_SB_OPCODE_IMM_ATOMIC_IADD ,
  317. D3D11_SB_OPCODE_IMM_ATOMIC_AND ,
  318. D3D11_SB_OPCODE_IMM_ATOMIC_OR ,
  319. D3D11_SB_OPCODE_IMM_ATOMIC_XOR ,
  320. D3D11_SB_OPCODE_IMM_ATOMIC_EXCH ,
  321. D3D11_SB_OPCODE_IMM_ATOMIC_CMP_EXCH ,
  322. D3D11_SB_OPCODE_IMM_ATOMIC_IMAX ,
  323. D3D11_SB_OPCODE_IMM_ATOMIC_IMIN ,
  324. D3D11_SB_OPCODE_IMM_ATOMIC_UMAX ,
  325. D3D11_SB_OPCODE_IMM_ATOMIC_UMIN ,
  326. D3D11_SB_OPCODE_SYNC ,
  327. D3D11_SB_OPCODE_DADD ,
  328. D3D11_SB_OPCODE_DMAX ,
  329. D3D11_SB_OPCODE_DMIN ,
  330. D3D11_SB_OPCODE_DMUL ,
  331. D3D11_SB_OPCODE_DEQ ,
  332. D3D11_SB_OPCODE_DGE ,
  333. D3D11_SB_OPCODE_DLT ,
  334. D3D11_SB_OPCODE_DNE ,
  335. D3D11_SB_OPCODE_DMOV ,
  336. D3D11_SB_OPCODE_DMOVC ,
  337. D3D11_SB_OPCODE_DTOF ,
  338. D3D11_SB_OPCODE_FTOD ,
  339. D3D11_SB_OPCODE_EVAL_SNAPPED ,
  340. D3D11_SB_OPCODE_EVAL_SAMPLE_INDEX ,
  341. D3D11_SB_OPCODE_EVAL_CENTROID ,
  342. D3D11_SB_OPCODE_DCL_GS_INSTANCE_COUNT ,
  343. D3D11_SB_OPCODE_ABORT ,
  344. D3D11_SB_OPCODE_DEBUG_BREAK ,
  345. // -----------------------------------------------
  346. // This marks the end of D3D11.0 opcodes
  347. D3D11_SB_OPCODE_RESERVED0,
  348. D3D11_1_SB_OPCODE_DDIV,
  349. D3D11_1_SB_OPCODE_DFMA,
  350. D3D11_1_SB_OPCODE_DRCP,
  351. D3D11_1_SB_OPCODE_MSAD,
  352. D3D11_1_SB_OPCODE_DTOI,
  353. D3D11_1_SB_OPCODE_DTOU,
  354. D3D11_1_SB_OPCODE_ITOD,
  355. D3D11_1_SB_OPCODE_UTOD,
  356. // -----------------------------------------------
  357. // This marks the end of D3D11.1 opcodes
  358. D3D11_1_SB_OPCODE_RESERVED0,
  359. D3DWDDM1_3_SB_OPCODE_GATHER4_FEEDBACK,
  360. D3DWDDM1_3_SB_OPCODE_GATHER4_C_FEEDBACK,
  361. D3DWDDM1_3_SB_OPCODE_GATHER4_PO_FEEDBACK,
  362. D3DWDDM1_3_SB_OPCODE_GATHER4_PO_C_FEEDBACK,
  363. D3DWDDM1_3_SB_OPCODE_LD_FEEDBACK,
  364. D3DWDDM1_3_SB_OPCODE_LD_MS_FEEDBACK,
  365. D3DWDDM1_3_SB_OPCODE_LD_UAV_TYPED_FEEDBACK,
  366. D3DWDDM1_3_SB_OPCODE_LD_RAW_FEEDBACK,
  367. D3DWDDM1_3_SB_OPCODE_LD_STRUCTURED_FEEDBACK,
  368. D3DWDDM1_3_SB_OPCODE_SAMPLE_L_FEEDBACK,
  369. D3DWDDM1_3_SB_OPCODE_SAMPLE_C_LZ_FEEDBACK,
  370. D3DWDDM1_3_SB_OPCODE_SAMPLE_CLAMP_FEEDBACK,
  371. D3DWDDM1_3_SB_OPCODE_SAMPLE_B_CLAMP_FEEDBACK,
  372. D3DWDDM1_3_SB_OPCODE_SAMPLE_D_CLAMP_FEEDBACK,
  373. D3DWDDM1_3_SB_OPCODE_SAMPLE_C_CLAMP_FEEDBACK,
  374. D3DWDDM1_3_SB_OPCODE_CHECK_ACCESS_FULLY_MAPPED,
  375. // -----------------------------------------------
  376. // This marks the end of WDDM 1.3 opcodes
  377. D3DWDDM1_3_SB_OPCODE_RESERVED0,
  378. D3D10_SB_NUM_OPCODES // Should be the last entry
  379. } D3D10_SB_OPCODE_TYPE;
  380. #define D3D10_SB_OPCODE_TYPE_MASK 0x00007ff
  381. // DECODER MACRO: Retrieve program opcode
  382. #define DECODE_D3D10_SB_OPCODE_TYPE(OpcodeToken0) ((D3D10_SB_OPCODE_TYPE)((OpcodeToken0)&D3D10_SB_OPCODE_TYPE_MASK))
  383. // ENCODER MACRO: Create the opcode-type portion of OpcodeToken0
  384. #define ENCODE_D3D10_SB_OPCODE_TYPE(OpcodeName) ((OpcodeName)&D3D10_SB_OPCODE_TYPE_MASK)
  385. #define D3D10_SB_TOKENIZED_INSTRUCTION_LENGTH_MASK 0x7f000000
  386. #define D3D10_SB_TOKENIZED_INSTRUCTION_LENGTH_SHIFT 24
  387. // DECODER MACRO: Retrieve instruction length
  388. // in # of DWORDs including the opcode token(s).
  389. // The range is 1-127.
  390. #define DECODE_D3D10_SB_TOKENIZED_INSTRUCTION_LENGTH(OpcodeToken0) (((OpcodeToken0)&D3D10_SB_TOKENIZED_INSTRUCTION_LENGTH_MASK)>> D3D10_SB_TOKENIZED_INSTRUCTION_LENGTH_SHIFT)
  391. // ENCODER MACRO: Store instruction length
  392. // portion of OpcodeToken0, in # of DWORDs
  393. // including the opcode token(s).
  394. // Valid range is 1-127.
  395. #define ENCODE_D3D10_SB_TOKENIZED_INSTRUCTION_LENGTH(Length) (((Length)<<D3D10_SB_TOKENIZED_INSTRUCTION_LENGTH_SHIFT)&D3D10_SB_TOKENIZED_INSTRUCTION_LENGTH_MASK)
  396. #define MAX_D3D10_SB_TOKENIZED_INSTRUCTION_LENGTH 127
  397. #define D3D10_SB_INSTRUCTION_SATURATE_MASK 0x00002000
  398. // DECODER MACRO: Check OpcodeToken0 to see if an instruction
  399. // is to saturate the result [0..1]
  400. // This flag is indicated by one of the bits in the
  401. // opcode specific control range.
  402. #define DECODE_IS_D3D10_SB_INSTRUCTION_SATURATE_ENABLED(OpcodeToken0) ((OpcodeToken0)&D3D10_SB_INSTRUCTION_SATURATE_MASK)
  403. // ENCODER MACRO: Encode in OpcodeToken0 if instruction is to saturate the result.
  404. #define ENCODE_D3D10_SB_INSTRUCTION_SATURATE(bSat) (((bSat)!=0)?D3D10_SB_INSTRUCTION_SATURATE_MASK:0)
  405. // Boolean test for conditional instructions such as if (if_z or if_nz)
  406. // This is part of the opcode specific control range.
  407. typedef enum D3D10_SB_INSTRUCTION_TEST_BOOLEAN
  408. {
  409. D3D10_SB_INSTRUCTION_TEST_ZERO = 0,
  410. D3D10_SB_INSTRUCTION_TEST_NONZERO = 1
  411. } D3D10_SB_INSTRUCTION_TEST_BOOLEAN;
  412. #define D3D10_SB_INSTRUCTION_TEST_BOOLEAN_MASK 0x00040000
  413. #define D3D10_SB_INSTRUCTION_TEST_BOOLEAN_SHIFT 18
  414. // DECODER MACRO: For an OpcodeToken0 for requires either a
  415. // zero or non-zero test, determine which test was chosen.
  416. #define DECODE_D3D10_SB_INSTRUCTION_TEST_BOOLEAN(OpcodeToken0) ((D3D10_SB_INSTRUCTION_TEST_BOOLEAN)(((OpcodeToken0)&D3D10_SB_INSTRUCTION_TEST_BOOLEAN_MASK)>>D3D10_SB_INSTRUCTION_TEST_BOOLEAN_SHIFT))
  417. // ENCODER MACRO: Store "zero" or "nonzero" in the opcode
  418. // specific control range of OpcodeToken0
  419. #define ENCODE_D3D10_SB_INSTRUCTION_TEST_BOOLEAN(Boolean) (((Boolean)<<D3D10_SB_INSTRUCTION_TEST_BOOLEAN_SHIFT)&D3D10_SB_INSTRUCTION_TEST_BOOLEAN_MASK)
  420. // Precise value mask (bits 19-22)
  421. // This is part of the opcode specific control range.
  422. // It's 1 bit per-channel of the output, for instructions with multiple
  423. // output operands, it applies to that component in each operand. This
  424. // uses the components defined in D3D10_SB_COMPONENT_NAME.
  425. #define D3D11_SB_INSTRUCTION_PRECISE_VALUES_MASK 0x00780000
  426. #define D3D11_SB_INSTRUCTION_PRECISE_VALUES_SHIFT 19
  427. // DECODER MACRO: this macro extracts from OpcodeToken0 the 4 component
  428. // (xyzw) mask, as a field of D3D10_SB_4_COMPONENT_[X|Y|Z|W] flags.
  429. #define DECODE_D3D11_SB_INSTRUCTION_PRECISE_VALUES(OpcodeToken0) ((((OpcodeToken0)&D3D11_SB_INSTRUCTION_PRECISE_VALUES_MASK)>>D3D11_SB_INSTRUCTION_PRECISE_VALUES_SHIFT))
  430. // ENCODER MACRO: Given a set of
  431. // D3D10_SB_OPERAND_4_COMPONENT_[X|Y|Z|W] values
  432. // or'd together, encode them in OpcodeToken0.
  433. #define ENCODE_D3D11_SB_INSTRUCTION_PRECISE_VALUES(ComponentMask) (((ComponentMask)<<D3D11_SB_INSTRUCTION_PRECISE_VALUES_SHIFT)&D3D11_SB_INSTRUCTION_PRECISE_VALUES_MASK)
  434. // resinfo instruction return type
  435. typedef enum D3D10_SB_RESINFO_INSTRUCTION_RETURN_TYPE
  436. {
  437. D3D10_SB_RESINFO_INSTRUCTION_RETURN_FLOAT = 0,
  438. D3D10_SB_RESINFO_INSTRUCTION_RETURN_RCPFLOAT = 1,
  439. D3D10_SB_RESINFO_INSTRUCTION_RETURN_UINT = 2
  440. } D3D10_SB_RESINFO_INSTRUCTION_RETURN_TYPE;
  441. #define D3D10_SB_RESINFO_INSTRUCTION_RETURN_TYPE_MASK 0x00001800
  442. #define D3D10_SB_RESINFO_INSTRUCTION_RETURN_TYPE_SHIFT 11
  443. // DECODER MACRO: For an OpcodeToken0 for the resinfo instruction,
  444. // determine the return type.
  445. #define DECODE_D3D10_SB_RESINFO_INSTRUCTION_RETURN_TYPE(OpcodeToken0) ((D3D10_SB_RESINFO_INSTRUCTION_RETURN_TYPE)(((OpcodeToken0)&D3D10_SB_RESINFO_INSTRUCTION_RETURN_TYPE_MASK)>>D3D10_SB_RESINFO_INSTRUCTION_RETURN_TYPE_SHIFT))
  446. // ENCODER MACRO: Encode the return type for the resinfo instruction
  447. // in the opcode specific control range of OpcodeToken0
  448. #define ENCODE_D3D10_SB_RESINFO_INSTRUCTION_RETURN_TYPE(ReturnType) (((ReturnType)<<D3D10_SB_RESINFO_INSTRUCTION_RETURN_TYPE_SHIFT)&D3D10_SB_RESINFO_INSTRUCTION_RETURN_TYPE_MASK)
  449. // sync instruction flags
  450. #define D3D11_SB_SYNC_THREADS_IN_GROUP 0x00000800
  451. #define D3D11_SB_SYNC_THREAD_GROUP_SHARED_MEMORY 0x00001000
  452. #define D3D11_SB_SYNC_UNORDERED_ACCESS_VIEW_MEMORY_GROUP 0x00002000
  453. #define D3D11_SB_SYNC_UNORDERED_ACCESS_VIEW_MEMORY_GLOBAL 0x00004000
  454. #define D3D11_SB_SYNC_FLAGS_MASK 0x00007800
  455. // DECODER MACRO: Retrieve flags for sync instruction from OpcodeToken0.
  456. #define DECODE_D3D11_SB_SYNC_FLAGS(OperandToken0) ((OperandToken0)&D3D11_SB_SYNC_FLAGS_MASK)
  457. // ENCODER MACRO: Given a set of sync instruciton flags, encode them in OpcodeToken0.
  458. #define ENCODE_D3D11_SB_SYNC_FLAGS(Flags) ((Flags)&D3D11_SB_SYNC_FLAGS_MASK)
  459. #define D3D10_SB_OPCODE_EXTENDED_MASK 0x80000000
  460. #define D3D10_SB_OPCODE_EXTENDED_SHIFT 31
  461. // DECODER MACRO: Determine if the opcode is extended
  462. // by an additional opcode token. Currently there are no
  463. // extended opcodes.
  464. #define DECODE_IS_D3D10_SB_OPCODE_EXTENDED(OpcodeToken0) (((OpcodeToken0)&D3D10_SB_OPCODE_EXTENDED_MASK)>> D3D10_SB_OPCODE_EXTENDED_SHIFT)
  465. // ENCODER MACRO: Store in OpcodeToken0 whether the opcode is extended
  466. // by an additional opcode token.
  467. #define ENCODE_D3D10_SB_OPCODE_EXTENDED(bExtended) (((bExtended)!=0)?D3D10_SB_OPCODE_EXTENDED_MASK:0)
  468. // ----------------------------------------------------------------------------
  469. // Extended Opcode Format (OpcodeToken1)
  470. //
  471. // If bit31 of an opcode token is set, the
  472. // opcode has an additional extended opcode token DWORD
  473. // directly following OpcodeToken0. Other tokens
  474. // expected for the opcode, such as the operand
  475. // token(s) always follow
  476. // OpcodeToken0 AND OpcodeToken1..n (extended
  477. // opcode tokens, if present).
  478. //
  479. // [05:00] D3D10_SB_EXTENDED_OPCODE_TYPE
  480. // [30:06] if([05:00] == D3D10_SB_EXTENDED_OPCODE_SAMPLE_CONTROLS)
  481. // {
  482. // This custom opcode contains controls for SAMPLE.
  483. // [08:06] Ignored, 0.
  484. // [12:09] U texel immediate offset (4 bit 2's comp) (0 default)
  485. // [16:13] V texel immediate offset (4 bit 2's comp) (0 default)
  486. // [20:17] W texel immediate offset (4 bit 2's comp) (0 default)
  487. // [30:14] Ignored, 0.
  488. // }
  489. // else if( [05:00] == D3D11_SB_EXTENDED_OPCODE_RESOURCE_DIM )
  490. // {
  491. // [10:06] D3D10_SB_RESOURCE_DIMENSION
  492. // [22:11] When dimension is D3D11_SB_RESOURCE_DIMENSION_STRUCTURED_BUFFER this holds the buffer stride, otherwise 0
  493. // [30:23] Ignored, 0.
  494. // }
  495. // else if( [05:00] == D3D11_SB_EXTENDED_OPCODE_RESOURCE_RETURN_TYPE )
  496. // {
  497. // [09:06] D3D10_SB_RESOURCE_RETURN_TYPE for component X
  498. // [13:10] D3D10_SB_RESOURCE_RETURN_TYPE for component Y
  499. // [17:14] D3D10_SB_RESOURCE_RETURN_TYPE for component Z
  500. // [21:18] D3D10_SB_RESOURCE_RETURN_TYPE for component W
  501. // [30:22] Ignored, 0.
  502. // }
  503. // else
  504. // {
  505. // [30:04] Ignored, 0.
  506. // }
  507. // [31] 0 normally. 1 there is another extended opcode. Any number
  508. // of extended opcode tokens can be chained. It is possible that some extended
  509. // opcode tokens could include multiple DWORDS - that is defined
  510. // on a case by case basis.
  511. //
  512. // ----------------------------------------------------------------------------
  513. typedef enum D3D10_SB_EXTENDED_OPCODE_TYPE
  514. {
  515. D3D10_SB_EXTENDED_OPCODE_EMPTY = 0,
  516. D3D10_SB_EXTENDED_OPCODE_SAMPLE_CONTROLS = 1,
  517. D3D11_SB_EXTENDED_OPCODE_RESOURCE_DIM = 2,
  518. D3D11_SB_EXTENDED_OPCODE_RESOURCE_RETURN_TYPE = 3,
  519. } D3D10_SB_EXTENDED_OPCODE_TYPE;
  520. #define D3D11_SB_MAX_SIMULTANEOUS_EXTENDED_OPCODES 3
  521. #define D3D10_SB_EXTENDED_OPCODE_TYPE_MASK 0x0000003f
  522. // DECODER MACRO: Given an extended opcode
  523. // token (OpcodeToken1), figure out what type
  524. // of token it is (from D3D10_SB_EXTENDED_OPCODE_TYPE enum)
  525. // to be able to interpret the rest of the token's contents.
  526. #define DECODE_D3D10_SB_EXTENDED_OPCODE_TYPE(OpcodeToken1) ((D3D10_SB_EXTENDED_OPCODE_TYPE)((OpcodeToken1)&D3D10_SB_EXTENDED_OPCODE_TYPE_MASK))
  527. // ENCODER MACRO: Store extended opcode token
  528. // type in OpcodeToken1.
  529. #define ENCODE_D3D10_SB_EXTENDED_OPCODE_TYPE(ExtOpcodeType) ((ExtOpcodeType)&D3D10_SB_EXTENDED_OPCODE_TYPE_MASK)
  530. typedef enum D3D10_SB_IMMEDIATE_ADDRESS_OFFSET_COORD
  531. {
  532. D3D10_SB_IMMEDIATE_ADDRESS_OFFSET_U = 0,
  533. D3D10_SB_IMMEDIATE_ADDRESS_OFFSET_V = 1,
  534. D3D10_SB_IMMEDIATE_ADDRESS_OFFSET_W = 2,
  535. } D3D10_SB_IMMEDIATE_ADDRESS_OFFSET_COORD;
  536. #define D3D10_SB_IMMEDIATE_ADDRESS_OFFSET_COORD_MASK (3)
  537. #define D3D10_SB_IMMEDIATE_ADDRESS_OFFSET_SHIFT(Coord) (9+4*((Coord)&D3D10_SB_IMMEDIATE_ADDRESS_OFFSET_COORD_MASK))
  538. #define D3D10_SB_IMMEDIATE_ADDRESS_OFFSET_MASK(Coord) (0x0000000f<<D3D10_SB_IMMEDIATE_ADDRESS_OFFSET_SHIFT(Coord))
  539. // DECODER MACRO: Given an extended opcode token
  540. // (OpcodeToken1), and extended token type ==
  541. // D3D10_SB_EXTENDED_OPCODE_SAMPLE_CONTROLS, determine the immediate
  542. // texel address offset for u/v/w (D3D10_SB_ADDRESS_OFFSET_COORD)
  543. // This macro returns a (signed) integer, by sign extending the
  544. // decoded 4 bit 2's complement immediate value.
  545. #define DECODE_IMMEDIATE_D3D10_SB_ADDRESS_OFFSET(Coord,OpcodeToken1) ((((OpcodeToken1)&D3D10_SB_IMMEDIATE_ADDRESS_OFFSET_MASK(Coord))>>(D3D10_SB_IMMEDIATE_ADDRESS_OFFSET_SHIFT(Coord))))
  546. // ENCODER MACRO: Store the immediate texel address offset
  547. // for U or V or W Coord (D3D10_SB_ADDRESS_OFFSET_COORD) in an extended
  548. // opcode token (OpcodeToken1) that has extended opcode
  549. // type == D3D10_SB_EXTENDED_OPCODE_SAMPLE_CONTROLS (opcode type encoded separately)
  550. // A 2's complement number is expected as input, from which the LSB 4 bits are extracted.
  551. #define ENCODE_IMMEDIATE_D3D10_SB_ADDRESS_OFFSET(Coord,ImmediateOffset) (((ImmediateOffset)<<D3D10_SB_IMMEDIATE_ADDRESS_OFFSET_SHIFT(Coord))&D3D10_SB_IMMEDIATE_ADDRESS_OFFSET_MASK(Coord))
  552. #define D3D11_SB_EXTENDED_RESOURCE_DIMENSION_MASK 0x000007C0
  553. #define D3D11_SB_EXTENDED_RESOURCE_DIMENSION_SHIFT 6
  554. // DECODER MACRO: Given an extended resource declaration token,
  555. // (D3D11_SB_EXTENDED_OPCODE_RESOURCE_DIM), determine the resource dimension
  556. // (D3D10_SB_RESOURCE_DIMENSION enum)
  557. #define DECODE_D3D11_SB_EXTENDED_RESOURCE_DIMENSION(OpcodeTokenN) ((D3D10_SB_RESOURCE_DIMENSION)(((OpcodeTokenN)&D3D11_SB_EXTENDED_RESOURCE_DIMENSION_MASK)>>D3D11_SB_EXTENDED_RESOURCE_DIMENSION_SHIFT))
  558. // ENCODER MACRO: Store resource dimension
  559. // (D3D10_SB_RESOURCE_DIMENSION enum) into a
  560. // an extended resource declaration token (D3D11_SB_EXTENDED_OPCODE_RESOURCE_DIM)
  561. #define ENCODE_D3D11_SB_EXTENDED_RESOURCE_DIMENSION(ResourceDim) (((ResourceDim)<<D3D11_SB_EXTENDED_RESOURCE_DIMENSION_SHIFT)&D3D11_SB_EXTENDED_RESOURCE_DIMENSION_MASK)
  562. #define D3D11_SB_EXTENDED_RESOURCE_DIMENSION_STRUCTURE_STRIDE_MASK 0x007FF800
  563. #define D3D11_SB_EXTENDED_RESOURCE_DIMENSION_STRUCTURE_STRIDE_SHIFT 11
  564. // DECODER MACRO: Given an extended resource declaration token for a structured buffer,
  565. // (D3D11_SB_EXTENDED_OPCODE_RESOURCE_DIM), determine the structure stride
  566. // (12-bit unsigned integer)
  567. #define DECODE_D3D11_SB_EXTENDED_RESOURCE_DIMENSION_STRUCTURE_STRIDE(OpcodeTokenN) (((OpcodeTokenN)&D3D11_SB_EXTENDED_RESOURCE_DIMENSION_STRUCTURE_STRIDE_MASK)>>D3D11_SB_EXTENDED_RESOURCE_DIMENSION_STRUCTURE_STRIDE_SHIFT)
  568. // ENCODER MACRO: Store resource dimension structure stride
  569. // (12-bit unsigned integer) into a
  570. // an extended resource declaration token (D3D11_SB_EXTENDED_OPCODE_RESOURCE_DIM)
  571. #define ENCODE_D3D11_SB_EXTENDED_RESOURCE_DIMENSION_STRUCTURE_STRIDE(Stride) (((Stride)<<D3D11_SB_EXTENDED_RESOURCE_DIMENSION_STRUCTURE_STRIDE_SHIFT)&D3D11_SB_EXTENDED_RESOURCE_DIMENSION_STRUCTURE_STRIDE_MASK)
  572. #define D3D10_SB_RESOURCE_RETURN_TYPE_MASK 0x0000000f
  573. #define D3D10_SB_RESOURCE_RETURN_TYPE_NUMBITS 0x00000004
  574. #define D3D11_SB_EXTENDED_RESOURCE_RETURN_TYPE_SHIFT 6
  575. // DECODER MACRO: Get the resource return type for component (0-3) from
  576. // an extended resource declaration token (D3D11_SB_EXTENDED_OPCODE_RESOURCE_RETURN_TYPE)
  577. #define DECODE_D3D11_SB_EXTENDED_RESOURCE_RETURN_TYPE(OpcodeTokenN, Component) \
  578. ((D3D10_SB_RESOURCE_RETURN_TYPE)(((OpcodeTokenN) >> \
  579. (Component * D3D10_SB_RESOURCE_RETURN_TYPE_NUMBITS + D3D11_SB_EXTENDED_RESOURCE_RETURN_TYPE_SHIFT))&D3D10_SB_RESOURCE_RETURN_TYPE_MASK))
  580. // ENCODER MACRO: Generate a resource return type for a component in an extended
  581. // resource delcaration token (D3D11_SB_EXTENDED_OPCODE_RESOURCE_RETURN_TYPE)
  582. #define ENCODE_D3D11_SB_EXTENDED_RESOURCE_RETURN_TYPE(ReturnType, Component) \
  583. (((ReturnType)&D3D10_SB_RESOURCE_RETURN_TYPE_MASK) << (Component * D3D10_SB_RESOURCE_RETURN_TYPE_NUMBITS + D3D11_SB_EXTENDED_RESOURCE_RETURN_TYPE_SHIFT))
  584. // ----------------------------------------------------------------------------
  585. // Custom-Data Block Format
  586. //
  587. // DWORD 0 (CustomDataDescTok):
  588. // [10:00] == D3D10_SB_OPCODE_CUSTOMDATA
  589. // [31:11] == D3D10_SB_CUSTOMDATA_CLASS
  590. //
  591. // DWORD 1:
  592. // 32-bit unsigned integer count of number
  593. // of DWORDs in custom-data block,
  594. // including DWORD 0 and DWORD 1.
  595. // So the minimum value is 0x00000002,
  596. // meaning empty custom-data.
  597. //
  598. // Layout of custom-data contents, for the various meta-data classes,
  599. // not defined in this file.
  600. //
  601. // ----------------------------------------------------------------------------
  602. typedef enum D3D10_SB_CUSTOMDATA_CLASS
  603. {
  604. D3D10_SB_CUSTOMDATA_COMMENT = 0,
  605. D3D10_SB_CUSTOMDATA_DEBUGINFO,
  606. D3D10_SB_CUSTOMDATA_OPAQUE,
  607. D3D10_SB_CUSTOMDATA_DCL_IMMEDIATE_CONSTANT_BUFFER,
  608. D3D11_SB_CUSTOMDATA_SHADER_MESSAGE,
  609. D3D11_SB_CUSTOMDATA_SHADER_CLIP_PLANE_CONSTANT_MAPPINGS_FOR_DX9,
  610. } D3D10_SB_CUSTOMDATA_CLASS;
  611. #define D3D10_SB_CUSTOMDATA_CLASS_MASK 0xfffff800
  612. #define D3D10_SB_CUSTOMDATA_CLASS_SHIFT 11
  613. // DECODER MACRO: Find out what class of custom-data is present.
  614. // The contents of the custom-data block are defined
  615. // for each class of custom-data.
  616. #define DECODE_D3D10_SB_CUSTOMDATA_CLASS(CustomDataDescTok) ((D3D10_SB_CUSTOMDATA_CLASS)(((CustomDataDescTok)&D3D10_SB_CUSTOMDATA_CLASS_MASK)>>D3D10_SB_CUSTOMDATA_CLASS_SHIFT))
  617. // ENCODER MACRO: Create complete CustomDataDescTok
  618. #define ENCODE_D3D10_SB_CUSTOMDATA_CLASS(CustomDataClass) (ENCODE_D3D10_SB_OPCODE_TYPE(D3D10_SB_OPCODE_CUSTOMDATA)|(((CustomDataClass)<<D3D10_SB_CUSTOMDATA_CLASS_SHIFT)&D3D10_SB_CUSTOMDATA_CLASS_MASK))
  619. // ----------------------------------------------------------------------------
  620. // Instruction Operand Format (OperandToken0)
  621. //
  622. // [01:00] D3D10_SB_OPERAND_NUM_COMPONENTS
  623. // [11:02] Component Selection
  624. // if([01:00] == D3D10_SB_OPERAND_0_COMPONENT)
  625. // [11:02] = Ignored, 0
  626. // else if([01:00] == D3D10_SB_OPERAND_1_COMPONENT
  627. // [11:02] = Ignored, 0
  628. // else if([01:00] == D3D10_SB_OPERAND_4_COMPONENT
  629. // {
  630. // [03:02] = D3D10_SB_OPERAND_4_COMPONENT_SELECTION_MODE
  631. // if([03:02] == D3D10_SB_OPERAND_4_COMPONENT_MASK_MODE)
  632. // {
  633. // [07:04] = D3D10_SB_OPERAND_4_COMPONENT_MASK
  634. // [11:08] = Ignored, 0
  635. // }
  636. // else if([03:02] == D3D10_SB_OPERAND_4_COMPONENT_SWIZZLE_MODE)
  637. // {
  638. // [11:04] = D3D10_SB_4_COMPONENT_SWIZZLE
  639. // }
  640. // else if([03:02] == D3D10_SB_OPERAND_4_COMPONENT_SELECT_1_MODE)
  641. // {
  642. // [05:04] = D3D10_SB_4_COMPONENT_NAME
  643. // [11:06] = Ignored, 0
  644. // }
  645. // }
  646. // else if([01:00] == D3D10_SB_OPERAND_N_COMPONENT)
  647. // {
  648. // Currently not defined.
  649. // }
  650. // [19:12] D3D10_SB_OPERAND_TYPE
  651. // [21:20] D3D10_SB_OPERAND_INDEX_DIMENSION:
  652. // Number of dimensions in the register
  653. // file (NOT the # of dimensions in the
  654. // individual register or memory
  655. // resource being referenced).
  656. // [24:22] if( [21:20] >= D3D10_SB_OPERAND_INDEX_1D )
  657. // D3D10_SB_OPERAND_INDEX_REPRESENTATION for first operand index
  658. // else
  659. // Ignored, 0
  660. // [27:25] if( [21:20] >= D3D10_SB_OPERAND_INDEX_2D )
  661. // D3D10_SB_OPERAND_INDEX_REPRESENTATION for second operand index
  662. // else
  663. // Ignored, 0
  664. // [30:28] if( [21:20] == D3D10_SB_OPERAND_INDEX_3D )
  665. // D3D10_SB_OPERAND_INDEX_REPRESENTATION for third operand index
  666. // else
  667. // Ignored, 0
  668. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD
  669. // contains extended operand description.
  670. //
  671. // ----------------------------------------------------------------------------
  672. // Number of components in data vector referred to by operand.
  673. typedef enum D3D10_SB_OPERAND_NUM_COMPONENTS
  674. {
  675. D3D10_SB_OPERAND_0_COMPONENT = 0,
  676. D3D10_SB_OPERAND_1_COMPONENT = 1,
  677. D3D10_SB_OPERAND_4_COMPONENT = 2,
  678. D3D10_SB_OPERAND_N_COMPONENT = 3 // unused for now
  679. } D3D10_SB_OPERAND_NUM_COMPONENTS;
  680. #define D3D10_SB_OPERAND_NUM_COMPONENTS_MASK 0x00000003
  681. // DECODER MACRO: Extract from OperandToken0 how many components
  682. // the data vector referred to by the operand contains.
  683. // (D3D10_SB_OPERAND_NUM_COMPONENTS enum)
  684. #define DECODE_D3D10_SB_OPERAND_NUM_COMPONENTS(OperandToken0) ((D3D10_SB_OPERAND_NUM_COMPONENTS)((OperandToken0)&D3D10_SB_OPERAND_NUM_COMPONENTS_MASK))
  685. // ENCODER MACRO: Define in OperandToken0 how many components
  686. // the data vector referred to by the operand contains.
  687. // (D3D10_SB_OPERAND_NUM_COMPONENTS enum).
  688. #define ENCODE_D3D10_SB_OPERAND_NUM_COMPONENTS(NumComp) ((NumComp)&D3D10_SB_OPERAND_NUM_COMPONENTS_MASK)
  689. typedef enum D3D10_SB_OPERAND_4_COMPONENT_SELECTION_MODE
  690. {
  691. D3D10_SB_OPERAND_4_COMPONENT_MASK_MODE = 0, // mask 4 components
  692. D3D10_SB_OPERAND_4_COMPONENT_SWIZZLE_MODE = 1, // swizzle 4 components
  693. D3D10_SB_OPERAND_4_COMPONENT_SELECT_1_MODE = 2, // select 1 of 4 components
  694. } D3D10_SB_OPERAND_4_COMPONENT_SELECTION_MODE;
  695. #define D3D10_SB_OPERAND_4_COMPONENT_SELECTION_MODE_MASK 0x0000000c
  696. #define D3D10_SB_OPERAND_4_COMPONENT_SELECTION_MODE_SHIFT 2
  697. // DECODER MACRO: For an operand representing 4component data,
  698. // extract from OperandToken0 the method for selecting data from
  699. // the 4 components (D3D10_SB_OPERAND_4_COMPONENT_SELECTION_MODE).
  700. #define DECODE_D3D10_SB_OPERAND_4_COMPONENT_SELECTION_MODE(OperandToken0) ((D3D10_SB_OPERAND_4_COMPONENT_SELECTION_MODE)(((OperandToken0)&D3D10_SB_OPERAND_4_COMPONENT_SELECTION_MODE_MASK)>>D3D10_SB_OPERAND_4_COMPONENT_SELECTION_MODE_SHIFT))
  701. // ENCODER MACRO: For an operand representing 4component data,
  702. // encode in OperandToken0 a value from D3D10_SB_OPERAND_4_COMPONENT_SELECTION_MODE
  703. #define ENCODE_D3D10_SB_OPERAND_4_COMPONENT_SELECTION_MODE(SelectionMode) (((SelectionMode)<<D3D10_SB_OPERAND_4_COMPONENT_SELECTION_MODE_SHIFT)&D3D10_SB_OPERAND_4_COMPONENT_SELECTION_MODE_MASK)
  704. typedef enum D3D10_SB_4_COMPONENT_NAME
  705. {
  706. D3D10_SB_4_COMPONENT_X = 0,
  707. D3D10_SB_4_COMPONENT_Y = 1,
  708. D3D10_SB_4_COMPONENT_Z = 2,
  709. D3D10_SB_4_COMPONENT_W = 3,
  710. D3D10_SB_4_COMPONENT_R = 0,
  711. D3D10_SB_4_COMPONENT_G = 1,
  712. D3D10_SB_4_COMPONENT_B = 2,
  713. D3D10_SB_4_COMPONENT_A = 3
  714. } D3D10_SB_4_COMPONENT_NAME;
  715. #define D3D10_SB_4_COMPONENT_NAME_MASK 3
  716. // MACROS FOR USE IN D3D10_SB_OPERAND_4_COMPONENT_MASK_MODE:
  717. #define D3D10_SB_OPERAND_4_COMPONENT_MASK_MASK 0x000000f0
  718. #define D3D10_SB_OPERAND_4_COMPONENT_MASK_SHIFT 4
  719. #define D3D10_SB_OPERAND_4_COMPONENT_MASK_X 0x00000010
  720. #define D3D10_SB_OPERAND_4_COMPONENT_MASK_Y 0x00000020
  721. #define D3D10_SB_OPERAND_4_COMPONENT_MASK_Z 0x00000040
  722. #define D3D10_SB_OPERAND_4_COMPONENT_MASK_W 0x00000080
  723. #define D3D10_SB_OPERAND_4_COMPONENT_MASK_R D3D10_SB_OPERAND_4_COMPONENT_MASK_X
  724. #define D3D10_SB_OPERAND_4_COMPONENT_MASK_G D3D10_SB_OPERAND_4_COMPONENT_MASK_Y
  725. #define D3D10_SB_OPERAND_4_COMPONENT_MASK_B D3D10_SB_OPERAND_4_COMPONENT_MASK_Z
  726. #define D3D10_SB_OPERAND_4_COMPONENT_MASK_A D3D10_SB_OPERAND_4_COMPONENT_MASK_W
  727. #define D3D10_SB_OPERAND_4_COMPONENT_MASK_ALL D3D10_SB_OPERAND_4_COMPONENT_MASK_MASK
  728. // DECODER MACRO: When 4 component selection mode is
  729. // D3D10_SB_OPERAND_4_COMPONENT_MASK_MODE, this macro
  730. // extracts from OperandToken0 the 4 component (xyzw) mask,
  731. // as a field of D3D10_SB_OPERAND_4_COMPONENT_MASK_[X|Y|Z|W] flags.
  732. // Alternatively, the D3D10_SB_OPERAND_4_COMPONENT_MASK_[X|Y|Z|W] masks
  733. // can be tested on OperandToken0 directly, without this macro.
  734. #define DECODE_D3D10_SB_OPERAND_4_COMPONENT_MASK(OperandToken0) ((OperandToken0)&D3D10_SB_OPERAND_4_COMPONENT_MASK_MASK)
  735. // ENCODER MACRO: Given a set of
  736. // D3D10_SB_OPERAND_4_COMPONENT_MASK_[X|Y|Z|W] values
  737. // or'd together, encode them in OperandToken0.
  738. #define ENCODE_D3D10_SB_OPERAND_4_COMPONENT_MASK(ComponentMask) ((ComponentMask)&D3D10_SB_OPERAND_4_COMPONENT_MASK_MASK)
  739. // ENCODER/DECODER MACRO: Given a D3D10_SB_4_COMPONENT_NAME,
  740. // generate the 4-component mask for it.
  741. // This can be used in loops that build masks or read masks.
  742. // Alternatively, the D3D10_SB_OPERAND_4_COMPONENT_MASK_[X|Y|Z|W] masks
  743. // can be used directly, without this macro.
  744. #define D3D10_SB_OPERAND_4_COMPONENT_MASK(ComponentName) ((1<<(D3D10_SB_OPERAND_4_COMPONENT_MASK_SHIFT+ComponentName))&D3D10_SB_OPERAND_4_COMPONENT_MASK_MASK)
  745. // MACROS FOR USE IN D3D10_SB_OPERAND_4_COMPONENT_SWIZZLE_MODE:
  746. #define D3D10_SB_OPERAND_4_COMPONENT_SWIZZLE_MASK 0x00000ff0
  747. #define D3D10_SB_OPERAND_4_COMPONENT_SWIZZLE_SHIFT 4
  748. // DECODER MACRO: When 4 component selection mode is
  749. // D3D10_SB_OPERAND_4_COMPONENT_SWIZZLE_MODE, this macro
  750. // extracts from OperandToken0 the 4 component swizzle,
  751. // as a field of D3D10_SB_OPERAND_4_COMPONENT_MASK_[X|Y|Z|W] flags.
  752. #define DECODE_D3D10_SB_OPERAND_4_COMPONENT_SWIZZLE(OperandToken0) ((OperandToken0)&D3D10_SB_OPERAND_4_COMPONENT_SWIZZLE_MASK)
  753. // DECODER MACRO: Pass a D3D10_SB_4_COMPONENT_NAME as "DestComp" in following
  754. // macro to extract, from OperandToken0 or from a decoded swizzle,
  755. // the swizzle source component (D3D10_SB_4_COMPONENT_NAME enum):
  756. #define DECODE_D3D10_SB_OPERAND_4_COMPONENT_SWIZZLE_SOURCE(OperandToken0,DestComp) ((D3D10_SB_4_COMPONENT_NAME)(((OperandToken0)>>(D3D10_SB_OPERAND_4_COMPONENT_SWIZZLE_SHIFT+2*((DestComp)&D3D10_SB_4_COMPONENT_NAME_MASK)))&D3D10_SB_4_COMPONENT_NAME_MASK))
  757. // ENCODER MACRO: Generate a 4 component swizzle given
  758. // 4 D3D10_SB_4_COMPONENT_NAME source values for dest
  759. // components x, y, z, w respectively.
  760. #define ENCODE_D3D10_SB_OPERAND_4_COMPONENT_SWIZZLE(XSrc,YSrc,ZSrc,WSrc) ((((XSrc)&D3D10_SB_4_COMPONENT_NAME_MASK)| \
  761. (((YSrc)&D3D10_SB_4_COMPONENT_NAME_MASK)<<2)| \
  762. (((ZSrc)&D3D10_SB_4_COMPONENT_NAME_MASK)<<4)| \
  763. (((WSrc)&D3D10_SB_4_COMPONENT_NAME_MASK)<<6) \
  764. )<<D3D10_SB_OPERAND_4_COMPONENT_SWIZZLE_SHIFT)
  765. // ENCODER/DECODER MACROS: Various common swizzle patterns
  766. // (noswizzle and replicate of each channels)
  767. #define D3D10_SB_OPERAND_4_COMPONENT_NOSWIZZLE ENCODE_D3D10_SB_OPERAND_4_COMPONENT_SWIZZLE(D3D10_SB_4_COMPONENT_X,\
  768. D3D10_SB_4_COMPONENT_Y,\
  769. D3D10_SB_4_COMPONENT_Z,\
  770. D3D10_SB_4_COMPONENT_W)
  771. #define D3D10_SB_OPERAND_4_COMPONENT_REPLICATEX ENCODE_D3D10_SB_OPERAND_4_COMPONENT_SWIZZLE(D3D10_SB_4_COMPONENT_X,\
  772. D3D10_SB_4_COMPONENT_X,\
  773. D3D10_SB_4_COMPONENT_X,\
  774. D3D10_SB_4_COMPONENT_X)
  775. #define D3D10_SB_OPERAND_4_COMPONENT_REPLICATEY ENCODE_D3D10_SB_OPERAND_4_COMPONENT_SWIZZLE(D3D10_SB_4_COMPONENT_Y,\
  776. D3D10_SB_4_COMPONENT_Y,\
  777. D3D10_SB_4_COMPONENT_Y,\
  778. D3D10_SB_4_COMPONENT_Y)
  779. #define D3D10_SB_OPERAND_4_COMPONENT_REPLICATEZ ENCODE_D3D10_SB_OPERAND_4_COMPONENT_SWIZZLE(D3D10_SB_4_COMPONENT_Z,\
  780. D3D10_SB_4_COMPONENT_Z,\
  781. D3D10_SB_4_COMPONENT_Z,\
  782. D3D10_SB_4_COMPONENT_Z)
  783. #define D3D10_SB_OPERAND_4_COMPONENT_REPLICATEW ENCODE_D3D10_SB_OPERAND_4_COMPONENT_SWIZZLE(D3D10_SB_4_COMPONENT_W,\
  784. D3D10_SB_4_COMPONENT_W,\
  785. D3D10_SB_4_COMPONENT_W,\
  786. D3D10_SB_4_COMPONENT_W)
  787. #define D3D10_SB_OPERAND_4_COMPONENT_REPLICATERED D3D10_SB_OPERAND_4_COMPONENT_REPLICATEX
  788. #define D3D10_SB_OPERAND_4_COMPONENT_REPLICATEGREEN D3D10_SB_OPERAND_4_COMPONENT_REPLICATEY
  789. #define D3D10_SB_OPERAND_4_COMPONENT_REPLICATEBLUE D3D10_SB_OPERAND_4_COMPONENT_REPLICATEZ
  790. #define D3D10_SB_OPERAND_4_COMPONENT_REPLICATEALPHA D3D10_SB_OPERAND_4_COMPONENT_REPLICATEW
  791. // MACROS FOR USE IN D3D10_SB_OPERAND_4_COMPONENT_SELECT_1_MODE:
  792. #define D3D10_SB_OPERAND_4_COMPONENT_SELECT_1_MASK 0x00000030
  793. #define D3D10_SB_OPERAND_4_COMPONENT_SELECT_1_SHIFT 4
  794. // DECODER MACRO: When 4 component selection mode is
  795. // D3D10_SB_OPERAND_4_COMPONENT_SELECT_1_MODE, this macro
  796. // extracts from OperandToken0 a D3D10_SB_4_COMPONENT_NAME
  797. // which picks one of the 4 components.
  798. #define DECODE_D3D10_SB_OPERAND_4_COMPONENT_SELECT_1(OperandToken0) ((D3D10_SB_4_COMPONENT_NAME)(((OperandToken0)&D3D10_SB_OPERAND_4_COMPONENT_SELECT_1_MASK)>>D3D10_SB_OPERAND_4_COMPONENT_SELECT_1_SHIFT))
  799. // ENCODER MACRO: Given a D3D10_SB_4_COMPONENT_NAME selecting
  800. // a single component for D3D10_SB_OPERAND_4_COMPONENT_SELECT_1_MODE,
  801. // encode it into OperandToken0
  802. #define ENCODE_D3D10_SB_OPERAND_4_COMPONENT_SELECT_1(SelectedComp) (((SelectedComp)<<D3D10_SB_OPERAND_4_COMPONENT_SELECT_1_SHIFT)&D3D10_SB_OPERAND_4_COMPONENT_SELECT_1_MASK)
  803. // MACROS FOR DETERMINING OPERAND TYPE:
  804. typedef enum D3D10_SB_OPERAND_TYPE
  805. {
  806. D3D10_SB_OPERAND_TYPE_TEMP = 0, // Temporary Register File
  807. D3D10_SB_OPERAND_TYPE_INPUT = 1, // General Input Register File
  808. D3D10_SB_OPERAND_TYPE_OUTPUT = 2, // General Output Register File
  809. D3D10_SB_OPERAND_TYPE_INDEXABLE_TEMP = 3, // Temporary Register File (indexable)
  810. D3D10_SB_OPERAND_TYPE_IMMEDIATE32 = 4, // 32bit/component immediate value(s)
  811. // If for example, operand token bits
  812. // [01:00]==D3D10_SB_OPERAND_4_COMPONENT,
  813. // this means that the operand type:
  814. // D3D10_SB_OPERAND_TYPE_IMMEDIATE32
  815. // results in 4 additional 32bit
  816. // DWORDS present for the operand.
  817. D3D10_SB_OPERAND_TYPE_IMMEDIATE64 = 5, // 64bit/comp.imm.val(s)HI:LO
  818. D3D10_SB_OPERAND_TYPE_SAMPLER = 6, // Reference to sampler state
  819. D3D10_SB_OPERAND_TYPE_RESOURCE = 7, // Reference to memory resource (e.g. texture)
  820. D3D10_SB_OPERAND_TYPE_CONSTANT_BUFFER= 8, // Reference to constant buffer
  821. D3D10_SB_OPERAND_TYPE_IMMEDIATE_CONSTANT_BUFFER= 9, // Reference to immediate constant buffer
  822. D3D10_SB_OPERAND_TYPE_LABEL = 10, // Label
  823. D3D10_SB_OPERAND_TYPE_INPUT_PRIMITIVEID = 11, // Input primitive ID
  824. D3D10_SB_OPERAND_TYPE_OUTPUT_DEPTH = 12, // Output Depth
  825. D3D10_SB_OPERAND_TYPE_NULL = 13, // Null register, used to discard results of operations
  826. // Below Are operands new in DX 10.1
  827. D3D10_SB_OPERAND_TYPE_RASTERIZER = 14, // DX10.1 Rasterizer register, used to denote the depth/stencil and render target resources
  828. D3D10_SB_OPERAND_TYPE_OUTPUT_COVERAGE_MASK = 15, // DX10.1 PS output MSAA coverage mask (scalar)
  829. // Below Are operands new in DX 11
  830. D3D11_SB_OPERAND_TYPE_STREAM = 16, // Reference to GS stream output resource
  831. D3D11_SB_OPERAND_TYPE_FUNCTION_BODY = 17, // Reference to a function definition
  832. D3D11_SB_OPERAND_TYPE_FUNCTION_TABLE = 18, // Reference to a set of functions used by a class
  833. D3D11_SB_OPERAND_TYPE_INTERFACE = 19, // Reference to an interface
  834. D3D11_SB_OPERAND_TYPE_FUNCTION_INPUT = 20, // Reference to an input parameter to a function
  835. D3D11_SB_OPERAND_TYPE_FUNCTION_OUTPUT = 21, // Reference to an output parameter to a function
  836. D3D11_SB_OPERAND_TYPE_OUTPUT_CONTROL_POINT_ID = 22, // HS Control Point phase input saying which output control point ID this is
  837. D3D11_SB_OPERAND_TYPE_INPUT_FORK_INSTANCE_ID = 23, // HS Fork Phase input instance ID
  838. D3D11_SB_OPERAND_TYPE_INPUT_JOIN_INSTANCE_ID = 24, // HS Join Phase input instance ID
  839. D3D11_SB_OPERAND_TYPE_INPUT_CONTROL_POINT = 25, // HS Fork+Join, DS phase input control points (array of them)
  840. D3D11_SB_OPERAND_TYPE_OUTPUT_CONTROL_POINT = 26, // HS Fork+Join phase output control points (array of them)
  841. D3D11_SB_OPERAND_TYPE_INPUT_PATCH_CONSTANT = 27, // DS+HSJoin Input Patch Constants (array of them)
  842. D3D11_SB_OPERAND_TYPE_INPUT_DOMAIN_POINT = 28, // DS Input Domain point
  843. D3D11_SB_OPERAND_TYPE_THIS_POINTER = 29, // Reference to an interface this pointer
  844. D3D11_SB_OPERAND_TYPE_UNORDERED_ACCESS_VIEW = 30, // Reference to UAV u#
  845. D3D11_SB_OPERAND_TYPE_THREAD_GROUP_SHARED_MEMORY = 31, // Reference to Thread Group Shared Memory g#
  846. D3D11_SB_OPERAND_TYPE_INPUT_THREAD_ID = 32, // Compute Shader Thread ID
  847. D3D11_SB_OPERAND_TYPE_INPUT_THREAD_GROUP_ID = 33, // Compute Shader Thread Group ID
  848. D3D11_SB_OPERAND_TYPE_INPUT_THREAD_ID_IN_GROUP = 34, // Compute Shader Thread ID In Thread Group
  849. D3D11_SB_OPERAND_TYPE_INPUT_COVERAGE_MASK = 35, // Pixel shader coverage mask input
  850. D3D11_SB_OPERAND_TYPE_INPUT_THREAD_ID_IN_GROUP_FLATTENED = 36, // Compute Shader Thread ID In Group Flattened to a 1D value.
  851. D3D11_SB_OPERAND_TYPE_INPUT_GS_INSTANCE_ID = 37, // Input GS instance ID
  852. D3D11_SB_OPERAND_TYPE_OUTPUT_DEPTH_GREATER_EQUAL = 38, // Output Depth, forced to be greater than or equal than current depth
  853. D3D11_SB_OPERAND_TYPE_OUTPUT_DEPTH_LESS_EQUAL = 39, // Output Depth, forced to be less than or equal to current depth
  854. D3D11_SB_OPERAND_TYPE_CYCLE_COUNTER = 40, // Cycle counter
  855. D3D11_SB_OPERAND_TYPE_OUTPUT_STENCIL_REF = 41, // DX11 PS output stencil reference (scalar)
  856. D3D11_SB_OPERAND_TYPE_INNER_COVERAGE = 42, // DX11 PS input inner coverage (scalar)
  857. } D3D10_SB_OPERAND_TYPE;
  858. #define D3D10_SB_OPERAND_TYPE_MASK 0x000ff000
  859. #define D3D10_SB_OPERAND_TYPE_SHIFT 12
  860. // DECODER MACRO: Determine operand type from OperandToken0.
  861. #define DECODE_D3D10_SB_OPERAND_TYPE(OperandToken0) ((D3D10_SB_OPERAND_TYPE)(((OperandToken0)&D3D10_SB_OPERAND_TYPE_MASK)>>D3D10_SB_OPERAND_TYPE_SHIFT))
  862. // ENCODER MACRO: Store operand type in OperandToken0.
  863. #define ENCODE_D3D10_SB_OPERAND_TYPE(OperandType) (((OperandType)<<D3D10_SB_OPERAND_TYPE_SHIFT)&D3D10_SB_OPERAND_TYPE_MASK)
  864. typedef enum D3D10_SB_OPERAND_INDEX_DIMENSION
  865. {
  866. D3D10_SB_OPERAND_INDEX_0D = 0, // e.g. Position
  867. D3D10_SB_OPERAND_INDEX_1D = 1, // Most common. e.g. Temp registers.
  868. D3D10_SB_OPERAND_INDEX_2D = 2, // e.g. Geometry Program Input registers.
  869. D3D10_SB_OPERAND_INDEX_3D = 3, // 3D rarely if ever used.
  870. } D3D10_SB_OPERAND_INDEX_DIMENSION;
  871. #define D3D10_SB_OPERAND_INDEX_DIMENSION_MASK 0x00300000
  872. #define D3D10_SB_OPERAND_INDEX_DIMENSION_SHIFT 20
  873. // DECODER MACRO: Determine operand index dimension from OperandToken0.
  874. #define DECODE_D3D10_SB_OPERAND_INDEX_DIMENSION(OperandToken0) ((D3D10_SB_OPERAND_INDEX_DIMENSION)(((OperandToken0)&D3D10_SB_OPERAND_INDEX_DIMENSION_MASK)>>D3D10_SB_OPERAND_INDEX_DIMENSION_SHIFT))
  875. // ENCODER MACRO: Store operand index dimension
  876. // (D3D10_SB_OPERAND_INDEX_DIMENSION enum) in OperandToken0.
  877. #define ENCODE_D3D10_SB_OPERAND_INDEX_DIMENSION(OperandIndexDim) (((OperandIndexDim)<<D3D10_SB_OPERAND_INDEX_DIMENSION_SHIFT)&D3D10_SB_OPERAND_INDEX_DIMENSION_MASK)
  878. typedef enum D3D10_SB_OPERAND_INDEX_REPRESENTATION
  879. {
  880. D3D10_SB_OPERAND_INDEX_IMMEDIATE32 = 0, // Extra DWORD
  881. D3D10_SB_OPERAND_INDEX_IMMEDIATE64 = 1, // 2 Extra DWORDs
  882. // (HI32:LO32)
  883. D3D10_SB_OPERAND_INDEX_RELATIVE = 2, // Extra operand
  884. D3D10_SB_OPERAND_INDEX_IMMEDIATE32_PLUS_RELATIVE = 3, // Extra DWORD followed by
  885. // extra operand
  886. D3D10_SB_OPERAND_INDEX_IMMEDIATE64_PLUS_RELATIVE = 4, // 2 Extra DWORDS
  887. // (HI32:LO32) followed
  888. // by extra operand
  889. } D3D10_SB_OPERAND_INDEX_REPRESENTATION;
  890. #define D3D10_SB_OPERAND_INDEX_REPRESENTATION_SHIFT(Dim) (22+3*((Dim)&3))
  891. #define D3D10_SB_OPERAND_INDEX_REPRESENTATION_MASK(Dim) (0x3<<D3D10_SB_OPERAND_INDEX_REPRESENTATION_SHIFT(Dim))
  892. // DECODER MACRO: Determine from OperandToken0 what representation
  893. // an operand index is provided as (D3D10_SB_OPERAND_INDEX_REPRESENTATION enum),
  894. // for index dimension [0], [1] or [2], depending on D3D10_SB_OPERAND_INDEX_DIMENSION.
  895. #define DECODE_D3D10_SB_OPERAND_INDEX_REPRESENTATION(Dim,OperandToken0) ((D3D10_SB_OPERAND_INDEX_REPRESENTATION)(((OperandToken0)&D3D10_SB_OPERAND_INDEX_REPRESENTATION_MASK(Dim))>>D3D10_SB_OPERAND_INDEX_REPRESENTATION_SHIFT(Dim)))
  896. // ENCODER MACRO: Store in OperandToken0 what representation
  897. // an operand index is provided as (D3D10_SB_OPERAND_INDEX_REPRESENTATION enum),
  898. // for index dimension [0], [1] or [2], depending on D3D10_SB_OPERAND_INDEX_DIMENSION.
  899. #define ENCODE_D3D10_SB_OPERAND_INDEX_REPRESENTATION(Dim,IndexRepresentation) (((IndexRepresentation)<<D3D10_SB_OPERAND_INDEX_REPRESENTATION_SHIFT(Dim))&D3D10_SB_OPERAND_INDEX_REPRESENTATION_MASK(Dim))
  900. #define D3D10_SB_OPERAND_EXTENDED_MASK 0x80000000
  901. #define D3D10_SB_OPERAND_EXTENDED_SHIFT 31
  902. // DECODER MACRO: Determine if the operand is extended
  903. // by an additional opcode token.
  904. #define DECODE_IS_D3D10_SB_OPERAND_EXTENDED(OperandToken0) (((OperandToken0)&D3D10_SB_OPERAND_EXTENDED_MASK)>>D3D10_SB_OPERAND_EXTENDED_SHIFT)
  905. // ENCODER MACRO: Store in OperandToken0 whether the operand is extended
  906. // by an additional operand token.
  907. #define ENCODE_D3D10_SB_OPERAND_EXTENDED(bExtended) (((bExtended)!=0)?D3D10_SB_OPERAND_EXTENDED_MASK:0)
  908. // ----------------------------------------------------------------------------
  909. // Extended Instruction Operand Format (OperandToken1)
  910. //
  911. // If bit31 of an operand token is set, the
  912. // operand has additional data in a second DWORD
  913. // directly following OperandToken0. Other tokens
  914. // expected for the operand, such as immmediate
  915. // values or relative address operands (full
  916. // operands in themselves) always follow
  917. // OperandToken0 AND OperandToken1..n (extended
  918. // operand tokens, if present).
  919. //
  920. // [05:00] D3D10_SB_EXTENDED_OPERAND_TYPE
  921. // [16:06] if([05:00] == D3D10_SB_EXTENDED_OPERAND_MODIFIER)
  922. // {
  923. // [13:06] D3D10_SB_OPERAND_MODIFIER
  924. // [16:14] Min Precision: D3D11_SB_OPERAND_MIN_PRECISION
  925. // [17:17] Non-uniform: D3D12_SB_OPERAND_NON_UNIFORM
  926. // }
  927. // else
  928. // {
  929. // [17:06] Ignored, 0.
  930. // }
  931. // [30:18] Ignored, 0.
  932. // [31] 0 normally. 1 if second order extended operand definition,
  933. // meaning next DWORD contains yet ANOTHER extended operand
  934. // description. Currently no second order extensions defined.
  935. // This would be useful if a particular extended operand does
  936. // not have enough space to store the required information in
  937. // a single token and so is extended further.
  938. //
  939. // ----------------------------------------------------------------------------
  940. typedef enum D3D10_SB_EXTENDED_OPERAND_TYPE
  941. {
  942. D3D10_SB_EXTENDED_OPERAND_EMPTY = 0, // Might be used if this
  943. // enum is full and
  944. // further extended opcode
  945. // is needed.
  946. D3D10_SB_EXTENDED_OPERAND_MODIFIER = 1,
  947. } D3D10_SB_EXTENDED_OPERAND_TYPE;
  948. #define D3D10_SB_EXTENDED_OPERAND_TYPE_MASK 0x0000003f
  949. // DECODER MACRO: Given an extended operand
  950. // token (OperandToken1), figure out what type
  951. // of token it is (from D3D10_SB_EXTENDED_OPERAND_TYPE enum)
  952. // to be able to interpret the rest of the token's contents.
  953. #define DECODE_D3D10_SB_EXTENDED_OPERAND_TYPE(OperandToken1) ((D3D10_SB_EXTENDED_OPERAND_TYPE)((OperandToken1)&D3D10_SB_EXTENDED_OPERAND_TYPE_MASK))
  954. // ENCODER MACRO: Store extended operand token
  955. // type in OperandToken1.
  956. #define ENCODE_D3D10_SB_EXTENDED_OPERAND_TYPE(ExtOperandType) ((ExtOperandType)&D3D10_SB_EXTENDED_OPERAND_TYPE_MASK)
  957. typedef enum D3D10_SB_OPERAND_MODIFIER
  958. {
  959. D3D10_SB_OPERAND_MODIFIER_NONE = 0, // Nop. This is the implied
  960. // default if the extended
  961. // operand is not present for
  962. // an operand for which source
  963. // modifiers are meaningful
  964. D3D10_SB_OPERAND_MODIFIER_NEG = 1, // Negate
  965. D3D10_SB_OPERAND_MODIFIER_ABS = 2, // Absolute value, abs()
  966. D3D10_SB_OPERAND_MODIFIER_ABSNEG = 3, // -abs()
  967. } D3D10_SB_OPERAND_MODIFIER;
  968. #define D3D10_SB_OPERAND_MODIFIER_MASK 0x00003fc0
  969. #define D3D10_SB_OPERAND_MODIFIER_SHIFT 6
  970. // DECODER MACRO: Given a D3D10_SB_EXTENDED_OPERAND_MODIFIER
  971. // extended token (OperandToken1), determine the source modifier
  972. // (D3D10_SB_OPERAND_MODIFIER enum)
  973. #define DECODE_D3D10_SB_OPERAND_MODIFIER(OperandToken1) ((D3D10_SB_OPERAND_MODIFIER)(((OperandToken1)&D3D10_SB_OPERAND_MODIFIER_MASK)>>D3D10_SB_OPERAND_MODIFIER_SHIFT))
  974. // ENCODER MACRO: Generate a complete source modifier extended token
  975. // (OperandToken1), given D3D10_SB_OPERAND_MODIFIER enum (the
  976. // ext. operand type is also set to D3D10_SB_EXTENDED_OPERAND_MODIFIER).
  977. #define ENCODE_D3D10_SB_EXTENDED_OPERAND_MODIFIER(SourceMod) ((((SourceMod)<<D3D10_SB_OPERAND_MODIFIER_SHIFT)&D3D10_SB_OPERAND_MODIFIER_MASK)| \
  978. ENCODE_D3D10_SB_EXTENDED_OPERAND_TYPE(D3D10_SB_EXTENDED_OPERAND_MODIFIER) | \
  979. ENCODE_D3D10_SB_OPERAND_DOUBLE_EXTENDED(0))
  980. // Min precision specifier for source/dest operands. This
  981. // fits in the extended operand token field. Implementations are free to
  982. // execute at higher precision than the min - details spec'ed elsewhere.
  983. // This is part of the opcode specific control range.
  984. typedef enum D3D11_SB_OPERAND_MIN_PRECISION
  985. {
  986. D3D11_SB_OPERAND_MIN_PRECISION_DEFAULT = 0, // Default precision
  987. // for the shader model
  988. D3D11_SB_OPERAND_MIN_PRECISION_FLOAT_16 = 1, // Min 16 bit/component float
  989. D3D11_SB_OPERAND_MIN_PRECISION_FLOAT_2_8 = 2, // Min 10(2.8)bit/comp. float
  990. D3D11_SB_OPERAND_MIN_PRECISION_SINT_16 = 4, // Min 16 bit/comp. signed integer
  991. D3D11_SB_OPERAND_MIN_PRECISION_UINT_16 = 5, // Min 16 bit/comp. unsigned integer
  992. } D3D11_SB_OPERAND_MIN_PRECISION;
  993. #define D3D11_SB_OPERAND_MIN_PRECISION_MASK 0x0001C000
  994. #define D3D11_SB_OPERAND_MIN_PRECISION_SHIFT 14
  995. // DECODER MACRO: For an OperandToken1 that can specify
  996. // a minimum precision for execution, find out what it is.
  997. #define DECODE_D3D11_SB_OPERAND_MIN_PRECISION(OperandToken1) ((D3D11_SB_OPERAND_MIN_PRECISION)(((OperandToken1)& D3D11_SB_OPERAND_MIN_PRECISION_MASK)>> D3D11_SB_OPERAND_MIN_PRECISION_SHIFT))
  998. // ENCODER MACRO: Encode minimum precision for execution
  999. // into the extended operand token, OperandToken1
  1000. #define ENCODE_D3D11_SB_OPERAND_MIN_PRECISION(MinPrecision) (((MinPrecision)<< D3D11_SB_OPERAND_MIN_PRECISION_SHIFT)& D3D11_SB_OPERAND_MIN_PRECISION_MASK)
  1001. // Non-uniform extended operand modifier.
  1002. #define D3D12_SB_OPERAND_NON_UNIFORM_MASK 0x00020000
  1003. #define D3D12_SB_OPERAND_NON_UNIFORM_SHIFT 17
  1004. // DECODER MACRO: For an OperandToken1 that can specify a non-uniform operand
  1005. #define DECODE_D3D12_SB_OPERAND_NON_UNIFORM(OperandToken1) (((OperandToken1)& D3D12_SB_OPERAND_NON_UNIFORM_MASK)>> D3D12_SB_OPERAND_NON_UNIFORM_SHIFT)
  1006. // ENCODER MACRO: Encode non-uniform state into the extended operand token, OperandToken1
  1007. #define ENCODE_D3D12_SB_OPERAND_NON_UNIFORM(NonUniform) (((NonUniform)<< D3D12_SB_OPERAND_NON_UNIFORM_SHIFT)& D3D12_SB_OPERAND_NON_UNIFORM_MASK)
  1008. #define D3D10_SB_OPERAND_DOUBLE_EXTENDED_MASK 0x80000000
  1009. #define D3D10_SB_OPERAND_DOUBLE_EXTENDED_SHIFT 31
  1010. // DECODER MACRO: Determine if an extended operand token
  1011. // (OperandToken1) is further extended by yet another token
  1012. // (OperandToken2). Currently there are no secondary
  1013. // extended operand tokens.
  1014. #define DECODE_IS_D3D10_SB_OPERAND_DOUBLE_EXTENDED(OperandToken1) (((OperandToken1)&D3D10_SB_OPERAND_DOUBLE_EXTENDED_MASK)>>D3D10_SB_OPERAND_DOUBLE_EXTENDED_SHIFT)
  1015. // ENCODER MACRO: Store in OperandToken1 whether the operand is extended
  1016. // by an additional operand token. Currently there are no secondary
  1017. // extended operand tokens.
  1018. #define ENCODE_D3D10_SB_OPERAND_DOUBLE_EXTENDED(bExtended) (((bExtended)!=0)?D3D10_SB_OPERAND_DOUBLE_EXTENDED_MASK:0)
  1019. // ----------------------------------------------------------------------------
  1020. // Name Token (NameToken) (used in declaration statements)
  1021. //
  1022. // [15:00] D3D10_SB_NAME enumeration
  1023. // [31:16] Reserved, 0
  1024. //
  1025. // ----------------------------------------------------------------------------
  1026. #define D3D10_SB_NAME_MASK 0x0000ffff
  1027. // DECODER MACRO: Get the name from NameToken
  1028. #define DECODE_D3D10_SB_NAME(NameToken) ((D3D10_SB_NAME)((NameToken)&D3D10_SB_NAME_MASK))
  1029. // ENCODER MACRO: Generate a complete NameToken given a D3D10_SB_NAME
  1030. #define ENCODE_D3D10_SB_NAME(Name) ((Name)&D3D10_SB_NAME_MASK)
  1031. //---------------------------------------------------------------------
  1032. // Declaration Statements
  1033. //
  1034. // Declarations start with a standard opcode token,
  1035. // having opcode type being D3D10_SB_OPCODE_DCL*.
  1036. // Each particular declaration type has custom
  1037. // operand token(s), described below.
  1038. //---------------------------------------------------------------------
  1039. // ----------------------------------------------------------------------------
  1040. // Global Flags Declaration
  1041. //
  1042. // OpcodeToken0:
  1043. //
  1044. // [10:00] D3D10_SB_OPCODE_DCL_GLOBAL_FLAGS
  1045. // [11:11] Refactoring allowed if bit set.
  1046. // [12:12] Enable double precision float ops.
  1047. // [13:13] Force early depth-stencil test.
  1048. // [14:14] Enable RAW and structured buffers in non-CS 4.x shaders.
  1049. // [15:15] Skip optimizations of shader IL when translating to native code
  1050. // [16:16] Enable minimum-precision data types
  1051. // [17:17] Enable 11.1 double-precision floating-point instruction extensions
  1052. // [18:18] Enable 11.1 non-double instruction extensions
  1053. // [23:19] Reserved for future flags.
  1054. // [30:24] Instruction length in DWORDs including the opcode token. == 1
  1055. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD
  1056. // contains extended operand description. This dcl is currently not
  1057. // extended.
  1058. //
  1059. // OpcodeToken0 is followed by no operands.
  1060. //
  1061. // ----------------------------------------------------------------------------
  1062. #define D3D10_SB_GLOBAL_FLAG_REFACTORING_ALLOWED (1<<11)
  1063. #define D3D11_SB_GLOBAL_FLAG_ENABLE_DOUBLE_PRECISION_FLOAT_OPS (1<<12)
  1064. #define D3D11_SB_GLOBAL_FLAG_FORCE_EARLY_DEPTH_STENCIL (1<<13)
  1065. #define D3D11_SB_GLOBAL_FLAG_ENABLE_RAW_AND_STRUCTURED_BUFFERS (1<<14)
  1066. #define D3D11_1_SB_GLOBAL_FLAG_SKIP_OPTIMIZATION (1<<15)
  1067. #define D3D11_1_SB_GLOBAL_FLAG_ENABLE_MINIMUM_PRECISION (1<<16)
  1068. #define D3D11_1_SB_GLOBAL_FLAG_ENABLE_DOUBLE_EXTENSIONS (1<<17)
  1069. #define D3D11_1_SB_GLOBAL_FLAG_ENABLE_SHADER_EXTENSIONS (1<<18)
  1070. #define D3D12_SB_GLOBAL_FLAG_ALL_RESOURCES_BOUND (1<<19)
  1071. #define D3D10_SB_GLOBAL_FLAGS_MASK 0x00fff800
  1072. // DECODER MACRO: Get global flags
  1073. #define DECODE_D3D10_SB_GLOBAL_FLAGS(OpcodeToken0) ((OpcodeToken0)&D3D10_SB_GLOBAL_FLAGS_MASK)
  1074. // ENCODER MACRO: Encode global flags
  1075. #define ENCODE_D3D10_SB_GLOBAL_FLAGS(Flags) ((Flags)&D3D10_SB_GLOBAL_FLAGS_MASK)
  1076. // ----------------------------------------------------------------------------
  1077. // Resource Declaration (non multisampled)
  1078. //
  1079. // OpcodeToken0:
  1080. //
  1081. // [10:00] D3D10_SB_OPCODE_DCL_RESOURCE
  1082. // [15:11] D3D10_SB_RESOURCE_DIMENSION
  1083. // [23:16] Ignored, 0
  1084. // [30:24] Instruction length in DWORDs including the opcode token.
  1085. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD
  1086. // contains extended operand description. This dcl is currently not
  1087. // extended.
  1088. //
  1089. // OpcodeToken0 is followed by 2 operands on Shader Models 4.0 through 5.0:
  1090. // (1) an operand, starting with OperandToken0, defining which
  1091. // t# register (D3D10_SB_OPERAND_TYPE_RESOURCE) is being declared.
  1092. // (2) a Resource Return Type token (ResourceReturnTypeToken)
  1093. //
  1094. // OpcodeToken0 is followed by 3 operands on Shader Model 5.1 and later:
  1095. // (1) an operand, starting with OperandToken0, defining which
  1096. // t# register (D3D10_SB_OPERAND_TYPE_RESOURCE) is being declared.
  1097. // The indexing dimension for the register must be D3D10_SB_OPERAND_INDEX_DIMENSION_3D,
  1098. // and the meaning of the index dimensions are as follows: (t<id>[<lbound>:<ubound>])
  1099. // 1 <id>: variable ID being declared
  1100. // 2 <lbound>: the lower bound of the range of resources in the space
  1101. // 3 <ubound>: the upper bound (inclusive) of this range
  1102. // As opposed to when the t# is used in shader instructions, where the register
  1103. // must be D3D10_SB_OPERAND_INDEX_DIMENSION_2D, and the meaning of the index
  1104. // dimensions are as follows: (t<id>[<idx>]):
  1105. // 1 <id>: variable ID being used (matches dcl)
  1106. // 2 <idx>: absolute index of resource within space (may be dynamically indexed)
  1107. // (2) a Resource Return Type token (ResourceReturnTypeToken)
  1108. // (3) a DWORD indicating the space index.
  1109. //
  1110. // ----------------------------------------------------------------------------
  1111. #define D3D10_SB_RESOURCE_DIMENSION_MASK 0x0000F800
  1112. #define D3D10_SB_RESOURCE_DIMENSION_SHIFT 11
  1113. // DECODER MACRO: Given a resource declaration token,
  1114. // (OpcodeToken0), determine the resource dimension
  1115. // (D3D10_SB_RESOURCE_DIMENSION enum)
  1116. #define DECODE_D3D10_SB_RESOURCE_DIMENSION(OpcodeToken0) ((D3D10_SB_RESOURCE_DIMENSION)(((OpcodeToken0)&D3D10_SB_RESOURCE_DIMENSION_MASK)>>D3D10_SB_RESOURCE_DIMENSION_SHIFT))
  1117. // ENCODER MACRO: Store resource dimension
  1118. // (D3D10_SB_RESOURCE_DIMENSION enum) into a
  1119. // a resource declaration token (OpcodeToken0)
  1120. #define ENCODE_D3D10_SB_RESOURCE_DIMENSION(ResourceDim) (((ResourceDim)<<D3D10_SB_RESOURCE_DIMENSION_SHIFT)&D3D10_SB_RESOURCE_DIMENSION_MASK)
  1121. // ----------------------------------------------------------------------------
  1122. // Resource Declaration (multisampled)
  1123. //
  1124. // OpcodeToken0:
  1125. //
  1126. // [10:00] D3D10_SB_OPCODE_DCL_RESOURCE (same opcode as non-multisampled case)
  1127. // [15:11] D3D10_SB_RESOURCE_DIMENSION (must be TEXTURE2DMS or TEXTURE2DMSARRAY)
  1128. // [22:16] Sample count 1...127. 0 is currently disallowed, though
  1129. // in future versions 0 could mean "configurable" sample count
  1130. // [23:23] Ignored, 0
  1131. // [30:24] Instruction length in DWORDs including the opcode token.
  1132. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD
  1133. // contains extended operand description. This dcl is currently not
  1134. // extended.
  1135. //
  1136. // OpcodeToken0 is followed by 2 operands on Shader Models 4.0 through 5.0:
  1137. // (1) an operand, starting with OperandToken0, defining which
  1138. // t# register (D3D10_SB_OPERAND_TYPE_RESOURCE) is being declared.
  1139. // (2) a Resource Return Type token (ResourceReturnTypeToken)
  1140. //
  1141. // OpcodeToken0 is followed by 3 operands on Shader Model 5.1 and later:
  1142. // (1) an operand, starting with OperandToken0, defining which
  1143. // t# register (D3D10_SB_OPERAND_TYPE_RESOURCE) is being declared.
  1144. // The indexing dimension for the register must be D3D10_SB_OPERAND_INDEX_DIMENSION_3D,
  1145. // and the meaning of the index dimensions are as follows: (t<id>[<lbound>:<ubound>])
  1146. // 1 <id>: variable ID being declared
  1147. // 2 <lbound>: the lower bound of the range of resources in the space
  1148. // 3 <ubound>: the upper bound (inclusive) of this range
  1149. // As opposed to when the t# is used in shader instructions, where the register
  1150. // must be D3D10_SB_OPERAND_INDEX_DIMENSION_2D, and the meaning of the index
  1151. // dimensions are as follows: (t<id>[<idx>]):
  1152. // 1 <id>: variable ID being used (matches dcl)
  1153. // 2 <idx>: absolute index of resource within space (may be dynamically indexed)
  1154. // (2) a Resource Return Type token (ResourceReturnTypeToken)
  1155. // (3) a DWORD indicating the space index.
  1156. //
  1157. // ----------------------------------------------------------------------------
  1158. // use same macro for encoding/decoding resource dimension aas the non-msaa declaration
  1159. #define D3D10_SB_RESOURCE_SAMPLE_COUNT_MASK 0x07F0000
  1160. #define D3D10_SB_RESOURCE_SAMPLE_COUNT_SHIFT 16
  1161. // DECODER MACRO: Given a resource declaration token,
  1162. // (OpcodeToken0), determine the resource sample count (1..127)
  1163. #define DECODE_D3D10_SB_RESOURCE_SAMPLE_COUNT(OpcodeToken0) ((UINT)(((OpcodeToken0)&D3D10_SB_RESOURCE_SAMPLE_COUNT_MASK)>>D3D10_SB_RESOURCE_SAMPLE_COUNT_SHIFT))
  1164. // ENCODER MACRO: Store resource sample count up to 127 into a
  1165. // a resource declaration token (OpcodeToken0)
  1166. #define ENCODE_D3D10_SB_RESOURCE_SAMPLE_COUNT(SampleCount) (((SampleCount > 127 ? 127 : SampleCount)<<D3D10_SB_RESOURCE_SAMPLE_COUNT_SHIFT)&D3D10_SB_RESOURCE_SAMPLE_COUNT_MASK)
  1167. // ----------------------------------------------------------------------------
  1168. // Resource Return Type Token (ResourceReturnTypeToken) (used in resource
  1169. // declaration statements)
  1170. //
  1171. // [03:00] D3D10_SB_RESOURCE_RETURN_TYPE for component X
  1172. // [07:04] D3D10_SB_RESOURCE_RETURN_TYPE for component Y
  1173. // [11:08] D3D10_SB_RESOURCE_RETURN_TYPE for component Z
  1174. // [15:12] D3D10_SB_RESOURCE_RETURN_TYPE for component W
  1175. // [31:16] Reserved, 0
  1176. //
  1177. // ----------------------------------------------------------------------------
  1178. // DECODER MACRO: Get the resource return type for component (0-3) from
  1179. // ResourceReturnTypeToken
  1180. #define DECODE_D3D10_SB_RESOURCE_RETURN_TYPE(ResourceReturnTypeToken, Component) \
  1181. ((D3D10_SB_RESOURCE_RETURN_TYPE)(((ResourceReturnTypeToken) >> \
  1182. (Component * D3D10_SB_RESOURCE_RETURN_TYPE_NUMBITS))&D3D10_SB_RESOURCE_RETURN_TYPE_MASK))
  1183. // ENCODER MACRO: Generate a resource return type for a component
  1184. #define ENCODE_D3D10_SB_RESOURCE_RETURN_TYPE(ReturnType, Component) \
  1185. (((ReturnType)&D3D10_SB_RESOURCE_RETURN_TYPE_MASK) << (Component * D3D10_SB_RESOURCE_RETURN_TYPE_NUMBITS))
  1186. // ----------------------------------------------------------------------------
  1187. // Sampler Declaration
  1188. //
  1189. // OpcodeToken0:
  1190. //
  1191. // [10:00] D3D10_SB_OPCODE_DCL_SAMPLER
  1192. // [14:11] D3D10_SB_SAMPLER_MODE
  1193. // [23:15] Ignored, 0
  1194. // [30:24] Instruction length in DWORDs including the opcode token.
  1195. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD
  1196. // contains extended operand description. This dcl is currently not
  1197. // extended.
  1198. //
  1199. // OpcodeToken0 is followed by 1 operand on Shader Models 4.0 through 5.0:
  1200. // (1) Operand starting with OperandToken0, defining which sampler
  1201. // (D3D10_SB_OPERAND_TYPE_SAMPLER) register # is being declared.
  1202. //
  1203. // OpcodeToken0 is followed by 2 operands on Shader Model 5.1 and later:
  1204. // (1) an operand, starting with OperandToken0, defining which
  1205. // s# register (D3D10_SB_OPERAND_TYPE_SAMPLER) is being declared.
  1206. // The indexing dimension for the register must be D3D10_SB_OPERAND_INDEX_DIMENSION_3D,
  1207. // and the meaning of the index dimensions are as follows: (s<id>[<lbound>:<ubound>])
  1208. // 1 <id>: variable ID being declared
  1209. // 2 <lbound>: the lower bound of the range of samplers in the space
  1210. // 3 <ubound>: the upper bound (inclusive) of this range
  1211. // As opposed to when the s# is used in shader instructions, where the register
  1212. // must be D3D10_SB_OPERAND_INDEX_DIMENSION_2D, and the meaning of the index
  1213. // dimensions are as follows: (s<id>[<idx>]):
  1214. // 1 <id>: variable ID being used (matches dcl)
  1215. // 2 <idx>: absolute index of sampler within space (may be dynamically indexed)
  1216. // (2) a DWORD indicating the space index.
  1217. //
  1218. // ----------------------------------------------------------------------------
  1219. typedef enum D3D10_SB_SAMPLER_MODE
  1220. {
  1221. D3D10_SB_SAMPLER_MODE_DEFAULT = 0,
  1222. D3D10_SB_SAMPLER_MODE_COMPARISON = 1,
  1223. D3D10_SB_SAMPLER_MODE_MONO = 2,
  1224. } D3D10_SB_SAMPLER_MODE;
  1225. #define D3D10_SB_SAMPLER_MODE_MASK 0x00007800
  1226. #define D3D10_SB_SAMPLER_MODE_SHIFT 11
  1227. // DECODER MACRO: Find out if a Constant Buffer is going to be indexed or not
  1228. #define DECODE_D3D10_SB_SAMPLER_MODE(OpcodeToken0) ((D3D10_SB_SAMPLER_MODE)(((OpcodeToken0)&D3D10_SB_SAMPLER_MODE_MASK)>>D3D10_SB_SAMPLER_MODE_SHIFT))
  1229. // ENCODER MACRO: Generate a resource return type for a component
  1230. #define ENCODE_D3D10_SB_SAMPLER_MODE(SamplerMode) (((SamplerMode)<<D3D10_SB_SAMPLER_MODE_SHIFT)&D3D10_SB_SAMPLER_MODE_MASK)
  1231. // ----------------------------------------------------------------------------
  1232. // Input Register Declaration (see separate declarations for Pixel Shaders)
  1233. //
  1234. // OpcodeToken0:
  1235. //
  1236. // [10:00] D3D10_SB_OPCODE_DCL_INPUT
  1237. // [23:11] Ignored, 0
  1238. // [30:24] Instruction length in DWORDs including the opcode token.
  1239. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD
  1240. // contains extended operand description. This dcl is currently not
  1241. // extended.
  1242. //
  1243. // OpcodeToken0 is followed by 1 operand:
  1244. // (1) Operand, starting with OperandToken0, defining which input
  1245. // v# register (D3D10_SB_OPERAND_TYPE_INPUT) is being declared,
  1246. // including writemask.
  1247. //
  1248. // ----------------------------------------------------------------------------
  1249. // ----------------------------------------------------------------------------
  1250. // Input Register Declaration w/System Interpreted Value
  1251. // (see separate declarations for Pixel Shaders)
  1252. //
  1253. // OpcodeToken0:
  1254. //
  1255. // [10:00] D3D10_SB_OPCODE_DCL_INPUT_SIV
  1256. // [23:11] Ignored, 0
  1257. // [30:24] Instruction length in DWORDs including the opcode token.
  1258. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD
  1259. // contains extended operand description. This dcl is currently not
  1260. // extended.
  1261. //
  1262. // OpcodeToken0 is followed by 2 operands:
  1263. // (1) Operand, starting with OperandToken0, defining which input
  1264. // v# register (D3D10_SB_OPERAND_TYPE_INPUT) is being declared,
  1265. // including writemask. For Geometry Shaders, the input is
  1266. // v[vertex][attribute], and this declaration is only for which register
  1267. // on the attribute axis is being declared. The vertex axis value must
  1268. // be equal to the # of vertices in the current input primitive for the GS
  1269. // (i.e. 6 for triangle + adjacency).
  1270. // (2) a System Interpreted Value Name (NameToken)
  1271. //
  1272. // ----------------------------------------------------------------------------
  1273. // ----------------------------------------------------------------------------
  1274. // Input Register Declaration w/System Generated Value
  1275. // (available for all shaders incl. Pixel Shader, no interpolation mode needed)
  1276. //
  1277. // OpcodeToken0:
  1278. //
  1279. // [10:00] D3D10_SB_OPCODE_DCL_INPUT_SGV
  1280. // [23:11] Ignored, 0
  1281. // [30:24] Instruction length in DWORDs including the opcode token.
  1282. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD
  1283. // contains extended operand description. This dcl is currently not
  1284. // extended.
  1285. //
  1286. // OpcodeToken0 is followed by 2 operands:
  1287. // (1) Operand, starting with OperandToken0, defining which input
  1288. // v# register (D3D10_SB_OPERAND_TYPE_INPUT) is being declared,
  1289. // including writemask.
  1290. // (2) a System Generated Value Name (NameToken)
  1291. //
  1292. // ----------------------------------------------------------------------------
  1293. // ----------------------------------------------------------------------------
  1294. // Pixel Shader Input Register Declaration
  1295. //
  1296. // OpcodeToken0:
  1297. //
  1298. // [10:00] D3D10_SB_OPCODE_DCL_INPUT_PS
  1299. // [14:11] D3D10_SB_INTERPOLATION_MODE
  1300. // [23:15] Ignored, 0
  1301. // [30:24] Instruction length in DWORDs including the opcode token.
  1302. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD
  1303. // contains extended operand description. This dcl is currently not
  1304. // extended.
  1305. //
  1306. // OpcodeToken0 is followed by 1 operand:
  1307. // (1) Operand, starting with OperandToken0, defining which input
  1308. // v# register (D3D10_SB_OPERAND_TYPE_INPUT) is being declared,
  1309. // including writemask.
  1310. //
  1311. // ----------------------------------------------------------------------------
  1312. #define D3D10_SB_INPUT_INTERPOLATION_MODE_MASK 0x00007800
  1313. #define D3D10_SB_INPUT_INTERPOLATION_MODE_SHIFT 11
  1314. // DECODER MACRO: Find out interpolation mode for the input register
  1315. #define DECODE_D3D10_SB_INPUT_INTERPOLATION_MODE(OpcodeToken0) ((D3D10_SB_INTERPOLATION_MODE)(((OpcodeToken0)&D3D10_SB_INPUT_INTERPOLATION_MODE_MASK)>>D3D10_SB_INPUT_INTERPOLATION_MODE_SHIFT))
  1316. // ENCODER MACRO: Encode interpolation mode for a register.
  1317. #define ENCODE_D3D10_SB_INPUT_INTERPOLATION_MODE(InterpolationMode) (((InterpolationMode)<<D3D10_SB_INPUT_INTERPOLATION_MODE_SHIFT)&D3D10_SB_INPUT_INTERPOLATION_MODE_MASK)
  1318. // ----------------------------------------------------------------------------
  1319. // Pixel Shader Input Register Declaration w/System Interpreted Value
  1320. //
  1321. // OpcodeToken0:
  1322. //
  1323. // [10:00] D3D10_SB_OPCODE_DCL_INPUT_PS_SIV
  1324. // [14:11] D3D10_SB_INTERPOLATION_MODE
  1325. // [23:15] Ignored, 0
  1326. // [30:24] Instruction length in DWORDs including the opcode token.
  1327. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD
  1328. // contains extended operand description. This dcl is currently not
  1329. // extended.
  1330. //
  1331. // OpcodeToken0 is followed by 2 operands:
  1332. // (1) Operand, starting with OperandToken0, defining which input
  1333. // v# register (D3D10_SB_OPERAND_TYPE_INPUT) is being declared.
  1334. // (2) a System Interpreted Value Name (NameToken)
  1335. //
  1336. // ----------------------------------------------------------------------------
  1337. // ----------------------------------------------------------------------------
  1338. // Pixel Shader Input Register Declaration w/System Generated Value
  1339. //
  1340. // OpcodeToken0:
  1341. //
  1342. // [10:00] D3D10_SB_OPCODE_DCL_INPUT_PS_SGV
  1343. // [23:11] Ignored, 0
  1344. // [30:24] Instruction length in DWORDs including the opcode token.
  1345. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD
  1346. // contains extended operand description. This dcl is currently not
  1347. // extended.
  1348. //
  1349. // OpcodeToken0 is followed by 2 operands:
  1350. // (1) Operand, starting with OperandToken0, defining which input
  1351. // v# register (D3D10_SB_OPERAND_TYPE_INPUT) is being declared.
  1352. // (2) a System Generated Value Name (NameToken)
  1353. //
  1354. // ----------------------------------------------------------------------------
  1355. // ----------------------------------------------------------------------------
  1356. // Output Register Declaration
  1357. //
  1358. // OpcodeToken0:
  1359. //
  1360. // [10:00] D3D10_SB_OPCODE_DCL_OUTPUT
  1361. // [23:11] Ignored, 0
  1362. // [30:24] Instruction length in DWORDs including the opcode token.
  1363. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD
  1364. // contains extended operand description. This dcl is currently not
  1365. // extended.
  1366. //
  1367. // OpcodeToken0 is followed by 1 operand:
  1368. // (1) Operand, starting with OperandToken0, defining which
  1369. // o# register (D3D10_SB_OPERAND_TYPE_OUTPUT) is being declared,
  1370. // including writemask.
  1371. // (in Pixel Shader, output can also be one of
  1372. // D3D10_SB_OPERAND_TYPE_OUTPUT_DEPTH,
  1373. // D3D11_SB_OPERAND_TYPE_OUTPUT_DEPTH_GREATER_EQUAL, or
  1374. // D3D11_SB_OPERAND_TYPE_OUTPUT_DEPTH_LESS_EQUAL )
  1375. //
  1376. // ----------------------------------------------------------------------------
  1377. // ----------------------------------------------------------------------------
  1378. // Output Register Declaration w/System Interpreted Value
  1379. //
  1380. // OpcodeToken0:
  1381. //
  1382. // [10:00] D3D10_SB_OPCODE_DCL_OUTPUT_SIV
  1383. // [23:11] Ignored, 0
  1384. // [30:24] Instruction length in DWORDs including the opcode token.
  1385. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD
  1386. // contains extended operand description. This dcl is currently not
  1387. // extended.
  1388. //
  1389. // OpcodeToken0 is followed by 2 operands:
  1390. // (1) an operand, starting with OperandToken0, defining which
  1391. // o# register (D3D10_SB_OPERAND_TYPE_OUTPUT) is being declared,
  1392. // including writemask.
  1393. // (2) a System Interpreted Name token (NameToken)
  1394. //
  1395. // ----------------------------------------------------------------------------
  1396. // ----------------------------------------------------------------------------
  1397. // Output Register Declaration w/System Generated Value
  1398. //
  1399. // OpcodeToken0:
  1400. //
  1401. // [10:00] D3D10_SB_OPCODE_DCL_OUTPUT_SGV
  1402. // [23:11] Ignored, 0
  1403. // [30:24] Instruction length in DWORDs including the opcode token.
  1404. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD
  1405. // contains extended operand description. This dcl is currently not
  1406. // extended.
  1407. //
  1408. // OpcodeToken0 is followed by 2 operands:
  1409. // (1) an operand, starting with OperandToken0, defining which
  1410. // o# register (D3D10_SB_OPERAND_TYPE_OUTPUT) is being declared,
  1411. // including writemask.
  1412. // (2) a System Generated Name token (NameToken)
  1413. //
  1414. // ----------------------------------------------------------------------------
  1415. // ----------------------------------------------------------------------------
  1416. // Input or Output Register Indexing Range Declaration
  1417. //
  1418. // OpcodeToken0:
  1419. //
  1420. // [10:00] D3D10_SB_OPCODE_DCL_INDEX_RANGE
  1421. // [23:11] Ignored, 0
  1422. // [30:24] Instruction length in DWORDs including the opcode token.
  1423. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD
  1424. // contains extended operand description. This dcl is currently not
  1425. // extended.
  1426. //
  1427. // OpcodeToken0 is followed by 2 operands:
  1428. // (1) an operand, starting with OperandToken0, defining which
  1429. // input (v#) or output (o#) register is having its array indexing range
  1430. // declared, including writemask. For Geometry Shader inputs,
  1431. // it is assumed that the vertex axis is always fully indexable,
  1432. // and 0 must be specified as the vertex# in this declaration, so that
  1433. // only the a range of attributes are having their index range defined.
  1434. //
  1435. // (2) a DWORD representing the count of registers starting from the one
  1436. // indicated in (1).
  1437. //
  1438. // ----------------------------------------------------------------------------
  1439. // ----------------------------------------------------------------------------
  1440. // Temp Register Declaration r0...r(n-1)
  1441. //
  1442. // OpcodeToken0:
  1443. //
  1444. // [10:00] D3D10_SB_OPCODE_DCL_TEMPS
  1445. // [23:11] Ignored, 0
  1446. // [30:24] Instruction length in DWORDs including the opcode token.
  1447. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD
  1448. // contains extended operand description. This dcl is currently not
  1449. // extended.
  1450. //
  1451. // OpcodeToken0 is followed by 1 operand:
  1452. // (1) DWORD (unsigned int) indicating how many temps are being declared.
  1453. // i.e. 5 means r0...r4 are declared.
  1454. //
  1455. // ----------------------------------------------------------------------------
  1456. // ----------------------------------------------------------------------------
  1457. // Indexable Temp Register (x#[size]) Declaration
  1458. //
  1459. // OpcodeToken0:
  1460. //
  1461. // [10:00] D3D10_SB_OPCODE_DCL_INDEXABLE_TEMP
  1462. // [23:11] Ignored, 0
  1463. // [30:24] Instruction length in DWORDs including the opcode token.
  1464. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD
  1465. // contains extended operand description. This dcl is currently not
  1466. // extended.
  1467. //
  1468. // OpcodeToken0 is followed by 3 DWORDs:
  1469. // (1) Register index (defines which x# register is declared)
  1470. // (2) Number of registers in this register bank
  1471. // (3) Number of components in the array (1-4). 1 means .x, 2 means .xy etc.
  1472. //
  1473. // ----------------------------------------------------------------------------
  1474. // ----------------------------------------------------------------------------
  1475. // Constant Buffer Declaration
  1476. //
  1477. // OpcodeToken0:
  1478. //
  1479. // [10:00] D3D10_SB_OPCODE_DCL_CONSTANT_BUFFER
  1480. // [11] D3D10_SB_CONSTANT_BUFFER_ACCESS_PATTERN
  1481. // [23:12] Ignored, 0
  1482. // [30:24] Instruction length in DWORDs including the opcode token.
  1483. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD
  1484. // contains extended operand description. This dcl is currently not
  1485. // extended.
  1486. //
  1487. // OpcodeToken0 is followed by 1 operand on Shader Model 4.0 through 5.0:
  1488. // (1) Operand, starting with OperandToken0, defining which CB slot (cb#[size])
  1489. // is being declared. (operand type: D3D10_SB_OPERAND_TYPE_CONSTANT_BUFFER)
  1490. // The indexing dimension for the register must be
  1491. // D3D10_SB_OPERAND_INDEX_DIMENSION_2D, where the first index specifies
  1492. // which cb#[] is being declared, and the second (array) index specifies the size
  1493. // of the buffer, as a count of 32-bit*4 elements. (As opposed to when the
  1494. // cb#[] is used in shader instructions, and the array index represents which
  1495. // location in the constant buffer is being referenced.)
  1496. // If the size is specified as 0, the CB size is not known (any size CB
  1497. // can be bound to the slot).
  1498. //
  1499. // The order of constant buffer declarations in a shader indicates their
  1500. // relative priority from highest to lowest (hint to driver).
  1501. //
  1502. // OpcodeToken0 is followed by 3 operands on Shader Model 5.1 and later:
  1503. // (1) Operand, starting with OperandToken0, defining which CB range (ID and bounds)
  1504. // is being declared. (operand type: D3D10_SB_OPERAND_TYPE_CONSTANT_BUFFER)
  1505. // The indexing dimension for the register must be D3D10_SB_OPERAND_INDEX_DIMENSION_3D,
  1506. // and the meaning of the index dimensions are as follows: (cb<id>[<lbound>:<ubound>])
  1507. // 1 <id>: variable ID being declared
  1508. // 2 <lbound>: the lower bound of the range of constant buffers in the space
  1509. // 3 <ubound>: the upper bound (inclusive) of this range
  1510. // As opposed to when the cb#[] is used in shader instructions: (cb<id>[<idx>][<loc>])
  1511. // 1 <id>: variable ID being used (matches dcl)
  1512. // 2 <idx>: absolute index of constant buffer within space (may be dynamically indexed)
  1513. // 3 <loc>: location of vector within constant buffer being referenced,
  1514. // which may also be dynamically indexed, with no access pattern flag required.
  1515. // (2) a DWORD indicating the size of the constant buffer as a count of 16-byte vectors.
  1516. // Each vector is 32-bit*4 elements == 128-bits == 16 bytes.
  1517. // If the size is specified as 0, the CB size is not known (any size CB
  1518. // can be bound to the slot).
  1519. // (3) a DWORD indicating the space index.
  1520. //
  1521. // ----------------------------------------------------------------------------
  1522. typedef enum D3D10_SB_CONSTANT_BUFFER_ACCESS_PATTERN
  1523. {
  1524. D3D10_SB_CONSTANT_BUFFER_IMMEDIATE_INDEXED = 0,
  1525. D3D10_SB_CONSTANT_BUFFER_DYNAMIC_INDEXED = 1
  1526. } D3D10_SB_CONSTANT_BUFFER_ACCESS_PATTERN;
  1527. #define D3D10_SB_CONSTANT_BUFFER_ACCESS_PATTERN_MASK 0x00000800
  1528. #define D3D10_SB_CONSTANT_BUFFER_ACCESS_PATTERN_SHIFT 11
  1529. // DECODER MACRO: Find out if a Constant Buffer is going to be indexed or not
  1530. #define DECODE_D3D10_SB_CONSTANT_BUFFER_ACCESS_PATTERN(OpcodeToken0) ((D3D10_SB_CONSTANT_BUFFER_ACCESS_PATTERN)(((OpcodeToken0)&D3D10_SB_CONSTANT_BUFFER_ACCESS_PATTERN_MASK)>>D3D10_SB_CONSTANT_BUFFER_ACCESS_PATTERN_SHIFT))
  1531. // ENCODER MACRO: Encode the access pattern for the Constant Buffer
  1532. #define ENCODE_D3D10_SB_D3D10_SB_CONSTANT_BUFFER_ACCESS_PATTERN(AccessPattern) (((AccessPattern)<<D3D10_SB_CONSTANT_BUFFER_ACCESS_PATTERN_SHIFT)&D3D10_SB_CONSTANT_BUFFER_ACCESS_PATTERN_MASK)
  1533. // ----------------------------------------------------------------------------
  1534. // Immediate Constant Buffer Declaration
  1535. //
  1536. // OpcodeToken0:
  1537. //
  1538. // [10:00] D3D10_SB_OPCODE_CUSTOMDATA
  1539. // [31:11] == D3D10_SB_CUSTOMDATA_DCL_IMMEDIATE_CONSTANT_BUFFER
  1540. //
  1541. // OpcodeToken0 is followed by:
  1542. // (1) DWORD indicating length of declaration, including OpcodeToken0.
  1543. // This length must = 2(for OpcodeToken0 and 1) + a multiple of 4
  1544. // (# of immediate constants)
  1545. // (2) Sequence of 4-tuples of DWORDs defining the Immediate Constant Buffer.
  1546. // The number of 4-tuples is (length above - 1) / 4
  1547. // ----------------------------------------------------------------------------
  1548. // ----------------------------------------------------------------------------
  1549. // Shader Message Declaration
  1550. //
  1551. // OpcodeToken0:
  1552. //
  1553. // [10:00] D3D10_SB_OPCODE_CUSTOMDATA
  1554. // [31:11] == D3D11_SB_CUSTOMDATA_SHADER_MESSAGE
  1555. //
  1556. // OpcodeToken0 is followed by:
  1557. // (1) DWORD indicating length of declaration, including OpcodeToken0.
  1558. // (2) DWORD (D3D11_SB_SHADER_MESSAGE_ID) indicating shader message or error.
  1559. // (3) D3D11_SB_SHADER_MESSAGE_FORMAT indicating the convention for formatting the message.
  1560. // (4) DWORD indicating the number of characters in the string without the terminator.
  1561. // (5) DWORD indicating the number of operands.
  1562. // (6) DWORD indicating length of operands.
  1563. // (7) Encoded operands.
  1564. // (8) String with trailing zero, padded to a multiple of DWORDs.
  1565. // The string is in the given format and the operands given should
  1566. // be used for argument substitutions when formatting.
  1567. // ----------------------------------------------------------------------------
  1568. typedef enum D3D11_SB_SHADER_MESSAGE_ID
  1569. {
  1570. D3D11_SB_SHADER_MESSAGE_ID_MESSAGE = 0x00200102,
  1571. D3D11_SB_SHADER_MESSAGE_ID_ERROR = 0x00200103
  1572. } D3D11_SB_SHADER_MESSAGE_ID;
  1573. typedef enum D3D11_SB_SHADER_MESSAGE_FORMAT
  1574. {
  1575. // No formatting, just a text string. Operands are ignored.
  1576. D3D11_SB_SHADER_MESSAGE_FORMAT_ANSI_TEXT,
  1577. // Format string follows C/C++ printf conventions.
  1578. D3D11_SB_SHADER_MESSAGE_FORMAT_ANSI_PRINTF,
  1579. } D3D11_SB_SHADER_MESSAGE_FORMAT;
  1580. // ----------------------------------------------------------------------------
  1581. // Shader Clip Plane Constant Mappings for DX9 hardware
  1582. //
  1583. // OpcodeToken0:
  1584. //
  1585. // [10:00] D3D10_SB_OPCODE_CUSTOMDATA
  1586. // [31:11] == D3D11_SB_CUSTOMDATA_SHADER_CLIP_PLANE_CONSTANT_MAPPINGS_FOR_DX9
  1587. //
  1588. // OpcodeToken0 is followed by:
  1589. // (1) DWORD indicating length of declaration, including OpcodeToken0.
  1590. // (2) DWORD indicating number of constant mappings (up to 6 mappings).
  1591. // (3+) Constant mapping tables in following format.
  1592. //
  1593. // struct _Clip_Plane_Constant_Mapping
  1594. // {
  1595. // WORD ConstantBufferIndex; // cb[n]
  1596. // WORD StartConstantElement; // starting index of cb[n][m]
  1597. // WORD ConstantElemntCount; // number of elements cb[n][m] ~ cb[n][m+l]
  1598. // WORD Reserved; //
  1599. // };
  1600. // ----------------------------------------------------------------------------
  1601. // ----------------------------------------------------------------------------
  1602. // Geometry Shader Input Primitive Declaration
  1603. //
  1604. // OpcodeToken0:
  1605. //
  1606. // [10:00] D3D10_SB_OPCODE_DCL_GS_INPUT_PRIMITIVE
  1607. // [16:11] D3D10_SB_PRIMITIVE [not D3D10_SB_PRIMITIVE_TOPOLOGY]
  1608. // [23:17] Ignored, 0
  1609. // [30:24] Instruction length in DWORDs including the opcode token. == 1
  1610. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD
  1611. // contains extended operand description. This dcl is currently not
  1612. // extended.
  1613. //
  1614. // ----------------------------------------------------------------------------
  1615. #define D3D10_SB_GS_INPUT_PRIMITIVE_MASK 0x0001f800
  1616. #define D3D10_SB_GS_INPUT_PRIMITIVE_SHIFT 11
  1617. // DECODER MACRO: Given a primitive topology declaration,
  1618. // (OpcodeToken0), determine the primitive topology
  1619. // (D3D10_SB_PRIMITIVE enum)
  1620. #define DECODE_D3D10_SB_GS_INPUT_PRIMITIVE(OpcodeToken0) ((D3D10_SB_PRIMITIVE)(((OpcodeToken0)&D3D10_SB_GS_INPUT_PRIMITIVE_MASK)>>D3D10_SB_GS_INPUT_PRIMITIVE_SHIFT))
  1621. // ENCODER MACRO: Store primitive topology
  1622. // (D3D10_SB_PRIMITIVE enum) into a
  1623. // a primitive topology declaration token (OpcodeToken0)
  1624. #define ENCODE_D3D10_SB_GS_INPUT_PRIMITIVE(Prim) (((Prim)<<D3D10_SB_GS_INPUT_PRIMITIVE_SHIFT)&D3D10_SB_GS_INPUT_PRIMITIVE_MASK)
  1625. // ----------------------------------------------------------------------------
  1626. // Geometry Shader Output Topology Declaration
  1627. //
  1628. // OpcodeToken0:
  1629. //
  1630. // [10:00] D3D10_SB_OPCODE_DCL_GS_OUTPUT_PRIMITIVE_TOPOLOGY
  1631. // [17:11] D3D10_SB_PRIMITIVE_TOPOLOGY
  1632. // [23:18] Ignored, 0
  1633. // [30:24] Instruction length in DWORDs including the opcode token. == 1
  1634. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD
  1635. // contains extended operand description. This dcl is currently not
  1636. // extended.
  1637. //
  1638. // ----------------------------------------------------------------------------
  1639. #define D3D10_SB_GS_OUTPUT_PRIMITIVE_TOPOLOGY_MASK 0x0001f800
  1640. #define D3D10_SB_GS_OUTPUT_PRIMITIVE_TOPOLOGY_SHIFT 11
  1641. // DECODER MACRO: Given a primitive topology declaration,
  1642. // (OpcodeToken0), determine the primitive topology
  1643. // (D3D10_SB_PRIMITIVE_TOPOLOGY enum)
  1644. #define DECODE_D3D10_SB_GS_OUTPUT_PRIMITIVE_TOPOLOGY(OpcodeToken0) ((D3D10_SB_PRIMITIVE_TOPOLOGY)(((OpcodeToken0)&D3D10_SB_GS_OUTPUT_PRIMITIVE_TOPOLOGY_MASK)>>D3D10_SB_GS_OUTPUT_PRIMITIVE_TOPOLOGY_SHIFT))
  1645. // ENCODER MACRO: Store primitive topology
  1646. // (D3D10_SB_PRIMITIVE_TOPOLOGY enum) into a
  1647. // a primitive topology declaration token (OpcodeToken0)
  1648. #define ENCODE_D3D10_SB_GS_OUTPUT_PRIMITIVE_TOPOLOGY(PrimTopology) (((PrimTopology)<<D3D10_SB_GS_OUTPUT_PRIMITIVE_TOPOLOGY_SHIFT)&D3D10_SB_GS_OUTPUT_PRIMITIVE_TOPOLOGY_MASK)
  1649. // ----------------------------------------------------------------------------
  1650. // Geometry Shader Maximum Output Vertex Count Declaration
  1651. //
  1652. // OpcodeToken0:
  1653. //
  1654. // [10:00] D3D10_SB_OPCODE_DCL_MAX_OUTPUT_VERTEX_COUNT
  1655. // [23:11] Ignored, 0
  1656. // [30:24] Instruction length in DWORDs including the opcode token.
  1657. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD
  1658. // contains extended operand description. This dcl is currently not
  1659. // extended.
  1660. //
  1661. // OpcodeToken0 is followed by a DWORD representing the
  1662. // maximum number of primitives that could be output
  1663. // by the Geometry Shader.
  1664. //
  1665. // ----------------------------------------------------------------------------
  1666. // ----------------------------------------------------------------------------
  1667. // Geometry Shader Instance Count Declaration
  1668. //
  1669. // OpcodeToken0:
  1670. //
  1671. // [10:00] D3D11_SB_OPCODE_DCL_GS_INSTANCE_COUNT
  1672. // [23:11] Ignored, 0
  1673. // [30:24] Instruction length in DWORDs including the opcode token.
  1674. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD
  1675. // contains extended operand description. This dcl is currently not
  1676. // extended.
  1677. //
  1678. // OpcodeToken0 is followed by a UINT32 representing the
  1679. // number of instances of the geometry shader program to execute.
  1680. //
  1681. // ----------------------------------------------------------------------------
  1682. // ----------------------------------------------------------------------------
  1683. // Hull Shader Declaration Phase: HS/DS Input Control Point Count
  1684. //
  1685. // OpcodeToken0:
  1686. //
  1687. // [10:00] D3D11_SB_OPCODE_DCL_INPUT_CONTROL_POINT_COUNT
  1688. // [16:11] Control point count
  1689. // [23:17] Ignored, 0
  1690. // [30:24] Instruction length in DWORDs including the opcode token. == 1
  1691. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD
  1692. // contains extended operand description. This dcl is currently not
  1693. // extended.
  1694. //
  1695. // ----------------------------------------------------------------------------
  1696. #define D3D11_SB_INPUT_CONTROL_POINT_COUNT_MASK 0x0001f800
  1697. #define D3D11_SB_INPUT_CONTROL_POINT_COUNT_SHIFT 11
  1698. // DECODER MACRO: Given an input control point count declaration token,
  1699. // (OpcodeToken0), determine the control point count
  1700. #define DECODE_D3D11_SB_INPUT_CONTROL_POINT_COUNT(OpcodeToken0) ((UINT)(((OpcodeToken0)&D3D11_SB_INPUT_CONTROL_POINT_COUNT_MASK)>>D3D11_SB_INPUT_CONTROL_POINT_COUNT_SHIFT))
  1701. // ENCODER MACRO: Store input control point count into a declaration token
  1702. #define ENCODE_D3D11_SB_INPUT_CONTROL_POINT_COUNT(Count) (((Count)<<D3D11_SB_INPUT_CONTROL_POINT_COUNT_SHIFT)&D3D11_SB_INPUT_CONTROL_POINT_COUNT_MASK)
  1703. // ----------------------------------------------------------------------------
  1704. // Hull Shader Declaration Phase: HS Output Control Point Count
  1705. //
  1706. // OpcodeToken0:
  1707. //
  1708. // [10:00] D3D11_SB_OPCODE_DCL_OUTPUT_CONTROL_POINT_COUNT
  1709. // [16:11] Control point count
  1710. // [23:17] Ignored, 0
  1711. // [30:24] Instruction length in DWORDs including the opcode token. == 1
  1712. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD
  1713. // contains extended operand description. This dcl is currently not
  1714. // extended.
  1715. //
  1716. // ----------------------------------------------------------------------------
  1717. #define D3D11_SB_OUTPUT_CONTROL_POINT_COUNT_MASK 0x0001f800
  1718. #define D3D11_SB_OUTPUT_CONTROL_POINT_COUNT_SHIFT 11
  1719. // DECODER MACRO: Given an output control point count declaration token,
  1720. // (OpcodeToken0), determine the control point count
  1721. #define DECODE_D3D11_SB_OUTPUT_CONTROL_POINT_COUNT(OpcodeToken0) ((UINT)(((OpcodeToken0)&D3D11_SB_OUTPUT_CONTROL_POINT_COUNT_MASK)>>D3D11_SB_OUTPUT_CONTROL_POINT_COUNT_SHIFT))
  1722. // ENCODER MACRO: Store output control point count into a declaration token
  1723. #define ENCODE_D3D11_SB_OUTPUT_CONTROL_POINT_COUNT(Count) (((Count)<<D3D11_SB_OUTPUT_CONTROL_POINT_COUNT_SHIFT)&D3D11_SB_OUTPUT_CONTROL_POINT_COUNT_MASK)
  1724. // ----------------------------------------------------------------------------
  1725. // Hull Shader Declaration Phase: Tessellator Domain
  1726. //
  1727. // OpcodeToken0:
  1728. //
  1729. // [10:00] D3D11_SB_OPCODE_DCL_TESS_DOMAIN
  1730. // [12:11] Domain
  1731. // [23:13] Ignored, 0
  1732. // [30:24] Instruction length in DWORDs including the opcode token. == 1
  1733. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD
  1734. // contains extended operand description. This dcl is currently not
  1735. // extended.
  1736. //
  1737. // ----------------------------------------------------------------------------
  1738. typedef enum D3D11_SB_TESSELLATOR_DOMAIN
  1739. {
  1740. D3D11_SB_TESSELLATOR_DOMAIN_UNDEFINED = 0,
  1741. D3D11_SB_TESSELLATOR_DOMAIN_ISOLINE = 1,
  1742. D3D11_SB_TESSELLATOR_DOMAIN_TRI = 2,
  1743. D3D11_SB_TESSELLATOR_DOMAIN_QUAD = 3
  1744. } D3D11_SB_TESSELLATOR_DOMAIN;
  1745. #define D3D11_SB_TESS_DOMAIN_MASK 0x00001800
  1746. #define D3D11_SB_TESS_DOMAIN_SHIFT 11
  1747. // DECODER MACRO: Given a tessellator domain declaration,
  1748. // (OpcodeToken0), determine the domain
  1749. // (D3D11_SB_TESSELLATOR_DOMAIN enum)
  1750. #define DECODE_D3D11_SB_TESS_DOMAIN(OpcodeToken0) ((D3D11_SB_TESSELLATOR_DOMAIN)(((OpcodeToken0)&D3D11_SB_TESS_DOMAIN_MASK)>>D3D11_SB_TESS_DOMAIN_SHIFT))
  1751. // ENCODER MACRO: Store tessellator domain
  1752. // (D3D11_SB_TESSELLATOR_DOMAIN enum) into a
  1753. // a tessellator domain declaration token (OpcodeToken0)
  1754. #define ENCODE_D3D11_SB_TESS_DOMAIN(Domain) (((Domain)<<D3D11_SB_TESS_DOMAIN_SHIFT)&D3D11_SB_TESS_DOMAIN_MASK)
  1755. // ----------------------------------------------------------------------------
  1756. // Hull Shader Declaration Phase: Tessellator Partitioning
  1757. //
  1758. // OpcodeToken0:
  1759. //
  1760. // [10:00] D3D11_SB_OPCODE_DCL_TESS_PARTITIONING
  1761. // [13:11] Partitioning
  1762. // [23:14] Ignored, 0
  1763. // [30:24] Instruction length in DWORDs including the opcode token. == 1
  1764. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD
  1765. // contains extended operand description. This dcl is currently not
  1766. // extended.
  1767. //
  1768. // ----------------------------------------------------------------------------
  1769. typedef enum D3D11_SB_TESSELLATOR_PARTITIONING
  1770. {
  1771. D3D11_SB_TESSELLATOR_PARTITIONING_UNDEFINED = 0,
  1772. D3D11_SB_TESSELLATOR_PARTITIONING_INTEGER = 1,
  1773. D3D11_SB_TESSELLATOR_PARTITIONING_POW2 = 2,
  1774. D3D11_SB_TESSELLATOR_PARTITIONING_FRACTIONAL_ODD = 3,
  1775. D3D11_SB_TESSELLATOR_PARTITIONING_FRACTIONAL_EVEN = 4
  1776. } D3D11_SB_TESSELLATOR_PARTITIONING;
  1777. #define D3D11_SB_TESS_PARTITIONING_MASK 0x00003800
  1778. #define D3D11_SB_TESS_PARTITIONING_SHIFT 11
  1779. // DECODER MACRO: Given a tessellator partitioning declaration,
  1780. // (OpcodeToken0), determine the domain
  1781. // (D3D11_SB_TESSELLATOR_PARTITIONING enum)
  1782. #define DECODE_D3D11_SB_TESS_PARTITIONING(OpcodeToken0) ((D3D11_SB_TESSELLATOR_PARTITIONING)(((OpcodeToken0)&D3D11_SB_TESS_PARTITIONING_MASK)>>D3D11_SB_TESS_PARTITIONING_SHIFT))
  1783. // ENCODER MACRO: Store tessellator partitioning
  1784. // (D3D11_SB_TESSELLATOR_PARTITIONING enum) into a
  1785. // a tessellator partitioning declaration token (OpcodeToken0)
  1786. #define ENCODE_D3D11_SB_TESS_PARTITIONING(Partitioning) (((Partitioning)<<D3D11_SB_TESS_PARTITIONING_SHIFT)&D3D11_SB_TESS_PARTITIONING_MASK)
  1787. // ----------------------------------------------------------------------------
  1788. // Hull Shader Declaration Phase: Tessellator Output Primitive
  1789. //
  1790. // OpcodeToken0:
  1791. //
  1792. // [10:00] D3D11_SB_OPCODE_DCL_TESS_OUTPUT_PRIMITIVE
  1793. // [13:11] Output Primitive
  1794. // [23:14] Ignored, 0
  1795. // [30:24] Instruction length in DWORDs including the opcode token. == 1
  1796. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD
  1797. // contains extended operand description. This dcl is currently not
  1798. // extended.
  1799. //
  1800. // ----------------------------------------------------------------------------
  1801. typedef enum D3D11_SB_TESSELLATOR_OUTPUT_PRIMITIVE
  1802. {
  1803. D3D11_SB_TESSELLATOR_OUTPUT_UNDEFINED = 0,
  1804. D3D11_SB_TESSELLATOR_OUTPUT_POINT = 1,
  1805. D3D11_SB_TESSELLATOR_OUTPUT_LINE = 2,
  1806. D3D11_SB_TESSELLATOR_OUTPUT_TRIANGLE_CW = 3,
  1807. D3D11_SB_TESSELLATOR_OUTPUT_TRIANGLE_CCW = 4
  1808. } D3D11_SB_TESSELLATOR_OUTPUT_PRIMITIVE;
  1809. #define D3D11_SB_TESS_OUTPUT_PRIMITIVE_MASK 0x00003800
  1810. #define D3D11_SB_TESS_OUTPUT_PRIMITIVE_SHIFT 11
  1811. // DECODER MACRO: Given a tessellator output primitive declaration,
  1812. // (OpcodeToken0), determine the domain
  1813. // (D3D11_SB_TESSELLATOR_OUTPUT_PRIMITIVE enum)
  1814. #define DECODE_D3D11_SB_TESS_OUTPUT_PRIMITIVE(OpcodeToken0) ((D3D11_SB_TESSELLATOR_OUTPUT_PRIMITIVE)(((OpcodeToken0)&D3D11_SB_TESS_OUTPUT_PRIMITIVE_MASK)>>D3D11_SB_TESS_OUTPUT_PRIMITIVE_SHIFT))
  1815. // ENCODER MACRO: Store tessellator output primitive
  1816. // (D3D11_SB_TESSELLATOR_OUTPUT_PRIMITIVE enum) into a
  1817. // a tessellator output primitive declaration token (OpcodeToken0)
  1818. #define ENCODE_D3D11_SB_TESS_OUTPUT_PRIMITIVE(OutputPrimitive) (((OutputPrimitive)<<D3D11_SB_TESS_OUTPUT_PRIMITIVE_SHIFT)&D3D11_SB_TESS_OUTPUT_PRIMITIVE_MASK)
  1819. // ----------------------------------------------------------------------------
  1820. // Hull Shader Declaration Phase: Hull Shader Max Tessfactor
  1821. //
  1822. // OpcodeToken0:
  1823. //
  1824. // [10:00] D3D11_SB_OPCODE_DCL_HS_MAX_TESSFACTOR
  1825. // [23:11] Ignored, 0
  1826. // [30:24] Instruction length in DWORDs including the opcode token.
  1827. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD
  1828. // contains extended operand description. This dcl is currently not
  1829. // extended.
  1830. //
  1831. // OpcodeToken0 is followed by a float32 representing the
  1832. // maximum TessFactor.
  1833. //
  1834. // ----------------------------------------------------------------------------
  1835. // ----------------------------------------------------------------------------
  1836. // Hull Shader Declaration Phase: Hull Shader Fork Phase Instance Count
  1837. //
  1838. // OpcodeToken0:
  1839. //
  1840. // [10:00] D3D11_SB_OPCODE_DCL_HS_FORK_PHASE_INSTANCE_COUNT
  1841. // [23:11] Ignored, 0
  1842. // [30:24] Instruction length in DWORDs including the opcode token.
  1843. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD
  1844. // contains extended operand description. This dcl is currently not
  1845. // extended.
  1846. //
  1847. // OpcodeToken0 is followed by a UINT32 representing the
  1848. // number of instances of the current fork phase program to execute.
  1849. //
  1850. // ----------------------------------------------------------------------------
  1851. typedef enum D3D10_SB_INTERPOLATION_MODE
  1852. {
  1853. D3D10_SB_INTERPOLATION_UNDEFINED = 0,
  1854. D3D10_SB_INTERPOLATION_CONSTANT = 1,
  1855. D3D10_SB_INTERPOLATION_LINEAR = 2,
  1856. D3D10_SB_INTERPOLATION_LINEAR_CENTROID = 3,
  1857. D3D10_SB_INTERPOLATION_LINEAR_NOPERSPECTIVE = 4,
  1858. D3D10_SB_INTERPOLATION_LINEAR_NOPERSPECTIVE_CENTROID = 5,
  1859. D3D10_SB_INTERPOLATION_LINEAR_SAMPLE = 6, // DX10.1
  1860. D3D10_SB_INTERPOLATION_LINEAR_NOPERSPECTIVE_SAMPLE = 7, // DX10.1
  1861. } D3D10_SB_INTERPOLATION_MODE;
  1862. // Keep PRIMITIVE_TOPOLOGY values in sync with earlier DX versions (HW consumes values directly).
  1863. typedef enum D3D10_SB_PRIMITIVE_TOPOLOGY
  1864. {
  1865. D3D10_SB_PRIMITIVE_TOPOLOGY_UNDEFINED = 0,
  1866. D3D10_SB_PRIMITIVE_TOPOLOGY_POINTLIST = 1,
  1867. D3D10_SB_PRIMITIVE_TOPOLOGY_LINELIST = 2,
  1868. D3D10_SB_PRIMITIVE_TOPOLOGY_LINESTRIP = 3,
  1869. D3D10_SB_PRIMITIVE_TOPOLOGY_TRIANGLELIST = 4,
  1870. D3D10_SB_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP = 5,
  1871. // 6 is reserved for legacy triangle fans
  1872. // Adjacency values should be equal to (0x8 & non-adjacency):
  1873. D3D10_SB_PRIMITIVE_TOPOLOGY_LINELIST_ADJ = 10,
  1874. D3D10_SB_PRIMITIVE_TOPOLOGY_LINESTRIP_ADJ = 11,
  1875. D3D10_SB_PRIMITIVE_TOPOLOGY_TRIANGLELIST_ADJ = 12,
  1876. D3D10_SB_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP_ADJ = 13,
  1877. } D3D10_SB_PRIMITIVE_TOPOLOGY;
  1878. typedef enum D3D10_SB_PRIMITIVE
  1879. {
  1880. D3D10_SB_PRIMITIVE_UNDEFINED = 0,
  1881. D3D10_SB_PRIMITIVE_POINT = 1,
  1882. D3D10_SB_PRIMITIVE_LINE = 2,
  1883. D3D10_SB_PRIMITIVE_TRIANGLE = 3,
  1884. // Adjacency values should be equal to (0x4 & non-adjacency):
  1885. D3D10_SB_PRIMITIVE_LINE_ADJ = 6,
  1886. D3D10_SB_PRIMITIVE_TRIANGLE_ADJ = 7,
  1887. D3D11_SB_PRIMITIVE_1_CONTROL_POINT_PATCH = 8,
  1888. D3D11_SB_PRIMITIVE_2_CONTROL_POINT_PATCH = 9,
  1889. D3D11_SB_PRIMITIVE_3_CONTROL_POINT_PATCH = 10,
  1890. D3D11_SB_PRIMITIVE_4_CONTROL_POINT_PATCH = 11,
  1891. D3D11_SB_PRIMITIVE_5_CONTROL_POINT_PATCH = 12,
  1892. D3D11_SB_PRIMITIVE_6_CONTROL_POINT_PATCH = 13,
  1893. D3D11_SB_PRIMITIVE_7_CONTROL_POINT_PATCH = 14,
  1894. D3D11_SB_PRIMITIVE_8_CONTROL_POINT_PATCH = 15,
  1895. D3D11_SB_PRIMITIVE_9_CONTROL_POINT_PATCH = 16,
  1896. D3D11_SB_PRIMITIVE_10_CONTROL_POINT_PATCH = 17,
  1897. D3D11_SB_PRIMITIVE_11_CONTROL_POINT_PATCH = 18,
  1898. D3D11_SB_PRIMITIVE_12_CONTROL_POINT_PATCH = 19,
  1899. D3D11_SB_PRIMITIVE_13_CONTROL_POINT_PATCH = 20,
  1900. D3D11_SB_PRIMITIVE_14_CONTROL_POINT_PATCH = 21,
  1901. D3D11_SB_PRIMITIVE_15_CONTROL_POINT_PATCH = 22,
  1902. D3D11_SB_PRIMITIVE_16_CONTROL_POINT_PATCH = 23,
  1903. D3D11_SB_PRIMITIVE_17_CONTROL_POINT_PATCH = 24,
  1904. D3D11_SB_PRIMITIVE_18_CONTROL_POINT_PATCH = 25,
  1905. D3D11_SB_PRIMITIVE_19_CONTROL_POINT_PATCH = 26,
  1906. D3D11_SB_PRIMITIVE_20_CONTROL_POINT_PATCH = 27,
  1907. D3D11_SB_PRIMITIVE_21_CONTROL_POINT_PATCH = 28,
  1908. D3D11_SB_PRIMITIVE_22_CONTROL_POINT_PATCH = 29,
  1909. D3D11_SB_PRIMITIVE_23_CONTROL_POINT_PATCH = 30,
  1910. D3D11_SB_PRIMITIVE_24_CONTROL_POINT_PATCH = 31,
  1911. D3D11_SB_PRIMITIVE_25_CONTROL_POINT_PATCH = 32,
  1912. D3D11_SB_PRIMITIVE_26_CONTROL_POINT_PATCH = 33,
  1913. D3D11_SB_PRIMITIVE_27_CONTROL_POINT_PATCH = 34,
  1914. D3D11_SB_PRIMITIVE_28_CONTROL_POINT_PATCH = 35,
  1915. D3D11_SB_PRIMITIVE_29_CONTROL_POINT_PATCH = 36,
  1916. D3D11_SB_PRIMITIVE_30_CONTROL_POINT_PATCH = 37,
  1917. D3D11_SB_PRIMITIVE_31_CONTROL_POINT_PATCH = 38,
  1918. D3D11_SB_PRIMITIVE_32_CONTROL_POINT_PATCH = 39,
  1919. } D3D10_SB_PRIMITIVE;
  1920. typedef enum D3D10_SB_COMPONENT_MASK
  1921. {
  1922. D3D10_SB_COMPONENT_MASK_X = 1,
  1923. D3D10_SB_COMPONENT_MASK_Y = 2,
  1924. D3D10_SB_COMPONENT_MASK_Z = 4,
  1925. D3D10_SB_COMPONENT_MASK_W = 8,
  1926. D3D10_SB_COMPONENT_MASK_R = 1,
  1927. D3D10_SB_COMPONENT_MASK_G = 2,
  1928. D3D10_SB_COMPONENT_MASK_B = 4,
  1929. D3D10_SB_COMPONENT_MASK_A = 8,
  1930. D3D10_SB_COMPONENT_MASK_ALL = 15,
  1931. } D3D10_SB_COMPONENT_MASK;
  1932. typedef enum D3D10_SB_NAME
  1933. {
  1934. D3D10_SB_NAME_UNDEFINED = 0,
  1935. D3D10_SB_NAME_POSITION = 1,
  1936. D3D10_SB_NAME_CLIP_DISTANCE = 2,
  1937. D3D10_SB_NAME_CULL_DISTANCE = 3,
  1938. D3D10_SB_NAME_RENDER_TARGET_ARRAY_INDEX = 4,
  1939. D3D10_SB_NAME_VIEWPORT_ARRAY_INDEX = 5,
  1940. D3D10_SB_NAME_VERTEX_ID = 6,
  1941. D3D10_SB_NAME_PRIMITIVE_ID = 7,
  1942. D3D10_SB_NAME_INSTANCE_ID = 8,
  1943. D3D10_SB_NAME_IS_FRONT_FACE = 9,
  1944. D3D10_SB_NAME_SAMPLE_INDEX = 10,
  1945. // The following are added for D3D11
  1946. D3D11_SB_NAME_FINAL_QUAD_U_EQ_0_EDGE_TESSFACTOR = 11,
  1947. D3D11_SB_NAME_FINAL_QUAD_V_EQ_0_EDGE_TESSFACTOR = 12,
  1948. D3D11_SB_NAME_FINAL_QUAD_U_EQ_1_EDGE_TESSFACTOR = 13,
  1949. D3D11_SB_NAME_FINAL_QUAD_V_EQ_1_EDGE_TESSFACTOR = 14,
  1950. D3D11_SB_NAME_FINAL_QUAD_U_INSIDE_TESSFACTOR = 15,
  1951. D3D11_SB_NAME_FINAL_QUAD_V_INSIDE_TESSFACTOR = 16,
  1952. D3D11_SB_NAME_FINAL_TRI_U_EQ_0_EDGE_TESSFACTOR = 17,
  1953. D3D11_SB_NAME_FINAL_TRI_V_EQ_0_EDGE_TESSFACTOR = 18,
  1954. D3D11_SB_NAME_FINAL_TRI_W_EQ_0_EDGE_TESSFACTOR = 19,
  1955. D3D11_SB_NAME_FINAL_TRI_INSIDE_TESSFACTOR = 20,
  1956. D3D11_SB_NAME_FINAL_LINE_DETAIL_TESSFACTOR = 21,
  1957. D3D11_SB_NAME_FINAL_LINE_DENSITY_TESSFACTOR = 22,
  1958. // The following are added for D3D12
  1959. D3D12_SB_NAME_BARYCENTRICS = 23,
  1960. D3D12_SB_NAME_SHADINGRATE = 24,
  1961. D3D12_SB_NAME_CULLPRIMITIVE = 25,
  1962. } D3D10_SB_NAME;
  1963. typedef enum D3D10_SB_RESOURCE_DIMENSION
  1964. {
  1965. D3D10_SB_RESOURCE_DIMENSION_UNKNOWN = 0,
  1966. D3D10_SB_RESOURCE_DIMENSION_BUFFER = 1,
  1967. D3D10_SB_RESOURCE_DIMENSION_TEXTURE1D = 2,
  1968. D3D10_SB_RESOURCE_DIMENSION_TEXTURE2D = 3,
  1969. D3D10_SB_RESOURCE_DIMENSION_TEXTURE2DMS = 4,
  1970. D3D10_SB_RESOURCE_DIMENSION_TEXTURE3D = 5,
  1971. D3D10_SB_RESOURCE_DIMENSION_TEXTURECUBE = 6,
  1972. D3D10_SB_RESOURCE_DIMENSION_TEXTURE1DARRAY = 7,
  1973. D3D10_SB_RESOURCE_DIMENSION_TEXTURE2DARRAY = 8,
  1974. D3D10_SB_RESOURCE_DIMENSION_TEXTURE2DMSARRAY = 9,
  1975. D3D10_SB_RESOURCE_DIMENSION_TEXTURECUBEARRAY = 10,
  1976. D3D11_SB_RESOURCE_DIMENSION_RAW_BUFFER = 11,
  1977. D3D11_SB_RESOURCE_DIMENSION_STRUCTURED_BUFFER = 12,
  1978. } D3D10_SB_RESOURCE_DIMENSION;
  1979. typedef enum D3D10_SB_RESOURCE_RETURN_TYPE
  1980. {
  1981. D3D10_SB_RETURN_TYPE_UNORM = 1,
  1982. D3D10_SB_RETURN_TYPE_SNORM = 2,
  1983. D3D10_SB_RETURN_TYPE_SINT = 3,
  1984. D3D10_SB_RETURN_TYPE_UINT = 4,
  1985. D3D10_SB_RETURN_TYPE_FLOAT = 5,
  1986. D3D10_SB_RETURN_TYPE_MIXED = 6,
  1987. D3D11_SB_RETURN_TYPE_DOUBLE = 7,
  1988. D3D11_SB_RETURN_TYPE_CONTINUED = 8,
  1989. D3D11_SB_RETURN_TYPE_UNUSED = 9,
  1990. } D3D10_SB_RESOURCE_RETURN_TYPE;
  1991. typedef enum D3D10_SB_REGISTER_COMPONENT_TYPE
  1992. {
  1993. D3D10_SB_REGISTER_COMPONENT_UNKNOWN = 0,
  1994. D3D10_SB_REGISTER_COMPONENT_UINT32 = 1,
  1995. D3D10_SB_REGISTER_COMPONENT_SINT32 = 2,
  1996. D3D10_SB_REGISTER_COMPONENT_FLOAT32 = 3
  1997. } D3D10_SB_REGISTER_COMPONENT_TYPE;
  1998. typedef enum D3D10_SB_INSTRUCTION_RETURN_TYPE
  1999. {
  2000. D3D10_SB_INSTRUCTION_RETURN_FLOAT = 0,
  2001. D3D10_SB_INSTRUCTION_RETURN_UINT = 1
  2002. } D3D10_SB_INSTRUCTION_RETURN_TYPE;
  2003. #define D3D10_SB_INSTRUCTION_RETURN_TYPE_MASK 0x00001800
  2004. #define D3D10_SB_INSTRUCTION_RETURN_TYPE_SHIFT 11
  2005. // DECODER MACRO: For an OpcodeToken0 with the return type
  2006. // determine the return type.
  2007. #define DECODE_D3D10_SB_INSTRUCTION_RETURN_TYPE(OpcodeToken0) ((D3D10_SB_INSTRUCTION_RETURN_TYPE)(((OpcodeToken0)&D3D10_SB_INSTRUCTION_RETURN_TYPE_MASK)>>D3D10_SB_INSTRUCTION_RETURN_TYPE_SHIFT))
  2008. // ENCODER MACRO: Encode the return type for instructions
  2009. // in the opcode specific control range of OpcodeToken0
  2010. #define ENCODE_D3D10_SB_INSTRUCTION_RETURN_TYPE(ReturnType) (((ReturnType)<<D3D10_SB_INSTRUCTION_RETURN_TYPE_SHIFT)&D3D10_SB_INSTRUCTION_RETURN_TYPE_MASK)
  2011. // ----------------------------------------------------------------------------
  2012. // Interface function body Declaration
  2013. //
  2014. // OpcodeToken0:
  2015. //
  2016. // [10:00] D3D10_SB_OPCODE_DCL_FUNCTION_BODY
  2017. // [23:11] Ignored, 0
  2018. // [30:24] Instruction length in DWORDs including the opcode token.
  2019. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD
  2020. // contains extended operand description. If it is extended, then
  2021. // it contains the actual instruction length in DWORDs, since
  2022. // it may not fit into 7 bits if enough operands are defined.
  2023. //
  2024. // OpcodeToken0 is followed by a DWORD that represents the function body
  2025. // identifier.
  2026. //
  2027. // ----------------------------------------------------------------------------
  2028. // ----------------------------------------------------------------------------
  2029. // Interface function table Declaration
  2030. //
  2031. // OpcodeToken0:
  2032. //
  2033. // [10:00] D3D10_SB_OPCODE_DCL_FUNCTION_TABLE
  2034. // [23:11] Ignored, 0
  2035. // [30:24] Instruction length in DWORDs including the opcode token.
  2036. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD
  2037. // contains extended operand description. If it is extended, then
  2038. // it contains the actual instruction length in DWORDs, since
  2039. // it may not fit into 7 bits if enough functions are defined.
  2040. //
  2041. // OpcodeToken0 is followed by a DWORD that represents the function table
  2042. // identifier and another DWORD (TableLength) that gives the number of
  2043. // functions in the table.
  2044. //
  2045. // This is followed by TableLength DWORDs which are function body indices.
  2046. //
  2047. // ----------------------------------------------------------------------------
  2048. // ----------------------------------------------------------------------------
  2049. // Interface Declaration
  2050. //
  2051. // OpcodeToken0:
  2052. //
  2053. // [10:00] D3D10_SB_OPCODE_DCL_INTERFACE
  2054. // [11] 1 if the interface is indexed dynamically, 0 otherwise.
  2055. // [23:12] Ignored, 0
  2056. // [30:24] Instruction length in DWORDs including the opcode token.
  2057. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD
  2058. // contains extended operand description. If it is extended, then
  2059. // it contains the actual instruction length in DWORDs, since
  2060. // it may not fit into 7 bits if enough types are used.
  2061. //
  2062. // OpcodeToken0 is followed by a DWORD that represents the interface
  2063. // identifier. Next is a DWORD that gives the expected function table
  2064. // length. Then another DWORD (OpcodeToken3) with the following layout:
  2065. //
  2066. // [15:00] TableLength, the number of types that implement this interface
  2067. // [31:16] ArrayLength, the number of interfaces that are defined in this array.
  2068. //
  2069. // This is followed by TableLength DWORDs which are function table
  2070. // identifiers, representing possible tables for a given interface.
  2071. //
  2072. // ----------------------------------------------------------------------------
  2073. #define D3D11_SB_INTERFACE_INDEXED_BIT_MASK 0x00000800
  2074. #define D3D11_SB_INTERFACE_INDEXED_BIT_SHIFT 11
  2075. #define D3D11_SB_INTERFACE_TABLE_LENGTH_MASK 0x0000ffff
  2076. #define D3D11_SB_INTERFACE_TABLE_LENGTH_SHIFT 0
  2077. #define D3D11_SB_INTERFACE_ARRAY_LENGTH_MASK 0xffff0000
  2078. #define D3D11_SB_INTERFACE_ARRAY_LENGTH_SHIFT 16
  2079. // get/set the indexed bit for an interface definition
  2080. #define DECODE_D3D11_SB_INTERFACE_INDEXED_BIT(OpcodeToken0) ((((OpcodeToken0)&D3D11_SB_INTERFACE_INDEXED_BIT_MASK)>>D3D11_SB_INTERFACE_INDEXED_BIT_SHIFT) ? true : false)
  2081. #define ENCODE_D3D11_SB_INTERFACE_INDEXED_BIT(IndexedBit) (((IndexedBit)<<D3D11_SB_INTERFACE_INDEXED_BIT_SHIFT)&D3D11_SB_INTERFACE_INDEXED_BIT_MASK)
  2082. // get/set the table length for an interface definition
  2083. #define DECODE_D3D11_SB_INTERFACE_TABLE_LENGTH(OpcodeToken0) ((UINT)(((OpcodeToken0)&D3D11_SB_INTERFACE_TABLE_LENGTH_MASK)>>D3D11_SB_INTERFACE_TABLE_LENGTH_SHIFT))
  2084. #define ENCODE_D3D11_SB_INTERFACE_TABLE_LENGTH(TableLength) (((TableLength)<<D3D11_SB_INTERFACE_TABLE_LENGTH_SHIFT)&D3D11_SB_INTERFACE_TABLE_LENGTH_MASK)
  2085. // get/set the array length for an interface definition
  2086. #define DECODE_D3D11_SB_INTERFACE_ARRAY_LENGTH(OpcodeToken0) ((UINT)(((OpcodeToken0)&D3D11_SB_INTERFACE_ARRAY_LENGTH_MASK)>>D3D11_SB_INTERFACE_ARRAY_LENGTH_SHIFT))
  2087. #define ENCODE_D3D11_SB_INTERFACE_ARRAY_LENGTH(ArrayLength) (((ArrayLength)<<D3D11_SB_INTERFACE_ARRAY_LENGTH_SHIFT)&D3D11_SB_INTERFACE_ARRAY_LENGTH_MASK)
  2088. // ----------------------------------------------------------------------------
  2089. // Interface call
  2090. //
  2091. // OpcodeToken0:
  2092. //
  2093. // [10:00] D3D10_SB_OPCODE_INTERFACE_CALL
  2094. // [23:11] Ignored, 0
  2095. // [30:24] Instruction length in DWORDs including the opcode token.
  2096. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD
  2097. // contains extended operand description. If it is extended, then
  2098. // it contains the actual instruction length in DWORDs, since
  2099. // it may not fit into 7 bits if enough types are used.
  2100. //
  2101. // OpcodeToken0 is followed by a DWORD that gives the function index to
  2102. // call in the function table specified for the given interface.
  2103. // Next is the interface operand.
  2104. //
  2105. // ----------------------------------------------------------------------------
  2106. // ----------------------------------------------------------------------------
  2107. // Thread Group Declaration (Compute Shader)
  2108. //
  2109. // OpcodeToken0:
  2110. //
  2111. // [10:00] D3D11_SB_OPCODE_DCL_THREAD_GROUP
  2112. // [23:11] Ignored, 0
  2113. // [30:24] Instruction length in DWORDs including the opcode token.
  2114. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD
  2115. // contains extended operand description. If it is extended, then
  2116. // it contains the actual instruction length in DWORDs, since
  2117. // it may not fit into 7 bits if enough types are used.
  2118. //
  2119. // OpcodeToken0 is followed by 3 DWORDs, the Thread Group dimensions as UINT32:
  2120. // x, y, z
  2121. //
  2122. // ----------------------------------------------------------------------------
  2123. // ----------------------------------------------------------------------------
  2124. // Typed Unordered Access View Declaration
  2125. //
  2126. // OpcodeToken0:
  2127. //
  2128. // [10:00] D3D11_SB_OPCODE_DCL_UNORDERED_ACCESS_VIEW_TYPED
  2129. // [15:11] D3D10_SB_RESOURCE_DIMENSION
  2130. // [16:16] D3D11_SB_GLOBALLY_COHERENT_ACCESS or 0 (LOCALLY_COHERENT)
  2131. // [17:17] D3D11_SB_RASTERIZER_ORDERED_ACCESS or 0
  2132. // [23:18] Ignored, 0
  2133. // [30:24] Instruction length in DWORDs including the opcode token.
  2134. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD
  2135. // contains extended operand description. This dcl is currently not
  2136. // extended.
  2137. //
  2138. // OpcodeToken0 is followed by 2 operands on Shader Models 4.0 through 5.0:
  2139. // (1) an operand, starting with OperandToken0, defining which
  2140. // u# register (D3D11_SB_OPERAND_TYPE_UNORDERED_ACCESS_VIEW) is being declared.
  2141. // (2) a Resource Return Type token (ResourceReturnTypeToken)
  2142. //
  2143. // OpcodeToken0 is followed by 3 operands on Shader Model 5.1 and later:
  2144. // (1) an operand, starting with OperandToken0, defining which
  2145. // u# register (D3D11_SB_OPERAND_TYPE_UNORDERED_ACCESS_VIEW) is being declared.
  2146. // The indexing dimension for the register must be D3D10_SB_OPERAND_INDEX_DIMENSION_3D,
  2147. // and the meaning of the index dimensions are as follows: (u<id>[<lbound>:<ubound>])
  2148. // 1 <id>: variable ID being declared
  2149. // 2 <lbound>: the lower bound of the range of UAV's in the space
  2150. // 3 <ubound>: the upper bound (inclusive) of this range
  2151. // As opposed to when the u# is used in shader instructions, where the register
  2152. // must be D3D10_SB_OPERAND_INDEX_DIMENSION_2D, and the meaning of the index
  2153. // dimensions are as follows: (u<id>[<idx>]):
  2154. // 1 <id>: variable ID being used (matches dcl)
  2155. // 2 <idx>: absolute index of uav within space (may be dynamically indexed)
  2156. // (2) a Resource Return Type token (ResourceReturnTypeToken)
  2157. // (3) a DWORD indicating the space index.
  2158. //
  2159. // ----------------------------------------------------------------------------
  2160. // UAV access scope flags
  2161. #define D3D11_SB_GLOBALLY_COHERENT_ACCESS 0x00010000
  2162. #define D3D11_SB_ACCESS_COHERENCY_MASK 0x00010000
  2163. // DECODER MACRO: Retrieve flags for sync instruction from OpcodeToken0.
  2164. #define DECODE_D3D11_SB_ACCESS_COHERENCY_FLAGS(OperandToken0) ((OperandToken0)&D3D11_SB_ACCESS_COHERENCY_MASK)
  2165. // ENCODER MACRO: Given a set of sync instruciton flags, encode them in OpcodeToken0.
  2166. #define ENCODE_D3D11_SB_ACCESS_COHERENCY_FLAGS(Flags) ((Flags)&D3D11_SB_ACCESS_COHERENCY_MASK)
  2167. // Additional UAV access flags
  2168. #define D3D11_SB_RASTERIZER_ORDERED_ACCESS 0x00020000
  2169. // Resource flags mask. Use to retrieve all resource flags, including the order preserving counter.
  2170. #define D3D11_SB_RESOURCE_FLAGS_MASK (D3D11_SB_GLOBALLY_COHERENT_ACCESS|D3D11_SB_RASTERIZER_ORDERED_ACCESS|D3D11_SB_UAV_HAS_ORDER_PRESERVING_COUNTER)
  2171. // DECODER MACRO: Retrieve UAV access flags for from OpcodeToken0.
  2172. #define DECODE_D3D11_SB_RESOURCE_FLAGS(OperandToken0) ((OperandToken0)&D3D11_SB_RESOURCE_FLAGS_MASK)
  2173. // ENCODER MACRO: Given UAV access flags, encode them in OpcodeToken0.
  2174. #define ENCODE_D3D11_SB_RESOURCE_FLAGS(Flags) ((Flags)&D3D11_SB_RESOURCE_FLAGS_MASK)
  2175. // ----------------------------------------------------------------------------
  2176. // Raw Unordered Access View Declaration
  2177. //
  2178. // OpcodeToken0:
  2179. //
  2180. // [10:00] D3D11_SB_OPCODE_DCL_UNORDERED_ACCESS_VIEW_RAW
  2181. // [15:11] Ignored, 0
  2182. // [16:16] D3D11_SB_GLOBALLY_COHERENT_ACCESS or 0 (LOCALLY_COHERENT)
  2183. // [17:17] D3D11_SB_RASTERIZER_ORDERED_ACCESS or 0
  2184. // [23:18] Ignored, 0
  2185. // [30:24] Instruction length in DWORDs including the opcode token.
  2186. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD
  2187. // contains extended operand description. This dcl is currently not
  2188. // extended.
  2189. //
  2190. // OpcodeToken0 is followed by 1 operand on Shader Models 4.0 through 5.0:
  2191. // (1) an operand, starting with OperandToken0, defining which
  2192. // u# register (D3D11_SB_OPERAND_TYPE_UNORDERED_ACCESS_VIEW) is being declared.
  2193. //
  2194. // OpcodeToken0 is followed by 2 operands on Shader Model 5.1 and later:
  2195. // (1) an operand, starting with OperandToken0, defining which
  2196. // u# register (D3D11_SB_OPERAND_TYPE_UNORDERED_ACCESS_VIEW) is being declared.
  2197. // The indexing dimension for the register must be D3D10_SB_OPERAND_INDEX_DIMENSION_3D,
  2198. // and the meaning of the index dimensions are as follows: (u<id>[<lbound>:<ubound>])
  2199. // 1 <id>: variable ID being declared
  2200. // 2 <lbound>: the lower bound of the range of UAV's in the space
  2201. // 3 <ubound>: the upper bound (inclusive) of this range
  2202. // As opposed to when the u# is used in shader instructions, where the register
  2203. // must be D3D10_SB_OPERAND_INDEX_DIMENSION_2D, and the meaning of the index
  2204. // dimensions are as follows: (u<id>[<idx>]):
  2205. // 1 <id>: variable ID being used (matches dcl)
  2206. // 2 <idx>: absolute index of uav within space (may be dynamically indexed)
  2207. // (2) a DWORD indicating the space index.
  2208. //
  2209. // ----------------------------------------------------------------------------
  2210. // ----------------------------------------------------------------------------
  2211. // Structured Unordered Access View Declaration
  2212. //
  2213. // OpcodeToken0:
  2214. //
  2215. // [10:00] D3D11_SB_OPCODE_DCL_UNORDERED_ACCESS_VIEW_STRUCTURED
  2216. // [15:11] Ignored, 0
  2217. // [16:16] D3D11_SB_GLOBALLY_COHERENT_ACCESS or 0 (LOCALLY_COHERENT)
  2218. // [17:17] D3D11_SB_RASTERIZER_ORDERED_ACCESS or 0
  2219. // [22:18] Ignored, 0
  2220. // [23:23] D3D11_SB_UAV_HAS_ORDER_PRESERVING_COUNTER or 0
  2221. //
  2222. // The presence of this flag means that if a UAV is bound to the
  2223. // corresponding slot, it must have been created with
  2224. // D3D11_BUFFER_UAV_FLAG_COUNTER at the API. Also, the shader
  2225. // can contain either imm_atomic_alloc or _consume instructions
  2226. // operating on the given UAV.
  2227. //
  2228. // If this flag is not present, the shader can still contain
  2229. // either imm_atomic_alloc or imm_atomic_consume instructions for
  2230. // this UAV. But if such instructions are present in this case,
  2231. // and a UAV is bound corresponding slot, it must have been created
  2232. // with the D3D11_BUFFER_UAV_FLAG_APPEND flag at the API.
  2233. // Append buffers have a counter as well, but values returned
  2234. // to the shader are only valid for the lifetime of the shader
  2235. // invocation.
  2236. //
  2237. // [30:24] Instruction length in DWORDs including the opcode token.
  2238. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD
  2239. // contains extended operand description. This dcl is currently not
  2240. // extended.
  2241. //
  2242. // OpcodeToken0 is followed by 2 operands:
  2243. // (1) an operand, starting with OperandToken0, defining which
  2244. // u# register (D3D11_SB_OPERAND_TYPE_UNORDERED_ACCESS_VIEW) is
  2245. // being declared.
  2246. // (2) a DWORD indicating UINT32 byte stride
  2247. //
  2248. // OpcodeToken0 is followed by 3 operands on Shader Model 5.1 and later:
  2249. // (1) an operand, starting with OperandToken0, defining which
  2250. // u# register (D3D11_SB_OPERAND_TYPE_UNORDERED_ACCESS_VIEW) is being declared.
  2251. // The indexing dimension for the register must be D3D10_SB_OPERAND_INDEX_DIMENSION_3D,
  2252. // and the meaning of the index dimensions are as follows: (u<id>[<lbound>:<ubound>])
  2253. // 1 <id>: variable ID being declared
  2254. // 2 <lbound>: the lower bound of the range of UAV's in the space
  2255. // 3 <ubound>: the upper bound (inclusive) of this range
  2256. // As opposed to when the u# is used in shader instructions, where the register
  2257. // must be D3D10_SB_OPERAND_INDEX_DIMENSION_2D, and the meaning of the index
  2258. // dimensions are as follows: (u<id>[<idx>]):
  2259. // 1 <id>: variable ID being used (matches dcl)
  2260. // 2 <idx>: absolute index of uav within space (may be dynamically indexed)
  2261. // (2) a DWORD indicating UINT32 byte stride
  2262. // (3) a DWORD indicating the space index.
  2263. //
  2264. // ----------------------------------------------------------------------------
  2265. // UAV flags
  2266. #define D3D11_SB_UAV_HAS_ORDER_PRESERVING_COUNTER 0x00800000
  2267. #define D3D11_SB_UAV_FLAGS_MASK 0x00800000
  2268. // DECODER MACRO: Retrieve flags about UAV from OpcodeToken0.
  2269. #define DECODE_D3D11_SB_UAV_FLAGS(OperandToken0) ((OperandToken0)&D3D11_SB_UAV_FLAGS_MASK)
  2270. // ENCODER MACRO: Given a set of UAV flags, encode them in OpcodeToken0.
  2271. #define ENCODE_D3D11_SB_UAV_FLAGS(Flags) ((Flags)&D3D11_SB_UAV_FLAGS_MASK)
  2272. // ----------------------------------------------------------------------------
  2273. // Raw Thread Group Shared Memory Declaration
  2274. //
  2275. // OpcodeToken0:
  2276. //
  2277. // [10:00] D3D11_SB_OPCODE_DCL_THREAD_GROUP_SHARED_MEMORY_RAW
  2278. // [23:11] Ignored, 0
  2279. // [30:24] Instruction length in DWORDs including the opcode token.
  2280. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD
  2281. // contains extended operand description. This dcl is currently not
  2282. // extended.
  2283. //
  2284. // OpcodeToken0 is followed by 2 operands:
  2285. // (1) an operand, starting with OperandToken0, defining which
  2286. // g# register (D3D11_SB_OPERAND_TYPE_THREAD_GROUP_SHARED_MEMORY) is being declared.
  2287. // (2) a DWORD indicating the byte count, which must be a multiple of 4.
  2288. //
  2289. // ----------------------------------------------------------------------------
  2290. // ----------------------------------------------------------------------------
  2291. // Structured Thread Group Shared Memory Declaration
  2292. //
  2293. // OpcodeToken0:
  2294. //
  2295. // [10:00] D3D11_SB_OPCODE_DCL_THREAD_GROUP_SHARED_MEMORY_STRUCTURED
  2296. // [23:11] Ignored, 0
  2297. // [30:24] Instruction length in DWORDs including the opcode token.
  2298. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD
  2299. // contains extended operand description. This dcl is currently not
  2300. // extended.
  2301. //
  2302. // OpcodeToken0 is followed by 3 operands:
  2303. // (1) an operand, starting with OperandToken0, defining which
  2304. // g# register (D3D11_SB_OPERAND_TYPE_THREAD_GROUP_SHARED_MEMORY) is
  2305. // being declared.
  2306. // (2) a DWORD indicating UINT32 struct byte stride
  2307. // (3) a DWORD indicating UINT32 struct count
  2308. //
  2309. // ----------------------------------------------------------------------------
  2310. // ----------------------------------------------------------------------------
  2311. // Raw Shader Resource View Declaration
  2312. //
  2313. // OpcodeToken0:
  2314. //
  2315. // [10:00] D3D11_SB_OPCODE_DCL_RESOURCE_RAW
  2316. // [23:11] Ignored, 0
  2317. // [30:24] Instruction length in DWORDs including the opcode token.
  2318. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD
  2319. // contains extended operand description. This dcl is currently not
  2320. // extended.
  2321. //
  2322. // OpcodeToken0 is followed by 1 operand:
  2323. // (1) an operand, starting with OperandToken0, defining which
  2324. // t# register (D3D10_SB_OPERAND_TYPE_RESOURCE) is being declared.
  2325. //
  2326. // OpcodeToken0 is followed by 2 operands on Shader Model 5.1 and later:
  2327. // (1) an operand, starting with OperandToken0, defining which
  2328. // t# register (D3D10_SB_OPERAND_TYPE_RESOURCE) is being declared.
  2329. // The indexing dimension for the register must be D3D10_SB_OPERAND_INDEX_DIMENSION_3D,
  2330. // and the meaning of the index dimensions are as follows: (t<id>[<lbound>:<ubound>])
  2331. // 1 <id>: variable ID being declared
  2332. // 2 <lbound>: the lower bound of the range of resources in the space
  2333. // 3 <ubound>: the upper bound (inclusive) of this range
  2334. // As opposed to when the t# is used in shader instructions, where the register
  2335. // must be D3D10_SB_OPERAND_INDEX_DIMENSION_2D, and the meaning of the index
  2336. // dimensions are as follows: (t<id>[<idx>]):
  2337. // 1 <id>: variable ID being used (matches dcl)
  2338. // 2 <idx>: absolute index of resource within space (may be dynamically indexed)
  2339. // (2) a DWORD indicating the space index.
  2340. //
  2341. // ----------------------------------------------------------------------------
  2342. // ----------------------------------------------------------------------------
  2343. // Structured Shader Resource View Declaration
  2344. //
  2345. // OpcodeToken0:
  2346. //
  2347. // [10:00] D3D11_SB_OPCODE_DCL_RESOURCE_STRUCTURED
  2348. // [23:11] Ignored, 0
  2349. // [30:24] Instruction length in DWORDs including the opcode token.
  2350. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD
  2351. // contains extended operand description. This dcl is currently not
  2352. // extended.
  2353. //
  2354. // OpcodeToken0 is followed by 2 operands:
  2355. // (1) an operand, starting with OperandToken0, defining which
  2356. // g# register (D3D10_SB_OPERAND_TYPE_RESOURCE) is
  2357. // being declared.
  2358. // (2) a DWORD indicating UINT32 struct byte stride
  2359. //
  2360. // OpcodeToken0 is followed by 3 operands on Shader Model 5.1 and later:
  2361. // (1) an operand, starting with OperandToken0, defining which
  2362. // t# register (D3D10_SB_OPERAND_TYPE_RESOURCE) is being declared.
  2363. // The indexing dimension for the register must be D3D10_SB_OPERAND_INDEX_DIMENSION_3D,
  2364. // and the meaning of the index dimensions are as follows: (t<id>[<lbound>:<ubound>])
  2365. // 1 <id>: variable ID being declared
  2366. // 2 <lbound>: the lower bound of the range of resources in the space
  2367. // 3 <ubound>: the upper bound (inclusive) of this range
  2368. // As opposed to when the t# is used in shader instructions, where the register
  2369. // must be D3D10_SB_OPERAND_INDEX_DIMENSION_2D, and the meaning of the index
  2370. // dimensions are as follows: (t<id>[<idx>]):
  2371. // 1 <id>: variable ID being used (matches dcl)
  2372. // 2 <idx>: absolute index of resource within space (may be dynamically indexed)
  2373. // (2) a DWORD indicating UINT32 struct byte stride
  2374. // (3) a DWORD indicating the space index.
  2375. //
  2376. // ----------------------------------------------------------------------------
  2377. #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_GAMES) */
  2378. #pragma endregion