Bug 1205168 - Part 4: Texel Conversion - RG32F format. r=jgilbert

This commit is contained in:
Dan Glastonbury 2015-12-22 22:01:00 +01:00
parent c260e2ebb8
commit eb973f8e9f
3 changed files with 33 additions and 4 deletions

View File

@ -55,6 +55,7 @@ class WebGLImageConverter
case WebGLTexelFormat::RA32F:
case WebGLTexelFormat::RG8:
case WebGLTexelFormat::RG16F:
case WebGLTexelFormat::RG32F:
return 2;
case WebGLTexelFormat::RGB8:
case WebGLTexelFormat::RGB16F:
@ -261,6 +262,7 @@ class WebGLImageConverter
WEBGLIMAGECONVERTER_CASE_DSTFORMAT(WebGLTexelFormat::RA32F)
WEBGLIMAGECONVERTER_CASE_DSTFORMAT(WebGLTexelFormat::RG8)
WEBGLIMAGECONVERTER_CASE_DSTFORMAT(WebGLTexelFormat::RG16F)
WEBGLIMAGECONVERTER_CASE_DSTFORMAT(WebGLTexelFormat::RG32F)
// 3-channel formats
WEBGLIMAGECONVERTER_CASE_DSTFORMAT(WebGLTexelFormat::RGB565)
WEBGLIMAGECONVERTER_CASE_DSTFORMAT(WebGLTexelFormat::RGB8)

View File

@ -167,10 +167,11 @@ template<WebGLTexelFormat Format>
struct IsFloatFormat
{
static const bool Value =
Format == WebGLTexelFormat::A32F ||
Format == WebGLTexelFormat::R32F ||
Format == WebGLTexelFormat::RA32F ||
Format == WebGLTexelFormat::RGB32F ||
Format == WebGLTexelFormat::A32F ||
Format == WebGLTexelFormat::R32F ||
Format == WebGLTexelFormat::RA32F ||
Format == WebGLTexelFormat::RG32F ||
Format == WebGLTexelFormat::RGB32F ||
Format == WebGLTexelFormat::RGBA32F;
};
@ -293,6 +294,7 @@ inline size_t TexelBytesForFormat(WebGLTexelFormat format) {
case WebGLTexelFormat::RGB16F:
return 6;
case WebGLTexelFormat::RA32F:
case WebGLTexelFormat::RG32F:
case WebGLTexelFormat::RGBA16F:
return 8;
case WebGLTexelFormat::RGB32F:
@ -329,6 +331,7 @@ MOZ_ALWAYS_INLINE bool HasColor(WebGLTexelFormat format) {
format == WebGLTexelFormat::RA32F ||
format == WebGLTexelFormat::RG8 ||
format == WebGLTexelFormat::RG16F ||
format == WebGLTexelFormat::RG32F ||
format == WebGLTexelFormat::RGB565 ||
format == WebGLTexelFormat::RGB8 ||
format == WebGLTexelFormat::RGB16F ||
@ -822,6 +825,29 @@ pack<WebGLTexelFormat::RG16F, WebGLTexelPremultiplicationOp::Unpremultiply, uint
dst[1] = packToFloat16(unpackFromFloat16(src[1]) * scaleFactor);
}
template<> MOZ_ALWAYS_INLINE void
pack<WebGLTexelFormat::RG32F, WebGLTexelPremultiplicationOp::None, float, float>(const float* __restrict src, float* __restrict dst)
{
dst[0] = src[0];
dst[1] = src[1];
}
template<> MOZ_ALWAYS_INLINE void
pack<WebGLTexelFormat::RG32F, WebGLTexelPremultiplicationOp::Premultiply, float, float>(const float* __restrict src, float* __restrict dst)
{
float scaleFactor = src[3];
dst[0] = src[0] * scaleFactor;
dst[1] = src[1] * scaleFactor;
}
template<> MOZ_ALWAYS_INLINE void
pack<WebGLTexelFormat::RG32F, WebGLTexelPremultiplicationOp::Unpremultiply, float, float>(const float* __restrict src, float* __restrict dst)
{
float scaleFactor = src[3] ? 1.0f / src[3] : 1.0f;
dst[0] = src[0] * scaleFactor;
dst[1] = src[1] * scaleFactor;
}
////////////////////////////////////////////////////////////////////////////////
// 3-channel formats
template<> MOZ_ALWAYS_INLINE void

View File

@ -102,6 +102,7 @@ enum class WebGLTexelFormat : uint8_t {
RA32F, // OES_texture_float
RG8,
RG16F,
RG32F,
// 3-channel formats
RGB8,
RGB565,