FastUIDraw
Public Types | Public Member Functions | List of all members
fastuidraw::glsl::UnpackSourceGenerator Class Reference

An unpack source generator is used to generate shader source code to unpack data from the data store buffer into a GLSL struct. More...

#include <unpack_source_generator.hpp>

Public Types

enum  cast_t { reinterpret_to_float_bits, type_cast }
 
enum  type_t { float_type, uint_type, int_type, padding_type }
 

Public Member Functions

 UnpackSourceGenerator (c_string type_name)
 
 UnpackSourceGenerator (c_array< const c_string > type_names)
 
 UnpackSourceGenerator (const UnpackSourceGenerator &obj)
 
UnpackSourceGeneratoroperator= (const UnpackSourceGenerator &rhs)
 
UnpackSourceGeneratorset (unsigned int offset, c_string field_name, type_t type, enum cast_t cast, unsigned int struct_idx=0)
 
UnpackSourceGeneratorset (unsigned int offset, unsigned int bit0, unsigned int num_bits, c_string field_name, type_t type, enum cast_t cast, unsigned int struct_idx=0)
 
UnpackSourceGeneratorset_float (unsigned int offset, c_string field_name, unsigned int struct_idx=0)
 
UnpackSourceGeneratorset_int (unsigned int offset, c_string field_name, unsigned int struct_idx=0)
 
UnpackSourceGeneratorset_uint (unsigned int offset, c_string field_name, unsigned int struct_idx=0)
 
const UnpackSourceGeneratorstream_unpack_function (ShaderSource &str, c_string function_name) const
 
ShaderSource stream_unpack_function (c_string function_name) const
 
const UnpackSourceGeneratorstream_unpack_size_function (ShaderSource &str, c_string function_name) const
 
ShaderSource stream_unpack_size_function (c_string function_name) const
 
void swap (UnpackSourceGenerator &obj)
 

Detailed Description

An unpack source generator is used to generate shader source code to unpack data from the data store buffer into a GLSL struct.

Definition at line 37 of file unpack_source_generator.hpp.

Member Enumeration Documentation

◆ cast_t

Enumeration specifying to bit-cast with GLSL's built-in uintBitsToFloat() or not

Enumerator
reinterpret_to_float_bits 

Reinterpret the bits as float bits, i.e. use uintBitsToFloat() of GLSL

type_cast 

only type-cast the bits.

Definition at line 61 of file unpack_source_generator.hpp.

◆ type_t

Enumeration specifing GLSL type for field (or subfield) of a value to unpack.

Enumerator
float_type 

GLSL type is float

uint_type 

GLSL type is uint

int_type 

GLSL type is int

padding_type 

indicates that the offset corresponds to padding and not any field or data.

Definition at line 44 of file unpack_source_generator.hpp.

Constructor & Destructor Documentation

◆ UnpackSourceGenerator() [1/3]

fastuidraw::glsl::UnpackSourceGenerator::UnpackSourceGenerator ( c_string  type_name)
explicit

Ctor.

Parameters
type_namename of GLSL type to which to unpack data from the data store buffer

◆ UnpackSourceGenerator() [2/3]

fastuidraw::glsl::UnpackSourceGenerator::UnpackSourceGenerator ( c_array< const c_string type_names)
explicit

Ctor.

Parameters
type_namesnames of GLSL type to which to unpack data from the data store buffer

◆ UnpackSourceGenerator() [3/3]

fastuidraw::glsl::UnpackSourceGenerator::UnpackSourceGenerator ( const UnpackSourceGenerator obj)

Copy ctor.

Parameters
objvalue from which to copy values.

Member Function Documentation

◆ operator=()

UnpackSourceGenerator& fastuidraw::glsl::UnpackSourceGenerator::operator= ( const UnpackSourceGenerator rhs)

Assignment operator

◆ set() [1/2]

UnpackSourceGenerator& fastuidraw::glsl::UnpackSourceGenerator::set ( unsigned int  offset,
c_string  field_name,
type_t  type,
enum cast_t  cast,
unsigned int  struct_idx = 0 
)

Set the field name that corresponds to an offset

Parameters
offsetoffset from the start of the packed struct in units of uint32_t
field_nameGLSL name of the field to which to unpack the single scalar value. The value must include the dot if it is a field member of a struct.
typethe GLSL type of the field
casthow to interpret the bits of the value
struct_idxif the ctor was given an array of c_string values, refers to the index into that array of the values.

◆ set() [2/2]

UnpackSourceGenerator& fastuidraw::glsl::UnpackSourceGenerator::set ( unsigned int  offset,
unsigned int  bit0,
unsigned int  num_bits,
c_string  field_name,
type_t  type,
enum cast_t  cast,
unsigned int  struct_idx = 0 
)

