From f6f3b40eccc40d8768e3b9a53ecc4942b224ce35 Mon Sep 17 00:00:00 2001 From: kd-11 Date: Tue, 21 May 2019 21:36:08 +0300 Subject: [PATCH] rsx: Fix AA coordinate transforms - Requires native_pitch value to take samples into account --- rpcs3/Emu/RSX/Common/surface_store.h | 2 +- rpcs3/Emu/RSX/Common/surface_utils.h | 4 ++-- rpcs3/Emu/RSX/GL/GLRenderTargets.h | 6 +++--- rpcs3/Emu/RSX/VK/VKRenderTargets.h | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/rpcs3/Emu/RSX/Common/surface_store.h b/rpcs3/Emu/RSX/Common/surface_store.h index 4236581fd7..5e904f801a 100644 --- a/rpcs3/Emu/RSX/Common/surface_store.h +++ b/rpcs3/Emu/RSX/Common/surface_store.h @@ -701,7 +701,7 @@ namespace rsx info.base_address = this_address; info.is_depth = is_depth; - const auto normalized_surface_width = surface->get_native_pitch() / required_bpp; + const auto normalized_surface_width = surface->get_surface_width(rsx::surface_metrics::bytes) / required_bpp; const auto normalized_surface_height = surface->get_surface_height(rsx::surface_metrics::samples); if (LIKELY(this_address >= texaddr)) diff --git a/rpcs3/Emu/RSX/Common/surface_utils.h b/rpcs3/Emu/RSX/Common/surface_utils.h index aa82644fa4..f46c948010 100644 --- a/rpcs3/Emu/RSX/Common/surface_utils.h +++ b/rpcs3/Emu/RSX/Common/surface_utils.h @@ -153,7 +153,7 @@ namespace rsx case rsx::surface_metrics::pixels: return surface_width; case rsx::surface_metrics::bytes: - return rsx_pitch; + return native_pitch; default: fmt::throw_exception("Unknown surface metric %d", u32(metrics)); } @@ -185,7 +185,7 @@ namespace rsx u8 get_bpp() const { - return u8(get_native_pitch() / get_surface_width()); + return u8(get_native_pitch() / get_surface_width(rsx::surface_metrics::samples)); } u8 get_spp() const diff --git a/rpcs3/Emu/RSX/GL/GLRenderTargets.h b/rpcs3/Emu/RSX/GL/GLRenderTargets.h index c1da2b8f0e..82df7c90b9 100644 --- a/rpcs3/Emu/RSX/GL/GLRenderTargets.h +++ b/rpcs3/Emu/RSX/GL/GLRenderTargets.h @@ -148,7 +148,7 @@ struct gl_render_target_traits std::unique_ptr result(new gl::render_target(rsx::apply_resolution_scale((u16)width, true), rsx::apply_resolution_scale((u16)height, true), (GLenum)internal_fmt)); - result->set_native_pitch((u16)width * format.channel_count * format.channel_size); + result->set_native_pitch((u16)width * format.channel_count * format.channel_size * get_format_sample_count(antialias)); result->set_surface_dimensions((u16)width, (u16)height, (u16)pitch); result->set_format(surface_color_format); result->set_aa_mode(antialias); @@ -175,7 +175,7 @@ struct gl_render_target_traits std::unique_ptr result(new gl::render_target(rsx::apply_resolution_scale((u16)width, true), rsx::apply_resolution_scale((u16)height, true), (GLenum)format.internal_format)); - u16 native_pitch = (u16)width * 2; + u16 native_pitch = (u16)width * 2 * get_format_sample_count(antialias); if (surface_depth_format == rsx::surface_depth_format::z24s8) native_pitch *= 2; @@ -213,7 +213,7 @@ struct gl_render_target_traits sink->format_info = ref->format_info; sink->set_spp(ref->get_spp()); - sink->set_native_pitch(prev.width * ref->get_bpp()); + sink->set_native_pitch(prev.width * ref->get_bpp() * ref->get_spp()); sink->set_surface_dimensions(prev.width, prev.height, ref->get_rsx_pitch()); sink->set_native_component_layout(ref->get_native_component_layout()); sink->queue_tag(address); diff --git a/rpcs3/Emu/RSX/VK/VKRenderTargets.h b/rpcs3/Emu/RSX/VK/VKRenderTargets.h index 4468a75281..34e35c3fa8 100644 --- a/rpcs3/Emu/RSX/VK/VKRenderTargets.h +++ b/rpcs3/Emu/RSX/VK/VKRenderTargets.h @@ -187,7 +187,7 @@ namespace rsx rtt->state_flags = rsx::surface_state_flags::erase_bkgnd; rtt->native_component_map = fmt.second; rtt->rsx_pitch = (u16)pitch; - rtt->native_pitch = (u16)width * get_format_block_size_in_bytes(format); + rtt->native_pitch = (u16)width * get_format_block_size_in_bytes(format) * get_format_sample_count(antialias); rtt->surface_width = (u16)width; rtt->surface_height = (u16)height; rtt->queue_tag(address); @@ -232,7 +232,7 @@ namespace rsx change_image_layout(cmd, ds.get(), VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, range); - ds->native_pitch = (u16)width * 2; + ds->native_pitch = (u16)width * 2 * get_format_sample_count(antialias); if (format == rsx::surface_depth_format::z24s8) ds->native_pitch *= 2; @@ -273,7 +273,7 @@ namespace rsx sink->memory_usage_flags = rsx::surface_usage_flags::storage; sink->state_flags = rsx::surface_state_flags::erase_bkgnd; sink->native_component_map = ref->native_component_map; - sink->native_pitch = u16(prev.width * ref->get_bpp()); + sink->native_pitch = u16(prev.width * ref->get_bpp() * ref->get_spp()); sink->surface_width = prev.width; sink->surface_height = prev.height; sink->queue_tag(address);