module CrShader::GLSLLayoutPacker

Overview

Deterministic std430 / std140 byte-offset calculator for Vulkan / RenderingDevice push constants and uniform buffer objects (UBOs).

Defined in:

crshader/transpiler/glsl/layout_packer.cr

Constant Summary

OPAQUE_PREFIXES = ["sampler", "isampler", "usampler", "image", "iimage", "uimage", "subpassInput"]

Class Method Summary

Class Method Detail

def self.align_up(value : Int32, alignment : Int32) : Int32 #

def self.compute_layout(program : ShaderProgram) : PackedLayout #

Computes deterministic layout for non-opaque uniforms in GLSL 450. Uses push_constant (std430) when no manual push_constant exists, no arrays are present, and total size <= 128 bytes; otherwise falls back to set = 1, binding = 0 UBO (std140).


def self.opaque_uniform?(u : UniformDecl) : Bool #

def self.pack_fields(uniforms : Array(UniformDecl), std140 : Bool) : Tuple(Array(FieldSlot), Int32) #

def self.split_uniforms(uniforms : Array(UniformDecl)) : Tuple(Array(UniformDecl), Array(UniformDecl)) #

def self.type_metrics(glsl_type : String) : Tuple(Int32, Int32) #