1 module directx.d3d11shader;
2 //////////////////////////////////////////////////////////////////////////////
3 //
4 //  Copyright (c) Microsoft Corporation.  All rights reserved.
5 //
6 //  File:       D3D11Shader.h
7 //  Content:    D3D11 Shader Types and APIs
8 //
9 //////////////////////////////////////////////////////////////////////////////
10 
11 version(Windows):
12 
13 public import directx.d3dcommon;
14 
15 alias D3D11_SHADER_VERSION_TYPE = int;
16 enum : D3D11_SHADER_VERSION_TYPE
17 {
18     D3D11_SHVER_PIXEL_SHADER    = 0,
19     D3D11_SHVER_VERTEX_SHADER   = 1,
20     D3D11_SHVER_GEOMETRY_SHADER = 2,
21     
22     // D3D11 Shaders
23     D3D11_SHVER_HULL_SHADER     = 3,
24     D3D11_SHVER_DOMAIN_SHADER   = 4,
25     D3D11_SHVER_COMPUTE_SHADER  = 5,
26 }
27 
28 int D3D11_SHVER_GET_TYPE(T)(_Version) {
29     return (((_Version) >> 16) & 0xffff);
30 }
31 
32 int D3D11_SHVER_GET_MAJOR(T)(_Version) {
33     return (((_Version) >> 4) & 0xf);
34 }
35 
36 int D3D11_SHVER_GET_MINOR(T)(_Version) {
37     return (((_Version) >> 0) & 0xf);
38 }
39 
40 alias D3D_RESOURCE_RETURN_TYPE D3D11_RESOURCE_RETURN_TYPE;
41 
42 alias D3D_CBUFFER_TYPE D3D11_CBUFFER_TYPE;
43 
44 struct _D3D11_SIGNATURE_PARAMETER_DESC
45 {
46     LPCSTR                      SemanticName;   // Name of the semantic
47     UINT                        SemanticIndex;  // Index of the semantic
48     UINT                        Register;       // Number of member variables
49     D3D_NAME                    SystemValueType;// A predefined system value, or D3D_NAME_UNDEFINED if not applicable
50     D3D_REGISTER_COMPONENT_TYPE ComponentType;// Scalar type (e.g. uint, float, etc.)
51     BYTE                        Mask;           // Mask to indicate which components of the register
52                                                 // are used (combination of D3D10_COMPONENT_MASK values)
53     BYTE                        ReadWriteMask;  // Mask to indicate whether a given component is 
54                                                 // never written (if this is an output signature) or
55                                                 // always read (if this is an input signature).
56                                                 // (combination of D3D10_COMPONENT_MASK values)
57     UINT Stream;                                // Stream index
58 }
59 alias _D3D11_SIGNATURE_PARAMETER_DESC D3D11_SIGNATURE_PARAMETER_DESC;
60 
61 struct _D3D11_SHADER_BUFFER_DESC
62 {
63     LPCSTR                  Name;           // Name of the constant buffer
64     D3D_CBUFFER_TYPE        Type;           // Indicates type of buffer content
65     UINT                    Variables;      // Number of member variables
66     UINT                    Size;           // Size of CB (in bytes)
67     UINT                    uFlags;         // Buffer description flags
68 }
69 alias _D3D11_SHADER_BUFFER_DESC D3D11_SHADER_BUFFER_DESC;
70 
71 struct _D3D11_SHADER_VARIABLE_DESC
72 {
73     LPCSTR                  Name;           // Name of the variable
74     UINT                    StartOffset;    // Offset in constant buffer's backing store
75     UINT                    Size;           // Size of variable (in bytes)
76     UINT                    uFlags;         // Variable flags
77     LPVOID                  DefaultValue;   // Raw pointer to default value
78     UINT                    StartTexture;   // First texture index (or -1 if no textures used)
79     UINT                    TextureSize;    // Number of texture slots possibly used.
80     UINT                    StartSampler;   // First sampler index (or -1 if no textures used)
81     UINT                    SamplerSize;    // Number of sampler slots possibly used.
82 }
83 alias _D3D11_SHADER_VARIABLE_DESC D3D11_SHADER_VARIABLE_DESC;
84 
85 struct _D3D11_SHADER_TYPE_DESC
86 {
87     D3D_SHADER_VARIABLE_CLASS   Class;          // Variable class (e.g. object, matrix, etc.)
88     D3D_SHADER_VARIABLE_TYPE    Type;           // Variable type (e.g. float, sampler, etc.)
89     UINT                        Rows;           // Number of rows (for matrices, 1 for other numeric, 0 if not applicable)
90     UINT                        Columns;        // Number of columns (for vectors & matrices, 1 for other numeric, 0 if not applicable)
91     UINT                        Elements;       // Number of elements (0 if not an array)
92     UINT                        Members;        // Number of members (0 if not a structure)
93     UINT                        Offset;         // Offset from the start of structure (0 if not a structure member)
94     LPCSTR                      Name;           // Name of type, can be NULL
95 }
96 alias _D3D11_SHADER_TYPE_DESC D3D11_SHADER_TYPE_DESC;
97 
98 alias D3D_TESSELLATOR_DOMAIN D3D11_TESSELLATOR_DOMAIN;
99 
100 alias D3D_TESSELLATOR_PARTITIONING D3D11_TESSELLATOR_PARTITIONING;
101 
102 alias D3D_TESSELLATOR_OUTPUT_PRIMITIVE D3D11_TESSELLATOR_OUTPUT_PRIMITIVE;
103 
104 struct _D3D11_SHADER_DESC
105 {
106     UINT                    Version;                     // Shader version
107     LPCSTR                  Creator;                     // Creator string
108     UINT                    Flags;                       // Shader compilation/parse flags
109     
110     UINT                    ConstantBuffers;             // Number of constant buffers
111     UINT                    BoundResources;              // Number of bound resources
112     UINT                    InputParameters;             // Number of parameters in the input signature
113     UINT                    OutputParameters;            // Number of parameters in the output signature
114 
115     UINT                    InstructionCount;            // Number of emitted instructions
116     UINT                    TempRegisterCount;           // Number of temporary registers used 
117     UINT                    TempArrayCount;              // Number of temporary arrays used
118     UINT                    DefCount;                    // Number of constant defines 
119     UINT                    DclCount;                    // Number of declarations (input + output)
120     UINT                    TextureNormalInstructions;   // Number of non-categorized texture instructions
121     UINT                    TextureLoadInstructions;     // Number of texture load instructions
122     UINT                    TextureCompInstructions;     // Number of texture comparison instructions
123     UINT                    TextureBiasInstructions;     // Number of texture bias instructions
124     UINT                    TextureGradientInstructions; // Number of texture gradient instructions
125     UINT                    FloatInstructionCount;       // Number of floating point arithmetic instructions used
126     UINT                    IntInstructionCount;         // Number of signed integer arithmetic instructions used
127     UINT                    UintInstructionCount;        // Number of unsigned integer arithmetic instructions used
128     UINT                    StaticFlowControlCount;      // Number of static flow control instructions used
129     UINT                    DynamicFlowControlCount;     // Number of dynamic flow control instructions used
130     UINT                    MacroInstructionCount;       // Number of macro instructions used
131     UINT                    ArrayInstructionCount;       // Number of array instructions used
132     UINT                    CutInstructionCount;         // Number of cut instructions used
133     UINT                    EmitInstructionCount;        // Number of emit instructions used
134     D3D_PRIMITIVE_TOPOLOGY   GSOutputTopology;           // Geometry shader output topology
135     UINT                    GSMaxOutputVertexCount;      // Geometry shader maximum output vertex count
136     D3D_PRIMITIVE           InputPrimitive;              // GS/HS input primitive
137     UINT                    PatchConstantParameters;     // Number of parameters in the patch constant signature
138     UINT                    cGSInstanceCount;            // Number of Geometry shader instances
139     UINT                    cControlPoints;              // Number of control points in the HS->DS stage
140     D3D_TESSELLATOR_OUTPUT_PRIMITIVE HSOutputPrimitive;  // Primitive output by the tessellator
141     D3D_TESSELLATOR_PARTITIONING HSPartitioning;         // Partitioning mode of the tessellator
142     D3D_TESSELLATOR_DOMAIN  TessellatorDomain;           // Domain of the tessellator (quad, tri, isoline)
143     // instruction counts
144     UINT cBarrierInstructions;                           // Number of barrier instructions in a compute shader
145     UINT cInterlockedInstructions;                       // Number of interlocked instructions
146     UINT cTextureStoreInstructions;                      // Number of texture writes
147 }
148 alias _D3D11_SHADER_DESC D3D11_SHADER_DESC;
149 
150 struct _D3D11_SHADER_INPUT_BIND_DESC
151 {
152     LPCSTR                      Name;           // Name of the resource
153     D3D_SHADER_INPUT_TYPE       Type;           // Type of resource (e.g. texture, cbuffer, etc.)
154     UINT                        BindPoint;      // Starting bind point
155     UINT                        BindCount;      // Number of contiguous bind points (for arrays)
156     
157     UINT                        uFlags;         // Input binding flags
158     D3D_RESOURCE_RETURN_TYPE    ReturnType;     // Return type (if texture)
159     D3D_SRV_DIMENSION           Dimension;      // Dimension (if texture)
160     UINT                        NumSamples;     // Number of samples (0 if not MS texture)
161 }
162 alias _D3D11_SHADER_INPUT_BIND_DESC D3D11_SHADER_INPUT_BIND_DESC;
163 
164 
165 //////////////////////////////////////////////////////////////////////////////
166 // Interfaces ////////////////////////////////////////////////////////////////
167 //////////////////////////////////////////////////////////////////////////////
168 
169 mixin( uuid!(ID3D11ShaderReflectionType, "6E6FFA6A-9BAE-4613-A51E-91652D508C21") );
170 interface ID3D11ShaderReflectionType
171 {
172 	extern(Windows):
173 	HRESULT GetDesc(
174 				D3D11_SHADER_TYPE_DESC* pDesc);
175     
176     ID3D11ShaderReflectionType GetMemberTypeByIndex(
177 				UINT Index);
178 	
179     ID3D11ShaderReflectionType GetMemberTypeByName(
180 				LPCSTR Name);
181 	
182     LPCSTR GetMemberTypeName(
183 				UINT Index);
184 
185     HRESULT IsEqual(
186 				ID3D11ShaderReflectionType pType);
187 
188     ID3D11ShaderReflectionType GetSubType();
189 	
190     ID3D11ShaderReflectionType GetBaseClass();
191 	
192     UINT GetNumInterfaces();
193 	
194     ID3D11ShaderReflectionType GetInterfaceByIndex(
195 				UINT uIndex);
196 	
197     HRESULT IsOfType(
198 				ID3D11ShaderReflectionType pType);
199 				
200     HRESULT ImplementsInterface(
201 				ID3D11ShaderReflectionType pBase);
202 }
203 alias ID3D11ShaderReflectionType LPD3D11SHADERREFLECTIONTYPE;
204 
205 
206 
207 mixin( uuid!(ID3D11ShaderReflectionVariable, "51F23923-F3E5-4BD1-91CB-606177D8DB4C") );
208 interface ID3D11ShaderReflectionVariable
209 {
210 	extern(Windows):
211 	HRESULT GetDesc(
212 				D3D11_SHADER_VARIABLE_DESC* pDesc);
213     
214     ID3D11ShaderReflectionType GetType();
215 
216     ID3D11ShaderReflectionConstantBuffer GetBuffer();
217 
218     UINT GetInterfaceSlot(
219 				UINT uArrayIndex);
220 }
221 alias ID3D11ShaderReflectionVariable LPD3D11SHADERREFLECTIONVARIABLE;
222 
223 
224 
225 
226 mixin( uuid!(ID3D11ShaderReflectionConstantBuffer, "EB62D63D-93DD-4318-8AE8-C6F83AD371B8") );
227 interface ID3D11ShaderReflectionConstantBuffer
228 {
229 	extern(Windows):
230 	HRESULT GetDesc(
231 				D3D11_SHADER_BUFFER_DESC* pDesc);
232     
233     ID3D11ShaderReflectionVariable GetVariableByIndex(
234 				UINT Index);
235 				
236     ID3D11ShaderReflectionVariable GetVariableByName(
237 				LPCSTR Name);
238 	
239 }
240 alias ID3D11ShaderReflectionConstantBuffer LPD3D11SHADERREFLECTIONCONSTANTBUFFER;
241 
242 
243 
244 // The ID3D11ShaderReflection IID may change from SDK version to SDK version
245 // if the reflection API changes.  This prevents new code with the new API
246 // from working with an old binary.  Recompiling with the new header
247 // will pick up the new IID.
248 
249 mixin( uuid!(ID3D11ShaderReflection, "0a233719-3960-4578-9d7c-203b8b1d9cc1") );
250 interface ID3D11ShaderReflection : IUnknown
251 {
252 	extern(Windows):
253     HRESULT GetDesc(
254 				D3D11_SHADER_DESC* pDesc);
255     
256     ID3D11ShaderReflectionConstantBuffer GetConstantBufferByIndex(
257 				UINT Index);
258 
259     ID3D11ShaderReflectionConstantBuffer GetConstantBufferByName(
260 				LPCSTR Name);
261     
262     HRESULT GetResourceBindingDesc(
263 				UINT ResourceIndex,
264 				D3D11_SHADER_INPUT_BIND_DESC* pDesc);
265     
266     HRESULT GetInputParameterDesc(
267 				UINT ParameterIndex,
268 				D3D11_SIGNATURE_PARAMETER_DESC* pDesc);
269 				
270     HRESULT GetOutputParameterDesc(
271 				UINT ParameterIndex,
272 				D3D11_SIGNATURE_PARAMETER_DESC* pDesc);
273 				
274     HRESULT GetPatchConstantParameterDesc(
275 				UINT ParameterIndex,
276 				D3D11_SIGNATURE_PARAMETER_DESC* pDesc);
277 
278     ID3D11ShaderReflectionVariable GetVariableByName(
279 				LPCSTR Name);
280 
281     HRESULT GetResourceBindingDescByName(
282 				LPCSTR Name,
283 				D3D11_SHADER_INPUT_BIND_DESC* pDesc);
284 
285     UINT GetMovInstructionCount();
286 
287     UINT GetMovcInstructionCount();
288 
289     UINT GetConversionInstructionCount();
290 
291     UINT GetBitwiseInstructionCount();
292     
293     D3D_PRIMITIVE GetGSInputPrimitive();
294 	
295     BOOL IsSampleFrequencyShader();
296 
297     UINT GetNumInterfaceSlots();
298 	
299     HRESULT GetMinFeatureLevel(
300 				D3D_FEATURE_LEVEL* pLevel) ;
301 
302     UINT GetThreadGroupSize(
303 				UINT* pSizeX,
304 				UINT* pSizeY,
305 				UINT* pSizeZ);
306 	
307 }
308 alias ID3D11ShaderReflection LPD3D11SHADERREFLECTION;