#endif
}
+inline deUint32 readUint24Low8 (const deUint8* src)
+{
+#if (DE_ENDIANNESS == DE_LITTLE_ENDIAN)
+ const deUint32 uint24ByteOffsetBits0To8 = 0; //!< least significant byte in the lowest address
+#else
+ const deUint32 uint24ByteOffsetBits0To8 = 2; //!< least significant byte in the highest address
+#endif
+
+ return src[uint24ByteOffsetBits0To8];
+}
+
+inline void writeUint24Low8 (deUint8* dst, deUint8 val)
+{
+#if (DE_ENDIANNESS == DE_LITTLE_ENDIAN)
+ const deUint32 uint24ByteOffsetBits0To8 = 0; //!< least significant byte in the lowest address
+#else
+ const deUint32 uint24ByteOffsetBits0To8 = 2; //!< least significant byte in the highest address
+#endif
+
+ dst[uint24ByteOffsetBits0To8] = val;
+}
+
+inline deUint32 readUint24High16 (const deUint8* src)
+{
+#if (DE_ENDIANNESS == DE_LITTLE_ENDIAN)
+ return (((deUint32)src[1]) << 0u) |
+ (((deUint32)src[2]) << 8u);
+#else
+ return (((deUint32)src[0]) << 8u) |
+ (((deUint32)src[1]) << 0u);
+#endif
+}
+
+inline void writeUint24High16 (deUint8* dst, deUint16 val)
+{
+#if (DE_ENDIANNESS == DE_LITTLE_ENDIAN)
+ dst[1] = (deUint8)((val & (deUint16)0x00FFu) >> 0u);
+ dst[2] = (deUint8)((val & (deUint16)0xFF00u) >> 8u);
+#else
+ dst[0] = (deUint8)((val & (deUint16)0xFF00u) >> 8u);
+ dst[1] = (deUint8)((val & (deUint16)0x00FFu) >> 0u);
+#endif
+}
+
inline deUint8 readUint32Low8 (const deUint8* src)
{
#if (DE_ENDIANNESS == DE_LITTLE_ENDIAN)
int getChannelSize (TextureFormat::ChannelType type)
{
// make sure this table is updated if format table is updated
- DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 27);
+ DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 29);
switch (type)
{
inline float channelToFloat (const deUint8* value, TextureFormat::ChannelType type)
{
// make sure this table is updated if format table is updated
- DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 27);
+ DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 29);
switch (type)
{
inline int channelToInt (const deUint8* value, TextureFormat::ChannelType type)
{
// make sure this table is updated if format table is updated
- DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 27);
+ DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 29);
switch (type)
{
void floatToChannel (deUint8* dst, float src, TextureFormat::ChannelType type)
{
// make sure this table is updated if format table is updated
- DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 27);
+ DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 29);
switch (type)
{
void intToChannel (deUint8* dst, int src, TextureFormat::ChannelType type)
{
// make sure this table is updated if format table is updated
- DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 27);
+ DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 29);
switch (type)
{
DE_ASSERT(order == RGBA);
return 4;
}
+ else if (type == UNSIGNED_INT_16_8)
+ {
+ DE_ASSERT(order == D || order == DS);
+ return 3;
+ }
else if (type == UNSIGNED_INT_24_8)
{
DE_ASSERT(order == D || order == DS);
return 4;
}
+ else if (type == FLOAT_UNSIGNED_INT_8)
+ {
+ DE_ASSERT(order == DS);
+ return 5;
+ }
else if (type == FLOAT_UNSIGNED_INT_24_8_REV)
{
DE_ASSERT(order == DS);
const deUint8* const pixelPtr = (const deUint8*)getPixelPtr(x, y, z);
- DE_ASSERT(m_format.order == TextureFormat::DS || m_format.order == TextureFormat::D);
-
switch (m_format.type)
{
- case TextureFormat::UNSIGNED_INT_24_8:
- switch (m_format.order)
- {
- case TextureFormat::D:
- case TextureFormat::DS: // \note Fall-through.
- return (float)readUint32High24(pixelPtr) / 16777215.0f;
+ case TextureFormat::UNSIGNED_INT_16_8:
+ DE_ASSERT(m_format.order == TextureFormat::DS);
+ return (float)readUint24High16(pixelPtr) / 65535.0f;
- default:
- DE_ASSERT(false);
- return 0.0f;
- }
+ case TextureFormat::UNSIGNED_INT_24_8:
+ DE_ASSERT(m_format.order == TextureFormat::DS);
+ return (float)readUint32High24(pixelPtr) / 16777215.0f;
+ case TextureFormat::FLOAT_UNSIGNED_INT_8:
case TextureFormat::FLOAT_UNSIGNED_INT_24_8_REV:
DE_ASSERT(m_format.order == TextureFormat::DS);
return *((const float*)pixelPtr);
switch (m_format.type)
{
+ case TextureFormat::UNSIGNED_INT_16_8:
+ DE_ASSERT(m_format.order == TextureFormat::DS);
+ return (int)readUint24Low8(pixelPtr);
+
case TextureFormat::UNSIGNED_INT_24_8:
- switch (m_format.order)
- {
- case TextureFormat::S:
- case TextureFormat::DS:
- return (int)readUint32Low8(pixelPtr);
+ DE_ASSERT(m_format.order == TextureFormat::DS);
+ return (int)readUint32Low8(pixelPtr);
- default:
- DE_ASSERT(false);
- return 0;
- }
+ case TextureFormat::FLOAT_UNSIGNED_INT_8:
+ DE_ASSERT(m_format.order == TextureFormat::DS);
+ return (int)pixelPtr[4];
case TextureFormat::FLOAT_UNSIGNED_INT_24_8_REV:
DE_ASSERT(m_format.order == TextureFormat::DS);
switch (m_format.type)
{
- case TextureFormat::UNSIGNED_INT_24_8:
- switch (m_format.order)
- {
- case TextureFormat::D:
- case TextureFormat::DS:
- writeUint32High24(pixelPtr, convertSatRteUint24(depth * 16777215.0f));
- break;
+ case TextureFormat::UNSIGNED_INT_16_8:
+ DE_ASSERT(m_format.order == TextureFormat::DS);
+ writeUint24High16(pixelPtr, convertSatRte<deUint16>(depth * 65535.0f));
+ break;
- default:
- DE_ASSERT(false);
- }
+ case TextureFormat::UNSIGNED_INT_24_8:
+ DE_ASSERT(m_format.order == TextureFormat::DS);
+ writeUint32High24(pixelPtr, convertSatRteUint24(depth * 16777215.0f));
break;
+ case TextureFormat::FLOAT_UNSIGNED_INT_8:
case TextureFormat::FLOAT_UNSIGNED_INT_24_8_REV:
DE_ASSERT(m_format.order == TextureFormat::DS);
*((float*)pixelPtr) = depth;
switch (m_format.type)
{
+ case TextureFormat::UNSIGNED_INT_16_8:
+ DE_ASSERT(m_format.order == TextureFormat::DS);
+ writeUint24Low8(pixelPtr, convertSat<deUint8>((deUint32)stencil));
+ break;
+
case TextureFormat::UNSIGNED_INT_24_8:
- switch (m_format.order)
- {
- case TextureFormat::S:
- case TextureFormat::DS:
- writeUint32Low8(pixelPtr, convertSat<deUint8>((deUint32)stencil));
- break;
+ DE_ASSERT(m_format.order == TextureFormat::DS);
+ writeUint32Low8(pixelPtr, convertSat<deUint8>((deUint32)stencil));
+ break;
- default:
- DE_ASSERT(false);
- }
+ case TextureFormat::FLOAT_UNSIGNED_INT_8:
+ DE_ASSERT(m_format.order == TextureFormat::DS);
break;
case TextureFormat::FLOAT_UNSIGNED_INT_24_8_REV:
"UNSIGNED_INT_1010102_REV",
"UNSIGNED_INT_11F_11F_10F_REV",
"UNSIGNED_INT_999_E5_REV",
+ "UNSIGNED_INT_16_8",
"UNSIGNED_INT_24_8",
"SIGNED_INT8",
"SIGNED_INT16",
"UNSIGNED_INT32",
"HALF_FLOAT",
"FLOAT",
+ "FLOAT_UNSIGNED_INT_8",
"FLOAT_UNSIGNED_INT_24_8_REV"
};
bool isCombinedDepthStencilType (TextureFormat::ChannelType type)
{
// make sure to update this if type table is updated
- DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 27);
+ DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 29);
- return type == TextureFormat::UNSIGNED_INT_24_8 ||
+ return type == TextureFormat::UNSIGNED_INT_16_8 ||
+ type == TextureFormat::UNSIGNED_INT_24_8 ||
+ type == TextureFormat::FLOAT_UNSIGNED_INT_8 ||
type == TextureFormat::FLOAT_UNSIGNED_INT_24_8_REV;
}
TextureChannelClass getTextureChannelClass (TextureFormat::ChannelType channelType)
{
// make sure this table is updated if format table is updated
- DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 27);
+ DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 29);
switch (channelType)
{
case TextureFormat::UNSIGNED_INT_1010102_REV: return TEXTURECHANNELCLASS_UNSIGNED_INTEGER;
case TextureFormat::UNSIGNED_INT_11F_11F_10F_REV: return TEXTURECHANNELCLASS_FLOATING_POINT;
case TextureFormat::UNSIGNED_INT_999_E5_REV: return TEXTURECHANNELCLASS_FLOATING_POINT;
+ case TextureFormat::UNSIGNED_INT_16_8: return TEXTURECHANNELCLASS_LAST; //!< packed unorm16-uint8
case TextureFormat::UNSIGNED_INT_24_8: return TEXTURECHANNELCLASS_LAST; //!< packed unorm24-uint8
case TextureFormat::SIGNED_INT8: return TEXTURECHANNELCLASS_SIGNED_INTEGER;
case TextureFormat::SIGNED_INT16: return TEXTURECHANNELCLASS_SIGNED_INTEGER;
case TextureFormat::UNSIGNED_INT32: return TEXTURECHANNELCLASS_UNSIGNED_INTEGER;
case TextureFormat::HALF_FLOAT: return TEXTURECHANNELCLASS_FLOATING_POINT;
case TextureFormat::FLOAT: return TEXTURECHANNELCLASS_FLOATING_POINT;
+ case TextureFormat::FLOAT_UNSIGNED_INT_8: return TEXTURECHANNELCLASS_LAST; //!< packed float32-uint8
case TextureFormat::FLOAT_UNSIGNED_INT_24_8_REV: return TEXTURECHANNELCLASS_LAST; //!< packed float32-pad24-uint8
default: return TEXTURECHANNELCLASS_LAST;
}
static Vec2 getChannelValueRange (TextureFormat::ChannelType channelType)
{
// make sure this table is updated if format table is updated
- DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 27);
+ DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 29);
float cMin = 0.0f;
float cMax = 0.0f;
static IVec4 getChannelBitDepth (TextureFormat::ChannelType channelType)
{
// make sure this table is updated if format table is updated
- DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 27);
+ DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 29);
switch (channelType)
{
case TextureFormat::UNSIGNED_INT24: return IVec4(24);
case TextureFormat::UNSIGNED_INT32: return IVec4(32);
case TextureFormat::UNSIGNED_INT_1010102_REV: return IVec4(10,10,10,2);
+ case TextureFormat::UNSIGNED_INT_16_8: return IVec4(16,8,0,0);
case TextureFormat::UNSIGNED_INT_24_8: return IVec4(24,8,0,0);
case TextureFormat::HALF_FLOAT: return IVec4(16);
case TextureFormat::FLOAT: return IVec4(32);
case TextureFormat::UNSIGNED_INT_11F_11F_10F_REV: return IVec4(11,11,10,0);
case TextureFormat::UNSIGNED_INT_999_E5_REV: return IVec4(9,9,9,0);
+ case TextureFormat::FLOAT_UNSIGNED_INT_8: return IVec4(32,8,0,0);
case TextureFormat::FLOAT_UNSIGNED_INT_24_8_REV: return IVec4(32,8,0,0);
default:
DE_ASSERT(false);
static IVec4 getChannelMantissaBitDepth (TextureFormat::ChannelType channelType)
{
// make sure this table is updated if format table is updated
- DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 27);
+ DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 29);
switch (channelType)
{
case TextureFormat::UNSIGNED_INT24:
case TextureFormat::UNSIGNED_INT32:
case TextureFormat::UNSIGNED_INT_1010102_REV:
+ case TextureFormat::UNSIGNED_INT_16_8:
case TextureFormat::UNSIGNED_INT_24_8:
case TextureFormat::UNSIGNED_INT_999_E5_REV:
return getChannelBitDepth(channelType);
case TextureFormat::HALF_FLOAT: return IVec4(10);
case TextureFormat::FLOAT: return IVec4(23);
case TextureFormat::UNSIGNED_INT_11F_11F_10F_REV: return IVec4(6,6,5,0);
+ case TextureFormat::FLOAT_UNSIGNED_INT_8: return IVec4(23,8,0,0);
case TextureFormat::FLOAT_UNSIGNED_INT_24_8_REV: return IVec4(23,8,0,0);
default:
DE_ASSERT(false);
static AccessType toSamplerAccess (const AccessType& baseAccess, Sampler::DepthStencilMode mode)
{
// make sure to update this if type table is updated
- DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 27);
+ DE_STATIC_ASSERT(TextureFormat::CHANNELTYPE_LAST == 29);
if (!isCombinedDepthStencilType(baseAccess.getFormat().type))
return baseAccess;
else
{
#if (DE_ENDIANNESS == DE_LITTLE_ENDIAN)
- const deUint32 uint32ByteOffsetBits0To8 = 0; //!< least significant byte in the lowest address
- const deUint32 uint32ByteOffset8To32 = 1;
+ const deUint32 uint24ByteOffsetBits0To8 = 0; //!< least significant byte in the lowest address
+ const deUint32 uint24ByteOffsetBits8To24 = 1;
+ const deUint32 uint32ByteOffsetBits0To8 = 0;
+ const deUint32 uint32ByteOffsetBits8To32 = 1;
#else
- const deUint32 uint32ByteOffsetBits0To8 = 3; //!< least significant byte in the highest address
- const deUint32 uint32ByteOffset8To32 = 0;
+ const deUint32 uint24ByteOffsetBits0To8 = 2; //!< least significant byte in the highest address
+ const deUint32 uint24ByteOffsetBits8To24 = 0;
+ const deUint32 uint32ByteOffsetBits0To8 = 3;
+ const deUint32 uint32ByteOffsetBits8To32 = 0;
#endif
// Sampled channel must exist
// combined formats have multiple channel classes, detect on sampler settings
switch (baseAccess.getFormat().type)
{
+ case TextureFormat::FLOAT_UNSIGNED_INT_8:
+ {
+ if (mode == Sampler::MODE_DEPTH)
+ {
+ // select the float component
+ return AccessType(TextureFormat(TextureFormat::D, TextureFormat::FLOAT),
+ baseAccess.getSize(),
+ baseAccess.getPitch(),
+ baseAccess.getDataPtr());
+ }
+ else if (mode == Sampler::MODE_STENCIL)
+ {
+ // select the uint 8 component
+ return AccessType(TextureFormat(TextureFormat::S, TextureFormat::UNSIGNED_INT8),
+ baseAccess.getSize(),
+ baseAccess.getPitch(),
+ addOffset(baseAccess.getDataPtr(), 4));
+ }
+ else
+ {
+ // unknown sampler mode
+ DE_ASSERT(false);
+ return AccessType();
+ }
+ }
+
case TextureFormat::FLOAT_UNSIGNED_INT_24_8_REV:
{
if (mode == Sampler::MODE_DEPTH)
}
}
+ case TextureFormat::UNSIGNED_INT_16_8:
+ {
+ if (mode == Sampler::MODE_DEPTH)
+ {
+ // select the unorm16 component
+ return AccessType(TextureFormat(TextureFormat::D, TextureFormat::UNORM_INT16),
+ baseAccess.getSize(),
+ baseAccess.getPitch(),
+ addOffset(baseAccess.getDataPtr(), uint24ByteOffsetBits8To24));
+ }
+ else if (mode == Sampler::MODE_STENCIL)
+ {
+ // select the uint 8 component
+ return AccessType(TextureFormat(TextureFormat::S, TextureFormat::UNSIGNED_INT8),
+ baseAccess.getSize(),
+ baseAccess.getPitch(),
+ addOffset(baseAccess.getDataPtr(), uint24ByteOffsetBits0To8));
+ }
+ else
+ {
+ // unknown sampler mode
+ DE_ASSERT(false);
+ return AccessType();
+ }
+ }
+
case TextureFormat::UNSIGNED_INT_24_8:
{
if (mode == Sampler::MODE_DEPTH)
return AccessType(TextureFormat(TextureFormat::D, TextureFormat::UNORM_INT24),
baseAccess.getSize(),
baseAccess.getPitch(),
- addOffset(baseAccess.getDataPtr(), uint32ByteOffset8To32));
+ addOffset(baseAccess.getDataPtr(), uint32ByteOffsetBits8To32));
}
else if (mode == Sampler::MODE_STENCIL)
{