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