Support for ASTC compressed textures wrapped in KTX files 77/54477/11
authorTom Robinson <tom.robinson@samsung.com>
Tue, 15 Dec 2015 11:29:44 +0000 (11:29 +0000)
committerTom Robinson <tom.robinson@samsung.com>
Fri, 8 Jan 2016 15:14:47 +0000 (07:14 -0800)
ASTC is supported by OpenGL ES 3.1 and above.
To build this patch with ASTC support, a GLES 31 context must be specified.

To build for desktop with configure, the gles version must be set to 31.
Here is an example configure line:
CXXFLAGS="-g -O0 -Wno-unused-local-typedefs" CXX="ccache g++" ./configure --prefix=$DESKTOP_PREFIX --enable-debug=yes --enable-profile=UBUNTU --enable-gles=31

With GBS, add the following to your gbs build line:
--define "%target_gles_version 31"

Change-Id: I376e55094e408c1b9081a3e86b81e7b3d64633bd

17 files changed:
README
adaptors/common/gl/egl-implementation.cpp
adaptors/common/gl/gl-implementation.h
automated-tests/images/frac-32x64.png [new file with mode: 0644]
automated-tests/images/fractal-compressed-ETC1_RGB8_OES-45x80.ktx [new file with mode: 0644]
automated-tests/images/fractal-compressed-R11_EAC-45x80.ktx [new file with mode: 0644]
automated-tests/images/fractal-compressed-RGB8_ETC2-45x80.ktx [new file with mode: 0644]
automated-tests/images/fractal-compressed-RGBA_ASTC_4x4_KHR-32x64.ktx [new file with mode: 0644]
automated-tests/images/fractal-compressed-RGB_PVRTC_4BPPV1_IMG-32x64.ktx [new file with mode: 0644]
automated-tests/images/fractal-compressed-SRBG8_ALPHA8_ASTC_4x4_KHR-32x64.ktx [new file with mode: 0644]
automated-tests/src/dali-adaptor-internal/CMakeLists.txt
automated-tests/src/dali-adaptor-internal/image-loaders.cpp
automated-tests/src/dali-adaptor-internal/image-loaders.h
automated-tests/src/dali-adaptor-internal/utc-Dali-CompressedTextures.cpp [new file with mode: 0644]
packaging/dali-adaptor.spec
platform-abstractions/tizen/image-loaders/loader-ktx.cpp
platform-abstractions/tizen/image-loaders/loader-ktx.h

diff --git a/README b/README
index 6cb641c..248c63a 100644 (file)
--- a/README
+++ b/README
@@ -5,7 +5,8 @@ T.O.C.
  2.   Building for Ubuntu desktop
  2.1. Minimum Requirements
  2.2. Building the Repository
- 2.3. Building and executing test cases
+ 2.3. Build target options
+ 2.4. Building and executing test cases
 
 
 
@@ -39,7 +40,22 @@ Then run the following commands:
  make install -j8
 
 
-2.3. Building and executing test cases
+2.3. Build target options
+-------------------------
+
+OpenGL ES context:
+
+When building, the OpenGL ES version of the target should be specified.
+
+Valid version options are 20, 30, 31
+
+With configure:
+Add: --enable-gles=X
+
+With gbs:
+Add to the gbs build line: --define "%target_gles_version X"
+
+2.4. Building and executing test cases
 --------------------------------------
 
 See the README.md in dali-adaptor/automated-tests.
