From ba02d564f8a0b0167b96f247b6ad9d2bde05b6c8 Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Sun, 15 Sep 2019 11:48:54 -0400 Subject: Video Core: initial Implementation of InstanceDraw Packaging --- src/video_core/renderer_opengl/gl_rasterizer.cpp | 89 +++++++++++++++++++++--- 1 file changed, 81 insertions(+), 8 deletions(-) (limited to 'src/video_core/renderer_opengl/gl_rasterizer.cpp') diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index 4dd08bccb..5df7f3f56 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -405,6 +405,12 @@ bool RasterizerOpenGL::AccelerateDrawBatch(bool is_indexed) { return true; } +bool RasterizerOpenGL::AccelerateDrawMultiBatch(bool is_indexed) { + accelerate_draw = is_indexed ? AccelDraw::Indexed : AccelDraw::Arrays; + DrawMultiArrays(); + return true; +} + template static constexpr auto RangeFromInterval(Map& map, const Interval& interval) { return boost::make_iterator_range(map.equal_range(interval)); @@ -688,7 +694,7 @@ void RasterizerOpenGL::Clear() { } } -void RasterizerOpenGL::DrawArrays() { +void RasterizerOpenGL::DrawPrelude() { if (accelerate_draw == AccelDraw::Disabled) return; @@ -743,10 +749,7 @@ void RasterizerOpenGL::DrawArrays() { // Upload vertex and index data. SetupVertexBuffer(vao); SetupVertexInstances(vao); - const GLintptr index_buffer_offset = SetupIndexBuffer(); - - // Setup draw parameters. It will automatically choose what glDraw* method to use. - const DrawParameters params = SetupDraw(index_buffer_offset); + index_buffer_offset = SetupIndexBuffer(); // Prepare packed bindings. bind_ubo_pushbuffer.Setup(0); @@ -754,7 +757,8 @@ void RasterizerOpenGL::DrawArrays() { // Setup shaders and their used resources. texture_cache.GuardSamplers(true); - SetupShaders(params.primitive_mode); + const auto primitive_mode = MaxwellToGL::PrimitiveTopology(gpu.regs.draw.topology); + SetupShaders(primitive_mode); texture_cache.GuardSamplers(false); ConfigureFramebuffers(state); @@ -778,11 +782,80 @@ void RasterizerOpenGL::DrawArrays() { if (texture_cache.TextureBarrier()) { glTextureBarrier(); } +} - params.DispatchDraw(); +void RasterizerOpenGL::DrawArrays() { + DrawPrelude(); + + auto& maxwell3d = system.GPU().Maxwell3D(); + auto& regs = maxwell3d.regs; + auto current_instance = maxwell3d.state.current_instance; + auto primitive_mode = MaxwellToGL::PrimitiveTopology(regs.draw.topology); + if (accelerate_draw == AccelDraw::Indexed) { + auto index_format = MaxwellToGL::IndexFormat(regs.index_array.format); + auto count = regs.index_array.count; + auto base_vertex = static_cast(regs.vb_element_base); + const auto index_buffer_ptr = reinterpret_cast(index_buffer_offset); + if (current_instance > 0) { + glDrawElementsInstancedBaseVertexBaseInstance(primitive_mode, count, index_format, + index_buffer_ptr, 1, base_vertex, + current_instance); + } else { + glDrawElementsBaseVertex(primitive_mode, count, index_format, index_buffer_ptr, + base_vertex); + } + } else { + auto count = regs.vertex_buffer.count; + auto vertex_first = regs.vertex_buffer.first; + if (current_instance > 0) { + glDrawArraysInstancedBaseInstance(primitive_mode, vertex_first, count, 1, + current_instance); + } else { + glDrawArrays(primitive_mode, vertex_first, count); + } + } + + accelerate_draw = AccelDraw::Disabled; + maxwell3d.dirty.memory_general = false; +} + +#pragma optimize("", off) + +void RasterizerOpenGL::DrawMultiArrays() { + DrawPrelude(); + + auto& maxwell3d = system.GPU().Maxwell3D(); + auto& regs = maxwell3d.regs; + auto& draw_setup = maxwell3d.mme_draw; + auto num_instances = draw_setup.instance_count; + auto base_instance = static_cast(regs.vb_base_instance); + auto primitive_mode = MaxwellToGL::PrimitiveTopology(regs.draw.topology); + if (draw_setup.current_mode == Tegra::Engines::Maxwell3D::MMMEDrawMode::Indexed) { + auto index_format = MaxwellToGL::IndexFormat(regs.index_array.format); + auto count = regs.index_array.count; + auto base_vertex = static_cast(regs.vb_element_base); + const auto index_buffer_ptr = reinterpret_cast(index_buffer_offset); + if (num_instances > 1) { + glDrawElementsInstancedBaseVertexBaseInstance(primitive_mode, count, index_format, + index_buffer_ptr, num_instances, + base_vertex, base_instance); + } else { + glDrawElementsBaseVertex(primitive_mode, count, index_format, index_buffer_ptr, + base_vertex); + } + } else { + auto count = regs.vertex_buffer.count; + auto vertex_first = regs.vertex_buffer.first; + if (num_instances > 1) { + glDrawArraysInstancedBaseInstance(primitive_mode, vertex_first, count, num_instances, + base_instance); + } else { + glDrawArrays(primitive_mode, vertex_first, count); + } + } accelerate_draw = AccelDraw::Disabled; - gpu.dirty.memory_general = false; + maxwell3d.dirty.memory_general = false; } void RasterizerOpenGL::DispatchCompute(GPUVAddr code_addr) { -- cgit v1.2.3 From 7606da5611b5626790e99b4387e033eaea20c2cb Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Sun, 15 Sep 2019 14:25:07 -0400 Subject: VideoCore: Corrections to the MME Inliner and removal of hacky instance management. --- src/video_core/renderer_opengl/gl_rasterizer.cpp | 38 +++++++++++------------- 1 file changed, 18 insertions(+), 20 deletions(-) (limited to 'src/video_core/renderer_opengl/gl_rasterizer.cpp') diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index 5df7f3f56..f71a22738 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -788,13 +788,13 @@ void RasterizerOpenGL::DrawArrays() { DrawPrelude(); auto& maxwell3d = system.GPU().Maxwell3D(); - auto& regs = maxwell3d.regs; - auto current_instance = maxwell3d.state.current_instance; - auto primitive_mode = MaxwellToGL::PrimitiveTopology(regs.draw.topology); + const auto& regs = maxwell3d.regs; + const auto current_instance = maxwell3d.state.current_instance; + const auto primitive_mode = MaxwellToGL::PrimitiveTopology(regs.draw.topology); if (accelerate_draw == AccelDraw::Indexed) { - auto index_format = MaxwellToGL::IndexFormat(regs.index_array.format); - auto count = regs.index_array.count; - auto base_vertex = static_cast(regs.vb_element_base); + const auto index_format = MaxwellToGL::IndexFormat(regs.index_array.format); + const auto count = regs.index_array.count; + const auto base_vertex = static_cast(regs.vb_element_base); const auto index_buffer_ptr = reinterpret_cast(index_buffer_offset); if (current_instance > 0) { glDrawElementsInstancedBaseVertexBaseInstance(primitive_mode, count, index_format, @@ -805,8 +805,8 @@ void RasterizerOpenGL::DrawArrays() { base_vertex); } } else { - auto count = regs.vertex_buffer.count; - auto vertex_first = regs.vertex_buffer.first; + const auto count = regs.vertex_buffer.count; + const auto vertex_first = regs.vertex_buffer.first; if (current_instance > 0) { glDrawArraysInstancedBaseInstance(primitive_mode, vertex_first, count, 1, current_instance); @@ -819,21 +819,19 @@ void RasterizerOpenGL::DrawArrays() { maxwell3d.dirty.memory_general = false; } -#pragma optimize("", off) - void RasterizerOpenGL::DrawMultiArrays() { DrawPrelude(); auto& maxwell3d = system.GPU().Maxwell3D(); - auto& regs = maxwell3d.regs; - auto& draw_setup = maxwell3d.mme_draw; - auto num_instances = draw_setup.instance_count; - auto base_instance = static_cast(regs.vb_base_instance); - auto primitive_mode = MaxwellToGL::PrimitiveTopology(regs.draw.topology); + const auto& regs = maxwell3d.regs; + const auto& draw_setup = maxwell3d.mme_draw; + const auto num_instances = draw_setup.instance_count; + const auto base_instance = static_cast(regs.vb_base_instance); + const auto primitive_mode = MaxwellToGL::PrimitiveTopology(regs.draw.topology); if (draw_setup.current_mode == Tegra::Engines::Maxwell3D::MMMEDrawMode::Indexed) { - auto index_format = MaxwellToGL::IndexFormat(regs.index_array.format); - auto count = regs.index_array.count; - auto base_vertex = static_cast(regs.vb_element_base); + const auto index_format = MaxwellToGL::IndexFormat(regs.index_array.format); + const auto count = regs.index_array.count; + const auto base_vertex = static_cast(regs.vb_element_base); const auto index_buffer_ptr = reinterpret_cast(index_buffer_offset); if (num_instances > 1) { glDrawElementsInstancedBaseVertexBaseInstance(primitive_mode, count, index_format, @@ -844,8 +842,8 @@ void RasterizerOpenGL::DrawMultiArrays() { base_vertex); } } else { - auto count = regs.vertex_buffer.count; - auto vertex_first = regs.vertex_buffer.first; + const auto count = regs.vertex_buffer.count; + const auto vertex_first = regs.vertex_buffer.first; if (num_instances > 1) { glDrawArraysInstancedBaseInstance(primitive_mode, vertex_first, count, num_instances, base_instance); -- cgit v1.2.3 From c17655ce7465815bb69adf22c2d12f02a93d7d5c Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Wed, 18 Sep 2019 07:51:05 -0400 Subject: Rasterizer: Refactor draw calls, remove deadcode and clean up. --- src/video_core/renderer_opengl/gl_rasterizer.cpp | 169 +++++++++-------------- 1 file changed, 66 insertions(+), 103 deletions(-) (limited to 'src/video_core/renderer_opengl/gl_rasterizer.cpp') diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index f71a22738..9ca832863 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -49,40 +49,6 @@ MICROPROFILE_DEFINE(OpenGL_Blits, "OpenGL", "Blits", MP_RGB(128, 128, 192)); MICROPROFILE_DEFINE(OpenGL_CacheManagement, "OpenGL", "Cache Mgmt", MP_RGB(100, 255, 100)); MICROPROFILE_DEFINE(OpenGL_PrimitiveAssembly, "OpenGL", "Prim Asmbl", MP_RGB(255, 100, 100)); -struct DrawParameters { - GLenum primitive_mode; - GLsizei count; - GLint current_instance; - bool use_indexed; - - GLint vertex_first; - - GLenum index_format; - GLint base_vertex; - GLintptr index_buffer_offset; - - void DispatchDraw() const { - if (use_indexed) { - const auto index_buffer_ptr = reinterpret_cast(index_buffer_offset); - if (current_instance > 0) { - glDrawElementsInstancedBaseVertexBaseInstance(primitive_mode, count, index_format, - index_buffer_ptr, 1, base_vertex, - current_instance); - } else { - glDrawElementsBaseVertex(primitive_mode, count, index_format, index_buffer_ptr, - base_vertex); - } - } else { - if (current_instance > 0) { - glDrawArraysInstancedBaseInstance(primitive_mode, vertex_first, count, 1, - current_instance); - } else { - glDrawArrays(primitive_mode, vertex_first, count); - } - } - } -}; - static std::size_t GetConstBufferSize(const Tegra::Engines::ConstBufferInfo& buffer, const GLShader::ConstBufferEntry& entry) { if (!entry.IsIndirect()) { @@ -270,29 +236,6 @@ GLintptr RasterizerOpenGL::SetupIndexBuffer() { return offset; } -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; - - DrawParameters params{}; - params.current_instance = gpu.state.current_instance; - - params.use_indexed = is_indexed; - params.primitive_mode = MaxwellToGL::PrimitiveTopology(regs.draw.topology); - - if (is_indexed) { - params.index_format = MaxwellToGL::IndexFormat(regs.index_array.format); - params.count = regs.index_array.count; - params.index_buffer_offset = index_buffer_offset; - params.base_vertex = static_cast(regs.vb_element_base); - } else { - params.count = regs.vertex_buffer.count; - params.vertex_first = regs.vertex_buffer.first; - } - return params; -} - void RasterizerOpenGL::SetupShaders(GLenum primitive_mode) { MICROPROFILE_SCOPE(OpenGL_Shader); auto& gpu = system.GPU().Maxwell3D(); @@ -784,36 +727,65 @@ void RasterizerOpenGL::DrawPrelude() { } } +struct DrawParams { + bool is_indexed; + bool is_instanced; + GLenum primitive_mode; + GLint count; + GLint base_vertex; + + // Indexed settings + GLenum index_format; + GLintptr index_buffer_offset; + + // Instanced setting + GLint num_instances; + GLint base_instance; + + void DispatchDraw() { + if (is_indexed) { + const auto index_buffer_ptr = reinterpret_cast(index_buffer_offset); + if (is_instanced) { + glDrawElementsInstancedBaseVertexBaseInstance(primitive_mode, count, index_format, + index_buffer_ptr, num_instances, + base_vertex, base_instance); + } else { + glDrawElementsBaseVertex(primitive_mode, count, index_format, index_buffer_ptr, + base_vertex); + } + } else { + if (is_instanced) { + glDrawArraysInstancedBaseInstance(primitive_mode, base_vertex, count, num_instances, + base_instance); + } else { + glDrawArrays(primitive_mode, base_vertex, count); + } + } + } +}; + void RasterizerOpenGL::DrawArrays() { DrawPrelude(); auto& maxwell3d = system.GPU().Maxwell3D(); const auto& regs = maxwell3d.regs; const auto current_instance = maxwell3d.state.current_instance; - const auto primitive_mode = MaxwellToGL::PrimitiveTopology(regs.draw.topology); - if (accelerate_draw == AccelDraw::Indexed) { - const auto index_format = MaxwellToGL::IndexFormat(regs.index_array.format); - const auto count = regs.index_array.count; - const auto base_vertex = static_cast(regs.vb_element_base); - const auto index_buffer_ptr = reinterpret_cast(index_buffer_offset); - if (current_instance > 0) { - glDrawElementsInstancedBaseVertexBaseInstance(primitive_mode, count, index_format, - index_buffer_ptr, 1, base_vertex, - current_instance); - } else { - glDrawElementsBaseVertex(primitive_mode, count, index_format, index_buffer_ptr, - base_vertex); - } + DrawParams draw_call; + draw_call.is_indexed = accelerate_draw == AccelDraw::Indexed; + draw_call.num_instances = static_cast(1); + draw_call.base_instance = static_cast(current_instance); + draw_call.is_instanced = current_instance > 0; + draw_call.primitive_mode = MaxwellToGL::PrimitiveTopology(regs.draw.topology); + if (draw_call.is_indexed) { + draw_call.count = static_cast(regs.index_array.count); + draw_call.base_vertex = static_cast(regs.vb_element_base); + draw_call.index_format = MaxwellToGL::IndexFormat(regs.index_array.format); + draw_call.index_buffer_offset = index_buffer_offset; } else { - const auto count = regs.vertex_buffer.count; - const auto vertex_first = regs.vertex_buffer.first; - if (current_instance > 0) { - glDrawArraysInstancedBaseInstance(primitive_mode, vertex_first, count, 1, - current_instance); - } else { - glDrawArrays(primitive_mode, vertex_first, count); - } + draw_call.count = static_cast(regs.vertex_buffer.count); + draw_call.base_vertex = static_cast(regs.vertex_buffer.first); } + draw_call.DispatchDraw(); accelerate_draw = AccelDraw::Disabled; maxwell3d.dirty.memory_general = false; @@ -825,32 +797,23 @@ void RasterizerOpenGL::DrawMultiArrays() { auto& maxwell3d = system.GPU().Maxwell3D(); const auto& regs = maxwell3d.regs; const auto& draw_setup = maxwell3d.mme_draw; - const auto num_instances = draw_setup.instance_count; - const auto base_instance = static_cast(regs.vb_base_instance); - const auto primitive_mode = MaxwellToGL::PrimitiveTopology(regs.draw.topology); - if (draw_setup.current_mode == Tegra::Engines::Maxwell3D::MMMEDrawMode::Indexed) { - const auto index_format = MaxwellToGL::IndexFormat(regs.index_array.format); - const auto count = regs.index_array.count; - const auto base_vertex = static_cast(regs.vb_element_base); - const auto index_buffer_ptr = reinterpret_cast(index_buffer_offset); - if (num_instances > 1) { - glDrawElementsInstancedBaseVertexBaseInstance(primitive_mode, count, index_format, - index_buffer_ptr, num_instances, - base_vertex, base_instance); - } else { - glDrawElementsBaseVertex(primitive_mode, count, index_format, index_buffer_ptr, - base_vertex); - } + DrawParams draw_call; + draw_call.is_indexed = + draw_setup.current_mode == Tegra::Engines::Maxwell3D::MMMEDrawMode::Indexed; + draw_call.num_instances = static_cast(draw_setup.instance_count); + draw_call.base_instance = static_cast(regs.vb_base_instance); + draw_call.is_instanced = draw_setup.instance_count > 1; + draw_call.primitive_mode = MaxwellToGL::PrimitiveTopology(regs.draw.topology); + if (draw_call.is_indexed) { + draw_call.count = static_cast(regs.index_array.count); + draw_call.base_vertex = static_cast(regs.vb_element_base); + draw_call.index_format = MaxwellToGL::IndexFormat(regs.index_array.format); + draw_call.index_buffer_offset = index_buffer_offset; } else { - const auto count = regs.vertex_buffer.count; - const auto vertex_first = regs.vertex_buffer.first; - if (num_instances > 1) { - glDrawArraysInstancedBaseInstance(primitive_mode, vertex_first, count, num_instances, - base_instance); - } else { - glDrawArrays(primitive_mode, vertex_first, count); - } + draw_call.count = static_cast(regs.vertex_buffer.count); + draw_call.base_vertex = static_cast(regs.vertex_buffer.first); } + draw_call.DispatchDraw(); accelerate_draw = AccelDraw::Disabled; maxwell3d.dirty.memory_general = false; -- cgit v1.2.3 From d2ea592ddbf1d236ebb4eb58eedd2d0ffbe92455 Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Wed, 18 Sep 2019 10:20:33 -0400 Subject: Rasterizer: Address Feedback and conscerns. --- src/video_core/renderer_opengl/gl_rasterizer.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/video_core/renderer_opengl/gl_rasterizer.cpp') diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index 9ca832863..b86aa49f3 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -728,19 +728,19 @@ void RasterizerOpenGL::DrawPrelude() { } struct DrawParams { - bool is_indexed; - bool is_instanced; - GLenum primitive_mode; - GLint count; - GLint base_vertex; + bool is_indexed{}; + bool is_instanced{}; + GLenum primitive_mode{}; + GLint count{}; + GLint base_vertex{}; // Indexed settings - GLenum index_format; - GLintptr index_buffer_offset; + GLenum index_format{}; + GLintptr index_buffer_offset{}; // Instanced setting - GLint num_instances; - GLint base_instance; + GLint num_instances{}; + GLint base_instance{}; void DispatchDraw() { if (is_indexed) { @@ -770,7 +770,7 @@ void RasterizerOpenGL::DrawArrays() { auto& maxwell3d = system.GPU().Maxwell3D(); const auto& regs = maxwell3d.regs; const auto current_instance = maxwell3d.state.current_instance; - DrawParams draw_call; + DrawParams draw_call{}; draw_call.is_indexed = accelerate_draw == AccelDraw::Indexed; draw_call.num_instances = static_cast(1); draw_call.base_instance = static_cast(current_instance); @@ -797,7 +797,7 @@ void RasterizerOpenGL::DrawMultiArrays() { auto& maxwell3d = system.GPU().Maxwell3D(); const auto& regs = maxwell3d.regs; const auto& draw_setup = maxwell3d.mme_draw; - DrawParams draw_call; + DrawParams draw_call{}; draw_call.is_indexed = draw_setup.current_mode == Tegra::Engines::Maxwell3D::MMMEDrawMode::Indexed; draw_call.num_instances = static_cast(draw_setup.instance_count); -- cgit v1.2.3 From 7761e44d186deff278e51814bdec0c25e8e1a09c Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Thu, 19 Sep 2019 11:41:07 -0400 Subject: Rasterizer: Refactor and simplify DrawBatch Interface. --- src/video_core/renderer_opengl/gl_rasterizer.cpp | 29 ++++++++---------------- 1 file changed, 10 insertions(+), 19 deletions(-) (limited to 'src/video_core/renderer_opengl/gl_rasterizer.cpp') diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index b86aa49f3..b5c55482f 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -342,18 +342,6 @@ std::size_t RasterizerOpenGL::CalculateIndexBufferSize() const { static_cast(regs.index_array.FormatSizeInBytes()); } -bool RasterizerOpenGL::AccelerateDrawBatch(bool is_indexed) { - accelerate_draw = is_indexed ? AccelDraw::Indexed : AccelDraw::Arrays; - DrawArrays(); - return true; -} - -bool RasterizerOpenGL::AccelerateDrawMultiBatch(bool is_indexed) { - accelerate_draw = is_indexed ? AccelDraw::Indexed : AccelDraw::Arrays; - DrawMultiArrays(); - return true; -} - template static constexpr auto RangeFromInterval(Map& map, const Interval& interval) { return boost::make_iterator_range(map.equal_range(interval)); @@ -764,14 +752,15 @@ struct DrawParams { } }; -void RasterizerOpenGL::DrawArrays() { +bool RasterizerOpenGL::DrawBatch(bool is_indexed) { + accelerate_draw = is_indexed ? AccelDraw::Indexed : AccelDraw::Arrays; DrawPrelude(); auto& maxwell3d = system.GPU().Maxwell3D(); const auto& regs = maxwell3d.regs; const auto current_instance = maxwell3d.state.current_instance; DrawParams draw_call{}; - draw_call.is_indexed = accelerate_draw == AccelDraw::Indexed; + draw_call.is_indexed = is_indexed; draw_call.num_instances = static_cast(1); draw_call.base_instance = static_cast(current_instance); draw_call.is_instanced = current_instance > 0; @@ -787,19 +776,20 @@ void RasterizerOpenGL::DrawArrays() { } draw_call.DispatchDraw(); - accelerate_draw = AccelDraw::Disabled; maxwell3d.dirty.memory_general = false; + accelerate_draw = AccelDraw::Disabled; + return true; } -void RasterizerOpenGL::DrawMultiArrays() { +bool RasterizerOpenGL::DrawMultiBatch(bool is_indexed) { + accelerate_draw = is_indexed ? AccelDraw::Indexed : AccelDraw::Arrays; DrawPrelude(); auto& maxwell3d = system.GPU().Maxwell3D(); const auto& regs = maxwell3d.regs; const auto& draw_setup = maxwell3d.mme_draw; DrawParams draw_call{}; - draw_call.is_indexed = - draw_setup.current_mode == Tegra::Engines::Maxwell3D::MMMEDrawMode::Indexed; + draw_call.is_indexed = is_indexed; draw_call.num_instances = static_cast(draw_setup.instance_count); draw_call.base_instance = static_cast(regs.vb_base_instance); draw_call.is_instanced = draw_setup.instance_count > 1; @@ -815,8 +805,9 @@ void RasterizerOpenGL::DrawMultiArrays() { } draw_call.DispatchDraw(); - accelerate_draw = AccelDraw::Disabled; maxwell3d.dirty.memory_general = false; + accelerate_draw = AccelDraw::Disabled; + return true; } void RasterizerOpenGL::DispatchCompute(GPUVAddr code_addr) { -- cgit v1.2.3 From 433e764bb0e8e7478f0cca675960c994fadae3ea Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Fri, 20 Sep 2019 15:44:28 -0400 Subject: Rasterizer: Correct introduced bug where a conditional render wouldn't stop a draw call from executing --- src/video_core/renderer_opengl/gl_rasterizer.cpp | 26 +++++++++++++++--------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'src/video_core/renderer_opengl/gl_rasterizer.cpp') diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index b5c55482f..a6fe7dd71 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -626,16 +626,8 @@ void RasterizerOpenGL::Clear() { } void RasterizerOpenGL::DrawPrelude() { - if (accelerate_draw == AccelDraw::Disabled) - return; - - MICROPROFILE_SCOPE(OpenGL_Drawing); auto& gpu = system.GPU().Maxwell3D(); - if (!gpu.ShouldExecute()) { - return; - } - SyncColorMask(); SyncFragmentColorClampState(); SyncMultiSampleState(); @@ -754,9 +746,16 @@ struct DrawParams { bool RasterizerOpenGL::DrawBatch(bool is_indexed) { accelerate_draw = is_indexed ? AccelDraw::Indexed : AccelDraw::Arrays; - DrawPrelude(); + + MICROPROFILE_SCOPE(OpenGL_Drawing); auto& maxwell3d = system.GPU().Maxwell3D(); + if (!maxwell3d.ShouldExecute()) { + return false; + } + + DrawPrelude(); + const auto& regs = maxwell3d.regs; const auto current_instance = maxwell3d.state.current_instance; DrawParams draw_call{}; @@ -783,9 +782,16 @@ bool RasterizerOpenGL::DrawBatch(bool is_indexed) { bool RasterizerOpenGL::DrawMultiBatch(bool is_indexed) { accelerate_draw = is_indexed ? AccelDraw::Indexed : AccelDraw::Arrays; - DrawPrelude(); + + MICROPROFILE_SCOPE(OpenGL_Drawing); auto& maxwell3d = system.GPU().Maxwell3D(); + if (!maxwell3d.ShouldExecute()) { + return false; + } + + DrawPrelude(); + const auto& regs = maxwell3d.regs; const auto& draw_setup = maxwell3d.mme_draw; DrawParams draw_call{}; -- cgit v1.2.3 From 68f5aff64f231e77fed726b91619061e308b7b2d Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Sun, 22 Sep 2019 07:23:13 -0400 Subject: Maxwell3D: Corrections and refactors to MME instance refactor --- src/video_core/renderer_opengl/gl_rasterizer.cpp | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'src/video_core/renderer_opengl/gl_rasterizer.cpp') diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index a6fe7dd71..246b892c5 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -749,13 +749,9 @@ bool RasterizerOpenGL::DrawBatch(bool is_indexed) { MICROPROFILE_SCOPE(OpenGL_Drawing); - auto& maxwell3d = system.GPU().Maxwell3D(); - if (!maxwell3d.ShouldExecute()) { - return false; - } - DrawPrelude(); + auto& maxwell3d = system.GPU().Maxwell3D(); const auto& regs = maxwell3d.regs; const auto current_instance = maxwell3d.state.current_instance; DrawParams draw_call{}; @@ -785,13 +781,9 @@ bool RasterizerOpenGL::DrawMultiBatch(bool is_indexed) { MICROPROFILE_SCOPE(OpenGL_Drawing); - auto& maxwell3d = system.GPU().Maxwell3D(); - if (!maxwell3d.ShouldExecute()) { - return false; - } - DrawPrelude(); + auto& maxwell3d = system.GPU().Maxwell3D(); const auto& regs = maxwell3d.regs; const auto& draw_setup = maxwell3d.mme_draw; DrawParams draw_call{}; -- cgit v1.2.3