summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2019-05-28 00:37:46 +0200
committerReinUsesLisp <reinuseslisp@airmail.cc>2019-07-06 05:37:55 +0200
commit2e39c20da5701b8356bd1024f4f783c1db39a3fd (patch)
tree5fff3454afc3294b0eaaf0339febee508030aafe
parentMerge pull request #2601 from FernandoS27/texture_cache (diff)
downloadyuzu-2e39c20da5701b8356bd1024f4f783c1db39a3fd.tar
yuzu-2e39c20da5701b8356bd1024f4f783c1db39a3fd.tar.gz
yuzu-2e39c20da5701b8356bd1024f4f783c1db39a3fd.tar.bz2
yuzu-2e39c20da5701b8356bd1024f4f783c1db39a3fd.tar.lz
yuzu-2e39c20da5701b8356bd1024f4f783c1db39a3fd.tar.xz
yuzu-2e39c20da5701b8356bd1024f4f783c1db39a3fd.tar.zst
yuzu-2e39c20da5701b8356bd1024f4f783c1db39a3fd.zip
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp21
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.h4
2 files changed, 18 insertions, 7 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index f45a3c5ef..e89f96aec 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -215,7 +215,15 @@ void RasterizerOpenGL::SetupVertexBuffer(GLuint vao) {
gpu.dirty_flags.vertex_array.reset();
}
-DrawParameters RasterizerOpenGL::SetupDraw() {
+GLintptr RasterizerOpenGL::SetupIndexBuffer() {
+ if (accelerate_draw != AccelDraw::Indexed) {
+ return 0;
+ }
+ const auto& regs = system.GPU().Maxwell3D().regs;
+ return buffer_cache.UploadMemory(regs.index_array.IndexStart(), CalculateIndexBufferSize());
+}
+
+DrawParameters RasterizerOpenGL::SetupDraw(GLintptr index_buffer_offset) {
const auto& gpu = system.GPU().Maxwell3D();
const auto& regs = gpu.regs;
const bool is_indexed = accelerate_draw == AccelDraw::Indexed;
@@ -230,8 +238,7 @@ DrawParameters RasterizerOpenGL::SetupDraw() {
MICROPROFILE_SCOPE(OpenGL_Index);
params.index_format = MaxwellToGL::IndexFormat(regs.index_array.format);
params.count = regs.index_array.count;
- params.index_buffer_offset =
- buffer_cache.UploadMemory(regs.index_array.IndexStart(), CalculateIndexBufferSize());
+ params.index_buffer_offset = index_buffer_offset;
params.base_vertex = static_cast<GLint>(regs.vb_element_base);
} else {
params.count = regs.vertex_buffer.count;
@@ -643,10 +650,12 @@ void RasterizerOpenGL::DrawArrays() {
gpu.dirty_flags.vertex_array.set();
}
- const GLuint vao = SetupVertexFormat();
- SetupVertexBuffer(vao);
+ const GLuint vertex_array = SetupVertexFormat();
+
+ SetupVertexBuffer(vertex_array);
+ const GLintptr index_buffer_offset = SetupIndexBuffer();
- DrawParameters params = SetupDraw();
+ DrawParameters params = SetupDraw(index_buffer_offset);
texture_cache.GuardSamplers(true);
SetupShaders(params.primitive_mode);
texture_cache.GuardSamplers(false);
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h
index bf67e3a70..8f1757e25 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.h
+++ b/src/video_core/renderer_opengl/gl_rasterizer.h
@@ -220,7 +220,9 @@ private:
void SetupVertexBuffer(GLuint vao);
- DrawParameters SetupDraw();
+ GLintptr SetupIndexBuffer();
+
+ DrawParameters SetupDraw(GLintptr index_buffer_offset);
void SetupShaders(GLenum primitive_mode);