Swizzle

Engine/source/core/util/swizzle.h

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

More...

Private Attributes

mMap [mapLength]

This is an array from 0..n.

Public Functions

Construct a swizzle.

InPlace(void * memory, const dsize_t size)

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.

ToBuffer(void * destination, const void * source, const dsize_t size)

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

Detailed Description

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

Private Attributes

dsize_t mMap [mapLength]

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' }

Public Functions

Swizzle(const dsize_t * map)

Construct a swizzle.

see:

Swizzle::mMap

~Swizzle()

InPlace(void * memory, const dsize_t size)

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 by: DXT5nmSwizzle, DXT5nmSwizzleUp24t32, NullSwizzle

ToBuffer(void * destination, const void * source, const dsize_t size)

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 by: DXT5nmSwizzle, DXT5nmSwizzleUp24t32, NullSwizzle