- Make sampling from stencil texture return stencil value in R channel.
This makes stencil textures behave as in GL.
- Fix tests assuming component w is always stencil.
Change-Id: Ibc12949435330e0ac52a469b2fe8f3eab57d9e67
static const TextureSwizzle BGRA = {{ TextureSwizzle::CHANNEL_2, TextureSwizzle::CHANNEL_1, TextureSwizzle::CHANNEL_0, TextureSwizzle::CHANNEL_3 }};
static const TextureSwizzle ARGB = {{ TextureSwizzle::CHANNEL_1, TextureSwizzle::CHANNEL_2, TextureSwizzle::CHANNEL_3, TextureSwizzle::CHANNEL_0 }};
static const TextureSwizzle D = {{ TextureSwizzle::CHANNEL_0, TextureSwizzle::CHANNEL_ZERO, TextureSwizzle::CHANNEL_ZERO, TextureSwizzle::CHANNEL_ONE }};
- static const TextureSwizzle S = {{ TextureSwizzle::CHANNEL_ZERO, TextureSwizzle::CHANNEL_ZERO, TextureSwizzle::CHANNEL_ZERO, TextureSwizzle::CHANNEL_0 }};
+ static const TextureSwizzle S = {{ TextureSwizzle::CHANNEL_0, TextureSwizzle::CHANNEL_ZERO, TextureSwizzle::CHANNEL_ZERO, TextureSwizzle::CHANNEL_ONE }};
static const TextureSwizzle DS = {{ TextureSwizzle::CHANNEL_0, TextureSwizzle::CHANNEL_ZERO, TextureSwizzle::CHANNEL_ZERO, TextureSwizzle::CHANNEL_1 }};
switch (order)
static const TextureSwizzle BGRA = {{ TextureSwizzle::CHANNEL_2, TextureSwizzle::CHANNEL_1, TextureSwizzle::CHANNEL_0, TextureSwizzle::CHANNEL_3 }};
static const TextureSwizzle ARGB = {{ TextureSwizzle::CHANNEL_3, TextureSwizzle::CHANNEL_0, TextureSwizzle::CHANNEL_1, TextureSwizzle::CHANNEL_2 }};
static const TextureSwizzle D = {{ TextureSwizzle::CHANNEL_0, TextureSwizzle::CHANNEL_LAST, TextureSwizzle::CHANNEL_LAST, TextureSwizzle::CHANNEL_LAST }};
- static const TextureSwizzle S = {{ TextureSwizzle::CHANNEL_3, TextureSwizzle::CHANNEL_LAST, TextureSwizzle::CHANNEL_LAST, TextureSwizzle::CHANNEL_LAST }};
+ static const TextureSwizzle S = {{ TextureSwizzle::CHANNEL_0, TextureSwizzle::CHANNEL_LAST, TextureSwizzle::CHANNEL_LAST, TextureSwizzle::CHANNEL_LAST }};
static const TextureSwizzle DS = {{ TextureSwizzle::CHANNEL_0, TextureSwizzle::CHANNEL_3, TextureSwizzle::CHANNEL_LAST, TextureSwizzle::CHANNEL_LAST }};
switch (order)
PixelBufferAccess flipYAccess (const PixelBufferAccess& access);
ConstPixelBufferAccess flipYAccess (const ConstPixelBufferAccess& access);
+bool isCombinedDepthStencilType (TextureFormat::ChannelType type);
+
// sRGB - linear conversion.
Vec4 sRGBToLinear (const Vec4& cs);
Vec4 linearToSRGB (const Vec4& cl);
bool isSRGB (TextureFormat format);
-bool isCombinedDepthStencilType (TextureFormat::ChannelType type);
/*--------------------------------------------------------------------*//*!
* \brief Color channel storage type
continue;
for (int x = clearRect.x(); x < clearRect.x()+clearRect.z(); x++)
- rowAccess.setPixel(Vec4(de::clamp(clear->clearDepth, 0.0f, 1.0f)), x, 0);
+ rowAccess.setPixDepth(de::clamp(clear->clearDepth, 0.0f, 1.0f), x, 0);
}
// Map to colors.
for (int x = 0; x < dst.getWidth(); x++)
{
- float depth = rowAccess.getPixel(x, 0).x();
+ float depth = rowAccess.getPixDepth(x, 0);
float step = deFloatFloor(depth * (float)DEPTH_STEPS) / (float)(DEPTH_STEPS-1);
tcu::RGBA oldColor = dst.getPixel(x, y);
tcu::RGBA newColor = tcu::RGBA(oldColor.getRed(), oldColor.getGreen(), deClamp32(deRoundFloatToInt32(step * 255.0f), 0, 255), oldColor.getAlpha());
for (int x = clearRect.x(); x < clearRect.x()+clearRect.z(); x++)
{
- deUint32 oldVal = rowAccess.getPixelUint(x, 0).w();
+ deUint32 oldVal = rowAccess.getPixStencil(x, 0);
deUint32 newVal = ((oldVal & ~clear->stencilMask) | (clear->clearStencil & clear->stencilMask)) & bufMask;
- rowAccess.setPixel(tcu::UVec4(newVal), x, 0);
+ rowAccess.setPixStencil(newVal, x, 0);
}
}
// Map to colors.
for (int x = 0; x < dst.getWidth(); x++)
{
- deUint32 stencil = rowAccess.getPixelUint(x, 0).w();
+ deUint32 stencil = rowAccess.getPixStencil(x, 0);
float step = (float)(stencil / ((1u<<stencilBits) / (deUint32)STENCIL_STEPS)) / (float)(STENCIL_STEPS-1);
tcu::RGBA oldColor = dst.getPixel(x, y);
tcu::RGBA newColor = tcu::RGBA(oldColor.getRed(), deClamp32(deRoundFloatToInt32(step * 255.0f), 0, 255), oldColor.getBlue(), oldColor.getAlpha());
continue;
for (int x = clearRect.x(); x < clearRect.x()+clearRect.z(); x++)
- rowAccess.setPixel(Vec4(de::clamp(clear->clearDepth, 0.0f, 1.0f)), x, 0);
+ rowAccess.setPixDepth(de::clamp(clear->clearDepth, 0.0f, 1.0f), x, 0);
}
// Map to colors.
for (int x = 0; x < dst.getWidth(); x++)
{
- float depth = rowAccess.getPixel(x, 0).x();
+ float depth = rowAccess.getPixDepth(x, 0);
float step = deFloatFloor(depth * (float)DEPTH_STEPS) / (float)(DEPTH_STEPS-1);
tcu::RGBA oldColor = dst.getPixel(x, y);
tcu::RGBA newColor = tcu::RGBA(oldColor.getRed(), oldColor.getGreen(), deClamp32(deRoundFloatToInt32(step * 255.0f), 0, 255), oldColor.getAlpha());
for (int x = clearRect.x(); x < clearRect.x()+clearRect.z(); x++)
{
- deUint32 oldVal = rowAccess.getPixelUint(x, 0).w();
+ deUint32 oldVal = rowAccess.getPixStencil(x, 0);
deUint32 newVal = ((oldVal & ~clear->stencilMask) | (clear->clearStencil & clear->stencilMask)) & bufMask;
- rowAccess.setPixel(tcu::UVec4(newVal), x, 0);
+ rowAccess.setPixStencil(newVal, x, 0);
}
}
// Map to colors.
for (int x = 0; x < dst.getWidth(); x++)
{
- deUint32 stencil = rowAccess.getPixelUint(x, 0).w();
+ deUint32 stencil = rowAccess.getPixStencil(x, 0);
float step = (float)(stencil / ((1u<<stencilBits) / (deUint32)STENCIL_STEPS)) / (float)(STENCIL_STEPS-1);
tcu::RGBA oldColor = dst.getPixel(x, y);
tcu::RGBA newColor = tcu::RGBA(oldColor.getRed(), deClamp32(deRoundFloatToInt32(step * 255.0f), 0, 255), oldColor.getBlue(), oldColor.getAlpha());
static void renderTestPatternReference (const tcu::PixelBufferAccess& dst)
{
- const int stencilBits = tcu::getTextureFormatBitDepth(dst.getFormat()).w();
+ const int stencilBits = tcu::getTextureFormatBitDepth(tcu::getEffectiveDepthStencilAccess(dst, tcu::Sampler::MODE_STENCIL).getFormat()).x();
const deUint32 stencilMask = (1u<<stencilBits)-1u;
vector<IVec4> rects;
DE_ASSERT(dst.getFormat().order == TextureFormat::S || dst.getFormat().order == TextureFormat::DS);
+ // clear depth and stencil
tcu::clear(dst, IVec4(0));
genTestRects(rects, dst.getWidth(), dst.getHeight());
static inline tcu::ConstPixelBufferAccess stencilToRedAccess (const tcu::ConstPixelBufferAccess& access)
{
DE_ASSERT(access.getFormat() == TextureFormat(TextureFormat::S, TextureFormat::UNSIGNED_INT8));
- return tcu::ConstPixelBufferAccess(TextureFormat(TextureFormat::R, TextureFormat::UNSIGNED_INT8),
- access.getWidth(), access.getHeight(), access.getDepth(), access.getRowPitch(), access.getSlicePitch(), access.getDataPtr());
+ return tcu::ConstPixelBufferAccess(TextureFormat(TextureFormat::R, TextureFormat::UNSIGNED_INT8), access.getSize(), access.getPitch(), access.getDataPtr());
}
static bool compareStencilToRed (tcu::TestLog& log, const tcu::ConstPixelBufferAccess& stencilRef, const tcu::ConstPixelBufferAccess& result)
if (levelNdx == ptrnLevel)
renderTestPatternReference(levelAccess);
else
- tcu::clear(levelAccess, IVec4(0, 0, 0, levelNdx));
+ tcu::clearStencil(levelAccess, levelNdx);
}
gl.bindTexture(GL_TEXTURE_2D_ARRAY, *depthStencilTex);
const int stencilVal = 42*faceNdx;
texData.allocLevel(face, 0);
- tcu::clear(texData.getLevelFace(0, face), IVec4(0, 0, 0, stencilVal));
+ tcu::clearStencil(texData.getLevelFace(0, face), stencilVal);
}
gls::TextureTestUtil::computeQuadTexCoordCube(texCoord, tcu::CUBEFACE_NEGATIVE_X, Vec2(-1.5f, -1.3f), Vec2(1.3f, 1.4f));
gl.scissor(x, y, clearW, clearH);
gl.clear(GL_STENCIL_BUFFER_BIT);
- tcu::clear(tcu::getSubregion(reference.getAccess(), x, y, clearW, clearH), IVec4(0, 0, 0, stencil));
+ tcu::clearStencil(tcu::getSubregion(reference.getAccess(), x, y, clearW, clearH), stencil);
}
}