VERY experimental Nintendo Switch 2 emulator
C++
gl_rasterizer: Implement flushing.
bunnei6ac61f17991b
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cppindex 8d5f277e2c..18db072171 100644--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp@@ -424,6 +424,13 @@ void RasterizerOpenGL::ConfigureFramebuffers(bool using_color_fb, bool using_dep// Used when just a single color attachment is enabled, e.g. for clearing a color bufferSurface color_surface =res_cache.GetColorBufferSurface(*single_color_target, preserve_contents);++ if (color_surface) {+ // Assume that a surface will be written to if it is used as a framebuffer, even if+ // the shader doesn't actually write to it.+ color_surface->MarkAsDirty();+ }+glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER,GL_COLOR_ATTACHMENT0 + static_cast<GLenum>(*single_color_target), GL_TEXTURE_2D,@@ -434,6 +441,13 @@ void RasterizerOpenGL::ConfigureFramebuffers(bool using_color_fb, bool using_depstd::array<GLenum, Maxwell::NumRenderTargets> buffers;for (std::size_t index = 0; index < Maxwell::NumRenderTargets; ++index) {Surface color_surface = res_cache.GetColorBufferSurface(index, preserve_contents);++ if (color_surface) {+ // Assume that a surface will be written to if it is used as a framebuffer, even+ // if the shader doesn't actually write to it.+ color_surface->MarkAsDirty();+ }+buffers[index] = GL_COLOR_ATTACHMENT0 + regs.rt_control.GetMap(index);glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + static_cast<GLenum>(index),@@ -453,6 +467,10 @@ void RasterizerOpenGL::ConfigureFramebuffers(bool using_color_fb, bool using_dep}if (depth_surface) {+ // Assume that a surface will be written to if it is used as a framebuffer, even if+ // the shader doesn't actually write to it.+ depth_surface->MarkAsDirty();+if (regs.stencil_enable) {// Attach both depth and stencilglFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D,@@ -617,7 +635,12 @@ void RasterizerOpenGL::DrawArrays() {void RasterizerOpenGL::FlushAll() {}-void RasterizerOpenGL::FlushRegion(VAddr addr, u64 size) {}+void RasterizerOpenGL::FlushRegion(VAddr addr, u64 size) {+ MICROPROFILE_SCOPE(OpenGL_CacheManagement);+ res_cache.FlushRegion(addr, size);+ shader_cache.FlushRegion(addr, size);+ buffer_cache.FlushRegion(addr, size);+}void RasterizerOpenGL::InvalidateRegion(VAddr addr, u64 size) {MICROPROFILE_SCOPE(OpenGL_CacheManagement);@@ -627,6 +650,7 @@ void RasterizerOpenGL::InvalidateRegion(VAddr addr, u64 size) {}void RasterizerOpenGL::FlushAndInvalidateRegion(VAddr addr, u64 size) {+ FlushRegion(addr, size);InvalidateRegion(addr, size);}