Diligent Engine
 
Loading...
Searching...
No Matches
Diligent::ShaderCreateInfo Struct Reference

Shader creation attributes. More...

#include <Shader.h>

Public Member Functions

bool operator== (const ShaderCreateInfo &RHS) const noexcept
 

Public Attributes

const Char * FilePath = nullptr
 Source file path.
 
IShaderSourceInputStreamFactorypShaderSourceStreamFactory = nullptr
 Pointer to the shader source input stream factory.
 
const Char * Source = nullptr
 Shader source.
 
const void * ByteCode = nullptr
 Compiled shader bytecode.
 
const Char * EntryPoint = "main"
 Shader entry point.
 
ShaderMacroArray Macros
 Shader macros (see Diligent::ShaderMacroArray)
 
ShaderDesc Desc
 Shader description. See Diligent::ShaderDesc.
 
SHADER_SOURCE_LANGUAGE SourceLanguage = SHADER_SOURCE_LANGUAGE_DEFAULT
 Shader source language. See Diligent::SHADER_SOURCE_LANGUAGE.
 
SHADER_COMPILER ShaderCompiler = SHADER_COMPILER_DEFAULT
 Shader compiler. See Diligent::SHADER_COMPILER.
 
ShaderVersion HLSLVersion = {}
 HLSL shader model to use when compiling the shader.
 
ShaderVersion GLSLVersion = {}
 GLSL version to use when creating the shader.
 
ShaderVersion GLESSLVersion = {}
 GLES shading language version to use when creating the shader.
 
ShaderVersion MSLVersion = {}
 Metal shading language version to use when creating the shader.
 
SHADER_COMPILE_FLAGS CompileFlags = SHADER_COMPILE_FLAG_NONE
 Shader compile flags (see Diligent::SHADER_COMPILE_FLAGS).
 
bool LoadConstantBufferReflection = false
 Whether to load constant buffer reflection information.
 
const char * GLSLExtensions = nullptr
 An optional list of GLSL extensions to enable when compiling GLSL source code.
 
const char * WebGPUEmulatedArrayIndexSuffix = nullptr
 Emulated array index suffix for WebGPU backend.
 

Detailed Description

Shader creation attributes.

Member Function Documentation

◆ operator==()

bool Diligent::ShaderCreateInfo::operator== ( const ShaderCreateInfo & RHS) const
inlinenoexcept

Comparison operator tests if two structures are equivalent.

Note
Comparison ignores shader name.

Member Data Documentation

◆ ByteCode

const void* Diligent::ShaderCreateInfo::ByteCode = nullptr

Compiled shader bytecode.

If shader byte code is provided, FilePath and Source members must be null

This option is supported for D3D11, D3D12, Vulkan and Metal backends. For D3D11 and D3D12 backends, DXBC should be provided. Vulkan backend expects SPIRV bytecode. Metal backend supports .metallib bytecode to create MTLLibrary or SPIRV to translate it to MSL and compile (may be slow).

If SHADER_COMPILE_FLAG_SKIP_REFLECTION flag is not used, the bytecode must contain reflection information. If shaders were compiled using fxc, make sure that /Qstrip_reflect option is not specified. HLSL shaders need to be compiled against 4.0 profile or higher.

◆ ByteCodeSize

size_t Diligent::ShaderCreateInfo::ByteCodeSize

Size of the compiled shader byte code, when ByteCode is not null.

Byte code size (in bytes) must not be zero if ByteCode is not null.

◆ EntryPoint

const Char* Diligent::ShaderCreateInfo::EntryPoint = "main"

Shader entry point.

This member is ignored if ByteCode is not null

◆ FilePath

const Char* Diligent::ShaderCreateInfo::FilePath = nullptr

Source file path.

If source file path is provided, Source and ByteCode members must be null

◆ GLESSLVersion

ShaderVersion Diligent::ShaderCreateInfo::GLESSLVersion = {}

GLES shading language version to use when creating the shader.

When default value is given (0, 0), the engine will attempt to use the highest GLESSL version supported by the device.

◆ GLSLVersion

ShaderVersion Diligent::ShaderCreateInfo::GLSLVersion = {}

GLSL version to use when creating the shader.

When default value is given (0, 0), the engine will attempt to use the highest GLSL version supported by the device.

◆ HLSLVersion

ShaderVersion Diligent::ShaderCreateInfo::HLSLVersion = {}

HLSL shader model to use when compiling the shader.

When default value is given (0, 0), the engine will attempt to use the highest HLSL shader model supported by the device. If the shader is created from the byte code, this value has no effect.

Note
When HLSL source is converted to GLSL, corresponding GLSL/GLESSL version will be used.

◆ LoadConstantBufferReflection

bool Diligent::ShaderCreateInfo::LoadConstantBufferReflection = false

Whether to load constant buffer reflection information.

The reflection information can be queried through IShader::GetConstantBufferDesc() method.

Note
Loading constant buffer reflection introduces some overhead, and should be disabled when it is not needed.

◆ MSLVersion

ShaderVersion Diligent::ShaderCreateInfo::MSLVersion = {}

Metal shading language version to use when creating the shader.

When default value is given (0, 0), the engine will attempt to use the highest MSL version supported by the device.

◆ pShaderSourceStreamFactory

IShaderSourceInputStreamFactory* Diligent::ShaderCreateInfo::pShaderSourceStreamFactory = nullptr

Pointer to the shader source input stream factory.

The factory is used to load the shader source file if FilePath is not null. It is also used to create additional input streams for shader include files

◆ Source

const Char* Diligent::ShaderCreateInfo::Source = nullptr

Shader source.

If shader source is provided, FilePath and ByteCode members must be null

◆ SourceLength

size_t Diligent::ShaderCreateInfo::SourceLength = 0

Length of the source code, when Source is not null.

When Source is not null and is not a null-terminated string, this member should be used to specify the length of the source code. If SourceLength is zero, the source code string is assumed to be null-terminated.

◆ WebGPUEmulatedArrayIndexSuffix

const char* Diligent::ShaderCreateInfo::WebGPUEmulatedArrayIndexSuffix = nullptr

Emulated array index suffix for WebGPU backend.

An optional suffix to append to the name of emulated array variables to get the indexed array element name.

Since WebGPU does not support arrays of resources, Diligent Engine emulates them by appending an index to the resource name. For instance, if the suffix is set to "_", resources named "g_Tex2D_0", "g_Tex2D_1", "g_Tex2D_2" will be grouped into an array of 3 textures named "g_Tex2D". All resources must be the same type to be grouped into an array.

When suffix is null or empty, no array emulation is performed.

Remarks
This member is ignored when compiling shaders for backends other than WebGPU.