Beatmup
|
3D tensor stored in a set of textures. More...
#include <storage.h>
Classes | |
class | Binder |
Binding of different input/output storages/texture handlers to a GLSL program. More... | |
class | InconsistentStorageState |
class | Scanner |
Scans a storageview in RAM for further computations on CPU. More... | |
struct | Texture |
class | TextureHandler |
TextureHandler representation of a pack of 4 channels from a non-empty View. More... | |
class | View |
Maps a 3D tensor onto a storage. More... | |
Public Member Functions | |
Storage (Context &ctx, GraphicPipeline &gpu, const Size size, const int pad, const int reservedChannels=0) | |
Creates a storage. More... | |
Storage (Context &ctx, GraphicPipeline &gpu, const Size size) | |
Creates a flat storage. More... | |
~Storage () | |
void | allocate (GraphicPipeline &gpu) |
Allocates the storage in GPU memory. More... | |
void | allocate () |
Allocates the storage in RAM. More... | |
void | free (GraphicPipeline &gpu) |
Frees the allocated memory immediately. More... | |
void | free () |
Deferred storage disposal: the textures are put into the GPU recycle bin associated with the context. More... | |
void | pull (GraphicPipeline &gpu) |
Pulls storage data from GPU memory to RAM. More... | |
void | push (GraphicPipeline &gpu) |
Pushes storage data from RAM to CPU memory. More... | |
void | push (GraphicPipeline &gpu, const float *hwcData, const size_t numSamples) |
Pushes a given data to GPU memory. More... | |
bool | isUpToDate (ProcessingTarget target) const |
Checks if the storage is up to date for a given processing target (CPU or GPU). More... | |
bool | isAllocated () const |
Returns true if the storage is allocated. More... | |
InternalBitmap * | getImage (Context &ctx, GraphicPipeline &gpu, int channel) const |
Converts a feature channel into a bitmap for debugging purposes. More... | |
int | getNumberOfTextures () const |
Returns total number of textures in the storage. More... | |
int | getChannelTextureNumber (int channel) const |
Returns number of texture containing a given channel. More... | |
IntPoint | getChannelOrigin (int channel) const |
Returns origin in pixels of a given channel within the texture containing it. More... | |
int | getTextureWidth () const |
Returns width in pixels of all the textures. More... | |
int | getTextureHeight () const |
Returns height in pixels of all the textures. More... | |
int | getPadding () const |
Returns storage padding. More... | |
Size | getSize () const |
Returns storage size in pixels. More... | |
size_t | getMemorySize () const |
AlignedMemory & | getMemory () |
Returns the storage memory, if allocated in RAM (for CPU). More... | |
const AlignedMemory & | getMemory () const |
Public Member Functions inherited from Beatmup::Object | |
virtual | ~Object () |
Static Public Member Functions | |
static void | checkChannelNumber (int channel) |
Checks whether a channel number points to the first channel in a texture. More... | |
Private Member Functions | |
Storage (const Storage &)=delete | |
disabling copying constructor More... | |
void | push (GraphicPipeline &gpu, const void *data) |
Private Attributes | |
Context & | context |
Texture * | textures |
AlignedMemory | memory |
data storage in RAM More... | |
const Size | size |
const int | pad |
padding in pixels added along width and height dimensions More... | |
int | packX |
int | packY |
number of blocks of 4 channels per texture (spatial packing) More... | |
bool | upToDate [2] |
Friends | |
class | Binder |
class | View |
3D tensor stored in a set of textures.
Constraints: The tensor entries are in [0, 1] range and sampled in 8 bits. The tensor depth is a multiple of 4. Feature maps are stored as RGBA textures (at least four channels per texture). More feature maps can be packed in the same texture. The textures are all of the same size though.
|
privatedelete |
disabling copying constructor
Storage::Storage | ( | Context & | ctx, |
GraphicPipeline & | gpu, | ||
const Size | size, | ||
const int | pad, | ||
const int | reservedChannels = 0 |
||
) |
Creates a storage.
[in] | ctx | A context |
[in] | gpu | A graphic pipeline instance |
[in] | size | Storage size |
[in] | pad | Additional padding to add to the texture dimensions |
[in] | reservedChannels | Number of depth dimensions that may be sampled together with this storage |
Definition at line 127 of file storage.cpp.
Storage::Storage | ( | Context & | ctx, |
GraphicPipeline & | gpu, | ||
const Size | size | ||
) |
Creates a flat storage.
It uses only one texture stacking all the feature maps in a column and has no padding.
[in] | ctx | A context |
[in] | gpu | A graphic pipeline instance |
[in] | size | Storage size |
Definition at line 151 of file storage.cpp.
Storage::~Storage | ( | ) |
Definition at line 162 of file storage.cpp.
|
private |
Definition at line 86 of file storage.cpp.
void Storage::allocate | ( | GraphicPipeline & | gpu | ) |
Allocates the storage in GPU memory.
[in] | gpu | A graphic pipeline instance |
Definition at line 167 of file storage.cpp.
void Storage::allocate | ( | ) |
void Storage::free | ( | GraphicPipeline & | gpu | ) |
Frees the allocated memory immediately.
[in] | gpu | A graphic pipeline instance |
Definition at line 190 of file storage.cpp.
void Storage::free | ( | ) |
Deferred storage disposal: the textures are put into the GPU recycle bin associated with the context.
Definition at line 204 of file storage.cpp.
void Storage::pull | ( | GraphicPipeline & | gpu | ) |
Pulls storage data from GPU memory to RAM.
[in] | gpu | A graphic pipeline instance |
Definition at line 233 of file storage.cpp.
void Storage::push | ( | GraphicPipeline & | gpu | ) |
Pushes storage data from RAM to CPU memory.
[in] | gpu | A graphic pipeline instance |
Definition at line 259 of file storage.cpp.
void Storage::push | ( | GraphicPipeline & | gpu, |
const float * | hwcData, | ||
const size_t | numSamples | ||
) |
Pushes a given data to GPU memory.
The data is stored as a 3D array of (height, width, channels) layout (n and n+1 channel values are next to each other in memory). If the array length does not match the storage capacity, an exception is thrown.
[in] | gpu | A graphic pipeline instance |
[in] | hwcData | The data to push. |
[in] | numSamples | The data array length (number of floating point values to push). |
Definition at line 277 of file storage.cpp.
|
inline |
|
inline |
InternalBitmap * Storage::getImage | ( | Context & | ctx, |
GraphicPipeline & | gpu, | ||
int | channel | ||
) | const |
Converts a feature channel into a bitmap for debugging purposes.
[in] | ctx | A context |
[in] | gpu | A graphic pipeline instance |
[in] | channel | Feature channel number to export |
Definition at line 312 of file storage.cpp.
int Storage::getNumberOfTextures | ( | ) | const |
int Storage::getChannelTextureNumber | ( | int | channel | ) | const |
Returns number of texture containing a given channel.
Definition at line 370 of file storage.cpp.
IntPoint Storage::getChannelOrigin | ( | int | channel | ) | const |
Returns origin in pixels of a given channel within the texture containing it.
Definition at line 379 of file storage.cpp.
int Storage::getTextureWidth | ( | ) | const |
int Storage::getTextureHeight | ( | ) | const |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlinestatic |
Checks whether a channel number points to the first channel in a texture.
Throws an exception otherwise.
|
private |
|
private |
|
private |