From: David Steele Date: Wed, 12 May 2021 10:35:01 +0000 (+0100) Subject: Added pixel format to fix bug with ktx loader X-Git-Tag: dali_2.0.28~3^2~3^2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=4f25cf329f0fb1be2d3aafd7887ca5a2cf263460 Added pixel format to fix bug with ktx loader KTX loader allows GL packed small float format, currently uses wrong float format when storing pixel data. Change-Id: I85798fe3b62fb0a78589e045bc5f265ff591f6a6 Signed-off-by: David Steele --- diff --git a/automated-tests/resources/papermill_E_diffuse-64.ktx b/automated-tests/resources/papermill_E_diffuse-64.ktx new file mode 100644 index 0000000..c000b61 Binary files /dev/null and b/automated-tests/resources/papermill_E_diffuse-64.ktx differ diff --git a/automated-tests/src/dali-scene-loader/utc-Dali-KtxLoader.cpp b/automated-tests/src/dali-scene-loader/utc-Dali-KtxLoader.cpp index 15d6b58..783745d 100644 --- a/automated-tests/src/dali-scene-loader/utc-Dali-KtxLoader.cpp +++ b/automated-tests/src/dali-scene-loader/utc-Dali-KtxLoader.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -146,3 +146,20 @@ int UtcDaliKtxLoaderCubeDataCreateTexture2(void) END_TEST; } + +int UtcDaliKtxLoaderCubeDataCreateTexture3(void) +{ + CubeData cubeData; + auto path = TEST_RESOURCE_DIR "/papermill_E_diffuse-64.ktx"; + DALI_TEST_CHECK(LoadCubeMapData(path, cubeData)); + + TestApplication app; + auto texture = cubeData.CreateTexture(); + + DALI_TEST_CHECK(texture); + DALI_TEST_EQUAL(64u, texture.GetWidth()); + DALI_TEST_EQUAL(64u, texture.GetHeight()); + + END_TEST; + +} diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-texture.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-texture.cpp index adeeeca..9e1ad3e 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-texture.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-texture.cpp @@ -183,6 +183,7 @@ bool IsCompressedFormat(Graphics::Format pixelFormat) 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: @@ -618,6 +619,12 @@ void PixelFormatToGl(Graphics::Format pixelFormat, GLenum& glFormat, GLint& glIn glFormat = 0; break; } + 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: @@ -768,6 +775,7 @@ void PixelFormatToGl(Graphics::Format pixelFormat, GLenum& glFormat, GLint& glIn { case Graphics::Format::R16G16B16A16_SFLOAT: case Graphics::Format::R32G32B32A32_SFLOAT: + case Graphics::Format::R11G11B10_UFLOAT_PACK32: { glInternalFormat = GL_R11F_G11F_B10F; break; diff --git a/dali-scene-loader/public-api/ktx-loader.cpp b/dali-scene-loader/public-api/ktx-loader.cpp index 147b3fd..857163d 100644 --- a/dali-scene-loader/public-api/ktx-loader.cpp +++ b/dali-scene-loader/public-api/ktx-loader.cpp @@ -161,7 +161,7 @@ bool ConvertPixelFormat(const uint32_t ktxPixelFormat, Pixel::Format& format) } case 0x8C3A: // GL_R11F_G11F_B10F { - format = Pixel::RGB32F; + format = Pixel::R11G11B10F; break; } case 0x8D7C: // GL_RGBA8UI diff --git a/dali-toolkit/devel-api/utility/npatch-utilities.cpp b/dali-toolkit/devel-api/utility/npatch-utilities.cpp index 7f462f6..78a6268 100644 --- a/dali-toolkit/devel-api/utility/npatch-utilities.cpp +++ b/dali-toolkit/devel-api/utility/npatch-utilities.cpp @@ -1,5 +1,5 @@ /* -* Copyright (c) 2020 Samsung Electronics Co., Ltd. +* Copyright (c) 2021 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -175,6 +175,7 @@ void GetRedOffsetAndMask(Dali::Pixel::Format pixelFormat, int32_t& byteOffset, i case Dali::Pixel::DEPTH_UNSIGNED_INT: case Dali::Pixel::DEPTH_FLOAT: case Dali::Pixel::DEPTH_STENCIL: + case Dali::Pixel::R11G11B10F: { DALI_LOG_ERROR("Pixel format not compatible.\n"); byteOffset = 0;