Commit a63e5f96 by Ben Clayton Committed by Ben Clayton

GLES: Fix for crashes when sampling certain textures.

There was an optimization that skipped a [0, 1] clamp for a particular sampling mode as it assumed the input coordinates were always within these bounds. However, if the texture sample coordinates were inf or NaN, this assumption broke, causing the returned address to be outside the bounds of the image data. Bug: b/123731195 Bug: b/124368982 Change-Id: I0af34ee4c2792b19081d9270fd0b1e0d0559287e Reviewed-on: https://swiftshader-review.googlesource.com/c/24868Reviewed-by: 's avatarBen Clayton <bclayton@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Tested-by: 's avatarBen Clayton <bclayton@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
parent 24021a2d
......@@ -2380,14 +2380,16 @@ namespace sw
case ADDRESSING_CLAMP:
case ADDRESSING_BORDER:
case ADDRESSING_SEAMLESS:
// Linear filtering of cube doesn't require clamping because the coordinates
// are already in [0, 1] range and numerical imprecision is tolerated.
if(addressingMode != ADDRESSING_SEAMLESS || pointFilter)
{
Float4 one = As<Float4>(Int4(oneBits));
coord = Min(Max(coord, Float4(0.0f)), one);
}
break;
{
// While cube face coordinates are nominally already in the
// [0, 1] range due to the projection, and numerical
// imprecision is tolerated due to the border of pixels for
// seamless filtering, this isn't true for inf and NaN
// values. So we always clamp.
Float4 one = As<Float4>(Int4(oneBits));
coord = Min(Max(coord, Float4(0.0f)), one);
}
break;
case ADDRESSING_MIRROR:
{
Float4 half = As<Float4>(Int4(halfBits));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment