1 module aurora.directx.d3d12.d3d12shader;
2 
3 version(Windows):
4 
5 public import aurora.directx.com;
6 public import aurora.directx.d3d.d3dcommon;
7 
8 public:
9 
10 ///
11 /// Constants
12 ///
13 
14 alias D3D_RESOURCE_RETURN_TYPE D3D12_RESOURCE_RETURN_TYPE;
15 alias D3D_CBUFFER_TYPE D3D12_CBUFFER_TYPE;
16 alias D3D_TESSELLATOR_DOMAIN D3D12_TESSELLATOR_DOMAIN;
17 alias D3D_TESSELLATOR_PARTITIONING D3D12_TESSELLATOR_PARTITIONING;
18 alias D3D_TESSELLATOR_OUTPUT_PRIMITIVE D3D12_TESSELLATOR_OUTPUT_PRIMITIVE;
19 
20 enum uint D3D_SHADER_REQUIRES_DOUBLES = 0x00000001;
21 enum uint D3D_SHADER_REQUIRES_EARLY_DEPTH_STENCIL = 0x00000002;
22 enum uint D3D_SHADER_REQUIRES_UAVS_AT_EVERY_STAGE = 0x00000004;
23 enum uint D3D_SHADER_REQUIRES_64_UAVS = 0x00000008;
24 enum uint D3D_SHADER_REQUIRES_MINIMUM_PRECISION = 0x00000010;
25 enum uint D3D_SHADER_REQUIRES_11_1_DOUBLE_EXTENSIONS = 0x00000020;
26 enum uint D3D_SHADER_REQUIRES_11_1_SHADER_EXTENSIONS = 0x00000040;
27 enum uint D3D_SHADER_REQUIRES_LEVEL_9_COMPARISON_FILTERING = 0x00000080;
28 enum uint D3D_SHADER_REQUIRES_TILED_RESOURCES = 0x00000100;
29 enum uint D3D_SHADER_REQUIRES_STENCIL_REF = 0x00000200;
30 enum uint D3D_SHADER_REQUIRES_INNER_COVERAGE = 0x00000400;
31 enum uint D3D_SHADER_REQUIRES_TYPED_UAV_LOAD_ADDITIONAL_FORMATS = 0x00000800;
32 enum uint D3D_SHADER_REQUIRES_ROVS = 0x00001000;
33 enum uint D3D_SHADER_REQUIRES_VIEWPORT_AND_RT_ARRAY_INDEX_FROM_ANY_SHADER_FEEDING_RASTERIZER = 0x00002000;
34 
35 ///
36 /// Functions
37 ///
38 
39 ///
40 /// Enumerations
41 ///
42 
43 enum D3D12_SHADER_VERSION_TYPE
44 {
45     PIXEL_SHADER    = 0,
46     VERTEX_SHADER   = 1,
47     GEOMETRY_SHADER = 2,
48     HULL_SHADER     = 3,
49     DOMAIN_SHADER   = 4,
50     COMPUTE_SHADER  = 5,
51     RESERVED0       = 0xFFF0,
52 }
53 
54 ///
55 /// Structures
56 ///
57 
58 struct D3D12_SIGNATURE_PARAMETER_DESC
59 {
60     const char *SemanticName; 
61     uint SemanticIndex;
62     uint Register;
63     D3D_NAME SystemValueType;
64     D3D_REGISTER_COMPONENT_TYPE ComponentType;
65     ubyte Mask;
66     ubyte ReadWriteMask;
67     uint Stream;
68     D3D_MIN_PRECISION MinPrecision;
69 }
70 
71 struct D3D12_SHADER_BUFFER_DESC
72 {
73     const char *SemanticName; 
74     D3D_CBUFFER_TYPE Type;
75     uint Variables;
76     uint Size;
77     uint uFlags;
78 }
79 
80 struct D3D12_SHADER_VARIABLE_DESC
81 {
82     const char *SemanticName; 
83     uint StartOffset;
84     uint Size;
85     uint uFlags;
86     void *DefaultValue;
87     uint StartTexture;
88     uint TextureSize;
89     uint StartSampler;
90     uint SamplerSize;
91 }
92 
93 struct D3D12_SHADER_TYPE_DESC
94 {
95     D3D_SHADER_VARIABLE_CLASS Class;
96     D3D_SHADER_VARIABLE_TYPE Type;
97     uint Rows;
98     uint Columns;
99     uint Elements;
100     uint Members;
101     uint Offset;
102     const char *SemanticName; 
103 }
104 
105 struct D3D12_SHADER_DESC
106 {
107     uint Version;
108     const char *Creator;
109     uint Flags;
110     uint ConstantBuffers;
111     uint BoundResources;
112     uint InputParameters;
113     uint OutputParameters;
114     uint InstructionCount;
115     uint TempRegisterCount;
116     uint TempArrayCount;
117     uint DefCount;
118     uint DclCount;
119     uint TextureNormalInstructions;
120     uint TextureLoadInstructions;
121     uint TextureCompInstructions;
122     uint TextureBiasInstructions;
123     uint TextureGradientInstructions;
124     uint FloatInstructionCount;
125     uint IntInstructionCount;
126     uint UintInstructionCount;
127     uint StaticFlowControlCount;
128     uint DynamicFlowControlCount;
129     uint MacroInstructionCount;
130     uint ArrayInstructionCount;
131     uint CutInstructionCount;
132     uint EmitInstructionCount;
133     D3D_PRIMITIVE_TOPOLOGY GSOutputTopology;
134     uint GSMaxOutputVertexCount;
135     D3D_PRIMITIVE InputPrimitive;
136     uint PatchConstantParameters;
137     uint cGSInstanceCount;
138     uint cControlPoints;
139     D3D_TESSELLATOR_OUTPUT_PRIMITIVE HSOutputPrimitive;
140     D3D_TESSELLATOR_PARTITIONING HSPartitioning;
141     D3D_TESSELLATOR_DOMAIN TessellatorDomain;
142     uint cBarrierInstructions;
143     uint cInterlockedInstructions;
144     uint cTextureStoreInstructions;
145 }
146 
147 struct D3D12_SHADER_INPUT_BIND_DESC
148 {
149     const char *Name;
150     D3D_SHADER_INPUT_TYPE Type;
151     uint BindPoint;
152     uint BindCount;
153     uint uFlags;
154     D3D_RESOURCE_RETURN_TYPE ReturnType;
155     D3D_SRV_DIMENSION Dimension;
156     uint NumSamples;
157     uint Space;
158     uint uID;
159 }
160 
161 struct D3D12_LIBRARY_DESC
162 {
163     const char *Creator;
164     uint Flags;
165     uint FunctionCount;
166 }
167 
168 struct D3D12_FUNCTION_DESC
169 {
170     uint Version;
171     const char *Creator;
172     uint Flags;    
173     uint ConstantBuffers;
174     uint BoundResources;
175     uint InstructionCount;
176     uint TempRegisterCount;
177     uint TempArrayCount;
178     uint DefCount;
179     uint DclCount;
180     uint TextureNormalInstructions;
181     uint TextureLoadInstructions;
182     uint TextureCompInstructions;
183     uint TextureBiasInstructions;
184     uint TextureGradientInstructions;
185     uint FloatInstructionCount;
186     uint IntInstructionCount;
187     uint UintInstructionCount;
188     uint StaticFlowControlCount;
189     uint DynamicFlowControlCount;
190     uint MacroInstructionCount;
191     uint ArrayInstructionCount;
192     uint MovInstructionCount;
193     uint MovcInstructionCount;
194     uint ConversionInstructionCount;
195     uint BitwiseInstructionCount;
196     D3D_FEATURE_LEVEL MinFeatureLevel;
197     ulong RequiredFeatureFlags;
198     const char *Name;
199     int FunctionParameterCount;
200     bool HasReturn;
201     bool Has10Level9VertexShader;
202     bool Has10Level9PixelShader;
203 }
204 
205 struct D3D12_PARAMETER_DESC
206 {
207     const char *Name;
208     const char *SemanticName;
209     D3D_SHADER_VARIABLE_TYPE Type;
210     D3D_SHADER_VARIABLE_CLASS Class;
211     uint Rows;
212     uint Columns;
213     D3D_INTERPOLATION_MODE InterpolationMode;
214     D3D_PARAMETER_FLAGS Flags;
215     uint FirstInRegister;
216     uint FirstInComponent;
217     uint FirstOutRegister;
218     uint FirstOutComponent;
219 }
220 
221 ///
222 /// Interfaces
223 ///
224 
225 mixin(uuid!(ID3D12ShaderReflectionType, "E913C351-783D-48CA-A1D1-4F306284AD56"));
226 public interface ID3D12ShaderReflectionType : IUnknown
227 {
228 extern(Windows):
229 	ID3D12ShaderReflectionType GetBaseClass();
230     HRESULT GetDesc(D3D12_SHADER_TYPE_DESC *pDesc);
231     ID3D12ShaderReflectionType GetInterfaceByIndex(uint uIndex);
232     ID3D12ShaderReflectionType GetMemberTypeByIndex(uint Index);
233     ID3D12ShaderReflectionType GetMemberTypeByName(const char *Name);
234     const char* GetMemberTypeName(uint Index);
235     uint GetNumInterfaces();
236     ID3D12ShaderReflectionType GetSubType();
237     HRESULT ImplementsInterface(ID3D12ShaderReflectionType pBase);
238     HRESULT IsEqual(ID3D12ShaderReflectionType pType);
239     HRESULT IsOfType(ID3D12ShaderReflectionType pType);
240 }
241 
242 mixin(uuid!(ID3D12ShaderReflectionVariable, "8337A8A6-A216-444A-B2F4-314733A73AEA"));
243 public interface ID3D12ShaderReflectionVariable : IUnknown
244 {
245 extern(Windows):
246 	ID3D12ShaderReflectionConstantBuffer GetBuffer();
247     HRESULT GetDesc(D3D12_SHADER_VARIABLE_DESC *pDesc);
248     uint GetInterfaceSlot(uint uArrayIndex);
249     ID3D12ShaderReflectionType GetType();
250 }
251 
252 mixin(uuid!(ID3D12ShaderReflectionConstantBuffer, "C59598B4-48B3-4869-B9B1-B1618B14A8B7"));
253 public interface ID3D12ShaderReflectionConstantBuffer : IUnknown
254 {
255 extern(Windows):
256 	HRESULT GetDesc(D3D12_SHADER_BUFFER_DESC *pDesc);
257     ID3D12ShaderReflectionVariable GetVariableByIndex(uint Index);
258     ID3D12ShaderReflectionVariable GetVariableByName(const char *Name);
259 }
260 
261 mixin(uuid!(ID3D12ShaderReflection, "5A58797D-A72C-478D-8BA2-EFC6B0EFE88E"));
262 public interface ID3D12ShaderReflection : IUnknown
263 {
264 extern(Windows):
265 	uint GetBitwiseInstructionCount();
266     ID3D12ShaderReflectionConstantBuffer GetConstantBufferByIndex(uint Index);
267     ID3D12ShaderReflectionConstantBuffer GetConstantBufferByName(const char *Name);
268     uint GetConversionInstructionCount();
269     HRESULT GetDesc(D3D12_SHADER_DESC *pDesc);
270     D3D_PRIMITIVE GetGSInputPrimitive();
271     HRESULT GetMinFeatureLevel(D3D_FEATURE_LEVEL *pLevel);
272     uint GetMovcInstructionCount();
273     uint GetMovInstructionCount();
274     uint GetNumInterfaceSlots();
275     HRESULT GetOutputParameterDesc(uint ParameterIndex, D3D12_SIGNATURE_PARAMETER_DESC *pDesc);
276     HRESULT GetPatchConstantParameterDesc(uint ParameterIndex, D3D12_SIGNATURE_PARAMETER_DESC *pDesc);
277     ulong GetRequiresFlags();
278     HRESULT GetResourceBindingDesc(uint ResourceIndex, D3D12_SHADER_INPUT_BIND_DESC *pDesc);
279     HRESULT GetResourceBindingDescByName(const char *Name, D3D12_SHADER_INPUT_BIND_DESC *pDesc);
280     uint GetThreadGroupSize(uint *pSizeX, uint *pSizeY, uint *pSizeZ);
281     ID3D12ShaderReflectionVariable GetVariableByName(const char *Name);
282     bool IsSampleFrequencyShader();
283 }
284 
285 mixin(uuid!(ID3D12LibraryReflection, "8E349D19-54DB-4A56-9DC9-119D87BDB804"));
286 public interface ID3D12LibraryReflection : IUnknown
287 {
288 extern(Windows):
289 	HRESULT GetDesc(D3D12_LIBRARY_DESC *pDesc);
290     ID3D12FunctionReflection GetFunctionByIndex(int FunctionIndex);
291 }
292 
293 mixin(uuid!(ID3D12FunctionReflection, "1108795C-2772-4BA9-B2A8-D464DC7E2799"));
294 public interface ID3D12FunctionReflection : IUnknown
295 {
296 extern(Windows):
297 	ID3D12ShaderReflectionConstantBuffer GetConstantBufferByIndex(uint BufferIndex);
298     ID3D12ShaderReflectionConstantBuffer GetConstantBufferByName(const char *Name);
299     HRESULT GetDesc(D3D12_FUNCTION_DESC *pDesc);
300     ID3D12FunctionParameterReflection GetFunctionParameter(int ParameterIndex);
301     HRESULT GetResourceBindingDesc(uint ResourceIndex, D3D12_SHADER_INPUT_BIND_DESC *pDesc);
302     HRESULT GetResourceBindingDescByName(const char *Name, D3D12_SHADER_INPUT_BIND_DESC *pDesc);
303     ID3D12ShaderReflectionVariable GetVariableByName(const char *Name);
304 }
305 
306 mixin(uuid!(ID3D12FunctionParameterReflection, "EC25F42D-7006-4F2B-B33E-02CC3375733F"));
307 public interface ID3D12FunctionParameterReflection : IUnknown
308 {
309 extern(Windows):
310     HRESULT GetDesc(D3D12_PARAMETER_DESC *pDesc);
311 }