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

Shader compilation flags enumeration. More...

#include <ShaderFlags.h>

Public Types

enum  {
  Debug = (1 << 0) , NoOptimization = (1 << 1) , OptimizationLevel1 = (1 << 2) , OptimizationLevel2 = (1 << 3) ,
  OptimizationLevel3 = (1 << 4) , WarningsAreErrors = (1 << 5) , PatchClippingOrigin = (1 << 6) , SeparateShader = (1 << 7) ,
  DefaultLibrary = (1 << 8) , CaseInsensitiveAttribs = (1 << 9)
}

Detailed Description

Shader compilation flags enumeration.

Remarks
The shader compile flags are heavily backend dependent and are therefore silently ignored if they are not supported by the backend.
See also
ShaderDescriptor::flags
Todo
Rename to CompileFlags.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
Debug 

Generate debug information.

Remarks
This compile option is equivalent to the command line arguments fxc /Od, dxc -Od, metal -O0.
Note
Only supported with: HLSL, Metal.
NoOptimization 

Disable optimizations.

Remarks
This compile option is equivalent to command line arguments fxc /Od, dxc -Od, metal -O0.
Note
Only supported with: HLSL, Metal, GLSL (adds #pragma optimize(off) after the #version-directive).
OptimizationLevel1 

Optimization level 1.

Remarks
This compile option is equivalent to command line arguments fxc /O1, dxc -O1, metal -O1.
Note
Only supported with: HLSL, Metal.
OptimizationLevel2 

Optimization level 2.

Remarks
This compile option is equivalent to command line arguments fxc /O2, dxc -O2, metal -O2.
Note
Only supported with: HLSL, Metal.
OptimizationLevel3 

Optimization level 3.

Remarks
This compile option is equivalent to command line arguments fxc /O3, dxc -O3, metal -O3.
Note
Only supported with: HLSL, Metal.
WarningsAreErrors 

Warnings are treated as errors.

Remarks
This compile option is equivalent to command line arguments fxc /WX, dxc -WX, metal -Werror.
Note
Only supported with: HLSL, Metal.
PatchClippingOrigin 

Patches the GLSL shader source to accommodate a flipped coordinate system from lower-left to upper-left and vice-versa, effectively injecting gl_Position.y = -gl_Position.y; statements into a vertex shader.

Remarks
This can be used to maintain the same vertex shader logic between GLSL and other shading languages when the screen origin is lower-left (see ScreenOrigin::LowerLeft). This flag should also only be used for shaders that render into an OpenGL texture as their coordinate system is reversed compared to the other rendering APIs. What shader stage should this flag be used with depends on what shader stage is the last to modify vertex positions before they are passed to the clipping stage, i.e. either vertex, tessellation-evaluation, or geometry shaders.
Note
Since there is no preprocessing performed prior to scanning the shader source, control-flow modifying macros are not recognized. For example, using macros that change the control flow in the main entry point or even obfuscate the declaration of the entry point will not be scanned correctly by this feature. If in doubt, write your own adjustment in the shader source like this:
void main() {
// Vertex shader body ...
#if FLIP_POSITION_Y
gl_Position.y = -gl_Position.y;
#endif
}
Then define the macro FLIP_POSITION_Y on the API side like this and pass it to all vertex (or tessellation-evaluation or geometry) shaders that will be used for render targets, i.e. those shaders that render into a texture instead of a Window or Canvas:
const LLGL::ShaderMacro myDefinesForRenderTargetShaders[] = {
{ "FLIP_POSITION_Y", myRenderer->GetRenderingCaps().screenOrigin == LLGL::ScreenOrigin::LowerLeft ? "1" : "0" },
{ nullptr, nullptr } // Null terminating entry
};
@ LowerLeft
Specifies a screen origin in the lower-left.
Definition RenderSystemFlags.h:135
Shader macro structure with name and optional body definition.
Definition ShaderFlags.h:263
Only supported with: GLSL.
See also
RenderingCapabilities::screenOrigin
SeparateShader 

Specifies whether to create separable or legacy shaders.

Remarks
This is only used for the OpenGL backend. Separate and non-separate shaders (i.e. legacy shaders) must not be mixed and matched when a graphics PSO is created! If specified, the GLSL vertex shader must contain a gl_PerVertex block and the GLSL fragment shader may contain a gl_PerFragment block.
See also
https://registry.khronos.org/OpenGL/extensions/ARB/ARB_separate_shader_objects.txt
Note
Only supported with: GLSL.
DefaultLibrary 

Specifies whether to load the shader from the default.metallib file.

Remarks
This is only used for Metal and primarily for iOS (but also available on macOS). The default Xcode configuration will compile all Metal shaders into a single library named default.metallib. All shader entry points must have unique names or linker errors will occur.
Note
Only supported with: Metal.
CaseInsensitiveAttribs 

Specifies whether input/output attributes should be treated case insensitive.

Remarks
This can be used to simplify compatibility with GLSL shaders of older versions that were cross-compiled from HLSL. Some compiler toolchains use the HLSL semantic name for the GLSL counterpart, but HLSL attributes are already case-insensitive.
Consider the following HLSL code snippet of a vertex shader:
struct VertexInput {
float3 position : POSITION;
float2 texCoord : TEXCOORD;
};
A hand-written translated GLSL shader for these attributes might look like this:
in vec3 position;
in vec2 texCoord;
An auto-generated GLSL shader for these attributes on the other hand might look like this:
in vec3 POSITION;
in vec2 TEXCOORD;
This flag relaxes this condition by making the lookup case-insensitive. GLSL shaders with #version 420 or higher can ignore this, since attributes are already bound within the shader themselves via their layout(location=N) qualifier.
Note
Only supported with: OpenGL.

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