module external.directx.d3dcompiler;

/*-------------------------------------------------------------------------------------
 *
 * Copyright (c) Microsoft Corporation
 *
 *-------------------------------------------------------------------------------------*/
// Direct3D Compiler Header translation from d3dcompiler.h
// Latest update: Windows 10, version 1809

public import external.directx.d3d11shader;
public import external.directx.d3d12shader;

enum D3DCOMPILER_DLL_W = "d3dcompiler_47.dll"w;
enum D3DCOMPILER_DLL_A = "d3dcompiler_47.dll";
enum D3D_COMPILER_VERSION = 47;

extern (Windows) nothrow HRESULT D3DReadFileToBlob(LPCWSTR pFileName, ID3DBlob** ppContents);
extern (Windows) nothrow HRESULT D3DWriteBlobToFile(ID3DBlob* pBlob, LPCWSTR pFileName, bool bOverwrite);

enum D3DCOMPILE_DEBUG = (1 << 0);
enum D3DCOMPILE_SKIP_VALIDATION = (1 << 1);
enum D3DCOMPILE_SKIP_OPTIMIZATION = (1 << 2);
enum D3DCOMPILE_PACK_MATRIX_ROW_MAJOR = (1 << 3);
enum D3DCOMPILE_PACK_MATRIX_COLUMN_MAJOR = (1 << 4);
enum D3DCOMPILE_PARTIAL_PRECISION = (1 << 5);
enum D3DCOMPILE_FORCE_VS_SOFTWARE_NO_OPT = (1 << 6);
enum D3DCOMPILE_FORCE_PS_SOFTWARE_NO_OPT = (1 << 7);
enum D3DCOMPILE_NO_PRESHADER = (1 << 8);
enum D3DCOMPILE_AVOID_FLOW_CONTROL = (1 << 9);
enum D3DCOMPILE_PREFER_FLOW_CONTROL = (1 << 10);
enum D3DCOMPILE_ENABLE_STRICTNESS = (1 << 11);
enum D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY = (1 << 12);
enum D3DCOMPILE_IEEE_STRICTNESS = (1 << 13);
enum D3DCOMPILE_OPTIMIZATION_LEVEL0 = (1 << 14);
enum D3DCOMPILE_OPTIMIZATION_LEVEL1 = 0;
enum D3DCOMPILE_OPTIMIZATION_LEVEL2 = ((1 << 14) | (1 << 15));
enum D3DCOMPILE_OPTIMIZATION_LEVEL3 = (1 << 15);
enum D3DCOMPILE_RESERVED16 = (1 << 16);
enum D3DCOMPILE_RESERVED17 = (1 << 17);
enum D3DCOMPILE_WARNINGS_ARE_ERRORS = (1 << 18);
enum D3DCOMPILE_RESOURCES_MAY_ALIAS = (1 << 19);
enum D3DCOMPILE_ENABLE_UNBOUNDED_DESCRIPTOR_TABLES = (1 << 20);
enum D3DCOMPILE_ALL_RESOURCES_BOUND = (1 << 21);
enum D3DCOMPILE_DEBUG_NAME_FOR_SOURCE = (1 << 22);
enum D3DCOMPILE_DEBUG_NAME_FOR_BINARY = (1 << 23);
enum D3DCOMPILE_EFFECT_CHILD_EFFECT = (1 << 0);
enum D3DCOMPILE_EFFECT_ALLOW_SLOW_OPS = (1 << 1);
enum D3DCOMPILE_FLAGS2_FORCE_ROOT_SIGNATURE_LATEST = 0;
enum D3DCOMPILE_FLAGS2_FORCE_ROOT_SIGNATURE_1_0 = (1 << 4);
enum D3DCOMPILE_FLAGS2_FORCE_ROOT_SIGNATURE_1_1 = (1 << 5);
enum D3D_COMPILE_STANDARD_FILE_INCLUDE = (cast(ID3DInclude*) cast(UINT_PTR) 1);

extern (Windows) nothrow HRESULT D3DCompile(const(void)* pSrcData, size_t SrcDataSize, LPCSTR pSourceName, const D3D_SHADER_MACRO* pDefines, ID3DInclude* pInclude, LPCSTR pEntrypoint, LPCSTR pTarget, uint Flags1, uint Flags2, ID3DBlob** ppCode, ID3DBlob** ppErrorMsgs);
alias pD3DCompile = extern (Windows) nothrow HRESULT function(const(void)* pSrcData, size_t SrcDataSize, LPCSTR pFileName, const D3D_SHADER_MACRO* pDefines, ID3DInclude* pInclude, LPCSTR pEntrypoint, LPCSTR pTarget, uint Flags1, uint Flags2, ID3DBlob** ppCode, ID3DBlob** ppErrorMsgs);

