class HLSLCompiler

The HLSLCompiler specialization of ICompiler interface. Handles everything necessary to compile and extract shader reflection data for HSLS and then exports the binary and reflection data for consumption by HLSL-specific backends.

File location: sdk/tools/ffx_shader_compiler/src/hlsl_compiler.h

Enumerations

Name

Description

Backend

Enumeration of possible HLSL backends to compile with.
DXC – Use included DXC compiler processes.
GDK_DESKTOP_X64 – Use GDK-provided shader compiler dll (requires the GDK be installed)
GDK_SCARLETT_X64 – Use GDK-provided shader compiler dll (requires the GDK be installed)
FXC – Use included FXC compiler processes.

Construction

Return type

Description

HLSLCompiler ( Backend backend, const std::string& dll, const std::string& shaderPath, const std::string& shaderName, const std::string& shaderFileName, const std::string& outputPath, bool disableLogs, bool debugCompile )
HLSL Compiler construction function.

Methods

Return type

Description

bool

Compile ( Permutation & permutation, const std::vector<std::string>& arguments, std::mutex& writeMutex )
Compiles a HLSL shader permutation.

bool

Extracts HLSL shader reflection data.

void

WriteBinaryHeaderReflectionData ( FILE* fp, const Permutation & permutation, std::mutex& writeMutex )
Writes HLSL reflection header data for shader permutations.

void

Writes HLSL permutation reflection header data structures for shader permutations.

void

WritePermutationHeaderReflectionData (FILE* fp, const Permutation & permutation)
Writes HLSL permutation reflection header data for shader permutations.

Detailed description

The HLSLCompiler specialization of ICompiler interface. Handles everything necessary to compile and extract shader reflection data for HSLS and then exports the binary and reflection data for consumption by HLSL-specific backends.

Construction

HLSLCompiler

Copied!

HLSLCompiler (
    Backend  backend,
    const std::string& dll,
    const std::string& shaderPath,
    const std::string& shaderName,
    const std::string& shaderFileName,
    const std::string& outputPath,
    bool disableLogs,
    bool debugCompile
)

HLSL Compiler construction function.

Parameters:

backend

The backend HLSL compile process to use

dll

DXC/FXC DLL override to use when compiling

shaderPath

Path to the shader to compile

shaderName

Shader entry point

shaderFileName

Filename of the shader file to compile

outputPath

Output path for shader export

disableLogs

Enables/Disables logging of errors and warnings

debugCompile

Compile shaders in debug and generate pdb information

Returns:

none


Methods

Compile

Copied!

virtual bool Compile (
    Permutation & permutation,
    const std::vector<std::string>& arguments,
    std::mutex& writeMutex
)

Compiles a HLSL shader permutation.

Parameters:

permutation

The permutation representation to compile

arguments

List of arguments to pass to the compiler

wrietMutex

Mutex to use for thread safety of compile process

Returns:

true if successful, false otherwise


ExtractReflectionData

Copied!

virtual bool ExtractReflectionData (Permutation & permutation)

Extracts HLSL shader reflection data.

Parameters:

permutation

The permutation representation to extract reflection for

Returns:

true if successful, false otherwise


WriteBinaryHeaderReflectionData

Copied!

virtual void WriteBinaryHeaderReflectionData (
    FILE* fp,
    const Permutation & permutation,
    std::mutex& writeMutex
)

Writes HLSL reflection header data for shader permutations.

Parameters:

fp

The file to write header information into

permutation

The permutation representation to write to head

wrietMutex

Mutex to use for thread safety of reflection data export

Returns:

none


WritePermutationHeaderReflectionStructMembers

Copied!

virtual void WritePermutationHeaderReflectionStructMembers (FILE* fp)

Writes HLSL permutation reflection header data structures for shader permutations.

Parameters:

fp

The file to write header data structures into

Returns:

none


WritePermutationHeaderReflectionData

Copied!

virtual void WritePermutationHeaderReflectionData (
    FILE* fp,
    const Permutation & permutation
)

Writes HLSL permutation reflection header data for shader permutations.

Parameters:

fp

The file to write header information into

permutation

The permutation representation to write to head

Returns:

none