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.

300 lines
12 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) Microsoft Corporation. All rights reserved.
  4. //
  5. // File: D3D10_1Shader.h
  6. // Content: D3D10.1 Shader Types and APIs
  7. //
  8. //////////////////////////////////////////////////////////////////////////////
  9. #ifndef __D3D10_1SHADER_H__
  10. #define __D3D10_1SHADER_H__
  11. #include "d3d10shader.h"
  12. //----------------------------------------------------------------------------
  13. // Shader debugging structures
  14. //----------------------------------------------------------------------------
  15. typedef enum _D3D10_SHADER_DEBUG_REGTYPE
  16. {
  17. D3D10_SHADER_DEBUG_REG_INPUT,
  18. D3D10_SHADER_DEBUG_REG_OUTPUT,
  19. D3D10_SHADER_DEBUG_REG_CBUFFER,
  20. D3D10_SHADER_DEBUG_REG_TBUFFER,
  21. D3D10_SHADER_DEBUG_REG_TEMP,
  22. D3D10_SHADER_DEBUG_REG_TEMPARRAY,
  23. D3D10_SHADER_DEBUG_REG_TEXTURE,
  24. D3D10_SHADER_DEBUG_REG_SAMPLER,
  25. D3D10_SHADER_DEBUG_REG_IMMEDIATECBUFFER,
  26. D3D10_SHADER_DEBUG_REG_LITERAL,
  27. D3D10_SHADER_DEBUG_REG_UNUSED,
  28. D3D11_SHADER_DEBUG_REG_INTERFACE_POINTERS,
  29. D3D10_SHADER_DEBUG_REG_FORCE_DWORD = 0x7fffffff,
  30. } D3D10_SHADER_DEBUG_REGTYPE;
  31. typedef enum _D3D10_SHADER_DEBUG_SCOPETYPE
  32. {
  33. D3D10_SHADER_DEBUG_SCOPE_GLOBAL,
  34. D3D10_SHADER_DEBUG_SCOPE_BLOCK,
  35. D3D10_SHADER_DEBUG_SCOPE_FORLOOP,
  36. D3D10_SHADER_DEBUG_SCOPE_STRUCT,
  37. D3D10_SHADER_DEBUG_SCOPE_FUNC_PARAMS,
  38. D3D10_SHADER_DEBUG_SCOPE_STATEBLOCK,
  39. D3D10_SHADER_DEBUG_SCOPE_NAMESPACE,
  40. D3D10_SHADER_DEBUG_SCOPE_ANNOTATION,
  41. D3D10_SHADER_DEBUG_SCOPE_FORCE_DWORD = 0x7fffffff,
  42. } D3D10_SHADER_DEBUG_SCOPETYPE;
  43. typedef enum _D3D10_SHADER_DEBUG_VARTYPE
  44. {
  45. D3D10_SHADER_DEBUG_VAR_VARIABLE,
  46. D3D10_SHADER_DEBUG_VAR_FUNCTION,
  47. D3D10_SHADER_DEBUG_VAR_FORCE_DWORD = 0x7fffffff,
  48. } D3D10_SHADER_DEBUG_VARTYPE;
  49. /////////////////////////////////////////////////////////////////////
  50. // These are the serialized structures that get written to the file
  51. /////////////////////////////////////////////////////////////////////
  52. typedef struct _D3D10_SHADER_DEBUG_TOKEN_INFO
  53. {
  54. UINT File; // offset into file list
  55. UINT Line; // line #
  56. UINT Column; // column #
  57. UINT TokenLength;
  58. UINT TokenId; // offset to LPCSTR of length TokenLength in string datastore
  59. } D3D10_SHADER_DEBUG_TOKEN_INFO;
  60. // Variable list
  61. typedef struct _D3D10_SHADER_DEBUG_VAR_INFO
  62. {
  63. // Index into token list for declaring identifier
  64. UINT TokenId;
  65. D3D10_SHADER_VARIABLE_TYPE Type;
  66. // register and component for this variable, only valid/necessary for arrays
  67. UINT Register;
  68. UINT Component;
  69. // gives the original variable that declared this variable
  70. UINT ScopeVar;
  71. // this variable's offset in its ScopeVar
  72. UINT ScopeVarOffset;
  73. } D3D10_SHADER_DEBUG_VAR_INFO;
  74. typedef struct _D3D10_SHADER_DEBUG_INPUT_INFO
  75. {
  76. // index into array of variables of variable to initialize
  77. UINT Var;
  78. // input, cbuffer, tbuffer
  79. D3D10_SHADER_DEBUG_REGTYPE InitialRegisterSet;
  80. // set to cbuffer or tbuffer slot, geometry shader input primitive #,
  81. // identifying register for indexable temp, or -1
  82. UINT InitialBank;
  83. // -1 if temp, otherwise gives register in register set
  84. UINT InitialRegister;
  85. // -1 if temp, otherwise gives component
  86. UINT InitialComponent;
  87. // initial value if literal
  88. UINT InitialValue;
  89. } D3D10_SHADER_DEBUG_INPUT_INFO;
  90. typedef struct _D3D10_SHADER_DEBUG_SCOPEVAR_INFO
  91. {
  92. // Index into variable token
  93. UINT TokenId;
  94. D3D10_SHADER_DEBUG_VARTYPE VarType; // variable or function (different namespaces)
  95. D3D10_SHADER_VARIABLE_CLASS Class;
  96. UINT Rows; // number of rows (matrices)
  97. UINT Columns; // number of columns (vectors and matrices)
  98. // In an array of structures, one struct member scope is provided, and
  99. // you'll have to add the array stride times the index to the variable
  100. // index you find, then find that variable in this structure's list of
  101. // variables.
  102. // gives a scope to look up struct members. -1 if not a struct
  103. UINT StructMemberScope;
  104. // number of array indices
  105. UINT uArrayIndices; // a[3][2][1] has 3 indices
  106. // maximum array index for each index
  107. // offset to UINT[uArrayIndices] in UINT datastore
  108. UINT ArrayElements; // a[3][2][1] has {3, 2, 1}
  109. // how many variables each array index moves
  110. // offset to UINT[uArrayIndices] in UINT datastore
  111. UINT ArrayStrides; // a[3][2][1] has {2, 1, 1}
  112. UINT uVariables;
  113. // index of the first variable, later variables are offsets from this one
  114. UINT uFirstVariable;
  115. } D3D10_SHADER_DEBUG_SCOPEVAR_INFO;
  116. // scope data, this maps variable names to debug variables (useful for the watch window)
  117. typedef struct _D3D10_SHADER_DEBUG_SCOPE_INFO
  118. {
  119. D3D10_SHADER_DEBUG_SCOPETYPE ScopeType;
  120. UINT Name; // offset to name of scope in strings list
  121. UINT uNameLen; // length of name string
  122. UINT uVariables;
  123. UINT VariableData; // Offset to UINT[uVariables] indexing the Scope Variable list
  124. } D3D10_SHADER_DEBUG_SCOPE_INFO;
  125. // instruction outputs
  126. typedef struct _D3D10_SHADER_DEBUG_OUTPUTVAR
  127. {
  128. // index variable being written to, if -1 it's not going to a variable
  129. UINT Var;
  130. // range data that the compiler expects to be true
  131. UINT uValueMin, uValueMax;
  132. INT iValueMin, iValueMax;
  133. FLOAT fValueMin, fValueMax;
  134. BOOL bNaNPossible, bInfPossible;
  135. } D3D10_SHADER_DEBUG_OUTPUTVAR;
  136. typedef struct _D3D10_SHADER_DEBUG_OUTPUTREG_INFO
  137. {
  138. // Only temp, indexable temp, and output are valid here
  139. D3D10_SHADER_DEBUG_REGTYPE OutputRegisterSet;
  140. // -1 means no output
  141. UINT OutputReg;
  142. // if a temp array, identifier for which one
  143. UINT TempArrayReg;
  144. // -1 means masked out
  145. UINT OutputComponents[4];
  146. D3D10_SHADER_DEBUG_OUTPUTVAR OutputVars[4];
  147. // when indexing the output, get the value of this register, then add
  148. // that to uOutputReg. If uIndexReg is -1, then there is no index.
  149. // find the variable whose register is the sum (by looking in the ScopeVar)
  150. // and component matches, then set it. This should only happen for indexable
  151. // temps and outputs.
  152. UINT IndexReg;
  153. UINT IndexComp;
  154. } D3D10_SHADER_DEBUG_OUTPUTREG_INFO;
  155. // per instruction data
  156. typedef struct _D3D10_SHADER_DEBUG_INST_INFO
  157. {
  158. UINT Id; // Which instruction this is in the bytecode
  159. UINT Opcode; // instruction type
  160. // 0, 1, or 2
  161. UINT uOutputs;
  162. // up to two outputs per instruction
  163. D3D10_SHADER_DEBUG_OUTPUTREG_INFO pOutputs[2];
  164. // index into the list of tokens for this instruction's token
  165. UINT TokenId;
  166. // how many function calls deep this instruction is
  167. UINT NestingLevel;
  168. // list of scopes from outer-most to inner-most
  169. // Number of scopes
  170. UINT Scopes;
  171. UINT ScopeInfo; // Offset to UINT[uScopes] specifying indices of the ScopeInfo Array
  172. // list of variables accessed by this instruction
  173. // Number of variables
  174. UINT AccessedVars;
  175. UINT AccessedVarsInfo; // Offset to UINT[AccessedVars] specifying indices of the ScopeVariableInfo Array
  176. } D3D10_SHADER_DEBUG_INST_INFO;
  177. typedef struct _D3D10_SHADER_DEBUG_FILE_INFO
  178. {
  179. UINT FileName; // Offset to LPCSTR for file name
  180. UINT FileNameLen; // Length of file name
  181. UINT FileData; // Offset to LPCSTR of length FileLen
  182. UINT FileLen; // Length of file
  183. } D3D10_SHADER_DEBUG_FILE_INFO;
  184. typedef struct _D3D10_SHADER_DEBUG_INFO
  185. {
  186. UINT Size; // sizeof(D3D10_SHADER_DEBUG_INFO)
  187. UINT Creator; // Offset to LPCSTR for compiler version
  188. UINT EntrypointName; // Offset to LPCSTR for Entry point name
  189. UINT ShaderTarget; // Offset to LPCSTR for shader target
  190. UINT CompileFlags; // flags used to compile
  191. UINT Files; // number of included files
  192. UINT FileInfo; // Offset to D3D10_SHADER_DEBUG_FILE_INFO[Files]
  193. UINT Instructions; // number of instructions
  194. UINT InstructionInfo; // Offset to D3D10_SHADER_DEBUG_INST_INFO[Instructions]
  195. UINT Variables; // number of variables
  196. UINT VariableInfo; // Offset to D3D10_SHADER_DEBUG_VAR_INFO[Variables]
  197. UINT InputVariables; // number of variables to initialize before running
  198. UINT InputVariableInfo; // Offset to D3D10_SHADER_DEBUG_INPUT_INFO[InputVariables]
  199. UINT Tokens; // number of tokens to initialize
  200. UINT TokenInfo; // Offset to D3D10_SHADER_DEBUG_TOKEN_INFO[Tokens]
  201. UINT Scopes; // number of scopes
  202. UINT ScopeInfo; // Offset to D3D10_SHADER_DEBUG_SCOPE_INFO[Scopes]
  203. UINT ScopeVariables; // number of variables declared
  204. UINT ScopeVariableInfo; // Offset to D3D10_SHADER_DEBUG_SCOPEVAR_INFO[Scopes]
  205. UINT UintOffset; // Offset to the UINT datastore, all UINT offsets are from this offset
  206. UINT StringOffset; // Offset to the string datastore, all string offsets are from this offset
  207. } D3D10_SHADER_DEBUG_INFO;
  208. //----------------------------------------------------------------------------
  209. // ID3D10ShaderReflection1:
  210. //----------------------------------------------------------------------------
  211. //
  212. // Interface definitions
  213. //
  214. typedef interface ID3D10ShaderReflection1 ID3D10ShaderReflection1;
  215. typedef interface ID3D10ShaderReflection1 *LPD3D10SHADERREFLECTION1;
  216. // {C3457783-A846-47CE-9520-CEA6F66E7447}
  217. DEFINE_GUID(IID_ID3D10ShaderReflection1,
  218. 0xc3457783, 0xa846, 0x47ce, 0x95, 0x20, 0xce, 0xa6, 0xf6, 0x6e, 0x74, 0x47);
  219. #undef INTERFACE
  220. #define INTERFACE ID3D10ShaderReflection1
  221. DECLARE_INTERFACE_(ID3D10ShaderReflection1, IUnknown)
  222. {
  223. STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
  224. STDMETHOD_(ULONG, AddRef)(THIS) PURE;
  225. STDMETHOD_(ULONG, Release)(THIS) PURE;
  226. STDMETHOD(GetDesc)(THIS_ D3D10_SHADER_DESC *pDesc) PURE;
  227. STDMETHOD_(ID3D10ShaderReflectionConstantBuffer*, GetConstantBufferByIndex)(THIS_ UINT Index) PURE;
  228. STDMETHOD_(ID3D10ShaderReflectionConstantBuffer*, GetConstantBufferByName)(THIS_ LPCSTR Name) PURE;
  229. STDMETHOD(GetResourceBindingDesc)(THIS_ UINT ResourceIndex, D3D10_SHADER_INPUT_BIND_DESC *pDesc) PURE;
  230. STDMETHOD(GetInputParameterDesc)(THIS_ UINT ParameterIndex, D3D10_SIGNATURE_PARAMETER_DESC *pDesc) PURE;
  231. STDMETHOD(GetOutputParameterDesc)(THIS_ UINT ParameterIndex, D3D10_SIGNATURE_PARAMETER_DESC *pDesc) PURE;
  232. STDMETHOD_(ID3D10ShaderReflectionVariable*, GetVariableByName)(THIS_ LPCSTR Name) PURE;
  233. STDMETHOD(GetResourceBindingDescByName)(THIS_ LPCSTR Name, D3D10_SHADER_INPUT_BIND_DESC *pDesc) PURE;
  234. STDMETHOD(GetMovInstructionCount)(THIS_ UINT* pCount) PURE;
  235. STDMETHOD(GetMovcInstructionCount)(THIS_ UINT* pCount) PURE;
  236. STDMETHOD(GetConversionInstructionCount)(THIS_ UINT* pCount) PURE;
  237. STDMETHOD(GetBitwiseInstructionCount)(THIS_ UINT* pCount) PURE;
  238. STDMETHOD(GetGSInputPrimitive)(THIS_ D3D10_PRIMITIVE* pPrim) PURE;
  239. STDMETHOD(IsLevel9Shader)(THIS_ BOOL* pbLevel9Shader) PURE;
  240. STDMETHOD(IsSampleFrequencyShader)(THIS_ BOOL* pbSampleFrequency) PURE;
  241. };
  242. //////////////////////////////////////////////////////////////////////////////
  243. // APIs //////////////////////////////////////////////////////////////////////
  244. //////////////////////////////////////////////////////////////////////////////
  245. #ifdef __cplusplus
  246. extern "C" {
  247. #endif //__cplusplus
  248. #ifdef __cplusplus
  249. }
  250. #endif //__cplusplus
  251. #endif //__D3D10_1SHADER_H__