summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2019-01-06 06:07:20 +0100
committerReinUsesLisp <reinuseslisp@airmail.cc>2019-01-06 20:49:24 +0100
commit5933b3ea967341eb8e891b8141015c6ecd815830 (patch)
tree3749573712dda6907dfcaa3039cc1c5fb496e59b
parentgl_rasterizer: Use DSA for vertex array objects (diff)
downloadyuzu-5933b3ea967341eb8e891b8141015c6ecd815830.tar
yuzu-5933b3ea967341eb8e891b8141015c6ecd815830.tar.gz
yuzu-5933b3ea967341eb8e891b8141015c6ecd815830.tar.bz2
yuzu-5933b3ea967341eb8e891b8141015c6ecd815830.tar.lz
yuzu-5933b3ea967341eb8e891b8141015c6ecd815830.tar.xz
yuzu-5933b3ea967341eb8e891b8141015c6ecd815830.tar.zst
yuzu-5933b3ea967341eb8e891b8141015c6ecd815830.zip
-rw-r--r--src/video_core/renderer_opengl/gl_buffer_cache.cpp2
-rw-r--r--src/video_core/renderer_opengl/gl_stream_buffer.cpp26
-rw-r--r--src/video_core/renderer_opengl/gl_stream_buffer.h3
3 files changed, 14 insertions, 17 deletions
diff --git a/src/video_core/renderer_opengl/gl_buffer_cache.cpp b/src/video_core/renderer_opengl/gl_buffer_cache.cpp
index 46a6c0308..bd2b30e77 100644
--- a/src/video_core/renderer_opengl/gl_buffer_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_buffer_cache.cpp
@@ -14,7 +14,7 @@
namespace OpenGL {
OGLBufferCache::OGLBufferCache(RasterizerOpenGL& rasterizer, std::size_t size)
- : RasterizerCache{rasterizer}, stream_buffer(GL_ARRAY_BUFFER, size) {}
+ : RasterizerCache{rasterizer}, stream_buffer(size, true) {}
GLintptr OGLBufferCache::UploadMemory(Tegra::GPUVAddr gpu_addr, std::size_t size,
std::size_t alignment, bool cache) {
diff --git a/src/video_core/renderer_opengl/gl_stream_buffer.cpp b/src/video_core/renderer_opengl/gl_stream_buffer.cpp
index b97b895a4..d0b14b3f6 100644
--- a/src/video_core/renderer_opengl/gl_stream_buffer.cpp
+++ b/src/video_core/renderer_opengl/gl_stream_buffer.cpp
@@ -15,13 +15,12 @@ MICROPROFILE_DEFINE(OpenGL_StreamBuffer, "OpenGL", "Stream Buffer Orphaning",
namespace OpenGL {
-OGLStreamBuffer::OGLStreamBuffer(GLenum target, GLsizeiptr size, bool prefer_coherent)
- : gl_target(target), buffer_size(size) {
+OGLStreamBuffer::OGLStreamBuffer(GLsizeiptr size, bool vertex_data_usage, bool prefer_coherent)
+ : buffer_size(size) {
gl_buffer.Create();
- glBindBuffer(gl_target, gl_buffer.handle);
GLsizeiptr allocate_size = size;
- if (target == GL_ARRAY_BUFFER) {
+ if (vertex_data_usage) {
// On AMD GPU there is a strange crash in indexed drawing. The crash happens when the buffer
// read position is near the end and is an out-of-bound access to the vertex buffer. This is
// probably a bug in the driver and is related to the usage of vec3<byte> attributes in the
@@ -35,18 +34,17 @@ OGLStreamBuffer::OGLStreamBuffer(GLenum target, GLsizeiptr size, bool prefer_coh
coherent = prefer_coherent;
const GLbitfield flags =
GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | (coherent ? GL_MAP_COHERENT_BIT : 0);
- glBufferStorage(gl_target, allocate_size, nullptr, flags);
- mapped_ptr = static_cast<u8*>(glMapBufferRange(
- gl_target, 0, buffer_size, flags | (coherent ? 0 : GL_MAP_FLUSH_EXPLICIT_BIT)));
+ glNamedBufferStorage(gl_buffer.handle, allocate_size, nullptr, flags);
+ mapped_ptr = static_cast<u8*>(glMapNamedBufferRange(
+ gl_buffer.handle, 0, buffer_size, flags | (coherent ? 0 : GL_MAP_FLUSH_EXPLICIT_BIT)));
} else {
- glBufferData(gl_target, allocate_size, nullptr, GL_STREAM_DRAW);
+ glNamedBufferData(gl_buffer.handle, allocate_size, nullptr, GL_STREAM_DRAW);
}
}
OGLStreamBuffer::~OGLStreamBuffer() {
if (persistent) {
- glBindBuffer(gl_target, gl_buffer.handle);
- glUnmapBuffer(gl_target);
+ glUnmapNamedBuffer(gl_buffer.handle);
}
gl_buffer.Release();
}
@@ -74,7 +72,7 @@ std::tuple<u8*, GLintptr, bool> OGLStreamBuffer::Map(GLsizeiptr size, GLintptr a
invalidate = true;
if (persistent) {
- glUnmapBuffer(gl_target);
+ glUnmapNamedBuffer(gl_buffer.handle);
}
}
@@ -84,7 +82,7 @@ std::tuple<u8*, GLintptr, bool> OGLStreamBuffer::Map(GLsizeiptr size, GLintptr a
(coherent ? GL_MAP_COHERENT_BIT : GL_MAP_FLUSH_EXPLICIT_BIT) |
(invalidate ? GL_MAP_INVALIDATE_BUFFER_BIT : GL_MAP_UNSYNCHRONIZED_BIT);
mapped_ptr = static_cast<u8*>(
- glMapBufferRange(gl_target, buffer_pos, buffer_size - buffer_pos, flags));
+ glMapNamedBufferRange(gl_buffer.handle, buffer_pos, buffer_size - buffer_pos, flags));
mapped_offset = buffer_pos;
}
@@ -95,11 +93,11 @@ void OGLStreamBuffer::Unmap(GLsizeiptr size) {
ASSERT(size <= mapped_size);
if (!coherent && size > 0) {
- glFlushMappedBufferRange(gl_target, buffer_pos - mapped_offset, size);
+ glFlushMappedNamedBufferRange(gl_buffer.handle, buffer_pos - mapped_offset, size);
}
if (!persistent) {
- glUnmapBuffer(gl_target);
+ glUnmapNamedBuffer(gl_buffer.handle);
}
buffer_pos += size;
diff --git a/src/video_core/renderer_opengl/gl_stream_buffer.h b/src/video_core/renderer_opengl/gl_stream_buffer.h
index ae7961bd7..3d18ecb4d 100644
--- a/src/video_core/renderer_opengl/gl_stream_buffer.h
+++ b/src/video_core/renderer_opengl/gl_stream_buffer.h
@@ -13,7 +13,7 @@ namespace OpenGL {
class OGLStreamBuffer : private NonCopyable {
public:
- explicit OGLStreamBuffer(GLenum target, GLsizeiptr size, bool prefer_coherent = false);
+ explicit OGLStreamBuffer(GLsizeiptr size, bool vertex_data_usage, bool prefer_coherent = false);
~OGLStreamBuffer();
GLuint GetHandle() const;
@@ -33,7 +33,6 @@ public:
private:
OGLBuffer gl_buffer;
- GLenum gl_target;
bool coherent = false;
bool persistent = false;