EffectBinaryFormat.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679
  1. //--------------------------------------------------------------------------------------
  2. // File: EffectBinaryFormat.h
  3. //
  4. // Direct3D11 Effects Binary Format
  5. // This is the binary file interface shared between the Effects
  6. // compiler and runtime.
  7. //
  8. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
  9. // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
  10. // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  11. // PARTICULAR PURPOSE.
  12. //
  13. // Copyright (c) Microsoft Corporation. All rights reserved.
  14. //
  15. // http://go.microsoft.com/fwlink/p/?LinkId=271568
  16. //--------------------------------------------------------------------------------------
  17. #pragma once
  18. namespace D3DX11Effects
  19. {
  20. //////////////////////////////////////////////////////////////////////////
  21. // Version Control
  22. //////////////////////////////////////////////////////////////////////////
  23. #define D3DX11_FXL_VERSION(_Major,_Minor) (('F' << 24) | ('X' << 16) | ((_Major) << 8) | (_Minor))
  24. struct EVersionTag
  25. {
  26. const char* m_pName;
  27. DWORD m_Version;
  28. uint32_t m_Tag;
  29. };
  30. // versions must be listed in ascending order
  31. static const EVersionTag g_EffectVersions[] =
  32. {
  33. { "fx_4_0", D3DX11_FXL_VERSION(4,0), 0xFEFF1001 },
  34. { "fx_4_1", D3DX11_FXL_VERSION(4,1), 0xFEFF1011 },
  35. { "fx_5_0", D3DX11_FXL_VERSION(5,0), 0xFEFF2001 },
  36. };
  37. //////////////////////////////////////////////////////////////////////////
  38. // Reflection & Type structures
  39. //////////////////////////////////////////////////////////////////////////
  40. // Enumeration of the possible left-hand side values of an assignment,
  41. // divided up categorically by the type of block they may appear in
  42. enum ELhsType
  43. {
  44. ELHS_Invalid,
  45. // Pass block assignment types
  46. ELHS_PixelShaderBlock, // SBlock *pValue points to the block to apply
  47. ELHS_VertexShaderBlock,
  48. ELHS_GeometryShaderBlock,
  49. ELHS_RenderTargetView,
  50. ELHS_DepthStencilView,
  51. ELHS_RasterizerBlock,
  52. ELHS_DepthStencilBlock,
  53. ELHS_BlendBlock,
  54. ELHS_GenerateMips, // This is really a call to D3D::GenerateMips
  55. // Various SAssignment.Value.*
  56. ELHS_DS_StencilRef, // SAssignment.Value.pdValue
  57. ELHS_B_BlendFactor, // D3D11_BLEND_CONFIG.BlendFactor, points to a float4
  58. ELHS_B_SampleMask, // D3D11_BLEND_CONFIG.SampleMask
  59. ELHS_GeometryShaderSO, // When setting SO assignments, GeometryShaderSO precedes the actual GeometryShader assn
  60. ELHS_ComputeShaderBlock,
  61. ELHS_HullShaderBlock,
  62. ELHS_DomainShaderBlock,
  63. // Rasterizer
  64. ELHS_FillMode = 0x20000,
  65. ELHS_CullMode,
  66. ELHS_FrontCC,
  67. ELHS_DepthBias,
  68. ELHS_DepthBiasClamp,
  69. ELHS_SlopeScaledDepthBias,
  70. ELHS_DepthClipEnable,
  71. ELHS_ScissorEnable,
  72. ELHS_MultisampleEnable,
  73. ELHS_AntialiasedLineEnable,
  74. // Sampler
  75. ELHS_Filter = 0x30000,
  76. ELHS_AddressU,
  77. ELHS_AddressV,
  78. ELHS_AddressW,
  79. ELHS_MipLODBias,
  80. ELHS_MaxAnisotropy,
  81. ELHS_ComparisonFunc,
  82. ELHS_BorderColor,
  83. ELHS_MinLOD,
  84. ELHS_MaxLOD,
  85. ELHS_Texture,
  86. // DepthStencil
  87. ELHS_DepthEnable = 0x40000,
  88. ELHS_DepthWriteMask,
  89. ELHS_DepthFunc,
  90. ELHS_StencilEnable,
  91. ELHS_StencilReadMask,
  92. ELHS_StencilWriteMask,
  93. ELHS_FrontFaceStencilFailOp,
  94. ELHS_FrontFaceStencilDepthFailOp,
  95. ELHS_FrontFaceStencilPassOp,
  96. ELHS_FrontFaceStencilFunc,
  97. ELHS_BackFaceStencilFailOp,
  98. ELHS_BackFaceStencilDepthFailOp,
  99. ELHS_BackFaceStencilPassOp,
  100. ELHS_BackFaceStencilFunc,
  101. // BlendState
  102. ELHS_AlphaToCoverage = 0x50000,
  103. ELHS_BlendEnable,
  104. ELHS_SrcBlend,
  105. ELHS_DestBlend,
  106. ELHS_BlendOp,
  107. ELHS_SrcBlendAlpha,
  108. ELHS_DestBlendAlpha,
  109. ELHS_BlendOpAlpha,
  110. ELHS_RenderTargetWriteMask,
  111. };
  112. enum EBlockType
  113. {
  114. EBT_Invalid,
  115. EBT_DepthStencil,
  116. EBT_Blend,
  117. EBT_Rasterizer,
  118. EBT_Sampler,
  119. EBT_Pass
  120. };
  121. enum EVarType
  122. {
  123. EVT_Invalid,
  124. EVT_Numeric,
  125. EVT_Object,
  126. EVT_Struct,
  127. EVT_Interface,
  128. };
  129. enum EScalarType
  130. {
  131. EST_Invalid,
  132. EST_Float,
  133. EST_Int,
  134. EST_UInt,
  135. EST_Bool,
  136. EST_Count
  137. };
  138. enum ENumericLayout
  139. {
  140. ENL_Invalid,
  141. ENL_Scalar,
  142. ENL_Vector,
  143. ENL_Matrix,
  144. ENL_Count
  145. };
  146. enum EObjectType
  147. {
  148. EOT_Invalid,
  149. EOT_String,
  150. EOT_Blend,
  151. EOT_DepthStencil,
  152. EOT_Rasterizer,
  153. EOT_PixelShader,
  154. EOT_VertexShader,
  155. EOT_GeometryShader, // Regular geometry shader
  156. EOT_GeometryShaderSO, // Geometry shader with a attached StreamOut decl
  157. EOT_Texture,
  158. EOT_Texture1D,
  159. EOT_Texture1DArray,
  160. EOT_Texture2D,
  161. EOT_Texture2DArray,
  162. EOT_Texture2DMS,
  163. EOT_Texture2DMSArray,
  164. EOT_Texture3D,
  165. EOT_TextureCube,
  166. EOT_ConstantBuffer,
  167. EOT_RenderTargetView,
  168. EOT_DepthStencilView,
  169. EOT_Sampler,
  170. EOT_Buffer,
  171. EOT_TextureCubeArray,
  172. EOT_Count,
  173. EOT_PixelShader5,
  174. EOT_VertexShader5,
  175. EOT_GeometryShader5,
  176. EOT_ComputeShader5,
  177. EOT_HullShader5,
  178. EOT_DomainShader5,
  179. EOT_RWTexture1D,
  180. EOT_RWTexture1DArray,
  181. EOT_RWTexture2D,
  182. EOT_RWTexture2DArray,
  183. EOT_RWTexture3D,
  184. EOT_RWBuffer,
  185. EOT_ByteAddressBuffer,
  186. EOT_RWByteAddressBuffer,
  187. EOT_StructuredBuffer,
  188. EOT_RWStructuredBuffer,
  189. EOT_RWStructuredBufferAlloc,
  190. EOT_RWStructuredBufferConsume,
  191. EOT_AppendStructuredBuffer,
  192. EOT_ConsumeStructuredBuffer,
  193. };
  194. inline bool IsObjectTypeHelper(EVarType InVarType,
  195. EObjectType InObjType,
  196. EObjectType TargetObjType)
  197. {
  198. return (InVarType == EVT_Object) && (InObjType == TargetObjType);
  199. }
  200. inline bool IsSamplerHelper(EVarType InVarType,
  201. EObjectType InObjType)
  202. {
  203. return (InVarType == EVT_Object) && (InObjType == EOT_Sampler);
  204. }
  205. inline bool IsStateBlockObjectHelper(EVarType InVarType,
  206. EObjectType InObjType)
  207. {
  208. return (InVarType == EVT_Object) && ((InObjType == EOT_Blend) || (InObjType == EOT_DepthStencil) || (InObjType == EOT_Rasterizer) || IsSamplerHelper(InVarType, InObjType));
  209. }
  210. inline bool IsShaderHelper(EVarType InVarType,
  211. EObjectType InObjType)
  212. {
  213. return (InVarType == EVT_Object) && ((InObjType == EOT_VertexShader) ||
  214. (InObjType == EOT_VertexShader5) ||
  215. (InObjType == EOT_HullShader5) ||
  216. (InObjType == EOT_DomainShader5) ||
  217. (InObjType == EOT_ComputeShader5) ||
  218. (InObjType == EOT_GeometryShader) ||
  219. (InObjType == EOT_GeometryShaderSO) ||
  220. (InObjType == EOT_GeometryShader5) ||
  221. (InObjType == EOT_PixelShader) ||
  222. (InObjType == EOT_PixelShader5));
  223. }
  224. inline bool IsShader5Helper(EVarType InVarType,
  225. EObjectType InObjType)
  226. {
  227. return (InVarType == EVT_Object) && ((InObjType == EOT_VertexShader5) ||
  228. (InObjType == EOT_HullShader5) ||
  229. (InObjType == EOT_DomainShader5) ||
  230. (InObjType == EOT_ComputeShader5) ||
  231. (InObjType == EOT_GeometryShader5) ||
  232. (InObjType == EOT_PixelShader5));
  233. }
  234. inline bool IsInterfaceHelper(EVarType InVarType, EObjectType InObjType)
  235. {
  236. UNREFERENCED_PARAMETER(InObjType);
  237. return (InVarType == EVT_Interface);
  238. }
  239. inline bool IsShaderResourceHelper(EVarType InVarType,
  240. EObjectType InObjType)
  241. {
  242. return (InVarType == EVT_Object) && ((InObjType == EOT_Texture) ||
  243. (InObjType == EOT_Texture1D) ||
  244. (InObjType == EOT_Texture1DArray) ||
  245. (InObjType == EOT_Texture2D) ||
  246. (InObjType == EOT_Texture2DArray) ||
  247. (InObjType == EOT_Texture2DMS) ||
  248. (InObjType == EOT_Texture2DMSArray) ||
  249. (InObjType == EOT_Texture3D) ||
  250. (InObjType == EOT_TextureCube) ||
  251. (InObjType == EOT_TextureCubeArray) ||
  252. (InObjType == EOT_Buffer) ||
  253. (InObjType == EOT_StructuredBuffer) ||
  254. (InObjType == EOT_ByteAddressBuffer));
  255. }
  256. inline bool IsUnorderedAccessViewHelper(EVarType InVarType,
  257. EObjectType InObjType)
  258. {
  259. return (InVarType == EVT_Object) &&
  260. ((InObjType == EOT_RWTexture1D) ||
  261. (InObjType == EOT_RWTexture1DArray) ||
  262. (InObjType == EOT_RWTexture2D) ||
  263. (InObjType == EOT_RWTexture2DArray) ||
  264. (InObjType == EOT_RWTexture3D) ||
  265. (InObjType == EOT_RWBuffer) ||
  266. (InObjType == EOT_RWByteAddressBuffer) ||
  267. (InObjType == EOT_RWStructuredBuffer) ||
  268. (InObjType == EOT_RWStructuredBufferAlloc) ||
  269. (InObjType == EOT_RWStructuredBufferConsume) ||
  270. (InObjType == EOT_AppendStructuredBuffer) ||
  271. (InObjType == EOT_ConsumeStructuredBuffer));
  272. }
  273. inline bool IsRenderTargetViewHelper(EVarType InVarType,
  274. EObjectType InObjType)
  275. {
  276. return (InVarType == EVT_Object) && (InObjType == EOT_RenderTargetView);
  277. }
  278. inline bool IsDepthStencilViewHelper(EVarType InVarType,
  279. EObjectType InObjType)
  280. {
  281. return (InVarType == EVT_Object) && (InObjType == EOT_DepthStencilView);
  282. }
  283. inline bool IsObjectAssignmentHelper(ELhsType LhsType)
  284. {
  285. switch(LhsType)
  286. {
  287. case ELHS_VertexShaderBlock:
  288. case ELHS_HullShaderBlock:
  289. case ELHS_DepthStencilView:
  290. case ELHS_GeometryShaderBlock:
  291. case ELHS_PixelShaderBlock:
  292. case ELHS_ComputeShaderBlock:
  293. case ELHS_DepthStencilBlock:
  294. case ELHS_RasterizerBlock:
  295. case ELHS_BlendBlock:
  296. case ELHS_Texture:
  297. case ELHS_RenderTargetView:
  298. case ELHS_DomainShaderBlock:
  299. return true;
  300. }
  301. return false;
  302. }
  303. // Effect file format structures /////////////////////////////////////////////
  304. // File format:
  305. // File header (SBinaryHeader Header)
  306. // Unstructured data block (uint8_t[Header.cbUnstructured))
  307. // Structured data block
  308. // ConstantBuffer (SBinaryConstantBuffer CB) * Header.Effect.cCBs
  309. // uint32_t NumAnnotations
  310. // Annotation data (SBinaryAnnotation) * (NumAnnotations) *this structure is variable sized
  311. // Variable data (SBinaryNumericVariable Var) * (CB.cVariables)
  312. // uint32_t NumAnnotations
  313. // Annotation data (SBinaryAnnotation) * (NumAnnotations) *this structure is variable sized
  314. // Object variables (SBinaryObjectVariable Var) * (Header.cObjectVariables) *this structure is variable sized
  315. // uint32_t NumAnnotations
  316. // Annotation data (SBinaryAnnotation) * (NumAnnotations) *this structure is variable sized
  317. // Interface variables (SBinaryInterfaceVariable Var) * (Header.cInterfaceVariables) *this structure is variable sized
  318. // uint32_t NumAnnotations
  319. // Annotation data (SBinaryAnnotation) * (NumAnnotations) *this structure is variable sized
  320. // Groups (SBinaryGroup Group) * Header.cGroups
  321. // uint32_t NumAnnotations
  322. // Annotation data (SBinaryAnnotation) * (NumAnnotations) *this structure is variable sized
  323. // Techniques (SBinaryTechnique Technique) * Group.cTechniques
  324. // uint32_t NumAnnotations
  325. // Annotation data (SBinaryAnnotation) * (NumAnnotations) *this structure is variable sized
  326. // Pass (SBinaryPass Pass) * Technique.cPasses
  327. // uint32_t NumAnnotations
  328. // Annotation data (SBinaryAnnotation) * (NumAnnotations) *this structure is variable sized
  329. // Pass assignments (SBinaryAssignment) * Pass.cAssignments
  330. struct SBinaryHeader
  331. {
  332. struct SVarCounts
  333. {
  334. uint32_t cCBs;
  335. uint32_t cNumericVariables;
  336. uint32_t cObjectVariables;
  337. };
  338. uint32_t Tag; // should be equal to c_EffectFileTag
  339. // this is used to identify ASCII vs Binary files
  340. SVarCounts Effect;
  341. SVarCounts Pool;
  342. uint32_t cTechniques;
  343. uint32_t cbUnstructured;
  344. uint32_t cStrings;
  345. uint32_t cShaderResources;
  346. uint32_t cDepthStencilBlocks;
  347. uint32_t cBlendStateBlocks;
  348. uint32_t cRasterizerStateBlocks;
  349. uint32_t cSamplers;
  350. uint32_t cRenderTargetViews;
  351. uint32_t cDepthStencilViews;
  352. uint32_t cTotalShaders;
  353. uint32_t cInlineShaders; // of the aforementioned shaders, the number that are defined inline within pass blocks
  354. inline bool RequiresPool() const
  355. {
  356. return (Pool.cCBs != 0) ||
  357. (Pool.cNumericVariables != 0) ||
  358. (Pool.cObjectVariables != 0);
  359. }
  360. };
  361. struct SBinaryHeader5 : public SBinaryHeader
  362. {
  363. uint32_t cGroups;
  364. uint32_t cUnorderedAccessViews;
  365. uint32_t cInterfaceVariables;
  366. uint32_t cInterfaceVariableElements;
  367. uint32_t cClassInstanceElements;
  368. };
  369. // Constant buffer definition
  370. struct SBinaryConstantBuffer
  371. {
  372. // private flags
  373. static const uint32_t c_IsTBuffer = (1 << 0);
  374. static const uint32_t c_IsSingle = (1 << 1);
  375. uint32_t oName; // Offset to constant buffer name
  376. uint32_t Size; // Size, in bytes
  377. uint32_t Flags;
  378. uint32_t cVariables; // # of variables inside this buffer
  379. uint32_t ExplicitBindPoint; // Defined if the effect file specifies a bind point using the register keyword
  380. // otherwise, -1
  381. };
  382. struct SBinaryAnnotation
  383. {
  384. uint32_t oName; // Offset to variable name
  385. uint32_t oType; // Offset to type information (SBinaryType)
  386. // For numeric annotations:
  387. // uint32_t oDefaultValue; // Offset to default initializer value
  388. //
  389. // For string annotations:
  390. // uint32_t oStringOffsets[Elements]; // Elements comes from the type data at oType
  391. };
  392. struct SBinaryNumericVariable
  393. {
  394. uint32_t oName; // Offset to variable name
  395. uint32_t oType; // Offset to type information (SBinaryType)
  396. uint32_t oSemantic; // Offset to semantic information
  397. uint32_t Offset; // Offset in parent constant buffer
  398. uint32_t oDefaultValue; // Offset to default initializer value
  399. uint32_t Flags; // Explicit bind point
  400. };
  401. struct SBinaryInterfaceVariable
  402. {
  403. uint32_t oName; // Offset to variable name
  404. uint32_t oType; // Offset to type information (SBinaryType)
  405. uint32_t oDefaultValue; // Offset to default initializer array (SBinaryInterfaceInitializer[Elements])
  406. uint32_t Flags;
  407. };
  408. struct SBinaryInterfaceInitializer
  409. {
  410. uint32_t oInstanceName;
  411. uint32_t ArrayIndex;
  412. };
  413. struct SBinaryObjectVariable
  414. {
  415. uint32_t oName; // Offset to variable name
  416. uint32_t oType; // Offset to type information (SBinaryType)
  417. uint32_t oSemantic; // Offset to semantic information
  418. uint32_t ExplicitBindPoint; // Used when a variable has been explicitly bound (register(XX)). -1 if not
  419. // Initializer data:
  420. //
  421. // The type structure pointed to by oType gives you Elements,
  422. // VarType (must be EVT_Object), and ObjectType
  423. //
  424. // For ObjectType == EOT_Blend, EOT_DepthStencil, EOT_Rasterizer, EOT_Sampler
  425. // struct
  426. // {
  427. // uint32_t cAssignments;
  428. // SBinaryAssignment Assignments[cAssignments];
  429. // } Blocks[Elements]
  430. //
  431. // For EObjectType == EOT_Texture*, EOT_Buffer
  432. // <nothing>
  433. //
  434. // For EObjectType == EOT_*Shader, EOT_String
  435. // uint32_t oData[Elements]; // offsets to a shader data block or a nullptr-terminated string
  436. //
  437. // For EObjectType == EOT_GeometryShaderSO
  438. // SBinaryGSSOInitializer[Elements]
  439. //
  440. // For EObjectType == EOT_*Shader5
  441. // SBinaryShaderData5[Elements]
  442. };
  443. struct SBinaryGSSOInitializer
  444. {
  445. uint32_t oShader; // Offset to shader bytecode data block
  446. uint32_t oSODecl; // Offset to StreamOutput decl string
  447. };
  448. struct SBinaryShaderData5
  449. {
  450. uint32_t oShader; // Offset to shader bytecode data block
  451. uint32_t oSODecls[4]; // Offset to StreamOutput decl strings
  452. uint32_t cSODecls; // Count of valid oSODecls entries.
  453. uint32_t RasterizedStream; // Which stream is used for rasterization
  454. uint32_t cInterfaceBindings; // Count of interface bindings.
  455. uint32_t oInterfaceBindings; // Offset to SBinaryInterfaceInitializer[cInterfaceBindings].
  456. };
  457. struct SBinaryType
  458. {
  459. uint32_t oTypeName; // Offset to friendly type name ("float4", "VS_OUTPUT")
  460. EVarType VarType; // Numeric, Object, or Struct
  461. uint32_t Elements; // # of array elements (0 for non-arrays)
  462. uint32_t TotalSize; // Size in bytes; not necessarily Stride * Elements for arrays
  463. // because of possible gap left in final register
  464. uint32_t Stride; // If an array, this is the spacing between elements.
  465. // For unpacked arrays, always divisible by 16-bytes (1 register).
  466. // No support for packed arrays
  467. uint32_t PackedSize; // Size, in bytes, of this data typed when fully packed
  468. struct SBinaryMember
  469. {
  470. uint32_t oName; // Offset to structure member name ("m_pFoo")
  471. uint32_t oSemantic; // Offset to semantic ("POSITION0")
  472. uint32_t Offset; // Offset, in bytes, relative to start of parent structure
  473. uint32_t oType; // Offset to member's type descriptor
  474. };
  475. // the data that follows depends on the VarType:
  476. // Numeric: SType::SNumericType
  477. // Object: EObjectType
  478. // Struct:
  479. // struct
  480. // {
  481. // uint32_t cMembers;
  482. // SBinaryMembers Members[cMembers];
  483. // } MemberInfo
  484. // struct
  485. // {
  486. // uint32_t oBaseClassType; // Offset to type information (SBinaryType)
  487. // uint32_t cInterfaces;
  488. // uint32_t oInterfaceTypes[cInterfaces];
  489. // } SBinaryTypeInheritance
  490. // Interface: (nothing)
  491. };
  492. struct SBinaryNumericType
  493. {
  494. ENumericLayout NumericLayout : 3; // scalar (1x1), vector (1xN), matrix (NxN)
  495. EScalarType ScalarType : 5; // float32, int32, int8, etc.
  496. uint32_t Rows : 3; // 1 <= Rows <= 4
  497. uint32_t Columns : 3; // 1 <= Columns <= 4
  498. uint32_t IsColumnMajor : 1; // applies only to matrices
  499. uint32_t IsPackedArray : 1; // if this is an array, indicates whether elements should be greedily packed
  500. };
  501. struct SBinaryTypeInheritance
  502. {
  503. uint32_t oBaseClass; // Offset to base class type info or 0 if no base class.
  504. uint32_t cInterfaces;
  505. // Followed by uint32_t[cInterfaces] with offsets to the type
  506. // info of each interface.
  507. };
  508. struct SBinaryGroup
  509. {
  510. uint32_t oName;
  511. uint32_t cTechniques;
  512. };
  513. struct SBinaryTechnique
  514. {
  515. uint32_t oName;
  516. uint32_t cPasses;
  517. };
  518. struct SBinaryPass
  519. {
  520. uint32_t oName;
  521. uint32_t cAssignments;
  522. };
  523. enum ECompilerAssignmentType
  524. {
  525. ECAT_Invalid, // Assignment-specific data (always in the unstructured blob)
  526. ECAT_Constant, // -N SConstant structures
  527. ECAT_Variable, // -nullptr terminated string with variable name ("foo")
  528. ECAT_ConstIndex, // -SConstantIndex structure
  529. ECAT_VariableIndex, // -SVariableIndex structure
  530. ECAT_ExpressionIndex, // -SIndexedObjectExpression structure
  531. ECAT_Expression, // -Data block containing FXLVM code
  532. ECAT_InlineShader, // -Data block containing shader
  533. ECAT_InlineShader5, // -Data block containing shader with extended 5.0 data (SBinaryShaderData5)
  534. };
  535. struct SBinaryAssignment
  536. {
  537. uint32_t iState; // index into g_lvGeneral
  538. uint32_t Index; // the particular index to assign to (see g_lvGeneral to find the # of valid indices)
  539. ECompilerAssignmentType AssignmentType;
  540. uint32_t oInitializer; // Offset of assignment-specific data
  541. struct SConstantIndex
  542. {
  543. uint32_t oArrayName;
  544. uint32_t Index;
  545. };
  546. struct SVariableIndex
  547. {
  548. uint32_t oArrayName;
  549. uint32_t oIndexVarName;
  550. };
  551. struct SIndexedObjectExpression
  552. {
  553. uint32_t oArrayName;
  554. uint32_t oCode;
  555. };
  556. struct SInlineShader
  557. {
  558. uint32_t oShader;
  559. uint32_t oSODecl;
  560. };
  561. };
  562. struct SBinaryConstant
  563. {
  564. EScalarType Type;
  565. union
  566. {
  567. BOOL bValue;
  568. INT iValue;
  569. float fValue;
  570. };
  571. };
  572. static_assert( sizeof(SBinaryHeader) == 76, "FX11 binary size mismatch" );
  573. static_assert( sizeof(SBinaryHeader::SVarCounts) == 12, "FX11 binary size mismatch" );
  574. static_assert( sizeof(SBinaryHeader5) == 96, "FX11 binary size mismatch" );
  575. static_assert( sizeof(SBinaryConstantBuffer) == 20, "FX11 binary size mismatch" );
  576. static_assert( sizeof(SBinaryAnnotation) == 8, "FX11 binary size mismatch" );
  577. static_assert( sizeof(SBinaryNumericVariable) == 24, "FX11 binary size mismatch" );
  578. static_assert( sizeof(SBinaryInterfaceVariable) == 16, "FX11 binary size mismatch" );
  579. static_assert( sizeof(SBinaryInterfaceInitializer) == 8, "FX11 binary size mismatch" );
  580. static_assert( sizeof(SBinaryObjectVariable) == 16, "FX11 binary size mismatch" );
  581. static_assert( sizeof(SBinaryGSSOInitializer) == 8, "FX11 binary size mismatch" );
  582. static_assert( sizeof(SBinaryShaderData5) == 36, "FX11 binary size mismatch" );
  583. static_assert( sizeof(SBinaryType) == 24, "FX11 binary size mismatch" );
  584. static_assert( sizeof(SBinaryType::SBinaryMember) == 16, "FX11 binary size mismatch" );
  585. static_assert( sizeof(SBinaryNumericType) == 4, "FX11 binary size mismatch" );
  586. static_assert( sizeof(SBinaryTypeInheritance) == 8, "FX11 binary size mismatch" );
  587. static_assert( sizeof(SBinaryGroup) == 8, "FX11 binary size mismatch" );
  588. static_assert( sizeof(SBinaryTechnique) == 8, "FX11 binary size mismatch" );
  589. static_assert( sizeof(SBinaryPass) == 8, "FX11 binary size mismatch" );
  590. static_assert( sizeof(SBinaryAssignment) == 16, "FX11 binary size mismatch" );
  591. static_assert( sizeof(SBinaryAssignment::SConstantIndex) == 8, "FX11 binary size mismatch" );
  592. static_assert( sizeof(SBinaryAssignment::SVariableIndex) == 8, "FX11 binary size mismatch" );
  593. static_assert( sizeof(SBinaryAssignment::SIndexedObjectExpression) == 8, "FX11 binary size mismatch" );
  594. static_assert( sizeof(SBinaryAssignment::SInlineShader) == 8, "FX11 binary size mismatch" );
  595. } // end namespace D3DX11Effects