Adding packed small float pixel format
KTX supports packed small float pixel format, adding to DALi pixel format.
Modified texture upload to ensure the right internal format is used for
the destination texture, and the right method is chosen for uploading
cube map image.
Change-Id: I877ec5e5573c5f0482afc2b6c201ea8dda032cdc
Signed-off-by: David Steele <david.steele@samsung.com>
case Graphics::Format::R64G64B64A64_SINT:
case Graphics::Format::R64G64B64A64_SFLOAT:
case Graphics::Format::B10G11R11_UFLOAT_PACK32:
case Graphics::Format::R64G64B64A64_SINT:
case Graphics::Format::R64G64B64A64_SFLOAT:
case Graphics::Format::B10G11R11_UFLOAT_PACK32:
+ case Graphics::Format::R11G11B10_UFLOAT_PACK32:
case Graphics::Format::E5B9G9R9_UFLOAT_PACK32:
case Graphics::Format::D16_UNORM:
case Graphics::Format::X8_D24_UNORM_PACK32:
case Graphics::Format::E5B9G9R9_UFLOAT_PACK32:
case Graphics::Format::D16_UNORM:
case Graphics::Format::X8_D24_UNORM_PACK32:
+ case Graphics::Format::R11G11B10_UFLOAT_PACK32:
+ {
+ glFormat = GL_RGB;
+ pixelDataType = GL_FLOAT;
+ break;
+ }
case Graphics::Format::R4G4_UNORM_PACK8:
case Graphics::Format::A1R5G5B5_UNORM_PACK16:
case Graphics::Format::R4G4_UNORM_PACK8:
case Graphics::Format::A1R5G5B5_UNORM_PACK16:
{
case Graphics::Format::R16G16B16A16_SFLOAT:
case Graphics::Format::R32G32B32A32_SFLOAT:
{
case Graphics::Format::R16G16B16A16_SFLOAT:
case Graphics::Format::R32G32B32A32_SFLOAT:
+ case Graphics::Format::R11G11B10_UFLOAT_PACK32:
{
glInternalFormat = GL_R11F_G11F_B10F;
break;
{
glInternalFormat = GL_R11F_G11F_B10F;
break;
// GPU memory must be already allocated.
// Check if it needs conversion
// GPU memory must be already allocated.
// Check if it needs conversion
- auto* texture = static_cast<GLES::Texture*>(info.dstTexture);
- const auto& createInfo = texture->GetCreateInfo();
- auto srcFormat = GLES::GLTextureFormatType(info.srcFormat).format;
- auto destFormat = GLES::GLTextureFormatType(createInfo.format).format;
- auto destType = GLES::GLTextureFormatType(createInfo.format).type;
+ auto* texture = static_cast<GLES::Texture*>(info.dstTexture);
+ const auto& createInfo = texture->GetCreateInfo();
+ auto srcFormat = GLES::GLTextureFormatType(info.srcFormat).format;
+ auto srcType = GLES::GLTextureFormatType(info.srcFormat).type;
+ auto destInternalFormat = GLES::GLTextureFormatType(createInfo.format).internalFormat;
+ auto destFormat = GLES::GLTextureFormatType(createInfo.format).format;
// From render-texture.cpp
const bool isSubImage(info.dstOffset2D.x != 0 || info.dstOffset2D.y != 0 ||
// From render-texture.cpp
const bool isSubImage(info.dstOffset2D.x != 0 || info.dstOffset2D.y != 0 ||
// Convert RGB to RGBA if necessary.
texture->TryConvertPixelData(source.memorySource.memory, info.srcFormat, createInfo.format, info.srcSize, info.srcExtent2D.width, info.srcExtent2D.height, tempBuffer);
sourceBuffer = &tempBuffer[0];
// Convert RGB to RGBA if necessary.
texture->TryConvertPixelData(source.memorySource.memory, info.srcFormat, createInfo.format, info.srcSize, info.srcExtent2D.width, info.srcExtent2D.height, tempBuffer);
sourceBuffer = &tempBuffer[0];
+ srcFormat = destFormat;
+ srcType = GLES::GLTextureFormatType(createInfo.format).type;
}
// Calculate the maximum mipmap level for the texture
texture->SetMaxMipMapLevel(std::max(texture->GetMaxMipMapLevel(), info.level));
}
// Calculate the maximum mipmap level for the texture
texture->SetMaxMipMapLevel(std::max(texture->GetMaxMipMapLevel(), info.level));
- switch(createInfo.textureType)
- {
- // Texture 2D
- case Graphics::TextureType::TEXTURE_2D:
- {
- mGlAbstraction->PixelStorei(GL_UNPACK_ALIGNMENT, 1);
-
- mGlAbstraction->BindTexture(GL_TEXTURE_2D, texture->GetGLTexture());
-
- mGlAbstraction->TexSubImage2D(GL_TEXTURE_2D,
- info.level,
- info.dstOffset2D.x,
- info.dstOffset2D.y,
- info.srcExtent2D.width,
- info.srcExtent2D.height,
- destFormat,
- destType,
- sourceBuffer);
- break;
- }
- // Texture Cubemap
- case Graphics::TextureType::TEXTURE_CUBEMAP:
- {
- mGlAbstraction->PixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ GLenum bindTarget{GL_TEXTURE_2D};
+ GLenum target{GL_TEXTURE_2D};
- mGlAbstraction->BindTexture(GL_TEXTURE_CUBE_MAP, texture->GetGLTexture());
+ if(createInfo.textureType == Graphics::TextureType::TEXTURE_CUBEMAP)
+ {
+ bindTarget = GL_TEXTURE_CUBE_MAP;
+ target = GL_TEXTURE_CUBE_MAP_POSITIVE_X + info.layer;
+ }
- mGlAbstraction->TexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + info.layer,
- info.level,
- info.dstOffset2D.x,
- info.dstOffset2D.y,
- info.srcExtent2D.width,
- info.srcExtent2D.height,
- destFormat,
- destType,
- sourceBuffer);
+ mGlAbstraction->PixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ mGlAbstraction->BindTexture(bindTarget, texture->GetGLTexture());
- break;
- }
- default:
- {
- // nothing?
- }
+ if(!isSubImage)
+ {
+ mGlAbstraction->TexImage2D(target,
+ info.level,
+ destInternalFormat,
+ info.srcExtent2D.width,
+ info.srcExtent2D.height,
+ 0,
+ srcFormat,
+ srcType,
+ sourceBuffer);
+ }
+ else
+ {
+ mGlAbstraction->TexSubImage2D(target,
+ info.level,
+ info.dstOffset2D.x,
+ info.dstOffset2D.y,
+ info.srcExtent2D.width,
+ info.srcExtent2D.height,
+ srcFormat,
+ srcType,
+ sourceBuffer);
// free staging memory
free(source.memorySource.memory);
}
// free staging memory
free(source.memorySource.memory);
}
// Allocate memory for the texture
gl->TexImage2D(GL_TEXTURE_2D,
0,
// Allocate memory for the texture
gl->TexImage2D(GL_TEXTURE_2D,
0,
mCreateInfo.size.width,
mCreateInfo.size.height,
0,
mCreateInfo.size.width,
mCreateInfo.size.height,
0,
{
gl->TexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i,
0,
{
gl->TexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i,
0,
mCreateInfo.size.width,
mCreateInfo.size.height,
0,
mCreateInfo.size.width,
mCreateInfo.size.height,
0,
case Graphics::Format::R16G16B16_SFLOAT:
{
// GLES 3.0 floating point formats.
case Graphics::Format::R16G16B16_SFLOAT:
{
// GLES 3.0 floating point formats.
- Assign(GL_RGB, GL_HALF_FLOAT);
+ AssignInternal(GL_RGB, GL_R11F_G11F_B10F, GL_HALF_FLOAT); // DALi uses compact internal format
break;
}
case Graphics::Format::R16G16B16A16_UNORM:
break;
}
case Graphics::Format::R16G16B16A16_UNORM:
}
case Graphics::Format::R32G32B32_SFLOAT:
{
}
case Graphics::Format::R32G32B32_SFLOAT:
{
- // GLES 3.0 floating point formats.
- Assign(GL_RGB, GL_FLOAT);
+ AssignInternal(GL_RGB, GL_R11F_G11F_B10F, GL_FLOAT); // DALi uses compact internal format
break;
}
case Graphics::Format::R32G32B32A32_UINT:
break;
}
case Graphics::Format::R32G32B32A32_UINT:
+ case Graphics::Format::R11G11B10_UFLOAT_PACK32:
+ {
+ AssignInternal(GL_RGB, GL_R11F_G11F_B10F, GL_FLOAT);
+ break;
+ }
case Graphics::Format::B10G11R11_UFLOAT_PACK32:
{
Assign(0, 0);
case Graphics::Format::B10G11R11_UFLOAT_PACK32:
{
Assign(0, 0);
case Graphics::Format::D32_SFLOAT:
{
// GLES 3.0 depth and stencil formats
case Graphics::Format::D32_SFLOAT:
{
// GLES 3.0 depth and stencil formats
- Assign(GL_DEPTH_COMPONENT, GL_FLOAT);
+ AssignInternal(GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT32F, GL_FLOAT);
break;
}
case Graphics::Format::S8_UINT:
break;
}
case Graphics::Format::S8_UINT:
case Graphics::Format::D24_UNORM_S8_UINT:
{
// GLES 3.0 depth and stencil formats
case Graphics::Format::D24_UNORM_S8_UINT:
{
// GLES 3.0 depth and stencil formats
- Assign(GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8);
+ AssignInternal(GL_DEPTH_STENCIL, GL_DEPTH24_STENCIL8, GL_UNSIGNED_INT_24_8);
break;
}
case Graphics::Format::D32_SFLOAT_S8_UINT:
break;
}
case Graphics::Format::D32_SFLOAT_S8_UINT:
constexpr inline void Assign(uint32_t f, uint32_t t)
{
constexpr inline void Assign(uint32_t f, uint32_t t)
{
- format = f;
- type = t;
+ format = f;
+ internalFormat = f;
+ type = t;
+ }
+ constexpr inline void AssignInternal(uint32_t f, uint32_t i, uint32_t t)
+ {
+ format = f;
+ internalFormat = i;
+ type = t;
+ uint32_t internalFormat{0};
case Dali::Pixel::BGR8888:
case Dali::Pixel::RGB16F:
case Dali::Pixel::RGB32F:
case Dali::Pixel::BGR8888:
case Dali::Pixel::RGB16F:
case Dali::Pixel::RGB32F:
+ case Dali::Pixel::R11G11B10F:
{
return (channel == RED || channel == GREEN || channel == BLUE);
}
{
return (channel == RED || channel == GREEN || channel == BLUE);
}