mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-07-03 14:34:34 +00:00
fixes to VertexBuffer
- only reallocate if size changes - fix logic error in the rare case of glUnmapBufferARB() failing
This commit is contained in:
parent
3a55777d63
commit
5eecf2d84c
2 changed files with 11 additions and 6 deletions
|
@ -93,8 +93,11 @@ void* DynamicGPUBuffer::beginWrite(BufDataType type, size_t newsize, unsigned ac
|
|||
}
|
||||
if(!(access & GPUACCESS_HOSTCOPY))
|
||||
{
|
||||
_d_cap = newsize;
|
||||
glBufferDataARB(_gl_binding, newsize, NULL, _gl_usage); // orphan buffer
|
||||
if(_d_cap != newsize)
|
||||
{
|
||||
_d_cap = newsize;
|
||||
glBufferDataARB(_gl_binding, newsize, NULL, _gl_usage); // orphan buffer
|
||||
}
|
||||
void *p = glMapBufferARB(_gl_binding, GL_WRITE_ONLY_ARB);
|
||||
_d_map = p;
|
||||
if(p)
|
||||
|
@ -131,10 +134,8 @@ bool DynamicGPUBuffer::_commitWrite(size_t used)
|
|||
if(_d_map)
|
||||
{
|
||||
assert(used <= _d_cap);
|
||||
bool ok = glUnmapBufferARB(_gl_binding); // can fail
|
||||
if(ok)
|
||||
_d_map = NULL;
|
||||
return ok;
|
||||
_d_map = NULL;
|
||||
return glUnmapBufferARB(_gl_binding); // can fail
|
||||
}
|
||||
// otherwise, the prev. call to glMapBufferARB failed (or GPUACCESS_HOSTCOPY was set).
|
||||
// -> didn't map, but wrote to host memory. upload it.
|
||||
|
|
|
@ -82,6 +82,10 @@ public:
|
|||
// Pass invert==true to draw from bottom to top.
|
||||
size_t initGridIndices_Triangles(size_t w, size_t h, bool invert, unsigned access);
|
||||
|
||||
|
||||
// For debugging only
|
||||
inline unsigned _glBufferId() const { return _bufid; }
|
||||
|
||||
private:
|
||||
|
||||
void* _allocBytes(size_t bytes);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue