From 5a9df3c6753e66519acaa13685abb89231e45ade Mon Sep 17 00:00:00 2001 From: Subv Date: Tue, 3 Jul 2018 22:32:59 -0500 Subject: GPU: Only configure the used framebuffers during clear. Don't try to configure the color buffer if it is not being cleared, it may not be completely valid at this point. --- .../renderer_opengl/gl_rasterizer_cache.cpp | 34 +++++++++++++++++----- 1 file changed, 27 insertions(+), 7 deletions(-) (limited to 'src/video_core/renderer_opengl/gl_rasterizer_cache.cpp') diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp index 3a00d9383..50469c05c 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp @@ -65,6 +65,25 @@ struct FormatTuple { return params; } +/*static*/ SurfaceParams SurfaceParams::CreateForDepthBuffer( + const Tegra::Engines::Maxwell3D::Regs::RenderTargetConfig& config, Tegra::GPUVAddr zeta_address, + Tegra::DepthFormat format) { + + SurfaceParams params{}; + params.addr = zeta_address; + params.is_tiled = true; + params.block_height = Tegra::Texture::TICEntry::DefaultBlockHeight; + params.pixel_format = PixelFormatFromDepthFormat(format); + params.component_type = ComponentTypeFromDepthFormat(format); + params.type = GetFormatType(params.pixel_format); + params.size_in_bytes = params.SizeInBytes(); + params.width = config.width; + params.height = config.height; + params.unaligned_height = config.height; + params.size_in_bytes = params.SizeInBytes(); + return params; +} + static constexpr std::array tex_format_tuples = {{ {GL_RGBA8, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, ComponentType::UNorm, false}, // ABGR8 {GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5_REV, ComponentType::UNorm, false}, // B5G6R5 @@ -461,15 +480,16 @@ SurfaceSurfaceRect_Tuple RasterizerCacheOpenGL::GetFramebufferSurfaces( LOG_WARNING(Render_OpenGL, "hard-coded for render target 0!"); // get color and depth surfaces - const SurfaceParams color_params{SurfaceParams::CreateForFramebuffer(regs.rt[0])}; - SurfaceParams depth_params{color_params}; + SurfaceParams color_params{}; + SurfaceParams depth_params{}; + + if (using_color_fb) { + color_params = SurfaceParams::CreateForFramebuffer(regs.rt[0]); + } if (using_depth_fb) { - depth_params.addr = regs.zeta.Address(); - depth_params.pixel_format = SurfaceParams::PixelFormatFromDepthFormat(regs.zeta.format); - depth_params.component_type = SurfaceParams::ComponentTypeFromDepthFormat(regs.zeta.format); - depth_params.type = SurfaceParams::GetFormatType(depth_params.pixel_format); - depth_params.size_in_bytes = depth_params.SizeInBytes(); + depth_params = + SurfaceParams::CreateForDepthBuffer(regs.rt[0], regs.zeta.Address(), regs.zeta.format); } MathUtil::Rectangle color_rect{}; -- cgit v1.2.3