cgv
Loading...
Searching...
No Matches
cgv::data::packing_info Class Reference

the packing_info class stores information about packed integers structures. More...

#include <packing_info.h>

Inheritance diagram for cgv::data::packing_info:
cgv::data::component_format cgv::data::data_format cgv::render::render_buffer cgv::media::image::image cgv::render::texture

Public Member Functions

 packing_info (unsigned align=1, unsigned d0=0, unsigned d1=0, unsigned d2=0, unsigned d3=0)
 construct packing information from alignment and bit depths.
 
void clear ()
 clear packing info information
 
unsigned get_bit_depth (unsigned ci) const
 return the bit depth of the ci-th component
 
void set_bit_depth (unsigned ci, unsigned depth)
 set the bit depth of the ci-th component
 
bool is_packing () const
 return whether packing is enabled
 
void set_packing (bool enable=true)
 set the packing flag
 
unsigned int get_component_alignment () const
 return the component alignment in bits in the packed case and in bytes in the unpacked case
 
void set_component_alignment (unsigned a)
 set the component alignment in bits in the packed case and in bytes in the unpacked case
 
int get_signed (unsigned ci, const void *ptr) const
 return the ci-th component of the data entry pointed to by the given pointer of a signed packed component
 
unsigned int get_unsigned (unsigned ci, const void *ptr) const
 return the ci-th component of the data entry pointed to by the given pointer of an unsigned packed component
 
bool set_signed (unsigned ci, void *ptr, int v) const
 set the ci-th component of the data entry pointed to by the given pointer of a signed packed component
 
bool set_unsigned (unsigned ci, void *ptr, unsigned v) const
 set the ci-th component of the data entry pointed to by the given pointer of an unsigned packed component
 
bool operator== (const packing_info &pi) const
 equal comparison
 
bool operator!= (const packing_info &pi) const
 unequal comparison
 

Static Public Member Functions

static size_t align (size_t v, unsigned a)
 return the next integer larger or equal to v which is dividable by a
 

Protected Member Functions

bool prepare_bit_operation (unsigned ci, void *ptr, unsigned &off, unsigned &bd, unsigned *&iptr) const
 
bool prepare_bit_operation (unsigned ci, const void *ptr, unsigned &off, unsigned &bd, const unsigned *&iptr) const
 
unsigned int get_bit_offset (unsigned ci) const
 

Protected Attributes

bool is_packed: 1
 
unsigned bd0: 6
 
unsigned bd1: 6
 
unsigned bd2: 6
 
unsigned bd3: 6
 
unsigned ca: 6
 

Detailed Description

the packing_info class stores information about packed integers structures.

It is typically used to define packed component formats. The stored information includes, whether packing is used, the alignment of the components and bit depths of up to 4 components. The aligment is an integer defining a multiple to which the components are aligned. If the alignment is 1, the components are packed densely. If it is for example 8, the components are stored at starting at locations that are multiples of 8. For example if the components have bit depth 6 and the alignment is 8, then the first component is stored starting with the first bit, the second component starting with the 8th bit and so on. In case no packing is used the alignment is measured in bytes. The bit depths and alignment are stored as unsigned integers with 6 bits, i.e. the maximum value is 63.

Definition at line 24 of file packing_info.h.

Constructor & Destructor Documentation

◆ packing_info()

cgv::data::packing_info::packing_info ( unsigned  align = 1,
unsigned  d0 = 0,
unsigned  d1 = 0,
unsigned  d2 = 0,
unsigned  d3 = 0 
)

construct packing information from alignment and bit depths.

If no bit depths are given, the components are not packed and the alignment is in bytes. If one or more depths are specified, the alignment is in bits. If exactly one depth is given, all component bit depths are set to this bit depth

Definition at line 12 of file packing_info.cxx.

Member Function Documentation

◆ align()

size_t cgv::data::packing_info::align ( size_t  v,
unsigned  a 
)
static

◆ clear()

void cgv::data::packing_info::clear ( )

clear packing info information

Definition at line 20 of file packing_info.cxx.

Referenced by cgv::data::component_format::clear().

◆ get_bit_depth()

unsigned cgv::data::packing_info::get_bit_depth ( unsigned  ci) const

return the bit depth of the ci-th component

Definition at line 26 of file packing_info.cxx.

Referenced by cgv::data::fmt1_compares_better(), cgv::data::component_format::get_entry_size(), and operator==().

◆ get_bit_offset()

unsigned cgv::data::packing_info::get_bit_offset ( unsigned  ci) const
protected

