Adding packed small float pixel format. 24/258224/4
authorDavid Steele <david.steele@samsung.com>
Wed, 12 May 2021 10:15:46 +0000 (11:15 +0100)
committerDavid Steele <david.steele@samsung.com>
Wed, 12 May 2021 13:26:14 +0000 (14:26 +0100)
KTX format supports GL_R11F_G11F_B10F format, we don't have a pixel
format definition for it.

Fixed pixel sizes for RGB16F and RGB32F

Change-Id: I7ca550bb61a7ced476970de38e721cac36ef4e1c
Signed-off-by: David Steele <david.steele@samsung.com>
automated-tests/src/dali/dali-test-suite-utils/test-graphics-texture.cpp
automated-tests/src/dali/utc-Dali-Pixel.cpp
automated-tests/src/dali/utc-Dali-Texture.cpp
dali/graphics-api/graphics-types.h
dali/integration-api/bitmap.cpp
dali/internal/render/renderers/render-texture.cpp
dali/public-api/images/pixel.cpp
dali/public-api/images/pixel.h

index adeeeca..9e1ad3e 100644 (file)
@@ -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;
index 3c57159..cd94b61 100644 (file)
@@ -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.
@@ -49,7 +49,7 @@ int UtcDaliPixelHasAlpha(void)
 
   tet_infoline("UtcDaliPixelHasAlpha");
 
-  TestPixelEnumSize(59);
+  TestPixelEnumSize(60);
 
   DALI_TEST_CHECK(Pixel::HasAlpha(Pixel::INVALID) == false); // For completeness
 
@@ -117,6 +117,8 @@ int UtcDaliPixelHasAlpha(void)
   DALI_TEST_CHECK(Pixel::HasAlpha(Pixel::DEPTH_FLOAT) == false);
   DALI_TEST_CHECK(Pixel::HasAlpha(Pixel::DEPTH_STENCIL) == false);
 
+  DALI_TEST_CHECK(Pixel::HasAlpha(Pixel::R11G11B10F) == false);
+
   END_TEST;
 }
 
@@ -133,7 +135,7 @@ int UtcDaliPixelGetBytesPerPixel(void)
   tet_infoline("UtcDaliPixelGetBytesPerPixel");
 
   // Be sure that the number of cases tested below is correct:
-  TestPixelEnumSize(59);
+  TestPixelEnumSize(60);
 
   DALI_TEST_CHECK(Pixel::GetBytesPerPixel(Pixel::INVALID) == 0); // For completeness
 
@@ -199,13 +201,13 @@ int UtcDaliPixelGetBytesPerPixel(void)
   DALI_TEST_CHECK(Pixel::GetBytesPerPixel(Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR) == 0);
   DALI_TEST_CHECK(Pixel::GetBytesPerPixel(Pixel::COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR) == 0);
 
-  DALI_TEST_CHECK(Pixel::GetBytesPerPixel(Pixel::RGB16F) == 12);
-  DALI_TEST_CHECK(Pixel::GetBytesPerPixel(Pixel::RGB32F) == 24);
+  DALI_TEST_CHECK(Pixel::GetBytesPerPixel(Pixel::RGB16F) == 6);
+  DALI_TEST_CHECK(Pixel::GetBytesPerPixel(Pixel::RGB32F) == 12);
 
   DALI_TEST_CHECK(Pixel::GetBytesPerPixel(Pixel::DEPTH_UNSIGNED_INT) == 4);
   DALI_TEST_CHECK(Pixel::GetBytesPerPixel(Pixel::DEPTH_FLOAT) == 4);
   DALI_TEST_CHECK(Pixel::GetBytesPerPixel(Pixel::DEPTH_STENCIL) == 4);
-
+  DALI_TEST_CHECK(Pixel::GetBytesPerPixel(Pixel::R11G11B10F) == 4);
   END_TEST;
 }
 
@@ -225,7 +227,7 @@ int UtcDaliPixelGetAlphaOffsetAndMaskP(void)
   int bitMask    = 0;
 
   // Be sure that the number of cases tested below is correct:
-  TestPixelEnumSize(59);
+  TestPixelEnumSize(60);
 
   Pixel::GetAlphaOffsetAndMask(Pixel::INVALID, byteOffset, bitMask); // For completeness
   DALI_TEST_CHECK(byteOffset == 0 && bitMask == 0);
@@ -352,6 +354,8 @@ int UtcDaliPixelGetAlphaOffsetAndMaskP(void)
   DALI_TEST_CHECK(byteOffset == 0 && bitMask == 0);
   Pixel::GetAlphaOffsetAndMask(Pixel::DEPTH_STENCIL, byteOffset, bitMask);
   DALI_TEST_CHECK(byteOffset == 0 && bitMask == 0);
+  Pixel::GetAlphaOffsetAndMask(Pixel::R11G11B10F, byteOffset, bitMask);
+  DALI_TEST_CHECK(byteOffset == 0 && bitMask == 0);
 
   END_TEST;
 }
@@ -372,6 +376,10 @@ int UtcDaliPixelConvertGlFormat(void)
   Dali::Integration::ConvertToGlFormat(Pixel::Format::DEPTH_STENCIL, pixelDataType, internalFormat);
   DALI_TEST_CHECK(pixelDataType == GL_UNSIGNED_INT_24_8);
   DALI_TEST_CHECK(internalFormat == GL_DEPTH_STENCIL);
