Swizzle< T, mapLength > Class Template Reference

#include <swizzle.h>

Inheritance diagram for Swizzle< T, mapLength >:

Inheritance graph
[legend]
List of all members.

Detailed Description


template<class T, dsize_t mapLength> class Swizzle< T, mapLength >

This class will swizzle 'sizeof( T )' length chunks of memory into different patterns which are user described.

The pattern is described by an instance of Swizzle and this swizzle can then be executed on buffers. The following must be true of the buffer size: size % ( sizeof( T ) * mapLength ) == 0


Public Member Functions

 Swizzle (const dsize_t *map)
 Construct a swizzle.
virtual void InPlace (void *memory, const dsize_t size) const
 This method will, in the general case, use the ToBuffer method to swizzle the memory specified into a temporary buffer, allocated by FrameTemp, and then copy the temporary memory into the source memory.
virtual void ToBuffer (void *destination, const void *source, const dsize_t size) const
 This method copies the data from source to destination while applying the re-ordering.
template<>
void InPlace (void *memory, const dsize_t size) const
template<>
void ToBuffer (void *destination, const void *source, const dsize_t size) const
template<>
void InPlace (void *memory, const dsize_t size) const
template<>
void ToBuffer (void *destination, const void *source, const dsize_t size) const
template<>
void ToBuffer (void *__restrict destination, const void *__restrict source, const dsize_t size) const

Private Attributes

dsize_t mMap [mapLength]
 This is an array from 0.


Constructor & Destructor Documentation

template<class T, dsize_t mapLength>
Swizzle< T, mapLength >::Swizzle ( const dsize_t map  ) 

Construct a swizzle.

See also:
Swizzle::mMap


Member Function Documentation

template<class T, dsize_t mapLength>
void Swizzle< T, mapLength >::InPlace ( void memory,
const dsize_t  size 
) const [inline, virtual]

This method will, in the general case, use the ToBuffer method to swizzle the memory specified into a temporary buffer, allocated by FrameTemp, and then copy the temporary memory into the source memory.

Parameters:
memory Pointer to the start of the buffer to swizzle
size Size of the buffer

Reimplemented in DXT5nmSwizzle, DXT5nmSwizzleUp24t32, and NullSwizzle< T, mapLength >.

template<class T, dsize_t mapLength>
void Swizzle< T, mapLength >::ToBuffer ( void destination,
const void source,
const dsize_t  size 
) const [inline, virtual]

This method copies the data from source to destination while applying the re-ordering.

This method is, in the non-specalized case, O(N^2) where N is sizeof( T ) / size; the number of instances of type 'T' in the buffer

Parameters:
destination The destination of the swizzled data
source The source data to be swizzled
size Size of the source and destination buffers.

Reimplemented in DXT5nmSwizzle, DXT5nmSwizzleUp24t32, and NullSwizzle< T, mapLength >.

template<>
void Swizzle< U8, 4 >::InPlace ( void memory,
const dsize_t  size 
) const [inline]

template<>
void Swizzle< U8, 4 >::ToBuffer ( void destination,
const void source,
const dsize_t  size 
) const [inline]

template<>
void Swizzle< U8, 3 >::InPlace ( void memory,
const dsize_t  size 
) const [inline]

template<>
void Swizzle< U8, 3 >::ToBuffer ( void destination,
const void source,
const dsize_t  size 
) const [inline]

template<>
void Swizzle< U8, 4 >::ToBuffer ( void *__restrict  destination,
const void *__restrict  source,
const dsize_t  size 
) const [inline]


Member Data Documentation

template<class T, dsize_t mapLength>
dsize_t Swizzle< T, mapLength >::mMap[mapLength] [private]

This is an array from 0.

.n. Each entry in the array is a dsize_t with values in the range 0..n. Each value in the range 0..n can occur any number of times.

For example: This is our data set, an array of characters with 4 elements { 'a', 'b', 'c', 'd' }

If the map { 3, 2, 1, 0 } was applied to this set, the result would be: { 'd', 'c', 'b', 'a' }

If the map { 3, 0, 2, 2 } was applied to the set, the result would be: { 'd', 'a', 'c', 'c' }