/////////////////////////////////////////////////////////////////////////////// // // // dxcapi.h // // Copyright (C) Microsoft Corporation. All rights reserved. // // This file is distributed under the University of Illinois Open Source // // License. See LICENSE.TXT for details. // // // // Provides declarations for the DirectX Compiler API entry point. // // // /////////////////////////////////////////////////////////////////////////////// #ifndef __DXC_API__ #define __DXC_API__ #ifdef _WIN32 #ifndef DXC_API_IMPORT #define DXC_API_IMPORT … #endif #else #ifndef DXC_API_IMPORT #define DXC_API_IMPORT … #endif #endif #ifdef _WIN32 #ifndef CROSS_PLATFORM_UUIDOF // Warning: This macro exists in WinAdapter.h as well #define CROSS_PLATFORM_UUIDOF … #endif #else #include "WinAdapter.h" #include <dlfcn.h> #endif struct IMalloc; struct IDxcIncludeHandler; /// \brief Typedef for DxcCreateInstance function pointer. /// /// This can be used with GetProcAddress to get the DxcCreateInstance function. DxcCreateInstanceProc; /// \brief Typedef for DxcCreateInstance2 function pointer. /// /// This can be used with GetProcAddress to get the DxcCreateInstance2 function. DxcCreateInstance2Proc; /// \brief Creates a single uninitialized object of the class associated with a /// specified CLSID. /// /// \param rclsid The CLSID associated with the data and code that will be used /// to create the object. /// /// \param riid A reference to the identifier of the interface to be used to /// communicate with the object. /// /// \param ppv Address of pointer variable that receives the interface pointer /// requested in riid. Upon successful return, *ppv contains the requested /// interface pointer. Upon failure, *ppv contains NULL. /// /// While this function is similar to CoCreateInstance, there is no COM /// involvement. extern "C" DXC_API_IMPORT HRESULT __stdcall DxcCreateInstance(_In_ REFCLSID rclsid, _In_ REFIID riid, _Out_ LPVOID *ppv); /// \brief Version of DxcCreateInstance that takes an IMalloc interface. /// /// This can be used to create an instance of the compiler with a custom memory /// allocator. extern "C" DXC_API_IMPORT HRESULT __stdcall DxcCreateInstance2(_In_ IMalloc *pMalloc, _In_ REFCLSID rclsid, _In_ REFIID riid, _Out_ LPVOID *ppv); // For convenience, equivalent definitions to CP_UTF8 and CP_UTF16. #define DXC_CP_UTF8 … #define DXC_CP_UTF16 … #define DXC_CP_UTF32 … // Use DXC_CP_ACP for: Binary; ANSI Text; Autodetect UTF with BOM #define DXC_CP_ACP … /// Codepage for "wide" characters - UTF16 on Windows, UTF32 on other platforms. #ifdef _WIN32 #define DXC_CP_WIDE … #else #define DXC_CP_WIDE … #endif /// Indicates that the shader hash was computed taking into account source /// information (-Zss). #define DXC_HASHFLAG_INCLUDES_SOURCE … /// Hash digest type for ShaderHash. DxcShaderHash; #define DXC_FOURCC(ch0, ch1, ch2, ch3) … #define DXC_PART_PDB … #define DXC_PART_PDB_NAME … #define DXC_PART_PRIVATE_DATA … #define DXC_PART_ROOT_SIGNATURE … #define DXC_PART_DXIL … #define DXC_PART_REFLECTION_DATA … #define DXC_PART_SHADER_HASH … #define DXC_PART_INPUT_SIGNATURE … #define DXC_PART_OUTPUT_SIGNATURE … #define DXC_PART_PATCH_CONSTANT_SIGNATURE … // Some option arguments are defined here for continuity with D3DCompile // interface. #define DXC_ARG_DEBUG … #define DXC_ARG_SKIP_VALIDATION … #define DXC_ARG_SKIP_OPTIMIZATIONS … #define DXC_ARG_PACK_MATRIX_ROW_MAJOR … #define DXC_ARG_PACK_MATRIX_COLUMN_MAJOR … #define DXC_ARG_AVOID_FLOW_CONTROL … #define DXC_ARG_PREFER_FLOW_CONTROL … #define DXC_ARG_ENABLE_STRICTNESS … #define DXC_ARG_ENABLE_BACKWARDS_COMPATIBILITY … #define DXC_ARG_IEEE_STRICTNESS … #define DXC_ARG_OPTIMIZATION_LEVEL0 … #define DXC_ARG_OPTIMIZATION_LEVEL1 … #define DXC_ARG_OPTIMIZATION_LEVEL2 … #define DXC_ARG_OPTIMIZATION_LEVEL3 … #define DXC_ARG_WARNINGS_ARE_ERRORS … #define DXC_ARG_RESOURCES_MAY_ALIAS … #define DXC_ARG_ALL_RESOURCES_BOUND … #define DXC_ARG_DEBUG_NAME_FOR_SOURCE … #define DXC_ARG_DEBUG_NAME_FOR_BINARY … CROSS_PLATFORM_UUIDOF(IDxcBlob, "8BA5FB08-5195-40e2-AC58-0D989C3A0102") /// \brief A sized buffer that can be passed in and out of DXC APIs. /// /// This is an alias of ID3D10Blob and ID3DBlob. struct IDxcBlob : public IUnknown { … }; CROSS_PLATFORM_UUIDOF(IDxcBlobEncoding, "7241d424-2646-4191-97c0-98e96e42fc68") /// \brief A blob that might have a known encoding. struct IDxcBlobEncoding : public IDxcBlob { … }; CROSS_PLATFORM_UUIDOF(IDxcBlobWide, "A3F84EAB-0FAA-497E-A39C-EE6ED60B2D84") /// \brief A blob containing a null-terminated wide string. /// /// This uses the native wide character encoding (utf16 on Windows, utf32 on /// Linux). /// /// The value returned by GetBufferSize() is the size of the buffer, in bytes, /// including the null-terminator. /// /// This interface is used to return output name strings DXC. Other string /// output blobs, such as errors/warnings, preprocessed HLSL, or other text are /// returned using encodings based on the -encoding option passed to the /// compiler. struct IDxcBlobWide : public IDxcBlobEncoding { … }; CROSS_PLATFORM_UUIDOF(IDxcBlobUtf8, "3DA636C9-BA71-4024-A301-30CBF125305B") /// \brief A blob containing a UTF-8 encoded string. /// /// The value returned by GetBufferSize() is the size of the buffer, in bytes, /// including the null-terminator. /// /// Depending on the -encoding option passed to the compiler, this interface is /// used to return string output blobs, such as errors/warnings, preprocessed /// HLSL, or other text. Output name strings always use IDxcBlobWide. struct IDxcBlobUtf8 : public IDxcBlobEncoding { … }; #ifdef _WIN32 /// IDxcBlobUtf16 is a legacy alias for IDxcBlobWide on Win32. typedef IDxcBlobWide IDxcBlobUtf16; #endif CROSS_PLATFORM_UUIDOF(IDxcIncludeHandler, "7f61fc7d-950d-467f-b3e3-3c02fb49187c") /// \brief Interface for handling include directives. /// /// This interface can be implemented to customize handling of include /// directives. /// /// Use IDxcUtils::CreateDefaultIncludeHandler to create a default /// implementation that reads include files from the filesystem. /// struct IDxcIncludeHandler : public IUnknown { … }; /// \brief Structure for supplying bytes or text input to Dxc APIs. DxcText; /// \brief Structure for supplying defines to Dxc APIs. struct DxcDefine { … }; CROSS_PLATFORM_UUIDOF(IDxcCompilerArgs, "73EFFE2A-70DC-45F8-9690-EFF64C02429D") /// \brief Interface for managing arguments passed to DXC. /// /// Use IDxcUtils::BuildArguments to create an instance of this interface. struct IDxcCompilerArgs : public IUnknown { … }; ////////////////////////// // Legacy Interfaces ///////////////////////// CROSS_PLATFORM_UUIDOF(IDxcLibrary, "e5204dc7-d18c-4c3c-bdfb-851673980fe7") /// \deprecated IDxcUtils replaces IDxcLibrary; please use IDxcUtils insted. struct IDxcLibrary : public IUnknown { … }; CROSS_PLATFORM_UUIDOF(IDxcOperationResult, "CEDB484A-D4E9-445A-B991-CA21CA157DC2") /// \brief The results of a DXC operation. /// /// Note: IDxcResult replaces IDxcOperationResult and should be used wherever /// possible. struct IDxcOperationResult : public IUnknown { … }; CROSS_PLATFORM_UUIDOF(IDxcCompiler, "8c210bf3-011f-4422-8d70-6f9acb8db617") /// \deprecated Please use IDxcCompiler3 instead. struct IDxcCompiler : public IUnknown { … }; CROSS_PLATFORM_UUIDOF(IDxcCompiler2, "A005A9D9-B8BB-4594-B5C9-0E633BEC4D37") /// \deprecated Please use IDxcCompiler3 instead. struct IDxcCompiler2 : public IDxcCompiler { … }; CROSS_PLATFORM_UUIDOF(IDxcLinker, "F1B5BE2A-62DD-4327-A1C2-42AC1E1E78E6") /// \brief DXC linker interface. /// /// Use DxcCreateInstance with CLSID_DxcLinker to obtain an instance of this /// interface. struct IDxcLinker : public IUnknown { … }; ///////////////////////// // Latest interfaces. Please use these. //////////////////////// CROSS_PLATFORM_UUIDOF(IDxcUtils, "4605C4CB-2019-492A-ADA4-65F20BB7D67F") /// \brief Various utility functions for DXC. /// /// Use DxcCreateInstance with CLSID_DxcUtils to obtain an instance of this /// interface. /// /// IDxcUtils replaces IDxcLibrary. struct IDxcUtils : public IUnknown { … }; /// \brief Specifies the kind of output to retrieve from a IDxcResult. /// /// Note: text outputs returned from version 2 APIs are UTF-8 or UTF-16 based on /// the -encoding option passed to the compiler. DXC_OUT_KIND; static_assert …; CROSS_PLATFORM_UUIDOF(IDxcResult, "58346CDA-DDE7-4497-9461-6F87AF5E0659") /// \brief Result of a DXC operation. /// /// DXC operations may have multiple outputs, such as a shader object and /// errors. This interface provides access to the outputs. struct IDxcResult : public IDxcOperationResult { … }; // Special names for extra output that should get written to specific streams. #define DXC_EXTRA_OUTPUT_NAME_STDOUT … #define DXC_EXTRA_OUTPUT_NAME_STDERR … CROSS_PLATFORM_UUIDOF(IDxcExtraOutputs, "319b37a2-a5c2-494a-a5de-4801b2faf989") /// \brief Additional outputs from a DXC operation. /// /// This can be used to obtain outputs that don't have an explicit DXC_OUT_KIND. /// Use DXC_OUT_EXTRA_OUTPUTS to obtain instances of this. struct IDxcExtraOutputs : public IUnknown { … }; CROSS_PLATFORM_UUIDOF(IDxcCompiler3, "228B4687-5A6A-4730-900C-9702B2203F54") /// \brief Interface to the DirectX Shader Compiler. /// /// Use DxcCreateInstance with CLSID_DxcCompiler to obtain an instance of this /// interface. struct IDxcCompiler3 : public IUnknown { … }; static const UINT32 DxcValidatorFlags_Default = …; static const UINT32 DxcValidatorFlags_InPlaceEdit = …; // Validator is allowed to update shader blob in-place. static const UINT32 DxcValidatorFlags_RootSignatureOnly = …; static const UINT32 DxcValidatorFlags_ModuleOnly = …; static const UINT32 DxcValidatorFlags_ValidMask = …; CROSS_PLATFORM_UUIDOF(IDxcValidator, "A6E82BD2-1FD7-4826-9811-2857E797F49A") /// \brief Interface to DXC shader validator. /// /// Use DxcCreateInstance with CLSID_DxcValidator to obtain an instance of this. struct IDxcValidator : public IUnknown { … }; CROSS_PLATFORM_UUIDOF(IDxcValidator2, "458e1fd1-b1b2-4750-a6e1-9c10f03bed92") /// \brief Interface to DXC shader validator. /// /// Use DxcCreateInstance with CLSID_DxcValidator to obtain an instance of this. struct IDxcValidator2 : public IDxcValidator { … }; CROSS_PLATFORM_UUIDOF(IDxcContainerBuilder, "334b1f50-2292-4b35-99a1-25588d8c17fe") /// \brief Interface to DXC container builder. /// /// Use DxcCreateInstance with CLSID_DxcContainerBuilder to obtain an instance /// of this. struct IDxcContainerBuilder : public IUnknown { … }; CROSS_PLATFORM_UUIDOF(IDxcAssembler, "091f7a26-1c1f-4948-904b-e6e3a8a771d5") /// \brief Interface to DxcAssembler. /// /// Use DxcCreateInstance with CLSID_DxcAssembler to obtain an instance of this. struct IDxcAssembler : public IUnknown { … }; CROSS_PLATFORM_UUIDOF(IDxcContainerReflection, "d2c21b26-8350-4bdc-976a-331ce6f4c54c") /// \brief Interface to DxcContainerReflection. /// /// Use DxcCreateInstance with CLSID_DxcContainerReflection to obtain an /// instance of this. struct IDxcContainerReflection : public IUnknown { … }; CROSS_PLATFORM_UUIDOF(IDxcOptimizerPass, "AE2CD79F-CC22-453F-9B6B-B124E7A5204C") /// \brief An optimizer pass. /// /// Instances of this can be obtained via IDxcOptimizer::GetAvailablePass. struct IDxcOptimizerPass : public IUnknown { … }; CROSS_PLATFORM_UUIDOF(IDxcOptimizer, "25740E2E-9CBA-401B-9119-4FB42F39F270") /// \brief Interface to DxcOptimizer. /// /// Use DxcCreateInstance with CLSID_DxcOptimizer to obtain an instance of this. struct IDxcOptimizer : public IUnknown { … }; static const UINT32 DxcVersionInfoFlags_None = …; static const UINT32 DxcVersionInfoFlags_Debug = …; // Matches VS_FF_DEBUG static const UINT32 DxcVersionInfoFlags_Internal = …; // Internal Validator (non-signing) CROSS_PLATFORM_UUIDOF(IDxcVersionInfo, "b04f5b50-2059-4f12-a8ff-a1e0cde1cc7e") /// \brief PDB Version information. /// /// Use IDxcPdbUtils2::GetVersionInfo to obtain an instance of this. struct IDxcVersionInfo : public IUnknown { … }; CROSS_PLATFORM_UUIDOF(IDxcVersionInfo2, "fb6904c4-42f0-4b62-9c46-983af7da7c83") /// \brief PDB Version Information. /// /// Use IDxcPdbUtils2::GetVersionInfo to obtain a IDxcVersionInfo interface, and /// then use QueryInterface to obtain an instance of this interface from it. struct IDxcVersionInfo2 : public IDxcVersionInfo { … }; CROSS_PLATFORM_UUIDOF(IDxcVersionInfo3, "5e13e843-9d25-473c-9ad2-03b2d0b44b1e") /// \brief PDB Version Information. /// /// Use IDxcPdbUtils2::GetVersionInfo to obtain a IDxcVersionInfo interface, and /// then use QueryInterface to obtain an instance of this interface from it. struct IDxcVersionInfo3 : public IUnknown { … }; struct DxcArgPair { … }; CROSS_PLATFORM_UUIDOF(IDxcPdbUtils, "E6C9647E-9D6A-4C3B-B94C-524B5A6C343D") /// \deprecated Please use IDxcPdbUtils2 instead. struct IDxcPdbUtils : public IUnknown { … }; CROSS_PLATFORM_UUIDOF(IDxcPdbUtils2, "4315D938-F369-4F93-95A2-252017CC3807") /// \brief DxcPdbUtils interface. /// /// Use DxcCreateInstance with CLSID_DxcPdbUtils to create an instance of this. struct IDxcPdbUtils2 : public IUnknown { … }; // Note: __declspec(selectany) requires 'extern' // On Linux __declspec(selectany) is removed and using 'extern' results in link // error. #ifdef _MSC_VER #define CLSID_SCOPE … #else #define CLSID_SCOPE #endif CLSID_SCOPE const CLSID CLSID_DxcCompiler = …; // {EF6A8087-B0EA-4D56-9E45-D07E1A8B7806} CLSID_SCOPE const GUID CLSID_DxcLinker = …; // {CD1F6B73-2AB0-484D-8EDC-EBE7A43CA09F} CLSID_SCOPE const CLSID CLSID_DxcDiaDataSource = …; // {3E56AE82-224D-470F-A1A1-FE3016EE9F9D} CLSID_SCOPE const CLSID CLSID_DxcCompilerArgs = …; // {6245D6AF-66E0-48FD-80B4-4D271796748C} CLSID_SCOPE const GUID CLSID_DxcLibrary = …; CLSID_SCOPE const GUID CLSID_DxcUtils = …; // {8CA3E215-F728-4CF3-8CDD-88AF917587A1} CLSID_SCOPE const GUID CLSID_DxcValidator = …; // {D728DB68-F903-4F80-94CD-DCCF76EC7151} CLSID_SCOPE const GUID CLSID_DxcAssembler = …; // {b9f54489-55b8-400c-ba3a-1675e4728b91} CLSID_SCOPE const GUID CLSID_DxcContainerReflection = …; // {AE2CD79F-CC22-453F-9B6B-B124E7A5204C} CLSID_SCOPE const GUID CLSID_DxcOptimizer = …; // {94134294-411f-4574-b4d0-8741e25240d2} CLSID_SCOPE const GUID CLSID_DxcContainerBuilder = …; // {54621dfb-f2ce-457e-ae8c-ec355faeec7c} CLSID_SCOPE const GUID CLSID_DxcPdbUtils = …; #endif