+
+  Dali::Integration::ConvertToGlFormat(Pixel::Format::R11G11B10F, pixelDataType, internalFormat);
+  DALI_TEST_CHECK(pixelDataType == GL_FLOAT);
+  DALI_TEST_CHECK(internalFormat == GL_R11F_G11F_B10F);
   END_TEST;
 }
 
index b278b8c..810cc39 100644 (file)
@@ -681,11 +681,15 @@ int UtcDaliTextureUploadPixelFormats(void)
       Pixel::BGRA8888,
       Pixel::DEPTH_UNSIGNED_INT,
       Pixel::DEPTH_FLOAT,
-      Pixel::DEPTH_STENCIL};
+      Pixel::DEPTH_STENCIL,
+      Pixel::RGB16F,
+      Pixel::RGB32F,
+      Pixel::R11G11B10F,
+    };
 
   for(auto format : formats)
   {
-    tet_infoline("Creating a Texure with an alpha channel");
+    tet_infoline("Creating a Texure with a new or recent format");
     Texture texture = CreateTexture(TextureType::TEXTURE_2D, format, width, height);
 
     application.SendNotification();
index 31b358e..698a7be 100644 (file)
@@ -774,6 +774,7 @@ enum class Format
   R64G64B64A64_UINT,
   R64G64B64A64_SINT,
   R64G64B64A64_SFLOAT,
+  R11G11B10_UFLOAT_PACK32,
   B10G11R11_UFLOAT_PACK32,
   E5B9G9R9_UFLOAT_PACK32,
   D16_UNORM,
index dbebee5..5f6a013 100644 (file)
@@ -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.
@@ -422,6 +422,13 @@ void ConvertToGlFormat(Format pixelformat, unsigned& pixelDataType, unsigned& in
       internalFormat = GL_RGB;
       break;
     }
+    case R11G11B10F:
+    {
+      DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 GLES 3.0 floating point format.\n");
+      pixelDataType  = GL_FLOAT;
+      internalFormat = GL_R11F_G11F_B10F;
+      break;
+    }
 
     // GLES 3.0 depth and stencil formats
     case Pixel::DEPTH_UNSIGNED_INT:
index 1e74ce3..89366f6 100644 (file)
@@ -180,6 +180,8 @@ constexpr Graphics::Format ConvertPixelFormat(Pixel::Format format)
       return Graphics::Format::R16G16B16_SFLOAT;
     case Pixel::RGB32F:
       return Graphics::Format::R32G32B32_SFLOAT;
+    case Pixel::R11G11B10F:
+      return Graphics::Format::R11G11B10_UFLOAT_PACK32;
   }
   return Graphics::Format::UNDEFINED;
 }
index 38b962f..1571166 100644 (file)
@@ -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.
@@ -93,6 +93,7 @@ bool Pixel::HasAlpha(Format pixelformat)
     case DEPTH_UNSIGNED_INT:
     case DEPTH_FLOAT:
     case DEPTH_STENCIL:
+    case R11G11B10F:
     case INVALID:
     {
       return false;
@@ -134,18 +135,19 @@ uint32_t Pixel::GetBytesPerPixel(Format pixelFormat)
     case DEPTH_UNSIGNED_INT:
     case DEPTH_FLOAT:
     case DEPTH_STENCIL:
+    case R11G11B10F:
     {
       return 4;
     }
 
     case RGB16F:
     {
-      return 12;
+      return 6;
     }
 
     case RGB32F:
     {
-      return 24;
+      return 12;
     }
 
     case COMPRESSED_R11_EAC:
@@ -296,6 +298,7 @@ void Pixel::GetAlphaOffsetAndMask(Format pixelFormat, int& byteOffset, int& bitM
     case DEPTH_UNSIGNED_INT:
     case DEPTH_FLOAT:
     case DEPTH_STENCIL:
+    case R11G11B10F:
     case INVALID:
     {
       DALI_LOG_ERROR("Pixel formats are not compatible with simple masking-out of per-pixel alpha.\n");
index 5b1b9de..5c25141 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_PIXEL_H
 
 /*
- * 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.
@@ -117,7 +117,9 @@ enum Format
   DEPTH_UNSIGNED_INT, ///< Unsigned int depth format 32-bit. @SINCE_1_9.9
   DEPTH_FLOAT,        ///< Float depth format 32-bit. @SINCE_1_9.9
 
-  DEPTH_STENCIL ///< Depth stencil 32-bit, 24 bit for depth, 8 bit for stencil. @SINCE_1_9.9
+  DEPTH_STENCIL, ///< Depth stencil 32-bit, 24 bit for depth, 8 bit for stencil. @SINCE_1_9.9
+
+  R11G11B10F ///< Packed 32-bit, 11-11-10 unsigned floating point.
   ///! Update LAST_VALID_PIXEL_FORMAT below if you add an enum value here.
 };
 
@@ -133,7 +135,7 @@ const Format FIRST_VALID_PIXEL_FORMAT = A8;
  *
  * Sync it to the last value above.
  */
-const Format LAST_VALID_PIXEL_FORMAT = DEPTH_STENCIL;
+const Format LAST_VALID_PIXEL_FORMAT = R11G11B10F;
 
 /**
  * @brief Whether specified pixel format contains an alpha value.