Vulkan Schnee 0.0.1
High-performance rendering engine
Loading...
Searching...
No Matches
Shader Bindings

Most renderer shader resources use shared binding constants across C++ and GLSL.

The system is centered around Engine/include/Engine/Renderer/ShaderBindingsDef.hpp and Engine/include/Engine/Renderer/GpuDataLayouts.hpp.

Shaders include the generated GLSL bindings header before declaring bound resources.

Some legacy and particle shaders still hard-code numeric bindings. Current examples include Engine/shaders/TrailPrepareDraw.comp, Engine/shaders/ParticleSimulate.comp, and Engine/shaders/TrailUpdate.comp.

Example

C++ defines binding enums through a macro list.

#define SHADER_BINDING_ENUM_NAME( X ) \
X(ENUM_A, 0) \
X(ENUM_B, 1)
namespace ShaderNamespace
{
enum Binding : uint32_t
{
SHADER_BINDING_ENUM_NAME(BINDING_ENUM_ENTRY)
};
}
#define BINDING_ENUM_ENTRY(name, value)

GLSL using the generated bindings header uses BINDING_ constants.

#extension GL_GOOGLE_include_directive : require
#include "shader_bindings.glsl.h"
// Generated binding names are prefixed by BINDING_
layout(std430, set = 0, binding = BINDING_ENUM_A) readonly buffer BufferA {
uint value_A;
};
layout(std430, set = 0, binding = BINDING_ENUM_B) readonly buffer BufferB {
uint value_B;
};