LLGL 0.05 Beta
Loading...
Searching...
No Matches
LLGL::ShaderDescriptor Struct Reference

Shader source and binary code descriptor structure. More...

#include <ShaderFlags.h>

Public Member Functions

 ShaderDescriptor (const ShaderDescriptor &)=default
 ShaderDescriptor (ShaderDescriptor &&)=default
ShaderDescriptor & operator= (const ShaderDescriptor &)=default
ShaderDescriptor & operator= (ShaderDescriptor &&)=default
 ~ShaderDescriptor ()=default
 ShaderDescriptor ()=default
 ShaderDescriptor (const ShaderType type, const char *source)
 Constructor to initialize the shader descriptor with a source filename.
 ShaderDescriptor (const ShaderType type, const char *source, const char *entryPoint, const char *profile, long flags=0)
 Constructor to initialize the shader descriptor with a source filename, entry point, profile, and optional flags.

Public Attributes

const char * debugName = nullptr
 Optional name for debugging purposes. By default null.
ShaderType type = ShaderType::Undefined
 Specifies the type of the shader, i.e. if it is either a vertex or fragment shader or the like. By default ShaderType::Undefined.
const char * source = nullptr
 Pointer to the shader source. This is either a null terminated string or a raw byte buffer (depending on the sourceType member).
std::size_t sourceSize = 0
 Specifies the size of the shader source (excluding the null terminator).
ShaderSourceType sourceType = ShaderSourceType::CodeFile
 Specifies the type of the shader source. By default ShaderSourceType::CodeFile.
const char * entryPoint = nullptr
 Shader entry point (shader main function). If this is null, the empty string is used. By default null.
const char * profile = nullptr
 Shader target profile. If this is null, the empty string is used. By default null.
const ShaderMacro * defines = nullptr
 Optional array of macro definitions. By default null.
long flags = 0
 Optional compilation flags. By default 0.
IncludeHandler * includeHandler = nullptr
 Optional include handler. By default, the backend specific default include handler will be used.
VertexShaderAttributes vertex
FragmentShaderAttributes fragment
 Fragment shader specific attributes.
ComputeShaderAttributes compute
 Compute shader specific attributes.

Detailed Description

Shader source and binary code descriptor structure.

See also
RenderSystem::CreateShader

Constructor & Destructor Documentation

◆ ShaderDescriptor() [1/5]

LLGL::ShaderDescriptor::ShaderDescriptor ( const ShaderDescriptor & )
default

◆ ShaderDescriptor() [2/5]

LLGL::ShaderDescriptor::ShaderDescriptor ( ShaderDescriptor && )
default

◆ ~ShaderDescriptor()

LLGL::ShaderDescriptor::~ShaderDescriptor ( )
default

◆ ShaderDescriptor() [3/5]

LLGL::ShaderDescriptor::ShaderDescriptor ( )
default

◆ ShaderDescriptor() [4/5]

LLGL::ShaderDescriptor::ShaderDescriptor ( const ShaderType type,
const char * source )
inline

Constructor to initialize the shader descriptor with a source filename.

◆ ShaderDescriptor() [5/5]

LLGL::ShaderDescriptor::ShaderDescriptor ( const ShaderType type,
const char * source,
const char * entryPoint,
const char * profile,
long flags = 0 )
inline

Constructor to initialize the shader descriptor with a source filename, entry point, profile, and optional flags.

Member Function Documentation

◆ operator=() [1/2]

ShaderDescriptor & LLGL::ShaderDescriptor::operator= ( const ShaderDescriptor & )
default

◆ operator=() [2/2]

ShaderDescriptor & LLGL::ShaderDescriptor::operator= ( ShaderDescriptor && )
default

Member Data Documentation

◆ compute

ComputeShaderAttributes LLGL::ShaderDescriptor::compute

Compute shader specific attributes.

Remarks
This member is only used to specify the number of threads per threadgroup for the Metal backend.
Note
Only supported with: Metal.

◆ debugName

const char* LLGL::ShaderDescriptor::debugName = nullptr

Optional name for debugging purposes. By default null.

Remarks
The final name of the native hardware resource is implementation defined.
For the HLSL backend, this will also be used as shader name if the shader is provided in source form.
See also
RenderSystemChild::SetDebugName

