Program Listing for File dxil-compiler.h

Return to documentation for file (include\shader-utilities\dxil-compiler.h)

/******************************************************************************
© Intel Corporation.

This software and the related documents are Intel copyrighted materials,
and your use of them is governed by the express license under which they
were provided to you ("License"). Unless the License provides otherwise,
you may not use, modify, copy, publish, distribute, disclose or transmit
this software or the related documents without Intel's prior written
permission.


 This software and the related documents are provided as is, with no express
or implied warranties, other than those that are expressly stated in the
License.

******************************************************************************/

#pragma once

#include <d3dcompiler.h>
#include <dxcapi.h>
#include "api-types/api-types.h"

namespace gpa {
namespace shader_utilities {
namespace dxil_compiler {

/*
 * @brief Compiles HLSL source into DXIL machine code.
 * @details This can be used to compile HLSL code written with Shader Model 6.0 or above.
 *          To compile SM 5.x or below, @see dxbc_compiler::Compile.
 */
bool Compile(_In_reads_bytes_(SrcDataSize) LPCVOID pSrcData,
             _In_ SIZE_T srcDataSize,
             _In_opt_ LPCSTR pSourceName,
             const D3D_SHADER_MACRO *pDefines,
             _In_opt_ IDxcIncludeHandler *pInclude,
             _In_opt_ LPCSTR pEntrypoint,
             _In_ LPCSTR pTarget,
             _In_ UINT flags1,
             _In_ UINT flags2,
             ID3DBlob **ppCode,
             ID3DBlob **ppErrorMsgs);

/*
 * @brief Performs reflection on DXIL machine code.
 */
bool Reflect(_In_reads_bytes_(SrcDataSize) LPCVOID pSrcData,
             _In_ SIZE_T srcDataSize,
             _In_ REFIID pInterface,
             _Out_ void **ppReflector);

/*
 * @brief Disassembles DXIL machine code into readable DXBC source.
 */
bool Disassemble(_In_reads_bytes_(SrcDataSize) LPCVOID pSrcData,
                 _In_ SIZE_T srcDataSize,
                 _In_ UINT flags,
                 _In_opt_ LPCSTR szComments,
                 _Out_ ID3DBlob **ppDisassembly);

/*
 * @brief Disassembles DXIL machine code from a debug shader into readable HLSL source.
 */
api_types::ManagedShaderSource Decompile(_In_reads_bytes_(SrcDataSize) LPCVOID pSrcData, _In_ SIZE_T SrcDataSize);

/*
 * @brief Assembles DXIL machine code from readable DXIL.
 */
HRESULT Assemble(const std::string &dxil, ID3DBlob **ppCode, ID3DBlob **ppErrorMsgs);

/*
 * @brief Detects if provided source byte code is DXIL machine code
 */
bool IsDXILMachineCode(_In_reads_bytes_(SrcDataSize) LPCVOID pSrcData,
                       _In_ SIZE_T srcDataSize);

/*
 * @brief Creates IDxcBlobEncoding object from provided data pointer
 *        Data pointer must stay valid for the lifetime of the blob
 */
bool CreateIDxcBlobFromPinned(void *pData, uint32_t size, void **ppBlob);

}  // namespace dxil_compiler
}  // namespace shader_utilities
}  // namespace gpa