gl_stream_buffer: Always use persistent memory maps
yuzu no longer supports platforms without persistent maps.
This commit is contained in:
parent
b66ccaa376
commit
da79ec9565
|
@ -14,8 +14,7 @@ MICROPROFILE_DEFINE(OpenGL_StreamBuffer, "OpenGL", "Stream Buffer Orphaning",
|
||||||
|
|
||||||
namespace OpenGL {
|
namespace OpenGL {
|
||||||
|
|
||||||
OGLStreamBuffer::OGLStreamBuffer(GLsizeiptr size, bool vertex_data_usage, bool prefer_coherent,
|
OGLStreamBuffer::OGLStreamBuffer(GLsizeiptr size, bool vertex_data_usage, bool prefer_coherent)
|
||||||
bool use_persistent)
|
|
||||||
: buffer_size(size) {
|
: buffer_size(size) {
|
||||||
gl_buffer.Create();
|
gl_buffer.Create();
|
||||||
|
|
||||||
|
@ -29,23 +28,16 @@ OGLStreamBuffer::OGLStreamBuffer(GLsizeiptr size, bool vertex_data_usage, bool p
|
||||||
allocate_size *= 2;
|
allocate_size *= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (use_persistent) {
|
coherent = prefer_coherent;
|
||||||
persistent = true;
|
const GLbitfield flags =
|
||||||
coherent = prefer_coherent;
|
GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | (coherent ? GL_MAP_COHERENT_BIT : 0);
|
||||||
const GLbitfield flags =
|
glNamedBufferStorage(gl_buffer.handle, allocate_size, nullptr, flags);
|
||||||
GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | (coherent ? GL_MAP_COHERENT_BIT : 0);
|
mapped_ptr = static_cast<u8*>(glMapNamedBufferRange(
|
||||||
glNamedBufferStorage(gl_buffer.handle, allocate_size, nullptr, flags);
|
gl_buffer.handle, 0, buffer_size, flags | (coherent ? 0 : GL_MAP_FLUSH_EXPLICIT_BIT)));
|
||||||
mapped_ptr = static_cast<u8*>(glMapNamedBufferRange(
|
|
||||||
gl_buffer.handle, 0, buffer_size, flags | (coherent ? 0 : GL_MAP_FLUSH_EXPLICIT_BIT)));
|
|
||||||
} else {
|
|
||||||
glNamedBufferData(gl_buffer.handle, allocate_size, nullptr, GL_STREAM_DRAW);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OGLStreamBuffer::~OGLStreamBuffer() {
|
OGLStreamBuffer::~OGLStreamBuffer() {
|
||||||
if (persistent) {
|
glUnmapNamedBuffer(gl_buffer.handle);
|
||||||
glUnmapNamedBuffer(gl_buffer.handle);
|
|
||||||
}
|
|
||||||
gl_buffer.Release();
|
gl_buffer.Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,16 +55,14 @@ std::tuple<u8*, GLintptr, bool> OGLStreamBuffer::Map(GLsizeiptr size, GLintptr a
|
||||||
buffer_pos = 0;
|
buffer_pos = 0;
|
||||||
invalidate = true;
|
invalidate = true;
|
||||||
|
|
||||||
if (persistent) {
|
glUnmapNamedBuffer(gl_buffer.handle);
|
||||||
glUnmapNamedBuffer(gl_buffer.handle);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (invalidate || !persistent) {
|
if (invalidate) {
|
||||||
MICROPROFILE_SCOPE(OpenGL_StreamBuffer);
|
MICROPROFILE_SCOPE(OpenGL_StreamBuffer);
|
||||||
GLbitfield flags = GL_MAP_WRITE_BIT | (persistent ? GL_MAP_PERSISTENT_BIT : 0) |
|
const GLbitfield flags = GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT |
|
||||||
(coherent ? GL_MAP_COHERENT_BIT : GL_MAP_FLUSH_EXPLICIT_BIT) |
|
GL_MAP_INVALIDATE_BUFFER_BIT |
|
||||||
(invalidate ? GL_MAP_INVALIDATE_BUFFER_BIT : GL_MAP_UNSYNCHRONIZED_BIT);
|
(coherent ? GL_MAP_COHERENT_BIT : GL_MAP_FLUSH_EXPLICIT_BIT);
|
||||||
mapped_ptr = static_cast<u8*>(
|
mapped_ptr = static_cast<u8*>(
|
||||||
glMapNamedBufferRange(gl_buffer.handle, buffer_pos, buffer_size - buffer_pos, flags));
|
glMapNamedBufferRange(gl_buffer.handle, buffer_pos, buffer_size - buffer_pos, flags));
|
||||||
mapped_offset = buffer_pos;
|
mapped_offset = buffer_pos;
|
||||||
|
@ -88,10 +78,6 @@ void OGLStreamBuffer::Unmap(GLsizeiptr size) {
|
||||||
glFlushMappedNamedBufferRange(gl_buffer.handle, buffer_pos - mapped_offset, size);
|
glFlushMappedNamedBufferRange(gl_buffer.handle, buffer_pos - mapped_offset, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!persistent) {
|
|
||||||
glUnmapNamedBuffer(gl_buffer.handle);
|
|
||||||
}
|
|
||||||
|
|
||||||
buffer_pos += size;
|
buffer_pos += size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,7 @@ namespace OpenGL {
|
||||||
|
|
||||||
class OGLStreamBuffer : private NonCopyable {
|
class OGLStreamBuffer : private NonCopyable {
|
||||||
public:
|
public:
|
||||||
explicit OGLStreamBuffer(GLsizeiptr size, bool vertex_data_usage, bool prefer_coherent = false,
|
explicit OGLStreamBuffer(GLsizeiptr size, bool vertex_data_usage, bool prefer_coherent = false);
|
||||||
bool use_persistent = true);
|
|
||||||
~OGLStreamBuffer();
|
~OGLStreamBuffer();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -41,7 +40,6 @@ private:
|
||||||
OGLBuffer gl_buffer;
|
OGLBuffer gl_buffer;
|
||||||
|
|
||||||
bool coherent = false;
|
bool coherent = false;
|
||||||
bool persistent = false;
|
|
||||||
|
|
||||||
GLintptr buffer_pos = 0;
|
GLintptr buffer_pos = 0;
|
||||||
GLsizeiptr buffer_size = 0;
|
GLsizeiptr buffer_size = 0;
|
||||||
|
|
Loading…
Reference in New Issue