Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

733 lines
30 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) Microsoft Corporation. All rights reserved.
  4. //
  5. // File: D3D10Shader.h
  6. // Content: D3D10 Shader Types and APIs
  7. //
  8. //////////////////////////////////////////////////////////////////////////////
  9. #ifndef __D3D10SHADER_H__
  10. #define __D3D10SHADER_H__
  11. #include "d3d10.h"
  12. //---------------------------------------------------------------------------
  13. // D3D10_TX_VERSION:
  14. // --------------
  15. // Version token used to create a procedural texture filler in effects
  16. // Used by D3D10Fill[]TX functions
  17. //---------------------------------------------------------------------------
  18. #define D3D10_TX_VERSION(_Major,_Minor) (('T' << 24) | ('X' << 16) | ((_Major) << 8) | (_Minor))
  19. //----------------------------------------------------------------------------
  20. // D3D10SHADER flags:
  21. // -----------------
  22. // D3D10_SHADER_DEBUG
  23. // Insert debug file/line/type/symbol information.
  24. //
  25. // D3D10_SHADER_SKIP_VALIDATION
  26. // Do not validate the generated code against known capabilities and
  27. // constraints. This option is only recommended when compiling shaders
  28. // you KNOW will work. (ie. have compiled before without this option.)
  29. // Shaders are always validated by D3D before they are set to the device.
  30. //
  31. // D3D10_SHADER_SKIP_OPTIMIZATION
  32. // Instructs the compiler to skip optimization steps during code generation.
  33. // Unless you are trying to isolate a problem in your code using this option
  34. // is not recommended.
  35. //
  36. // D3D10_SHADER_PACK_MATRIX_ROW_MAJOR
  37. // Unless explicitly specified, matrices will be packed in row-major order
  38. // on input and output from the shader.
  39. //
  40. // D3D10_SHADER_PACK_MATRIX_COLUMN_MAJOR
  41. // Unless explicitly specified, matrices will be packed in column-major
  42. // order on input and output from the shader. This is generally more
  43. // efficient, since it allows vector-matrix multiplication to be performed
  44. // using a series of dot-products.
  45. //
  46. // D3D10_SHADER_PARTIAL_PRECISION
  47. // Force all computations in resulting shader to occur at partial precision.
  48. // This may result in faster evaluation of shaders on some hardware.
  49. //
  50. // D3D10_SHADER_FORCE_VS_SOFTWARE_NO_OPT
  51. // Force compiler to compile against the next highest available software
  52. // target for vertex shaders. This flag also turns optimizations off,
  53. // and debugging on.
  54. //
  55. // D3D10_SHADER_FORCE_PS_SOFTWARE_NO_OPT
  56. // Force compiler to compile against the next highest available software
  57. // target for pixel shaders. This flag also turns optimizations off,
  58. // and debugging on.
  59. //
  60. // D3D10_SHADER_NO_PRESHADER
  61. // Disables Preshaders. Using this flag will cause the compiler to not
  62. // pull out static expression for evaluation on the host cpu
  63. //
  64. // D3D10_SHADER_AVOID_FLOW_CONTROL
  65. // Hint compiler to avoid flow-control constructs where possible.
  66. //
  67. // D3D10_SHADER_PREFER_FLOW_CONTROL
  68. // Hint compiler to prefer flow-control constructs where possible.
  69. //
  70. // D3D10_SHADER_ENABLE_STRICTNESS
  71. // By default, the HLSL/Effect compilers are not strict on deprecated syntax.
  72. // Specifying this flag enables the strict mode. Deprecated syntax may be
  73. // removed in a future release, and enabling syntax is a good way to make sure
  74. // your shaders comply to the latest spec.
  75. //
  76. // D3D10_SHADER_ENABLE_BACKWARDS_COMPATIBILITY
  77. // This enables older shaders to compile to 4_0 targets.
  78. //
  79. //----------------------------------------------------------------------------
  80. #define D3D10_SHADER_DEBUG (1 << 0)
  81. #define D3D10_SHADER_SKIP_VALIDATION (1 << 1)
  82. #define D3D10_SHADER_SKIP_OPTIMIZATION (1 << 2)
  83. #define D3D10_SHADER_PACK_MATRIX_ROW_MAJOR (1 << 3)
  84. #define D3D10_SHADER_PACK_MATRIX_COLUMN_MAJOR (1 << 4)
  85. #define D3D10_SHADER_PARTIAL_PRECISION (1 << 5)
  86. #define D3D10_SHADER_FORCE_VS_SOFTWARE_NO_OPT (1 << 6)
  87. #define D3D10_SHADER_FORCE_PS_SOFTWARE_NO_OPT (1 << 7)
  88. #define D3D10_SHADER_NO_PRESHADER (1 << 8)
  89. #define D3D10_SHADER_AVOID_FLOW_CONTROL (1 << 9)
  90. #define D3D10_SHADER_PREFER_FLOW_CONTROL (1 << 10)
  91. #define D3D10_SHADER_ENABLE_STRICTNESS (1 << 11)
  92. #define D3D10_SHADER_ENABLE_BACKWARDS_COMPATIBILITY (1 << 12)
  93. #define D3D10_SHADER_IEEE_STRICTNESS (1 << 13)
  94. // optimization level flags
  95. #define D3D10_SHADER_OPTIMIZATION_LEVEL0 (1 << 14)
  96. #define D3D10_SHADER_OPTIMIZATION_LEVEL1 0
  97. #define D3D10_SHADER_OPTIMIZATION_LEVEL2 ((1 << 14) | (1 << 15))
  98. #define D3D10_SHADER_OPTIMIZATION_LEVEL3 (1 << 15)
  99. //----------------------------------------------------------------------------
  100. // D3D10_SHADER_MACRO:
  101. // ----------
  102. // Preprocessor macro definition. The application pass in a NULL-terminated
  103. // array of this structure to various D3D10 APIs. This enables the application
  104. // to #define tokens at runtime, before the file is parsed.
  105. //----------------------------------------------------------------------------
  106. typedef struct _D3D10_SHADER_MACRO
  107. {
  108. LPCSTR Name;
  109. LPCSTR Definition;
  110. } D3D10_SHADER_MACRO, *LPD3D10_SHADER_MACRO;
  111. //----------------------------------------------------------------------------
  112. // D3D10_SHADER_VARIABLE_CLASS:
  113. //----------------------------------------------------------------------------
  114. typedef enum _D3D10_SHADER_VARIABLE_CLASS
  115. {
  116. D3D10_SVC_SCALAR,
  117. D3D10_SVC_VECTOR,
  118. D3D10_SVC_MATRIX_ROWS,
  119. D3D10_SVC_MATRIX_COLUMNS,
  120. D3D10_SVC_OBJECT,
  121. D3D10_SVC_STRUCT,
  122. D3D11_SVC_INTERFACE_CLASS,
  123. D3D11_SVC_INTERFACE_POINTER,
  124. // force 32-bit size enum
  125. D3D10_SVC_FORCE_DWORD = 0x7fffffff
  126. } D3D10_SHADER_VARIABLE_CLASS, *LPD3D10_SHADER_VARIABLE_CLASS;
  127. typedef enum _D3D10_SHADER_VARIABLE_FLAGS
  128. {
  129. D3D10_SVF_USERPACKED = 1,
  130. D3D10_SVF_USED = 2,
  131. D3D11_SVF_INTERFACE_POINTER = 4,
  132. // force 32-bit size enum
  133. D3D10_SVF_FORCE_DWORD = 0x7fffffff
  134. } D3D10_SHADER_VARIABLE_FLAGS, *LPD3D10_SHADER_VARIABLE_FLAGS;
  135. //----------------------------------------------------------------------------
  136. // D3D10_SHADER_VARIABLE_TYPE:
  137. //----------------------------------------------------------------------------
  138. typedef enum _D3D10_SHADER_VARIABLE_TYPE
  139. {
  140. D3D10_SVT_VOID = 0,
  141. D3D10_SVT_BOOL = 1,
  142. D3D10_SVT_INT = 2,
  143. D3D10_SVT_FLOAT = 3,
  144. D3D10_SVT_STRING = 4,
  145. D3D10_SVT_TEXTURE = 5,
  146. D3D10_SVT_TEXTURE1D = 6,
  147. D3D10_SVT_TEXTURE2D = 7,
  148. D3D10_SVT_TEXTURE3D = 8,
  149. D3D10_SVT_TEXTURECUBE = 9,
  150. D3D10_SVT_SAMPLER = 10,
  151. D3D10_SVT_PIXELSHADER = 15,
  152. D3D10_SVT_VERTEXSHADER = 16,
  153. D3D10_SVT_UINT = 19,
  154. D3D10_SVT_UINT8 = 20,
  155. D3D10_SVT_GEOMETRYSHADER = 21,
  156. D3D10_SVT_RASTERIZER = 22,
  157. D3D10_SVT_DEPTHSTENCIL = 23,
  158. D3D10_SVT_BLEND = 24,
  159. D3D10_SVT_BUFFER = 25,
  160. D3D10_SVT_CBUFFER = 26,
  161. D3D10_SVT_TBUFFER = 27,
  162. D3D10_SVT_TEXTURE1DARRAY = 28,
  163. D3D10_SVT_TEXTURE2DARRAY = 29,
  164. D3D10_SVT_RENDERTARGETVIEW = 30,
  165. D3D10_SVT_DEPTHSTENCILVIEW = 31,
  166. D3D10_SVT_TEXTURE2DMS = 32,
  167. D3D10_SVT_TEXTURE2DMSARRAY = 33,
  168. D3D10_SVT_TEXTURECUBEARRAY = 34,
  169. D3D11_SVT_HULLSHADER = 35,
  170. D3D11_SVT_DOMAINSHADER = 36,
  171. D3D11_SVT_INTERFACE_POINTER = 37,
  172. D3D11_SVT_COMPUTESHADER = 38,
  173. D3D11_SVT_DOUBLE = 39,
  174. // force 32-bit size enum
  175. D3D10_SVT_FORCE_DWORD = 0x7fffffff
  176. } D3D10_SHADER_VARIABLE_TYPE, *LPD3D10_SHADER_VARIABLE_TYPE;
  177. typedef enum _D3D10_SHADER_INPUT_FLAGS
  178. {
  179. D3D10_SIF_USERPACKED = 1,
  180. D3D10_SIF_COMPARISON_SAMPLER = 2, // is this a comparison sampler?
  181. D3D10_SIF_TEXTURE_COMPONENT_0 = 4, // this 2-bit value encodes c - 1, where c
  182. D3D10_SIF_TEXTURE_COMPONENT_1 = 8, // is the number of components in the texture
  183. D3D10_SIF_TEXTURE_COMPONENTS = 12,
  184. // force 32-bit size enum
  185. D3D10_SIF_FORCE_DWORD = 0x7fffffff
  186. } D3D10_SHADER_INPUT_FLAGS, *LPD3D10_SHADER_INPUT_FLAGS;
  187. //----------------------------------------------------------------------------
  188. // D3D10_SHADER_INPUT_TYPE
  189. //----------------------------------------------------------------------------
  190. typedef enum _D3D10_SHADER_INPUT_TYPE
  191. {
  192. D3D10_SIT_CBUFFER,
  193. D3D10_SIT_TBUFFER,
  194. D3D10_SIT_TEXTURE,
  195. D3D10_SIT_SAMPLER,
  196. D3D11_SIT_UAV_RWTYPED,
  197. D3D11_SIT_STRUCTURED,
  198. D3D11_SIT_UAV_RWSTRUCTURED,
  199. D3D11_SIT_BYTEADDRESS,
  200. D3D11_SIT_UAV_RWBYTEADDRESS,
  201. D3D11_SIT_UAV_APPEND_BYTEADDRESS,
  202. D3D11_SIT_UAV_CONSUME_BYTEADDRESS,
  203. D3D11_SIT_UAV_APPEND_STRUCTURED,
  204. D3D11_SIT_UAV_CONSUME_STRUCTURED,
  205. } D3D10_SHADER_INPUT_TYPE, *LPD3D10_SHADER_INPUT_TYPE;
  206. typedef enum _D3D10_SHADER_CBUFFER_FLAGS
  207. {
  208. D3D10_CBF_USERPACKED = 1,
  209. // force 32-bit size enum
  210. D3D10_CBF_FORCE_DWORD = 0x7fffffff
  211. } D3D10_SHADER_CBUFFER_FLAGS, *LPD3D10_SHADER_CBUFFER_FLAGS;
  212. typedef enum _D3D10_CBUFFER_TYPE
  213. {
  214. D3D10_CT_CBUFFER,
  215. D3D10_CT_TBUFFER,
  216. } D3D10_CBUFFER_TYPE, *LPD3D10_CBUFFER_TYPE;
  217. typedef enum D3D10_NAME
  218. {
  219. D3D10_NAME_UNDEFINED = 0,
  220. // Names meaningful to both HLSL and hardware
  221. D3D10_NAME_POSITION = 1,
  222. D3D10_NAME_CLIP_DISTANCE = 2,
  223. D3D10_NAME_CULL_DISTANCE = 3,
  224. D3D10_NAME_RENDER_TARGET_ARRAY_INDEX = 4,
  225. D3D10_NAME_VIEWPORT_ARRAY_INDEX = 5,
  226. D3D10_NAME_VERTEX_ID = 6,
  227. D3D10_NAME_PRIMITIVE_ID = 7,
  228. D3D10_NAME_INSTANCE_ID = 8,
  229. D3D10_NAME_IS_FRONT_FACE = 9,
  230. D3D10_NAME_SAMPLE_INDEX = 10,
  231. D3D11_NAME_FINAL_QUAD_EDGE_TESSFACTOR = 11,
  232. D3D11_NAME_FINAL_QUAD_INSIDE_TESSFACTOR = 12,
  233. D3D11_NAME_FINAL_TRI_EDGE_TESSFACTOR = 13,
  234. D3D11_NAME_FINAL_TRI_INSIDE_TESSFACTOR = 14,
  235. D3D11_NAME_FINAL_LINE_DETAIL_TESSFACTOR = 15,
  236. D3D11_NAME_FINAL_LINE_DENSITY_TESSFACTOR = 16,
  237. // Names meaningful to HLSL only
  238. D3D10_NAME_TARGET = 64,
  239. D3D10_NAME_DEPTH = 65,
  240. D3D10_NAME_COVERAGE = 66,
  241. D3D11_NAME_DEPTH_GREATER_EQUAL = 67,
  242. D3D11_NAME_DEPTH_LESS_EQUAL = 68,
  243. } D3D10_NAME;
  244. typedef enum D3D10_RESOURCE_RETURN_TYPE
  245. {
  246. D3D10_RETURN_TYPE_UNORM = 1,
  247. D3D10_RETURN_TYPE_SNORM = 2,
  248. D3D10_RETURN_TYPE_SINT = 3,
  249. D3D10_RETURN_TYPE_UINT = 4,
  250. D3D10_RETURN_TYPE_FLOAT = 5,
  251. D3D10_RETURN_TYPE_MIXED = 6,
  252. } D3D10_RESOURCE_RETURN_TYPE;
  253. typedef enum D3D10_REGISTER_COMPONENT_TYPE
  254. {
  255. D3D10_REGISTER_COMPONENT_UNKNOWN = 0,
  256. D3D10_REGISTER_COMPONENT_UINT32 = 1,
  257. D3D10_REGISTER_COMPONENT_SINT32 = 2,
  258. D3D10_REGISTER_COMPONENT_FLOAT32 = 3
  259. } D3D10_REGISTER_COMPONENT_TYPE;
  260. //----------------------------------------------------------------------------
  261. // D3D10_INCLUDE_TYPE:
  262. //----------------------------------------------------------------------------
  263. typedef enum _D3D10_INCLUDE_TYPE
  264. {
  265. D3D10_INCLUDE_LOCAL,
  266. D3D10_INCLUDE_SYSTEM,
  267. // force 32-bit size enum
  268. D3D10_INCLUDE_FORCE_DWORD = 0x7fffffff
  269. } D3D10_INCLUDE_TYPE, *LPD3D10_INCLUDE_TYPE;
  270. //----------------------------------------------------------------------------
  271. // ID3D10Include:
  272. // -------------
  273. // This interface is intended to be implemented by the application, and can
  274. // be used by various D3D10 APIs. This enables application-specific handling
  275. // of #include directives in source files.
  276. //
  277. // Open()
  278. // Opens an include file. If successful, it should fill in ppData and
  279. // pBytes. The data pointer returned must remain valid until Close is
  280. // subsequently called. The name of the file is encoded in UTF-8 format.
  281. // Close()
  282. // Closes an include file. If Open was successful, Close is guaranteed
  283. // to be called before the API using this interface returns.
  284. //----------------------------------------------------------------------------
  285. typedef interface ID3D10Include ID3D10Include;
  286. typedef interface ID3D10Include *LPD3D10INCLUDE;
  287. #undef INTERFACE
  288. #define INTERFACE ID3D10Include
  289. DECLARE_INTERFACE(ID3D10Include)
  290. {
  291. STDMETHOD(Open)(THIS_ D3D10_INCLUDE_TYPE IncludeType, LPCSTR pFileName, LPCVOID pParentData, LPCVOID *ppData, UINT *pBytes) PURE;
  292. STDMETHOD(Close)(THIS_ LPCVOID pData) PURE;
  293. };
  294. //----------------------------------------------------------------------------
  295. // ID3D10ShaderReflection:
  296. //----------------------------------------------------------------------------
  297. //
  298. // Structure definitions
  299. //
  300. typedef struct _D3D10_SHADER_DESC
  301. {
  302. UINT Version; // Shader version
  303. LPCSTR Creator; // Creator string
  304. UINT Flags; // Shader compilation/parse flags
  305. UINT ConstantBuffers; // Number of constant buffers
  306. UINT BoundResources; // Number of bound resources
  307. UINT InputParameters; // Number of parameters in the input signature
  308. UINT OutputParameters; // Number of parameters in the output signature
  309. UINT InstructionCount; // Number of emitted instructions
  310. UINT TempRegisterCount; // Number of temporary registers used
  311. UINT TempArrayCount; // Number of temporary arrays used
  312. UINT DefCount; // Number of constant defines
  313. UINT DclCount; // Number of declarations (input + output)
  314. UINT TextureNormalInstructions; // Number of non-categorized texture instructions
  315. UINT TextureLoadInstructions; // Number of texture load instructions
  316. UINT TextureCompInstructions; // Number of texture comparison instructions
  317. UINT TextureBiasInstructions; // Number of texture bias instructions
  318. UINT TextureGradientInstructions; // Number of texture gradient instructions
  319. UINT FloatInstructionCount; // Number of floating point arithmetic instructions used
  320. UINT IntInstructionCount; // Number of signed integer arithmetic instructions used
  321. UINT UintInstructionCount; // Number of unsigned integer arithmetic instructions used
  322. UINT StaticFlowControlCount; // Number of static flow control instructions used
  323. UINT DynamicFlowControlCount; // Number of dynamic flow control instructions used
  324. UINT MacroInstructionCount; // Number of macro instructions used
  325. UINT ArrayInstructionCount; // Number of array instructions used
  326. UINT CutInstructionCount; // Number of cut instructions used
  327. UINT EmitInstructionCount; // Number of emit instructions used
  328. D3D10_PRIMITIVE_TOPOLOGY GSOutputTopology; // Geometry shader output topology
  329. UINT GSMaxOutputVertexCount; // Geometry shader maximum output vertex count
  330. } D3D10_SHADER_DESC;
  331. typedef struct _D3D10_SHADER_BUFFER_DESC
  332. {
  333. LPCSTR Name; // Name of the constant buffer
  334. D3D10_CBUFFER_TYPE Type; // Indicates that this is a CBuffer or TBuffer
  335. UINT Variables; // Number of member variables
  336. UINT Size; // Size of CB (in bytes)
  337. UINT uFlags; // Buffer description flags
  338. } D3D10_SHADER_BUFFER_DESC;
  339. typedef struct _D3D10_SHADER_VARIABLE_DESC
  340. {
  341. LPCSTR Name; // Name of the variable
  342. UINT StartOffset; // Offset in constant buffer's backing store
  343. UINT Size; // Size of variable (in bytes)
  344. UINT uFlags; // Variable flags
  345. LPVOID DefaultValue; // Raw pointer to default value
  346. } D3D10_SHADER_VARIABLE_DESC;
  347. typedef struct _D3D10_SHADER_TYPE_DESC
  348. {
  349. D3D10_SHADER_VARIABLE_CLASS Class; // Variable class (e.g. object, matrix, etc.)
  350. D3D10_SHADER_VARIABLE_TYPE Type; // Variable type (e.g. float, sampler, etc.)
  351. UINT Rows; // Number of rows (for matrices, 1 for other numeric, 0 if not applicable)
  352. UINT Columns; // Number of columns (for vectors & matrices, 1 for other numeric, 0 if not applicable)
  353. UINT Elements; // Number of elements (0 if not an array)
  354. UINT Members; // Number of members (0 if not a structure)
  355. UINT Offset; // Offset from the start of structure (0 if not a structure member)
  356. } D3D10_SHADER_TYPE_DESC;
  357. typedef struct _D3D10_SHADER_INPUT_BIND_DESC
  358. {
  359. LPCSTR Name; // Name of the resource
  360. D3D10_SHADER_INPUT_TYPE Type; // Type of resource (e.g. texture, cbuffer, etc.)
  361. UINT BindPoint; // Starting bind point
  362. UINT BindCount; // Number of contiguous bind points (for arrays)
  363. UINT uFlags; // Input binding flags
  364. D3D10_RESOURCE_RETURN_TYPE ReturnType; // Return type (if texture)
  365. D3D10_SRV_DIMENSION Dimension; // Dimension (if texture)
  366. UINT NumSamples; // Number of samples (0 if not MS texture)
  367. } D3D10_SHADER_INPUT_BIND_DESC;
  368. typedef struct _D3D10_SIGNATURE_PARAMETER_DESC
  369. {
  370. LPCSTR SemanticName; // Name of the semantic
  371. UINT SemanticIndex; // Index of the semantic
  372. UINT Register; // Number of member variables
  373. D3D10_NAME SystemValueType;// A predefined system value, or D3D10_NAME_UNDEFINED if not applicable
  374. D3D10_REGISTER_COMPONENT_TYPE ComponentType;// Scalar type (e.g. uint, float, etc.)
  375. BYTE Mask; // Mask to indicate which components of the register
  376. // are used (combination of D3D10_COMPONENT_MASK values)
  377. BYTE ReadWriteMask; // Mask to indicate whether a given component is
  378. // never written (if this is an output signature) or
  379. // always read (if this is an input signature).
  380. // (combination of D3D10_COMPONENT_MASK values)
  381. } D3D10_SIGNATURE_PARAMETER_DESC;
  382. //
  383. // Interface definitions
  384. //
  385. typedef interface ID3D10ShaderReflectionType ID3D10ShaderReflectionType;
  386. typedef interface ID3D10ShaderReflectionType *LPD3D10SHADERREFLECTIONTYPE;
  387. // {C530AD7D-9B16-4395-A979-BA2ECFF83ADD}
  388. DEFINE_GUID(IID_ID3D10ShaderReflectionType,
  389. 0xc530ad7d, 0x9b16, 0x4395, 0xa9, 0x79, 0xba, 0x2e, 0xcf, 0xf8, 0x3a, 0xdd);
  390. #undef INTERFACE
  391. #define INTERFACE ID3D10ShaderReflectionType
  392. DECLARE_INTERFACE(ID3D10ShaderReflectionType)
  393. {
  394. STDMETHOD(GetDesc)(THIS_ D3D10_SHADER_TYPE_DESC *pDesc) PURE;
  395. STDMETHOD_(ID3D10ShaderReflectionType*, GetMemberTypeByIndex)(THIS_ UINT Index) PURE;
  396. STDMETHOD_(ID3D10ShaderReflectionType*, GetMemberTypeByName)(THIS_ LPCSTR Name) PURE;
  397. STDMETHOD_(LPCSTR, GetMemberTypeName)(THIS_ UINT Index) PURE;
  398. };
  399. typedef interface ID3D10ShaderReflectionVariable ID3D10ShaderReflectionVariable;
  400. typedef interface ID3D10ShaderReflectionVariable *LPD3D10SHADERREFLECTIONVARIABLE;
  401. // {1BF63C95-2650-405d-99C1-3636BD1DA0A1}
  402. DEFINE_GUID(IID_ID3D10ShaderReflectionVariable,
  403. 0x1bf63c95, 0x2650, 0x405d, 0x99, 0xc1, 0x36, 0x36, 0xbd, 0x1d, 0xa0, 0xa1);
  404. #undef INTERFACE
  405. #define INTERFACE ID3D10ShaderReflectionVariable
  406. DECLARE_INTERFACE(ID3D10ShaderReflectionVariable)
  407. {
  408. STDMETHOD(GetDesc)(THIS_ D3D10_SHADER_VARIABLE_DESC *pDesc) PURE;
  409. STDMETHOD_(ID3D10ShaderReflectionType*, GetType)(THIS) PURE;
  410. };
  411. typedef interface ID3D10ShaderReflectionConstantBuffer ID3D10ShaderReflectionConstantBuffer;
  412. typedef interface ID3D10ShaderReflectionConstantBuffer *LPD3D10SHADERREFLECTIONCONSTANTBUFFER;
  413. // {66C66A94-DDDD-4b62-A66A-F0DA33C2B4D0}
  414. DEFINE_GUID(IID_ID3D10ShaderReflectionConstantBuffer,
  415. 0x66c66a94, 0xdddd, 0x4b62, 0xa6, 0x6a, 0xf0, 0xda, 0x33, 0xc2, 0xb4, 0xd0);
  416. #undef INTERFACE
  417. #define INTERFACE ID3D10ShaderReflectionConstantBuffer
  418. DECLARE_INTERFACE(ID3D10ShaderReflectionConstantBuffer)
  419. {
  420. STDMETHOD(GetDesc)(THIS_ D3D10_SHADER_BUFFER_DESC *pDesc) PURE;
  421. STDMETHOD_(ID3D10ShaderReflectionVariable*, GetVariableByIndex)(THIS_ UINT Index) PURE;
  422. STDMETHOD_(ID3D10ShaderReflectionVariable*, GetVariableByName)(THIS_ LPCSTR Name) PURE;
  423. };
  424. typedef interface ID3D10ShaderReflection ID3D10ShaderReflection;
  425. typedef interface ID3D10ShaderReflection *LPD3D10SHADERREFLECTION;
  426. // {D40E20B6-F8F7-42ad-AB20-4BAF8F15DFAA}
  427. DEFINE_GUID(IID_ID3D10ShaderReflection,
  428. 0xd40e20b6, 0xf8f7, 0x42ad, 0xab, 0x20, 0x4b, 0xaf, 0x8f, 0x15, 0xdf, 0xaa);
  429. #undef INTERFACE
  430. #define INTERFACE ID3D10ShaderReflection
  431. DECLARE_INTERFACE_(ID3D10ShaderReflection, IUnknown)
  432. {
  433. STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
  434. STDMETHOD_(ULONG, AddRef)(THIS) PURE;
  435. STDMETHOD_(ULONG, Release)(THIS) PURE;
  436. STDMETHOD(GetDesc)(THIS_ D3D10_SHADER_DESC *pDesc) PURE;
  437. STDMETHOD_(ID3D10ShaderReflectionConstantBuffer*, GetConstantBufferByIndex)(THIS_ UINT Index) PURE;
  438. STDMETHOD_(ID3D10ShaderReflectionConstantBuffer*, GetConstantBufferByName)(THIS_ LPCSTR Name) PURE;
  439. STDMETHOD(GetResourceBindingDesc)(THIS_ UINT ResourceIndex, D3D10_SHADER_INPUT_BIND_DESC *pDesc) PURE;
  440. STDMETHOD(GetInputParameterDesc)(THIS_ UINT ParameterIndex, D3D10_SIGNATURE_PARAMETER_DESC *pDesc) PURE;
  441. STDMETHOD(GetOutputParameterDesc)(THIS_ UINT ParameterIndex, D3D10_SIGNATURE_PARAMETER_DESC *pDesc) PURE;
  442. };
  443. //////////////////////////////////////////////////////////////////////////////
  444. // APIs //////////////////////////////////////////////////////////////////////
  445. //////////////////////////////////////////////////////////////////////////////
  446. #ifdef __cplusplus
  447. extern "C" {
  448. #endif //__cplusplus
  449. //----------------------------------------------------------------------------
  450. // D3D10CompileShader:
  451. // ------------------
  452. // Compiles a shader.
  453. //
  454. // Parameters:
  455. // pSrcFile
  456. // Source file name.
  457. // hSrcModule
  458. // Module handle. if NULL, current module will be used.
  459. // pSrcResource
  460. // Resource name in module.
  461. // pSrcData
  462. // Pointer to source code.
  463. // SrcDataLen
  464. // Size of source code, in bytes.
  465. // pDefines
  466. // Optional NULL-terminated array of preprocessor macro definitions.
  467. // pInclude
  468. // Optional interface pointer to use for handling #include directives.
  469. // If this parameter is NULL, #includes will be honored when compiling
  470. // from file, and will error when compiling from resource or memory.
  471. // pFunctionName
  472. // Name of the entrypoint function where execution should begin.
  473. // pProfile
  474. // Instruction set to be used when generating code. The D3D10 entry
  475. // point currently supports only "vs_4_0", "ps_4_0", and "gs_4_0".
  476. // Flags
  477. // See D3D10_SHADER_xxx flags.
  478. // ppShader
  479. // Returns a buffer containing the created shader. This buffer contains
  480. // the compiled shader code, as well as any embedded debug and symbol
  481. // table info. (See D3D10GetShaderConstantTable)
  482. // ppErrorMsgs
  483. // Returns a buffer containing a listing of errors and warnings that were
  484. // encountered during the compile. If you are running in a debugger,
  485. // these are the same messages you will see in your debug output.
  486. //----------------------------------------------------------------------------
  487. HRESULT WINAPI D3D10CompileShader(LPCSTR pSrcData, SIZE_T SrcDataLen, LPCSTR pFileName, CONST D3D10_SHADER_MACRO* pDefines, LPD3D10INCLUDE pInclude,
  488. LPCSTR pFunctionName, LPCSTR pProfile, UINT Flags, ID3D10Blob** ppShader, ID3D10Blob** ppErrorMsgs);
  489. //----------------------------------------------------------------------------
  490. // D3D10DisassembleShader:
  491. // ----------------------
  492. // Takes a binary shader, and returns a buffer containing text assembly.
  493. //
  494. // Parameters:
  495. // pShader
  496. // Pointer to the shader byte code.
  497. // BytecodeLength
  498. // Size of the shader byte code in bytes.
  499. // EnableColorCode
  500. // Emit HTML tags for color coding the output?
  501. // pComments
  502. // Pointer to a comment string to include at the top of the shader.
  503. // ppDisassembly
  504. // Returns a buffer containing the disassembled shader.
  505. //----------------------------------------------------------------------------
  506. HRESULT WINAPI D3D10DisassembleShader(CONST void *pShader, SIZE_T BytecodeLength, BOOL EnableColorCode, LPCSTR pComments, ID3D10Blob** ppDisassembly);
  507. //----------------------------------------------------------------------------
  508. // D3D10GetPixelShaderProfile/D3D10GetVertexShaderProfile/D3D10GetGeometryShaderProfile:
  509. // -----------------------------------------------------
  510. // Returns the name of the HLSL profile best suited to a given device.
  511. //
  512. // Parameters:
  513. // pDevice
  514. // Pointer to the device in question
  515. //----------------------------------------------------------------------------
  516. LPCSTR WINAPI D3D10GetPixelShaderProfile(ID3D10Device *pDevice);
  517. LPCSTR WINAPI D3D10GetVertexShaderProfile(ID3D10Device *pDevice);
  518. LPCSTR WINAPI D3D10GetGeometryShaderProfile(ID3D10Device *pDevice);
  519. //----------------------------------------------------------------------------
  520. // D3D10ReflectShader:
  521. // ------------------
  522. // Creates a shader reflection object that can be used to retrieve information
  523. // about a compiled shader
  524. //
  525. // Parameters:
  526. // pShaderBytecode
  527. // Pointer to a compiled shader (same pointer that is passed into
  528. // ID3D10Device::CreateShader)
  529. // BytecodeLength
  530. // Length of the shader bytecode buffer
  531. // ppReflector
  532. // [out] Returns a ID3D10ShaderReflection object that can be used to
  533. // retrieve shader resource and constant buffer information
  534. //
  535. //----------------------------------------------------------------------------
  536. HRESULT WINAPI D3D10ReflectShader(CONST void *pShaderBytecode, SIZE_T BytecodeLength, ID3D10ShaderReflection **ppReflector);
  537. //----------------------------------------------------------------------------
  538. // D3D10PreprocessShader
  539. // ---------------------
  540. // Creates a shader reflection object that can be used to retrieve information
  541. // about a compiled shader
  542. //
  543. // Parameters:
  544. // pSrcData
  545. // Pointer to source code
  546. // SrcDataLen
  547. // Size of source code, in bytes
  548. // pFileName
  549. // Source file name (used for error output)
  550. // pDefines
  551. // Optional NULL-terminated array of preprocessor macro definitions.
  552. // pInclude
  553. // Optional interface pointer to use for handling #include directives.
  554. // If this parameter is NULL, #includes will be honored when assembling
  555. // from file, and will error when assembling from resource or memory.
  556. // ppShaderText
  557. // Returns a buffer containing a single large string that represents
  558. // the resulting formatted token stream
  559. // ppErrorMsgs
  560. // Returns a buffer containing a listing of errors and warnings that were
  561. // encountered during assembly. If you are running in a debugger,
  562. // these are the same messages you will see in your debug output.
  563. //----------------------------------------------------------------------------
  564. HRESULT WINAPI D3D10PreprocessShader(LPCSTR pSrcData, SIZE_T SrcDataSize, LPCSTR pFileName, CONST D3D10_SHADER_MACRO* pDefines,
  565. LPD3D10INCLUDE pInclude, ID3D10Blob** ppShaderText, ID3D10Blob** ppErrorMsgs);
  566. //////////////////////////////////////////////////////////////////////////
  567. //
  568. // Shader blob manipulation routines
  569. // ---------------------------------
  570. //
  571. // void *pShaderBytecode - a buffer containing the result of an HLSL
  572. // compilation. Typically this opaque buffer contains several
  573. // discrete sections including the shader executable code, the input
  574. // signature, and the output signature. This can typically be retrieved
  575. // by calling ID3D10Blob::GetBufferPointer() on the returned blob
  576. // from HLSL's compile APIs.
  577. //
  578. // UINT BytecodeLength - the length of pShaderBytecode. This can
  579. // typically be retrieved by calling ID3D10Blob::GetBufferSize()
  580. // on the returned blob from HLSL's compile APIs.
  581. //
  582. // ID3D10Blob **ppSignatureBlob(s) - a newly created buffer that
  583. // contains only the signature portions of the original bytecode.
  584. // This is a copy; the original bytecode is not modified. You may
  585. // specify NULL for this parameter to have the bytecode validated
  586. // for the presence of the corresponding signatures without actually
  587. // copying them and creating a new blob.
  588. //
  589. // Returns E_INVALIDARG if any required parameters are NULL
  590. // Returns E_FAIL is the bytecode is corrupt or missing signatures
  591. // Returns S_OK on success
  592. //
  593. //////////////////////////////////////////////////////////////////////////
  594. HRESULT WINAPI D3D10GetInputSignatureBlob(CONST void *pShaderBytecode, SIZE_T BytecodeLength, ID3D10Blob **ppSignatureBlob);
  595. HRESULT WINAPI D3D10GetOutputSignatureBlob(CONST void *pShaderBytecode, SIZE_T BytecodeLength, ID3D10Blob **ppSignatureBlob);
  596. HRESULT WINAPI D3D10GetInputAndOutputSignatureBlob(CONST void *pShaderBytecode, SIZE_T BytecodeLength, ID3D10Blob **ppSignatureBlob);
  597. //----------------------------------------------------------------------------
  598. // D3D10GetShaderDebugInfo:
  599. // -----------------------
  600. // Gets shader debug info. Debug info is generated by D3D10CompileShader and is
  601. // embedded in the body of the shader.
  602. //
  603. // Parameters:
  604. // pShaderBytecode
  605. // Pointer to the function bytecode
  606. // BytecodeLength
  607. // Length of the shader bytecode buffer
  608. // ppDebugInfo
  609. // Buffer used to return debug info. For information about the layout
  610. // of this buffer, see definition of D3D10_SHADER_DEBUG_INFO above.
  611. //----------------------------------------------------------------------------
  612. HRESULT WINAPI D3D10GetShaderDebugInfo(CONST void *pShaderBytecode, SIZE_T BytecodeLength, ID3D10Blob** ppDebugInfo);
  613. #ifdef __cplusplus
  614. }
  615. #endif //__cplusplus
  616. #endif //__D3D10SHADER_H__