diff --git a/rpcs3/Emu/RSX/GL/GLRenderTargets.cpp b/rpcs3/Emu/RSX/GL/GLRenderTargets.cpp index e6f62a4189..5d0996ae04 100644 --- a/rpcs3/Emu/RSX/GL/GLRenderTargets.cpp +++ b/rpcs3/Emu/RSX/GL/GLRenderTargets.cpp @@ -185,11 +185,27 @@ void GLGSRender::init_buffers(rsx::framebuffer_creation_context context, bool sk const auto surface_format = rsx::method_registers.surface_color(); const auto depth_format = rsx::method_registers.surface_depth_fmt(); - const auto required_color_pitch = rsx::utility::get_packed_pitch(surface_format, clip_horizontal); - const u32 required_z_pitch = depth_format == rsx::surface_depth_format::z16 ? clip_horizontal * 2 : clip_horizontal * 4; + //TODO: Verify that buffers <= 16 pixels in X (pitch=64) cannot have a depth buffer + const auto required_z_pitch = 64;//depth_fmt == rsx::surface_depth_format::z16 ? clip_width * 2 : clip_width * 4; + const auto required_color_pitch = std::max(rsx::utility::get_packed_pitch(surface_format, clip_horizontal), 64u); - if (depth_address && zeta_pitch < required_z_pitch) - depth_address = 0; + if (depth_address) + { + if (zeta_pitch < required_z_pitch) + { + depth_address = 0; + } + else if (!rsx::method_registers.depth_test_enabled()) + { + //Disable depth buffer if depth testing is not enabled, unless a clear command is targeting the depth buffer + const bool is_depth_clear = rsx::method_registers.depth_write_enabled() && !!(context & rsx::framebuffer_creation_context::context_clear_depth); + if (!is_depth_clear) + { + depth_address = 0; + m_framebuffer_state_contested = true; + } + } + } for (const auto &addr : surface_addresses) { @@ -202,7 +218,7 @@ void GLGSRender::init_buffers(rsx::framebuffer_creation_context context, bool sk for (const auto &index : rsx::utility::get_rtt_indexes(rsx::method_registers.surface_color_target())) { - if (pitchs[index] < 64) + if (pitchs[index] < required_color_pitch) surface_addresses[index] = 0; if (surface_addresses[index] == depth_address && diff --git a/rpcs3/Emu/RSX/VK/VKGSRender.cpp b/rpcs3/Emu/RSX/VK/VKGSRender.cpp index 588812a07e..6e7a8b491c 100644 --- a/rpcs3/Emu/RSX/VK/VKGSRender.cpp +++ b/rpcs3/Emu/RSX/VK/VKGSRender.cpp @@ -2423,10 +2423,27 @@ void VKGSRender::prepare_rtts(rsx::framebuffer_creation_context context) const auto color_fmt = rsx::method_registers.surface_color(); const auto depth_fmt = rsx::method_registers.surface_depth_fmt(); - const auto required_z_pitch = depth_fmt == rsx::surface_depth_format::z16 ? clip_width * 2 : clip_width * 4; + //TODO: Verify that buffers <= 16 pixels in X (pitch=64) cannot have a depth buffer + const auto required_z_pitch = 64;//depth_fmt == rsx::surface_depth_format::z16 ? clip_width * 2 : clip_width * 4; + const auto required_color_pitch = std::max(rsx::utility::get_packed_pitch(color_fmt, clip_width), 64u); - if (zeta_address && zeta_pitch < required_z_pitch) - zeta_address = 0; + if (zeta_address) + { + if (zeta_pitch < required_z_pitch) + { + zeta_address = 0; + } + else if (!rsx::method_registers.depth_test_enabled()) + { + //Disable depth buffer if depth testing is not enabled, unless a clear command is targeting the depth buffer + const bool is_depth_clear = rsx::method_registers.depth_write_enabled() && !!(context & rsx::framebuffer_creation_context::context_clear_depth); + if (!is_depth_clear) + { + zeta_address = 0; + m_framebuffer_state_contested = true; + } + } + } for (const auto &addr: surface_addresses) { @@ -2439,7 +2456,7 @@ void VKGSRender::prepare_rtts(rsx::framebuffer_creation_context context) for (const auto &index : rsx::utility::get_rtt_indexes(rsx::method_registers.surface_color_target())) { - if (surface_pitchs[index] < 64) + if (surface_pitchs[index] < required_color_pitch) surface_addresses[index] = 0; if (surface_addresses[index] == zeta_address && @@ -2474,6 +2491,7 @@ void VKGSRender::prepare_rtts(rsx::framebuffer_creation_context context) const auto fbo_width = rsx::apply_resolution_scale(clip_width, true); const auto fbo_height = rsx::apply_resolution_scale(clip_height, true); const auto aa_mode = rsx::method_registers.surface_antialias(); + const auto bpp = get_format_block_size_in_bytes(color_fmt); if (m_draw_fbo) { @@ -2540,8 +2558,6 @@ void VKGSRender::prepare_rtts(rsx::framebuffer_creation_context context) std::vector bound_images; bound_images.reserve(5); - const auto bpp = get_format_block_size_in_bytes(color_fmt); - for (u8 index : draw_buffers) { if (auto surface = std::get<1>(m_rtts.m_bound_render_targets[index]))