yuzu-emu
/
yuzu-mainline
Archived
1
0
Fork 0

gl_stream_buffer: Always use a non-coherent buffer

This commit is contained in:
ReinUsesLisp 2020-05-11 16:21:08 -03:00
parent da79ec9565
commit 00c66a7289
2 changed files with 10 additions and 14 deletions

View File

@ -4,6 +4,7 @@
#include <deque> #include <deque>
#include <vector> #include <vector>
#include "common/alignment.h" #include "common/alignment.h"
#include "common/assert.h" #include "common/assert.h"
#include "common/microprofile.h" #include "common/microprofile.h"
@ -14,8 +15,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) : buffer_size(size) {
: buffer_size(size) {
gl_buffer.Create(); gl_buffer.Create();
GLsizeiptr allocate_size = size; GLsizeiptr allocate_size = size;
@ -28,12 +28,10 @@ OGLStreamBuffer::OGLStreamBuffer(GLsizeiptr size, bool vertex_data_usage, bool p
allocate_size *= 2; allocate_size *= 2;
} }
coherent = prefer_coherent; static constexpr GLbitfield flags = GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT;
const GLbitfield flags =
GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | (coherent ? GL_MAP_COHERENT_BIT : 0);
glNamedBufferStorage(gl_buffer.handle, allocate_size, nullptr, flags); glNamedBufferStorage(gl_buffer.handle, allocate_size, nullptr, flags);
mapped_ptr = static_cast<u8*>(glMapNamedBufferRange( mapped_ptr = static_cast<u8*>(
gl_buffer.handle, 0, buffer_size, flags | (coherent ? 0 : GL_MAP_FLUSH_EXPLICIT_BIT))); glMapNamedBufferRange(gl_buffer.handle, 0, buffer_size, flags | GL_MAP_FLUSH_EXPLICIT_BIT));
} }
OGLStreamBuffer::~OGLStreamBuffer() { OGLStreamBuffer::~OGLStreamBuffer() {
@ -59,10 +57,10 @@ std::tuple<u8*, GLintptr, bool> OGLStreamBuffer::Map(GLsizeiptr size, GLintptr a
} }
if (invalidate) { if (invalidate) {
static const GLbitfield flags = GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT |
GL_MAP_INVALIDATE_BUFFER_BIT | GL_MAP_FLUSH_EXPLICIT_BIT;
MICROPROFILE_SCOPE(OpenGL_StreamBuffer); MICROPROFILE_SCOPE(OpenGL_StreamBuffer);
const GLbitfield flags = GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT |
GL_MAP_INVALIDATE_BUFFER_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;
@ -74,7 +72,7 @@ std::tuple<u8*, GLintptr, bool> OGLStreamBuffer::Map(GLsizeiptr size, GLintptr a
void OGLStreamBuffer::Unmap(GLsizeiptr size) { void OGLStreamBuffer::Unmap(GLsizeiptr size) {
ASSERT(size <= mapped_size); ASSERT(size <= mapped_size);
if (!coherent && size > 0) { if (size > 0) {
glFlushMappedNamedBufferRange(gl_buffer.handle, buffer_pos - mapped_offset, size); glFlushMappedNamedBufferRange(gl_buffer.handle, buffer_pos - mapped_offset, size);
} }

View File

@ -13,7 +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);
~OGLStreamBuffer(); ~OGLStreamBuffer();
/* /*
@ -39,8 +39,6 @@ public:
private: private:
OGLBuffer gl_buffer; OGLBuffer gl_buffer;
bool coherent = false;
GLintptr buffer_pos = 0; GLintptr buffer_pos = 0;
GLsizeiptr buffer_size = 0; GLsizeiptr buffer_size = 0;
GLintptr mapped_offset = 0; GLintptr mapped_offset = 0;