mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-06-07 17:11:56 +00:00
Fix issues with empty VBO upload and vbo size desync
This commit is contained in:
parent
e89dd41be6
commit
5f9d26c360
2 changed files with 16 additions and 9 deletions
|
@ -70,7 +70,11 @@ void CurrentRender::onUpdate(float dt)
|
|||
size_t usedsize;
|
||||
do
|
||||
{
|
||||
float *p = (float*)vbo.beginWrite(GPUBUFTYPE_VEC2_TC_RGBA, bytes, GPUACCESS_DEFAULT);
|
||||
// Usually we write much less data than maximally possible to the GPU,
|
||||
// because most segments are off-screen and not visible.
|
||||
// The hostcopy flag accumulates the used data in the host heap
|
||||
// and only uploads what is necessary in the end
|
||||
float *p = (float*)vbo.beginWrite(GPUBUFTYPE_VEC2_TC_RGBA, bytes, GPUACCESS_HOSTCOPY);
|
||||
verts = writeVBOData(p);
|
||||
usedsize = verts * 8 * sizeof(float);
|
||||
}
|
||||
|
@ -109,9 +113,6 @@ size_t CurrentRender::writeVBOData(float *p)
|
|||
if (diff.isZero())
|
||||
continue;
|
||||
|
||||
float len = diff.getLength2D();
|
||||
float texScale = len/256.0f;
|
||||
|
||||
if (isTouchingLine(p1, p2, dsq->screenCenter, dsq->cullRadius+w2))
|
||||
{
|
||||
Vector pl = diff.getPerpendicularLeft();
|
||||
|
@ -132,6 +133,8 @@ size_t CurrentRender::writeVBOData(float *p)
|
|||
|
||||
const float ao = P->animOffset;
|
||||
const float a = P->amount;
|
||||
const float len = diff.getLength2D();
|
||||
const float texScale = len/256.0f;
|
||||
|
||||
/* This builds a structure like this:
|
||||
a = 0 alpha
|
||||
|
|
|
@ -141,12 +141,15 @@ bool DynamicGPUBuffer::_commitWrite(size_t used)
|
|||
// -> didn't map, but wrote to host memory. upload it.
|
||||
assert(_h_data);
|
||||
assert(used <= _h_cap);
|
||||
if(used <= _d_cap)
|
||||
glBufferSubDataARB(_gl_binding, 0, used, _h_data); // update existing buffer
|
||||
else
|
||||
if(used)
|
||||
{
|
||||
_d_cap = used;
|
||||
glBufferDataARB(_gl_binding, used, _h_data, _gl_usage); // alloc new buffer
|
||||
if(used <= _d_cap)
|
||||
glBufferSubDataARB(_gl_binding, 0, used, _h_data); // update existing buffer
|
||||
else
|
||||
{
|
||||
_d_cap = used;
|
||||
glBufferDataARB(_gl_binding, used, _h_data, _gl_usage); // alloc new buffer
|
||||
}
|
||||
}
|
||||
}
|
||||
// else nothing to do
|
||||
|
@ -168,6 +171,7 @@ void DynamicGPUBuffer::upload(BufDataType type, const void* data, size_t size)
|
|||
last = id;
|
||||
glBindBufferARB(_gl_binding, id);
|
||||
}
|
||||
_d_cap = size;
|
||||
glBufferDataARB(_gl_binding, size, data, _gl_usage);
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Add table
Reference in a new issue