evil hack: map the buffer once and use this pointer after unmaping
This isn't allowed by gl and may _only_ work, if the driver uses cpu bound buffer. But it may speed up :-)
This commit is contained in:
parent
f677b8cba3
commit
1d86dafbe2
|
@ -41,7 +41,7 @@ StreamBuffer::StreamBuffer(u32 type, size_t size, StreamType uploadType)
|
||||||
if(g_Config.backend_info.bSupportsGLPinnedMemory)
|
if(g_Config.backend_info.bSupportsGLPinnedMemory)
|
||||||
m_uploadtype = PINNED_MEMORY;
|
m_uploadtype = PINNED_MEMORY;
|
||||||
else
|
else
|
||||||
m_uploadtype = MAP_AND_SYNC;
|
m_uploadtype = MAP_AND_RISK;
|
||||||
}
|
}
|
||||||
|
|
||||||
Init();
|
Init();
|
||||||
|
@ -73,6 +73,7 @@ void StreamBuffer::Alloc ( size_t size, u32 stride )
|
||||||
break;
|
break;
|
||||||
case MAP_AND_SYNC:
|
case MAP_AND_SYNC:
|
||||||
case PINNED_MEMORY:
|
case PINNED_MEMORY:
|
||||||
|
case MAP_AND_RISK:
|
||||||
|
|
||||||
// insert waiting slots for used memory
|
// insert waiting slots for used memory
|
||||||
for(u32 i=SLOT(m_used_iterator); i<SLOT(m_iterator); i++)
|
for(u32 i=SLOT(m_used_iterator); i<SLOT(m_iterator); i++)
|
||||||
|
@ -133,6 +134,7 @@ size_t StreamBuffer::Upload ( u8* data, size_t size )
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PINNED_MEMORY:
|
case PINNED_MEMORY:
|
||||||
|
case MAP_AND_RISK:
|
||||||
memcpy(pointer+m_iterator, data, size);
|
memcpy(pointer+m_iterator, data, size);
|
||||||
break;
|
break;
|
||||||
case BUFFERSUBDATA:
|
case BUFFERSUBDATA:
|
||||||
|
@ -174,6 +176,16 @@ void StreamBuffer::Init()
|
||||||
glBindBuffer(GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD, 0);
|
glBindBuffer(GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD, 0);
|
||||||
glBindBuffer(m_buffertype, m_buffer);
|
glBindBuffer(m_buffertype, m_buffer);
|
||||||
break;
|
break;
|
||||||
|
case MAP_AND_RISK:
|
||||||
|
fences = new GLsync[SYNC_POINTS];
|
||||||
|
for(u32 i=0; i<SYNC_POINTS; i++)
|
||||||
|
fences[i] = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
|
||||||
|
|
||||||
|
glBindBuffer(m_buffertype, m_buffer);
|
||||||
|
glBufferData(m_buffertype, m_size, NULL, GL_STREAM_DRAW);
|
||||||
|
pointer = (u8*)glMapBuffer(m_buffertype, GL_WRITE_ONLY);
|
||||||
|
glUnmapBuffer(m_buffertype);
|
||||||
|
|
||||||
case STREAM_DETECT:
|
case STREAM_DETECT:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -183,6 +195,7 @@ void StreamBuffer::Shutdown()
|
||||||
{
|
{
|
||||||
switch(m_uploadtype) {
|
switch(m_uploadtype) {
|
||||||
case MAP_AND_SYNC:
|
case MAP_AND_SYNC:
|
||||||
|
case MAP_AND_RISK:
|
||||||
for(u32 i=0; i<SYNC_POINTS; i++)
|
for(u32 i=0; i<SYNC_POINTS; i++)
|
||||||
glDeleteSync(fences[i]);
|
glDeleteSync(fences[i]);
|
||||||
delete [] fences;
|
delete [] fences;
|
||||||
|
|
|
@ -29,6 +29,7 @@ enum StreamType {
|
||||||
STREAM_DETECT,
|
STREAM_DETECT,
|
||||||
MAP_AND_ORPHAN,
|
MAP_AND_ORPHAN,
|
||||||
MAP_AND_SYNC,
|
MAP_AND_SYNC,
|
||||||
|
MAP_AND_RISK,
|
||||||
PINNED_MEMORY,
|
PINNED_MEMORY,
|
||||||
BUFFERSUBDATA
|
BUFFERSUBDATA
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue