summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2018-09-19 17:58:22 +0200
committerGitHub <noreply@github.com>2018-09-19 17:58:22 +0200
commit52fb86c65c0e7a2acef78522571de89491797f24 (patch)
treed55714cbb3b3ab66f87983e4be7a211db3c8370b
parentMerge pull request #1359 from ogniK5377/nes (diff)
parentgl_rasterizer: Fix StartAddress handling with indexed draw calls. (diff)
downloadyuzu-52fb86c65c0e7a2acef78522571de89491797f24.tar
yuzu-52fb86c65c0e7a2acef78522571de89491797f24.tar.gz
yuzu-52fb86c65c0e7a2acef78522571de89491797f24.tar.bz2
yuzu-52fb86c65c0e7a2acef78522571de89491797f24.tar.lz
yuzu-52fb86c65c0e7a2acef78522571de89491797f24.tar.xz
yuzu-52fb86c65c0e7a2acef78522571de89491797f24.tar.zst
yuzu-52fb86c65c0e7a2acef78522571de89491797f24.zip
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index 274c2dbcf..e37acbfac 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -484,8 +484,13 @@ void RasterizerOpenGL::DrawArrays() {
GLintptr index_buffer_offset = 0;
if (is_indexed) {
MICROPROFILE_SCOPE(OpenGL_Index);
- index_buffer_offset =
- buffer_cache.UploadMemory(regs.index_array.StartAddress(), index_buffer_size);
+
+ // Adjust the index buffer offset so it points to the first desired index.
+ auto index_start = regs.index_array.StartAddress();
+ index_start += static_cast<size_t>(regs.index_array.first) *
+ static_cast<size_t>(regs.index_array.FormatSizeInBytes());
+
+ index_buffer_offset = buffer_cache.UploadMemory(index_start, index_buffer_size);
}
SetupShaders();
@@ -499,10 +504,6 @@ void RasterizerOpenGL::DrawArrays() {
if (is_indexed) {
const GLint base_vertex{static_cast<GLint>(regs.vb_element_base)};
- // Adjust the index buffer offset so it points to the first desired index.
- index_buffer_offset += static_cast<GLintptr>(regs.index_array.first) *
- static_cast<GLintptr>(regs.index_array.FormatSizeInBytes());
-
if (gpu.state.current_instance > 0) {
glDrawElementsInstancedBaseVertexBaseInstance(
primitive_mode, regs.index_array.count,