1 module aurora.directx.d3d.d3dcompiler; 2 3 version(Windows): 4 5 public import aurora.directx.com; 6 public import aurora.directx.d3d.d3dcommon; 7 public import aurora.directx.d3d11.d3d11shader; 8 9 public: 10 11 /// 12 /// Constants 13 /// 14 15 enum wstring D3DCOMPILER_DLL_W = "d3dcompiler_47.dll"; 16 enum string D3DCOMPILER_DLL_A = "d3dcompiler_47.dll"; 17 enum int D3D_COMPILER_VERSION = 47; 18 19 enum int D3DCOMPILE_DEBUG = (1 << 0); 20 enum int D3DCOMPILE_SKIP_VALIDATION = (1 << 1); 21 enum int D3DCOMPILE_SKIP_OPTIMIZATION = (1 << 2); 22 enum int D3DCOMPILE_PACK_MATRIX_ROW_MAJOR = (1 << 3); 23 enum int D3DCOMPILE_PACK_MATRIX_COLUMN_MAJOR = (1 << 4); 24 enum int D3DCOMPILE_PARTIAL_PRECISION = (1 << 5); 25 enum int D3DCOMPILE_FORCE_VS_SOFTWARE_NO_OPT = (1 << 6); 26 enum int D3DCOMPILE_FORCE_PS_SOFTWARE_NO_OPT = (1 << 7); 27 enum int D3DCOMPILE_NO_PRESHADER = (1 << 8); 28 enum int D3DCOMPILE_AVOID_FLOW_CONTROL = (1 << 9); 29 enum int D3DCOMPILE_PREFER_FLOW_CONTROL = (1 << 10); 30 enum int D3DCOMPILE_ENABLE_STRICTNESS = (1 << 11); 31 enum int D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY = (1 << 12); 32 enum int D3DCOMPILE_IEEE_STRICTNESS = (1 << 13); 33 enum int D3DCOMPILE_OPTIMIZATION_LEVEL0 = (1 << 14); 34 enum int D3DCOMPILE_OPTIMIZATION_LEVEL1 = 0; 35 enum int D3DCOMPILE_OPTIMIZATION_LEVEL2 = ((1 << 14) | (1 << 15)); 36 enum int D3DCOMPILE_OPTIMIZATION_LEVEL3 = (1 << 15); 37 enum int D3DCOMPILE_RESERVED16 =(1 << 16); 38 enum int D3DCOMPILE_RESERVED17 = (1 << 17); 39 enum int D3DCOMPILE_WARNINGS_ARE_ERRORS = (1 << 18); 40 enum int D3DCOMPILE_RESOURCES_MAY_ALIAS = (1 << 19); 41 enum int D3DCOMPILE_ENABLE_UNBOUNDED_DESCRIPTOR_TABLES = (1 << 20); 42 enum int D3DCOMPILE_ALL_RESOURCES_BOUND = (1 << 21); 43 enum int D3DCOMPILE_DEBUG_NAME_FOR_SOURCE = (1 << 22); 44 enum int D3DCOMPILE_DEBUG_NAME_FOR_BINARY = (1 << 23); 45 46 enum int D3DCOMPILE_EFFECT_CHILD_EFFECT = (1 << 0); 47 enum int D3DCOMPILE_EFFECT_ALLOW_SLOW_OPS = (1 << 1); 48 49 enum int D3DCOMPILE_FLAGS2_FORCE_ROOT_SIGNATURE_LATEST = 0; 50 enum int D3DCOMPILE_FLAGS2_FORCE_ROOT_SIGNATURE_1_0 = (1 << 4); 51 enum int D3DCOMPILE_FLAGS2_FORCE_ROOT_SIGNATURE_1_1 = (1 << 5); 52 53 enum int D3DCOMPILE_SECDATA_MERGE_UAV_SLOTS = 0x00000001; 54 enum int D3DCOMPILE_SECDATA_PRESERVE_TEMPLATE_SLOTS = 0x00000002; 55 enum int D3DCOMPILE_SECDATA_REQUIRE_TEMPLATE_MATCH = 0x00000004; 56 57 enum int D3D_DISASM_ENABLE_COLOR_CODE = 0x00000001; 58 enum int D3D_DISASM_ENABLE_DEFAULT_VALUE_PRINTS = 0x00000002; 59 enum int D3D_DISASM_ENABLE_INSTRUCTION_NUMBERING = 0x00000004; 60 enum int D3D_DISASM_ENABLE_INSTRUCTION_CYCLE = 0x00000008; 61 enum int D3D_DISASM_DISABLE_DEBUG_INFO = 0x00000010; 62 enum int D3D_DISASM_ENABLE_INSTRUCTION_OFFSET = 0x00000020; 63 enum int D3D_DISASM_INSTRUCTION_ONLY = 0x00000040; 64 enum int D3D_DISASM_PRINT_HEX_LITERALS = 0x00000080; 65 66 enum int D3D_GET_INST_OFFSETS_INCLUDE_NON_EXECUTABLE = 0x00000001; 67 68 enum int D3D_COMPRESS_SHADER_KEEP_ALL_PARTS = 0x00000001; 69 70 /// 71 /// Functions 72 /// 73 74 extern(Windows) { 75 HRESULT D3DReadFileToBlob(const wchar *pFileName, ID3DBlob* ppContents); 76 HRESULT D3DWriteBlobToFile(ID3DBlob pBlob, const wchar *pFileName, bool bOverwrite); 77 HRESULT D3DCompile(const void *pSrcData, size_t SrcDataSize, const char *pSourceName, const D3D_SHADER_MACRO* pDefines, ID3DInclude pInclude, const char *pEntrypoint, const char *pTarget, uint Flags1, uint Flags2, ID3DBlob* ppCode, ID3DBlob* ppErrorMsgs); 78 HRESULT D3DCompile2(const void *pSrcData, size_t SrcDataSize, const char *pSourceName, const D3D_SHADER_MACRO* pDefines, ID3DInclude pInclude, const char *pEntrypoint, const char *pTarget, uint Flags1, uint Flags2, uint SecondaryDataFlags, void *pSecondaryData, size_t SecondaryDataSize, ID3DBlob* ppCode, ID3DBlob* ppErrorMsgs); 79 HRESULT D3DCompileFromFile(const wchar *pFileName, const D3D_SHADER_MACRO* pDefines, ID3DInclude pInclude, const char *pEntrypoint, const char *pTarget, uint Flags1, uint Flags2, ID3DBlob* ppCode, ID3DBlob* ppErrorMsgs); 80 HRESULT D3DPreprocess(const void *pSrcData, size_t SrcDataSize, const char *pSourceName, const D3D_SHADER_MACRO* pDefines, ID3DInclude pInclude, ID3DBlob* ppCodeText, ID3DBlob* ppErrorMsgs); 81 HRESULT D3DGetDebugInfo(const void *pSrcData, size_t SrcDataSize, ID3DBlob* ppDebugInfo); 82 HRESULT D3DReflect(const void *pSrcData, size_t SrcDataSize, REFIID pInterface, void** ppReflector); 83 HRESULT D3DReflectLibrary(const void *pSrcData, size_t SrcDataSize, REFIID riid, void** ppReflector); 84 HRESULT D3DDisassemble(const void *pSrcData, size_t SrcDataSize, uint Flags, const char *szComments, ID3DBlob* ppDisassembly); 85 HRESULT D3DDisassembleRegion(const void *pSrcData, size_t SrcDataSize, uint Flags, const char *szComments, size_t StartByteOffset, size_t NumInsts, size_t* pFinishByteOffset, ID3DBlob* ppDisassembly); 86 HRESULT D3DCreateLinker(ID3D11Linker *ppLinker); 87 HRESULT D3DLoadModule(const void *pSrcData, size_t cbSrcDataSize, ID3D11Module *ppModule); 88 HRESULT D3DCreateFunctionLinkingGraph(uint uFlags, ID3D11FunctionLinkingGraph *ppFunctionLinkingGraph); 89 HRESULT D3DGetTraceInstructionOffsets(const void *pSrcData, size_t SrcDataSize, uint Flags, size_t StartInstIndex, size_t NumInsts, size_t* pOffsets, size_t* pTotalInsts); 90 HRESULT D3DGetInputSignatureBlob(const void *pSrcData, size_t SrcDataSize, ID3DBlob* ppSignatureBlob); 91 HRESULT D3DGetOutputSignatureBlob(void *pSrcData, size_t SrcDataSize, ID3DBlob* ppSignatureBlob); 92 HRESULT D3DGetInputAndOutputSignatureBlob(const void *pSrcData, size_t SrcDataSize, ID3DBlob* ppSignatureBlob); 93 HRESULT D3DStripShader(const void *pShaderBytecode, size_t BytecodeLength, uint uStripFlags, ID3DBlob* ppStrippedBlob); 94 HRESULT D3DGetBlobPart(const void *pSrcData, size_t SrcDataSize, D3D_BLOB_PART Part, uint Flags, ID3DBlob* ppPart); 95 HRESULT D3DSetBlobPart(const void *pSrcData, size_t SrcDataSize, D3D_BLOB_PART Part, uint Flags, const void *pPart, size_t PartSize, ID3DBlob* ppNewShader); 96 HRESULT D3DCreateBlob(size_t Size, ID3DBlob* ppBlob); 97 HRESULT D3DCompressShaders(uint uNumShaders, D3D_SHADER_DATA* pShaderData, uint uFlags, ID3DBlob* ppCompressedData); 98 HRESULT D3DDecompressShaders(const void *pSrcData, size_t SrcDataSize, uint uNumShaders, uint uStartIndex, uint* pIndices, uint uFlags, ID3DBlob* ppShaders, uint* pTotalShaders); 99 } 100 101 /// 102 /// Enumerations 103 /// 104 105 enum D3DCOMPILER_STRIP_FLAGS 106 { 107 REFLECTION_DATA = 0x00000001, 108 DEBUG_INFO = 0x00000002, 109 TEST_BLOBS = 0x00000004, 110 PRIVATE_DATA = 0x00000008, 111 ROOT_SIGNATURE = 0x00000010, 112 FORCE_DWORD = 0x7fffffff, 113 } 114 115 enum D3D_BLOB_PART 116 { 117 INPUT_SIGNATURE_BLOB, 118 OUTPUT_SIGNATURE_BLOB, 119 INPUT_AND_OUTPUT_SIGNATURE_BLOB, 120 PATCH_CONSTANT_SIGNATURE_BLOB, 121 ALL_SIGNATURE_BLOB, 122 DEBUG_INFO, 123 LEGACY_SHADER, 124 XNA_PREPASS_SHADER, 125 XNA_SHADER, 126 PDB, 127 PRIVATE_DATA, 128 ROOT_SIGNATURE, 129 DEBUG_NAME, 130 TEST_ALTERNATE_SHADER = 0x8000, 131 TEST_COMPILE_DETAILS, 132 TEST_COMPILE_PERF, 133 TEST_COMPILE_REPORT, 134 } 135 136 /// 137 /// Structures 138 /// 139 140 struct D3D_SHADER_DATA 141 { 142 const void *pBytecode; 143 size_t BytecodeLength; 144 } 145 146 /// 147 /// Interfaces 148 ///