From 4487cc8e7a2913900276d12d6394144ab31732c0 Mon Sep 17 00:00:00 2001 From: kd-11 Date: Tue, 20 Feb 2018 16:29:03 +0300 Subject: [PATCH] Remove an ugly hack pertaining to partial framebuffer-resident texture data - Its better to fill in the missing information with a wrap or clamp than to fake the texture reads in valid regions - Texture coordinate scaling is used to fill in for the cropped dimension available --- rpcs3/Emu/RSX/Common/GLSLCommon.h | 6 ++--- rpcs3/Emu/RSX/Common/texture_cache.h | 33 +++++++++------------------- 2 files changed, 13 insertions(+), 26 deletions(-) diff --git a/rpcs3/Emu/RSX/Common/GLSLCommon.h b/rpcs3/Emu/RSX/Common/GLSLCommon.h index 39642cec7..e95f95d11 100644 --- a/rpcs3/Emu/RSX/Common/GLSLCommon.h +++ b/rpcs3/Emu/RSX/Common/GLSLCommon.h @@ -444,15 +444,15 @@ namespace glsl case FUNCTION::FUNCTION_TEXTURE_SAMPLE2D: return "texture($t, $0.xy * texture_parameters[$_i].xy)"; case FUNCTION::FUNCTION_TEXTURE_SAMPLE2D_PROJ: - return "textureProj($t, $0 , $1.x)"; // Note: $1.x is bias + return "textureProj($t, $0 * vec4(texture_parameters[$_i].xy, 1., 1.), $1.x)"; // Note: $1.x is bias case FUNCTION::FUNCTION_TEXTURE_SAMPLE2D_LOD: return "textureLod($t, $0.xy * texture_parameters[$_i].xy, $1.x)"; case FUNCTION::FUNCTION_TEXTURE_SAMPLE2D_GRAD: return "textureGrad($t, $0.xy * texture_parameters[$_i].xy , $1.xy, $2.xy)"; case FUNCTION::FUNCTION_TEXTURE_SHADOW2D: - return "texture($t, $0.xyz)"; + return "texture($t, $0.xyz * vec3(texture_parameters[$_i].xy, 1.))"; case FUNCTION::FUNCTION_TEXTURE_SHADOW2D_PROJ: - return "textureProj($t, $0, $1.x)"; // Note: $1.x is bias + return "textureProj($t, $0 * vec4(texture_parameters[$_i].xy, 1., 1.), $1.x)"; // Note: $1.x is bias case FUNCTION::FUNCTION_TEXTURE_SAMPLECUBE: return "texture($t, $0.xyz)"; case FUNCTION::FUNCTION_TEXTURE_SAMPLECUBE_PROJ: diff --git a/rpcs3/Emu/RSX/Common/texture_cache.h b/rpcs3/Emu/RSX/Common/texture_cache.h index 86719d843..bcf2ad8fc 100644 --- a/rpcs3/Emu/RSX/Common/texture_cache.h +++ b/rpcs3/Emu/RSX/Common/texture_cache.h @@ -1311,28 +1311,6 @@ namespace rsx u32 internal_height = tex_height; get_native_dimensions(internal_width, internal_height, texptr); - if (internal_width > surface_width || internal_height > surface_height) - { - //An AA flag is likely missing - //HACK - auto aa_mode = texptr->aa_mode; - if ((internal_width >> 1) == surface_width) - { - if (internal_height > surface_height) - texptr->aa_mode = rsx::surface_antialiasing::square_centered_4_samples; - else - texptr->aa_mode = rsx::surface_antialiasing::diagonal_centered_2_samples; - - internal_width = tex_width; - internal_height = tex_height; - get_native_dimensions(internal_width, internal_height, texptr); - } - - internal_width = std::min(internal_width, (u32)surface_width); - internal_height = std::min(internal_height, (u32)surface_height); - texptr->aa_mode = aa_mode; - } - const bool unnormalized = (gcm_format & CELL_GCM_TEXTURE_UN) != 0; f32 scale_x = (unnormalized)? (1.f / tex_width) : 1.f; f32 scale_y = (unnormalized)? (1.f / tex_height) : 1.f; @@ -1343,9 +1321,18 @@ namespace rsx scale_y = 0.f; } - bool requires_processing = surface_width != internal_width || surface_height != internal_height; + bool requires_processing = surface_width > internal_width || surface_height > internal_height; if (!requires_processing) { + //NOTE: The scale also accounts for sampling outside the RTT region, e.g render to one quadrant but send whole texture for sampling + //In these cases, internal dimensions will exceed available surface dimensions. Account for the missing information using scaling (missing data will result in border color) + //TODO: Proper gather and stitching without performance loss + if (internal_width > surface_width) + scale_x *= ((f32)internal_width / surface_width); + + if (internal_height > surface_height) + scale_y *= ((f32)internal_height / surface_height); + if (!is_depth) { for (const auto& tex : m_rtts.m_bound_render_targets)