Commit d0b7d1e3 by Nicolas Capens Committed by Nicolas Capens

Zero out texel index after sample and layer offset

This ensures that if the sample or layer coordinate were not forced to be in range but the 'valid' mask indicates whether they're in range, we sample texel 0 instead of potentially outside the image memory. Note this does not yet validate the sample coordinate. Bug: b/162419571 Change-Id: I08561862cbf371c1109c8949cd90557110d4ee24 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/47228 Presubmit-Ready: Nicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarChris Forbes <chrisforbes@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Tested-by: 's avatarNicolas Capens <nicolascapens@google.com> Kokoro-Result: kokoro <noreply+kokoro@google.com>
parent be7c55a2
...@@ -1436,13 +1436,6 @@ void SamplerCore::computeIndices(UInt index[4], Int4 uuuu, Int4 vvvv, Int4 wwww, ...@@ -1436,13 +1436,6 @@ void SamplerCore::computeIndices(UInt index[4], Int4 uuuu, Int4 vvvv, Int4 wwww,
indices += As<UInt4>(wwww); indices += As<UInt4>(wwww);
} }
if(borderModeActive())
{
// Texels out of range are still sampled before being replaced
// with the border color, so sample them at linear index 0.
indices &= As<UInt4>(valid);
}
if(function.sample) if(function.sample)
{ {
indices += Min(As<UInt4>(sampleId), *Pointer<UInt4>(mipmap + OFFSET(Mipmap, sampleMax), 16)) * indices += Min(As<UInt4>(sampleId), *Pointer<UInt4>(mipmap + OFFSET(Mipmap, sampleMax), 16)) *
...@@ -1454,6 +1447,13 @@ void SamplerCore::computeIndices(UInt index[4], Int4 uuuu, Int4 vvvv, Int4 wwww, ...@@ -1454,6 +1447,13 @@ void SamplerCore::computeIndices(UInt index[4], Int4 uuuu, Int4 vvvv, Int4 wwww,
indices += As<UInt4>(cubeArrayId) * *Pointer<UInt4>(mipmap + OFFSET(Mipmap, sliceP)) * UInt4(6); indices += As<UInt4>(cubeArrayId) * *Pointer<UInt4>(mipmap + OFFSET(Mipmap, sliceP)) * UInt4(6);
} }
if(borderModeActive())
{
// Texels out of range are still sampled before being replaced
// with the border color, so sample them at linear index 0.
indices &= As<UInt4>(valid);
}
for(int i = 0; i < 4; i++) for(int i = 0; i < 4; i++)
{ {
index[i] = Extract(As<Int4>(indices), i); index[i] = Extract(As<Int4>(indices), i);
......
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