GL3: Manual syncing

--HG--
branch : opengl3
hg/feature/opengl3
kaetemi 11 years ago
parent 42936097ce
commit afea49e83d

@ -54,7 +54,8 @@ IVertexBufferGL3::~IVertexBufferGL3()
CVertexBufferGL3::CVertexBufferGL3(CDriverGL3 *drv, uint size, uint numVertices, CVertexBuffer::TPreferredMemory preferred, CVertexBuffer *vb) CVertexBufferGL3::CVertexBufferGL3(CDriverGL3 *drv, uint size, uint numVertices, CVertexBuffer::TPreferredMemory preferred, CVertexBuffer *vb)
: IVertexBufferGL3(drv, vb, IVertexBufferGL3::GL3), : IVertexBufferGL3(drv, vb, IVertexBufferGL3::GL3),
m_VertexPtr(NULL), m_VertexPtr(NULL),
m_VertexObjectId(0) m_VertexObjectId(0),
m_FenceId(0)
{ {
H_AUTO_OGL(CVertexBufferGLARB_CVertexBufferGLARB) H_AUTO_OGL(CVertexBufferGLARB_CVertexBufferGLARB)
@ -174,11 +175,29 @@ void *CVertexBufferGL3::lock()
case CVertexBuffer::RAMPreferred: case CVertexBuffer::RAMPreferred:
// m_VertexPtr = nglMapBufferRange(GL_ARRAY_BUFFER, 0, size, GL_MAP_WRITE_BIT | GL_MAP_READ_BIT | GL_MAP_PERSISTENT | GL_MAP_COHERENT); // m_VertexPtr = nglMapBufferRange(GL_ARRAY_BUFFER, 0, size, GL_MAP_WRITE_BIT | GL_MAP_READ_BIT | GL_MAP_PERSISTENT | GL_MAP_COHERENT);
// NOTE: Persistent / Coherent is only available in OpenGL 4.4 (2013/2014 hardware with recent drivers) // NOTE: Persistent / Coherent is only available in OpenGL 4.4 (2013/2014 hardware with recent drivers)
m_VertexPtr = nglMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE); // m_VertexPtr = nglMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE);
if (m_FenceId)
{
GLenum result = nglClientWaitSync(m_FenceId, GL_SYNC_FLUSH_COMMANDS_BIT, 0);
nlassert(result != GL_TIMEOUT_EXPIRED);
nlassert(result != GL_WAIT_FAILED);
nglDeleteSync(m_FenceId);
m_FenceId = NULL;
}
m_VertexPtr = nglMapBufferRange(GL_ARRAY_BUFFER, 0, size, GL_MAP_WRITE_BIT | GL_MAP_READ_BIT | GL_MAP_UNSYNCHRONIZED_BIT);
break; break;
default: default:
// m_VertexPtr = nglMapBufferRange(GL_ARRAY_BUFFER, 0, size, GL_MAP_WRITE_BIT); // m_VertexPtr = nglMapBufferRange(GL_ARRAY_BUFFER, 0, size, GL_MAP_WRITE_BIT);
m_VertexPtr = nglMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY); // m_VertexPtr = nglMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
if (m_FenceId)
{
GLenum result = nglClientWaitSync(m_FenceId, GL_SYNC_FLUSH_COMMANDS_BIT, 0);
nlassert(result != GL_TIMEOUT_EXPIRED);
nlassert(result != GL_WAIT_FAILED);
nglDeleteSync(m_FenceId);
m_FenceId = NULL;
}
m_VertexPtr = nglMapBufferRange(GL_ARRAY_BUFFER, 0, size, GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT);
break; break;
} }
@ -302,7 +321,22 @@ void CVertexBufferGL3::setFence()
{ {
H_AUTO_OGL(CVertexBufferGLARB_setFence) H_AUTO_OGL(CVertexBufferGLARB_setFence)
// no-op // Set the fence
switch (m_MemType)
{
case CVertexBuffer::AGPVolatile:
case CVertexBuffer::RAMVolatile:
break;
default:
if (m_FenceId)
{
nglDeleteSync(m_FenceId);
m_FenceId = 0;
}
m_FenceId = nglFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
nlassert(m_FenceId);
break;
}
} }
// *************************************************************************** // ***************************************************************************

@ -103,6 +103,8 @@ private:
std::list<CVertexBufferGL3*>::iterator m_IteratorInLostVBList; std::list<CVertexBufferGL3*>::iterator m_IteratorInLostVBList;
uint m_VertexObjectId; uint m_VertexObjectId;
GLsync m_FenceId;
}; };
// *************************************************************************** // ***************************************************************************

Loading…
Cancel
Save