#include <storage_buffer.h>
|
| StorageBuffer (GL::RecycleBin &recycleBin) |
|
| ~StorageBuffer () |
|
void | allocate (GraphicPipeline &gpu, const size_t sizeBytes, const void *data=nullptr) |
|
void | allocateStatic (GraphicPipeline &gpu, const size_t sizeBytes, const void *data) |
|
void | bind (GraphicPipeline &gpu, int unit) const |
|
void | fetch (GraphicPipeline &gpu, void *data, size_t limit) |
|
void | fetchToBitmap (GraphicPipeline &gpu, size_t offset, size_t stride, AbstractBitmap &bitmap) |
| Copies buffer content to a bitmap. More...
|
|
size_t | getCurrentCapacity () const |
|
Definition at line 26 of file storage_buffer.h.
◆ StorageBuffer()
◆ ~StorageBuffer()
StorageBuffer::~StorageBuffer |
( |
| ) |
|
Definition at line 35 of file storage_buffer.cpp.
42 glDeleteBuffers(1, &
handle);
A wrapper for a GPU resource.
void put(Item *item)
Puts an item into the recycle bin.
unsigned int handle_t
A reference to a GPU resource.
◆ allocate()
void StorageBuffer::allocate |
( |
GraphicPipeline & |
gpu, |
|
|
const size_t |
sizeBytes, |
|
|
const void * |
data = nullptr |
|
) |
| |
Definition at line 51 of file storage_buffer.cpp.
53 glDeleteBuffers(1, &
handle);
59 glBindBuffer(GL_SHADER_STORAGE_BUFFER,
handle);
60 glBufferData(GL_SHADER_STORAGE_BUFFER,
sizeBytes, data, GL_DYNAMIC_COPY);
◆ allocateStatic()
void Beatmup::GL::StorageBuffer::allocateStatic |
( |
GraphicPipeline & |
gpu, |
|
|
const size_t |
sizeBytes, |
|
|
const void * |
data |
|
) |
| |
Definition at line 66 of file storage_buffer.cpp.
68 glDeleteBuffers(1, &
handle);
74 glBindBuffer(GL_SHADER_STORAGE_BUFFER,
handle);
75 glBufferData(GL_SHADER_STORAGE_BUFFER,
sizeBytes, data, GL_STATIC_DRAW);
◆ bind()
Definition at line 82 of file storage_buffer.cpp.
83 glBindBufferBase(GL_SHADER_STORAGE_BUFFER, unit,
handle);
static void check(const std::string &info)
◆ fetch()
void StorageBuffer::fetch |
( |
GraphicPipeline & |
gpu, |
|
|
void * |
data, |
|
|
size_t |
limit |
|
) |
| |
Definition at line 88 of file storage_buffer.cpp.
89 glBindBuffer(GL_SHADER_STORAGE_BUFFER,
handle);
90 void* buffer = glMapBufferRange(GL_SHADER_STORAGE_BUFFER, 0, limit, GL_MAP_READ_BIT);
91 const bool okay = buffer !=
nullptr;
93 memcpy(data, buffer, limit);
94 glUnmapBuffer(GL_SHADER_STORAGE_BUFFER);
95 glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0);
◆ fetchToBitmap()
Copies buffer content to a bitmap.
- Parameters
-
[in] | gpu | Graphic pipeline instance |
[in] | offset | Offset in the buffer in bytes |
[in] | stride | Stride between entries to be copied to the bitmap in the buffer in bytes |
[out] | bitmap | The bitmap to fill |
Definition at line 101 of file storage_buffer.cpp.
108 glBindBuffer(GL_SHADER_STORAGE_BUFFER,
handle);
109 const pixbyte* buffer = (
const pixbyte*)glMapBufferRange(GL_SHADER_STORAGE_BUFFER, offset, limit - offset, GL_MAP_READ_BIT);
110 const bool okay = buffer !=
nullptr;
116 for (
int i = 0; i < nPix; ++i, ptr +=
step, buffer += stride)
117 memcpy(ptr, buffer,
step);
119 glUnmapBuffer(GL_SHADER_STORAGE_BUFFER);
120 glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0);
Makes a bitmap writable for a specific target device.
const ImageResolution getSize() const
Returns the bitmap resolution within ImageResolution object.
const unsigned char getBitsPerPixel() const
Returns number of bits per pixel stored in each bitmap.
bool isMask() const
Returns true if the bitmap is a mask, false otherwise.
size_t getCurrentCapacity() const
const pixbyte * getData(int x, int y) const
Returns a pointer to given pixel.
static void check(const bool condition, const std::string &message)
Beatmup::InternalBitmap * bitmap
◆ getCurrentCapacity()
size_t Beatmup::GL::StorageBuffer::getCurrentCapacity |
( |
| ) |
const |
|
inline |
◆ AbstractProgram
◆ sizeBytes
size_t Beatmup::GL::StorageBuffer::sizeBytes |
|
private |
◆ recycleBin
◆ handle
handle_t Beatmup::GL::StorageBuffer::handle |
|
private |
The documentation for this class was generated from the following files: