From fca3d1cc65c3a0a838cf57b716063d9d803c5788 Mon Sep 17 00:00:00 2001 From: Subv Date: Mon, 2 Jul 2018 11:22:17 -0500 Subject: GPU: Fixed the index offset rendering, and implemented the base vertex functionality. This fixes Stardew Valley. --- src/video_core/renderer_opengl/gl_rasterizer.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index 62ee45a36..fe78f4226 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -412,12 +412,14 @@ void RasterizerOpenGL::DrawArrays() { const GLenum primitive_mode{MaxwellToGL::PrimitiveTopology(regs.draw.topology)}; if (is_indexed) { - const GLint index_min{static_cast(regs.index_array.first)}; - const GLint index_max{static_cast(regs.index_array.first + regs.index_array.count)}; - glDrawRangeElementsBaseVertex(primitive_mode, index_min, index_max, regs.index_array.count, - MaxwellToGL::IndexFormat(regs.index_array.format), - reinterpret_cast(index_buffer_offset), - -index_min); + const GLint base_vertex{static_cast(regs.vb_element_base)}; + + // Adjust the index buffer offset so it points to the first desired index. + index_buffer_offset += regs.index_array.first * regs.index_array.FormatSizeInBytes(); + + glDrawElementsBaseVertex(primitive_mode, regs.index_array.count, + MaxwellToGL::IndexFormat(regs.index_array.format), + reinterpret_cast(index_buffer_offset), base_vertex); } else { glDrawArrays(primitive_mode, 0, regs.vertex_buffer.count); } -- cgit v1.2.3