mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-13 19:44:28 +00:00
gl_engine: fix memory out of bounds error in GlGpuBuffer
If buffer data is larger than memory alignment, need to make sure there is enough memory in current stage buffer
This commit is contained in:
parent
bcb35ba33b
commit
5949a994c8
2 changed files with 5 additions and 5 deletions
|
@ -87,7 +87,7 @@ GlStageBuffer::~GlStageBuffer()
|
|||
|
||||
uint32_t GlStageBuffer::push(void *data, uint32_t size, bool alignGpuOffset)
|
||||
{
|
||||
if (alignGpuOffset) alignOffset();
|
||||
if (alignGpuOffset) alignOffset(size);
|
||||
|
||||
uint32_t offset = mStageBuffer.count;
|
||||
|
||||
|
@ -135,7 +135,7 @@ GLuint GlStageBuffer::getBufferId()
|
|||
return mGpuBuffer->getBufferId();
|
||||
}
|
||||
|
||||
void GlStageBuffer::alignOffset()
|
||||
void GlStageBuffer::alignOffset(uint32_t size)
|
||||
{
|
||||
|
||||
uint32_t alignment = _getGpuBufferAlign();
|
||||
|
@ -145,8 +145,8 @@ void GlStageBuffer::alignOffset()
|
|||
|
||||
uint32_t offset = alignment - mStageBuffer.count % alignment;
|
||||
|
||||
if (mStageBuffer.count + offset > mStageBuffer.reserved) {
|
||||
mStageBuffer.grow(max(alignment, mStageBuffer.reserved));
|
||||
if (mStageBuffer.count + offset + size > mStageBuffer.reserved) {
|
||||
mStageBuffer.grow(max(offset + size, mStageBuffer.reserved));
|
||||
}
|
||||
|
||||
mStageBuffer.count += offset;
|
||||
|
|
|
@ -64,7 +64,7 @@ public:
|
|||
|
||||
GLuint getBufferId();
|
||||
private:
|
||||
void alignOffset();
|
||||
void alignOffset(uint32_t size);
|
||||
private:
|
||||
GLuint mVao = 0;
|
||||
unique_ptr<GlGpuBuffer> mGpuBuffer = {};
|
||||
|
|
Loading…
Add table
Reference in a new issue