1 module aurora.directx.d3d11.d3d11shader;
2 
3 version(Windows):
4 
5 import std.bitmanip;
6 import aurora.directx.com;
7 import aurora.directx.d3d11;
8 
9 public:
10 
11 ///
12 /// Constants
13 ///
14 
15 enum int D3D_SHADER_REQUIRES_DOUBLES = 0x00000001;
16 enum int D3D_SHADER_REQUIRES_EARLY_DEPTH_STENCIL = 0x00000002;
17 enum int D3D_SHADER_REQUIRES_UAVS_AT_EVERY_STAGE = 0x00000004;
18 enum int D3D_SHADER_REQUIRES_64_UAVS = 0x00000008;
19 enum int D3D_SHADER_REQUIRES_MINIMUM_PRECISION = 0x00000010;
20 enum int D3D_SHADER_REQUIRES_11_1_DOUBLE_EXTENSIONS = 0x00000020;
21 enum int D3D_SHADER_REQUIRES_11_1_SHADER_EXTENSIONS = 0x00000040;
22 enum int D3D_SHADER_REQUIRES_LEVEL_9_COMPARISON_FILTERING = 0x00000080;
23 enum int D3D_SHADER_REQUIRES_TILED_RESOURCES = 0x00000100;
24 
25 alias D3D_RESOURCE_RETURN_TYPE D3D11_RESOURCE_RETURN_TYPE;
26 alias D3D_CBUFFER_TYPE D3D11_CBUFFER_TYPE;
27 alias D3D_TESSELLATOR_DOMAIN D3D11_TESSELLATOR_DOMAIN;
28 alias D3D_TESSELLATOR_PARTITIONING D3D11_TESSELLATOR_PARTITIONING;
29 alias D3D_TESSELLATOR_OUTPUT_PRIMITIVE D3D11_TESSELLATOR_OUTPUT_PRIMITIVE;
30 
31 ///
32 /// Functions
33 ///
34 
35 ///
36 /// Enumerations
37 ///
38 
39 enum D3D11_SHADER_VERSION_TYPE
40 {
41     PIXEL_SHADER    = 0,
42     VERTEX_SHADER   = 1,
43     GEOMETRY_SHADER = 2,
44     
45     // D3D11 Shaders
46     HULL_SHADER     = 3,
47     DOMAIN_SHADER   = 4,
48     COMPUTE_SHADER  = 5,
49 
50     RESERVED0       = 0xFFF0,
51 }
52 
53 ///
54 /// Structures
55 ///
56 
57 struct D3D11_SIGNATURE_PARAMETER_DESC
58 {
59     const char *SemanticName;
60     uint SemanticIndex;
61     uint Register;
62     D3D_NAME SystemValueType;
63     D3D_REGISTER_COMPONENT_TYPE ComponentType;
64     byte Mask;
65     byte ReadWriteMask;
66     uint Stream;
67     D3D_MIN_PRECISION MinPrecision;
68 }
69 
70 struct D3D11_SHADER_BUFFER_DESC
71 {
72     const char *Name;
73     D3D_CBUFFER_TYPE Type;
74     uint Variables;
75     uint Size;
76     uint uFlags;
77 }
78 
79 struct D3D11_SHADER_VARIABLE_DESC
80 {
81     const char *Name;
82     uint StartOffset;
83     uint Size;
84     uint uFlags;
85     void *DefaultValue;
86     uint StartTexture;
87     uint TextureSize;
88     uint StartSampler;
89     uint SamplerSize;
90 }
91 
92 struct D3D11_SHADER_TYPE_DESC
93 {
94     D3D_SHADER_VARIABLE_CLASS Class;
95     D3D_SHADER_VARIABLE_TYPE Type;
96     uint Rows;
97     uint Columns;
98     uint Elements;
99     uint Members;
100     uint Offset; 
101     const char *Name;
102 }
103 
104 struct D3D11_SHADER_DESC
105 {
106     uint Version;
107     const char *Creator;
108     uint Flags;
109     uint ConstantBuffers;
110     uint BoundResources;
111     uint InputParameters;
112     uint OutputParameters;
113     uint InstructionCount;
114     uint TempRegisterCount;
115     uint TempArrayCount;
116     uint DefCount;
117     uint DclCount;
118     uint TextureNormalInstructions;
119     uint TextureLoadInstructions;
120     uint TextureCompInstructions;
121     uint TextureBiasInstructions;
122     uint TextureGradientInstructions;
123     uint FloatInstructionCount;
124     uint IntInstructionCount;
125     uint UintInstructionCount;
126     uint StaticFlowControlCount;
127     uint DynamicFlowControlCount;
128     uint MacroInstructionCount;
129     uint ArrayInstructionCount;
130     uint CutInstructionCount;
131     uint EmitInstructionCount;
132     D3D_PRIMITIVE_TOPOLOGY GSOutputTopology;
133     uint GSMaxOutputVertexCount;
134     D3D_PRIMITIVE InputPrimitive;
135     uint PatchConstantParameters;
136     uint cGSInstanceCount;
137     uint cControlPoints;
138     D3D_TESSELLATOR_OUTPUT_PRIMITIVE HSOutputPrimitive;
139     D3D_TESSELLATOR_PARTITIONING HSPartitioning;
140     D3D_TESSELLATOR_DOMAIN TessellatorDomain;
141     uint cBarrierInstructions;
142     uint cInterlockedInstructions;
143     uint cTextureStoreInstructions;
144 }
145 
146 struct D3D11_SHADER_INPUT_BIND_DESC
147 {
148     const char *Name;
149     D3D_SHADER_INPUT_TYPE Type;
150     uint BindPoint;
151     uint BindCount;
152     uint uFlags;
153     D3D_RESOURCE_RETURN_TYPE ReturnType;
154     D3D_SRV_DIMENSION Dimension;
155     uint NumSamples;
156 }
157 
158 struct D3D11_LIBRARY_DESC
159 {
160     const char *Creator;
161     uint Flags;
162     uint FunctionCount;
163 }
164 
165 struct D3D11_FUNCTION_DESC
166 {
167     uint Version;
168     const char *Creator;
169     uint Flags;
170     uint ConstantBuffers;
171     uint BoundResources;
172     uint InstructionCount;
173     uint TempRegisterCount;
174     uint TempArrayCount;
175     uint DefCount;
176     uint DclCount;
177     uint TextureNormalInstructions;
178     uint TextureLoadInstructions;
179     uint TextureCompInstructions;
180     uint TextureBiasInstructions;
181     uint TextureGradientInstructions;
182     uint FloatInstructionCount;
183     uint IntInstructionCount;
184     uint UintInstructionCount;
185     uint StaticFlowControlCount;
186     uint DynamicFlowControlCount;
187     uint MacroInstructionCount;
188     uint ArrayInstructionCount;
189     uint MovInstructionCount;
190     uint MovcInstructionCount;
191     uint ConversionInstructionCount;
192     uint BitwiseInstructionCount;
193     D3D_FEATURE_LEVEL MinFeatureLevel;
194     ulong RequiredFeatureFlags;
195     const char *Name;
196     int FunctionParameterCount;
197     bool HasReturn;
198     bool Has10Level9VertexShader;
199     bool Has10Level9PixelShader;
200 }
201 
202 struct D3D11_PARAMETER_DESC
203 {
204     const char *Name;
205     const char *SemanticName;
206     D3D_SHADER_VARIABLE_TYPE Type;
207     D3D_SHADER_VARIABLE_CLASS Class;
208     uint Rows;
209     uint Columns;
210     D3D_INTERPOLATION_MODE InterpolationMode;
211     D3D_PARAMETER_FLAGS Flags;
212     uint FirstInRegister;
213     uint FirstInComponent;
214     uint FirstOutRegister;
215     uint FirstOutComponent;
216 }
217 
218 ///
219 /// Interfaces
220 ///
221 
222 mixin(uuid!(ID3D11ShaderReflectionType, "6E6FFA6A-9BAE-4613-A51E-91652D508C21"));
223 public interface ID3D11ShaderReflectionType : IUnknown
224 {
225 extern(Windows):
226     ID3D11ShaderReflectionType GetBaseClass();
227     HRESULT GetDesc(D3D11_SHADER_TYPE_DESC *pDesc);
228     ID3D11ShaderReflectionType GetInterfaceByIndex(uint uIndex);
229     ID3D11ShaderReflectionType* GetMemberTypeByIndex(uint Index);
230     ID3D11ShaderReflectionType* GetMemberTypeByName(const char *Name);
231     const char* GetMemberTypeName(uint Index);
232     uint GetNumInterfaces();
233     ID3D11ShaderReflectionType GetSubType();
234     HRESULT ImplementsInterface(ID3D11ShaderReflectionType pBase);
235     HRESULT IsEqual(ID3D11ShaderReflectionType pType);
236     HRESULT IsOfType(ID3D11ShaderReflectionType pType);
237 }
238 
239 mixin(uuid!(ID3D11ShaderReflectionVariable, "51F23923-F3E5-4BD1-91CB-606177D8DB4C"));
240 public interface ID3D11ShaderReflectionVariable : IUnknown
241 {
242 extern(Windows):
243     ID3D11ShaderReflectionConstantBuffer GetBuffer();
244     HRESULT GetDesc(D3D11_SHADER_VARIABLE_DESC pDesc);
245     uint GetInterfaceSlot(uint uArrayIndex);
246     ID3D11ShaderReflectionType GetType();
247 }
248 
249 mixin(uuid!(ID3D11ShaderReflectionConstantBuffer, "EB62D63D-93DD-4318-8AE8-C6F83AD371B8"));
250 public interface ID3D11ShaderReflectionConstantBuffer : IUnknown
251 {
252 extern(Windows):
253     HRESULT GetDesc(D3D11_SHADER_BUFFER_DESC *pDesc);
254     ID3D11ShaderReflectionVariable GetVariableByIndex(uint Index);
255     ID3D11ShaderReflectionVariable* GetVariableByName(const char *Name);
256 }
257 
258 mixin(uuid!(ID3D11ShaderReflection, "8d536ca1-0cca-4956-a837-786963755584"));
259 public interface ID3D11ShaderReflection : IUnknown
260 {
261 extern(Windows):
262     uint GetBitwiseInstructionCount();
263     ID3D11ShaderReflectionConstantBuffer GetConstantBufferByIndex(uint Index);
264     ID3D11ShaderReflectionConstantBuffer GetConstantBufferByName(const char *Name);
265     uint GetConversionInstructionCount();
266     HRESULT GetDesc(D3D11_SHADER_DESC *pDesc);
267     D3D_PRIMITIVE GetGSInputPrimitive();
268     HRESULT GetInputParameterDesc(uint ParameterIndex, D3D11_SIGNATURE_PARAMETER_DESC *pDesc);
269     HRESULT GetMinFeatureLevel(D3D_FEATURE_LEVEL *pLevel);
270     uint GetMovInstructionCount();
271     uint GetMovcInstructionCount();
272     uint GetNumInterfaceSlots();
273     HRESULT GetOutputParameterDesc(uint ParameterIndex, D3D11_SIGNATURE_PARAMETER_DESC *pDesc);
274     HRESULT GetPatchConstantParameterDesc(uint ParameterIndex, D3D11_SIGNATURE_PARAMETER_DESC *pDesc);
275     ulong GetRequiresFlags();
276     HRESULT GetResourceBindingDesc(uint ResourceIndex, D3D11_SHADER_INPUT_BIND_DESC *pDesc);
277     HRESULT GetResourceBindingDescByName(const char *Name, D3D11_SHADER_INPUT_BIND_DESC *pDesc);
278     uint GetThreadGroupSize(uint *pSizeX, uint *pSizeY, uint *pSizeZ);
279     ID3D11ShaderReflectionVariable* GetVariableByName(const char *Name);
280     bool IsSampleFrequencyShader();
281 }
282 
283 mixin(uuid!(ID3D11LibraryReflection, "54384F1B-5B3E-4BB7-AE01-60BA3097CBB6"));
284 public interface ID3D11LibraryReflection : IUnknown
285 {
286 extern(Windows):
287     HRESULT GetDesc(D3D11_LIBRARY_DESC *pDesc);
288     ID3D11FunctionReflection GetFunctionByIndex(int FunctionIndex);
289 }
290 
291 mixin(uuid!(ID3D11FunctionReflection, "207BCECB-D683-4A06-A8A3-9B149B9F73A4"));
292 public interface ID3D11FunctionReflection : IUnknown
293 {
294 extern(Windows):
295     ID3D11ShaderReflectionConstantBuffer GetConstantBufferByIndex(uint BufferIndex);
296     ID3D11ShaderReflectionConstantBuffer GetConstantBufferByName(const char *Name);
297     HRESULT GetDesc(D3D11_FUNCTION_DESC *pDesc);
298     ID3D11FunctionParameterReflection GetFunctionParameter(int ParameterIndex);
299     HRESULT GetResourceBindingDesc(uint ResourceIndex, D3D11_SHADER_INPUT_BIND_DESC *pDesc);
300     HRESULT GetResourceBindingDescByName(const char *Name, D3D11_SHADER_INPUT_BIND_DESC *pDesc);
301     ID3D11ShaderReflectionVariable* GetVariableByName(const char *Name);
302 }
303 
304 mixin(uuid!(ID3D11FunctionParameterReflection, "42757488-334F-47FE-982E-1A65D08CC462"));
305 public interface ID3D11FunctionParameterReflection : IUnknown
306 {
307 extern(Windows):
308     HRESULT GetDesc(D3D11_PARAMETER_DESC *pDesc);
309 }
310 
311 mixin(uuid!(ID3D11Module, "CAC701EE-80FC-4122-8242-10B39C8CEC34"));
312 public interface ID3D11Module : IUnknown
313 {
314 extern(Windows):
315     HRESULT CreateInstance(const char *pNamespace, ID3D11ModuleInstance *ppModuleInstance);
316 }
317 
318 mixin(uuid!(ID3D11ModuleInstance, "469E07F7-045A-48D5-AA12-68A478CDF75D"));
319 public interface ID3D11ModuleInstance : IUnknown
320 {
321 extern(Windows):
322     HRESULT BindConstantBuffer(uint uSrcSlot, uint uDstSlot, uint cbDstOffset);
323     HRESULT BindConstantBufferByName(const char *pName, uint uDstSlot, uint cbDstOffset);
324     HRESULT BindResource(uint uSrcSlot, uint uDstSlot, uint uCount);
325     HRESULT BindResourceAsUnorderedAccessView(uint uSrcSrvSlot, uint uDstUavSlot, uint uCount);
326     HRESULT BindResourceAsUnorderedAccessViewByName(const char *pSrvName, uint uDstUavSlot, uint uCount);
327     HRESULT BindResourceByName(const char *pName, uint uDstSlot, uint uCount);
328     HRESULT BindSampler(uint uSrcSlot, uint uDstSlot, uint uCount);
329     HRESULT BindSamplerByName(const char *pName, uint uDstSlot, uint uCount);
330     HRESULT BindUnorderedAccessView(uint uSrcSlot, uint uDstSlot, uint uCount);
331     HRESULT BindUnorderedAccessViewByName(const char *pName, uint uDstSlot, uint uCount);
332 }
333 
334 mixin(uuid!(ID3D11Linker, "59A6CD0E-E10D-4C1F-88C0-63ABA1DAF30E"));
335 public interface ID3D11Linker : IUnknown
336 {
337 extern(Windows):
338     HRESULT AddClipPlaneFromCBuffer(uint uCBufferSlot, uint uCBufferEntry);
339     HRESULT Link(ID3D11ModuleInstance pEntry, const char *pEntryName, const char *pTargetName, uint uFlags, ID3DBlob *ppShaderBlob, ID3DBlob *ppErrorBuffer);
340     HRESULT UseLibrary(ID3D11ModuleInstance pLibraryMI);
341 }
342 
343 mixin(uuid!(ID3D11LinkingNode, "D80DD70C-8D2F-4751-94A1-03C79B3556DB"));
344 public interface ID3D11LinkingNode : IUnknown
345 {
346 extern(Windows):
347 }
348 
349 mixin(uuid!(ID3D11FunctionLinkingGraph, "54133220-1CE8-43D3-8236-9855C5CEECFF"));
350 public interface ID3D11FunctionLinkingGraph : IUnknown
351 {
352 extern(Windows):
353     HRESULT CallFunction(const char *pModuleInstanceNamespace, ID3D11Module pModuleWithFunctionPrototype, const char *pFunctionName, ID3D11LinkingNode *ppCallNode);
354     HRESULT CreateModuleInstance(ID3D11ModuleInstance *ppModuleInstance, ID3DBlob *ppErrorBuffer);
355     HRESULT GenerateHlsl(uint uFlags, ID3DBlob *ppBuffer);
356     HRESULT GetLastError(ID3DBlob *ppErrorBuffer);
357     HRESULT PassValue(ID3D11LinkingNode pSrcNode, int SrcParameterIndex, ID3D11LinkingNode pDstNode, int DstParameterIndex);
358     HRESULT PassValueWithSwizzle(ID3D11LinkingNode pSrcNode, int SrcParameterIndex, const char *pSrcSwizzle, ID3D11LinkingNode pDstNode, int DstParameterIndex, const char *pDstSwizzle);
359     HRESULT SetInputSignature(const D3D11_PARAMETER_DESC *pInputParameters, uint  cInputParameters, ID3D11LinkingNode *ppInputNode);
360     HRESULT SetOutputSignature(const D3D11_PARAMETER_DESC *pOutputParameters, uint cOutputParameters, ID3D11LinkingNode *ppOutputNode);
361 }