Definition at line 69 of file packing_info.cxx.

◆ get_component_alignment()

unsigned int cgv::data::packing_info::get_component_alignment ( ) const

return the component alignment in bits in the packed case and in bytes in the unpacked case

Definition at line 43 of file packing_info.cxx.

Referenced by cgv::data::component_format::get_entry_size(), operator==(), and cgv::render::gl::gl_context::read_frame_buffer().

◆ get_signed()

int cgv::data::packing_info::get_signed ( unsigned  ci,
const void *  ptr 
) const

return the ci-th component of the data entry pointed to by the given pointer of a signed packed component

Definition at line 76 of file packing_info.cxx.

References cgv::utils::disable_upper_bits(), cgv::utils::enable_upper_bits(), and cgv::utils::is_bit_set().

◆ get_unsigned()

unsigned cgv::data::packing_info::get_unsigned ( unsigned  ci,
const void *  ptr 
) const

return the ci-th component of the data entry pointed to by the given pointer of an unsigned packed component

Definition at line 88 of file packing_info.cxx.

References cgv::utils::disable_upper_bits().

◆ is_packing()

bool cgv::data::packing_info::is_packing ( ) const

return whether packing is enabled

Definition at line 35 of file packing_info.cxx.

Referenced by cgv::data::fmt1_compares_better(), cgv::data::component_format::get_entry_size(), and operator==().

◆ operator!=()

bool cgv::data::packing_info::operator!= ( const packing_info pi) const

unequal comparison

Definition at line 122 of file packing_info.cxx.

◆ operator==()

bool cgv::data::packing_info::operator== ( const packing_info pi) const

equal comparison

Definition at line 111 of file packing_info.cxx.

References get_bit_depth(), get_component_alignment(), and is_packing().

◆ prepare_bit_operation() [1/2]

bool cgv::data::packing_info::prepare_bit_operation ( unsigned  ci,
const void *  ptr,
unsigned &  off,
unsigned &  bd,
const unsigned *&  iptr 
) const
protected

Definition at line 60 of file packing_info.cxx.

◆ prepare_bit_operation() [2/2]

bool cgv::data::packing_info::prepare_bit_operation ( unsigned  ci,
void *  ptr,
unsigned &  off,
unsigned &  bd,
unsigned *&  iptr 
) const
protected

Definition at line 51 of file packing_info.cxx.

◆ set_bit_depth()

void cgv::data::packing_info::set_bit_depth ( unsigned  ci,
unsigned  depth 
)

set the bit depth of the ci-th component

Definition at line 30 of file packing_info.cxx.

Referenced by cgv::data::component_format::set_component_format().

◆ set_component_alignment()

void cgv::data::packing_info::set_component_alignment ( unsigned  a)

set the component alignment in bits in the packed case and in bytes in the unpacked case

Definition at line 47 of file packing_info.cxx.

Referenced by cgv::data::component_format::set_component_format().

◆ set_packing()

void cgv::data::packing_info::set_packing ( bool  enable = true)

set the packing flag

Definition at line 39 of file packing_info.cxx.

Referenced by cgv::data::component_format::set_component_format().

◆ set_signed()

bool cgv::data::packing_info::set_signed ( unsigned  ci,
void *  ptr,
int  v 
) const

set the ci-th component of the data entry pointed to by the given pointer of a signed packed component

Definition at line 97 of file packing_info.cxx.

References cgv::utils::set_bits().

◆ set_unsigned()

bool cgv::data::packing_info::set_unsigned ( unsigned  ci,
void *  ptr,
unsigned  v 
) const

set the ci-th component of the data entry pointed to by the given pointer of an unsigned packed component

Definition at line 104 of file packing_info.cxx.

References cgv::utils::set_bits().

Member Data Documentation

◆ bd0

unsigned cgv::data::packing_info::bd0
protected

Definition at line 28 of file packing_info.h.

◆ bd1

unsigned cgv::data::packing_info::bd1
protected

Definition at line 29 of file packing_info.h.

◆ bd2

unsigned cgv::data::packing_info::bd2
protected

Definition at line 30 of file packing_info.h.

◆ bd3

unsigned cgv::data::packing_info::bd3
protected

Definition at line 31 of file packing_info.h.

◆ ca

unsigned cgv::data::packing_info::ca
protected

Definition at line 32 of file packing_info.h.

◆ is_packed

bool cgv::data::packing_info::is_packed
protected

Definition at line 27 of file packing_info.h.


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