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