diff options
| author | 2019-11-26 18:30:21 -0300 | |
|---|---|---|
| committer | 2020-02-14 17:27:17 -0300 | |
| commit | fe1238be7a14b98c1698b5f8398b0efe83ade43a (patch) | |
| tree | dbf9199d7680b405d4e50df29a4395d36e3e4135 /src | |
| parent | maxwell_3d: Slow implementation of passed samples (query 21) (diff) | |
| download | yuzu-fe1238be7a14b98c1698b5f8398b0efe83ade43a.tar.gz yuzu-fe1238be7a14b98c1698b5f8398b0efe83ade43a.tar.xz yuzu-fe1238be7a14b98c1698b5f8398b0efe83ade43a.zip | |
gl_rasterizer: Add queued commands counter
Keep track of the queued OpenGL commands that can signal a fence if
waited on. As a side effect, we avoid calls to glFlush when no commands
are queued.
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 13 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.h | 3 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index 8d132732a..652db705b 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp | |||
| @@ -541,6 +541,8 @@ void RasterizerOpenGL::Clear() { | |||
| 541 | } else if (use_stencil) { | 541 | } else if (use_stencil) { |
| 542 | glClearBufferiv(GL_STENCIL, 0, ®s.clear_stencil); | 542 | glClearBufferiv(GL_STENCIL, 0, ®s.clear_stencil); |
| 543 | } | 543 | } |
| 544 | |||
| 545 | ++num_queued_commands; | ||
| 544 | } | 546 | } |
| 545 | 547 | ||
| 546 | void RasterizerOpenGL::Draw(bool is_indexed, bool is_instanced) { | 548 | void RasterizerOpenGL::Draw(bool is_indexed, bool is_instanced) { |
| @@ -641,6 +643,8 @@ void RasterizerOpenGL::Draw(bool is_indexed, bool is_instanced) { | |||
| 641 | glTextureBarrier(); | 643 | glTextureBarrier(); |
| 642 | } | 644 | } |
| 643 | 645 | ||
| 646 | ++num_queued_commands; | ||
| 647 | |||
| 644 | const GLuint base_instance = static_cast<GLuint>(gpu.regs.vb_base_instance); | 648 | const GLuint base_instance = static_cast<GLuint>(gpu.regs.vb_base_instance); |
| 645 | const GLsizei num_instances = | 649 | const GLsizei num_instances = |
| 646 | static_cast<GLsizei>(is_instanced ? gpu.mme_draw.instance_count : 1); | 650 | static_cast<GLsizei>(is_instanced ? gpu.mme_draw.instance_count : 1); |
| @@ -710,6 +714,7 @@ void RasterizerOpenGL::DispatchCompute(GPUVAddr code_addr) { | |||
| 710 | state.ApplyProgramPipeline(); | 714 | state.ApplyProgramPipeline(); |
| 711 | 715 | ||
| 712 | glDispatchCompute(launch_desc.grid_dim_x, launch_desc.grid_dim_y, launch_desc.grid_dim_z); | 716 | glDispatchCompute(launch_desc.grid_dim_x, launch_desc.grid_dim_y, launch_desc.grid_dim_z); |
| 717 | ++num_queued_commands; | ||
| 713 | } | 718 | } |
| 714 | 719 | ||
| 715 | void RasterizerOpenGL::ResetCounter(VideoCore::QueryType type) { | 720 | void RasterizerOpenGL::ResetCounter(VideoCore::QueryType type) { |
| @@ -762,10 +767,18 @@ void RasterizerOpenGL::FlushAndInvalidateRegion(CacheAddr addr, u64 size) { | |||
| 762 | } | 767 | } |
| 763 | 768 | ||
| 764 | void RasterizerOpenGL::FlushCommands() { | 769 | void RasterizerOpenGL::FlushCommands() { |
| 770 | // Only flush when we have commands queued to OpenGL. | ||
| 771 | if (num_queued_commands == 0) { | ||
| 772 | return; | ||
| 773 | } | ||
| 774 | num_queued_commands = 0; | ||
| 765 | glFlush(); | 775 | glFlush(); |
| 766 | } | 776 | } |
| 767 | 777 | ||
| 768 | void RasterizerOpenGL::TickFrame() { | 778 | void RasterizerOpenGL::TickFrame() { |
| 779 | // Ticking a frame means that buffers will be swapped, calling glFlush implicitly. | ||
| 780 | num_queued_commands = 0; | ||
| 781 | |||
| 769 | buffer_cache.TickFrame(); | 782 | buffer_cache.TickFrame(); |
| 770 | } | 783 | } |
| 771 | 784 | ||
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h index 32bcaf8c2..a9218db22 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.h +++ b/src/video_core/renderer_opengl/gl_rasterizer.h | |||
| @@ -226,6 +226,9 @@ private: | |||
| 226 | void SetupShaders(GLenum primitive_mode); | 226 | void SetupShaders(GLenum primitive_mode); |
| 227 | 227 | ||
| 228 | HostCounter samples_passed{GL_SAMPLES_PASSED}; | 228 | HostCounter samples_passed{GL_SAMPLES_PASSED}; |
| 229 | |||
| 230 | /// Number of commands queued to the OpenGL driver. Reseted on flush. | ||
| 231 | std::size_t num_queued_commands = 0; | ||
| 229 | }; | 232 | }; |
| 230 | 233 | ||
| 231 | } // namespace OpenGL | 234 | } // namespace OpenGL |