Commit 1c462ebc by Alexis Hetu Committed by Alexis Hétu

Stencil buffer texture sampling

In order to perform a blitFramebuffer operation, ANGLE uses a compute shader which reads the stencil from a depth+stencil image to a buffer, and then copies this buffer to the stencil of the other image. This cl basically treats VK_FORMAT_S8_UINT as VK_FORMAT_R8_UINT with quad layout for the purpose of texture sampling. Fixes the following tests: dEQP-GLES3.functional.fbo.blit.depth_stencil.depth32f_stencil8_basic dEQP-GLES3.functional.fbo.blit.depth_stencil.depth32f_stencil8_stencil_only dEQP-GLES3.functional.fbo.blit.depth_stencil.depth24_stencil8_basic dEQP-GLES3.functional.fbo.blit.depth_stencil.depth24_stencil8_stencil_only Bug: b/142385547 Change-Id: Ib2ea7fa81496ceca1c24ea7f065b1c2cd05596ee Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/37188 Presubmit-Ready: Alexis Hétu <sugoi@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarAntonio Maiorano <amaiorano@google.com>
parent ae022faf
...@@ -1032,6 +1032,7 @@ namespace sw ...@@ -1032,6 +1032,7 @@ namespace sw
case VK_FORMAT_R8G8_UINT: case VK_FORMAT_R8G8_UINT:
c = Insert(c, Int(*Pointer<Byte>(element + 1)), 1); c = Insert(c, Int(*Pointer<Byte>(element + 1)), 1);
case VK_FORMAT_R8_UINT: case VK_FORMAT_R8_UINT:
case VK_FORMAT_S8_UINT:
c = Insert(c, Int(*Pointer<Byte>(element)), 0); c = Insert(c, Int(*Pointer<Byte>(element)), 0);
break; break;
case VK_FORMAT_R16G16B16A16_SINT: case VK_FORMAT_R16G16B16A16_SINT:
...@@ -1090,6 +1091,7 @@ namespace sw ...@@ -1090,6 +1091,7 @@ namespace sw
case VK_FORMAT_R8G8B8_USCALED: case VK_FORMAT_R8G8B8_USCALED:
case VK_FORMAT_R8G8_USCALED: case VK_FORMAT_R8G8_USCALED:
case VK_FORMAT_R8_USCALED: case VK_FORMAT_R8_USCALED:
case VK_FORMAT_S8_UINT:
c = Min(As<UInt4>(c), UInt4(0xFF)); c = Min(As<UInt4>(c), UInt4(0xFF));
break; break;
case VK_FORMAT_R16G16B16A16_UINT: case VK_FORMAT_R16G16B16A16_UINT:
...@@ -1215,6 +1217,7 @@ namespace sw ...@@ -1215,6 +1217,7 @@ namespace sw
if(writeG) { *Pointer<Byte>(element + 1) = Byte(Extract(c, 1)); } if(writeG) { *Pointer<Byte>(element + 1) = Byte(Extract(c, 1)); }
case VK_FORMAT_R8_UINT: case VK_FORMAT_R8_UINT:
case VK_FORMAT_R8_USCALED: case VK_FORMAT_R8_USCALED:
case VK_FORMAT_S8_UINT:
if(writeR) { *Pointer<Byte>(element) = Byte(Extract(c, 0)); } if(writeR) { *Pointer<Byte>(element) = Byte(Extract(c, 0)); }
break; break;
case VK_FORMAT_R16G16B16A16_SINT: case VK_FORMAT_R16G16B16A16_SINT:
...@@ -1358,7 +1361,7 @@ namespace sw ...@@ -1358,7 +1361,7 @@ namespace sw
{ {
// (x & ~1) * 2 + (x & 1) == (x - (x & 1)) * 2 + (x & 1) == x * 2 - (x & 1) * 2 + (x & 1) == x * 2 - (x & 1) // (x & ~1) * 2 + (x & 1) == (x - (x & 1)) * 2 + (x & 1) == x * 2 - (x & 1) * 2 + (x & 1) == x * 2 - (x & 1)
return (y & Int(~1)) * pitchB + return (y & Int(~1)) * pitchB +
((y & Int(1)) * 2 + x * 2 - (x & Int(1))) * bytes; ((((y & Int(1)) + x) << 1) - (x & Int(1))) * bytes;
} }
} }
......
...@@ -45,6 +45,13 @@ namespace ...@@ -45,6 +45,13 @@ namespace
default: ASSERT(false); default: ASSERT(false);
} }
} }
template <typename T>
void applyQuadLayout(T& x, T& y)
{
x = (((y & T(1)) + x) << 1) - (x & T(1));
y &= T(~1);
}
} }
namespace sw namespace sw
...@@ -895,6 +902,11 @@ namespace sw ...@@ -895,6 +902,11 @@ namespace sw
address(v, y0, y1, fv, mipmap, offset.y, filter, OFFSET(Mipmap, height), state.addressingModeV, function); address(v, y0, y1, fv, mipmap, offset.y, filter, OFFSET(Mipmap, height), state.addressingModeV, function);
address(w, z0, z0, fw, mipmap, offset.z, filter, OFFSET(Mipmap, depth), state.addressingModeW, function); address(w, z0, z0, fw, mipmap, offset.z, filter, OFFSET(Mipmap, depth), state.addressingModeW, function);
if(hasQuadLayout())
{
::applyQuadLayout(x0, y0);
}
Int4 pitchP = *Pointer<Int4>(mipmap + OFFSET(Mipmap, pitchP), 16); Int4 pitchP = *Pointer<Int4>(mipmap + OFFSET(Mipmap, pitchP), 16);
y0 *= pitchP; y0 *= pitchP;
if(state.addressingModeW != ADDRESSING_UNUSED) if(state.addressingModeW != ADDRESSING_UNUSED)
...@@ -908,6 +920,11 @@ namespace sw ...@@ -908,6 +920,11 @@ namespace sw
} }
else else
{ {
if(hasQuadLayout())
{
::applyQuadLayout(x1, y1);
}
y1 *= pitchP; y1 *= pitchP;
Vector4f c00 = sampleTexel(x0, y0, z0, q, mipmap, buffer, function); Vector4f c00 = sampleTexel(x0, y0, z0, q, mipmap, buffer, function);
...@@ -971,6 +988,11 @@ namespace sw ...@@ -971,6 +988,11 @@ namespace sw
address(v, y0, y1, fv, mipmap, offset.y, filter, OFFSET(Mipmap, height), state.addressingModeV, function); address(v, y0, y1, fv, mipmap, offset.y, filter, OFFSET(Mipmap, height), state.addressingModeV, function);
address(w, z0, z1, fw, mipmap, offset.z, filter, OFFSET(Mipmap, depth), state.addressingModeW, function); address(w, z0, z1, fw, mipmap, offset.z, filter, OFFSET(Mipmap, depth), state.addressingModeW, function);
if(hasQuadLayout())
{
::applyQuadLayout(x0, y0);
}
Int4 pitchP = *Pointer<Int4>(mipmap + OFFSET(Mipmap, pitchP), 16); Int4 pitchP = *Pointer<Int4>(mipmap + OFFSET(Mipmap, pitchP), 16);
Int4 sliceP = *Pointer<Int4>(mipmap + OFFSET(Mipmap, sliceP), 16); Int4 sliceP = *Pointer<Int4>(mipmap + OFFSET(Mipmap, sliceP), 16);
y0 *= pitchP; y0 *= pitchP;
...@@ -982,6 +1004,11 @@ namespace sw ...@@ -982,6 +1004,11 @@ namespace sw
} }
else else
{ {
if(hasQuadLayout())
{
::applyQuadLayout(x1, y1);
}
y1 *= pitchP; y1 *= pitchP;
z1 *= sliceP; z1 *= sliceP;
...@@ -1280,6 +1307,11 @@ namespace sw ...@@ -1280,6 +1307,11 @@ namespace sw
texelFetch ? ADDRESSING_TEXELFETCH : state.addressingModeV); texelFetch ? ADDRESSING_TEXELFETCH : state.addressingModeV);
} }
if(hasQuadLayout())
{
::applyQuadLayout(uuuu, vvvv);
}
Short4 uuu2 = uuuu; Short4 uuu2 = uuuu;
uuuu = As<Short4>(UnpackLow(uuuu, vvvv)); uuuu = As<Short4>(UnpackLow(uuuu, vvvv));
uuu2 = As<Short4>(UnpackHigh(uuu2, vvvv)); uuu2 = As<Short4>(UnpackHigh(uuu2, vvvv));
...@@ -1491,6 +1523,7 @@ namespace sw ...@@ -1491,6 +1523,7 @@ namespace sw
{ {
case VK_FORMAT_R8_SINT: case VK_FORMAT_R8_SINT:
case VK_FORMAT_R8_UINT: case VK_FORMAT_R8_UINT:
case VK_FORMAT_S8_UINT:
{ {
Int zero(0); Int zero(0);
c.x = Unpack(As<Byte4>(c0), As<Byte4>(zero)); c.x = Unpack(As<Byte4>(c0), As<Byte4>(zero));
...@@ -2386,6 +2419,11 @@ namespace sw ...@@ -2386,6 +2419,11 @@ namespace sw
return state.textureFormat.has32bitIntegerTextureComponents(); return state.textureFormat.has32bitIntegerTextureComponents();
} }
bool SamplerCore::hasQuadLayout() const
{
return state.textureFormat.hasQuadLayout();
}
bool SamplerCore::isYcbcrFormat() const bool SamplerCore::isYcbcrFormat() const
{ {
return state.textureFormat.isYcbcrFormat(); return state.textureFormat.isYcbcrFormat();
......
...@@ -104,6 +104,7 @@ namespace sw ...@@ -104,6 +104,7 @@ namespace sw
bool has8bitTextureComponents() const; bool has8bitTextureComponents() const;
bool has16bitTextureComponents() const; bool has16bitTextureComponents() const;
bool has32bitIntegerTextureComponents() const; bool has32bitIntegerTextureComponents() const;
bool hasQuadLayout() const;
bool isYcbcrFormat() const; bool isYcbcrFormat() const;
bool isRGBComponent(int component) const; bool isRGBComponent(int component) const;
bool borderModeActive() const; bool borderModeActive() const;
......
...@@ -127,6 +127,7 @@ bool Format::isUnsignedNonNormalizedInteger() const ...@@ -127,6 +127,7 @@ bool Format::isUnsignedNonNormalizedInteger() const
case VK_FORMAT_R64G64_UINT: case VK_FORMAT_R64G64_UINT:
case VK_FORMAT_R64G64B64_UINT: case VK_FORMAT_R64G64B64_UINT:
case VK_FORMAT_R64G64B64A64_UINT: case VK_FORMAT_R64G64B64A64_UINT:
case VK_FORMAT_S8_UINT:
return true; return true;
default: default:
return false; return false;
...@@ -1978,6 +1979,7 @@ bool Format::has16bitTextureFormat() const ...@@ -1978,6 +1979,7 @@ bool Format::has16bitTextureFormat() const
case VK_FORMAT_E5B9G9R9_UFLOAT_PACK32: case VK_FORMAT_E5B9G9R9_UFLOAT_PACK32:
case VK_FORMAT_B10G11R11_UFLOAT_PACK32: case VK_FORMAT_B10G11R11_UFLOAT_PACK32:
case VK_FORMAT_D16_UNORM: case VK_FORMAT_D16_UNORM:
case VK_FORMAT_S8_UINT:
return false; return false;
default: default:
UNIMPLEMENTED("Format: %d", int(format)); UNIMPLEMENTED("Format: %d", int(format));
...@@ -2009,6 +2011,7 @@ bool Format::has8bitTextureComponents() const ...@@ -2009,6 +2011,7 @@ bool Format::has8bitTextureComponents() const
case VK_FORMAT_R8G8_UINT: case VK_FORMAT_R8G8_UINT:
case VK_FORMAT_R8G8B8A8_SINT: case VK_FORMAT_R8G8B8A8_SINT:
case VK_FORMAT_R8G8B8A8_UINT: case VK_FORMAT_R8G8B8A8_UINT:
case VK_FORMAT_S8_UINT:
return true; return true;
case VK_FORMAT_A1R5G5B5_UNORM_PACK16: case VK_FORMAT_A1R5G5B5_UNORM_PACK16:
case VK_FORMAT_B4G4R4A4_UNORM_PACK16: case VK_FORMAT_B4G4R4A4_UNORM_PACK16:
...@@ -2092,6 +2095,7 @@ bool Format::has16bitTextureComponents() const ...@@ -2092,6 +2095,7 @@ bool Format::has16bitTextureComponents() const
case VK_FORMAT_A2B10G10R10_UINT_PACK32: case VK_FORMAT_A2B10G10R10_UINT_PACK32:
case VK_FORMAT_E5B9G9R9_UFLOAT_PACK32: case VK_FORMAT_E5B9G9R9_UFLOAT_PACK32:
case VK_FORMAT_B10G11R11_UFLOAT_PACK32: case VK_FORMAT_B10G11R11_UFLOAT_PACK32:
case VK_FORMAT_S8_UINT:
return false; return false;
case VK_FORMAT_R16_UNORM: case VK_FORMAT_R16_UNORM:
case VK_FORMAT_R16_SNORM: case VK_FORMAT_R16_SNORM:
...@@ -2166,6 +2170,7 @@ bool Format::has32bitIntegerTextureComponents() const ...@@ -2166,6 +2170,7 @@ bool Format::has32bitIntegerTextureComponents() const
case VK_FORMAT_E5B9G9R9_UFLOAT_PACK32: case VK_FORMAT_E5B9G9R9_UFLOAT_PACK32:
case VK_FORMAT_B10G11R11_UFLOAT_PACK32: case VK_FORMAT_B10G11R11_UFLOAT_PACK32:
case VK_FORMAT_D16_UNORM: case VK_FORMAT_D16_UNORM:
case VK_FORMAT_S8_UINT:
return false; return false;
case VK_FORMAT_R32_SINT: case VK_FORMAT_R32_SINT:
case VK_FORMAT_R32_UINT: case VK_FORMAT_R32_UINT:
...@@ -2239,6 +2244,7 @@ bool Format::isRGBComponent(int component) const ...@@ -2239,6 +2244,7 @@ bool Format::isRGBComponent(int component) const
return component < 3; return component < 3;
case VK_FORMAT_D32_SFLOAT: case VK_FORMAT_D32_SFLOAT:
case VK_FORMAT_D16_UNORM: case VK_FORMAT_D16_UNORM:
case VK_FORMAT_S8_UINT:
return false; return false;
default: default:
UNIMPLEMENTED("Format: %d", int(format)); UNIMPLEMENTED("Format: %d", int(format));
......
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