Set the field name that corresponds to an offset and range of bits within the value at the named offset

Parameters
offsetoffset from the start of the packed struct in units of uint32_t
bit0first bit of field value storted at offset
num_bitsnumber of bits used to store value.
field_nameGLSL name of the field to which to unpack the single scalar value. The value must include the dot if it is a field member of a struct.
typethe GLSL type of the field, must be uint_type or int_type
casthow to interpret the bits of the value
struct_idxif the ctor was given an array of c_string values, refers to the index into that array of the values.

◆ set_float()

UnpackSourceGenerator& fastuidraw::glsl::UnpackSourceGenerator::set_float ( unsigned int  offset,
c_string  field_name,
unsigned int  struct_idx = 0 
)
inline

Provided as a conveniance, equivalent to

set(offset, field_name, float_type, reinterpret_to_float_bits, struct_idx);
Parameters
offsetoffset from the start of the packed struct in units of uint32_t
field_nameGLSL name of the field to which to unpack the single scalar value. The value must include the dot if it is a field member of a struct.
struct_idxif the ctor was given an array of c_string values, refers to the index into that array of the values.

Definition at line 170 of file unpack_source_generator.hpp.

◆ set_int()

UnpackSourceGenerator& fastuidraw::glsl::UnpackSourceGenerator::set_int ( unsigned int  offset,
c_string  field_name,
unsigned int  struct_idx = 0 
)
inline

Provided as a conveniance, equivalent to

set(offset, field_name, int_type, type_cast, struct_idx);
Parameters
offsetoffset from the start of the packed struct in units of uint32_t
field_nameGLSL name of the field to which to unpack the single scalar value. The value must include the dot if it is a field member of a struct.
struct_idxif the ctor was given an array of c_string values, refers to the index into that array of the values.

Definition at line 214 of file unpack_source_generator.hpp.

◆ set_uint()

UnpackSourceGenerator& fastuidraw::glsl::UnpackSourceGenerator::set_uint ( unsigned int  offset,
c_string  field_name,
unsigned int  struct_idx = 0 
)
inline

Provided as a conveniance, equivalent to

set(offset, field_name, uint_type, type_cast, struct_idx);
Parameters
offsetoffset from the start of the packed struct in units of uint32_t
field_nameGLSL name of the field to which to unpack the single scalar value. The value must include the dot if it is a field member of a struct.
struct_idxif the ctor was given an array of c_string values, refers to the index into that array of the values.

Definition at line 192 of file unpack_source_generator.hpp.

◆ stream_unpack_function() [1/2]

const UnpackSourceGenerator& fastuidraw::glsl::UnpackSourceGenerator::stream_unpack_function ( ShaderSource str,
c_string  function_name 
) const

Stream the unpack function into a ShaderSource object. For values constructed passed a single c_string, the function generated is

void
function_name(in uint location, out struct_name v)

and for those values constructed passed an array of c_string values, the function generated is

void
function_name(in uint location, out struct_name0 v0, out struct_name1 v1, ...)

where for both, location is the location from which to unpack data and the remaining arguments are the struct types to which to unpacked as passed in the ctor.

Parameters
strShaderSource to which to stream the unpack function
function_namename to give the function

◆ stream_unpack_function() [2/2]

ShaderSource fastuidraw::glsl::UnpackSourceGenerator::stream_unpack_function ( c_string  function_name) const
inline

Provided as a conveniance, equivalent to

ShaderSource return_value;
stream_unpack_function(return_value, function_name);
return return_value;
Parameters
function_nameto give the function

Definition at line 266 of file unpack_source_generator.hpp.

◆ stream_unpack_size_function() [1/2]

const UnpackSourceGenerator& fastuidraw::glsl::UnpackSourceGenerator::stream_unpack_size_function ( ShaderSource str,
c_string  function_name 
) const

Stream a function with the given name that returns the number of data blocks (i.e. the number of uvec4 elements) used to store the struct described by this UnpackSourceGenerator.

Parameters
strShaderSource to which to stream the unpack function
function_namename to give the function

◆ stream_unpack_size_function() [2/2]

ShaderSource fastuidraw::glsl::UnpackSourceGenerator::stream_unpack_size_function ( c_string  function_name) const
inline

Provided as a conveniance, equivalent to

ShaderSource return_value;
stream_unpack_size_function(return_value, function_name);
return return_value;
Parameters
function_nameto give the function

Definition at line 283 of file unpack_source_generator.hpp.

◆ swap()

void fastuidraw::glsl::UnpackSourceGenerator::swap ( UnpackSourceGenerator obj)

Swap operation

Parameters
objobject with which to swap

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