◆ defines

const ShaderMacro* LLGL::ShaderDescriptor::defines = nullptr

Optional array of macro definitions. By default null.

Remarks
Shader macros can only be defined if sourceType refers to source code, i.e. ShaderSourceType::CodeString or ShaderSourceType::CodeFile. Otherwise, this field is ignored.
This must either be null or a null-terminated array of ShaderMacro entries as shown here:
const LLGL::ShaderMacro myDefines[] = {
{ "ENABLE_SHADER_PASS_FOO", "1" }, // first macro
{ "ENABLE_SHADER_PASS_BAR", "0" }, // second macro
{ nullptr, nullptr }, // terminate array
};
LLGL::ShaderDescriptor myShaderDesc;
myShaderDesc.defines = myDefines;
const ShaderMacro * defines
Optional array of macro definitions. By default null.
Definition ShaderFlags.h:456
Shader macro structure with name and optional body definition.
Definition ShaderFlags.h:263

◆ entryPoint

const char* LLGL::ShaderDescriptor::entryPoint = nullptr

Shader entry point (shader main function). If this is null, the empty string is used. By default null.

Note
Only supported with: HLSL, SPIR-V, Metal.

◆ flags

long LLGL::ShaderDescriptor::flags = 0

Optional compilation flags. By default 0.

Remarks
This can be a bitwise OR combination of the ShaderCompileFlags enumeration entries.
See also
ShaderCompileFlags

◆ fragment

FragmentShaderAttributes LLGL::ShaderDescriptor::fragment

Fragment shader specific attributes.

◆ includeHandler

IncludeHandler* LLGL::ShaderDescriptor::includeHandler = nullptr

Optional include handler. By default, the backend specific default include handler will be used.

Remarks
This can be used to handle customized search paths for include directories. This is only relevant when compiling from source as binary files generally do not contain #include-directives.
Note
Only supported with: Direct3D 11, Direct3D 12.

◆ profile

const char* LLGL::ShaderDescriptor::profile = nullptr

Shader target profile. If this is null, the empty string is used. By default null.

Remarks
This is renderer API dependent and is forwarded to the respective shader compiler.
Here are a few examples:
  • For HLSL: "vs_5_0" specifies vertex shader model 5.0.
  • For Metal: "2.1" specifies shader version 2.1.
  • For GLSL: "320 es" specifies that the GLSL version must be patched to "#version 300 es".
See also
https://msdn.microsoft.com/en-us/library/windows/desktop/jj215820(v=vs.85).aspx

◆ source

const char* LLGL::ShaderDescriptor::source = nullptr

Pointer to the shader source. This is either a null terminated string or a raw byte buffer (depending on the sourceType member).

Remarks
This must not be null when passed to the RenderSystem::CreateShader function. If this is raw byte buffer rather than a null terminated string, the sourceSize member must not be zero!
See also
sourceSize
sourceType

◆ sourceSize

std::size_t LLGL::ShaderDescriptor::sourceSize = 0

Specifies the size of the shader source (excluding the null terminator).

Remarks
If this is zero, the 'source' member is expected to point to a null terminated string and the size is automatically determined. For the binary buffer source type (i.e. ShaderSourceType::BinaryBuffer), this must not be zero!
See also
source

◆ sourceType

ShaderSourceType LLGL::ShaderDescriptor::sourceType = ShaderSourceType::CodeFile

Specifies the type of the shader source. By default ShaderSourceType::CodeFile.

Remarks
With the filename source types (i.e. ShaderSourceType::CodeFile and ShaderSourceType::BinaryFile), the shader source or binary code will be loaded from file using the standard C++ file streams (i.e. std::ifstream). Only the binary buffer source type (i.e. ShaderSourceType::BinaryBuffer) does not require a null terminator for the source pointer.
See also
ShaderSourceType
source

◆ type

ShaderType LLGL::ShaderDescriptor::type = ShaderType::Undefined

Specifies the type of the shader, i.e. if it is either a vertex or fragment shader or the like. By default ShaderType::Undefined.

◆ vertex

VertexShaderAttributes LLGL::ShaderDescriptor::vertex

The documentation for this struct was generated from the following file: