22 #include "../exception.h"
25 #ifndef BEATMUP_OPENGLVERSION_GLES20
31 sizeBytes(0), recycleBin(recycleBin),
handle(0)
42 glDeleteBuffers(1, &
handle);
53 glDeleteBuffers(1, &
handle);
59 glBindBuffer(GL_SHADER_STORAGE_BUFFER,
handle);
60 glBufferData(GL_SHADER_STORAGE_BUFFER,
sizeBytes, data, GL_DYNAMIC_COPY);
67 if (
handle && this->sizeBytes != sizeBytes) {
68 glDeleteBuffers(1, &
handle);
72 if (!
handle && sizeBytes > 0) {
74 glBindBuffer(GL_SHADER_STORAGE_BUFFER,
handle);
75 glBufferData(GL_SHADER_STORAGE_BUFFER, sizeBytes, data, GL_STATIC_DRAW);
78 this->sizeBytes = sizeBytes;
83 glBindBufferBase(GL_SHADER_STORAGE_BUFFER, unit,
handle);
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);
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);
126 buffer(buffer), outputBuffer(outputBuffer), outputBufferSize(outputBufferSize)
Makes a bitmap writable for a specific target device.
A very basic class for any image.
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.
static void check(const std::string &info)
A wrapper for a GPU resource.
Stores references to GPU resources that will not be used anymore and needed to be recycled in a threa...
void put(Item *item)
Puts an item into the recycle bin.
const size_t outputBufferSize
bool processOnGPU(GraphicPipeline &gpu, TaskThread &thread)
Executes the task on GPU.
StorageBufferFetcher(StorageBuffer &buffer, void *outputBuffer, size_t outputBufferSize)
void fetch(GraphicPipeline &gpu, void *data, size_t limit)
GL::RecycleBin & recycleBin
StorageBuffer(GL::RecycleBin &recycleBin)
void bind(GraphicPipeline &gpu, int unit) const
void allocate(GraphicPipeline &gpu, const size_t sizeBytes, const void *data=nullptr)
void fetchToBitmap(GraphicPipeline &gpu, size_t offset, size_t stride, AbstractBitmap &bitmap)
Copies buffer content to a bitmap.
void allocateStatic(GraphicPipeline &gpu, const size_t sizeBytes, const void *data)
Internal low-level GPU control API.
const pixbyte * getData(int x, int y) const
Returns a pointer to given pixel.
static void check(const bool condition, const std::string &message)
unsigned int handle_t
A reference to a GPU resource.
JNIEnv jobject jlong handle
Beatmup::InternalBitmap * bitmap