inline Vector<float, 4> lookup (const ConstPixelBufferAccess& access, const Sampler& sampler, int i, int j, int k)
{
// Specialization for float lookups: sRGB conversion is performed as specified in format.
- Vec4 p;
-
if (coordsInBounds(access, i, j, k))
- p = access.getPixel(i, j, k);
+ {
+ const Vec4 p = access.getPixel(i, j, k);
+ return isSRGB(access.getFormat()) ? sRGBToLinear(p) : p;
+ }
else
- p = sampleTextureBorder<float>(access.getFormat(), sampler);
-
- return isSRGB(access.getFormat()) ? sRGBToLinear(p) : p;
+ return sampleTextureBorder<float>(access.getFormat(), sampler);
}
static inline bool isColorValid (const LookupPrecision& prec, const Vec4& ref, const Vec4& result)
const bool isPureUnsignedInteger = channelClass == tcu::TEXTURECHANNELCLASS_UNSIGNED_INTEGER;
if (isFloat || isFixed)
- {
- const Vec4 p = sampleTextureBorder<float>(format, sampler);
- return isSRGB(format) ? sRGBToLinear(p) : p;
- }
+ return sampleTextureBorder<float>(format, sampler);
else if (isPureInteger)
return sampleTextureBorder<deInt32>(format, sampler).cast<float>();
else if (isPureUnsignedInteger)
}
}
- return isSRGB(format) ? sRGBToLinear(result) : result;
+ return result;
}
static tcu::IVec4 getTextureBorderColorInt (const TextureFormat& format, const Sampler& sampler)
de::ArrayBuffer<deUint8, 4> buffer (texFormat.getPixelSize());
tcu::PixelBufferAccess access (texFormat, tcu::IVec3(1, 1, 1), buffer.getPtr());
+ if (tcu::isSRGB(texFormat))
+ {
+ DE_ASSERT(texFormat.type == tcu::TextureFormat::UNORM_INT8);
+
+ // make sure border color (in linear space) can be converted to 8-bit sRGB space without
+ // significant loss.
+ const tcu::Vec4 sRGB = tcu::linearToSRGB(normalizedRange);
+ const tcu::IVec4 sRGB8 = tcu::IVec4(tcu::floatToU8(sRGB[0]),
+ tcu::floatToU8(sRGB[1]),
+ tcu::floatToU8(sRGB[2]),
+ tcu::floatToU8(sRGB[3]));
+ const tcu::Vec4 linearized = tcu::sRGBToLinear(tcu::Vec4(sRGB8[0] / 255.0f,
+ sRGB8[1] / 255.0f,
+ sRGB8[2] / 255.0f,
+ sRGB8[3] / 255.0f));
+
+ return rr::GenericVec4(tcu::select(linearized, tcu::Vec4(0.0f), channelMask));
+ }
+
switch (tcu::getTextureChannelClass(texFormat.type))
{
case tcu::TEXTURECHANNELCLASS_SIGNED_FIXED_POINT: