d3d10_1shader.h 12 KB

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