Commit c4b1bfa9 by Nicolas Capens Committed by Nicolas Capens

Perform coordinate clamping on border addressing mode.

The border addressing mode should ideally blend with the border color when using linear filtering. Until we have a border of pixels around 2D textures, we should probably avoid bleeding pixels from the opposite edge and just clamp the coordinates. Change-Id: I7afbb629998732b62413e00ba7bcd55340c7b9bb Reviewed-on: https://swiftshader-review.googlesource.com/14289Tested-by: 's avatarNicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com>
parent 73e18c1b
...@@ -2332,7 +2332,7 @@ namespace sw ...@@ -2332,7 +2332,7 @@ namespace sw
{ {
return Min(Max(Short4(RoundInt(uw)), Short4(0)), *Pointer<Short4>(mipmap + OFFSET(Mipmap, depth)) - Short4(1)); return Min(Max(Short4(RoundInt(uw)), Short4(0)), *Pointer<Short4>(mipmap + OFFSET(Mipmap, depth)) - Short4(1));
} }
else if(addressingMode == ADDRESSING_CLAMP) else if(addressingMode == ADDRESSING_CLAMP || addressingMode == ADDRESSING_BORDER)
{ {
Float4 clamp = Min(Max(uw, Float4(0.0f)), Float4(65535.0f / 65536.0f)); Float4 clamp = Min(Max(uw, Float4(0.0f)), Float4(65535.0f / 65536.0f));
...@@ -2358,7 +2358,7 @@ namespace sw ...@@ -2358,7 +2358,7 @@ namespace sw
return As<Short4>(Int2(convert)) + Short4(0x8000u); return As<Short4>(Int2(convert)) + Short4(0x8000u);
} }
else // Wrap (or border) else // Wrap
{ {
return Short4(Int4(uw * Float4(1 << 16))); return Short4(Int4(uw * Float4(1 << 16)));
} }
...@@ -2392,6 +2392,7 @@ namespace sw ...@@ -2392,6 +2392,7 @@ namespace sw
switch(addressingMode) switch(addressingMode)
{ {
case ADDRESSING_CLAMP: case ADDRESSING_CLAMP:
case ADDRESSING_BORDER:
{ {
Float4 one = As<Float4>(Int4(oneBits)); Float4 one = As<Float4>(Int4(oneBits));
coord = Min(Max(coord, Float4(0.0f)), one); coord = Min(Max(coord, Float4(0.0f)), one);
...@@ -2413,7 +2414,7 @@ namespace sw ...@@ -2413,7 +2414,7 @@ namespace sw
coord = one - Abs(two * Frac(Min(Max(coord, -one), two) * half) - one); coord = one - Abs(two * Frac(Min(Max(coord, -one), two) * half) - one);
} }
break; break;
default: // Wrap (or border) default: // Wrap
coord = Frac(coord); coord = Frac(coord);
break; break;
} }
......
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