GLSL Struct 1.4.0
glslstruct
Loading...
Searching...
No Matches
Layout Traits

Traits for different layouts. More...

Collaboration diagram for Layout Traits:

Concepts

concept  glslstruct::layout_traits
 The primary concept for GLSL layout trait definitions.

Classes

struct  glslstruct::scalar_layout_context
 Scalar Layout additional context. More...
struct  glslstruct::scalar_layout_traits
 Scalar Layout traits. More...
struct  glslstruct::std140_layout_context
 Std140 Layout additional context. More...
struct  glslstruct::std140_layout_traits
 Std140 Layout traits. More...
struct  glslstruct::std430_layout_context
 Std430 Layout additional context. More...
struct  glslstruct::std430_layout_traits
 Std430 Layout traits. More...
struct  glslstruct::is_layout_traits< T >
 Type trait to check if T is a valid layout trait. More...

Variables

template<class T>
static _GLSL_STRUCT_CONSTEXPR17 bool glslstruct::is_layout_traits_v = layout_traits<T>
 Compile-time constant to check if T is a valid layout trait.

Detailed Description

Traits for different layouts.

Layout Trait needs to have defined static functions:

size_t get_scalar_alignment(const ValueType type, [[optional(define only if you have using context_type)]] context_type& ctx); // returns base alignment of scalar with given scalar type
size_t get_vec_alignment(const ValueType type, const size_t length, [[optional(define only if you have using context_type)]] context_type& ctx); // returns base alignment of vec with given scalar type and length
size_t get_array_alignment(const size_t elemBaseAlignment, [[optional(define only if you have using context_type)]] context_type& ctx); // returns base alignment of array with given array elem base alignment
size_t get_struct_alignment([[optional(define only if you have using context_type)]] context_type& ctx); // returns base alignment of struct

There are also optional functions:

  • To make action before variable is added:
    // Default for all types
    void before_add(size_t& currentOffset, [[optional(define only if you have using context_type)]] context_type& ctx);
    // Specialized for given type (if defined they are invoked instead of before_add)
    void before_add_scalar(size_t& currentOffset, [[optional(define only if you have using context_type)]] context_type& ctx);
    void before_add_vec(size_t& currentOffset, [[optional(define only if you have using context_type)]] context_type& ctx);
    void before_add_mat(size_t& currentOffset, [[optional(define only if you have using context_type)]] context_type& ctx);
    void before_add_array(size_t& currentOffset, [[optional(define only if you have using context_type)]] context_type& ctx);
    void before_add_struct(size_t& currentOffset, [[optional(define only if you have using context_type)]] context_type& ctx);
  • To make some action after variable was added:
    // Default for all types
    void after_add(size_t& currentOffset, const size_t size, const size_t alignment, [[optional(define only if you have using context_type)]] context_type& ctx);
    // Specialized for given type (if defined they are invoked instead of after_add)
    void after_add_scalar(size_t& currentOffset, const size_t size, const size_t alignment, [[optional(define only if you have using context_type)]] context_type& ctx);
    void after_add_vec(size_t& currentOffset, const size_t size, const size_t alignment, [[optional(define only if you have using context_type)]] context_type& ctx);
    void after_add_mat(size_t& currentOffset, const size_t size, const size_t alignment, [[optional(define only if you have using context_type)]] context_type& ctx);
    void after_add_array(size_t& currentOffset, const size_t size, const size_t alignment, [[optional(define only if you have using context_type)]] context_type& ctx);
    void after_add_struct(size_t& currentOffset, const size_t size, const size_t alignment, [[optional(define only if you have using context_type)]] context_type& ctx);

Variable Documentation

◆ is_layout_traits_v

template<class T>
_GLSL_STRUCT_CONSTEXPR17 bool glslstruct::is_layout_traits_v = layout_traits<T>
static

Compile-time constant to check if T is a valid layout trait.