enum D3DCOMPILE_SECDATA_MERGE_UAV_SLOTS = 0x00000001;
enum D3DCOMPILE_SECDATA_PRESERVE_TEMPLATE_SLOTS = 0x00000002;
enum D3DCOMPILE_SECDATA_REQUIRE_TEMPLATE_MATCH = 0x00000004;

extern (Windows) nothrow HRESULT D3DCompile2(const(void)* pSrcData, size_t SrcDataSize, LPCSTR pSourceName, const D3D_SHADER_MACRO* pDefines, ID3DInclude* pInclude, LPCSTR pEntrypoint, LPCSTR pTarget, uint Flags1, uint Flags2, uint SecondaryDataFlags, const(void)* pSecondaryData, size_t SecondaryDataSize, ID3DBlob** ppCode, ID3DBlob** ppErrorMsgs);
extern (Windows) nothrow HRESULT D3DCompileFromFile(LPCWSTR pFileName, const D3D_SHADER_MACRO* pDefines, ID3DInclude* pInclude, LPCSTR pEntrypoint, LPCSTR pTarget, uint Flags1, uint Flags2, ID3DBlob** ppCode, ID3DBlob** ppErrorMsgs);
extern (Windows) nothrow HRESULT D3DPreprocess(const(void)* pSrcData, size_t SrcDataSize, LPCSTR pSourceName, const D3D_SHADER_MACRO* pDefines, ID3DInclude* pInclude, ID3DBlob** ppCodeText, ID3DBlob** ppErrorMsgs);

alias pD3DPreprocess = extern (Windows) nothrow HRESULT function(const(void)* pSrcData, size_t SrcDataSize, LPCSTR pFileName, const D3D_SHADER_MACRO* pDefines, ID3DInclude* pInclude, ID3DBlob** ppCodeText, ID3DBlob** ppErrorMsgs);

extern (Windows) nothrow HRESULT D3DGetDebugInfo(const(void)* pSrcData, size_t SrcDataSize, ID3DBlob** ppDebugInfo);
extern (Windows) nothrow HRESULT D3DReflect(const(void)* pSrcData, size_t SrcDataSize, REFIID pInterface, void** ppReflector);
extern (Windows) nothrow HRESULT D3DReflectLibrary(const(void)* pSrcData, size_t SrcDataSize, REFIID riid, LPVOID** ppReflector);

enum D3D_DISASM_ENABLE_COLOR_CODE = 0x00000001;
enum D3D_DISASM_ENABLE_DEFAULT_VALUE_PRINTS = 0x00000002;
enum D3D_DISASM_ENABLE_INSTRUCTION_NUMBERING = 0x00000004;
enum D3D_DISASM_ENABLE_INSTRUCTION_CYCLE = 0x00000008;
enum D3D_DISASM_DISABLE_DEBUG_INFO = 0x00000010;
enum D3D_DISASM_ENABLE_INSTRUCTION_OFFSET = 0x00000020;
enum D3D_DISASM_INSTRUCTION_ONLY = 0x00000040;
enum D3D_DISASM_PRINT_HEX_LITERALS = 0x00000080;

extern (Windows) nothrow HRESULT D3DDisassemble(const(void)* pSrcData, size_t SrcDataSize, uint Flags, LPCSTR szComments, ID3DBlob** ppDisassembly);
alias pD3DDisassemble = extern (Windows) nothrow HRESULT function(const(void)* pSrcData, size_t SrcDataSize, uint Flags, LPCSTR szComments, ID3DBlob** ppDisassembly);

extern (Windows) nothrow HRESULT D3DDisassembleRegion(const(void)* pSrcData, size_t SrcDataSize, uint Flags, LPCSTR szComments, size_t StartByteOffset, size_t NumInsts, size_t* pFinishByteOffset, ID3DBlob** ppDisassembly);
extern (Windows) nothrow HRESULT D3DCreateLinker(ID3D11Linker** ppLinker);
extern (Windows) nothrow HRESULT D3DLoadModule(const(void)* pSrcData, size_t cbSrcDataSize, ID3D11Module** ppModule);
extern (Windows) nothrow HRESULT D3DCreateFunctionLinkingGraph(uint uFlags, ID3D11FunctionLinkingGraph** ppFunctionLinkingGraph);

