Program Listing for File hlsl-utilities.h

Return to documentation for file (include\shader-utilities\hlsl-utilities.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 "api-types/api-types.h"

namespace gpa {
namespace shader_utilities {
namespace hlsl {

//@brief Return true if target string contains shader model version 6 and above
bool IsDXILTarget(LPCSTR target);

/*
 * @brief Helper function to compile HLSL source.
 * @details The appropriate compiler for the given source's Shader
 *          Model will be automatically selected.
 * @returns true on success
 */
bool Compile(LPCVOID pSrcData,
             SIZE_T SrcDataSize,
             LPCSTR pSourceName,
             const D3D_SHADER_MACRO *pDefines,
             const std::vector<api_types::ManagedSourceFile> *pInclude,
             LPCSTR pEntrypoint,
             LPCSTR pTarget,
             UINT flags1,
             UINT flags2,
             ID3DBlob **ppCode,
             ID3DBlob **ppErrorMsgs);

/*
 * @brief Helper function to reflect shader bytecode.
 * @details The appropriate reflection mechanism will be automatically
 *          selected based on the given shader's Shader Model.
 * @returns true on success
 */
bool Reflect(_In_reads_bytes_(srcDataSize) LPCVOID pSrcData,
             _In_ SIZE_T srcDataSize,
             _In_ REFIID pInterface,
             _Out_ void **ppReflector);

/*
 * @brief Helper function to disassemble shader bytecode into readable intermediate
 *        language source code.
 * @details The returned readable source could be given as DXBC or DXIL depending
 *          on the given bytecode.
 * @returns true on success
 */
bool Disassemble(_In_reads_bytes_(srcDataSize) LPCVOID pSrcData,
                 _In_ SIZE_T srcDataSize,
                 _In_ UINT flags,
                 _In_opt_ LPCSTR szComments,
                 _Out_ ID3DBlob **ppDisassembly);

/*
 * @brief Function to extract shader ISA from a given shaderObject(D3D12PipelineState or ID3D11Shader*)
 * @details If successful, outShaderISA is populated with vendor specific isa string data for a requested shaderStage
 * @returns true on success
 */
bool ExtractShaderISA(IUnknown *shaderObject, api_types::ShaderStageFlagBits requestedShaderStage, std::string *outShaderISA);

/*
 * @brief Helper function to determine the shading language of compiled DX shader bytecode.
 * @return An shader_utilities::ShaderLanguageType value representing the language of the bytecode
 */
api_types::ShaderLanguage GetShaderLanguage(_In_reads_bytes_(srcDataSize) LPCVOID pSrcData,
                                            _In_ SIZE_T srcDataSize);

}  // namespace hlsl
}  // namespace shader_utilities
}  // namespace gpa