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.

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