diff options
Diffstat (limited to '')
-rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 22 | ||||
-rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | 5 |
2 files changed, 19 insertions, 8 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index a3c5ad2a9..ca3814cfc 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -415,14 +415,16 @@ void RasterizerOpenGL::DrawArrays() { const GLenum primitive_mode{MaxwellToGL::PrimitiveTopology(regs.draw.topology)}; if (is_indexed) { - const GLint index_min{static_cast<GLint>(regs.index_array.first)}; - const GLint index_max{static_cast<GLint>(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<const void*>(index_buffer_offset), - -index_min); + 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 += regs.index_array.first * regs.index_array.FormatSizeInBytes(); + + glDrawElementsBaseVertex(primitive_mode, regs.index_array.count, + MaxwellToGL::IndexFormat(regs.index_array.format), + reinterpret_cast<const void*>(index_buffer_offset), base_vertex); } else { - glDrawArrays(primitive_mode, 0, regs.vertex_buffer.count); + glDrawArrays(primitive_mode, regs.vertex_buffer.first, regs.vertex_buffer.count); } // Disable scissor test @@ -639,7 +641,11 @@ u32 RasterizerOpenGL::SetupTextures(Maxwell::ShaderStage stage, GLuint program, glProgramUniform1i(program, uniform, current_bindpoint); const auto texture = maxwell3d.GetStageTexture(entry.GetStage(), entry.GetOffset()); - ASSERT(texture.enabled); + + if (!texture.enabled) { + state.texture_units[current_bindpoint].texture_2d = 0; + continue; + } texture_samplers[current_bindpoint].SyncWithConfig(texture.tsc); Surface surface = res_cache.GetTextureSurface(texture); diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp index 35ad4f161..851ebc263 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp @@ -470,6 +470,11 @@ Surface RasterizerCacheOpenGL::GetSurface(const SurfaceParams& params) { return {}; } + const auto& gpu = Core::System::GetInstance().GPU(); + // Don't try to create any entries in the cache if the address of the texture is invalid. + if (gpu.memory_manager->GpuToCpuAddress(params.addr) == boost::none) + return {}; + // Check for an exact match in existing surfaces const auto& surface_key{SurfaceKey::Create(params)}; const auto& search{surface_cache.find(surface_key)}; |