index 0902442..57fd7c7 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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.
@@ -98,9 +98,9 @@ bool EglImplementation::InitializeGles( EGLNativeDisplayType display, bool isOwn
 
     mContextAttribs.Reserve(5);
     mContextAttribs.PushBack( EGL_CONTEXT_MAJOR_VERSION_KHR );
-    mContextAttribs.PushBack( 3 );
+    mContextAttribs.PushBack( DALI_GLES_VERSION / 10 );
     mContextAttribs.PushBack( EGL_CONTEXT_MINOR_VERSION_KHR );
-    mContextAttribs.PushBack( 0 );
+    mContextAttribs.PushBack( DALI_GLES_VERSION % 10 );
 
 #else // DALI_GLES_VERSION >= 30
 
index 3bccd22..452367e 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_INTERNAL_GL_IMPLEMENTATION_H__
 
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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.
@@ -23,7 +23,9 @@
 #error "OpenGL ES version not specified"
 #endif
 
-#if DALI_GLES_VERSION >= 30
+#if DALI_GLES_VERSION >= 31
+#include <GLES3/gl31.h>
+#elif DALI_GLES_VERSION >= 30
 #include <GLES3/gl3.h>
 #else
 #include <cstdlib>
diff --git a/automated-tests/images/frac-32x64.png b/automated-tests/images/frac-32x64.png
new file mode 100644 (file)
index 0000000..847b0d5
Binary files /dev/null and b/automated-tests/images/frac-32x64.png differ
diff --git a/automated-tests/images/fractal-compressed-ETC1_RGB8_OES-45x80.ktx b/automated-tests/images/fractal-compressed-ETC1_RGB8_OES-45x80.ktx
new file mode 100644 (file)
index 0000000..07256f5
Binary files /dev/null and b/automated-tests/images/fractal-compressed-ETC1_RGB8_OES-45x80.ktx differ
diff --git a/automated-tests/images/fractal-compressed-R11_EAC-45x80.ktx b/automated-tests/images/fractal-compressed-R11_EAC-45x80.ktx
new file mode 100644 (file)
index 0000000..980e57b
Binary files /dev/null and b/automated-tests/images/fractal-compressed-R11_EAC-45x80.ktx differ
diff --git a/automated-tests/images/fractal-compressed-RGB8_ETC2-45x80.ktx b/automated-tests/images/fractal-compressed-RGB8_ETC2-45x80.ktx
new file mode 100644 (file)
index 0000000..5824896
Binary files /dev/null and b/automated-tests/images/fractal-compressed-RGB8_ETC2-45x80.ktx differ
diff --git a/automated-tests/images/fractal-compressed-RGBA_ASTC_4x4_KHR-32x64.ktx b/automated-tests/images/fractal-compressed-RGBA_ASTC_4x4_KHR-32x64.ktx
new file mode 100644 (file)
index 0000000..27234b5
Binary files /dev/null and b/automated-tests/images/fractal-compressed-RGBA_ASTC_4x4_KHR-32x64.ktx differ
diff --git a/automated-tests/images/fractal-compressed-RGB_PVRTC_4BPPV1_IMG-32x64.ktx b/automated-tests/images/fractal-compressed-RGB_PVRTC_4BPPV1_IMG-32x64.ktx
new file mode 100644 (file)
index 0000000..a8b7e24
Binary files /dev/null and b/automated-tests/images/fractal-compressed-RGB_PVRTC_4BPPV1_IMG-32x64.ktx differ
diff --git a/automated-tests/images/fractal-compressed-SRBG8_ALPHA8_ASTC_4x4_KHR-32x64.ktx b/automated-tests/images/fractal-compressed-SRBG8_ALPHA8_ASTC_4x4_KHR-32x64.ktx
new file mode 100644 (file)
index 0000000..27234b5
Binary files /dev/null and b/automated-tests/images/fractal-compressed-SRBG8_ALPHA8_ASTC_4x4_KHR-32x64.ktx differ
index 99d4f39..e3df5d6 100644 (file)
@@ -7,6 +7,7 @@ SET(CAPI_LIB "dali-adaptor-internal")
 
 SET(TC_SOURCES
     utc-Dali-CommandLineOptions.cpp
+    utc-Dali-CompressedTextures.cpp
     utc-Dali-FontClient.cpp
     utc-Dali-GifLoader.cpp
     utc-Dali-ImageOperations.cpp
index 0c0efca..6b026f6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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.
@@ -92,7 +92,7 @@ LoadFunctions::LoadFunctions( LoadBitmapHeaderFunction _header, LoadBitmapFuncti
 {
 }
 
-void TestImageLoading( const ImageDetails& image, const LoadFunctions& functions )
+void TestImageLoading( const ImageDetails& image, const LoadFunctions& functions, Dali::Integration::Bitmap::Profile bitmapProfile )
 {
   FILE* fp = fopen( image.name.c_str() , "rb" );
   AutoCloseFile autoClose( fp );
@@ -111,10 +111,9 @@ void TestImageLoading( const ImageDetails& image, const LoadFunctions& functions
   fseek( fp, 0, 0 );
 
   // Create a bitmap object and store a pointer to that object so it is destroyed at the end.
-  Dali::Integration::Bitmap * bitmap = Dali::Integration::Bitmap::New( Dali::Integration::Bitmap::BITMAP_2D_PACKED_PIXELS,  ResourcePolicy::OWNED_RETAIN  );
+  Dali::Integration::Bitmap * bitmap = Dali::Integration::Bitmap::New( bitmapProfile, ResourcePolicy::OWNED_RETAIN  );
   Dali::Integration::BitmapPtr bitmapPtr( bitmap );
 
-
   // Load Bitmap and check its return values.
   DALI_TEST_CHECK( functions.loader( StubImageLoaderClient(), input, *bitmap ) );
   DALI_TEST_EQUALS( image.width,  bitmap->GetImageWidth(),  TEST_LOCATION );
index ffbb2b3..2385104 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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.
@@ -96,10 +96,11 @@ struct LoadFunctions
  * Use this method to test the header and and bitmap loading of each image.
  * The loaded bitmap is then checked with the reference bitmap in ImageDetails.
  *
- * @param[in]  image      The image details.
- * @param[in]  functions  The loader functions that need to be called.
+ * @param[in]  image         The image details.
+ * @param[in]  functions     The loader functions that need to be called.
+ * @param[in]  bitmapProfile Whether or not the bitmap is raw
  */
-void TestImageLoading( const ImageDetails& image, const LoadFunctions& functions );
+void TestImageLoading( const ImageDetails& image, const LoadFunctions& functions, Dali::Integration::Bitmap::Profile bitmapProfile = Dali::Integration::Bitmap::BITMAP_2D_PACKED_PIXELS );
 
 /**
  * Helper function which should be used when first creating a reference buffer file.
diff --git a/automated-tests/src/dali-adaptor-internal/utc-Dali-CompressedTextures.cpp b/automated-tests/src/dali-adaptor-internal/utc-Dali-CompressedTextures.cpp
new file mode 100644 (file)
index 0000000..6b7a616
--- /dev/null
@@ -0,0 +1,162 @@
+/*
+ * Copyright (c) 2016 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <iostream>
+#include <stdlib.h>
+#include <vector>
+#include <dali-test-suite-utils.h>
+#include "platform-abstractions/tizen/image-loaders/loader-ktx.h"
+
+// INTERNAL INCLUDES
+#include "image-loaders.h"
+
+using namespace Dali;
+
+/**
+ * This class encapsulates knowledge of testing compressed files.
+ * It requires a few input parameters per test to confirm if the file was read and understood.
+ * The fixture guarantees that each test performed is setup and closed individually, therefore run order does not matter.
+ */
+class KtxTestFixture
+{
+  public:
+
+    KtxTestFixture() {}
+    ~KtxTestFixture() {}
+
+    /**
+     * This struct contains any per-test parameters.
+     * This should be added to if more properties of a file/format should be tested.
+     */
+    struct TestEntry
+    {
+        std::string filename; ///< Name of the compressed texture KTX file to load.
+        int expectedWidth;    ///< The width the texture should be.
+        int expectedHeight;   ///< The height the KTX texture should be.
+
+        TestEntry( std::string newFilename, int newExpectedWidth, int newExpectedHeight )
+        : filename( newFilename ),
+          expectedWidth( newExpectedWidth ),
+          expectedHeight( newExpectedHeight )
+        {
+        }
+    };
+
+  private:
+
+    typedef std::vector< TestEntry > TestContainer;
+
+  public:
+
+    /**
+     * Adds a test to be performed.
+     * @param[in] testEntry A TestEntry struct containing all the details to perform one test.
+     */
+    void AddTest( TestEntry testEntry )
+    {
+        mTests.push_back( testEntry );
+    }
+
+    /**
+     * Runs all tests created with "AddTest".
+     * This will create failures upon failing tests.
+     */
+    void RunTests()
+    {
+      for( TestContainer::iterator testIterator = mTests.begin(); testIterator != mTests.end(); ++testIterator )
+      {
+        const TestEntry& currentTest = *testIterator;
+
+        RunTest( currentTest );
+      }
+    }
+
+  private:
+
+    /**
+     * Sets up, Runs and Closes-down an individual test.
+     * @param[in] testEntry A TestEntry struct containing all the details to perform one test.
+     */
+    void RunTest( const TestEntry& testEntry )
+    {
+      FILE* fileDescriptor = fopen( testEntry.filename.c_str(), "rb" );
+      AutoCloseFile autoClose( fileDescriptor );
+      DALI_TEST_CHECK( fileDescriptor != NULL );
+
+      // Check the header file.
+      unsigned int width( 0 ), height( 0 );
+      const Dali::TizenPlatform::ImageLoader::Input input( fileDescriptor );
+
+      DALI_TEST_CHECK( TizenPlatform::LoadKtxHeader( input, width, height ) );
+
+      DALI_TEST_EQUALS( width,  testEntry.expectedWidth,  TEST_LOCATION );
+      DALI_TEST_EQUALS( height, testEntry.expectedHeight, TEST_LOCATION );
+    }
+
+  private:
+
+    TestContainer mTests;    ///< Holds all tests to be run.
+
+};
+
+
+int UtcDaliKtxLoaderETC(void)
+{
+  KtxTestFixture fixture;
+
+  fixture.AddTest( KtxTestFixture::TestEntry( TEST_IMAGE_DIR "/fractal-compressed-ETC1_RGB8_OES-45x80.ktx", 45u, 80u ) );
+  fixture.AddTest( KtxTestFixture::TestEntry( TEST_IMAGE_DIR "/fractal-compressed-RGB8_ETC2-45x80.ktx", 45u, 80u ) );
+
+  fixture.RunTests();
+
+  END_TEST;
+}
+
+int UtcDaliKtxLoaderPVRTC(void)
+{
+  KtxTestFixture fixture;
+
+  fixture.AddTest( KtxTestFixture::TestEntry( TEST_IMAGE_DIR "/fractal-compressed-RGB_PVRTC_4BPPV1_IMG-32x64.ktx", 32u, 64u ) );
+
+  fixture.RunTests();
+
+  END_TEST;
+}
+
+int UtcDaliKtxLoaderEAC(void)
+{
+  KtxTestFixture fixture;
+
+  fixture.AddTest( KtxTestFixture::TestEntry( TEST_IMAGE_DIR "/fractal-compressed-R11_EAC-45x80.ktx", 45u, 80u ) );
+
+  fixture.RunTests();
+
+  END_TEST;
+}
+
+int UtcDaliKtxLoaderASTC(void)
+{
+  KtxTestFixture fixture;
+
+  fixture.AddTest( KtxTestFixture::TestEntry( TEST_IMAGE_DIR "/fractal-compressed-RGBA_ASTC_4x4_KHR-32x64.ktx", 32u, 64u ) );
+  fixture.AddTest( KtxTestFixture::TestEntry( TEST_IMAGE_DIR "/fractal-compressed-SRBG8_ALPHA8_ASTC_4x4_KHR-32x64.ktx", 32u, 64u ) );
+
+  fixture.RunTests();
+
+  END_TEST;
+}
index 2a59f0f..735cac7 100644 (file)
@@ -21,6 +21,10 @@ License:    Apache-2.0 and BSD-2-Clause and MIT
 URL:        https://review.tizen.org/git/?p=platform/core/uifw/dali-adaptor.git;a=summary
 Source0:    %{name}-%{version}.tar.gz
 
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+Requires:       giflib
+
 # Get the profile from tizen_profile_name if it exists.
 %if 0%{?tizen_profile_name:1}
 %define profile %{tizen_profile_name}
@@ -30,18 +34,24 @@ Source0:    %{name}-%{version}.tar.gz
 %define dali_profile MOBILE
 %define dali_feedback_plugin 0
 %define shaderbincache_flag DISABLE
+BuildRequires:  pkgconfig(gles20)
+%define gles_requirement_setup 1
 %endif
 
 %if "%{profile}" == "tv"
 %define dali_profile TV
 %define dali_feedback_plugin 0
 %define shaderbincache_flag ENABLE
+BuildRequires:  pkgconfig(glesv2)
+%define gles_requirement_setup 1
 %endif
 
 %if "%{profile}" == "wearable"
 %define dali_profile WEARABLE
 %define dali_feedback_plugin 0
 %define shaderbincache_flag DISABLE
+BuildRequires:  pkgconfig(gles20)
+%define gles_requirement_setup 1
 %endif
 
 %if "%{profile}" == "common"
@@ -49,14 +59,16 @@ Source0:    %{name}-%{version}.tar.gz
 %define dali_feedback_plugin 0
 %define tizen_2_2_compatibility 1
 %define shaderbincache_flag DISABLE
+BuildRequires:  pkgconfig(glesv2)
+%define gles_requirement_setup 1
 %endif
 
+# If we have not set a BuildRequires for the gles version, default it here.
+%{!?gles_requirement_setup: BuildRequires:  pkgconfig(glesv2)}
+
 # macro is enabled by passing gbs build --define "with_libuv 1"
 %define build_with_libuv 0%{?with_libuv:1}
 
-Requires(post): /sbin/ldconfig
-Requires(postun): /sbin/ldconfig
-Requires:       giflib
 BuildRequires:  pkgconfig
 BuildRequires:  gawk
 BuildRequires:  pkgconfig(sensor)
@@ -72,13 +84,11 @@ BuildRequires:  pkgconfig(dlog)
 BuildRequires:  libdrm-devel
 BuildRequires:  pkgconfig(libexif)
 BuildRequires:  pkgconfig(libpng)
-BuildRequires:  pkgconfig(glesv2)
+BuildRequires:  pkgconfig(egl)
 BuildRequires:  libcurl-devel
 BuildRequires:  pkgconfig(harfbuzz)
-
 BuildRequires:  fribidi-devel
 
-
 %if 0%{?tizen_2_2_compatibility} != 1
 BuildRequires:  pkgconfig(capi-system-info)
 %endif
@@ -90,7 +100,6 @@ BuildRequires:  nodejs-devel
 %endif
 
 
-
 %define dali_needs_efl_libraries 1
 %define dali_needs_appfw_libraries 1
 %if %{with wayland}
@@ -143,8 +152,6 @@ BuildRequires:  pkgconfig(capi-system-info)
 
 
 
-
-
 %description
 The DALi Tizen Adaptor provides a Tizen specific implementation of the dali-core
 platform abstraction and application shell
@@ -238,7 +245,11 @@ FONT_DOWNLOADED_PATH="%{font_downloaded_path}" ; export FONT_DOWNLOADED_PATH
 FONT_APPLICATION_PATH="%{font_application_path}"  ; export FONT_APPLICATION_PATH
 FONT_CONFIGURATION_FILE="%{font_configuration_file}" ; export FONT_CONFIGURATION_FILE
 
-%configure --prefix=$PREFIX --with-jpeg-turbo --enable-gles=20 --enable-shaderbincache=%{shaderbincache_flag} --enable-profile=%{dali_profile} \
+# Default to GLES 2.0 if not specified.
+%{!?target_gles_version: %define target_gles_version 20}
+
+# Set up the build via configure.
+%configure --prefix=$PREFIX --with-jpeg-turbo --enable-gles=%{target_gles_version} --enable-shaderbincache=%{shaderbincache_flag} --enable-profile=%{dali_profile} \
 %if 0%{?dali_feedback_plugin}
            --enable-feedback \
 %endif
@@ -260,6 +271,7 @@ FONT_CONFIGURATION_FILE="%{font_configuration_file}" ; export FONT_CONFIGURATION
 %endif
            $configure_flags --libdir=%{_libdir}
 
+# Build.
 make %{?jobs:-j%jobs}
 
 ##############################
index ca58304..766eefe 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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.
  *
  */
 
+// CLASS HEADER
 #include "loader-ktx.h"
 
+// EXTERNAL INCLUDES
 #include <cstdio>
 #include <cstdlib>
 #include <cstring>
@@ -51,6 +53,7 @@ const Byte FileIdentifier[] = {
    0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A
 };
 
+
 /** The formats we support inside a KTX file container.
  *  Currently only compressed formats are allowed as we'd rather
  *  use a PNG or JPEG with their own compression for the general
@@ -58,6 +61,11 @@ const Byte FileIdentifier[] = {
 enum KtxInternalFormat
 {
   KTX_NOTEXIST = 0,
+
+  // GLES 2 Extension formats:
+  KTX_ETC1_RGB8_OES                               = 0x8D64,
+  KTX_COMPRESSED_RGB_PVRTC_4BPPV1_IMG             = 0x8C00,
+
   // GLES 3 Standard compressed formats (values same as in gl3.h):
   KTX_COMPRESSED_R11_EAC                          = 0x9270,
   KTX_COMPRESSED_SIGNED_R11_EAC                   = 0x9271,
@@ -70,14 +78,45 @@ enum KtxInternalFormat
   KTX_COMPRESSED_RGBA8_ETC2_EAC                   = 0x9278,
   KTX_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC            = 0x9279,
 
-  // GLES 2 EXTENSION FORMATS:
-  KTX_ETC1_RGB8_OES                               = 0x8D64,
-  KTX_COMPRESSED_RGB_PVRTC_4BPPV1_IMG             = 0x8C00,
-  KTX_SENTINEL = ~0u,
+  // GLES 3.1 compressed formats:
+  KTX_COMPRESSED_RGBA_ASTC_4x4_KHR                = 0x93B0,
+  KTX_COMPRESSED_RGBA_ASTC_5x4_KHR                = 0x93B1,
+  KTX_COMPRESSED_RGBA_ASTC_5x5_KHR                = 0x93B2,
+  KTX_COMPRESSED_RGBA_ASTC_6x5_KHR                = 0x93B3,
+  KTX_COMPRESSED_RGBA_ASTC_6x6_KHR                = 0x93B4,
+  KTX_COMPRESSED_RGBA_ASTC_8x5_KHR                = 0x93B5,
+  KTX_COMPRESSED_RGBA_ASTC_8x6_KHR                = 0x93B6,
+  KTX_COMPRESSED_RGBA_ASTC_8x8_KHR                = 0x93B7,
+  KTX_COMPRESSED_RGBA_ASTC_10x5_KHR               = 0x93B8,
+  KTX_COMPRESSED_RGBA_ASTC_10x6_KHR               = 0x93B9,
+  KTX_COMPRESSED_RGBA_ASTC_10x8_KHR               = 0x93BA,
+  KTX_COMPRESSED_RGBA_ASTC_10x10_KHR              = 0x93BB,
+  KTX_COMPRESSED_RGBA_ASTC_12x10_KHR              = 0x93BC,
+  KTX_COMPRESSED_RGBA_ASTC_12x12_KHR              = 0x93BD,
+  KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR        = 0x93D0,
+  KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR        = 0x93D1,
+  KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR        = 0x93D2,
+  KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR        = 0x93D3,
+  KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR        = 0x93D4,
+  KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR        = 0x93D5,
+  KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR        = 0x93D6,
+  KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR        = 0x93D7,
+  KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR       = 0x93D8,
+  KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR       = 0x93D9,
+  KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR       = 0x93DA,
+  KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR      = 0x93DB,
+  KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR      = 0x93DC,
+  KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR      = 0x93DD,
+
+  KTX_SENTINEL = ~0u
 };
 
 const unsigned KtxInternalFormats[] =
 {
+  // GLES 2 Extension formats:
+  KTX_ETC1_RGB8_OES,
+  KTX_COMPRESSED_RGB_PVRTC_4BPPV1_IMG,
+
   // GLES 3 Standard compressed formats:
   KTX_COMPRESSED_R11_EAC,
   KTX_COMPRESSED_SIGNED_R11_EAC,
@@ -89,9 +128,37 @@ const unsigned KtxInternalFormats[] =
   KTX_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,
   KTX_COMPRESSED_RGBA8_ETC2_EAC,
   KTX_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,
-  // GLES 2 EXTENSION FORMATS:
-  KTX_ETC1_RGB8_OES,
-  KTX_COMPRESSED_RGB_PVRTC_4BPPV1_IMG,
+
+  // GLES 3.1 Compressed formats:
+  KTX_COMPRESSED_RGBA_ASTC_4x4_KHR,
+  KTX_COMPRESSED_RGBA_ASTC_5x4_KHR,
+  KTX_COMPRESSED_RGBA_ASTC_5x5_KHR,
+  KTX_COMPRESSED_RGBA_ASTC_6x5_KHR,
+  KTX_COMPRESSED_RGBA_ASTC_6x6_KHR,
+  KTX_COMPRESSED_RGBA_ASTC_8x5_KHR,
+  KTX_COMPRESSED_RGBA_ASTC_8x6_KHR,
+  KTX_COMPRESSED_RGBA_ASTC_8x8_KHR,
+  KTX_COMPRESSED_RGBA_ASTC_10x5_KHR,
+  KTX_COMPRESSED_RGBA_ASTC_10x6_KHR,
+  KTX_COMPRESSED_RGBA_ASTC_10x8_KHR,
+  KTX_COMPRESSED_RGBA_ASTC_10x10_KHR,
+  KTX_COMPRESSED_RGBA_ASTC_12x10_KHR,
+  KTX_COMPRESSED_RGBA_ASTC_12x12_KHR,
+  KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,
+  KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,
+  KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,
+  KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,
+  KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,
+  KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,
+  KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,
+  KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,
+  KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,
+  KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,
+  KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,
+  KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,
+  KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,
+  KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR,
+
   KTX_SENTINEL
 };
 
@@ -173,9 +240,22 @@ bool ConvertPixelFormat(const uint32_t ktxPixelFormat, Dali::Pixel::Format& form
   using namespace Dali::Pixel;
   switch(ktxPixelFormat)
   {
+    // GLES 2 extension compressed formats:
+    case KTX_ETC1_RGB8_OES:
+    {
+      format = COMPRESSED_RGB8_ETC1;
+      break;
+    }
+    case KTX_COMPRESSED_RGB_PVRTC_4BPPV1_IMG:
+    {
+      format = COMPRESSED_RGB_PVRTC_4BPPV1;
+      break;
+    }
+
+    // GLES 3 extension compressed formats:
     case KTX_COMPRESSED_R11_EAC:
     {
-      format = Dali::Pixel::COMPRESSED_R11_EAC;
+      format = COMPRESSED_R11_EAC;
       break;
     }
     case KTX_COMPRESSED_SIGNED_R11_EAC:
@@ -223,15 +303,146 @@ bool ConvertPixelFormat(const uint32_t ktxPixelFormat, Dali::Pixel::Format& form
       format = COMPRESSED_SRGB8_ALPHA8_ETC2_EAC;
       break;
     }
-    // GLES 2 extension compressed formats:
-    case KTX_ETC1_RGB8_OES:
+
+    // GLES 3.1 extension compressed formats:
+    case KTX_COMPRESSED_RGBA_ASTC_4x4_KHR:
     {
-      format = COMPRESSED_RGB8_ETC1;
+      format = COMPRESSED_RGBA_ASTC_4x4_KHR;
       break;
     }
-    case KTX_COMPRESSED_RGB_PVRTC_4BPPV1_IMG:
+    case KTX_COMPRESSED_RGBA_ASTC_5x4_KHR:
     {
-      format = COMPRESSED_RGB_PVRTC_4BPPV1;
+      format = COMPRESSED_RGBA_ASTC_5x4_KHR;
+      break;
+    }
+    case KTX_COMPRESSED_RGBA_ASTC_5x5_KHR:
+    {
+      format = COMPRESSED_RGBA_ASTC_5x5_KHR;
+      break;
+    }
+    case KTX_COMPRESSED_RGBA_ASTC_6x5_KHR:
+    {
+      format = COMPRESSED_RGBA_ASTC_6x5_KHR;
+      break;
+    }
+    case KTX_COMPRESSED_RGBA_ASTC_6x6_KHR:
+    {
+      format = COMPRESSED_RGBA_ASTC_6x6_KHR;
+      break;
+    }
+    case KTX_COMPRESSED_RGBA_ASTC_8x5_KHR:
+    {
+      format = COMPRESSED_RGBA_ASTC_8x5_KHR;
+      break;
+    }
+    case KTX_COMPRESSED_RGBA_ASTC_8x6_KHR:
+    {
+      format = COMPRESSED_RGBA_ASTC_8x6_KHR;
+      break;
+    }
+    case KTX_COMPRESSED_RGBA_ASTC_8x8_KHR:
+    {
+      format = COMPRESSED_RGBA_ASTC_8x8_KHR;
+      break;
+    }
+    case KTX_COMPRESSED_RGBA_ASTC_10x5_KHR:
+    {
+      format = COMPRESSED_RGBA_ASTC_10x5_KHR;
+      break;
+    }
+    case KTX_COMPRESSED_RGBA_ASTC_10x6_KHR:
+    {
+      format = COMPRESSED_RGBA_ASTC_10x6_KHR;
+      break;
+    }
+    case KTX_COMPRESSED_RGBA_ASTC_10x8_KHR:
+    {
+      format = COMPRESSED_RGBA_ASTC_10x8_KHR;
+      break;
+    }
+    case KTX_COMPRESSED_RGBA_ASTC_10x10_KHR:
+    {
+      format = COMPRESSED_RGBA_ASTC_10x10_KHR;
+      break;
+    }
+    case KTX_COMPRESSED_RGBA_ASTC_12x10_KHR:
+    {
+      format = COMPRESSED_RGBA_ASTC_12x10_KHR;
+      break;
+    }
+    case KTX_COMPRESSED_RGBA_ASTC_12x12_KHR:
+    {
+      format = COMPRESSED_RGBA_ASTC_12x12_KHR;
+      break;
+    }
+    case KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:
+    {
+      format = COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR;
+      break;
+    }
+    case KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:
+    {
+      format = COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR;
+      break;
+    }
+    case KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:
+    {
+      format = COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR;
+      break;
+    }
+    case KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:
+    {
+      format = COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR;
+      break;
+    }
+    case KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:
+    {
+      format = COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR;
+      break;
+    }
+    case KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:
+    {
+      format = COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR;
+      break;
+    }
+    case KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:
+    {
+      format = COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR;
+      break;
+    }
+    case KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:
+    {
+      format = COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR;
+      break;
+    }
+    case KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:
+    {
+      format = COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR;
+      break;
+    }
+    case KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:
+    {
+      format = COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR;
+      break;
+    }
+    case KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:
+    {
+      format = COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR;
+      break;
+    }
+    case KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:
+    {
+      format = COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR;
+      break;
+    }
+    case KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:
+    {
+      format = COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR;
+      break;
+    }
+    case KTX_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:
+    {
+      format = COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR;
       break;
     }
 
index c521ad2..1728f81 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_TIZEN_PLATFORM_LOADER_KTX_H__
 
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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.