mirror of https://github.com/bkaradzic/bgfx
GL: Added orphaning buffers to avoid transient buffer stalls. Issue #706.
This commit is contained in:
parent
fe89637a8c
commit
937da03f04
|
@ -5383,13 +5383,13 @@ namespace bgfx { namespace gl
|
|||
if (0 < _render->m_iboffset)
|
||||
{
|
||||
TransientIndexBuffer* ib = _render->m_transientIb;
|
||||
m_indexBuffers[ib->handle.idx].update(0, _render->m_iboffset, ib->data);
|
||||
m_indexBuffers[ib->handle.idx].update(0, _render->m_iboffset, ib->data, true);
|
||||
}
|
||||
|
||||
if (0 < _render->m_vboffset)
|
||||
{
|
||||
TransientVertexBuffer* vb = _render->m_transientVb;
|
||||
m_vertexBuffers[vb->handle.idx].update(0, _render->m_vboffset, vb->data);
|
||||
m_vertexBuffers[vb->handle.idx].update(0, _render->m_vboffset, vb->data, true);
|
||||
}
|
||||
|
||||
_render->sort();
|
||||
|
|
|
@ -1058,9 +1058,17 @@ namespace bgfx { namespace gl
|
|||
GL_CHECK(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0) );
|
||||
}
|
||||
|
||||
void update(uint32_t _offset, uint32_t _size, void* _data)
|
||||
void update(uint32_t _offset, uint32_t _size, void* _data, bool _discard = false)
|
||||
{
|
||||
BX_CHECK(0 != m_id, "Updating invalid index buffer.");
|
||||
|
||||
if (_discard)
|
||||
{
|
||||
// orphan buffer...
|
||||
destroy();
|
||||
create(m_size, NULL, m_flags);
|
||||
}
|
||||
|
||||
GL_CHECK(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_id) );
|
||||
GL_CHECK(glBufferSubData(GL_ELEMENT_ARRAY_BUFFER
|
||||
, _offset
|
||||
|
@ -1104,9 +1112,17 @@ namespace bgfx { namespace gl
|
|||
GL_CHECK(glBindBuffer(m_target, 0) );
|
||||
}
|
||||
|
||||
void update(uint32_t _offset, uint32_t _size, void* _data)
|
||||
void update(uint32_t _offset, uint32_t _size, void* _data, bool _discard = false)
|
||||
{
|
||||
BX_CHECK(0 != m_id, "Updating invalid vertex buffer.");
|
||||
|
||||
if (_discard)
|
||||
{
|
||||
// orphan buffer...
|
||||
destroy();
|
||||
create(m_size, NULL, m_decl, 0);
|
||||
}
|
||||
|
||||
GL_CHECK(glBindBuffer(m_target, m_id) );
|
||||
GL_CHECK(glBufferSubData(m_target
|
||||
, _offset
|
||||
|
|
Loading…
Reference in New Issue