D3D12TokenizedProgramFormat.hpp 127 KB

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