Skip to content

Commit

Permalink
Remove an ugly hack pertaining to partial framebuffer-resident textur…
Browse files Browse the repository at this point in the history
…e 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
  • Loading branch information
kd-11 committed Mar 13, 2018
1 parent cb9e6e7 commit 4487cc8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 26 deletions.
6 changes: 3 additions & 3 deletions rpcs3/Emu/RSX/Common/GLSLCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
33 changes: 10 additions & 23 deletions rpcs3/Emu/RSX/Common/texture_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand Down

0 comments on commit 4487cc8

Please sign in to comment.