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.
6 use ctypes::c_void;
7 use shared::basetsd::SIZE_T;
8 use shared::guiddef::REFIID;
9 use shared::minwindef::{BOOL, DWORD, LPCVOID, LPVOID, UINT};
10 use um::d3d11shader::{ID3D11FunctionLinkingGraph, ID3D11Linker, ID3D11Module};
11 use um::d3dcommon::{D3D_SHADER_MACRO, ID3DBlob, ID3DInclude};
12 use um::winnt::{HRESULT, LPCSTR, LPCWSTR};
13 pub const D3DCOMPILER_DLL: &'static str = "d3dcompiler_47.dll";
14 pub const D3D_COMPILER_VERSION: DWORD = 47;
15 extern "system" {
D3DReadFileToBlob( pFileName: LPCWSTR, ppContents: *mut *mut ID3DBlob, ) -> HRESULT16     pub fn D3DReadFileToBlob(
17         pFileName: LPCWSTR,
18         ppContents: *mut *mut ID3DBlob,
19     ) -> HRESULT;
D3DWriteBlobToFile( pBlob: *mut ID3DBlob, pFileName: LPCWSTR, bOverwrite: BOOL, ) -> HRESULT20     pub fn D3DWriteBlobToFile(
21         pBlob: *mut ID3DBlob,
22         pFileName: LPCWSTR,
23         bOverwrite: BOOL,
24     ) -> HRESULT;
25 }
26 pub const D3DCOMPILE_DEBUG: DWORD = 1 << 0;
27 pub const D3DCOMPILE_SKIP_VALIDATION: DWORD = 1 << 1;
28 pub const D3DCOMPILE_SKIP_OPTIMIZATION: DWORD = 1 << 2;
29 pub const D3DCOMPILE_PACK_MATRIX_ROW_MAJOR: DWORD = 1 << 3;
30 pub const D3DCOMPILE_PACK_MATRIX_COLUMN_MAJOR: DWORD = 1 << 4;
31 pub const D3DCOMPILE_PARTIAL_PRECISION: DWORD = 1 << 5;
32 pub const D3DCOMPILE_FORCE_VS_SOFTWARE_NO_OPT: DWORD = 1 << 6;
33 pub const D3DCOMPILE_FORCE_PS_SOFTWARE_NO_OPT: DWORD = 1 << 7;
34 pub const D3DCOMPILE_NO_PRESHADER: DWORD = 1 << 8;
35 pub const D3DCOMPILE_AVOID_FLOW_CONTROL: DWORD = 1 << 9;
36 pub const D3DCOMPILE_PREFER_FLOW_CONTROL: DWORD = 1 << 10;
37 pub const D3DCOMPILE_ENABLE_STRICTNESS: DWORD = 1 << 11;
38 pub const D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY: DWORD = 1 << 12;
39 pub const D3DCOMPILE_IEEE_STRICTNESS: DWORD = 1 << 13;
40 pub const D3DCOMPILE_OPTIMIZATION_LEVEL0: DWORD = 1 << 14;
41 pub const D3DCOMPILE_OPTIMIZATION_LEVEL1: DWORD = 0;
42 pub const D3DCOMPILE_OPTIMIZATION_LEVEL2: DWORD = (1 << 14) | (1 << 15);
43 pub const D3DCOMPILE_OPTIMIZATION_LEVEL3: DWORD = 1 << 15;
44 pub const D3DCOMPILE_RESERVED16: DWORD = 1 << 16;
45 pub const D3DCOMPILE_RESERVED17: DWORD = 1 << 17;
46 pub const D3DCOMPILE_WARNINGS_ARE_ERRORS: DWORD = 1 << 18;
47 pub const D3DCOMPILE_RESOURCES_MAY_ALIAS: DWORD = 1 << 19;
48 pub const D3DCOMPILE_ENABLE_UNBOUNDED_DESCRIPTOR_TABLES: DWORD = 1 << 20;
49 pub const D3DCOMPILE_ALL_RESOURCES_BOUND: DWORD = 1 << 21;
50 pub const D3DCOMPILE_EFFECT_CHILD_EFFECT: DWORD = 1 << 0;
51 pub const D3DCOMPILE_EFFECT_ALLOW_SLOW_OPS: DWORD = 1 << 1;
52 pub const D3D_COMPILE_STANDARD_FILE_INCLUDE: *mut ID3DInclude = 1 as *mut ID3DInclude;
53 extern "system" {
D3DCompile( pSrcData: LPCVOID, SrcDataSize: SIZE_T, pSourceName: LPCSTR, pDefines: *const D3D_SHADER_MACRO, pInclude: *mut ID3DInclude, pEntrypoint: LPCSTR, pTarget: LPCSTR, Flags1: UINT, Flags2: UINT, ppCode: *mut *mut ID3DBlob, ppErrorMsgs: *mut *mut ID3DBlob, ) -> HRESULT54     pub fn D3DCompile(
55         pSrcData: LPCVOID,
56         SrcDataSize: SIZE_T,
57         pSourceName: LPCSTR,
58         pDefines: *const D3D_SHADER_MACRO,
59         pInclude: *mut ID3DInclude,
60         pEntrypoint: LPCSTR,
61         pTarget: LPCSTR,
62         Flags1: UINT,
63         Flags2: UINT,
64         ppCode: *mut *mut ID3DBlob,
65         ppErrorMsgs: *mut *mut ID3DBlob,
66     ) -> HRESULT;
67 }
68 pub const D3DCOMPILE_SECDATA_MERGE_UAV_SLOTS: DWORD = 0x00000001;
69 pub const D3DCOMPILE_SECDATA_PRESERVE_TEMPLATE_SLOTS: DWORD = 0x00000002;
70 pub const D3DCOMPILE_SECDATA_REQUIRE_TEMPLATE_MATCH: DWORD = 0x00000004;
71 extern "system" {
D3DCompile2( pSrcData: LPCVOID, SrcDataSize: SIZE_T, pSourceName: LPCSTR, pDefines: *const D3D_SHADER_MACRO, pInclude: *mut ID3DInclude, pEntrypoint: LPCSTR, pTarget: LPCSTR, Flags1: UINT, Flags2: UINT, SecondaryDataFlags: UINT, pSecondaryData: LPCVOID, SecondaryDataSize: SIZE_T, ppCode: *mut *mut ID3DBlob, ppErrorMsgs: *mut *mut ID3DBlob, ) -> HRESULT72     pub fn D3DCompile2(
73         pSrcData: LPCVOID,
74         SrcDataSize: SIZE_T,
75         pSourceName: LPCSTR,
76         pDefines: *const D3D_SHADER_MACRO,
77         pInclude: *mut ID3DInclude,
78         pEntrypoint: LPCSTR,
79         pTarget: LPCSTR,
80         Flags1: UINT,
81         Flags2: UINT,
82         SecondaryDataFlags: UINT,
83         pSecondaryData: LPCVOID,
84         SecondaryDataSize: SIZE_T,
85         ppCode: *mut *mut ID3DBlob,
86         ppErrorMsgs: *mut *mut ID3DBlob,
87     ) -> HRESULT;
D3DCompileFromFile( pFileName: LPCWSTR, pDefines: *const D3D_SHADER_MACRO, pInclude: *mut ID3DInclude, pEntrypoint: LPCSTR, pTarget: LPCSTR, Flags1: UINT, Flags2: UINT, ppCode: *mut *mut ID3DBlob, ppErrorMsgs: *mut *mut ID3DBlob, ) -> HRESULT88     pub fn D3DCompileFromFile(
89         pFileName: LPCWSTR,
90         pDefines: *const D3D_SHADER_MACRO,
91         pInclude: *mut ID3DInclude,
92         pEntrypoint: LPCSTR,
93         pTarget: LPCSTR,
94         Flags1: UINT,
95         Flags2: UINT,
96         ppCode: *mut *mut ID3DBlob,
97         ppErrorMsgs: *mut *mut ID3DBlob,
98     ) -> HRESULT;
D3DPreprocess( pSrcData: LPCVOID, SrcDataSize: SIZE_T, pSourceName: LPCSTR, pDefines: *const D3D_SHADER_MACRO, pInclude: *mut ID3DInclude, ppCodeText: *mut *mut ID3DBlob, ppErrorMsgs: *mut *mut ID3DBlob, ) -> HRESULT99     pub fn D3DPreprocess(
100         pSrcData: LPCVOID,
101         SrcDataSize: SIZE_T,
102         pSourceName: LPCSTR,
103         pDefines: *const D3D_SHADER_MACRO,
104         pInclude: *mut ID3DInclude,
105         ppCodeText: *mut *mut ID3DBlob,
106         ppErrorMsgs: *mut *mut ID3DBlob,
107     ) -> HRESULT;
D3DGetDebugInfo( pSrcData: LPCVOID, SrcDataSize: SIZE_T, ppDebugInfo: *mut *mut ID3DBlob, ) -> HRESULT108     pub fn D3DGetDebugInfo(
109         pSrcData: LPCVOID,
110         SrcDataSize: SIZE_T,
111         ppDebugInfo: *mut *mut ID3DBlob,
112     ) -> HRESULT;
D3DReflect( pSrcData: LPCVOID, SrcDataSize: SIZE_T, pInterface: REFIID, ppReflector: *mut *mut c_void, ) -> HRESULT113     pub fn D3DReflect(
114         pSrcData: LPCVOID,
115         SrcDataSize: SIZE_T,
116         pInterface: REFIID,
117         ppReflector: *mut *mut c_void,
118     ) -> HRESULT;
D3DReflectLibrary( pSrcData: LPCVOID, SrcDataSize: SIZE_T, riid: REFIID, ppReflector: *mut LPVOID, ) -> HRESULT119     pub fn D3DReflectLibrary(
120         pSrcData: LPCVOID,
121         SrcDataSize: SIZE_T,
122         riid: REFIID,
123         ppReflector: *mut LPVOID,
124     ) -> HRESULT;
125 }
126 pub const D3D_DISASM_ENABLE_COLOR_CODE: DWORD = 0x00000001;
127 pub const D3D_DISASM_ENABLE_DEFAULT_VALUE_PRINTS: DWORD = 0x00000002;
128 pub const D3D_DISASM_ENABLE_INSTRUCTION_NUMBERING: DWORD = 0x00000004;
129 pub const D3D_DISASM_ENABLE_INSTRUCTION_CYCLE: DWORD = 0x00000008;
130 pub const D3D_DISASM_DISABLE_DEBUG_INFO: DWORD = 0x00000010;
131 pub const D3D_DISASM_ENABLE_INSTRUCTION_OFFSET: DWORD = 0x00000020;
132 pub const D3D_DISASM_INSTRUCTION_ONLY: DWORD = 0x00000040;
133 pub const D3D_DISASM_PRINT_HEX_LITERALS: DWORD = 0x00000080;
134 extern "system" {
D3DDisassemble( pSrcData: LPCVOID, SrcDataSize: SIZE_T, Flags: UINT, szComments: LPCSTR, ppDisassembly: *mut *mut ID3DBlob, ) -> HRESULT135     pub fn D3DDisassemble(
136         pSrcData: LPCVOID,
137         SrcDataSize: SIZE_T,
138         Flags: UINT,
139         szComments: LPCSTR,
140         ppDisassembly: *mut *mut ID3DBlob,
141     ) -> HRESULT;
D3DDisassembleRegion( pSrcData: LPCVOID, SrcDataSize: SIZE_T, Flags: UINT, szComments: LPCSTR, StartByteOffset: SIZE_T, NumInsts: SIZE_T, pFinishByteOffset: *mut SIZE_T, ppDisassembly: *mut *mut ID3DBlob, ) -> HRESULT142     pub fn D3DDisassembleRegion(
143         pSrcData: LPCVOID,
144         SrcDataSize: SIZE_T,
145         Flags: UINT,
146         szComments: LPCSTR,
147         StartByteOffset: SIZE_T,
148         NumInsts: SIZE_T,
149         pFinishByteOffset: *mut SIZE_T,
150         ppDisassembly: *mut *mut ID3DBlob,
151     ) -> HRESULT;
D3DCreateLinker( ppLinker: *mut *mut ID3D11Linker, ) -> HRESULT152     pub fn D3DCreateLinker(
153         ppLinker: *mut *mut ID3D11Linker,
154     ) -> HRESULT;
D3DLoadModule( pSrcData: LPCVOID, cbSrcDataSize: SIZE_T, ppModule: *mut *mut ID3D11Module, ) -> HRESULT155     pub fn D3DLoadModule(
156         pSrcData: LPCVOID,
157         cbSrcDataSize: SIZE_T,
158         ppModule: *mut *mut ID3D11Module,
159     ) -> HRESULT;
D3DCreateFunctionLinkingGraph( uFlags: UINT, ppFunctionLinkingGraph: *mut *mut ID3D11FunctionLinkingGraph, ) -> HRESULT160     pub fn D3DCreateFunctionLinkingGraph(
161         uFlags: UINT,
162         ppFunctionLinkingGraph: *mut *mut ID3D11FunctionLinkingGraph,
163     ) -> HRESULT;
164 }
165 pub const D3D_GET_INST_OFFSETS_INCLUDE_NON_EXECUTABLE: DWORD = 0x00000001;
166 extern "system" {
D3DGetTraceInstructionOffsets( pSrcData: LPCVOID, SrcDataSize: SIZE_T, Flags: UINT, StartInstIndex: SIZE_T, NumInsts: SIZE_T, pOffsets: *mut SIZE_T, pTotalInsts: *mut SIZE_T, ) -> HRESULT167     pub fn D3DGetTraceInstructionOffsets(
168         pSrcData: LPCVOID,
169         SrcDataSize: SIZE_T,
170         Flags: UINT,
171         StartInstIndex: SIZE_T,
172         NumInsts: SIZE_T,
173         pOffsets: *mut SIZE_T,
174         pTotalInsts: *mut SIZE_T,
175     ) -> HRESULT;
D3DGetInputSignatureBlob( pSrcData: LPCVOID, SrcDataSize: SIZE_T, ppSignatureBlob: *mut *mut ID3DBlob, ) -> HRESULT176     pub fn D3DGetInputSignatureBlob(
177         pSrcData: LPCVOID,
178         SrcDataSize: SIZE_T,
179         ppSignatureBlob: *mut *mut ID3DBlob,
180     ) -> HRESULT;
D3DGetOutputSignatureBlob( pSrcData: LPCVOID, SrcDataSize: SIZE_T, ppSignatureBlob: *mut *mut ID3DBlob, ) -> HRESULT181     pub fn D3DGetOutputSignatureBlob(
182         pSrcData: LPCVOID,
183         SrcDataSize: SIZE_T,
184         ppSignatureBlob: *mut *mut ID3DBlob,
185     ) -> HRESULT;
D3DGetInputAndOutputSignatureBlob( pSrcData: LPCVOID, SrcDataSize: SIZE_T, ppSignatureBlob: *mut *mut ID3DBlob, ) -> HRESULT186     pub fn D3DGetInputAndOutputSignatureBlob(
187         pSrcData: LPCVOID,
188         SrcDataSize: SIZE_T,
189         ppSignatureBlob: *mut *mut ID3DBlob,
190     ) -> HRESULT;
191 }
192 ENUM!{enum D3DCOMPILER_STRIP_FLAGS {
193     D3DCOMPILER_STRIP_REFLECTION_DATA = 0x00000001,
194     D3DCOMPILER_STRIP_DEBUG_INFO = 0x00000002,
195     D3DCOMPILER_STRIP_TEST_BLOBS = 0x00000004,
196     D3DCOMPILER_STRIP_PRIVATE_DATA = 0x00000008,
197     D3DCOMPILER_STRIP_ROOT_SIGNATURE = 0x00000010,
198     D3DCOMPILER_STRIP_FORCE_DWORD = 0x7fffffff,
199 }}
200 extern "system" {
D3DStripShader( pShaderBytecode: LPCVOID, BytecodeLength: SIZE_T, uStripFlags: UINT, ppStrippedBlob: *mut *mut ID3DBlob, ) -> HRESULT201     pub fn D3DStripShader(
202         pShaderBytecode: LPCVOID,
203         BytecodeLength: SIZE_T,
204         uStripFlags: UINT,
205         ppStrippedBlob: *mut *mut ID3DBlob,
206     ) -> HRESULT;
207 }
208 ENUM!{enum D3D_BLOB_PART {
209     D3D_BLOB_INPUT_SIGNATURE_BLOB,
210     D3D_BLOB_OUTPUT_SIGNATURE_BLOB,
211     D3D_BLOB_INPUT_AND_OUTPUT_SIGNATURE_BLOB,
212     D3D_BLOB_PATCH_CONSTANT_SIGNATURE_BLOB,
213     D3D_BLOB_ALL_SIGNATURE_BLOB,
214     D3D_BLOB_DEBUG_INFO,
215     D3D_BLOB_LEGACY_SHADER,
216     D3D_BLOB_XNA_PREPASS_SHADER,
217     D3D_BLOB_XNA_SHADER,
218     D3D_BLOB_PDB,
219     D3D_BLOB_PRIVATE_DATA,
220     D3D_BLOB_ROOT_SIGNATURE,
221     D3D_BLOB_TEST_ALTERNATE_SHADER = 0x8000,
222     D3D_BLOB_TEST_COMPILE_DETAILS,
223     D3D_BLOB_TEST_COMPILE_PERF,
224     D3D_BLOB_TEST_COMPILE_REPORT,
225 }}
226 extern "system" {
D3DGetBlobPart( pSrcData: LPCVOID, SrcDataSize: SIZE_T, Part: D3D_BLOB_PART, Flags: UINT, ppPart: *mut *mut ID3DBlob, ) -> HRESULT227     pub fn D3DGetBlobPart(
228         pSrcData: LPCVOID,
229         SrcDataSize: SIZE_T,
230         Part: D3D_BLOB_PART,
231         Flags: UINT,
232         ppPart: *mut *mut ID3DBlob,
233     ) -> HRESULT;
D3DSetBlobPart( pSrcData: LPCVOID, SrcDataSize: SIZE_T, Part: D3D_BLOB_PART, Flags: UINT, pPart: LPCVOID, PartSize: SIZE_T, ppNewShader: *mut *mut ID3DBlob, ) -> HRESULT234     pub fn D3DSetBlobPart(
235         pSrcData: LPCVOID,
236         SrcDataSize: SIZE_T,
237         Part: D3D_BLOB_PART,
238         Flags: UINT,
239         pPart: LPCVOID,
240         PartSize: SIZE_T,
241         ppNewShader: *mut *mut ID3DBlob,
242     ) -> HRESULT;
D3DCreateBlob( Size: SIZE_T, ppBlob: *mut *mut ID3DBlob, ) -> HRESULT243     pub fn D3DCreateBlob(
244         Size: SIZE_T,
245         ppBlob: *mut *mut ID3DBlob,
246     ) -> HRESULT;
247 }
248 STRUCT!{struct D3D_SHADER_DATA {
249     pBytecode: LPCVOID,
250     BytecodeLength: SIZE_T,
251 }}
252 extern "system" {
D3DCompressShaders( uNumShaders: UINT, pShaderData: *mut D3D_SHADER_DATA, uFlags: UINT, ppCompressedData: *mut *mut ID3DBlob, ) -> HRESULT253     pub fn D3DCompressShaders(
254         uNumShaders: UINT,
255         pShaderData: *mut D3D_SHADER_DATA,
256         uFlags: UINT,
257         ppCompressedData: *mut *mut ID3DBlob,
258     ) -> HRESULT;
D3DDecompressShaders( pSrcData: LPCVOID, SrcDataSize: SIZE_T, uNumShaders: UINT, uStartIndex: UINT, pIndices: *mut UINT, uFlags: UINT, ppShaders: *mut *mut ID3DBlob, pTotalShaders: *mut UINT, ) -> HRESULT259     pub fn D3DDecompressShaders(
260         pSrcData: LPCVOID,
261         SrcDataSize: SIZE_T,
262         uNumShaders: UINT,
263         uStartIndex: UINT,
264         pIndices: *mut UINT,
265         uFlags: UINT,
266         ppShaders: *mut *mut ID3DBlob,
267         pTotalShaders: *mut UINT,
268     ) -> HRESULT;
269     // pub fn D3DDisassemble10Effect(
270     //     pEffect: *mut ID3D10Effect,
271     //     Flags: UINT,
272     //     ppDisassembly: *mut *mut ID3DBlob,
273     // ) -> HRESULT;
274 }
275