D3D12TokenizedProgramFormat.hpp 127 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627
  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. } D3D10_SB_REGISTER_COMPONENT_TYPE;
  1993. typedef enum D3D10_SB_INSTRUCTION_RETURN_TYPE
  1994. {
  1995. D3D10_SB_INSTRUCTION_RETURN_FLOAT = 0,
  1996. D3D10_SB_INSTRUCTION_RETURN_UINT = 1
  1997. } D3D10_SB_INSTRUCTION_RETURN_TYPE;
  1998. #define D3D10_SB_INSTRUCTION_RETURN_TYPE_MASK 0x00001800
  1999. #define D3D10_SB_INSTRUCTION_RETURN_TYPE_SHIFT 11
  2000. // DECODER MACRO: For an OpcodeToken0 with the return type
  2001. // determine the return type.
  2002. #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))
  2003. // ENCODER MACRO: Encode the return type for instructions
  2004. // in the opcode specific control range of OpcodeToken0
  2005. #define ENCODE_D3D10_SB_INSTRUCTION_RETURN_TYPE(ReturnType) (((ReturnType)<<D3D10_SB_INSTRUCTION_RETURN_TYPE_SHIFT)&D3D10_SB_INSTRUCTION_RETURN_TYPE_MASK)
  2006. // ----------------------------------------------------------------------------
  2007. // Interface function body Declaration
  2008. //
  2009. // OpcodeToken0:
  2010. //
  2011. // [10:00] D3D10_SB_OPCODE_DCL_FUNCTION_BODY
  2012. // [23:11] Ignored, 0
  2013. // [30:24] Instruction length in DWORDs including the opcode token.
  2014. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD
  2015. // contains extended operand description. If it is extended, then
  2016. // it contains the actual instruction length in DWORDs, since
  2017. // it may not fit into 7 bits if enough operands are defined.
  2018. //
  2019. // OpcodeToken0 is followed by a DWORD that represents the function body
  2020. // identifier.
  2021. //
  2022. // ----------------------------------------------------------------------------
  2023. // ----------------------------------------------------------------------------
  2024. // Interface function table Declaration
  2025. //
  2026. // OpcodeToken0:
  2027. //
  2028. // [10:00] D3D10_SB_OPCODE_DCL_FUNCTION_TABLE
  2029. // [23:11] Ignored, 0
  2030. // [30:24] Instruction length in DWORDs including the opcode token.
  2031. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD
  2032. // contains extended operand description. If it is extended, then
  2033. // it contains the actual instruction length in DWORDs, since
  2034. // it may not fit into 7 bits if enough functions are defined.
  2035. //
  2036. // OpcodeToken0 is followed by a DWORD that represents the function table
  2037. // identifier and another DWORD (TableLength) that gives the number of
  2038. // functions in the table.
  2039. //
  2040. // This is followed by TableLength DWORDs which are function body indices.
  2041. //
  2042. // ----------------------------------------------------------------------------
  2043. // ----------------------------------------------------------------------------
  2044. // Interface Declaration
  2045. //
  2046. // OpcodeToken0:
  2047. //
  2048. // [10:00] D3D10_SB_OPCODE_DCL_INTERFACE
  2049. // [11] 1 if the interface is indexed dynamically, 0 otherwise.
  2050. // [23:12] Ignored, 0
  2051. // [30:24] Instruction length in DWORDs including the opcode token.
  2052. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD
  2053. // contains extended operand description. If it is extended, then
  2054. // it contains the actual instruction length in DWORDs, since
  2055. // it may not fit into 7 bits if enough types are used.
  2056. //
  2057. // OpcodeToken0 is followed by a DWORD that represents the interface
  2058. // identifier. Next is a DWORD that gives the expected function table
  2059. // length. Then another DWORD (OpcodeToken3) with the following layout:
  2060. //
  2061. // [15:00] TableLength, the number of types that implement this interface
  2062. // [31:16] ArrayLength, the number of interfaces that are defined in this array.
  2063. //
  2064. // This is followed by TableLength DWORDs which are function table
  2065. // identifiers, representing possible tables for a given interface.
  2066. //
  2067. // ----------------------------------------------------------------------------
  2068. #define D3D11_SB_INTERFACE_INDEXED_BIT_MASK 0x00000800
  2069. #define D3D11_SB_INTERFACE_INDEXED_BIT_SHIFT 11
  2070. #define D3D11_SB_INTERFACE_TABLE_LENGTH_MASK 0x0000ffff
  2071. #define D3D11_SB_INTERFACE_TABLE_LENGTH_SHIFT 0
  2072. #define D3D11_SB_INTERFACE_ARRAY_LENGTH_MASK 0xffff0000
  2073. #define D3D11_SB_INTERFACE_ARRAY_LENGTH_SHIFT 16
  2074. // get/set the indexed bit for an interface definition
  2075. #define DECODE_D3D11_SB_INTERFACE_INDEXED_BIT(OpcodeToken0) ((((OpcodeToken0)&D3D11_SB_INTERFACE_INDEXED_BIT_MASK)>>D3D11_SB_INTERFACE_INDEXED_BIT_SHIFT) ? true : false)
  2076. #define ENCODE_D3D11_SB_INTERFACE_INDEXED_BIT(IndexedBit) (((IndexedBit)<<D3D11_SB_INTERFACE_INDEXED_BIT_SHIFT)&D3D11_SB_INTERFACE_INDEXED_BIT_MASK)
  2077. // get/set the table length for an interface definition
  2078. #define DECODE_D3D11_SB_INTERFACE_TABLE_LENGTH(OpcodeToken0) ((UINT)(((OpcodeToken0)&D3D11_SB_INTERFACE_TABLE_LENGTH_MASK)>>D3D11_SB_INTERFACE_TABLE_LENGTH_SHIFT))
  2079. #define ENCODE_D3D11_SB_INTERFACE_TABLE_LENGTH(TableLength) (((TableLength)<<D3D11_SB_INTERFACE_TABLE_LENGTH_SHIFT)&D3D11_SB_INTERFACE_TABLE_LENGTH_MASK)
  2080. // get/set the array length for an interface definition
  2081. #define DECODE_D3D11_SB_INTERFACE_ARRAY_LENGTH(OpcodeToken0) ((UINT)(((OpcodeToken0)&D3D11_SB_INTERFACE_ARRAY_LENGTH_MASK)>>D3D11_SB_INTERFACE_ARRAY_LENGTH_SHIFT))
  2082. #define ENCODE_D3D11_SB_INTERFACE_ARRAY_LENGTH(ArrayLength) (((ArrayLength)<<D3D11_SB_INTERFACE_ARRAY_LENGTH_SHIFT)&D3D11_SB_INTERFACE_ARRAY_LENGTH_MASK)
  2083. // ----------------------------------------------------------------------------
  2084. // Interface call
  2085. //
  2086. // OpcodeToken0:
  2087. //
  2088. // [10:00] D3D10_SB_OPCODE_INTERFACE_CALL
  2089. // [23:11] Ignored, 0
  2090. // [30:24] Instruction length in DWORDs including the opcode token.
  2091. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD
  2092. // contains extended operand description. If it is extended, then
  2093. // it contains the actual instruction length in DWORDs, since
  2094. // it may not fit into 7 bits if enough types are used.
  2095. //
  2096. // OpcodeToken0 is followed by a DWORD that gives the function index to
  2097. // call in the function table specified for the given interface.
  2098. // Next is the interface operand.
  2099. //
  2100. // ----------------------------------------------------------------------------
  2101. // ----------------------------------------------------------------------------
  2102. // Thread Group Declaration (Compute Shader)
  2103. //
  2104. // OpcodeToken0:
  2105. //
  2106. // [10:00] D3D11_SB_OPCODE_DCL_THREAD_GROUP
  2107. // [23:11] Ignored, 0
  2108. // [30:24] Instruction length in DWORDs including the opcode token.
  2109. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD
  2110. // contains extended operand description. If it is extended, then
  2111. // it contains the actual instruction length in DWORDs, since
  2112. // it may not fit into 7 bits if enough types are used.
  2113. //
  2114. // OpcodeToken0 is followed by 3 DWORDs, the Thread Group dimensions as UINT32:
  2115. // x, y, z
  2116. //
  2117. // ----------------------------------------------------------------------------
  2118. // ----------------------------------------------------------------------------
  2119. // Typed Unordered Access View Declaration
  2120. //
  2121. // OpcodeToken0:
  2122. //
  2123. // [10:00] D3D11_SB_OPCODE_DCL_UNORDERED_ACCESS_VIEW_TYPED
  2124. // [15:11] D3D10_SB_RESOURCE_DIMENSION
  2125. // [16:16] D3D11_SB_GLOBALLY_COHERENT_ACCESS or 0 (LOCALLY_COHERENT)
  2126. // [17:17] D3D11_SB_RASTERIZER_ORDERED_ACCESS or 0
  2127. // [23:18] Ignored, 0
  2128. // [30:24] Instruction length in DWORDs including the opcode token.
  2129. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD
  2130. // contains extended operand description. This dcl is currently not
  2131. // extended.
  2132. //
  2133. // OpcodeToken0 is followed by 2 operands on Shader Models 4.0 through 5.0:
  2134. // (1) an operand, starting with OperandToken0, defining which
  2135. // u# register (D3D11_SB_OPERAND_TYPE_UNORDERED_ACCESS_VIEW) is being declared.
  2136. // (2) a Resource Return Type token (ResourceReturnTypeToken)
  2137. //
  2138. // OpcodeToken0 is followed by 3 operands on Shader Model 5.1 and later:
  2139. // (1) an operand, starting with OperandToken0, defining which
  2140. // u# register (D3D11_SB_OPERAND_TYPE_UNORDERED_ACCESS_VIEW) is being declared.
  2141. // The indexing dimension for the register must be D3D10_SB_OPERAND_INDEX_DIMENSION_3D,
  2142. // and the meaning of the index dimensions are as follows: (u<id>[<lbound>:<ubound>])
  2143. // 1 <id>: variable ID being declared
  2144. // 2 <lbound>: the lower bound of the range of UAV's in the space
  2145. // 3 <ubound>: the upper bound (inclusive) of this range
  2146. // As opposed to when the u# is used in shader instructions, where the register
  2147. // must be D3D10_SB_OPERAND_INDEX_DIMENSION_2D, and the meaning of the index
  2148. // dimensions are as follows: (u<id>[<idx>]):
  2149. // 1 <id>: variable ID being used (matches dcl)
  2150. // 2 <idx>: absolute index of uav within space (may be dynamically indexed)
  2151. // (2) a Resource Return Type token (ResourceReturnTypeToken)
  2152. // (3) a DWORD indicating the space index.
  2153. //
  2154. // ----------------------------------------------------------------------------
  2155. // UAV access scope flags
  2156. #define D3D11_SB_GLOBALLY_COHERENT_ACCESS 0x00010000
  2157. #define D3D11_SB_ACCESS_COHERENCY_MASK 0x00010000
  2158. // DECODER MACRO: Retrieve flags for sync instruction from OpcodeToken0.
  2159. #define DECODE_D3D11_SB_ACCESS_COHERENCY_FLAGS(OperandToken0) ((OperandToken0)&D3D11_SB_ACCESS_COHERENCY_MASK)
  2160. // ENCODER MACRO: Given a set of sync instruciton flags, encode them in OpcodeToken0.
  2161. #define ENCODE_D3D11_SB_ACCESS_COHERENCY_FLAGS(Flags) ((Flags)&D3D11_SB_ACCESS_COHERENCY_MASK)
  2162. // Additional UAV access flags
  2163. #define D3D11_SB_RASTERIZER_ORDERED_ACCESS 0x00020000
  2164. // Resource flags mask. Use to retrieve all resource flags, including the order preserving counter.
  2165. #define D3D11_SB_RESOURCE_FLAGS_MASK (D3D11_SB_GLOBALLY_COHERENT_ACCESS|D3D11_SB_RASTERIZER_ORDERED_ACCESS|D3D11_SB_UAV_HAS_ORDER_PRESERVING_COUNTER)
  2166. // DECODER MACRO: Retrieve UAV access flags for from OpcodeToken0.
  2167. #define DECODE_D3D11_SB_RESOURCE_FLAGS(OperandToken0) ((OperandToken0)&D3D11_SB_RESOURCE_FLAGS_MASK)
  2168. // ENCODER MACRO: Given UAV access flags, encode them in OpcodeToken0.
  2169. #define ENCODE_D3D11_SB_RESOURCE_FLAGS(Flags) ((Flags)&D3D11_SB_RESOURCE_FLAGS_MASK)
  2170. // ----------------------------------------------------------------------------
  2171. // Raw Unordered Access View Declaration
  2172. //
  2173. // OpcodeToken0:
  2174. //
  2175. // [10:00] D3D11_SB_OPCODE_DCL_UNORDERED_ACCESS_VIEW_RAW
  2176. // [15:11] Ignored, 0
  2177. // [16:16] D3D11_SB_GLOBALLY_COHERENT_ACCESS or 0 (LOCALLY_COHERENT)
  2178. // [17:17] D3D11_SB_RASTERIZER_ORDERED_ACCESS or 0
  2179. // [23:18] Ignored, 0
  2180. // [30:24] Instruction length in DWORDs including the opcode token.
  2181. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD
  2182. // contains extended operand description. This dcl is currently not
  2183. // extended.
  2184. //
  2185. // OpcodeToken0 is followed by 1 operand on Shader Models 4.0 through 5.0:
  2186. // (1) an operand, starting with OperandToken0, defining which
  2187. // u# register (D3D11_SB_OPERAND_TYPE_UNORDERED_ACCESS_VIEW) is being declared.
  2188. //
  2189. // OpcodeToken0 is followed by 2 operands on Shader Model 5.1 and later:
  2190. // (1) an operand, starting with OperandToken0, defining which
  2191. // u# register (D3D11_SB_OPERAND_TYPE_UNORDERED_ACCESS_VIEW) is being declared.
  2192. // The indexing dimension for the register must be D3D10_SB_OPERAND_INDEX_DIMENSION_3D,
  2193. // and the meaning of the index dimensions are as follows: (u<id>[<lbound>:<ubound>])
  2194. // 1 <id>: variable ID being declared
  2195. // 2 <lbound>: the lower bound of the range of UAV's in the space
  2196. // 3 <ubound>: the upper bound (inclusive) of this range
  2197. // As opposed to when the u# is used in shader instructions, where the register
  2198. // must be D3D10_SB_OPERAND_INDEX_DIMENSION_2D, and the meaning of the index
  2199. // dimensions are as follows: (u<id>[<idx>]):
  2200. // 1 <id>: variable ID being used (matches dcl)
  2201. // 2 <idx>: absolute index of uav within space (may be dynamically indexed)
  2202. // (2) a DWORD indicating the space index.
  2203. //
  2204. // ----------------------------------------------------------------------------
  2205. // ----------------------------------------------------------------------------
  2206. // Structured Unordered Access View Declaration
  2207. //
  2208. // OpcodeToken0:
  2209. //
  2210. // [10:00] D3D11_SB_OPCODE_DCL_UNORDERED_ACCESS_VIEW_STRUCTURED
  2211. // [15:11] Ignored, 0
  2212. // [16:16] D3D11_SB_GLOBALLY_COHERENT_ACCESS or 0 (LOCALLY_COHERENT)
  2213. // [17:17] D3D11_SB_RASTERIZER_ORDERED_ACCESS or 0
  2214. // [22:18] Ignored, 0
  2215. // [23:23] D3D11_SB_UAV_HAS_ORDER_PRESERVING_COUNTER or 0
  2216. //
  2217. // The presence of this flag means that if a UAV is bound to the
  2218. // corresponding slot, it must have been created with
  2219. // D3D11_BUFFER_UAV_FLAG_COUNTER at the API. Also, the shader
  2220. // can contain either imm_atomic_alloc or _consume instructions
  2221. // operating on the given UAV.
  2222. //
  2223. // If this flag is not present, the shader can still contain
  2224. // either imm_atomic_alloc or imm_atomic_consume instructions for
  2225. // this UAV. But if such instructions are present in this case,
  2226. // and a UAV is bound corresponding slot, it must have been created
  2227. // with the D3D11_BUFFER_UAV_FLAG_APPEND flag at the API.
  2228. // Append buffers have a counter as well, but values returned
  2229. // to the shader are only valid for the lifetime of the shader
  2230. // invocation.
  2231. //
  2232. // [30:24] Instruction length in DWORDs including the opcode token.
  2233. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD
  2234. // contains extended operand description. This dcl is currently not
  2235. // extended.
  2236. //
  2237. // OpcodeToken0 is followed by 2 operands:
  2238. // (1) an operand, starting with OperandToken0, defining which
  2239. // u# register (D3D11_SB_OPERAND_TYPE_UNORDERED_ACCESS_VIEW) is
  2240. // being declared.
  2241. // (2) a DWORD indicating UINT32 byte stride
  2242. //
  2243. // OpcodeToken0 is followed by 3 operands on Shader Model 5.1 and later:
  2244. // (1) an operand, starting with OperandToken0, defining which
  2245. // u# register (D3D11_SB_OPERAND_TYPE_UNORDERED_ACCESS_VIEW) is being declared.
  2246. // The indexing dimension for the register must be D3D10_SB_OPERAND_INDEX_DIMENSION_3D,
  2247. // and the meaning of the index dimensions are as follows: (u<id>[<lbound>:<ubound>])
  2248. // 1 <id>: variable ID being declared
  2249. // 2 <lbound>: the lower bound of the range of UAV's in the space
  2250. // 3 <ubound>: the upper bound (inclusive) of this range
  2251. // As opposed to when the u# is used in shader instructions, where the register
  2252. // must be D3D10_SB_OPERAND_INDEX_DIMENSION_2D, and the meaning of the index
  2253. // dimensions are as follows: (u<id>[<idx>]):
  2254. // 1 <id>: variable ID being used (matches dcl)
  2255. // 2 <idx>: absolute index of uav within space (may be dynamically indexed)
  2256. // (2) a DWORD indicating UINT32 byte stride
  2257. // (3) a DWORD indicating the space index.
  2258. //
  2259. // ----------------------------------------------------------------------------
  2260. // UAV flags
  2261. #define D3D11_SB_UAV_HAS_ORDER_PRESERVING_COUNTER 0x00800000
  2262. #define D3D11_SB_UAV_FLAGS_MASK 0x00800000
  2263. // DECODER MACRO: Retrieve flags about UAV from OpcodeToken0.
  2264. #define DECODE_D3D11_SB_UAV_FLAGS(OperandToken0) ((OperandToken0)&D3D11_SB_UAV_FLAGS_MASK)
  2265. // ENCODER MACRO: Given a set of UAV flags, encode them in OpcodeToken0.
  2266. #define ENCODE_D3D11_SB_UAV_FLAGS(Flags) ((Flags)&D3D11_SB_UAV_FLAGS_MASK)
  2267. // ----------------------------------------------------------------------------
  2268. // Raw Thread Group Shared Memory Declaration
  2269. //
  2270. // OpcodeToken0:
  2271. //
  2272. // [10:00] D3D11_SB_OPCODE_DCL_THREAD_GROUP_SHARED_MEMORY_RAW
  2273. // [23:11] Ignored, 0
  2274. // [30:24] Instruction length in DWORDs including the opcode token.
  2275. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD
  2276. // contains extended operand description. This dcl is currently not
  2277. // extended.
  2278. //
  2279. // OpcodeToken0 is followed by 2 operands:
  2280. // (1) an operand, starting with OperandToken0, defining which
  2281. // g# register (D3D11_SB_OPERAND_TYPE_THREAD_GROUP_SHARED_MEMORY) is being declared.
  2282. // (2) a DWORD indicating the byte count, which must be a multiple of 4.
  2283. //
  2284. // ----------------------------------------------------------------------------
  2285. // ----------------------------------------------------------------------------
  2286. // Structured Thread Group Shared Memory Declaration
  2287. //
  2288. // OpcodeToken0:
  2289. //
  2290. // [10:00] D3D11_SB_OPCODE_DCL_THREAD_GROUP_SHARED_MEMORY_STRUCTURED
  2291. // [23:11] Ignored, 0
  2292. // [30:24] Instruction length in DWORDs including the opcode token.
  2293. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD
  2294. // contains extended operand description. This dcl is currently not
  2295. // extended.
  2296. //
  2297. // OpcodeToken0 is followed by 3 operands:
  2298. // (1) an operand, starting with OperandToken0, defining which
  2299. // g# register (D3D11_SB_OPERAND_TYPE_THREAD_GROUP_SHARED_MEMORY) is
  2300. // being declared.
  2301. // (2) a DWORD indicating UINT32 struct byte stride
  2302. // (3) a DWORD indicating UINT32 struct count
  2303. //
  2304. // ----------------------------------------------------------------------------
  2305. // ----------------------------------------------------------------------------
  2306. // Raw Shader Resource View Declaration
  2307. //
  2308. // OpcodeToken0:
  2309. //
  2310. // [10:00] D3D11_SB_OPCODE_DCL_RESOURCE_RAW
  2311. // [23:11] Ignored, 0
  2312. // [30:24] Instruction length in DWORDs including the opcode token.
  2313. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD
  2314. // contains extended operand description. This dcl is currently not
  2315. // extended.
  2316. //
  2317. // OpcodeToken0 is followed by 1 operand:
  2318. // (1) an operand, starting with OperandToken0, defining which
  2319. // t# register (D3D10_SB_OPERAND_TYPE_RESOURCE) is being declared.
  2320. //
  2321. // OpcodeToken0 is followed by 2 operands on Shader Model 5.1 and later:
  2322. // (1) an operand, starting with OperandToken0, defining which
  2323. // t# register (D3D10_SB_OPERAND_TYPE_RESOURCE) is being declared.
  2324. // The indexing dimension for the register must be D3D10_SB_OPERAND_INDEX_DIMENSION_3D,
  2325. // and the meaning of the index dimensions are as follows: (t<id>[<lbound>:<ubound>])
  2326. // 1 <id>: variable ID being declared
  2327. // 2 <lbound>: the lower bound of the range of resources in the space
  2328. // 3 <ubound>: the upper bound (inclusive) of this range
  2329. // As opposed to when the t# is used in shader instructions, where the register
  2330. // must be D3D10_SB_OPERAND_INDEX_DIMENSION_2D, and the meaning of the index
  2331. // dimensions are as follows: (t<id>[<idx>]):
  2332. // 1 <id>: variable ID being used (matches dcl)
  2333. // 2 <idx>: absolute index of resource within space (may be dynamically indexed)
  2334. // (2) a DWORD indicating the space index.
  2335. //
  2336. // ----------------------------------------------------------------------------
  2337. // ----------------------------------------------------------------------------
  2338. // Structured Shader Resource View Declaration
  2339. //
  2340. // OpcodeToken0:
  2341. //
  2342. // [10:00] D3D11_SB_OPCODE_DCL_RESOURCE_STRUCTURED
  2343. // [23:11] Ignored, 0
  2344. // [30:24] Instruction length in DWORDs including the opcode token.
  2345. // [31] 0 normally. 1 if extended operand definition, meaning next DWORD
  2346. // contains extended operand description. This dcl is currently not
  2347. // extended.
  2348. //
  2349. // OpcodeToken0 is followed by 2 operands:
  2350. // (1) an operand, starting with OperandToken0, defining which
  2351. // g# register (D3D10_SB_OPERAND_TYPE_RESOURCE) is
  2352. // being declared.
  2353. // (2) a DWORD indicating UINT32 struct byte stride
  2354. //
  2355. // OpcodeToken0 is followed by 3 operands on Shader Model 5.1 and later:
  2356. // (1) an operand, starting with OperandToken0, defining which
  2357. // t# register (D3D10_SB_OPERAND_TYPE_RESOURCE) is being declared.
  2358. // The indexing dimension for the register must be D3D10_SB_OPERAND_INDEX_DIMENSION_3D,
  2359. // and the meaning of the index dimensions are as follows: (t<id>[<lbound>:<ubound>])
  2360. // 1 <id>: variable ID being declared
  2361. // 2 <lbound>: the lower bound of the range of resources in the space
  2362. // 3 <ubound>: the upper bound (inclusive) of this range
  2363. // As opposed to when the t# is used in shader instructions, where the register
  2364. // must be D3D10_SB_OPERAND_INDEX_DIMENSION_2D, and the meaning of the index
  2365. // dimensions are as follows: (t<id>[<idx>]):
  2366. // 1 <id>: variable ID being used (matches dcl)
  2367. // 2 <idx>: absolute index of resource within space (may be dynamically indexed)
  2368. // (2) a DWORD indicating UINT32 struct byte stride
  2369. // (3) a DWORD indicating the space index.
  2370. //
  2371. // ----------------------------------------------------------------------------
  2372. #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_GAMES) */
  2373. #pragma endregion