diff options
| author | 2018-11-11 08:17:57 -0800 | |
|---|---|---|
| committer | 2018-11-11 08:17:57 -0800 | |
| commit | 8ea62615475f97ce76e047d2e48e817635071bad (patch) | |
| tree | 92a561e431acb2e1f6d1d4434ddb55acde4e5181 /src | |
| parent | Merge pull request #1656 from ogniK5377/message-queue (diff) | |
| parent | gl_rasterizer: Skip VAO binding if the state is clean. (diff) | |
| download | yuzu-8ea62615475f97ce76e047d2e48e817635071bad.tar.gz yuzu-8ea62615475f97ce76e047d2e48e817635071bad.tar.xz yuzu-8ea62615475f97ce76e047d2e48e817635071bad.zip | |
Merge pull request #1654 from degasus/dirty_flags
gl_rasterizer: Skip VAO binding if the state is clean.
Diffstat (limited to '')
| -rw-r--r-- | src/video_core/engines/maxwell_3d.cpp | 8 | ||||
| -rw-r--r-- | src/video_core/engines/maxwell_3d.h | 6 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 27 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.h | 3 |
4 files changed, 37 insertions, 7 deletions
diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp index 2cd595f26..5ae836aca 100644 --- a/src/video_core/engines/maxwell_3d.cpp +++ b/src/video_core/engines/maxwell_3d.cpp | |||
| @@ -108,8 +108,16 @@ void Maxwell3D::WriteReg(u32 method, u32 value, u32 remaining_params) { | |||
| 108 | debug_context->OnEvent(Tegra::DebugContext::Event::MaxwellCommandLoaded, nullptr); | 108 | debug_context->OnEvent(Tegra::DebugContext::Event::MaxwellCommandLoaded, nullptr); |
| 109 | } | 109 | } |
| 110 | 110 | ||
| 111 | u32 old = regs.reg_array[method]; | ||
| 111 | regs.reg_array[method] = value; | 112 | regs.reg_array[method] = value; |
| 112 | 113 | ||
| 114 | if (value != old) { | ||
| 115 | if (method >= MAXWELL3D_REG_INDEX(vertex_attrib_format) && | ||
| 116 | method < MAXWELL3D_REG_INDEX(vertex_attrib_format) + regs.vertex_attrib_format.size()) { | ||
| 117 | dirty_flags.vertex_attrib_format = true; | ||
| 118 | } | ||
| 119 | } | ||
| 120 | |||
| 113 | switch (method) { | 121 | switch (method) { |
| 114 | case MAXWELL3D_REG_INDEX(macros.data): { | 122 | case MAXWELL3D_REG_INDEX(macros.data): { |
| 115 | ProcessMacroUpload(value); | 123 | ProcessMacroUpload(value); |
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h index 0509ba3a2..557795d0f 100644 --- a/src/video_core/engines/maxwell_3d.h +++ b/src/video_core/engines/maxwell_3d.h | |||
| @@ -1004,6 +1004,12 @@ public: | |||
| 1004 | State state{}; | 1004 | State state{}; |
| 1005 | MemoryManager& memory_manager; | 1005 | MemoryManager& memory_manager; |
| 1006 | 1006 | ||
| 1007 | struct DirtyFlags { | ||
| 1008 | bool vertex_attrib_format = true; | ||
| 1009 | }; | ||
| 1010 | |||
| 1011 | DirtyFlags dirty_flags; | ||
| 1012 | |||
| 1007 | /// Reads a register value located at the input method address | 1013 | /// Reads a register value located at the input method address |
| 1008 | u32 GetRegisterValue(u32 method) const; | 1014 | u32 GetRegisterValue(u32 method) const; |
| 1009 | 1015 | ||
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index bb263b6aa..1bdd4c054 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp | |||
| @@ -33,7 +33,8 @@ using Maxwell = Tegra::Engines::Maxwell3D::Regs; | |||
| 33 | using PixelFormat = VideoCore::Surface::PixelFormat; | 33 | using PixelFormat = VideoCore::Surface::PixelFormat; |
| 34 | using SurfaceType = VideoCore::Surface::SurfaceType; | 34 | using SurfaceType = VideoCore::Surface::SurfaceType; |
| 35 | 35 | ||
| 36 | MICROPROFILE_DEFINE(OpenGL_VAO, "OpenGL", "Vertex Array Setup", MP_RGB(128, 128, 192)); | 36 | MICROPROFILE_DEFINE(OpenGL_VAO, "OpenGL", "Vertex Format Setup", MP_RGB(128, 128, 192)); |
| 37 | MICROPROFILE_DEFINE(OpenGL_VB, "OpenGL", "Vertex Buffer Setup", MP_RGB(128, 128, 192)); | ||
| 37 | MICROPROFILE_DEFINE(OpenGL_Shader, "OpenGL", "Shader Setup", MP_RGB(128, 128, 192)); | 38 | MICROPROFILE_DEFINE(OpenGL_Shader, "OpenGL", "Shader Setup", MP_RGB(128, 128, 192)); |
| 38 | MICROPROFILE_DEFINE(OpenGL_UBO, "OpenGL", "Const Buffer Setup", MP_RGB(128, 128, 192)); | 39 | MICROPROFILE_DEFINE(OpenGL_UBO, "OpenGL", "Const Buffer Setup", MP_RGB(128, 128, 192)); |
| 39 | MICROPROFILE_DEFINE(OpenGL_Index, "OpenGL", "Index Buffer Setup", MP_RGB(128, 128, 192)); | 40 | MICROPROFILE_DEFINE(OpenGL_Index, "OpenGL", "Index Buffer Setup", MP_RGB(128, 128, 192)); |
| @@ -122,11 +123,16 @@ RasterizerOpenGL::RasterizerOpenGL(Core::Frontend::EmuWindow& window, ScreenInfo | |||
| 122 | 123 | ||
| 123 | RasterizerOpenGL::~RasterizerOpenGL() {} | 124 | RasterizerOpenGL::~RasterizerOpenGL() {} |
| 124 | 125 | ||
| 125 | void RasterizerOpenGL::SetupVertexArrays() { | 126 | void RasterizerOpenGL::SetupVertexFormat() { |
| 126 | MICROPROFILE_SCOPE(OpenGL_VAO); | 127 | auto& gpu = Core::System::GetInstance().GPU().Maxwell3D(); |
| 127 | const auto& gpu = Core::System::GetInstance().GPU().Maxwell3D(); | ||
| 128 | const auto& regs = gpu.regs; | 128 | const auto& regs = gpu.regs; |
| 129 | 129 | ||
| 130 | if (!gpu.dirty_flags.vertex_attrib_format) | ||
| 131 | return; | ||
| 132 | gpu.dirty_flags.vertex_attrib_format = false; | ||
| 133 | |||
| 134 | MICROPROFILE_SCOPE(OpenGL_VAO); | ||
| 135 | |||
| 130 | auto [iter, is_cache_miss] = vertex_array_cache.try_emplace(regs.vertex_attrib_format); | 136 | auto [iter, is_cache_miss] = vertex_array_cache.try_emplace(regs.vertex_attrib_format); |
| 131 | auto& VAO = iter->second; | 137 | auto& VAO = iter->second; |
| 132 | 138 | ||
| @@ -175,8 +181,13 @@ void RasterizerOpenGL::SetupVertexArrays() { | |||
| 175 | } | 181 | } |
| 176 | } | 182 | } |
| 177 | state.draw.vertex_array = VAO.handle; | 183 | state.draw.vertex_array = VAO.handle; |
| 178 | state.draw.vertex_buffer = buffer_cache.GetHandle(); | ||
| 179 | state.Apply(); | 184 | state.Apply(); |
| 185 | } | ||
| 186 | |||
| 187 | void RasterizerOpenGL::SetupVertexBuffer() { | ||
| 188 | MICROPROFILE_SCOPE(OpenGL_VB); | ||
| 189 | const auto& gpu = Core::System::GetInstance().GPU().Maxwell3D(); | ||
| 190 | const auto& regs = gpu.regs; | ||
| 180 | 191 | ||
| 181 | // Upload all guest vertex arrays sequentially to our buffer | 192 | // Upload all guest vertex arrays sequentially to our buffer |
| 182 | for (u32 index = 0; index < Maxwell::NumVertexArrays; ++index) { | 193 | for (u32 index = 0; index < Maxwell::NumVertexArrays; ++index) { |
| @@ -203,6 +214,9 @@ void RasterizerOpenGL::SetupVertexArrays() { | |||
| 203 | glVertexBindingDivisor(index, 0); | 214 | glVertexBindingDivisor(index, 0); |
| 204 | } | 215 | } |
| 205 | } | 216 | } |
| 217 | |||
| 218 | // Implicit set by glBindVertexBuffer. Stupid glstate handling... | ||
| 219 | state.draw.vertex_buffer = buffer_cache.GetHandle(); | ||
| 206 | } | 220 | } |
| 207 | 221 | ||
| 208 | DrawParameters RasterizerOpenGL::SetupDraw() { | 222 | DrawParameters RasterizerOpenGL::SetupDraw() { |
| @@ -620,7 +634,8 @@ void RasterizerOpenGL::DrawArrays() { | |||
| 620 | 634 | ||
| 621 | buffer_cache.Map(buffer_size); | 635 | buffer_cache.Map(buffer_size); |
| 622 | 636 | ||
| 623 | SetupVertexArrays(); | 637 | SetupVertexFormat(); |
| 638 | SetupVertexBuffer(); | ||
| 624 | DrawParameters params = SetupDraw(); | 639 | DrawParameters params = SetupDraw(); |
| 625 | SetupShaders(params.primitive_mode); | 640 | SetupShaders(params.primitive_mode); |
| 626 | 641 | ||
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h index 60e783803..5eee5f088 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.h +++ b/src/video_core/renderer_opengl/gl_rasterizer.h | |||
| @@ -207,7 +207,8 @@ private: | |||
| 207 | 207 | ||
| 208 | std::size_t CalculateIndexBufferSize() const; | 208 | std::size_t CalculateIndexBufferSize() const; |
| 209 | 209 | ||
| 210 | void SetupVertexArrays(); | 210 | void SetupVertexFormat(); |
| 211 | void SetupVertexBuffer(); | ||
| 211 | 212 | ||
| 212 | DrawParameters SetupDraw(); | 213 | DrawParameters SetupDraw(); |
| 213 | 214 | ||