From 3350e7ee559afc83c434754a4180bd9064de6fd7 Mon Sep 17 00:00:00 2001 From: kd-11 Date: Sat, 25 Nov 2017 12:13:06 +0300 Subject: [PATCH] rsx: Fixes for framebuffer setup code --- rpcs3/Emu/RSX/GL/GLRenderTargets.cpp | 24 +++++++++--------------- rpcs3/Emu/RSX/VK/VKGSRender.cpp | 23 +++++++++-------------- 2 files changed, 18 insertions(+), 29 deletions(-) diff --git a/rpcs3/Emu/RSX/GL/GLRenderTargets.cpp b/rpcs3/Emu/RSX/GL/GLRenderTargets.cpp index 8236e4b8f2..8c617204b1 100644 --- a/rpcs3/Emu/RSX/GL/GLRenderTargets.cpp +++ b/rpcs3/Emu/RSX/GL/GLRenderTargets.cpp @@ -184,9 +184,10 @@ void GLGSRender::init_buffers(rsx::framebuffer_creation_context context, bool sk const auto zeta_pitch = rsx::method_registers.surface_z_pitch(); const auto surface_format = rsx::method_registers.surface_color(); const auto depth_format = rsx::method_registers.surface_depth_fmt(); + const auto target = rsx::method_registers.surface_color_target(); - const auto required_z_pitch = depth_format == rsx::surface_depth_format::z16 ? clip_horizontal * 2 : clip_horizontal * 4; - const auto required_color_pitch = std::max(rsx::utility::get_packed_pitch(surface_format, clip_horizontal), 64u); + const auto required_z_pitch = depth_format == rsx::surface_depth_format::z16 ? clip_horizontal * 2u : clip_horizontal * 4u; + const auto required_color_pitch = std::max((u32)rsx::utility::get_packed_pitch(surface_format, clip_horizontal), 64u); if (depth_address) { @@ -195,7 +196,7 @@ void GLGSRender::init_buffers(rsx::framebuffer_creation_context context, bool sk { depth_address = 0; } - else if (!rsx::method_registers.depth_test_enabled()) + else if (!rsx::method_registers.depth_test_enabled() && target != rsx::surface_target::none) { //Disable depth buffer if depth testing is not enabled, unless a clear command is targeting the depth buffer const bool is_depth_clear = !!(context & rsx::framebuffer_creation_context::context_clear_depth); @@ -207,16 +208,7 @@ void GLGSRender::init_buffers(rsx::framebuffer_creation_context context, bool sk } } - for (const auto &addr : surface_addresses) - { - if (addr) - { - framebuffer_status_valid = true; - break; - } - } - - for (const auto &index : rsx::utility::get_rtt_indexes(rsx::method_registers.surface_color_target())) + for (const auto &index : rsx::utility::get_rtt_indexes(target)) { if (pitchs[index] < required_color_pitch) surface_addresses[index] = 0; @@ -242,14 +234,16 @@ void GLGSRender::init_buffers(rsx::framebuffer_creation_context context, bool sk break; } } + + if (surface_addresses[index]) + framebuffer_status_valid = true; } if (!framebuffer_status_valid && !depth_address) return; m_rtts.prepare_render_target(nullptr, surface_format, depth_format, clip_horizontal, clip_vertical, - rsx::method_registers.surface_color_target(), - surface_addresses, depth_address); + target, surface_addresses, depth_address); draw_fbo.recreate(); diff --git a/rpcs3/Emu/RSX/VK/VKGSRender.cpp b/rpcs3/Emu/RSX/VK/VKGSRender.cpp index 567b93ece5..883af0cc06 100644 --- a/rpcs3/Emu/RSX/VK/VKGSRender.cpp +++ b/rpcs3/Emu/RSX/VK/VKGSRender.cpp @@ -2420,9 +2420,10 @@ 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 target = rsx::method_registers.surface_color_target(); const auto required_z_pitch = 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); + const auto required_color_pitch = std::max((u32)rsx::utility::get_packed_pitch(color_fmt, clip_width), 64u); if (zeta_address) { @@ -2431,7 +2432,7 @@ void VKGSRender::prepare_rtts(rsx::framebuffer_creation_context context) { zeta_address = 0; } - else if (!rsx::method_registers.depth_test_enabled()) + else if (!rsx::method_registers.depth_test_enabled() && target != rsx::surface_target::none) { //Disable depth buffer if depth testing is not enabled, unless a clear command is targeting the depth buffer const bool is_depth_clear = !!(context & rsx::framebuffer_creation_context::context_clear_depth); @@ -2443,16 +2444,7 @@ void VKGSRender::prepare_rtts(rsx::framebuffer_creation_context context) } } - for (const auto &addr: surface_addresses) - { - if (addr) - { - framebuffer_status_valid = true; - break; - } - } - - for (const auto &index : rsx::utility::get_rtt_indexes(rsx::method_registers.surface_color_target())) + for (const auto &index : rsx::utility::get_rtt_indexes(target)) { if (surface_pitchs[index] < required_color_pitch) surface_addresses[index] = 0; @@ -2477,6 +2469,9 @@ void VKGSRender::prepare_rtts(rsx::framebuffer_creation_context context) break; } } + + if (surface_addresses[index]) + framebuffer_status_valid = true; } if (!framebuffer_status_valid && !zeta_address) @@ -2519,7 +2514,7 @@ void VKGSRender::prepare_rtts(rsx::framebuffer_creation_context context) m_rtts.prepare_render_target(&*m_current_command_buffer, color_fmt, depth_fmt, clip_width, clip_height, - rsx::method_registers.surface_color_target(), + target, surface_addresses, zeta_address, (*m_device), &*m_current_command_buffer, m_optimal_tiling_supported_formats, m_memory_type_mapping); @@ -2549,7 +2544,7 @@ void VKGSRender::prepare_rtts(rsx::framebuffer_creation_context context) m_depth_surface_info.depth_format = depth_fmt; //Bind created rtts as current fbo... - std::vector draw_buffers = rsx::utility::get_rtt_indexes(rsx::method_registers.surface_color_target()); + std::vector draw_buffers = rsx::utility::get_rtt_indexes(target); m_draw_buffers_count = 0; std::vector bound_images;