enum D3D_GET_INST_OFFSETS_INCLUDE_NON_EXECUTABLE = 0x00000001;

extern (Windows) nothrow HRESULT D3DGetTraceInstructionOffsets(const(void)* pSrcData, size_t SrcDataSize, uint Flags, size_t StartInstIndex, size_t NumInsts, size_t* pOffsets, size_t* pTotalInsts);
extern (Windows) nothrow HRESULT D3DGetInputSignatureBlob(const(void)* pSrcData, size_t SrcDataSize, ID3DBlob** ppSignatureBlob);
extern (Windows) nothrow HRESULT D3DGetOutputSignatureBlob(const(void)* pSrcData, size_t SrcDataSize, ID3DBlob** ppSignatureBlob);
extern (Windows) nothrow HRESULT D3DGetInputAndOutputSignatureBlob(const(void)* pSrcData, size_t SrcDataSize, ID3DBlob** ppSignatureBlob);

alias D3DCOMPILER_STRIP_FLAGS = uint;
enum : D3DCOMPILER_STRIP_FLAGS
{
    D3DCOMPILER_STRIP_REFLECTION_DATA = 0x00000001,
    D3DCOMPILER_STRIP_DEBUG_INFO = 0x00000002,
    D3DCOMPILER_STRIP_TEST_BLOBS = 0x00000004,
    D3DCOMPILER_STRIP_PRIVATE_DATA = 0x00000008,
    D3DCOMPILER_STRIP_ROOT_SIGNATURE = 0x00000010,
    D3DCOMPILER_STRIP_FORCE_DWORD = 0x7fffffff,
}

extern (Windows) nothrow HRESULT D3DStripShader(const(void)* pShaderBytecode, size_t BytecodeLength, uint uStripFlags, ID3DBlob** ppStrippedBlob);

alias D3D_BLOB_PART = uint;
enum : D3D_BLOB_PART
{
    D3D_BLOB_INPUT_SIGNATURE_BLOB,
    D3D_BLOB_OUTPUT_SIGNATURE_BLOB,
    D3D_BLOB_INPUT_AND_OUTPUT_SIGNATURE_BLOB,
    D3D_BLOB_PATCH_CONSTANT_SIGNATURE_BLOB,
    D3D_BLOB_ALL_SIGNATURE_BLOB,
    D3D_BLOB_DEBUG_INFO,
    D3D_BLOB_LEGACY_SHADER,
    D3D_BLOB_XNA_PREPASS_SHADER,
    D3D_BLOB_XNA_SHADER,
    D3D_BLOB_PDB,
    D3D_BLOB_PRIVATE_DATA,
    D3D_BLOB_ROOT_SIGNATURE,
    D3D_BLOB_DEBUG_NAME,
    // Test parts are only produced by special compiler versions and so are usually not present in shaders.
    D3D_BLOB_TEST_ALTERNATE_SHADER = 0x8000,
    D3D_BLOB_TEST_COMPILE_DETAILS,
    D3D_BLOB_TEST_COMPILE_PERF,
    D3D_BLOB_TEST_COMPILE_REPORT,
}

extern (Windows) nothrow HRESULT D3DGetBlobPart(const(void)* pSrcData, size_t SrcDataSize, D3D_BLOB_PART Part, uint Flags, ID3DBlob** ppPart);
extern (Windows) nothrow HRESULT D3DSetBlobPart(const(void)* pSrcData, size_t SrcDataSize, D3D_BLOB_PART Part, uint Flags, const(void)* pPart, size_t PartSize, ID3DBlob** ppNewShader);
extern (Windows) nothrow HRESULT D3DCreateBlob(size_t Size, ID3DBlob** ppBlob);

struct D3D_SHADER_DATA
{
    const(void)* pBytecode;
    size_t BytecodeLength;
}

enum D3D_COMPRESS_SHADER_KEEP_ALL_PARTS = 0x00000001;
extern (Windows) nothrow HRESULT D3DCompressShaders(uint uNumShaders, D3D_SHADER_DATA* pShaderData, uint uFlags, ID3DBlob** ppCompressedData);
extern (Windows) nothrow HRESULT D3DDecompressShaders(const(void)* pSrcData, size_t SrcDataSize, uint uNumShaders, uint uStartIndex, uint* pIndices, uint uFlags, ID3DBlob** ppShaders, uint* pTotalShaders);
//extern (Windows) nothrow HRESULT D3DDisassemble10Effect(ID3D10Effect* pEffect, uint Flags, ID3DBlob** ppDisassembly);
