winapi_ui_automation/um/
d3d12shader.rs

1// Licensed under the Apache License, Version 2.0
2// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
3// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
4// All files in the project carrying such notice may not be copied, modified, or distributed
5// except according to those terms.
6use shared::basetsd::UINT64;
7use shared::minwindef::{BOOL, BYTE, INT, LPVOID, UINT};
8use um::d3dcommon::{
9    D3D_CBUFFER_TYPE, D3D_FEATURE_LEVEL, D3D_INTERPOLATION_MODE, D3D_MIN_PRECISION, D3D_NAME,
10    D3D_PARAMETER_FLAGS, D3D_PRIMITIVE, D3D_PRIMITIVE_TOPOLOGY, D3D_REGISTER_COMPONENT_TYPE,
11    D3D_RESOURCE_RETURN_TYPE, D3D_SHADER_INPUT_TYPE, D3D_SHADER_VARIABLE_CLASS,
12    D3D_SHADER_VARIABLE_TYPE, D3D_SRV_DIMENSION, D3D_TESSELLATOR_DOMAIN,
13    D3D_TESSELLATOR_OUTPUT_PRIMITIVE, D3D_TESSELLATOR_PARTITIONING,
14};
15use um::unknwnbase::{IUnknown, IUnknownVtbl};
16use um::winnt::{HRESULT, LPCSTR};
17ENUM!{enum D3D12_SHADER_VERSION_TYPE {
18    D3D12_SHVER_PIXEL_SHADER = 0x0,
19    D3D12_SHVER_VERTEX_SHADER = 0x1,
20    D3D12_SHVER_GEOMETRY_SHADER = 0x2,
21    D3D12_SHVER_HULL_SHADER = 0x3,
22    D3D12_SHVER_DOMAIN_SHADER = 0x4,
23    D3D12_SHVER_COMPUTE_SHADER = 0x5,
24    D3D12_SHVER_RESERVED0 = 0xFFF0,
25}}
26STRUCT!{struct D3D12_FUNCTION_DESC {
27    Version: UINT,
28    Creator: LPCSTR,
29    Flags: UINT,
30    ConstantBuffers: UINT,
31    BoundResources: UINT,
32    InstructionCount: UINT,
33    TempRegisterCount: UINT,
34    TempArrayCount: UINT,
35    DefCount: UINT,
36    DclCount: UINT,
37    TextureNormalInstructions: UINT,
38    TextureLoadInstructions: UINT,
39    TextureCompInstructions: UINT,
40    TextureBiasInstructions: UINT,
41    TextureGradientInstructions: UINT,
42    FloatInstructionCount: UINT,
43    IntInstructionCount: UINT,
44    UintInstructionCount: UINT,
45    StaticFlowControlCount: UINT,
46    DynamicFlowControlCount: UINT,
47    MacroInstructionCount: UINT,
48    ArrayInstructionCount: UINT,
49    MovInstructionCount: UINT,
50    MovcInstructionCount: UINT,
51    ConversionInstructionCount: UINT,
52    BitwiseInstructionCount: UINT,
53    MinFeatureLevel: D3D_FEATURE_LEVEL,
54    RequiredFeatureFlags: UINT64,
55    Name: LPCSTR,
56    FunctionParameterCount: INT,
57    HasReturn: BOOL,
58    Has10Level9VertexShader: BOOL,
59    Has10Level9PixelShader: BOOL,
60}}
61STRUCT!{struct D3D12_LIBRARY_DESC {
62    Creator: LPCSTR,
63    Flags: UINT,
64    FunctionCount: UINT,
65}}
66STRUCT!{struct D3D12_PARAMETER_DESC {
67    Name: LPCSTR,
68    SemanticName: LPCSTR,
69    Type: D3D_SHADER_VARIABLE_TYPE,
70    Class: D3D_SHADER_VARIABLE_CLASS,
71    Rows: UINT,
72    Columns: UINT,
73    InterpolationMode: D3D_INTERPOLATION_MODE,
74    Flags: D3D_PARAMETER_FLAGS,
75    FirstInRegister: UINT,
76    FirstInComponent: UINT,
77    FirstOutRegister: UINT,
78    FirstOutComponent: UINT,
79}}
80STRUCT!{struct D3D12_SHADER_BUFFER_DESC {
81    Name: LPCSTR,
82    Type: D3D_CBUFFER_TYPE,
83    Variables: UINT,
84    Size: UINT,
85    uFlags: UINT,
86}}
87STRUCT!{struct D3D12_SHADER_DESC {
88    Version: UINT,
89    Creator: LPCSTR,
90    Flags: UINT,
91    ConstantBuffers: UINT,
92    BoundResources: UINT,
93    InputParameters: UINT,
94    OutputParameters: UINT,
95    InstructionCount: UINT,
96    TempRegisterCount: UINT,
97    TempArrayCount: UINT,
98    DefCount: UINT,
99    DclCount: UINT,
100    TextureNormalInstructions: UINT,
101    TextureLoadInstructions: UINT,
102    TextureCompInstructions: UINT,
103    TextureBiasInstructions: UINT,
104    TextureGradientInstructions: UINT,
105    FloatInstructionCount: UINT,
106    IntInstructionCount: UINT,
107    UintInstructionCount: UINT,
108    StaticFlowControlCount: UINT,
109    DynamicFlowControlCount: UINT,
110    MacroInstructionCount: UINT,
111    ArrayInstructionCount: UINT,
112    CutInstructionCount: UINT,
113    EmitInstructionCount: UINT,
114    GSOutputTopology: D3D_PRIMITIVE_TOPOLOGY,
115    GSMaxOutputVertexCount: UINT,
116    InputPrimitive: D3D_PRIMITIVE,
117    PatchConstantParameters: UINT,
118    cGSInstanceCount: UINT,
119    cControlPoints: UINT,
120    HSOutputPrimitive: D3D_TESSELLATOR_OUTPUT_PRIMITIVE,
121    HSPartitioning: D3D_TESSELLATOR_PARTITIONING,
122    TessellatorDomain: D3D_TESSELLATOR_DOMAIN,
123    cBarrierInstructions: UINT,
124    cInterlockedInstructions: UINT,
125    cTextureStoreInstructions: UINT,
126}}
127STRUCT!{struct D3D12_SHADER_INPUT_BIND_DESC {
128    Name: LPCSTR,
129    Type: D3D_SHADER_INPUT_TYPE,
130    BindPoint: UINT,
131    BindCount: UINT,
132    uFlags: UINT,
133    ReturnType: D3D_RESOURCE_RETURN_TYPE,
134    Dimension: D3D_SRV_DIMENSION,
135    NumSamples: UINT,
136    Space: UINT,
137    uID: UINT,
138}}
139STRUCT!{struct D3D12_SHADER_TYPE_DESC {
140    Class: D3D_SHADER_VARIABLE_CLASS,
141    Type: D3D_SHADER_VARIABLE_TYPE,
142    Rows: UINT,
143    Columns: UINT,
144    Elements: UINT,
145    Members: UINT,
146    Offset: UINT,
147    Name: LPCSTR,
148}}
149STRUCT!{struct D3D12_SHADER_VARIABLE_DESC {
150    Name: LPCSTR,
151    StartOffset: UINT,
152    Size: UINT,
153    uFlags: UINT,
154    DefaultValue: LPVOID,
155    StartTexture: UINT,
156    TextureSize: UINT,
157    StartSampler: UINT,
158    SamplerSize: UINT,
159}}
160STRUCT!{struct D3D12_SIGNATURE_PARAMETER_DESC {
161    SemanticName: LPCSTR,
162    SemanticIndex: UINT,
163    Register: UINT,
164    SystemValueType: D3D_NAME,
165    ComponentType: D3D_REGISTER_COMPONENT_TYPE,
166    Mask: BYTE,
167    ReadWriteMask: BYTE,
168    Stream: UINT,
169    MinPrecision: D3D_MIN_PRECISION,
170}}
171RIDL!{#[uuid(0xec25f42d, 0x7006, 0x4f2b, 0xb3, 0x3e, 0x02, 0xcc, 0x33, 0x75, 0x73, 0x3f)]
172interface ID3D12FunctionParameterReflection(ID3D12FunctionParameterReflectionVtbl) {
173    fn GetDesc(
174        pDesc: *mut D3D12_PARAMETER_DESC,
175    ) -> HRESULT,
176}}
177RIDL!{#[uuid(0x1108795c, 0x2772, 0x4ba9, 0xb2, 0xa8, 0xd4, 0x64, 0xdc, 0x7e, 0x27, 0x99)]
178interface ID3D12FunctionReflection(ID3D12FunctionReflectionVtbl) {
179    fn GetDesc(
180        pDesc: *mut D3D12_FUNCTION_DESC,
181    ) -> HRESULT,
182    fn GetConstantBufferByIndex(
183        BufferIndex: UINT,
184    ) -> *mut ID3D12ShaderReflectionConstantBuffer,
185    fn GetConstantBufferByName(
186        Name: LPCSTR,
187    ) -> *mut ID3D12ShaderReflectionConstantBuffer,
188    fn GetResourceBindingDesc(
189        ResourceIndex: UINT,
190        pDesc: *mut D3D12_SHADER_INPUT_BIND_DESC,
191    ) -> HRESULT,
192    fn GetVariableByName(
193        Name: LPCSTR,
194    ) -> *mut ID3D12ShaderReflectionVariable,
195    fn GetResourceBindingDescByName(
196        Name: LPCSTR,
197        pDesc: *mut D3D12_SHADER_INPUT_BIND_DESC,
198    ) -> HRESULT,
199    fn GetFunctionParameter(
200        ParameterIndex: INT,
201    ) -> *mut ID3D12FunctionParameterReflection,
202}}
203RIDL!{#[uuid(0x8e349d19, 0x54db, 0x4a56, 0x9d, 0xc9, 0x11, 0x9d, 0x87, 0xbd, 0xb8, 0x4)]
204interface ID3D12LibraryReflection(ID3D12LibraryReflectionVtbl): IUnknown(IUnknownVtbl) {
205    fn GetDesc(
206        pDesc: *mut D3D12_LIBRARY_DESC,
207    ) -> HRESULT,
208    fn GetFunctionByIndex(
209        FunctionIndex: INT,
210    ) -> *mut ID3D12FunctionReflection,
211}}
212DEFINE_GUID!{IID_ID3D12ShaderReflectionConstantBuffer,
213    0xc59598b4, 0x48b3, 0x4869, 0xb9, 0xb1, 0xb1, 0x61, 0x8b, 0x14, 0xa8, 0xb7}
214RIDL!{#[uuid(0xc59598b4, 0x48b3, 0x4869, 0xb9, 0xb1, 0xb1, 0x61, 0x8b, 0x14, 0xa8, 0xb7)]
215interface ID3D12ShaderReflectionConstantBuffer(ID3D12ShaderReflectionConstantBufferVtbl) {
216    fn GetDesc(
217        pDesc: *mut D3D12_SHADER_BUFFER_DESC,
218    ) -> HRESULT,
219    fn GetVariableByIndex(
220        Index: UINT,
221    ) -> *mut ID3D12ShaderReflectionVariable,
222    fn GetVariableByName(
223        Name: LPCSTR,
224    ) -> *mut ID3D12ShaderReflectionVariable,
225}}
226DEFINE_GUID!{IID_ID3D12ShaderReflectionType,
227    0xe913c351, 0x783d, 0x48ca, 0xa1, 0xd1, 0x4f, 0x30, 0x62, 0x84, 0xad, 0x56}
228RIDL!{#[uuid(0xe913c351, 0x783d, 0x48ca, 0xa1, 0xd1, 0x4f, 0x30, 0x62, 0x84, 0xad, 0x56)]
229interface ID3D12ShaderReflectionType(ID3D12ShaderReflectionTypeVtbl) {
230    fn GetDesc(
231        pDesc: *mut D3D12_SHADER_TYPE_DESC,
232    ) -> HRESULT,
233    fn GetMemberTypeByIndex(
234        Index: UINT,
235    ) -> *mut ID3D12ShaderReflectionType,
236    fn GetMemberTypeByName(
237        Name: LPCSTR,
238    ) -> *mut ID3D12ShaderReflectionType,
239    fn GetMemberTypeName(
240        Index: UINT,
241    ) -> LPCSTR,
242    fn IsEqual(
243        pType: *mut ID3D12ShaderReflectionType,
244    ) -> HRESULT,
245    fn GetSubType() -> *mut ID3D12ShaderReflectionType,
246    fn GetBaseClass() -> *mut ID3D12ShaderReflectionType,
247    fn GetNumInterfaces() -> UINT,
248    fn GetInterfaceByIndex(
249        uIndex: UINT,
250    ) -> *mut ID3D12ShaderReflectionType,
251    fn IsOfType(
252        pType: *mut ID3D12ShaderReflectionType,
253    ) -> HRESULT,
254    fn ImplementsInterface(
255        pBase: *mut ID3D12ShaderReflectionType,
256    ) -> HRESULT,
257}}
258DEFINE_GUID!{IID_ID3D12ShaderReflectionVariable,
259    0x8337a8a6, 0xa216, 0x444a, 0xb2, 0xf4, 0x31, 0x47, 0x33, 0xa7, 0x3a, 0xea}
260RIDL!{#[uuid(0x8337a8a6, 0xa216, 0x444a, 0xb2, 0xf4, 0x31, 0x47, 0x33, 0xa7, 0x3a, 0xea)]
261interface ID3D12ShaderReflectionVariable(ID3D12ShaderReflectionVariableVtbl) {
262    fn GetDesc(
263        pDesc: *mut D3D12_SHADER_VARIABLE_DESC,
264    ) -> HRESULT,
265    fn GetType() -> *mut ID3D12ShaderReflectionType,
266    fn GetBuffer() -> *mut ID3D12ShaderReflectionConstantBuffer,
267    fn GetInterfaceSlot(
268        uArrayIndex: UINT,
269    ) -> UINT,
270}}
271DEFINE_GUID!{IID_ID3D12ShaderReflection,
272    0x5a58797d, 0xa72c, 0x478d, 0x8b, 0xa2, 0xef, 0xc6, 0xb0, 0xef, 0xe8, 0x8e}
273RIDL!{#[uuid(0x5a58797d, 0xa72c, 0x478d, 0x8b, 0xa2, 0xef, 0xc6, 0xb0, 0xef, 0xe8, 0x8e)]
274interface ID3D12ShaderReflection(ID3D12ShaderReflectionVtbl): IUnknown(IUnknownVtbl) {
275    fn GetDesc(
276        pDesc: *mut D3D12_SHADER_DESC,
277    ) -> HRESULT,
278    fn GetConstantBufferByIndex(
279        Index: UINT,
280    ) -> *mut ID3D12ShaderReflectionConstantBuffer,
281    fn GetConstantBufferByName(
282        Name: LPCSTR,
283    ) -> *mut ID3D12ShaderReflectionConstantBuffer,
284    fn GetResourceBindingDesc(
285        ResourceIndex: UINT,
286        pDesc: *mut D3D12_SHADER_INPUT_BIND_DESC,
287    ) -> HRESULT,
288    fn GetInputParameterDesc(
289        ParameterIndex: UINT,
290        pDesc: *mut D3D12_SIGNATURE_PARAMETER_DESC,
291    ) -> HRESULT,
292    fn GetOutputParameterDesc(
293        ParameterIndex: UINT,
294        pDesc: *mut D3D12_SIGNATURE_PARAMETER_DESC,
295    ) -> HRESULT,
296    fn GetPatchConstantParameterDesc(
297        ParameterIndex: UINT,
298        pDesc: *mut D3D12_SIGNATURE_PARAMETER_DESC,
299    ) -> HRESULT,
300    fn GetVariableByName(
301        Name: LPCSTR,
302    ) -> *mut ID3D12ShaderReflectionVariable,
303    fn GetResourceBindingDescByName(
304        Name: LPCSTR,
305        pDesc: *mut D3D12_SHADER_INPUT_BIND_DESC,
306    ) -> HRESULT,
307    fn GetMovInstructionCount() -> UINT,
308    fn GetMovcInstructionCount() -> UINT,
309    fn GetConversionInstructionCount() -> UINT,
310    fn GetBitwiseInstructionCount() -> UINT,
311    fn GetGSInputPrimitive() -> D3D_PRIMITIVE,
312    fn IsSampleFrequencyShader() -> BOOL,
313    fn GetNumInterfaceSlots() -> UINT,
314    fn GetMinFeatureLevel(
315        pLevel: *mut D3D_FEATURE_LEVEL,
316    ) -> HRESULT,
317    fn GetThreadGroupSize(
318        pSizeX: *mut UINT,
319        pSizeY: *mut UINT,
320        pSizeZ: *mut UINT,
321    ) -> UINT,
322    fn GetRequiresFlags() -> UINT64,
323}}
324DEFINE_GUID!{IID_ID3D12LibraryReflection,
325    0x8e349d19, 0x54db, 0x4a56, 0x9d, 0xc9, 0x11, 0x9d, 0x87, 0xbd, 0xb8, 0x04}
326DEFINE_GUID!{IID_ID3D12FunctionReflection,
327    0x1108795c, 0x2772, 0x4ba9, 0xb2, 0xa8, 0xd4, 0x64, 0xdc, 0x7e, 0x27, 0x99}
328DEFINE_GUID!{IID_ID3D12FunctionParameterReflection,
329    0xec25f42d, 0x7006, 0x4f2b, 0xb3, 0x3e, 0x02, 0xcc, 0x33, 0x75, 0x73, 0x3f}
330pub type D3D12_CBUFFER_TYPE = D3D_CBUFFER_TYPE;
331pub type D3D12_RESOURCE_RETURN_TYPE = D3D_RESOURCE_RETURN_TYPE;
332pub type D3D12_TESSELLATOR_DOMAIN = D3D_TESSELLATOR_DOMAIN;
333pub type D3D12_TESSELLATOR_OUTPUT_PRIMITIVE = D3D_TESSELLATOR_OUTPUT_PRIMITIVE;
334pub type D3D12_TESSELLATOR_PARTITIONING = D3D_TESSELLATOR_PARTITIONING;
335pub type LPD3D12FUNCTIONPARAMETERREFLECTION = *mut ID3D12FunctionParameterReflection;
336pub type LPD3D12FUNCTIONREFLECTION = *mut ID3D12FunctionReflection;
337pub type LPD3D12LIBRARYREFLECTION = *mut ID3D12LibraryReflection;
338pub type LPD3D12SHADERREFLECTION = *mut ID3D12ShaderReflection;
339pub type LPD3D12SHADERREFLECTIONCONSTANTBUFFER = *mut ID3D12ShaderReflectionConstantBuffer;
340pub type LPD3D12SHADERREFLECTIONTYPE = *mut ID3D12ShaderReflectionType;
341pub type LPD3D12SHADERREFLECTIONVARIABLE = *mut ID3D12ShaderReflectionVariable;
342pub const D3D_SHADER_REQUIRES_INNER_COVERAGE: UINT64 = 0x00000400;
343pub const D3D_SHADER_REQUIRES_ROVS: UINT64 = 0x00001000;
344pub const D3D_SHADER_REQUIRES_STENCIL_REF: UINT64 = 0x00000200;
345pub const D3D_SHADER_REQUIRES_TYPED_UAV_LOAD_ADDITIONAL_FORMATS: UINT64 = 0x00000800;
346pub const D3D_SHADER_REQUIRES_VIEWPORT_AND_RT_ARRAY_INDEX_FROM_ANY_SHADER_FEEDING_RASTERIZER:
347    UINT64 = 0x00002000;