diff options
author | ReinUsesLisp <reinuseslisp@airmail.cc> | 2020-02-14 01:55:21 +0100 |
---|---|---|
committer | ReinUsesLisp <reinuseslisp@airmail.cc> | 2020-02-14 01:55:21 +0100 |
commit | 336a4f8e99fcfb4aea6ac399ac171c1207432150 (patch) | |
tree | a77a6e138b72e4d890a48474faf32bd50de5ddf5 /src/video_core | |
parent | Merge pull request #3405 from lioncash/thread (diff) | |
download | yuzu-336a4f8e99fcfb4aea6ac399ac171c1207432150.tar yuzu-336a4f8e99fcfb4aea6ac399ac171c1207432150.tar.gz yuzu-336a4f8e99fcfb4aea6ac399ac171c1207432150.tar.bz2 yuzu-336a4f8e99fcfb4aea6ac399ac171c1207432150.tar.lz yuzu-336a4f8e99fcfb4aea6ac399ac171c1207432150.tar.xz yuzu-336a4f8e99fcfb4aea6ac399ac171c1207432150.tar.zst yuzu-336a4f8e99fcfb4aea6ac399ac171c1207432150.zip |
Diffstat (limited to 'src/video_core')
-rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index b0eb14c8b..88e40827b 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -611,7 +611,7 @@ void RasterizerOpenGL::Draw(bool is_indexed, bool is_instanced) { // Setup shaders and their used resources. texture_cache.GuardSamplers(true); - const auto primitive_mode = MaxwellToGL::PrimitiveTopology(gpu.regs.draw.topology); + const GLenum primitive_mode = MaxwellToGL::PrimitiveTopology(gpu.regs.draw.topology); SetupShaders(primitive_mode); texture_cache.GuardSamplers(false); @@ -642,18 +642,38 @@ void RasterizerOpenGL::Draw(bool is_indexed, bool is_instanced) { const GLsizei num_instances = static_cast<GLsizei>(is_instanced ? gpu.mme_draw.instance_count : 1); if (is_indexed) { - const GLenum index_format = MaxwellToGL::IndexFormat(gpu.regs.index_array.format); const GLint base_vertex = static_cast<GLint>(gpu.regs.vb_element_base); const GLsizei num_vertices = static_cast<GLsizei>(gpu.regs.index_array.count); - glDrawElementsInstancedBaseVertexBaseInstance( - primitive_mode, num_vertices, index_format, - reinterpret_cast<const void*>(index_buffer_offset), num_instances, base_vertex, - base_instance); + const GLvoid* offset = reinterpret_cast<const GLvoid*>(index_buffer_offset); + const GLenum format = MaxwellToGL::IndexFormat(gpu.regs.index_array.format); + if (num_instances == 1 && base_instance == 0 && base_vertex == 0) { + glDrawElements(primitive_mode, num_vertices, format, offset); + } else if (num_instances == 1 && base_instance == 0) { + glDrawElementsBaseVertex(primitive_mode, num_vertices, format, offset, base_vertex); + } else if (base_vertex == 0 && base_instance == 0) { + glDrawElementsInstanced(primitive_mode, num_vertices, format, offset, num_instances); + } else if (base_vertex == 0) { + glDrawElementsInstancedBaseInstance(primitive_mode, num_vertices, format, offset, + num_instances, base_instance); + } else if (base_instance == 0) { + glDrawElementsInstancedBaseVertex(primitive_mode, num_vertices, format, offset, + num_instances, base_vertex); + } else { + glDrawElementsInstancedBaseVertexBaseInstance(primitive_mode, num_vertices, format, + offset, num_instances, base_vertex, + base_instance); + } } else { const GLint base_vertex = static_cast<GLint>(gpu.regs.vertex_buffer.first); const GLsizei num_vertices = static_cast<GLsizei>(gpu.regs.vertex_buffer.count); - glDrawArraysInstancedBaseInstance(primitive_mode, base_vertex, num_vertices, num_instances, - base_instance); + if (num_instances == 1 && base_instance == 0) { + glDrawArrays(primitive_mode, base_vertex, num_vertices); + } else if (base_instance == 0) { + glDrawArraysInstanced(primitive_mode, base_vertex, num_vertices, num_instances); + } else { + glDrawArraysInstancedBaseInstance(primitive_mode, base_vertex, num_vertices, + num_instances, base_instance); + } } } |