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.

297 lines
15 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) Microsoft Corporation. All rights reserved.
  4. //
  5. // File: D3D11Shader.h
  6. // Content: D3D11 Shader Types and APIs
  7. //
  8. //////////////////////////////////////////////////////////////////////////////
  9. #ifndef __D3D11SHADER_H__
  10. #define __D3D11SHADER_H__
  11. #include "d3d10_1shader.h"
  12. typedef enum D3D11_RESOURCE_RETURN_TYPE
  13. {
  14. D3D11_RETURN_TYPE_UNORM = 1,
  15. D3D11_RETURN_TYPE_SNORM = 2,
  16. D3D11_RETURN_TYPE_SINT = 3,
  17. D3D11_RETURN_TYPE_UINT = 4,
  18. D3D11_RETURN_TYPE_FLOAT = 5,
  19. D3D11_RETURN_TYPE_MIXED = 6,
  20. D3D11_RETURN_TYPE_DOUBLE = 7,
  21. D3D11_RETURN_TYPE_CONTINUED = 8,
  22. } D3D11_RESOURCE_RETURN_TYPE;
  23. typedef enum _D3D11_CBUFFER_TYPE
  24. {
  25. D3D11_CT_CBUFFER,
  26. D3D11_CT_TBUFFER,
  27. D3D11_CT_INTERFACE_POINTERS,
  28. D3D11_CT_RESOURCE_BIND_INFO,
  29. } D3D11_CBUFFER_TYPE, *LPD3D11_CBUFFER_TYPE;
  30. typedef struct _D3D11_SIGNATURE_PARAMETER_DESC
  31. {
  32. LPCSTR SemanticName; // Name of the semantic
  33. UINT SemanticIndex; // Index of the semantic
  34. UINT Register; // Number of member variables
  35. D3D10_NAME SystemValueType;// A predefined system value, or D3D10_NAME_UNDEFINED if not applicable
  36. D3D10_REGISTER_COMPONENT_TYPE ComponentType;// Scalar type (e.g. uint, float, etc.)
  37. BYTE Mask; // Mask to indicate which components of the register
  38. // are used (combination of D3D10_COMPONENT_MASK values)
  39. BYTE ReadWriteMask; // Mask to indicate whether a given component is
  40. // never written (if this is an output signature) or
  41. // always read (if this is an input signature).
  42. // (combination of D3D10_COMPONENT_MASK values)
  43. UINT Stream; // Stream index
  44. } D3D11_SIGNATURE_PARAMETER_DESC;
  45. typedef struct _D3D11_SHADER_BUFFER_DESC
  46. {
  47. LPCSTR Name; // Name of the constant buffer
  48. D3D11_CBUFFER_TYPE Type; // Indicates type of buffer content
  49. UINT Variables; // Number of member variables
  50. UINT Size; // Size of CB (in bytes)
  51. UINT uFlags; // Buffer description flags
  52. } D3D11_SHADER_BUFFER_DESC;
  53. typedef struct _D3D11_SHADER_VARIABLE_DESC
  54. {
  55. LPCSTR Name; // Name of the variable
  56. UINT StartOffset; // Offset in constant buffer's backing store
  57. UINT Size; // Size of variable (in bytes)
  58. UINT uFlags; // Variable flags
  59. LPVOID DefaultValue; // Raw pointer to default value
  60. UINT StartTexture; // First texture index (or -1 if no textures used)
  61. UINT TextureSize; // Number of texture slots possibly used.
  62. UINT StartSampler; // First sampler index (or -1 if no textures used)
  63. UINT SamplerSize; // Number of sampler slots possibly used.
  64. } D3D11_SHADER_VARIABLE_DESC;
  65. typedef struct _D3D11_SHADER_TYPE_DESC
  66. {
  67. D3D10_SHADER_VARIABLE_CLASS Class; // Variable class (e.g. object, matrix, etc.)
  68. D3D10_SHADER_VARIABLE_TYPE Type; // Variable type (e.g. float, sampler, etc.)
  69. UINT Rows; // Number of rows (for matrices, 1 for other numeric, 0 if not applicable)
  70. UINT Columns; // Number of columns (for vectors & matrices, 1 for other numeric, 0 if not applicable)
  71. UINT Elements; // Number of elements (0 if not an array)
  72. UINT Members; // Number of members (0 if not a structure)
  73. UINT Offset; // Offset from the start of structure (0 if not a structure member)
  74. LPCSTR Name; // Name of type, can be NULL
  75. } D3D11_SHADER_TYPE_DESC;
  76. typedef enum D3D11_TESSELLATOR_DOMAIN
  77. {
  78. D3D11_TESSELLATOR_DOMAIN_UNDEFINED = 0,
  79. D3D11_TESSELLATOR_DOMAIN_ISOLINE = 1,
  80. D3D11_TESSELLATOR_DOMAIN_TRI = 2,
  81. D3D11_TESSELLATOR_DOMAIN_QUAD = 3
  82. } D3D11_TESSELLATOR_DOMAIN;
  83. typedef enum D3D11_TESSELLATOR_PARTITIONING
  84. {
  85. D3D11_TESSELLATOR_PARTITIONING_UNDEFINED = 0,
  86. D3D11_TESSELLATOR_PARTITIONING_INTEGER = 1,
  87. D3D11_TESSELLATOR_PARTITIONING_POW2 = 2,
  88. D3D11_TESSELLATOR_PARTITIONING_FRACTIONAL_ODD = 3,
  89. D3D11_TESSELLATOR_PARTITIONING_FRACTIONAL_EVEN = 4
  90. } D3D11_TESSELLATOR_PARTITIONING;
  91. typedef enum D3D11_TESSELLATOR_OUTPUT_PRIMITIVE
  92. {
  93. D3D11_TESSELLATOR_OUTPUT_UNDEFINED = 0,
  94. D3D11_TESSELLATOR_OUTPUT_POINT = 1,
  95. D3D11_TESSELLATOR_OUTPUT_LINE = 2,
  96. D3D11_TESSELLATOR_OUTPUT_TRIANGLE_CW = 3,
  97. D3D11_TESSELLATOR_OUTPUT_TRIANGLE_CCW = 4
  98. } D3D11_TESSELLATOR_OUTPUT_PRIMITIVE;
  99. typedef struct _D3D11_SHADER_DESC
  100. {
  101. UINT Version; // Shader version
  102. LPCSTR Creator; // Creator string
  103. UINT Flags; // Shader compilation/parse flags
  104. UINT ConstantBuffers; // Number of constant buffers
  105. UINT BoundResources; // Number of bound resources
  106. UINT InputParameters; // Number of parameters in the input signature
  107. UINT OutputParameters; // Number of parameters in the output signature
  108. UINT InstructionCount; // Number of emitted instructions
  109. UINT TempRegisterCount; // Number of temporary registers used
  110. UINT TempArrayCount; // Number of temporary arrays used
  111. UINT DefCount; // Number of constant defines
  112. UINT DclCount; // Number of declarations (input + output)
  113. UINT TextureNormalInstructions; // Number of non-categorized texture instructions
  114. UINT TextureLoadInstructions; // Number of texture load instructions
  115. UINT TextureCompInstructions; // Number of texture comparison instructions
  116. UINT TextureBiasInstructions; // Number of texture bias instructions
  117. UINT TextureGradientInstructions; // Number of texture gradient instructions
  118. UINT FloatInstructionCount; // Number of floating point arithmetic instructions used
  119. UINT IntInstructionCount; // Number of signed integer arithmetic instructions used
  120. UINT UintInstructionCount; // Number of unsigned integer arithmetic instructions used
  121. UINT StaticFlowControlCount; // Number of static flow control instructions used
  122. UINT DynamicFlowControlCount; // Number of dynamic flow control instructions used
  123. UINT MacroInstructionCount; // Number of macro instructions used
  124. UINT ArrayInstructionCount; // Number of array instructions used
  125. UINT CutInstructionCount; // Number of cut instructions used
  126. UINT EmitInstructionCount; // Number of emit instructions used
  127. D3D10_PRIMITIVE_TOPOLOGY GSOutputTopology; // Geometry shader output topology
  128. UINT GSMaxOutputVertexCount; // Geometry shader maximum output vertex count
  129. D3D11_PRIMITIVE InputPrimitive; // GS/HS input primitive
  130. UINT PatchConstantParameters; // Number of parameters in the patch constant signature
  131. UINT cGSInstanceCount; // Number of Geometry shader instances
  132. UINT cControlPoints; // Number of control points in the HS->DS stage
  133. D3D11_TESSELLATOR_OUTPUT_PRIMITIVE HSOutputPrimitive; // Primitive output by the tessellator
  134. D3D11_TESSELLATOR_PARTITIONING HSPartitioning; // Partitioning mode of the tessellator
  135. D3D11_TESSELLATOR_DOMAIN TessellatorDomain; // Domain of the tessellator (quad, tri, isoline)
  136. // instruction counts
  137. UINT cBarrierInstructions; // Number of barrier instructions in a compute shader
  138. UINT cInterlockedInstructions; // Number of interlocked instructions
  139. UINT cTextureStoreInstructions; // Number of texture writes
  140. } D3D11_SHADER_DESC;
  141. typedef struct _D3D11_SHADER_INPUT_BIND_DESC
  142. {
  143. LPCSTR Name; // Name of the resource
  144. D3D10_SHADER_INPUT_TYPE Type; // Type of resource (e.g. texture, cbuffer, etc.)
  145. UINT BindPoint; // Starting bind point
  146. UINT BindCount; // Number of contiguous bind points (for arrays)
  147. UINT uFlags; // Input binding flags
  148. D3D11_RESOURCE_RETURN_TYPE ReturnType; // Return type (if texture)
  149. D3D10_SRV_DIMENSION Dimension; // Dimension (if texture)
  150. UINT NumSamples; // Number of samples (0 if not MS texture)
  151. } D3D11_SHADER_INPUT_BIND_DESC;
  152. //////////////////////////////////////////////////////////////////////////////
  153. // Interfaces ////////////////////////////////////////////////////////////////
  154. //////////////////////////////////////////////////////////////////////////////
  155. typedef interface ID3D11ShaderReflectionType ID3D11ShaderReflectionType;
  156. typedef interface ID3D11ShaderReflectionType *LPD3D11SHADERREFLECTIONTYPE;
  157. typedef interface ID3D11ShaderReflectionVariable ID3D11ShaderReflectionVariable;
  158. typedef interface ID3D11ShaderReflectionVariable *LPD3D11SHADERREFLECTIONVARIABLE;
  159. typedef interface ID3D11ShaderReflectionConstantBuffer ID3D11ShaderReflectionConstantBuffer;
  160. typedef interface ID3D11ShaderReflectionConstantBuffer *LPD3D11SHADERREFLECTIONCONSTANTBUFFER;
  161. typedef interface ID3D11ShaderReflection ID3D11ShaderReflection;
  162. typedef interface ID3D11ShaderReflection *LPD3D11SHADERREFLECTION;
  163. // {6E6FFA6A-9BAE-4613-A51E-91652D508C21}
  164. DEFINE_GUID(IID_ID3D11ShaderReflectionType,
  165. 0x6e6ffa6a, 0x9bae, 0x4613, 0xa5, 0x1e, 0x91, 0x65, 0x2d, 0x50, 0x8c, 0x21);
  166. #undef INTERFACE
  167. #define INTERFACE ID3D11ShaderReflectionType
  168. DECLARE_INTERFACE(ID3D11ShaderReflectionType)
  169. {
  170. STDMETHOD(GetDesc)(THIS_ D3D11_SHADER_TYPE_DESC *pDesc) PURE;
  171. STDMETHOD_(ID3D11ShaderReflectionType*, GetMemberTypeByIndex)(THIS_ UINT Index) PURE;
  172. STDMETHOD_(ID3D11ShaderReflectionType*, GetMemberTypeByName)(THIS_ LPCSTR Name) PURE;
  173. STDMETHOD_(LPCSTR, GetMemberTypeName)(THIS_ UINT Index) PURE;
  174. STDMETHOD(IsEqual)(THIS_ ID3D11ShaderReflectionType* pType) PURE;
  175. STDMETHOD_(ID3D11ShaderReflectionType*, GetSubType)(THIS) PURE;
  176. STDMETHOD_(ID3D11ShaderReflectionType*, GetBaseClass)(THIS) PURE;
  177. STDMETHOD_(UINT, GetNumInterfaces)(THIS) PURE;
  178. STDMETHOD_(ID3D11ShaderReflectionType*, GetInterfaceByIndex)(THIS_ UINT uIndex) PURE;
  179. STDMETHOD(IsOfType)(THIS_ ID3D11ShaderReflectionType* pType) PURE;
  180. STDMETHOD(ImplementsInterface)(THIS_ ID3D11ShaderReflectionType* pBase) PURE;
  181. };
  182. // {51F23923-F3E5-4BD1-91CB-606177D8DB4C}
  183. DEFINE_GUID(IID_ID3D11ShaderReflectionVariable,
  184. 0x51f23923, 0xf3e5, 0x4bd1, 0x91, 0xcb, 0x60, 0x61, 0x77, 0xd8, 0xdb, 0x4c);
  185. #undef INTERFACE
  186. #define INTERFACE ID3D11ShaderReflectionVariable
  187. DECLARE_INTERFACE(ID3D11ShaderReflectionVariable)
  188. {
  189. STDMETHOD(GetDesc)(THIS_ D3D11_SHADER_VARIABLE_DESC *pDesc) PURE;
  190. STDMETHOD_(ID3D11ShaderReflectionType*, GetType)(THIS) PURE;
  191. STDMETHOD_(ID3D11ShaderReflectionConstantBuffer*, GetBuffer)(THIS) PURE;
  192. STDMETHOD_(UINT, GetInterfaceSlot)(THIS_ UINT uArrayIndex) PURE;
  193. };
  194. // {EB62D63D-93DD-4318-8AE8-C6F83AD371B8}
  195. DEFINE_GUID(IID_ID3D11ShaderReflectionConstantBuffer,
  196. 0xeb62d63d, 0x93dd, 0x4318, 0x8a, 0xe8, 0xc6, 0xf8, 0x3a, 0xd3, 0x71, 0xb8);
  197. #undef INTERFACE
  198. #define INTERFACE ID3D11ShaderReflectionConstantBuffer
  199. DECLARE_INTERFACE(ID3D11ShaderReflectionConstantBuffer)
  200. {
  201. STDMETHOD(GetDesc)(THIS_ D3D11_SHADER_BUFFER_DESC *pDesc) PURE;
  202. STDMETHOD_(ID3D11ShaderReflectionVariable*, GetVariableByIndex)(THIS_ UINT Index) PURE;
  203. STDMETHOD_(ID3D11ShaderReflectionVariable*, GetVariableByName)(THIS_ LPCSTR Name) PURE;
  204. };
  205. // {17F27486-A342-4D10-8842-AB0874E7F670}
  206. DEFINE_GUID(IID_ID3D11ShaderReflection,
  207. 0x17f27486, 0xa342, 0x4d10, 0x88, 0x42, 0xab, 0x08, 0x74, 0xe7, 0xf6, 0x70);
  208. #undef INTERFACE
  209. #define INTERFACE ID3D11ShaderReflection
  210. DECLARE_INTERFACE_(ID3D11ShaderReflection, IUnknown)
  211. {
  212. STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
  213. STDMETHOD_(ULONG, AddRef)(THIS) PURE;
  214. STDMETHOD_(ULONG, Release)(THIS) PURE;
  215. STDMETHOD(GetDesc)(THIS_ D3D11_SHADER_DESC *pDesc) PURE;
  216. STDMETHOD_(ID3D11ShaderReflectionConstantBuffer*, GetConstantBufferByIndex)(THIS_ UINT Index) PURE;
  217. STDMETHOD_(ID3D11ShaderReflectionConstantBuffer*, GetConstantBufferByName)(THIS_ LPCSTR Name) PURE;
  218. STDMETHOD(GetResourceBindingDesc)(THIS_ UINT ResourceIndex, D3D11_SHADER_INPUT_BIND_DESC *pDesc) PURE;
  219. STDMETHOD(GetInputParameterDesc)(THIS_ UINT ParameterIndex, D3D11_SIGNATURE_PARAMETER_DESC *pDesc) PURE;
  220. STDMETHOD(GetOutputParameterDesc)(THIS_ UINT ParameterIndex, D3D11_SIGNATURE_PARAMETER_DESC *pDesc) PURE;
  221. STDMETHOD(GetPatchConstantParameterDesc)(THIS_ UINT ParameterIndex, D3D11_SIGNATURE_PARAMETER_DESC *pDesc) PURE;
  222. STDMETHOD_(ID3D11ShaderReflectionVariable*, GetVariableByName)(THIS_ LPCSTR Name) PURE;
  223. STDMETHOD(GetResourceBindingDescByName)(THIS_ LPCSTR Name, D3D11_SHADER_INPUT_BIND_DESC *pDesc) PURE;
  224. STDMETHOD_(UINT, GetMovInstructionCount)(THIS) PURE;
  225. STDMETHOD_(UINT, GetMovcInstructionCount)(THIS) PURE;
  226. STDMETHOD_(UINT, GetConversionInstructionCount)(THIS) PURE;
  227. STDMETHOD_(UINT, GetBitwiseInstructionCount)(THIS) PURE;
  228. STDMETHOD_(D3D10_PRIMITIVE, GetGSInputPrimitive)(THIS) PURE;
  229. STDMETHOD_(BOOL, IsSampleFrequencyShader)(THIS) PURE;
  230. STDMETHOD_(UINT, GetNumInterfaceSlots)(THIS) PURE;
  231. STDMETHOD(GetMinFeatureLevel)(THIS_ enum D3D_FEATURE_LEVEL* pLevel) PURE;
  232. };
  233. //////////////////////////////////////////////////////////////////////////////
  234. // APIs //////////////////////////////////////////////////////////////////////
  235. //////////////////////////////////////////////////////////////////////////////
  236. #ifdef __cplusplus
  237. extern "C" {
  238. #endif //__cplusplus
  239. #ifdef __cplusplus
  240. }
  241. #endif //__cplusplus
  242. #endif //__D3D11SHADER_H__