diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000000..882446e74b --- /dev/null +++ b/.clang-format @@ -0,0 +1,12 @@ +# Copyright 2024 The Khronos Group Inc. +# SPDX-License-Identifier: Apache-2.0 +--- +# Use defaults from the Google style with the following exceptions: +Language: Cpp +BasedOnStyle: Google +IndentWidth: 4 +IndentCaseLabels: false +AccessModifierOffset: -2 +ColumnLimit: 132 +SortIncludes: false +... diff --git a/.github/workflows/formatting.yml b/.github/workflows/formatting.yml new file mode 100644 index 0000000000..783a9b7673 --- /dev/null +++ b/.github/workflows/formatting.yml @@ -0,0 +1,39 @@ +# Copyright 2024 The Khronos Group Inc. +# Copyright 2024 RasterGrid Kft. +# SPDX-License-Identifier: Apache-2.0 +name: Formatting + +on: + # Trigger the workflow on a pull request, + pull_request: + + push: + # And on pushes to main, which will occur when a PR is merged. + branches: + - main + # Also trigger on push of release tags to any branch. Useful + # for testing release builds before merging to main. + tags: + - 'v[0-9]+.[0-9]+.[0-9]+' + - 'v[0-9]+.[0-9]+.[0-9]+-*' + paths-ignore: + - .appveyor.yml + - .travis.yml + +permissions: + contents: read + +jobs: + clang-format: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Run clang-format + uses: HorstBaerbel/action-clang-format@1.5 + + clang-tidy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Run clang-tidy + uses: HorstBaerbel/action-clang-tidy@1.2 diff --git a/.gitignore b/.gitignore index e26a0c5b00..26958c4291 100644 --- a/.gitignore +++ b/.gitignore @@ -13,13 +13,12 @@ # /include/ /include/imdebug.h -# /lib/ -/lib/astc-encoder/.gitmodules -/lib/astc-encoder/Source/GoogleTest -/lib/basisu/bin_osx -/lib/basisu/bin -/lib/basisu/build -/lib/src +# /external/ +/external/astc-encoder/.gitmodules +/external/astc-encoder/Source/GoogleTest +/external/basisu/bin_osx +/external/basisu/bin +/external/basisu/build # /testimages/ /testimages/*.png diff --git a/.reuse/dep5 b/.reuse/dep5 index 3e42ee118e..a23558d88c 100644 --- a/.reuse/dep5 +++ b/.reuse/dep5 @@ -70,36 +70,36 @@ Files: */*.json Copyright: 2017-2020 Mark Callow License: Apache-2.0 -Files: lib/astc-encoder/Docs/* lib/astc-encoder/Test/* lib/astc-encoder/jenkins/* lib/astc-encoder/.gitattributes lib/astc-encoder/.gitignore lib/astc-encoder/.gitmodules lib/astc-encoder/.pylintrc lib/astc-encoder/README.md lib/astc-encoder/Utils/Example/README.md +Files: external/astc-encoder/Docs/* external/astc-encoder/Test/* external/astc-encoder/jenkins/* external/astc-encoder/.gitattributes external/astc-encoder/.gitignore external/astc-encoder/.gitmodules external/astc-encoder/.pylintrc external/astc-encoder/README.md external/astc-encoder/Utils/Example/README.md Copyright: 2020-2021 Arm Limited License: Apache-2.0 -Files: lib/astc-encoder/.gitrepo +Files: external/astc-encoder/.gitrepo Copyright: 2021 Mark Callow License: Apache-2.0 -Files: lib/astc-encoder/Source/stb_image*.h +Files: external/astc-encoder/Source/stb_image*.h Copyright: 2017 Sean Barrett License: MIT -Files: lib/astc-encoder/Source/tinyexr.h +Files: external/astc-encoder/Source/tinyexr.h Copyright: 2014-2019 Syoyo Fujita and many contributors License: BSD-3-Clause -Files: lib/astc-encoder/Source/wuffs-v0.3.c +Files: external/astc-encoder/Source/wuffs-v0.3.c Copyright: 2022 The Wuffs Authors. License: Apache-2.0 # We have asked Binomial about REUSE compliance for their repo, see https://github.com/BinomialLLC/basis_universal/issues/165 -Files: lib/basisu/* +Files: external/basisu/* Copyright: 2019-2020 Binomial LLC License: Apache-2.0 -Files: lib/basisu/apg_bmp.* lib/basisu/CMakeLists.txt lib/basisu/webgl/transcoder/CMakeLists.txt +Files: external/basisu/apg_bmp.* external/basisu/CMakeLists.txt external/basisu/webgl/transcoder/CMakeLists.txt Copyright: 2019 Anton Gerdelan License: Apache-2.0 -Files: lib/basisu/basisu_astc_decomp.* +Files: external/basisu/basisu_astc_decomp.* Copyright: 2016 The Android Open Source Project License: Apache-2.0 @@ -107,11 +107,11 @@ Files: tools/imageio/png.imageio/lodepng.* Copyright: 2005-2019 Lode Vandevenne License: Zlib -Files: lib/dfdutils/vulkan/* +Files: external/dfdutils/vulkan/* Copyright: 2015-2020 The Khronos Group Inc. License: Apache-2.0 -Files: lib/dfdutils/.gitrepo +Files: external/dfdutils/.gitrepo Copyright: 2019-2020 The Khronos Group Inc License: Apache-2.0 @@ -201,10 +201,10 @@ Files: the_khronos_group_inc.p12.enc Copyright: 2022 The Khronos Group Inc. License: Apache-2.0 -Files: other_projects/fmt/* +Files: external/fmt/* Copyright: 2012 - present Victor Zverovich License: MIT -Files: other_projects/cxxopts/* +Files: external/cxxopts/* Copyright: 2014-2022 Jarryd Beck License: MIT diff --git a/CMakeLists.txt b/CMakeLists.txt index 07e30d63b8..a1703e9e4a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -101,12 +101,12 @@ endif() if(BASISU_SUPPORT_OPENCL AND WIN32 AND NOT OpenCL_FOUND) # To avoid fiddly setting up of OpenCL on Windows CI VMs, use copy in repo. set(OpenCL_INCLUDE_DIR - "${CMAKE_CURRENT_SOURCE_DIR}/lib/basisu/opencl" + "${CMAKE_CURRENT_SOURCE_DIR}/external/basisu/opencl" # FORCE to override *-NOTFOUND set by the failed find. CACHE PATH "" FORCE ) set(OpenCL_LIBRARY - "${CMAKE_CURRENT_SOURCE_DIR}/lib/basisu/opencl/lib/OpenCL64.lib" + "${CMAKE_CURRENT_SOURCE_DIR}/external/basisu/opencl/lib/OpenCL64.lib" CACHE FILEPATH "" FORCE ) set(OpenCL_INCLUDE_DIRS ${OpenCL_INCLUDE_DIR}) @@ -302,7 +302,7 @@ else() endif() # To improve output determinism enable precise floating point operations globally -# This code was based on lib/astc-encoder/Source/cmake_core.cmake +# This code was based on external/astc-encoder/Source/cmake_core.cmake # For Visual Studio prior to 2022 (compiler < 19.30) /fp:strict # For Visual Studio 2022 (compiler >= 19.30) /fp:precise @@ -358,26 +358,26 @@ set(KTX_MAIN_SRC lib/basis_sgd.h lib/basis_transcode.cpp lib/miniz_wrapper.cpp - lib/basisu/transcoder/basisu_containers.h - lib/basisu/transcoder/basisu_containers_impl.h - lib/basisu/transcoder/basisu_file_headers.h - lib/basisu/transcoder/basisu_transcoder_internal.h - lib/basisu/transcoder/basisu_transcoder_uastc.h - lib/basisu/transcoder/basisu_transcoder.cpp - lib/basisu/transcoder/basisu_transcoder.h - lib/basisu/transcoder/basisu.h - lib/basisu/zstd/zstd.c + external/basisu/transcoder/basisu_containers.h + external/basisu/transcoder/basisu_containers_impl.h + external/basisu/transcoder/basisu_file_headers.h + external/basisu/transcoder/basisu_transcoder_internal.h + external/basisu/transcoder/basisu_transcoder_uastc.h + external/basisu/transcoder/basisu_transcoder.cpp + external/basisu/transcoder/basisu_transcoder.h + external/basisu/transcoder/basisu.h + external/basisu/zstd/zstd.c lib/checkheader.c - lib/dfdutils/createdfd.c - lib/dfdutils/colourspaces.c - lib/dfdutils/dfd.h - lib/dfdutils/interpretdfd.c - lib/dfdutils/printdfd.c - lib/dfdutils/queries.c - lib/dfdutils/vk2dfd.c - lib/dfdutils/vk2dfd.inl - lib/dfdutils/vulkan/vk_platform.h - lib/dfdutils/vulkan/vulkan_core.h + external/dfdutils/createdfd.c + external/dfdutils/colourspaces.c + external/dfdutils/dfd.h + external/dfdutils/interpretdfd.c + external/dfdutils/printdfd.c + external/dfdutils/queries.c + external/dfdutils/vk2dfd.c + external/dfdutils/vk2dfd.inl + external/dfdutils/vulkan/vk_platform.h + external/dfdutils/vulkan/vulkan_core.h lib/etcunpack.cxx lib/filestream.c lib/filestream.h @@ -413,43 +413,43 @@ if (KTX_FEATURE_ETC_UNPACK) endif() set(BASISU_ENCODER_CXX_SRC - lib/basisu/encoder/basisu_backend.cpp - lib/basisu/encoder/basisu_backend.h - lib/basisu/encoder/basisu_basis_file.cpp - lib/basisu/encoder/basisu_basis_file.h - lib/basisu/encoder/basisu_bc7enc.cpp - lib/basisu/encoder/basisu_bc7enc.h - lib/basisu/encoder/basisu_comp.cpp - lib/basisu/encoder/basisu_comp.h - lib/basisu/encoder/basisu_enc.cpp - lib/basisu/encoder/basisu_enc.h - lib/basisu/encoder/basisu_etc.cpp - lib/basisu/encoder/basisu_etc.h - lib/basisu/encoder/basisu_frontend.cpp - lib/basisu/encoder/basisu_frontend.h - lib/basisu/encoder/basisu_gpu_texture.cpp - lib/basisu/encoder/basisu_gpu_texture.h - lib/basisu/encoder/basisu_kernels_declares.h - lib/basisu/encoder/basisu_kernels_imp.h - lib/basisu/encoder/basisu_kernels_sse.cpp - lib/basisu/encoder/basisu_miniz.h - lib/basisu/encoder/basisu_opencl.cpp - lib/basisu/encoder/basisu_opencl.h - lib/basisu/encoder/basisu_pvrtc1_4.cpp - lib/basisu/encoder/basisu_pvrtc1_4.h - lib/basisu/encoder/basisu_resample_filters.cpp - lib/basisu/encoder/basisu_resampler_filters.h - lib/basisu/encoder/basisu_resampler.cpp - lib/basisu/encoder/basisu_resampler.h - lib/basisu/encoder/basisu_ssim.cpp - lib/basisu/encoder/basisu_ssim.h - lib/basisu/encoder/basisu_uastc_enc.cpp - lib/basisu/encoder/basisu_uastc_enc.h - lib/basisu/encoder/cppspmd_flow.h - lib/basisu/encoder/cppspmd_math.h - lib/basisu/encoder/cppspmd_math_declares.h - lib/basisu/encoder/cppspmd_sse.h - lib/basisu/encoder/cppspmd_type_aliases.h + external/basisu/encoder/basisu_backend.cpp + external/basisu/encoder/basisu_backend.h + external/basisu/encoder/basisu_basis_file.cpp + external/basisu/encoder/basisu_basis_file.h + external/basisu/encoder/basisu_bc7enc.cpp + external/basisu/encoder/basisu_bc7enc.h + external/basisu/encoder/basisu_comp.cpp + external/basisu/encoder/basisu_comp.h + external/basisu/encoder/basisu_enc.cpp + external/basisu/encoder/basisu_enc.h + external/basisu/encoder/basisu_etc.cpp + external/basisu/encoder/basisu_etc.h + external/basisu/encoder/basisu_frontend.cpp + external/basisu/encoder/basisu_frontend.h + external/basisu/encoder/basisu_gpu_texture.cpp + external/basisu/encoder/basisu_gpu_texture.h + external/basisu/encoder/basisu_kernels_declares.h + external/basisu/encoder/basisu_kernels_imp.h + external/basisu/encoder/basisu_kernels_sse.cpp + external/basisu/encoder/basisu_miniz.h + external/basisu/encoder/basisu_opencl.cpp + external/basisu/encoder/basisu_opencl.h + external/basisu/encoder/basisu_pvrtc1_4.cpp + external/basisu/encoder/basisu_pvrtc1_4.h + external/basisu/encoder/basisu_resample_filters.cpp + external/basisu/encoder/basisu_resampler_filters.h + external/basisu/encoder/basisu_resampler.cpp + external/basisu/encoder/basisu_resampler.h + external/basisu/encoder/basisu_ssim.cpp + external/basisu/encoder/basisu_ssim.h + external/basisu/encoder/basisu_uastc_enc.cpp + external/basisu/encoder/basisu_uastc_enc.h + external/basisu/encoder/cppspmd_flow.h + external/basisu/encoder/cppspmd_math.h + external/basisu/encoder/cppspmd_math_declares.h + external/basisu/encoder/cppspmd_sse.h + external/basisu/encoder/cppspmd_type_aliases.h ) if(KTX_FEATURE_GL_UPLOAD) @@ -474,7 +474,7 @@ elseif(APPLE_MAC_OS OR LINUX) endif() set(KTX_BASISU_INCLUDE_DIRS - $ + $ ) # Main library @@ -563,10 +563,11 @@ macro(common_libktx_settings target enable_write library_type) $ PRIVATE ${KTX_BASISU_INCLUDE_DIRS} - $ + $ - $ - $ + $ + $ + $ $ $ @@ -698,8 +699,8 @@ macro(common_libktx_settings target enable_write library_type) target_include_directories( ${target} PRIVATE - $ - $ + $ + $ ) get_target_property( KTX_PUBLIC_HEADER ${target} PUBLIC_HEADER ) @@ -727,8 +728,8 @@ macro(common_libktx_settings target enable_write library_type) target_include_directories( ${target} PRIVATE - $ - $ + $ + $ $<$:${OpenCL_INCLUDE_DIRS}> ) target_compile_definitions( @@ -801,7 +802,7 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") PROPERTIES COMPILE_OPTIONS "-Wno-sign-compare;-Wno-unused-variable;-Wno-class-memaccess;-Wno-misleading-indentation;-Wno-extra;-Wno-deprecated-copy;-Wno-parentheses;-Wno-strict-aliasing" ) set_source_files_properties( - lib/basisu/transcoder/basisu_transcoder.cpp + external/basisu/transcoder/basisu_transcoder.cpp PROPERTIES COMPILE_OPTIONS "-Wno-sign-compare;-Wno-unused-function;-Wno-unused-variable;-Wno-class-memaccess;-Wno-maybe-uninitialized" ) if (${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER_EQUAL "11") @@ -811,11 +812,11 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") # the facts that we have never seen a crash and version 12 no # longer raises the warnings. get_source_file_property(cur_options - lib/basisu/encoder/basisu_comp.cpp + external/basisu/encoder/basisu_comp.cpp COMPILE_OPTIONS ) set_source_files_properties( - lib/basisu/encoder/basisu_comp.cpp + external/basisu/encoder/basisu_comp.cpp PROPERTIES COMPILE_OPTIONS "${cur_options};-Wno-stringop-overflow" ) endif() @@ -826,7 +827,7 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") # line 326, where the error is raised, to be > the array length. # Also we have never seen any crashes. set_source_files_properties( - lib/basisu/encoder/basisu_uastc_enc.cpp + external/basisu/encoder/basisu_uastc_enc.cpp PROPERTIES COMPILE_OPTIONS "-Wno-stringop-overflow" ) endif() @@ -851,11 +852,11 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") endif() # BEWARE: set_source_files_properties is not additive; it replaces. if (${clang_version} VERSION_GREATER_EQUAL "12.0.0") - set_source_files_properties( lib/basisu/encoder/basisu_kernels_sse.cpp + set_source_files_properties( external/basisu/encoder/basisu_kernels_sse.cpp PROPERTIES COMPILE_OPTIONS "-Wno-unused-parameter;-Wno-deprecated-copy;-Wno-uninitialized-const-reference" ) else() - set_source_files_properties( lib/basisu/encoder/basisu_kernels_sse.cpp + set_source_files_properties( external/basisu/encoder/basisu_kernels_sse.cpp PROPERTIES COMPILE_OPTIONS "-Wno-unused-parameter" ) endif() @@ -867,11 +868,11 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") PROPERTIES COMPILE_OPTIONS "-Wno-sign-compare;-Wno-unused-variable;-Wno-unused-parameter;-Wno-deprecated-copy-with-user-provided-copy" ) set_source_files_properties( - lib/basisu/transcoder/basisu_transcoder.cpp + external/basisu/transcoder/basisu_transcoder.cpp PROPERTIES COMPILE_OPTIONS "-Wno-sign-compare;-Wno-unused-function;-Wno-unused-variable" ) set_source_files_properties( - lib/basisu/zstd/zstd.c + external/basisu/zstd/zstd.c PROPERTIES COMPILE_OPTIONS "-Wno-unused-function" ) endif() @@ -884,10 +885,10 @@ endif() # target to retrieve these from the ktx target are not available until # v18 and we still need to work with v16 in the Emscripten Docker image. get_source_file_property(transcoder_options - lib/basisu/transcoder/basisu_transcoder.cpp + external/basisu/transcoder/basisu_transcoder.cpp COMPILE_OPTIONS ) -get_source_file_property(zstd_options lib/basisu/zstd/zstd.c COMPILE_OPTIONS) +get_source_file_property(zstd_options external/basisu/zstd/zstd.c COMPILE_OPTIONS) if(EMSCRIPTEN) set( @@ -938,7 +939,7 @@ if(EMSCRIPTEN) target_include_directories( msc_basis_transcoder_js PRIVATE lib - lib/basisu/transcoder + external ) # Re-use ktx's compile options @@ -1064,7 +1065,7 @@ endif() # astcenc set(ASTCENC_CLI OFF) # Only build as library not the CLI astcencoder -add_subdirectory(lib/astc-encoder) +add_subdirectory(external/astc-encoder) set_property(TARGET ${ASTCENC_LIB_TARGET} PROPERTY POSITION_INDEPENDENT_CODE ON) if(KTX_FEATURE_STATIC_LIBRARY AND APPLE) @@ -1090,10 +1091,10 @@ endif() if((KTX_FEATURE_TOOLS OR KTX_FEATURE_TESTS) AND NOT TARGET fmt::fmt) set(FMT_INSTALL OFF) set(FMT_SYSTEM_HEADERS ON) - add_subdirectory(other_projects/fmt) + add_subdirectory(external/fmt) endif() if(KTX_FEATURE_TOOLS AND NOT TARGET cxxopts::cxxopts) - add_subdirectory(other_projects/cxxopts) + add_subdirectory(external/cxxopts) endif() # Tools diff --git a/ci_scripts/install_win.ps1 b/ci_scripts/install_win.ps1 index 6c479ad93f..02fad5a04a 100644 --- a/ci_scripts/install_win.ps1 +++ b/ci_scripts/install_win.ps1 @@ -80,7 +80,7 @@ function Augment-UserPath { if ($SUPPORT_OPENCL -eq "ON") { # Must be in repo root for this lfs pull. - git lfs pull --include=lib/basisu/opencl + git lfs pull --include=external/basisu/opencl echo "Download and install OpenCL CPU runtime..." echo "... in sibling of cloned repo (../$OPENCL_SDK_NAME)." pushd .. diff --git a/ci_scripts/mkvkformatfiles b/ci_scripts/mkvkformatfiles index 197a2d5eef..7a3fb5b3f1 100755 --- a/ci_scripts/mkvkformatfiles +++ b/ci_scripts/mkvkformatfiles @@ -6,7 +6,7 @@ # # output_dir defaults to the current directory. # path/to/vulkan_core defaults to ENVIRON["Vulkan_INCLUDE_DIR"]. If not -# set, default is lib/dfdutils/vulkan/vulkan_core.h. +# set, default is external/dfdutils/vulkan/vulkan_core.h. # # When specifying path/to/vulkan_core, output-dir must also be # specified. @@ -55,7 +55,7 @@ BEGIN { } else { # Use local vulkan_core.h until ASTC 3D texture extension is released. # ARGV[1] = "/usr/include"; - ARGV[1] = "lib/dfdutils/vulkan/vulkan_core.h"; ARGC = 2 + ARGV[1] = "external/dfdutils/vulkan/vulkan_core.h"; ARGC = 2 } } diff --git a/cmake/mkvk.cmake b/cmake/mkvk.cmake index 49afb164a8..74283a1d26 100644 --- a/cmake/mkvk.cmake +++ b/cmake/mkvk.cmake @@ -26,7 +26,7 @@ if (NOT IOS AND NOT ANDROID) # This cmake file is included from its parent so has the same scope as # the including file. If we change Vulkan_INCLUDE_DIR, other parts will # be affected. - set(mkvk_vulkan_include_dir lib/dfdutils) + set(mkvk_vulkan_include_dir external/dfdutils) else() # Skip mkvk. There is no need to use iOS or Android to regenerate # the files. @@ -121,13 +121,13 @@ add_custom_target(mkvkformatfiles list(APPEND makevk2dfd_input ${vulkan_header} - lib/dfdutils/makevk2dfd.pl) + external/dfdutils/makevk2dfd.pl) set(makevk2dfd_output - "${PROJECT_SOURCE_DIR}/lib/dfdutils/vk2dfd.inl") + "${PROJECT_SOURCE_DIR}/external/dfdutils/vk2dfd.inl") add_custom_command( OUTPUT ${makevk2dfd_output} - COMMAND "${PERL_EXECUTABLE}" lib/dfdutils/makevk2dfd.pl ${vulkan_header} lib/dfdutils/vk2dfd.inl + COMMAND "${PERL_EXECUTABLE}" external/dfdutils/makevk2dfd.pl ${vulkan_header} external/dfdutils/vk2dfd.inl DEPENDS ${makevk2dfd_input} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMENT "Generating VkFormat/DFD switch body" @@ -142,14 +142,14 @@ add_custom_target(makevk2dfd list(APPEND makedfd2vk_input ${vulkan_header} - lib/dfdutils/makedfd2vk.pl) + external/dfdutils/makedfd2vk.pl) list(APPEND makedfd2vk_output - "${PROJECT_SOURCE_DIR}/lib/dfdutils/dfd2vk.inl") + "${PROJECT_SOURCE_DIR}/external/dfdutils/dfd2vk.inl") add_custom_command( OUTPUT ${makedfd2vk_output} - COMMAND ${CMAKE_COMMAND} -E make_directory lib/dfdutils - COMMAND "${PERL_EXECUTABLE}" lib/dfdutils/makedfd2vk.pl ${vulkan_header} lib/dfdutils/dfd2vk.inl + COMMAND ${CMAKE_COMMAND} -E make_directory external/dfdutils + COMMAND "${PERL_EXECUTABLE}" external/dfdutils/makedfd2vk.pl ${vulkan_header} external/dfdutils/dfd2vk.inl DEPENDS ${makedfd2vk_input} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMENT "Generating DFD/VkFormat switch body" diff --git a/examples/vkload.cpp b/examples/vkload.cpp index a9f77f6898..edec08343b 100644 --- a/examples/vkload.cpp +++ b/examples/vkload.cpp @@ -22,14 +22,13 @@ class Texture { prepareSamplerAndView(); }; -Texture::Texture(const std::string ktxfile) -{ +Texture::Texture(const std::string ktxfile) { ktxVulkanDeviceInfo kvdi; ktxTexture* kTexture; KTX_error_code ktxresult; createVulkanInstance(); - findVulkanGpu(); // Find a suitable physical device + findVulkanGpu(); // Find a suitable physical device createVulkanSurface(); createVulkanDevice(); prepareVulkanSwapchain(); @@ -43,20 +42,14 @@ Texture::Texture(const std::string ktxfile) // with the expectation that app's will typically load many textures. ktxVulkanDeviceInfo_Construct(&kvdi, gpu, device, queue, commandPool, nullptr); - ktxresult = ktxTexture_CreateFromNamedFile( - (getAssetPath() + ktxfile).c_str(), - KTX_TEXTURE_CREATE_NO_FLAGS, - &kTexture); + ktxresult = ktxTexture_CreateFromNamedFile((getAssetPath() + ktxfile).c_str(), KTX_TEXTURE_CREATE_NO_FLAGS, &kTexture); if (KTX_SUCCESS != ktxresult) { std::stringstream message; - message << "Creation of ktxTexture from \"" << getAssetPath() - << ktxfile << "\" failed: " << ktxErrorString(ktxresult); + message << "Creation of ktxTexture from \"" << getAssetPath() << ktxfile << "\" failed: " << ktxErrorString(ktxresult); throw std::runtime_error(message.str()); } - ktxresult = ktxTexture_VkUploadEx(kTexture, &kvdi, &texture, - VK_IMAGE_TILING_OPTIMAL, - VK_IMAGE_USAGE_SAMPLED_BIT, + ktxresult = ktxTexture_VkUploadEx(kTexture, &kvdi, &texture, VK_IMAGE_TILING_OPTIMAL, VK_IMAGE_USAGE_SAMPLED_BIT, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); if (KTX_SUCCESS != ktxresult) { std::stringstream message; @@ -67,10 +60,7 @@ Texture::Texture(const std::string ktxfile) char* pValue; uint32_t valueLen; - if (KTX_SUCCESS == ktxHashTable_FindValue(&kTexture->kvDataHead, - KTX_ORIENTATION_KEY, - &valueLen, (void**)&pValue)) - { + if (KTX_SUCCESS == ktxHashTable_FindValue(&kTexture->kvDataHead, KTX_ORIENTATION_KEY, &valueLen, (void**)&pValue)) { char s, t; if (sscanf(pValue, KTX_ORIENTATION2_FMT, &s, &t) == 2) { @@ -83,7 +73,7 @@ Texture::Texture(const std::string ktxfile) ktxVulkanDeviceInfo_destruct(&kvdi); try { - prepareSamplerAndView(); // See below for implementation. + prepareSamplerAndView(); // See below for implementation. // Setup a layout with, e.g., a binding for a combined image-sampler. setupDescriptorSetLayout(); // Create a descriptor set and update it with the sampler and image view handles. @@ -98,13 +88,9 @@ Texture::Texture(const std::string ktxfile) } } -Texture::~Texture() -{ - cleanup(); -} +Texture::~Texture() { cleanup(); } -Texture::cleanup() -{ +Texture::cleanup() { destroyCommandBuffers(); destroySampler(); destroyImageview(); @@ -116,9 +102,7 @@ Texture::cleanup() */ } -void -Texture::prepareSamplerAndView() -{ +void Texture::prepareSamplerAndView() { // Create sampler. vk::SamplerCreateInfo samplerInfo; // Set the non-default values diff --git a/external/.clang-format b/external/.clang-format new file mode 100644 index 0000000000..ddf42b4634 --- /dev/null +++ b/external/.clang-format @@ -0,0 +1,7 @@ +# Copyright 2024 The Khronos Group Inc. +# SPDX-License-Identifier: Apache-2.0 +--- +# Disable clang-format in this directory +DisableFormat: true +SortIncludes: false +--- diff --git a/lib/astc-encoder/.gitattributes b/external/astc-encoder/.gitattributes similarity index 100% rename from lib/astc-encoder/.gitattributes rename to external/astc-encoder/.gitattributes diff --git a/lib/astc-encoder/.gitignore b/external/astc-encoder/.gitignore similarity index 100% rename from lib/astc-encoder/.gitignore rename to external/astc-encoder/.gitignore diff --git a/lib/astc-encoder/.gitrepo b/external/astc-encoder/.gitrepo similarity index 100% rename from lib/astc-encoder/.gitrepo rename to external/astc-encoder/.gitrepo diff --git a/lib/astc-encoder/.pylintrc b/external/astc-encoder/.pylintrc similarity index 100% rename from lib/astc-encoder/.pylintrc rename to external/astc-encoder/.pylintrc diff --git a/lib/astc-encoder/CMakeLists.txt b/external/astc-encoder/CMakeLists.txt similarity index 100% rename from lib/astc-encoder/CMakeLists.txt rename to external/astc-encoder/CMakeLists.txt diff --git a/lib/astc-encoder/Docs/Building.md b/external/astc-encoder/Docs/Building.md similarity index 100% rename from lib/astc-encoder/Docs/Building.md rename to external/astc-encoder/Docs/Building.md diff --git a/lib/astc-encoder/Docs/ChangeLog-2x.md b/external/astc-encoder/Docs/ChangeLog-2x.md similarity index 100% rename from lib/astc-encoder/Docs/ChangeLog-2x.md rename to external/astc-encoder/Docs/ChangeLog-2x.md diff --git a/lib/astc-encoder/Docs/ChangeLog-3x.md b/external/astc-encoder/Docs/ChangeLog-3x.md similarity index 100% rename from lib/astc-encoder/Docs/ChangeLog-3x.md rename to external/astc-encoder/Docs/ChangeLog-3x.md diff --git a/lib/astc-encoder/Docs/ChangeLog-4x.md b/external/astc-encoder/Docs/ChangeLog-4x.md similarity index 100% rename from lib/astc-encoder/Docs/ChangeLog-4x.md rename to external/astc-encoder/Docs/ChangeLog-4x.md diff --git a/lib/astc-encoder/Docs/ChangeLogImg/absolute-1.7-to-2.0.png b/external/astc-encoder/Docs/ChangeLogImg/absolute-1.7-to-2.0.png similarity index 100% rename from lib/astc-encoder/Docs/ChangeLogImg/absolute-1.7-to-2.0.png rename to external/astc-encoder/Docs/ChangeLogImg/absolute-1.7-to-2.0.png diff --git a/lib/astc-encoder/Docs/ChangeLogImg/absolute-2.0-to-2.1.png b/external/astc-encoder/Docs/ChangeLogImg/absolute-2.0-to-2.1.png similarity index 100% rename from lib/astc-encoder/Docs/ChangeLogImg/absolute-2.0-to-2.1.png rename to external/astc-encoder/Docs/ChangeLogImg/absolute-2.0-to-2.1.png diff --git a/lib/astc-encoder/Docs/ChangeLogImg/absolute-2.1-to-2.2.png b/external/astc-encoder/Docs/ChangeLogImg/absolute-2.1-to-2.2.png similarity index 100% rename from lib/astc-encoder/Docs/ChangeLogImg/absolute-2.1-to-2.2.png rename to external/astc-encoder/Docs/ChangeLogImg/absolute-2.1-to-2.2.png diff --git a/lib/astc-encoder/Docs/ChangeLogImg/absolute-2.2-to-2.3.png b/external/astc-encoder/Docs/ChangeLogImg/absolute-2.2-to-2.3.png similarity index 100% rename from lib/astc-encoder/Docs/ChangeLogImg/absolute-2.2-to-2.3.png rename to external/astc-encoder/Docs/ChangeLogImg/absolute-2.2-to-2.3.png diff --git a/lib/astc-encoder/Docs/ChangeLogImg/absolute-2.5-to-3.0.png b/external/astc-encoder/Docs/ChangeLogImg/absolute-2.5-to-3.0.png similarity index 100% rename from lib/astc-encoder/Docs/ChangeLogImg/absolute-2.5-to-3.0.png rename to external/astc-encoder/Docs/ChangeLogImg/absolute-2.5-to-3.0.png diff --git a/lib/astc-encoder/Docs/ChangeLogImg/relative-1.7-to-2.0.png b/external/astc-encoder/Docs/ChangeLogImg/relative-1.7-to-2.0.png similarity index 100% rename from lib/astc-encoder/Docs/ChangeLogImg/relative-1.7-to-2.0.png rename to external/astc-encoder/Docs/ChangeLogImg/relative-1.7-to-2.0.png diff --git a/lib/astc-encoder/Docs/ChangeLogImg/relative-2.0-to-2.1.png b/external/astc-encoder/Docs/ChangeLogImg/relative-2.0-to-2.1.png similarity index 100% rename from lib/astc-encoder/Docs/ChangeLogImg/relative-2.0-to-2.1.png rename to external/astc-encoder/Docs/ChangeLogImg/relative-2.0-to-2.1.png diff --git a/lib/astc-encoder/Docs/ChangeLogImg/relative-2.1-to-2.2.png b/external/astc-encoder/Docs/ChangeLogImg/relative-2.1-to-2.2.png similarity index 100% rename from lib/astc-encoder/Docs/ChangeLogImg/relative-2.1-to-2.2.png rename to external/astc-encoder/Docs/ChangeLogImg/relative-2.1-to-2.2.png diff --git a/lib/astc-encoder/Docs/ChangeLogImg/relative-2.2-to-2.3.png b/external/astc-encoder/Docs/ChangeLogImg/relative-2.2-to-2.3.png similarity index 100% rename from lib/astc-encoder/Docs/ChangeLogImg/relative-2.2-to-2.3.png rename to external/astc-encoder/Docs/ChangeLogImg/relative-2.2-to-2.3.png diff --git a/lib/astc-encoder/Docs/ChangeLogImg/relative-2.5-to-3.0.png b/external/astc-encoder/Docs/ChangeLogImg/relative-2.5-to-3.0.png similarity index 100% rename from lib/astc-encoder/Docs/ChangeLogImg/relative-2.5-to-3.0.png rename to external/astc-encoder/Docs/ChangeLogImg/relative-2.5-to-3.0.png diff --git a/lib/astc-encoder/Docs/ChangeLogImg/relative-3.0-to-3.1.png b/external/astc-encoder/Docs/ChangeLogImg/relative-3.0-to-3.1.png similarity index 100% rename from lib/astc-encoder/Docs/ChangeLogImg/relative-3.0-to-3.1.png rename to external/astc-encoder/Docs/ChangeLogImg/relative-3.0-to-3.1.png diff --git a/lib/astc-encoder/Docs/ChangeLogImg/relative-3.3-to-3.4.png b/external/astc-encoder/Docs/ChangeLogImg/relative-3.3-to-3.4.png similarity index 100% rename from lib/astc-encoder/Docs/ChangeLogImg/relative-3.3-to-3.4.png rename to external/astc-encoder/Docs/ChangeLogImg/relative-3.3-to-3.4.png diff --git a/lib/astc-encoder/Docs/ChangeLogImg/relative-3.4-to-3.5.png b/external/astc-encoder/Docs/ChangeLogImg/relative-3.4-to-3.5.png similarity index 100% rename from lib/astc-encoder/Docs/ChangeLogImg/relative-3.4-to-3.5.png rename to external/astc-encoder/Docs/ChangeLogImg/relative-3.4-to-3.5.png diff --git a/lib/astc-encoder/Docs/ChangeLogImg/relative-3.5-to-3.6.png b/external/astc-encoder/Docs/ChangeLogImg/relative-3.5-to-3.6.png similarity index 100% rename from lib/astc-encoder/Docs/ChangeLogImg/relative-3.5-to-3.6.png rename to external/astc-encoder/Docs/ChangeLogImg/relative-3.5-to-3.6.png diff --git a/lib/astc-encoder/Docs/ChangeLogImg/relative-3.6-to-3.7.png b/external/astc-encoder/Docs/ChangeLogImg/relative-3.6-to-3.7.png similarity index 100% rename from lib/astc-encoder/Docs/ChangeLogImg/relative-3.6-to-3.7.png rename to external/astc-encoder/Docs/ChangeLogImg/relative-3.6-to-3.7.png diff --git a/lib/astc-encoder/Docs/ChangeLogImg/relative-3.7-to-4.0.png b/external/astc-encoder/Docs/ChangeLogImg/relative-3.7-to-4.0.png similarity index 100% rename from lib/astc-encoder/Docs/ChangeLogImg/relative-3.7-to-4.0.png rename to external/astc-encoder/Docs/ChangeLogImg/relative-3.7-to-4.0.png diff --git a/lib/astc-encoder/Docs/ChangeLogImg/relative-4.0-to-4.2.png b/external/astc-encoder/Docs/ChangeLogImg/relative-4.0-to-4.2.png similarity index 100% rename from lib/astc-encoder/Docs/ChangeLogImg/relative-4.0-to-4.2.png rename to external/astc-encoder/Docs/ChangeLogImg/relative-4.0-to-4.2.png diff --git a/lib/astc-encoder/Docs/ChangeLogImg/relative-4.2-to-4.3.png b/external/astc-encoder/Docs/ChangeLogImg/relative-4.2-to-4.3.png similarity index 100% rename from lib/astc-encoder/Docs/ChangeLogImg/relative-4.2-to-4.3.png rename to external/astc-encoder/Docs/ChangeLogImg/relative-4.2-to-4.3.png diff --git a/lib/astc-encoder/Docs/ChangeLogImg/relative-4.3-to-4.4.png b/external/astc-encoder/Docs/ChangeLogImg/relative-4.3-to-4.4.png similarity index 100% rename from lib/astc-encoder/Docs/ChangeLogImg/relative-4.3-to-4.4.png rename to external/astc-encoder/Docs/ChangeLogImg/relative-4.3-to-4.4.png diff --git a/lib/astc-encoder/Docs/Encoding.md b/external/astc-encoder/Docs/Encoding.md similarity index 100% rename from lib/astc-encoder/Docs/Encoding.md rename to external/astc-encoder/Docs/Encoding.md diff --git a/lib/astc-encoder/Docs/FileFormat.md b/external/astc-encoder/Docs/FileFormat.md similarity index 100% rename from lib/astc-encoder/Docs/FileFormat.md rename to external/astc-encoder/Docs/FileFormat.md diff --git a/lib/astc-encoder/Docs/FormatOverview.md b/external/astc-encoder/Docs/FormatOverview.md similarity index 100% rename from lib/astc-encoder/Docs/FormatOverview.md rename to external/astc-encoder/Docs/FormatOverview.md diff --git a/lib/astc-encoder/Docs/FormatOverviewImg/astc-quality.png b/external/astc-encoder/Docs/FormatOverviewImg/astc-quality.png similarity index 100% rename from lib/astc-encoder/Docs/FormatOverviewImg/astc-quality.png rename to external/astc-encoder/Docs/FormatOverviewImg/astc-quality.png diff --git a/lib/astc-encoder/Docs/FormatOverviewImg/binary.png b/external/astc-encoder/Docs/FormatOverviewImg/binary.png similarity index 100% rename from lib/astc-encoder/Docs/FormatOverviewImg/binary.png rename to external/astc-encoder/Docs/FormatOverviewImg/binary.png diff --git a/lib/astc-encoder/Docs/FormatOverviewImg/bise.png b/external/astc-encoder/Docs/FormatOverviewImg/bise.png similarity index 100% rename from lib/astc-encoder/Docs/FormatOverviewImg/bise.png rename to external/astc-encoder/Docs/FormatOverviewImg/bise.png diff --git a/lib/astc-encoder/Docs/FormatOverviewImg/coverage-astc.svg b/external/astc-encoder/Docs/FormatOverviewImg/coverage-astc.svg similarity index 100% rename from lib/astc-encoder/Docs/FormatOverviewImg/coverage-astc.svg rename to external/astc-encoder/Docs/FormatOverviewImg/coverage-astc.svg diff --git a/lib/astc-encoder/Docs/FormatOverviewImg/coverage-legacy.svg b/external/astc-encoder/Docs/FormatOverviewImg/coverage-legacy.svg similarity index 100% rename from lib/astc-encoder/Docs/FormatOverviewImg/coverage-legacy.svg rename to external/astc-encoder/Docs/FormatOverviewImg/coverage-legacy.svg diff --git a/lib/astc-encoder/Docs/FormatOverviewImg/gradient-1p.svg b/external/astc-encoder/Docs/FormatOverviewImg/gradient-1p.svg similarity index 100% rename from lib/astc-encoder/Docs/FormatOverviewImg/gradient-1p.svg rename to external/astc-encoder/Docs/FormatOverviewImg/gradient-1p.svg diff --git a/lib/astc-encoder/Docs/FormatOverviewImg/gradient-2p.svg b/external/astc-encoder/Docs/FormatOverviewImg/gradient-2p.svg similarity index 100% rename from lib/astc-encoder/Docs/FormatOverviewImg/gradient-2p.svg rename to external/astc-encoder/Docs/FormatOverviewImg/gradient-2p.svg diff --git a/lib/astc-encoder/Docs/FormatOverviewImg/hash.png b/external/astc-encoder/Docs/FormatOverviewImg/hash.png similarity index 100% rename from lib/astc-encoder/Docs/FormatOverviewImg/hash.png rename to external/astc-encoder/Docs/FormatOverviewImg/hash.png diff --git a/lib/astc-encoder/Docs/Profiling.md b/external/astc-encoder/Docs/Profiling.md similarity index 100% rename from lib/astc-encoder/Docs/Profiling.md rename to external/astc-encoder/Docs/Profiling.md diff --git a/lib/astc-encoder/Docs/Terminology.md b/external/astc-encoder/Docs/Terminology.md similarity index 100% rename from lib/astc-encoder/Docs/Terminology.md rename to external/astc-encoder/Docs/Terminology.md diff --git a/lib/astc-encoder/Docs/Testing.md b/external/astc-encoder/Docs/Testing.md similarity index 100% rename from lib/astc-encoder/Docs/Testing.md rename to external/astc-encoder/Docs/Testing.md diff --git a/lib/astc-encoder/LICENSE.txt b/external/astc-encoder/LICENSE.txt similarity index 100% rename from lib/astc-encoder/LICENSE.txt rename to external/astc-encoder/LICENSE.txt diff --git a/lib/astc-encoder/README.md b/external/astc-encoder/README.md similarity index 100% rename from lib/astc-encoder/README.md rename to external/astc-encoder/README.md diff --git a/lib/astc-encoder/Source/CMakeLists.txt b/external/astc-encoder/Source/CMakeLists.txt similarity index 100% rename from lib/astc-encoder/Source/CMakeLists.txt rename to external/astc-encoder/Source/CMakeLists.txt diff --git a/lib/astc-encoder/Source/Fuzzers/build.sh b/external/astc-encoder/Source/Fuzzers/build.sh similarity index 100% rename from lib/astc-encoder/Source/Fuzzers/build.sh rename to external/astc-encoder/Source/Fuzzers/build.sh diff --git a/lib/astc-encoder/Source/Fuzzers/fuzz_astc_physical_to_symbolic.cpp b/external/astc-encoder/Source/Fuzzers/fuzz_astc_physical_to_symbolic.cpp similarity index 100% rename from lib/astc-encoder/Source/Fuzzers/fuzz_astc_physical_to_symbolic.cpp rename to external/astc-encoder/Source/Fuzzers/fuzz_astc_physical_to_symbolic.cpp diff --git a/lib/astc-encoder/Source/UnitTest/CMakeLists.txt b/external/astc-encoder/Source/UnitTest/CMakeLists.txt similarity index 100% rename from lib/astc-encoder/Source/UnitTest/CMakeLists.txt rename to external/astc-encoder/Source/UnitTest/CMakeLists.txt diff --git a/lib/astc-encoder/Source/UnitTest/cmake_core.cmake b/external/astc-encoder/Source/UnitTest/cmake_core.cmake similarity index 100% rename from lib/astc-encoder/Source/UnitTest/cmake_core.cmake rename to external/astc-encoder/Source/UnitTest/cmake_core.cmake diff --git a/lib/astc-encoder/Source/UnitTest/test_simd.cpp b/external/astc-encoder/Source/UnitTest/test_simd.cpp similarity index 100% rename from lib/astc-encoder/Source/UnitTest/test_simd.cpp rename to external/astc-encoder/Source/UnitTest/test_simd.cpp diff --git a/lib/astc-encoder/Source/UnitTest/test_softfloat.cpp b/external/astc-encoder/Source/UnitTest/test_softfloat.cpp similarity index 100% rename from lib/astc-encoder/Source/UnitTest/test_softfloat.cpp rename to external/astc-encoder/Source/UnitTest/test_softfloat.cpp diff --git a/lib/astc-encoder/Source/astcenc.h b/external/astc-encoder/Source/astcenc.h similarity index 100% rename from lib/astc-encoder/Source/astcenc.h rename to external/astc-encoder/Source/astcenc.h diff --git a/lib/astc-encoder/Source/astcenc_averages_and_directions.cpp b/external/astc-encoder/Source/astcenc_averages_and_directions.cpp similarity index 100% rename from lib/astc-encoder/Source/astcenc_averages_and_directions.cpp rename to external/astc-encoder/Source/astcenc_averages_and_directions.cpp diff --git a/lib/astc-encoder/Source/astcenc_block_sizes.cpp b/external/astc-encoder/Source/astcenc_block_sizes.cpp similarity index 100% rename from lib/astc-encoder/Source/astcenc_block_sizes.cpp rename to external/astc-encoder/Source/astcenc_block_sizes.cpp diff --git a/lib/astc-encoder/Source/astcenc_color_quantize.cpp b/external/astc-encoder/Source/astcenc_color_quantize.cpp similarity index 100% rename from lib/astc-encoder/Source/astcenc_color_quantize.cpp rename to external/astc-encoder/Source/astcenc_color_quantize.cpp diff --git a/lib/astc-encoder/Source/astcenc_color_unquantize.cpp b/external/astc-encoder/Source/astcenc_color_unquantize.cpp similarity index 100% rename from lib/astc-encoder/Source/astcenc_color_unquantize.cpp rename to external/astc-encoder/Source/astcenc_color_unquantize.cpp diff --git a/lib/astc-encoder/Source/astcenc_compress_symbolic.cpp b/external/astc-encoder/Source/astcenc_compress_symbolic.cpp similarity index 100% rename from lib/astc-encoder/Source/astcenc_compress_symbolic.cpp rename to external/astc-encoder/Source/astcenc_compress_symbolic.cpp diff --git a/lib/astc-encoder/Source/astcenc_compute_variance.cpp b/external/astc-encoder/Source/astcenc_compute_variance.cpp similarity index 100% rename from lib/astc-encoder/Source/astcenc_compute_variance.cpp rename to external/astc-encoder/Source/astcenc_compute_variance.cpp diff --git a/lib/astc-encoder/Source/astcenc_decompress_symbolic.cpp b/external/astc-encoder/Source/astcenc_decompress_symbolic.cpp similarity index 100% rename from lib/astc-encoder/Source/astcenc_decompress_symbolic.cpp rename to external/astc-encoder/Source/astcenc_decompress_symbolic.cpp diff --git a/lib/astc-encoder/Source/astcenc_diagnostic_trace.cpp b/external/astc-encoder/Source/astcenc_diagnostic_trace.cpp similarity index 100% rename from lib/astc-encoder/Source/astcenc_diagnostic_trace.cpp rename to external/astc-encoder/Source/astcenc_diagnostic_trace.cpp diff --git a/lib/astc-encoder/Source/astcenc_diagnostic_trace.h b/external/astc-encoder/Source/astcenc_diagnostic_trace.h similarity index 100% rename from lib/astc-encoder/Source/astcenc_diagnostic_trace.h rename to external/astc-encoder/Source/astcenc_diagnostic_trace.h diff --git a/lib/astc-encoder/Source/astcenc_entry.cpp b/external/astc-encoder/Source/astcenc_entry.cpp similarity index 100% rename from lib/astc-encoder/Source/astcenc_entry.cpp rename to external/astc-encoder/Source/astcenc_entry.cpp diff --git a/lib/astc-encoder/Source/astcenc_find_best_partitioning.cpp b/external/astc-encoder/Source/astcenc_find_best_partitioning.cpp similarity index 100% rename from lib/astc-encoder/Source/astcenc_find_best_partitioning.cpp rename to external/astc-encoder/Source/astcenc_find_best_partitioning.cpp diff --git a/lib/astc-encoder/Source/astcenc_ideal_endpoints_and_weights.cpp b/external/astc-encoder/Source/astcenc_ideal_endpoints_and_weights.cpp similarity index 100% rename from lib/astc-encoder/Source/astcenc_ideal_endpoints_and_weights.cpp rename to external/astc-encoder/Source/astcenc_ideal_endpoints_and_weights.cpp diff --git a/lib/astc-encoder/Source/astcenc_image.cpp b/external/astc-encoder/Source/astcenc_image.cpp similarity index 100% rename from lib/astc-encoder/Source/astcenc_image.cpp rename to external/astc-encoder/Source/astcenc_image.cpp diff --git a/lib/astc-encoder/Source/astcenc_integer_sequence.cpp b/external/astc-encoder/Source/astcenc_integer_sequence.cpp similarity index 100% rename from lib/astc-encoder/Source/astcenc_integer_sequence.cpp rename to external/astc-encoder/Source/astcenc_integer_sequence.cpp diff --git a/lib/astc-encoder/Source/astcenc_internal.h b/external/astc-encoder/Source/astcenc_internal.h similarity index 100% rename from lib/astc-encoder/Source/astcenc_internal.h rename to external/astc-encoder/Source/astcenc_internal.h diff --git a/lib/astc-encoder/Source/astcenc_internal_entry.h b/external/astc-encoder/Source/astcenc_internal_entry.h similarity index 100% rename from lib/astc-encoder/Source/astcenc_internal_entry.h rename to external/astc-encoder/Source/astcenc_internal_entry.h diff --git a/lib/astc-encoder/Source/astcenc_mathlib.cpp b/external/astc-encoder/Source/astcenc_mathlib.cpp similarity index 100% rename from lib/astc-encoder/Source/astcenc_mathlib.cpp rename to external/astc-encoder/Source/astcenc_mathlib.cpp diff --git a/lib/astc-encoder/Source/astcenc_mathlib.h b/external/astc-encoder/Source/astcenc_mathlib.h similarity index 100% rename from lib/astc-encoder/Source/astcenc_mathlib.h rename to external/astc-encoder/Source/astcenc_mathlib.h diff --git a/lib/astc-encoder/Source/astcenc_mathlib_softfloat.cpp b/external/astc-encoder/Source/astcenc_mathlib_softfloat.cpp similarity index 100% rename from lib/astc-encoder/Source/astcenc_mathlib_softfloat.cpp rename to external/astc-encoder/Source/astcenc_mathlib_softfloat.cpp diff --git a/lib/astc-encoder/Source/astcenc_partition_tables.cpp b/external/astc-encoder/Source/astcenc_partition_tables.cpp similarity index 100% rename from lib/astc-encoder/Source/astcenc_partition_tables.cpp rename to external/astc-encoder/Source/astcenc_partition_tables.cpp diff --git a/lib/astc-encoder/Source/astcenc_percentile_tables.cpp b/external/astc-encoder/Source/astcenc_percentile_tables.cpp similarity index 100% rename from lib/astc-encoder/Source/astcenc_percentile_tables.cpp rename to external/astc-encoder/Source/astcenc_percentile_tables.cpp diff --git a/lib/astc-encoder/Source/astcenc_pick_best_endpoint_format.cpp b/external/astc-encoder/Source/astcenc_pick_best_endpoint_format.cpp similarity index 100% rename from lib/astc-encoder/Source/astcenc_pick_best_endpoint_format.cpp rename to external/astc-encoder/Source/astcenc_pick_best_endpoint_format.cpp diff --git a/lib/astc-encoder/Source/astcenc_platform_isa_detection.cpp b/external/astc-encoder/Source/astcenc_platform_isa_detection.cpp similarity index 100% rename from lib/astc-encoder/Source/astcenc_platform_isa_detection.cpp rename to external/astc-encoder/Source/astcenc_platform_isa_detection.cpp diff --git a/lib/astc-encoder/Source/astcenc_quantization.cpp b/external/astc-encoder/Source/astcenc_quantization.cpp similarity index 100% rename from lib/astc-encoder/Source/astcenc_quantization.cpp rename to external/astc-encoder/Source/astcenc_quantization.cpp diff --git a/lib/astc-encoder/Source/astcenc_symbolic_physical.cpp b/external/astc-encoder/Source/astcenc_symbolic_physical.cpp similarity index 100% rename from lib/astc-encoder/Source/astcenc_symbolic_physical.cpp rename to external/astc-encoder/Source/astcenc_symbolic_physical.cpp diff --git a/lib/astc-encoder/Source/astcenc_vecmathlib.h b/external/astc-encoder/Source/astcenc_vecmathlib.h similarity index 100% rename from lib/astc-encoder/Source/astcenc_vecmathlib.h rename to external/astc-encoder/Source/astcenc_vecmathlib.h diff --git a/lib/astc-encoder/Source/astcenc_vecmathlib_avx2_8.h b/external/astc-encoder/Source/astcenc_vecmathlib_avx2_8.h similarity index 100% rename from lib/astc-encoder/Source/astcenc_vecmathlib_avx2_8.h rename to external/astc-encoder/Source/astcenc_vecmathlib_avx2_8.h diff --git a/lib/astc-encoder/Source/astcenc_vecmathlib_common_4.h b/external/astc-encoder/Source/astcenc_vecmathlib_common_4.h similarity index 100% rename from lib/astc-encoder/Source/astcenc_vecmathlib_common_4.h rename to external/astc-encoder/Source/astcenc_vecmathlib_common_4.h diff --git a/lib/astc-encoder/Source/astcenc_vecmathlib_neon_4.h b/external/astc-encoder/Source/astcenc_vecmathlib_neon_4.h similarity index 100% rename from lib/astc-encoder/Source/astcenc_vecmathlib_neon_4.h rename to external/astc-encoder/Source/astcenc_vecmathlib_neon_4.h diff --git a/lib/astc-encoder/Source/astcenc_vecmathlib_none_4.h b/external/astc-encoder/Source/astcenc_vecmathlib_none_4.h similarity index 100% rename from lib/astc-encoder/Source/astcenc_vecmathlib_none_4.h rename to external/astc-encoder/Source/astcenc_vecmathlib_none_4.h diff --git a/lib/astc-encoder/Source/astcenc_vecmathlib_sse_4.h b/external/astc-encoder/Source/astcenc_vecmathlib_sse_4.h similarity index 100% rename from lib/astc-encoder/Source/astcenc_vecmathlib_sse_4.h rename to external/astc-encoder/Source/astcenc_vecmathlib_sse_4.h diff --git a/lib/astc-encoder/Source/astcenc_weight_align.cpp b/external/astc-encoder/Source/astcenc_weight_align.cpp similarity index 100% rename from lib/astc-encoder/Source/astcenc_weight_align.cpp rename to external/astc-encoder/Source/astcenc_weight_align.cpp diff --git a/lib/astc-encoder/Source/astcenc_weight_quant_xfer_tables.cpp b/external/astc-encoder/Source/astcenc_weight_quant_xfer_tables.cpp similarity index 100% rename from lib/astc-encoder/Source/astcenc_weight_quant_xfer_tables.cpp rename to external/astc-encoder/Source/astcenc_weight_quant_xfer_tables.cpp diff --git a/lib/astc-encoder/Source/astcenccli_entry.cpp b/external/astc-encoder/Source/astcenccli_entry.cpp similarity index 100% rename from lib/astc-encoder/Source/astcenccli_entry.cpp rename to external/astc-encoder/Source/astcenccli_entry.cpp diff --git a/lib/astc-encoder/Source/astcenccli_error_metrics.cpp b/external/astc-encoder/Source/astcenccli_error_metrics.cpp similarity index 100% rename from lib/astc-encoder/Source/astcenccli_error_metrics.cpp rename to external/astc-encoder/Source/astcenccli_error_metrics.cpp diff --git a/lib/astc-encoder/Source/astcenccli_image.cpp b/external/astc-encoder/Source/astcenccli_image.cpp similarity index 100% rename from lib/astc-encoder/Source/astcenccli_image.cpp rename to external/astc-encoder/Source/astcenccli_image.cpp diff --git a/lib/astc-encoder/Source/astcenccli_image_external.cpp b/external/astc-encoder/Source/astcenccli_image_external.cpp similarity index 100% rename from lib/astc-encoder/Source/astcenccli_image_external.cpp rename to external/astc-encoder/Source/astcenccli_image_external.cpp diff --git a/lib/astc-encoder/Source/astcenccli_image_load_store.cpp b/external/astc-encoder/Source/astcenccli_image_load_store.cpp similarity index 100% rename from lib/astc-encoder/Source/astcenccli_image_load_store.cpp rename to external/astc-encoder/Source/astcenccli_image_load_store.cpp diff --git a/lib/astc-encoder/Source/astcenccli_internal.h b/external/astc-encoder/Source/astcenccli_internal.h similarity index 100% rename from lib/astc-encoder/Source/astcenccli_internal.h rename to external/astc-encoder/Source/astcenccli_internal.h diff --git a/lib/astc-encoder/Source/astcenccli_platform_dependents.cpp b/external/astc-encoder/Source/astcenccli_platform_dependents.cpp similarity index 100% rename from lib/astc-encoder/Source/astcenccli_platform_dependents.cpp rename to external/astc-encoder/Source/astcenccli_platform_dependents.cpp diff --git a/lib/astc-encoder/Source/astcenccli_toplevel.cpp b/external/astc-encoder/Source/astcenccli_toplevel.cpp similarity index 100% rename from lib/astc-encoder/Source/astcenccli_toplevel.cpp rename to external/astc-encoder/Source/astcenccli_toplevel.cpp diff --git a/lib/astc-encoder/Source/astcenccli_toplevel_help.cpp b/external/astc-encoder/Source/astcenccli_toplevel_help.cpp similarity index 100% rename from lib/astc-encoder/Source/astcenccli_toplevel_help.cpp rename to external/astc-encoder/Source/astcenccli_toplevel_help.cpp diff --git a/lib/astc-encoder/Source/astcenccli_version.h.in b/external/astc-encoder/Source/astcenccli_version.h.in similarity index 100% rename from lib/astc-encoder/Source/astcenccli_version.h.in rename to external/astc-encoder/Source/astcenccli_version.h.in diff --git a/lib/astc-encoder/Source/cmake_core.cmake b/external/astc-encoder/Source/cmake_core.cmake similarity index 100% rename from lib/astc-encoder/Source/cmake_core.cmake rename to external/astc-encoder/Source/cmake_core.cmake diff --git a/lib/astc-encoder/Source/stb_image.h b/external/astc-encoder/Source/stb_image.h similarity index 100% rename from lib/astc-encoder/Source/stb_image.h rename to external/astc-encoder/Source/stb_image.h diff --git a/lib/astc-encoder/Source/stb_image_write.h b/external/astc-encoder/Source/stb_image_write.h similarity index 100% rename from lib/astc-encoder/Source/stb_image_write.h rename to external/astc-encoder/Source/stb_image_write.h diff --git a/lib/astc-encoder/Source/tinyexr.h b/external/astc-encoder/Source/tinyexr.h similarity index 100% rename from lib/astc-encoder/Source/tinyexr.h rename to external/astc-encoder/Source/tinyexr.h diff --git a/lib/astc-encoder/Source/wuffs-v0.3.c b/external/astc-encoder/Source/wuffs-v0.3.c similarity index 100% rename from lib/astc-encoder/Source/wuffs-v0.3.c rename to external/astc-encoder/Source/wuffs-v0.3.c diff --git a/lib/astc-encoder/Test/Data/HDR-A-1x1.astc b/external/astc-encoder/Test/Data/HDR-A-1x1.astc similarity index 100% rename from lib/astc-encoder/Test/Data/HDR-A-1x1.astc rename to external/astc-encoder/Test/Data/HDR-A-1x1.astc diff --git a/lib/astc-encoder/Test/Data/HDR-A-1x1.exr b/external/astc-encoder/Test/Data/HDR-A-1x1.exr similarity index 100% rename from lib/astc-encoder/Test/Data/HDR-A-1x1.exr rename to external/astc-encoder/Test/Data/HDR-A-1x1.exr diff --git a/lib/astc-encoder/Test/Data/LDR-A-1x1.astc b/external/astc-encoder/Test/Data/LDR-A-1x1.astc similarity index 100% rename from lib/astc-encoder/Test/Data/LDR-A-1x1.astc rename to external/astc-encoder/Test/Data/LDR-A-1x1.astc diff --git a/lib/astc-encoder/Test/Data/LDR-A-1x1.png b/external/astc-encoder/Test/Data/LDR-A-1x1.png similarity index 100% rename from lib/astc-encoder/Test/Data/LDR-A-1x1.png rename to external/astc-encoder/Test/Data/LDR-A-1x1.png diff --git a/lib/astc-encoder/Test/Data/LDRS-A-1x1.astc b/external/astc-encoder/Test/Data/LDRS-A-1x1.astc similarity index 100% rename from lib/astc-encoder/Test/Data/LDRS-A-1x1.astc rename to external/astc-encoder/Test/Data/LDRS-A-1x1.astc diff --git a/lib/astc-encoder/Test/Data/LDRS-A-1x1.png b/external/astc-encoder/Test/Data/LDRS-A-1x1.png similarity index 100% rename from lib/astc-encoder/Test/Data/LDRS-A-1x1.png rename to external/astc-encoder/Test/Data/LDRS-A-1x1.png diff --git a/lib/astc-encoder/Test/Data/Tiles/hdr-complex.exr b/external/astc-encoder/Test/Data/Tiles/hdr-complex.exr similarity index 100% rename from lib/astc-encoder/Test/Data/Tiles/hdr-complex.exr rename to external/astc-encoder/Test/Data/Tiles/hdr-complex.exr diff --git a/lib/astc-encoder/Test/Data/Tiles/hdr.astc b/external/astc-encoder/Test/Data/Tiles/hdr.astc similarity index 100% rename from lib/astc-encoder/Test/Data/Tiles/hdr.astc rename to external/astc-encoder/Test/Data/Tiles/hdr.astc diff --git a/lib/astc-encoder/Test/Data/Tiles/hdr.exr b/external/astc-encoder/Test/Data/Tiles/hdr.exr similarity index 100% rename from lib/astc-encoder/Test/Data/Tiles/hdr.exr rename to external/astc-encoder/Test/Data/Tiles/hdr.exr diff --git a/lib/astc-encoder/Test/Data/Tiles/hdr.hdr b/external/astc-encoder/Test/Data/Tiles/hdr.hdr similarity index 100% rename from lib/astc-encoder/Test/Data/Tiles/hdr.hdr rename to external/astc-encoder/Test/Data/Tiles/hdr.hdr diff --git a/lib/astc-encoder/Test/Data/Tiles/ldr-complex.png b/external/astc-encoder/Test/Data/Tiles/ldr-complex.png similarity index 100% rename from lib/astc-encoder/Test/Data/Tiles/ldr-complex.png rename to external/astc-encoder/Test/Data/Tiles/ldr-complex.png diff --git a/lib/astc-encoder/Test/Data/Tiles/ldr.astc b/external/astc-encoder/Test/Data/Tiles/ldr.astc similarity index 100% rename from lib/astc-encoder/Test/Data/Tiles/ldr.astc rename to external/astc-encoder/Test/Data/Tiles/ldr.astc diff --git a/lib/astc-encoder/Test/Data/Tiles/ldr.bmp b/external/astc-encoder/Test/Data/Tiles/ldr.bmp similarity index 100% rename from lib/astc-encoder/Test/Data/Tiles/ldr.bmp rename to external/astc-encoder/Test/Data/Tiles/ldr.bmp diff --git a/lib/astc-encoder/Test/Data/Tiles/ldr.dds b/external/astc-encoder/Test/Data/Tiles/ldr.dds similarity index 100% rename from lib/astc-encoder/Test/Data/Tiles/ldr.dds rename to external/astc-encoder/Test/Data/Tiles/ldr.dds diff --git a/lib/astc-encoder/Test/Data/Tiles/ldr.jpg b/external/astc-encoder/Test/Data/Tiles/ldr.jpg similarity index 100% rename from lib/astc-encoder/Test/Data/Tiles/ldr.jpg rename to external/astc-encoder/Test/Data/Tiles/ldr.jpg diff --git a/lib/astc-encoder/Test/Data/Tiles/ldr.ktx b/external/astc-encoder/Test/Data/Tiles/ldr.ktx similarity index 100% rename from lib/astc-encoder/Test/Data/Tiles/ldr.ktx rename to external/astc-encoder/Test/Data/Tiles/ldr.ktx diff --git a/lib/astc-encoder/Test/Data/Tiles/ldr.png b/external/astc-encoder/Test/Data/Tiles/ldr.png similarity index 100% rename from lib/astc-encoder/Test/Data/Tiles/ldr.png rename to external/astc-encoder/Test/Data/Tiles/ldr.png diff --git a/lib/astc-encoder/Test/Data/Tiles/ldr.tga b/external/astc-encoder/Test/Data/Tiles/ldr.tga similarity index 100% rename from lib/astc-encoder/Test/Data/Tiles/ldr.tga rename to external/astc-encoder/Test/Data/Tiles/ldr.tga diff --git a/lib/astc-encoder/Test/Data/Tiles/ldr_0.png b/external/astc-encoder/Test/Data/Tiles/ldr_0.png similarity index 100% rename from lib/astc-encoder/Test/Data/Tiles/ldr_0.png rename to external/astc-encoder/Test/Data/Tiles/ldr_0.png diff --git a/lib/astc-encoder/Test/Data/Tiles/ldr_1.png b/external/astc-encoder/Test/Data/Tiles/ldr_1.png similarity index 100% rename from lib/astc-encoder/Test/Data/Tiles/ldr_1.png rename to external/astc-encoder/Test/Data/Tiles/ldr_1.png diff --git a/lib/astc-encoder/Test/Data/empty.unk b/external/astc-encoder/Test/Data/empty.unk similarity index 100% rename from lib/astc-encoder/Test/Data/empty.unk rename to external/astc-encoder/Test/Data/empty.unk diff --git a/lib/astc-encoder/Test/DocSource/astc_image_info.rst b/external/astc-encoder/Test/DocSource/astc_image_info.rst similarity index 100% rename from lib/astc-encoder/Test/DocSource/astc_image_info.rst rename to external/astc-encoder/Test/DocSource/astc_image_info.rst diff --git a/lib/astc-encoder/Test/DocSource/astc_size_binary.rst b/external/astc-encoder/Test/DocSource/astc_size_binary.rst similarity index 100% rename from lib/astc-encoder/Test/DocSource/astc_size_binary.rst rename to external/astc-encoder/Test/DocSource/astc_size_binary.rst diff --git a/lib/astc-encoder/Test/DocSource/astc_test_functional.rst b/external/astc-encoder/Test/DocSource/astc_test_functional.rst similarity index 100% rename from lib/astc-encoder/Test/DocSource/astc_test_functional.rst rename to external/astc-encoder/Test/DocSource/astc_test_functional.rst diff --git a/lib/astc-encoder/Test/DocSource/astc_test_image.rst b/external/astc-encoder/Test/DocSource/astc_test_image.rst similarity index 100% rename from lib/astc-encoder/Test/DocSource/astc_test_image.rst rename to external/astc-encoder/Test/DocSource/astc_test_image.rst diff --git a/lib/astc-encoder/Test/DocSource/astc_test_image_dl.rst b/external/astc-encoder/Test/DocSource/astc_test_image_dl.rst similarity index 100% rename from lib/astc-encoder/Test/DocSource/astc_test_image_dl.rst rename to external/astc-encoder/Test/DocSource/astc_test_image_dl.rst diff --git a/lib/astc-encoder/Test/DocSource/conf.py b/external/astc-encoder/Test/DocSource/conf.py similarity index 100% rename from lib/astc-encoder/Test/DocSource/conf.py rename to external/astc-encoder/Test/DocSource/conf.py diff --git a/lib/astc-encoder/Test/DocSource/index.rst b/external/astc-encoder/Test/DocSource/index.rst similarity index 100% rename from lib/astc-encoder/Test/DocSource/index.rst rename to external/astc-encoder/Test/DocSource/index.rst diff --git a/lib/astc-encoder/Test/DocSource/testlib-encoder.rst b/external/astc-encoder/Test/DocSource/testlib-encoder.rst similarity index 100% rename from lib/astc-encoder/Test/DocSource/testlib-encoder.rst rename to external/astc-encoder/Test/DocSource/testlib-encoder.rst diff --git a/lib/astc-encoder/Test/DocSource/testlib-image.rst b/external/astc-encoder/Test/DocSource/testlib-image.rst similarity index 100% rename from lib/astc-encoder/Test/DocSource/testlib-image.rst rename to external/astc-encoder/Test/DocSource/testlib-image.rst diff --git a/lib/astc-encoder/Test/DocSource/testlib-misc.rst b/external/astc-encoder/Test/DocSource/testlib-misc.rst similarity index 100% rename from lib/astc-encoder/Test/DocSource/testlib-misc.rst rename to external/astc-encoder/Test/DocSource/testlib-misc.rst diff --git a/lib/astc-encoder/Test/DocSource/testlib-resultset.rst b/external/astc-encoder/Test/DocSource/testlib-resultset.rst similarity index 100% rename from lib/astc-encoder/Test/DocSource/testlib-resultset.rst rename to external/astc-encoder/Test/DocSource/testlib-resultset.rst diff --git a/lib/astc-encoder/Test/DocSource/testlib-testset.rst b/external/astc-encoder/Test/DocSource/testlib-testset.rst similarity index 100% rename from lib/astc-encoder/Test/DocSource/testlib-testset.rst rename to external/astc-encoder/Test/DocSource/testlib-testset.rst diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/HDR-RGB/hdr-rgb-arboretum.exr b/external/astc-encoder/Test/Images/HDRIHaven/HDR-RGB/hdr-rgb-arboretum.exr similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/HDR-RGB/hdr-rgb-arboretum.exr rename to external/astc-encoder/Test/Images/HDRIHaven/HDR-RGB/hdr-rgb-arboretum.exr diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/HDR-RGB/hdr-rgb-arboretum.hdr b/external/astc-encoder/Test/Images/HDRIHaven/HDR-RGB/hdr-rgb-arboretum.hdr similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/HDR-RGB/hdr-rgb-arboretum.hdr rename to external/astc-encoder/Test/Images/HDRIHaven/HDR-RGB/hdr-rgb-arboretum.hdr diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/HDR-RGB/hdr-rgb-bellparkpier.hdr b/external/astc-encoder/Test/Images/HDRIHaven/HDR-RGB/hdr-rgb-bellparkpier.hdr similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/HDR-RGB/hdr-rgb-bellparkpier.hdr rename to external/astc-encoder/Test/Images/HDRIHaven/HDR-RGB/hdr-rgb-bellparkpier.hdr diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/HDR-RGB/hdr-rgb-canarywharf.hdr b/external/astc-encoder/Test/Images/HDRIHaven/HDR-RGB/hdr-rgb-canarywharf.hdr similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/HDR-RGB/hdr-rgb-canarywharf.hdr rename to external/astc-encoder/Test/Images/HDRIHaven/HDR-RGB/hdr-rgb-canarywharf.hdr diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/HDR-RGB/hdr-rgb-eveningroad.hdr b/external/astc-encoder/Test/Images/HDRIHaven/HDR-RGB/hdr-rgb-eveningroad.hdr similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/HDR-RGB/hdr-rgb-eveningroad.hdr rename to external/astc-encoder/Test/Images/HDRIHaven/HDR-RGB/hdr-rgb-eveningroad.hdr diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/HDR-RGB/hdr-rgb-riverwalk.hdr b/external/astc-encoder/Test/Images/HDRIHaven/HDR-RGB/hdr-rgb-riverwalk.hdr similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/HDR-RGB/hdr-rgb-riverwalk.hdr rename to external/astc-encoder/Test/Images/HDRIHaven/HDR-RGB/hdr-rgb-riverwalk.hdr diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/LICENSE.txt b/external/astc-encoder/Test/Images/HDRIHaven/LICENSE.txt similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/LICENSE.txt rename to external/astc-encoder/Test/Images/HDRIHaven/LICENSE.txt diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-1.7_fast_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-1.7_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-1.7_fast_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-1.7_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-1.7_fastest_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-1.7_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-1.7_fastest_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-1.7_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-1.7_medium_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-1.7_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-1.7_medium_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-1.7_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-1.7_thorough_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-1.7_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-1.7_thorough_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-1.7_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-2.5-avx2_fast_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-2.5-avx2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-2.5-avx2_fast_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-2.5-avx2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-2.5-avx2_fastest_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-2.5-avx2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-2.5-avx2_fastest_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-2.5-avx2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-2.5-avx2_medium_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-2.5-avx2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-2.5-avx2_medium_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-2.5-avx2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-2.5-avx2_thorough_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-2.5-avx2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-2.5-avx2_thorough_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-2.5-avx2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-2.5-sse2_fast_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-2.5-sse2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-2.5-sse2_fast_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-2.5-sse2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-2.5-sse2_fastest_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-2.5-sse2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-2.5-sse2_fastest_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-2.5-sse2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-2.5-sse2_medium_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-2.5-sse2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-2.5-sse2_medium_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-2.5-sse2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-2.5-sse2_thorough_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-2.5-sse2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-2.5-sse2_thorough_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-2.5-sse2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-2.5-sse4.1_fast_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-2.5-sse4.1_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-2.5-sse4.1_fast_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-2.5-sse4.1_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-2.5-sse4.1_fastest_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-2.5-sse4.1_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-2.5-sse4.1_fastest_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-2.5-sse4.1_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-2.5-sse4.1_medium_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-2.5-sse4.1_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-2.5-sse4.1_medium_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-2.5-sse4.1_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-2.5-sse4.1_thorough_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-2.5-sse4.1_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-2.5-sse4.1_thorough_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-2.5-sse4.1_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.6-avx2_fast_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.6-avx2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.6-avx2_fast_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.6-avx2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.6-avx2_fastest_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.6-avx2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.6-avx2_fastest_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.6-avx2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.6-avx2_medium_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.6-avx2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.6-avx2_medium_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.6-avx2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.6-avx2_thorough_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.6-avx2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.6-avx2_thorough_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.6-avx2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.6-sse2_fast_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.6-sse2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.6-sse2_fast_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.6-sse2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.6-sse2_fastest_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.6-sse2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.6-sse2_fastest_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.6-sse2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.6-sse2_medium_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.6-sse2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.6-sse2_medium_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.6-sse2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.6-sse2_thorough_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.6-sse2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.6-sse2_thorough_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.6-sse2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.6-sse4.1_fast_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.6-sse4.1_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.6-sse4.1_fast_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.6-sse4.1_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.6-sse4.1_fastest_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.6-sse4.1_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.6-sse4.1_fastest_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.6-sse4.1_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.6-sse4.1_medium_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.6-sse4.1_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.6-sse4.1_medium_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.6-sse4.1_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.6-sse4.1_thorough_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.6-sse4.1_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.6-sse4.1_thorough_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.6-sse4.1_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.7-avx2_fast_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.7-avx2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.7-avx2_fast_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.7-avx2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.7-avx2_fastest_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.7-avx2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.7-avx2_fastest_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.7-avx2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.7-avx2_medium_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.7-avx2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.7-avx2_medium_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.7-avx2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.7-avx2_thorough_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.7-avx2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.7-avx2_thorough_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.7-avx2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.7-sse2_fast_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.7-sse2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.7-sse2_fast_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.7-sse2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.7-sse2_fastest_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.7-sse2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.7-sse2_fastest_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.7-sse2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.7-sse2_medium_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.7-sse2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.7-sse2_medium_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.7-sse2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.7-sse2_thorough_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.7-sse2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.7-sse2_thorough_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.7-sse2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.7-sse4.1_fast_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.7-sse4.1_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.7-sse4.1_fast_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.7-sse4.1_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.7-sse4.1_fastest_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.7-sse4.1_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.7-sse4.1_fastest_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.7-sse4.1_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.7-sse4.1_medium_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.7-sse4.1_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.7-sse4.1_medium_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.7-sse4.1_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.7-sse4.1_thorough_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.7-sse4.1_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.7-sse4.1_thorough_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-3.7-sse4.1_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.3-avx2_fast_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.3-avx2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.3-avx2_fast_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.3-avx2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.3-avx2_fastest_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.3-avx2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.3-avx2_fastest_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.3-avx2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.3-avx2_medium_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.3-avx2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.3-avx2_medium_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.3-avx2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.3-avx2_thorough_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.3-avx2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.3-avx2_thorough_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.3-avx2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.3-sse2_fast_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.3-sse2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.3-sse2_fast_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.3-sse2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.3-sse2_fastest_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.3-sse2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.3-sse2_fastest_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.3-sse2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.3-sse2_medium_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.3-sse2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.3-sse2_medium_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.3-sse2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.3-sse2_thorough_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.3-sse2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.3-sse2_thorough_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.3-sse2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.3-sse4.1_fast_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.3-sse4.1_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.3-sse4.1_fast_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.3-sse4.1_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.3-sse4.1_fastest_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.3-sse4.1_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.3-sse4.1_fastest_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.3-sse4.1_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.3-sse4.1_medium_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.3-sse4.1_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.3-sse4.1_medium_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.3-sse4.1_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.3-sse4.1_thorough_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.3-sse4.1_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.3-sse4.1_thorough_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.3-sse4.1_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.4-avx2_fast_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.4-avx2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.4-avx2_fast_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.4-avx2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.4-avx2_fastest_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.4-avx2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.4-avx2_fastest_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.4-avx2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.4-avx2_medium_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.4-avx2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.4-avx2_medium_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.4-avx2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.4-avx2_thorough_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.4-avx2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.4-avx2_thorough_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.4-avx2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.4-sse2_fast_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.4-sse2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.4-sse2_fast_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.4-sse2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.4-sse2_fastest_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.4-sse2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.4-sse2_fastest_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.4-sse2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.4-sse2_medium_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.4-sse2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.4-sse2_medium_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.4-sse2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.4-sse2_thorough_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.4-sse2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.4-sse2_thorough_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.4-sse2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.4-sse4.1_fast_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.4-sse4.1_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.4-sse4.1_fast_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.4-sse4.1_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.4-sse4.1_fastest_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.4-sse4.1_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.4-sse4.1_fastest_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.4-sse4.1_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.4-sse4.1_medium_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.4-sse4.1_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.4-sse4.1_medium_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.4-sse4.1_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.4-sse4.1_thorough_results.csv b/external/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.4-sse4.1_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.4-sse4.1_thorough_results.csv rename to external/astc-encoder/Test/Images/HDRIHaven/astc_reference-4.4-sse4.1_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/LDR-L/ldr-l-occlusion.png b/external/astc-encoder/Test/Images/Khronos/LDR-L/ldr-l-occlusion.png similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/LDR-L/ldr-l-occlusion.png rename to external/astc-encoder/Test/Images/Khronos/LDR-L/ldr-l-occlusion.png diff --git a/lib/astc-encoder/Test/Images/Khronos/LDR-RGB/ldr-rgb-diffuse.png b/external/astc-encoder/Test/Images/Khronos/LDR-RGB/ldr-rgb-diffuse.png similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/LDR-RGB/ldr-rgb-diffuse.png rename to external/astc-encoder/Test/Images/Khronos/LDR-RGB/ldr-rgb-diffuse.png diff --git a/lib/astc-encoder/Test/Images/Khronos/LDR-RGB/ldr-rgb-emissive.png b/external/astc-encoder/Test/Images/Khronos/LDR-RGB/ldr-rgb-emissive.png similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/LDR-RGB/ldr-rgb-emissive.png rename to external/astc-encoder/Test/Images/Khronos/LDR-RGB/ldr-rgb-emissive.png diff --git a/lib/astc-encoder/Test/Images/Khronos/LDR-RGB/ldr-rgb-metalrough.png b/external/astc-encoder/Test/Images/Khronos/LDR-RGB/ldr-rgb-metalrough.png similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/LDR-RGB/ldr-rgb-metalrough.png rename to external/astc-encoder/Test/Images/Khronos/LDR-RGB/ldr-rgb-metalrough.png diff --git a/lib/astc-encoder/Test/Images/Khronos/LDR-RGB/ldr-rgb-metalrough2.png b/external/astc-encoder/Test/Images/Khronos/LDR-RGB/ldr-rgb-metalrough2.png similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/LDR-RGB/ldr-rgb-metalrough2.png rename to external/astc-encoder/Test/Images/Khronos/LDR-RGB/ldr-rgb-metalrough2.png diff --git a/lib/astc-encoder/Test/Images/Khronos/LDR-RGBA/ldr-rgba-base.png b/external/astc-encoder/Test/Images/Khronos/LDR-RGBA/ldr-rgba-base.png similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/LDR-RGBA/ldr-rgba-base.png rename to external/astc-encoder/Test/Images/Khronos/LDR-RGBA/ldr-rgba-base.png diff --git a/lib/astc-encoder/Test/Images/Khronos/LDR-RGBA/ldr-rgba-diffuse.png b/external/astc-encoder/Test/Images/Khronos/LDR-RGBA/ldr-rgba-diffuse.png similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/LDR-RGBA/ldr-rgba-diffuse.png rename to external/astc-encoder/Test/Images/Khronos/LDR-RGBA/ldr-rgba-diffuse.png diff --git a/lib/astc-encoder/Test/Images/Khronos/LDR-RGBA/ldr-rgba-specgloss.png b/external/astc-encoder/Test/Images/Khronos/LDR-RGBA/ldr-rgba-specgloss.png similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/LDR-RGBA/ldr-rgba-specgloss.png rename to external/astc-encoder/Test/Images/Khronos/LDR-RGBA/ldr-rgba-specgloss.png diff --git a/lib/astc-encoder/Test/Images/Khronos/LDR-XY/ldr-xy-normal1.png b/external/astc-encoder/Test/Images/Khronos/LDR-XY/ldr-xy-normal1.png similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/LDR-XY/ldr-xy-normal1.png rename to external/astc-encoder/Test/Images/Khronos/LDR-XY/ldr-xy-normal1.png diff --git a/lib/astc-encoder/Test/Images/Khronos/LDR-XY/ldr-xy-normal2.png b/external/astc-encoder/Test/Images/Khronos/LDR-XY/ldr-xy-normal2.png similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/LDR-XY/ldr-xy-normal2.png rename to external/astc-encoder/Test/Images/Khronos/LDR-XY/ldr-xy-normal2.png diff --git a/lib/astc-encoder/Test/Images/Khronos/LICENSE.txt b/external/astc-encoder/Test/Images/Khronos/LICENSE.txt similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/LICENSE.txt rename to external/astc-encoder/Test/Images/Khronos/LICENSE.txt diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-1.7_fast_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-1.7_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-1.7_fast_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-1.7_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-1.7_fastest_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-1.7_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-1.7_fastest_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-1.7_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-1.7_medium_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-1.7_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-1.7_medium_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-1.7_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-1.7_thorough_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-1.7_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-1.7_thorough_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-1.7_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-2.5-avx2_fast_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-2.5-avx2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-2.5-avx2_fast_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-2.5-avx2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-2.5-avx2_fastest_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-2.5-avx2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-2.5-avx2_fastest_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-2.5-avx2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-2.5-avx2_medium_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-2.5-avx2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-2.5-avx2_medium_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-2.5-avx2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-2.5-avx2_thorough_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-2.5-avx2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-2.5-avx2_thorough_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-2.5-avx2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-2.5-sse2_fast_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-2.5-sse2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-2.5-sse2_fast_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-2.5-sse2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-2.5-sse2_fastest_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-2.5-sse2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-2.5-sse2_fastest_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-2.5-sse2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-2.5-sse2_medium_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-2.5-sse2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-2.5-sse2_medium_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-2.5-sse2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-2.5-sse2_thorough_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-2.5-sse2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-2.5-sse2_thorough_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-2.5-sse2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-2.5-sse4.1_fast_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-2.5-sse4.1_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-2.5-sse4.1_fast_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-2.5-sse4.1_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-2.5-sse4.1_fastest_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-2.5-sse4.1_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-2.5-sse4.1_fastest_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-2.5-sse4.1_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-2.5-sse4.1_medium_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-2.5-sse4.1_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-2.5-sse4.1_medium_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-2.5-sse4.1_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-2.5-sse4.1_thorough_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-2.5-sse4.1_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-2.5-sse4.1_thorough_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-2.5-sse4.1_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-3.6-avx2_fast_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-3.6-avx2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-3.6-avx2_fast_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-3.6-avx2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-3.6-avx2_fastest_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-3.6-avx2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-3.6-avx2_fastest_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-3.6-avx2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-3.6-avx2_medium_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-3.6-avx2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-3.6-avx2_medium_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-3.6-avx2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-3.6-avx2_thorough_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-3.6-avx2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-3.6-avx2_thorough_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-3.6-avx2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-3.6-sse2_fast_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-3.6-sse2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-3.6-sse2_fast_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-3.6-sse2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-3.6-sse2_fastest_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-3.6-sse2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-3.6-sse2_fastest_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-3.6-sse2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-3.6-sse2_medium_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-3.6-sse2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-3.6-sse2_medium_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-3.6-sse2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-3.6-sse2_thorough_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-3.6-sse2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-3.6-sse2_thorough_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-3.6-sse2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-3.6-sse4.1_fast_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-3.6-sse4.1_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-3.6-sse4.1_fast_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-3.6-sse4.1_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-3.6-sse4.1_fastest_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-3.6-sse4.1_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-3.6-sse4.1_fastest_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-3.6-sse4.1_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-3.6-sse4.1_medium_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-3.6-sse4.1_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-3.6-sse4.1_medium_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-3.6-sse4.1_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-3.6-sse4.1_thorough_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-3.6-sse4.1_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-3.6-sse4.1_thorough_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-3.6-sse4.1_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-3.7-avx2_fast_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-3.7-avx2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-3.7-avx2_fast_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-3.7-avx2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-3.7-avx2_fastest_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-3.7-avx2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-3.7-avx2_fastest_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-3.7-avx2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-3.7-avx2_medium_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-3.7-avx2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-3.7-avx2_medium_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-3.7-avx2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-3.7-avx2_thorough_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-3.7-avx2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-3.7-avx2_thorough_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-3.7-avx2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-3.7-sse2_fast_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-3.7-sse2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-3.7-sse2_fast_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-3.7-sse2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-3.7-sse2_fastest_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-3.7-sse2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-3.7-sse2_fastest_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-3.7-sse2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-3.7-sse2_medium_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-3.7-sse2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-3.7-sse2_medium_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-3.7-sse2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-3.7-sse2_thorough_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-3.7-sse2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-3.7-sse2_thorough_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-3.7-sse2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-3.7-sse4.1_fast_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-3.7-sse4.1_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-3.7-sse4.1_fast_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-3.7-sse4.1_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-3.7-sse4.1_fastest_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-3.7-sse4.1_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-3.7-sse4.1_fastest_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-3.7-sse4.1_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-3.7-sse4.1_medium_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-3.7-sse4.1_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-3.7-sse4.1_medium_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-3.7-sse4.1_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-3.7-sse4.1_thorough_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-3.7-sse4.1_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-3.7-sse4.1_thorough_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-3.7-sse4.1_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-4.3-avx2_fast_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-4.3-avx2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-4.3-avx2_fast_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-4.3-avx2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-4.3-avx2_fastest_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-4.3-avx2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-4.3-avx2_fastest_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-4.3-avx2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-4.3-avx2_medium_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-4.3-avx2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-4.3-avx2_medium_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-4.3-avx2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-4.3-avx2_thorough_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-4.3-avx2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-4.3-avx2_thorough_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-4.3-avx2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-4.3-sse2_fast_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-4.3-sse2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-4.3-sse2_fast_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-4.3-sse2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-4.3-sse2_fastest_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-4.3-sse2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-4.3-sse2_fastest_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-4.3-sse2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-4.3-sse2_medium_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-4.3-sse2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-4.3-sse2_medium_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-4.3-sse2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-4.3-sse2_thorough_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-4.3-sse2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-4.3-sse2_thorough_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-4.3-sse2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-4.3-sse4.1_fast_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-4.3-sse4.1_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-4.3-sse4.1_fast_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-4.3-sse4.1_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-4.3-sse4.1_fastest_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-4.3-sse4.1_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-4.3-sse4.1_fastest_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-4.3-sse4.1_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-4.3-sse4.1_medium_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-4.3-sse4.1_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-4.3-sse4.1_medium_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-4.3-sse4.1_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-4.3-sse4.1_thorough_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-4.3-sse4.1_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-4.3-sse4.1_thorough_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-4.3-sse4.1_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-4.4-avx2_fast_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-4.4-avx2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-4.4-avx2_fast_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-4.4-avx2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-4.4-avx2_fastest_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-4.4-avx2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-4.4-avx2_fastest_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-4.4-avx2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-4.4-avx2_medium_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-4.4-avx2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-4.4-avx2_medium_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-4.4-avx2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-4.4-avx2_thorough_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-4.4-avx2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-4.4-avx2_thorough_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-4.4-avx2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-4.4-sse2_fast_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-4.4-sse2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-4.4-sse2_fast_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-4.4-sse2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-4.4-sse2_fastest_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-4.4-sse2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-4.4-sse2_fastest_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-4.4-sse2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-4.4-sse2_medium_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-4.4-sse2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-4.4-sse2_medium_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-4.4-sse2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-4.4-sse2_thorough_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-4.4-sse2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-4.4-sse2_thorough_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-4.4-sse2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-4.4-sse4.1_fast_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-4.4-sse4.1_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-4.4-sse4.1_fast_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-4.4-sse4.1_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-4.4-sse4.1_fastest_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-4.4-sse4.1_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-4.4-sse4.1_fastest_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-4.4-sse4.1_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-4.4-sse4.1_medium_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-4.4-sse4.1_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-4.4-sse4.1_medium_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-4.4-sse4.1_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/Khronos/astc_reference-4.4-sse4.1_thorough_results.csv b/external/astc-encoder/Test/Images/Khronos/astc_reference-4.4-sse4.1_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Khronos/astc_reference-4.4-sse4.1_thorough_results.csv rename to external/astc-encoder/Test/Images/Khronos/astc_reference-4.4-sse4.1_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-1.7_fast_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-1.7_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-1.7_fast_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-1.7_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-1.7_fastest_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-1.7_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-1.7_fastest_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-1.7_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-1.7_medium_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-1.7_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-1.7_medium_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-1.7_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-1.7_thorough_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-1.7_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-1.7_thorough_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-1.7_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-2.5-avx2_fast_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-2.5-avx2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-2.5-avx2_fast_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-2.5-avx2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-2.5-avx2_fastest_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-2.5-avx2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-2.5-avx2_fastest_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-2.5-avx2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-2.5-avx2_medium_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-2.5-avx2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-2.5-avx2_medium_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-2.5-avx2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-2.5-avx2_thorough_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-2.5-avx2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-2.5-avx2_thorough_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-2.5-avx2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-2.5-sse2_fast_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-2.5-sse2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-2.5-sse2_fast_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-2.5-sse2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-2.5-sse2_fastest_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-2.5-sse2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-2.5-sse2_fastest_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-2.5-sse2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-2.5-sse2_medium_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-2.5-sse2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-2.5-sse2_medium_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-2.5-sse2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-2.5-sse2_thorough_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-2.5-sse2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-2.5-sse2_thorough_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-2.5-sse2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-2.5-sse4.1_fast_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-2.5-sse4.1_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-2.5-sse4.1_fast_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-2.5-sse4.1_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-2.5-sse4.1_fastest_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-2.5-sse4.1_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-2.5-sse4.1_fastest_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-2.5-sse4.1_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-2.5-sse4.1_medium_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-2.5-sse4.1_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-2.5-sse4.1_medium_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-2.5-sse4.1_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-2.5-sse4.1_thorough_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-2.5-sse4.1_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-2.5-sse4.1_thorough_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-2.5-sse4.1_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-3.6-avx2_fast_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-3.6-avx2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-3.6-avx2_fast_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-3.6-avx2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-3.6-avx2_fastest_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-3.6-avx2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-3.6-avx2_fastest_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-3.6-avx2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-3.6-avx2_medium_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-3.6-avx2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-3.6-avx2_medium_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-3.6-avx2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-3.6-avx2_thorough_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-3.6-avx2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-3.6-avx2_thorough_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-3.6-avx2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-3.6-sse2_fast_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-3.6-sse2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-3.6-sse2_fast_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-3.6-sse2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-3.6-sse2_fastest_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-3.6-sse2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-3.6-sse2_fastest_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-3.6-sse2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-3.6-sse2_medium_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-3.6-sse2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-3.6-sse2_medium_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-3.6-sse2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-3.6-sse2_thorough_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-3.6-sse2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-3.6-sse2_thorough_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-3.6-sse2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-3.6-sse4.1_fast_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-3.6-sse4.1_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-3.6-sse4.1_fast_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-3.6-sse4.1_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-3.6-sse4.1_fastest_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-3.6-sse4.1_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-3.6-sse4.1_fastest_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-3.6-sse4.1_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-3.6-sse4.1_medium_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-3.6-sse4.1_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-3.6-sse4.1_medium_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-3.6-sse4.1_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-3.6-sse4.1_thorough_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-3.6-sse4.1_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-3.6-sse4.1_thorough_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-3.6-sse4.1_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-3.7-avx2_fast_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-3.7-avx2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-3.7-avx2_fast_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-3.7-avx2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-3.7-avx2_fastest_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-3.7-avx2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-3.7-avx2_fastest_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-3.7-avx2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-3.7-avx2_medium_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-3.7-avx2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-3.7-avx2_medium_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-3.7-avx2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-3.7-avx2_thorough_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-3.7-avx2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-3.7-avx2_thorough_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-3.7-avx2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-3.7-sse2_fast_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-3.7-sse2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-3.7-sse2_fast_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-3.7-sse2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-3.7-sse2_fastest_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-3.7-sse2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-3.7-sse2_fastest_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-3.7-sse2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-3.7-sse2_medium_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-3.7-sse2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-3.7-sse2_medium_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-3.7-sse2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-3.7-sse2_thorough_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-3.7-sse2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-3.7-sse2_thorough_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-3.7-sse2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-3.7-sse4.1_fast_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-3.7-sse4.1_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-3.7-sse4.1_fast_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-3.7-sse4.1_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-3.7-sse4.1_fastest_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-3.7-sse4.1_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-3.7-sse4.1_fastest_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-3.7-sse4.1_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-3.7-sse4.1_medium_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-3.7-sse4.1_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-3.7-sse4.1_medium_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-3.7-sse4.1_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-3.7-sse4.1_thorough_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-3.7-sse4.1_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-3.7-sse4.1_thorough_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-3.7-sse4.1_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-4.3-avx2_fast_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-4.3-avx2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-4.3-avx2_fast_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-4.3-avx2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-4.3-avx2_fastest_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-4.3-avx2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-4.3-avx2_fastest_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-4.3-avx2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-4.3-avx2_medium_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-4.3-avx2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-4.3-avx2_medium_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-4.3-avx2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-4.3-avx2_thorough_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-4.3-avx2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-4.3-avx2_thorough_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-4.3-avx2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-4.3-sse2_fast_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-4.3-sse2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-4.3-sse2_fast_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-4.3-sse2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-4.3-sse2_fastest_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-4.3-sse2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-4.3-sse2_fastest_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-4.3-sse2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-4.3-sse2_medium_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-4.3-sse2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-4.3-sse2_medium_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-4.3-sse2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-4.3-sse2_thorough_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-4.3-sse2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-4.3-sse2_thorough_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-4.3-sse2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-4.3-sse4.1_fast_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-4.3-sse4.1_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-4.3-sse4.1_fast_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-4.3-sse4.1_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-4.3-sse4.1_fastest_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-4.3-sse4.1_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-4.3-sse4.1_fastest_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-4.3-sse4.1_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-4.3-sse4.1_medium_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-4.3-sse4.1_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-4.3-sse4.1_medium_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-4.3-sse4.1_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-4.3-sse4.1_thorough_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-4.3-sse4.1_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-4.3-sse4.1_thorough_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-4.3-sse4.1_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-4.4-avx2_fast_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-4.4-avx2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-4.4-avx2_fast_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-4.4-avx2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-4.4-avx2_fastest_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-4.4-avx2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-4.4-avx2_fastest_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-4.4-avx2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-4.4-avx2_medium_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-4.4-avx2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-4.4-avx2_medium_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-4.4-avx2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-4.4-avx2_thorough_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-4.4-avx2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-4.4-avx2_thorough_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-4.4-avx2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-4.4-sse2_fast_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-4.4-sse2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-4.4-sse2_fast_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-4.4-sse2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-4.4-sse2_fastest_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-4.4-sse2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-4.4-sse2_fastest_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-4.4-sse2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-4.4-sse2_medium_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-4.4-sse2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-4.4-sse2_medium_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-4.4-sse2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-4.4-sse2_thorough_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-4.4-sse2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-4.4-sse2_thorough_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-4.4-sse2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-4.4-sse4.1_fast_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-4.4-sse4.1_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-4.4-sse4.1_fast_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-4.4-sse4.1_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-4.4-sse4.1_fastest_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-4.4-sse4.1_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-4.4-sse4.1_fastest_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-4.4-sse4.1_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-4.4-sse4.1_medium_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-4.4-sse4.1_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-4.4-sse4.1_medium_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-4.4-sse4.1_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/Kodak/astc_reference-4.4-sse4.1_thorough_results.csv b/external/astc-encoder/Test/Images/Kodak/astc_reference-4.4-sse4.1_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Kodak/astc_reference-4.4-sse4.1_thorough_results.csv rename to external/astc-encoder/Test/Images/Kodak/astc_reference-4.4-sse4.1_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-1.7_fast_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-1.7_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-1.7_fast_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-1.7_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-1.7_fastest_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-1.7_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-1.7_fastest_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-1.7_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-1.7_medium_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-1.7_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-1.7_medium_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-1.7_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-1.7_thorough_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-1.7_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-1.7_thorough_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-1.7_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-2.5-avx2_fast_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-2.5-avx2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-2.5-avx2_fast_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-2.5-avx2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-2.5-avx2_fastest_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-2.5-avx2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-2.5-avx2_fastest_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-2.5-avx2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-2.5-avx2_medium_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-2.5-avx2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-2.5-avx2_medium_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-2.5-avx2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-2.5-avx2_thorough_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-2.5-avx2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-2.5-avx2_thorough_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-2.5-avx2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-2.5-sse2_fast_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-2.5-sse2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-2.5-sse2_fast_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-2.5-sse2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-2.5-sse2_fastest_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-2.5-sse2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-2.5-sse2_fastest_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-2.5-sse2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-2.5-sse2_medium_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-2.5-sse2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-2.5-sse2_medium_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-2.5-sse2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-2.5-sse2_thorough_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-2.5-sse2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-2.5-sse2_thorough_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-2.5-sse2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-2.5-sse4.1_fast_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-2.5-sse4.1_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-2.5-sse4.1_fast_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-2.5-sse4.1_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-2.5-sse4.1_fastest_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-2.5-sse4.1_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-2.5-sse4.1_fastest_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-2.5-sse4.1_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-2.5-sse4.1_medium_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-2.5-sse4.1_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-2.5-sse4.1_medium_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-2.5-sse4.1_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-2.5-sse4.1_thorough_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-2.5-sse4.1_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-2.5-sse4.1_thorough_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-2.5-sse4.1_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-3.6-avx2_fast_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-3.6-avx2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-3.6-avx2_fast_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-3.6-avx2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-3.6-avx2_fastest_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-3.6-avx2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-3.6-avx2_fastest_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-3.6-avx2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-3.6-avx2_medium_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-3.6-avx2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-3.6-avx2_medium_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-3.6-avx2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-3.6-avx2_thorough_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-3.6-avx2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-3.6-avx2_thorough_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-3.6-avx2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-3.6-sse2_fast_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-3.6-sse2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-3.6-sse2_fast_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-3.6-sse2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-3.6-sse2_fastest_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-3.6-sse2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-3.6-sse2_fastest_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-3.6-sse2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-3.6-sse2_medium_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-3.6-sse2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-3.6-sse2_medium_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-3.6-sse2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-3.6-sse2_thorough_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-3.6-sse2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-3.6-sse2_thorough_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-3.6-sse2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-3.6-sse4.1_fast_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-3.6-sse4.1_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-3.6-sse4.1_fast_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-3.6-sse4.1_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-3.6-sse4.1_fastest_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-3.6-sse4.1_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-3.6-sse4.1_fastest_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-3.6-sse4.1_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-3.6-sse4.1_medium_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-3.6-sse4.1_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-3.6-sse4.1_medium_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-3.6-sse4.1_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-3.6-sse4.1_thorough_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-3.6-sse4.1_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-3.6-sse4.1_thorough_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-3.6-sse4.1_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-3.7-avx2_fast_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-3.7-avx2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-3.7-avx2_fast_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-3.7-avx2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-3.7-avx2_fastest_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-3.7-avx2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-3.7-avx2_fastest_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-3.7-avx2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-3.7-avx2_medium_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-3.7-avx2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-3.7-avx2_medium_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-3.7-avx2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-3.7-avx2_thorough_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-3.7-avx2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-3.7-avx2_thorough_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-3.7-avx2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-3.7-sse2_fast_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-3.7-sse2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-3.7-sse2_fast_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-3.7-sse2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-3.7-sse2_fastest_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-3.7-sse2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-3.7-sse2_fastest_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-3.7-sse2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-3.7-sse2_medium_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-3.7-sse2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-3.7-sse2_medium_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-3.7-sse2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-3.7-sse2_thorough_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-3.7-sse2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-3.7-sse2_thorough_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-3.7-sse2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-3.7-sse4.1_fast_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-3.7-sse4.1_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-3.7-sse4.1_fast_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-3.7-sse4.1_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-3.7-sse4.1_fastest_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-3.7-sse4.1_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-3.7-sse4.1_fastest_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-3.7-sse4.1_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-3.7-sse4.1_medium_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-3.7-sse4.1_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-3.7-sse4.1_medium_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-3.7-sse4.1_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-3.7-sse4.1_thorough_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-3.7-sse4.1_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-3.7-sse4.1_thorough_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-3.7-sse4.1_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-4.3-avx2_fast_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-4.3-avx2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-4.3-avx2_fast_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-4.3-avx2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-4.3-avx2_fastest_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-4.3-avx2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-4.3-avx2_fastest_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-4.3-avx2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-4.3-avx2_medium_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-4.3-avx2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-4.3-avx2_medium_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-4.3-avx2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-4.3-avx2_thorough_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-4.3-avx2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-4.3-avx2_thorough_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-4.3-avx2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-4.3-sse2_fast_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-4.3-sse2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-4.3-sse2_fast_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-4.3-sse2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-4.3-sse2_fastest_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-4.3-sse2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-4.3-sse2_fastest_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-4.3-sse2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-4.3-sse2_medium_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-4.3-sse2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-4.3-sse2_medium_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-4.3-sse2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-4.3-sse2_thorough_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-4.3-sse2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-4.3-sse2_thorough_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-4.3-sse2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-4.3-sse4.1_fast_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-4.3-sse4.1_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-4.3-sse4.1_fast_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-4.3-sse4.1_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-4.3-sse4.1_fastest_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-4.3-sse4.1_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-4.3-sse4.1_fastest_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-4.3-sse4.1_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-4.3-sse4.1_medium_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-4.3-sse4.1_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-4.3-sse4.1_medium_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-4.3-sse4.1_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-4.3-sse4.1_thorough_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-4.3-sse4.1_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-4.3-sse4.1_thorough_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-4.3-sse4.1_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-4.4-avx2_fast_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-4.4-avx2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-4.4-avx2_fast_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-4.4-avx2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-4.4-avx2_fastest_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-4.4-avx2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-4.4-avx2_fastest_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-4.4-avx2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-4.4-avx2_medium_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-4.4-avx2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-4.4-avx2_medium_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-4.4-avx2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-4.4-avx2_thorough_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-4.4-avx2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-4.4-avx2_thorough_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-4.4-avx2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-4.4-sse2_fast_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-4.4-sse2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-4.4-sse2_fast_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-4.4-sse2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-4.4-sse2_fastest_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-4.4-sse2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-4.4-sse2_fastest_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-4.4-sse2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-4.4-sse2_medium_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-4.4-sse2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-4.4-sse2_medium_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-4.4-sse2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-4.4-sse2_thorough_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-4.4-sse2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-4.4-sse2_thorough_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-4.4-sse2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-4.4-sse4.1_fast_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-4.4-sse4.1_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-4.4-sse4.1_fast_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-4.4-sse4.1_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-4.4-sse4.1_fastest_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-4.4-sse4.1_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-4.4-sse4.1_fastest_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-4.4-sse4.1_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-4.4-sse4.1_medium_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-4.4-sse4.1_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-4.4-sse4.1_medium_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-4.4-sse4.1_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakMnt/astc_reference-4.4-sse4.1_thorough_results.csv b/external/astc-encoder/Test/Images/KodakMnt/astc_reference-4.4-sse4.1_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakMnt/astc_reference-4.4-sse4.1_thorough_results.csv rename to external/astc-encoder/Test/Images/KodakMnt/astc_reference-4.4-sse4.1_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-1.7_fast_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-1.7_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-1.7_fast_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-1.7_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-1.7_fastest_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-1.7_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-1.7_fastest_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-1.7_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-1.7_medium_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-1.7_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-1.7_medium_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-1.7_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-1.7_thorough_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-1.7_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-1.7_thorough_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-1.7_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-2.5-avx2_fast_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-2.5-avx2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-2.5-avx2_fast_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-2.5-avx2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-2.5-avx2_fastest_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-2.5-avx2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-2.5-avx2_fastest_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-2.5-avx2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-2.5-avx2_medium_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-2.5-avx2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-2.5-avx2_medium_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-2.5-avx2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-2.5-avx2_thorough_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-2.5-avx2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-2.5-avx2_thorough_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-2.5-avx2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-2.5-sse2_fast_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-2.5-sse2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-2.5-sse2_fast_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-2.5-sse2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-2.5-sse2_fastest_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-2.5-sse2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-2.5-sse2_fastest_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-2.5-sse2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-2.5-sse2_medium_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-2.5-sse2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-2.5-sse2_medium_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-2.5-sse2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-2.5-sse2_thorough_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-2.5-sse2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-2.5-sse2_thorough_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-2.5-sse2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-2.5-sse4.1_fast_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-2.5-sse4.1_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-2.5-sse4.1_fast_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-2.5-sse4.1_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-2.5-sse4.1_fastest_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-2.5-sse4.1_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-2.5-sse4.1_fastest_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-2.5-sse4.1_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-2.5-sse4.1_medium_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-2.5-sse4.1_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-2.5-sse4.1_medium_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-2.5-sse4.1_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-2.5-sse4.1_thorough_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-2.5-sse4.1_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-2.5-sse4.1_thorough_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-2.5-sse4.1_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-3.6-avx2_fast_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-3.6-avx2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-3.6-avx2_fast_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-3.6-avx2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-3.6-avx2_fastest_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-3.6-avx2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-3.6-avx2_fastest_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-3.6-avx2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-3.6-avx2_medium_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-3.6-avx2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-3.6-avx2_medium_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-3.6-avx2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-3.6-avx2_thorough_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-3.6-avx2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-3.6-avx2_thorough_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-3.6-avx2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-3.6-sse2_fast_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-3.6-sse2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-3.6-sse2_fast_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-3.6-sse2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-3.6-sse2_fastest_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-3.6-sse2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-3.6-sse2_fastest_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-3.6-sse2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-3.6-sse2_medium_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-3.6-sse2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-3.6-sse2_medium_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-3.6-sse2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-3.6-sse2_thorough_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-3.6-sse2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-3.6-sse2_thorough_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-3.6-sse2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-3.6-sse4.1_fast_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-3.6-sse4.1_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-3.6-sse4.1_fast_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-3.6-sse4.1_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-3.6-sse4.1_fastest_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-3.6-sse4.1_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-3.6-sse4.1_fastest_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-3.6-sse4.1_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-3.6-sse4.1_medium_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-3.6-sse4.1_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-3.6-sse4.1_medium_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-3.6-sse4.1_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-3.6-sse4.1_thorough_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-3.6-sse4.1_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-3.6-sse4.1_thorough_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-3.6-sse4.1_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-3.7-avx2_fast_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-3.7-avx2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-3.7-avx2_fast_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-3.7-avx2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-3.7-avx2_fastest_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-3.7-avx2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-3.7-avx2_fastest_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-3.7-avx2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-3.7-avx2_medium_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-3.7-avx2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-3.7-avx2_medium_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-3.7-avx2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-3.7-avx2_thorough_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-3.7-avx2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-3.7-avx2_thorough_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-3.7-avx2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-3.7-sse2_fast_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-3.7-sse2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-3.7-sse2_fast_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-3.7-sse2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-3.7-sse2_fastest_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-3.7-sse2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-3.7-sse2_fastest_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-3.7-sse2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-3.7-sse2_medium_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-3.7-sse2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-3.7-sse2_medium_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-3.7-sse2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-3.7-sse2_thorough_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-3.7-sse2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-3.7-sse2_thorough_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-3.7-sse2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-3.7-sse4.1_fast_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-3.7-sse4.1_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-3.7-sse4.1_fast_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-3.7-sse4.1_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-3.7-sse4.1_fastest_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-3.7-sse4.1_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-3.7-sse4.1_fastest_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-3.7-sse4.1_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-3.7-sse4.1_medium_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-3.7-sse4.1_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-3.7-sse4.1_medium_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-3.7-sse4.1_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-3.7-sse4.1_thorough_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-3.7-sse4.1_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-3.7-sse4.1_thorough_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-3.7-sse4.1_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-4.3-avx2_fast_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-4.3-avx2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-4.3-avx2_fast_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-4.3-avx2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-4.3-avx2_fastest_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-4.3-avx2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-4.3-avx2_fastest_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-4.3-avx2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-4.3-avx2_medium_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-4.3-avx2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-4.3-avx2_medium_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-4.3-avx2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-4.3-avx2_thorough_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-4.3-avx2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-4.3-avx2_thorough_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-4.3-avx2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-4.3-sse2_fast_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-4.3-sse2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-4.3-sse2_fast_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-4.3-sse2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-4.3-sse2_fastest_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-4.3-sse2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-4.3-sse2_fastest_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-4.3-sse2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-4.3-sse2_medium_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-4.3-sse2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-4.3-sse2_medium_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-4.3-sse2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-4.3-sse2_thorough_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-4.3-sse2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-4.3-sse2_thorough_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-4.3-sse2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-4.3-sse4.1_fast_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-4.3-sse4.1_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-4.3-sse4.1_fast_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-4.3-sse4.1_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-4.3-sse4.1_fastest_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-4.3-sse4.1_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-4.3-sse4.1_fastest_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-4.3-sse4.1_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-4.3-sse4.1_medium_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-4.3-sse4.1_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-4.3-sse4.1_medium_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-4.3-sse4.1_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-4.3-sse4.1_thorough_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-4.3-sse4.1_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-4.3-sse4.1_thorough_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-4.3-sse4.1_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-4.4-avx2_fast_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-4.4-avx2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-4.4-avx2_fast_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-4.4-avx2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-4.4-avx2_fastest_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-4.4-avx2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-4.4-avx2_fastest_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-4.4-avx2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-4.4-avx2_medium_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-4.4-avx2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-4.4-avx2_medium_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-4.4-avx2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-4.4-avx2_thorough_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-4.4-avx2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-4.4-avx2_thorough_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-4.4-avx2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-4.4-sse2_fast_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-4.4-sse2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-4.4-sse2_fast_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-4.4-sse2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-4.4-sse2_fastest_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-4.4-sse2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-4.4-sse2_fastest_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-4.4-sse2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-4.4-sse2_medium_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-4.4-sse2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-4.4-sse2_medium_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-4.4-sse2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-4.4-sse2_thorough_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-4.4-sse2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-4.4-sse2_thorough_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-4.4-sse2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-4.4-sse4.1_fast_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-4.4-sse4.1_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-4.4-sse4.1_fast_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-4.4-sse4.1_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-4.4-sse4.1_fastest_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-4.4-sse4.1_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-4.4-sse4.1_fastest_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-4.4-sse4.1_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-4.4-sse4.1_medium_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-4.4-sse4.1_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-4.4-sse4.1_medium_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-4.4-sse4.1_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/KodakSim/astc_reference-4.4-sse4.1_thorough_results.csv b/external/astc-encoder/Test/Images/KodakSim/astc_reference-4.4-sse4.1_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/KodakSim/astc_reference-4.4-sse4.1_thorough_results.csv rename to external/astc-encoder/Test/Images/KodakSim/astc_reference-4.4-sse4.1_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/HDR-RGB/hdr-rgb-00.hdr b/external/astc-encoder/Test/Images/Small/HDR-RGB/hdr-rgb-00.hdr similarity index 100% rename from lib/astc-encoder/Test/Images/Small/HDR-RGB/hdr-rgb-00.hdr rename to external/astc-encoder/Test/Images/Small/HDR-RGB/hdr-rgb-00.hdr diff --git a/lib/astc-encoder/Test/Images/Small/HDR-RGB/hdr-rgb-r16.ktx b/external/astc-encoder/Test/Images/Small/HDR-RGB/hdr-rgb-r16.ktx similarity index 100% rename from lib/astc-encoder/Test/Images/Small/HDR-RGB/hdr-rgb-r16.ktx rename to external/astc-encoder/Test/Images/Small/HDR-RGB/hdr-rgb-r16.ktx diff --git a/lib/astc-encoder/Test/Images/Small/HDR-RGB/hdr-rgb-r32.ktx b/external/astc-encoder/Test/Images/Small/HDR-RGB/hdr-rgb-r32.ktx similarity index 100% rename from lib/astc-encoder/Test/Images/Small/HDR-RGB/hdr-rgb-r32.ktx rename to external/astc-encoder/Test/Images/Small/HDR-RGB/hdr-rgb-r32.ktx diff --git a/lib/astc-encoder/Test/Images/Small/HDR-RGB/hdr-rgb-rg16.ktx b/external/astc-encoder/Test/Images/Small/HDR-RGB/hdr-rgb-rg16.ktx similarity index 100% rename from lib/astc-encoder/Test/Images/Small/HDR-RGB/hdr-rgb-rg16.ktx rename to external/astc-encoder/Test/Images/Small/HDR-RGB/hdr-rgb-rg16.ktx diff --git a/lib/astc-encoder/Test/Images/Small/HDR-RGB/hdr-rgb-rg32.ktx b/external/astc-encoder/Test/Images/Small/HDR-RGB/hdr-rgb-rg32.ktx similarity index 100% rename from lib/astc-encoder/Test/Images/Small/HDR-RGB/hdr-rgb-rg32.ktx rename to external/astc-encoder/Test/Images/Small/HDR-RGB/hdr-rgb-rg32.ktx diff --git a/lib/astc-encoder/Test/Images/Small/HDR-RGB/hdr-rgb-rgb16.ktx b/external/astc-encoder/Test/Images/Small/HDR-RGB/hdr-rgb-rgb16.ktx similarity index 100% rename from lib/astc-encoder/Test/Images/Small/HDR-RGB/hdr-rgb-rgb16.ktx rename to external/astc-encoder/Test/Images/Small/HDR-RGB/hdr-rgb-rgb16.ktx diff --git a/lib/astc-encoder/Test/Images/Small/HDR-RGB/hdr-rgb-rgb32.ktx b/external/astc-encoder/Test/Images/Small/HDR-RGB/hdr-rgb-rgb32.ktx similarity index 100% rename from lib/astc-encoder/Test/Images/Small/HDR-RGB/hdr-rgb-rgb32.ktx rename to external/astc-encoder/Test/Images/Small/HDR-RGB/hdr-rgb-rgb32.ktx diff --git a/lib/astc-encoder/Test/Images/Small/HDR-RGBA/hdr-rgba-rgba16.ktx b/external/astc-encoder/Test/Images/Small/HDR-RGBA/hdr-rgba-rgba16.ktx similarity index 100% rename from lib/astc-encoder/Test/Images/Small/HDR-RGBA/hdr-rgba-rgba16.ktx rename to external/astc-encoder/Test/Images/Small/HDR-RGBA/hdr-rgba-rgba16.ktx diff --git a/lib/astc-encoder/Test/Images/Small/HDR-RGBA/hdr-rgba-rgba32.ktx b/external/astc-encoder/Test/Images/Small/HDR-RGBA/hdr-rgba-rgba32.ktx similarity index 100% rename from lib/astc-encoder/Test/Images/Small/HDR-RGBA/hdr-rgba-rgba32.ktx rename to external/astc-encoder/Test/Images/Small/HDR-RGBA/hdr-rgba-rgba32.ktx diff --git a/lib/astc-encoder/Test/Images/Small/LDR-L/ldr-l-00-3.dds b/external/astc-encoder/Test/Images/Small/LDR-L/ldr-l-00-3.dds similarity index 100% rename from lib/astc-encoder/Test/Images/Small/LDR-L/ldr-l-00-3.dds rename to external/astc-encoder/Test/Images/Small/LDR-L/ldr-l-00-3.dds diff --git a/lib/astc-encoder/Test/Images/Small/LDR-L/ldr-l-01-3.dds b/external/astc-encoder/Test/Images/Small/LDR-L/ldr-l-01-3.dds similarity index 100% rename from lib/astc-encoder/Test/Images/Small/LDR-L/ldr-l-01-3.dds rename to external/astc-encoder/Test/Images/Small/LDR-L/ldr-l-01-3.dds diff --git a/lib/astc-encoder/Test/Images/Small/LDR-RGB/ldr-rgb-00.png b/external/astc-encoder/Test/Images/Small/LDR-RGB/ldr-rgb-00.png similarity index 100% rename from lib/astc-encoder/Test/Images/Small/LDR-RGB/ldr-rgb-00.png rename to external/astc-encoder/Test/Images/Small/LDR-RGB/ldr-rgb-00.png diff --git a/lib/astc-encoder/Test/Images/Small/LDR-RGB/ldr-rgb-01.png b/external/astc-encoder/Test/Images/Small/LDR-RGB/ldr-rgb-01.png similarity index 100% rename from lib/astc-encoder/Test/Images/Small/LDR-RGB/ldr-rgb-01.png rename to external/astc-encoder/Test/Images/Small/LDR-RGB/ldr-rgb-01.png diff --git a/lib/astc-encoder/Test/Images/Small/LDR-RGB/ldr-rgb-02.png b/external/astc-encoder/Test/Images/Small/LDR-RGB/ldr-rgb-02.png similarity index 100% rename from lib/astc-encoder/Test/Images/Small/LDR-RGB/ldr-rgb-02.png rename to external/astc-encoder/Test/Images/Small/LDR-RGB/ldr-rgb-02.png diff --git a/lib/astc-encoder/Test/Images/Small/LDR-RGB/ldr-rgb-03.png b/external/astc-encoder/Test/Images/Small/LDR-RGB/ldr-rgb-03.png similarity index 100% rename from lib/astc-encoder/Test/Images/Small/LDR-RGB/ldr-rgb-03.png rename to external/astc-encoder/Test/Images/Small/LDR-RGB/ldr-rgb-03.png diff --git a/lib/astc-encoder/Test/Images/Small/LDR-RGB/ldr-rgb-04.png b/external/astc-encoder/Test/Images/Small/LDR-RGB/ldr-rgb-04.png similarity index 100% rename from lib/astc-encoder/Test/Images/Small/LDR-RGB/ldr-rgb-04.png rename to external/astc-encoder/Test/Images/Small/LDR-RGB/ldr-rgb-04.png diff --git a/lib/astc-encoder/Test/Images/Small/LDR-RGB/ldr-rgb-05.png b/external/astc-encoder/Test/Images/Small/LDR-RGB/ldr-rgb-05.png similarity index 100% rename from lib/astc-encoder/Test/Images/Small/LDR-RGB/ldr-rgb-05.png rename to external/astc-encoder/Test/Images/Small/LDR-RGB/ldr-rgb-05.png diff --git a/lib/astc-encoder/Test/Images/Small/LDR-RGB/ldr-rgb-06.png b/external/astc-encoder/Test/Images/Small/LDR-RGB/ldr-rgb-06.png similarity index 100% rename from lib/astc-encoder/Test/Images/Small/LDR-RGB/ldr-rgb-06.png rename to external/astc-encoder/Test/Images/Small/LDR-RGB/ldr-rgb-06.png diff --git a/lib/astc-encoder/Test/Images/Small/LDR-RGB/ldr-rgb-07.png b/external/astc-encoder/Test/Images/Small/LDR-RGB/ldr-rgb-07.png similarity index 100% rename from lib/astc-encoder/Test/Images/Small/LDR-RGB/ldr-rgb-07.png rename to external/astc-encoder/Test/Images/Small/LDR-RGB/ldr-rgb-07.png diff --git a/lib/astc-encoder/Test/Images/Small/LDR-RGB/ldr-rgb-08.png b/external/astc-encoder/Test/Images/Small/LDR-RGB/ldr-rgb-08.png similarity index 100% rename from lib/astc-encoder/Test/Images/Small/LDR-RGB/ldr-rgb-08.png rename to external/astc-encoder/Test/Images/Small/LDR-RGB/ldr-rgb-08.png diff --git a/lib/astc-encoder/Test/Images/Small/LDR-RGB/ldr-rgb-09.png b/external/astc-encoder/Test/Images/Small/LDR-RGB/ldr-rgb-09.png similarity index 100% rename from lib/astc-encoder/Test/Images/Small/LDR-RGB/ldr-rgb-09.png rename to external/astc-encoder/Test/Images/Small/LDR-RGB/ldr-rgb-09.png diff --git a/lib/astc-encoder/Test/Images/Small/LDR-RGB/ldr-rgb-10.png b/external/astc-encoder/Test/Images/Small/LDR-RGB/ldr-rgb-10.png similarity index 100% rename from lib/astc-encoder/Test/Images/Small/LDR-RGB/ldr-rgb-10.png rename to external/astc-encoder/Test/Images/Small/LDR-RGB/ldr-rgb-10.png diff --git a/lib/astc-encoder/Test/Images/Small/LDR-RGBA/ldr-rgba-00.png b/external/astc-encoder/Test/Images/Small/LDR-RGBA/ldr-rgba-00.png similarity index 100% rename from lib/astc-encoder/Test/Images/Small/LDR-RGBA/ldr-rgba-00.png rename to external/astc-encoder/Test/Images/Small/LDR-RGBA/ldr-rgba-00.png diff --git a/lib/astc-encoder/Test/Images/Small/LDR-RGBA/ldr-rgba-01.png b/external/astc-encoder/Test/Images/Small/LDR-RGBA/ldr-rgba-01.png similarity index 100% rename from lib/astc-encoder/Test/Images/Small/LDR-RGBA/ldr-rgba-01.png rename to external/astc-encoder/Test/Images/Small/LDR-RGBA/ldr-rgba-01.png diff --git a/lib/astc-encoder/Test/Images/Small/LDR-RGBA/ldr-rgba-02.png b/external/astc-encoder/Test/Images/Small/LDR-RGBA/ldr-rgba-02.png similarity index 100% rename from lib/astc-encoder/Test/Images/Small/LDR-RGBA/ldr-rgba-02.png rename to external/astc-encoder/Test/Images/Small/LDR-RGBA/ldr-rgba-02.png diff --git a/lib/astc-encoder/Test/Images/Small/LDR-XY/ldr-xy-00.png b/external/astc-encoder/Test/Images/Small/LDR-XY/ldr-xy-00.png similarity index 100% rename from lib/astc-encoder/Test/Images/Small/LDR-XY/ldr-xy-00.png rename to external/astc-encoder/Test/Images/Small/LDR-XY/ldr-xy-00.png diff --git a/lib/astc-encoder/Test/Images/Small/LDR-XY/ldr-xy-01.png b/external/astc-encoder/Test/Images/Small/LDR-XY/ldr-xy-01.png similarity index 100% rename from lib/astc-encoder/Test/Images/Small/LDR-XY/ldr-xy-01.png rename to external/astc-encoder/Test/Images/Small/LDR-XY/ldr-xy-01.png diff --git a/lib/astc-encoder/Test/Images/Small/LDR-XY/ldr-xy-02.png b/external/astc-encoder/Test/Images/Small/LDR-XY/ldr-xy-02.png similarity index 100% rename from lib/astc-encoder/Test/Images/Small/LDR-XY/ldr-xy-02.png rename to external/astc-encoder/Test/Images/Small/LDR-XY/ldr-xy-02.png diff --git a/lib/astc-encoder/Test/Images/Small/LDRS-RGBA/ldrs-rgba-00.png b/external/astc-encoder/Test/Images/Small/LDRS-RGBA/ldrs-rgba-00.png similarity index 100% rename from lib/astc-encoder/Test/Images/Small/LDRS-RGBA/ldrs-rgba-00.png rename to external/astc-encoder/Test/Images/Small/LDRS-RGBA/ldrs-rgba-00.png diff --git a/lib/astc-encoder/Test/Images/Small/LDRS-RGBA/ldrs-rgba-01.png b/external/astc-encoder/Test/Images/Small/LDRS-RGBA/ldrs-rgba-01.png similarity index 100% rename from lib/astc-encoder/Test/Images/Small/LDRS-RGBA/ldrs-rgba-01.png rename to external/astc-encoder/Test/Images/Small/LDRS-RGBA/ldrs-rgba-01.png diff --git a/lib/astc-encoder/Test/Images/Small/LDRS-RGBA/ldrs-rgba-02.png b/external/astc-encoder/Test/Images/Small/LDRS-RGBA/ldrs-rgba-02.png similarity index 100% rename from lib/astc-encoder/Test/Images/Small/LDRS-RGBA/ldrs-rgba-02.png rename to external/astc-encoder/Test/Images/Small/LDRS-RGBA/ldrs-rgba-02.png diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-1.7_fast_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-1.7_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-1.7_fast_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-1.7_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-1.7_fastest_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-1.7_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-1.7_fastest_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-1.7_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-1.7_medium_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-1.7_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-1.7_medium_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-1.7_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-1.7_thorough_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-1.7_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-1.7_thorough_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-1.7_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-2.5-avx2_fast_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-2.5-avx2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-2.5-avx2_fast_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-2.5-avx2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-2.5-avx2_fastest_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-2.5-avx2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-2.5-avx2_fastest_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-2.5-avx2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-2.5-avx2_medium_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-2.5-avx2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-2.5-avx2_medium_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-2.5-avx2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-2.5-avx2_thorough_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-2.5-avx2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-2.5-avx2_thorough_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-2.5-avx2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-2.5-sse2_fast_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-2.5-sse2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-2.5-sse2_fast_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-2.5-sse2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-2.5-sse2_fastest_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-2.5-sse2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-2.5-sse2_fastest_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-2.5-sse2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-2.5-sse2_medium_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-2.5-sse2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-2.5-sse2_medium_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-2.5-sse2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-2.5-sse2_thorough_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-2.5-sse2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-2.5-sse2_thorough_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-2.5-sse2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-2.5-sse4.1_fast_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-2.5-sse4.1_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-2.5-sse4.1_fast_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-2.5-sse4.1_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-2.5-sse4.1_fastest_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-2.5-sse4.1_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-2.5-sse4.1_fastest_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-2.5-sse4.1_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-2.5-sse4.1_medium_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-2.5-sse4.1_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-2.5-sse4.1_medium_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-2.5-sse4.1_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-2.5-sse4.1_thorough_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-2.5-sse4.1_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-2.5-sse4.1_thorough_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-2.5-sse4.1_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-3.6-avx2_fast_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-3.6-avx2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-3.6-avx2_fast_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-3.6-avx2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-3.6-avx2_fastest_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-3.6-avx2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-3.6-avx2_fastest_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-3.6-avx2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-3.6-avx2_medium_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-3.6-avx2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-3.6-avx2_medium_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-3.6-avx2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-3.6-avx2_thorough_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-3.6-avx2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-3.6-avx2_thorough_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-3.6-avx2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-3.6-sse2_fast_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-3.6-sse2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-3.6-sse2_fast_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-3.6-sse2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-3.6-sse2_fastest_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-3.6-sse2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-3.6-sse2_fastest_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-3.6-sse2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-3.6-sse2_medium_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-3.6-sse2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-3.6-sse2_medium_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-3.6-sse2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-3.6-sse2_thorough_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-3.6-sse2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-3.6-sse2_thorough_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-3.6-sse2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-3.6-sse4.1_fast_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-3.6-sse4.1_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-3.6-sse4.1_fast_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-3.6-sse4.1_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-3.6-sse4.1_fastest_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-3.6-sse4.1_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-3.6-sse4.1_fastest_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-3.6-sse4.1_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-3.6-sse4.1_medium_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-3.6-sse4.1_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-3.6-sse4.1_medium_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-3.6-sse4.1_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-3.6-sse4.1_thorough_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-3.6-sse4.1_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-3.6-sse4.1_thorough_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-3.6-sse4.1_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-3.7-avx2_fast_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-3.7-avx2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-3.7-avx2_fast_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-3.7-avx2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-3.7-avx2_fastest_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-3.7-avx2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-3.7-avx2_fastest_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-3.7-avx2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-3.7-avx2_medium_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-3.7-avx2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-3.7-avx2_medium_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-3.7-avx2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-3.7-avx2_thorough_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-3.7-avx2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-3.7-avx2_thorough_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-3.7-avx2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-3.7-sse2_fast_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-3.7-sse2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-3.7-sse2_fast_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-3.7-sse2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-3.7-sse2_fastest_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-3.7-sse2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-3.7-sse2_fastest_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-3.7-sse2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-3.7-sse2_medium_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-3.7-sse2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-3.7-sse2_medium_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-3.7-sse2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-3.7-sse2_thorough_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-3.7-sse2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-3.7-sse2_thorough_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-3.7-sse2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-3.7-sse4.1_fast_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-3.7-sse4.1_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-3.7-sse4.1_fast_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-3.7-sse4.1_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-3.7-sse4.1_fastest_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-3.7-sse4.1_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-3.7-sse4.1_fastest_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-3.7-sse4.1_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-3.7-sse4.1_medium_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-3.7-sse4.1_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-3.7-sse4.1_medium_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-3.7-sse4.1_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-3.7-sse4.1_thorough_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-3.7-sse4.1_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-3.7-sse4.1_thorough_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-3.7-sse4.1_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-4.3-avx2_fast_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-4.3-avx2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-4.3-avx2_fast_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-4.3-avx2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-4.3-avx2_fastest_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-4.3-avx2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-4.3-avx2_fastest_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-4.3-avx2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-4.3-avx2_medium_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-4.3-avx2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-4.3-avx2_medium_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-4.3-avx2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-4.3-avx2_thorough_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-4.3-avx2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-4.3-avx2_thorough_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-4.3-avx2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-4.3-sse2_fast_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-4.3-sse2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-4.3-sse2_fast_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-4.3-sse2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-4.3-sse2_fastest_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-4.3-sse2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-4.3-sse2_fastest_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-4.3-sse2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-4.3-sse2_medium_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-4.3-sse2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-4.3-sse2_medium_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-4.3-sse2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-4.3-sse2_thorough_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-4.3-sse2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-4.3-sse2_thorough_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-4.3-sse2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-4.3-sse4.1_fast_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-4.3-sse4.1_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-4.3-sse4.1_fast_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-4.3-sse4.1_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-4.3-sse4.1_fastest_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-4.3-sse4.1_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-4.3-sse4.1_fastest_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-4.3-sse4.1_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-4.3-sse4.1_medium_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-4.3-sse4.1_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-4.3-sse4.1_medium_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-4.3-sse4.1_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-4.3-sse4.1_thorough_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-4.3-sse4.1_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-4.3-sse4.1_thorough_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-4.3-sse4.1_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-4.4-avx2_fast_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-4.4-avx2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-4.4-avx2_fast_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-4.4-avx2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-4.4-avx2_fastest_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-4.4-avx2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-4.4-avx2_fastest_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-4.4-avx2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-4.4-avx2_medium_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-4.4-avx2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-4.4-avx2_medium_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-4.4-avx2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-4.4-avx2_thorough_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-4.4-avx2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-4.4-avx2_thorough_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-4.4-avx2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-4.4-sse2_fast_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-4.4-sse2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-4.4-sse2_fast_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-4.4-sse2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-4.4-sse2_fastest_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-4.4-sse2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-4.4-sse2_fastest_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-4.4-sse2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-4.4-sse2_medium_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-4.4-sse2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-4.4-sse2_medium_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-4.4-sse2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-4.4-sse2_thorough_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-4.4-sse2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-4.4-sse2_thorough_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-4.4-sse2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-4.4-sse4.1_fast_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-4.4-sse4.1_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-4.4-sse4.1_fast_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-4.4-sse4.1_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-4.4-sse4.1_fastest_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-4.4-sse4.1_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-4.4-sse4.1_fastest_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-4.4-sse4.1_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-4.4-sse4.1_medium_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-4.4-sse4.1_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-4.4-sse4.1_medium_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-4.4-sse4.1_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-4.4-sse4.1_thorough_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-4.4-sse4.1_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-4.4-sse4.1_thorough_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-4.4-sse4.1_thorough_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-main-avx2_fast_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-main-avx2_fast_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-main-avx2_fast_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-main-avx2_fast_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-main-avx2_fastest_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-main-avx2_fastest_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-main-avx2_fastest_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-main-avx2_fastest_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-main-avx2_medium_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-main-avx2_medium_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-main-avx2_medium_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-main-avx2_medium_results.csv diff --git a/lib/astc-encoder/Test/Images/Small/astc_reference-main-avx2_thorough_results.csv b/external/astc-encoder/Test/Images/Small/astc_reference-main-avx2_thorough_results.csv similarity index 100% rename from lib/astc-encoder/Test/Images/Small/astc_reference-main-avx2_thorough_results.csv rename to external/astc-encoder/Test/Images/Small/astc_reference-main-avx2_thorough_results.csv diff --git a/lib/astc-encoder/Test/Makefile b/external/astc-encoder/Test/Makefile similarity index 100% rename from lib/astc-encoder/Test/Makefile rename to external/astc-encoder/Test/Makefile diff --git a/lib/astc-encoder/Test/astc_dump_binary.py b/external/astc-encoder/Test/astc_dump_binary.py similarity index 100% rename from lib/astc-encoder/Test/astc_dump_binary.py rename to external/astc-encoder/Test/astc_dump_binary.py diff --git a/lib/astc-encoder/Test/astc_image_info.py b/external/astc-encoder/Test/astc_image_info.py similarity index 100% rename from lib/astc-encoder/Test/astc_image_info.py rename to external/astc-encoder/Test/astc_image_info.py diff --git a/lib/astc-encoder/Test/astc_image_sweep.py b/external/astc-encoder/Test/astc_image_sweep.py similarity index 100% rename from lib/astc-encoder/Test/astc_image_sweep.py rename to external/astc-encoder/Test/astc_image_sweep.py diff --git a/lib/astc-encoder/Test/astc_minify_test.sh b/external/astc-encoder/Test/astc_minify_test.sh similarity index 100% rename from lib/astc-encoder/Test/astc_minify_test.sh rename to external/astc-encoder/Test/astc_minify_test.sh diff --git a/lib/astc-encoder/Test/astc_profile_valgrind.py b/external/astc-encoder/Test/astc_profile_valgrind.py similarity index 100% rename from lib/astc-encoder/Test/astc_profile_valgrind.py rename to external/astc-encoder/Test/astc_profile_valgrind.py diff --git a/lib/astc-encoder/Test/astc_quality_test.py b/external/astc-encoder/Test/astc_quality_test.py similarity index 100% rename from lib/astc-encoder/Test/astc_quality_test.py rename to external/astc-encoder/Test/astc_quality_test.py diff --git a/lib/astc-encoder/Test/astc_size_binary.py b/external/astc-encoder/Test/astc_size_binary.py similarity index 100% rename from lib/astc-encoder/Test/astc_size_binary.py rename to external/astc-encoder/Test/astc_size_binary.py diff --git a/lib/astc-encoder/Test/astc_test_competitive.py b/external/astc-encoder/Test/astc_test_competitive.py similarity index 100% rename from lib/astc-encoder/Test/astc_test_competitive.py rename to external/astc-encoder/Test/astc_test_competitive.py diff --git a/lib/astc-encoder/Test/astc_test_competitive_plot.py b/external/astc-encoder/Test/astc_test_competitive_plot.py similarity index 100% rename from lib/astc-encoder/Test/astc_test_competitive_plot.py rename to external/astc-encoder/Test/astc_test_competitive_plot.py diff --git a/lib/astc-encoder/Test/astc_test_functional.py b/external/astc-encoder/Test/astc_test_functional.py similarity index 100% rename from lib/astc-encoder/Test/astc_test_functional.py rename to external/astc-encoder/Test/astc_test_functional.py diff --git a/lib/astc-encoder/Test/astc_test_image.py b/external/astc-encoder/Test/astc_test_image.py similarity index 100% rename from lib/astc-encoder/Test/astc_test_image.py rename to external/astc-encoder/Test/astc_test_image.py diff --git a/lib/astc-encoder/Test/astc_test_image_dl.py b/external/astc-encoder/Test/astc_test_image_dl.py similarity index 100% rename from lib/astc-encoder/Test/astc_test_image_dl.py rename to external/astc-encoder/Test/astc_test_image_dl.py diff --git a/lib/astc-encoder/Test/astc_test_python.py b/external/astc-encoder/Test/astc_test_python.py similarity index 100% rename from lib/astc-encoder/Test/astc_test_python.py rename to external/astc-encoder/Test/astc_test_python.py diff --git a/lib/astc-encoder/Test/astc_test_result_plot.py b/external/astc-encoder/Test/astc_test_result_plot.py similarity index 100% rename from lib/astc-encoder/Test/astc_test_result_plot.py rename to external/astc-encoder/Test/astc_test_result_plot.py diff --git a/lib/astc-encoder/Test/astc_test_result_report.py b/external/astc-encoder/Test/astc_test_result_report.py similarity index 100% rename from lib/astc-encoder/Test/astc_test_result_report.py rename to external/astc-encoder/Test/astc_test_result_report.py diff --git a/lib/astc-encoder/Test/astc_trace_analysis.py b/external/astc-encoder/Test/astc_trace_analysis.py similarity index 100% rename from lib/astc-encoder/Test/astc_trace_analysis.py rename to external/astc-encoder/Test/astc_trace_analysis.py diff --git a/lib/astc-encoder/Test/astc_update_ref.sh b/external/astc-encoder/Test/astc_update_ref.sh similarity index 100% rename from lib/astc-encoder/Test/astc_update_ref.sh rename to external/astc-encoder/Test/astc_update_ref.sh diff --git a/lib/astc-encoder/Test/make.bat b/external/astc-encoder/Test/make.bat similarity index 100% rename from lib/astc-encoder/Test/make.bat rename to external/astc-encoder/Test/make.bat diff --git a/lib/astc-encoder/Test/testlib/__init__.py b/external/astc-encoder/Test/testlib/__init__.py similarity index 100% rename from lib/astc-encoder/Test/testlib/__init__.py rename to external/astc-encoder/Test/testlib/__init__.py diff --git a/lib/astc-encoder/Test/testlib/encoder.py b/external/astc-encoder/Test/testlib/encoder.py similarity index 100% rename from lib/astc-encoder/Test/testlib/encoder.py rename to external/astc-encoder/Test/testlib/encoder.py diff --git a/lib/astc-encoder/Test/testlib/image.py b/external/astc-encoder/Test/testlib/image.py similarity index 100% rename from lib/astc-encoder/Test/testlib/image.py rename to external/astc-encoder/Test/testlib/image.py diff --git a/lib/astc-encoder/Test/testlib/misc.py b/external/astc-encoder/Test/testlib/misc.py similarity index 100% rename from lib/astc-encoder/Test/testlib/misc.py rename to external/astc-encoder/Test/testlib/misc.py diff --git a/lib/astc-encoder/Test/testlib/resultset.py b/external/astc-encoder/Test/testlib/resultset.py similarity index 100% rename from lib/astc-encoder/Test/testlib/resultset.py rename to external/astc-encoder/Test/testlib/resultset.py diff --git a/lib/astc-encoder/Test/testlib/testset.py b/external/astc-encoder/Test/testlib/testset.py similarity index 100% rename from lib/astc-encoder/Test/testlib/testset.py rename to external/astc-encoder/Test/testlib/testset.py diff --git a/lib/astc-encoder/Utils/Example/CMakeLists.txt b/external/astc-encoder/Utils/Example/CMakeLists.txt similarity index 100% rename from lib/astc-encoder/Utils/Example/CMakeLists.txt rename to external/astc-encoder/Utils/Example/CMakeLists.txt diff --git a/lib/astc-encoder/Utils/Example/README.md b/external/astc-encoder/Utils/Example/README.md similarity index 100% rename from lib/astc-encoder/Utils/Example/README.md rename to external/astc-encoder/Utils/Example/README.md diff --git a/lib/astc-encoder/Utils/Example/astc_api_example.cpp b/external/astc-encoder/Utils/Example/astc_api_example.cpp similarity index 100% rename from lib/astc-encoder/Utils/Example/astc_api_example.cpp rename to external/astc-encoder/Utils/Example/astc_api_example.cpp diff --git a/lib/astc-encoder/Utils/astc_blend_test.cpp b/external/astc-encoder/Utils/astc_blend_test.cpp similarity index 100% rename from lib/astc-encoder/Utils/astc_blend_test.cpp rename to external/astc-encoder/Utils/astc_blend_test.cpp diff --git a/lib/astc-encoder/Utils/astc_quant_generator.cpp b/external/astc-encoder/Utils/astc_quant_generator.cpp similarity index 100% rename from lib/astc-encoder/Utils/astc_quant_generator.cpp rename to external/astc-encoder/Utils/astc_quant_generator.cpp diff --git a/lib/astc-encoder/Utils/astc_rgbm_codec.cpp b/external/astc-encoder/Utils/astc_rgbm_codec.cpp similarity index 100% rename from lib/astc-encoder/Utils/astc_rgbm_codec.cpp rename to external/astc-encoder/Utils/astc_rgbm_codec.cpp diff --git a/lib/astc-encoder/Utils/astc_test_autoextract.cpp b/external/astc-encoder/Utils/astc_test_autoextract.cpp similarity index 100% rename from lib/astc-encoder/Utils/astc_test_autoextract.cpp rename to external/astc-encoder/Utils/astc_test_autoextract.cpp diff --git a/lib/astc-encoder/Utils/astc_test_autoextract_hdr.cpp b/external/astc-encoder/Utils/astc_test_autoextract_hdr.cpp similarity index 100% rename from lib/astc-encoder/Utils/astc_test_autoextract_hdr.cpp rename to external/astc-encoder/Utils/astc_test_autoextract_hdr.cpp diff --git a/lib/astc-encoder/jenkins/build-image.sh b/external/astc-encoder/jenkins/build-image.sh similarity index 100% rename from lib/astc-encoder/jenkins/build-image.sh rename to external/astc-encoder/jenkins/build-image.sh diff --git a/lib/astc-encoder/jenkins/build.Dockerfile b/external/astc-encoder/jenkins/build.Dockerfile similarity index 100% rename from lib/astc-encoder/jenkins/build.Dockerfile rename to external/astc-encoder/jenkins/build.Dockerfile diff --git a/lib/astc-encoder/jenkins/dockerimage.Jenkinsfile b/external/astc-encoder/jenkins/dockerimage.Jenkinsfile similarity index 100% rename from lib/astc-encoder/jenkins/dockerimage.Jenkinsfile rename to external/astc-encoder/jenkins/dockerimage.Jenkinsfile diff --git a/lib/astc-encoder/jenkins/nightly.Jenkinsfile b/external/astc-encoder/jenkins/nightly.Jenkinsfile similarity index 100% rename from lib/astc-encoder/jenkins/nightly.Jenkinsfile rename to external/astc-encoder/jenkins/nightly.Jenkinsfile diff --git a/lib/astc-encoder/jenkins/release.Jenkinsfile b/external/astc-encoder/jenkins/release.Jenkinsfile similarity index 100% rename from lib/astc-encoder/jenkins/release.Jenkinsfile rename to external/astc-encoder/jenkins/release.Jenkinsfile diff --git a/lib/basisu/.gitignore b/external/basisu/.gitignore similarity index 100% rename from lib/basisu/.gitignore rename to external/basisu/.gitignore diff --git a/lib/basisu/.gitrepo b/external/basisu/.gitrepo similarity index 100% rename from lib/basisu/.gitrepo rename to external/basisu/.gitrepo diff --git a/lib/basisu/.reuse/dep5 b/external/basisu/.reuse/dep5 similarity index 100% rename from lib/basisu/.reuse/dep5 rename to external/basisu/.reuse/dep5 diff --git a/lib/basisu/CMakeLists.txt b/external/basisu/CMakeLists.txt similarity index 100% rename from lib/basisu/CMakeLists.txt rename to external/basisu/CMakeLists.txt diff --git a/lib/basisu/CppProperties.json b/external/basisu/CppProperties.json similarity index 100% rename from lib/basisu/CppProperties.json rename to external/basisu/CppProperties.json diff --git a/lib/basisu/LICENSE b/external/basisu/LICENSE similarity index 100% rename from lib/basisu/LICENSE rename to external/basisu/LICENSE diff --git a/lib/basisu/LICENSES/Apache-2.0.txt b/external/basisu/LICENSES/Apache-2.0.txt similarity index 100% rename from lib/basisu/LICENSES/Apache-2.0.txt rename to external/basisu/LICENSES/Apache-2.0.txt diff --git a/lib/basisu/LICENSES/BSD.txt b/external/basisu/LICENSES/BSD.txt similarity index 100% rename from lib/basisu/LICENSES/BSD.txt rename to external/basisu/LICENSES/BSD.txt diff --git a/lib/basisu/LICENSES/Zlib.txt b/external/basisu/LICENSES/Zlib.txt similarity index 100% rename from lib/basisu/LICENSES/Zlib.txt rename to external/basisu/LICENSES/Zlib.txt diff --git a/lib/basisu/OpenCL/CL/cl.h b/external/basisu/OpenCL/CL/cl.h similarity index 100% rename from lib/basisu/OpenCL/CL/cl.h rename to external/basisu/OpenCL/CL/cl.h diff --git a/lib/basisu/OpenCL/CL/cl_d3d10.h b/external/basisu/OpenCL/CL/cl_d3d10.h similarity index 100% rename from lib/basisu/OpenCL/CL/cl_d3d10.h rename to external/basisu/OpenCL/CL/cl_d3d10.h diff --git a/lib/basisu/OpenCL/CL/cl_d3d11.h b/external/basisu/OpenCL/CL/cl_d3d11.h similarity index 100% rename from lib/basisu/OpenCL/CL/cl_d3d11.h rename to external/basisu/OpenCL/CL/cl_d3d11.h diff --git a/lib/basisu/OpenCL/CL/cl_dx9_media_sharing.h b/external/basisu/OpenCL/CL/cl_dx9_media_sharing.h similarity index 100% rename from lib/basisu/OpenCL/CL/cl_dx9_media_sharing.h rename to external/basisu/OpenCL/CL/cl_dx9_media_sharing.h diff --git a/lib/basisu/OpenCL/CL/cl_dx9_media_sharing_intel.h b/external/basisu/OpenCL/CL/cl_dx9_media_sharing_intel.h similarity index 100% rename from lib/basisu/OpenCL/CL/cl_dx9_media_sharing_intel.h rename to external/basisu/OpenCL/CL/cl_dx9_media_sharing_intel.h diff --git a/lib/basisu/OpenCL/CL/cl_egl.h b/external/basisu/OpenCL/CL/cl_egl.h similarity index 100% rename from lib/basisu/OpenCL/CL/cl_egl.h rename to external/basisu/OpenCL/CL/cl_egl.h diff --git a/lib/basisu/OpenCL/CL/cl_ext.h b/external/basisu/OpenCL/CL/cl_ext.h similarity index 100% rename from lib/basisu/OpenCL/CL/cl_ext.h rename to external/basisu/OpenCL/CL/cl_ext.h diff --git a/lib/basisu/OpenCL/CL/cl_ext_intel.h b/external/basisu/OpenCL/CL/cl_ext_intel.h similarity index 100% rename from lib/basisu/OpenCL/CL/cl_ext_intel.h rename to external/basisu/OpenCL/CL/cl_ext_intel.h diff --git a/lib/basisu/OpenCL/CL/cl_gl.h b/external/basisu/OpenCL/CL/cl_gl.h similarity index 100% rename from lib/basisu/OpenCL/CL/cl_gl.h rename to external/basisu/OpenCL/CL/cl_gl.h diff --git a/lib/basisu/OpenCL/CL/cl_gl_ext.h b/external/basisu/OpenCL/CL/cl_gl_ext.h similarity index 100% rename from lib/basisu/OpenCL/CL/cl_gl_ext.h rename to external/basisu/OpenCL/CL/cl_gl_ext.h diff --git a/lib/basisu/OpenCL/CL/cl_half.h b/external/basisu/OpenCL/CL/cl_half.h similarity index 100% rename from lib/basisu/OpenCL/CL/cl_half.h rename to external/basisu/OpenCL/CL/cl_half.h diff --git a/lib/basisu/OpenCL/CL/cl_icd.h b/external/basisu/OpenCL/CL/cl_icd.h similarity index 100% rename from lib/basisu/OpenCL/CL/cl_icd.h rename to external/basisu/OpenCL/CL/cl_icd.h diff --git a/lib/basisu/OpenCL/CL/cl_layer.h b/external/basisu/OpenCL/CL/cl_layer.h similarity index 100% rename from lib/basisu/OpenCL/CL/cl_layer.h rename to external/basisu/OpenCL/CL/cl_layer.h diff --git a/lib/basisu/OpenCL/CL/cl_platform.h b/external/basisu/OpenCL/CL/cl_platform.h similarity index 100% rename from lib/basisu/OpenCL/CL/cl_platform.h rename to external/basisu/OpenCL/CL/cl_platform.h diff --git a/lib/basisu/OpenCL/CL/cl_va_api_media_sharing_intel.h b/external/basisu/OpenCL/CL/cl_va_api_media_sharing_intel.h similarity index 100% rename from lib/basisu/OpenCL/CL/cl_va_api_media_sharing_intel.h rename to external/basisu/OpenCL/CL/cl_va_api_media_sharing_intel.h diff --git a/lib/basisu/OpenCL/CL/cl_version.h b/external/basisu/OpenCL/CL/cl_version.h similarity index 100% rename from lib/basisu/OpenCL/CL/cl_version.h rename to external/basisu/OpenCL/CL/cl_version.h diff --git a/lib/basisu/OpenCL/CL/opencl.h b/external/basisu/OpenCL/CL/opencl.h similarity index 100% rename from lib/basisu/OpenCL/CL/opencl.h rename to external/basisu/OpenCL/CL/opencl.h diff --git a/lib/basisu/OpenCL/lib/OpenCL.lib b/external/basisu/OpenCL/lib/OpenCL.lib similarity index 100% rename from lib/basisu/OpenCL/lib/OpenCL.lib rename to external/basisu/OpenCL/lib/OpenCL.lib diff --git a/lib/basisu/OpenCL/lib/OpenCL64.lib b/external/basisu/OpenCL/lib/OpenCL64.lib similarity index 100% rename from lib/basisu/OpenCL/lib/OpenCL64.lib rename to external/basisu/OpenCL/lib/OpenCL64.lib diff --git a/lib/basisu/OpenCL/license.txt b/external/basisu/OpenCL/license.txt similarity index 100% rename from lib/basisu/OpenCL/license.txt rename to external/basisu/OpenCL/license.txt diff --git a/lib/basisu/README.md b/external/basisu/README.md similarity index 100% rename from lib/basisu/README.md rename to external/basisu/README.md diff --git a/lib/basisu/appveyor.yml b/external/basisu/appveyor.yml similarity index 100% rename from lib/basisu/appveyor.yml rename to external/basisu/appveyor.yml diff --git a/lib/basisu/basisu.sln b/external/basisu/basisu.sln similarity index 100% rename from lib/basisu/basisu.sln rename to external/basisu/basisu.sln diff --git a/lib/basisu/basisu.vcxproj b/external/basisu/basisu.vcxproj similarity index 100% rename from lib/basisu/basisu.vcxproj rename to external/basisu/basisu.vcxproj diff --git a/lib/basisu/basisu.vcxproj.filters b/external/basisu/basisu.vcxproj.filters similarity index 100% rename from lib/basisu/basisu.vcxproj.filters rename to external/basisu/basisu.vcxproj.filters diff --git a/lib/basisu/basisu_tool.cpp b/external/basisu/basisu_tool.cpp similarity index 100% rename from lib/basisu/basisu_tool.cpp rename to external/basisu/basisu_tool.cpp diff --git a/lib/basisu/bin/ocl_kernels.cl b/external/basisu/bin/ocl_kernels.cl similarity index 100% rename from lib/basisu/bin/ocl_kernels.cl rename to external/basisu/bin/ocl_kernels.cl diff --git a/lib/basisu/bin/readme.txt b/external/basisu/bin/readme.txt similarity index 100% rename from lib/basisu/bin/readme.txt rename to external/basisu/bin/readme.txt diff --git a/lib/basisu/build_clang.sh b/external/basisu/build_clang.sh similarity index 100% rename from lib/basisu/build_clang.sh rename to external/basisu/build_clang.sh diff --git a/lib/basisu/build_emscripten.sh b/external/basisu/build_emscripten.sh similarity index 100% rename from lib/basisu/build_emscripten.sh rename to external/basisu/build_emscripten.sh diff --git a/lib/basisu/contrib/.gitignore b/external/basisu/contrib/.gitignore similarity index 100% rename from lib/basisu/contrib/.gitignore rename to external/basisu/contrib/.gitignore diff --git a/lib/basisu/contrib/previewers/lib/README.md b/external/basisu/contrib/previewers/lib/README.md similarity index 100% rename from lib/basisu/contrib/previewers/lib/README.md rename to external/basisu/contrib/previewers/lib/README.md diff --git a/lib/basisu/contrib/previewers/lib/basisu_transcoder.cpp b/external/basisu/contrib/previewers/lib/basisu_transcoder.cpp similarity index 100% rename from lib/basisu/contrib/previewers/lib/basisu_transcoder.cpp rename to external/basisu/contrib/previewers/lib/basisu_transcoder.cpp diff --git a/lib/basisu/contrib/previewers/win/.gitignore b/external/basisu/contrib/previewers/win/.gitignore similarity index 100% rename from lib/basisu/contrib/previewers/win/.gitignore rename to external/basisu/contrib/previewers/win/.gitignore diff --git a/lib/basisu/contrib/previewers/win/README.md b/external/basisu/contrib/previewers/win/README.md similarity index 100% rename from lib/basisu/contrib/previewers/win/README.md rename to external/basisu/contrib/previewers/win/README.md diff --git a/lib/basisu/contrib/previewers/win/basisthumbprovider.cpp b/external/basisu/contrib/previewers/win/basisthumbprovider.cpp similarity index 100% rename from lib/basisu/contrib/previewers/win/basisthumbprovider.cpp rename to external/basisu/contrib/previewers/win/basisthumbprovider.cpp diff --git a/lib/basisu/contrib/previewers/win/basisthumbprovider.h b/external/basisu/contrib/previewers/win/basisthumbprovider.h similarity index 100% rename from lib/basisu/contrib/previewers/win/basisthumbprovider.h rename to external/basisu/contrib/previewers/win/basisthumbprovider.h diff --git a/lib/basisu/contrib/previewers/win/helpers.cpp b/external/basisu/contrib/previewers/win/helpers.cpp similarity index 100% rename from lib/basisu/contrib/previewers/win/helpers.cpp rename to external/basisu/contrib/previewers/win/helpers.cpp diff --git a/lib/basisu/contrib/previewers/win/helpers.h b/external/basisu/contrib/previewers/win/helpers.h similarity index 100% rename from lib/basisu/contrib/previewers/win/helpers.h rename to external/basisu/contrib/previewers/win/helpers.h diff --git a/lib/basisu/contrib/previewers/win/preview.png b/external/basisu/contrib/previewers/win/preview.png similarity index 100% rename from lib/basisu/contrib/previewers/win/preview.png rename to external/basisu/contrib/previewers/win/preview.png diff --git a/lib/basisu/contrib/previewers/win/previewers.cpp b/external/basisu/contrib/previewers/win/previewers.cpp similarity index 100% rename from lib/basisu/contrib/previewers/win/previewers.cpp rename to external/basisu/contrib/previewers/win/previewers.cpp diff --git a/lib/basisu/contrib/previewers/win/previewers.def b/external/basisu/contrib/previewers/win/previewers.def similarity index 100% rename from lib/basisu/contrib/previewers/win/previewers.def rename to external/basisu/contrib/previewers/win/previewers.def diff --git a/lib/basisu/contrib/previewers/win/previewers.sln b/external/basisu/contrib/previewers/win/previewers.sln similarity index 100% rename from lib/basisu/contrib/previewers/win/previewers.sln rename to external/basisu/contrib/previewers/win/previewers.sln diff --git a/lib/basisu/contrib/previewers/win/previewers.vcxproj b/external/basisu/contrib/previewers/win/previewers.vcxproj similarity index 100% rename from lib/basisu/contrib/previewers/win/previewers.vcxproj rename to external/basisu/contrib/previewers/win/previewers.vcxproj diff --git a/lib/basisu/contrib/previewers/win/previewers.vcxproj.filters b/external/basisu/contrib/previewers/win/previewers.vcxproj.filters similarity index 100% rename from lib/basisu/contrib/previewers/win/previewers.vcxproj.filters rename to external/basisu/contrib/previewers/win/previewers.vcxproj.filters diff --git a/lib/basisu/contrib/single_file_transcoder/.editorconfig b/external/basisu/contrib/single_file_transcoder/.editorconfig similarity index 100% rename from lib/basisu/contrib/single_file_transcoder/.editorconfig rename to external/basisu/contrib/single_file_transcoder/.editorconfig diff --git a/lib/basisu/contrib/single_file_transcoder/.gitignore b/external/basisu/contrib/single_file_transcoder/.gitignore similarity index 100% rename from lib/basisu/contrib/single_file_transcoder/.gitignore rename to external/basisu/contrib/single_file_transcoder/.gitignore diff --git a/lib/basisu/contrib/single_file_transcoder/README.md b/external/basisu/contrib/single_file_transcoder/README.md similarity index 100% rename from lib/basisu/contrib/single_file_transcoder/README.md rename to external/basisu/contrib/single_file_transcoder/README.md diff --git a/lib/basisu/contrib/single_file_transcoder/basisu_transcoder-in.cpp b/external/basisu/contrib/single_file_transcoder/basisu_transcoder-in.cpp similarity index 100% rename from lib/basisu/contrib/single_file_transcoder/basisu_transcoder-in.cpp rename to external/basisu/contrib/single_file_transcoder/basisu_transcoder-in.cpp diff --git a/lib/basisu/contrib/single_file_transcoder/combine.py b/external/basisu/contrib/single_file_transcoder/combine.py similarity index 100% rename from lib/basisu/contrib/single_file_transcoder/combine.py rename to external/basisu/contrib/single_file_transcoder/combine.py diff --git a/lib/basisu/contrib/single_file_transcoder/combine.sh b/external/basisu/contrib/single_file_transcoder/combine.sh similarity index 100% rename from lib/basisu/contrib/single_file_transcoder/combine.sh rename to external/basisu/contrib/single_file_transcoder/combine.sh diff --git a/lib/basisu/contrib/single_file_transcoder/create_transcoder.sh b/external/basisu/contrib/single_file_transcoder/create_transcoder.sh similarity index 100% rename from lib/basisu/contrib/single_file_transcoder/create_transcoder.sh rename to external/basisu/contrib/single_file_transcoder/create_transcoder.sh diff --git a/lib/basisu/contrib/single_file_transcoder/examples/README.md b/external/basisu/contrib/single_file_transcoder/examples/README.md similarity index 100% rename from lib/basisu/contrib/single_file_transcoder/examples/README.md rename to external/basisu/contrib/single_file_transcoder/examples/README.md diff --git a/lib/basisu/contrib/single_file_transcoder/examples/emscripten.cpp b/external/basisu/contrib/single_file_transcoder/examples/emscripten.cpp similarity index 100% rename from lib/basisu/contrib/single_file_transcoder/examples/emscripten.cpp rename to external/basisu/contrib/single_file_transcoder/examples/emscripten.cpp diff --git a/lib/basisu/contrib/single_file_transcoder/examples/shell.html b/external/basisu/contrib/single_file_transcoder/examples/shell.html similarity index 100% rename from lib/basisu/contrib/single_file_transcoder/examples/shell.html rename to external/basisu/contrib/single_file_transcoder/examples/shell.html diff --git a/lib/basisu/contrib/single_file_transcoder/examples/simple.cpp b/external/basisu/contrib/single_file_transcoder/examples/simple.cpp similarity index 100% rename from lib/basisu/contrib/single_file_transcoder/examples/simple.cpp rename to external/basisu/contrib/single_file_transcoder/examples/simple.cpp diff --git a/lib/basisu/contrib/single_file_transcoder/examples/testcard-rgba.basis.inc b/external/basisu/contrib/single_file_transcoder/examples/testcard-rgba.basis.inc similarity index 100% rename from lib/basisu/contrib/single_file_transcoder/examples/testcard-rgba.basis.inc rename to external/basisu/contrib/single_file_transcoder/examples/testcard-rgba.basis.inc diff --git a/lib/basisu/contrib/single_file_transcoder/examples/testcard-rgba.png b/external/basisu/contrib/single_file_transcoder/examples/testcard-rgba.png similarity index 100% rename from lib/basisu/contrib/single_file_transcoder/examples/testcard-rgba.png rename to external/basisu/contrib/single_file_transcoder/examples/testcard-rgba.png diff --git a/lib/basisu/contrib/single_file_transcoder/examples/testcard.basis.inc b/external/basisu/contrib/single_file_transcoder/examples/testcard.basis.inc similarity index 100% rename from lib/basisu/contrib/single_file_transcoder/examples/testcard.basis.inc rename to external/basisu/contrib/single_file_transcoder/examples/testcard.basis.inc diff --git a/lib/basisu/contrib/single_file_transcoder/examples/testcard.png b/external/basisu/contrib/single_file_transcoder/examples/testcard.png similarity index 100% rename from lib/basisu/contrib/single_file_transcoder/examples/testcard.png rename to external/basisu/contrib/single_file_transcoder/examples/testcard.png diff --git a/lib/basisu/encoder/basisu_backend.cpp b/external/basisu/encoder/basisu_backend.cpp similarity index 100% rename from lib/basisu/encoder/basisu_backend.cpp rename to external/basisu/encoder/basisu_backend.cpp diff --git a/lib/basisu/encoder/basisu_backend.h b/external/basisu/encoder/basisu_backend.h similarity index 100% rename from lib/basisu/encoder/basisu_backend.h rename to external/basisu/encoder/basisu_backend.h diff --git a/lib/basisu/encoder/basisu_basis_file.cpp b/external/basisu/encoder/basisu_basis_file.cpp similarity index 100% rename from lib/basisu/encoder/basisu_basis_file.cpp rename to external/basisu/encoder/basisu_basis_file.cpp diff --git a/lib/basisu/encoder/basisu_basis_file.h b/external/basisu/encoder/basisu_basis_file.h similarity index 100% rename from lib/basisu/encoder/basisu_basis_file.h rename to external/basisu/encoder/basisu_basis_file.h diff --git a/lib/basisu/encoder/basisu_bc7enc.cpp b/external/basisu/encoder/basisu_bc7enc.cpp similarity index 100% rename from lib/basisu/encoder/basisu_bc7enc.cpp rename to external/basisu/encoder/basisu_bc7enc.cpp diff --git a/lib/basisu/encoder/basisu_bc7enc.h b/external/basisu/encoder/basisu_bc7enc.h similarity index 100% rename from lib/basisu/encoder/basisu_bc7enc.h rename to external/basisu/encoder/basisu_bc7enc.h diff --git a/lib/basisu/encoder/basisu_comp.cpp b/external/basisu/encoder/basisu_comp.cpp similarity index 100% rename from lib/basisu/encoder/basisu_comp.cpp rename to external/basisu/encoder/basisu_comp.cpp diff --git a/lib/basisu/encoder/basisu_comp.h b/external/basisu/encoder/basisu_comp.h similarity index 100% rename from lib/basisu/encoder/basisu_comp.h rename to external/basisu/encoder/basisu_comp.h diff --git a/lib/basisu/encoder/basisu_enc.cpp b/external/basisu/encoder/basisu_enc.cpp similarity index 100% rename from lib/basisu/encoder/basisu_enc.cpp rename to external/basisu/encoder/basisu_enc.cpp diff --git a/lib/basisu/encoder/basisu_enc.h b/external/basisu/encoder/basisu_enc.h similarity index 100% rename from lib/basisu/encoder/basisu_enc.h rename to external/basisu/encoder/basisu_enc.h diff --git a/lib/basisu/encoder/basisu_etc.cpp b/external/basisu/encoder/basisu_etc.cpp similarity index 100% rename from lib/basisu/encoder/basisu_etc.cpp rename to external/basisu/encoder/basisu_etc.cpp diff --git a/lib/basisu/encoder/basisu_etc.h b/external/basisu/encoder/basisu_etc.h similarity index 100% rename from lib/basisu/encoder/basisu_etc.h rename to external/basisu/encoder/basisu_etc.h diff --git a/lib/basisu/encoder/basisu_frontend.cpp b/external/basisu/encoder/basisu_frontend.cpp similarity index 100% rename from lib/basisu/encoder/basisu_frontend.cpp rename to external/basisu/encoder/basisu_frontend.cpp diff --git a/lib/basisu/encoder/basisu_frontend.h b/external/basisu/encoder/basisu_frontend.h similarity index 100% rename from lib/basisu/encoder/basisu_frontend.h rename to external/basisu/encoder/basisu_frontend.h diff --git a/lib/basisu/encoder/basisu_gpu_texture.cpp b/external/basisu/encoder/basisu_gpu_texture.cpp similarity index 100% rename from lib/basisu/encoder/basisu_gpu_texture.cpp rename to external/basisu/encoder/basisu_gpu_texture.cpp diff --git a/lib/basisu/encoder/basisu_gpu_texture.h b/external/basisu/encoder/basisu_gpu_texture.h similarity index 100% rename from lib/basisu/encoder/basisu_gpu_texture.h rename to external/basisu/encoder/basisu_gpu_texture.h diff --git a/lib/basisu/encoder/basisu_kernels_declares.h b/external/basisu/encoder/basisu_kernels_declares.h similarity index 100% rename from lib/basisu/encoder/basisu_kernels_declares.h rename to external/basisu/encoder/basisu_kernels_declares.h diff --git a/lib/basisu/encoder/basisu_kernels_imp.h b/external/basisu/encoder/basisu_kernels_imp.h similarity index 100% rename from lib/basisu/encoder/basisu_kernels_imp.h rename to external/basisu/encoder/basisu_kernels_imp.h diff --git a/lib/basisu/encoder/basisu_kernels_sse.cpp b/external/basisu/encoder/basisu_kernels_sse.cpp similarity index 100% rename from lib/basisu/encoder/basisu_kernels_sse.cpp rename to external/basisu/encoder/basisu_kernels_sse.cpp diff --git a/lib/basisu/encoder/basisu_miniz.h b/external/basisu/encoder/basisu_miniz.h similarity index 100% rename from lib/basisu/encoder/basisu_miniz.h rename to external/basisu/encoder/basisu_miniz.h diff --git a/lib/basisu/encoder/basisu_ocl_kernels.h b/external/basisu/encoder/basisu_ocl_kernels.h similarity index 100% rename from lib/basisu/encoder/basisu_ocl_kernels.h rename to external/basisu/encoder/basisu_ocl_kernels.h diff --git a/lib/basisu/encoder/basisu_opencl.cpp b/external/basisu/encoder/basisu_opencl.cpp similarity index 100% rename from lib/basisu/encoder/basisu_opencl.cpp rename to external/basisu/encoder/basisu_opencl.cpp diff --git a/lib/basisu/encoder/basisu_opencl.h b/external/basisu/encoder/basisu_opencl.h similarity index 100% rename from lib/basisu/encoder/basisu_opencl.h rename to external/basisu/encoder/basisu_opencl.h diff --git a/lib/basisu/encoder/basisu_pvrtc1_4.cpp b/external/basisu/encoder/basisu_pvrtc1_4.cpp similarity index 100% rename from lib/basisu/encoder/basisu_pvrtc1_4.cpp rename to external/basisu/encoder/basisu_pvrtc1_4.cpp diff --git a/lib/basisu/encoder/basisu_pvrtc1_4.h b/external/basisu/encoder/basisu_pvrtc1_4.h similarity index 100% rename from lib/basisu/encoder/basisu_pvrtc1_4.h rename to external/basisu/encoder/basisu_pvrtc1_4.h diff --git a/lib/basisu/encoder/basisu_resample_filters.cpp b/external/basisu/encoder/basisu_resample_filters.cpp similarity index 100% rename from lib/basisu/encoder/basisu_resample_filters.cpp rename to external/basisu/encoder/basisu_resample_filters.cpp diff --git a/lib/basisu/encoder/basisu_resampler.cpp b/external/basisu/encoder/basisu_resampler.cpp similarity index 100% rename from lib/basisu/encoder/basisu_resampler.cpp rename to external/basisu/encoder/basisu_resampler.cpp diff --git a/lib/basisu/encoder/basisu_resampler.h b/external/basisu/encoder/basisu_resampler.h similarity index 100% rename from lib/basisu/encoder/basisu_resampler.h rename to external/basisu/encoder/basisu_resampler.h diff --git a/lib/basisu/encoder/basisu_resampler_filters.h b/external/basisu/encoder/basisu_resampler_filters.h similarity index 100% rename from lib/basisu/encoder/basisu_resampler_filters.h rename to external/basisu/encoder/basisu_resampler_filters.h diff --git a/lib/basisu/encoder/basisu_ssim.cpp b/external/basisu/encoder/basisu_ssim.cpp similarity index 100% rename from lib/basisu/encoder/basisu_ssim.cpp rename to external/basisu/encoder/basisu_ssim.cpp diff --git a/lib/basisu/encoder/basisu_ssim.h b/external/basisu/encoder/basisu_ssim.h similarity index 100% rename from lib/basisu/encoder/basisu_ssim.h rename to external/basisu/encoder/basisu_ssim.h diff --git a/lib/basisu/encoder/basisu_uastc_enc.cpp b/external/basisu/encoder/basisu_uastc_enc.cpp similarity index 100% rename from lib/basisu/encoder/basisu_uastc_enc.cpp rename to external/basisu/encoder/basisu_uastc_enc.cpp diff --git a/lib/basisu/encoder/basisu_uastc_enc.h b/external/basisu/encoder/basisu_uastc_enc.h similarity index 100% rename from lib/basisu/encoder/basisu_uastc_enc.h rename to external/basisu/encoder/basisu_uastc_enc.h diff --git a/lib/basisu/encoder/cppspmd_flow.h b/external/basisu/encoder/cppspmd_flow.h similarity index 100% rename from lib/basisu/encoder/cppspmd_flow.h rename to external/basisu/encoder/cppspmd_flow.h diff --git a/lib/basisu/encoder/cppspmd_math.h b/external/basisu/encoder/cppspmd_math.h similarity index 100% rename from lib/basisu/encoder/cppspmd_math.h rename to external/basisu/encoder/cppspmd_math.h diff --git a/lib/basisu/encoder/cppspmd_math_declares.h b/external/basisu/encoder/cppspmd_math_declares.h similarity index 100% rename from lib/basisu/encoder/cppspmd_math_declares.h rename to external/basisu/encoder/cppspmd_math_declares.h diff --git a/lib/basisu/encoder/cppspmd_sse.h b/external/basisu/encoder/cppspmd_sse.h similarity index 100% rename from lib/basisu/encoder/cppspmd_sse.h rename to external/basisu/encoder/cppspmd_sse.h diff --git a/lib/basisu/encoder/cppspmd_type_aliases.h b/external/basisu/encoder/cppspmd_type_aliases.h similarity index 100% rename from lib/basisu/encoder/cppspmd_type_aliases.h rename to external/basisu/encoder/cppspmd_type_aliases.h diff --git a/lib/basisu/encoder/jpgd.cpp b/external/basisu/encoder/jpgd.cpp similarity index 100% rename from lib/basisu/encoder/jpgd.cpp rename to external/basisu/encoder/jpgd.cpp diff --git a/lib/basisu/encoder/jpgd.h b/external/basisu/encoder/jpgd.h similarity index 100% rename from lib/basisu/encoder/jpgd.h rename to external/basisu/encoder/jpgd.h diff --git a/lib/basisu/encoder/pvpngreader.cpp b/external/basisu/encoder/pvpngreader.cpp similarity index 100% rename from lib/basisu/encoder/pvpngreader.cpp rename to external/basisu/encoder/pvpngreader.cpp diff --git a/lib/basisu/encoder/pvpngreader.h b/external/basisu/encoder/pvpngreader.h similarity index 100% rename from lib/basisu/encoder/pvpngreader.h rename to external/basisu/encoder/pvpngreader.h diff --git a/lib/basisu/encoder_lvl_vs_perf.png b/external/basisu/encoder_lvl_vs_perf.png similarity index 100% rename from lib/basisu/encoder_lvl_vs_perf.png rename to external/basisu/encoder_lvl_vs_perf.png diff --git a/lib/basisu/format.sh b/external/basisu/format.sh similarity index 100% rename from lib/basisu/format.sh rename to external/basisu/format.sh diff --git a/lib/basisu/spec/basis_spec.txt b/external/basisu/spec/basis_spec.txt similarity index 100% rename from lib/basisu/spec/basis_spec.txt rename to external/basisu/spec/basis_spec.txt diff --git a/lib/basisu/test_files/alpha0.png b/external/basisu/test_files/alpha0.png similarity index 100% rename from lib/basisu/test_files/alpha0.png rename to external/basisu/test_files/alpha0.png diff --git a/lib/basisu/test_files/black_1x1.png b/external/basisu/test_files/black_1x1.png similarity index 100% rename from lib/basisu/test_files/black_1x1.png rename to external/basisu/test_files/black_1x1.png diff --git a/lib/basisu/test_files/kodim01.png b/external/basisu/test_files/kodim01.png similarity index 100% rename from lib/basisu/test_files/kodim01.png rename to external/basisu/test_files/kodim01.png diff --git a/lib/basisu/test_files/kodim02.png b/external/basisu/test_files/kodim02.png similarity index 100% rename from lib/basisu/test_files/kodim02.png rename to external/basisu/test_files/kodim02.png diff --git a/lib/basisu/test_files/kodim03.png b/external/basisu/test_files/kodim03.png similarity index 100% rename from lib/basisu/test_files/kodim03.png rename to external/basisu/test_files/kodim03.png diff --git a/lib/basisu/test_files/kodim04.png b/external/basisu/test_files/kodim04.png similarity index 100% rename from lib/basisu/test_files/kodim04.png rename to external/basisu/test_files/kodim04.png diff --git a/lib/basisu/test_files/kodim05.png b/external/basisu/test_files/kodim05.png similarity index 100% rename from lib/basisu/test_files/kodim05.png rename to external/basisu/test_files/kodim05.png diff --git a/lib/basisu/test_files/kodim06.png b/external/basisu/test_files/kodim06.png similarity index 100% rename from lib/basisu/test_files/kodim06.png rename to external/basisu/test_files/kodim06.png diff --git a/lib/basisu/test_files/kodim07.png b/external/basisu/test_files/kodim07.png similarity index 100% rename from lib/basisu/test_files/kodim07.png rename to external/basisu/test_files/kodim07.png diff --git a/lib/basisu/test_files/kodim08.png b/external/basisu/test_files/kodim08.png similarity index 100% rename from lib/basisu/test_files/kodim08.png rename to external/basisu/test_files/kodim08.png diff --git a/lib/basisu/test_files/kodim09.png b/external/basisu/test_files/kodim09.png similarity index 100% rename from lib/basisu/test_files/kodim09.png rename to external/basisu/test_files/kodim09.png diff --git a/lib/basisu/test_files/kodim10.png b/external/basisu/test_files/kodim10.png similarity index 100% rename from lib/basisu/test_files/kodim10.png rename to external/basisu/test_files/kodim10.png diff --git a/lib/basisu/test_files/kodim11.png b/external/basisu/test_files/kodim11.png similarity index 100% rename from lib/basisu/test_files/kodim11.png rename to external/basisu/test_files/kodim11.png diff --git a/lib/basisu/test_files/kodim12.png b/external/basisu/test_files/kodim12.png similarity index 100% rename from lib/basisu/test_files/kodim12.png rename to external/basisu/test_files/kodim12.png diff --git a/lib/basisu/test_files/kodim13.png b/external/basisu/test_files/kodim13.png similarity index 100% rename from lib/basisu/test_files/kodim13.png rename to external/basisu/test_files/kodim13.png diff --git a/lib/basisu/test_files/kodim14.png b/external/basisu/test_files/kodim14.png similarity index 100% rename from lib/basisu/test_files/kodim14.png rename to external/basisu/test_files/kodim14.png diff --git a/lib/basisu/test_files/kodim15.png b/external/basisu/test_files/kodim15.png similarity index 100% rename from lib/basisu/test_files/kodim15.png rename to external/basisu/test_files/kodim15.png diff --git a/lib/basisu/test_files/kodim16.png b/external/basisu/test_files/kodim16.png similarity index 100% rename from lib/basisu/test_files/kodim16.png rename to external/basisu/test_files/kodim16.png diff --git a/lib/basisu/test_files/kodim17.png b/external/basisu/test_files/kodim17.png similarity index 100% rename from lib/basisu/test_files/kodim17.png rename to external/basisu/test_files/kodim17.png diff --git a/lib/basisu/test_files/kodim18.png b/external/basisu/test_files/kodim18.png similarity index 100% rename from lib/basisu/test_files/kodim18.png rename to external/basisu/test_files/kodim18.png diff --git a/lib/basisu/test_files/kodim19.png b/external/basisu/test_files/kodim19.png similarity index 100% rename from lib/basisu/test_files/kodim19.png rename to external/basisu/test_files/kodim19.png diff --git a/lib/basisu/test_files/kodim20.png b/external/basisu/test_files/kodim20.png similarity index 100% rename from lib/basisu/test_files/kodim20.png rename to external/basisu/test_files/kodim20.png diff --git a/lib/basisu/test_files/kodim21.png b/external/basisu/test_files/kodim21.png similarity index 100% rename from lib/basisu/test_files/kodim21.png rename to external/basisu/test_files/kodim21.png diff --git a/lib/basisu/test_files/kodim22.png b/external/basisu/test_files/kodim22.png similarity index 100% rename from lib/basisu/test_files/kodim22.png rename to external/basisu/test_files/kodim22.png diff --git a/lib/basisu/test_files/kodim23.png b/external/basisu/test_files/kodim23.png similarity index 100% rename from lib/basisu/test_files/kodim23.png rename to external/basisu/test_files/kodim23.png diff --git a/lib/basisu/test_files/kodim24.png b/external/basisu/test_files/kodim24.png similarity index 100% rename from lib/basisu/test_files/kodim24.png rename to external/basisu/test_files/kodim24.png diff --git a/lib/basisu/test_files/white_1x1.png b/external/basisu/test_files/white_1x1.png similarity index 100% rename from lib/basisu/test_files/white_1x1.png rename to external/basisu/test_files/white_1x1.png diff --git a/lib/basisu/test_files/wikipedia.png b/external/basisu/test_files/wikipedia.png similarity index 100% rename from lib/basisu/test_files/wikipedia.png rename to external/basisu/test_files/wikipedia.png diff --git a/lib/basisu/transcoder/basisu.h b/external/basisu/transcoder/basisu.h similarity index 100% rename from lib/basisu/transcoder/basisu.h rename to external/basisu/transcoder/basisu.h diff --git a/lib/basisu/transcoder/basisu_containers.h b/external/basisu/transcoder/basisu_containers.h similarity index 100% rename from lib/basisu/transcoder/basisu_containers.h rename to external/basisu/transcoder/basisu_containers.h diff --git a/lib/basisu/transcoder/basisu_containers_impl.h b/external/basisu/transcoder/basisu_containers_impl.h similarity index 100% rename from lib/basisu/transcoder/basisu_containers_impl.h rename to external/basisu/transcoder/basisu_containers_impl.h diff --git a/lib/basisu/transcoder/basisu_file_headers.h b/external/basisu/transcoder/basisu_file_headers.h similarity index 100% rename from lib/basisu/transcoder/basisu_file_headers.h rename to external/basisu/transcoder/basisu_file_headers.h diff --git a/lib/basisu/transcoder/basisu_transcoder.cpp b/external/basisu/transcoder/basisu_transcoder.cpp similarity index 100% rename from lib/basisu/transcoder/basisu_transcoder.cpp rename to external/basisu/transcoder/basisu_transcoder.cpp diff --git a/lib/basisu/transcoder/basisu_transcoder.h b/external/basisu/transcoder/basisu_transcoder.h similarity index 100% rename from lib/basisu/transcoder/basisu_transcoder.h rename to external/basisu/transcoder/basisu_transcoder.h diff --git a/lib/basisu/transcoder/basisu_transcoder_internal.h b/external/basisu/transcoder/basisu_transcoder_internal.h similarity index 100% rename from lib/basisu/transcoder/basisu_transcoder_internal.h rename to external/basisu/transcoder/basisu_transcoder_internal.h diff --git a/lib/basisu/transcoder/basisu_transcoder_tables_astc.inc b/external/basisu/transcoder/basisu_transcoder_tables_astc.inc similarity index 100% rename from lib/basisu/transcoder/basisu_transcoder_tables_astc.inc rename to external/basisu/transcoder/basisu_transcoder_tables_astc.inc diff --git a/lib/basisu/transcoder/basisu_transcoder_tables_astc_0_255.inc b/external/basisu/transcoder/basisu_transcoder_tables_astc_0_255.inc similarity index 100% rename from lib/basisu/transcoder/basisu_transcoder_tables_astc_0_255.inc rename to external/basisu/transcoder/basisu_transcoder_tables_astc_0_255.inc diff --git a/lib/basisu/transcoder/basisu_transcoder_tables_atc_55.inc b/external/basisu/transcoder/basisu_transcoder_tables_atc_55.inc similarity index 100% rename from lib/basisu/transcoder/basisu_transcoder_tables_atc_55.inc rename to external/basisu/transcoder/basisu_transcoder_tables_atc_55.inc diff --git a/lib/basisu/transcoder/basisu_transcoder_tables_atc_56.inc b/external/basisu/transcoder/basisu_transcoder_tables_atc_56.inc similarity index 100% rename from lib/basisu/transcoder/basisu_transcoder_tables_atc_56.inc rename to external/basisu/transcoder/basisu_transcoder_tables_atc_56.inc diff --git a/lib/basisu/transcoder/basisu_transcoder_tables_bc7_m5_alpha.inc b/external/basisu/transcoder/basisu_transcoder_tables_bc7_m5_alpha.inc similarity index 100% rename from lib/basisu/transcoder/basisu_transcoder_tables_bc7_m5_alpha.inc rename to external/basisu/transcoder/basisu_transcoder_tables_bc7_m5_alpha.inc diff --git a/lib/basisu/transcoder/basisu_transcoder_tables_bc7_m5_color.inc b/external/basisu/transcoder/basisu_transcoder_tables_bc7_m5_color.inc similarity index 100% rename from lib/basisu/transcoder/basisu_transcoder_tables_bc7_m5_color.inc rename to external/basisu/transcoder/basisu_transcoder_tables_bc7_m5_color.inc diff --git a/lib/basisu/transcoder/basisu_transcoder_tables_dxt1_5.inc b/external/basisu/transcoder/basisu_transcoder_tables_dxt1_5.inc similarity index 100% rename from lib/basisu/transcoder/basisu_transcoder_tables_dxt1_5.inc rename to external/basisu/transcoder/basisu_transcoder_tables_dxt1_5.inc diff --git a/lib/basisu/transcoder/basisu_transcoder_tables_dxt1_6.inc b/external/basisu/transcoder/basisu_transcoder_tables_dxt1_6.inc similarity index 100% rename from lib/basisu/transcoder/basisu_transcoder_tables_dxt1_6.inc rename to external/basisu/transcoder/basisu_transcoder_tables_dxt1_6.inc diff --git a/lib/basisu/transcoder/basisu_transcoder_tables_pvrtc2_45.inc b/external/basisu/transcoder/basisu_transcoder_tables_pvrtc2_45.inc similarity index 100% rename from lib/basisu/transcoder/basisu_transcoder_tables_pvrtc2_45.inc rename to external/basisu/transcoder/basisu_transcoder_tables_pvrtc2_45.inc diff --git a/lib/basisu/transcoder/basisu_transcoder_tables_pvrtc2_alpha_33.inc b/external/basisu/transcoder/basisu_transcoder_tables_pvrtc2_alpha_33.inc similarity index 100% rename from lib/basisu/transcoder/basisu_transcoder_tables_pvrtc2_alpha_33.inc rename to external/basisu/transcoder/basisu_transcoder_tables_pvrtc2_alpha_33.inc diff --git a/lib/basisu/transcoder/basisu_transcoder_uastc.h b/external/basisu/transcoder/basisu_transcoder_uastc.h similarity index 100% rename from lib/basisu/transcoder/basisu_transcoder_uastc.h rename to external/basisu/transcoder/basisu_transcoder_uastc.h diff --git a/lib/basisu/webgl/README.md b/external/basisu/webgl/README.md similarity index 100% rename from lib/basisu/webgl/README.md rename to external/basisu/webgl/README.md diff --git a/lib/basisu/webgl/encode_test/assets/kodim03.png b/external/basisu/webgl/encode_test/assets/kodim03.png similarity index 100% rename from lib/basisu/webgl/encode_test/assets/kodim03.png rename to external/basisu/webgl/encode_test/assets/kodim03.png diff --git a/lib/basisu/webgl/encode_test/assets/kodim18.png b/external/basisu/webgl/encode_test/assets/kodim18.png similarity index 100% rename from lib/basisu/webgl/encode_test/assets/kodim18.png rename to external/basisu/webgl/encode_test/assets/kodim18.png diff --git a/lib/basisu/webgl/encode_test/assets/kodim18_64x64.png b/external/basisu/webgl/encode_test/assets/kodim18_64x64.png similarity index 100% rename from lib/basisu/webgl/encode_test/assets/kodim18_64x64.png rename to external/basisu/webgl/encode_test/assets/kodim18_64x64.png diff --git a/lib/basisu/webgl/encode_test/assets/kodim26_uastc_1024.basis b/external/basisu/webgl/encode_test/assets/kodim26_uastc_1024.basis similarity index 100% rename from lib/basisu/webgl/encode_test/assets/kodim26_uastc_1024.basis rename to external/basisu/webgl/encode_test/assets/kodim26_uastc_1024.basis diff --git a/lib/basisu/webgl/encode_test/dxt-to-rgb565.js b/external/basisu/webgl/encode_test/dxt-to-rgb565.js similarity index 100% rename from lib/basisu/webgl/encode_test/dxt-to-rgb565.js rename to external/basisu/webgl/encode_test/dxt-to-rgb565.js diff --git a/lib/basisu/webgl/encode_test/index.html b/external/basisu/webgl/encode_test/index.html similarity index 100% rename from lib/basisu/webgl/encode_test/index.html rename to external/basisu/webgl/encode_test/index.html diff --git a/lib/basisu/webgl/encode_test/preview.png b/external/basisu/webgl/encode_test/preview.png similarity index 100% rename from lib/basisu/webgl/encode_test/preview.png rename to external/basisu/webgl/encode_test/preview.png diff --git a/lib/basisu/webgl/encode_test/renderer.js b/external/basisu/webgl/encode_test/renderer.js similarity index 100% rename from lib/basisu/webgl/encode_test/renderer.js rename to external/basisu/webgl/encode_test/renderer.js diff --git a/lib/basisu/webgl/encoder/.gitignore b/external/basisu/webgl/encoder/.gitignore similarity index 100% rename from lib/basisu/webgl/encoder/.gitignore rename to external/basisu/webgl/encoder/.gitignore diff --git a/lib/basisu/webgl/encoder/CMakeLists.txt b/external/basisu/webgl/encoder/CMakeLists.txt similarity index 100% rename from lib/basisu/webgl/encoder/CMakeLists.txt rename to external/basisu/webgl/encoder/CMakeLists.txt diff --git a/lib/basisu/webgl/encoder/README.md b/external/basisu/webgl/encoder/README.md similarity index 100% rename from lib/basisu/webgl/encoder/README.md rename to external/basisu/webgl/encoder/README.md diff --git a/lib/basisu/webgl/encoder/build/basis_encoder.js b/external/basisu/webgl/encoder/build/basis_encoder.js similarity index 100% rename from lib/basisu/webgl/encoder/build/basis_encoder.js rename to external/basisu/webgl/encoder/build/basis_encoder.js diff --git a/lib/basisu/webgl/encoder/build/basis_encoder.wasm b/external/basisu/webgl/encoder/build/basis_encoder.wasm similarity index 100% rename from lib/basisu/webgl/encoder/build/basis_encoder.wasm rename to external/basisu/webgl/encoder/build/basis_encoder.wasm diff --git a/lib/basisu/webgl/encoder/build/basis_loader.js b/external/basisu/webgl/encoder/build/basis_loader.js similarity index 100% rename from lib/basisu/webgl/encoder/build/basis_loader.js rename to external/basisu/webgl/encoder/build/basis_loader.js diff --git a/lib/basisu/webgl/gltf/BasisTextureLoader.js b/external/basisu/webgl/gltf/BasisTextureLoader.js similarity index 100% rename from lib/basisu/webgl/gltf/BasisTextureLoader.js rename to external/basisu/webgl/gltf/BasisTextureLoader.js diff --git a/lib/basisu/webgl/gltf/GLTFLoader.js b/external/basisu/webgl/gltf/GLTFLoader.js similarity index 100% rename from lib/basisu/webgl/gltf/GLTFLoader.js rename to external/basisu/webgl/gltf/GLTFLoader.js diff --git a/lib/basisu/webgl/gltf/README.md b/external/basisu/webgl/gltf/README.md similarity index 100% rename from lib/basisu/webgl/gltf/README.md rename to external/basisu/webgl/gltf/README.md diff --git a/lib/basisu/webgl/gltf/assets/AgiHqSmall.gltf b/external/basisu/webgl/gltf/assets/AgiHqSmall.gltf similarity index 100% rename from lib/basisu/webgl/gltf/assets/AgiHqSmall.gltf rename to external/basisu/webgl/gltf/assets/AgiHqSmall.gltf diff --git a/lib/basisu/webgl/gltf/assets/kodim26_uastc.basis b/external/basisu/webgl/gltf/assets/kodim26_uastc.basis similarity index 100% rename from lib/basisu/webgl/gltf/assets/kodim26_uastc.basis rename to external/basisu/webgl/gltf/assets/kodim26_uastc.basis diff --git a/lib/basisu/webgl/gltf/assets/mesh-0-0_Buffer_POSITION.bin b/external/basisu/webgl/gltf/assets/mesh-0-0_Buffer_POSITION.bin similarity index 100% rename from lib/basisu/webgl/gltf/assets/mesh-0-0_Buffer_POSITION.bin rename to external/basisu/webgl/gltf/assets/mesh-0-0_Buffer_POSITION.bin diff --git a/lib/basisu/webgl/gltf/assets/textureAtlasImage.basis b/external/basisu/webgl/gltf/assets/textureAtlasImage.basis similarity index 100% rename from lib/basisu/webgl/gltf/assets/textureAtlasImage.basis rename to external/basisu/webgl/gltf/assets/textureAtlasImage.basis diff --git a/lib/basisu/webgl/gltf/index.html b/external/basisu/webgl/gltf/index.html similarity index 100% rename from lib/basisu/webgl/gltf/index.html rename to external/basisu/webgl/gltf/index.html diff --git a/lib/basisu/webgl/gltf/preview.png b/external/basisu/webgl/gltf/preview.png similarity index 100% rename from lib/basisu/webgl/gltf/preview.png rename to external/basisu/webgl/gltf/preview.png diff --git a/lib/basisu/webgl/gltf/three.min.js b/external/basisu/webgl/gltf/three.min.js similarity index 100% rename from lib/basisu/webgl/gltf/three.min.js rename to external/basisu/webgl/gltf/three.min.js diff --git a/lib/basisu/webgl/index.html b/external/basisu/webgl/index.html similarity index 100% rename from lib/basisu/webgl/index.html rename to external/basisu/webgl/index.html diff --git a/lib/basisu/webgl/ktx2_encode_test/assets/kodim03.png b/external/basisu/webgl/ktx2_encode_test/assets/kodim03.png similarity index 100% rename from lib/basisu/webgl/ktx2_encode_test/assets/kodim03.png rename to external/basisu/webgl/ktx2_encode_test/assets/kodim03.png diff --git a/lib/basisu/webgl/ktx2_encode_test/assets/kodim18.png b/external/basisu/webgl/ktx2_encode_test/assets/kodim18.png similarity index 100% rename from lib/basisu/webgl/ktx2_encode_test/assets/kodim18.png rename to external/basisu/webgl/ktx2_encode_test/assets/kodim18.png diff --git a/lib/basisu/webgl/ktx2_encode_test/assets/kodim18_64x64.png b/external/basisu/webgl/ktx2_encode_test/assets/kodim18_64x64.png similarity index 100% rename from lib/basisu/webgl/ktx2_encode_test/assets/kodim18_64x64.png rename to external/basisu/webgl/ktx2_encode_test/assets/kodim18_64x64.png diff --git a/lib/basisu/webgl/ktx2_encode_test/assets/kodim23.ktx2 b/external/basisu/webgl/ktx2_encode_test/assets/kodim23.ktx2 similarity index 100% rename from lib/basisu/webgl/ktx2_encode_test/assets/kodim23.ktx2 rename to external/basisu/webgl/ktx2_encode_test/assets/kodim23.ktx2 diff --git a/lib/basisu/webgl/ktx2_encode_test/dxt-to-rgb565.js b/external/basisu/webgl/ktx2_encode_test/dxt-to-rgb565.js similarity index 100% rename from lib/basisu/webgl/ktx2_encode_test/dxt-to-rgb565.js rename to external/basisu/webgl/ktx2_encode_test/dxt-to-rgb565.js diff --git a/lib/basisu/webgl/ktx2_encode_test/index.html b/external/basisu/webgl/ktx2_encode_test/index.html similarity index 100% rename from lib/basisu/webgl/ktx2_encode_test/index.html rename to external/basisu/webgl/ktx2_encode_test/index.html diff --git a/lib/basisu/webgl/ktx2_encode_test/preview.png b/external/basisu/webgl/ktx2_encode_test/preview.png similarity index 100% rename from lib/basisu/webgl/ktx2_encode_test/preview.png rename to external/basisu/webgl/ktx2_encode_test/preview.png diff --git a/lib/basisu/webgl/ktx2_encode_test/renderer.js b/external/basisu/webgl/ktx2_encode_test/renderer.js similarity index 100% rename from lib/basisu/webgl/ktx2_encode_test/renderer.js rename to external/basisu/webgl/ktx2_encode_test/renderer.js diff --git a/lib/basisu/webgl/texture/assets/alpha3.basis b/external/basisu/webgl/texture/assets/alpha3.basis similarity index 100% rename from lib/basisu/webgl/texture/assets/alpha3.basis rename to external/basisu/webgl/texture/assets/alpha3.basis diff --git a/lib/basisu/webgl/texture/assets/kodim01_mipmapped.basis b/external/basisu/webgl/texture/assets/kodim01_mipmapped.basis similarity index 100% rename from lib/basisu/webgl/texture/assets/kodim01_mipmapped.basis rename to external/basisu/webgl/texture/assets/kodim01_mipmapped.basis diff --git a/lib/basisu/webgl/texture/assets/kodim03.basis b/external/basisu/webgl/texture/assets/kodim03.basis similarity index 100% rename from lib/basisu/webgl/texture/assets/kodim03.basis rename to external/basisu/webgl/texture/assets/kodim03.basis diff --git a/lib/basisu/webgl/texture/assets/kodim03_uastc.basis b/external/basisu/webgl/texture/assets/kodim03_uastc.basis similarity index 100% rename from lib/basisu/webgl/texture/assets/kodim03_uastc.basis rename to external/basisu/webgl/texture/assets/kodim03_uastc.basis diff --git a/lib/basisu/webgl/texture/assets/kodim18_uastc.basis b/external/basisu/webgl/texture/assets/kodim18_uastc.basis similarity index 100% rename from lib/basisu/webgl/texture/assets/kodim18_uastc.basis rename to external/basisu/webgl/texture/assets/kodim18_uastc.basis diff --git a/lib/basisu/webgl/texture/assets/kodim20.basis b/external/basisu/webgl/texture/assets/kodim20.basis similarity index 100% rename from lib/basisu/webgl/texture/assets/kodim20.basis rename to external/basisu/webgl/texture/assets/kodim20.basis diff --git a/lib/basisu/webgl/texture/assets/kodim20_1024x1024.basis b/external/basisu/webgl/texture/assets/kodim20_1024x1024.basis similarity index 100% rename from lib/basisu/webgl/texture/assets/kodim20_1024x1024.basis rename to external/basisu/webgl/texture/assets/kodim20_1024x1024.basis diff --git a/lib/basisu/webgl/texture/assets/kodim26_uastc_1024.basis b/external/basisu/webgl/texture/assets/kodim26_uastc_1024.basis similarity index 100% rename from lib/basisu/webgl/texture/assets/kodim26_uastc_1024.basis rename to external/basisu/webgl/texture/assets/kodim26_uastc_1024.basis diff --git a/lib/basisu/webgl/texture/dxt-to-rgb565.js b/external/basisu/webgl/texture/dxt-to-rgb565.js similarity index 100% rename from lib/basisu/webgl/texture/dxt-to-rgb565.js rename to external/basisu/webgl/texture/dxt-to-rgb565.js diff --git a/lib/basisu/webgl/texture/index.html b/external/basisu/webgl/texture/index.html similarity index 100% rename from lib/basisu/webgl/texture/index.html rename to external/basisu/webgl/texture/index.html diff --git a/lib/basisu/webgl/texture/preview.png b/external/basisu/webgl/texture/preview.png similarity index 100% rename from lib/basisu/webgl/texture/preview.png rename to external/basisu/webgl/texture/preview.png diff --git a/lib/basisu/webgl/texture/renderer.js b/external/basisu/webgl/texture/renderer.js similarity index 100% rename from lib/basisu/webgl/texture/renderer.js rename to external/basisu/webgl/texture/renderer.js diff --git a/lib/basisu/webgl/transcoder/.gitignore b/external/basisu/webgl/transcoder/.gitignore similarity index 100% rename from lib/basisu/webgl/transcoder/.gitignore rename to external/basisu/webgl/transcoder/.gitignore diff --git a/lib/basisu/webgl/transcoder/CMakeLists.txt b/external/basisu/webgl/transcoder/CMakeLists.txt similarity index 100% rename from lib/basisu/webgl/transcoder/CMakeLists.txt rename to external/basisu/webgl/transcoder/CMakeLists.txt diff --git a/lib/basisu/webgl/transcoder/README.md b/external/basisu/webgl/transcoder/README.md similarity index 100% rename from lib/basisu/webgl/transcoder/README.md rename to external/basisu/webgl/transcoder/README.md diff --git a/lib/basisu/webgl/transcoder/basis_wrappers.cpp b/external/basisu/webgl/transcoder/basis_wrappers.cpp similarity index 100% rename from lib/basisu/webgl/transcoder/basis_wrappers.cpp rename to external/basisu/webgl/transcoder/basis_wrappers.cpp diff --git a/lib/basisu/webgl/transcoder/build/basis_loader.js b/external/basisu/webgl/transcoder/build/basis_loader.js similarity index 100% rename from lib/basisu/webgl/transcoder/build/basis_loader.js rename to external/basisu/webgl/transcoder/build/basis_loader.js diff --git a/lib/basisu/webgl/transcoder/build/basis_transcoder.js b/external/basisu/webgl/transcoder/build/basis_transcoder.js similarity index 100% rename from lib/basisu/webgl/transcoder/build/basis_transcoder.js rename to external/basisu/webgl/transcoder/build/basis_transcoder.js diff --git a/lib/basisu/webgl/transcoder/build/basis_transcoder.wasm b/external/basisu/webgl/transcoder/build/basis_transcoder.wasm similarity index 100% rename from lib/basisu/webgl/transcoder/build/basis_transcoder.wasm rename to external/basisu/webgl/transcoder/build/basis_transcoder.wasm diff --git a/lib/basisu/webgl_videotest/6.1.01.basis b/external/basisu/webgl_videotest/6.1.01.basis similarity index 100% rename from lib/basisu/webgl_videotest/6.1.01.basis rename to external/basisu/webgl_videotest/6.1.01.basis diff --git a/lib/basisu/webgl_videotest/basis.js b/external/basisu/webgl_videotest/basis.js similarity index 100% rename from lib/basisu/webgl_videotest/basis.js rename to external/basisu/webgl_videotest/basis.js diff --git a/lib/basisu/webgl_videotest/basis.js.mem b/external/basisu/webgl_videotest/basis.js.mem similarity index 100% rename from lib/basisu/webgl_videotest/basis.js.mem rename to external/basisu/webgl_videotest/basis.js.mem diff --git a/lib/basisu/webgl_videotest/basis.wasm b/external/basisu/webgl_videotest/basis.wasm similarity index 100% rename from lib/basisu/webgl_videotest/basis.wasm rename to external/basisu/webgl_videotest/basis.wasm diff --git a/lib/basisu/webgl_videotest/basis_wrappers.cpp b/external/basisu/webgl_videotest/basis_wrappers.cpp similarity index 100% rename from lib/basisu/webgl_videotest/basis_wrappers.cpp rename to external/basisu/webgl_videotest/basis_wrappers.cpp diff --git a/lib/basisu/webgl_videotest/build.bat b/external/basisu/webgl_videotest/build.bat similarity index 100% rename from lib/basisu/webgl_videotest/build.bat rename to external/basisu/webgl_videotest/build.bat diff --git a/lib/basisu/webgl_videotest/build.sh b/external/basisu/webgl_videotest/build.sh similarity index 100% rename from lib/basisu/webgl_videotest/build.sh rename to external/basisu/webgl_videotest/build.sh diff --git a/lib/basisu/webgl_videotest/dxt-to-rgb565.js b/external/basisu/webgl_videotest/dxt-to-rgb565.js similarity index 100% rename from lib/basisu/webgl_videotest/dxt-to-rgb565.js rename to external/basisu/webgl_videotest/dxt-to-rgb565.js diff --git a/lib/basisu/webgl_videotest/index.html b/external/basisu/webgl_videotest/index.html similarity index 100% rename from lib/basisu/webgl_videotest/index.html rename to external/basisu/webgl_videotest/index.html diff --git a/lib/basisu/webgl_videotest/kodim01.basis b/external/basisu/webgl_videotest/kodim01.basis similarity index 100% rename from lib/basisu/webgl_videotest/kodim01.basis rename to external/basisu/webgl_videotest/kodim01.basis diff --git a/lib/basisu/webgl_videotest/kodim20.basis b/external/basisu/webgl_videotest/kodim20.basis similarity index 100% rename from lib/basisu/webgl_videotest/kodim20.basis rename to external/basisu/webgl_videotest/kodim20.basis diff --git a/lib/basisu/webgl_videotest/renderer.js b/external/basisu/webgl_videotest/renderer.js similarity index 100% rename from lib/basisu/webgl_videotest/renderer.js rename to external/basisu/webgl_videotest/renderer.js diff --git a/lib/basisu/zstd/LICENSE b/external/basisu/zstd/LICENSE similarity index 100% rename from lib/basisu/zstd/LICENSE rename to external/basisu/zstd/LICENSE diff --git a/lib/basisu/zstd/zstd.c b/external/basisu/zstd/zstd.c similarity index 100% rename from lib/basisu/zstd/zstd.c rename to external/basisu/zstd/zstd.c diff --git a/lib/basisu/zstd/zstd.h b/external/basisu/zstd/zstd.h similarity index 100% rename from lib/basisu/zstd/zstd.h rename to external/basisu/zstd/zstd.h diff --git a/lib/basisu/zstd/zstddeclib.c b/external/basisu/zstd/zstddeclib.c similarity index 100% rename from lib/basisu/zstd/zstddeclib.c rename to external/basisu/zstd/zstddeclib.c diff --git a/other_projects/cxxopts/CMakeLists.txt b/external/cxxopts/CMakeLists.txt similarity index 100% rename from other_projects/cxxopts/CMakeLists.txt rename to external/cxxopts/CMakeLists.txt diff --git a/other_projects/cxxopts/cmake/cxxopts.cmake b/external/cxxopts/cmake/cxxopts.cmake similarity index 100% rename from other_projects/cxxopts/cmake/cxxopts.cmake rename to external/cxxopts/cmake/cxxopts.cmake diff --git a/other_projects/cxxopts/include/CMakeLists.txt b/external/cxxopts/include/CMakeLists.txt similarity index 100% rename from other_projects/cxxopts/include/CMakeLists.txt rename to external/cxxopts/include/CMakeLists.txt diff --git a/other_projects/cxxopts/include/cxxopts.hpp b/external/cxxopts/include/cxxopts.hpp similarity index 100% rename from other_projects/cxxopts/include/cxxopts.hpp rename to external/cxxopts/include/cxxopts.hpp diff --git a/lib/dfdutils/.gitignore b/external/dfdutils/.gitignore similarity index 100% rename from lib/dfdutils/.gitignore rename to external/dfdutils/.gitignore diff --git a/lib/dfdutils/.gitrepo b/external/dfdutils/.gitrepo similarity index 100% rename from lib/dfdutils/.gitrepo rename to external/dfdutils/.gitrepo diff --git a/lib/dfdutils/.reuse/dep5 b/external/dfdutils/.reuse/dep5 similarity index 100% rename from lib/dfdutils/.reuse/dep5 rename to external/dfdutils/.reuse/dep5 diff --git a/lib/dfdutils/.travis.yml b/external/dfdutils/.travis.yml similarity index 100% rename from lib/dfdutils/.travis.yml rename to external/dfdutils/.travis.yml diff --git a/lib/dfdutils/CODE_OF_CONDUCT.adoc b/external/dfdutils/CODE_OF_CONDUCT.adoc similarity index 100% rename from lib/dfdutils/CODE_OF_CONDUCT.adoc rename to external/dfdutils/CODE_OF_CONDUCT.adoc diff --git a/lib/dfdutils/KHR/khr_df.h b/external/dfdutils/KHR/khr_df.h similarity index 100% rename from lib/dfdutils/KHR/khr_df.h rename to external/dfdutils/KHR/khr_df.h diff --git a/lib/dfdutils/LICENSE.adoc b/external/dfdutils/LICENSE.adoc similarity index 100% rename from lib/dfdutils/LICENSE.adoc rename to external/dfdutils/LICENSE.adoc diff --git a/lib/dfdutils/LICENSES/Apache-2.0.txt b/external/dfdutils/LICENSES/Apache-2.0.txt similarity index 100% rename from lib/dfdutils/LICENSES/Apache-2.0.txt rename to external/dfdutils/LICENSES/Apache-2.0.txt diff --git a/lib/dfdutils/Makefile b/external/dfdutils/Makefile similarity index 100% rename from lib/dfdutils/Makefile rename to external/dfdutils/Makefile diff --git a/lib/dfdutils/README.adoc b/external/dfdutils/README.adoc similarity index 100% rename from lib/dfdutils/README.adoc rename to external/dfdutils/README.adoc diff --git a/lib/dfdutils/colourspaces.c b/external/dfdutils/colourspaces.c similarity index 100% rename from lib/dfdutils/colourspaces.c rename to external/dfdutils/colourspaces.c diff --git a/lib/dfdutils/createdfd.c b/external/dfdutils/createdfd.c similarity index 100% rename from lib/dfdutils/createdfd.c rename to external/dfdutils/createdfd.c diff --git a/lib/dfdutils/createdfdtest.c b/external/dfdutils/createdfdtest.c similarity index 100% rename from lib/dfdutils/createdfdtest.c rename to external/dfdutils/createdfdtest.c diff --git a/lib/dfdutils/dfd.h b/external/dfdutils/dfd.h similarity index 99% rename from lib/dfdutils/dfd.h rename to external/dfdutils/dfd.h index 756490fc82..9ec915f18a 100644 --- a/lib/dfdutils/dfd.h +++ b/external/dfdutils/dfd.h @@ -65,7 +65,7 @@ typedef unsigned int uint32_t; #if !defined(LIBKTX) #include #else -#include "../vkformat_enum.h" +#include "../../lib/vkformat_enum.h" #endif uint32_t* vk2dfd(enum VkFormat format); diff --git a/lib/dfdutils/dfd2vk.c b/external/dfdutils/dfd2vk.c similarity index 100% rename from lib/dfdutils/dfd2vk.c rename to external/dfdutils/dfd2vk.c diff --git a/lib/dfdutils/dfd2vk.inl b/external/dfdutils/dfd2vk.inl similarity index 100% rename from lib/dfdutils/dfd2vk.inl rename to external/dfdutils/dfd2vk.inl diff --git a/lib/dfdutils/dfdutils.doxy b/external/dfdutils/dfdutils.doxy similarity index 100% rename from lib/dfdutils/dfdutils.doxy rename to external/dfdutils/dfdutils.doxy diff --git a/lib/dfdutils/endswap.c b/external/dfdutils/endswap.c similarity index 100% rename from lib/dfdutils/endswap.c rename to external/dfdutils/endswap.c diff --git a/lib/dfdutils/interpretdfd.c b/external/dfdutils/interpretdfd.c similarity index 100% rename from lib/dfdutils/interpretdfd.c rename to external/dfdutils/interpretdfd.c diff --git a/lib/dfdutils/interpretdfdtest.c b/external/dfdutils/interpretdfdtest.c similarity index 100% rename from lib/dfdutils/interpretdfdtest.c rename to external/dfdutils/interpretdfdtest.c diff --git a/lib/dfdutils/makedfd2vk.pl b/external/dfdutils/makedfd2vk.pl similarity index 100% rename from lib/dfdutils/makedfd2vk.pl rename to external/dfdutils/makedfd2vk.pl diff --git a/lib/dfdutils/makevk2dfd.pl b/external/dfdutils/makevk2dfd.pl similarity index 100% rename from lib/dfdutils/makevk2dfd.pl rename to external/dfdutils/makevk2dfd.pl diff --git a/lib/dfdutils/printdfd.c b/external/dfdutils/printdfd.c similarity index 100% rename from lib/dfdutils/printdfd.c rename to external/dfdutils/printdfd.c diff --git a/lib/dfdutils/queries.c b/external/dfdutils/queries.c similarity index 100% rename from lib/dfdutils/queries.c rename to external/dfdutils/queries.c diff --git a/lib/dfdutils/testbidirectionalmapping.c b/external/dfdutils/testbidirectionalmapping.c similarity index 100% rename from lib/dfdutils/testbidirectionalmapping.c rename to external/dfdutils/testbidirectionalmapping.c diff --git a/lib/dfdutils/vk2dfd.c b/external/dfdutils/vk2dfd.c similarity index 100% rename from lib/dfdutils/vk2dfd.c rename to external/dfdutils/vk2dfd.c diff --git a/lib/dfdutils/vk2dfd.inl b/external/dfdutils/vk2dfd.inl similarity index 100% rename from lib/dfdutils/vk2dfd.inl rename to external/dfdutils/vk2dfd.inl diff --git a/lib/dfdutils/vulkan/README.md b/external/dfdutils/vulkan/README.md similarity index 100% rename from lib/dfdutils/vulkan/README.md rename to external/dfdutils/vulkan/README.md diff --git a/lib/dfdutils/vulkan/build_custom_vulkan_core b/external/dfdutils/vulkan/build_custom_vulkan_core similarity index 100% rename from lib/dfdutils/vulkan/build_custom_vulkan_core rename to external/dfdutils/vulkan/build_custom_vulkan_core diff --git a/lib/dfdutils/vulkan/vk_platform.h b/external/dfdutils/vulkan/vk_platform.h similarity index 100% rename from lib/dfdutils/vulkan/vk_platform.h rename to external/dfdutils/vulkan/vk_platform.h diff --git a/lib/dfdutils/vulkan/vulkan_core.h b/external/dfdutils/vulkan/vulkan_core.h similarity index 100% rename from lib/dfdutils/vulkan/vulkan_core.h rename to external/dfdutils/vulkan/vulkan_core.h diff --git a/other_projects/fmt/.github/dependabot.yml b/external/fmt/.github/dependabot.yml similarity index 100% rename from other_projects/fmt/.github/dependabot.yml rename to external/fmt/.github/dependabot.yml diff --git a/other_projects/fmt/.github/issue_template.md b/external/fmt/.github/issue_template.md similarity index 100% rename from other_projects/fmt/.github/issue_template.md rename to external/fmt/.github/issue_template.md diff --git a/other_projects/fmt/.github/pull_request_template.md b/external/fmt/.github/pull_request_template.md similarity index 100% rename from other_projects/fmt/.github/pull_request_template.md rename to external/fmt/.github/pull_request_template.md diff --git a/other_projects/fmt/.github/workflows/cifuzz.yml b/external/fmt/.github/workflows/cifuzz.yml similarity index 100% rename from other_projects/fmt/.github/workflows/cifuzz.yml rename to external/fmt/.github/workflows/cifuzz.yml diff --git a/other_projects/fmt/.github/workflows/doc.yml b/external/fmt/.github/workflows/doc.yml similarity index 100% rename from other_projects/fmt/.github/workflows/doc.yml rename to external/fmt/.github/workflows/doc.yml diff --git a/other_projects/fmt/.github/workflows/linux.yml b/external/fmt/.github/workflows/linux.yml similarity index 100% rename from other_projects/fmt/.github/workflows/linux.yml rename to external/fmt/.github/workflows/linux.yml diff --git a/other_projects/fmt/.github/workflows/macos.yml b/external/fmt/.github/workflows/macos.yml similarity index 100% rename from other_projects/fmt/.github/workflows/macos.yml rename to external/fmt/.github/workflows/macos.yml diff --git a/other_projects/fmt/.github/workflows/scorecard.yml b/external/fmt/.github/workflows/scorecard.yml similarity index 100% rename from other_projects/fmt/.github/workflows/scorecard.yml rename to external/fmt/.github/workflows/scorecard.yml diff --git a/other_projects/fmt/.github/workflows/windows.yml b/external/fmt/.github/workflows/windows.yml similarity index 100% rename from other_projects/fmt/.github/workflows/windows.yml rename to external/fmt/.github/workflows/windows.yml diff --git a/other_projects/fmt/.gitignore b/external/fmt/.gitignore similarity index 100% rename from other_projects/fmt/.gitignore rename to external/fmt/.gitignore diff --git a/other_projects/fmt/.gitrepo b/external/fmt/.gitrepo similarity index 100% rename from other_projects/fmt/.gitrepo rename to external/fmt/.gitrepo diff --git a/other_projects/fmt/CMakeLists.txt b/external/fmt/CMakeLists.txt similarity index 100% rename from other_projects/fmt/CMakeLists.txt rename to external/fmt/CMakeLists.txt diff --git a/other_projects/fmt/CONTRIBUTING.md b/external/fmt/CONTRIBUTING.md similarity index 100% rename from other_projects/fmt/CONTRIBUTING.md rename to external/fmt/CONTRIBUTING.md diff --git a/other_projects/fmt/ChangeLog.md b/external/fmt/ChangeLog.md similarity index 100% rename from other_projects/fmt/ChangeLog.md rename to external/fmt/ChangeLog.md diff --git a/other_projects/fmt/LICENSE b/external/fmt/LICENSE similarity index 100% rename from other_projects/fmt/LICENSE rename to external/fmt/LICENSE diff --git a/other_projects/fmt/README.rst b/external/fmt/README.rst similarity index 100% rename from other_projects/fmt/README.rst rename to external/fmt/README.rst diff --git a/other_projects/fmt/doc/CMakeLists.txt b/external/fmt/doc/CMakeLists.txt similarity index 100% rename from other_projects/fmt/doc/CMakeLists.txt rename to external/fmt/doc/CMakeLists.txt diff --git a/other_projects/fmt/doc/_static/bootstrap.min.js b/external/fmt/doc/_static/bootstrap.min.js similarity index 100% rename from other_projects/fmt/doc/_static/bootstrap.min.js rename to external/fmt/doc/_static/bootstrap.min.js diff --git a/other_projects/fmt/doc/_static/breathe.css b/external/fmt/doc/_static/breathe.css similarity index 100% rename from other_projects/fmt/doc/_static/breathe.css rename to external/fmt/doc/_static/breathe.css diff --git a/other_projects/fmt/doc/_static/fonts/glyphicons-halflings-regular.eot b/external/fmt/doc/_static/fonts/glyphicons-halflings-regular.eot similarity index 100% rename from other_projects/fmt/doc/_static/fonts/glyphicons-halflings-regular.eot rename to external/fmt/doc/_static/fonts/glyphicons-halflings-regular.eot diff --git a/other_projects/fmt/doc/_static/fonts/glyphicons-halflings-regular.svg b/external/fmt/doc/_static/fonts/glyphicons-halflings-regular.svg similarity index 100% rename from other_projects/fmt/doc/_static/fonts/glyphicons-halflings-regular.svg rename to external/fmt/doc/_static/fonts/glyphicons-halflings-regular.svg diff --git a/other_projects/fmt/doc/_static/fonts/glyphicons-halflings-regular.ttf b/external/fmt/doc/_static/fonts/glyphicons-halflings-regular.ttf similarity index 100% rename from other_projects/fmt/doc/_static/fonts/glyphicons-halflings-regular.ttf rename to external/fmt/doc/_static/fonts/glyphicons-halflings-regular.ttf diff --git a/other_projects/fmt/doc/_static/fonts/glyphicons-halflings-regular.woff b/external/fmt/doc/_static/fonts/glyphicons-halflings-regular.woff similarity index 100% rename from other_projects/fmt/doc/_static/fonts/glyphicons-halflings-regular.woff rename to external/fmt/doc/_static/fonts/glyphicons-halflings-regular.woff diff --git a/other_projects/fmt/doc/_templates/layout.html b/external/fmt/doc/_templates/layout.html similarity index 100% rename from other_projects/fmt/doc/_templates/layout.html rename to external/fmt/doc/_templates/layout.html diff --git a/other_projects/fmt/doc/_templates/search.html b/external/fmt/doc/_templates/search.html similarity index 100% rename from other_projects/fmt/doc/_templates/search.html rename to external/fmt/doc/_templates/search.html diff --git a/other_projects/fmt/doc/api.rst b/external/fmt/doc/api.rst similarity index 100% rename from other_projects/fmt/doc/api.rst rename to external/fmt/doc/api.rst diff --git a/other_projects/fmt/doc/basic-bootstrap/README b/external/fmt/doc/basic-bootstrap/README similarity index 100% rename from other_projects/fmt/doc/basic-bootstrap/README rename to external/fmt/doc/basic-bootstrap/README diff --git a/other_projects/fmt/doc/basic-bootstrap/layout.html b/external/fmt/doc/basic-bootstrap/layout.html similarity index 100% rename from other_projects/fmt/doc/basic-bootstrap/layout.html rename to external/fmt/doc/basic-bootstrap/layout.html diff --git a/other_projects/fmt/doc/basic-bootstrap/theme.conf b/external/fmt/doc/basic-bootstrap/theme.conf similarity index 100% rename from other_projects/fmt/doc/basic-bootstrap/theme.conf rename to external/fmt/doc/basic-bootstrap/theme.conf diff --git a/other_projects/fmt/doc/bootstrap/alerts.less b/external/fmt/doc/bootstrap/alerts.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/alerts.less rename to external/fmt/doc/bootstrap/alerts.less diff --git a/other_projects/fmt/doc/bootstrap/badges.less b/external/fmt/doc/bootstrap/badges.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/badges.less rename to external/fmt/doc/bootstrap/badges.less diff --git a/other_projects/fmt/doc/bootstrap/bootstrap.less b/external/fmt/doc/bootstrap/bootstrap.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/bootstrap.less rename to external/fmt/doc/bootstrap/bootstrap.less diff --git a/other_projects/fmt/doc/bootstrap/breadcrumbs.less b/external/fmt/doc/bootstrap/breadcrumbs.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/breadcrumbs.less rename to external/fmt/doc/bootstrap/breadcrumbs.less diff --git a/other_projects/fmt/doc/bootstrap/button-groups.less b/external/fmt/doc/bootstrap/button-groups.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/button-groups.less rename to external/fmt/doc/bootstrap/button-groups.less diff --git a/other_projects/fmt/doc/bootstrap/buttons.less b/external/fmt/doc/bootstrap/buttons.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/buttons.less rename to external/fmt/doc/bootstrap/buttons.less diff --git a/other_projects/fmt/doc/bootstrap/carousel.less b/external/fmt/doc/bootstrap/carousel.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/carousel.less rename to external/fmt/doc/bootstrap/carousel.less diff --git a/other_projects/fmt/doc/bootstrap/close.less b/external/fmt/doc/bootstrap/close.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/close.less rename to external/fmt/doc/bootstrap/close.less diff --git a/other_projects/fmt/doc/bootstrap/code.less b/external/fmt/doc/bootstrap/code.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/code.less rename to external/fmt/doc/bootstrap/code.less diff --git a/other_projects/fmt/doc/bootstrap/component-animations.less b/external/fmt/doc/bootstrap/component-animations.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/component-animations.less rename to external/fmt/doc/bootstrap/component-animations.less diff --git a/other_projects/fmt/doc/bootstrap/dropdowns.less b/external/fmt/doc/bootstrap/dropdowns.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/dropdowns.less rename to external/fmt/doc/bootstrap/dropdowns.less diff --git a/other_projects/fmt/doc/bootstrap/forms.less b/external/fmt/doc/bootstrap/forms.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/forms.less rename to external/fmt/doc/bootstrap/forms.less diff --git a/other_projects/fmt/doc/bootstrap/glyphicons.less b/external/fmt/doc/bootstrap/glyphicons.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/glyphicons.less rename to external/fmt/doc/bootstrap/glyphicons.less diff --git a/other_projects/fmt/doc/bootstrap/grid.less b/external/fmt/doc/bootstrap/grid.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/grid.less rename to external/fmt/doc/bootstrap/grid.less diff --git a/other_projects/fmt/doc/bootstrap/input-groups.less b/external/fmt/doc/bootstrap/input-groups.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/input-groups.less rename to external/fmt/doc/bootstrap/input-groups.less diff --git a/other_projects/fmt/doc/bootstrap/jumbotron.less b/external/fmt/doc/bootstrap/jumbotron.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/jumbotron.less rename to external/fmt/doc/bootstrap/jumbotron.less diff --git a/other_projects/fmt/doc/bootstrap/labels.less b/external/fmt/doc/bootstrap/labels.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/labels.less rename to external/fmt/doc/bootstrap/labels.less diff --git a/other_projects/fmt/doc/bootstrap/list-group.less b/external/fmt/doc/bootstrap/list-group.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/list-group.less rename to external/fmt/doc/bootstrap/list-group.less diff --git a/other_projects/fmt/doc/bootstrap/media.less b/external/fmt/doc/bootstrap/media.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/media.less rename to external/fmt/doc/bootstrap/media.less diff --git a/other_projects/fmt/doc/bootstrap/mixins.less b/external/fmt/doc/bootstrap/mixins.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/mixins.less rename to external/fmt/doc/bootstrap/mixins.less diff --git a/other_projects/fmt/doc/bootstrap/mixins/alerts.less b/external/fmt/doc/bootstrap/mixins/alerts.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/mixins/alerts.less rename to external/fmt/doc/bootstrap/mixins/alerts.less diff --git a/other_projects/fmt/doc/bootstrap/mixins/background-variant.less b/external/fmt/doc/bootstrap/mixins/background-variant.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/mixins/background-variant.less rename to external/fmt/doc/bootstrap/mixins/background-variant.less diff --git a/other_projects/fmt/doc/bootstrap/mixins/border-radius.less b/external/fmt/doc/bootstrap/mixins/border-radius.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/mixins/border-radius.less rename to external/fmt/doc/bootstrap/mixins/border-radius.less diff --git a/other_projects/fmt/doc/bootstrap/mixins/buttons.less b/external/fmt/doc/bootstrap/mixins/buttons.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/mixins/buttons.less rename to external/fmt/doc/bootstrap/mixins/buttons.less diff --git a/other_projects/fmt/doc/bootstrap/mixins/center-block.less b/external/fmt/doc/bootstrap/mixins/center-block.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/mixins/center-block.less rename to external/fmt/doc/bootstrap/mixins/center-block.less diff --git a/other_projects/fmt/doc/bootstrap/mixins/clearfix.less b/external/fmt/doc/bootstrap/mixins/clearfix.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/mixins/clearfix.less rename to external/fmt/doc/bootstrap/mixins/clearfix.less diff --git a/other_projects/fmt/doc/bootstrap/mixins/forms.less b/external/fmt/doc/bootstrap/mixins/forms.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/mixins/forms.less rename to external/fmt/doc/bootstrap/mixins/forms.less diff --git a/other_projects/fmt/doc/bootstrap/mixins/gradients.less b/external/fmt/doc/bootstrap/mixins/gradients.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/mixins/gradients.less rename to external/fmt/doc/bootstrap/mixins/gradients.less diff --git a/other_projects/fmt/doc/bootstrap/mixins/grid-framework.less b/external/fmt/doc/bootstrap/mixins/grid-framework.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/mixins/grid-framework.less rename to external/fmt/doc/bootstrap/mixins/grid-framework.less diff --git a/other_projects/fmt/doc/bootstrap/mixins/grid.less b/external/fmt/doc/bootstrap/mixins/grid.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/mixins/grid.less rename to external/fmt/doc/bootstrap/mixins/grid.less diff --git a/other_projects/fmt/doc/bootstrap/mixins/hide-text.less b/external/fmt/doc/bootstrap/mixins/hide-text.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/mixins/hide-text.less rename to external/fmt/doc/bootstrap/mixins/hide-text.less diff --git a/other_projects/fmt/doc/bootstrap/mixins/image.less b/external/fmt/doc/bootstrap/mixins/image.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/mixins/image.less rename to external/fmt/doc/bootstrap/mixins/image.less diff --git a/other_projects/fmt/doc/bootstrap/mixins/labels.less b/external/fmt/doc/bootstrap/mixins/labels.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/mixins/labels.less rename to external/fmt/doc/bootstrap/mixins/labels.less diff --git a/other_projects/fmt/doc/bootstrap/mixins/list-group.less b/external/fmt/doc/bootstrap/mixins/list-group.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/mixins/list-group.less rename to external/fmt/doc/bootstrap/mixins/list-group.less diff --git a/other_projects/fmt/doc/bootstrap/mixins/nav-divider.less b/external/fmt/doc/bootstrap/mixins/nav-divider.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/mixins/nav-divider.less rename to external/fmt/doc/bootstrap/mixins/nav-divider.less diff --git a/other_projects/fmt/doc/bootstrap/mixins/nav-vertical-align.less b/external/fmt/doc/bootstrap/mixins/nav-vertical-align.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/mixins/nav-vertical-align.less rename to external/fmt/doc/bootstrap/mixins/nav-vertical-align.less diff --git a/other_projects/fmt/doc/bootstrap/mixins/opacity.less b/external/fmt/doc/bootstrap/mixins/opacity.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/mixins/opacity.less rename to external/fmt/doc/bootstrap/mixins/opacity.less diff --git a/other_projects/fmt/doc/bootstrap/mixins/pagination.less b/external/fmt/doc/bootstrap/mixins/pagination.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/mixins/pagination.less rename to external/fmt/doc/bootstrap/mixins/pagination.less diff --git a/other_projects/fmt/doc/bootstrap/mixins/panels.less b/external/fmt/doc/bootstrap/mixins/panels.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/mixins/panels.less rename to external/fmt/doc/bootstrap/mixins/panels.less diff --git a/other_projects/fmt/doc/bootstrap/mixins/progress-bar.less b/external/fmt/doc/bootstrap/mixins/progress-bar.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/mixins/progress-bar.less rename to external/fmt/doc/bootstrap/mixins/progress-bar.less diff --git a/other_projects/fmt/doc/bootstrap/mixins/reset-filter.less b/external/fmt/doc/bootstrap/mixins/reset-filter.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/mixins/reset-filter.less rename to external/fmt/doc/bootstrap/mixins/reset-filter.less diff --git a/other_projects/fmt/doc/bootstrap/mixins/resize.less b/external/fmt/doc/bootstrap/mixins/resize.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/mixins/resize.less rename to external/fmt/doc/bootstrap/mixins/resize.less diff --git a/other_projects/fmt/doc/bootstrap/mixins/responsive-visibility.less b/external/fmt/doc/bootstrap/mixins/responsive-visibility.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/mixins/responsive-visibility.less rename to external/fmt/doc/bootstrap/mixins/responsive-visibility.less diff --git a/other_projects/fmt/doc/bootstrap/mixins/size.less b/external/fmt/doc/bootstrap/mixins/size.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/mixins/size.less rename to external/fmt/doc/bootstrap/mixins/size.less diff --git a/other_projects/fmt/doc/bootstrap/mixins/tab-focus.less b/external/fmt/doc/bootstrap/mixins/tab-focus.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/mixins/tab-focus.less rename to external/fmt/doc/bootstrap/mixins/tab-focus.less diff --git a/other_projects/fmt/doc/bootstrap/mixins/table-row.less b/external/fmt/doc/bootstrap/mixins/table-row.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/mixins/table-row.less rename to external/fmt/doc/bootstrap/mixins/table-row.less diff --git a/other_projects/fmt/doc/bootstrap/mixins/text-emphasis.less b/external/fmt/doc/bootstrap/mixins/text-emphasis.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/mixins/text-emphasis.less rename to external/fmt/doc/bootstrap/mixins/text-emphasis.less diff --git a/other_projects/fmt/doc/bootstrap/mixins/text-overflow.less b/external/fmt/doc/bootstrap/mixins/text-overflow.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/mixins/text-overflow.less rename to external/fmt/doc/bootstrap/mixins/text-overflow.less diff --git a/other_projects/fmt/doc/bootstrap/mixins/vendor-prefixes.less b/external/fmt/doc/bootstrap/mixins/vendor-prefixes.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/mixins/vendor-prefixes.less rename to external/fmt/doc/bootstrap/mixins/vendor-prefixes.less diff --git a/other_projects/fmt/doc/bootstrap/modals.less b/external/fmt/doc/bootstrap/modals.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/modals.less rename to external/fmt/doc/bootstrap/modals.less diff --git a/other_projects/fmt/doc/bootstrap/navbar.less b/external/fmt/doc/bootstrap/navbar.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/navbar.less rename to external/fmt/doc/bootstrap/navbar.less diff --git a/other_projects/fmt/doc/bootstrap/navs.less b/external/fmt/doc/bootstrap/navs.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/navs.less rename to external/fmt/doc/bootstrap/navs.less diff --git a/other_projects/fmt/doc/bootstrap/normalize.less b/external/fmt/doc/bootstrap/normalize.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/normalize.less rename to external/fmt/doc/bootstrap/normalize.less diff --git a/other_projects/fmt/doc/bootstrap/pager.less b/external/fmt/doc/bootstrap/pager.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/pager.less rename to external/fmt/doc/bootstrap/pager.less diff --git a/other_projects/fmt/doc/bootstrap/pagination.less b/external/fmt/doc/bootstrap/pagination.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/pagination.less rename to external/fmt/doc/bootstrap/pagination.less diff --git a/other_projects/fmt/doc/bootstrap/panels.less b/external/fmt/doc/bootstrap/panels.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/panels.less rename to external/fmt/doc/bootstrap/panels.less diff --git a/other_projects/fmt/doc/bootstrap/popovers.less b/external/fmt/doc/bootstrap/popovers.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/popovers.less rename to external/fmt/doc/bootstrap/popovers.less diff --git a/other_projects/fmt/doc/bootstrap/print.less b/external/fmt/doc/bootstrap/print.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/print.less rename to external/fmt/doc/bootstrap/print.less diff --git a/other_projects/fmt/doc/bootstrap/progress-bars.less b/external/fmt/doc/bootstrap/progress-bars.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/progress-bars.less rename to external/fmt/doc/bootstrap/progress-bars.less diff --git a/other_projects/fmt/doc/bootstrap/responsive-embed.less b/external/fmt/doc/bootstrap/responsive-embed.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/responsive-embed.less rename to external/fmt/doc/bootstrap/responsive-embed.less diff --git a/other_projects/fmt/doc/bootstrap/responsive-utilities.less b/external/fmt/doc/bootstrap/responsive-utilities.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/responsive-utilities.less rename to external/fmt/doc/bootstrap/responsive-utilities.less diff --git a/other_projects/fmt/doc/bootstrap/scaffolding.less b/external/fmt/doc/bootstrap/scaffolding.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/scaffolding.less rename to external/fmt/doc/bootstrap/scaffolding.less diff --git a/other_projects/fmt/doc/bootstrap/tables.less b/external/fmt/doc/bootstrap/tables.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/tables.less rename to external/fmt/doc/bootstrap/tables.less diff --git a/other_projects/fmt/doc/bootstrap/theme.less b/external/fmt/doc/bootstrap/theme.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/theme.less rename to external/fmt/doc/bootstrap/theme.less diff --git a/other_projects/fmt/doc/bootstrap/thumbnails.less b/external/fmt/doc/bootstrap/thumbnails.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/thumbnails.less rename to external/fmt/doc/bootstrap/thumbnails.less diff --git a/other_projects/fmt/doc/bootstrap/tooltip.less b/external/fmt/doc/bootstrap/tooltip.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/tooltip.less rename to external/fmt/doc/bootstrap/tooltip.less diff --git a/other_projects/fmt/doc/bootstrap/type.less b/external/fmt/doc/bootstrap/type.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/type.less rename to external/fmt/doc/bootstrap/type.less diff --git a/other_projects/fmt/doc/bootstrap/utilities.less b/external/fmt/doc/bootstrap/utilities.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/utilities.less rename to external/fmt/doc/bootstrap/utilities.less diff --git a/other_projects/fmt/doc/bootstrap/variables.less b/external/fmt/doc/bootstrap/variables.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/variables.less rename to external/fmt/doc/bootstrap/variables.less diff --git a/other_projects/fmt/doc/bootstrap/wells.less b/external/fmt/doc/bootstrap/wells.less similarity index 100% rename from other_projects/fmt/doc/bootstrap/wells.less rename to external/fmt/doc/bootstrap/wells.less diff --git a/other_projects/fmt/doc/build.py b/external/fmt/doc/build.py similarity index 100% rename from other_projects/fmt/doc/build.py rename to external/fmt/doc/build.py diff --git a/other_projects/fmt/doc/conf.py b/external/fmt/doc/conf.py similarity index 100% rename from other_projects/fmt/doc/conf.py rename to external/fmt/doc/conf.py diff --git a/other_projects/fmt/doc/contents.rst b/external/fmt/doc/contents.rst similarity index 100% rename from other_projects/fmt/doc/contents.rst rename to external/fmt/doc/contents.rst diff --git a/other_projects/fmt/doc/fmt.less b/external/fmt/doc/fmt.less similarity index 100% rename from other_projects/fmt/doc/fmt.less rename to external/fmt/doc/fmt.less diff --git a/other_projects/fmt/doc/index.rst b/external/fmt/doc/index.rst similarity index 100% rename from other_projects/fmt/doc/index.rst rename to external/fmt/doc/index.rst diff --git a/other_projects/fmt/doc/python-license.txt b/external/fmt/doc/python-license.txt similarity index 100% rename from other_projects/fmt/doc/python-license.txt rename to external/fmt/doc/python-license.txt diff --git a/other_projects/fmt/doc/syntax.rst b/external/fmt/doc/syntax.rst similarity index 100% rename from other_projects/fmt/doc/syntax.rst rename to external/fmt/doc/syntax.rst diff --git a/other_projects/fmt/doc/usage.rst b/external/fmt/doc/usage.rst similarity index 100% rename from other_projects/fmt/doc/usage.rst rename to external/fmt/doc/usage.rst diff --git a/other_projects/fmt/include/fmt/args.h b/external/fmt/include/fmt/args.h similarity index 100% rename from other_projects/fmt/include/fmt/args.h rename to external/fmt/include/fmt/args.h diff --git a/other_projects/fmt/include/fmt/chrono.h b/external/fmt/include/fmt/chrono.h similarity index 100% rename from other_projects/fmt/include/fmt/chrono.h rename to external/fmt/include/fmt/chrono.h diff --git a/other_projects/fmt/include/fmt/color.h b/external/fmt/include/fmt/color.h similarity index 100% rename from other_projects/fmt/include/fmt/color.h rename to external/fmt/include/fmt/color.h diff --git a/other_projects/fmt/include/fmt/compile.h b/external/fmt/include/fmt/compile.h similarity index 100% rename from other_projects/fmt/include/fmt/compile.h rename to external/fmt/include/fmt/compile.h diff --git a/other_projects/fmt/include/fmt/core.h b/external/fmt/include/fmt/core.h similarity index 100% rename from other_projects/fmt/include/fmt/core.h rename to external/fmt/include/fmt/core.h diff --git a/other_projects/fmt/include/fmt/format-inl.h b/external/fmt/include/fmt/format-inl.h similarity index 100% rename from other_projects/fmt/include/fmt/format-inl.h rename to external/fmt/include/fmt/format-inl.h diff --git a/other_projects/fmt/include/fmt/format.h b/external/fmt/include/fmt/format.h similarity index 100% rename from other_projects/fmt/include/fmt/format.h rename to external/fmt/include/fmt/format.h diff --git a/other_projects/fmt/include/fmt/os.h b/external/fmt/include/fmt/os.h similarity index 100% rename from other_projects/fmt/include/fmt/os.h rename to external/fmt/include/fmt/os.h diff --git a/other_projects/fmt/include/fmt/ostream.h b/external/fmt/include/fmt/ostream.h similarity index 100% rename from other_projects/fmt/include/fmt/ostream.h rename to external/fmt/include/fmt/ostream.h diff --git a/other_projects/fmt/include/fmt/printf.h b/external/fmt/include/fmt/printf.h similarity index 100% rename from other_projects/fmt/include/fmt/printf.h rename to external/fmt/include/fmt/printf.h diff --git a/other_projects/fmt/include/fmt/ranges.h b/external/fmt/include/fmt/ranges.h similarity index 100% rename from other_projects/fmt/include/fmt/ranges.h rename to external/fmt/include/fmt/ranges.h diff --git a/other_projects/fmt/include/fmt/std.h b/external/fmt/include/fmt/std.h similarity index 100% rename from other_projects/fmt/include/fmt/std.h rename to external/fmt/include/fmt/std.h diff --git a/other_projects/fmt/include/fmt/xchar.h b/external/fmt/include/fmt/xchar.h similarity index 100% rename from other_projects/fmt/include/fmt/xchar.h rename to external/fmt/include/fmt/xchar.h diff --git a/other_projects/fmt/src/fmt.cc b/external/fmt/src/fmt.cc similarity index 100% rename from other_projects/fmt/src/fmt.cc rename to external/fmt/src/fmt.cc diff --git a/other_projects/fmt/src/format.cc b/external/fmt/src/format.cc similarity index 100% rename from other_projects/fmt/src/format.cc rename to external/fmt/src/format.cc diff --git a/other_projects/fmt/src/os.cc b/external/fmt/src/os.cc similarity index 100% rename from other_projects/fmt/src/os.cc rename to external/fmt/src/os.cc diff --git a/other_projects/fmt/support/Android.mk b/external/fmt/support/Android.mk similarity index 100% rename from other_projects/fmt/support/Android.mk rename to external/fmt/support/Android.mk diff --git a/other_projects/fmt/support/AndroidManifest.xml b/external/fmt/support/AndroidManifest.xml similarity index 100% rename from other_projects/fmt/support/AndroidManifest.xml rename to external/fmt/support/AndroidManifest.xml diff --git a/other_projects/fmt/support/C++.sublime-syntax b/external/fmt/support/C++.sublime-syntax similarity index 100% rename from other_projects/fmt/support/C++.sublime-syntax rename to external/fmt/support/C++.sublime-syntax diff --git a/other_projects/fmt/support/README b/external/fmt/support/README similarity index 100% rename from other_projects/fmt/support/README rename to external/fmt/support/README diff --git a/other_projects/fmt/support/Vagrantfile b/external/fmt/support/Vagrantfile similarity index 100% rename from other_projects/fmt/support/Vagrantfile rename to external/fmt/support/Vagrantfile diff --git a/other_projects/fmt/support/bazel/.bazelversion b/external/fmt/support/bazel/.bazelversion similarity index 100% rename from other_projects/fmt/support/bazel/.bazelversion rename to external/fmt/support/bazel/.bazelversion diff --git a/other_projects/fmt/support/bazel/BUILD.bazel b/external/fmt/support/bazel/BUILD.bazel similarity index 100% rename from other_projects/fmt/support/bazel/BUILD.bazel rename to external/fmt/support/bazel/BUILD.bazel diff --git a/other_projects/fmt/support/bazel/README.md b/external/fmt/support/bazel/README.md similarity index 100% rename from other_projects/fmt/support/bazel/README.md rename to external/fmt/support/bazel/README.md diff --git a/other_projects/fmt/support/bazel/WORKSPACE.bazel b/external/fmt/support/bazel/WORKSPACE.bazel similarity index 100% rename from other_projects/fmt/support/bazel/WORKSPACE.bazel rename to external/fmt/support/bazel/WORKSPACE.bazel diff --git a/other_projects/fmt/support/build-docs.py b/external/fmt/support/build-docs.py similarity index 100% rename from other_projects/fmt/support/build-docs.py rename to external/fmt/support/build-docs.py diff --git a/other_projects/fmt/support/build.gradle b/external/fmt/support/build.gradle similarity index 100% rename from other_projects/fmt/support/build.gradle rename to external/fmt/support/build.gradle diff --git a/other_projects/fmt/support/cmake/FindSetEnv.cmake b/external/fmt/support/cmake/FindSetEnv.cmake similarity index 100% rename from other_projects/fmt/support/cmake/FindSetEnv.cmake rename to external/fmt/support/cmake/FindSetEnv.cmake diff --git a/other_projects/fmt/support/cmake/JoinPaths.cmake b/external/fmt/support/cmake/JoinPaths.cmake similarity index 100% rename from other_projects/fmt/support/cmake/JoinPaths.cmake rename to external/fmt/support/cmake/JoinPaths.cmake diff --git a/other_projects/fmt/support/cmake/fmt-config.cmake.in b/external/fmt/support/cmake/fmt-config.cmake.in similarity index 100% rename from other_projects/fmt/support/cmake/fmt-config.cmake.in rename to external/fmt/support/cmake/fmt-config.cmake.in diff --git a/other_projects/fmt/support/cmake/fmt.pc.in b/external/fmt/support/cmake/fmt.pc.in similarity index 100% rename from other_projects/fmt/support/cmake/fmt.pc.in rename to external/fmt/support/cmake/fmt.pc.in diff --git a/other_projects/fmt/support/compute-powers.py b/external/fmt/support/compute-powers.py similarity index 100% rename from other_projects/fmt/support/compute-powers.py rename to external/fmt/support/compute-powers.py diff --git a/other_projects/fmt/support/docopt.py b/external/fmt/support/docopt.py similarity index 100% rename from other_projects/fmt/support/docopt.py rename to external/fmt/support/docopt.py diff --git a/other_projects/fmt/support/manage.py b/external/fmt/support/manage.py similarity index 100% rename from other_projects/fmt/support/manage.py rename to external/fmt/support/manage.py diff --git a/other_projects/fmt/support/printable.py b/external/fmt/support/printable.py similarity index 100% rename from other_projects/fmt/support/printable.py rename to external/fmt/support/printable.py diff --git a/other_projects/fmt/support/rtd/conf.py b/external/fmt/support/rtd/conf.py similarity index 100% rename from other_projects/fmt/support/rtd/conf.py rename to external/fmt/support/rtd/conf.py diff --git a/other_projects/fmt/support/rtd/index.rst b/external/fmt/support/rtd/index.rst similarity index 100% rename from other_projects/fmt/support/rtd/index.rst rename to external/fmt/support/rtd/index.rst diff --git a/other_projects/fmt/support/rtd/theme/layout.html b/external/fmt/support/rtd/theme/layout.html similarity index 100% rename from other_projects/fmt/support/rtd/theme/layout.html rename to external/fmt/support/rtd/theme/layout.html diff --git a/other_projects/fmt/support/rtd/theme/theme.conf b/external/fmt/support/rtd/theme/theme.conf similarity index 100% rename from other_projects/fmt/support/rtd/theme/theme.conf rename to external/fmt/support/rtd/theme/theme.conf diff --git a/other_projects/fmt/test/CMakeLists.txt b/external/fmt/test/CMakeLists.txt similarity index 100% rename from other_projects/fmt/test/CMakeLists.txt rename to external/fmt/test/CMakeLists.txt diff --git a/other_projects/fmt/test/add-subdirectory-test/CMakeLists.txt b/external/fmt/test/add-subdirectory-test/CMakeLists.txt similarity index 100% rename from other_projects/fmt/test/add-subdirectory-test/CMakeLists.txt rename to external/fmt/test/add-subdirectory-test/CMakeLists.txt diff --git a/other_projects/fmt/test/add-subdirectory-test/main.cc b/external/fmt/test/add-subdirectory-test/main.cc similarity index 100% rename from other_projects/fmt/test/add-subdirectory-test/main.cc rename to external/fmt/test/add-subdirectory-test/main.cc diff --git a/other_projects/fmt/test/args-test.cc b/external/fmt/test/args-test.cc similarity index 100% rename from other_projects/fmt/test/args-test.cc rename to external/fmt/test/args-test.cc diff --git a/other_projects/fmt/test/assert-test.cc b/external/fmt/test/assert-test.cc similarity index 100% rename from other_projects/fmt/test/assert-test.cc rename to external/fmt/test/assert-test.cc diff --git a/other_projects/fmt/test/chrono-test.cc b/external/fmt/test/chrono-test.cc similarity index 100% rename from other_projects/fmt/test/chrono-test.cc rename to external/fmt/test/chrono-test.cc diff --git a/other_projects/fmt/test/color-test.cc b/external/fmt/test/color-test.cc similarity index 100% rename from other_projects/fmt/test/color-test.cc rename to external/fmt/test/color-test.cc diff --git a/other_projects/fmt/test/compile-error-test/CMakeLists.txt b/external/fmt/test/compile-error-test/CMakeLists.txt similarity index 100% rename from other_projects/fmt/test/compile-error-test/CMakeLists.txt rename to external/fmt/test/compile-error-test/CMakeLists.txt diff --git a/other_projects/fmt/test/compile-fp-test.cc b/external/fmt/test/compile-fp-test.cc similarity index 100% rename from other_projects/fmt/test/compile-fp-test.cc rename to external/fmt/test/compile-fp-test.cc diff --git a/other_projects/fmt/test/compile-test.cc b/external/fmt/test/compile-test.cc similarity index 100% rename from other_projects/fmt/test/compile-test.cc rename to external/fmt/test/compile-test.cc diff --git a/other_projects/fmt/test/core-test.cc b/external/fmt/test/core-test.cc similarity index 100% rename from other_projects/fmt/test/core-test.cc rename to external/fmt/test/core-test.cc diff --git a/other_projects/fmt/test/cuda-test/CMakeLists.txt b/external/fmt/test/cuda-test/CMakeLists.txt similarity index 100% rename from other_projects/fmt/test/cuda-test/CMakeLists.txt rename to external/fmt/test/cuda-test/CMakeLists.txt diff --git a/other_projects/fmt/test/cuda-test/cpp14.cc b/external/fmt/test/cuda-test/cpp14.cc similarity index 100% rename from other_projects/fmt/test/cuda-test/cpp14.cc rename to external/fmt/test/cuda-test/cpp14.cc diff --git a/other_projects/fmt/test/cuda-test/cuda-cpp14.cu b/external/fmt/test/cuda-test/cuda-cpp14.cu similarity index 100% rename from other_projects/fmt/test/cuda-test/cuda-cpp14.cu rename to external/fmt/test/cuda-test/cuda-cpp14.cu diff --git a/other_projects/fmt/test/detect-stdfs.cc b/external/fmt/test/detect-stdfs.cc similarity index 100% rename from other_projects/fmt/test/detect-stdfs.cc rename to external/fmt/test/detect-stdfs.cc diff --git a/other_projects/fmt/test/enforce-checks-test.cc b/external/fmt/test/enforce-checks-test.cc similarity index 100% rename from other_projects/fmt/test/enforce-checks-test.cc rename to external/fmt/test/enforce-checks-test.cc diff --git a/other_projects/fmt/test/find-package-test/CMakeLists.txt b/external/fmt/test/find-package-test/CMakeLists.txt similarity index 100% rename from other_projects/fmt/test/find-package-test/CMakeLists.txt rename to external/fmt/test/find-package-test/CMakeLists.txt diff --git a/other_projects/fmt/test/find-package-test/main.cc b/external/fmt/test/find-package-test/main.cc similarity index 100% rename from other_projects/fmt/test/find-package-test/main.cc rename to external/fmt/test/find-package-test/main.cc diff --git a/other_projects/fmt/test/format-impl-test.cc b/external/fmt/test/format-impl-test.cc similarity index 100% rename from other_projects/fmt/test/format-impl-test.cc rename to external/fmt/test/format-impl-test.cc diff --git a/other_projects/fmt/test/format-test.cc b/external/fmt/test/format-test.cc similarity index 100% rename from other_projects/fmt/test/format-test.cc rename to external/fmt/test/format-test.cc diff --git a/other_projects/fmt/test/fuzzing/.gitignore b/external/fmt/test/fuzzing/.gitignore similarity index 100% rename from other_projects/fmt/test/fuzzing/.gitignore rename to external/fmt/test/fuzzing/.gitignore diff --git a/other_projects/fmt/test/fuzzing/CMakeLists.txt b/external/fmt/test/fuzzing/CMakeLists.txt similarity index 100% rename from other_projects/fmt/test/fuzzing/CMakeLists.txt rename to external/fmt/test/fuzzing/CMakeLists.txt diff --git a/other_projects/fmt/test/fuzzing/README.md b/external/fmt/test/fuzzing/README.md similarity index 100% rename from other_projects/fmt/test/fuzzing/README.md rename to external/fmt/test/fuzzing/README.md diff --git a/other_projects/fmt/test/fuzzing/build.sh b/external/fmt/test/fuzzing/build.sh similarity index 100% rename from other_projects/fmt/test/fuzzing/build.sh rename to external/fmt/test/fuzzing/build.sh diff --git a/other_projects/fmt/test/fuzzing/chrono-duration.cc b/external/fmt/test/fuzzing/chrono-duration.cc similarity index 100% rename from other_projects/fmt/test/fuzzing/chrono-duration.cc rename to external/fmt/test/fuzzing/chrono-duration.cc diff --git a/other_projects/fmt/test/fuzzing/chrono-timepoint.cc b/external/fmt/test/fuzzing/chrono-timepoint.cc similarity index 100% rename from other_projects/fmt/test/fuzzing/chrono-timepoint.cc rename to external/fmt/test/fuzzing/chrono-timepoint.cc diff --git a/other_projects/fmt/test/fuzzing/float.cc b/external/fmt/test/fuzzing/float.cc similarity index 100% rename from other_projects/fmt/test/fuzzing/float.cc rename to external/fmt/test/fuzzing/float.cc diff --git a/other_projects/fmt/test/fuzzing/fuzzer-common.h b/external/fmt/test/fuzzing/fuzzer-common.h similarity index 100% rename from other_projects/fmt/test/fuzzing/fuzzer-common.h rename to external/fmt/test/fuzzing/fuzzer-common.h diff --git a/other_projects/fmt/test/fuzzing/main.cc b/external/fmt/test/fuzzing/main.cc similarity index 100% rename from other_projects/fmt/test/fuzzing/main.cc rename to external/fmt/test/fuzzing/main.cc diff --git a/other_projects/fmt/test/fuzzing/named-arg.cc b/external/fmt/test/fuzzing/named-arg.cc similarity index 100% rename from other_projects/fmt/test/fuzzing/named-arg.cc rename to external/fmt/test/fuzzing/named-arg.cc diff --git a/other_projects/fmt/test/fuzzing/one-arg.cc b/external/fmt/test/fuzzing/one-arg.cc similarity index 100% rename from other_projects/fmt/test/fuzzing/one-arg.cc rename to external/fmt/test/fuzzing/one-arg.cc diff --git a/other_projects/fmt/test/fuzzing/two-args.cc b/external/fmt/test/fuzzing/two-args.cc similarity index 100% rename from other_projects/fmt/test/fuzzing/two-args.cc rename to external/fmt/test/fuzzing/two-args.cc diff --git a/other_projects/fmt/test/gtest-extra-test.cc b/external/fmt/test/gtest-extra-test.cc similarity index 100% rename from other_projects/fmt/test/gtest-extra-test.cc rename to external/fmt/test/gtest-extra-test.cc diff --git a/other_projects/fmt/test/gtest-extra.cc b/external/fmt/test/gtest-extra.cc similarity index 100% rename from other_projects/fmt/test/gtest-extra.cc rename to external/fmt/test/gtest-extra.cc diff --git a/other_projects/fmt/test/gtest-extra.h b/external/fmt/test/gtest-extra.h similarity index 100% rename from other_projects/fmt/test/gtest-extra.h rename to external/fmt/test/gtest-extra.h diff --git a/other_projects/fmt/test/gtest/.clang-format b/external/fmt/test/gtest/.clang-format similarity index 100% rename from other_projects/fmt/test/gtest/.clang-format rename to external/fmt/test/gtest/.clang-format diff --git a/other_projects/fmt/test/gtest/CMakeLists.txt b/external/fmt/test/gtest/CMakeLists.txt similarity index 100% rename from other_projects/fmt/test/gtest/CMakeLists.txt rename to external/fmt/test/gtest/CMakeLists.txt diff --git a/other_projects/fmt/test/gtest/gmock-gtest-all.cc b/external/fmt/test/gtest/gmock-gtest-all.cc similarity index 100% rename from other_projects/fmt/test/gtest/gmock-gtest-all.cc rename to external/fmt/test/gtest/gmock-gtest-all.cc diff --git a/other_projects/fmt/test/gtest/gmock/gmock.h b/external/fmt/test/gtest/gmock/gmock.h similarity index 100% rename from other_projects/fmt/test/gtest/gmock/gmock.h rename to external/fmt/test/gtest/gmock/gmock.h diff --git a/other_projects/fmt/test/gtest/gtest/gtest-spi.h b/external/fmt/test/gtest/gtest/gtest-spi.h similarity index 100% rename from other_projects/fmt/test/gtest/gtest/gtest-spi.h rename to external/fmt/test/gtest/gtest/gtest-spi.h diff --git a/other_projects/fmt/test/gtest/gtest/gtest.h b/external/fmt/test/gtest/gtest/gtest.h similarity index 100% rename from other_projects/fmt/test/gtest/gtest/gtest.h rename to external/fmt/test/gtest/gtest/gtest.h diff --git a/other_projects/fmt/test/header-only-test.cc b/external/fmt/test/header-only-test.cc similarity index 100% rename from other_projects/fmt/test/header-only-test.cc rename to external/fmt/test/header-only-test.cc diff --git a/other_projects/fmt/test/mock-allocator.h b/external/fmt/test/mock-allocator.h similarity index 100% rename from other_projects/fmt/test/mock-allocator.h rename to external/fmt/test/mock-allocator.h diff --git a/other_projects/fmt/test/module-test.cc b/external/fmt/test/module-test.cc similarity index 100% rename from other_projects/fmt/test/module-test.cc rename to external/fmt/test/module-test.cc diff --git a/other_projects/fmt/test/noexception-test.cc b/external/fmt/test/noexception-test.cc similarity index 100% rename from other_projects/fmt/test/noexception-test.cc rename to external/fmt/test/noexception-test.cc diff --git a/other_projects/fmt/test/os-test.cc b/external/fmt/test/os-test.cc similarity index 100% rename from other_projects/fmt/test/os-test.cc rename to external/fmt/test/os-test.cc diff --git a/other_projects/fmt/test/ostream-test.cc b/external/fmt/test/ostream-test.cc similarity index 100% rename from other_projects/fmt/test/ostream-test.cc rename to external/fmt/test/ostream-test.cc diff --git a/other_projects/fmt/test/posix-mock-test.cc b/external/fmt/test/posix-mock-test.cc similarity index 100% rename from other_projects/fmt/test/posix-mock-test.cc rename to external/fmt/test/posix-mock-test.cc diff --git a/other_projects/fmt/test/posix-mock.h b/external/fmt/test/posix-mock.h similarity index 100% rename from other_projects/fmt/test/posix-mock.h rename to external/fmt/test/posix-mock.h diff --git a/other_projects/fmt/test/printf-test.cc b/external/fmt/test/printf-test.cc similarity index 100% rename from other_projects/fmt/test/printf-test.cc rename to external/fmt/test/printf-test.cc diff --git a/other_projects/fmt/test/ranges-odr-test.cc b/external/fmt/test/ranges-odr-test.cc similarity index 100% rename from other_projects/fmt/test/ranges-odr-test.cc rename to external/fmt/test/ranges-odr-test.cc diff --git a/other_projects/fmt/test/ranges-test.cc b/external/fmt/test/ranges-test.cc similarity index 100% rename from other_projects/fmt/test/ranges-test.cc rename to external/fmt/test/ranges-test.cc diff --git a/other_projects/fmt/test/scan-test.cc b/external/fmt/test/scan-test.cc similarity index 100% rename from other_projects/fmt/test/scan-test.cc rename to external/fmt/test/scan-test.cc diff --git a/other_projects/fmt/test/scan.h b/external/fmt/test/scan.h similarity index 100% rename from other_projects/fmt/test/scan.h rename to external/fmt/test/scan.h diff --git a/other_projects/fmt/test/static-export-test/CMakeLists.txt b/external/fmt/test/static-export-test/CMakeLists.txt similarity index 100% rename from other_projects/fmt/test/static-export-test/CMakeLists.txt rename to external/fmt/test/static-export-test/CMakeLists.txt diff --git a/other_projects/fmt/test/static-export-test/library.cc b/external/fmt/test/static-export-test/library.cc similarity index 100% rename from other_projects/fmt/test/static-export-test/library.cc rename to external/fmt/test/static-export-test/library.cc diff --git a/other_projects/fmt/test/static-export-test/main.cc b/external/fmt/test/static-export-test/main.cc similarity index 100% rename from other_projects/fmt/test/static-export-test/main.cc rename to external/fmt/test/static-export-test/main.cc diff --git a/other_projects/fmt/test/std-test.cc b/external/fmt/test/std-test.cc similarity index 100% rename from other_projects/fmt/test/std-test.cc rename to external/fmt/test/std-test.cc diff --git a/other_projects/fmt/test/test-assert.h b/external/fmt/test/test-assert.h similarity index 100% rename from other_projects/fmt/test/test-assert.h rename to external/fmt/test/test-assert.h diff --git a/other_projects/fmt/test/test-main.cc b/external/fmt/test/test-main.cc similarity index 100% rename from other_projects/fmt/test/test-main.cc rename to external/fmt/test/test-main.cc diff --git a/other_projects/fmt/test/unicode-test.cc b/external/fmt/test/unicode-test.cc similarity index 100% rename from other_projects/fmt/test/unicode-test.cc rename to external/fmt/test/unicode-test.cc diff --git a/other_projects/fmt/test/util.cc b/external/fmt/test/util.cc similarity index 100% rename from other_projects/fmt/test/util.cc rename to external/fmt/test/util.cc diff --git a/other_projects/fmt/test/util.h b/external/fmt/test/util.h similarity index 100% rename from other_projects/fmt/test/util.h rename to external/fmt/test/util.h diff --git a/other_projects/fmt/test/xchar-test.cc b/external/fmt/test/xchar-test.cc similarity index 100% rename from other_projects/fmt/test/xchar-test.cc rename to external/fmt/test/xchar-test.cc diff --git a/include/.clang-format b/include/.clang-format new file mode 100644 index 0000000000..ddf42b4634 --- /dev/null +++ b/include/.clang-format @@ -0,0 +1,7 @@ +# Copyright 2024 The Khronos Group Inc. +# SPDX-License-Identifier: Apache-2.0 +--- +# Disable clang-format in this directory +DisableFormat: true +SortIncludes: false +--- diff --git a/lib/.clang-format b/lib/.clang-format new file mode 100644 index 0000000000..e0c089c680 --- /dev/null +++ b/lib/.clang-format @@ -0,0 +1,13 @@ +# Copyright 2024 The Khronos Group Inc. +# SPDX-License-Identifier: Apache-2.0 +--- +# Use defaults from the Google style with the following exceptions: +Language: Cpp +BasedOnStyle: Google +IndentWidth: 4 +IndentCaseLabels: false +AccessModifierOffset: -2 +ColumnLimit: 132 +SortIncludes: false +AlwaysBreakAfterDefinitionReturnType: TopLevel +... diff --git a/lib/astc_encode.cpp b/lib/astc_encode.cpp index 3cece4b293..1133347939 100644 --- a/lib/astc_encode.cpp +++ b/lib/astc_encode.cpp @@ -46,8 +46,7 @@ typedef int pthread_attr_t; /* Public function, see header file for detailed documentation */ static int -pthread_create(pthread_t* thread, const pthread_attr_t* attribs, - void* (*threadfunc)(void*), void* thread_arg) { +pthread_create(pthread_t *thread, const pthread_attr_t *attribs, void *(*threadfunc)(void *), void *thread_arg) { (void)attribs; LPTHREAD_START_ROUTINE func = (LPTHREAD_START_ROUTINE)threadfunc; *thread = CreateThread(nullptr, 0, func, thread_arg, 0, nullptr); @@ -56,46 +55,43 @@ pthread_create(pthread_t* thread, const pthread_attr_t* attribs, /* Public function, see header file for detailed documentation */ static int -pthread_join(pthread_t thread, void** value) { +pthread_join(pthread_t thread, void **value) { (void)value; WaitForSingleObject(thread, INFINITE); return 0; } #endif -static astcenc_image* -imageAllocate(uint32_t bitness, - uint32_t dim_x, uint32_t dim_y, uint32_t dim_z) { +static astcenc_image * +imageAllocate(uint32_t bitness, uint32_t dim_x, uint32_t dim_y, uint32_t dim_z) { astcenc_image *img = new astcenc_image; assert(img); - img->dim_x = dim_x; - img->dim_y = dim_y; - img->dim_z = dim_z; + img->dim_x = dim_x; + img->dim_y = dim_y; + img->dim_z = dim_z; if (bitness == 8) { - void **data = new void *[dim_z]; + void **data = new void *[dim_z]; img->data_type = ASTCENC_TYPE_U8; - img->data = data; + img->data = data; for (uint32_t z = 0; z < dim_z; z++) { data[z] = new uint8_t[dim_x * dim_y * 4]; } - } - else if (bitness == 16) { - void **data = new void *[dim_z]; + } else if (bitness == 16) { + void **data = new void *[dim_z]; img->data_type = ASTCENC_TYPE_F16; - img->data = data; + img->data = data; for (uint32_t z = 0; z < dim_z; z++) { data[z] = new uint16_t[dim_x * dim_y * 4]; } - } - else { // if (bitness == 32) + } else { // if (bitness == 32) assert(bitness == 32); - void **data = new void *[dim_z]; + void **data = new void *[dim_z]; img->data_type = ASTCENC_TYPE_F32; - img->data = data; + img->data = data; for (uint32_t z = 0; z < dim_z; z++) { data[z] = new float[dim_x * dim_y * 4]; @@ -119,17 +115,17 @@ imageFree(astcenc_image *img) { delete img; } -static astcenc_image* +static astcenc_image * unorm8x1ArrayToImage(const uint8_t *data, uint32_t dim_x, uint32_t dim_y) { astcenc_image *img = imageAllocate(8, dim_x, dim_y, 1); assert(img); for (uint32_t y = 0; y < dim_y; y++) { - uint8_t * data8 = static_cast(img->data[0]); - const uint8_t *src = data + dim_x * y; + uint8_t *data8 = static_cast(img->data[0]); + const uint8_t *src = data + dim_x * y; for (uint32_t x = 0; x < dim_x; x++) { - data8[(4 * dim_x * y) + (4 * x) ] = src[x]; + data8[(4 * dim_x * y) + (4 * x)] = src[x]; data8[(4 * dim_x * y) + (4 * x + 1)] = src[x]; data8[(4 * dim_x * y) + (4 * x + 2)] = src[x]; data8[(4 * dim_x * y) + (4 * x + 3)] = 255; @@ -139,19 +135,19 @@ unorm8x1ArrayToImage(const uint8_t *data, uint32_t dim_x, uint32_t dim_y) { return img; } -static astcenc_image* +static astcenc_image * unorm8x2ArrayToImage(const uint8_t *data, uint32_t dim_x, uint32_t dim_y) { astcenc_image *img = imageAllocate(8, dim_x, dim_y, 1); assert(img); for (uint32_t y = 0; y < dim_y; y++) { - uint8_t * data8 = static_cast(img->data[0]); - const uint8_t *src = data + 2 * dim_x * y; + uint8_t *data8 = static_cast(img->data[0]); + const uint8_t *src = data + 2 * dim_x * y; for (uint32_t x = 0; x < dim_x; x++) { - data8[(4 * dim_x * y) + (4 * x) ] = src[2 * x ]; - data8[(4 * dim_x * y) + (4 * x + 1)] = src[2 * x ]; - data8[(4 * dim_x * y) + (4 * x + 2)] = src[2 * x ]; + data8[(4 * dim_x * y) + (4 * x)] = src[2 * x]; + data8[(4 * dim_x * y) + (4 * x + 1)] = src[2 * x]; + data8[(4 * dim_x * y) + (4 * x + 2)] = src[2 * x]; data8[(4 * dim_x * y) + (4 * x + 3)] = src[2 * x + 1]; } } @@ -159,17 +155,17 @@ unorm8x2ArrayToImage(const uint8_t *data, uint32_t dim_x, uint32_t dim_y) { return img; } -static astcenc_image* +static astcenc_image * unorm8x3ArrayToImage(const uint8_t *data, uint32_t dim_x, uint32_t dim_y) { astcenc_image *img = imageAllocate(8, dim_x, dim_y, 1); assert(img); for (uint32_t y = 0; y < dim_y; y++) { - uint8_t * data8 = static_cast(img->data[0]); - const uint8_t *src = data + 3 * dim_x * y; + uint8_t *data8 = static_cast(img->data[0]); + const uint8_t *src = data + 3 * dim_x * y; for (uint32_t x = 0; x < dim_x; x++) { - data8[(4 * dim_x * y) + (4 * x) ] = src[3 * x ]; + data8[(4 * dim_x * y) + (4 * x)] = src[3 * x]; data8[(4 * dim_x * y) + (4 * x + 1)] = src[3 * x + 1]; data8[(4 * dim_x * y) + (4 * x + 2)] = src[3 * x + 2]; data8[(4 * dim_x * y) + (4 * x + 3)] = 255; @@ -179,17 +175,17 @@ unorm8x3ArrayToImage(const uint8_t *data, uint32_t dim_x, uint32_t dim_y) { return img; } -static astcenc_image* +static astcenc_image * unorm8x4ArrayToImage(const uint8_t *data, uint32_t dim_x, uint32_t dim_y) { astcenc_image *img = imageAllocate(8, dim_x, dim_y, 1); assert(img); for (uint32_t y = 0; y < dim_y; y++) { - uint8_t * data8 = static_cast(img->data[0]); - const uint8_t *src = data + 4 * dim_x * y; + uint8_t *data8 = static_cast(img->data[0]); + const uint8_t *src = data + 4 * dim_x * y; for (uint32_t x = 0; x < dim_x; x++) { - data8[(4 * dim_x * y) + (4 * x) ] = src[4 * x ]; + data8[(4 * dim_x * y) + (4 * x)] = src[4 * x]; data8[(4 * dim_x * y) + (4 * x + 1)] = src[4 * x + 1]; data8[(4 * dim_x * y) + (4 * x + 2)] = src[4 * x + 2]; data8[(4 * dim_x * y) + (4 * x + 3)] = src[4 * x + 3]; @@ -232,61 +228,109 @@ static VkFormat astcVkFormat(ktx_uint32_t block_size, bool sRGB) { if (sRGB) { switch (block_size) { - case KTX_PACK_ASTC_BLOCK_DIMENSION_4x4: return VK_FORMAT_ASTC_4x4_SRGB_BLOCK; - case KTX_PACK_ASTC_BLOCK_DIMENSION_5x4: return VK_FORMAT_ASTC_5x4_SRGB_BLOCK; - case KTX_PACK_ASTC_BLOCK_DIMENSION_5x5: return VK_FORMAT_ASTC_5x5_SRGB_BLOCK; - case KTX_PACK_ASTC_BLOCK_DIMENSION_6x5: return VK_FORMAT_ASTC_6x5_SRGB_BLOCK; - case KTX_PACK_ASTC_BLOCK_DIMENSION_6x6: return VK_FORMAT_ASTC_6x6_SRGB_BLOCK; - case KTX_PACK_ASTC_BLOCK_DIMENSION_8x5: return VK_FORMAT_ASTC_8x5_SRGB_BLOCK; - case KTX_PACK_ASTC_BLOCK_DIMENSION_8x6: return VK_FORMAT_ASTC_8x6_SRGB_BLOCK; - case KTX_PACK_ASTC_BLOCK_DIMENSION_8x8: return VK_FORMAT_ASTC_8x8_SRGB_BLOCK; - case KTX_PACK_ASTC_BLOCK_DIMENSION_10x5: return VK_FORMAT_ASTC_10x5_SRGB_BLOCK; - case KTX_PACK_ASTC_BLOCK_DIMENSION_10x6: return VK_FORMAT_ASTC_10x6_SRGB_BLOCK; - case KTX_PACK_ASTC_BLOCK_DIMENSION_10x8: return VK_FORMAT_ASTC_10x8_SRGB_BLOCK; - case KTX_PACK_ASTC_BLOCK_DIMENSION_10x10: return VK_FORMAT_ASTC_10x10_SRGB_BLOCK; - case KTX_PACK_ASTC_BLOCK_DIMENSION_12x10: return VK_FORMAT_ASTC_12x10_SRGB_BLOCK; - case KTX_PACK_ASTC_BLOCK_DIMENSION_12x12: return VK_FORMAT_ASTC_12x12_SRGB_BLOCK; - case KTX_PACK_ASTC_BLOCK_DIMENSION_3x3x3: return VK_FORMAT_ASTC_3x3x3_SRGB_BLOCK_EXT; - case KTX_PACK_ASTC_BLOCK_DIMENSION_4x3x3: return VK_FORMAT_ASTC_4x3x3_SRGB_BLOCK_EXT; - case KTX_PACK_ASTC_BLOCK_DIMENSION_4x4x3: return VK_FORMAT_ASTC_4x4x3_SRGB_BLOCK_EXT; - case KTX_PACK_ASTC_BLOCK_DIMENSION_4x4x4: return VK_FORMAT_ASTC_4x4x4_SRGB_BLOCK_EXT; - case KTX_PACK_ASTC_BLOCK_DIMENSION_5x4x4: return VK_FORMAT_ASTC_5x4x4_SRGB_BLOCK_EXT; - case KTX_PACK_ASTC_BLOCK_DIMENSION_5x5x4: return VK_FORMAT_ASTC_5x5x4_SRGB_BLOCK_EXT; - case KTX_PACK_ASTC_BLOCK_DIMENSION_5x5x5: return VK_FORMAT_ASTC_5x5x5_SRGB_BLOCK_EXT; - case KTX_PACK_ASTC_BLOCK_DIMENSION_6x5x5: return VK_FORMAT_ASTC_6x5x5_SRGB_BLOCK_EXT; - case KTX_PACK_ASTC_BLOCK_DIMENSION_6x6x5: return VK_FORMAT_ASTC_6x6x5_SRGB_BLOCK_EXT; - case KTX_PACK_ASTC_BLOCK_DIMENSION_6x6x6: return VK_FORMAT_ASTC_6x6x6_SRGB_BLOCK_EXT; + case KTX_PACK_ASTC_BLOCK_DIMENSION_4x4: + return VK_FORMAT_ASTC_4x4_SRGB_BLOCK; + case KTX_PACK_ASTC_BLOCK_DIMENSION_5x4: + return VK_FORMAT_ASTC_5x4_SRGB_BLOCK; + case KTX_PACK_ASTC_BLOCK_DIMENSION_5x5: + return VK_FORMAT_ASTC_5x5_SRGB_BLOCK; + case KTX_PACK_ASTC_BLOCK_DIMENSION_6x5: + return VK_FORMAT_ASTC_6x5_SRGB_BLOCK; + case KTX_PACK_ASTC_BLOCK_DIMENSION_6x6: + return VK_FORMAT_ASTC_6x6_SRGB_BLOCK; + case KTX_PACK_ASTC_BLOCK_DIMENSION_8x5: + return VK_FORMAT_ASTC_8x5_SRGB_BLOCK; + case KTX_PACK_ASTC_BLOCK_DIMENSION_8x6: + return VK_FORMAT_ASTC_8x6_SRGB_BLOCK; + case KTX_PACK_ASTC_BLOCK_DIMENSION_8x8: + return VK_FORMAT_ASTC_8x8_SRGB_BLOCK; + case KTX_PACK_ASTC_BLOCK_DIMENSION_10x5: + return VK_FORMAT_ASTC_10x5_SRGB_BLOCK; + case KTX_PACK_ASTC_BLOCK_DIMENSION_10x6: + return VK_FORMAT_ASTC_10x6_SRGB_BLOCK; + case KTX_PACK_ASTC_BLOCK_DIMENSION_10x8: + return VK_FORMAT_ASTC_10x8_SRGB_BLOCK; + case KTX_PACK_ASTC_BLOCK_DIMENSION_10x10: + return VK_FORMAT_ASTC_10x10_SRGB_BLOCK; + case KTX_PACK_ASTC_BLOCK_DIMENSION_12x10: + return VK_FORMAT_ASTC_12x10_SRGB_BLOCK; + case KTX_PACK_ASTC_BLOCK_DIMENSION_12x12: + return VK_FORMAT_ASTC_12x12_SRGB_BLOCK; + case KTX_PACK_ASTC_BLOCK_DIMENSION_3x3x3: + return VK_FORMAT_ASTC_3x3x3_SRGB_BLOCK_EXT; + case KTX_PACK_ASTC_BLOCK_DIMENSION_4x3x3: + return VK_FORMAT_ASTC_4x3x3_SRGB_BLOCK_EXT; + case KTX_PACK_ASTC_BLOCK_DIMENSION_4x4x3: + return VK_FORMAT_ASTC_4x4x3_SRGB_BLOCK_EXT; + case KTX_PACK_ASTC_BLOCK_DIMENSION_4x4x4: + return VK_FORMAT_ASTC_4x4x4_SRGB_BLOCK_EXT; + case KTX_PACK_ASTC_BLOCK_DIMENSION_5x4x4: + return VK_FORMAT_ASTC_5x4x4_SRGB_BLOCK_EXT; + case KTX_PACK_ASTC_BLOCK_DIMENSION_5x5x4: + return VK_FORMAT_ASTC_5x5x4_SRGB_BLOCK_EXT; + case KTX_PACK_ASTC_BLOCK_DIMENSION_5x5x5: + return VK_FORMAT_ASTC_5x5x5_SRGB_BLOCK_EXT; + case KTX_PACK_ASTC_BLOCK_DIMENSION_6x5x5: + return VK_FORMAT_ASTC_6x5x5_SRGB_BLOCK_EXT; + case KTX_PACK_ASTC_BLOCK_DIMENSION_6x6x5: + return VK_FORMAT_ASTC_6x6x5_SRGB_BLOCK_EXT; + case KTX_PACK_ASTC_BLOCK_DIMENSION_6x6x6: + return VK_FORMAT_ASTC_6x6x6_SRGB_BLOCK_EXT; } } else { switch (block_size) { - case KTX_PACK_ASTC_BLOCK_DIMENSION_4x4: return VK_FORMAT_ASTC_4x4_UNORM_BLOCK; - case KTX_PACK_ASTC_BLOCK_DIMENSION_5x4: return VK_FORMAT_ASTC_5x4_UNORM_BLOCK; - case KTX_PACK_ASTC_BLOCK_DIMENSION_5x5: return VK_FORMAT_ASTC_5x5_UNORM_BLOCK; - case KTX_PACK_ASTC_BLOCK_DIMENSION_6x5: return VK_FORMAT_ASTC_6x5_UNORM_BLOCK; - case KTX_PACK_ASTC_BLOCK_DIMENSION_6x6: return VK_FORMAT_ASTC_6x6_UNORM_BLOCK; - case KTX_PACK_ASTC_BLOCK_DIMENSION_8x5: return VK_FORMAT_ASTC_8x5_UNORM_BLOCK; - case KTX_PACK_ASTC_BLOCK_DIMENSION_8x6: return VK_FORMAT_ASTC_8x6_UNORM_BLOCK; - case KTX_PACK_ASTC_BLOCK_DIMENSION_8x8: return VK_FORMAT_ASTC_8x8_UNORM_BLOCK; - case KTX_PACK_ASTC_BLOCK_DIMENSION_10x5: return VK_FORMAT_ASTC_10x5_UNORM_BLOCK; - case KTX_PACK_ASTC_BLOCK_DIMENSION_10x6: return VK_FORMAT_ASTC_10x6_UNORM_BLOCK; - case KTX_PACK_ASTC_BLOCK_DIMENSION_10x8: return VK_FORMAT_ASTC_10x8_UNORM_BLOCK; - case KTX_PACK_ASTC_BLOCK_DIMENSION_10x10: return VK_FORMAT_ASTC_10x10_UNORM_BLOCK; - case KTX_PACK_ASTC_BLOCK_DIMENSION_12x10: return VK_FORMAT_ASTC_12x10_UNORM_BLOCK; - case KTX_PACK_ASTC_BLOCK_DIMENSION_12x12: return VK_FORMAT_ASTC_12x12_UNORM_BLOCK; - case KTX_PACK_ASTC_BLOCK_DIMENSION_3x3x3: return VK_FORMAT_ASTC_3x3x3_UNORM_BLOCK_EXT; - case KTX_PACK_ASTC_BLOCK_DIMENSION_4x3x3: return VK_FORMAT_ASTC_4x3x3_UNORM_BLOCK_EXT; - case KTX_PACK_ASTC_BLOCK_DIMENSION_4x4x3: return VK_FORMAT_ASTC_4x4x3_UNORM_BLOCK_EXT; - case KTX_PACK_ASTC_BLOCK_DIMENSION_4x4x4: return VK_FORMAT_ASTC_4x4x4_UNORM_BLOCK_EXT; - case KTX_PACK_ASTC_BLOCK_DIMENSION_5x4x4: return VK_FORMAT_ASTC_5x4x4_UNORM_BLOCK_EXT; - case KTX_PACK_ASTC_BLOCK_DIMENSION_5x5x4: return VK_FORMAT_ASTC_5x5x4_UNORM_BLOCK_EXT; - case KTX_PACK_ASTC_BLOCK_DIMENSION_5x5x5: return VK_FORMAT_ASTC_5x5x5_UNORM_BLOCK_EXT; - case KTX_PACK_ASTC_BLOCK_DIMENSION_6x5x5: return VK_FORMAT_ASTC_6x5x5_UNORM_BLOCK_EXT; - case KTX_PACK_ASTC_BLOCK_DIMENSION_6x6x5: return VK_FORMAT_ASTC_6x6x5_UNORM_BLOCK_EXT; - case KTX_PACK_ASTC_BLOCK_DIMENSION_6x6x6: return VK_FORMAT_ASTC_6x6x6_UNORM_BLOCK_EXT; + case KTX_PACK_ASTC_BLOCK_DIMENSION_4x4: + return VK_FORMAT_ASTC_4x4_UNORM_BLOCK; + case KTX_PACK_ASTC_BLOCK_DIMENSION_5x4: + return VK_FORMAT_ASTC_5x4_UNORM_BLOCK; + case KTX_PACK_ASTC_BLOCK_DIMENSION_5x5: + return VK_FORMAT_ASTC_5x5_UNORM_BLOCK; + case KTX_PACK_ASTC_BLOCK_DIMENSION_6x5: + return VK_FORMAT_ASTC_6x5_UNORM_BLOCK; + case KTX_PACK_ASTC_BLOCK_DIMENSION_6x6: + return VK_FORMAT_ASTC_6x6_UNORM_BLOCK; + case KTX_PACK_ASTC_BLOCK_DIMENSION_8x5: + return VK_FORMAT_ASTC_8x5_UNORM_BLOCK; + case KTX_PACK_ASTC_BLOCK_DIMENSION_8x6: + return VK_FORMAT_ASTC_8x6_UNORM_BLOCK; + case KTX_PACK_ASTC_BLOCK_DIMENSION_8x8: + return VK_FORMAT_ASTC_8x8_UNORM_BLOCK; + case KTX_PACK_ASTC_BLOCK_DIMENSION_10x5: + return VK_FORMAT_ASTC_10x5_UNORM_BLOCK; + case KTX_PACK_ASTC_BLOCK_DIMENSION_10x6: + return VK_FORMAT_ASTC_10x6_UNORM_BLOCK; + case KTX_PACK_ASTC_BLOCK_DIMENSION_10x8: + return VK_FORMAT_ASTC_10x8_UNORM_BLOCK; + case KTX_PACK_ASTC_BLOCK_DIMENSION_10x10: + return VK_FORMAT_ASTC_10x10_UNORM_BLOCK; + case KTX_PACK_ASTC_BLOCK_DIMENSION_12x10: + return VK_FORMAT_ASTC_12x10_UNORM_BLOCK; + case KTX_PACK_ASTC_BLOCK_DIMENSION_12x12: + return VK_FORMAT_ASTC_12x12_UNORM_BLOCK; + case KTX_PACK_ASTC_BLOCK_DIMENSION_3x3x3: + return VK_FORMAT_ASTC_3x3x3_UNORM_BLOCK_EXT; + case KTX_PACK_ASTC_BLOCK_DIMENSION_4x3x3: + return VK_FORMAT_ASTC_4x3x3_UNORM_BLOCK_EXT; + case KTX_PACK_ASTC_BLOCK_DIMENSION_4x4x3: + return VK_FORMAT_ASTC_4x4x3_UNORM_BLOCK_EXT; + case KTX_PACK_ASTC_BLOCK_DIMENSION_4x4x4: + return VK_FORMAT_ASTC_4x4x4_UNORM_BLOCK_EXT; + case KTX_PACK_ASTC_BLOCK_DIMENSION_5x4x4: + return VK_FORMAT_ASTC_5x4x4_UNORM_BLOCK_EXT; + case KTX_PACK_ASTC_BLOCK_DIMENSION_5x5x4: + return VK_FORMAT_ASTC_5x5x4_UNORM_BLOCK_EXT; + case KTX_PACK_ASTC_BLOCK_DIMENSION_5x5x5: + return VK_FORMAT_ASTC_5x5x5_UNORM_BLOCK_EXT; + case KTX_PACK_ASTC_BLOCK_DIMENSION_6x5x5: + return VK_FORMAT_ASTC_6x5x5_UNORM_BLOCK_EXT; + case KTX_PACK_ASTC_BLOCK_DIMENSION_6x6x5: + return VK_FORMAT_ASTC_6x6x5_UNORM_BLOCK_EXT; + case KTX_PACK_ASTC_BLOCK_DIMENSION_6x6x6: + return VK_FORMAT_ASTC_6x6x6_UNORM_BLOCK_EXT; } } - return VK_FORMAT_ASTC_6x6_SRGB_BLOCK; // Default is 6x6 sRGB image + return VK_FORMAT_ASTC_6x6_SRGB_BLOCK; // Default is 6x6 sRGB image } /** @@ -298,12 +342,10 @@ astcVkFormat(ktx_uint32_t block_size, bool sRGB) { * @return Valid astc_profile from string */ static astcenc_profile -astcEncoderAction(const ktxAstcParams ¶ms, const uint32_t* bdb) { - +astcEncoderAction(const ktxAstcParams ¶ms, const uint32_t *bdb) { ktx_uint32_t transfer = KHR_DFDVAL(bdb, TRANSFER); - if (transfer == KHR_DF_TRANSFER_SRGB && - params.mode == KTX_PACK_ASTC_ENCODER_MODE_LDR) + if (transfer == KHR_DF_TRANSFER_SRGB && params.mode == KTX_PACK_ASTC_ENCODER_MODE_LDR) return ASTCENC_PRF_LDR_SRGB; else if (transfer == KHR_DF_TRANSFER_LINEAR) { if (params.mode == KTX_PACK_ASTC_ENCODER_MODE_LDR) @@ -314,10 +356,9 @@ astcEncoderAction(const ktxAstcParams ¶ms, const uint32_t* bdb) { // TODO: Add support for the following // KTX_PACK_ASTC_ENCODER_ACTION_COMP_HDR_RGB_LDR_ALPHA; currently not supported - return ASTCENC_PRF_LDR_SRGB; + return ASTCENC_PRF_LDR_SRGB; } - /** * @memberof ktxTexture * @ingroup write @@ -328,10 +369,9 @@ astcEncoderAction(const ktxAstcParams ¶ms, const uint32_t* bdb) { */ static astcenc_swizzle astcSwizzle(const ktxAstcParams ¶ms) { - astcenc_swizzle swizzle{ASTCENC_SWZ_R, ASTCENC_SWZ_G, ASTCENC_SWZ_B, ASTCENC_SWZ_A}; - std::vector swizzle_array{&swizzle.r, &swizzle.g, &swizzle.b, &swizzle.a}; + std::vector swizzle_array{&swizzle.r, &swizzle.g, &swizzle.b, &swizzle.a}; std::string inputSwizzle = params.inputSwizzle; if (inputSwizzle.size() > 0) { @@ -359,68 +399,170 @@ astcSwizzle(const ktxAstcParams ¶ms) { } static void -astcBlockDimensions(ktx_uint32_t block_size, - uint32_t& block_x, uint32_t& block_y, uint32_t& block_z) { +astcBlockDimensions(ktx_uint32_t block_size, uint32_t &block_x, uint32_t &block_y, uint32_t &block_z) { switch (block_size) { - case KTX_PACK_ASTC_BLOCK_DIMENSION_4x4 : block_x = 4; block_y = 4; block_z = 1; break; - case KTX_PACK_ASTC_BLOCK_DIMENSION_5x4 : block_x = 5; block_y = 4; block_z = 1; break; - case KTX_PACK_ASTC_BLOCK_DIMENSION_5x5 : block_x = 5; block_y = 5; block_z = 1; break; - case KTX_PACK_ASTC_BLOCK_DIMENSION_6x5 : block_x = 6; block_y = 5; block_z = 1; break; - case KTX_PACK_ASTC_BLOCK_DIMENSION_6x6 : block_x = 6; block_y = 6; block_z = 1; break; - case KTX_PACK_ASTC_BLOCK_DIMENSION_8x5 : block_x = 8; block_y = 5; block_z = 1; break; - case KTX_PACK_ASTC_BLOCK_DIMENSION_8x6 : block_x = 8; block_y = 6; block_z = 1; break; - case KTX_PACK_ASTC_BLOCK_DIMENSION_10x5 : block_x = 10; block_y = 5; block_z = 1; break; - case KTX_PACK_ASTC_BLOCK_DIMENSION_10x6 : block_x = 10; block_y = 6; block_z = 1; break; - case KTX_PACK_ASTC_BLOCK_DIMENSION_8x8 : block_x = 8; block_y = 8; block_z = 1; break; - case KTX_PACK_ASTC_BLOCK_DIMENSION_10x8 : block_x = 10; block_y = 8; block_z = 1; break; - case KTX_PACK_ASTC_BLOCK_DIMENSION_10x10 : block_x = 10; block_y = 10; block_z = 1; break; - case KTX_PACK_ASTC_BLOCK_DIMENSION_12x10 : block_x = 12; block_y = 10; block_z = 1; break; - case KTX_PACK_ASTC_BLOCK_DIMENSION_12x12 : block_x = 12; block_y = 12; block_z = 1; break; - case KTX_PACK_ASTC_BLOCK_DIMENSION_3x3x3 : block_x = 3; block_y = 3; block_z = 3; break; - case KTX_PACK_ASTC_BLOCK_DIMENSION_4x3x3 : block_x = 4; block_y = 3; block_z = 3; break; - case KTX_PACK_ASTC_BLOCK_DIMENSION_4x4x3 : block_x = 4; block_y = 4; block_z = 3; break; - case KTX_PACK_ASTC_BLOCK_DIMENSION_4x4x4 : block_x = 4; block_y = 4; block_z = 4; break; - case KTX_PACK_ASTC_BLOCK_DIMENSION_5x4x4 : block_x = 5; block_y = 4; block_z = 4; break; - case KTX_PACK_ASTC_BLOCK_DIMENSION_5x5x4 : block_x = 5; block_y = 5; block_z = 4; break; - case KTX_PACK_ASTC_BLOCK_DIMENSION_5x5x5 : block_x = 5; block_y = 5; block_z = 5; break; - case KTX_PACK_ASTC_BLOCK_DIMENSION_6x5x5 : block_x = 6; block_y = 5; block_z = 5; break; - case KTX_PACK_ASTC_BLOCK_DIMENSION_6x6x5 : block_x = 6; block_y = 6; block_z = 5; break; - case KTX_PACK_ASTC_BLOCK_DIMENSION_6x6x6 : block_x = 6; block_y = 6; block_z = 6; break; + case KTX_PACK_ASTC_BLOCK_DIMENSION_4x4: + block_x = 4; + block_y = 4; + block_z = 1; + break; + case KTX_PACK_ASTC_BLOCK_DIMENSION_5x4: + block_x = 5; + block_y = 4; + block_z = 1; + break; + case KTX_PACK_ASTC_BLOCK_DIMENSION_5x5: + block_x = 5; + block_y = 5; + block_z = 1; + break; + case KTX_PACK_ASTC_BLOCK_DIMENSION_6x5: + block_x = 6; + block_y = 5; + block_z = 1; + break; + case KTX_PACK_ASTC_BLOCK_DIMENSION_6x6: + block_x = 6; + block_y = 6; + block_z = 1; + break; + case KTX_PACK_ASTC_BLOCK_DIMENSION_8x5: + block_x = 8; + block_y = 5; + block_z = 1; + break; + case KTX_PACK_ASTC_BLOCK_DIMENSION_8x6: + block_x = 8; + block_y = 6; + block_z = 1; + break; + case KTX_PACK_ASTC_BLOCK_DIMENSION_10x5: + block_x = 10; + block_y = 5; + block_z = 1; + break; + case KTX_PACK_ASTC_BLOCK_DIMENSION_10x6: + block_x = 10; + block_y = 6; + block_z = 1; + break; + case KTX_PACK_ASTC_BLOCK_DIMENSION_8x8: + block_x = 8; + block_y = 8; + block_z = 1; + break; + case KTX_PACK_ASTC_BLOCK_DIMENSION_10x8: + block_x = 10; + block_y = 8; + block_z = 1; + break; + case KTX_PACK_ASTC_BLOCK_DIMENSION_10x10: + block_x = 10; + block_y = 10; + block_z = 1; + break; + case KTX_PACK_ASTC_BLOCK_DIMENSION_12x10: + block_x = 12; + block_y = 10; + block_z = 1; + break; + case KTX_PACK_ASTC_BLOCK_DIMENSION_12x12: + block_x = 12; + block_y = 12; + block_z = 1; + break; + case KTX_PACK_ASTC_BLOCK_DIMENSION_3x3x3: + block_x = 3; + block_y = 3; + block_z = 3; + break; + case KTX_PACK_ASTC_BLOCK_DIMENSION_4x3x3: + block_x = 4; + block_y = 3; + block_z = 3; + break; + case KTX_PACK_ASTC_BLOCK_DIMENSION_4x4x3: + block_x = 4; + block_y = 4; + block_z = 3; + break; + case KTX_PACK_ASTC_BLOCK_DIMENSION_4x4x4: + block_x = 4; + block_y = 4; + block_z = 4; + break; + case KTX_PACK_ASTC_BLOCK_DIMENSION_5x4x4: + block_x = 5; + block_y = 4; + block_z = 4; + break; + case KTX_PACK_ASTC_BLOCK_DIMENSION_5x5x4: + block_x = 5; + block_y = 5; + block_z = 4; + break; + case KTX_PACK_ASTC_BLOCK_DIMENSION_5x5x5: + block_x = 5; + block_y = 5; + block_z = 5; + break; + case KTX_PACK_ASTC_BLOCK_DIMENSION_6x5x5: + block_x = 6; + block_y = 5; + block_z = 5; + break; + case KTX_PACK_ASTC_BLOCK_DIMENSION_6x6x5: + block_x = 6; + block_y = 6; + block_z = 5; + break; + case KTX_PACK_ASTC_BLOCK_DIMENSION_6x6x6: + block_x = 6; + block_y = 6; + block_z = 6; + break; default: - block_x = 6; block_y = 6; block_z = 1; break; + block_x = 6; + block_y = 6; + block_z = 1; + break; } } static float astcQuality(ktx_uint32_t quality_level) { switch (quality_level) { - case KTX_PACK_ASTC_QUALITY_LEVEL_FASTEST: return ASTCENC_PRE_FASTEST; - case KTX_PACK_ASTC_QUALITY_LEVEL_FAST: return ASTCENC_PRE_FAST; - case KTX_PACK_ASTC_QUALITY_LEVEL_MEDIUM: return ASTCENC_PRE_MEDIUM; - case KTX_PACK_ASTC_QUALITY_LEVEL_THOROUGH: return ASTCENC_PRE_THOROUGH; - case KTX_PACK_ASTC_QUALITY_LEVEL_EXHAUSTIVE: return ASTCENC_PRE_EXHAUSTIVE; + case KTX_PACK_ASTC_QUALITY_LEVEL_FASTEST: + return ASTCENC_PRE_FASTEST; + case KTX_PACK_ASTC_QUALITY_LEVEL_FAST: + return ASTCENC_PRE_FAST; + case KTX_PACK_ASTC_QUALITY_LEVEL_MEDIUM: + return ASTCENC_PRE_MEDIUM; + case KTX_PACK_ASTC_QUALITY_LEVEL_THOROUGH: + return ASTCENC_PRE_THOROUGH; + case KTX_PACK_ASTC_QUALITY_LEVEL_EXHAUSTIVE: + return ASTCENC_PRE_EXHAUSTIVE; } return ASTCENC_PRE_MEDIUM; } struct CompressionWorkload { - astcenc_context* context; - astcenc_image* image; + astcenc_context *context; + astcenc_image *image; astcenc_swizzle swizzle; - uint8_t* data_out; + uint8_t *data_out; size_t data_len; astcenc_error error; }; static void -compressionWorkloadRunner(int threadCount, int threadId, void* payload) { +compressionWorkloadRunner(int threadCount, int threadId, void *payload) { (void)threadCount; - CompressionWorkload* work = static_cast(payload); - astcenc_error error = astcenc_compress_image( - work->context, work->image, &work->swizzle, - work->data_out, work->data_len, threadId); + CompressionWorkload *work = static_cast(payload); + astcenc_error error = + astcenc_compress_image(work->context, work->image, &work->swizzle, work->data_out, work->data_len, threadId); // This is a racy update, so which error gets returned is a random, but it // will reliably report an error if an error occurs @@ -440,9 +582,9 @@ struct LaunchDesc { /** The thread index in the thread pool. */ int threadId; /** The user thread function to execute. */ - void (*func)(int, int, void*); + void (*func)(int, int, void *); /** The user thread payload. */ - void* payload; + void *payload; }; /** @@ -453,16 +595,16 @@ struct LaunchDesc { * * @param p The thread launch helper payload. */ -static void* +static void * launchThreadsHelper(void *p) { - LaunchDesc* ltd = (LaunchDesc*)p; + LaunchDesc *ltd = (LaunchDesc *)p; ltd->func(ltd->threadCount, ltd->threadId, ltd->payload); return nullptr; } /* Public function, see header file for detailed documentation */ static void -launchThreads(int threadCount, void (*func)(int, int, void*), void *payload) { +launchThreads(int threadCount, void (*func)(int, int, void *), void *payload) { // Directly execute single threaded workloads on this thread if (threadCount <= 1) { func(1, 0, payload); @@ -477,8 +619,7 @@ launchThreads(int threadCount, void (*func)(int, int, void*), void *payload) { threadDescs[i].payload = payload; threadDescs[i].func = func; - pthread_create(&(threadDescs[i].threadHandle), nullptr, - launchThreadsHelper, (void*)&(threadDescs[i])); + pthread_create(&(threadDescs[i].threadHandle), nullptr, launchThreadsHelper, (void *)&(threadDescs[i])); } // ... and then wait for them to complete @@ -526,46 +667,39 @@ launchThreads(int threadCount, void (*func)(int, int, void*), void *payload) { * @exception KTX_OUT_OF_MEMORY Not enough memory to carry out compression. */ extern "C" KTX_error_code -ktxTexture2_CompressAstcEx(ktxTexture2* This, ktxAstcParams* params) { +ktxTexture2_CompressAstcEx(ktxTexture2 *This, ktxAstcParams *params) { assert(This->classId == ktxTexture2_c && "Only support ktx2 ASTC."); KTX_error_code result; - if (!params) - return KTX_INVALID_VALUE; + if (!params) return KTX_INVALID_VALUE; - if (params->structSize != sizeof(struct ktxAstcParams)) - return KTX_INVALID_VALUE; + if (params->structSize != sizeof(struct ktxAstcParams)) return KTX_INVALID_VALUE; - if (This->supercompressionScheme != KTX_SS_NONE) - return KTX_INVALID_OPERATION; // Can't apply multiple schemes. + if (This->supercompressionScheme != KTX_SS_NONE) return KTX_INVALID_OPERATION; // Can't apply multiple schemes. if (This->isCompressed) return KTX_INVALID_OPERATION; // Only non-block compressed formats // can be encoded into an ASTC format. - if (This->_protected->_formatSize.flags & KTX_FORMAT_SIZE_PACKED_BIT) - return KTX_INVALID_OPERATION; + if (This->_protected->_formatSize.flags & KTX_FORMAT_SIZE_PACKED_BIT) return KTX_INVALID_OPERATION; // Basic descriptor block begins after the total size field. - const uint32_t* BDB = This->pDfd+1; + const uint32_t *BDB = This->pDfd + 1; uint32_t num_components, component_size; getDFDComponentInfoUnpacked(This->pDfd, &num_components, &component_size); - if (component_size != 1) - return KTX_INVALID_OPERATION; // Can only deal with 8-bit components at the moment + if (component_size != 1) return KTX_INVALID_OPERATION; // Can only deal with 8-bit components at the moment if (This->pData == NULL) { - result = ktxTexture2_LoadImageData((ktxTexture2*)This, nullptr, 0); + result = ktxTexture2_LoadImageData((ktxTexture2 *)This, nullptr, 0); - if (result != KTX_SUCCESS) - return result; + if (result != KTX_SUCCESS) return result; } ktx_uint32_t threadCount = params->threadCount; - if (threadCount < 1) - threadCount = 1; + if (threadCount < 1) threadCount = 1; ktx_uint32_t transfer = KHR_DFDVAL(BDB, TRANSFER); bool sRGB = transfer == KHR_DF_TRANSFER_SRGB; @@ -593,9 +727,8 @@ ktxTexture2_CompressAstcEx(ktxTexture2* This, ktxAstcParams* params) { createInfo.numLevels = This->numLevels; createInfo.pDfd = nullptr; - ktxTexture2* prototype; - result = ktxTexture2_Create(&createInfo, KTX_TEXTURE_CREATE_ALLOC_STORAGE, - &prototype); + ktxTexture2 *prototype; + result = ktxTexture2_Create(&createInfo, KTX_TEXTURE_CREATE_ALLOC_STORAGE, &prototype); if (result != KTX_SUCCESS) { assert(result == KTX_OUT_OF_MEMORY && "Out of memory allocating texture."); @@ -606,36 +739,28 @@ ktxTexture2_CompressAstcEx(ktxTexture2* This, ktxAstcParams* params) { astcenc_swizzle swizzle{ASTCENC_SWZ_R, ASTCENC_SWZ_G, ASTCENC_SWZ_B, ASTCENC_SWZ_A}; - uint32_t block_size_x{6}; - uint32_t block_size_y{6}; - uint32_t block_size_z{1}; - float quality{ASTCENC_PRE_MEDIUM}; - uint32_t flags{params->normalMap ? ASTCENC_FLG_MAP_NORMAL : 0}; + uint32_t block_size_x{6}; + uint32_t block_size_y{6}; + uint32_t block_size_z{1}; + float quality{ASTCENC_PRE_MEDIUM}; + uint32_t flags{params->normalMap ? ASTCENC_FLG_MAP_NORMAL : 0}; - astcBlockDimensions(params->blockDimension, - block_size_x, block_size_y, block_size_z); + astcBlockDimensions(params->blockDimension, block_size_x, block_size_y, block_size_z); quality = astcQuality(params->qualityLevel); profile = astcEncoderAction(*params, BDB); swizzle = astcSwizzle(*params); - if(params->perceptual) - flags |= ASTCENC_FLG_USE_PERCEPTUAL; + if (params->perceptual) flags |= ASTCENC_FLG_USE_PERCEPTUAL; - astcenc_config astc_config; + astcenc_config astc_config; astcenc_context *astc_context; - astcenc_error astc_error = astcenc_config_init(profile, - block_size_x, block_size_y, block_size_z, - quality, flags, - &astc_config); + astcenc_error astc_error = astcenc_config_init(profile, block_size_x, block_size_y, block_size_z, quality, flags, &astc_config); - if (astc_error != ASTCENC_SUCCESS) - return KTX_INVALID_OPERATION; + if (astc_error != ASTCENC_SUCCESS) return KTX_INVALID_OPERATION; - astc_error = astcenc_context_alloc(&astc_config, threadCount, - &astc_context); + astc_error = astcenc_context_alloc(&astc_config, threadCount, &astc_context); - if (astc_error != ASTCENC_SUCCESS) - return KTX_INVALID_OPERATION; + if (astc_error != ASTCENC_SUCCESS) return KTX_INVALID_OPERATION; // Walk in reverse on levels so we don't have to do this later assert(prototype->dataSize && "Prototype texture size not initialized.\n"); @@ -644,7 +769,7 @@ ktxTexture2_CompressAstcEx(ktxTexture2* This, ktxAstcParams* params) { return KTX_OUT_OF_MEMORY; } - uint8_t* buffer_out = prototype->pData; + uint8_t *buffer_out = prototype->pData; for (int32_t level = This->numLevels - 1; level >= 0; level--) { uint32_t width = MAX(1, This->baseWidth >> level); @@ -655,26 +780,20 @@ ktxTexture2_CompressAstcEx(ktxTexture2* This, ktxAstcParams* params) { ktx_uint32_t levelImages = 0; levelImages = This->numLayers * This->numFaces * depth; - levelImageSizeIn = ktxTexture_calcImageSize(ktxTexture(This), level, - KTX_FORMAT_VERSION_TWO); - levelImageSizeOut = ktxTexture_calcImageSize(ktxTexture(prototype), level, - KTX_FORMAT_VERSION_TWO); + levelImageSizeIn = ktxTexture_calcImageSize(ktxTexture(This), level, KTX_FORMAT_VERSION_TWO); + levelImageSizeOut = ktxTexture_calcImageSize(ktxTexture(prototype), level, KTX_FORMAT_VERSION_TWO); ktx_size_t offset = ktxTexture2_levelDataOffset(This, level); for (uint32_t image = 0; image < levelImages; image++) { astcenc_image *input_image = nullptr; if (num_components == 1) - input_image = unorm8x1ArrayToImage(This->pData + offset, - width, height); + input_image = unorm8x1ArrayToImage(This->pData + offset, width, height); else if (num_components == 2) - input_image = unorm8x2ArrayToImage(This->pData + offset, - width, height); + input_image = unorm8x2ArrayToImage(This->pData + offset, width, height); else if (num_components == 3) - input_image = unorm8x3ArrayToImage(This->pData + offset, - width, height); - else // assume (num_components == 4) - input_image = unorm8x4ArrayToImage(This->pData + offset, - width, height); + input_image = unorm8x3ArrayToImage(This->pData + offset, width, height); + else // assume (num_components == 4) + input_image = unorm8x4ArrayToImage(This->pData + offset, width, height); assert(input_image); @@ -697,8 +816,7 @@ ktxTexture2_CompressAstcEx(ktxTexture2* This, ktxAstcParams* params) { imageFree(input_image); if (work.error != ASTCENC_SUCCESS) { - std::cout << "ASTC compressor failed\n" << - astcenc_get_error_string(work.error) << std::endl; + std::cout << "ASTC compressor failed\n" << astcenc_get_error_string(work.error) << std::endl; astcenc_context_free(astc_context); return KTX_INVALID_OPERATION; @@ -709,30 +827,26 @@ ktxTexture2_CompressAstcEx(ktxTexture2* This, ktxAstcParams* params) { // We are done with astcencoder astcenc_context_free(astc_context); - assert(KHR_DFDVAL(prototype->pDfd+1, MODEL) == KHR_DF_MODEL_ASTC - && "Invalid dfd generated for ASTC image\n"); - assert((transfer == KHR_DF_TRANSFER_SRGB - ? KHR_DFDVAL(prototype->pDfd+1, PRIMARIES) == KHR_DF_PRIMARIES_SRGB - : true) && "Not a valid sRGB image\n"); + assert(KHR_DFDVAL(prototype->pDfd + 1, MODEL) == KHR_DF_MODEL_ASTC && "Invalid dfd generated for ASTC image\n"); + assert((transfer == KHR_DF_TRANSFER_SRGB ? KHR_DFDVAL(prototype->pDfd + 1, PRIMARIES) == KHR_DF_PRIMARIES_SRGB : true) && + "Not a valid sRGB image\n"); - // Fix up the current (This) texture - #undef DECLARE_PRIVATE - #undef DECLARE_PROTECTED - #define DECLARE_PRIVATE(n,t2) ktxTexture2_private& n = *(t2->_private) - #define DECLARE_PROTECTED(n,t2) ktxTexture_protected& n = *(t2->_protected) +// Fix up the current (This) texture +#undef DECLARE_PRIVATE +#undef DECLARE_PROTECTED +#define DECLARE_PRIVATE(n, t2) ktxTexture2_private &n = *(t2->_private) +#define DECLARE_PROTECTED(n, t2) ktxTexture_protected &n = *(t2->_protected) DECLARE_PROTECTED(thisPrtctd, This); DECLARE_PRIVATE(protoPriv, prototype); DECLARE_PROTECTED(protoPrtctd, prototype); - memcpy(&thisPrtctd._formatSize, &protoPrtctd._formatSize, - sizeof(ktxFormatSize)); + memcpy(&thisPrtctd._formatSize, &protoPrtctd._formatSize, sizeof(ktxFormatSize)); This->vkFormat = vkFormat; This->isCompressed = prototype->isCompressed; This->supercompressionScheme = KTX_SS_NONE; This->_private->_requiredLevelAlignment = protoPriv._requiredLevelAlignment; // Copy the levelIndex from the prototype to This. - memcpy(This->_private->_levelIndex, protoPriv._levelIndex, - This->numLevels * sizeof(ktxLevelIndexEntry)); + memcpy(This->_private->_levelIndex, protoPriv._levelIndex, This->numLevels * sizeof(ktxLevelIndexEntry)); // Move the DFD and data from the prototype to This. free(This->pDfd); This->pDfd = prototype->pDfd; @@ -783,23 +897,18 @@ ktxTexture2_CompressAstcEx(ktxTexture2* This, ktxAstcParams* params) { * @exception KTX_OUT_OF_MEMORY Not enough memory to carry out supercompression. */ extern "C" KTX_error_code -ktxTexture2_CompressAstc(ktxTexture2* This, ktx_uint32_t quality) { +ktxTexture2_CompressAstc(ktxTexture2 *This, ktx_uint32_t quality) { ktxAstcParams params = astcDefaultOptions(); - if (quality >= KTX_PACK_ASTC_QUALITY_LEVEL_FASTEST) - params.qualityLevel = KTX_PACK_ASTC_QUALITY_LEVEL_FASTEST; + if (quality >= KTX_PACK_ASTC_QUALITY_LEVEL_FASTEST) params.qualityLevel = KTX_PACK_ASTC_QUALITY_LEVEL_FASTEST; - if (quality >= KTX_PACK_ASTC_QUALITY_LEVEL_FAST) - params.qualityLevel = KTX_PACK_ASTC_QUALITY_LEVEL_FAST; + if (quality >= KTX_PACK_ASTC_QUALITY_LEVEL_FAST) params.qualityLevel = KTX_PACK_ASTC_QUALITY_LEVEL_FAST; - if (quality >= KTX_PACK_ASTC_QUALITY_LEVEL_MEDIUM) - params.qualityLevel = KTX_PACK_ASTC_QUALITY_LEVEL_MEDIUM; + if (quality >= KTX_PACK_ASTC_QUALITY_LEVEL_MEDIUM) params.qualityLevel = KTX_PACK_ASTC_QUALITY_LEVEL_MEDIUM; - if (quality >= KTX_PACK_ASTC_QUALITY_LEVEL_THOROUGH) - params.qualityLevel = KTX_PACK_ASTC_QUALITY_LEVEL_THOROUGH; + if (quality >= KTX_PACK_ASTC_QUALITY_LEVEL_THOROUGH) params.qualityLevel = KTX_PACK_ASTC_QUALITY_LEVEL_THOROUGH; - if (quality >= KTX_PACK_ASTC_QUALITY_LEVEL_EXHAUSTIVE) - params.qualityLevel = KTX_PACK_ASTC_QUALITY_LEVEL_EXHAUSTIVE; + if (quality >= KTX_PACK_ASTC_QUALITY_LEVEL_EXHAUSTIVE) params.qualityLevel = KTX_PACK_ASTC_QUALITY_LEVEL_EXHAUSTIVE; return ktxTexture2_CompressAstcEx(This, ¶ms); } diff --git a/lib/basis_encode.cpp b/lib/basis_encode.cpp index 9a00a9bca4..6ae40fb7b9 100644 --- a/lib/basis_encode.cpp +++ b/lib/basis_encode.cpp @@ -69,63 +69,57 @@ enum swizzle_e { ONE = 6, }; -typedef void -(* PFNBUCOPYCB)(uint8_t* rgbadst, uint8_t* rgbasrc, uint32_t src_len, - ktx_size_t image_size, swizzle_e swizzle[4]); +typedef void (*PFNBUCOPYCB)(uint8_t* rgbadst, uint8_t* rgbasrc, uint32_t src_len, ktx_size_t image_size, swizzle_e swizzle[4]); // All callbacks expect source images to have no row padding and expect // component size to be 8 bits. static void -copy_rgba_to_rgba(uint8_t* rgbadst, uint8_t* rgbasrc, uint32_t, - ktx_size_t image_size, swizzle_e[4]) -{ +copy_rgba_to_rgba(uint8_t* rgbadst, uint8_t* rgbasrc, uint32_t, ktx_size_t image_size, swizzle_e[4]) { memcpy(rgbadst, rgbasrc, image_size); } // Copy rgb to rgba. No swizzle. static void -copy_rgb_to_rgba(uint8_t* rgbadst, uint8_t* rgbsrc, uint32_t, - ktx_size_t image_size, swizzle_e[4]) -{ +copy_rgb_to_rgba(uint8_t* rgbadst, uint8_t* rgbsrc, uint32_t, ktx_size_t image_size, swizzle_e[4]) { for (ktx_size_t i = 0; i < image_size; i += 3) { memcpy(rgbadst, rgbsrc, 3); - rgbadst[3] = 0xff; // Convince Basis there is no alpha. - rgbadst += 4; rgbsrc += 3; + rgbadst[3] = 0xff; // Convince Basis there is no alpha. + rgbadst += 4; + rgbsrc += 3; } } // This is not static only so the unit tests can access it. void -swizzle_to_rgba(uint8_t* rgbadst, uint8_t* rgbasrc, uint32_t src_len, - ktx_size_t image_size, swizzle_e swizzle[4]) -{ +swizzle_to_rgba(uint8_t* rgbadst, uint8_t* rgbasrc, uint32_t src_len, ktx_size_t image_size, swizzle_e swizzle[4]) { for (ktx_size_t i = 0; i < image_size; i += src_len) { for (uint32_t c = 0; c < 4; c++) { switch (swizzle[c]) { - case R: + case R: rgbadst[c] = rgbasrc[0]; break; - case G: + case G: rgbadst[c] = rgbasrc[1]; break; - case B: + case B: rgbadst[c] = rgbasrc[2]; break; - case A: + case A: rgbadst[c] = rgbasrc[3]; break; - case ZERO: + case ZERO: rgbadst[c] = 0x00; break; - case ONE: + case ONE: rgbadst[c] = 0xff; break; - default: + default: assert(false); } } - rgbadst +=4; rgbasrc += src_len; + rgbadst += 4; + rgbasrc += src_len; } } @@ -233,24 +227,18 @@ swizzle_rg_to_rgb_a(uint8_t* rgbadst, uint8_t* rgsrc, ktx_size_t image_size, // not including an all 1's alpha channel, which would have been removed before // encoding and supercompression, by using hasAlpha. static KTX_error_code -ktxTexture2_rewriteDfd4BasisLzETC1S(ktxTexture2* This, - alpha_content_e alphaContent, - bool isLuminance, - swizzle_e swizzle[4]) -{ +ktxTexture2_rewriteDfd4BasisLzETC1S(ktxTexture2* This, alpha_content_e alphaContent, bool isLuminance, swizzle_e swizzle[4]) { uint32_t* cdfd = This->pDfd; uint32_t* cbdb = cdfd + 1; uint32_t newSampleCount = alphaContent != eNone ? 2 : 1; - uint32_t ndbSize = KHR_DF_WORD_SAMPLESTART - + newSampleCount * KHR_DF_WORD_SAMPLEWORDS; + uint32_t ndbSize = KHR_DF_WORD_SAMPLESTART + newSampleCount * KHR_DF_WORD_SAMPLEWORDS; ndbSize *= sizeof(uint32_t); uint32_t ndfdSize = ndbSize + 1 * sizeof(uint32_t); - uint32_t* ndfd = (uint32_t *)malloc(ndfdSize); + uint32_t* ndfd = (uint32_t*)malloc(ndfdSize); uint32_t* nbdb = ndfd + 1; - if (!ndfd) - return KTX_OUT_OF_MEMORY; + if (!ndfd) return KTX_OUT_OF_MEMORY; *ndfd = ndfdSize; KHR_DFDSETVAL(nbdb, VENDORID, KHR_DF_VENDORID_KHRONOS); @@ -262,8 +250,7 @@ ktxTexture2_rewriteDfd4BasisLzETC1S(ktxTexture2* This, KHR_DFDSETVAL(nbdb, TRANSFER, KHR_DFDVAL(cbdb, TRANSFER)); KHR_DFDSETVAL(nbdb, FLAGS, KHR_DFDVAL(cbdb, FLAGS)); - nbdb[KHR_DF_WORD_TEXELBLOCKDIMENSION0] = - 3 | (3 << KHR_DF_SHIFT_TEXELBLOCKDIMENSION1); + nbdb[KHR_DF_WORD_TEXELBLOCKDIMENSION0] = 3 | (3 << KHR_DF_SHIFT_TEXELBLOCKDIMENSION1); // Show it describes an unsized format. nbdb[KHR_DF_WORD_BYTESPLANE0] = 0; /* bytesPlane3..0 = 0 */ nbdb[KHR_DF_WORD_BYTESPLANE4] = 0; /* bytesPlane7..5 = 0 */ @@ -273,8 +260,7 @@ ktxTexture2_rewriteDfd4BasisLzETC1S(ktxTexture2* This, if (sample == 0) { bitOffset = 0; - if (!isLuminance && swizzle - && swizzle[0] == swizzle[1] && swizzle[1] == swizzle[2]) + if (!isLuminance && swizzle && swizzle[0] == swizzle[1] && swizzle[1] == swizzle[2]) channelId = KHR_DF_CHANNEL_ETC1S_RRR; else channelId = KHR_DF_CHANNEL_ETC1S_RGB; @@ -285,7 +271,7 @@ ktxTexture2_rewriteDfd4BasisLzETC1S(ktxTexture2* This, channelId = KHR_DF_CHANNEL_ETC1S_AAA; else if (alphaContent == eGreen) channelId = KHR_DF_CHANNEL_ETC1S_GGG; - else // This is just to quiet a compiler warning. + else // This is just to quiet a compiler warning. channelId = KHR_DF_CHANNEL_ETC1S_RGB; } KHR_DFDSETSVAL(nbdb, sample, CHANNELID, channelId); @@ -303,23 +289,17 @@ ktxTexture2_rewriteDfd4BasisLzETC1S(ktxTexture2* This, } static KTX_error_code -ktxTexture2_rewriteDfd4Uastc(ktxTexture2* This, - alpha_content_e alphaContent, - bool isLuminance, - swizzle_e swizzle[4]) -{ +ktxTexture2_rewriteDfd4Uastc(ktxTexture2* This, alpha_content_e alphaContent, bool isLuminance, swizzle_e swizzle[4]) { uint32_t* cdfd = This->pDfd; uint32_t* cbdb = cdfd + 1; - uint32_t ndbSize = KHR_DF_WORD_SAMPLESTART - + 1 * KHR_DF_WORD_SAMPLEWORDS; + uint32_t ndbSize = KHR_DF_WORD_SAMPLESTART + 1 * KHR_DF_WORD_SAMPLEWORDS; ndbSize *= sizeof(uint32_t); uint32_t ndfdSize = ndbSize + 1 * sizeof(uint32_t); - uint32_t* ndfd = (uint32_t *)malloc(ndfdSize); + uint32_t* ndfd = (uint32_t*)malloc(ndfdSize); uint32_t* nbdb = ndfd + 1; - if (!ndfd) - return KTX_OUT_OF_MEMORY; + if (!ndfd) return KTX_OUT_OF_MEMORY; *ndfd = ndfdSize; KHR_DFDSETVAL(nbdb, VENDORID, KHR_DF_VENDORID_KHRONOS); @@ -331,10 +311,9 @@ ktxTexture2_rewriteDfd4Uastc(ktxTexture2* This, KHR_DFDSETVAL(nbdb, TRANSFER, KHR_DFDVAL(cbdb, TRANSFER)); KHR_DFDSETVAL(nbdb, FLAGS, KHR_DFDVAL(cbdb, FLAGS)); - nbdb[KHR_DF_WORD_TEXELBLOCKDIMENSION0] = - 3 | (3 << KHR_DF_SHIFT_TEXELBLOCKDIMENSION1); + nbdb[KHR_DF_WORD_TEXELBLOCKDIMENSION0] = 3 | (3 << KHR_DF_SHIFT_TEXELBLOCKDIMENSION1); nbdb[KHR_DF_WORD_BYTESPLANE0] = 16; /* bytesPlane0 = 16, bytesPlane3..1 = 0 */ - nbdb[KHR_DF_WORD_BYTESPLANE4] = 0; /* bytesPlane7..5 = 0 */ + nbdb[KHR_DF_WORD_BYTESPLANE4] = 0; /* bytesPlane7..5 = 0 */ // Set the data for our single sample uint16_t channelId; @@ -344,8 +323,7 @@ ktxTexture2_rewriteDfd4Uastc(ktxTexture2* This, channelId = KHR_DF_CHANNEL_UASTC_RRRG; } else if (swizzle && swizzle[2] == 0 && swizzle[3] == 1) { channelId = KHR_DF_CHANNEL_UASTC_RG; - } else if (!isLuminance && swizzle - && swizzle[0] == swizzle[1] && swizzle[1] == swizzle[2]) { + } else if (!isLuminance && swizzle && swizzle[0] == swizzle[1] && swizzle[1] == swizzle[2]) { channelId = KHR_DF_CHANNEL_UASTC_RRR; } else { channelId = KHR_DF_CHANNEL_UASTC_RGB; @@ -406,57 +384,49 @@ static bool basisuEncoderInitialized = false; * @exception KTX_OUT_OF_MEMORY Not enough memory to carry out compression. */ extern "C" KTX_error_code -ktxTexture2_CompressBasisEx(ktxTexture2* This, ktxBasisParams* params) -{ +ktxTexture2_CompressBasisEx(ktxTexture2* This, ktxBasisParams* params) { KTX_error_code result; - if (!params) - return KTX_INVALID_VALUE; + if (!params) return KTX_INVALID_VALUE; - if (params->structSize != sizeof(struct ktxBasisParams)) - return KTX_INVALID_VALUE; + if (params->structSize != sizeof(struct ktxBasisParams)) return KTX_INVALID_VALUE; - if (This->supercompressionScheme != KTX_SS_NONE) - return KTX_INVALID_OPERATION; // Can't apply multiple schemes. + if (This->supercompressionScheme != KTX_SS_NONE) return KTX_INVALID_OPERATION; // Can't apply multiple schemes. if (This->isCompressed) return KTX_INVALID_OPERATION; // Only non-block compressed formats // can be encoded into a Basis format. - if (This->_protected->_formatSize.flags & KTX_FORMAT_SIZE_PACKED_BIT) - return KTX_INVALID_OPERATION; + if (This->_protected->_formatSize.flags & KTX_FORMAT_SIZE_PACKED_BIT) return KTX_INVALID_OPERATION; // Basic descriptor block begins after the total size field. - const uint32_t* BDB = This->pDfd+1; + const uint32_t* BDB = This->pDfd + 1; uint32_t num_components, component_size; getDFDComponentInfoUnpacked(This->pDfd, &num_components, &component_size); - if (component_size != 1) - return KTX_INVALID_OPERATION; // Basis must have 8-bit components. + if (component_size != 1) return KTX_INVALID_OPERATION; // Basis must have 8-bit components. - if (num_components == 1 && params->normalMap) - return KTX_INVALID_OPERATION; // Not enough components. + if (num_components == 1 && params->normalMap) return KTX_INVALID_OPERATION; // Not enough components. if (This->pData == NULL) { result = ktxTexture2_LoadImageData(This, NULL, 0); - if (result != KTX_SUCCESS) - return result; + if (result != KTX_SUCCESS) return result; } if (!basisuEncoderInitialized) { // force_serialization uses a mutex to serialize when multiple command // queues per thread are used. We shouldn't need to worry about this. // How to decide whether to use OpenCL? - basisu_encoder_init((BASISU_SUPPORT_OPENCL ? true : false)/*use_opencl*/ + basisu_encoder_init((BASISU_SUPPORT_OPENCL ? true : false) /*use_opencl*/ /*opencl_force_serialization = false*/); - //atexit(basisu_encoder_deinit); + // atexit(basisu_encoder_deinit); basisuEncoderInitialized = true; } basis_compressor_params cparams; - cparams.m_read_source_images = false; // Don't read from source files. - cparams.m_write_output_basis_files = false; // Don't write output files. + cparams.m_read_source_images = false; // Don't read from source files. + cparams.m_write_output_basis_files = false; // Don't write output files. cparams.m_status_output = params->verbose; // @@ -482,10 +452,10 @@ ktxTexture2_CompressBasisEx(ktxTexture2* This, ktxBasisParams* params) // Since we have to copy the data into the vector image anyway do the // separation here to avoid another loop over the image inside // basis_compressor. - swizzle_e rg_to_rgba_mapping_etc1s[4] = { R, R, R, G }; - swizzle_e rg_to_rgba_mapping_uastc[4] = { R, G, ZERO, ONE }; - swizzle_e normal_map_mapping[4] = { R, R, R, G }; - swizzle_e r_to_rgba_mapping[4] = { R, R, R, ONE }; + swizzle_e rg_to_rgba_mapping_etc1s[4] = {R, R, R, G}; + swizzle_e rg_to_rgba_mapping_uastc[4] = {R, G, ZERO, ONE}; + swizzle_e normal_map_mapping[4] = {R, R, R, G}; + swizzle_e r_to_rgba_mapping[4] = {R, R, R, ONE}; swizzle_e meta_mapping[4] = {}; // All the above declarations need to stay here so they remain in scope // until after the pixel copy loop as comp_mapping will ultimately point @@ -502,14 +472,12 @@ ktxTexture2_CompressBasisEx(ktxTexture2* This, ktxBasisParams* params) } ktxHashListEntry* swizzleEntry; - result = ktxHashList_FindEntry(&This->kvDataHead, KTX_SWIZZLE_KEY, - &swizzleEntry); + result = ktxHashList_FindEntry(&This->kvDataHead, KTX_SWIZZLE_KEY, &swizzleEntry); if (result == KTX_SUCCESS) { ktx_uint32_t swizzleLen = 0; char* swizzleStr = nullptr; - ktxHashListEntry_GetValue(swizzleEntry, - &swizzleLen, (void**)&swizzleStr); + ktxHashListEntry_GetValue(swizzleEntry, &swizzleLen, (void**)&swizzleStr); // Remove the swizzle as it is no longer needed. ktxHashList_DeleteEntry(&This->kvDataHead, swizzleEntry); // Do it this way in case there is no NUL terminator. @@ -538,17 +506,28 @@ ktxTexture2_CompressBasisEx(ktxTexture2* This, ktxBasisParams* params) } else { // Only set comp_mapping for cases we can't shortcut. // If num_components < 3 we always swizzle so no shortcut there. - if (num_components < 3 - || (num_components == 3 && swizzleString.compare("rgb1")) - || (num_components == 4 && swizzleString.compare("rgba"))) { + if (num_components < 3 || (num_components == 3 && swizzleString.compare("rgb1")) || + (num_components == 4 && swizzleString.compare("rgba"))) { for (int i = 0; i < 4; i++) { switch (swizzleString[i]) { - case 'r': meta_mapping[i] = R; break; - case 'g': meta_mapping[i] = G; break; - case 'b': meta_mapping[i] = B; break; - case 'a': meta_mapping[i] = A; break; - case '0': meta_mapping[i] = ZERO; break; - case '1': meta_mapping[i] = ONE; break; + case 'r': + meta_mapping[i] = R; + break; + case 'g': + meta_mapping[i] = G; + break; + case 'b': + meta_mapping[i] = B; + break; + case 'a': + meta_mapping[i] = A; + break; + case '0': + meta_mapping[i] = ZERO; + break; + case '1': + meta_mapping[i] = ONE; + break; } } comp_mapping = meta_mapping; @@ -559,8 +538,7 @@ ktxTexture2_CompressBasisEx(ktxTexture2* This, ktxBasisParams* params) // luminance texture. Set isLuminance so we can later distinguish // this from the identical swizzle used for normal maps. // cases for ETC1S. - if (meta_mapping[0] == meta_mapping[1] - && meta_mapping[1] == meta_mapping[2]) { + if (meta_mapping[0] == meta_mapping[1] && meta_mapping[1] == meta_mapping[2]) { // Same component in r, g & b isLuminance = true; } @@ -572,15 +550,20 @@ ktxTexture2_CompressBasisEx(ktxTexture2* This, ktxBasisParams* params) } } - PFNBUCOPYCB copycb = copy_rgba_to_rgba; // Initialization is just to keep - // compilers happy + PFNBUCOPYCB copycb = copy_rgba_to_rgba; // Initialization is just to keep + // compilers happy if (comp_mapping) { copycb = swizzle_to_rgba; } else { switch (num_components) { - case 4: copycb = copy_rgba_to_rgba; break; - case 3: copycb = copy_rgb_to_rgba; break; - default: assert(false); + case 4: + copycb = copy_rgba_to_rgba; + break; + case 3: + copycb = copy_rgb_to_rgba; + break; + default: + assert(false); } } @@ -597,15 +580,13 @@ ktxTexture2_CompressBasisEx(ktxTexture2* This, ktxBasisParams* params) ktx_size_t offset; ktxTexture2_GetImageOffset(This, level, layer, slice, &offset); iit->resize(width, height); - copycb((uint8_t*)iit->get_ptr(), This->pData + offset, - num_components, image_size, - comp_mapping); + copycb((uint8_t*)iit->get_ptr(), This->pData + offset, num_components, image_size, comp_mapping); ++iit; } } } - free(This->pData); // No longer needed. Reduce memory footprint. + free(This->pData); // No longer needed. Reduce memory footprint. This->pData = NULL; This->dataSize = 0; @@ -614,15 +595,13 @@ ktxTexture2_CompressBasisEx(ktxTexture2* This, ktxBasisParams* params) // ktx_uint32_t threadCount = params->threadCount; - if (threadCount < 1) - threadCount = 1; + if (threadCount < 1) threadCount = 1; job_pool jpool(threadCount); cparams.m_pJob_pool = &jpool; #if BASISU_SUPPORT_SSE bool prevSSESupport = g_cpu_supports_sse41; - if (params->noSSE) - g_cpu_supports_sse41 = false; + if (params->noSSE) g_cpu_supports_sse41 = false; #endif ktx_uint32_t transfer = KHR_DFDVAL(BDB, TRANSFER); @@ -631,7 +610,7 @@ ktxTexture2_CompressBasisEx(ktxTexture2* This, ktxBasisParams* params) else cparams.m_perceptual = false; - cparams.m_mip_gen = false; // We provide the mip levels. + cparams.m_mip_gen = false; // We provide the mip levels. cparams.m_uastc = params->uastc; if (params->uastc) { @@ -639,24 +618,19 @@ ktxTexture2_CompressBasisEx(ktxTexture2* This, ktxBasisParams* params) if (params->uastcRDO) { cparams.m_rdo_uastc = true; if (params->uastcRDOQualityScalar > 0.0f) { - cparams.m_rdo_uastc_quality_scalar = - params->uastcRDOQualityScalar; + cparams.m_rdo_uastc_quality_scalar = params->uastcRDOQualityScalar; } if (params->uastcRDODictSize > 0) { cparams.m_rdo_uastc_dict_size = params->uastcRDODictSize; } if (params->uastcRDOMaxSmoothBlockErrorScale > 0) { - cparams.m_rdo_uastc_max_smooth_block_error_scale = - params->uastcRDOMaxSmoothBlockErrorScale; + cparams.m_rdo_uastc_max_smooth_block_error_scale = params->uastcRDOMaxSmoothBlockErrorScale; } if (params->uastcRDOMaxSmoothBlockStdDev > 0) { - cparams.m_rdo_uastc_smooth_block_max_std_dev = - params->uastcRDOMaxSmoothBlockStdDev; + cparams.m_rdo_uastc_smooth_block_max_std_dev = params->uastcRDOMaxSmoothBlockStdDev; } - cparams.m_rdo_uastc_favor_simpler_modes_in_rdo_mode = - !params->uastcRDODontFavorSimplerModes; - cparams.m_rdo_uastc_favor_simpler_modes_in_rdo_mode = - !params->uastcRDONoMultithreading; + cparams.m_rdo_uastc_favor_simpler_modes_in_rdo_mode = !params->uastcRDODontFavorSimplerModes; + cparams.m_rdo_uastc_favor_simpler_modes_in_rdo_mode = !params->uastcRDONoMultithreading; } } else { // ETC1S-related params. @@ -697,10 +671,8 @@ ktxTexture2_CompressBasisEx(ktxTexture2* This, ktxBasisParams* params) cparams.m_quality_level = 128; } - if (params->endpointRDOThreshold > 0) - cparams.m_endpoint_rdo_thresh = params->endpointRDOThreshold; - if (params->selectorRDOThreshold > 0) - cparams.m_selector_rdo_thresh = params->selectorRDOThreshold; + if (params->endpointRDOThreshold > 0) cparams.m_endpoint_rdo_thresh = params->endpointRDOThreshold; + if (params->selectorRDOThreshold > 0) cparams.m_selector_rdo_thresh = params->selectorRDOThreshold; if (params->normalMap) { cparams.m_no_endpoint_rdo = true; @@ -716,14 +688,14 @@ ktxTexture2_CompressBasisEx(ktxTexture2* This, ktxBasisParams* params) // ktxTexture is consistent. // Output debug information during compression - //cparams.m_debug = true; + // cparams.m_debug = true; // m_debug_images is pretty slow - //cparams.m_debug_images = true; + // cparams.m_debug_images = true; // Split the R channel to RGB and the G channel to alpha. We do the // seperation in this func (see above) so leave this at its default, false. - //bool_param m_seperate_rg_to_color_alpha; + // bool_param m_seperate_rg_to_color_alpha; // m_userdata0, m_userdata1 go directly into the .basis file header. // No need to set. @@ -760,13 +732,12 @@ ktxTexture2_CompressBasisEx(ktxTexture2* This, ktxBasisParams* params) // As we don't use it, file reading support has been removed from the // BasisU code. Ensure we don't accidentally try to use it. - assert(cparams.m_read_source_images == false - && "m_read_source_images must be false"); + assert(cparams.m_read_source_images == false && "m_read_source_images must be false"); // init() only returns false if told to read source image files and the // list of files is empty. (void)c.init(cparams); - //enable_debug_printf(true); + // enable_debug_printf(true); basis_compressor::error_code ec = c.process(); @@ -833,8 +804,7 @@ ktxTexture2_CompressBasisEx(ktxTexture2* This, ktxBasisParams* params) uint32_t image_data_size = 0; ktxTexture2_private& priv = *This->_private; uint32_t base_offset = bfh.m_slice_desc_file_ofs; - const basis_slice_desc* slice - = reinterpret_cast(&bf[base_offset]); + const basis_slice_desc* slice = reinterpret_cast(&bf[base_offset]); std::vector level_file_offsets(This->numLevels); if (params->uastc) { @@ -857,10 +827,8 @@ ktxTexture2_CompressBasisEx(ktxTexture2* This, ktxBasisParams* params) // uint32_t image_desc_size = sizeof(ktxBasisLzEtc1sImageDesc); - bgd_size = sizeof(ktxBasisLzGlobalHeader) - + image_desc_size * num_images - + bfh.m_endpoint_cb_file_size + bfh.m_selector_cb_file_size - + bfh.m_tables_file_size; + bgd_size = sizeof(ktxBasisLzGlobalHeader) + image_desc_size * num_images + bfh.m_endpoint_cb_file_size + + bfh.m_selector_cb_file_size + bfh.m_tables_file_size; bgd = new ktx_uint8_t[bgd_size]; ktxBasisLzGlobalHeader& bgdh = *reinterpret_cast(bgd); bgdh.endpointCount = (uint16_t)bfh.m_total_endpoints; @@ -897,20 +865,16 @@ ktxTexture2_CompressBasisEx(ktxTexture2* This, ktxBasisParams* params) assert(!(slice->m_flags & cSliceDescFlagsHasAlpha)); level_file_offsets[level] = slice->m_file_ofs; for (uint32_t layer = 0; layer < This->numLayers; layer++) { - uint32_t faceSlices = This->numFaces == 1 ? depth - : This->numFaces; + uint32_t faceSlices = This->numFaces == 1 ? depth : This->numFaces; for (uint32_t faceSlice = 0; faceSlice < faceSlices; faceSlice++) { level_byte_length += slice->m_file_size; - kimages[image].rgbSliceByteOffset = slice->m_file_ofs - - level_file_offsets[level]; + kimages[image].rgbSliceByteOffset = slice->m_file_ofs - level_file_offsets[level]; kimages[image].rgbSliceByteLength = slice->m_file_size; if (bfh.m_flags & cBASISHeaderFlagHasAlphaSlices) { slice++; level_byte_length += slice->m_file_size; - kimages[image].alphaSliceByteOffset = - slice->m_file_ofs - level_file_offsets[level]; - kimages[image].alphaSliceByteLength = - slice->m_file_size; + kimages[image].alphaSliceByteOffset = slice->m_file_ofs - level_file_offsets[level]; + kimages[image].alphaSliceByteLength = slice->m_file_size; } else { kimages[image].alphaSliceByteOffset = 0; kimages[image].alphaSliceByteLength = 0; @@ -918,11 +882,9 @@ ktxTexture2_CompressBasisEx(ktxTexture2* This, ktxBasisParams* params) // Set the PFrame flag, inverse of the .basis IFrame flag. if (This->isVideo) { // Extract FrameIsIFrame - kimages[image].imageFlags = - (slice->m_flags & ~cSliceDescFlagsHasAlpha); + kimages[image].imageFlags = (slice->m_flags & ~cSliceDescFlagsHasAlpha); // Set our flag to the inverse. - kimages[image].imageFlags ^= - cSliceDescFlagsFrameIsIFrame; + kimages[image].imageFlags ^= cSliceDescFlagsFrameIsIFrame; } else { kimages[image].imageFlags = 0; } @@ -944,19 +906,13 @@ ktxTexture2_CompressBasisEx(ktxTexture2* This, ktxBasisParams* params) // byte where the endpoints, etc. must be written. uint8_t* dstptr = reinterpret_cast(&kimages[image]); // Copy the endpoints ... - memcpy(dstptr, - &bf[bfh.m_endpoint_cb_file_ofs], - bfh.m_endpoint_cb_file_size); + memcpy(dstptr, &bf[bfh.m_endpoint_cb_file_ofs], bfh.m_endpoint_cb_file_size); dstptr += bgdh.endpointsByteLength; // selectors ... - memcpy(dstptr, - &bf[bfh.m_selector_cb_file_ofs], - bfh.m_selector_cb_file_size); + memcpy(dstptr, &bf[bfh.m_selector_cb_file_ofs], bfh.m_selector_cb_file_size); dstptr += bgdh.selectorsByteLength; // and the huffman tables. - memcpy(dstptr, - &bf[bfh.m_tables_file_ofs], - bfh.m_tables_file_size); + memcpy(dstptr, &bf[bfh.m_tables_file_ofs], bfh.m_tables_file_size); assert((size_t)(dstptr + bgdh.tablesByteLength - bgd) <= bgd_size); @@ -987,7 +943,7 @@ ktxTexture2_CompressBasisEx(ktxTexture2* This, ktxBasisParams* params) alphaContent = eNone; } - new_data = (uint8_t*) malloc(image_data_size); + new_data = (uint8_t*)malloc(image_data_size); if (!new_data) { result = KTX_OUT_OF_MEMORY; goto cleanup; @@ -996,9 +952,7 @@ ktxTexture2_CompressBasisEx(ktxTexture2* This, ktxBasisParams* params) // Delayed modifying texture until here so it's after points of // possible failure. if (params->uastc) { - result = ktxTexture2_rewriteDfd4Uastc(This, alphaContent, - isLuminance, - comp_mapping); + result = ktxTexture2_rewriteDfd4Uastc(This, alphaContent, isLuminance, comp_mapping); if (result != KTX_SUCCESS) goto cleanup; // Reflect this in the formatSize @@ -1006,9 +960,7 @@ ktxTexture2_CompressBasisEx(ktxTexture2* This, ktxBasisParams* params) // and the requiredLevelAlignment. priv._requiredLevelAlignment = 4 * 4; } else { - result = ktxTexture2_rewriteDfd4BasisLzETC1S(This, alphaContent, - isLuminance, - comp_mapping); + result = ktxTexture2_rewriteDfd4BasisLzETC1S(This, alphaContent, isLuminance, comp_mapping); if (result != KTX_SUCCESS) goto cleanup; This->supercompressionScheme = KTX_SS_BASIS_LZ; @@ -1032,11 +984,8 @@ ktxTexture2_CompressBasisEx(ktxTexture2* This, ktxBasisParams* params) for (int32_t level = This->numLevels - 1; level >= 0; level--) { priv._levelIndex[level].byteOffset = level_offset; // byteLength was set in loop above - memcpy(This->pData + level_offset, - &bf[level_file_offsets[level]], - priv._levelIndex[level].byteLength); - level_offset += _KTX_PADN(priv._requiredLevelAlignment, - priv._levelIndex[level].byteLength); + memcpy(This->pData + level_offset, &bf[level_file_offsets[level]], priv._levelIndex[level].byteLength); + level_offset += _KTX_PADN(priv._requiredLevelAlignment, priv._levelIndex[level].byteLength); } return KTX_SUCCESS; @@ -1051,8 +1000,7 @@ ktxTexture2_CompressBasisEx(ktxTexture2* This, ktxBasisParams* params) return result; } -extern "C" KTX_API const ktx_uint32_t KTX_ETC1S_DEFAULT_COMPRESSION_LEVEL - = BASISU_DEFAULT_COMPRESSION_LEVEL; +extern "C" KTX_API const ktx_uint32_t KTX_ETC1S_DEFAULT_COMPRESSION_LEVEL = BASISU_DEFAULT_COMPRESSION_LEVEL; /** * @memberof ktxTexture2 @@ -1085,8 +1033,7 @@ extern "C" KTX_API const ktx_uint32_t KTX_ETC1S_DEFAULT_COMPRESSION_LEVEL * @exception KTX_OUT_OF_MEMORY Not enough memory to carry out supercompression. */ extern "C" KTX_error_code -ktxTexture2_CompressBasis(ktxTexture2* This, ktx_uint32_t quality) -{ +ktxTexture2_CompressBasis(ktxTexture2* This, ktx_uint32_t quality) { ktxBasisParams params = {}; params.structSize = sizeof(params); params.threadCount = 1; diff --git a/lib/basis_sgd.h b/lib/basis_sgd.h index 15804e8d26..dbfad81c0d 100644 --- a/lib/basis_sgd.h +++ b/lib/basis_sgd.h @@ -54,16 +54,14 @@ typedef struct ktxBasisLzEtc1sImageDesc { uint32_t alphaSliceByteLength; } ktxBasisLzEtc1sImageDesc; -#define BGD_ETC1S_IMAGE_DESCS(bgd) \ - reinterpret_cast(bgd + sizeof(ktxBasisLzGlobalHeader)) +#define BGD_ETC1S_IMAGE_DESCS(bgd) reinterpret_cast(bgd + sizeof(ktxBasisLzGlobalHeader)) // The are followed in the global data by these ... // uint8_t[endpointsByteLength] endpointsData; // uint8_t[selectorsByteLength] selectorsData; // uint8_t[tablesByteLength] tablesData; -#define BGD_ENDPOINTS_ADDR(bgd, imageCount) \ - (bgd + sizeof(ktxBasisLzGlobalHeader) + sizeof(ktxBasisLzEtc1sImageDesc) * imageCount) +#define BGD_ENDPOINTS_ADDR(bgd, imageCount) (bgd + sizeof(ktxBasisLzGlobalHeader) + sizeof(ktxBasisLzEtc1sImageDesc) * imageCount) #define BGD_SELECTORS_ADDR(bgd, bgdh, imageCount) (BGD_ENDPOINTS_ADDR(bgd, imageCount) + bgdh.endpointsByteLength) @@ -72,11 +70,7 @@ typedef struct ktxBasisLzEtc1sImageDesc { #define BGD_EXTENDED_ADDR(bgd, bgdh, imageCount) (BGD_TABLES_ADDR(bgd, bgdh, imageCount) + bgdh.tablesByteLength) // Just because this is a convenient place to put it for basis_{en,trans}code. -enum alpha_content_e { - eNone, - eAlpha, - eGreen -}; +enum alpha_content_e { eNone, eAlpha, eGreen }; #ifdef __cplusplus } diff --git a/lib/basis_transcode.cpp b/lib/basis_transcode.cpp index ca68545e4a..180793ddce 100644 --- a/lib/basis_transcode.cpp +++ b/lib/basis_transcode.cpp @@ -35,28 +35,26 @@ #undef DECLARE_PRIVATE #undef DECLARE_PROTECTED -#define DECLARE_PRIVATE(n,t2) ktxTexture2_private& n = *(t2->_private) -#define DECLARE_PROTECTED(n,t2) ktxTexture_protected& n = *(t2->_protected) +#define DECLARE_PRIVATE(n, t2) ktxTexture2_private& n = *(t2->_private) +#define DECLARE_PROTECTED(n, t2) ktxTexture_protected& n = *(t2->_protected) using namespace basisu; using namespace basist; -inline bool isPow2(uint32_t x) { return x && ((x & (x - 1U)) == 0U); } +inline bool +isPow2(uint32_t x) { + return x && ((x & (x - 1U)) == 0U); +} -inline bool isPow2(uint64_t x) { return x && ((x & (x - 1U)) == 0U); } +inline bool +isPow2(uint64_t x) { + return x && ((x & (x - 1U)) == 0U); +} -KTX_error_code -ktxTexture2_transcodeLzEtc1s(ktxTexture2* This, - alpha_content_e alphaContent, - ktxTexture2* prototype, - ktx_transcode_fmt_e outputFormat, - ktx_transcode_flags transcodeFlags); -KTX_error_code -ktxTexture2_transcodeUastc(ktxTexture2* This, - alpha_content_e alphaContent, - ktxTexture2* prototype, - ktx_transcode_fmt_e outputFormat, - ktx_transcode_flags transcodeFlags); +KTX_error_code ktxTexture2_transcodeLzEtc1s(ktxTexture2* This, alpha_content_e alphaContent, ktxTexture2* prototype, + ktx_transcode_fmt_e outputFormat, ktx_transcode_flags transcodeFlags); +KTX_error_code ktxTexture2_transcodeUastc(ktxTexture2* This, alpha_content_e alphaContent, ktxTexture2* prototype, + ktx_transcode_fmt_e outputFormat, ktx_transcode_flags transcodeFlags); /** * @memberof ktxTexture2 @@ -130,36 +128,30 @@ ktxTexture2_transcodeUastc(ktxTexture2* This, * included in the library being used. * @exception KTX_OUT_OF_MEMORY Not enough memory to carry out transcoding. */ - KTX_error_code - ktxTexture2_TranscodeBasis(ktxTexture2* This, - ktx_transcode_fmt_e outputFormat, - ktx_transcode_flags transcodeFlags) -{ +KTX_error_code +ktxTexture2_TranscodeBasis(ktxTexture2* This, ktx_transcode_fmt_e outputFormat, ktx_transcode_flags transcodeFlags) { uint32_t* BDB = This->pDfd + 1; khr_df_model_e colorModel = (khr_df_model_e)KHR_DFDVAL(BDB, MODEL); if (colorModel != KHR_DF_MODEL_UASTC // Constructor has checked color model matches BASIS_LZ. - && This->supercompressionScheme != KTX_SS_BASIS_LZ) - { - return KTX_INVALID_OPERATION; // Not in a transcodable format. + && This->supercompressionScheme != KTX_SS_BASIS_LZ) { + return KTX_INVALID_OPERATION; // Not in a transcodable format. } DECLARE_PRIVATE(priv, This); if (This->supercompressionScheme == KTX_SS_BASIS_LZ) { - if (!priv._supercompressionGlobalData || priv._sgdByteLength == 0) - return KTX_INVALID_OPERATION; + if (!priv._supercompressionGlobalData || priv._sgdByteLength == 0) return KTX_INVALID_OPERATION; } if (transcodeFlags & KTX_TF_PVRTC_DECODE_TO_NEXT_POW2) { - debug_printf("ktxTexture_TranscodeBasis: KTX_TF_PVRTC_DECODE_TO_NEXT_POW2 currently unsupported\n"); - return KTX_UNSUPPORTED_FEATURE; + debug_printf("ktxTexture_TranscodeBasis: KTX_TF_PVRTC_DECODE_TO_NEXT_POW2 currently unsupported\n"); + return KTX_UNSUPPORTED_FEATURE; } - if (outputFormat == KTX_TTF_PVRTC1_4_RGB - || outputFormat == KTX_TTF_PVRTC1_4_RGBA) { - if ((!isPow2(This->baseWidth)) || (!isPow2(This->baseHeight))) { - debug_printf("ktxTexture_TranscodeBasis: PVRTC1 only supports power of 2 dimensions\n"); - return KTX_INVALID_OPERATION; + if (outputFormat == KTX_TTF_PVRTC1_4_RGB || outputFormat == KTX_TTF_PVRTC1_4_RGBA) { + if ((!isPow2(This->baseWidth)) || (!isPow2(This->baseHeight))) { + debug_printf("ktxTexture_TranscodeBasis: PVRTC1 only supports power of 2 dimensions\n"); + return KTX_INVALID_OPERATION; } } @@ -170,7 +162,7 @@ ktxTexture2_transcodeUastc(ktxTexture2* This, uint32_t channelId = KHR_DFDSVAL(BDB, 1, CHANNELID); if (channelId == KHR_DF_CHANNEL_ETC1S_AAA) { alphaContent = eAlpha; - } else if (channelId == KHR_DF_CHANNEL_ETC1S_GGG){ + } else if (channelId == KHR_DF_CHANNEL_ETC1S_GGG) { alphaContent = eGreen; } else { return KTX_FILE_DATA_ERROR; @@ -188,90 +180,77 @@ ktxTexture2_transcodeUastc(ktxTexture2* This, // Do some format mapping. switch (outputFormat) { - case KTX_TTF_BC1_OR_3: - outputFormat = alphaContent != eNone ? KTX_TTF_BC3_RGBA - : KTX_TTF_BC1_RGB; + case KTX_TTF_BC1_OR_3: + outputFormat = alphaContent != eNone ? KTX_TTF_BC3_RGBA : KTX_TTF_BC1_RGB; break; - case KTX_TTF_ETC: - outputFormat = alphaContent != eNone ? KTX_TTF_ETC2_RGBA - : KTX_TTF_ETC1_RGB; + case KTX_TTF_ETC: + outputFormat = alphaContent != eNone ? KTX_TTF_ETC2_RGBA : KTX_TTF_ETC1_RGB; break; - case KTX_TTF_PVRTC1_4_RGBA: + case KTX_TTF_PVRTC1_4_RGBA: // This transcoder does not write opaque alpha blocks. - outputFormat = alphaContent != eNone ? KTX_TTF_PVRTC1_4_RGBA - : KTX_TTF_PVRTC1_4_RGB; + outputFormat = alphaContent != eNone ? KTX_TTF_PVRTC1_4_RGBA : KTX_TTF_PVRTC1_4_RGB; break; - case KTX_TTF_PVRTC2_4_RGBA: + case KTX_TTF_PVRTC2_4_RGBA: // This transcoder does not write opaque alpha blocks. - outputFormat = alphaContent != eNone ? KTX_TTF_PVRTC2_4_RGBA - : KTX_TTF_PVRTC2_4_RGB; + outputFormat = alphaContent != eNone ? KTX_TTF_PVRTC2_4_RGBA : KTX_TTF_PVRTC2_4_RGB; break; - default: + default: /*NOP*/; } switch (outputFormat) { - case KTX_TTF_ETC1_RGB: - vkFormat = srgb ? VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK - : VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK; + case KTX_TTF_ETC1_RGB: + vkFormat = srgb ? VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK : VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK; break; - case KTX_TTF_ETC2_RGBA: - vkFormat = srgb ? VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK - : VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK; + case KTX_TTF_ETC2_RGBA: + vkFormat = srgb ? VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK : VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK; break; - case KTX_TTF_ETC2_EAC_R11: + case KTX_TTF_ETC2_EAC_R11: vkFormat = VK_FORMAT_EAC_R11_UNORM_BLOCK; break; - case KTX_TTF_ETC2_EAC_RG11: + case KTX_TTF_ETC2_EAC_RG11: vkFormat = VK_FORMAT_EAC_R11G11_UNORM_BLOCK; break; - case KTX_TTF_BC1_RGB: + case KTX_TTF_BC1_RGB: // Transcoding doesn't support BC1 alpha. - vkFormat = srgb ? VK_FORMAT_BC1_RGB_SRGB_BLOCK - : VK_FORMAT_BC1_RGB_UNORM_BLOCK; + vkFormat = srgb ? VK_FORMAT_BC1_RGB_SRGB_BLOCK : VK_FORMAT_BC1_RGB_UNORM_BLOCK; break; - case KTX_TTF_BC3_RGBA: - vkFormat = srgb ? VK_FORMAT_BC3_SRGB_BLOCK - : VK_FORMAT_BC3_UNORM_BLOCK; + case KTX_TTF_BC3_RGBA: + vkFormat = srgb ? VK_FORMAT_BC3_SRGB_BLOCK : VK_FORMAT_BC3_UNORM_BLOCK; break; - case KTX_TTF_BC4_R: + case KTX_TTF_BC4_R: vkFormat = VK_FORMAT_BC4_UNORM_BLOCK; break; - case KTX_TTF_BC5_RG: + case KTX_TTF_BC5_RG: vkFormat = VK_FORMAT_BC5_UNORM_BLOCK; break; - case KTX_TTF_PVRTC1_4_RGB: - case KTX_TTF_PVRTC1_4_RGBA: - vkFormat = srgb ? VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG - : VK_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG; + case KTX_TTF_PVRTC1_4_RGB: + case KTX_TTF_PVRTC1_4_RGBA: + vkFormat = srgb ? VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG : VK_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG; break; - case KTX_TTF_PVRTC2_4_RGB: - case KTX_TTF_PVRTC2_4_RGBA: - vkFormat = srgb ? VK_FORMAT_PVRTC2_4BPP_SRGB_BLOCK_IMG - : VK_FORMAT_PVRTC2_4BPP_UNORM_BLOCK_IMG; + case KTX_TTF_PVRTC2_4_RGB: + case KTX_TTF_PVRTC2_4_RGBA: + vkFormat = srgb ? VK_FORMAT_PVRTC2_4BPP_SRGB_BLOCK_IMG : VK_FORMAT_PVRTC2_4BPP_UNORM_BLOCK_IMG; break; - case KTX_TTF_BC7_RGBA: - vkFormat = srgb ? VK_FORMAT_BC7_SRGB_BLOCK - : VK_FORMAT_BC7_UNORM_BLOCK; + case KTX_TTF_BC7_RGBA: + vkFormat = srgb ? VK_FORMAT_BC7_SRGB_BLOCK : VK_FORMAT_BC7_UNORM_BLOCK; break; - case KTX_TTF_ASTC_4x4_RGBA: - vkFormat = srgb ? VK_FORMAT_ASTC_4x4_SRGB_BLOCK - : VK_FORMAT_ASTC_4x4_UNORM_BLOCK; + case KTX_TTF_ASTC_4x4_RGBA: + vkFormat = srgb ? VK_FORMAT_ASTC_4x4_SRGB_BLOCK : VK_FORMAT_ASTC_4x4_UNORM_BLOCK; break; - case KTX_TTF_RGB565: + case KTX_TTF_RGB565: vkFormat = VK_FORMAT_R5G6B5_UNORM_PACK16; break; - case KTX_TTF_BGR565: + case KTX_TTF_BGR565: vkFormat = VK_FORMAT_B5G6R5_UNORM_PACK16; break; - case KTX_TTF_RGBA4444: + case KTX_TTF_RGBA4444: vkFormat = VK_FORMAT_R4G4B4A4_UNORM_PACK16; break; - case KTX_TTF_RGBA32: - vkFormat = srgb ? VK_FORMAT_R8G8B8A8_SRGB - : VK_FORMAT_R8G8B8A8_UNORM; + case KTX_TTF_RGBA32: + vkFormat = srgb ? VK_FORMAT_R8G8B8A8_SRGB : VK_FORMAT_R8G8B8A8_UNORM; break; - default: + default: return KTX_INVALID_VALUE; } @@ -281,12 +260,10 @@ ktxTexture2_transcodeUastc(ktxTexture2* This, else textureFormat = basis_tex_format::cETC1S; - if (!basis_is_format_supported((transcoder_texture_format)outputFormat, - textureFormat)) { + if (!basis_is_format_supported((transcoder_texture_format)outputFormat, textureFormat)) { return KTX_UNSUPPORTED_FEATURE; } - // Create a prototype texture to use for calculating sizes in the target // format and, as useful side effects, provide us with a properly sized // data allocation and the DFD for the target format. @@ -306,20 +283,18 @@ ktxTexture2_transcodeUastc(ktxTexture2* This, KTX_error_code result; ktxTexture2* prototype; - result = ktxTexture2_Create(&createInfo, KTX_TEXTURE_CREATE_ALLOC_STORAGE, - &prototype); + result = ktxTexture2_Create(&createInfo, KTX_TEXTURE_CREATE_ALLOC_STORAGE, &prototype); if (result != KTX_SUCCESS) { - assert(result == KTX_OUT_OF_MEMORY); // The only run time error + assert(result == KTX_OUT_OF_MEMORY); // The only run time error return result; } if (!This->pData) { if (ktxTexture_isActiveStream((ktxTexture*)This)) { - // Load pending. Complete it. + // Load pending. Complete it. result = ktxTexture2_LoadImageData(This, NULL, 0); - if (result != KTX_SUCCESS) - { + if (result != KTX_SUCCESS) { ktxTexture2_Destroy(prototype); return result; } @@ -340,13 +315,9 @@ ktxTexture2_transcodeUastc(ktxTexture2* This, } if (textureFormat == basis_tex_format::cETC1S) { - result = ktxTexture2_transcodeLzEtc1s(This, alphaContent, - prototype, outputFormat, - transcodeFlags); + result = ktxTexture2_transcodeLzEtc1s(This, alphaContent, prototype, outputFormat, transcodeFlags); } else { - result = ktxTexture2_transcodeUastc(This, alphaContent, - prototype, outputFormat, - transcodeFlags); + result = ktxTexture2_transcodeUastc(This, alphaContent, prototype, outputFormat, transcodeFlags); } if (result == KTX_SUCCESS) { @@ -354,15 +325,13 @@ ktxTexture2_transcodeUastc(ktxTexture2* This, DECLARE_PROTECTED(thisPrtctd, This); DECLARE_PRIVATE(protoPriv, prototype); DECLARE_PROTECTED(protoPrtctd, prototype); - memcpy(&thisPrtctd._formatSize, &protoPrtctd._formatSize, - sizeof(ktxFormatSize)); + memcpy(&thisPrtctd._formatSize, &protoPrtctd._formatSize, sizeof(ktxFormatSize)); This->vkFormat = vkFormat; This->isCompressed = prototype->isCompressed; This->supercompressionScheme = KTX_SS_NONE; priv._requiredLevelAlignment = protoPriv._requiredLevelAlignment; // Copy the levelIndex from the prototype to This. - memcpy(priv._levelIndex, protoPriv._levelIndex, - This->numLevels * sizeof(ktxLevelIndexEntry)); + memcpy(priv._levelIndex, protoPriv._levelIndex, This->numLevels * sizeof(ktxLevelIndexEntry)); // Move the DFD and data from the prototype to This. free(This->pDfd); This->pDfd = prototype->pDfd; @@ -381,7 +350,7 @@ ktxTexture2_transcodeUastc(ktxTexture2* This, } ktxTexture2_Destroy(prototype); return result; - } +} /** * @memberof ktxTexture2 @private @@ -454,12 +423,8 @@ ktxTexture2_transcodeUastc(ktxTexture2* This, * @exception KTX_OUT_OF_MEMORY Not enough memory to carry out transcoding. */ KTX_error_code -ktxTexture2_transcodeLzEtc1s(ktxTexture2* This, - alpha_content_e alphaContent, - ktxTexture2* prototype, - ktx_transcode_fmt_e outputFormat, - ktx_transcode_flags transcodeFlags) -{ +ktxTexture2_transcodeLzEtc1s(ktxTexture2* This, alpha_content_e alphaContent, ktxTexture2* prototype, + ktx_transcode_fmt_e outputFormat, ktx_transcode_flags transcodeFlags) { DECLARE_PRIVATE(priv, This); DECLARE_PRIVATE(protoPriv, prototype); KTX_error_code result = KTX_SUCCESS; @@ -480,7 +445,7 @@ ktxTexture2_transcodeLzEtc1s(ktxTexture2* This, // level to largest or when randomly accessing them (t.b.c). The last array // entry contains the total number of images, for calculating the offsets // of the endpoints, etc. - uint32_t* firstImages = new uint32_t[This->numLevels+1]; + uint32_t* firstImages = new uint32_t[This->numLevels + 1]; // Temporary invariant value uint32_t layersFaces = This->numLayers * This->numFaces; @@ -488,8 +453,7 @@ ktxTexture2_transcodeLzEtc1s(ktxTexture2* This, for (uint32_t level = 1; level <= This->numLevels; level++) { // NOTA BENE: numFaces * depth is only reasonable because they can't // both be > 1. I.e there are no 3d cubemaps. - firstImages[level] = firstImages[level - 1] - + layersFaces * MAX(This->baseDepth >> (level - 1), 1); + firstImages[level] = firstImages[level - 1] + layersFaces * MAX(This->baseDepth >> (level - 1), 1); } uint32_t& imageCount = firstImages[This->numLevels]; @@ -509,13 +473,10 @@ ktxTexture2_transcodeLzEtc1s(ktxTexture2* This, std::vector xcoderStates; xcoderStates.resize(This->isVideo ? This->numFaces : 1); - bit.decode_palettes(bgdh.endpointCount, BGD_ENDPOINTS_ADDR(bgd, imageCount), - bgdh.endpointsByteLength, - bgdh.selectorCount, BGD_SELECTORS_ADDR(bgd, bgdh, imageCount), - bgdh.selectorsByteLength); + bit.decode_palettes(bgdh.endpointCount, BGD_ENDPOINTS_ADDR(bgd, imageCount), bgdh.endpointsByteLength, bgdh.selectorCount, + BGD_SELECTORS_ADDR(bgd, bgdh, imageCount), bgdh.selectorsByteLength); - bit.decode_tables(BGD_TABLES_ADDR(bgd, bgdh, imageCount), - bgdh.tablesByteLength); + bit.decode_tables(BGD_TABLES_ADDR(bgd, bgdh, imageCount), bgdh.tablesByteLength); // Find matching VkFormat and calculate output sizes. @@ -527,10 +488,8 @@ ktxTexture2_transcodeLzEtc1s(ktxTexture2* This, // compressed output. The only reason for humouring the API is so // its buffer size tests provide a real check. An alternative is to // always provide the size in bytes which will always pass. - ktx_uint32_t outputBlockByteLength - = prototype->_protected->_formatSize.blockSizeInBits / 8; - ktx_size_t xcodedDataLength - = prototype->dataSize / outputBlockByteLength; + ktx_uint32_t outputBlockByteLength = prototype->_protected->_formatSize.blockSizeInBits / 8; + ktx_size_t xcodedDataLength = prototype->dataSize / outputBlockByteLength; ktxLevelIndexEntry* protoLevelIndex; uint64_t levelOffsetWrite; const ktxBasisLzEtc1sImageDesc* imageDescs = BGD_ETC1S_IMAGE_DESCS(bgd); @@ -554,7 +513,7 @@ ktxTexture2_transcodeLzEtc1s(ktxTexture2* This, uint32_t levelBlocksX = (levelWidth + (bw - 1)) / bw; uint32_t levelBlocksY = (levelHeight + (bh - 1)) / bh; uint32_t depth = MAX(1, This->baseDepth >> level); - //uint32_t faceSlices = This->numFaces == 1 ? depth : This->numFaces; + // uint32_t faceSlices = This->numFaces == 1 ? depth : This->numFaces; uint32_t faceSlices = This->numFaces * depth; uint32_t numImages = This->numLayers * faceSlices; uint32_t image = firstImages[level]; @@ -573,47 +532,31 @@ ktxTexture2_transcodeLzEtc1s(ktxTexture2* This, // rather than a double loop of layers and faceSlices as this // works for 3d texture and non-array cube maps as well as // cube map arrays without special casing. - if (++stateIndex == xcoderStates.size()) - stateIndex = 0; + if (++stateIndex == xcoderStates.size()) stateIndex = 0; - if (alphaContent != eNone) - { + if (alphaContent != eNone) { // The slice descriptions should have alpha information. - if (imageDesc.alphaSliceByteOffset == 0 - || imageDesc.alphaSliceByteLength == 0) - return KTX_FILE_DATA_ERROR; + if (imageDesc.alphaSliceByteOffset == 0 || imageDesc.alphaSliceByteLength == 0) return KTX_FILE_DATA_ERROR; } bool status; - status = bit.transcode_image( - (transcoder_texture_format)outputFormat, - pXcodedData + writeOffset, - (uint32_t)(xcodedDataLength - writeOffsetBlocks), - This->pData, - (uint32_t)This->dataSize, - levelBlocksX, - levelBlocksY, - levelWidth, - levelHeight, - level, - (uint32_t)(levelOffset + imageDesc.rgbSliceByteOffset), - imageDesc.rgbSliceByteLength, - (uint32_t)(levelOffset + imageDesc.alphaSliceByteOffset), - imageDesc.alphaSliceByteLength, - transcodeFlags, - alphaContent != eNone, - isVideo, - // Our P-Frame flag is in the same bit as - // cSliceDescFlagsFrameIsIFrame. We have to - // invert it to make it an I-Frame flag. - // - // API currently doesn't have any way to pass - // the I-Frame flag. - //imageDesc.imageFlags ^ cSliceDescFlagsFrameIsIFrame, - 0, // output_row_pitch_in_blocks_or_pixels - &xcoderState, - 0 // output_rows_in_pixels - ); + status = bit.transcode_image((transcoder_texture_format)outputFormat, pXcodedData + writeOffset, + (uint32_t)(xcodedDataLength - writeOffsetBlocks), This->pData, (uint32_t)This->dataSize, + levelBlocksX, levelBlocksY, levelWidth, levelHeight, level, + (uint32_t)(levelOffset + imageDesc.rgbSliceByteOffset), imageDesc.rgbSliceByteLength, + (uint32_t)(levelOffset + imageDesc.alphaSliceByteOffset), imageDesc.alphaSliceByteLength, + transcodeFlags, alphaContent != eNone, isVideo, + // Our P-Frame flag is in the same bit as + // cSliceDescFlagsFrameIsIFrame. We have to + // invert it to make it an I-Frame flag. + // + // API currently doesn't have any way to pass + // the I-Frame flag. + // imageDesc.imageFlags ^ cSliceDescFlagsFrameIsIFrame, + 0, // output_row_pitch_in_blocks_or_pixels + &xcoderState, + 0 // output_rows_in_pixels + ); if (!status) { result = KTX_TRANSCODE_FAILED; goto cleanup; @@ -621,16 +564,15 @@ ktxTexture2_transcodeLzEtc1s(ktxTexture2* This, writeOffset += levelImageSizeOut; levelSizeOut += levelImageSizeOut; - } // end images loop + } // end images loop protoLevelIndex[level].byteOffset = levelOffsetWrite; protoLevelIndex[level].byteLength = levelSizeOut; protoLevelIndex[level].uncompressedByteLength = levelSizeOut; levelOffsetWrite += levelSizeOut; assert(levelOffsetWrite == writeOffset); // In case of transcoding to uncompressed. - levelOffsetWrite = _KTX_PADN(protoPriv._requiredLevelAlignment, - levelOffsetWrite); - } // level loop + levelOffsetWrite = _KTX_PADN(protoPriv._requiredLevelAlignment, levelOffsetWrite); + } // level loop result = KTX_SUCCESS; @@ -639,21 +581,14 @@ ktxTexture2_transcodeLzEtc1s(ktxTexture2* This, return result; } - KTX_error_code -ktxTexture2_transcodeUastc(ktxTexture2* This, - alpha_content_e alphaContent, - ktxTexture2* prototype, - ktx_transcode_fmt_e outputFormat, - ktx_transcode_flags transcodeFlags) -{ +ktxTexture2_transcodeUastc(ktxTexture2* This, alpha_content_e alphaContent, ktxTexture2* prototype, + ktx_transcode_fmt_e outputFormat, ktx_transcode_flags transcodeFlags) { assert(This->supercompressionScheme != KTX_SS_BASIS_LZ); ktx_uint8_t* pXcodedData = prototype->pData; - ktx_uint32_t outputBlockByteLength - = prototype->_protected->_formatSize.blockSizeInBits / 8; - ktx_size_t xcodedDataLength - = prototype->dataSize / outputBlockByteLength; + ktx_uint32_t outputBlockByteLength = prototype->_protected->_formatSize.blockSizeInBits / 8; + ktx_size_t xcodedDataLength = prototype->dataSize / outputBlockByteLength; DECLARE_PRIVATE(protoPriv, prototype); ktxLevelIndexEntry* protoLevelIndex = protoPriv._levelIndex; ktx_size_t levelOffsetWrite = 0; @@ -663,8 +598,7 @@ ktxTexture2_transcodeUastc(ktxTexture2* This, std::vector xcoderStates; xcoderStates.resize(This->isVideo ? This->numFaces : 1); - for (ktx_int32_t level = This->numLevels - 1; level >= 0; level--) - { + for (ktx_int32_t level = This->numLevels - 1; level >= 0; level--) { ktx_uint32_t depth; uint64_t writeOffset = levelOffsetWrite; uint64_t writeOffsetBlocks = levelOffsetWrite / outputBlockByteLength; @@ -679,14 +613,11 @@ ktxTexture2_transcodeUastc(ktxTexture2* This, uint32_t levelBlocksY = (levelHeight + (bh - 1)) / bh; uint32_t stateIndex = 0; - depth = MAX(1, This->baseDepth >> level); + depth = MAX(1, This->baseDepth >> level); levelImageCount = This->numLayers * This->numFaces * depth; - levelImageSizeIn = ktxTexture_calcImageSize(ktxTexture(This), level, - KTX_FORMAT_VERSION_TWO); - levelImageSizeOut = ktxTexture_calcImageSize(ktxTexture(prototype), - level, - KTX_FORMAT_VERSION_TWO); + levelImageSizeIn = ktxTexture_calcImageSize(ktxTexture(This), level, KTX_FORMAT_VERSION_TWO); + levelImageSizeOut = ktxTexture_calcImageSize(ktxTexture(prototype), level, KTX_FORMAT_VERSION_TWO); levelImageOffsetIn = ktxTexture2_levelDataOffset(This, level); levelSizeOut = 0; @@ -694,34 +625,21 @@ ktxTexture2_transcodeUastc(ktxTexture2* This, for (uint32_t image = 0; image < levelImageCount; image++) { basisu_transcoder_state& xcoderState = xcoderStates[stateIndex]; // See comment before same lines in transcodeEtc1s. - if (++stateIndex == xcoderStates.size()) - stateIndex = 0; - - status = uit.transcode_image( - (transcoder_texture_format)outputFormat, - pXcodedData + writeOffset, - (uint32_t)(xcodedDataLength - writeOffsetBlocks), - This->pData, - (uint32_t)This->dataSize, - levelBlocksX, - levelBlocksY, - levelWidth, - levelHeight, - level, - (uint32_t)levelImageOffsetIn, - (uint32_t)levelImageSizeIn, - transcodeFlags, - alphaContent != eNone, - This->isVideo, // is_video - //imageDesc.imageFlags ^ cSliceDescFlagsFrameIsIFrame, - 0, // output_row_pitch_in_blocks_or_pixels - &xcoderState, // pState - 0, // output_rows_in_pixels, - -1, // channel0 - -1 // channel1 - ); - if (!status) - return KTX_TRANSCODE_FAILED; + if (++stateIndex == xcoderStates.size()) stateIndex = 0; + + status = uit.transcode_image((transcoder_texture_format)outputFormat, pXcodedData + writeOffset, + (uint32_t)(xcodedDataLength - writeOffsetBlocks), This->pData, (uint32_t)This->dataSize, + levelBlocksX, levelBlocksY, levelWidth, levelHeight, level, (uint32_t)levelImageOffsetIn, + (uint32_t)levelImageSizeIn, transcodeFlags, alphaContent != eNone, + This->isVideo, // is_video + // imageDesc.imageFlags ^ cSliceDescFlagsFrameIsIFrame, + 0, // output_row_pitch_in_blocks_or_pixels + &xcoderState, // pState + 0, // output_rows_in_pixels, + -1, // channel0 + -1 // channel1 + ); + if (!status) return KTX_TRANSCODE_FAILED; writeOffset += levelImageSizeOut; levelSizeOut += levelImageSizeOut; levelImageOffsetIn += levelImageSizeIn; @@ -733,7 +651,6 @@ ktxTexture2_transcodeUastc(ktxTexture2* This, levelOffsetWrite += levelSizeOut; } // In case of transcoding to uncompressed. - levelOffsetWrite = _KTX_PADN(protoPriv._requiredLevelAlignment, - levelOffsetWrite); + levelOffsetWrite = _KTX_PADN(protoPriv._requiredLevelAlignment, levelOffsetWrite); return KTX_SUCCESS; } diff --git a/lib/checkheader.c b/lib/checkheader.c index cee47ce341..6cb7080012 100644 --- a/lib/checkheader.c +++ b/lib/checkheader.c @@ -49,44 +49,34 @@ bool isValidFormat(VkFormat format); * @author Mark Callow, HI Corporation */ -KTX_error_code ktxCheckHeader1_(KTX_header* pHeader, - KTX_supplemental_info* pSuppInfo) -{ +KTX_error_code +ktxCheckHeader1_(KTX_header* pHeader, KTX_supplemental_info* pSuppInfo) { ktx_uint8_t identifier_reference[12] = KTX_IDENTIFIER_REF; ktx_uint32_t max_dim; assert(pHeader != NULL && pSuppInfo != NULL); /* Compare identifier, is this a KTX file? */ - if (memcmp(pHeader->identifier, identifier_reference, 12) != 0) - { + if (memcmp(pHeader->identifier, identifier_reference, 12) != 0) { return KTX_UNKNOWN_FILE_FORMAT; } - if (pHeader->endianness == KTX_ENDIAN_REF_REV) - { + if (pHeader->endianness == KTX_ENDIAN_REF_REV) { /* Convert endianness of pHeader fields. */ _ktxSwapEndian32(&pHeader->glType, 12); - if (pHeader->glTypeSize != 1 && - pHeader->glTypeSize != 2 && - pHeader->glTypeSize != 4) - { + if (pHeader->glTypeSize != 1 && pHeader->glTypeSize != 2 && pHeader->glTypeSize != 4) { /* Only 8-, 16-, and 32-bit types supported so far. */ return KTX_FILE_DATA_ERROR; } - } - else if (pHeader->endianness != KTX_ENDIAN_REF) - { + } else if (pHeader->endianness != KTX_ENDIAN_REF) { return KTX_FILE_DATA_ERROR; } /* Check glType and glFormat */ pSuppInfo->compressed = 0; - if (pHeader->glType == 0 || pHeader->glFormat == 0) - { - if (pHeader->glType + pHeader->glFormat != 0) - { + if (pHeader->glType == 0 || pHeader->glFormat == 0) { + if (pHeader->glType + pHeader->glFormat != 0) { /* either both or none of glType, glFormat must be zero */ return KTX_FILE_DATA_ERROR; } @@ -102,62 +92,45 @@ KTX_error_code ktxCheckHeader1_(KTX_header* pHeader, /* Check texture dimensions. KTX files can store 8 types of textures: 1D, 2D, 3D, cube, and array variants of these. There is currently no GL extension for 3D array textures. */ - if ((pHeader->pixelWidth == 0) || - (pHeader->pixelDepth > 0 && pHeader->pixelHeight == 0)) - { + if ((pHeader->pixelWidth == 0) || (pHeader->pixelDepth > 0 && pHeader->pixelHeight == 0)) { /* texture must have width */ /* texture must have height if it has depth */ return KTX_FILE_DATA_ERROR; } - - if (pHeader->pixelDepth > 0) - { - if (pHeader->numberOfArrayElements > 0) - { + if (pHeader->pixelDepth > 0) { + if (pHeader->numberOfArrayElements > 0) { /* No 3D array textures yet. */ return KTX_UNSUPPORTED_FEATURE; } pSuppInfo->textureDimension = 3; - } - else if (pHeader->pixelHeight > 0) - { + } else if (pHeader->pixelHeight > 0) { pSuppInfo->textureDimension = 2; - } - else - { + } else { pSuppInfo->textureDimension = 1; } - if (pHeader->numberOfFaces == 6) - { - if (pSuppInfo->textureDimension != 2) - { + if (pHeader->numberOfFaces == 6) { + if (pSuppInfo->textureDimension != 2) { /* cube map needs 2D faces */ return KTX_FILE_DATA_ERROR; } - } - else if (pHeader->numberOfFaces != 1) - { + } else if (pHeader->numberOfFaces != 1) { /* numberOfFaces must be either 1 or 6 */ return KTX_FILE_DATA_ERROR; } /* Check number of mipmap levels */ - if (pHeader->numberOfMipLevels == 0) - { + if (pHeader->numberOfMipLevels == 0) { pSuppInfo->generateMipmaps = 1; pHeader->numberOfMipLevels = 1; - } - else - { + } else { pSuppInfo->generateMipmaps = 0; } /* This test works for arrays too because height or depth will be 0. */ max_dim = MAX(MAX(pHeader->pixelWidth, pHeader->pixelHeight), pHeader->pixelDepth); - if (max_dim < ((ktx_uint32_t)1 << (pHeader->numberOfMipLevels - 1))) - { + if (max_dim < ((ktx_uint32_t)1 << (pHeader->numberOfMipLevels - 1))) { /* Can't have more mip levels than 1 + log2(max(width, height, depth)) */ return KTX_FILE_DATA_ERROR; } @@ -180,120 +153,96 @@ KTX_error_code ktxCheckHeader1_(KTX_header* pHeader, * * @author Mark Callow, HI Corporation */ -KTX_error_code ktxCheckHeader2_(KTX_header2* pHeader, - KTX_supplemental_info* pSuppInfo) -{ -// supp info is compressed, generateMipmaps and num dimensions. Don't need -// compressed as formatSize gives us that. I think the other 2 aren't needed. +KTX_error_code +ktxCheckHeader2_(KTX_header2* pHeader, KTX_supplemental_info* pSuppInfo) { + // supp info is compressed, generateMipmaps and num dimensions. Don't need + // compressed as formatSize gives us that. I think the other 2 aren't needed. ktx_uint8_t identifier_reference[12] = KTX2_IDENTIFIER_REF; assert(pHeader != NULL && pSuppInfo != NULL); ktx_uint32_t max_dim; /* Compare identifier, is this a KTX file? */ - if (memcmp(pHeader->identifier, identifier_reference, 12) != 0) - { + if (memcmp(pHeader->identifier, identifier_reference, 12) != 0) { return KTX_UNKNOWN_FILE_FORMAT; } /* Check format */ - if (isProhibitedFormat(pHeader->vkFormat)) - { + if (isProhibitedFormat(pHeader->vkFormat)) { return KTX_FILE_DATA_ERROR; } - if (!isValidFormat(pHeader->vkFormat)) - { + if (!isValidFormat(pHeader->vkFormat)) { return KTX_UNSUPPORTED_FEATURE; } - if (pHeader->supercompressionScheme == KTX_SS_BASIS_LZ && pHeader->vkFormat != VK_FORMAT_UNDEFINED) - { + if (pHeader->supercompressionScheme == KTX_SS_BASIS_LZ && pHeader->vkFormat != VK_FORMAT_UNDEFINED) { return KTX_FILE_DATA_ERROR; } /* Check texture dimensions. KTX files can store 8 types of textures: 1D, 2D, 3D, cube, and array variants of these. There is currently no extension for 3D array textures in any 3D API. */ - if ((pHeader->pixelWidth == 0) || - (pHeader->pixelDepth > 0 && pHeader->pixelHeight == 0)) - { + if ((pHeader->pixelWidth == 0) || (pHeader->pixelDepth > 0 && pHeader->pixelHeight == 0)) { /* texture must have width */ /* texture must have height if it has depth */ return KTX_FILE_DATA_ERROR; } - if (pHeader->pixelDepth > 0) - { - if (pHeader->layerCount > 0) - { + if (pHeader->pixelDepth > 0) { + if (pHeader->layerCount > 0) { /* No 3D array textures yet. */ return KTX_UNSUPPORTED_FEATURE; } pSuppInfo->textureDimension = 3; - } - else if (pHeader->pixelHeight > 0) - { + } else if (pHeader->pixelHeight > 0) { pSuppInfo->textureDimension = 2; - } - else - { + } else { pSuppInfo->textureDimension = 1; } - if (pHeader->faceCount == 6) - { - if (pSuppInfo->textureDimension != 2) - { + if (pHeader->faceCount == 6) { + if (pSuppInfo->textureDimension != 2) { /* cube map needs 2D faces */ return KTX_FILE_DATA_ERROR; } - if (pHeader->pixelDepth != 0) - { + if (pHeader->pixelDepth != 0) { /* cube map cannot have depth */ return KTX_FILE_DATA_ERROR; } - if (pHeader->pixelWidth != pHeader->pixelHeight) - { + if (pHeader->pixelWidth != pHeader->pixelHeight) { /* cube map needs square faces */ return KTX_FILE_DATA_ERROR; } - } - else if (pHeader->faceCount != 1) - { + } else if (pHeader->faceCount != 1) { /* numberOfFaces must be either 1 or 6 */ return KTX_FILE_DATA_ERROR; } // Check number of mipmap levels - if (pHeader->levelCount == 0) - { + if (pHeader->levelCount == 0) { pSuppInfo->generateMipmaps = 1; pHeader->levelCount = 1; - } - else - { + } else { pSuppInfo->generateMipmaps = 0; } // Check supercompression switch (pHeader->supercompressionScheme) { - case KTX_SS_NONE: - case KTX_SS_BASIS_LZ: - case KTX_SS_ZSTD: - case KTX_SS_ZLIB: + case KTX_SS_NONE: + case KTX_SS_BASIS_LZ: + case KTX_SS_ZSTD: + case KTX_SS_ZLIB: break; - default: + default: // Unsupported supercompression return KTX_UNSUPPORTED_FEATURE; } // This test works for arrays too because height or depth will be 0. max_dim = MAX(MAX(pHeader->pixelWidth, pHeader->pixelHeight), pHeader->pixelDepth); - if (max_dim < ((ktx_uint32_t)1 << (pHeader->levelCount - 1))) - { + if (max_dim < ((ktx_uint32_t)1 << (pHeader->levelCount - 1))) { // Can't have more mip levels than 1 + log2(max(width, height, depth)) return KTX_FILE_DATA_ERROR; } return KTX_SUCCESS; - } diff --git a/lib/etcdec.cxx b/lib/etcdec.cxx index a2764ddc95..89016ee1f4 100644 --- a/lib/etcdec.cxx +++ b/lib/etcdec.cxx @@ -1,9 +1,9 @@ /* - + @~English - + @section etcdec etcdec.cxx License - + etcdec.cxx is made available under the terms and conditions of the following License Agreement. @@ -118,9 +118,9 @@ submitted to the exclusive jurisdiction of the Swedish Courts. */ //// etcpack v2.74 -//// -//// NO WARRANTY -//// +//// +//// NO WARRANTY +//// //// BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE THE PROGRAM IS PROVIDED //// "AS IS". ERICSSON MAKES NO REPRESENTATIONS OF ANY KIND, EXTENDS NO //// WARRANTIES OR CONDITIONS OF ANY KIND; EITHER EXPRESS, IMPLIED OR @@ -137,7 +137,7 @@ submitted to the exclusive jurisdiction of the Swedish Courts. //// TO YOUR SOLE RESPONSIBILITY TO MAKE SUCH DETERMINATION AND ACQUIRE //// SUCH LICENSES AS MAY BE NECESSARY WITH RESPECT TO PATENTS, COPYRIGHT //// AND OTHER INTELLECTUAL PROPERTY OF THIRD PARTIES. -//// +//// //// FOR THE AVOIDANCE OF DOUBT THE PROGRAM (I) IS NOT LICENSED FOR; (II) //// IS NOT DESIGNED FOR OR INTENDED FOR; AND (III) MAY NOT BE USED FOR; //// ANY MISSION CRITICAL APPLICATIONS SUCH AS, BUT NOT LIMITED TO @@ -149,7 +149,7 @@ submitted to the exclusive jurisdiction of the Swedish Courts. //// DAMAGE. YOUR RIGHTS UNDER THIS LICENSE WILL TERMINATE AUTOMATICALLY //// AND IMMEDIATELY WITHOUT NOTICE IF YOU FAIL TO COMPLY WITH THIS //// PARAGRAPH. -//// +//// //// IN NO EVENT WILL ERICSSON, BE LIABLE FOR ANY DAMAGES WHATSOEVER, //// INCLUDING BUT NOT LIMITED TO PERSONAL INJURY, ANY GENERAL, SPECIAL, //// INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR IN @@ -160,9 +160,9 @@ submitted to the exclusive jurisdiction of the Swedish Courts. //// THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) REGARDLESS OF THE //// THEORY OF LIABILITY (CONTRACT, TORT OR OTHERWISE), EVEN IF SUCH HOLDER //// OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. -//// +//// //// (C) Ericsson AB 2013. All Rights Reserved. -//// +//// #include #include @@ -172,21 +172,21 @@ submitted to the exclusive jurisdiction of the Swedish Courts. // code to suppress them. Yes it is a mod but it doesn't change // the source of the functions or the compiled binary code. #if defined(_MSC_VER) - #pragma warning(push) - #pragma warning(disable: 4100 4244) +#pragma warning(push) +#pragma warning(disable : 4100 4244) #endif // clang-cl defines both _MSC_VER and __clang__ #if __clang__ - #pragma clang diagnostic push - #pragma clang diagnostic ignored "-Wunused-parameter" - #if __has_warning("-Wunused-but-set-variable") - #pragma clang diagnostic ignored "-Wunused-but-set-variable" - #endif +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunused-parameter" +#if __has_warning("-Wunused-but-set-variable") +#pragma clang diagnostic ignored "-Wunused-but-set-variable" +#endif #elif __GNUC__ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-parameter" #pragma GCC diagnostic ignored "-Wunused-but-set-variable" -#pragma GCC diagnostic ignored "-Wunused-result" // For the freads. +#pragma GCC diagnostic ignored "-Wunused-result" // For the freads. #endif // Typedefs @@ -195,370 +195,351 @@ typedef unsigned short uint16; typedef short int16; // Macros to help with bit extraction/insertion -#define SHIFT(size,startpos) ((startpos)-(size)+1) -#define MASK(size, startpos) (((2<<(size-1))-1) << SHIFT(size,startpos)) -#define PUTBITS( dest, data, size, startpos) dest = ((dest & ~MASK(size, startpos)) | ((data << SHIFT(size, startpos)) & MASK(size,startpos))) -#define SHIFTHIGH(size, startpos) (((startpos)-32)-(size)+1) -#define MASKHIGH(size, startpos) (((1<<(size))-1) << SHIFTHIGH(size,startpos)) -#define PUTBITSHIGH(dest, data, size, startpos) dest = ((dest & ~MASKHIGH(size, startpos)) | ((data << SHIFTHIGH(size, startpos)) & MASKHIGH(size,startpos))) -#define GETBITS(source, size, startpos) (( (source) >> ((startpos)-(size)+1) ) & ((1<<(size)) -1)) -#define GETBITSHIGH(source, size, startpos) (( (source) >> (((startpos)-32)-(size)+1) ) & ((1<<(size)) -1)) +#define SHIFT(size, startpos) ((startpos) - (size) + 1) +#define MASK(size, startpos) (((2 << (size - 1)) - 1) << SHIFT(size, startpos)) +#define PUTBITS(dest, data, size, startpos) \ + dest = ((dest & ~MASK(size, startpos)) | ((data << SHIFT(size, startpos)) & MASK(size, startpos))) +#define SHIFTHIGH(size, startpos) (((startpos)-32) - (size) + 1) +#define MASKHIGH(size, startpos) (((1 << (size)) - 1) << SHIFTHIGH(size, startpos)) +#define PUTBITSHIGH(dest, data, size, startpos) \ + dest = ((dest & ~MASKHIGH(size, startpos)) | ((data << SHIFTHIGH(size, startpos)) & MASKHIGH(size, startpos))) +#define GETBITS(source, size, startpos) (((source) >> ((startpos) - (size) + 1)) & ((1 << (size)) - 1)) +#define GETBITSHIGH(source, size, startpos) (((source) >> (((startpos)-32) - (size) + 1)) & ((1 << (size)) - 1)) #ifndef PGMOUT #define PGMOUT 0 #endif // Thumb macros and definitions -#define R_BITS59T 4 +#define R_BITS59T 4 #define G_BITS59T 4 -#define B_BITS59T 4 -#define R_BITS58H 4 +#define B_BITS59T 4 +#define R_BITS58H 4 #define G_BITS58H 4 -#define B_BITS58H 4 -#define MAXIMUM_ERROR (255*255*16*1000) +#define B_BITS58H 4 +#define MAXIMUM_ERROR (255 * 255 * 16 * 1000) #define R 0 #define G 1 #define B 2 #define BLOCKHEIGHT 4 #define BLOCKWIDTH 4 -#define BINPOW(power) (1<<(power)) -#define TABLE_BITS_59T 3 -#define TABLE_BITS_58H 3 +#define BINPOW(power) (1 << (power)) +#define TABLE_BITS_59T 3 +#define TABLE_BITS_58H 3 // Helper Macros -#define CLAMP(ll,x,ul) (((x)<(ll)) ? (ll) : (((x)>(ul)) ? (ul) : (x))) -#define JAS_ROUND(x) (((x) < 0.0 ) ? ((int)((x)-0.5)) : ((int)((x)+0.5))) - -#define RED_CHANNEL(img,width,x,y,channels) img[channels*(y*width+x)+0] -#define GREEN_CHANNEL(img,width,x,y,channels) img[channels*(y*width+x)+1] -#define BLUE_CHANNEL(img,width,x,y,channels) img[channels*(y*width+x)+2] -#define ALPHA_CHANNEL(img,width,x,y,channels) img[channels*(y*width+x)+3] +#define CLAMP(ll, x, ul) (((x) < (ll)) ? (ll) : (((x) > (ul)) ? (ul) : (x))) +#define JAS_ROUND(x) (((x) < 0.0) ? ((int)((x)-0.5)) : ((int)((x) + 0.5))) +#define RED_CHANNEL(img, width, x, y, channels) img[channels * (y * width + x) + 0] +#define GREEN_CHANNEL(img, width, x, y, channels) img[channels * (y * width + x) + 1] +#define BLUE_CHANNEL(img, width, x, y, channels) img[channels * (y * width + x) + 2] +#define ALPHA_CHANNEL(img, width, x, y, channels) img[channels * (y * width + x) + 3] // Global tables -static uint8 table59T[8] = {3,6,11,16,23,32,41,64}; // 3-bit table for the 59 bit T-mode -static uint8 table58H[8] = {3,6,11,16,23,32,41,64}; // 3-bit table for the 58 bit H-mode -static int compressParams[16][4] = {{-8, -2, 2, 8}, {-8, -2, 2, 8}, {-17, -5, 5, 17}, {-17, -5, 5, 17}, {-29, -9, 9, 29}, {-29, -9, 9, 29}, {-42, -13, 13, 42}, {-42, -13, 13, 42}, {-60, -18, 18, 60}, {-60, -18, 18, 60}, {-80, -24, 24, 80}, {-80, -24, 24, 80}, {-106, -33, 33, 106}, {-106, -33, 33, 106}, {-183, -47, 47, 183}, {-183, -47, 47, 183}}; +static uint8 table59T[8] = {3, 6, 11, 16, 23, 32, 41, 64}; // 3-bit table for the 59 bit T-mode +static uint8 table58H[8] = {3, 6, 11, 16, 23, 32, 41, 64}; // 3-bit table for the 58 bit H-mode +static int compressParams[16][4] = {{-8, -2, 2, 8}, {-8, -2, 2, 8}, {-17, -5, 5, 17}, {-17, -5, 5, 17}, + {-29, -9, 9, 29}, {-29, -9, 9, 29}, {-42, -13, 13, 42}, {-42, -13, 13, 42}, + {-60, -18, 18, 60}, {-60, -18, 18, 60}, {-80, -24, 24, 80}, {-80, -24, 24, 80}, + {-106, -33, 33, 106}, {-106, -33, 33, 106}, {-183, -47, 47, 183}, {-183, -47, 47, 183}}; static int unscramble[4] = {2, 3, 1, 0}; int alphaTableInitialized = 0; int alphaTable[256][8]; -int alphaBase[16][4] = { - {-15,-9,-6,-3}, - {-13,-10,-7,-3}, - {-13,-8,-5,-2}, - {-13,-6,-4,-2}, - {-12,-8,-6,-3}, - {-11,-9,-7,-3}, - {-11,-8,-7,-4}, - {-11,-8,-5,-3}, - { -10,-8,-6,-2}, - { -10,-8,-5,-2}, - { -10,-8,-4,-2}, - { -10,-7,-5,-2}, - { -10,-7,-4,-3}, - { -10,-3,-2, -1}, - { -9,-8,-6,-4}, - { -9,-7,-5,-3} - }; +int alphaBase[16][4] = {{-15, -9, -6, -3}, {-13, -10, -7, -3}, {-13, -8, -5, -2}, {-13, -6, -4, -2}, + {-12, -8, -6, -3}, {-11, -9, -7, -3}, {-11, -8, -7, -4}, {-11, -8, -5, -3}, + {-10, -8, -6, -2}, {-10, -8, -5, -2}, {-10, -8, -4, -2}, {-10, -7, -5, -2}, + {-10, -7, -4, -3}, {-10, -3, -2, -1}, {-9, -8, -6, -4}, {-9, -7, -5, -3}}; // Global variables int formatSigned = 0; // Enums - enum{PATTERN_H = 0, - PATTERN_T = 1}; - +enum { PATTERN_H = 0, PATTERN_T = 1 }; // Code used to create the valtab // NO WARRANTY --- SEE STATEMENT IN TOP OF FILE (C) Ericsson AB 2013. All Rights Reserved. -void setupAlphaTable() -{ - if(alphaTableInitialized) - return; - alphaTableInitialized = 1; - - //read table used for alpha compression - int buf; - for(int i = 16; i<32; i++) - { - for(int j=0; j<8; j++) - { - buf=alphaBase[i-16][3-j%4]; - if(j<4) - alphaTable[i][j]=buf; - else - alphaTable[i][j]=(-buf-1); - } - } - - //beyond the first 16 values, the rest of the table is implicit.. so calculate that! - for(int i=0; i<256; i++) - { - //fill remaining slots in table with multiples of the first ones. - int mul = i/16; - int old = 16+i%16; - for(int j = 0; j<8; j++) - { - alphaTable[i][j]=alphaTable[old][j]*mul; - //note: we don't do clamping here, though we could, because we'll be clamped afterwards anyway. - } - } +void +setupAlphaTable() { + if (alphaTableInitialized) return; + alphaTableInitialized = 1; + + // read table used for alpha compression + int buf; + for (int i = 16; i < 32; i++) { + for (int j = 0; j < 8; j++) { + buf = alphaBase[i - 16][3 - j % 4]; + if (j < 4) + alphaTable[i][j] = buf; + else + alphaTable[i][j] = (-buf - 1); + } + } + + // beyond the first 16 values, the rest of the table is implicit.. so calculate that! + for (int i = 0; i < 256; i++) { + // fill remaining slots in table with multiples of the first ones. + int mul = i / 16; + int old = 16 + i % 16; + for (int j = 0; j < 8; j++) { + alphaTable[i][j] = alphaTable[old][j] * mul; + // note: we don't do clamping here, though we could, because we'll be clamped afterwards anyway. + } + } } // Read a word in big endian style // NO WARRANTY --- SEE STATEMENT IN TOP OF FILE (C) Ericsson AB 2013. All Rights Reserved. -void read_big_endian_2byte_word(unsigned short *blockadr, FILE *f) -{ - uint8 bytes[2]; - unsigned short block; +void +read_big_endian_2byte_word(unsigned short *blockadr, FILE *f) { + uint8 bytes[2]; + unsigned short block; - fread(&bytes[0], 1, 1, f); - fread(&bytes[1], 1, 1, f); + fread(&bytes[0], 1, 1, f); + fread(&bytes[1], 1, 1, f); - block = 0; - block |= bytes[0]; - block = block << 8; - block |= bytes[1]; + block = 0; + block |= bytes[0]; + block = block << 8; + block |= bytes[1]; - blockadr[0] = block; + blockadr[0] = block; } // Read a word in big endian style // NO WARRANTY --- SEE STATEMENT IN TOP OF FILE (C) Ericsson AB 2013. All Rights Reserved. -void read_big_endian_4byte_word(unsigned int *blockadr, FILE *f) -{ - uint8 bytes[4]; - unsigned int block; - - fread(&bytes[0], 1, 1, f); - fread(&bytes[1], 1, 1, f); - fread(&bytes[2], 1, 1, f); - fread(&bytes[3], 1, 1, f); - - block = 0; - block |= bytes[0]; - block = block << 8; - block |= bytes[1]; - block = block << 8; - block |= bytes[2]; - block = block << 8; - block |= bytes[3]; - - blockadr[0] = block; +void +read_big_endian_4byte_word(unsigned int *blockadr, FILE *f) { + uint8 bytes[4]; + unsigned int block; + + fread(&bytes[0], 1, 1, f); + fread(&bytes[1], 1, 1, f); + fread(&bytes[2], 1, 1, f); + fread(&bytes[3], 1, 1, f); + + block = 0; + block |= bytes[0]; + block = block << 8; + block |= bytes[1]; + block = block << 8; + block |= bytes[2]; + block = block << 8; + block |= bytes[3]; + + blockadr[0] = block; } // The format stores the bits for the three extra modes in a roundabout way to be able to // fit them without increasing the bit rate. This function converts them into something -// that is easier to work with. +// that is easier to work with. // NO WARRANTY --- SEE STATEMENT IN TOP OF FILE (C) Ericsson AB 2013. All Rights Reserved. -void unstuff57bits(unsigned int planar_word1, unsigned int planar_word2, unsigned int &planar57_word1, unsigned int &planar57_word2) -{ - // Get bits from twotimer configuration for 57 bits - // - // Go to this bit layout: - // - // 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 - // ----------------------------------------------------------------------------------------------- - // |R0 |G01G02 |B01B02 ;B03 |RH1 |RH2|GH | - // ----------------------------------------------------------------------------------------------- - // - // 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 - // ----------------------------------------------------------------------------------------------- - // |BH |RV |GV |BV | not used | - // ----------------------------------------------------------------------------------------------- - // - // From this: - // - // 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 - // ------------------------------------------------------------------------------------------------ - // |//|R0 |G01|/|G02 |B01|/ // //|B02 |//|B03 |RH1 |df|RH2| - // ------------------------------------------------------------------------------------------------ - // - // 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 - // ----------------------------------------------------------------------------------------------- - // |GH |BH |RV |GV |BV | - // ----------------------------------------------------------------------------------------------- - // - // 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 - // --------------------------------------------------------------------------------------------------- - // | base col1 | dcol 2 | base col1 | dcol 2 | base col 1 | dcol 2 | table | table |diff|flip| - // | R1' (5 bits) | dR2 | G1' (5 bits) | dG2 | B1' (5 bits) | dB2 | cw 1 | cw 2 |bit |bit | - // --------------------------------------------------------------------------------------------------- - - uint8 RO, GO1, GO2, BO1, BO2, BO3, RH1, RH2, GH, BH, RV, GV, BV; - - RO = GETBITSHIGH( planar_word1, 6, 62); - GO1 = GETBITSHIGH( planar_word1, 1, 56); - GO2 = GETBITSHIGH( planar_word1, 6, 54); - BO1 = GETBITSHIGH( planar_word1, 1, 48); - BO2 = GETBITSHIGH( planar_word1, 2, 44); - BO3 = GETBITSHIGH( planar_word1, 3, 41); - RH1 = GETBITSHIGH( planar_word1, 5, 38); - RH2 = GETBITSHIGH( planar_word1, 1, 32); - GH = GETBITS( planar_word2, 7, 31); - BH = GETBITS( planar_word2, 6, 24); - RV = GETBITS( planar_word2, 6, 18); - GV = GETBITS( planar_word2, 7, 12); - BV = GETBITS( planar_word2, 6, 5); - - planar57_word1 = 0; planar57_word2 = 0; - PUTBITSHIGH( planar57_word1, RO, 6, 63); - PUTBITSHIGH( planar57_word1, GO1, 1, 57); - PUTBITSHIGH( planar57_word1, GO2, 6, 56); - PUTBITSHIGH( planar57_word1, BO1, 1, 50); - PUTBITSHIGH( planar57_word1, BO2, 2, 49); - PUTBITSHIGH( planar57_word1, BO3, 3, 47); - PUTBITSHIGH( planar57_word1, RH1, 5, 44); - PUTBITSHIGH( planar57_word1, RH2, 1, 39); - PUTBITSHIGH( planar57_word1, GH, 7, 38); - PUTBITS( planar57_word2, BH, 6, 31); - PUTBITS( planar57_word2, RV, 6, 25); - PUTBITS( planar57_word2, GV, 7, 19); - PUTBITS( planar57_word2, BV, 6, 12); +void +unstuff57bits(unsigned int planar_word1, unsigned int planar_word2, unsigned int &planar57_word1, unsigned int &planar57_word2) { + // Get bits from twotimer configuration for 57 bits + // + // Go to this bit layout: + // + // 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 + // ----------------------------------------------------------------------------------------------- + // |R0 |G01G02 |B01B02 ;B03 |RH1 |RH2|GH | + // ----------------------------------------------------------------------------------------------- + // + // 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 + // ----------------------------------------------------------------------------------------------- + // |BH |RV |GV |BV | not used | + // ----------------------------------------------------------------------------------------------- + // + // From this: + // + // 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 + // ------------------------------------------------------------------------------------------------ + // |//|R0 |G01|/|G02 |B01|/ // //|B02 |//|B03 |RH1 |df|RH2| + // ------------------------------------------------------------------------------------------------ + // + // 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 + // ----------------------------------------------------------------------------------------------- + // |GH |BH |RV |GV |BV | + // ----------------------------------------------------------------------------------------------- + // + // 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 + // --------------------------------------------------------------------------------------------------- + // | base col1 | dcol 2 | base col1 | dcol 2 | base col 1 | dcol 2 | table | table |diff|flip| + // | R1' (5 bits) | dR2 | G1' (5 bits) | dG2 | B1' (5 bits) | dB2 | cw 1 | cw 2 |bit |bit | + // --------------------------------------------------------------------------------------------------- + + uint8 RO, GO1, GO2, BO1, BO2, BO3, RH1, RH2, GH, BH, RV, GV, BV; + + RO = GETBITSHIGH(planar_word1, 6, 62); + GO1 = GETBITSHIGH(planar_word1, 1, 56); + GO2 = GETBITSHIGH(planar_word1, 6, 54); + BO1 = GETBITSHIGH(planar_word1, 1, 48); + BO2 = GETBITSHIGH(planar_word1, 2, 44); + BO3 = GETBITSHIGH(planar_word1, 3, 41); + RH1 = GETBITSHIGH(planar_word1, 5, 38); + RH2 = GETBITSHIGH(planar_word1, 1, 32); + GH = GETBITS(planar_word2, 7, 31); + BH = GETBITS(planar_word2, 6, 24); + RV = GETBITS(planar_word2, 6, 18); + GV = GETBITS(planar_word2, 7, 12); + BV = GETBITS(planar_word2, 6, 5); + + planar57_word1 = 0; + planar57_word2 = 0; + PUTBITSHIGH(planar57_word1, RO, 6, 63); + PUTBITSHIGH(planar57_word1, GO1, 1, 57); + PUTBITSHIGH(planar57_word1, GO2, 6, 56); + PUTBITSHIGH(planar57_word1, BO1, 1, 50); + PUTBITSHIGH(planar57_word1, BO2, 2, 49); + PUTBITSHIGH(planar57_word1, BO3, 3, 47); + PUTBITSHIGH(planar57_word1, RH1, 5, 44); + PUTBITSHIGH(planar57_word1, RH2, 1, 39); + PUTBITSHIGH(planar57_word1, GH, 7, 38); + PUTBITS(planar57_word2, BH, 6, 31); + PUTBITS(planar57_word2, RV, 6, 25); + PUTBITS(planar57_word2, GV, 7, 19); + PUTBITS(planar57_word2, BV, 6, 12); } // The format stores the bits for the three extra modes in a roundabout way to be able to // fit them without increasing the bit rate. This function converts them into something -// that is easier to work with. +// that is easier to work with. // NO WARRANTY --- SEE STATEMENT IN TOP OF FILE (C) Ericsson AB 2013. All Rights Reserved. -void unstuff58bits(unsigned int thumbH_word1, unsigned int thumbH_word2, unsigned int &thumbH58_word1, unsigned int &thumbH58_word2) -{ - // Go to this layout: - // - // |63 62 61 60 59 58|57 56 55 54 53 52 51|50 49|48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33|32 | - // |-------empty-----|part0---------------|part1|part2------------------------------------------|part3| - // - // from this: - // - // 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 - // --------------------------------------------------------------------------------------------------| - // |//|part0 |// // //|part1|//|part2 |df|part3| - // --------------------------------------------------------------------------------------------------| - - unsigned int part0, part1, part2, part3; - - // move parts - part0 = GETBITSHIGH( thumbH_word1, 7, 62); - part1 = GETBITSHIGH( thumbH_word1, 2, 52); - part2 = GETBITSHIGH( thumbH_word1,16, 49); - part3 = GETBITSHIGH( thumbH_word1, 1, 32); - thumbH58_word1 = 0; - PUTBITSHIGH( thumbH58_word1, part0, 7, 57); - PUTBITSHIGH( thumbH58_word1, part1, 2, 50); - PUTBITSHIGH( thumbH58_word1, part2, 16, 48); - PUTBITSHIGH( thumbH58_word1, part3, 1, 32); - - thumbH58_word2 = thumbH_word2; +void +unstuff58bits(unsigned int thumbH_word1, unsigned int thumbH_word2, unsigned int &thumbH58_word1, unsigned int &thumbH58_word2) { + // Go to this layout: + // + // |63 62 61 60 59 58|57 56 55 54 53 52 51|50 49|48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33|32 | + // |-------empty-----|part0---------------|part1|part2------------------------------------------|part3| + // + // from this: + // + // 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 + // --------------------------------------------------------------------------------------------------| + // |//|part0 |// // //|part1|//|part2 |df|part3| + // --------------------------------------------------------------------------------------------------| + + unsigned int part0, part1, part2, part3; + + // move parts + part0 = GETBITSHIGH(thumbH_word1, 7, 62); + part1 = GETBITSHIGH(thumbH_word1, 2, 52); + part2 = GETBITSHIGH(thumbH_word1, 16, 49); + part3 = GETBITSHIGH(thumbH_word1, 1, 32); + thumbH58_word1 = 0; + PUTBITSHIGH(thumbH58_word1, part0, 7, 57); + PUTBITSHIGH(thumbH58_word1, part1, 2, 50); + PUTBITSHIGH(thumbH58_word1, part2, 16, 48); + PUTBITSHIGH(thumbH58_word1, part3, 1, 32); + + thumbH58_word2 = thumbH_word2; } // The format stores the bits for the three extra modes in a roundabout way to be able to // fit them without increasing the bit rate. This function converts them into something -// that is easier to work with. +// that is easier to work with. // NO WARRANTY --- SEE STATEMENT IN TOP OF FILE (C) Ericsson AB 2013. All Rights Reserved. -void unstuff59bits(unsigned int thumbT_word1, unsigned int thumbT_word2, unsigned int &thumbT59_word1, unsigned int &thumbT59_word2) -{ - // Get bits from twotimer configuration 59 bits. - // - // Go to this bit layout: - // - // |63 62 61 60 59|58 57 56 55|54 53 52 51|50 49 48 47|46 45 44 43|42 41 40 39|38 37 36 35|34 33 32| - // |----empty-----|---red 0---|--green 0--|--blue 0---|---red 1---|--green 1--|--blue 1---|--dist--| - // - // |31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00| - // |----------------------------------------index bits---------------------------------------------| - // - // - // From this: - // - // 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 - // ----------------------------------------------------------------------------------------------- - // |// // //|R0a |//|R0b |G0 |B0 |R1 |G1 |B1 |da |df|db| - // ----------------------------------------------------------------------------------------------- - // - // |31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00| - // |----------------------------------------index bits---------------------------------------------| - // - // 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 - // ----------------------------------------------------------------------------------------------- - // | base col1 | dcol 2 | base col1 | dcol 2 | base col 1 | dcol 2 | table | table |df|fp| - // | R1' (5 bits) | dR2 | G1' (5 bits) | dG2 | B1' (5 bits) | dB2 | cw 1 | cw 2 |bt|bt| - // ------------------------------------------------------------------------------------------------ - - uint8 R0a; - - // Fix middle part - thumbT59_word1 = thumbT_word1 >> 1; - // Fix db (lowest bit of d) - PUTBITSHIGH( thumbT59_word1, thumbT_word1, 1, 32); - // Fix R0a (top two bits of R0) - R0a = GETBITSHIGH( thumbT_word1, 2, 60); - PUTBITSHIGH( thumbT59_word1, R0a, 2, 58); - - // Zero top part (not needed) - PUTBITSHIGH( thumbT59_word1, 0, 5, 63); - - thumbT59_word2 = thumbT_word2; +void +unstuff59bits(unsigned int thumbT_word1, unsigned int thumbT_word2, unsigned int &thumbT59_word1, unsigned int &thumbT59_word2) { + // Get bits from twotimer configuration 59 bits. + // + // Go to this bit layout: + // + // |63 62 61 60 59|58 57 56 55|54 53 52 51|50 49 48 47|46 45 44 43|42 41 40 39|38 37 36 35|34 33 32| + // |----empty-----|---red 0---|--green 0--|--blue 0---|---red 1---|--green 1--|--blue 1---|--dist--| + // + // |31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00| + // |----------------------------------------index bits---------------------------------------------| + // + // + // From this: + // + // 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 + // ----------------------------------------------------------------------------------------------- + // |// // //|R0a |//|R0b |G0 |B0 |R1 |G1 |B1 |da |df|db| + // ----------------------------------------------------------------------------------------------- + // + // |31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00| + // |----------------------------------------index bits---------------------------------------------| + // + // 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 + // ----------------------------------------------------------------------------------------------- + // | base col1 | dcol 2 | base col1 | dcol 2 | base col 1 | dcol 2 | table | table |df|fp| + // | R1' (5 bits) | dR2 | G1' (5 bits) | dG2 | B1' (5 bits) | dB2 | cw 1 | cw 2 |bt|bt| + // ------------------------------------------------------------------------------------------------ + + uint8 R0a; + + // Fix middle part + thumbT59_word1 = thumbT_word1 >> 1; + // Fix db (lowest bit of d) + PUTBITSHIGH(thumbT59_word1, thumbT_word1, 1, 32); + // Fix R0a (top two bits of R0) + R0a = GETBITSHIGH(thumbT_word1, 2, 60); + PUTBITSHIGH(thumbT59_word1, R0a, 2, 58); + + // Zero top part (not needed) + PUTBITSHIGH(thumbT59_word1, 0, 5, 63); + + thumbT59_word2 = thumbT_word2; } // The color bits are expanded to the full color // NO WARRANTY --- SEE STATEMENT IN TOP OF FILE (C) Ericsson AB 2013. All Rights Reserved. -void decompressColor(int R_B, int G_B, int B_B, uint8 (colors_RGB444)[2][3], uint8 (colors)[2][3]) -{ - // The color should be retrieved as: - // - // c = round(255/(r_bits^2-1))*comp_color - // - // This is similar to bit replication - // - // Note -- this code only work for bit replication from 4 bits and up --- 3 bits needs - // two copy operations. - - colors[0][R] = (colors_RGB444[0][R] << (8 - R_B)) | (colors_RGB444[0][R] >> (R_B - (8-R_B)) ); - colors[0][G] = (colors_RGB444[0][G] << (8 - G_B)) | (colors_RGB444[0][G] >> (G_B - (8-G_B)) ); - colors[0][B] = (colors_RGB444[0][B] << (8 - B_B)) | (colors_RGB444[0][B] >> (B_B - (8-B_B)) ); - colors[1][R] = (colors_RGB444[1][R] << (8 - R_B)) | (colors_RGB444[1][R] >> (R_B - (8-R_B)) ); - colors[1][G] = (colors_RGB444[1][G] << (8 - G_B)) | (colors_RGB444[1][G] >> (G_B - (8-G_B)) ); - colors[1][B] = (colors_RGB444[1][B] << (8 - B_B)) | (colors_RGB444[1][B] >> (B_B - (8-B_B)) ); +void +decompressColor(int R_B, int G_B, int B_B, uint8(colors_RGB444)[2][3], uint8(colors)[2][3]) { + // The color should be retrieved as: + // + // c = round(255/(r_bits^2-1))*comp_color + // + // This is similar to bit replication + // + // Note -- this code only work for bit replication from 4 bits and up --- 3 bits needs + // two copy operations. + + colors[0][R] = (colors_RGB444[0][R] << (8 - R_B)) | (colors_RGB444[0][R] >> (R_B - (8 - R_B))); + colors[0][G] = (colors_RGB444[0][G] << (8 - G_B)) | (colors_RGB444[0][G] >> (G_B - (8 - G_B))); + colors[0][B] = (colors_RGB444[0][B] << (8 - B_B)) | (colors_RGB444[0][B] >> (B_B - (8 - B_B))); + colors[1][R] = (colors_RGB444[1][R] << (8 - R_B)) | (colors_RGB444[1][R] >> (R_B - (8 - R_B))); + colors[1][G] = (colors_RGB444[1][G] << (8 - G_B)) | (colors_RGB444[1][G] >> (G_B - (8 - G_B))); + colors[1][B] = (colors_RGB444[1][B] << (8 - B_B)) | (colors_RGB444[1][B] >> (B_B - (8 - B_B))); } -void calculatePaintColors59T(uint8 d, uint8 p, uint8 (colors)[2][3], uint8 (possible_colors)[4][3]) -{ - ////////////////////////////////////////////// - // - // C3 C1 C4----C1---C2 - // | | | - // | | | - // |-------| | - // | | | - // | | | - // C4 C2 C3 - // - ////////////////////////////////////////////// - - // C4 - possible_colors[3][R] = CLAMP(0,colors[1][R] - table59T[d],255); - possible_colors[3][G] = CLAMP(0,colors[1][G] - table59T[d],255); - possible_colors[3][B] = CLAMP(0,colors[1][B] - table59T[d],255); - - if (p == PATTERN_T) - { - // C3 - possible_colors[0][R] = colors[0][R]; - possible_colors[0][G] = colors[0][G]; - possible_colors[0][B] = colors[0][B]; - // C2 - possible_colors[1][R] = CLAMP(0,colors[1][R] + table59T[d],255); - possible_colors[1][G] = CLAMP(0,colors[1][G] + table59T[d],255); - possible_colors[1][B] = CLAMP(0,colors[1][B] + table59T[d],255); - // C1 - possible_colors[2][R] = colors[1][R]; - possible_colors[2][G] = colors[1][G]; - possible_colors[2][B] = colors[1][B]; - - } - else - { - printf("Invalid pattern. Terminating"); - exit(1); - } +void +calculatePaintColors59T(uint8 d, uint8 p, uint8(colors)[2][3], uint8(possible_colors)[4][3]) { + ////////////////////////////////////////////// + // + // C3 C1 C4----C1---C2 + // | | | + // | | | + // |-------| | + // | | | + // | | | + // C4 C2 C3 + // + ////////////////////////////////////////////// + + // C4 + possible_colors[3][R] = CLAMP(0, colors[1][R] - table59T[d], 255); + possible_colors[3][G] = CLAMP(0, colors[1][G] - table59T[d], 255); + possible_colors[3][B] = CLAMP(0, colors[1][B] - table59T[d], 255); + + if (p == PATTERN_T) { + // C3 + possible_colors[0][R] = colors[0][R]; + possible_colors[0][G] = colors[0][G]; + possible_colors[0][B] = colors[0][B]; + // C2 + possible_colors[1][R] = CLAMP(0, colors[1][R] + table59T[d], 255); + possible_colors[1][G] = CLAMP(0, colors[1][G] + table59T[d], 255); + possible_colors[1][B] = CLAMP(0, colors[1][B] + table59T[d], 255); + // C1 + possible_colors[2][R] = colors[1][R]; + possible_colors[2][G] = colors[1][G]; + possible_colors[2][B] = colors[1][B]; + + } else { + printf("Invalid pattern. Terminating"); + exit(1); + } } // Decompress a T-mode block (simple packing) // Simple 59T packing: @@ -568,1077 +549,960 @@ void calculatePaintColors59T(uint8 d, uint8 p, uint8 (colors)[2][3], uint8 (poss //|31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00| //|----------------------------------------index bits---------------------------------------------| // NO WARRANTY --- SEE STATEMENT IN TOP OF FILE (C) Ericsson AB 2013. All Rights Reserved. -void decompressBlockTHUMB59Tc(unsigned int block_part1, unsigned int block_part2, uint8 *img,int width,int height,int startx,int starty, int channels) -{ - uint8 colorsRGB444[2][3]; - uint8 colors[2][3]; - uint8 paint_colors[4][3]; - uint8 distance; - uint8 block_mask[4][4]; - - // First decode left part of block. - colorsRGB444[0][R]= GETBITSHIGH(block_part1, 4, 58); - colorsRGB444[0][G]= GETBITSHIGH(block_part1, 4, 54); - colorsRGB444[0][B]= GETBITSHIGH(block_part1, 4, 50); - - colorsRGB444[1][R]= GETBITSHIGH(block_part1, 4, 46); - colorsRGB444[1][G]= GETBITSHIGH(block_part1, 4, 42); - colorsRGB444[1][B]= GETBITSHIGH(block_part1, 4, 38); - - distance = GETBITSHIGH(block_part1, TABLE_BITS_59T, 34); - - // Extend the two colors to RGB888 - decompressColor(R_BITS59T, G_BITS59T, B_BITS59T, colorsRGB444, colors); - calculatePaintColors59T(distance, PATTERN_T, colors, paint_colors); - - // Choose one of the four paint colors for each texel - for (uint8 x = 0; x < BLOCKWIDTH; ++x) - { - for (uint8 y = 0; y < BLOCKHEIGHT; ++y) - { - //block_mask[x][y] = GETBITS(block_part2,2,31-(y*4+x)*2); - block_mask[x][y] = GETBITS(block_part2,1,(y+x*4)+16)<<1; - block_mask[x][y] |= GETBITS(block_part2,1,(y+x*4)); - img[channels*((starty+y)*width+startx+x)+R] = - CLAMP(0,paint_colors[block_mask[x][y]][R],255); // RED - img[channels*((starty+y)*width+startx+x)+G] = - CLAMP(0,paint_colors[block_mask[x][y]][G],255); // GREEN - img[channels*((starty+y)*width+startx+x)+B] = - CLAMP(0,paint_colors[block_mask[x][y]][B],255); // BLUE - } - } +void +decompressBlockTHUMB59Tc(unsigned int block_part1, unsigned int block_part2, uint8 *img, int width, int height, int startx, + int starty, int channels) { + uint8 colorsRGB444[2][3]; + uint8 colors[2][3]; + uint8 paint_colors[4][3]; + uint8 distance; + uint8 block_mask[4][4]; + + // First decode left part of block. + colorsRGB444[0][R] = GETBITSHIGH(block_part1, 4, 58); + colorsRGB444[0][G] = GETBITSHIGH(block_part1, 4, 54); + colorsRGB444[0][B] = GETBITSHIGH(block_part1, 4, 50); + + colorsRGB444[1][R] = GETBITSHIGH(block_part1, 4, 46); + colorsRGB444[1][G] = GETBITSHIGH(block_part1, 4, 42); + colorsRGB444[1][B] = GETBITSHIGH(block_part1, 4, 38); + + distance = GETBITSHIGH(block_part1, TABLE_BITS_59T, 34); + + // Extend the two colors to RGB888 + decompressColor(R_BITS59T, G_BITS59T, B_BITS59T, colorsRGB444, colors); + calculatePaintColors59T(distance, PATTERN_T, colors, paint_colors); + + // Choose one of the four paint colors for each texel + for (uint8 x = 0; x < BLOCKWIDTH; ++x) { + for (uint8 y = 0; y < BLOCKHEIGHT; ++y) { + // block_mask[x][y] = GETBITS(block_part2,2,31-(y*4+x)*2); + block_mask[x][y] = GETBITS(block_part2, 1, (y + x * 4) + 16) << 1; + block_mask[x][y] |= GETBITS(block_part2, 1, (y + x * 4)); + img[channels * ((starty + y) * width + startx + x) + R] = CLAMP(0, paint_colors[block_mask[x][y]][R], 255); // RED + img[channels * ((starty + y) * width + startx + x) + G] = CLAMP(0, paint_colors[block_mask[x][y]][G], 255); // GREEN + img[channels * ((starty + y) * width + startx + x) + B] = CLAMP(0, paint_colors[block_mask[x][y]][B], 255); // BLUE + } + } } -void decompressBlockTHUMB59T(unsigned int block_part1, unsigned int block_part2, uint8 *img, int width, int height, int startx, int starty) -{ - decompressBlockTHUMB59Tc(block_part1, block_part2, img, width, height, startx, starty, 3); +void +decompressBlockTHUMB59T(unsigned int block_part1, unsigned int block_part2, uint8 *img, int width, int height, int startx, + int starty) { + decompressBlockTHUMB59Tc(block_part1, block_part2, img, width, height, startx, starty, 3); } -// Calculate the paint colors from the block colors +// Calculate the paint colors from the block colors // using a distance d and one of the H- or T-patterns. // NO WARRANTY --- SEE STATEMENT IN TOP OF FILE (C) Ericsson AB 2013. All Rights Reserved. -void calculatePaintColors58H(uint8 d, uint8 p, uint8 (colors)[2][3], uint8 (possible_colors)[4][3]) -{ - - ////////////////////////////////////////////// - // - // C3 C1 C4----C1---C2 - // | | | - // | | | - // |-------| | - // | | | - // | | | - // C4 C2 C3 - // - ////////////////////////////////////////////// - - // C4 - possible_colors[3][R] = CLAMP(0,colors[1][R] - table58H[d],255); - possible_colors[3][G] = CLAMP(0,colors[1][G] - table58H[d],255); - possible_colors[3][B] = CLAMP(0,colors[1][B] - table58H[d],255); - - if (p == PATTERN_H) - { - // C1 - possible_colors[0][R] = CLAMP(0,colors[0][R] + table58H[d],255); - possible_colors[0][G] = CLAMP(0,colors[0][G] + table58H[d],255); - possible_colors[0][B] = CLAMP(0,colors[0][B] + table58H[d],255); - // C2 - possible_colors[1][R] = CLAMP(0,colors[0][R] - table58H[d],255); - possible_colors[1][G] = CLAMP(0,colors[0][G] - table58H[d],255); - possible_colors[1][B] = CLAMP(0,colors[0][B] - table58H[d],255); - // C3 - possible_colors[2][R] = CLAMP(0,colors[1][R] + table58H[d],255); - possible_colors[2][G] = CLAMP(0,colors[1][G] + table58H[d],255); - possible_colors[2][B] = CLAMP(0,colors[1][B] + table58H[d],255); - } - else - { - printf("Invalid pattern. Terminating"); - exit(1); - } +void +calculatePaintColors58H(uint8 d, uint8 p, uint8(colors)[2][3], uint8(possible_colors)[4][3]) { + ////////////////////////////////////////////// + // + // C3 C1 C4----C1---C2 + // | | | + // | | | + // |-------| | + // | | | + // | | | + // C4 C2 C3 + // + ////////////////////////////////////////////// + + // C4 + possible_colors[3][R] = CLAMP(0, colors[1][R] - table58H[d], 255); + possible_colors[3][G] = CLAMP(0, colors[1][G] - table58H[d], 255); + possible_colors[3][B] = CLAMP(0, colors[1][B] - table58H[d], 255); + + if (p == PATTERN_H) { + // C1 + possible_colors[0][R] = CLAMP(0, colors[0][R] + table58H[d], 255); + possible_colors[0][G] = CLAMP(0, colors[0][G] + table58H[d], 255); + possible_colors[0][B] = CLAMP(0, colors[0][B] + table58H[d], 255); + // C2 + possible_colors[1][R] = CLAMP(0, colors[0][R] - table58H[d], 255); + possible_colors[1][G] = CLAMP(0, colors[0][G] - table58H[d], 255); + possible_colors[1][B] = CLAMP(0, colors[0][B] - table58H[d], 255); + // C3 + possible_colors[2][R] = CLAMP(0, colors[1][R] + table58H[d], 255); + possible_colors[2][G] = CLAMP(0, colors[1][G] + table58H[d], 255); + possible_colors[2][B] = CLAMP(0, colors[1][B] + table58H[d], 255); + } else { + printf("Invalid pattern. Terminating"); + exit(1); + } } -// Decompress an H-mode block +// Decompress an H-mode block // NO WARRANTY --- SEE STATEMENT IN TOP OF FILE (C) Ericsson AB 2013. All Rights Reserved. -void decompressBlockTHUMB58Hc(unsigned int block_part1, unsigned int block_part2, uint8 *img, int width, int height, int startx, int starty, int channels) -{ - unsigned int col0, col1; - uint8 colors[2][3]; - uint8 colorsRGB444[2][3]; - uint8 paint_colors[4][3]; - uint8 distance; - uint8 block_mask[4][4]; - - // First decode left part of block. - colorsRGB444[0][R]= GETBITSHIGH(block_part1, 4, 57); - colorsRGB444[0][G]= GETBITSHIGH(block_part1, 4, 53); - colorsRGB444[0][B]= GETBITSHIGH(block_part1, 4, 49); - - colorsRGB444[1][R]= GETBITSHIGH(block_part1, 4, 45); - colorsRGB444[1][G]= GETBITSHIGH(block_part1, 4, 41); - colorsRGB444[1][B]= GETBITSHIGH(block_part1, 4, 37); - - distance = 0; - distance = (GETBITSHIGH(block_part1, 2, 33)) << 1; - - col0 = GETBITSHIGH(block_part1, 12, 57); - col1 = GETBITSHIGH(block_part1, 12, 45); - - if(col0 >= col1) - { - distance |= 1; - } - - // Extend the two colors to RGB888 - decompressColor(R_BITS58H, G_BITS58H, B_BITS58H, colorsRGB444, colors); - - calculatePaintColors58H(distance, PATTERN_H, colors, paint_colors); - - // Choose one of the four paint colors for each texel - for (uint8 x = 0; x < BLOCKWIDTH; ++x) - { - for (uint8 y = 0; y < BLOCKHEIGHT; ++y) - { - //block_mask[x][y] = GETBITS(block_part2,2,31-(y*4+x)*2); - block_mask[x][y] = GETBITS(block_part2,1,(y+x*4)+16)<<1; - block_mask[x][y] |= GETBITS(block_part2,1,(y+x*4)); - img[channels*((starty+y)*width+startx+x)+R] = - CLAMP(0,paint_colors[block_mask[x][y]][R],255); // RED - img[channels*((starty+y)*width+startx+x)+G] = - CLAMP(0,paint_colors[block_mask[x][y]][G],255); // GREEN - img[channels*((starty+y)*width+startx+x)+B] = - CLAMP(0,paint_colors[block_mask[x][y]][B],255); // BLUE - } - } +void +decompressBlockTHUMB58Hc(unsigned int block_part1, unsigned int block_part2, uint8 *img, int width, int height, int startx, + int starty, int channels) { + unsigned int col0, col1; + uint8 colors[2][3]; + uint8 colorsRGB444[2][3]; + uint8 paint_colors[4][3]; + uint8 distance; + uint8 block_mask[4][4]; + + // First decode left part of block. + colorsRGB444[0][R] = GETBITSHIGH(block_part1, 4, 57); + colorsRGB444[0][G] = GETBITSHIGH(block_part1, 4, 53); + colorsRGB444[0][B] = GETBITSHIGH(block_part1, 4, 49); + + colorsRGB444[1][R] = GETBITSHIGH(block_part1, 4, 45); + colorsRGB444[1][G] = GETBITSHIGH(block_part1, 4, 41); + colorsRGB444[1][B] = GETBITSHIGH(block_part1, 4, 37); + + distance = 0; + distance = (GETBITSHIGH(block_part1, 2, 33)) << 1; + + col0 = GETBITSHIGH(block_part1, 12, 57); + col1 = GETBITSHIGH(block_part1, 12, 45); + + if (col0 >= col1) { + distance |= 1; + } + + // Extend the two colors to RGB888 + decompressColor(R_BITS58H, G_BITS58H, B_BITS58H, colorsRGB444, colors); + + calculatePaintColors58H(distance, PATTERN_H, colors, paint_colors); + + // Choose one of the four paint colors for each texel + for (uint8 x = 0; x < BLOCKWIDTH; ++x) { + for (uint8 y = 0; y < BLOCKHEIGHT; ++y) { + // block_mask[x][y] = GETBITS(block_part2,2,31-(y*4+x)*2); + block_mask[x][y] = GETBITS(block_part2, 1, (y + x * 4) + 16) << 1; + block_mask[x][y] |= GETBITS(block_part2, 1, (y + x * 4)); + img[channels * ((starty + y) * width + startx + x) + R] = CLAMP(0, paint_colors[block_mask[x][y]][R], 255); // RED + img[channels * ((starty + y) * width + startx + x) + G] = CLAMP(0, paint_colors[block_mask[x][y]][G], 255); // GREEN + img[channels * ((starty + y) * width + startx + x) + B] = CLAMP(0, paint_colors[block_mask[x][y]][B], 255); // BLUE + } + } } -void decompressBlockTHUMB58H(unsigned int block_part1, unsigned int block_part2, uint8 *img, int width, int height, int startx, int starty) -{ - decompressBlockTHUMB58Hc(block_part1, block_part2, img, width, height, startx, starty, 3); +void +decompressBlockTHUMB58H(unsigned int block_part1, unsigned int block_part2, uint8 *img, int width, int height, int startx, + int starty) { + decompressBlockTHUMB58Hc(block_part1, block_part2, img, width, height, startx, starty, 3); } // Decompress the planar mode. // NO WARRANTY --- SEE STATEMENT IN TOP OF FILE (C) Ericsson AB 2013. All Rights Reserved. -void decompressBlockPlanar57c(unsigned int compressed57_1, unsigned int compressed57_2, uint8 *img, int width, int height, int startx, int starty, int channels) -{ - uint8 colorO[3], colorH[3], colorV[3]; - - colorO[0] = GETBITSHIGH( compressed57_1, 6, 63); - colorO[1] = GETBITSHIGH( compressed57_1, 7, 57); - colorO[2] = GETBITSHIGH( compressed57_1, 6, 50); - colorH[0] = GETBITSHIGH( compressed57_1, 6, 44); - colorH[1] = GETBITSHIGH( compressed57_1, 7, 38); - colorH[2] = GETBITS( compressed57_2, 6, 31); - colorV[0] = GETBITS( compressed57_2, 6, 25); - colorV[1] = GETBITS( compressed57_2, 7, 19); - colorV[2] = GETBITS( compressed57_2, 6, 12); - - colorO[0] = (colorO[0] << 2) | (colorO[0] >> 4); - colorO[1] = (colorO[1] << 1) | (colorO[1] >> 6); - colorO[2] = (colorO[2] << 2) | (colorO[2] >> 4); - - colorH[0] = (colorH[0] << 2) | (colorH[0] >> 4); - colorH[1] = (colorH[1] << 1) | (colorH[1] >> 6); - colorH[2] = (colorH[2] << 2) | (colorH[2] >> 4); - - colorV[0] = (colorV[0] << 2) | (colorV[0] >> 4); - colorV[1] = (colorV[1] << 1) | (colorV[1] >> 6); - colorV[2] = (colorV[2] << 2) | (colorV[2] >> 4); - - int xx, yy; - - for( xx=0; xx<4; xx++) - { - for( yy=0; yy<4; yy++) - { - img[channels*width*(starty+yy) + channels*(startx+xx) + 0] = CLAMP(0, ((xx*(colorH[0]-colorO[0]) + yy*(colorV[0]-colorO[0]) + 4*colorO[0] + 2) >> 2),255); - img[channels*width*(starty+yy) + channels*(startx+xx) + 1] = CLAMP(0, ((xx*(colorH[1]-colorO[1]) + yy*(colorV[1]-colorO[1]) + 4*colorO[1] + 2) >> 2),255); - img[channels*width*(starty+yy) + channels*(startx+xx) + 2] = CLAMP(0, ((xx*(colorH[2]-colorO[2]) + yy*(colorV[2]-colorO[2]) + 4*colorO[2] + 2) >> 2),255); - - //Equivalent method - /*img[channels*width*(starty+yy) + channels*(startx+xx) + 0] = (int)CLAMP(0, JAS_ROUND((xx*(colorH[0]-colorO[0])/4.0 + yy*(colorV[0]-colorO[0])/4.0 + colorO[0])), 255); - img[channels*width*(starty+yy) + channels*(startx+xx) + 1] = (int)CLAMP(0, JAS_ROUND((xx*(colorH[1]-colorO[1])/4.0 + yy*(colorV[1]-colorO[1])/4.0 + colorO[1])), 255); - img[channels*width*(starty+yy) + channels*(startx+xx) + 2] = (int)CLAMP(0, JAS_ROUND((xx*(colorH[2]-colorO[2])/4.0 + yy*(colorV[2]-colorO[2])/4.0 + colorO[2])), 255);*/ - - } - } +void +decompressBlockPlanar57c(unsigned int compressed57_1, unsigned int compressed57_2, uint8 *img, int width, int height, int startx, + int starty, int channels) { + uint8 colorO[3], colorH[3], colorV[3]; + + colorO[0] = GETBITSHIGH(compressed57_1, 6, 63); + colorO[1] = GETBITSHIGH(compressed57_1, 7, 57); + colorO[2] = GETBITSHIGH(compressed57_1, 6, 50); + colorH[0] = GETBITSHIGH(compressed57_1, 6, 44); + colorH[1] = GETBITSHIGH(compressed57_1, 7, 38); + colorH[2] = GETBITS(compressed57_2, 6, 31); + colorV[0] = GETBITS(compressed57_2, 6, 25); + colorV[1] = GETBITS(compressed57_2, 7, 19); + colorV[2] = GETBITS(compressed57_2, 6, 12); + + colorO[0] = (colorO[0] << 2) | (colorO[0] >> 4); + colorO[1] = (colorO[1] << 1) | (colorO[1] >> 6); + colorO[2] = (colorO[2] << 2) | (colorO[2] >> 4); + + colorH[0] = (colorH[0] << 2) | (colorH[0] >> 4); + colorH[1] = (colorH[1] << 1) | (colorH[1] >> 6); + colorH[2] = (colorH[2] << 2) | (colorH[2] >> 4); + + colorV[0] = (colorV[0] << 2) | (colorV[0] >> 4); + colorV[1] = (colorV[1] << 1) | (colorV[1] >> 6); + colorV[2] = (colorV[2] << 2) | (colorV[2] >> 4); + + int xx, yy; + + for (xx = 0; xx < 4; xx++) { + for (yy = 0; yy < 4; yy++) { + img[channels * width * (starty + yy) + channels * (startx + xx) + 0] = + CLAMP(0, ((xx * (colorH[0] - colorO[0]) + yy * (colorV[0] - colorO[0]) + 4 * colorO[0] + 2) >> 2), 255); + img[channels * width * (starty + yy) + channels * (startx + xx) + 1] = + CLAMP(0, ((xx * (colorH[1] - colorO[1]) + yy * (colorV[1] - colorO[1]) + 4 * colorO[1] + 2) >> 2), 255); + img[channels * width * (starty + yy) + channels * (startx + xx) + 2] = + CLAMP(0, ((xx * (colorH[2] - colorO[2]) + yy * (colorV[2] - colorO[2]) + 4 * colorO[2] + 2) >> 2), 255); + + // Equivalent method + /*img[channels*width*(starty+yy) + channels*(startx+xx) + 0] = (int)CLAMP(0, JAS_ROUND((xx*(colorH[0]-colorO[0])/4.0 + + yy*(colorV[0]-colorO[0])/4.0 + colorO[0])), 255); img[channels*width*(starty+yy) + channels*(startx+xx) + 1] = + (int)CLAMP(0, JAS_ROUND((xx*(colorH[1]-colorO[1])/4.0 + yy*(colorV[1]-colorO[1])/4.0 + colorO[1])), 255); + img[channels*width*(starty+yy) + channels*(startx+xx) + 2] = (int)CLAMP(0, JAS_ROUND((xx*(colorH[2]-colorO[2])/4.0 + + yy*(colorV[2]-colorO[2])/4.0 + colorO[2])), 255);*/ + } + } } -void decompressBlockPlanar57(unsigned int compressed57_1, unsigned int compressed57_2, uint8 *img, int width, int height, int startx, int starty) -{ - decompressBlockPlanar57c(compressed57_1, compressed57_2, img, width, height, startx, starty, 3); +void +decompressBlockPlanar57(unsigned int compressed57_1, unsigned int compressed57_2, uint8 *img, int width, int height, int startx, + int starty) { + decompressBlockPlanar57c(compressed57_1, compressed57_2, img, width, height, startx, starty, 3); } // Decompress an ETC1 block (or ETC2 using individual or differential mode). // NO WARRANTY --- SEE STATEMENT IN TOP OF FILE (C) Ericsson AB 2013. All Rights Reserved. -void decompressBlockDiffFlipC(unsigned int block_part1, unsigned int block_part2, uint8 *img, int width, int height, int startx, int starty, int channels) -{ - uint8 avg_color[3], enc_color1[3], enc_color2[3]; - signed char diff[3]; - int table; - int index,shift; - int r,g,b; - int diffbit; - int flipbit; - - diffbit = (GETBITSHIGH(block_part1, 1, 33)); - flipbit = (GETBITSHIGH(block_part1, 1, 32)); - - if( !diffbit ) - { - // We have diffbit = 0. - - // First decode left part of block. - avg_color[0]= GETBITSHIGH(block_part1, 4, 63); - avg_color[1]= GETBITSHIGH(block_part1, 4, 55); - avg_color[2]= GETBITSHIGH(block_part1, 4, 47); - - // Here, we should really multiply by 17 instead of 16. This can - // be done by just copying the four lower bits to the upper ones - // while keeping the lower bits. - avg_color[0] |= (avg_color[0] <<4); - avg_color[1] |= (avg_color[1] <<4); - avg_color[2] |= (avg_color[2] <<4); - - table = GETBITSHIGH(block_part1, 3, 39) << 1; - - unsigned int pixel_indices_MSB, pixel_indices_LSB; - - pixel_indices_MSB = GETBITS(block_part2, 16, 31); - pixel_indices_LSB = GETBITS(block_part2, 16, 15); - - if( (flipbit) == 0 ) - { - // We should not flip - shift = 0; - for(int x=startx; x> shift) & 1) << 1; - index |= ((pixel_indices_LSB >> shift) & 1); - shift++; - index=unscramble[index]; - - r=RED_CHANNEL(img,width,x,y,channels) =CLAMP(0,avg_color[0]+compressParams[table][index],255); - g=GREEN_CHANNEL(img,width,x,y,channels)=CLAMP(0,avg_color[1]+compressParams[table][index],255); - b=BLUE_CHANNEL(img,width,x,y,channels) =CLAMP(0,avg_color[2]+compressParams[table][index],255); - } - } - } - else - { - // We should flip - shift = 0; - for(int x=startx; x> shift) & 1) << 1; - index |= ((pixel_indices_LSB >> shift) & 1); - shift++; - index=unscramble[index]; - - r=RED_CHANNEL(img,width,x,y,channels) =CLAMP(0,avg_color[0]+compressParams[table][index],255); - g=GREEN_CHANNEL(img,width,x,y,channels)=CLAMP(0,avg_color[1]+compressParams[table][index],255); - b=BLUE_CHANNEL(img,width,x,y,channels) =CLAMP(0,avg_color[2]+compressParams[table][index],255); - } - shift+=2; - } - } - - // Now decode other part of block. - avg_color[0]= GETBITSHIGH(block_part1, 4, 59); - avg_color[1]= GETBITSHIGH(block_part1, 4, 51); - avg_color[2]= GETBITSHIGH(block_part1, 4, 43); - - // Here, we should really multiply by 17 instead of 16. This can - // be done by just copying the four lower bits to the upper ones - // while keeping the lower bits. - avg_color[0] |= (avg_color[0] <<4); - avg_color[1] |= (avg_color[1] <<4); - avg_color[2] |= (avg_color[2] <<4); - - table = GETBITSHIGH(block_part1, 3, 36) << 1; - pixel_indices_MSB = GETBITS(block_part2, 16, 31); - pixel_indices_LSB = GETBITS(block_part2, 16, 15); - - if( (flipbit) == 0 ) - { - // We should not flip - shift=8; - for(int x=startx+2; x> shift) & 1) << 1; - index |= ((pixel_indices_LSB >> shift) & 1); - shift++; - index=unscramble[index]; - - r=RED_CHANNEL(img,width,x,y,channels) =CLAMP(0,avg_color[0]+compressParams[table][index],255); - g=GREEN_CHANNEL(img,width,x,y,channels)=CLAMP(0,avg_color[1]+compressParams[table][index],255); - b=BLUE_CHANNEL(img,width,x,y,channels) =CLAMP(0,avg_color[2]+compressParams[table][index],255); - } - } - } - else - { - // We should flip - shift=2; - for(int x=startx; x> shift) & 1) << 1; - index |= ((pixel_indices_LSB >> shift) & 1); - shift++; - index=unscramble[index]; - - r=RED_CHANNEL(img,width,x,y,channels) =CLAMP(0,avg_color[0]+compressParams[table][index],255); - g=GREEN_CHANNEL(img,width,x,y,channels)=CLAMP(0,avg_color[1]+compressParams[table][index],255); - b=BLUE_CHANNEL(img,width,x,y,channels) =CLAMP(0,avg_color[2]+compressParams[table][index],255); - } - shift += 2; - } - } - } - else - { - // We have diffbit = 1. - -// 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 -// --------------------------------------------------------------------------------------------------- -// | base col1 | dcol 2 | base col1 | dcol 2 | base col 1 | dcol 2 | table | table |diff|flip| -// | R1' (5 bits) | dR2 | G1' (5 bits) | dG2 | B1' (5 bits) | dB2 | cw 1 | cw 2 |bit |bit | -// --------------------------------------------------------------------------------------------------- -// -// -// c) bit layout in bits 31 through 0 (in both cases) -// -// 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 -// -------------------------------------------------------------------------------------------------- -// | most significant pixel index bits | least significant pixel index bits | -// | p| o| n| m| l| k| j| i| h| g| f| e| d| c| b| a| p| o| n| m| l| k| j| i| h| g| f| e| d| c | b | a | -// -------------------------------------------------------------------------------------------------- - - // First decode left part of block. - enc_color1[0]= GETBITSHIGH(block_part1, 5, 63); - enc_color1[1]= GETBITSHIGH(block_part1, 5, 55); - enc_color1[2]= GETBITSHIGH(block_part1, 5, 47); - - // Expand from 5 to 8 bits - avg_color[0] = (enc_color1[0] <<3) | (enc_color1[0] >> 2); - avg_color[1] = (enc_color1[1] <<3) | (enc_color1[1] >> 2); - avg_color[2] = (enc_color1[2] <<3) | (enc_color1[2] >> 2); - - table = GETBITSHIGH(block_part1, 3, 39) << 1; - - unsigned int pixel_indices_MSB, pixel_indices_LSB; - - pixel_indices_MSB = GETBITS(block_part2, 16, 31); - pixel_indices_LSB = GETBITS(block_part2, 16, 15); - - if( (flipbit) == 0 ) - { - // We should not flip - shift = 0; - for(int x=startx; x> shift) & 1) << 1; - index |= ((pixel_indices_LSB >> shift) & 1); - shift++; - index=unscramble[index]; - - r=RED_CHANNEL(img,width,x,y,channels) =CLAMP(0,avg_color[0]+compressParams[table][index],255); - g=GREEN_CHANNEL(img,width,x,y,channels)=CLAMP(0,avg_color[1]+compressParams[table][index],255); - b=BLUE_CHANNEL(img,width,x,y,channels) =CLAMP(0,avg_color[2]+compressParams[table][index],255); - } - } - } - else - { - // We should flip - shift = 0; - for(int x=startx; x> shift) & 1) << 1; - index |= ((pixel_indices_LSB >> shift) & 1); - shift++; - index=unscramble[index]; - - r=RED_CHANNEL(img,width,x,y,channels) =CLAMP(0,avg_color[0]+compressParams[table][index],255); - g=GREEN_CHANNEL(img,width,x,y,channels)=CLAMP(0,avg_color[1]+compressParams[table][index],255); - b=BLUE_CHANNEL(img,width,x,y,channels) =CLAMP(0,avg_color[2]+compressParams[table][index],255); - } - shift+=2; - } - } - - // Now decode right part of block. - diff[0]= GETBITSHIGH(block_part1, 3, 58); - diff[1]= GETBITSHIGH(block_part1, 3, 50); - diff[2]= GETBITSHIGH(block_part1, 3, 42); - - // Extend sign bit to entire byte. - diff[0] = (diff[0] << 5); - diff[1] = (diff[1] << 5); - diff[2] = (diff[2] << 5); - diff[0] = diff[0] >> 5; - diff[1] = diff[1] >> 5; - diff[2] = diff[2] >> 5; - - // Calculale second color - enc_color2[0]= enc_color1[0] + diff[0]; - enc_color2[1]= enc_color1[1] + diff[1]; - enc_color2[2]= enc_color1[2] + diff[2]; - - // Expand from 5 to 8 bits - avg_color[0] = (enc_color2[0] <<3) | (enc_color2[0] >> 2); - avg_color[1] = (enc_color2[1] <<3) | (enc_color2[1] >> 2); - avg_color[2] = (enc_color2[2] <<3) | (enc_color2[2] >> 2); - - table = GETBITSHIGH(block_part1, 3, 36) << 1; - pixel_indices_MSB = GETBITS(block_part2, 16, 31); - pixel_indices_LSB = GETBITS(block_part2, 16, 15); - - if( (flipbit) == 0 ) - { - // We should not flip - shift=8; - for(int x=startx+2; x> shift) & 1) << 1; - index |= ((pixel_indices_LSB >> shift) & 1); - shift++; - index=unscramble[index]; - - r=RED_CHANNEL(img,width,x,y,channels) =CLAMP(0,avg_color[0]+compressParams[table][index],255); - g=GREEN_CHANNEL(img,width,x,y,channels)=CLAMP(0,avg_color[1]+compressParams[table][index],255); - b=BLUE_CHANNEL(img,width,x,y,channels) =CLAMP(0,avg_color[2]+compressParams[table][index],255); - } - } - } - else - { - // We should flip - shift=2; - for(int x=startx; x> shift) & 1) << 1; - index |= ((pixel_indices_LSB >> shift) & 1); - shift++; - index=unscramble[index]; - - r=RED_CHANNEL(img,width,x,y,channels) =CLAMP(0,avg_color[0]+compressParams[table][index],255); - g=GREEN_CHANNEL(img,width,x,y,channels)=CLAMP(0,avg_color[1]+compressParams[table][index],255); - b=BLUE_CHANNEL(img,width,x,y,channels) =CLAMP(0,avg_color[2]+compressParams[table][index],255); - } - shift += 2; - } - } - } +void +decompressBlockDiffFlipC(unsigned int block_part1, unsigned int block_part2, uint8 *img, int width, int height, int startx, + int starty, int channels) { + uint8 avg_color[3], enc_color1[3], enc_color2[3]; + signed char diff[3]; + int table; + int index, shift; + int r, g, b; + int diffbit; + int flipbit; + + diffbit = (GETBITSHIGH(block_part1, 1, 33)); + flipbit = (GETBITSHIGH(block_part1, 1, 32)); + + if (!diffbit) { + // We have diffbit = 0. + + // First decode left part of block. + avg_color[0] = GETBITSHIGH(block_part1, 4, 63); + avg_color[1] = GETBITSHIGH(block_part1, 4, 55); + avg_color[2] = GETBITSHIGH(block_part1, 4, 47); + + // Here, we should really multiply by 17 instead of 16. This can + // be done by just copying the four lower bits to the upper ones + // while keeping the lower bits. + avg_color[0] |= (avg_color[0] << 4); + avg_color[1] |= (avg_color[1] << 4); + avg_color[2] |= (avg_color[2] << 4); + + table = GETBITSHIGH(block_part1, 3, 39) << 1; + + unsigned int pixel_indices_MSB, pixel_indices_LSB; + + pixel_indices_MSB = GETBITS(block_part2, 16, 31); + pixel_indices_LSB = GETBITS(block_part2, 16, 15); + + if ((flipbit) == 0) { + // We should not flip + shift = 0; + for (int x = startx; x < startx + 2; x++) { + for (int y = starty; y < starty + 4; y++) { + index = ((pixel_indices_MSB >> shift) & 1) << 1; + index |= ((pixel_indices_LSB >> shift) & 1); + shift++; + index = unscramble[index]; + + r = RED_CHANNEL(img, width, x, y, channels) = CLAMP(0, avg_color[0] + compressParams[table][index], 255); + g = GREEN_CHANNEL(img, width, x, y, channels) = CLAMP(0, avg_color[1] + compressParams[table][index], 255); + b = BLUE_CHANNEL(img, width, x, y, channels) = CLAMP(0, avg_color[2] + compressParams[table][index], 255); + } + } + } else { + // We should flip + shift = 0; + for (int x = startx; x < startx + 4; x++) { + for (int y = starty; y < starty + 2; y++) { + index = ((pixel_indices_MSB >> shift) & 1) << 1; + index |= ((pixel_indices_LSB >> shift) & 1); + shift++; + index = unscramble[index]; + + r = RED_CHANNEL(img, width, x, y, channels) = CLAMP(0, avg_color[0] + compressParams[table][index], 255); + g = GREEN_CHANNEL(img, width, x, y, channels) = CLAMP(0, avg_color[1] + compressParams[table][index], 255); + b = BLUE_CHANNEL(img, width, x, y, channels) = CLAMP(0, avg_color[2] + compressParams[table][index], 255); + } + shift += 2; + } + } + + // Now decode other part of block. + avg_color[0] = GETBITSHIGH(block_part1, 4, 59); + avg_color[1] = GETBITSHIGH(block_part1, 4, 51); + avg_color[2] = GETBITSHIGH(block_part1, 4, 43); + + // Here, we should really multiply by 17 instead of 16. This can + // be done by just copying the four lower bits to the upper ones + // while keeping the lower bits. + avg_color[0] |= (avg_color[0] << 4); + avg_color[1] |= (avg_color[1] << 4); + avg_color[2] |= (avg_color[2] << 4); + + table = GETBITSHIGH(block_part1, 3, 36) << 1; + pixel_indices_MSB = GETBITS(block_part2, 16, 31); + pixel_indices_LSB = GETBITS(block_part2, 16, 15); + + if ((flipbit) == 0) { + // We should not flip + shift = 8; + for (int x = startx + 2; x < startx + 4; x++) { + for (int y = starty; y < starty + 4; y++) { + index = ((pixel_indices_MSB >> shift) & 1) << 1; + index |= ((pixel_indices_LSB >> shift) & 1); + shift++; + index = unscramble[index]; + + r = RED_CHANNEL(img, width, x, y, channels) = CLAMP(0, avg_color[0] + compressParams[table][index], 255); + g = GREEN_CHANNEL(img, width, x, y, channels) = CLAMP(0, avg_color[1] + compressParams[table][index], 255); + b = BLUE_CHANNEL(img, width, x, y, channels) = CLAMP(0, avg_color[2] + compressParams[table][index], 255); + } + } + } else { + // We should flip + shift = 2; + for (int x = startx; x < startx + 4; x++) { + for (int y = starty + 2; y < starty + 4; y++) { + index = ((pixel_indices_MSB >> shift) & 1) << 1; + index |= ((pixel_indices_LSB >> shift) & 1); + shift++; + index = unscramble[index]; + + r = RED_CHANNEL(img, width, x, y, channels) = CLAMP(0, avg_color[0] + compressParams[table][index], 255); + g = GREEN_CHANNEL(img, width, x, y, channels) = CLAMP(0, avg_color[1] + compressParams[table][index], 255); + b = BLUE_CHANNEL(img, width, x, y, channels) = CLAMP(0, avg_color[2] + compressParams[table][index], 255); + } + shift += 2; + } + } + } else { + // We have diffbit = 1. + + // 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 + // --------------------------------------------------------------------------------------------------- + // | base col1 | dcol 2 | base col1 | dcol 2 | base col 1 | dcol 2 | table | table |diff|flip| + // | R1' (5 bits) | dR2 | G1' (5 bits) | dG2 | B1' (5 bits) | dB2 | cw 1 | cw 2 |bit |bit | + // --------------------------------------------------------------------------------------------------- + // + // + // c) bit layout in bits 31 through 0 (in both cases) + // + // 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 + // -------------------------------------------------------------------------------------------------- + // | most significant pixel index bits | least significant pixel index bits | + // | p| o| n| m| l| k| j| i| h| g| f| e| d| c| b| a| p| o| n| m| l| k| j| i| h| g| f| e| d| c | b | a | + // -------------------------------------------------------------------------------------------------- + + // First decode left part of block. + enc_color1[0] = GETBITSHIGH(block_part1, 5, 63); + enc_color1[1] = GETBITSHIGH(block_part1, 5, 55); + enc_color1[2] = GETBITSHIGH(block_part1, 5, 47); + + // Expand from 5 to 8 bits + avg_color[0] = (enc_color1[0] << 3) | (enc_color1[0] >> 2); + avg_color[1] = (enc_color1[1] << 3) | (enc_color1[1] >> 2); + avg_color[2] = (enc_color1[2] << 3) | (enc_color1[2] >> 2); + + table = GETBITSHIGH(block_part1, 3, 39) << 1; + + unsigned int pixel_indices_MSB, pixel_indices_LSB; + + pixel_indices_MSB = GETBITS(block_part2, 16, 31); + pixel_indices_LSB = GETBITS(block_part2, 16, 15); + + if ((flipbit) == 0) { + // We should not flip + shift = 0; + for (int x = startx; x < startx + 2; x++) { + for (int y = starty; y < starty + 4; y++) { + index = ((pixel_indices_MSB >> shift) & 1) << 1; + index |= ((pixel_indices_LSB >> shift) & 1); + shift++; + index = unscramble[index]; + + r = RED_CHANNEL(img, width, x, y, channels) = CLAMP(0, avg_color[0] + compressParams[table][index], 255); + g = GREEN_CHANNEL(img, width, x, y, channels) = CLAMP(0, avg_color[1] + compressParams[table][index], 255); + b = BLUE_CHANNEL(img, width, x, y, channels) = CLAMP(0, avg_color[2] + compressParams[table][index], 255); + } + } + } else { + // We should flip + shift = 0; + for (int x = startx; x < startx + 4; x++) { + for (int y = starty; y < starty + 2; y++) { + index = ((pixel_indices_MSB >> shift) & 1) << 1; + index |= ((pixel_indices_LSB >> shift) & 1); + shift++; + index = unscramble[index]; + + r = RED_CHANNEL(img, width, x, y, channels) = CLAMP(0, avg_color[0] + compressParams[table][index], 255); + g = GREEN_CHANNEL(img, width, x, y, channels) = CLAMP(0, avg_color[1] + compressParams[table][index], 255); + b = BLUE_CHANNEL(img, width, x, y, channels) = CLAMP(0, avg_color[2] + compressParams[table][index], 255); + } + shift += 2; + } + } + + // Now decode right part of block. + diff[0] = GETBITSHIGH(block_part1, 3, 58); + diff[1] = GETBITSHIGH(block_part1, 3, 50); + diff[2] = GETBITSHIGH(block_part1, 3, 42); + + // Extend sign bit to entire byte. + diff[0] = (diff[0] << 5); + diff[1] = (diff[1] << 5); + diff[2] = (diff[2] << 5); + diff[0] = diff[0] >> 5; + diff[1] = diff[1] >> 5; + diff[2] = diff[2] >> 5; + + // Calculale second color + enc_color2[0] = enc_color1[0] + diff[0]; + enc_color2[1] = enc_color1[1] + diff[1]; + enc_color2[2] = enc_color1[2] + diff[2]; + + // Expand from 5 to 8 bits + avg_color[0] = (enc_color2[0] << 3) | (enc_color2[0] >> 2); + avg_color[1] = (enc_color2[1] << 3) | (enc_color2[1] >> 2); + avg_color[2] = (enc_color2[2] << 3) | (enc_color2[2] >> 2); + + table = GETBITSHIGH(block_part1, 3, 36) << 1; + pixel_indices_MSB = GETBITS(block_part2, 16, 31); + pixel_indices_LSB = GETBITS(block_part2, 16, 15); + + if ((flipbit) == 0) { + // We should not flip + shift = 8; + for (int x = startx + 2; x < startx + 4; x++) { + for (int y = starty; y < starty + 4; y++) { + index = ((pixel_indices_MSB >> shift) & 1) << 1; + index |= ((pixel_indices_LSB >> shift) & 1); + shift++; + index = unscramble[index]; + + r = RED_CHANNEL(img, width, x, y, channels) = CLAMP(0, avg_color[0] + compressParams[table][index], 255); + g = GREEN_CHANNEL(img, width, x, y, channels) = CLAMP(0, avg_color[1] + compressParams[table][index], 255); + b = BLUE_CHANNEL(img, width, x, y, channels) = CLAMP(0, avg_color[2] + compressParams[table][index], 255); + } + } + } else { + // We should flip + shift = 2; + for (int x = startx; x < startx + 4; x++) { + for (int y = starty + 2; y < starty + 4; y++) { + index = ((pixel_indices_MSB >> shift) & 1) << 1; + index |= ((pixel_indices_LSB >> shift) & 1); + shift++; + index = unscramble[index]; + + r = RED_CHANNEL(img, width, x, y, channels) = CLAMP(0, avg_color[0] + compressParams[table][index], 255); + g = GREEN_CHANNEL(img, width, x, y, channels) = CLAMP(0, avg_color[1] + compressParams[table][index], 255); + b = BLUE_CHANNEL(img, width, x, y, channels) = CLAMP(0, avg_color[2] + compressParams[table][index], 255); + } + shift += 2; + } + } + } } -void decompressBlockDiffFlip(unsigned int block_part1, unsigned int block_part2, uint8 *img, int width, int height, int startx, int starty) -{ - decompressBlockDiffFlipC(block_part1, block_part2, img, width, height, startx, starty, 3); +void +decompressBlockDiffFlip(unsigned int block_part1, unsigned int block_part2, uint8 *img, int width, int height, int startx, + int starty) { + decompressBlockDiffFlipC(block_part1, block_part2, img, width, height, startx, starty, 3); } // Decompress an ETC2 RGB block // NO WARRANTY --- SEE STATEMENT IN TOP OF FILE (C) Ericsson AB 2013. All Rights Reserved. -void decompressBlockETC2c(unsigned int block_part1, unsigned int block_part2, uint8 *img, int width, int height, int startx, int starty, int channels) -{ - int diffbit; - signed char color1[3]; - signed char diff[3]; - signed char red, green, blue; - - diffbit = (GETBITSHIGH(block_part1, 1, 33)); - - if( diffbit ) - { - // We have diffbit = 1; - - // Base color - color1[0]= GETBITSHIGH(block_part1, 5, 63); - color1[1]= GETBITSHIGH(block_part1, 5, 55); - color1[2]= GETBITSHIGH(block_part1, 5, 47); - - // Diff color - diff[0]= GETBITSHIGH(block_part1, 3, 58); - diff[1]= GETBITSHIGH(block_part1, 3, 50); - diff[2]= GETBITSHIGH(block_part1, 3, 42); - - // Extend sign bit to entire byte. - diff[0] = (diff[0] << 5); - diff[1] = (diff[1] << 5); - diff[2] = (diff[2] << 5); - diff[0] = diff[0] >> 5; - diff[1] = diff[1] >> 5; - diff[2] = diff[2] >> 5; - - red = color1[0] + diff[0]; - green = color1[1] + diff[1]; - blue = color1[2] + diff[2]; - - if(red < 0 || red > 31) - { - unsigned int block59_part1, block59_part2; - unstuff59bits(block_part1, block_part2, block59_part1, block59_part2); - decompressBlockTHUMB59Tc(block59_part1, block59_part2, img, width, height, startx, starty, channels); - } - else if (green < 0 || green > 31) - { - unsigned int block58_part1, block58_part2; - unstuff58bits(block_part1, block_part2, block58_part1, block58_part2); - decompressBlockTHUMB58Hc(block58_part1, block58_part2, img, width, height, startx, starty, channels); - } - else if(blue < 0 || blue > 31) - { - unsigned int block57_part1, block57_part2; - - unstuff57bits(block_part1, block_part2, block57_part1, block57_part2); - decompressBlockPlanar57c(block57_part1, block57_part2, img, width, height, startx, starty, channels); - } - else - { - decompressBlockDiffFlipC(block_part1, block_part2, img, width, height, startx, starty, channels); - } - } - else - { - // We have diffbit = 0; - decompressBlockDiffFlipC(block_part1, block_part2, img, width, height, startx, starty, channels); - } +void +decompressBlockETC2c(unsigned int block_part1, unsigned int block_part2, uint8 *img, int width, int height, int startx, int starty, + int channels) { + int diffbit; + signed char color1[3]; + signed char diff[3]; + signed char red, green, blue; + + diffbit = (GETBITSHIGH(block_part1, 1, 33)); + + if (diffbit) { + // We have diffbit = 1; + + // Base color + color1[0] = GETBITSHIGH(block_part1, 5, 63); + color1[1] = GETBITSHIGH(block_part1, 5, 55); + color1[2] = GETBITSHIGH(block_part1, 5, 47); + + // Diff color + diff[0] = GETBITSHIGH(block_part1, 3, 58); + diff[1] = GETBITSHIGH(block_part1, 3, 50); + diff[2] = GETBITSHIGH(block_part1, 3, 42); + + // Extend sign bit to entire byte. + diff[0] = (diff[0] << 5); + diff[1] = (diff[1] << 5); + diff[2] = (diff[2] << 5); + diff[0] = diff[0] >> 5; + diff[1] = diff[1] >> 5; + diff[2] = diff[2] >> 5; + + red = color1[0] + diff[0]; + green = color1[1] + diff[1]; + blue = color1[2] + diff[2]; + + if (red < 0 || red > 31) { + unsigned int block59_part1, block59_part2; + unstuff59bits(block_part1, block_part2, block59_part1, block59_part2); + decompressBlockTHUMB59Tc(block59_part1, block59_part2, img, width, height, startx, starty, channels); + } else if (green < 0 || green > 31) { + unsigned int block58_part1, block58_part2; + unstuff58bits(block_part1, block_part2, block58_part1, block58_part2); + decompressBlockTHUMB58Hc(block58_part1, block58_part2, img, width, height, startx, starty, channels); + } else if (blue < 0 || blue > 31) { + unsigned int block57_part1, block57_part2; + + unstuff57bits(block_part1, block_part2, block57_part1, block57_part2); + decompressBlockPlanar57c(block57_part1, block57_part2, img, width, height, startx, starty, channels); + } else { + decompressBlockDiffFlipC(block_part1, block_part2, img, width, height, startx, starty, channels); + } + } else { + // We have diffbit = 0; + decompressBlockDiffFlipC(block_part1, block_part2, img, width, height, startx, starty, channels); + } } -void decompressBlockETC2(unsigned int block_part1, unsigned int block_part2, uint8 *img, int width, int height, int startx, int starty) -{ - decompressBlockETC2c(block_part1, block_part2, img, width, height, startx, starty, 3); +void +decompressBlockETC2(unsigned int block_part1, unsigned int block_part2, uint8 *img, int width, int height, int startx, int starty) { + decompressBlockETC2c(block_part1, block_part2, img, width, height, startx, starty, 3); } // Decompress an ETC2 block with punchthrough alpha // NO WARRANTY --- SEE STATEMENT IN TOP OF FILE (C) Ericsson AB 2013. All Rights Reserved. -void decompressBlockDifferentialWithAlphaC(unsigned int block_part1, unsigned int block_part2, uint8* img, uint8* alpha, int width, int height, int startx, int starty, int channelsRGB) -{ - - uint8 avg_color[3], enc_color1[3], enc_color2[3]; - signed char diff[3]; - int table; - int index,shift; - int r,g,b; - int diffbit; - int flipbit; - int channelsA; - - if(channelsRGB == 3) - { - // We will decode the alpha data to a separate memory area. - channelsA = 1; - } - else - { - // We will decode the RGB data and the alpha data to the same memory area, - // interleaved as RGBA. - channelsA = 4; - alpha = &img[0+3]; - } - - //the diffbit now encodes whether or not the entire alpha channel is 255. - diffbit = (GETBITSHIGH(block_part1, 1, 33)); - flipbit = (GETBITSHIGH(block_part1, 1, 32)); - - // First decode left part of block. - enc_color1[0]= GETBITSHIGH(block_part1, 5, 63); - enc_color1[1]= GETBITSHIGH(block_part1, 5, 55); - enc_color1[2]= GETBITSHIGH(block_part1, 5, 47); - - // Expand from 5 to 8 bits - avg_color[0] = (enc_color1[0] <<3) | (enc_color1[0] >> 2); - avg_color[1] = (enc_color1[1] <<3) | (enc_color1[1] >> 2); - avg_color[2] = (enc_color1[2] <<3) | (enc_color1[2] >> 2); - - table = GETBITSHIGH(block_part1, 3, 39) << 1; - - unsigned int pixel_indices_MSB, pixel_indices_LSB; - - pixel_indices_MSB = GETBITS(block_part2, 16, 31); - pixel_indices_LSB = GETBITS(block_part2, 16, 15); - - if( (flipbit) == 0 ) - { - // We should not flip - shift = 0; - for(int x=startx; x> shift) & 1) << 1; - index |= ((pixel_indices_LSB >> shift) & 1); - shift++; - index=unscramble[index]; - - int mod = compressParams[table][index]; - if(diffbit==0&&(index==1||index==2)) - { - mod=0; - } - - r=RED_CHANNEL(img,width,x,y,channelsRGB) =CLAMP(0,avg_color[0]+mod,255); - g=GREEN_CHANNEL(img,width,x,y,channelsRGB)=CLAMP(0,avg_color[1]+mod,255); - b=BLUE_CHANNEL(img,width,x,y,channelsRGB) =CLAMP(0,avg_color[2]+mod,255); - if(diffbit==0&&index==1) - { - alpha[(y*width+x)*channelsA]=0; - r=RED_CHANNEL(img,width,x,y,channelsRGB)=0; - g=GREEN_CHANNEL(img,width,x,y,channelsRGB)=0; - b=BLUE_CHANNEL(img,width,x,y,channelsRGB)=0; - } - else - { - alpha[(y*width+x)*channelsA]=255; - } - - } - } - } - else - { - // We should flip - shift = 0; - for(int x=startx; x> shift) & 1) << 1; - index |= ((pixel_indices_LSB >> shift) & 1); - shift++; - index=unscramble[index]; - int mod = compressParams[table][index]; - if(diffbit==0&&(index==1||index==2)) - { - mod=0; - } - r=RED_CHANNEL(img,width,x,y,channelsRGB) =CLAMP(0,avg_color[0]+mod,255); - g=GREEN_CHANNEL(img,width,x,y,channelsRGB)=CLAMP(0,avg_color[1]+mod,255); - b=BLUE_CHANNEL(img,width,x,y,channelsRGB) =CLAMP(0,avg_color[2]+mod,255); - if(diffbit==0&&index==1) - { - alpha[(y*width+x)*channelsA]=0; - r=RED_CHANNEL(img,width,x,y,channelsRGB)=0; - g=GREEN_CHANNEL(img,width,x,y,channelsRGB)=0; - b=BLUE_CHANNEL(img,width,x,y,channelsRGB)=0; - } - else - { - alpha[(y*width+x)*channelsA]=255; - } - } - shift+=2; - } - } - // Now decode right part of block. - diff[0]= GETBITSHIGH(block_part1, 3, 58); - diff[1]= GETBITSHIGH(block_part1, 3, 50); - diff[2]= GETBITSHIGH(block_part1, 3, 42); - - // Extend sign bit to entire byte. - diff[0] = (diff[0] << 5); - diff[1] = (diff[1] << 5); - diff[2] = (diff[2] << 5); - diff[0] = diff[0] >> 5; - diff[1] = diff[1] >> 5; - diff[2] = diff[2] >> 5; - - // Calculate second color - enc_color2[0]= enc_color1[0] + diff[0]; - enc_color2[1]= enc_color1[1] + diff[1]; - enc_color2[2]= enc_color1[2] + diff[2]; - - // Expand from 5 to 8 bits - avg_color[0] = (enc_color2[0] <<3) | (enc_color2[0] >> 2); - avg_color[1] = (enc_color2[1] <<3) | (enc_color2[1] >> 2); - avg_color[2] = (enc_color2[2] <<3) | (enc_color2[2] >> 2); - - table = GETBITSHIGH(block_part1, 3, 36) << 1; - pixel_indices_MSB = GETBITS(block_part2, 16, 31); - pixel_indices_LSB = GETBITS(block_part2, 16, 15); - - if( (flipbit) == 0 ) - { - // We should not flip - shift=8; - for(int x=startx+2; x> shift) & 1) << 1; - index |= ((pixel_indices_LSB >> shift) & 1); - shift++; - index=unscramble[index]; - int mod = compressParams[table][index]; - if(diffbit==0&&(index==1||index==2)) - { - mod=0; - } - - r=RED_CHANNEL(img,width,x,y,channelsRGB) =CLAMP(0,avg_color[0]+mod,255); - g=GREEN_CHANNEL(img,width,x,y,channelsRGB)=CLAMP(0,avg_color[1]+mod,255); - b=BLUE_CHANNEL(img,width,x,y,channelsRGB) =CLAMP(0,avg_color[2]+mod,255); - if(diffbit==0&&index==1) - { - alpha[(y*width+x)*channelsA]=0; - r=RED_CHANNEL(img,width,x,y,channelsRGB)=0; - g=GREEN_CHANNEL(img,width,x,y,channelsRGB)=0; - b=BLUE_CHANNEL(img,width,x,y,channelsRGB)=0; - } - else - { - alpha[(y*width+x)*channelsA]=255; - } - } - } - } - else - { - // We should flip - shift=2; - for(int x=startx; x> shift) & 1) << 1; - index |= ((pixel_indices_LSB >> shift) & 1); - shift++; - index=unscramble[index]; - int mod = compressParams[table][index]; - if(diffbit==0&&(index==1||index==2)) - { - mod=0; - } - - r=RED_CHANNEL(img,width,x,y,channelsRGB) =CLAMP(0,avg_color[0]+mod,255); - g=GREEN_CHANNEL(img,width,x,y,channelsRGB)=CLAMP(0,avg_color[1]+mod,255); - b=BLUE_CHANNEL(img,width,x,y,channelsRGB) =CLAMP(0,avg_color[2]+mod,255); - if(diffbit==0&&index==1) - { - alpha[(y*width+x)*channelsA]=0; - r=RED_CHANNEL(img,width,x,y,channelsRGB)=0; - g=GREEN_CHANNEL(img,width,x,y,channelsRGB)=0; - b=BLUE_CHANNEL(img,width,x,y,channelsRGB)=0; - } - else - { - alpha[(y*width+x)*channelsA]=255; - } - } - shift += 2; - } - } +void +decompressBlockDifferentialWithAlphaC(unsigned int block_part1, unsigned int block_part2, uint8 *img, uint8 *alpha, int width, + int height, int startx, int starty, int channelsRGB) { + uint8 avg_color[3], enc_color1[3], enc_color2[3]; + signed char diff[3]; + int table; + int index, shift; + int r, g, b; + int diffbit; + int flipbit; + int channelsA; + + if (channelsRGB == 3) { + // We will decode the alpha data to a separate memory area. + channelsA = 1; + } else { + // We will decode the RGB data and the alpha data to the same memory area, + // interleaved as RGBA. + channelsA = 4; + alpha = &img[0 + 3]; + } + + // the diffbit now encodes whether or not the entire alpha channel is 255. + diffbit = (GETBITSHIGH(block_part1, 1, 33)); + flipbit = (GETBITSHIGH(block_part1, 1, 32)); + + // First decode left part of block. + enc_color1[0] = GETBITSHIGH(block_part1, 5, 63); + enc_color1[1] = GETBITSHIGH(block_part1, 5, 55); + enc_color1[2] = GETBITSHIGH(block_part1, 5, 47); + + // Expand from 5 to 8 bits + avg_color[0] = (enc_color1[0] << 3) | (enc_color1[0] >> 2); + avg_color[1] = (enc_color1[1] << 3) | (enc_color1[1] >> 2); + avg_color[2] = (enc_color1[2] << 3) | (enc_color1[2] >> 2); + + table = GETBITSHIGH(block_part1, 3, 39) << 1; + + unsigned int pixel_indices_MSB, pixel_indices_LSB; + + pixel_indices_MSB = GETBITS(block_part2, 16, 31); + pixel_indices_LSB = GETBITS(block_part2, 16, 15); + + if ((flipbit) == 0) { + // We should not flip + shift = 0; + for (int x = startx; x < startx + 2; x++) { + for (int y = starty; y < starty + 4; y++) { + index = ((pixel_indices_MSB >> shift) & 1) << 1; + index |= ((pixel_indices_LSB >> shift) & 1); + shift++; + index = unscramble[index]; + + int mod = compressParams[table][index]; + if (diffbit == 0 && (index == 1 || index == 2)) { + mod = 0; + } + + r = RED_CHANNEL(img, width, x, y, channelsRGB) = CLAMP(0, avg_color[0] + mod, 255); + g = GREEN_CHANNEL(img, width, x, y, channelsRGB) = CLAMP(0, avg_color[1] + mod, 255); + b = BLUE_CHANNEL(img, width, x, y, channelsRGB) = CLAMP(0, avg_color[2] + mod, 255); + if (diffbit == 0 && index == 1) { + alpha[(y * width + x) * channelsA] = 0; + r = RED_CHANNEL(img, width, x, y, channelsRGB) = 0; + g = GREEN_CHANNEL(img, width, x, y, channelsRGB) = 0; + b = BLUE_CHANNEL(img, width, x, y, channelsRGB) = 0; + } else { + alpha[(y * width + x) * channelsA] = 255; + } + } + } + } else { + // We should flip + shift = 0; + for (int x = startx; x < startx + 4; x++) { + for (int y = starty; y < starty + 2; y++) { + index = ((pixel_indices_MSB >> shift) & 1) << 1; + index |= ((pixel_indices_LSB >> shift) & 1); + shift++; + index = unscramble[index]; + int mod = compressParams[table][index]; + if (diffbit == 0 && (index == 1 || index == 2)) { + mod = 0; + } + r = RED_CHANNEL(img, width, x, y, channelsRGB) = CLAMP(0, avg_color[0] + mod, 255); + g = GREEN_CHANNEL(img, width, x, y, channelsRGB) = CLAMP(0, avg_color[1] + mod, 255); + b = BLUE_CHANNEL(img, width, x, y, channelsRGB) = CLAMP(0, avg_color[2] + mod, 255); + if (diffbit == 0 && index == 1) { + alpha[(y * width + x) * channelsA] = 0; + r = RED_CHANNEL(img, width, x, y, channelsRGB) = 0; + g = GREEN_CHANNEL(img, width, x, y, channelsRGB) = 0; + b = BLUE_CHANNEL(img, width, x, y, channelsRGB) = 0; + } else { + alpha[(y * width + x) * channelsA] = 255; + } + } + shift += 2; + } + } + // Now decode right part of block. + diff[0] = GETBITSHIGH(block_part1, 3, 58); + diff[1] = GETBITSHIGH(block_part1, 3, 50); + diff[2] = GETBITSHIGH(block_part1, 3, 42); + + // Extend sign bit to entire byte. + diff[0] = (diff[0] << 5); + diff[1] = (diff[1] << 5); + diff[2] = (diff[2] << 5); + diff[0] = diff[0] >> 5; + diff[1] = diff[1] >> 5; + diff[2] = diff[2] >> 5; + + // Calculate second color + enc_color2[0] = enc_color1[0] + diff[0]; + enc_color2[1] = enc_color1[1] + diff[1]; + enc_color2[2] = enc_color1[2] + diff[2]; + + // Expand from 5 to 8 bits + avg_color[0] = (enc_color2[0] << 3) | (enc_color2[0] >> 2); + avg_color[1] = (enc_color2[1] << 3) | (enc_color2[1] >> 2); + avg_color[2] = (enc_color2[2] << 3) | (enc_color2[2] >> 2); + + table = GETBITSHIGH(block_part1, 3, 36) << 1; + pixel_indices_MSB = GETBITS(block_part2, 16, 31); + pixel_indices_LSB = GETBITS(block_part2, 16, 15); + + if ((flipbit) == 0) { + // We should not flip + shift = 8; + for (int x = startx + 2; x < startx + 4; x++) { + for (int y = starty; y < starty + 4; y++) { + index = ((pixel_indices_MSB >> shift) & 1) << 1; + index |= ((pixel_indices_LSB >> shift) & 1); + shift++; + index = unscramble[index]; + int mod = compressParams[table][index]; + if (diffbit == 0 && (index == 1 || index == 2)) { + mod = 0; + } + + r = RED_CHANNEL(img, width, x, y, channelsRGB) = CLAMP(0, avg_color[0] + mod, 255); + g = GREEN_CHANNEL(img, width, x, y, channelsRGB) = CLAMP(0, avg_color[1] + mod, 255); + b = BLUE_CHANNEL(img, width, x, y, channelsRGB) = CLAMP(0, avg_color[2] + mod, 255); + if (diffbit == 0 && index == 1) { + alpha[(y * width + x) * channelsA] = 0; + r = RED_CHANNEL(img, width, x, y, channelsRGB) = 0; + g = GREEN_CHANNEL(img, width, x, y, channelsRGB) = 0; + b = BLUE_CHANNEL(img, width, x, y, channelsRGB) = 0; + } else { + alpha[(y * width + x) * channelsA] = 255; + } + } + } + } else { + // We should flip + shift = 2; + for (int x = startx; x < startx + 4; x++) { + for (int y = starty + 2; y < starty + 4; y++) { + index = ((pixel_indices_MSB >> shift) & 1) << 1; + index |= ((pixel_indices_LSB >> shift) & 1); + shift++; + index = unscramble[index]; + int mod = compressParams[table][index]; + if (diffbit == 0 && (index == 1 || index == 2)) { + mod = 0; + } + + r = RED_CHANNEL(img, width, x, y, channelsRGB) = CLAMP(0, avg_color[0] + mod, 255); + g = GREEN_CHANNEL(img, width, x, y, channelsRGB) = CLAMP(0, avg_color[1] + mod, 255); + b = BLUE_CHANNEL(img, width, x, y, channelsRGB) = CLAMP(0, avg_color[2] + mod, 255); + if (diffbit == 0 && index == 1) { + alpha[(y * width + x) * channelsA] = 0; + r = RED_CHANNEL(img, width, x, y, channelsRGB) = 0; + g = GREEN_CHANNEL(img, width, x, y, channelsRGB) = 0; + b = BLUE_CHANNEL(img, width, x, y, channelsRGB) = 0; + } else { + alpha[(y * width + x) * channelsA] = 255; + } + } + shift += 2; + } + } } -void decompressBlockDifferentialWithAlpha(unsigned int block_part1, unsigned int block_part2, uint8* img, uint8* alpha, int width, int height, int startx, int starty) -{ - decompressBlockDifferentialWithAlphaC(block_part1, block_part2, img, alpha, width, height, startx, starty, 3); +void +decompressBlockDifferentialWithAlpha(unsigned int block_part1, unsigned int block_part2, uint8 *img, uint8 *alpha, int width, + int height, int startx, int starty) { + decompressBlockDifferentialWithAlphaC(block_part1, block_part2, img, alpha, width, height, startx, starty, 3); } - // similar to regular decompression, but alpha channel is set to 0 if pixel index is 2, otherwise 255. // NO WARRANTY --- SEE STATEMENT IN TOP OF FILE (C) Ericsson AB 2013. All Rights Reserved. -void decompressBlockTHUMB59TAlphaC(unsigned int block_part1, unsigned int block_part2, uint8 *img, uint8* alpha, int width, int height, int startx, int starty, int channelsRGB) -{ - - uint8 colorsRGB444[2][3]; - uint8 colors[2][3]; - uint8 paint_colors[4][3]; - uint8 distance; - uint8 block_mask[4][4]; - int channelsA; - - if(channelsRGB == 3) - { - // We will decode the alpha data to a separate memory area. - channelsA = 1; - } - else - { - // We will decode the RGB data and the alpha data to the same memory area, - // interleaved as RGBA. - channelsA = 4; - alpha = &img[0+3]; - } - - // First decode left part of block. - colorsRGB444[0][R]= GETBITSHIGH(block_part1, 4, 58); - colorsRGB444[0][G]= GETBITSHIGH(block_part1, 4, 54); - colorsRGB444[0][B]= GETBITSHIGH(block_part1, 4, 50); - - colorsRGB444[1][R]= GETBITSHIGH(block_part1, 4, 46); - colorsRGB444[1][G]= GETBITSHIGH(block_part1, 4, 42); - colorsRGB444[1][B]= GETBITSHIGH(block_part1, 4, 38); - - distance = GETBITSHIGH(block_part1, TABLE_BITS_59T, 34); - - // Extend the two colors to RGB888 - decompressColor(R_BITS59T, G_BITS59T, B_BITS59T, colorsRGB444, colors); - calculatePaintColors59T(distance, PATTERN_T, colors, paint_colors); - - // Choose one of the four paint colors for each texel - for (uint8 x = 0; x < BLOCKWIDTH; ++x) - { - for (uint8 y = 0; y < BLOCKHEIGHT; ++y) - { - //block_mask[x][y] = GETBITS(block_part2,2,31-(y*4+x)*2); - block_mask[x][y] = GETBITS(block_part2,1,(y+x*4)+16)<<1; - block_mask[x][y] |= GETBITS(block_part2,1,(y+x*4)); - img[channelsRGB*((starty+y)*width+startx+x)+R] = - CLAMP(0,paint_colors[block_mask[x][y]][R],255); // RED - img[channelsRGB*((starty+y)*width+startx+x)+G] = - CLAMP(0,paint_colors[block_mask[x][y]][G],255); // GREEN - img[channelsRGB*((starty+y)*width+startx+x)+B] = - CLAMP(0,paint_colors[block_mask[x][y]][B],255); // BLUE - if(block_mask[x][y]==2) - { - alpha[channelsA*(x+startx+(y+starty)*width)]=0; - img[channelsRGB*((starty+y)*width+startx+x)+R] =0; - img[channelsRGB*((starty+y)*width+startx+x)+G] =0; - img[channelsRGB*((starty+y)*width+startx+x)+B] =0; - } - else - alpha[channelsA*(x+startx+(y+starty)*width)]=255; - } - } +void +decompressBlockTHUMB59TAlphaC(unsigned int block_part1, unsigned int block_part2, uint8 *img, uint8 *alpha, int width, int height, + int startx, int starty, int channelsRGB) { + uint8 colorsRGB444[2][3]; + uint8 colors[2][3]; + uint8 paint_colors[4][3]; + uint8 distance; + uint8 block_mask[4][4]; + int channelsA; + + if (channelsRGB == 3) { + // We will decode the alpha data to a separate memory area. + channelsA = 1; + } else { + // We will decode the RGB data and the alpha data to the same memory area, + // interleaved as RGBA. + channelsA = 4; + alpha = &img[0 + 3]; + } + + // First decode left part of block. + colorsRGB444[0][R] = GETBITSHIGH(block_part1, 4, 58); + colorsRGB444[0][G] = GETBITSHIGH(block_part1, 4, 54); + colorsRGB444[0][B] = GETBITSHIGH(block_part1, 4, 50); + + colorsRGB444[1][R] = GETBITSHIGH(block_part1, 4, 46); + colorsRGB444[1][G] = GETBITSHIGH(block_part1, 4, 42); + colorsRGB444[1][B] = GETBITSHIGH(block_part1, 4, 38); + + distance = GETBITSHIGH(block_part1, TABLE_BITS_59T, 34); + + // Extend the two colors to RGB888 + decompressColor(R_BITS59T, G_BITS59T, B_BITS59T, colorsRGB444, colors); + calculatePaintColors59T(distance, PATTERN_T, colors, paint_colors); + + // Choose one of the four paint colors for each texel + for (uint8 x = 0; x < BLOCKWIDTH; ++x) { + for (uint8 y = 0; y < BLOCKHEIGHT; ++y) { + // block_mask[x][y] = GETBITS(block_part2,2,31-(y*4+x)*2); + block_mask[x][y] = GETBITS(block_part2, 1, (y + x * 4) + 16) << 1; + block_mask[x][y] |= GETBITS(block_part2, 1, (y + x * 4)); + img[channelsRGB * ((starty + y) * width + startx + x) + R] = CLAMP(0, paint_colors[block_mask[x][y]][R], 255); // RED + img[channelsRGB * ((starty + y) * width + startx + x) + G] = CLAMP(0, paint_colors[block_mask[x][y]][G], 255); // GREEN + img[channelsRGB * ((starty + y) * width + startx + x) + B] = CLAMP(0, paint_colors[block_mask[x][y]][B], 255); // BLUE + if (block_mask[x][y] == 2) { + alpha[channelsA * (x + startx + (y + starty) * width)] = 0; + img[channelsRGB * ((starty + y) * width + startx + x) + R] = 0; + img[channelsRGB * ((starty + y) * width + startx + x) + G] = 0; + img[channelsRGB * ((starty + y) * width + startx + x) + B] = 0; + } else + alpha[channelsA * (x + startx + (y + starty) * width)] = 255; + } + } } -void decompressBlockTHUMB59TAlpha(unsigned int block_part1, unsigned int block_part2, uint8 *img, uint8* alpha, int width, int height, int startx, int starty) -{ - decompressBlockTHUMB59TAlphaC(block_part1, block_part2, img, alpha, width, height, startx, starty, 3); +void +decompressBlockTHUMB59TAlpha(unsigned int block_part1, unsigned int block_part2, uint8 *img, uint8 *alpha, int width, int height, + int startx, int starty) { + decompressBlockTHUMB59TAlphaC(block_part1, block_part2, img, alpha, width, height, startx, starty, 3); } - // Decompress an H-mode block with alpha // NO WARRANTY --- SEE STATEMENT IN TOP OF FILE (C) Ericsson AB 2013. All Rights Reserved. -void decompressBlockTHUMB58HAlphaC(unsigned int block_part1, unsigned int block_part2, uint8 *img, uint8* alpha, int width, int height, int startx, int starty, int channelsRGB) -{ - unsigned int col0, col1; - uint8 colors[2][3]; - uint8 colorsRGB444[2][3]; - uint8 paint_colors[4][3]; - uint8 distance; - uint8 block_mask[4][4]; - int channelsA; - - if(channelsRGB == 3) - { - // We will decode the alpha data to a separate memory area. - channelsA = 1; - } - else - { - // We will decode the RGB data and the alpha data to the same memory area, - // interleaved as RGBA. - channelsA = 4; - alpha = &img[0+3]; - } - - // First decode left part of block. - colorsRGB444[0][R]= GETBITSHIGH(block_part1, 4, 57); - colorsRGB444[0][G]= GETBITSHIGH(block_part1, 4, 53); - colorsRGB444[0][B]= GETBITSHIGH(block_part1, 4, 49); - - colorsRGB444[1][R]= GETBITSHIGH(block_part1, 4, 45); - colorsRGB444[1][G]= GETBITSHIGH(block_part1, 4, 41); - colorsRGB444[1][B]= GETBITSHIGH(block_part1, 4, 37); - - distance = 0; - distance = (GETBITSHIGH(block_part1, 2, 33)) << 1; - - col0 = GETBITSHIGH(block_part1, 12, 57); - col1 = GETBITSHIGH(block_part1, 12, 45); - - if(col0 >= col1) - { - distance |= 1; - } - - // Extend the two colors to RGB888 - decompressColor(R_BITS58H, G_BITS58H, B_BITS58H, colorsRGB444, colors); - - calculatePaintColors58H(distance, PATTERN_H, colors, paint_colors); - - // Choose one of the four paint colors for each texel - for (uint8 x = 0; x < BLOCKWIDTH; ++x) - { - for (uint8 y = 0; y < BLOCKHEIGHT; ++y) - { - //block_mask[x][y] = GETBITS(block_part2,2,31-(y*4+x)*2); - block_mask[x][y] = GETBITS(block_part2,1,(y+x*4)+16)<<1; - block_mask[x][y] |= GETBITS(block_part2,1,(y+x*4)); - img[channelsRGB*((starty+y)*width+startx+x)+R] = - CLAMP(0,paint_colors[block_mask[x][y]][R],255); // RED - img[channelsRGB*((starty+y)*width+startx+x)+G] = - CLAMP(0,paint_colors[block_mask[x][y]][G],255); // GREEN - img[channelsRGB*((starty+y)*width+startx+x)+B] = - CLAMP(0,paint_colors[block_mask[x][y]][B],255); // BLUE - - if(block_mask[x][y]==2) - { - alpha[channelsA*(x+startx+(y+starty)*width)]=0; - img[channelsRGB*((starty+y)*width+startx+x)+R] =0; - img[channelsRGB*((starty+y)*width+startx+x)+G] =0; - img[channelsRGB*((starty+y)*width+startx+x)+B] =0; - } - else - alpha[channelsA*(x+startx+(y+starty)*width)]=255; - } - } +void +decompressBlockTHUMB58HAlphaC(unsigned int block_part1, unsigned int block_part2, uint8 *img, uint8 *alpha, int width, int height, + int startx, int starty, int channelsRGB) { + unsigned int col0, col1; + uint8 colors[2][3]; + uint8 colorsRGB444[2][3]; + uint8 paint_colors[4][3]; + uint8 distance; + uint8 block_mask[4][4]; + int channelsA; + + if (channelsRGB == 3) { + // We will decode the alpha data to a separate memory area. + channelsA = 1; + } else { + // We will decode the RGB data and the alpha data to the same memory area, + // interleaved as RGBA. + channelsA = 4; + alpha = &img[0 + 3]; + } + + // First decode left part of block. + colorsRGB444[0][R] = GETBITSHIGH(block_part1, 4, 57); + colorsRGB444[0][G] = GETBITSHIGH(block_part1, 4, 53); + colorsRGB444[0][B] = GETBITSHIGH(block_part1, 4, 49); + + colorsRGB444[1][R] = GETBITSHIGH(block_part1, 4, 45); + colorsRGB444[1][G] = GETBITSHIGH(block_part1, 4, 41); + colorsRGB444[1][B] = GETBITSHIGH(block_part1, 4, 37); + + distance = 0; + distance = (GETBITSHIGH(block_part1, 2, 33)) << 1; + + col0 = GETBITSHIGH(block_part1, 12, 57); + col1 = GETBITSHIGH(block_part1, 12, 45); + + if (col0 >= col1) { + distance |= 1; + } + + // Extend the two colors to RGB888 + decompressColor(R_BITS58H, G_BITS58H, B_BITS58H, colorsRGB444, colors); + + calculatePaintColors58H(distance, PATTERN_H, colors, paint_colors); + + // Choose one of the four paint colors for each texel + for (uint8 x = 0; x < BLOCKWIDTH; ++x) { + for (uint8 y = 0; y < BLOCKHEIGHT; ++y) { + // block_mask[x][y] = GETBITS(block_part2,2,31-(y*4+x)*2); + block_mask[x][y] = GETBITS(block_part2, 1, (y + x * 4) + 16) << 1; + block_mask[x][y] |= GETBITS(block_part2, 1, (y + x * 4)); + img[channelsRGB * ((starty + y) * width + startx + x) + R] = CLAMP(0, paint_colors[block_mask[x][y]][R], 255); // RED + img[channelsRGB * ((starty + y) * width + startx + x) + G] = CLAMP(0, paint_colors[block_mask[x][y]][G], 255); // GREEN + img[channelsRGB * ((starty + y) * width + startx + x) + B] = CLAMP(0, paint_colors[block_mask[x][y]][B], 255); // BLUE + + if (block_mask[x][y] == 2) { + alpha[channelsA * (x + startx + (y + starty) * width)] = 0; + img[channelsRGB * ((starty + y) * width + startx + x) + R] = 0; + img[channelsRGB * ((starty + y) * width + startx + x) + G] = 0; + img[channelsRGB * ((starty + y) * width + startx + x) + B] = 0; + } else + alpha[channelsA * (x + startx + (y + starty) * width)] = 255; + } + } } -void decompressBlockTHUMB58HAlpha(unsigned int block_part1, unsigned int block_part2, uint8 *img, uint8* alpha, int width, int height, int startx, int starty) -{ - decompressBlockTHUMB58HAlphaC(block_part1, block_part2, img, alpha, width, height, startx, starty, 3); +void +decompressBlockTHUMB58HAlpha(unsigned int block_part1, unsigned int block_part2, uint8 *img, uint8 *alpha, int width, int height, + int startx, int starty) { + decompressBlockTHUMB58HAlphaC(block_part1, block_part2, img, alpha, width, height, startx, starty, 3); } // Decompression function for ETC2_RGBA1 format. // NO WARRANTY --- SEE STATEMENT IN TOP OF FILE (C) Ericsson AB 2013. All Rights Reserved. -void decompressBlockETC21BitAlphaC(unsigned int block_part1, unsigned int block_part2, uint8 *img, uint8* alphaimg, int width, int height, int startx, int starty, int channelsRGB) -{ - int diffbit; - signed char color1[3]; - signed char diff[3]; - signed char red, green, blue; - int channelsA; - - if(channelsRGB == 3) - { - // We will decode the alpha data to a separate memory area. - channelsA = 1; - } - else - { - // We will decode the RGB data and the alpha data to the same memory area, - // interleaved as RGBA. - channelsA = 4; - alphaimg = &img[0+3]; - } - - diffbit = (GETBITSHIGH(block_part1, 1, 33)); - - if( diffbit ) - { - // We have diffbit = 1, meaning no transparent pixels. regular decompression. - - // Base color - color1[0]= GETBITSHIGH(block_part1, 5, 63); - color1[1]= GETBITSHIGH(block_part1, 5, 55); - color1[2]= GETBITSHIGH(block_part1, 5, 47); - - // Diff color - diff[0]= GETBITSHIGH(block_part1, 3, 58); - diff[1]= GETBITSHIGH(block_part1, 3, 50); - diff[2]= GETBITSHIGH(block_part1, 3, 42); - - // Extend sign bit to entire byte. - diff[0] = (diff[0] << 5); - diff[1] = (diff[1] << 5); - diff[2] = (diff[2] << 5); - diff[0] = diff[0] >> 5; - diff[1] = diff[1] >> 5; - diff[2] = diff[2] >> 5; - - red = color1[0] + diff[0]; - green = color1[1] + diff[1]; - blue = color1[2] + diff[2]; - - if(red < 0 || red > 31) - { - unsigned int block59_part1, block59_part2; - unstuff59bits(block_part1, block_part2, block59_part1, block59_part2); - decompressBlockTHUMB59Tc(block59_part1, block59_part2, img, width, height, startx, starty, channelsRGB); - } - else if (green < 0 || green > 31) - { - unsigned int block58_part1, block58_part2; - unstuff58bits(block_part1, block_part2, block58_part1, block58_part2); - decompressBlockTHUMB58Hc(block58_part1, block58_part2, img, width, height, startx, starty, channelsRGB); - } - else if(blue < 0 || blue > 31) - { - unsigned int block57_part1, block57_part2; - - unstuff57bits(block_part1, block_part2, block57_part1, block57_part2); - decompressBlockPlanar57c(block57_part1, block57_part2, img, width, height, startx, starty, channelsRGB); - } - else - { - decompressBlockDifferentialWithAlphaC(block_part1, block_part2, img, alphaimg, width, height, startx, starty, channelsRGB); - } - for(int x=startx; x> 5; - diff[1] = diff[1] >> 5; - diff[2] = diff[2] >> 5; - - red = color1[0] + diff[0]; - green = color1[1] + diff[1]; - blue = color1[2] + diff[2]; - if(red < 0 || red > 31) - { - unsigned int block59_part1, block59_part2; - unstuff59bits(block_part1, block_part2, block59_part1, block59_part2); - decompressBlockTHUMB59TAlphaC(block59_part1, block59_part2, img, alphaimg, width, height, startx, starty, channelsRGB); - } - else if(green < 0 || green > 31) - { - unsigned int block58_part1, block58_part2; - unstuff58bits(block_part1, block_part2, block58_part1, block58_part2); - decompressBlockTHUMB58HAlphaC(block58_part1, block58_part2, img, alphaimg, width, height, startx, starty, channelsRGB); - } - else if(blue < 0 || blue > 31) - { - unsigned int block57_part1, block57_part2; - - unstuff57bits(block_part1, block_part2, block57_part1, block57_part2); - decompressBlockPlanar57c(block57_part1, block57_part2, img, width, height, startx, starty, channelsRGB); - for(int x=startx; x> 5; + diff[1] = diff[1] >> 5; + diff[2] = diff[2] >> 5; + + red = color1[0] + diff[0]; + green = color1[1] + diff[1]; + blue = color1[2] + diff[2]; + + if (red < 0 || red > 31) { + unsigned int block59_part1, block59_part2; + unstuff59bits(block_part1, block_part2, block59_part1, block59_part2); + decompressBlockTHUMB59Tc(block59_part1, block59_part2, img, width, height, startx, starty, channelsRGB); + } else if (green < 0 || green > 31) { + unsigned int block58_part1, block58_part2; + unstuff58bits(block_part1, block_part2, block58_part1, block58_part2); + decompressBlockTHUMB58Hc(block58_part1, block58_part2, img, width, height, startx, starty, channelsRGB); + } else if (blue < 0 || blue > 31) { + unsigned int block57_part1, block57_part2; + + unstuff57bits(block_part1, block_part2, block57_part1, block57_part2); + decompressBlockPlanar57c(block57_part1, block57_part2, img, width, height, startx, starty, channelsRGB); + } else { + decompressBlockDifferentialWithAlphaC(block_part1, block_part2, img, alphaimg, width, height, startx, starty, + channelsRGB); + } + for (int x = startx; x < startx + 4; x++) { + for (int y = starty; y < starty + 4; y++) { + alphaimg[channelsA * (x + y * width)] = 255; + } + } + } else { + // We have diffbit = 0, transparent pixels. Only T-, H- or regular diff-mode possible. + + // Base color + color1[0] = GETBITSHIGH(block_part1, 5, 63); + color1[1] = GETBITSHIGH(block_part1, 5, 55); + color1[2] = GETBITSHIGH(block_part1, 5, 47); + + // Diff color + diff[0] = GETBITSHIGH(block_part1, 3, 58); + diff[1] = GETBITSHIGH(block_part1, 3, 50); + diff[2] = GETBITSHIGH(block_part1, 3, 42); + + // Extend sign bit to entire byte. + diff[0] = (diff[0] << 5); + diff[1] = (diff[1] << 5); + diff[2] = (diff[2] << 5); + diff[0] = diff[0] >> 5; + diff[1] = diff[1] >> 5; + diff[2] = diff[2] >> 5; + + red = color1[0] + diff[0]; + green = color1[1] + diff[1]; + blue = color1[2] + diff[2]; + if (red < 0 || red > 31) { + unsigned int block59_part1, block59_part2; + unstuff59bits(block_part1, block_part2, block59_part1, block59_part2); + decompressBlockTHUMB59TAlphaC(block59_part1, block59_part2, img, alphaimg, width, height, startx, starty, channelsRGB); + } else if (green < 0 || green > 31) { + unsigned int block58_part1, block58_part2; + unstuff58bits(block_part1, block_part2, block58_part1, block58_part2); + decompressBlockTHUMB58HAlphaC(block58_part1, block58_part2, img, alphaimg, width, height, startx, starty, channelsRGB); + } else if (blue < 0 || blue > 31) { + unsigned int block57_part1, block57_part2; + + unstuff57bits(block_part1, block_part2, block57_part1, block57_part2); + decompressBlockPlanar57c(block57_part1, block57_part2, img, width, height, startx, starty, channelsRGB); + for (int x = startx; x < startx + 4; x++) { + for (int y = starty; y < starty + 4; y++) { + alphaimg[channelsA * (x + y * width)] = 255; + } + } + } else + decompressBlockDifferentialWithAlphaC(block_part1, block_part2, img, alphaimg, width, height, startx, starty, + channelsRGB); + } } -void decompressBlockETC21BitAlpha(unsigned int block_part1, unsigned int block_part2, uint8 *img, uint8* alphaimg, int width, int height, int startx, int starty) -{ - decompressBlockETC21BitAlphaC(block_part1, block_part2, img, alphaimg, width, height, startx, starty, 3); +void +decompressBlockETC21BitAlpha(unsigned int block_part1, unsigned int block_part2, uint8 *img, uint8 *alphaimg, int width, int height, + int startx, int starty) { + decompressBlockETC21BitAlphaC(block_part1, block_part2, img, alphaimg, width, height, startx, starty, 3); } // // Utility functions used for alpha compression @@ -1646,22 +1510,19 @@ void decompressBlockETC21BitAlpha(unsigned int block_part1, unsigned int block_p // bit number frompos is extracted from input, and moved to bit number topos in the return value. // NO WARRANTY --- SEE STATEMENT IN TOP OF FILE (C) Ericsson AB 2013. All Rights Reserved. -uint8 getbit(uint8 input, int frompos, int topos) -{ - if(frompos>topos) - return ((1<>(frompos-topos); - return ((1< topos) return ((1 << frompos) & input) >> (frompos - topos); + return ((1 << frompos) & input) << (topos - frompos); } // takes as input a value, returns the value clamped to the interval [0,255]. // NO WARRANTY --- SEE STATEMENT IN TOP OF FILE (C) Ericsson AB 2013. All Rights Reserved. -int clamp(int val) -{ - if(val<0) - val=0; - if(val>255) - val=255; - return val; +int +clamp(int val) { + if (val < 0) val = 0; + if (val > 255) val = 255; + return val; } // Decodes tha alpha component in a block coded with GL_COMPRESSED_RGBA8_ETC2_EAC. @@ -1669,196 +1530,174 @@ int clamp(int val) // However, a hardware decoder can share gates between the two formats as explained // in the specification under GL_COMPRESSED_R11_EAC. // NO WARRANTY --- SEE STATEMENT IN TOP OF FILE (C) Ericsson AB 2013. All Rights Reserved. -void decompressBlockAlphaC(uint8* data, uint8* img, int width, int height, int ix, int iy, int channels) -{ - int alpha = data[0]; - int table = data[1]; - - int bit=0; - int byte=2; - //extract an alpha value for each pixel. - for(int x=0; x<4; x++) - { - for(int y=0; y<4; y++) - { - //Extract table index - int index=0; - for(int bitpos=0; bitpos<3; bitpos++) - { - index|=getbit(data[byte],7-bit,2-bitpos); - bit++; - if(bit>7) - { - bit=0; - byte++; - } - } - img[(ix+x+(iy+y)*width)*channels]=clamp(alpha +alphaTable[table][index]); - } - } +void +decompressBlockAlphaC(uint8 *data, uint8 *img, int width, int height, int ix, int iy, int channels) { + int alpha = data[0]; + int table = data[1]; + + int bit = 0; + int byte = 2; + // extract an alpha value for each pixel. + for (int x = 0; x < 4; x++) { + for (int y = 0; y < 4; y++) { + // Extract table index + int index = 0; + for (int bitpos = 0; bitpos < 3; bitpos++) { + index |= getbit(data[byte], 7 - bit, 2 - bitpos); + bit++; + if (bit > 7) { + bit = 0; + byte++; + } + } + img[(ix + x + (iy + y) * width) * channels] = clamp(alpha + alphaTable[table][index]); + } + } } -void decompressBlockAlpha(uint8* data, uint8* img, int width, int height, int ix, int iy) -{ - decompressBlockAlphaC(data, img, width, height, ix, iy, 1); +void +decompressBlockAlpha(uint8 *data, uint8 *img, int width, int height, int ix, int iy) { + decompressBlockAlphaC(data, img, width, height, ix, iy, 1); } // Does decompression and then immediately converts from 11 bit signed to a 16-bit format. -// +// // NO WARRANTY --- SEE STATEMENT IN TOP OF FILE (C) Ericsson AB 2013. All Rights Reserved. -int16 get16bits11signed(int base, int table, int mul, int index) -{ - int elevenbase = base-128; - if(elevenbase==-128) - elevenbase=-127; - elevenbase*=8; - //i want the positive value here - int tabVal = -alphaBase[table][3-index%4]-1; - //and the sign, please - int sign = 1-(index/4); - - if(sign) - tabVal=tabVal+1; - int elevenTabVal = tabVal*8; - - if(mul!=0) - elevenTabVal*=mul; - else - elevenTabVal/=8; - - if(sign) - elevenTabVal=-elevenTabVal; - - //calculate sum - int elevenbits = elevenbase+elevenTabVal; - - //clamp.. - if(elevenbits>=1024) - elevenbits=1023; - else if(elevenbits<-1023) - elevenbits=-1023; - //this is the value we would actually output.. - //but there aren't any good 11-bit file or uncompressed GL formats - //so we extend to 15 bits signed. - sign = elevenbits<0; - elevenbits=abs(elevenbits); - int16 fifteenbits = (elevenbits<<5)+(elevenbits>>5); - int16 sixteenbits=fifteenbits; - - if(sign) - sixteenbits=-sixteenbits; - - return sixteenbits; +int16 +get16bits11signed(int base, int table, int mul, int index) { + int elevenbase = base - 128; + if (elevenbase == -128) elevenbase = -127; + elevenbase *= 8; + // i want the positive value here + int tabVal = -alphaBase[table][3 - index % 4] - 1; + // and the sign, please + int sign = 1 - (index / 4); + + if (sign) tabVal = tabVal + 1; + int elevenTabVal = tabVal * 8; + + if (mul != 0) + elevenTabVal *= mul; + else + elevenTabVal /= 8; + + if (sign) elevenTabVal = -elevenTabVal; + + // calculate sum + int elevenbits = elevenbase + elevenTabVal; + + // clamp.. + if (elevenbits >= 1024) + elevenbits = 1023; + else if (elevenbits < -1023) + elevenbits = -1023; + // this is the value we would actually output.. + // but there aren't any good 11-bit file or uncompressed GL formats + // so we extend to 15 bits signed. + sign = elevenbits < 0; + elevenbits = abs(elevenbits); + int16 fifteenbits = (elevenbits << 5) + (elevenbits >> 5); + int16 sixteenbits = fifteenbits; + + if (sign) sixteenbits = -sixteenbits; + + return sixteenbits; } -// Does decompression and then immediately converts from 11 bit signed to a 16-bit format +// Does decompression and then immediately converts from 11 bit signed to a 16-bit format // Calculates the 11 bit value represented by base, table, mul and index, and extends it to 16 bits. // NO WARRANTY --- SEE STATEMENT IN TOP OF FILE (C) Ericsson AB 2013. All Rights Reserved. -uint16 get16bits11bits(int base, int table, int mul, int index) -{ - int elevenbase = base*8+4; - - //i want the positive value here - int tabVal = -alphaBase[table][3-index%4]-1; - //and the sign, please - int sign = 1-(index/4); - - if(sign) - tabVal=tabVal+1; - int elevenTabVal = tabVal*8; - - if(mul!=0) - elevenTabVal*=mul; - else - elevenTabVal/=8; - - if(sign) - elevenTabVal=-elevenTabVal; - - //calculate sum - int elevenbits = elevenbase+elevenTabVal; - - //clamp.. - if(elevenbits>=256*8) - elevenbits=256*8-1; - else if(elevenbits<0) - elevenbits=0; - //elevenbits now contains the 11 bit alpha value as defined in the spec. - - //extend to 16 bits before returning, since we don't have any good 11-bit file formats. - uint16 sixteenbits = (elevenbits<<5)+(elevenbits>>6); - - return sixteenbits; +uint16 +get16bits11bits(int base, int table, int mul, int index) { + int elevenbase = base * 8 + 4; + + // i want the positive value here + int tabVal = -alphaBase[table][3 - index % 4] - 1; + // and the sign, please + int sign = 1 - (index / 4); + + if (sign) tabVal = tabVal + 1; + int elevenTabVal = tabVal * 8; + + if (mul != 0) + elevenTabVal *= mul; + else + elevenTabVal /= 8; + + if (sign) elevenTabVal = -elevenTabVal; + + // calculate sum + int elevenbits = elevenbase + elevenTabVal; + + // clamp.. + if (elevenbits >= 256 * 8) + elevenbits = 256 * 8 - 1; + else if (elevenbits < 0) + elevenbits = 0; + // elevenbits now contains the 11 bit alpha value as defined in the spec. + + // extend to 16 bits before returning, since we don't have any good 11-bit file formats. + uint16 sixteenbits = (elevenbits << 5) + (elevenbits >> 6); + + return sixteenbits; } // Decompresses a block using one of the GL_COMPRESSED_R11_EAC or GL_COMPRESSED_SIGNED_R11_EAC-formats // NO WARRANTY --- SEE STATEMENT IN TOP OF FILE (C) Ericsson AB 2013. All Rights Reserved. -void decompressBlockAlpha16bitC(uint8* data, uint8* img, int width, int height, int ix, int iy, int channels) -{ - int alpha = data[0]; - int table = data[1]; - - if(formatSigned) - { - //if we have a signed format, the base value is given as a signed byte. We convert it to (0-255) here, - //so more code can be shared with the unsigned mode. - alpha = *((signed char*)(&data[0])); - alpha = alpha+128; - } - - int bit=0; - int byte=2; - //extract an alpha value for each pixel. - for(int x=0; x<4; x++) - { - for(int y=0; y<4; y++) - { - //Extract table index - int index=0; - for(int bitpos=0; bitpos<3; bitpos++) - { - index|=getbit(data[byte],7-bit,2-bitpos); - bit++; - if(bit>7) - { - bit=0; - byte++; - } - } - int windex = channels*(2*(ix+x+(iy+y)*width)); +void +decompressBlockAlpha16bitC(uint8 *data, uint8 *img, int width, int height, int ix, int iy, int channels) { + int alpha = data[0]; + int table = data[1]; + + if (formatSigned) { + // if we have a signed format, the base value is given as a signed byte. We convert it to (0-255) here, + // so more code can be shared with the unsigned mode. + alpha = *((signed char *)(&data[0])); + alpha = alpha + 128; + } + + int bit = 0; + int byte = 2; + // extract an alpha value for each pixel. + for (int x = 0; x < 4; x++) { + for (int y = 0; y < 4; y++) { + // Extract table index + int index = 0; + for (int bitpos = 0; bitpos < 3; bitpos++) { + index |= getbit(data[byte], 7 - bit, 2 - bitpos); + bit++; + if (bit > 7) { + bit = 0; + byte++; + } + } + int windex = channels * (2 * (ix + x + (iy + y) * width)); #if !PGMOUT - if(formatSigned) - { - *(int16 *)&img[windex] = get16bits11signed(alpha,(table%16),(table/16),index); - } - else - { - *(uint16 *)&img[windex] = get16bits11bits(alpha,(table%16),(table/16),index); - } + if (formatSigned) { + *(int16 *)&img[windex] = get16bits11signed(alpha, (table % 16), (table / 16), index); + } else { + *(uint16 *)&img[windex] = get16bits11bits(alpha, (table % 16), (table / 16), index); + } #else - //make data compatible with the .pgm format. See the comment in compressBlockAlpha16() for details. - uint16 uSixteen; - if (formatSigned) - { - //the pgm-format only allows unsigned images, - //so we add 2^15 to get a 16-bit value. - uSixteen = get16bits11signed(alpha,(table%16),(table/16),index) + 256*128; - } - else - { - uSixteen = get16bits11bits(alpha,(table%16),(table/16),index); - } - //byte swap for pgm - img[windex] = uSixteen/256; - img[windex+1] = uSixteen%256; + // make data compatible with the .pgm format. See the comment in compressBlockAlpha16() for details. + uint16 uSixteen; + if (formatSigned) { + // the pgm-format only allows unsigned images, + // so we add 2^15 to get a 16-bit value. + uSixteen = get16bits11signed(alpha, (table % 16), (table / 16), index) + 256 * 128; + } else { + uSixteen = get16bits11bits(alpha, (table % 16), (table / 16), index); + } + // byte swap for pgm + img[windex] = uSixteen / 256; + img[windex + 1] = uSixteen % 256; #endif - - } - } + } + } } -void decompressBlockAlpha16bit(uint8* data, uint8* img, int width, int height, int ix, int iy) -{ - decompressBlockAlpha16bitC(data, img, width, height, ix, iy, 1); +void +decompressBlockAlpha16bit(uint8 *data, uint8 *img, int width, int height, int ix, int iy) { + decompressBlockAlpha16bitC(data, img, width, height, ix, iy, 1); } // Reenable warnings disabled at the top of this file. diff --git a/lib/etcunpack.cxx b/lib/etcunpack.cxx index b84f0063f8..a4584fb86b 100644 --- a/lib/etcunpack.cxx +++ b/lib/etcunpack.cxx @@ -22,7 +22,7 @@ #include "GL/glcorearb.h" // Not defined in glcorearb.h. -#define GL_ETC1_RGB8_OES 0x8D64 +#define GL_ETC1_RGB8_OES 0x8D64 #include "ktx.h" #include "ktxint.h" @@ -30,14 +30,12 @@ typedef unsigned int uint; typedef unsigned char uint8; -extern void decompressBlockETC2c(uint block_part1, uint block_part2, uint8* img, - int width, int height, int startx, int starty, int channels); -extern void decompressBlockETC21BitAlphaC(uint block_part1, uint block_part2, uint8* img, uint8* alphaimg, - int width, int height, int startx, int starty, int channels); -extern void decompressBlockAlphaC(uint8* data, uint8* img, - int width, int height, int startx, int starty, int channels); -extern void decompressBlockAlpha16bitC(uint8* data, uint8* img, - int width, int height, int startx, int starty, int channels); +extern void decompressBlockETC2c(uint block_part1, uint block_part2, uint8* img, int width, int height, int startx, int starty, + int channels); +extern void decompressBlockETC21BitAlphaC(uint block_part1, uint block_part2, uint8* img, uint8* alphaimg, int width, int height, + int startx, int starty, int channels); +extern void decompressBlockAlphaC(uint8* data, uint8* img, int width, int height, int startx, int starty, int channels); +extern void decompressBlockAlpha16bitC(uint8* data, uint8* img, int width, int height, int startx, int starty, int channels); extern void setupAlphaTable(); @@ -45,233 +43,226 @@ extern void setupAlphaTable(); extern int formatSigned; static void -readBigEndian4byteWord(ktx_uint32_t* pBlock, const GLubyte *s) -{ - *pBlock = (s[0] << 24) | (s[1] << 16) | (s[2] << 8) | s[3]; +readBigEndian4byteWord(ktx_uint32_t* pBlock, const GLubyte* s) { + *pBlock = (s[0] << 24) | (s[1] << 16) | (s[2] << 8) | s[3]; } - /* Unpack an ETC1_RGB8_OES format compressed texture */ extern "C" KTX_error_code -_ktxUnpackETC(const GLubyte* srcETC, const GLenum srcFormat, - ktx_uint32_t activeWidth, ktx_uint32_t activeHeight, - GLubyte** dstImage, - GLenum* format, GLenum* internalFormat, GLenum* type, - GLint R16Formats, GLboolean supportsSRGB) -{ - unsigned int width, height; - unsigned int block_part1, block_part2; - unsigned int x, y; - /*const*/ GLubyte* src = (GLubyte*)srcETC; - // AF_11BIT is used to compress R11 & RG11 though its not alpha data. - enum {AF_NONE, AF_1BIT, AF_8BIT, AF_11BIT} alphaFormat = AF_NONE; - int dstChannels, dstChannelBytes; - - switch (srcFormat) { - case GL_COMPRESSED_SIGNED_R11_EAC: - if (R16Formats & _KTX_R16_FORMATS_SNORM) { - dstChannelBytes = sizeof(GLshort); - dstChannels = 1; - formatSigned = GL_TRUE; - *internalFormat = GL_R16_SNORM; - *format = GL_RED; - *type = GL_SHORT; - alphaFormat = AF_11BIT; - } else - return KTX_UNSUPPORTED_TEXTURE_TYPE; - break; - - case GL_COMPRESSED_R11_EAC: - if (R16Formats & _KTX_R16_FORMATS_NORM) { - dstChannelBytes = sizeof(GLshort); - dstChannels = 1; - formatSigned = GL_FALSE; - *internalFormat = GL_R16; - *format = GL_RED; - *type = GL_UNSIGNED_SHORT; - alphaFormat = AF_11BIT; - } else - return KTX_UNSUPPORTED_TEXTURE_TYPE; +_ktxUnpackETC(const GLubyte* srcETC, const GLenum srcFormat, ktx_uint32_t activeWidth, ktx_uint32_t activeHeight, + GLubyte** dstImage, GLenum* format, GLenum* internalFormat, GLenum* type, GLint R16Formats, GLboolean supportsSRGB) { + unsigned int width, height; + unsigned int block_part1, block_part2; + unsigned int x, y; + /*const*/ GLubyte* src = (GLubyte*)srcETC; + // AF_11BIT is used to compress R11 & RG11 though its not alpha data. + enum { AF_NONE, AF_1BIT, AF_8BIT, AF_11BIT } alphaFormat = AF_NONE; + int dstChannels, dstChannelBytes; + + switch (srcFormat) { + case GL_COMPRESSED_SIGNED_R11_EAC: + if (R16Formats & _KTX_R16_FORMATS_SNORM) { + dstChannelBytes = sizeof(GLshort); + dstChannels = 1; + formatSigned = GL_TRUE; + *internalFormat = GL_R16_SNORM; + *format = GL_RED; + *type = GL_SHORT; + alphaFormat = AF_11BIT; + } else + return KTX_UNSUPPORTED_TEXTURE_TYPE; + break; + + case GL_COMPRESSED_R11_EAC: + if (R16Formats & _KTX_R16_FORMATS_NORM) { + dstChannelBytes = sizeof(GLshort); + dstChannels = 1; + formatSigned = GL_FALSE; + *internalFormat = GL_R16; + *format = GL_RED; + *type = GL_UNSIGNED_SHORT; + alphaFormat = AF_11BIT; + } else + return KTX_UNSUPPORTED_TEXTURE_TYPE; + break; + + case GL_COMPRESSED_SIGNED_RG11_EAC: + if (R16Formats & _KTX_R16_FORMATS_SNORM) { + dstChannelBytes = sizeof(GLshort); + dstChannels = 2; + formatSigned = GL_TRUE; + *internalFormat = GL_RG16_SNORM; + *format = GL_RG; + *type = GL_SHORT; + alphaFormat = AF_11BIT; + } else + return KTX_UNSUPPORTED_TEXTURE_TYPE; + break; + + case GL_COMPRESSED_RG11_EAC: + if (R16Formats & _KTX_R16_FORMATS_NORM) { + dstChannelBytes = sizeof(GLshort); + dstChannels = 2; + formatSigned = GL_FALSE; + *internalFormat = GL_RG16; + *format = GL_RG; + *type = GL_UNSIGNED_SHORT; + alphaFormat = AF_11BIT; + } else + return KTX_UNSUPPORTED_TEXTURE_TYPE; break; - case GL_COMPRESSED_SIGNED_RG11_EAC: - if (R16Formats & _KTX_R16_FORMATS_SNORM) { - dstChannelBytes = sizeof(GLshort); - dstChannels = 2; - formatSigned = GL_TRUE; - *internalFormat = GL_RG16_SNORM; - *format = GL_RG; - *type = GL_SHORT; - alphaFormat = AF_11BIT; - } else - return KTX_UNSUPPORTED_TEXTURE_TYPE; + case GL_ETC1_RGB8_OES: + case GL_COMPRESSED_RGB8_ETC2: + dstChannelBytes = sizeof(GLubyte); + dstChannels = 3; + *internalFormat = GL_RGB8; + *format = GL_RGB; + *type = GL_UNSIGNED_BYTE; break; - case GL_COMPRESSED_RG11_EAC: - if (R16Formats & _KTX_R16_FORMATS_NORM) { - dstChannelBytes = sizeof(GLshort); - dstChannels = 2; - formatSigned = GL_FALSE; - *internalFormat = GL_RG16; - *format = GL_RG; - *type = GL_UNSIGNED_SHORT; - alphaFormat = AF_11BIT; - } else - return KTX_UNSUPPORTED_TEXTURE_TYPE; + case GL_COMPRESSED_RGBA8_ETC2_EAC: + dstChannelBytes = sizeof(GLubyte); + dstChannels = 4; + *internalFormat = GL_RGBA8; + *format = GL_RGBA; + *type = GL_UNSIGNED_BYTE; + alphaFormat = AF_8BIT; break; - case GL_ETC1_RGB8_OES: - case GL_COMPRESSED_RGB8_ETC2: - dstChannelBytes = sizeof(GLubyte); - dstChannels = 3; - *internalFormat = GL_RGB8; - *format = GL_RGB; - *type = GL_UNSIGNED_BYTE; + case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: + dstChannelBytes = sizeof(GLubyte); + dstChannels = 4; + *internalFormat = GL_RGBA8; + *format = GL_RGBA; + *type = GL_UNSIGNED_BYTE; + alphaFormat = AF_1BIT; break; - case GL_COMPRESSED_RGBA8_ETC2_EAC: - dstChannelBytes = sizeof(GLubyte); - dstChannels = 4; - *internalFormat = GL_RGBA8; - *format = GL_RGBA; - *type = GL_UNSIGNED_BYTE; - alphaFormat = AF_8BIT; - break; - - case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: - dstChannelBytes = sizeof(GLubyte); - dstChannels = 4; - *internalFormat = GL_RGBA8; - *format = GL_RGBA; - *type = GL_UNSIGNED_BYTE; - alphaFormat = AF_1BIT; + case GL_COMPRESSED_SRGB8_ETC2: + if (supportsSRGB) { + dstChannelBytes = sizeof(GLubyte); + dstChannels = 3; + *internalFormat = GL_SRGB8; + *format = GL_RGB; + *type = GL_UNSIGNED_BYTE; + } else + return KTX_UNSUPPORTED_TEXTURE_TYPE; break; - case GL_COMPRESSED_SRGB8_ETC2: - if (supportsSRGB) { - dstChannelBytes = sizeof(GLubyte); - dstChannels = 3; - *internalFormat = GL_SRGB8; - *format = GL_RGB; - *type = GL_UNSIGNED_BYTE; - } else - return KTX_UNSUPPORTED_TEXTURE_TYPE; + case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: + if (supportsSRGB) { + dstChannelBytes = sizeof(GLubyte); + dstChannels = 4; + *internalFormat = GL_SRGB8_ALPHA8; + *format = GL_RGBA; + *type = GL_UNSIGNED_BYTE; + alphaFormat = AF_8BIT; + } else + return KTX_UNSUPPORTED_TEXTURE_TYPE; break; - case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: - if (supportsSRGB) { - dstChannelBytes = sizeof(GLubyte); - dstChannels = 4; - *internalFormat = GL_SRGB8_ALPHA8; - *format = GL_RGBA; - *type = GL_UNSIGNED_BYTE; - alphaFormat = AF_8BIT; - } else - return KTX_UNSUPPORTED_TEXTURE_TYPE; - break; - - case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: - if (supportsSRGB) { - dstChannelBytes = sizeof(GLubyte); - dstChannels = 4; - *internalFormat = GL_SRGB8_ALPHA8; - *format = GL_RGBA; - *type = GL_UNSIGNED_BYTE; - alphaFormat = AF_1BIT; - } else - return KTX_UNSUPPORTED_TEXTURE_TYPE; + case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: + if (supportsSRGB) { + dstChannelBytes = sizeof(GLubyte); + dstChannels = 4; + *internalFormat = GL_SRGB8_ALPHA8; + *format = GL_RGBA; + *type = GL_UNSIGNED_BYTE; + alphaFormat = AF_1BIT; + } else + return KTX_UNSUPPORTED_TEXTURE_TYPE; break; - default: - assert(0); // Upper levels should pass only one of the above srcFormats. - return KTX_UNSUPPORTED_TEXTURE_TYPE; // For Release configurations. - } + default: + assert(0); // Upper levels should pass only one of the above srcFormats. + return KTX_UNSUPPORTED_TEXTURE_TYPE; // For Release configurations. + } /* active_{width,height} show how many pixels contain active data, - * (the rest are just for making sure we have a 2*a x 4*b size). - */ - - /* Compute the full width & height. */ - width = ((activeWidth+3)/4)*4; - height = ((activeHeight+3)/4)*4; - - /* printf("Width = %d, Height = %d\n", width, height); */ - /* printf("active pixel area: top left %d x %d area.\n", activeWidth, activeHeight); */ - - *dstImage = (GLubyte*)malloc(dstChannels*dstChannelBytes*width*height); - if (!*dstImage) { - return KTX_OUT_OF_MEMORY; - } - - if (alphaFormat != AF_NONE) - setupAlphaTable(); - - // NOTE: none of the decompress functions actually use the parameter - if (alphaFormat == AF_11BIT) { - // One or two 11-bit alpha channels for R or RG. - for (y=0; y < height/4; y++) { - for (x=0; x < width/4; x++) { - decompressBlockAlpha16bitC(src, *dstImage, width, height, 4*x, 4*y, dstChannels); - src += 8; - if (srcFormat == GL_COMPRESSED_RG11_EAC || srcFormat == GL_COMPRESSED_SIGNED_RG11_EAC) { - decompressBlockAlpha16bitC(src, *dstImage + dstChannelBytes, width, height, 4*x, 4*y, dstChannels); - src += 8; - } - } - } - } else { - for (y=0; y < height/4; y++) { - for (x=0; x < width/4; x++) { - // Decode alpha channel for RGBA - if (alphaFormat == AF_8BIT) { - decompressBlockAlphaC(src, *dstImage + 3, width, height, 4*x, 4*y, dstChannels); - src += 8; - } - // Decode color dstChannels - readBigEndian4byteWord(&block_part1, src); - src += 4; - readBigEndian4byteWord(&block_part2, src); - src += 4; - if (alphaFormat == AF_1BIT) - decompressBlockETC21BitAlphaC(block_part1, block_part2, *dstImage, 0, width, height, 4*x, 4*y, dstChannels); - else - decompressBlockETC2c(block_part1, block_part2, *dstImage, width, height, 4*x, 4*y, dstChannels); - } - } - } - - /* Ok, now write out the active pixels to the destination image. - * (But only if the active pixels differ from the total pixels) - */ - - if( !(height == activeHeight && width == activeWidth) ) { - int dstPixelBytes = dstChannels * dstChannelBytes; - int dstRowBytes = dstPixelBytes * width; - int activeRowBytes = activeWidth * dstPixelBytes; - GLubyte *newimg = (GLubyte*)malloc(dstPixelBytes * activeWidth * activeHeight); - unsigned int xx, yy; - int zz; - - if (!newimg) { - free(*dstImage); - return KTX_OUT_OF_MEMORY; - } - - /* Convert from total area to active area: */ - - for (yy = 0; yy < activeHeight; yy++) { - for (xx = 0; xx < activeWidth; xx++) { - for (zz = 0; zz < dstPixelBytes; zz++) { - newimg[ yy*activeRowBytes + xx*dstPixelBytes + zz ] = (*dstImage)[ yy*dstRowBytes + xx*dstPixelBytes + zz]; - } - } - } - - free(*dstImage); - *dstImage = newimg; - } - - return KTX_SUCCESS; + * (the rest are just for making sure we have a 2*a x 4*b size). + */ + + /* Compute the full width & height. */ + width = ((activeWidth + 3) / 4) * 4; + height = ((activeHeight + 3) / 4) * 4; + + /* printf("Width = %d, Height = %d\n", width, height); */ + /* printf("active pixel area: top left %d x %d area.\n", activeWidth, activeHeight); */ + + *dstImage = (GLubyte*)malloc(dstChannels * dstChannelBytes * width * height); + if (!*dstImage) { + return KTX_OUT_OF_MEMORY; + } + + if (alphaFormat != AF_NONE) setupAlphaTable(); + + // NOTE: none of the decompress functions actually use the parameter + if (alphaFormat == AF_11BIT) { + // One or two 11-bit alpha channels for R or RG. + for (y = 0; y < height / 4; y++) { + for (x = 0; x < width / 4; x++) { + decompressBlockAlpha16bitC(src, *dstImage, width, height, 4 * x, 4 * y, dstChannels); + src += 8; + if (srcFormat == GL_COMPRESSED_RG11_EAC || srcFormat == GL_COMPRESSED_SIGNED_RG11_EAC) { + decompressBlockAlpha16bitC(src, *dstImage + dstChannelBytes, width, height, 4 * x, 4 * y, dstChannels); + src += 8; + } + } + } + } else { + for (y = 0; y < height / 4; y++) { + for (x = 0; x < width / 4; x++) { + // Decode alpha channel for RGBA + if (alphaFormat == AF_8BIT) { + decompressBlockAlphaC(src, *dstImage + 3, width, height, 4 * x, 4 * y, dstChannels); + src += 8; + } + // Decode color dstChannels + readBigEndian4byteWord(&block_part1, src); + src += 4; + readBigEndian4byteWord(&block_part2, src); + src += 4; + if (alphaFormat == AF_1BIT) + decompressBlockETC21BitAlphaC(block_part1, block_part2, *dstImage, 0, width, height, 4 * x, 4 * y, dstChannels); + else + decompressBlockETC2c(block_part1, block_part2, *dstImage, width, height, 4 * x, 4 * y, dstChannels); + } + } + } + + /* Ok, now write out the active pixels to the destination image. + * (But only if the active pixels differ from the total pixels) + */ + + if (!(height == activeHeight && width == activeWidth)) { + int dstPixelBytes = dstChannels * dstChannelBytes; + int dstRowBytes = dstPixelBytes * width; + int activeRowBytes = activeWidth * dstPixelBytes; + GLubyte* newimg = (GLubyte*)malloc(dstPixelBytes * activeWidth * activeHeight); + unsigned int xx, yy; + int zz; + + if (!newimg) { + free(*dstImage); + return KTX_OUT_OF_MEMORY; + } + + /* Convert from total area to active area: */ + + for (yy = 0; yy < activeHeight; yy++) { + for (xx = 0; xx < activeWidth; xx++) { + for (zz = 0; zz < dstPixelBytes; zz++) { + newimg[yy * activeRowBytes + xx * dstPixelBytes + zz] = (*dstImage)[yy * dstRowBytes + xx * dstPixelBytes + zz]; + } + } + } + + free(*dstImage); + *dstImage = newimg; + } + + return KTX_SUCCESS; } #endif /* SUPPORT_SOFTWARE_ETC_UNPACK */ diff --git a/lib/filestream.c b/lib/filestream.c index 31f964b9fc..e6192f0304 100644 --- a/lib/filestream.c +++ b/lib/filestream.c @@ -27,8 +27,8 @@ #define _POSIX_SOURCE 1 // For both the above in Emscripten. #include #include -#include // For stat.h on Windows -#define __USE_MISC 1 // For declaration of S_IF... +#include // For stat.h on Windows +#define __USE_MISC 1 // For declaration of S_IF... #include #include "ktx.h" @@ -37,23 +37,23 @@ // Gotta love Windows :-( #if defined(_MSC_VER) - #if defined(_WIN64) - #define ftello _ftelli64 - #define fseeko _fseeki64 - #else - #define ftello ftell - #define fseeko fseek - #endif - #define fileno _fileno - #define fstat _fstat - #define stat _stat - #define S_IFIFO _S_IFIFO - #define S_IFSOCK 0xC000 - typedef unsigned short mode_t; +#if defined(_WIN64) +#define ftello _ftelli64 +#define fseeko _fseeki64 +#else +#define ftello ftell +#define fseeko fseek +#endif +#define fileno _fileno +#define fstat _fstat +#define stat _stat +#define S_IFIFO _S_IFIFO +#define S_IFSOCK 0xC000 +typedef unsigned short mode_t; #endif #if defined(__MINGW32__) - #define S_IFSOCK 0xC000 +#define S_IFSOCK 0xC000 #endif #define KTX_FILE_STREAM_MAX (1 << (sizeof(ktx_off_t) - 1) - 1) @@ -74,13 +74,11 @@ * @exception KTX_FILE_READ_ERROR an error occurred while reading the file. * @exception KTX_FILE_UNEXPECTED_EOF not enough data to satisfy the request. */ -static -KTX_error_code ktxFileStream_read(ktxStream* str, void* dst, const ktx_size_t count) -{ +static KTX_error_code +ktxFileStream_read(ktxStream* str, void* dst, const ktx_size_t count) { ktx_size_t nread; - if (!str || !dst) - return KTX_INVALID_VALUE; + if (!str || !dst) return KTX_INVALID_VALUE; assert(str->type == eStreamTypeFile); @@ -115,11 +113,9 @@ KTX_error_code ktxFileStream_read(ktxStream* str, void* dst, const ktx_size_t co * @p count is set to the number of bytes * skipped. */ -static -KTX_error_code ktxFileStream_skip(ktxStream* str, const ktx_size_t count) -{ - if (!str) - return KTX_INVALID_VALUE; +static KTX_error_code +ktxFileStream_skip(ktxStream* str, const ktx_size_t count) { + if (!str) return KTX_INVALID_VALUE; assert(str->type == eStreamTypeFile); @@ -158,13 +154,9 @@ KTX_error_code ktxFileStream_skip(ktxStream* str, const ktx_size_t count) * @exception KTX_FILE_WRITE_ERROR a system error occurred while writing the * file. */ -static -KTX_error_code ktxFileStream_write(ktxStream* str, const void *src, - const ktx_size_t size, - const ktx_size_t count) -{ - if (!str || !src) - return KTX_INVALID_VALUE; +static KTX_error_code +ktxFileStream_write(ktxStream* str, const void* src, const ktx_size_t size, const ktx_size_t count) { + if (!str || !src) return KTX_INVALID_VALUE; assert(str->type == eStreamTypeFile); @@ -192,13 +184,11 @@ KTX_error_code ktxFileStream_write(ktxStream* str, const void *src, * file-position indicator. * @exception KTX_INVALID_VALUE @p str or @p pos is @c NULL. */ -static -KTX_error_code ktxFileStream_getpos(ktxStream* str, ktx_off_t* pos) -{ +static KTX_error_code +ktxFileStream_getpos(ktxStream* str, ktx_off_t* pos) { ktx_off_t ftellval; - if (!str || !pos) - return KTX_INVALID_VALUE; + if (!str || !pos) return KTX_INVALID_VALUE; assert(str->type == eStreamTypeFile); @@ -211,8 +201,10 @@ KTX_error_code ktxFileStream_getpos(ktxStream* str, ktx_off_t* pos) ftellval = (ktx_off_t)ftello(str->data.file); if (ftellval < 0) { switch (errno) { - case ESPIPE: return KTX_FILE_ISPIPE; - case EOVERFLOW: return KTX_FILE_OVERFLOW; + case ESPIPE: + return KTX_FILE_ISPIPE; + case EOVERFLOW: + return KTX_FILE_OVERFLOW; } } @@ -243,14 +235,12 @@ KTX_error_code ktxFileStream_getpos(ktxStream* str, ktx_off_t* pos) * @exception KTX_INVALID_OPERATION @p pos is > the size of the file or an * fseek error occurred. */ -static -KTX_error_code ktxFileStream_setpos(ktxStream* str, ktx_off_t pos) -{ +static KTX_error_code +ktxFileStream_setpos(ktxStream* str, ktx_off_t pos) { ktx_size_t fileSize; KTX_error_code result; - if (!str) - return KTX_INVALID_VALUE; + if (!str) return KTX_INVALID_VALUE; assert(str->type == eStreamTypeFile); @@ -268,13 +258,12 @@ KTX_error_code ktxFileStream_setpos(ktxStream* str, ktx_off_t pos) return result; } - if (pos > (ktx_off_t)fileSize) - return KTX_INVALID_OPERATION; + if (pos > (ktx_off_t)fileSize) return KTX_INVALID_OPERATION; if (fseeko(str->data.file, pos, SEEK_SET) < 0) - return KTX_FILE_SEEK_ERROR; + return KTX_FILE_SEEK_ERROR; else - return KTX_SUCCESS; + return KTX_SUCCESS; } /** @@ -296,14 +285,12 @@ KTX_error_code ktxFileStream_setpos(ktxStream* str, ktx_off_t pos) * @exception KTX_INVALID_VALUE @p str or @p size is @c NULL. * @exception KTX_INVALID_OPERATION stream is a tty. */ -static -KTX_error_code ktxFileStream_getsize(ktxStream* str, ktx_size_t* size) -{ +static KTX_error_code +ktxFileStream_getsize(ktxStream* str, ktx_size_t* size) { struct stat statbuf; int statret; - if (!str || !size) - return KTX_INVALID_VALUE; + if (!str || !size) return KTX_INVALID_VALUE; assert(str->type == eStreamTypeFile); @@ -313,27 +300,25 @@ KTX_error_code ktxFileStream_getsize(ktxStream* str, ktx_size_t* size) #if (defined(_MSC_VER) && _MSC_VER < 1900) || defined(__MINGW64__) && !defined(_UCRT) // Bug in VS2013 msvcrt. fflush on FILE open for READ changes file offset // to 4096. - if (str->data.file->_flag & _IOWRT) - (void)fflush(str->data.file); + if (str->data.file->_flag & _IOWRT) (void)fflush(str->data.file); #else (void)fflush(str->data.file); #endif statret = fstat(fileno(str->data.file), &statbuf); if (statret < 0) { switch (errno) { - case EOVERFLOW: return KTX_FILE_OVERFLOW; - case EIO: - default: + case EOVERFLOW: + return KTX_FILE_OVERFLOW; + case EIO: + default: return KTX_FILE_READ_ERROR; } } mode_t ftype = statbuf.st_mode & S_IFMT; - if (ftype == S_IFIFO || ftype == S_IFSOCK) - return KTX_FILE_ISPIPE; + if (ftype == S_IFIFO || ftype == S_IFSOCK) return KTX_FILE_ISPIPE; - if (statbuf.st_mode & S_IFCHR) - return KTX_INVALID_OPERATION; + if (statbuf.st_mode & S_IFCHR) return KTX_INVALID_OPERATION; *size = (ktx_size_t)statbuf.st_size; /* See _getpos for why this cast. */ @@ -353,11 +338,9 @@ KTX_error_code ktxFileStream_getsize(ktxStream* str, ktx_size_t* size) * * @exception KTX_INVALID_VALUE @p stream is @c NULL or @p file is @c NULL. */ -KTX_error_code ktxFileStream_construct(ktxStream* str, FILE* file, - ktx_bool_t closeFileOnDestruct) -{ - if (!str || !file) - return KTX_INVALID_VALUE; +KTX_error_code +ktxFileStream_construct(ktxStream* str, FILE* file, ktx_bool_t closeFileOnDestruct) { + if (!str || !file) return KTX_INVALID_VALUE; str->data.file = file; str->readpos = 0; @@ -385,11 +368,9 @@ KTX_error_code ktxFileStream_construct(ktxStream* str, FILE* file, * be closed. */ void -ktxFileStream_destruct(ktxStream* str) -{ +ktxFileStream_destruct(ktxStream* str) { assert(str && str->type == eStreamTypeFile); - if (str->closeOnDestruct) - fclose(str->data.file); + if (str->closeOnDestruct) fclose(str->data.file); str->data.file = 0; } diff --git a/lib/filestream.h b/lib/filestream.h index 5c0ea7d2dd..eaa809c0a7 100644 --- a/lib/filestream.h +++ b/lib/filestream.h @@ -19,8 +19,7 @@ /* * ktxFileInit: Initialize a ktxStream to a ktxFileStream with a FILE object */ -KTX_error_code ktxFileStream_construct(ktxStream* str, FILE* file, - ktx_bool_t closeFileOnDestruct); +KTX_error_code ktxFileStream_construct(ktxStream* str, FILE* file, ktx_bool_t closeFileOnDestruct); void ktxFileStream_destruct(ktxStream* str); diff --git a/lib/formatsize.h b/lib/formatsize.h index 149ff18d61..757d212275 100644 --- a/lib/formatsize.h +++ b/lib/formatsize.h @@ -22,12 +22,12 @@ #include "ktx.h" typedef enum ktxFormatSizeFlagBits { - KTX_FORMAT_SIZE_PACKED_BIT = 0x00000001, - KTX_FORMAT_SIZE_COMPRESSED_BIT = 0x00000002, - KTX_FORMAT_SIZE_PALETTIZED_BIT = 0x00000004, - KTX_FORMAT_SIZE_DEPTH_BIT = 0x00000008, - KTX_FORMAT_SIZE_STENCIL_BIT = 0x00000010, - KTX_FORMAT_SIZE_YUVSDA_BIT = 0x00000020, + KTX_FORMAT_SIZE_PACKED_BIT = 0x00000001, + KTX_FORMAT_SIZE_COMPRESSED_BIT = 0x00000002, + KTX_FORMAT_SIZE_PALETTIZED_BIT = 0x00000004, + KTX_FORMAT_SIZE_DEPTH_BIT = 0x00000008, + KTX_FORMAT_SIZE_STENCIL_BIT = 0x00000010, + KTX_FORMAT_SIZE_YUVSDA_BIT = 0x00000020, } ktxFormatSizeFlagBits; typedef ktx_uint32_t ktxFormatSizeFlags; @@ -36,14 +36,14 @@ typedef ktx_uint32_t ktxFormatSizeFlags; * @brief Structure for holding size information for a texture format. */ typedef struct ktxFormatSize { - ktxFormatSizeFlags flags; - unsigned int paletteSizeInBits; // For KTX1. - unsigned int blockSizeInBits; - unsigned int blockWidth; // in texels - unsigned int blockHeight; // in texels - unsigned int blockDepth; // in texels - unsigned int minBlocksX; // Minimum required number of blocks - unsigned int minBlocksY; + ktxFormatSizeFlags flags; + unsigned int paletteSizeInBits; // For KTX1. + unsigned int blockSizeInBits; + unsigned int blockWidth; // in texels + unsigned int blockHeight; // in texels + unsigned int blockDepth; // in texels + unsigned int minBlocksX; // Minimum required number of blocks + unsigned int minBlocksY; } ktxFormatSize; #ifdef __cplusplus @@ -53,7 +53,7 @@ extern "C" { bool ktxFormatSize_initFromDfd(ktxFormatSize* This, ktx_uint32_t* pDfd); #ifdef __cplusplus -} // extern "C" +} // extern "C" #endif #endif /* _FORMATSIZE_H_ */ diff --git a/lib/gl_format.h b/lib/gl_format.h index 44abd2c6d4..71a90a6f3a 100644 --- a/lib/gl_format.h +++ b/lib/gl_format.h @@ -29,23 +29,23 @@ This header stores the OpenGL formats/types that are used as parameters to the following OpenGL functions: void glTexImage2D( GLenum target, GLint level, GLint internalFormat, - GLsizei width, GLsizei height, GLint border, - GLenum format, GLenum type, const GLvoid * data ); + GLsizei width, GLsizei height, GLint border, + GLenum format, GLenum type, const GLvoid * data ); void glTexImage3D( GLenum target, GLint level, GLint internalFormat, - GLsizei width, GLsizei height, GLsizei depth, GLint border, - GLenum format, GLenum type, const GLvoid * data ); + GLsizei width, GLsizei height, GLsizei depth, GLint border, + GLenum format, GLenum type, const GLvoid * data ); void glCompressedTexImage2D( GLenum target, GLint level, GLenum internalformat, - GLsizei width, GLsizei height, GLint border, - GLsizei imageSize, const GLvoid * data ); + GLsizei width, GLsizei height, GLint border, + GLsizei imageSize, const GLvoid * data ); void glCompressedTexImage3D( GLenum target, GLint level, GLenum internalformat, - GLsizei width, GLsizei height, GLsizei depth, GLint border, - GLsizei imageSize, const GLvoid * data ); + GLsizei width, GLsizei height, GLsizei depth, GLint border, + GLsizei imageSize, const GLvoid * data ); void glTexStorage2D( GLenum target, GLsizei levels, GLenum internalformat, - GLsizei width, GLsizei height ); + GLsizei width, GLsizei height ); void glTexStorage3D( GLenum target, GLsizei levels, GLenum internalformat, - GLsizei width, GLsizei height, GLsizei depth ); + GLsizei width, GLsizei height, GLsizei depth ); void glVertexAttribPointer( GLuint index, GLint size, GLenum type, GLboolean normalized, - GLsizei stride, const GLvoid * pointer); + GLsizei stride, const GLvoid * pointer); IMPLEMENTATION @@ -82,7 +82,7 @@ MODIFICATIONS for use in libktx ================================================================================================ */ -#if !defined( GL_FORMAT_H ) +#if !defined(GL_FORMAT_H) #define GL_FORMAT_H #include @@ -92,14 +92,13 @@ MODIFICATIONS for use in libktx #if defined(_WIN32) && !defined(__MINGW32__) #if !defined(NOMINMAX) #define NOMINMAX -#endif // !defined(NOMINMAX) +#endif // !defined(NOMINMAX) #ifndef __cplusplus #undef inline #define inline __inline -#endif // __cplusplus +#endif // __cplusplus #endif - /* =========================================================================== Avoid warnings or even errors when using strict C99. "Redefinition of @@ -113,8 +112,8 @@ typedef unsigned char GLboolean; typedef unsigned int GLuint; #endif -#if !defined( GL_INVALID_VALUE ) -#define GL_INVALID_VALUE 0x0501 +#if !defined(GL_INVALID_VALUE) +#define GL_INVALID_VALUE 0x0501 #endif /* @@ -125,92 +124,92 @@ Format to glTexImage2D and glTexImage3D. ================================================================================================================================ */ -#if !defined( GL_RED ) -#define GL_RED 0x1903 // same as GL_RED_EXT +#if !defined(GL_RED) +#define GL_RED 0x1903 // same as GL_RED_EXT #endif -#if !defined( GL_GREEN ) -#define GL_GREEN 0x1904 // deprecated +#if !defined(GL_GREEN) +#define GL_GREEN 0x1904 // deprecated #endif -#if !defined( GL_BLUE ) -#define GL_BLUE 0x1905 // deprecated +#if !defined(GL_BLUE) +#define GL_BLUE 0x1905 // deprecated #endif -#if !defined( GL_ALPHA ) -#define GL_ALPHA 0x1906 // deprecated +#if !defined(GL_ALPHA) +#define GL_ALPHA 0x1906 // deprecated #endif -#if !defined( GL_LUMINANCE ) -#define GL_LUMINANCE 0x1909 // deprecated +#if !defined(GL_LUMINANCE) +#define GL_LUMINANCE 0x1909 // deprecated #endif -#if !defined( GL_SLUMINANCE ) -#define GL_SLUMINANCE 0x8C46 // deprecated, same as GL_SLUMINANCE_EXT +#if !defined(GL_SLUMINANCE) +#define GL_SLUMINANCE 0x8C46 // deprecated, same as GL_SLUMINANCE_EXT #endif -#if !defined( GL_LUMINANCE_ALPHA ) -#define GL_LUMINANCE_ALPHA 0x190A // deprecated +#if !defined(GL_LUMINANCE_ALPHA) +#define GL_LUMINANCE_ALPHA 0x190A // deprecated #endif -#if !defined( GL_SLUMINANCE_ALPHA ) -#define GL_SLUMINANCE_ALPHA 0x8C44 // deprecated, same as GL_SLUMINANCE_ALPHA_EXT +#if !defined(GL_SLUMINANCE_ALPHA) +#define GL_SLUMINANCE_ALPHA 0x8C44 // deprecated, same as GL_SLUMINANCE_ALPHA_EXT #endif -#if !defined( GL_INTENSITY ) -#define GL_INTENSITY 0x8049 // deprecated, same as GL_INTENSITY_EXT +#if !defined(GL_INTENSITY) +#define GL_INTENSITY 0x8049 // deprecated, same as GL_INTENSITY_EXT #endif -#if !defined( GL_RG ) -#define GL_RG 0x8227 // same as GL_RG_EXT +#if !defined(GL_RG) +#define GL_RG 0x8227 // same as GL_RG_EXT #endif -#if !defined( GL_RGB ) -#define GL_RGB 0x1907 +#if !defined(GL_RGB) +#define GL_RGB 0x1907 #endif -#if !defined( GL_BGR ) -#define GL_BGR 0x80E0 // same as GL_BGR_EXT +#if !defined(GL_BGR) +#define GL_BGR 0x80E0 // same as GL_BGR_EXT #endif -#if !defined( GL_RGBA ) -#define GL_RGBA 0x1908 +#if !defined(GL_RGBA) +#define GL_RGBA 0x1908 #endif -#if !defined( GL_BGRA ) -#define GL_BGRA 0x80E1 // same as GL_BGRA_EXT +#if !defined(GL_BGRA) +#define GL_BGRA 0x80E1 // same as GL_BGRA_EXT #endif -#if !defined( GL_RED_INTEGER ) -#define GL_RED_INTEGER 0x8D94 // same as GL_RED_INTEGER_EXT +#if !defined(GL_RED_INTEGER) +#define GL_RED_INTEGER 0x8D94 // same as GL_RED_INTEGER_EXT #endif -#if !defined( GL_GREEN_INTEGER ) -#define GL_GREEN_INTEGER 0x8D95 // deprecated, same as GL_GREEN_INTEGER_EXT +#if !defined(GL_GREEN_INTEGER) +#define GL_GREEN_INTEGER 0x8D95 // deprecated, same as GL_GREEN_INTEGER_EXT #endif -#if !defined( GL_BLUE_INTEGER ) -#define GL_BLUE_INTEGER 0x8D96 // deprecated, same as GL_BLUE_INTEGER_EXT +#if !defined(GL_BLUE_INTEGER) +#define GL_BLUE_INTEGER 0x8D96 // deprecated, same as GL_BLUE_INTEGER_EXT #endif -#if !defined( GL_ALPHA_INTEGER ) -#define GL_ALPHA_INTEGER 0x8D97 // deprecated, same as GL_ALPHA_INTEGER_EXT +#if !defined(GL_ALPHA_INTEGER) +#define GL_ALPHA_INTEGER 0x8D97 // deprecated, same as GL_ALPHA_INTEGER_EXT #endif -#if !defined( GL_LUMINANCE_INTEGER ) -#define GL_LUMINANCE_INTEGER 0x8D9C // deprecated, same as GL_LUMINANCE_INTEGER_EXT +#if !defined(GL_LUMINANCE_INTEGER) +#define GL_LUMINANCE_INTEGER 0x8D9C // deprecated, same as GL_LUMINANCE_INTEGER_EXT #endif -#if !defined( GL_LUMINANCE_ALPHA_INTEGER ) -#define GL_LUMINANCE_ALPHA_INTEGER 0x8D9D // deprecated, same as GL_LUMINANCE_ALPHA_INTEGER_EXT +#if !defined(GL_LUMINANCE_ALPHA_INTEGER) +#define GL_LUMINANCE_ALPHA_INTEGER 0x8D9D // deprecated, same as GL_LUMINANCE_ALPHA_INTEGER_EXT #endif -#if !defined( GL_RG_INTEGER ) -#define GL_RG_INTEGER 0x8228 // same as GL_RG_INTEGER_EXT +#if !defined(GL_RG_INTEGER) +#define GL_RG_INTEGER 0x8228 // same as GL_RG_INTEGER_EXT #endif -#if !defined( GL_RGB_INTEGER ) -#define GL_RGB_INTEGER 0x8D98 // same as GL_RGB_INTEGER_EXT +#if !defined(GL_RGB_INTEGER) +#define GL_RGB_INTEGER 0x8D98 // same as GL_RGB_INTEGER_EXT #endif -#if !defined( GL_BGR_INTEGER ) -#define GL_BGR_INTEGER 0x8D9A // same as GL_BGR_INTEGER_EXT +#if !defined(GL_BGR_INTEGER) +#define GL_BGR_INTEGER 0x8D9A // same as GL_BGR_INTEGER_EXT #endif -#if !defined( GL_RGBA_INTEGER ) -#define GL_RGBA_INTEGER 0x8D99 // same as GL_RGBA_INTEGER_EXT +#if !defined(GL_RGBA_INTEGER) +#define GL_RGBA_INTEGER 0x8D99 // same as GL_RGBA_INTEGER_EXT #endif -#if !defined( GL_BGRA_INTEGER ) -#define GL_BGRA_INTEGER 0x8D9B // same as GL_BGRA_INTEGER_EXT +#if !defined(GL_BGRA_INTEGER) +#define GL_BGRA_INTEGER 0x8D9B // same as GL_BGRA_INTEGER_EXT #endif -#if !defined( GL_COLOR_INDEX ) -#define GL_COLOR_INDEX 0x1900 // deprecated +#if !defined(GL_COLOR_INDEX) +#define GL_COLOR_INDEX 0x1900 // deprecated #endif -#if !defined( GL_STENCIL_INDEX ) -#define GL_STENCIL_INDEX 0x1901 +#if !defined(GL_STENCIL_INDEX) +#define GL_STENCIL_INDEX 0x1901 #endif -#if !defined( GL_DEPTH_COMPONENT ) -#define GL_DEPTH_COMPONENT 0x1902 +#if !defined(GL_DEPTH_COMPONENT) +#define GL_DEPTH_COMPONENT 0x1902 #endif -#if !defined( GL_DEPTH_STENCIL ) -#define GL_DEPTH_STENCIL 0x84F9 // same as GL_DEPTH_STENCIL_NV and GL_DEPTH_STENCIL_EXT and GL_DEPTH_STENCIL_OES +#if !defined(GL_DEPTH_STENCIL) +#define GL_DEPTH_STENCIL 0x84F9 // same as GL_DEPTH_STENCIL_NV and GL_DEPTH_STENCIL_EXT and GL_DEPTH_STENCIL_OES #endif /* @@ -221,89 +220,90 @@ Type to glTexImage2D, glTexImage3D and glVertexAttribPointer. ================================================================================================================================ */ -#if !defined( GL_BYTE ) -#define GL_BYTE 0x1400 +#if !defined(GL_BYTE) +#define GL_BYTE 0x1400 #endif -#if !defined( GL_UNSIGNED_BYTE ) -#define GL_UNSIGNED_BYTE 0x1401 +#if !defined(GL_UNSIGNED_BYTE) +#define GL_UNSIGNED_BYTE 0x1401 #endif -#if !defined( GL_SHORT ) -#define GL_SHORT 0x1402 +#if !defined(GL_SHORT) +#define GL_SHORT 0x1402 #endif -#if !defined( GL_UNSIGNED_SHORT ) -#define GL_UNSIGNED_SHORT 0x1403 +#if !defined(GL_UNSIGNED_SHORT) +#define GL_UNSIGNED_SHORT 0x1403 #endif -#if !defined( GL_INT ) -#define GL_INT 0x1404 +#if !defined(GL_INT) +#define GL_INT 0x1404 #endif -#if !defined( GL_UNSIGNED_INT ) -#define GL_UNSIGNED_INT 0x1405 +#if !defined(GL_UNSIGNED_INT) +#define GL_UNSIGNED_INT 0x1405 #endif -#if !defined( GL_INT64 ) -#define GL_INT64 0x140E // same as GL_INT64_NV and GL_INT64_ARB +#if !defined(GL_INT64) +#define GL_INT64 0x140E // same as GL_INT64_NV and GL_INT64_ARB #endif -#if !defined( GL_UNSIGNED_INT64 ) -#define GL_UNSIGNED_INT64 0x140F // same as GL_UNSIGNED_INT64_NV and GL_UNSIGNED_INT64_ARB +#if !defined(GL_UNSIGNED_INT64) +#define GL_UNSIGNED_INT64 0x140F // same as GL_UNSIGNED_INT64_NV and GL_UNSIGNED_INT64_ARB #endif -#if !defined( GL_HALF_FLOAT ) -#define GL_HALF_FLOAT 0x140B // same as GL_HALF_FLOAT_NV and GL_HALF_FLOAT_ARB +#if !defined(GL_HALF_FLOAT) +#define GL_HALF_FLOAT 0x140B // same as GL_HALF_FLOAT_NV and GL_HALF_FLOAT_ARB #endif -#if !defined( GL_HALF_FLOAT_OES ) -#define GL_HALF_FLOAT_OES 0x8D61 // Note that this different from GL_HALF_FLOAT. +#if !defined(GL_HALF_FLOAT_OES) +#define GL_HALF_FLOAT_OES 0x8D61 // Note that this different from GL_HALF_FLOAT. #endif -#if !defined( GL_FLOAT ) -#define GL_FLOAT 0x1406 +#if !defined(GL_FLOAT) +#define GL_FLOAT 0x1406 #endif -#if !defined( GL_DOUBLE ) -#define GL_DOUBLE 0x140A // same as GL_DOUBLE_EXT +#if !defined(GL_DOUBLE) +#define GL_DOUBLE 0x140A // same as GL_DOUBLE_EXT #endif -#if !defined( GL_UNSIGNED_BYTE_3_3_2 ) -#define GL_UNSIGNED_BYTE_3_3_2 0x8032 // same as GL_UNSIGNED_BYTE_3_3_2_EXT +#if !defined(GL_UNSIGNED_BYTE_3_3_2) +#define GL_UNSIGNED_BYTE_3_3_2 0x8032 // same as GL_UNSIGNED_BYTE_3_3_2_EXT #endif -#if !defined( GL_UNSIGNED_BYTE_2_3_3_REV ) -#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 // same as GL_UNSIGNED_BYTE_2_3_3_REV_EXT +#if !defined(GL_UNSIGNED_BYTE_2_3_3_REV) +#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 // same as GL_UNSIGNED_BYTE_2_3_3_REV_EXT #endif -#if !defined( GL_UNSIGNED_SHORT_5_6_5 ) -#define GL_UNSIGNED_SHORT_5_6_5 0x8363 // same as GL_UNSIGNED_SHORT_5_6_5_EXT +#if !defined(GL_UNSIGNED_SHORT_5_6_5) +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 // same as GL_UNSIGNED_SHORT_5_6_5_EXT #endif -#if !defined( GL_UNSIGNED_SHORT_5_6_5_REV ) -#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 // same as GL_UNSIGNED_SHORT_5_6_5_REV_EXT +#if !defined(GL_UNSIGNED_SHORT_5_6_5_REV) +#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 // same as GL_UNSIGNED_SHORT_5_6_5_REV_EXT #endif -#if !defined( GL_UNSIGNED_SHORT_4_4_4_4 ) -#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 // same as GL_UNSIGNED_SHORT_4_4_4_4_EXT +#if !defined(GL_UNSIGNED_SHORT_4_4_4_4) +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 // same as GL_UNSIGNED_SHORT_4_4_4_4_EXT #endif -#if !defined( GL_UNSIGNED_SHORT_4_4_4_4_REV ) -#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 // same as GL_UNSIGNED_SHORT_4_4_4_4_REV_IMG and GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT +#if !defined(GL_UNSIGNED_SHORT_4_4_4_4_REV) +#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 // same as GL_UNSIGNED_SHORT_4_4_4_4_REV_IMG and GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT #endif -#if !defined( GL_UNSIGNED_SHORT_5_5_5_1 ) -#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 // same as GL_UNSIGNED_SHORT_5_5_5_1_EXT +#if !defined(GL_UNSIGNED_SHORT_5_5_5_1) +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 // same as GL_UNSIGNED_SHORT_5_5_5_1_EXT #endif -#if !defined( GL_UNSIGNED_SHORT_1_5_5_5_REV ) -#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 // same as GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT +#if !defined(GL_UNSIGNED_SHORT_1_5_5_5_REV) +#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 // same as GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT #endif -#if !defined( GL_UNSIGNED_INT_8_8_8_8 ) -#define GL_UNSIGNED_INT_8_8_8_8 0x8035 // same as GL_UNSIGNED_INT_8_8_8_8_EXT +#if !defined(GL_UNSIGNED_INT_8_8_8_8) +#define GL_UNSIGNED_INT_8_8_8_8 0x8035 // same as GL_UNSIGNED_INT_8_8_8_8_EXT #endif -#if !defined( GL_UNSIGNED_INT_8_8_8_8_REV ) -#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 // same as GL_UNSIGNED_INT_8_8_8_8_REV_EXT +#if !defined(GL_UNSIGNED_INT_8_8_8_8_REV) +#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 // same as GL_UNSIGNED_INT_8_8_8_8_REV_EXT #endif -#if !defined( GL_UNSIGNED_INT_10_10_10_2 ) -#define GL_UNSIGNED_INT_10_10_10_2 0x8036 // same as GL_UNSIGNED_INT_10_10_10_2_EXT +#if !defined(GL_UNSIGNED_INT_10_10_10_2) +#define GL_UNSIGNED_INT_10_10_10_2 0x8036 // same as GL_UNSIGNED_INT_10_10_10_2_EXT #endif -#if !defined( GL_UNSIGNED_INT_2_10_10_10_REV ) -#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 // same as GL_UNSIGNED_INT_2_10_10_10_REV_EXT +#if !defined(GL_UNSIGNED_INT_2_10_10_10_REV) +#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 // same as GL_UNSIGNED_INT_2_10_10_10_REV_EXT #endif -#if !defined( GL_UNSIGNED_INT_10F_11F_11F_REV ) -#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B // same as GL_UNSIGNED_INT_10F_11F_11F_REV_EXT +#if !defined(GL_UNSIGNED_INT_10F_11F_11F_REV) +#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B // same as GL_UNSIGNED_INT_10F_11F_11F_REV_EXT #endif -#if !defined( GL_UNSIGNED_INT_5_9_9_9_REV ) -#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E // same as GL_UNSIGNED_INT_5_9_9_9_REV_EXT +#if !defined(GL_UNSIGNED_INT_5_9_9_9_REV) +#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E // same as GL_UNSIGNED_INT_5_9_9_9_REV_EXT #endif -#if !defined( GL_UNSIGNED_INT_24_8 ) -#define GL_UNSIGNED_INT_24_8 0x84FA // same as GL_UNSIGNED_INT_24_8_NV and GL_UNSIGNED_INT_24_8_EXT and GL_UNSIGNED_INT_24_8_OES +#if !defined(GL_UNSIGNED_INT_24_8) +#define GL_UNSIGNED_INT_24_8 0x84FA // same as GL_UNSIGNED_INT_24_8_NV and GL_UNSIGNED_INT_24_8_EXT and GL_UNSIGNED_INT_24_8_OES #endif -#if !defined( GL_FLOAT_32_UNSIGNED_INT_24_8_REV ) -#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD // same as GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV and GL_FLOAT_32_UNSIGNED_INT_24_8_REV_ARB +#if !defined(GL_FLOAT_32_UNSIGNED_INT_24_8_REV) +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV \ + 0x8DAD // same as GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV and GL_FLOAT_32_UNSIGNED_INT_24_8_REV_ARB #endif /* @@ -318,2121 +318,2484 @@ Internal format to glTexImage2D, glTexImage3D, glCompressedTexImage2D, glCompres // 8 bits per component // -#if !defined( GL_R8 ) -#define GL_R8 0x8229 // same as GL_R8_EXT +#if !defined(GL_R8) +#define GL_R8 0x8229 // same as GL_R8_EXT #endif -#if !defined( GL_RG8 ) -#define GL_RG8 0x822B // same as GL_RG8_EXT +#if !defined(GL_RG8) +#define GL_RG8 0x822B // same as GL_RG8_EXT #endif -#if !defined( GL_RGB8 ) -#define GL_RGB8 0x8051 // same as GL_RGB8_EXT and GL_RGB8_OES +#if !defined(GL_RGB8) +#define GL_RGB8 0x8051 // same as GL_RGB8_EXT and GL_RGB8_OES #endif -#if !defined( GL_RGBA8 ) -#define GL_RGBA8 0x8058 // same as GL_RGBA8_EXT and GL_RGBA8_OES +#if !defined(GL_RGBA8) +#define GL_RGBA8 0x8058 // same as GL_RGBA8_EXT and GL_RGBA8_OES #endif -#if !defined( GL_R8_SNORM ) -#define GL_R8_SNORM 0x8F94 +#if !defined(GL_R8_SNORM) +#define GL_R8_SNORM 0x8F94 #endif -#if !defined( GL_RG8_SNORM ) -#define GL_RG8_SNORM 0x8F95 +#if !defined(GL_RG8_SNORM) +#define GL_RG8_SNORM 0x8F95 #endif -#if !defined( GL_RGB8_SNORM ) -#define GL_RGB8_SNORM 0x8F96 +#if !defined(GL_RGB8_SNORM) +#define GL_RGB8_SNORM 0x8F96 #endif -#if !defined( GL_RGBA8_SNORM ) -#define GL_RGBA8_SNORM 0x8F97 +#if !defined(GL_RGBA8_SNORM) +#define GL_RGBA8_SNORM 0x8F97 #endif -#if !defined( GL_R8UI ) -#define GL_R8UI 0x8232 +#if !defined(GL_R8UI) +#define GL_R8UI 0x8232 #endif -#if !defined( GL_RG8UI ) -#define GL_RG8UI 0x8238 +#if !defined(GL_RG8UI) +#define GL_RG8UI 0x8238 #endif -#if !defined( GL_RGB8UI ) -#define GL_RGB8UI 0x8D7D // same as GL_RGB8UI_EXT +#if !defined(GL_RGB8UI) +#define GL_RGB8UI 0x8D7D // same as GL_RGB8UI_EXT #endif -#if !defined( GL_RGBA8UI ) -#define GL_RGBA8UI 0x8D7C // same as GL_RGBA8UI_EXT +#if !defined(GL_RGBA8UI) +#define GL_RGBA8UI 0x8D7C // same as GL_RGBA8UI_EXT #endif -#if !defined( GL_R8I ) -#define GL_R8I 0x8231 +#if !defined(GL_R8I) +#define GL_R8I 0x8231 #endif -#if !defined( GL_RG8I ) -#define GL_RG8I 0x8237 +#if !defined(GL_RG8I) +#define GL_RG8I 0x8237 #endif -#if !defined( GL_RGB8I ) -#define GL_RGB8I 0x8D8F // same as GL_RGB8I_EXT +#if !defined(GL_RGB8I) +#define GL_RGB8I 0x8D8F // same as GL_RGB8I_EXT #endif -#if !defined( GL_RGBA8I ) -#define GL_RGBA8I 0x8D8E // same as GL_RGBA8I_EXT +#if !defined(GL_RGBA8I) +#define GL_RGBA8I 0x8D8E // same as GL_RGBA8I_EXT #endif -#if !defined( GL_SR8 ) -#define GL_SR8 0x8FBD // same as GL_SR8_EXT +#if !defined(GL_SR8) +#define GL_SR8 0x8FBD // same as GL_SR8_EXT #endif -#if !defined( GL_SRG8 ) -#define GL_SRG8 0x8FBE // same as GL_SRG8_EXT +#if !defined(GL_SRG8) +#define GL_SRG8 0x8FBE // same as GL_SRG8_EXT #endif -#if !defined( GL_SRGB8 ) -#define GL_SRGB8 0x8C41 // same as GL_SRGB8_EXT +#if !defined(GL_SRGB8) +#define GL_SRGB8 0x8C41 // same as GL_SRGB8_EXT #endif -#if !defined( GL_SRGB8_ALPHA8 ) -#define GL_SRGB8_ALPHA8 0x8C43 // same as GL_SRGB8_ALPHA8_EXT +#if !defined(GL_SRGB8_ALPHA8) +#define GL_SRGB8_ALPHA8 0x8C43 // same as GL_SRGB8_ALPHA8_EXT #endif // // 16 bits per component // -#if !defined( GL_R16 ) -#define GL_R16 0x822A // same as GL_R16_EXT +#if !defined(GL_R16) +#define GL_R16 0x822A // same as GL_R16_EXT #endif -#if !defined( GL_RG16 ) -#define GL_RG16 0x822C // same as GL_RG16_EXT +#if !defined(GL_RG16) +#define GL_RG16 0x822C // same as GL_RG16_EXT #endif -#if !defined( GL_RGB16 ) -#define GL_RGB16 0x8054 // same as GL_RGB16_EXT +#if !defined(GL_RGB16) +#define GL_RGB16 0x8054 // same as GL_RGB16_EXT #endif -#if !defined( GL_RGBA16 ) -#define GL_RGBA16 0x805B // same as GL_RGBA16_EXT +#if !defined(GL_RGBA16) +#define GL_RGBA16 0x805B // same as GL_RGBA16_EXT #endif -#if !defined( GL_R16_SNORM ) -#define GL_R16_SNORM 0x8F98 // same as GL_R16_SNORM_EXT +#if !defined(GL_R16_SNORM) +#define GL_R16_SNORM 0x8F98 // same as GL_R16_SNORM_EXT #endif -#if !defined( GL_RG16_SNORM ) -#define GL_RG16_SNORM 0x8F99 // same as GL_RG16_SNORM_EXT +#if !defined(GL_RG16_SNORM) +#define GL_RG16_SNORM 0x8F99 // same as GL_RG16_SNORM_EXT #endif -#if !defined( GL_RGB16_SNORM ) -#define GL_RGB16_SNORM 0x8F9A // same as GL_RGB16_SNORM_EXT +#if !defined(GL_RGB16_SNORM) +#define GL_RGB16_SNORM 0x8F9A // same as GL_RGB16_SNORM_EXT #endif -#if !defined( GL_RGBA16_SNORM ) -#define GL_RGBA16_SNORM 0x8F9B // same as GL_RGBA16_SNORM_EXT +#if !defined(GL_RGBA16_SNORM) +#define GL_RGBA16_SNORM 0x8F9B // same as GL_RGBA16_SNORM_EXT #endif -#if !defined( GL_R16UI ) -#define GL_R16UI 0x8234 +#if !defined(GL_R16UI) +#define GL_R16UI 0x8234 #endif -#if !defined( GL_RG16UI ) -#define GL_RG16UI 0x823A +#if !defined(GL_RG16UI) +#define GL_RG16UI 0x823A #endif -#if !defined( GL_RGB16UI ) -#define GL_RGB16UI 0x8D77 // same as GL_RGB16UI_EXT +#if !defined(GL_RGB16UI) +#define GL_RGB16UI 0x8D77 // same as GL_RGB16UI_EXT #endif -#if !defined( GL_RGBA16UI ) -#define GL_RGBA16UI 0x8D76 // same as GL_RGBA16UI_EXT +#if !defined(GL_RGBA16UI) +#define GL_RGBA16UI 0x8D76 // same as GL_RGBA16UI_EXT #endif -#if !defined( GL_R16I ) -#define GL_R16I 0x8233 +#if !defined(GL_R16I) +#define GL_R16I 0x8233 #endif -#if !defined( GL_RG16I ) -#define GL_RG16I 0x8239 +#if !defined(GL_RG16I) +#define GL_RG16I 0x8239 #endif -#if !defined( GL_RGB16I ) -#define GL_RGB16I 0x8D89 // same as GL_RGB16I_EXT +#if !defined(GL_RGB16I) +#define GL_RGB16I 0x8D89 // same as GL_RGB16I_EXT #endif -#if !defined( GL_RGBA16I ) -#define GL_RGBA16I 0x8D88 // same as GL_RGBA16I_EXT +#if !defined(GL_RGBA16I) +#define GL_RGBA16I 0x8D88 // same as GL_RGBA16I_EXT #endif -#if !defined( GL_R16F ) -#define GL_R16F 0x822D // same as GL_R16F_EXT +#if !defined(GL_R16F) +#define GL_R16F 0x822D // same as GL_R16F_EXT #endif -#if !defined( GL_RG16F ) -#define GL_RG16F 0x822F // same as GL_RG16F_EXT +#if !defined(GL_RG16F) +#define GL_RG16F 0x822F // same as GL_RG16F_EXT #endif -#if !defined( GL_RGB16F ) -#define GL_RGB16F 0x881B // same as GL_RGB16F_EXT and GL_RGB16F_ARB +#if !defined(GL_RGB16F) +#define GL_RGB16F 0x881B // same as GL_RGB16F_EXT and GL_RGB16F_ARB #endif -#if !defined( GL_RGBA16F ) -#define GL_RGBA16F 0x881A // sama as GL_RGBA16F_EXT and GL_RGBA16F_ARB +#if !defined(GL_RGBA16F) +#define GL_RGBA16F 0x881A // sama as GL_RGBA16F_EXT and GL_RGBA16F_ARB #endif // // 32 bits per component // -#if !defined( GL_R32UI ) -#define GL_R32UI 0x8236 +#if !defined(GL_R32UI) +#define GL_R32UI 0x8236 #endif -#if !defined( GL_RG32UI ) -#define GL_RG32UI 0x823C +#if !defined(GL_RG32UI) +#define GL_RG32UI 0x823C #endif -#if !defined( GL_RGB32UI ) -#define GL_RGB32UI 0x8D71 // same as GL_RGB32UI_EXT +#if !defined(GL_RGB32UI) +#define GL_RGB32UI 0x8D71 // same as GL_RGB32UI_EXT #endif -#if !defined( GL_RGBA32UI ) -#define GL_RGBA32UI 0x8D70 // same as GL_RGBA32UI_EXT +#if !defined(GL_RGBA32UI) +#define GL_RGBA32UI 0x8D70 // same as GL_RGBA32UI_EXT #endif -#if !defined( GL_R32I ) -#define GL_R32I 0x8235 +#if !defined(GL_R32I) +#define GL_R32I 0x8235 #endif -#if !defined( GL_RG32I ) -#define GL_RG32I 0x823B +#if !defined(GL_RG32I) +#define GL_RG32I 0x823B #endif -#if !defined( GL_RGB32I ) -#define GL_RGB32I 0x8D83 // same as GL_RGB32I_EXT +#if !defined(GL_RGB32I) +#define GL_RGB32I 0x8D83 // same as GL_RGB32I_EXT #endif -#if !defined( GL_RGBA32I ) -#define GL_RGBA32I 0x8D82 // same as GL_RGBA32I_EXT +#if !defined(GL_RGBA32I) +#define GL_RGBA32I 0x8D82 // same as GL_RGBA32I_EXT #endif -#if !defined( GL_R32F ) -#define GL_R32F 0x822E // same as GL_R32F_EXT +#if !defined(GL_R32F) +#define GL_R32F 0x822E // same as GL_R32F_EXT #endif -#if !defined( GL_RG32F ) -#define GL_RG32F 0x8230 // same as GL_RG32F_EXT +#if !defined(GL_RG32F) +#define GL_RG32F 0x8230 // same as GL_RG32F_EXT #endif -#if !defined( GL_RGB32F ) -#define GL_RGB32F 0x8815 // same as GL_RGB32F_EXT and GL_RGB32F_ARB +#if !defined(GL_RGB32F) +#define GL_RGB32F 0x8815 // same as GL_RGB32F_EXT and GL_RGB32F_ARB #endif -#if !defined( GL_RGBA32F ) -#define GL_RGBA32F 0x8814 // same as GL_RGBA32F_EXT and GL_RGBA32F_ARB +#if !defined(GL_RGBA32F) +#define GL_RGBA32F 0x8814 // same as GL_RGBA32F_EXT and GL_RGBA32F_ARB #endif // // Packed // -#if !defined( GL_R3_G3_B2 ) -#define GL_R3_G3_B2 0x2A10 +#if !defined(GL_R3_G3_B2) +#define GL_R3_G3_B2 0x2A10 #endif -#if !defined( GL_RGB4 ) -#define GL_RGB4 0x804F // same as GL_RGB4_EXT +#if !defined(GL_RGB4) +#define GL_RGB4 0x804F // same as GL_RGB4_EXT #endif -#if !defined( GL_RGB5 ) -#define GL_RGB5 0x8050 // same as GL_RGB5_EXT +#if !defined(GL_RGB5) +#define GL_RGB5 0x8050 // same as GL_RGB5_EXT #endif -#if !defined( GL_RGB565 ) -#define GL_RGB565 0x8D62 // same as GL_RGB565_EXT and GL_RGB565_OES +#if !defined(GL_RGB565) +#define GL_RGB565 0x8D62 // same as GL_RGB565_EXT and GL_RGB565_OES #endif -#if !defined( GL_RGB10 ) -#define GL_RGB10 0x8052 // same as GL_RGB10_EXT +#if !defined(GL_RGB10) +#define GL_RGB10 0x8052 // same as GL_RGB10_EXT #endif -#if !defined( GL_RGB12 ) -#define GL_RGB12 0x8053 // same as GL_RGB12_EXT +#if !defined(GL_RGB12) +#define GL_RGB12 0x8053 // same as GL_RGB12_EXT #endif -#if !defined( GL_RGBA2 ) -#define GL_RGBA2 0x8055 // same as GL_RGBA2_EXT +#if !defined(GL_RGBA2) +#define GL_RGBA2 0x8055 // same as GL_RGBA2_EXT #endif -#if !defined( GL_RGBA4 ) -#define GL_RGBA4 0x8056 // same as GL_RGBA4_EXT and GL_RGBA4_OES +#if !defined(GL_RGBA4) +#define GL_RGBA4 0x8056 // same as GL_RGBA4_EXT and GL_RGBA4_OES #endif -#if !defined( GL_RGBA12 ) -#define GL_RGBA12 0x805A // same as GL_RGBA12_EXT +#if !defined(GL_RGBA12) +#define GL_RGBA12 0x805A // same as GL_RGBA12_EXT #endif -#if !defined( GL_RGB5_A1 ) -#define GL_RGB5_A1 0x8057 // same as GL_RGB5_A1_EXT and GL_RGB5_A1_OES +#if !defined(GL_RGB5_A1) +#define GL_RGB5_A1 0x8057 // same as GL_RGB5_A1_EXT and GL_RGB5_A1_OES #endif -#if !defined( GL_RGB10_A2 ) -#define GL_RGB10_A2 0x8059 // same as GL_RGB10_A2_EXT +#if !defined(GL_RGB10_A2) +#define GL_RGB10_A2 0x8059 // same as GL_RGB10_A2_EXT #endif -#if !defined( GL_RGB10_A2UI ) -#define GL_RGB10_A2UI 0x906F +#if !defined(GL_RGB10_A2UI) +#define GL_RGB10_A2UI 0x906F #endif -#if !defined( GL_R11F_G11F_B10F ) -#define GL_R11F_G11F_B10F 0x8C3A // same as GL_R11F_G11F_B10F_APPLE and GL_R11F_G11F_B10F_EXT +#if !defined(GL_R11F_G11F_B10F) +#define GL_R11F_G11F_B10F 0x8C3A // same as GL_R11F_G11F_B10F_APPLE and GL_R11F_G11F_B10F_EXT #endif -#if !defined( GL_RGB9_E5 ) -#define GL_RGB9_E5 0x8C3D // same as GL_RGB9_E5_APPLE and GL_RGB9_E5_EXT +#if !defined(GL_RGB9_E5) +#define GL_RGB9_E5 0x8C3D // same as GL_RGB9_E5_APPLE and GL_RGB9_E5_EXT #endif // // Alpha // -#if !defined( GL_ALPHA4 ) -#define GL_ALPHA4 0x803B // deprecated, same as GL_ALPHA4_EXT +#if !defined(GL_ALPHA4) +#define GL_ALPHA4 0x803B // deprecated, same as GL_ALPHA4_EXT #endif -#if !defined( GL_ALPHA8 ) -#define GL_ALPHA8 0x803C // deprecated, same as GL_ALPHA8_EXT +#if !defined(GL_ALPHA8) +#define GL_ALPHA8 0x803C // deprecated, same as GL_ALPHA8_EXT #endif -#if !defined( GL_ALPHA8_SNORM ) -#define GL_ALPHA8_SNORM 0x9014 // deprecated +#if !defined(GL_ALPHA8_SNORM) +#define GL_ALPHA8_SNORM 0x9014 // deprecated #endif -#if !defined( GL_ALPHA8UI_EXT ) -#define GL_ALPHA8UI_EXT 0x8D7E // deprecated +#if !defined(GL_ALPHA8UI_EXT) +#define GL_ALPHA8UI_EXT 0x8D7E // deprecated #endif -#if !defined( GL_ALPHA8I_EXT ) -#define GL_ALPHA8I_EXT 0x8D90 // deprecated +#if !defined(GL_ALPHA8I_EXT) +#define GL_ALPHA8I_EXT 0x8D90 // deprecated #endif -#if !defined( GL_ALPHA12 ) -#define GL_ALPHA12 0x803D // deprecated, same as GL_ALPHA12_EXT +#if !defined(GL_ALPHA12) +#define GL_ALPHA12 0x803D // deprecated, same as GL_ALPHA12_EXT #endif -#if !defined( GL_ALPHA16 ) -#define GL_ALPHA16 0x803E // deprecated, same as GL_ALPHA16_EXT +#if !defined(GL_ALPHA16) +#define GL_ALPHA16 0x803E // deprecated, same as GL_ALPHA16_EXT #endif -#if !defined( GL_ALPHA16_SNORM ) -#define GL_ALPHA16_SNORM 0x9018 // deprecated +#if !defined(GL_ALPHA16_SNORM) +#define GL_ALPHA16_SNORM 0x9018 // deprecated #endif -#if !defined( GL_ALPHA16UI_EXT ) -#define GL_ALPHA16UI_EXT 0x8D78 // deprecated +#if !defined(GL_ALPHA16UI_EXT) +#define GL_ALPHA16UI_EXT 0x8D78 // deprecated #endif -#if !defined( GL_ALPHA16I_EXT ) -#define GL_ALPHA16I_EXT 0x8D8A // deprecated +#if !defined(GL_ALPHA16I_EXT) +#define GL_ALPHA16I_EXT 0x8D8A // deprecated #endif -#if !defined( GL_ALPHA16F_ARB ) -#define GL_ALPHA16F_ARB 0x881C // deprecated, same as GL_ALPHA_FLOAT16_APPLE and GL_ALPHA_FLOAT16_ATI +#if !defined(GL_ALPHA16F_ARB) +#define GL_ALPHA16F_ARB 0x881C // deprecated, same as GL_ALPHA_FLOAT16_APPLE and GL_ALPHA_FLOAT16_ATI #endif -#if !defined( GL_ALPHA32UI_EXT ) -#define GL_ALPHA32UI_EXT 0x8D72 // deprecated +#if !defined(GL_ALPHA32UI_EXT) +#define GL_ALPHA32UI_EXT 0x8D72 // deprecated #endif -#if !defined( GL_ALPHA32I_EXT ) -#define GL_ALPHA32I_EXT 0x8D84 // deprecated +#if !defined(GL_ALPHA32I_EXT) +#define GL_ALPHA32I_EXT 0x8D84 // deprecated #endif -#if !defined( GL_ALPHA32F_ARB ) -#define GL_ALPHA32F_ARB 0x8816 // deprecated, same as GL_ALPHA_FLOAT32_APPLE and GL_ALPHA_FLOAT32_ATI +#if !defined(GL_ALPHA32F_ARB) +#define GL_ALPHA32F_ARB 0x8816 // deprecated, same as GL_ALPHA_FLOAT32_APPLE and GL_ALPHA_FLOAT32_ATI #endif // // Luminance // -#if !defined( GL_LUMINANCE4 ) -#define GL_LUMINANCE4 0x803F // deprecated, same as GL_LUMINANCE4_EXT +#if !defined(GL_LUMINANCE4) +#define GL_LUMINANCE4 0x803F // deprecated, same as GL_LUMINANCE4_EXT #endif -#if !defined( GL_LUMINANCE8 ) -#define GL_LUMINANCE8 0x8040 // deprecated, same as GL_LUMINANCE8_EXT +#if !defined(GL_LUMINANCE8) +#define GL_LUMINANCE8 0x8040 // deprecated, same as GL_LUMINANCE8_EXT #endif -#if !defined( GL_LUMINANCE8_SNORM ) -#define GL_LUMINANCE8_SNORM 0x9015 // deprecated +#if !defined(GL_LUMINANCE8_SNORM) +#define GL_LUMINANCE8_SNORM 0x9015 // deprecated #endif -#if !defined( GL_SLUMINANCE8 ) -#define GL_SLUMINANCE8 0x8C47 // deprecated, same as GL_SLUMINANCE8_EXT +#if !defined(GL_SLUMINANCE8) +#define GL_SLUMINANCE8 0x8C47 // deprecated, same as GL_SLUMINANCE8_EXT #endif -#if !defined( GL_LUMINANCE8UI_EXT ) -#define GL_LUMINANCE8UI_EXT 0x8D80 // deprecated +#if !defined(GL_LUMINANCE8UI_EXT) +#define GL_LUMINANCE8UI_EXT 0x8D80 // deprecated #endif -#if !defined( GL_LUMINANCE8I_EXT ) -#define GL_LUMINANCE8I_EXT 0x8D92 // deprecated +#if !defined(GL_LUMINANCE8I_EXT) +#define GL_LUMINANCE8I_EXT 0x8D92 // deprecated #endif -#if !defined( GL_LUMINANCE12 ) -#define GL_LUMINANCE12 0x8041 // deprecated, same as GL_LUMINANCE12_EXT +#if !defined(GL_LUMINANCE12) +#define GL_LUMINANCE12 0x8041 // deprecated, same as GL_LUMINANCE12_EXT #endif -#if !defined( GL_LUMINANCE16 ) -#define GL_LUMINANCE16 0x8042 // deprecated, same as GL_LUMINANCE16_EXT +#if !defined(GL_LUMINANCE16) +#define GL_LUMINANCE16 0x8042 // deprecated, same as GL_LUMINANCE16_EXT #endif -#if !defined( GL_LUMINANCE16_SNORM ) -#define GL_LUMINANCE16_SNORM 0x9019 // deprecated +#if !defined(GL_LUMINANCE16_SNORM) +#define GL_LUMINANCE16_SNORM 0x9019 // deprecated #endif -#if !defined( GL_LUMINANCE16UI_EXT ) -#define GL_LUMINANCE16UI_EXT 0x8D7A // deprecated +#if !defined(GL_LUMINANCE16UI_EXT) +#define GL_LUMINANCE16UI_EXT 0x8D7A // deprecated #endif -#if !defined( GL_LUMINANCE16I_EXT ) -#define GL_LUMINANCE16I_EXT 0x8D8C // deprecated +#if !defined(GL_LUMINANCE16I_EXT) +#define GL_LUMINANCE16I_EXT 0x8D8C // deprecated #endif -#if !defined( GL_LUMINANCE16F_ARB ) -#define GL_LUMINANCE16F_ARB 0x881E // deprecated, same as GL_LUMINANCE_FLOAT16_APPLE and GL_LUMINANCE_FLOAT16_ATI +#if !defined(GL_LUMINANCE16F_ARB) +#define GL_LUMINANCE16F_ARB 0x881E // deprecated, same as GL_LUMINANCE_FLOAT16_APPLE and GL_LUMINANCE_FLOAT16_ATI #endif -#if !defined( GL_LUMINANCE32UI_EXT ) -#define GL_LUMINANCE32UI_EXT 0x8D74 // deprecated +#if !defined(GL_LUMINANCE32UI_EXT) +#define GL_LUMINANCE32UI_EXT 0x8D74 // deprecated #endif -#if !defined( GL_LUMINANCE32I_EXT ) -#define GL_LUMINANCE32I_EXT 0x8D86 // deprecated +#if !defined(GL_LUMINANCE32I_EXT) +#define GL_LUMINANCE32I_EXT 0x8D86 // deprecated #endif -#if !defined( GL_LUMINANCE32F_ARB ) -#define GL_LUMINANCE32F_ARB 0x8818 // deprecated, same as GL_LUMINANCE_FLOAT32_APPLE and GL_LUMINANCE_FLOAT32_ATI +#if !defined(GL_LUMINANCE32F_ARB) +#define GL_LUMINANCE32F_ARB 0x8818 // deprecated, same as GL_LUMINANCE_FLOAT32_APPLE and GL_LUMINANCE_FLOAT32_ATI #endif // // Luminance/Alpha // -#if !defined( GL_LUMINANCE4_ALPHA4 ) -#define GL_LUMINANCE4_ALPHA4 0x8043 // deprecated, same as GL_LUMINANCE4_ALPHA4_EXT +#if !defined(GL_LUMINANCE4_ALPHA4) +#define GL_LUMINANCE4_ALPHA4 0x8043 // deprecated, same as GL_LUMINANCE4_ALPHA4_EXT #endif -#if !defined( GL_LUMINANCE6_ALPHA2 ) -#define GL_LUMINANCE6_ALPHA2 0x8044 // deprecated, same as GL_LUMINANCE6_ALPHA2_EXT +#if !defined(GL_LUMINANCE6_ALPHA2) +#define GL_LUMINANCE6_ALPHA2 0x8044 // deprecated, same as GL_LUMINANCE6_ALPHA2_EXT #endif -#if !defined( GL_LUMINANCE8_ALPHA8 ) -#define GL_LUMINANCE8_ALPHA8 0x8045 // deprecated, same as GL_LUMINANCE8_ALPHA8_EXT +#if !defined(GL_LUMINANCE8_ALPHA8) +#define GL_LUMINANCE8_ALPHA8 0x8045 // deprecated, same as GL_LUMINANCE8_ALPHA8_EXT #endif -#if !defined( GL_LUMINANCE8_ALPHA8_SNORM ) -#define GL_LUMINANCE8_ALPHA8_SNORM 0x9016 // deprecated +#if !defined(GL_LUMINANCE8_ALPHA8_SNORM) +#define GL_LUMINANCE8_ALPHA8_SNORM 0x9016 // deprecated #endif -#if !defined( GL_SLUMINANCE8_ALPHA8 ) -#define GL_SLUMINANCE8_ALPHA8 0x8C45 // deprecated, same as GL_SLUMINANCE8_ALPHA8_EXT +#if !defined(GL_SLUMINANCE8_ALPHA8) +#define GL_SLUMINANCE8_ALPHA8 0x8C45 // deprecated, same as GL_SLUMINANCE8_ALPHA8_EXT #endif -#if !defined( GL_LUMINANCE_ALPHA8UI_EXT ) -#define GL_LUMINANCE_ALPHA8UI_EXT 0x8D81 // deprecated +#if !defined(GL_LUMINANCE_ALPHA8UI_EXT) +#define GL_LUMINANCE_ALPHA8UI_EXT 0x8D81 // deprecated #endif -#if !defined( GL_LUMINANCE_ALPHA8I_EXT ) -#define GL_LUMINANCE_ALPHA8I_EXT 0x8D93 // deprecated +#if !defined(GL_LUMINANCE_ALPHA8I_EXT) +#define GL_LUMINANCE_ALPHA8I_EXT 0x8D93 // deprecated #endif -#if !defined( GL_LUMINANCE12_ALPHA4 ) -#define GL_LUMINANCE12_ALPHA4 0x8046 // deprecated, same as GL_LUMINANCE12_ALPHA4_EXT +#if !defined(GL_LUMINANCE12_ALPHA4) +#define GL_LUMINANCE12_ALPHA4 0x8046 // deprecated, same as GL_LUMINANCE12_ALPHA4_EXT #endif -#if !defined( GL_LUMINANCE12_ALPHA12 ) -#define GL_LUMINANCE12_ALPHA12 0x8047 // deprecated, same as GL_LUMINANCE12_ALPHA12_EXT +#if !defined(GL_LUMINANCE12_ALPHA12) +#define GL_LUMINANCE12_ALPHA12 0x8047 // deprecated, same as GL_LUMINANCE12_ALPHA12_EXT #endif -#if !defined( GL_LUMINANCE16_ALPHA16 ) -#define GL_LUMINANCE16_ALPHA16 0x8048 // deprecated, same as GL_LUMINANCE16_ALPHA16_EXT +#if !defined(GL_LUMINANCE16_ALPHA16) +#define GL_LUMINANCE16_ALPHA16 0x8048 // deprecated, same as GL_LUMINANCE16_ALPHA16_EXT #endif -#if !defined( GL_LUMINANCE16_ALPHA16_SNORM ) -#define GL_LUMINANCE16_ALPHA16_SNORM 0x901A // deprecated +#if !defined(GL_LUMINANCE16_ALPHA16_SNORM) +#define GL_LUMINANCE16_ALPHA16_SNORM 0x901A // deprecated #endif -#if !defined( GL_LUMINANCE_ALPHA16UI_EXT ) -#define GL_LUMINANCE_ALPHA16UI_EXT 0x8D7B // deprecated +#if !defined(GL_LUMINANCE_ALPHA16UI_EXT) +#define GL_LUMINANCE_ALPHA16UI_EXT 0x8D7B // deprecated #endif -#if !defined( GL_LUMINANCE_ALPHA16I_EXT ) -#define GL_LUMINANCE_ALPHA16I_EXT 0x8D8D // deprecated +#if !defined(GL_LUMINANCE_ALPHA16I_EXT) +#define GL_LUMINANCE_ALPHA16I_EXT 0x8D8D // deprecated #endif -#if !defined( GL_LUMINANCE_ALPHA16F_ARB ) -#define GL_LUMINANCE_ALPHA16F_ARB 0x881F // deprecated, same as GL_LUMINANCE_ALPHA_FLOAT16_APPLE and GL_LUMINANCE_ALPHA_FLOAT16_ATI +#if !defined(GL_LUMINANCE_ALPHA16F_ARB) +#define GL_LUMINANCE_ALPHA16F_ARB 0x881F // deprecated, same as GL_LUMINANCE_ALPHA_FLOAT16_APPLE and GL_LUMINANCE_ALPHA_FLOAT16_ATI #endif -#if !defined( GL_LUMINANCE_ALPHA32UI_EXT ) -#define GL_LUMINANCE_ALPHA32UI_EXT 0x8D75 // deprecated +#if !defined(GL_LUMINANCE_ALPHA32UI_EXT) +#define GL_LUMINANCE_ALPHA32UI_EXT 0x8D75 // deprecated #endif -#if !defined( GL_LUMINANCE_ALPHA32I_EXT ) -#define GL_LUMINANCE_ALPHA32I_EXT 0x8D87 // deprecated +#if !defined(GL_LUMINANCE_ALPHA32I_EXT) +#define GL_LUMINANCE_ALPHA32I_EXT 0x8D87 // deprecated #endif -#if !defined( GL_LUMINANCE_ALPHA32F_ARB ) -#define GL_LUMINANCE_ALPHA32F_ARB 0x8819 // deprecated, same as GL_LUMINANCE_ALPHA_FLOAT32_APPLE and GL_LUMINANCE_ALPHA_FLOAT32_ATI +#if !defined(GL_LUMINANCE_ALPHA32F_ARB) +#define GL_LUMINANCE_ALPHA32F_ARB 0x8819 // deprecated, same as GL_LUMINANCE_ALPHA_FLOAT32_APPLE and GL_LUMINANCE_ALPHA_FLOAT32_ATI #endif // // Intensity // -#if !defined( GL_INTENSITY4 ) -#define GL_INTENSITY4 0x804A // deprecated, same as GL_INTENSITY4_EXT +#if !defined(GL_INTENSITY4) +#define GL_INTENSITY4 0x804A // deprecated, same as GL_INTENSITY4_EXT #endif -#if !defined( GL_INTENSITY8 ) -#define GL_INTENSITY8 0x804B // deprecated, same as GL_INTENSITY8_EXT +#if !defined(GL_INTENSITY8) +#define GL_INTENSITY8 0x804B // deprecated, same as GL_INTENSITY8_EXT #endif -#if !defined( GL_INTENSITY8_SNORM ) -#define GL_INTENSITY8_SNORM 0x9017 // deprecated +#if !defined(GL_INTENSITY8_SNORM) +#define GL_INTENSITY8_SNORM 0x9017 // deprecated #endif -#if !defined( GL_INTENSITY8UI_EXT ) -#define GL_INTENSITY8UI_EXT 0x8D7F // deprecated +#if !defined(GL_INTENSITY8UI_EXT) +#define GL_INTENSITY8UI_EXT 0x8D7F // deprecated #endif -#if !defined( GL_INTENSITY8I_EXT ) -#define GL_INTENSITY8I_EXT 0x8D91 // deprecated +#if !defined(GL_INTENSITY8I_EXT) +#define GL_INTENSITY8I_EXT 0x8D91 // deprecated #endif -#if !defined( GL_INTENSITY12 ) -#define GL_INTENSITY12 0x804C // deprecated, same as GL_INTENSITY12_EXT +#if !defined(GL_INTENSITY12) +#define GL_INTENSITY12 0x804C // deprecated, same as GL_INTENSITY12_EXT #endif -#if !defined( GL_INTENSITY16 ) -#define GL_INTENSITY16 0x804D // deprecated, same as GL_INTENSITY16_EXT +#if !defined(GL_INTENSITY16) +#define GL_INTENSITY16 0x804D // deprecated, same as GL_INTENSITY16_EXT #endif -#if !defined( GL_INTENSITY16_SNORM ) -#define GL_INTENSITY16_SNORM 0x901B // deprecated +#if !defined(GL_INTENSITY16_SNORM) +#define GL_INTENSITY16_SNORM 0x901B // deprecated #endif -#if !defined( GL_INTENSITY16UI_EXT ) -#define GL_INTENSITY16UI_EXT 0x8D79 // deprecated +#if !defined(GL_INTENSITY16UI_EXT) +#define GL_INTENSITY16UI_EXT 0x8D79 // deprecated #endif -#if !defined( GL_INTENSITY16I_EXT ) -#define GL_INTENSITY16I_EXT 0x8D8B // deprecated +#if !defined(GL_INTENSITY16I_EXT) +#define GL_INTENSITY16I_EXT 0x8D8B // deprecated #endif -#if !defined( GL_INTENSITY16F_ARB ) -#define GL_INTENSITY16F_ARB 0x881D // deprecated, same as GL_INTENSITY_FLOAT16_APPLE and GL_INTENSITY_FLOAT16_ATI +#if !defined(GL_INTENSITY16F_ARB) +#define GL_INTENSITY16F_ARB 0x881D // deprecated, same as GL_INTENSITY_FLOAT16_APPLE and GL_INTENSITY_FLOAT16_ATI #endif -#if !defined( GL_INTENSITY32UI_EXT ) -#define GL_INTENSITY32UI_EXT 0x8D73 // deprecated +#if !defined(GL_INTENSITY32UI_EXT) +#define GL_INTENSITY32UI_EXT 0x8D73 // deprecated #endif -#if !defined( GL_INTENSITY32I_EXT ) -#define GL_INTENSITY32I_EXT 0x8D85 // deprecated +#if !defined(GL_INTENSITY32I_EXT) +#define GL_INTENSITY32I_EXT 0x8D85 // deprecated #endif -#if !defined( GL_INTENSITY32F_ARB ) -#define GL_INTENSITY32F_ARB 0x8817 // deprecated, same as GL_INTENSITY_FLOAT32_APPLE and GL_INTENSITY_FLOAT32_ATI +#if !defined(GL_INTENSITY32F_ARB) +#define GL_INTENSITY32F_ARB 0x8817 // deprecated, same as GL_INTENSITY_FLOAT32_APPLE and GL_INTENSITY_FLOAT32_ATI #endif // // Generic compression // -#if !defined( GL_COMPRESSED_RED ) -#define GL_COMPRESSED_RED 0x8225 +#if !defined(GL_COMPRESSED_RED) +#define GL_COMPRESSED_RED 0x8225 #endif -#if !defined( GL_COMPRESSED_ALPHA ) -#define GL_COMPRESSED_ALPHA 0x84E9 // deprecated, same as GL_COMPRESSED_ALPHA_ARB +#if !defined(GL_COMPRESSED_ALPHA) +#define GL_COMPRESSED_ALPHA 0x84E9 // deprecated, same as GL_COMPRESSED_ALPHA_ARB #endif -#if !defined( GL_COMPRESSED_LUMINANCE ) -#define GL_COMPRESSED_LUMINANCE 0x84EA // deprecated, same as GL_COMPRESSED_LUMINANCE_ARB +#if !defined(GL_COMPRESSED_LUMINANCE) +#define GL_COMPRESSED_LUMINANCE 0x84EA // deprecated, same as GL_COMPRESSED_LUMINANCE_ARB #endif -#if !defined( GL_COMPRESSED_SLUMINANCE ) -#define GL_COMPRESSED_SLUMINANCE 0x8C4A // deprecated, same as GL_COMPRESSED_SLUMINANCE_EXT +#if !defined(GL_COMPRESSED_SLUMINANCE) +#define GL_COMPRESSED_SLUMINANCE 0x8C4A // deprecated, same as GL_COMPRESSED_SLUMINANCE_EXT #endif -#if !defined( GL_COMPRESSED_LUMINANCE_ALPHA ) -#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB // deprecated, same as GL_COMPRESSED_LUMINANCE_ALPHA_ARB +#if !defined(GL_COMPRESSED_LUMINANCE_ALPHA) +#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB // deprecated, same as GL_COMPRESSED_LUMINANCE_ALPHA_ARB #endif -#if !defined( GL_COMPRESSED_SLUMINANCE_ALPHA ) -#define GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B // deprecated, same as GL_COMPRESSED_SLUMINANCE_ALPHA_EXT +#if !defined(GL_COMPRESSED_SLUMINANCE_ALPHA) +#define GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B // deprecated, same as GL_COMPRESSED_SLUMINANCE_ALPHA_EXT #endif -#if !defined( GL_COMPRESSED_INTENSITY ) -#define GL_COMPRESSED_INTENSITY 0x84EC // deprecated, same as GL_COMPRESSED_INTENSITY_ARB +#if !defined(GL_COMPRESSED_INTENSITY) +#define GL_COMPRESSED_INTENSITY 0x84EC // deprecated, same as GL_COMPRESSED_INTENSITY_ARB #endif -#if !defined( GL_COMPRESSED_RG ) -#define GL_COMPRESSED_RG 0x8226 +#if !defined(GL_COMPRESSED_RG) +#define GL_COMPRESSED_RG 0x8226 #endif -#if !defined( GL_COMPRESSED_RGB ) -#define GL_COMPRESSED_RGB 0x84ED // same as GL_COMPRESSED_RGB_ARB +#if !defined(GL_COMPRESSED_RGB) +#define GL_COMPRESSED_RGB 0x84ED // same as GL_COMPRESSED_RGB_ARB #endif -#if !defined( GL_COMPRESSED_RGBA ) -#define GL_COMPRESSED_RGBA 0x84EE // same as GL_COMPRESSED_RGBA_ARB +#if !defined(GL_COMPRESSED_RGBA) +#define GL_COMPRESSED_RGBA 0x84EE // same as GL_COMPRESSED_RGBA_ARB #endif -#if !defined( GL_COMPRESSED_SRGB ) -#define GL_COMPRESSED_SRGB 0x8C48 // same as GL_COMPRESSED_SRGB_EXT +#if !defined(GL_COMPRESSED_SRGB) +#define GL_COMPRESSED_SRGB 0x8C48 // same as GL_COMPRESSED_SRGB_EXT #endif -#if !defined( GL_COMPRESSED_SRGB_ALPHA ) -#define GL_COMPRESSED_SRGB_ALPHA 0x8C49 // same as GL_COMPRESSED_SRGB_ALPHA_EXT +#if !defined(GL_COMPRESSED_SRGB_ALPHA) +#define GL_COMPRESSED_SRGB_ALPHA 0x8C49 // same as GL_COMPRESSED_SRGB_ALPHA_EXT #endif // // FXT1 // -#if !defined( GL_COMPRESSED_RGB_FXT1_3DFX ) -#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 // deprecated +#if !defined(GL_COMPRESSED_RGB_FXT1_3DFX) +#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 // deprecated #endif -#if !defined( GL_COMPRESSED_RGBA_FXT1_3DFX ) -#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 // deprecated +#if !defined(GL_COMPRESSED_RGBA_FXT1_3DFX) +#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 // deprecated #endif // // S3TC/DXT/BC // -#if !defined( GL_COMPRESSED_RGB_S3TC_DXT1_EXT ) -#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 +#if !defined(GL_COMPRESSED_RGB_S3TC_DXT1_EXT) +#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 #endif -#if !defined( GL_COMPRESSED_RGBA_S3TC_DXT1_EXT ) -#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 +#if !defined(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT) +#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 #endif -#if !defined( GL_COMPRESSED_RGBA_S3TC_DXT3_EXT ) -#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 +#if !defined(GL_COMPRESSED_RGBA_S3TC_DXT3_EXT) +#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 #endif -#if !defined( GL_COMPRESSED_RGBA_S3TC_DXT5_EXT ) -#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 +#if !defined(GL_COMPRESSED_RGBA_S3TC_DXT5_EXT) +#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 #endif -#if !defined( GL_COMPRESSED_SRGB_S3TC_DXT1_EXT ) -#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C +#if !defined(GL_COMPRESSED_SRGB_S3TC_DXT1_EXT) +#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C #endif -#if !defined( GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT ) -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D +#if !defined(GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT) +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D #endif -#if !defined( GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT ) -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E +#if !defined(GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT) +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E #endif -#if !defined( GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT ) -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F +#if !defined(GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT) +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F #endif -#if !defined( GL_COMPRESSED_LUMINANCE_LATC1_EXT ) -#define GL_COMPRESSED_LUMINANCE_LATC1_EXT 0x8C70 +#if !defined(GL_COMPRESSED_LUMINANCE_LATC1_EXT) +#define GL_COMPRESSED_LUMINANCE_LATC1_EXT 0x8C70 #endif -#if !defined( GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT ) -#define GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT 0x8C72 +#if !defined(GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT) +#define GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT 0x8C72 #endif -#if !defined( GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT ) -#define GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT 0x8C71 +#if !defined(GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT) +#define GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT 0x8C71 #endif -#if !defined( GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT ) -#define GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT 0x8C73 +#if !defined(GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT) +#define GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT 0x8C73 #endif -#if !defined( GL_COMPRESSED_RED_RGTC1 ) -#define GL_COMPRESSED_RED_RGTC1 0x8DBB // same as GL_COMPRESSED_RED_RGTC1_EXT +#if !defined(GL_COMPRESSED_RED_RGTC1) +#define GL_COMPRESSED_RED_RGTC1 0x8DBB // same as GL_COMPRESSED_RED_RGTC1_EXT #endif -#if !defined( GL_COMPRESSED_RG_RGTC2 ) -#define GL_COMPRESSED_RG_RGTC2 0x8DBD // same as GL_COMPRESSED_RG_RGTC2_EXT +#if !defined(GL_COMPRESSED_RG_RGTC2) +#define GL_COMPRESSED_RG_RGTC2 0x8DBD // same as GL_COMPRESSED_RG_RGTC2_EXT #endif -#if !defined( GL_COMPRESSED_SIGNED_RED_RGTC1 ) -#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC // same as GL_COMPRESSED_SIGNED_RED_RGTC1_EXT +#if !defined(GL_COMPRESSED_SIGNED_RED_RGTC1) +#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC // same as GL_COMPRESSED_SIGNED_RED_RGTC1_EXT #endif -#if !defined( GL_COMPRESSED_SIGNED_RG_RGTC2 ) -#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE // same as GL_COMPRESSED_SIGNED_RG_RGTC2_EXT +#if !defined(GL_COMPRESSED_SIGNED_RG_RGTC2) +#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE // same as GL_COMPRESSED_SIGNED_RG_RGTC2_EXT #endif -#if !defined( GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT ) -#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT 0x8E8E // same as GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB +#if !defined(GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT) +#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT 0x8E8E // same as GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB #endif -#if !defined( GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT ) -#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT 0x8E8F // same as GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB +#if !defined(GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT) +#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT 0x8E8F // same as GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB #endif -#if !defined( GL_COMPRESSED_RGBA_BPTC_UNORM ) -#define GL_COMPRESSED_RGBA_BPTC_UNORM 0x8E8C // same as GL_COMPRESSED_RGBA_BPTC_UNORM_ARB +#if !defined(GL_COMPRESSED_RGBA_BPTC_UNORM) +#define GL_COMPRESSED_RGBA_BPTC_UNORM 0x8E8C // same as GL_COMPRESSED_RGBA_BPTC_UNORM_ARB #endif -#if !defined( GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM ) -#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM 0x8E8D // same as GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB +#if !defined(GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM) +#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM 0x8E8D // same as GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB #endif // // ETC // -#if !defined( GL_ETC1_RGB8_OES ) -#define GL_ETC1_RGB8_OES 0x8D64 +#if !defined(GL_ETC1_RGB8_OES) +#define GL_ETC1_RGB8_OES 0x8D64 #endif -#if !defined( GL_COMPRESSED_RGB8_ETC2 ) -#define GL_COMPRESSED_RGB8_ETC2 0x9274 +#if !defined(GL_COMPRESSED_RGB8_ETC2) +#define GL_COMPRESSED_RGB8_ETC2 0x9274 #endif -#if !defined( GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 ) -#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276 +#if !defined(GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2) +#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276 #endif -#if !defined( GL_COMPRESSED_RGBA8_ETC2_EAC ) -#define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278 +#if !defined(GL_COMPRESSED_RGBA8_ETC2_EAC) +#define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278 #endif -#if !defined( GL_COMPRESSED_SRGB8_ETC2 ) -#define GL_COMPRESSED_SRGB8_ETC2 0x9275 +#if !defined(GL_COMPRESSED_SRGB8_ETC2) +#define GL_COMPRESSED_SRGB8_ETC2 0x9275 #endif -#if !defined( GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 ) -#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277 +#if !defined(GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2) +#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277 #endif -#if !defined( GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC ) -#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279 +#if !defined(GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC) +#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279 #endif -#if !defined( GL_COMPRESSED_R11_EAC ) -#define GL_COMPRESSED_R11_EAC 0x9270 +#if !defined(GL_COMPRESSED_R11_EAC) +#define GL_COMPRESSED_R11_EAC 0x9270 #endif -#if !defined( GL_COMPRESSED_RG11_EAC ) -#define GL_COMPRESSED_RG11_EAC 0x9272 +#if !defined(GL_COMPRESSED_RG11_EAC) +#define GL_COMPRESSED_RG11_EAC 0x9272 #endif -#if !defined( GL_COMPRESSED_SIGNED_R11_EAC ) -#define GL_COMPRESSED_SIGNED_R11_EAC 0x9271 +#if !defined(GL_COMPRESSED_SIGNED_R11_EAC) +#define GL_COMPRESSED_SIGNED_R11_EAC 0x9271 #endif -#if !defined( GL_COMPRESSED_SIGNED_RG11_EAC ) -#define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273 +#if !defined(GL_COMPRESSED_SIGNED_RG11_EAC) +#define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273 #endif // // PVRTC // -#if !defined( GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG ) -#define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01 -#define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00 -#define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03 -#define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02 +#if !defined(GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG) +#define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01 +#define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00 +#define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03 +#define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02 #endif -#if !defined( GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG ) -#define GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG 0x9137 -#define GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG 0x9138 +#if !defined(GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG) +#define GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG 0x9137 +#define GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG 0x9138 #endif -#if !defined( GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT ) -#define GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT 0x8A54 -#define GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT 0x8A55 -#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT 0x8A56 -#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT 0x8A57 +#if !defined(GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT) +#define GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT 0x8A54 +#define GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT 0x8A55 +#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT 0x8A56 +#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT 0x8A57 #endif -#if !defined( GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV2_IMG ) -#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV2_IMG 0x93F0 -#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV2_IMG 0x93F1 +#if !defined(GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV2_IMG) +#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV2_IMG 0x93F0 +#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV2_IMG 0x93F1 #endif // // ASTC // -#if !defined( GL_COMPRESSED_RGBA_ASTC_4x4_KHR ) -#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0 -#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1 -#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2 -#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3 -#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4 -#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5 -#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6 -#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7 -#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8 -#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9 -#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA -#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB -#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC -#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD -#endif - -#if !defined( GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR ) -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD -#endif - -#if !defined( GL_COMPRESSED_RGBA_ASTC_3x3x3_OES ) -#define GL_COMPRESSED_RGBA_ASTC_3x3x3_OES 0x93C0 -#define GL_COMPRESSED_RGBA_ASTC_4x3x3_OES 0x93C1 -#define GL_COMPRESSED_RGBA_ASTC_4x4x3_OES 0x93C2 -#define GL_COMPRESSED_RGBA_ASTC_4x4x4_OES 0x93C3 -#define GL_COMPRESSED_RGBA_ASTC_5x4x4_OES 0x93C4 -#define GL_COMPRESSED_RGBA_ASTC_5x5x4_OES 0x93C5 -#define GL_COMPRESSED_RGBA_ASTC_5x5x5_OES 0x93C6 -#define GL_COMPRESSED_RGBA_ASTC_6x5x5_OES 0x93C7 -#define GL_COMPRESSED_RGBA_ASTC_6x6x5_OES 0x93C8 -#define GL_COMPRESSED_RGBA_ASTC_6x6x6_OES 0x93C9 -#endif - -#if !defined( GL_COMPRESSED_SRGB8_ALPHA8_ASTC_3x3x3_OES ) -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_3x3x3_OES 0x93E0 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x3x3_OES 0x93E1 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x3_OES 0x93E2 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x4_OES 0x93E3 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4x4_OES 0x93E4 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x4_OES 0x93E5 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x5_OES 0x93E6 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5x5_OES 0x93E7 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x5_OES 0x93E8 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x6_OES 0x93E9 +#if !defined(GL_COMPRESSED_RGBA_ASTC_4x4_KHR) +#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0 +#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1 +#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2 +#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3 +#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4 +#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5 +#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6 +#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7 +#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8 +#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9 +#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA +#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB +#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC +#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD +#endif + +#if !defined(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR) +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD +#endif + +#if !defined(GL_COMPRESSED_RGBA_ASTC_3x3x3_OES) +#define GL_COMPRESSED_RGBA_ASTC_3x3x3_OES 0x93C0 +#define GL_COMPRESSED_RGBA_ASTC_4x3x3_OES 0x93C1 +#define GL_COMPRESSED_RGBA_ASTC_4x4x3_OES 0x93C2 +#define GL_COMPRESSED_RGBA_ASTC_4x4x4_OES 0x93C3 +#define GL_COMPRESSED_RGBA_ASTC_5x4x4_OES 0x93C4 +#define GL_COMPRESSED_RGBA_ASTC_5x5x4_OES 0x93C5 +#define GL_COMPRESSED_RGBA_ASTC_5x5x5_OES 0x93C6 +#define GL_COMPRESSED_RGBA_ASTC_6x5x5_OES 0x93C7 +#define GL_COMPRESSED_RGBA_ASTC_6x6x5_OES 0x93C8 +#define GL_COMPRESSED_RGBA_ASTC_6x6x6_OES 0x93C9 +#endif + +#if !defined(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_3x3x3_OES) +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_3x3x3_OES 0x93E0 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x3x3_OES 0x93E1 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x3_OES 0x93E2 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x4_OES 0x93E3 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4x4_OES 0x93E4 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x4_OES 0x93E5 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x5_OES 0x93E6 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5x5_OES 0x93E7 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x5_OES 0x93E8 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x6_OES 0x93E9 #endif // // ATC // -#if !defined( GL_ATC_RGB_AMD ) -#define GL_ATC_RGB_AMD 0x8C92 -#define GL_ATC_RGBA_EXPLICIT_ALPHA_AMD 0x8C93 -#define GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD 0x87EE +#if !defined(GL_ATC_RGB_AMD) +#define GL_ATC_RGB_AMD 0x8C92 +#define GL_ATC_RGBA_EXPLICIT_ALPHA_AMD 0x8C93 +#define GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD 0x87EE #endif // // Palletized (combined palette) // -#if !defined( GL_PALETTE4_RGB8_OES ) -#define GL_PALETTE4_RGB8_OES 0x8B90 -#define GL_PALETTE4_RGBA8_OES 0x8B91 -#define GL_PALETTE4_R5_G6_B5_OES 0x8B92 -#define GL_PALETTE4_RGBA4_OES 0x8B93 -#define GL_PALETTE4_RGB5_A1_OES 0x8B94 -#define GL_PALETTE8_RGB8_OES 0x8B95 -#define GL_PALETTE8_RGBA8_OES 0x8B96 -#define GL_PALETTE8_R5_G6_B5_OES 0x8B97 -#define GL_PALETTE8_RGBA4_OES 0x8B98 -#define GL_PALETTE8_RGB5_A1_OES 0x8B99 +#if !defined(GL_PALETTE4_RGB8_OES) +#define GL_PALETTE4_RGB8_OES 0x8B90 +#define GL_PALETTE4_RGBA8_OES 0x8B91 +#define GL_PALETTE4_R5_G6_B5_OES 0x8B92 +#define GL_PALETTE4_RGBA4_OES 0x8B93 +#define GL_PALETTE4_RGB5_A1_OES 0x8B94 +#define GL_PALETTE8_RGB8_OES 0x8B95 +#define GL_PALETTE8_RGBA8_OES 0x8B96 +#define GL_PALETTE8_R5_G6_B5_OES 0x8B97 +#define GL_PALETTE8_RGBA4_OES 0x8B98 +#define GL_PALETTE8_RGB5_A1_OES 0x8B99 #endif // // Palletized (separate palette) // -#if !defined( GL_COLOR_INDEX1_EXT ) -#define GL_COLOR_INDEX1_EXT 0x80E2 // deprecated -#define GL_COLOR_INDEX2_EXT 0x80E3 // deprecated -#define GL_COLOR_INDEX4_EXT 0x80E4 // deprecated -#define GL_COLOR_INDEX8_EXT 0x80E5 // deprecated -#define GL_COLOR_INDEX12_EXT 0x80E6 // deprecated -#define GL_COLOR_INDEX16_EXT 0x80E7 // deprecated +#if !defined(GL_COLOR_INDEX1_EXT) +#define GL_COLOR_INDEX1_EXT 0x80E2 // deprecated +#define GL_COLOR_INDEX2_EXT 0x80E3 // deprecated +#define GL_COLOR_INDEX4_EXT 0x80E4 // deprecated +#define GL_COLOR_INDEX8_EXT 0x80E5 // deprecated +#define GL_COLOR_INDEX12_EXT 0x80E6 // deprecated +#define GL_COLOR_INDEX16_EXT 0x80E7 // deprecated #endif // // Depth/stencil // -#if !defined( GL_DEPTH_COMPONENT16 ) -#define GL_DEPTH_COMPONENT16 0x81A5 // same as GL_DEPTH_COMPONENT16_SGIX and GL_DEPTH_COMPONENT16_ARB -#endif -#if !defined( GL_DEPTH_COMPONENT24 ) -#define GL_DEPTH_COMPONENT24 0x81A6 // same as GL_DEPTH_COMPONENT24_SGIX and GL_DEPTH_COMPONENT24_ARB -#endif -#if !defined( GL_DEPTH_COMPONENT32 ) -#define GL_DEPTH_COMPONENT32 0x81A7 // same as GL_DEPTH_COMPONENT32_SGIX and GL_DEPTH_COMPONENT32_ARB and GL_DEPTH_COMPONENT32_OES -#endif -#if !defined( GL_DEPTH_COMPONENT32F ) -#define GL_DEPTH_COMPONENT32F 0x8CAC // same as GL_DEPTH_COMPONENT32F_ARB -#endif -#if !defined( GL_DEPTH_COMPONENT32F_NV ) -#define GL_DEPTH_COMPONENT32F_NV 0x8DAB // note that this is different from GL_DEPTH_COMPONENT32F -#endif -#if !defined( GL_STENCIL_INDEX1 ) -#define GL_STENCIL_INDEX1 0x8D46 // same as GL_STENCIL_INDEX1_EXT -#endif -#if !defined( GL_STENCIL_INDEX4 ) -#define GL_STENCIL_INDEX4 0x8D47 // same as GL_STENCIL_INDEX4_EXT -#endif -#if !defined( GL_STENCIL_INDEX8 ) -#define GL_STENCIL_INDEX8 0x8D48 // same as GL_STENCIL_INDEX8_EXT -#endif -#if !defined( GL_STENCIL_INDEX16 ) -#define GL_STENCIL_INDEX16 0x8D49 // same as GL_STENCIL_INDEX16_EXT -#endif -#if !defined( GL_DEPTH24_STENCIL8 ) -#define GL_DEPTH24_STENCIL8 0x88F0 // same as GL_DEPTH24_STENCIL8_EXT and GL_DEPTH24_STENCIL8_OES -#endif -#if !defined( GL_DEPTH32F_STENCIL8 ) -#define GL_DEPTH32F_STENCIL8 0x8CAD // same as GL_DEPTH32F_STENCIL8_ARB -#endif -#if !defined( GL_DEPTH32F_STENCIL8_NV ) -#define GL_DEPTH32F_STENCIL8_NV 0x8DAC // note that this is different from GL_DEPTH32F_STENCIL8 -#endif - -static inline GLenum glGetFormatFromInternalFormat( const GLenum internalFormat ) -{ - switch ( internalFormat ) - { - // - // 8 bits per component - // - case GL_R8: return GL_RED; // 1-component, 8-bit unsigned normalized - case GL_RG8: return GL_RG; // 2-component, 8-bit unsigned normalized - case GL_RGB8: return GL_RGB; // 3-component, 8-bit unsigned normalized - case GL_RGBA8: return GL_RGBA; // 4-component, 8-bit unsigned normalized - - case GL_R8_SNORM: return GL_RED; // 1-component, 8-bit signed normalized - case GL_RG8_SNORM: return GL_RG; // 2-component, 8-bit signed normalized - case GL_RGB8_SNORM: return GL_RGB; // 3-component, 8-bit signed normalized - case GL_RGBA8_SNORM: return GL_RGBA; // 4-component, 8-bit signed normalized - - case GL_R8UI: return GL_RED; // 1-component, 8-bit unsigned integer - case GL_RG8UI: return GL_RG; // 2-component, 8-bit unsigned integer - case GL_RGB8UI: return GL_RGB; // 3-component, 8-bit unsigned integer - case GL_RGBA8UI: return GL_RGBA; // 4-component, 8-bit unsigned integer - - case GL_R8I: return GL_RED; // 1-component, 8-bit signed integer - case GL_RG8I: return GL_RG; // 2-component, 8-bit signed integer - case GL_RGB8I: return GL_RGB; // 3-component, 8-bit signed integer - case GL_RGBA8I: return GL_RGBA; // 4-component, 8-bit signed integer - - case GL_SR8: return GL_RED; // 1-component, 8-bit sRGB - case GL_SRG8: return GL_RG; // 2-component, 8-bit sRGB - case GL_SRGB8: return GL_RGB; // 3-component, 8-bit sRGB - case GL_SRGB8_ALPHA8: return GL_RGBA; // 4-component, 8-bit sRGB - - // - // 16 bits per component - // - case GL_R16: return GL_RED; // 1-component, 16-bit unsigned normalized - case GL_RG16: return GL_RG; // 2-component, 16-bit unsigned normalized - case GL_RGB16: return GL_RGB; // 3-component, 16-bit unsigned normalized - case GL_RGBA16: return GL_RGBA; // 4-component, 16-bit unsigned normalized - - case GL_R16_SNORM: return GL_RED; // 1-component, 16-bit signed normalized - case GL_RG16_SNORM: return GL_RG; // 2-component, 16-bit signed normalized - case GL_RGB16_SNORM: return GL_RGB; // 3-component, 16-bit signed normalized - case GL_RGBA16_SNORM: return GL_RGBA; // 4-component, 16-bit signed normalized - - case GL_R16UI: return GL_RED; // 1-component, 16-bit unsigned integer - case GL_RG16UI: return GL_RG; // 2-component, 16-bit unsigned integer - case GL_RGB16UI: return GL_RGB; // 3-component, 16-bit unsigned integer - case GL_RGBA16UI: return GL_RGBA; // 4-component, 16-bit unsigned integer - - case GL_R16I: return GL_RED; // 1-component, 16-bit signed integer - case GL_RG16I: return GL_RG; // 2-component, 16-bit signed integer - case GL_RGB16I: return GL_RGB; // 3-component, 16-bit signed integer - case GL_RGBA16I: return GL_RGBA; // 4-component, 16-bit signed integer - - case GL_R16F: return GL_RED; // 1-component, 16-bit floating-point - case GL_RG16F: return GL_RG; // 2-component, 16-bit floating-point - case GL_RGB16F: return GL_RGB; // 3-component, 16-bit floating-point - case GL_RGBA16F: return GL_RGBA; // 4-component, 16-bit floating-point - - // - // 32 bits per component - // - case GL_R32UI: return GL_RED; // 1-component, 32-bit unsigned integer - case GL_RG32UI: return GL_RG; // 2-component, 32-bit unsigned integer - case GL_RGB32UI: return GL_RGB; // 3-component, 32-bit unsigned integer - case GL_RGBA32UI: return GL_RGBA; // 4-component, 32-bit unsigned integer - - case GL_R32I: return GL_RED; // 1-component, 32-bit signed integer - case GL_RG32I: return GL_RG; // 2-component, 32-bit signed integer - case GL_RGB32I: return GL_RGB; // 3-component, 32-bit signed integer - case GL_RGBA32I: return GL_RGBA; // 4-component, 32-bit signed integer - - case GL_R32F: return GL_RED; // 1-component, 32-bit floating-point - case GL_RG32F: return GL_RG; // 2-component, 32-bit floating-point - case GL_RGB32F: return GL_RGB; // 3-component, 32-bit floating-point - case GL_RGBA32F: return GL_RGBA; // 4-component, 32-bit floating-point - - // - // Packed - // - case GL_R3_G3_B2: return GL_RGB; // 3-component 3:3:2, unsigned normalized - case GL_RGB4: return GL_RGB; // 3-component 4:4:4, unsigned normalized - case GL_RGB5: return GL_RGB; // 3-component 5:5:5, unsigned normalized - case GL_RGB565: return GL_RGB; // 3-component 5:6:5, unsigned normalized - case GL_RGB10: return GL_RGB; // 3-component 10:10:10, unsigned normalized - case GL_RGB12: return GL_RGB; // 3-component 12:12:12, unsigned normalized - case GL_RGBA2: return GL_RGBA; // 4-component 2:2:2:2, unsigned normalized - case GL_RGBA4: return GL_RGBA; // 4-component 4:4:4:4, unsigned normalized - case GL_RGBA12: return GL_RGBA; // 4-component 12:12:12:12, unsigned normalized - case GL_RGB5_A1: return GL_RGBA; // 4-component 5:5:5:1, unsigned normalized - case GL_RGB10_A2: return GL_RGBA; // 4-component 10:10:10:2, unsigned normalized - case GL_RGB10_A2UI: return GL_RGBA; // 4-component 10:10:10:2, unsigned integer - case GL_R11F_G11F_B10F: return GL_RGB; // 3-component 11:11:10, floating-point - case GL_RGB9_E5: return GL_RGB; // 3-component/exp 9:9:9/5, floating-point - - // - // S3TC/DXT/BC - // - - case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: return GL_RGB; // line through 3D space, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: return GL_RGBA; // line through 3D space plus 1-bit alpha, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: return GL_RGBA; // line through 3D space plus line through 1D space, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: return GL_RGBA; // line through 3D space plus 4-bit alpha, 4x4 blocks, unsigned normalized - - case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: return GL_RGB; // line through 3D space, 4x4 blocks, sRGB - case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: return GL_RGBA; // line through 3D space plus 1-bit alpha, 4x4 blocks, sRGB - case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: return GL_RGBA; // line through 3D space plus line through 1D space, 4x4 blocks, sRGB - case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: return GL_RGBA; // line through 3D space plus 4-bit alpha, 4x4 blocks, sRGB - - case GL_COMPRESSED_LUMINANCE_LATC1_EXT: return GL_RED; // line through 1D space, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT: return GL_RG; // two lines through 1D space, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT: return GL_RED; // line through 1D space, 4x4 blocks, signed normalized - case GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT: return GL_RG; // two lines through 1D space, 4x4 blocks, signed normalized - - case GL_COMPRESSED_RED_RGTC1: return GL_RED; // line through 1D space, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_RG_RGTC2: return GL_RG; // two lines through 1D space, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_SIGNED_RED_RGTC1: return GL_RED; // line through 1D space, 4x4 blocks, signed normalized - case GL_COMPRESSED_SIGNED_RG_RGTC2: return GL_RG; // two lines through 1D space, 4x4 blocks, signed normalized - - case GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT: return GL_RGB; // 3-component, 4x4 blocks, unsigned floating-point - case GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT: return GL_RGB; // 3-component, 4x4 blocks, signed floating-point - case GL_COMPRESSED_RGBA_BPTC_UNORM: return GL_RGBA; // 4-component, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM: return GL_RGBA; // 4-component, 4x4 blocks, sRGB - - // - // ETC - // - case GL_ETC1_RGB8_OES: return GL_RGB; // 3-component ETC1, 4x4 blocks, unsigned normalized - - case GL_COMPRESSED_RGB8_ETC2: return GL_RGB; // 3-component ETC2, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: return GL_RGBA; // 4-component ETC2 with 1-bit alpha, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_RGBA8_ETC2_EAC: return GL_RGBA; // 4-component ETC2, 4x4 blocks, unsigned normalized - - case GL_COMPRESSED_SRGB8_ETC2: return GL_RGB; // 3-component ETC2, 4x4 blocks, sRGB - case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: return GL_RGBA; // 4-component ETC2 with 1-bit alpha, 4x4 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: return GL_RGBA; // 4-component ETC2, 4x4 blocks, sRGB - - case GL_COMPRESSED_R11_EAC: return GL_RED; // 1-component ETC, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_RG11_EAC: return GL_RG; // 2-component ETC, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_SIGNED_R11_EAC: return GL_RED; // 1-component ETC, 4x4 blocks, signed normalized - case GL_COMPRESSED_SIGNED_RG11_EAC: return GL_RG; // 2-component ETC, 4x4 blocks, signed normalized - - // - // PVRTC - // - case GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG: return GL_RGB; // 3-component PVRTC, 16x8 blocks, unsigned normalized - case GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG: return GL_RGB; // 3-component PVRTC, 8x8 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: return GL_RGBA; // 4-component PVRTC, 16x8 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: return GL_RGBA; // 4-component PVRTC, 8x8 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG: return GL_RGBA; // 4-component PVRTC, 8x4 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG: return GL_RGBA; // 4-component PVRTC, 4x4 blocks, unsigned normalized - - case GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT: return GL_RGB; // 3-component PVRTC, 16x8 blocks, sRGB - case GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT: return GL_RGB; // 3-component PVRTC, 8x8 blocks, sRGB - case GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT: return GL_RGBA; // 4-component PVRTC, 16x8 blocks, sRGB - case GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT: return GL_RGBA; // 4-component PVRTC, 8x8 blocks, sRGB - case GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV2_IMG: return GL_RGBA; // 4-component PVRTC, 8x4 blocks, sRGB - case GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV2_IMG: return GL_RGBA; // 4-component PVRTC, 4x4 blocks, sRGB - - // - // ASTC - // - case GL_COMPRESSED_RGBA_ASTC_4x4_KHR: return GL_RGBA; // 4-component ASTC, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_5x4_KHR: return GL_RGBA; // 4-component ASTC, 5x4 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_5x5_KHR: return GL_RGBA; // 4-component ASTC, 5x5 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_6x5_KHR: return GL_RGBA; // 4-component ASTC, 6x5 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_6x6_KHR: return GL_RGBA; // 4-component ASTC, 6x6 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_8x5_KHR: return GL_RGBA; // 4-component ASTC, 8x5 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_8x6_KHR: return GL_RGBA; // 4-component ASTC, 8x6 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_8x8_KHR: return GL_RGBA; // 4-component ASTC, 8x8 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_10x5_KHR: return GL_RGBA; // 4-component ASTC, 10x5 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_10x6_KHR: return GL_RGBA; // 4-component ASTC, 10x6 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_10x8_KHR: return GL_RGBA; // 4-component ASTC, 10x8 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_10x10_KHR: return GL_RGBA; // 4-component ASTC, 10x10 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_12x10_KHR: return GL_RGBA; // 4-component ASTC, 12x10 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_12x12_KHR: return GL_RGBA; // 4-component ASTC, 12x12 blocks, unsigned normalized - - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR: return GL_RGBA; // 4-component ASTC, 4x4 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR: return GL_RGBA; // 4-component ASTC, 5x4 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR: return GL_RGBA; // 4-component ASTC, 5x5 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR: return GL_RGBA; // 4-component ASTC, 6x5 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR: return GL_RGBA; // 4-component ASTC, 6x6 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR: return GL_RGBA; // 4-component ASTC, 8x5 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR: return GL_RGBA; // 4-component ASTC, 8x6 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR: return GL_RGBA; // 4-component ASTC, 8x8 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR: return GL_RGBA; // 4-component ASTC, 10x5 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR: return GL_RGBA; // 4-component ASTC, 10x6 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR: return GL_RGBA; // 4-component ASTC, 10x8 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR: return GL_RGBA; // 4-component ASTC, 10x10 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR: return GL_RGBA; // 4-component ASTC, 12x10 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR: return GL_RGBA; // 4-component ASTC, 12x12 blocks, sRGB - - case GL_COMPRESSED_RGBA_ASTC_3x3x3_OES: return GL_RGBA; // 4-component ASTC, 3x3x3 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_4x3x3_OES: return GL_RGBA; // 4-component ASTC, 4x3x3 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_4x4x3_OES: return GL_RGBA; // 4-component ASTC, 4x4x3 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_4x4x4_OES: return GL_RGBA; // 4-component ASTC, 4x4x4 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_5x4x4_OES: return GL_RGBA; // 4-component ASTC, 5x4x4 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_5x5x4_OES: return GL_RGBA; // 4-component ASTC, 5x5x4 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_5x5x5_OES: return GL_RGBA; // 4-component ASTC, 5x5x5 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_6x5x5_OES: return GL_RGBA; // 4-component ASTC, 6x5x5 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_6x6x5_OES: return GL_RGBA; // 4-component ASTC, 6x6x5 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_6x6x6_OES: return GL_RGBA; // 4-component ASTC, 6x6x6 blocks, unsigned normalized - - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_3x3x3_OES: return GL_RGBA; // 4-component ASTC, 3x3x3 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x3x3_OES: return GL_RGBA; // 4-component ASTC, 4x3x3 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x3_OES: return GL_RGBA; // 4-component ASTC, 4x4x3 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x4_OES: return GL_RGBA; // 4-component ASTC, 4x4x4 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4x4_OES: return GL_RGBA; // 4-component ASTC, 5x4x4 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x4_OES: return GL_RGBA; // 4-component ASTC, 5x5x4 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x5_OES: return GL_RGBA; // 4-component ASTC, 5x5x5 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5x5_OES: return GL_RGBA; // 4-component ASTC, 6x5x5 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x5_OES: return GL_RGBA; // 4-component ASTC, 6x6x5 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x6_OES: return GL_RGBA; // 4-component ASTC, 6x6x6 blocks, sRGB - - // - // ATC - // - case GL_ATC_RGB_AMD: return GL_RGB; // 3-component, 4x4 blocks, unsigned normalized - case GL_ATC_RGBA_EXPLICIT_ALPHA_AMD: return GL_RGBA; // 4-component, 4x4 blocks, unsigned normalized - case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD: return GL_RGBA; // 4-component, 4x4 blocks, unsigned normalized - - // - // Palletized - // - case GL_PALETTE4_RGB8_OES: return GL_RGB; // 3-component 8:8:8, 4-bit palette, unsigned normalized - case GL_PALETTE4_RGBA8_OES: return GL_RGBA; // 4-component 8:8:8:8, 4-bit palette, unsigned normalized - case GL_PALETTE4_R5_G6_B5_OES: return GL_RGB; // 3-component 5:6:5, 4-bit palette, unsigned normalized - case GL_PALETTE4_RGBA4_OES: return GL_RGBA; // 4-component 4:4:4:4, 4-bit palette, unsigned normalized - case GL_PALETTE4_RGB5_A1_OES: return GL_RGBA; // 4-component 5:5:5:1, 4-bit palette, unsigned normalized - case GL_PALETTE8_RGB8_OES: return GL_RGB; // 3-component 8:8:8, 8-bit palette, unsigned normalized - case GL_PALETTE8_RGBA8_OES: return GL_RGBA; // 4-component 8:8:8:8, 8-bit palette, unsigned normalized - case GL_PALETTE8_R5_G6_B5_OES: return GL_RGB; // 3-component 5:6:5, 8-bit palette, unsigned normalized - case GL_PALETTE8_RGBA4_OES: return GL_RGBA; // 4-component 4:4:4:4, 8-bit palette, unsigned normalized - case GL_PALETTE8_RGB5_A1_OES: return GL_RGBA; // 4-component 5:5:5:1, 8-bit palette, unsigned normalized - - // - // Depth/stencil - // - case GL_DEPTH_COMPONENT16: return GL_DEPTH_COMPONENT; - case GL_DEPTH_COMPONENT24: return GL_DEPTH_COMPONENT; - case GL_DEPTH_COMPONENT32: return GL_DEPTH_COMPONENT; - case GL_DEPTH_COMPONENT32F: return GL_DEPTH_COMPONENT; - case GL_DEPTH_COMPONENT32F_NV: return GL_DEPTH_COMPONENT; - case GL_STENCIL_INDEX1: return GL_STENCIL_INDEX; - case GL_STENCIL_INDEX4: return GL_STENCIL_INDEX; - case GL_STENCIL_INDEX8: return GL_STENCIL_INDEX; - case GL_STENCIL_INDEX16: return GL_STENCIL_INDEX; - case GL_DEPTH24_STENCIL8: return GL_DEPTH_STENCIL; - case GL_DEPTH32F_STENCIL8: return GL_DEPTH_STENCIL; - case GL_DEPTH32F_STENCIL8_NV: return GL_DEPTH_STENCIL; - - default: return GL_INVALID_VALUE; - } +#if !defined(GL_DEPTH_COMPONENT16) +#define GL_DEPTH_COMPONENT16 0x81A5 // same as GL_DEPTH_COMPONENT16_SGIX and GL_DEPTH_COMPONENT16_ARB +#endif +#if !defined(GL_DEPTH_COMPONENT24) +#define GL_DEPTH_COMPONENT24 0x81A6 // same as GL_DEPTH_COMPONENT24_SGIX and GL_DEPTH_COMPONENT24_ARB +#endif +#if !defined(GL_DEPTH_COMPONENT32) +#define GL_DEPTH_COMPONENT32 0x81A7 // same as GL_DEPTH_COMPONENT32_SGIX and GL_DEPTH_COMPONENT32_ARB and GL_DEPTH_COMPONENT32_OES +#endif +#if !defined(GL_DEPTH_COMPONENT32F) +#define GL_DEPTH_COMPONENT32F 0x8CAC // same as GL_DEPTH_COMPONENT32F_ARB +#endif +#if !defined(GL_DEPTH_COMPONENT32F_NV) +#define GL_DEPTH_COMPONENT32F_NV 0x8DAB // note that this is different from GL_DEPTH_COMPONENT32F +#endif +#if !defined(GL_STENCIL_INDEX1) +#define GL_STENCIL_INDEX1 0x8D46 // same as GL_STENCIL_INDEX1_EXT +#endif +#if !defined(GL_STENCIL_INDEX4) +#define GL_STENCIL_INDEX4 0x8D47 // same as GL_STENCIL_INDEX4_EXT +#endif +#if !defined(GL_STENCIL_INDEX8) +#define GL_STENCIL_INDEX8 0x8D48 // same as GL_STENCIL_INDEX8_EXT +#endif +#if !defined(GL_STENCIL_INDEX16) +#define GL_STENCIL_INDEX16 0x8D49 // same as GL_STENCIL_INDEX16_EXT +#endif +#if !defined(GL_DEPTH24_STENCIL8) +#define GL_DEPTH24_STENCIL8 0x88F0 // same as GL_DEPTH24_STENCIL8_EXT and GL_DEPTH24_STENCIL8_OES +#endif +#if !defined(GL_DEPTH32F_STENCIL8) +#define GL_DEPTH32F_STENCIL8 0x8CAD // same as GL_DEPTH32F_STENCIL8_ARB +#endif +#if !defined(GL_DEPTH32F_STENCIL8_NV) +#define GL_DEPTH32F_STENCIL8_NV 0x8DAC // note that this is different from GL_DEPTH32F_STENCIL8 +#endif + +static inline GLenum +glGetFormatFromInternalFormat(const GLenum internalFormat) { + switch (internalFormat) { + // + // 8 bits per component + // + case GL_R8: + return GL_RED; // 1-component, 8-bit unsigned normalized + case GL_RG8: + return GL_RG; // 2-component, 8-bit unsigned normalized + case GL_RGB8: + return GL_RGB; // 3-component, 8-bit unsigned normalized + case GL_RGBA8: + return GL_RGBA; // 4-component, 8-bit unsigned normalized + + case GL_R8_SNORM: + return GL_RED; // 1-component, 8-bit signed normalized + case GL_RG8_SNORM: + return GL_RG; // 2-component, 8-bit signed normalized + case GL_RGB8_SNORM: + return GL_RGB; // 3-component, 8-bit signed normalized + case GL_RGBA8_SNORM: + return GL_RGBA; // 4-component, 8-bit signed normalized + + case GL_R8UI: + return GL_RED; // 1-component, 8-bit unsigned integer + case GL_RG8UI: + return GL_RG; // 2-component, 8-bit unsigned integer + case GL_RGB8UI: + return GL_RGB; // 3-component, 8-bit unsigned integer + case GL_RGBA8UI: + return GL_RGBA; // 4-component, 8-bit unsigned integer + + case GL_R8I: + return GL_RED; // 1-component, 8-bit signed integer + case GL_RG8I: + return GL_RG; // 2-component, 8-bit signed integer + case GL_RGB8I: + return GL_RGB; // 3-component, 8-bit signed integer + case GL_RGBA8I: + return GL_RGBA; // 4-component, 8-bit signed integer + + case GL_SR8: + return GL_RED; // 1-component, 8-bit sRGB + case GL_SRG8: + return GL_RG; // 2-component, 8-bit sRGB + case GL_SRGB8: + return GL_RGB; // 3-component, 8-bit sRGB + case GL_SRGB8_ALPHA8: + return GL_RGBA; // 4-component, 8-bit sRGB + + // + // 16 bits per component + // + case GL_R16: + return GL_RED; // 1-component, 16-bit unsigned normalized + case GL_RG16: + return GL_RG; // 2-component, 16-bit unsigned normalized + case GL_RGB16: + return GL_RGB; // 3-component, 16-bit unsigned normalized + case GL_RGBA16: + return GL_RGBA; // 4-component, 16-bit unsigned normalized + + case GL_R16_SNORM: + return GL_RED; // 1-component, 16-bit signed normalized + case GL_RG16_SNORM: + return GL_RG; // 2-component, 16-bit signed normalized + case GL_RGB16_SNORM: + return GL_RGB; // 3-component, 16-bit signed normalized + case GL_RGBA16_SNORM: + return GL_RGBA; // 4-component, 16-bit signed normalized + + case GL_R16UI: + return GL_RED; // 1-component, 16-bit unsigned integer + case GL_RG16UI: + return GL_RG; // 2-component, 16-bit unsigned integer + case GL_RGB16UI: + return GL_RGB; // 3-component, 16-bit unsigned integer + case GL_RGBA16UI: + return GL_RGBA; // 4-component, 16-bit unsigned integer + + case GL_R16I: + return GL_RED; // 1-component, 16-bit signed integer + case GL_RG16I: + return GL_RG; // 2-component, 16-bit signed integer + case GL_RGB16I: + return GL_RGB; // 3-component, 16-bit signed integer + case GL_RGBA16I: + return GL_RGBA; // 4-component, 16-bit signed integer + + case GL_R16F: + return GL_RED; // 1-component, 16-bit floating-point + case GL_RG16F: + return GL_RG; // 2-component, 16-bit floating-point + case GL_RGB16F: + return GL_RGB; // 3-component, 16-bit floating-point + case GL_RGBA16F: + return GL_RGBA; // 4-component, 16-bit floating-point + + // + // 32 bits per component + // + case GL_R32UI: + return GL_RED; // 1-component, 32-bit unsigned integer + case GL_RG32UI: + return GL_RG; // 2-component, 32-bit unsigned integer + case GL_RGB32UI: + return GL_RGB; // 3-component, 32-bit unsigned integer + case GL_RGBA32UI: + return GL_RGBA; // 4-component, 32-bit unsigned integer + + case GL_R32I: + return GL_RED; // 1-component, 32-bit signed integer + case GL_RG32I: + return GL_RG; // 2-component, 32-bit signed integer + case GL_RGB32I: + return GL_RGB; // 3-component, 32-bit signed integer + case GL_RGBA32I: + return GL_RGBA; // 4-component, 32-bit signed integer + + case GL_R32F: + return GL_RED; // 1-component, 32-bit floating-point + case GL_RG32F: + return GL_RG; // 2-component, 32-bit floating-point + case GL_RGB32F: + return GL_RGB; // 3-component, 32-bit floating-point + case GL_RGBA32F: + return GL_RGBA; // 4-component, 32-bit floating-point + + // + // Packed + // + case GL_R3_G3_B2: + return GL_RGB; // 3-component 3:3:2, unsigned normalized + case GL_RGB4: + return GL_RGB; // 3-component 4:4:4, unsigned normalized + case GL_RGB5: + return GL_RGB; // 3-component 5:5:5, unsigned normalized + case GL_RGB565: + return GL_RGB; // 3-component 5:6:5, unsigned normalized + case GL_RGB10: + return GL_RGB; // 3-component 10:10:10, unsigned normalized + case GL_RGB12: + return GL_RGB; // 3-component 12:12:12, unsigned normalized + case GL_RGBA2: + return GL_RGBA; // 4-component 2:2:2:2, unsigned normalized + case GL_RGBA4: + return GL_RGBA; // 4-component 4:4:4:4, unsigned normalized + case GL_RGBA12: + return GL_RGBA; // 4-component 12:12:12:12, unsigned normalized + case GL_RGB5_A1: + return GL_RGBA; // 4-component 5:5:5:1, unsigned normalized + case GL_RGB10_A2: + return GL_RGBA; // 4-component 10:10:10:2, unsigned normalized + case GL_RGB10_A2UI: + return GL_RGBA; // 4-component 10:10:10:2, unsigned integer + case GL_R11F_G11F_B10F: + return GL_RGB; // 3-component 11:11:10, floating-point + case GL_RGB9_E5: + return GL_RGB; // 3-component/exp 9:9:9/5, floating-point + + // + // S3TC/DXT/BC + // + + case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: + return GL_RGB; // line through 3D space, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: + return GL_RGBA; // line through 3D space plus 1-bit alpha, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: + return GL_RGBA; // line through 3D space plus line through 1D space, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: + return GL_RGBA; // line through 3D space plus 4-bit alpha, 4x4 blocks, unsigned normalized + + case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: + return GL_RGB; // line through 3D space, 4x4 blocks, sRGB + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: + return GL_RGBA; // line through 3D space plus 1-bit alpha, 4x4 blocks, sRGB + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: + return GL_RGBA; // line through 3D space plus line through 1D space, 4x4 blocks, sRGB + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: + return GL_RGBA; // line through 3D space plus 4-bit alpha, 4x4 blocks, sRGB + + case GL_COMPRESSED_LUMINANCE_LATC1_EXT: + return GL_RED; // line through 1D space, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT: + return GL_RG; // two lines through 1D space, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT: + return GL_RED; // line through 1D space, 4x4 blocks, signed normalized + case GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT: + return GL_RG; // two lines through 1D space, 4x4 blocks, signed normalized + + case GL_COMPRESSED_RED_RGTC1: + return GL_RED; // line through 1D space, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_RG_RGTC2: + return GL_RG; // two lines through 1D space, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_SIGNED_RED_RGTC1: + return GL_RED; // line through 1D space, 4x4 blocks, signed normalized + case GL_COMPRESSED_SIGNED_RG_RGTC2: + return GL_RG; // two lines through 1D space, 4x4 blocks, signed normalized + + case GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT: + return GL_RGB; // 3-component, 4x4 blocks, unsigned floating-point + case GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT: + return GL_RGB; // 3-component, 4x4 blocks, signed floating-point + case GL_COMPRESSED_RGBA_BPTC_UNORM: + return GL_RGBA; // 4-component, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM: + return GL_RGBA; // 4-component, 4x4 blocks, sRGB + + // + // ETC + // + case GL_ETC1_RGB8_OES: + return GL_RGB; // 3-component ETC1, 4x4 blocks, unsigned normalized + + case GL_COMPRESSED_RGB8_ETC2: + return GL_RGB; // 3-component ETC2, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: + return GL_RGBA; // 4-component ETC2 with 1-bit alpha, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_RGBA8_ETC2_EAC: + return GL_RGBA; // 4-component ETC2, 4x4 blocks, unsigned normalized + + case GL_COMPRESSED_SRGB8_ETC2: + return GL_RGB; // 3-component ETC2, 4x4 blocks, sRGB + case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: + return GL_RGBA; // 4-component ETC2 with 1-bit alpha, 4x4 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: + return GL_RGBA; // 4-component ETC2, 4x4 blocks, sRGB + + case GL_COMPRESSED_R11_EAC: + return GL_RED; // 1-component ETC, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_RG11_EAC: + return GL_RG; // 2-component ETC, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_SIGNED_R11_EAC: + return GL_RED; // 1-component ETC, 4x4 blocks, signed normalized + case GL_COMPRESSED_SIGNED_RG11_EAC: + return GL_RG; // 2-component ETC, 4x4 blocks, signed normalized + + // + // PVRTC + // + case GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG: + return GL_RGB; // 3-component PVRTC, 16x8 blocks, unsigned normalized + case GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG: + return GL_RGB; // 3-component PVRTC, 8x8 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: + return GL_RGBA; // 4-component PVRTC, 16x8 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: + return GL_RGBA; // 4-component PVRTC, 8x8 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG: + return GL_RGBA; // 4-component PVRTC, 8x4 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG: + return GL_RGBA; // 4-component PVRTC, 4x4 blocks, unsigned normalized + + case GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT: + return GL_RGB; // 3-component PVRTC, 16x8 blocks, sRGB + case GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT: + return GL_RGB; // 3-component PVRTC, 8x8 blocks, sRGB + case GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT: + return GL_RGBA; // 4-component PVRTC, 16x8 blocks, sRGB + case GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT: + return GL_RGBA; // 4-component PVRTC, 8x8 blocks, sRGB + case GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV2_IMG: + return GL_RGBA; // 4-component PVRTC, 8x4 blocks, sRGB + case GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV2_IMG: + return GL_RGBA; // 4-component PVRTC, 4x4 blocks, sRGB + + // + // ASTC + // + case GL_COMPRESSED_RGBA_ASTC_4x4_KHR: + return GL_RGBA; // 4-component ASTC, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_5x4_KHR: + return GL_RGBA; // 4-component ASTC, 5x4 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_5x5_KHR: + return GL_RGBA; // 4-component ASTC, 5x5 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_6x5_KHR: + return GL_RGBA; // 4-component ASTC, 6x5 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_6x6_KHR: + return GL_RGBA; // 4-component ASTC, 6x6 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_8x5_KHR: + return GL_RGBA; // 4-component ASTC, 8x5 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_8x6_KHR: + return GL_RGBA; // 4-component ASTC, 8x6 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_8x8_KHR: + return GL_RGBA; // 4-component ASTC, 8x8 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_10x5_KHR: + return GL_RGBA; // 4-component ASTC, 10x5 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_10x6_KHR: + return GL_RGBA; // 4-component ASTC, 10x6 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_10x8_KHR: + return GL_RGBA; // 4-component ASTC, 10x8 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_10x10_KHR: + return GL_RGBA; // 4-component ASTC, 10x10 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_12x10_KHR: + return GL_RGBA; // 4-component ASTC, 12x10 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_12x12_KHR: + return GL_RGBA; // 4-component ASTC, 12x12 blocks, unsigned normalized + + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR: + return GL_RGBA; // 4-component ASTC, 4x4 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR: + return GL_RGBA; // 4-component ASTC, 5x4 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR: + return GL_RGBA; // 4-component ASTC, 5x5 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR: + return GL_RGBA; // 4-component ASTC, 6x5 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR: + return GL_RGBA; // 4-component ASTC, 6x6 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR: + return GL_RGBA; // 4-component ASTC, 8x5 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR: + return GL_RGBA; // 4-component ASTC, 8x6 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR: + return GL_RGBA; // 4-component ASTC, 8x8 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR: + return GL_RGBA; // 4-component ASTC, 10x5 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR: + return GL_RGBA; // 4-component ASTC, 10x6 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR: + return GL_RGBA; // 4-component ASTC, 10x8 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR: + return GL_RGBA; // 4-component ASTC, 10x10 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR: + return GL_RGBA; // 4-component ASTC, 12x10 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR: + return GL_RGBA; // 4-component ASTC, 12x12 blocks, sRGB + + case GL_COMPRESSED_RGBA_ASTC_3x3x3_OES: + return GL_RGBA; // 4-component ASTC, 3x3x3 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_4x3x3_OES: + return GL_RGBA; // 4-component ASTC, 4x3x3 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_4x4x3_OES: + return GL_RGBA; // 4-component ASTC, 4x4x3 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_4x4x4_OES: + return GL_RGBA; // 4-component ASTC, 4x4x4 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_5x4x4_OES: + return GL_RGBA; // 4-component ASTC, 5x4x4 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_5x5x4_OES: + return GL_RGBA; // 4-component ASTC, 5x5x4 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_5x5x5_OES: + return GL_RGBA; // 4-component ASTC, 5x5x5 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_6x5x5_OES: + return GL_RGBA; // 4-component ASTC, 6x5x5 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_6x6x5_OES: + return GL_RGBA; // 4-component ASTC, 6x6x5 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_6x6x6_OES: + return GL_RGBA; // 4-component ASTC, 6x6x6 blocks, unsigned normalized + + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_3x3x3_OES: + return GL_RGBA; // 4-component ASTC, 3x3x3 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x3x3_OES: + return GL_RGBA; // 4-component ASTC, 4x3x3 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x3_OES: + return GL_RGBA; // 4-component ASTC, 4x4x3 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x4_OES: + return GL_RGBA; // 4-component ASTC, 4x4x4 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4x4_OES: + return GL_RGBA; // 4-component ASTC, 5x4x4 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x4_OES: + return GL_RGBA; // 4-component ASTC, 5x5x4 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x5_OES: + return GL_RGBA; // 4-component ASTC, 5x5x5 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5x5_OES: + return GL_RGBA; // 4-component ASTC, 6x5x5 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x5_OES: + return GL_RGBA; // 4-component ASTC, 6x6x5 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x6_OES: + return GL_RGBA; // 4-component ASTC, 6x6x6 blocks, sRGB + + // + // ATC + // + case GL_ATC_RGB_AMD: + return GL_RGB; // 3-component, 4x4 blocks, unsigned normalized + case GL_ATC_RGBA_EXPLICIT_ALPHA_AMD: + return GL_RGBA; // 4-component, 4x4 blocks, unsigned normalized + case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD: + return GL_RGBA; // 4-component, 4x4 blocks, unsigned normalized + + // + // Palletized + // + case GL_PALETTE4_RGB8_OES: + return GL_RGB; // 3-component 8:8:8, 4-bit palette, unsigned normalized + case GL_PALETTE4_RGBA8_OES: + return GL_RGBA; // 4-component 8:8:8:8, 4-bit palette, unsigned normalized + case GL_PALETTE4_R5_G6_B5_OES: + return GL_RGB; // 3-component 5:6:5, 4-bit palette, unsigned normalized + case GL_PALETTE4_RGBA4_OES: + return GL_RGBA; // 4-component 4:4:4:4, 4-bit palette, unsigned normalized + case GL_PALETTE4_RGB5_A1_OES: + return GL_RGBA; // 4-component 5:5:5:1, 4-bit palette, unsigned normalized + case GL_PALETTE8_RGB8_OES: + return GL_RGB; // 3-component 8:8:8, 8-bit palette, unsigned normalized + case GL_PALETTE8_RGBA8_OES: + return GL_RGBA; // 4-component 8:8:8:8, 8-bit palette, unsigned normalized + case GL_PALETTE8_R5_G6_B5_OES: + return GL_RGB; // 3-component 5:6:5, 8-bit palette, unsigned normalized + case GL_PALETTE8_RGBA4_OES: + return GL_RGBA; // 4-component 4:4:4:4, 8-bit palette, unsigned normalized + case GL_PALETTE8_RGB5_A1_OES: + return GL_RGBA; // 4-component 5:5:5:1, 8-bit palette, unsigned normalized + + // + // Depth/stencil + // + case GL_DEPTH_COMPONENT16: + return GL_DEPTH_COMPONENT; + case GL_DEPTH_COMPONENT24: + return GL_DEPTH_COMPONENT; + case GL_DEPTH_COMPONENT32: + return GL_DEPTH_COMPONENT; + case GL_DEPTH_COMPONENT32F: + return GL_DEPTH_COMPONENT; + case GL_DEPTH_COMPONENT32F_NV: + return GL_DEPTH_COMPONENT; + case GL_STENCIL_INDEX1: + return GL_STENCIL_INDEX; + case GL_STENCIL_INDEX4: + return GL_STENCIL_INDEX; + case GL_STENCIL_INDEX8: + return GL_STENCIL_INDEX; + case GL_STENCIL_INDEX16: + return GL_STENCIL_INDEX; + case GL_DEPTH24_STENCIL8: + return GL_DEPTH_STENCIL; + case GL_DEPTH32F_STENCIL8: + return GL_DEPTH_STENCIL; + case GL_DEPTH32F_STENCIL8_NV: + return GL_DEPTH_STENCIL; + + default: + return GL_INVALID_VALUE; + } } -static inline GLenum glGetTypeFromInternalFormat( const GLenum internalFormat ) -{ - switch ( internalFormat ) - { - // - // 8 bits per component - // - case GL_R8: return GL_UNSIGNED_BYTE; // 1-component, 8-bit unsigned normalized - case GL_RG8: return GL_UNSIGNED_BYTE; // 2-component, 8-bit unsigned normalized - case GL_RGB8: return GL_UNSIGNED_BYTE; // 3-component, 8-bit unsigned normalized - case GL_RGBA8: return GL_UNSIGNED_BYTE; // 4-component, 8-bit unsigned normalized - - case GL_R8_SNORM: return GL_BYTE; // 1-component, 8-bit signed normalized - case GL_RG8_SNORM: return GL_BYTE; // 2-component, 8-bit signed normalized - case GL_RGB8_SNORM: return GL_BYTE; // 3-component, 8-bit signed normalized - case GL_RGBA8_SNORM: return GL_BYTE; // 4-component, 8-bit signed normalized - - case GL_R8UI: return GL_UNSIGNED_BYTE; // 1-component, 8-bit unsigned integer - case GL_RG8UI: return GL_UNSIGNED_BYTE; // 2-component, 8-bit unsigned integer - case GL_RGB8UI: return GL_UNSIGNED_BYTE; // 3-component, 8-bit unsigned integer - case GL_RGBA8UI: return GL_UNSIGNED_BYTE; // 4-component, 8-bit unsigned integer - - case GL_R8I: return GL_BYTE; // 1-component, 8-bit signed integer - case GL_RG8I: return GL_BYTE; // 2-component, 8-bit signed integer - case GL_RGB8I: return GL_BYTE; // 3-component, 8-bit signed integer - case GL_RGBA8I: return GL_BYTE; // 4-component, 8-bit signed integer - - case GL_SR8: return GL_UNSIGNED_BYTE; // 1-component, 8-bit sRGB - case GL_SRG8: return GL_UNSIGNED_BYTE; // 2-component, 8-bit sRGB - case GL_SRGB8: return GL_UNSIGNED_BYTE; // 3-component, 8-bit sRGB - case GL_SRGB8_ALPHA8: return GL_UNSIGNED_BYTE; // 4-component, 8-bit sRGB - - // - // 16 bits per component - // - case GL_R16: return GL_UNSIGNED_SHORT; // 1-component, 16-bit unsigned normalized - case GL_RG16: return GL_UNSIGNED_SHORT; // 2-component, 16-bit unsigned normalized - case GL_RGB16: return GL_UNSIGNED_SHORT; // 3-component, 16-bit unsigned normalized - case GL_RGBA16: return GL_UNSIGNED_SHORT; // 4-component, 16-bit unsigned normalized - - case GL_R16_SNORM: return GL_SHORT; // 1-component, 16-bit signed normalized - case GL_RG16_SNORM: return GL_SHORT; // 2-component, 16-bit signed normalized - case GL_RGB16_SNORM: return GL_SHORT; // 3-component, 16-bit signed normalized - case GL_RGBA16_SNORM: return GL_SHORT; // 4-component, 16-bit signed normalized - - case GL_R16UI: return GL_UNSIGNED_SHORT; // 1-component, 16-bit unsigned integer - case GL_RG16UI: return GL_UNSIGNED_SHORT; // 2-component, 16-bit unsigned integer - case GL_RGB16UI: return GL_UNSIGNED_SHORT; // 3-component, 16-bit unsigned integer - case GL_RGBA16UI: return GL_UNSIGNED_SHORT; // 4-component, 16-bit unsigned integer - - case GL_R16I: return GL_SHORT; // 1-component, 16-bit signed integer - case GL_RG16I: return GL_SHORT; // 2-component, 16-bit signed integer - case GL_RGB16I: return GL_SHORT; // 3-component, 16-bit signed integer - case GL_RGBA16I: return GL_SHORT; // 4-component, 16-bit signed integer - - case GL_R16F: return GL_HALF_FLOAT; // 1-component, 16-bit floating-point - case GL_RG16F: return GL_HALF_FLOAT; // 2-component, 16-bit floating-point - case GL_RGB16F: return GL_HALF_FLOAT; // 3-component, 16-bit floating-point - case GL_RGBA16F: return GL_HALF_FLOAT; // 4-component, 16-bit floating-point - - // - // 32 bits per component - // - case GL_R32UI: return GL_UNSIGNED_INT; // 1-component, 32-bit unsigned integer - case GL_RG32UI: return GL_UNSIGNED_INT; // 2-component, 32-bit unsigned integer - case GL_RGB32UI: return GL_UNSIGNED_INT; // 3-component, 32-bit unsigned integer - case GL_RGBA32UI: return GL_UNSIGNED_INT; // 4-component, 32-bit unsigned integer - - case GL_R32I: return GL_INT; // 1-component, 32-bit signed integer - case GL_RG32I: return GL_INT; // 2-component, 32-bit signed integer - case GL_RGB32I: return GL_INT; // 3-component, 32-bit signed integer - case GL_RGBA32I: return GL_INT; // 4-component, 32-bit signed integer - - case GL_R32F: return GL_FLOAT; // 1-component, 32-bit floating-point - case GL_RG32F: return GL_FLOAT; // 2-component, 32-bit floating-point - case GL_RGB32F: return GL_FLOAT; // 3-component, 32-bit floating-point - case GL_RGBA32F: return GL_FLOAT; // 4-component, 32-bit floating-point - - // - // Packed - // - case GL_R3_G3_B2: return GL_UNSIGNED_BYTE_2_3_3_REV; // 3-component 3:3:2, unsigned normalized - case GL_RGB4: return GL_UNSIGNED_SHORT_4_4_4_4; // 3-component 4:4:4, unsigned normalized - case GL_RGB5: return GL_UNSIGNED_SHORT_5_5_5_1; // 3-component 5:5:5, unsigned normalized - case GL_RGB565: return GL_UNSIGNED_SHORT_5_6_5; // 3-component 5:6:5, unsigned normalized - case GL_RGB10: return GL_UNSIGNED_INT_10_10_10_2; // 3-component 10:10:10, unsigned normalized - case GL_RGB12: return GL_UNSIGNED_SHORT; // 3-component 12:12:12, unsigned normalized - case GL_RGBA2: return GL_UNSIGNED_BYTE; // 4-component 2:2:2:2, unsigned normalized - case GL_RGBA4: return GL_UNSIGNED_SHORT_4_4_4_4; // 4-component 4:4:4:4, unsigned normalized - case GL_RGBA12: return GL_UNSIGNED_SHORT; // 4-component 12:12:12:12, unsigned normalized - case GL_RGB5_A1: return GL_UNSIGNED_SHORT_5_5_5_1; // 4-component 5:5:5:1, unsigned normalized - case GL_RGB10_A2: return GL_UNSIGNED_INT_2_10_10_10_REV; // 4-component 10:10:10:2, unsigned normalized - case GL_RGB10_A2UI: return GL_UNSIGNED_INT_2_10_10_10_REV; // 4-component 10:10:10:2, unsigned integer - case GL_R11F_G11F_B10F: return GL_UNSIGNED_INT_10F_11F_11F_REV; // 3-component 11:11:10, floating-point - case GL_RGB9_E5: return GL_UNSIGNED_INT_5_9_9_9_REV; // 3-component/exp 9:9:9/5, floating-point - - // - // S3TC/DXT/BC - // - - case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: return GL_UNSIGNED_BYTE; // line through 3D space, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: return GL_UNSIGNED_BYTE; // line through 3D space plus 1-bit alpha, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: return GL_UNSIGNED_BYTE; // line through 3D space plus line through 1D space, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: return GL_UNSIGNED_BYTE; // line through 3D space plus 4-bit alpha, 4x4 blocks, unsigned normalized - - case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: return GL_UNSIGNED_BYTE; // line through 3D space, 4x4 blocks, sRGB - case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: return GL_UNSIGNED_BYTE; // line through 3D space plus 1-bit alpha, 4x4 blocks, sRGB - case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: return GL_UNSIGNED_BYTE; // line through 3D space plus line through 1D space, 4x4 blocks, sRGB - case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: return GL_UNSIGNED_BYTE; // line through 3D space plus 4-bit alpha, 4x4 blocks, sRGB - - case GL_COMPRESSED_LUMINANCE_LATC1_EXT: return GL_UNSIGNED_BYTE; // line through 1D space, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT: return GL_UNSIGNED_BYTE; // two lines through 1D space, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT: return GL_UNSIGNED_BYTE; // line through 1D space, 4x4 blocks, signed normalized - case GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT: return GL_UNSIGNED_BYTE; // two lines through 1D space, 4x4 blocks, signed normalized - - case GL_COMPRESSED_RED_RGTC1: return GL_UNSIGNED_BYTE; // line through 1D space, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_RG_RGTC2: return GL_UNSIGNED_BYTE; // two lines through 1D space, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_SIGNED_RED_RGTC1: return GL_UNSIGNED_BYTE; // line through 1D space, 4x4 blocks, signed normalized - case GL_COMPRESSED_SIGNED_RG_RGTC2: return GL_UNSIGNED_BYTE; // two lines through 1D space, 4x4 blocks, signed normalized - - case GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT: return GL_FLOAT; // 3-component, 4x4 blocks, unsigned floating-point - case GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT: return GL_FLOAT; // 3-component, 4x4 blocks, signed floating-point - case GL_COMPRESSED_RGBA_BPTC_UNORM: return GL_UNSIGNED_BYTE; // 4-component, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM: return GL_UNSIGNED_BYTE; // 4-component, 4x4 blocks, sRGB - - // - // ETC - // - case GL_ETC1_RGB8_OES: return GL_UNSIGNED_BYTE; // 3-component ETC1, 4x4 blocks, unsigned normalized" ), - - case GL_COMPRESSED_RGB8_ETC2: return GL_UNSIGNED_BYTE; // 3-component ETC2, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: return GL_UNSIGNED_BYTE; // 4-component ETC2 with 1-bit alpha, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_RGBA8_ETC2_EAC: return GL_UNSIGNED_BYTE; // 4-component ETC2, 4x4 blocks, unsigned normalized - - case GL_COMPRESSED_SRGB8_ETC2: return GL_UNSIGNED_BYTE; // 3-component ETC2, 4x4 blocks, sRGB - case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: return GL_UNSIGNED_BYTE; // 4-component ETC2 with 1-bit alpha, 4x4 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: return GL_UNSIGNED_BYTE; // 4-component ETC2, 4x4 blocks, sRGB - - case GL_COMPRESSED_R11_EAC: return GL_UNSIGNED_BYTE; // 1-component ETC, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_RG11_EAC: return GL_UNSIGNED_BYTE; // 2-component ETC, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_SIGNED_R11_EAC: return GL_UNSIGNED_BYTE; // 1-component ETC, 4x4 blocks, signed normalized - case GL_COMPRESSED_SIGNED_RG11_EAC: return GL_UNSIGNED_BYTE; // 2-component ETC, 4x4 blocks, signed normalized - - // - // PVRTC - // - case GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG: return GL_UNSIGNED_BYTE; // 3-component PVRTC, 16x8 blocks, unsigned normalized - case GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG: return GL_UNSIGNED_BYTE; // 3-component PVRTC, 8x8 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: return GL_UNSIGNED_BYTE; // 4-component PVRTC, 16x8 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: return GL_UNSIGNED_BYTE; // 4-component PVRTC, 8x8 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG: return GL_UNSIGNED_BYTE; // 4-component PVRTC, 8x4 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG: return GL_UNSIGNED_BYTE; // 4-component PVRTC, 4x4 blocks, unsigned normalized - - case GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT: return GL_UNSIGNED_BYTE; // 3-component PVRTC, 16x8 blocks, sRGB - case GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT: return GL_UNSIGNED_BYTE; // 3-component PVRTC, 8x8 blocks, sRGB - case GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT: return GL_UNSIGNED_BYTE; // 4-component PVRTC, 16x8 blocks, sRGB - case GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT: return GL_UNSIGNED_BYTE; // 4-component PVRTC, 8x8 blocks, sRGB - case GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV2_IMG: return GL_UNSIGNED_BYTE; // 4-component PVRTC, 8x4 blocks, sRGB - case GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV2_IMG: return GL_UNSIGNED_BYTE; // 4-component PVRTC, 4x4 blocks, sRGB - - // - // ASTC - // - case GL_COMPRESSED_RGBA_ASTC_4x4_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_5x4_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 5x4 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_5x5_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 5x5 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_6x5_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 6x5 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_6x6_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 6x6 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_8x5_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 8x5 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_8x6_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 8x6 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_8x8_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 8x8 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_10x5_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 10x5 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_10x6_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 10x6 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_10x8_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 10x8 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_10x10_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 10x10 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_12x10_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 12x10 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_12x12_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 12x12 blocks, unsigned normalized - - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 4x4 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 5x4 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 5x5 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 6x5 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 6x6 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 8x5 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 8x6 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 8x8 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 10x5 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 10x6 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 10x8 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 10x10 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 12x10 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR: return GL_UNSIGNED_BYTE; // 4-component ASTC, 12x12 blocks, sRGB - - case GL_COMPRESSED_RGBA_ASTC_3x3x3_OES: return GL_UNSIGNED_BYTE; // 4-component ASTC, 3x3x3 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_4x3x3_OES: return GL_UNSIGNED_BYTE; // 4-component ASTC, 4x3x3 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_4x4x3_OES: return GL_UNSIGNED_BYTE; // 4-component ASTC, 4x4x3 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_4x4x4_OES: return GL_UNSIGNED_BYTE; // 4-component ASTC, 4x4x4 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_5x4x4_OES: return GL_UNSIGNED_BYTE; // 4-component ASTC, 5x4x4 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_5x5x4_OES: return GL_UNSIGNED_BYTE; // 4-component ASTC, 5x5x4 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_5x5x5_OES: return GL_UNSIGNED_BYTE; // 4-component ASTC, 5x5x5 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_6x5x5_OES: return GL_UNSIGNED_BYTE; // 4-component ASTC, 6x5x5 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_6x6x5_OES: return GL_UNSIGNED_BYTE; // 4-component ASTC, 6x6x5 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_6x6x6_OES: return GL_UNSIGNED_BYTE; // 4-component ASTC, 6x6x6 blocks, unsigned normalized - - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_3x3x3_OES: return GL_UNSIGNED_BYTE; // 4-component ASTC, 3x3x3 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x3x3_OES: return GL_UNSIGNED_BYTE; // 4-component ASTC, 4x3x3 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x3_OES: return GL_UNSIGNED_BYTE; // 4-component ASTC, 4x4x3 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x4_OES: return GL_UNSIGNED_BYTE; // 4-component ASTC, 4x4x4 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4x4_OES: return GL_UNSIGNED_BYTE; // 4-component ASTC, 5x4x4 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x4_OES: return GL_UNSIGNED_BYTE; // 4-component ASTC, 5x5x4 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x5_OES: return GL_UNSIGNED_BYTE; // 4-component ASTC, 5x5x5 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5x5_OES: return GL_UNSIGNED_BYTE; // 4-component ASTC, 6x5x5 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x5_OES: return GL_UNSIGNED_BYTE; // 4-component ASTC, 6x6x5 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x6_OES: return GL_UNSIGNED_BYTE; // 4-component ASTC, 6x6x6 blocks, sRGB - - // - // ATC - // - case GL_ATC_RGB_AMD: return GL_UNSIGNED_BYTE; // 3-component, 4x4 blocks, unsigned normalized - case GL_ATC_RGBA_EXPLICIT_ALPHA_AMD: return GL_UNSIGNED_BYTE; // 4-component, 4x4 blocks, unsigned normalized - case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD: return GL_UNSIGNED_BYTE; // 4-component, 4x4 blocks, unsigned normalized - - // - // Palletized - // - case GL_PALETTE4_RGB8_OES: return GL_UNSIGNED_BYTE; // 3-component 8:8:8, 4-bit palette, unsigned normalized - case GL_PALETTE4_RGBA8_OES: return GL_UNSIGNED_BYTE; // 4-component 8:8:8:8, 4-bit palette, unsigned normalized - case GL_PALETTE4_R5_G6_B5_OES: return GL_UNSIGNED_SHORT_5_6_5; // 3-component 5:6:5, 4-bit palette, unsigned normalized - case GL_PALETTE4_RGBA4_OES: return GL_UNSIGNED_SHORT_4_4_4_4; // 4-component 4:4:4:4, 4-bit palette, unsigned normalized - case GL_PALETTE4_RGB5_A1_OES: return GL_UNSIGNED_SHORT_5_5_5_1; // 4-component 5:5:5:1, 4-bit palette, unsigned normalized - case GL_PALETTE8_RGB8_OES: return GL_UNSIGNED_BYTE; // 3-component 8:8:8, 8-bit palette, unsigned normalized - case GL_PALETTE8_RGBA8_OES: return GL_UNSIGNED_BYTE; // 4-component 8:8:8:8, 8-bit palette, unsigned normalized - case GL_PALETTE8_R5_G6_B5_OES: return GL_UNSIGNED_SHORT_5_6_5; // 3-component 5:6:5, 8-bit palette, unsigned normalized - case GL_PALETTE8_RGBA4_OES: return GL_UNSIGNED_SHORT_4_4_4_4; // 4-component 4:4:4:4, 8-bit palette, unsigned normalized - case GL_PALETTE8_RGB5_A1_OES: return GL_UNSIGNED_SHORT_5_5_5_1; // 4-component 5:5:5:1, 8-bit palette, unsigned normalized - - // - // Depth/stencil - // - case GL_DEPTH_COMPONENT16: return GL_UNSIGNED_SHORT; - case GL_DEPTH_COMPONENT24: return GL_UNSIGNED_INT_24_8; - case GL_DEPTH_COMPONENT32: return GL_UNSIGNED_INT; - case GL_DEPTH_COMPONENT32F: return GL_FLOAT; - case GL_DEPTH_COMPONENT32F_NV: return GL_FLOAT; - case GL_STENCIL_INDEX1: return GL_UNSIGNED_BYTE; - case GL_STENCIL_INDEX4: return GL_UNSIGNED_BYTE; - case GL_STENCIL_INDEX8: return GL_UNSIGNED_BYTE; - case GL_STENCIL_INDEX16: return GL_UNSIGNED_SHORT; - case GL_DEPTH24_STENCIL8: return GL_UNSIGNED_INT_24_8; - case GL_DEPTH32F_STENCIL8: return GL_FLOAT_32_UNSIGNED_INT_24_8_REV; - case GL_DEPTH32F_STENCIL8_NV: return GL_FLOAT_32_UNSIGNED_INT_24_8_REV; - - default: return GL_INVALID_VALUE; - } +static inline GLenum +glGetTypeFromInternalFormat(const GLenum internalFormat) { + switch (internalFormat) { + // + // 8 bits per component + // + case GL_R8: + return GL_UNSIGNED_BYTE; // 1-component, 8-bit unsigned normalized + case GL_RG8: + return GL_UNSIGNED_BYTE; // 2-component, 8-bit unsigned normalized + case GL_RGB8: + return GL_UNSIGNED_BYTE; // 3-component, 8-bit unsigned normalized + case GL_RGBA8: + return GL_UNSIGNED_BYTE; // 4-component, 8-bit unsigned normalized + + case GL_R8_SNORM: + return GL_BYTE; // 1-component, 8-bit signed normalized + case GL_RG8_SNORM: + return GL_BYTE; // 2-component, 8-bit signed normalized + case GL_RGB8_SNORM: + return GL_BYTE; // 3-component, 8-bit signed normalized + case GL_RGBA8_SNORM: + return GL_BYTE; // 4-component, 8-bit signed normalized + + case GL_R8UI: + return GL_UNSIGNED_BYTE; // 1-component, 8-bit unsigned integer + case GL_RG8UI: + return GL_UNSIGNED_BYTE; // 2-component, 8-bit unsigned integer + case GL_RGB8UI: + return GL_UNSIGNED_BYTE; // 3-component, 8-bit unsigned integer + case GL_RGBA8UI: + return GL_UNSIGNED_BYTE; // 4-component, 8-bit unsigned integer + + case GL_R8I: + return GL_BYTE; // 1-component, 8-bit signed integer + case GL_RG8I: + return GL_BYTE; // 2-component, 8-bit signed integer + case GL_RGB8I: + return GL_BYTE; // 3-component, 8-bit signed integer + case GL_RGBA8I: + return GL_BYTE; // 4-component, 8-bit signed integer + + case GL_SR8: + return GL_UNSIGNED_BYTE; // 1-component, 8-bit sRGB + case GL_SRG8: + return GL_UNSIGNED_BYTE; // 2-component, 8-bit sRGB + case GL_SRGB8: + return GL_UNSIGNED_BYTE; // 3-component, 8-bit sRGB + case GL_SRGB8_ALPHA8: + return GL_UNSIGNED_BYTE; // 4-component, 8-bit sRGB + + // + // 16 bits per component + // + case GL_R16: + return GL_UNSIGNED_SHORT; // 1-component, 16-bit unsigned normalized + case GL_RG16: + return GL_UNSIGNED_SHORT; // 2-component, 16-bit unsigned normalized + case GL_RGB16: + return GL_UNSIGNED_SHORT; // 3-component, 16-bit unsigned normalized + case GL_RGBA16: + return GL_UNSIGNED_SHORT; // 4-component, 16-bit unsigned normalized + + case GL_R16_SNORM: + return GL_SHORT; // 1-component, 16-bit signed normalized + case GL_RG16_SNORM: + return GL_SHORT; // 2-component, 16-bit signed normalized + case GL_RGB16_SNORM: + return GL_SHORT; // 3-component, 16-bit signed normalized + case GL_RGBA16_SNORM: + return GL_SHORT; // 4-component, 16-bit signed normalized + + case GL_R16UI: + return GL_UNSIGNED_SHORT; // 1-component, 16-bit unsigned integer + case GL_RG16UI: + return GL_UNSIGNED_SHORT; // 2-component, 16-bit unsigned integer + case GL_RGB16UI: + return GL_UNSIGNED_SHORT; // 3-component, 16-bit unsigned integer + case GL_RGBA16UI: + return GL_UNSIGNED_SHORT; // 4-component, 16-bit unsigned integer + + case GL_R16I: + return GL_SHORT; // 1-component, 16-bit signed integer + case GL_RG16I: + return GL_SHORT; // 2-component, 16-bit signed integer + case GL_RGB16I: + return GL_SHORT; // 3-component, 16-bit signed integer + case GL_RGBA16I: + return GL_SHORT; // 4-component, 16-bit signed integer + + case GL_R16F: + return GL_HALF_FLOAT; // 1-component, 16-bit floating-point + case GL_RG16F: + return GL_HALF_FLOAT; // 2-component, 16-bit floating-point + case GL_RGB16F: + return GL_HALF_FLOAT; // 3-component, 16-bit floating-point + case GL_RGBA16F: + return GL_HALF_FLOAT; // 4-component, 16-bit floating-point + + // + // 32 bits per component + // + case GL_R32UI: + return GL_UNSIGNED_INT; // 1-component, 32-bit unsigned integer + case GL_RG32UI: + return GL_UNSIGNED_INT; // 2-component, 32-bit unsigned integer + case GL_RGB32UI: + return GL_UNSIGNED_INT; // 3-component, 32-bit unsigned integer + case GL_RGBA32UI: + return GL_UNSIGNED_INT; // 4-component, 32-bit unsigned integer + + case GL_R32I: + return GL_INT; // 1-component, 32-bit signed integer + case GL_RG32I: + return GL_INT; // 2-component, 32-bit signed integer + case GL_RGB32I: + return GL_INT; // 3-component, 32-bit signed integer + case GL_RGBA32I: + return GL_INT; // 4-component, 32-bit signed integer + + case GL_R32F: + return GL_FLOAT; // 1-component, 32-bit floating-point + case GL_RG32F: + return GL_FLOAT; // 2-component, 32-bit floating-point + case GL_RGB32F: + return GL_FLOAT; // 3-component, 32-bit floating-point + case GL_RGBA32F: + return GL_FLOAT; // 4-component, 32-bit floating-point + + // + // Packed + // + case GL_R3_G3_B2: + return GL_UNSIGNED_BYTE_2_3_3_REV; // 3-component 3:3:2, unsigned normalized + case GL_RGB4: + return GL_UNSIGNED_SHORT_4_4_4_4; // 3-component 4:4:4, unsigned normalized + case GL_RGB5: + return GL_UNSIGNED_SHORT_5_5_5_1; // 3-component 5:5:5, unsigned normalized + case GL_RGB565: + return GL_UNSIGNED_SHORT_5_6_5; // 3-component 5:6:5, unsigned normalized + case GL_RGB10: + return GL_UNSIGNED_INT_10_10_10_2; // 3-component 10:10:10, unsigned normalized + case GL_RGB12: + return GL_UNSIGNED_SHORT; // 3-component 12:12:12, unsigned normalized + case GL_RGBA2: + return GL_UNSIGNED_BYTE; // 4-component 2:2:2:2, unsigned normalized + case GL_RGBA4: + return GL_UNSIGNED_SHORT_4_4_4_4; // 4-component 4:4:4:4, unsigned normalized + case GL_RGBA12: + return GL_UNSIGNED_SHORT; // 4-component 12:12:12:12, unsigned normalized + case GL_RGB5_A1: + return GL_UNSIGNED_SHORT_5_5_5_1; // 4-component 5:5:5:1, unsigned normalized + case GL_RGB10_A2: + return GL_UNSIGNED_INT_2_10_10_10_REV; // 4-component 10:10:10:2, unsigned normalized + case GL_RGB10_A2UI: + return GL_UNSIGNED_INT_2_10_10_10_REV; // 4-component 10:10:10:2, unsigned integer + case GL_R11F_G11F_B10F: + return GL_UNSIGNED_INT_10F_11F_11F_REV; // 3-component 11:11:10, floating-point + case GL_RGB9_E5: + return GL_UNSIGNED_INT_5_9_9_9_REV; // 3-component/exp 9:9:9/5, floating-point + + // + // S3TC/DXT/BC + // + + case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: + return GL_UNSIGNED_BYTE; // line through 3D space, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: + return GL_UNSIGNED_BYTE; // line through 3D space plus 1-bit alpha, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: + return GL_UNSIGNED_BYTE; // line through 3D space plus line through 1D space, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: + return GL_UNSIGNED_BYTE; // line through 3D space plus 4-bit alpha, 4x4 blocks, unsigned normalized + + case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: + return GL_UNSIGNED_BYTE; // line through 3D space, 4x4 blocks, sRGB + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: + return GL_UNSIGNED_BYTE; // line through 3D space plus 1-bit alpha, 4x4 blocks, sRGB + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: + return GL_UNSIGNED_BYTE; // line through 3D space plus line through 1D space, 4x4 blocks, sRGB + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: + return GL_UNSIGNED_BYTE; // line through 3D space plus 4-bit alpha, 4x4 blocks, sRGB + + case GL_COMPRESSED_LUMINANCE_LATC1_EXT: + return GL_UNSIGNED_BYTE; // line through 1D space, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT: + return GL_UNSIGNED_BYTE; // two lines through 1D space, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT: + return GL_UNSIGNED_BYTE; // line through 1D space, 4x4 blocks, signed normalized + case GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT: + return GL_UNSIGNED_BYTE; // two lines through 1D space, 4x4 blocks, signed normalized + + case GL_COMPRESSED_RED_RGTC1: + return GL_UNSIGNED_BYTE; // line through 1D space, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_RG_RGTC2: + return GL_UNSIGNED_BYTE; // two lines through 1D space, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_SIGNED_RED_RGTC1: + return GL_UNSIGNED_BYTE; // line through 1D space, 4x4 blocks, signed normalized + case GL_COMPRESSED_SIGNED_RG_RGTC2: + return GL_UNSIGNED_BYTE; // two lines through 1D space, 4x4 blocks, signed normalized + + case GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT: + return GL_FLOAT; // 3-component, 4x4 blocks, unsigned floating-point + case GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT: + return GL_FLOAT; // 3-component, 4x4 blocks, signed floating-point + case GL_COMPRESSED_RGBA_BPTC_UNORM: + return GL_UNSIGNED_BYTE; // 4-component, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM: + return GL_UNSIGNED_BYTE; // 4-component, 4x4 blocks, sRGB + + // + // ETC + // + case GL_ETC1_RGB8_OES: + return GL_UNSIGNED_BYTE; // 3-component ETC1, 4x4 blocks, unsigned normalized" ), + + case GL_COMPRESSED_RGB8_ETC2: + return GL_UNSIGNED_BYTE; // 3-component ETC2, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: + return GL_UNSIGNED_BYTE; // 4-component ETC2 with 1-bit alpha, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_RGBA8_ETC2_EAC: + return GL_UNSIGNED_BYTE; // 4-component ETC2, 4x4 blocks, unsigned normalized + + case GL_COMPRESSED_SRGB8_ETC2: + return GL_UNSIGNED_BYTE; // 3-component ETC2, 4x4 blocks, sRGB + case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: + return GL_UNSIGNED_BYTE; // 4-component ETC2 with 1-bit alpha, 4x4 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: + return GL_UNSIGNED_BYTE; // 4-component ETC2, 4x4 blocks, sRGB + + case GL_COMPRESSED_R11_EAC: + return GL_UNSIGNED_BYTE; // 1-component ETC, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_RG11_EAC: + return GL_UNSIGNED_BYTE; // 2-component ETC, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_SIGNED_R11_EAC: + return GL_UNSIGNED_BYTE; // 1-component ETC, 4x4 blocks, signed normalized + case GL_COMPRESSED_SIGNED_RG11_EAC: + return GL_UNSIGNED_BYTE; // 2-component ETC, 4x4 blocks, signed normalized + + // + // PVRTC + // + case GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG: + return GL_UNSIGNED_BYTE; // 3-component PVRTC, 16x8 blocks, unsigned normalized + case GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG: + return GL_UNSIGNED_BYTE; // 3-component PVRTC, 8x8 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: + return GL_UNSIGNED_BYTE; // 4-component PVRTC, 16x8 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: + return GL_UNSIGNED_BYTE; // 4-component PVRTC, 8x8 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG: + return GL_UNSIGNED_BYTE; // 4-component PVRTC, 8x4 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG: + return GL_UNSIGNED_BYTE; // 4-component PVRTC, 4x4 blocks, unsigned normalized + + case GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT: + return GL_UNSIGNED_BYTE; // 3-component PVRTC, 16x8 blocks, sRGB + case GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT: + return GL_UNSIGNED_BYTE; // 3-component PVRTC, 8x8 blocks, sRGB + case GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT: + return GL_UNSIGNED_BYTE; // 4-component PVRTC, 16x8 blocks, sRGB + case GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT: + return GL_UNSIGNED_BYTE; // 4-component PVRTC, 8x8 blocks, sRGB + case GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV2_IMG: + return GL_UNSIGNED_BYTE; // 4-component PVRTC, 8x4 blocks, sRGB + case GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV2_IMG: + return GL_UNSIGNED_BYTE; // 4-component PVRTC, 4x4 blocks, sRGB + + // + // ASTC + // + case GL_COMPRESSED_RGBA_ASTC_4x4_KHR: + return GL_UNSIGNED_BYTE; // 4-component ASTC, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_5x4_KHR: + return GL_UNSIGNED_BYTE; // 4-component ASTC, 5x4 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_5x5_KHR: + return GL_UNSIGNED_BYTE; // 4-component ASTC, 5x5 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_6x5_KHR: + return GL_UNSIGNED_BYTE; // 4-component ASTC, 6x5 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_6x6_KHR: + return GL_UNSIGNED_BYTE; // 4-component ASTC, 6x6 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_8x5_KHR: + return GL_UNSIGNED_BYTE; // 4-component ASTC, 8x5 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_8x6_KHR: + return GL_UNSIGNED_BYTE; // 4-component ASTC, 8x6 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_8x8_KHR: + return GL_UNSIGNED_BYTE; // 4-component ASTC, 8x8 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_10x5_KHR: + return GL_UNSIGNED_BYTE; // 4-component ASTC, 10x5 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_10x6_KHR: + return GL_UNSIGNED_BYTE; // 4-component ASTC, 10x6 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_10x8_KHR: + return GL_UNSIGNED_BYTE; // 4-component ASTC, 10x8 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_10x10_KHR: + return GL_UNSIGNED_BYTE; // 4-component ASTC, 10x10 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_12x10_KHR: + return GL_UNSIGNED_BYTE; // 4-component ASTC, 12x10 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_12x12_KHR: + return GL_UNSIGNED_BYTE; // 4-component ASTC, 12x12 blocks, unsigned normalized + + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR: + return GL_UNSIGNED_BYTE; // 4-component ASTC, 4x4 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR: + return GL_UNSIGNED_BYTE; // 4-component ASTC, 5x4 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR: + return GL_UNSIGNED_BYTE; // 4-component ASTC, 5x5 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR: + return GL_UNSIGNED_BYTE; // 4-component ASTC, 6x5 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR: + return GL_UNSIGNED_BYTE; // 4-component ASTC, 6x6 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR: + return GL_UNSIGNED_BYTE; // 4-component ASTC, 8x5 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR: + return GL_UNSIGNED_BYTE; // 4-component ASTC, 8x6 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR: + return GL_UNSIGNED_BYTE; // 4-component ASTC, 8x8 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR: + return GL_UNSIGNED_BYTE; // 4-component ASTC, 10x5 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR: + return GL_UNSIGNED_BYTE; // 4-component ASTC, 10x6 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR: + return GL_UNSIGNED_BYTE; // 4-component ASTC, 10x8 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR: + return GL_UNSIGNED_BYTE; // 4-component ASTC, 10x10 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR: + return GL_UNSIGNED_BYTE; // 4-component ASTC, 12x10 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR: + return GL_UNSIGNED_BYTE; // 4-component ASTC, 12x12 blocks, sRGB + + case GL_COMPRESSED_RGBA_ASTC_3x3x3_OES: + return GL_UNSIGNED_BYTE; // 4-component ASTC, 3x3x3 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_4x3x3_OES: + return GL_UNSIGNED_BYTE; // 4-component ASTC, 4x3x3 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_4x4x3_OES: + return GL_UNSIGNED_BYTE; // 4-component ASTC, 4x4x3 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_4x4x4_OES: + return GL_UNSIGNED_BYTE; // 4-component ASTC, 4x4x4 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_5x4x4_OES: + return GL_UNSIGNED_BYTE; // 4-component ASTC, 5x4x4 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_5x5x4_OES: + return GL_UNSIGNED_BYTE; // 4-component ASTC, 5x5x4 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_5x5x5_OES: + return GL_UNSIGNED_BYTE; // 4-component ASTC, 5x5x5 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_6x5x5_OES: + return GL_UNSIGNED_BYTE; // 4-component ASTC, 6x5x5 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_6x6x5_OES: + return GL_UNSIGNED_BYTE; // 4-component ASTC, 6x6x5 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_6x6x6_OES: + return GL_UNSIGNED_BYTE; // 4-component ASTC, 6x6x6 blocks, unsigned normalized + + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_3x3x3_OES: + return GL_UNSIGNED_BYTE; // 4-component ASTC, 3x3x3 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x3x3_OES: + return GL_UNSIGNED_BYTE; // 4-component ASTC, 4x3x3 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x3_OES: + return GL_UNSIGNED_BYTE; // 4-component ASTC, 4x4x3 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x4_OES: + return GL_UNSIGNED_BYTE; // 4-component ASTC, 4x4x4 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4x4_OES: + return GL_UNSIGNED_BYTE; // 4-component ASTC, 5x4x4 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x4_OES: + return GL_UNSIGNED_BYTE; // 4-component ASTC, 5x5x4 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x5_OES: + return GL_UNSIGNED_BYTE; // 4-component ASTC, 5x5x5 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5x5_OES: + return GL_UNSIGNED_BYTE; // 4-component ASTC, 6x5x5 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x5_OES: + return GL_UNSIGNED_BYTE; // 4-component ASTC, 6x6x5 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x6_OES: + return GL_UNSIGNED_BYTE; // 4-component ASTC, 6x6x6 blocks, sRGB + + // + // ATC + // + case GL_ATC_RGB_AMD: + return GL_UNSIGNED_BYTE; // 3-component, 4x4 blocks, unsigned normalized + case GL_ATC_RGBA_EXPLICIT_ALPHA_AMD: + return GL_UNSIGNED_BYTE; // 4-component, 4x4 blocks, unsigned normalized + case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD: + return GL_UNSIGNED_BYTE; // 4-component, 4x4 blocks, unsigned normalized + + // + // Palletized + // + case GL_PALETTE4_RGB8_OES: + return GL_UNSIGNED_BYTE; // 3-component 8:8:8, 4-bit palette, unsigned normalized + case GL_PALETTE4_RGBA8_OES: + return GL_UNSIGNED_BYTE; // 4-component 8:8:8:8, 4-bit palette, unsigned normalized + case GL_PALETTE4_R5_G6_B5_OES: + return GL_UNSIGNED_SHORT_5_6_5; // 3-component 5:6:5, 4-bit palette, unsigned normalized + case GL_PALETTE4_RGBA4_OES: + return GL_UNSIGNED_SHORT_4_4_4_4; // 4-component 4:4:4:4, 4-bit palette, unsigned normalized + case GL_PALETTE4_RGB5_A1_OES: + return GL_UNSIGNED_SHORT_5_5_5_1; // 4-component 5:5:5:1, 4-bit palette, unsigned normalized + case GL_PALETTE8_RGB8_OES: + return GL_UNSIGNED_BYTE; // 3-component 8:8:8, 8-bit palette, unsigned normalized + case GL_PALETTE8_RGBA8_OES: + return GL_UNSIGNED_BYTE; // 4-component 8:8:8:8, 8-bit palette, unsigned normalized + case GL_PALETTE8_R5_G6_B5_OES: + return GL_UNSIGNED_SHORT_5_6_5; // 3-component 5:6:5, 8-bit palette, unsigned normalized + case GL_PALETTE8_RGBA4_OES: + return GL_UNSIGNED_SHORT_4_4_4_4; // 4-component 4:4:4:4, 8-bit palette, unsigned normalized + case GL_PALETTE8_RGB5_A1_OES: + return GL_UNSIGNED_SHORT_5_5_5_1; // 4-component 5:5:5:1, 8-bit palette, unsigned normalized + + // + // Depth/stencil + // + case GL_DEPTH_COMPONENT16: + return GL_UNSIGNED_SHORT; + case GL_DEPTH_COMPONENT24: + return GL_UNSIGNED_INT_24_8; + case GL_DEPTH_COMPONENT32: + return GL_UNSIGNED_INT; + case GL_DEPTH_COMPONENT32F: + return GL_FLOAT; + case GL_DEPTH_COMPONENT32F_NV: + return GL_FLOAT; + case GL_STENCIL_INDEX1: + return GL_UNSIGNED_BYTE; + case GL_STENCIL_INDEX4: + return GL_UNSIGNED_BYTE; + case GL_STENCIL_INDEX8: + return GL_UNSIGNED_BYTE; + case GL_STENCIL_INDEX16: + return GL_UNSIGNED_SHORT; + case GL_DEPTH24_STENCIL8: + return GL_UNSIGNED_INT_24_8; + case GL_DEPTH32F_STENCIL8: + return GL_FLOAT_32_UNSIGNED_INT_24_8_REV; + case GL_DEPTH32F_STENCIL8_NV: + return GL_FLOAT_32_UNSIGNED_INT_24_8_REV; + + default: + return GL_INVALID_VALUE; + } } -static inline unsigned int glGetTypeSizeFromType(GLenum type) -{ +static inline unsigned int +glGetTypeSizeFromType(GLenum type) { switch (type) { - case GL_BYTE: - case GL_UNSIGNED_BYTE: - case GL_UNSIGNED_BYTE_3_3_2: - case GL_UNSIGNED_BYTE_2_3_3_REV: - return 1; - - case GL_SHORT: - case GL_UNSIGNED_SHORT: - case GL_UNSIGNED_SHORT_5_6_5: - case GL_UNSIGNED_SHORT_4_4_4_4: - case GL_UNSIGNED_SHORT_5_5_5_1: - case GL_UNSIGNED_SHORT_5_6_5_REV: - case GL_UNSIGNED_SHORT_4_4_4_4_REV: - case GL_UNSIGNED_SHORT_1_5_5_5_REV: - case GL_HALF_FLOAT: - return 2; - - case GL_INT: - case GL_UNSIGNED_INT: - case GL_UNSIGNED_INT_8_8_8_8: - case GL_UNSIGNED_INT_8_8_8_8_REV: - case GL_UNSIGNED_INT_10_10_10_2: - case GL_UNSIGNED_INT_2_10_10_10_REV: - case GL_UNSIGNED_INT_24_8: - case GL_UNSIGNED_INT_10F_11F_11F_REV: - case GL_UNSIGNED_INT_5_9_9_9_REV: - case GL_FLOAT: - case GL_FLOAT_32_UNSIGNED_INT_24_8_REV: - return 4; - - default: - return GL_INVALID_VALUE; + case GL_BYTE: + case GL_UNSIGNED_BYTE: + case GL_UNSIGNED_BYTE_3_3_2: + case GL_UNSIGNED_BYTE_2_3_3_REV: + return 1; + + case GL_SHORT: + case GL_UNSIGNED_SHORT: + case GL_UNSIGNED_SHORT_5_6_5: + case GL_UNSIGNED_SHORT_4_4_4_4: + case GL_UNSIGNED_SHORT_5_5_5_1: + case GL_UNSIGNED_SHORT_5_6_5_REV: + case GL_UNSIGNED_SHORT_4_4_4_4_REV: + case GL_UNSIGNED_SHORT_1_5_5_5_REV: + case GL_HALF_FLOAT: + return 2; + + case GL_INT: + case GL_UNSIGNED_INT: + case GL_UNSIGNED_INT_8_8_8_8: + case GL_UNSIGNED_INT_8_8_8_8_REV: + case GL_UNSIGNED_INT_10_10_10_2: + case GL_UNSIGNED_INT_2_10_10_10_REV: + case GL_UNSIGNED_INT_24_8: + case GL_UNSIGNED_INT_10F_11F_11F_REV: + case GL_UNSIGNED_INT_5_9_9_9_REV: + case GL_FLOAT: + case GL_FLOAT_32_UNSIGNED_INT_24_8_REV: + return 4; + + default: + return GL_INVALID_VALUE; } } -static inline void glGetFormatSize( const GLenum internalFormat, ktxFormatSize * pFormatSize ) -{ - pFormatSize->minBlocksX = pFormatSize->minBlocksY = 1; - switch ( internalFormat ) - { - // - // 8 bits per component - // - case GL_R8: // 1-component, 8-bit unsigned normalized - case GL_R8_SNORM: // 1-component, 8-bit signed normalized - case GL_R8UI: // 1-component, 8-bit unsigned integer - case GL_R8I: // 1-component, 8-bit signed integer - case GL_SR8: // 1-component, 8-bit sRGB - pFormatSize->flags = 0; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 1 * 8; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case GL_RG8: // 2-component, 8-bit unsigned normalized - case GL_RG8_SNORM: // 2-component, 8-bit signed normalized - case GL_RG8UI: // 2-component, 8-bit unsigned integer - case GL_RG8I: // 2-component, 8-bit signed integer - case GL_SRG8: // 2-component, 8-bit sRGB - pFormatSize->flags = 0; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 2 * 8; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case GL_RGB8: // 3-component, 8-bit unsigned normalized - case GL_RGB8_SNORM: // 3-component, 8-bit signed normalized - case GL_RGB8UI: // 3-component, 8-bit unsigned integer - case GL_RGB8I: // 3-component, 8-bit signed integer - case GL_SRGB8: // 3-component, 8-bit sRGB - pFormatSize->flags = 0; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 3 * 8; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case GL_RGBA8: // 4-component, 8-bit unsigned normalized - case GL_RGBA8_SNORM: // 4-component, 8-bit signed normalized - case GL_RGBA8UI: // 4-component, 8-bit unsigned integer - case GL_RGBA8I: // 4-component, 8-bit signed integer - case GL_SRGB8_ALPHA8: // 4-component, 8-bit sRGB - pFormatSize->flags = 0; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 4 * 8; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - - // - // 16 bits per component - // - case GL_R16: // 1-component, 16-bit unsigned normalized - case GL_R16_SNORM: // 1-component, 16-bit signed normalized - case GL_R16UI: // 1-component, 16-bit unsigned integer - case GL_R16I: // 1-component, 16-bit signed integer - case GL_R16F: // 1-component, 16-bit floating-point - pFormatSize->flags = 0; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 2 * 8; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case GL_RG16: // 2-component, 16-bit unsigned normalized - case GL_RG16_SNORM: // 2-component, 16-bit signed normalized - case GL_RG16UI: // 2-component, 16-bit unsigned integer - case GL_RG16I: // 2-component, 16-bit signed integer - case GL_RG16F: // 2-component, 16-bit floating-point - pFormatSize->flags = 0; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 4 * 8; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case GL_RGB16: // 3-component, 16-bit unsigned normalized - case GL_RGB16_SNORM: // 3-component, 16-bit signed normalized - case GL_RGB16UI: // 3-component, 16-bit unsigned integer - case GL_RGB16I: // 3-component, 16-bit signed integer - case GL_RGB16F: // 3-component, 16-bit floating-point - pFormatSize->flags = 0; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 6 * 8; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case GL_RGBA16: // 4-component, 16-bit unsigned normalized - case GL_RGBA16_SNORM: // 4-component, 16-bit signed normalized - case GL_RGBA16UI: // 4-component, 16-bit unsigned integer - case GL_RGBA16I: // 4-component, 16-bit signed integer - case GL_RGBA16F: // 4-component, 16-bit floating-point - pFormatSize->flags = 0; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 8 * 8; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - - // - // 32 bits per component - // - case GL_R32UI: // 1-component, 32-bit unsigned integer - case GL_R32I: // 1-component, 32-bit signed integer - case GL_R32F: // 1-component, 32-bit floating-point - pFormatSize->flags = 0; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 4 * 8; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case GL_RG32UI: // 2-component, 32-bit unsigned integer - case GL_RG32I: // 2-component, 32-bit signed integer - case GL_RG32F: // 2-component, 32-bit floating-point - pFormatSize->flags = 0; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 8 * 8; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case GL_RGB32UI: // 3-component, 32-bit unsigned integer - case GL_RGB32I: // 3-component, 32-bit signed integer - case GL_RGB32F: // 3-component, 32-bit floating-point - pFormatSize->flags = 0; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 12 * 8; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case GL_RGBA32UI: // 4-component, 32-bit unsigned integer - case GL_RGBA32I: // 4-component, 32-bit signed integer - case GL_RGBA32F: // 4-component, 32-bit floating-point - pFormatSize->flags = 0; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 16 * 8; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - - // - // Packed - // - case GL_R3_G3_B2: // 3-component 3:3:2, unsigned normalized - pFormatSize->flags = KTX_FORMAT_SIZE_PACKED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 8; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case GL_RGB4: // 3-component 4:4:4, unsigned normalized - pFormatSize->flags = KTX_FORMAT_SIZE_PACKED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 12; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case GL_RGB5: // 3-component 5:5:5, unsigned normalized - pFormatSize->flags = KTX_FORMAT_SIZE_PACKED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 16; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case GL_RGB565: // 3-component 5:6:5, unsigned normalized - pFormatSize->flags = KTX_FORMAT_SIZE_PACKED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 16; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case GL_RGB10: // 3-component 10:10:10, unsigned normalized - pFormatSize->flags = KTX_FORMAT_SIZE_PACKED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 32; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case GL_RGB12: // 3-component 12:12:12, unsigned normalized - pFormatSize->flags = KTX_FORMAT_SIZE_PACKED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 36; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case GL_RGBA2: // 4-component 2:2:2:2, unsigned normalized - pFormatSize->flags = KTX_FORMAT_SIZE_PACKED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 8; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case GL_RGBA4: // 4-component 4:4:4:4, unsigned normalized - pFormatSize->flags = KTX_FORMAT_SIZE_PACKED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 16; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case GL_RGBA12: // 4-component 12:12:12:12, unsigned normalized - pFormatSize->flags = KTX_FORMAT_SIZE_PACKED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 48; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case GL_RGB5_A1: // 4-component 5:5:5:1, unsigned normalized - pFormatSize->flags = KTX_FORMAT_SIZE_PACKED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 32; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case GL_RGB10_A2: // 4-component 10:10:10:2, unsigned normalized - pFormatSize->flags = KTX_FORMAT_SIZE_PACKED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 32; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case GL_RGB10_A2UI: // 4-component 10:10:10:2, unsigned integer - pFormatSize->flags = KTX_FORMAT_SIZE_PACKED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 32; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case GL_R11F_G11F_B10F: // 3-component 11:11:10, floating-point - case GL_RGB9_E5: // 3-component/exp 9:9:9/5, floating-point - pFormatSize->flags = KTX_FORMAT_SIZE_PACKED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 32; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - - // - // S3TC/DXT/BC - // - case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: // line through 3D space, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: // line through 3D space plus 1-bit alpha, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: // line through 3D space, 4x4 blocks, sRGB - case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: // line through 3D space plus 1-bit alpha, 4x4 blocks, sRGB - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 64; - pFormatSize->blockWidth = 4; - pFormatSize->blockHeight = 4; - pFormatSize->blockDepth = 1; - break; - case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: // line through 3D space plus line through 1D space, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: // line through 3D space plus 4-bit alpha, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: // line through 3D space plus line through 1D space, 4x4 blocks, sRGB - case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: // line through 3D space plus 4-bit alpha, 4x4 blocks, sRGB - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 128; - pFormatSize->blockWidth = 4; - pFormatSize->blockHeight = 4; - pFormatSize->blockDepth = 1; - break; - - case GL_COMPRESSED_LUMINANCE_LATC1_EXT: // line through 1D space, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT: // line through 1D space, 4x4 blocks, signed normalized - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 64; - pFormatSize->blockWidth = 4; - pFormatSize->blockHeight = 4; - pFormatSize->blockDepth = 1; - break; - case GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT: // two lines through 1D space, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT: // two lines through 1D space, 4x4 blocks, signed normalized - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 128; - pFormatSize->blockWidth = 4; - pFormatSize->blockHeight = 4; - pFormatSize->blockDepth = 1; - break; - - case GL_COMPRESSED_RED_RGTC1: // line through 1D space, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_SIGNED_RED_RGTC1: // line through 1D space, 4x4 blocks, signed normalized - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 64; - pFormatSize->blockWidth = 4; - pFormatSize->blockHeight = 4; - pFormatSize->blockDepth = 1; - break; - case GL_COMPRESSED_RG_RGTC2: // two lines through 1D space, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_SIGNED_RG_RGTC2: // two lines through 1D space, 4x4 blocks, signed normalized - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 128; - pFormatSize->blockWidth = 4; - pFormatSize->blockHeight = 4; - pFormatSize->blockDepth = 1; - break; - - case GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT: // 3-component, 4x4 blocks, unsigned floating-point - case GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT: // 3-component, 4x4 blocks, signed floating-point - case GL_COMPRESSED_RGBA_BPTC_UNORM: // 4-component, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM: // 4-component, 4x4 blocks, sRGB - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 128; - pFormatSize->blockWidth = 4; - pFormatSize->blockHeight = 4; - pFormatSize->blockDepth = 1; - break; - - // - // ETC - // - case GL_ETC1_RGB8_OES: // 3-component ETC1, 4x4 blocks, unsigned normalized" ), - case GL_COMPRESSED_RGB8_ETC2: // 3-component ETC2, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_SRGB8_ETC2: // 3-component ETC2, 4x4 blocks, sRGB - case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: // 4-component ETC2 with 1-bit alpha, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: // 4-component ETC2 with 1-bit alpha, 4x4 blocks, sRGB - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 64; - pFormatSize->blockWidth = 4; - pFormatSize->blockHeight = 4; - pFormatSize->blockDepth = 1; - break; - case GL_COMPRESSED_RGBA8_ETC2_EAC: // 4-component ETC2, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: // 4-component ETC2, 4x4 blocks, sRGB - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 128; - pFormatSize->blockWidth = 4; - pFormatSize->blockHeight = 4; - pFormatSize->blockDepth = 1; - break; - - case GL_COMPRESSED_R11_EAC: // 1-component ETC, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_SIGNED_R11_EAC: // 1-component ETC, 4x4 blocks, signed normalized - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 64; - pFormatSize->blockWidth = 4; - pFormatSize->blockHeight = 4; - pFormatSize->blockDepth = 1; - break; - case GL_COMPRESSED_RG11_EAC: // 2-component ETC, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_SIGNED_RG11_EAC: // 2-component ETC, 4x4 blocks, signed normalized - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 128; - pFormatSize->blockWidth = 4; - pFormatSize->blockHeight = 4; - pFormatSize->blockDepth = 1; - break; - - // - // PVRTC - // - case GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG: // 3-component PVRTC, 8x4 blocks, unsigned normalized - case GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT: // 3-component PVRTC, 8x4 blocks, sRGB - case GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: // 4-component PVRTC, 8x4 blocks, unsigned normalized - case GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT: // 4-component PVRTC, 8x4 blocks, sRGB - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 64; - pFormatSize->blockWidth = 8; - pFormatSize->blockHeight = 4; - pFormatSize->blockDepth = 1; - pFormatSize->minBlocksX = 2; - pFormatSize->minBlocksY = 2; - break; - case GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG: // 3-component PVRTC, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT: // 3-component PVRTC, 4x4 blocks, sRGB - case GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: // 4-component PVRTC, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT: // 4-component PVRTC, 4x4 blocks, sRGB - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 64; - pFormatSize->blockWidth = 4; - pFormatSize->blockHeight = 4; - pFormatSize->blockDepth = 1; - pFormatSize->minBlocksX = 2; - pFormatSize->minBlocksY = 2; - break; - case GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG: // 4-component PVRTC, 8x4 blocks, unsigned normalized - case GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV2_IMG: // 4-component PVRTC, 8x4 blocks, sRGB - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 64; - pFormatSize->blockWidth = 8; - pFormatSize->blockHeight = 4; - pFormatSize->blockDepth = 1; - break; - case GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG: // 4-component PVRTC, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV2_IMG: // 4-component PVRTC, 4x4 blocks, sRGB - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 64; - pFormatSize->blockWidth = 4; - pFormatSize->blockHeight = 4; - pFormatSize->blockDepth = 1; - break; - - // - // ASTC - // - case GL_COMPRESSED_RGBA_ASTC_4x4_KHR: // 4-component ASTC, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR: // 4-component ASTC, 4x4 blocks, sRGB - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 128; - pFormatSize->blockWidth = 4; - pFormatSize->blockHeight = 4; - pFormatSize->blockDepth = 1; - break; - case GL_COMPRESSED_RGBA_ASTC_5x4_KHR: // 4-component ASTC, 5x4 blocks, unsigned normalized - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR: // 4-component ASTC, 5x4 blocks, sRGB - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 128; - pFormatSize->blockWidth = 5; - pFormatSize->blockHeight = 4; - pFormatSize->blockDepth = 1; - break; - case GL_COMPRESSED_RGBA_ASTC_5x5_KHR: // 4-component ASTC, 5x5 blocks, unsigned normalized - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR: // 4-component ASTC, 5x5 blocks, sRGB - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 128; - pFormatSize->blockWidth = 5; - pFormatSize->blockHeight = 5; - pFormatSize->blockDepth = 1; - break; - case GL_COMPRESSED_RGBA_ASTC_6x5_KHR: // 4-component ASTC, 6x5 blocks, unsigned normalized - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR: // 4-component ASTC, 6x5 blocks, sRGB - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 128; - pFormatSize->blockWidth = 6; - pFormatSize->blockHeight = 5; - pFormatSize->blockDepth = 1; - break; - case GL_COMPRESSED_RGBA_ASTC_6x6_KHR: // 4-component ASTC, 6x6 blocks, unsigned normalized - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR: // 4-component ASTC, 6x6 blocks, sRGB - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 128; - pFormatSize->blockWidth = 6; - pFormatSize->blockHeight = 6; - pFormatSize->blockDepth = 1; - break; - case GL_COMPRESSED_RGBA_ASTC_8x5_KHR: // 4-component ASTC, 8x5 blocks, unsigned normalized - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR: // 4-component ASTC, 8x5 blocks, sRGB - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 128; - pFormatSize->blockWidth = 8; - pFormatSize->blockHeight = 5; - pFormatSize->blockDepth = 1; - break; - case GL_COMPRESSED_RGBA_ASTC_8x6_KHR: // 4-component ASTC, 8x6 blocks, unsigned normalized - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR: // 4-component ASTC, 8x6 blocks, sRGB - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 128; - pFormatSize->blockWidth = 8; - pFormatSize->blockHeight = 6; - pFormatSize->blockDepth = 1; - break; - case GL_COMPRESSED_RGBA_ASTC_8x8_KHR: // 4-component ASTC, 8x8 blocks, unsigned normalized - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR: // 4-component ASTC, 8x8 blocks, sRGB - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 128; - pFormatSize->blockWidth = 8; - pFormatSize->blockHeight = 8; - pFormatSize->blockDepth = 1; - break; - case GL_COMPRESSED_RGBA_ASTC_10x5_KHR: // 4-component ASTC, 10x5 blocks, unsigned normalized - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR: // 4-component ASTC, 10x5 blocks, sRGB - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 128; - pFormatSize->blockWidth = 10; - pFormatSize->blockHeight = 5; - pFormatSize->blockDepth = 1; - break; - case GL_COMPRESSED_RGBA_ASTC_10x6_KHR: // 4-component ASTC, 10x6 blocks, unsigned normalized - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR: // 4-component ASTC, 10x6 blocks, sRGB - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 128; - pFormatSize->blockWidth = 10; - pFormatSize->blockHeight = 6; - pFormatSize->blockDepth = 1; - break; - case GL_COMPRESSED_RGBA_ASTC_10x8_KHR: // 4-component ASTC, 10x8 blocks, unsigned normalized - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR: // 4-component ASTC, 10x8 blocks, sRGB - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 128; - pFormatSize->blockWidth = 10; - pFormatSize->blockHeight = 8; - pFormatSize->blockDepth = 1; - break; - case GL_COMPRESSED_RGBA_ASTC_10x10_KHR: // 4-component ASTC, 10x10 blocks, unsigned normalized - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR: // 4-component ASTC, 10x10 blocks, sRGB - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 128; - pFormatSize->blockWidth = 10; - pFormatSize->blockHeight = 10; - pFormatSize->blockDepth = 1; - break; - case GL_COMPRESSED_RGBA_ASTC_12x10_KHR: // 4-component ASTC, 12x10 blocks, unsigned normalized - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR: // 4-component ASTC, 12x10 blocks, sRGB - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 128; - pFormatSize->blockWidth = 12; - pFormatSize->blockHeight = 10; - pFormatSize->blockDepth = 1; - break; - case GL_COMPRESSED_RGBA_ASTC_12x12_KHR: // 4-component ASTC, 12x12 blocks, unsigned normalized - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR: // 4-component ASTC, 12x12 blocks, sRGB - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 128; - pFormatSize->blockWidth = 12; - pFormatSize->blockHeight = 12; - pFormatSize->blockDepth = 1; - break; - - case GL_COMPRESSED_RGBA_ASTC_3x3x3_OES: // 4-component ASTC, 3x3x3 blocks, unsigned normalized - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_3x3x3_OES: // 4-component ASTC, 3x3x3 blocks, sRGB - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 128; - pFormatSize->blockWidth = 3; - pFormatSize->blockHeight = 3; - pFormatSize->blockDepth = 3; - break; - case GL_COMPRESSED_RGBA_ASTC_4x3x3_OES: // 4-component ASTC, 4x3x3 blocks, unsigned normalized - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x3x3_OES: // 4-component ASTC, 4x3x3 blocks, sRGB - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 128; - pFormatSize->blockWidth = 4; - pFormatSize->blockHeight = 3; - pFormatSize->blockDepth = 3; - break; - case GL_COMPRESSED_RGBA_ASTC_4x4x3_OES: // 4-component ASTC, 4x4x3 blocks, unsigned normalized - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x3_OES: // 4-component ASTC, 4x4x3 blocks, sRGB - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 128; - pFormatSize->blockWidth = 4; - pFormatSize->blockHeight = 4; - pFormatSize->blockDepth = 3; - break; - case GL_COMPRESSED_RGBA_ASTC_4x4x4_OES: // 4-component ASTC, 4x4x4 blocks, unsigned normalized - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x4_OES: // 4-component ASTC, 4x4x4 blocks, sRGB - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 128; - pFormatSize->blockWidth = 4; - pFormatSize->blockHeight = 4; - pFormatSize->blockDepth = 4; - break; - case GL_COMPRESSED_RGBA_ASTC_5x4x4_OES: // 4-component ASTC, 5x4x4 blocks, unsigned normalized - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4x4_OES: // 4-component ASTC, 5x4x4 blocks, sRGB - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 128; - pFormatSize->blockWidth = 5; - pFormatSize->blockHeight = 4; - pFormatSize->blockDepth = 4; - break; - case GL_COMPRESSED_RGBA_ASTC_5x5x4_OES: // 4-component ASTC, 5x5x4 blocks, unsigned normalized - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x4_OES: // 4-component ASTC, 5x5x4 blocks, sRGB - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 128; - pFormatSize->blockWidth = 5; - pFormatSize->blockHeight = 5; - pFormatSize->blockDepth = 4; - break; - case GL_COMPRESSED_RGBA_ASTC_5x5x5_OES: // 4-component ASTC, 5x5x5 blocks, unsigned normalized - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x5_OES: // 4-component ASTC, 5x5x5 blocks, sRGB - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 128; - pFormatSize->blockWidth = 5; - pFormatSize->blockHeight = 5; - pFormatSize->blockDepth = 5; - break; - case GL_COMPRESSED_RGBA_ASTC_6x5x5_OES: // 4-component ASTC, 6x5x5 blocks, unsigned normalized - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5x5_OES: // 4-component ASTC, 6x5x5 blocks, sRGB - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 128; - pFormatSize->blockWidth = 6; - pFormatSize->blockHeight = 5; - pFormatSize->blockDepth = 5; - break; - case GL_COMPRESSED_RGBA_ASTC_6x6x5_OES: // 4-component ASTC, 6x6x5 blocks, unsigned normalized - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x5_OES: // 4-component ASTC, 6x6x5 blocks, sRGB - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 128; - pFormatSize->blockWidth = 6; - pFormatSize->blockHeight = 6; - pFormatSize->blockDepth = 5; - break; - case GL_COMPRESSED_RGBA_ASTC_6x6x6_OES: // 4-component ASTC, 6x6x6 blocks, unsigned normalized - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x6_OES: // 4-component ASTC, 6x6x6 blocks, sRGB - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 128; - pFormatSize->blockWidth = 6; - pFormatSize->blockHeight = 6; - pFormatSize->blockDepth = 6; - break; - - // - // ATC - // - case GL_ATC_RGB_AMD: // 3-component, 4x4 blocks, unsigned normalized - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 64; - pFormatSize->blockWidth = 4; - pFormatSize->blockHeight = 4; - pFormatSize->blockDepth = 1; - break; - case GL_ATC_RGBA_EXPLICIT_ALPHA_AMD: // 4-component, 4x4 blocks, unsigned normalized - case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD: // 4-component, 4x4 blocks, unsigned normalized - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 128; - pFormatSize->blockWidth = 4; - pFormatSize->blockHeight = 4; - pFormatSize->blockDepth = 1; - break; - - // - // Palletized - // - case GL_PALETTE4_RGB8_OES: // 3-component 8:8:8, 4-bit palette, unsigned normalized - pFormatSize->flags = KTX_FORMAT_SIZE_PALETTIZED_BIT; - pFormatSize->paletteSizeInBits = 16 * 24; - pFormatSize->blockSizeInBits = 4; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case GL_PALETTE4_RGBA8_OES: // 4-component 8:8:8:8, 4-bit palette, unsigned normalized - pFormatSize->flags = KTX_FORMAT_SIZE_PALETTIZED_BIT; - pFormatSize->paletteSizeInBits = 16 * 32; - pFormatSize->blockSizeInBits = 4; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case GL_PALETTE4_R5_G6_B5_OES: // 3-component 5:6:5, 4-bit palette, unsigned normalized - case GL_PALETTE4_RGBA4_OES: // 4-component 4:4:4:4, 4-bit palette, unsigned normalized - case GL_PALETTE4_RGB5_A1_OES: // 4-component 5:5:5:1, 4-bit palette, unsigned normalized - pFormatSize->flags = KTX_FORMAT_SIZE_PALETTIZED_BIT; - pFormatSize->paletteSizeInBits = 16 * 16; - pFormatSize->blockSizeInBits = 4; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case GL_PALETTE8_RGB8_OES: // 3-component 8:8:8, 8-bit palette, unsigned normalized - pFormatSize->flags = KTX_FORMAT_SIZE_PALETTIZED_BIT; - pFormatSize->paletteSizeInBits = 256 * 24; - pFormatSize->blockSizeInBits = 8; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case GL_PALETTE8_RGBA8_OES: // 4-component 8:8:8:8, 8-bit palette, unsigned normalized - pFormatSize->flags = KTX_FORMAT_SIZE_PALETTIZED_BIT; - pFormatSize->paletteSizeInBits = 256 * 32; - pFormatSize->blockSizeInBits = 8; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case GL_PALETTE8_R5_G6_B5_OES: // 3-component 5:6:5, 8-bit palette, unsigned normalized - case GL_PALETTE8_RGBA4_OES: // 4-component 4:4:4:4, 8-bit palette, unsigned normalized - case GL_PALETTE8_RGB5_A1_OES: // 4-component 5:5:5:1, 8-bit palette, unsigned normalized - pFormatSize->flags = KTX_FORMAT_SIZE_PALETTIZED_BIT; - pFormatSize->paletteSizeInBits = 256 * 16; - pFormatSize->blockSizeInBits = 8; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - - // - // Depth/stencil - // - case GL_DEPTH_COMPONENT16: - pFormatSize->flags = KTX_FORMAT_SIZE_DEPTH_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 16; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case GL_DEPTH_COMPONENT24: - case GL_DEPTH_COMPONENT32: - case GL_DEPTH_COMPONENT32F: - case GL_DEPTH_COMPONENT32F_NV: - pFormatSize->flags = KTX_FORMAT_SIZE_DEPTH_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 32; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case GL_STENCIL_INDEX1: - pFormatSize->flags = KTX_FORMAT_SIZE_STENCIL_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 1; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case GL_STENCIL_INDEX4: - pFormatSize->flags = KTX_FORMAT_SIZE_STENCIL_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 4; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case GL_STENCIL_INDEX8: - pFormatSize->flags = KTX_FORMAT_SIZE_STENCIL_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 8; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case GL_STENCIL_INDEX16: - pFormatSize->flags = KTX_FORMAT_SIZE_STENCIL_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 16; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case GL_DEPTH24_STENCIL8: - pFormatSize->flags = KTX_FORMAT_SIZE_DEPTH_BIT | KTX_FORMAT_SIZE_STENCIL_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 32; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case GL_DEPTH32F_STENCIL8: - case GL_DEPTH32F_STENCIL8_NV: - pFormatSize->flags = KTX_FORMAT_SIZE_DEPTH_BIT | KTX_FORMAT_SIZE_STENCIL_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 64; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - - default: - pFormatSize->flags = 0; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 0 * 8; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - } +static inline void +glGetFormatSize(const GLenum internalFormat, ktxFormatSize* pFormatSize) { + pFormatSize->minBlocksX = pFormatSize->minBlocksY = 1; + switch (internalFormat) { + // + // 8 bits per component + // + case GL_R8: // 1-component, 8-bit unsigned normalized + case GL_R8_SNORM: // 1-component, 8-bit signed normalized + case GL_R8UI: // 1-component, 8-bit unsigned integer + case GL_R8I: // 1-component, 8-bit signed integer + case GL_SR8: // 1-component, 8-bit sRGB + pFormatSize->flags = 0; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 1 * 8; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case GL_RG8: // 2-component, 8-bit unsigned normalized + case GL_RG8_SNORM: // 2-component, 8-bit signed normalized + case GL_RG8UI: // 2-component, 8-bit unsigned integer + case GL_RG8I: // 2-component, 8-bit signed integer + case GL_SRG8: // 2-component, 8-bit sRGB + pFormatSize->flags = 0; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 2 * 8; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case GL_RGB8: // 3-component, 8-bit unsigned normalized + case GL_RGB8_SNORM: // 3-component, 8-bit signed normalized + case GL_RGB8UI: // 3-component, 8-bit unsigned integer + case GL_RGB8I: // 3-component, 8-bit signed integer + case GL_SRGB8: // 3-component, 8-bit sRGB + pFormatSize->flags = 0; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 3 * 8; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case GL_RGBA8: // 4-component, 8-bit unsigned normalized + case GL_RGBA8_SNORM: // 4-component, 8-bit signed normalized + case GL_RGBA8UI: // 4-component, 8-bit unsigned integer + case GL_RGBA8I: // 4-component, 8-bit signed integer + case GL_SRGB8_ALPHA8: // 4-component, 8-bit sRGB + pFormatSize->flags = 0; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 4 * 8; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + + // + // 16 bits per component + // + case GL_R16: // 1-component, 16-bit unsigned normalized + case GL_R16_SNORM: // 1-component, 16-bit signed normalized + case GL_R16UI: // 1-component, 16-bit unsigned integer + case GL_R16I: // 1-component, 16-bit signed integer + case GL_R16F: // 1-component, 16-bit floating-point + pFormatSize->flags = 0; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 2 * 8; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case GL_RG16: // 2-component, 16-bit unsigned normalized + case GL_RG16_SNORM: // 2-component, 16-bit signed normalized + case GL_RG16UI: // 2-component, 16-bit unsigned integer + case GL_RG16I: // 2-component, 16-bit signed integer + case GL_RG16F: // 2-component, 16-bit floating-point + pFormatSize->flags = 0; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 4 * 8; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case GL_RGB16: // 3-component, 16-bit unsigned normalized + case GL_RGB16_SNORM: // 3-component, 16-bit signed normalized + case GL_RGB16UI: // 3-component, 16-bit unsigned integer + case GL_RGB16I: // 3-component, 16-bit signed integer + case GL_RGB16F: // 3-component, 16-bit floating-point + pFormatSize->flags = 0; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 6 * 8; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case GL_RGBA16: // 4-component, 16-bit unsigned normalized + case GL_RGBA16_SNORM: // 4-component, 16-bit signed normalized + case GL_RGBA16UI: // 4-component, 16-bit unsigned integer + case GL_RGBA16I: // 4-component, 16-bit signed integer + case GL_RGBA16F: // 4-component, 16-bit floating-point + pFormatSize->flags = 0; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 8 * 8; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + + // + // 32 bits per component + // + case GL_R32UI: // 1-component, 32-bit unsigned integer + case GL_R32I: // 1-component, 32-bit signed integer + case GL_R32F: // 1-component, 32-bit floating-point + pFormatSize->flags = 0; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 4 * 8; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case GL_RG32UI: // 2-component, 32-bit unsigned integer + case GL_RG32I: // 2-component, 32-bit signed integer + case GL_RG32F: // 2-component, 32-bit floating-point + pFormatSize->flags = 0; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 8 * 8; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case GL_RGB32UI: // 3-component, 32-bit unsigned integer + case GL_RGB32I: // 3-component, 32-bit signed integer + case GL_RGB32F: // 3-component, 32-bit floating-point + pFormatSize->flags = 0; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 12 * 8; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case GL_RGBA32UI: // 4-component, 32-bit unsigned integer + case GL_RGBA32I: // 4-component, 32-bit signed integer + case GL_RGBA32F: // 4-component, 32-bit floating-point + pFormatSize->flags = 0; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 16 * 8; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + + // + // Packed + // + case GL_R3_G3_B2: // 3-component 3:3:2, unsigned normalized + pFormatSize->flags = KTX_FORMAT_SIZE_PACKED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 8; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case GL_RGB4: // 3-component 4:4:4, unsigned normalized + pFormatSize->flags = KTX_FORMAT_SIZE_PACKED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 12; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case GL_RGB5: // 3-component 5:5:5, unsigned normalized + pFormatSize->flags = KTX_FORMAT_SIZE_PACKED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 16; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case GL_RGB565: // 3-component 5:6:5, unsigned normalized + pFormatSize->flags = KTX_FORMAT_SIZE_PACKED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 16; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case GL_RGB10: // 3-component 10:10:10, unsigned normalized + pFormatSize->flags = KTX_FORMAT_SIZE_PACKED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 32; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case GL_RGB12: // 3-component 12:12:12, unsigned normalized + pFormatSize->flags = KTX_FORMAT_SIZE_PACKED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 36; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case GL_RGBA2: // 4-component 2:2:2:2, unsigned normalized + pFormatSize->flags = KTX_FORMAT_SIZE_PACKED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 8; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case GL_RGBA4: // 4-component 4:4:4:4, unsigned normalized + pFormatSize->flags = KTX_FORMAT_SIZE_PACKED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 16; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case GL_RGBA12: // 4-component 12:12:12:12, unsigned normalized + pFormatSize->flags = KTX_FORMAT_SIZE_PACKED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 48; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case GL_RGB5_A1: // 4-component 5:5:5:1, unsigned normalized + pFormatSize->flags = KTX_FORMAT_SIZE_PACKED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 32; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case GL_RGB10_A2: // 4-component 10:10:10:2, unsigned normalized + pFormatSize->flags = KTX_FORMAT_SIZE_PACKED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 32; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case GL_RGB10_A2UI: // 4-component 10:10:10:2, unsigned integer + pFormatSize->flags = KTX_FORMAT_SIZE_PACKED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 32; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case GL_R11F_G11F_B10F: // 3-component 11:11:10, floating-point + case GL_RGB9_E5: // 3-component/exp 9:9:9/5, floating-point + pFormatSize->flags = KTX_FORMAT_SIZE_PACKED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 32; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + + // + // S3TC/DXT/BC + // + case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: // line through 3D space, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: // line through 3D space plus 1-bit alpha, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: // line through 3D space, 4x4 blocks, sRGB + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: // line through 3D space plus 1-bit alpha, 4x4 blocks, sRGB + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 64; + pFormatSize->blockWidth = 4; + pFormatSize->blockHeight = 4; + pFormatSize->blockDepth = 1; + break; + case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: // line through 3D space plus line through 1D space, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: // line through 3D space plus 4-bit alpha, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: // line through 3D space plus line through 1D space, 4x4 blocks, sRGB + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: // line through 3D space plus 4-bit alpha, 4x4 blocks, sRGB + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 128; + pFormatSize->blockWidth = 4; + pFormatSize->blockHeight = 4; + pFormatSize->blockDepth = 1; + break; + + case GL_COMPRESSED_LUMINANCE_LATC1_EXT: // line through 1D space, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT: // line through 1D space, 4x4 blocks, signed normalized + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 64; + pFormatSize->blockWidth = 4; + pFormatSize->blockHeight = 4; + pFormatSize->blockDepth = 1; + break; + case GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT: // two lines through 1D space, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT: // two lines through 1D space, 4x4 blocks, signed normalized + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 128; + pFormatSize->blockWidth = 4; + pFormatSize->blockHeight = 4; + pFormatSize->blockDepth = 1; + break; + + case GL_COMPRESSED_RED_RGTC1: // line through 1D space, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_SIGNED_RED_RGTC1: // line through 1D space, 4x4 blocks, signed normalized + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 64; + pFormatSize->blockWidth = 4; + pFormatSize->blockHeight = 4; + pFormatSize->blockDepth = 1; + break; + case GL_COMPRESSED_RG_RGTC2: // two lines through 1D space, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_SIGNED_RG_RGTC2: // two lines through 1D space, 4x4 blocks, signed normalized + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 128; + pFormatSize->blockWidth = 4; + pFormatSize->blockHeight = 4; + pFormatSize->blockDepth = 1; + break; + + case GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT: // 3-component, 4x4 blocks, unsigned floating-point + case GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT: // 3-component, 4x4 blocks, signed floating-point + case GL_COMPRESSED_RGBA_BPTC_UNORM: // 4-component, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM: // 4-component, 4x4 blocks, sRGB + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 128; + pFormatSize->blockWidth = 4; + pFormatSize->blockHeight = 4; + pFormatSize->blockDepth = 1; + break; + + // + // ETC + // + case GL_ETC1_RGB8_OES: // 3-component ETC1, 4x4 blocks, unsigned normalized" ), + case GL_COMPRESSED_RGB8_ETC2: // 3-component ETC2, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_SRGB8_ETC2: // 3-component ETC2, 4x4 blocks, sRGB + case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: // 4-component ETC2 with 1-bit alpha, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: // 4-component ETC2 with 1-bit alpha, 4x4 blocks, sRGB + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 64; + pFormatSize->blockWidth = 4; + pFormatSize->blockHeight = 4; + pFormatSize->blockDepth = 1; + break; + case GL_COMPRESSED_RGBA8_ETC2_EAC: // 4-component ETC2, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: // 4-component ETC2, 4x4 blocks, sRGB + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 128; + pFormatSize->blockWidth = 4; + pFormatSize->blockHeight = 4; + pFormatSize->blockDepth = 1; + break; + + case GL_COMPRESSED_R11_EAC: // 1-component ETC, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_SIGNED_R11_EAC: // 1-component ETC, 4x4 blocks, signed normalized + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 64; + pFormatSize->blockWidth = 4; + pFormatSize->blockHeight = 4; + pFormatSize->blockDepth = 1; + break; + case GL_COMPRESSED_RG11_EAC: // 2-component ETC, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_SIGNED_RG11_EAC: // 2-component ETC, 4x4 blocks, signed normalized + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 128; + pFormatSize->blockWidth = 4; + pFormatSize->blockHeight = 4; + pFormatSize->blockDepth = 1; + break; + + // + // PVRTC + // + case GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG: // 3-component PVRTC, 8x4 blocks, unsigned normalized + case GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT: // 3-component PVRTC, 8x4 blocks, sRGB + case GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: // 4-component PVRTC, 8x4 blocks, unsigned normalized + case GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT: // 4-component PVRTC, 8x4 blocks, sRGB + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 64; + pFormatSize->blockWidth = 8; + pFormatSize->blockHeight = 4; + pFormatSize->blockDepth = 1; + pFormatSize->minBlocksX = 2; + pFormatSize->minBlocksY = 2; + break; + case GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG: // 3-component PVRTC, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT: // 3-component PVRTC, 4x4 blocks, sRGB + case GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: // 4-component PVRTC, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT: // 4-component PVRTC, 4x4 blocks, sRGB + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 64; + pFormatSize->blockWidth = 4; + pFormatSize->blockHeight = 4; + pFormatSize->blockDepth = 1; + pFormatSize->minBlocksX = 2; + pFormatSize->minBlocksY = 2; + break; + case GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG: // 4-component PVRTC, 8x4 blocks, unsigned normalized + case GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV2_IMG: // 4-component PVRTC, 8x4 blocks, sRGB + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 64; + pFormatSize->blockWidth = 8; + pFormatSize->blockHeight = 4; + pFormatSize->blockDepth = 1; + break; + case GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG: // 4-component PVRTC, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV2_IMG: // 4-component PVRTC, 4x4 blocks, sRGB + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 64; + pFormatSize->blockWidth = 4; + pFormatSize->blockHeight = 4; + pFormatSize->blockDepth = 1; + break; + + // + // ASTC + // + case GL_COMPRESSED_RGBA_ASTC_4x4_KHR: // 4-component ASTC, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR: // 4-component ASTC, 4x4 blocks, sRGB + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 128; + pFormatSize->blockWidth = 4; + pFormatSize->blockHeight = 4; + pFormatSize->blockDepth = 1; + break; + case GL_COMPRESSED_RGBA_ASTC_5x4_KHR: // 4-component ASTC, 5x4 blocks, unsigned normalized + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR: // 4-component ASTC, 5x4 blocks, sRGB + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 128; + pFormatSize->blockWidth = 5; + pFormatSize->blockHeight = 4; + pFormatSize->blockDepth = 1; + break; + case GL_COMPRESSED_RGBA_ASTC_5x5_KHR: // 4-component ASTC, 5x5 blocks, unsigned normalized + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR: // 4-component ASTC, 5x5 blocks, sRGB + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 128; + pFormatSize->blockWidth = 5; + pFormatSize->blockHeight = 5; + pFormatSize->blockDepth = 1; + break; + case GL_COMPRESSED_RGBA_ASTC_6x5_KHR: // 4-component ASTC, 6x5 blocks, unsigned normalized + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR: // 4-component ASTC, 6x5 blocks, sRGB + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 128; + pFormatSize->blockWidth = 6; + pFormatSize->blockHeight = 5; + pFormatSize->blockDepth = 1; + break; + case GL_COMPRESSED_RGBA_ASTC_6x6_KHR: // 4-component ASTC, 6x6 blocks, unsigned normalized + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR: // 4-component ASTC, 6x6 blocks, sRGB + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 128; + pFormatSize->blockWidth = 6; + pFormatSize->blockHeight = 6; + pFormatSize->blockDepth = 1; + break; + case GL_COMPRESSED_RGBA_ASTC_8x5_KHR: // 4-component ASTC, 8x5 blocks, unsigned normalized + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR: // 4-component ASTC, 8x5 blocks, sRGB + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 128; + pFormatSize->blockWidth = 8; + pFormatSize->blockHeight = 5; + pFormatSize->blockDepth = 1; + break; + case GL_COMPRESSED_RGBA_ASTC_8x6_KHR: // 4-component ASTC, 8x6 blocks, unsigned normalized + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR: // 4-component ASTC, 8x6 blocks, sRGB + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 128; + pFormatSize->blockWidth = 8; + pFormatSize->blockHeight = 6; + pFormatSize->blockDepth = 1; + break; + case GL_COMPRESSED_RGBA_ASTC_8x8_KHR: // 4-component ASTC, 8x8 blocks, unsigned normalized + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR: // 4-component ASTC, 8x8 blocks, sRGB + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 128; + pFormatSize->blockWidth = 8; + pFormatSize->blockHeight = 8; + pFormatSize->blockDepth = 1; + break; + case GL_COMPRESSED_RGBA_ASTC_10x5_KHR: // 4-component ASTC, 10x5 blocks, unsigned normalized + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR: // 4-component ASTC, 10x5 blocks, sRGB + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 128; + pFormatSize->blockWidth = 10; + pFormatSize->blockHeight = 5; + pFormatSize->blockDepth = 1; + break; + case GL_COMPRESSED_RGBA_ASTC_10x6_KHR: // 4-component ASTC, 10x6 blocks, unsigned normalized + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR: // 4-component ASTC, 10x6 blocks, sRGB + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 128; + pFormatSize->blockWidth = 10; + pFormatSize->blockHeight = 6; + pFormatSize->blockDepth = 1; + break; + case GL_COMPRESSED_RGBA_ASTC_10x8_KHR: // 4-component ASTC, 10x8 blocks, unsigned normalized + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR: // 4-component ASTC, 10x8 blocks, sRGB + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 128; + pFormatSize->blockWidth = 10; + pFormatSize->blockHeight = 8; + pFormatSize->blockDepth = 1; + break; + case GL_COMPRESSED_RGBA_ASTC_10x10_KHR: // 4-component ASTC, 10x10 blocks, unsigned normalized + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR: // 4-component ASTC, 10x10 blocks, sRGB + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 128; + pFormatSize->blockWidth = 10; + pFormatSize->blockHeight = 10; + pFormatSize->blockDepth = 1; + break; + case GL_COMPRESSED_RGBA_ASTC_12x10_KHR: // 4-component ASTC, 12x10 blocks, unsigned normalized + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR: // 4-component ASTC, 12x10 blocks, sRGB + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 128; + pFormatSize->blockWidth = 12; + pFormatSize->blockHeight = 10; + pFormatSize->blockDepth = 1; + break; + case GL_COMPRESSED_RGBA_ASTC_12x12_KHR: // 4-component ASTC, 12x12 blocks, unsigned normalized + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR: // 4-component ASTC, 12x12 blocks, sRGB + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 128; + pFormatSize->blockWidth = 12; + pFormatSize->blockHeight = 12; + pFormatSize->blockDepth = 1; + break; + + case GL_COMPRESSED_RGBA_ASTC_3x3x3_OES: // 4-component ASTC, 3x3x3 blocks, unsigned normalized + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_3x3x3_OES: // 4-component ASTC, 3x3x3 blocks, sRGB + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 128; + pFormatSize->blockWidth = 3; + pFormatSize->blockHeight = 3; + pFormatSize->blockDepth = 3; + break; + case GL_COMPRESSED_RGBA_ASTC_4x3x3_OES: // 4-component ASTC, 4x3x3 blocks, unsigned normalized + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x3x3_OES: // 4-component ASTC, 4x3x3 blocks, sRGB + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 128; + pFormatSize->blockWidth = 4; + pFormatSize->blockHeight = 3; + pFormatSize->blockDepth = 3; + break; + case GL_COMPRESSED_RGBA_ASTC_4x4x3_OES: // 4-component ASTC, 4x4x3 blocks, unsigned normalized + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x3_OES: // 4-component ASTC, 4x4x3 blocks, sRGB + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 128; + pFormatSize->blockWidth = 4; + pFormatSize->blockHeight = 4; + pFormatSize->blockDepth = 3; + break; + case GL_COMPRESSED_RGBA_ASTC_4x4x4_OES: // 4-component ASTC, 4x4x4 blocks, unsigned normalized + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x4_OES: // 4-component ASTC, 4x4x4 blocks, sRGB + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 128; + pFormatSize->blockWidth = 4; + pFormatSize->blockHeight = 4; + pFormatSize->blockDepth = 4; + break; + case GL_COMPRESSED_RGBA_ASTC_5x4x4_OES: // 4-component ASTC, 5x4x4 blocks, unsigned normalized + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4x4_OES: // 4-component ASTC, 5x4x4 blocks, sRGB + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 128; + pFormatSize->blockWidth = 5; + pFormatSize->blockHeight = 4; + pFormatSize->blockDepth = 4; + break; + case GL_COMPRESSED_RGBA_ASTC_5x5x4_OES: // 4-component ASTC, 5x5x4 blocks, unsigned normalized + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x4_OES: // 4-component ASTC, 5x5x4 blocks, sRGB + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 128; + pFormatSize->blockWidth = 5; + pFormatSize->blockHeight = 5; + pFormatSize->blockDepth = 4; + break; + case GL_COMPRESSED_RGBA_ASTC_5x5x5_OES: // 4-component ASTC, 5x5x5 blocks, unsigned normalized + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x5_OES: // 4-component ASTC, 5x5x5 blocks, sRGB + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 128; + pFormatSize->blockWidth = 5; + pFormatSize->blockHeight = 5; + pFormatSize->blockDepth = 5; + break; + case GL_COMPRESSED_RGBA_ASTC_6x5x5_OES: // 4-component ASTC, 6x5x5 blocks, unsigned normalized + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5x5_OES: // 4-component ASTC, 6x5x5 blocks, sRGB + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 128; + pFormatSize->blockWidth = 6; + pFormatSize->blockHeight = 5; + pFormatSize->blockDepth = 5; + break; + case GL_COMPRESSED_RGBA_ASTC_6x6x5_OES: // 4-component ASTC, 6x6x5 blocks, unsigned normalized + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x5_OES: // 4-component ASTC, 6x6x5 blocks, sRGB + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 128; + pFormatSize->blockWidth = 6; + pFormatSize->blockHeight = 6; + pFormatSize->blockDepth = 5; + break; + case GL_COMPRESSED_RGBA_ASTC_6x6x6_OES: // 4-component ASTC, 6x6x6 blocks, unsigned normalized + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x6_OES: // 4-component ASTC, 6x6x6 blocks, sRGB + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 128; + pFormatSize->blockWidth = 6; + pFormatSize->blockHeight = 6; + pFormatSize->blockDepth = 6; + break; + + // + // ATC + // + case GL_ATC_RGB_AMD: // 3-component, 4x4 blocks, unsigned normalized + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 64; + pFormatSize->blockWidth = 4; + pFormatSize->blockHeight = 4; + pFormatSize->blockDepth = 1; + break; + case GL_ATC_RGBA_EXPLICIT_ALPHA_AMD: // 4-component, 4x4 blocks, unsigned normalized + case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD: // 4-component, 4x4 blocks, unsigned normalized + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 128; + pFormatSize->blockWidth = 4; + pFormatSize->blockHeight = 4; + pFormatSize->blockDepth = 1; + break; + + // + // Palletized + // + case GL_PALETTE4_RGB8_OES: // 3-component 8:8:8, 4-bit palette, unsigned normalized + pFormatSize->flags = KTX_FORMAT_SIZE_PALETTIZED_BIT; + pFormatSize->paletteSizeInBits = 16 * 24; + pFormatSize->blockSizeInBits = 4; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case GL_PALETTE4_RGBA8_OES: // 4-component 8:8:8:8, 4-bit palette, unsigned normalized + pFormatSize->flags = KTX_FORMAT_SIZE_PALETTIZED_BIT; + pFormatSize->paletteSizeInBits = 16 * 32; + pFormatSize->blockSizeInBits = 4; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case GL_PALETTE4_R5_G6_B5_OES: // 3-component 5:6:5, 4-bit palette, unsigned normalized + case GL_PALETTE4_RGBA4_OES: // 4-component 4:4:4:4, 4-bit palette, unsigned normalized + case GL_PALETTE4_RGB5_A1_OES: // 4-component 5:5:5:1, 4-bit palette, unsigned normalized + pFormatSize->flags = KTX_FORMAT_SIZE_PALETTIZED_BIT; + pFormatSize->paletteSizeInBits = 16 * 16; + pFormatSize->blockSizeInBits = 4; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case GL_PALETTE8_RGB8_OES: // 3-component 8:8:8, 8-bit palette, unsigned normalized + pFormatSize->flags = KTX_FORMAT_SIZE_PALETTIZED_BIT; + pFormatSize->paletteSizeInBits = 256 * 24; + pFormatSize->blockSizeInBits = 8; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case GL_PALETTE8_RGBA8_OES: // 4-component 8:8:8:8, 8-bit palette, unsigned normalized + pFormatSize->flags = KTX_FORMAT_SIZE_PALETTIZED_BIT; + pFormatSize->paletteSizeInBits = 256 * 32; + pFormatSize->blockSizeInBits = 8; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case GL_PALETTE8_R5_G6_B5_OES: // 3-component 5:6:5, 8-bit palette, unsigned normalized + case GL_PALETTE8_RGBA4_OES: // 4-component 4:4:4:4, 8-bit palette, unsigned normalized + case GL_PALETTE8_RGB5_A1_OES: // 4-component 5:5:5:1, 8-bit palette, unsigned normalized + pFormatSize->flags = KTX_FORMAT_SIZE_PALETTIZED_BIT; + pFormatSize->paletteSizeInBits = 256 * 16; + pFormatSize->blockSizeInBits = 8; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + + // + // Depth/stencil + // + case GL_DEPTH_COMPONENT16: + pFormatSize->flags = KTX_FORMAT_SIZE_DEPTH_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 16; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case GL_DEPTH_COMPONENT24: + case GL_DEPTH_COMPONENT32: + case GL_DEPTH_COMPONENT32F: + case GL_DEPTH_COMPONENT32F_NV: + pFormatSize->flags = KTX_FORMAT_SIZE_DEPTH_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 32; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case GL_STENCIL_INDEX1: + pFormatSize->flags = KTX_FORMAT_SIZE_STENCIL_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 1; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case GL_STENCIL_INDEX4: + pFormatSize->flags = KTX_FORMAT_SIZE_STENCIL_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 4; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case GL_STENCIL_INDEX8: + pFormatSize->flags = KTX_FORMAT_SIZE_STENCIL_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 8; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case GL_STENCIL_INDEX16: + pFormatSize->flags = KTX_FORMAT_SIZE_STENCIL_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 16; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case GL_DEPTH24_STENCIL8: + pFormatSize->flags = KTX_FORMAT_SIZE_DEPTH_BIT | KTX_FORMAT_SIZE_STENCIL_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 32; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case GL_DEPTH32F_STENCIL8: + case GL_DEPTH32F_STENCIL8_NV: + pFormatSize->flags = KTX_FORMAT_SIZE_DEPTH_BIT | KTX_FORMAT_SIZE_STENCIL_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 64; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + + default: + pFormatSize->flags = 0; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 0 * 8; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + } } -#endif // !GL_FORMAT_H +#endif // !GL_FORMAT_H diff --git a/lib/gl_funcs.c b/lib/gl_funcs.c index 8947f0e0cb..ac72d16911 100644 --- a/lib/gl_funcs.c +++ b/lib/gl_funcs.c @@ -35,7 +35,7 @@ #undef MACOS #define MACOS 1 #endif -#if defined(__APPLE__) && (defined(__arm64__) || defined (__arm__)) +#if defined(__APPLE__) && (defined(__arm64__) || defined(__arm__)) #undef IOS #define IOS 1 #endif @@ -69,21 +69,21 @@ HMODULE ktxOpenGLModuleHandle; #define GetOpenGLModuleHandle(flags) dlopen(NULL, flags) #define LoadProcAddr dlsym #define LIBRARY_NAME NULL -void* ktxOpenGLModuleHandle; +void *ktxOpenGLModuleHandle; #elif WEB -extern void* emscripten_GetProcAddress(const char *name_); -#define GetOpenGLModuleHandle(flag) (void*)0x0000ffff // Value doesn't matter. +extern void *emscripten_GetProcAddress(const char *name_); +#define GetOpenGLModuleHandle(flag) (void *)0x0000ffff // Value doesn't matter. #define LoadProcAddr(lib, proc) emscripten_GetProcAddress(proc) #define LIBRARY_NAME "unused" -void* ktxOpenGLModuleHandle; +void *ktxOpenGLModuleHandle; #else #error "Don\'t know how to load symbols on this OS." #endif -typedef void (WINAPI *PFNVOIDFUNCTION)(void); -typedef PFNVOIDFUNCTION *(WINAPI * PFNWGLGETPROCADDRESS) (const char *proc); -static PFNWGLGETPROCADDRESS wglGetProcAddressPtr; -static const char* noloadmsg = "Could not load OpenGL command: %s!\n"; +typedef void(WINAPI *PFNVOIDFUNCTION)(void); +typedef PFNVOIDFUNCTION *(WINAPI *PFNWGLGETPROCADDRESS)(const char *proc); +static PFNWGLGETPROCADDRESS wglGetProcAddressPtr; +static const char *noloadmsg = "Could not load OpenGL command: %s!\n"; /* Define pointers for functions libktx is using. */ struct glFuncPtrs gl; @@ -95,25 +95,21 @@ struct glFuncPtrs gl; // compiler thus no warning even though -pedantic is set. Since the // platform supports dlsym, conversion to function pointers must // work, despite the mandated ISO C warning. -#define GL_FUNCTION(type, func, required) \ - if ( wglGetProcAddressPtr ) \ - *(void **)(&gl.func) = wglGetProcAddressPtr(#func); \ - if ( !gl.func ) \ - *(void **)(&gl.func) = LoadProcAddr(ktxOpenGLModuleHandle, #func); \ - if ( !gl.func && required ) { \ - fprintf(stderr, noloadmsg, #func); \ - return KTX_NOT_FOUND; \ - } +#define GL_FUNCTION(type, func, required) \ + if (wglGetProcAddressPtr) *(void **)(&gl.func) = wglGetProcAddressPtr(#func); \ + if (!gl.func) *(void **)(&gl.func) = LoadProcAddr(ktxOpenGLModuleHandle, #func); \ + if (!gl.func && required) { \ + fprintf(stderr, noloadmsg, #func); \ + return KTX_NOT_FOUND; \ + } #else -#define GL_FUNCTION(type, func, required) \ - if ( wglGetProcAddressPtr ) \ - gl.func = (type)wglGetProcAddressPtr(#func); \ - if ( !gl.func) \ - gl.func = (type)LoadProcAddr(ktxOpenGLModuleHandle, #func); \ - if ( !gl.func && required) { \ - fprintf(stderr, noloadmsg, #func); \ - return KTX_NOT_FOUND; \ - } +#define GL_FUNCTION(type, func, required) \ + if (wglGetProcAddressPtr) gl.func = (type)wglGetProcAddressPtr(#func); \ + if (!gl.func) gl.func = (type)LoadProcAddr(ktxOpenGLModuleHandle, #func); \ + if (!gl.func && required) { \ + fprintf(stderr, noloadmsg, #func); \ + return KTX_NOT_FOUND; \ + } #endif #if WINDOWS @@ -124,51 +120,29 @@ ktxFindOpenGL() { // Use GetModule not LoadLibrary so we only succeed if the process // has already loaded some OpenGL library. // Check current module to see if we are statically linked to GL. - found = GetModuleHandleExA( - GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, - (LPCSTR)ktxFindOpenGL, - &module - ); + found = GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCSTR)ktxFindOpenGL, &module); if (found) { - if (LoadProcAddr(module, "glGetError") != NULL) - return module; + if (LoadProcAddr(module, "glGetError") != NULL) return module; } // Not statically linked. See what dll the process has loaded. // Emulators probably also have opengl32.lib loaded so check that last. - found = GetModuleHandleExA( - 0, - "libGLESv2.dll", - &module - ); + found = GetModuleHandleExA(0, "libGLESv2.dll", &module); if (found) return module; - found = GetModuleHandleExA( - 0, - "libGLES_CM.dll", - &module - ); + found = GetModuleHandleExA(0, "libGLES_CM.dll", &module); if (found) return module; - found = GetModuleHandleExA( - 0, - "opengl32.dll", - &module - ); + found = GetModuleHandleExA(0, "opengl32.dll", &module); if (found) { // Need wglGetProcAddr for non-OpenGL-2 functions. - wglGetProcAddressPtr = - (PFNWGLGETPROCADDRESS)LoadProcAddr(module, - "wglGetProcAddress"); - if (wglGetProcAddressPtr != NULL) - return module; + wglGetProcAddressPtr = (PFNWGLGETPROCADDRESS)LoadProcAddr(module, "wglGetProcAddress"); + if (wglGetProcAddressPtr != NULL) return module; } - return module; // Keep the compiler happy! + return module; // Keep the compiler happy! } #endif ktx_error_code_e -ktxLoadOpenGLLibrary(void) -{ - if (ktxOpenGLModuleHandle) - return KTX_SUCCESS; +ktxLoadOpenGLLibrary(void) { + if (ktxOpenGLModuleHandle) return KTX_SUCCESS; ktxOpenGLModuleHandle = GetOpenGLModuleHandle(RTLD_LAZY); if (ktxOpenGLModuleHandle == NULL) { @@ -181,7 +155,7 @@ ktxLoadOpenGLLibrary(void) #if defined(DEBUG) abort(); #else - return KTX_LIBRARY_NOT_LINKED; // So release version doesn't crash. + return KTX_LIBRARY_NOT_LINKED; // So release version doesn't crash. #endif } @@ -191,4 +165,3 @@ ktxLoadOpenGLLibrary(void) } #undef GL_FUNCTION - diff --git a/lib/gl_funcs.h b/lib/gl_funcs.h index 0c8f6ccea5..11439f0d90 100644 --- a/lib/gl_funcs.h +++ b/lib/gl_funcs.h @@ -20,7 +20,7 @@ #ifndef _GL_FUNCS_H_ #define _GL_FUNCS_H_ -#undef GL_GLEXT_PROTOTYPES // Just to be sure. +#undef GL_GLEXT_PROTOTYPES // Just to be sure. #include "GL/glcorearb.h" #include "ktx.h" @@ -61,4 +61,3 @@ extern struct glFuncPtrs { #endif #endif /* _GL_FUNCS_H_ */ - diff --git a/lib/glloader.c b/lib/glloader.c index da09738194..858b5655b2 100644 --- a/lib/glloader.c +++ b/lib/glloader.c @@ -43,14 +43,14 @@ /* * These are defined only in compatibility mode (gl.h) not glcorearb.h */ -#if !defined( GL_LUMINANCE ) -#define GL_LUMINANCE 0x1909 // deprecated +#if !defined(GL_LUMINANCE) +#define GL_LUMINANCE 0x1909 // deprecated #endif -#if !defined( GL_LUMINANCE_ALPHA ) -#define GL_LUMINANCE_ALPHA 0x190A // deprecated +#if !defined(GL_LUMINANCE_ALPHA) +#define GL_LUMINANCE_ALPHA 0x190A // deprecated #endif -#if !defined( GL_INTENSITY ) -#define GL_INTENSITY 0x8049 // deprecated +#if !defined(GL_INTENSITY) +#define GL_INTENSITY 0x8049 // deprecated #endif /* @@ -99,7 +99,7 @@ * * Only used when glGenerateMipmaps not available. */ -#define GL_GENERATE_MIPMAP 0x8191 +#define GL_GENERATE_MIPMAP 0x8191 /** * @internal @@ -123,7 +123,7 @@ */ /**@{*/ #define _NON_LEGACY_FORMATS 0x1 /*< @internal Non-legacy sized formats are supported. */ -#define _LEGACY_FORMATS 0x2 /*< @internal Legacy sized formats are supported. */ +#define _LEGACY_FORMATS 0x2 /*< @internal Legacy sized formats are supported. */ /** * @internal * @~English @@ -180,8 +180,7 @@ static GLboolean supportsMaxLevel = GL_FALSE; * @brief Check for existence of OpenGL extension */ static GLboolean -hasExtension(const char* extension) -{ +hasExtension(const char* extension) { if (gl.glGetStringi == NULL) { if (strstr(glGetString(GL_EXTENSIONS), extension) != NULL) { return GL_TRUE; @@ -193,8 +192,7 @@ hasExtension(const char* extension) glGetIntegerv(GL_NUM_EXTENSIONS, &n); for (i = 0; i < n; i++) { - if (strcmp((const char*)gl.glGetStringi(GL_EXTENSIONS, i), extension) == 0) - return GL_TRUE; + if (strcmp((const char*)gl.glGetStringi(GL_EXTENSIONS, i), extension) == 0) return GL_TRUE; } return GL_FALSE; } @@ -215,24 +213,20 @@ hasExtension(const char* extension) * @li supportsMaxLevel */ static void -discoverContextCapabilities(void) -{ +discoverContextCapabilities(void) { GLint majorVersion = 1; GLint minorVersion = 0; - if (strstr(glGetString(GL_VERSION), "GL ES") != NULL) - contextProfile = _CONTEXT_ES_PROFILE_BIT; + if (strstr(glGetString(GL_VERSION), "GL ES") != NULL) contextProfile = _CONTEXT_ES_PROFILE_BIT; // MAJOR & MINOR only introduced in GL {,ES} 3.0 glGetIntegerv(GL_MAJOR_VERSION, &majorVersion); glGetIntegerv(GL_MINOR_VERSION, &minorVersion); if (glGetError() != GL_NO_ERROR) { // < v3.0; resort to the old-fashioned way. if (contextProfile & _CONTEXT_ES_PROFILE_BIT) - sscanf(glGetString(GL_VERSION), "OpenGL ES %d.%d ", - &majorVersion, &minorVersion); + sscanf(glGetString(GL_VERSION), "OpenGL ES %d.%d ", &majorVersion, &minorVersion); else - sscanf(glGetString(GL_VERSION), "OpenGL %d.%d ", - &majorVersion, &minorVersion); + sscanf(glGetString(GL_VERSION), "OpenGL %d.%d ", &majorVersion, &minorVersion); } if (contextProfile & _CONTEXT_ES_PROFILE_BIT) { if (majorVersion < 3) { @@ -255,8 +249,7 @@ discoverContextCapabilities(void) gl.glTexImage3D = NULL; gl.glTexSubImage3D = NULL; } - if (majorVersion < 2) - gl.glGenerateMipmap = NULL; + if (majorVersion < 2) gl.glGenerateMipmap = NULL; } else { sizedFormats = _NON_LEGACY_FORMATS; @@ -276,12 +269,9 @@ discoverContextCapabilities(void) glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &contextProfile); if (glGetError() == GL_NO_ERROR) { // >= 3.2 - if (majorVersion == 3 && minorVersion < 3) - supportsSwizzle = GL_FALSE; - if ((contextProfile & GL_CONTEXT_CORE_PROFILE_BIT)) - sizedFormats &= ~_LEGACY_FORMATS; - if (majorVersion >= 4) - supportsCubeMapArrays = GL_TRUE; + if (majorVersion == 3 && minorVersion < 3) supportsSwizzle = GL_FALSE; + if ((contextProfile & GL_CONTEXT_CORE_PROFILE_BIT)) sizedFormats &= ~_LEGACY_FORMATS; + if (majorVersion >= 4) supportsCubeMapArrays = GL_TRUE; supportsMaxLevel = GL_TRUE; } else { // < 3.2 @@ -293,13 +283,11 @@ discoverContextCapabilities(void) } // R{,G]16 introduced in 3.0; R{,G}16_SNORM introduced in 3.1. if (majorVersion == 3) { - if (minorVersion == 0) - R16Formats &= ~_KTX_R16_FORMATS_SNORM; + if (minorVersion == 0) R16Formats &= ~_KTX_R16_FORMATS_SNORM; if (minorVersion < 1) { - if (hasExtension("GL_ARB_texture_query_levels")) - supportsMaxLevel = GL_TRUE; + if (hasExtension("GL_ARB_texture_query_levels")) supportsMaxLevel = GL_TRUE; } else { - supportsMaxLevel = GL_TRUE; + supportsMaxLevel = GL_TRUE; } } else if (hasExtension("GL_ARB_texture_rg")) { R16Formats &= ~_KTX_R16_FORMATS_SNORM; @@ -334,40 +322,39 @@ discoverContextCapabilities(void) * @return void unrecognized formats will be passed on to OpenGL. Any loading * error that arises will be handled in the usual way. */ -static void convertFormat(GLenum target, GLenum* pFormat, GLenum* pInternalformat) { +static void +convertFormat(GLenum target, GLenum* pFormat, GLenum* pInternalformat) { switch (*pFormat) { - case GL_ALPHA: - { - GLint swizzle[] = {GL_ZERO, GL_ZERO, GL_ZERO, GL_RED}; - *pFormat = GL_RED; - glTexParameteriv(target, GL_TEXTURE_SWIZZLE_RGBA, swizzle); - switch (*pInternalformat) { - case GL_ALPHA: - case GL_ALPHA4: - case GL_ALPHA8: - *pInternalformat = GL_R8; - break; - case GL_ALPHA12: - case GL_ALPHA16: - *pInternalformat = GL_R16; - break; - } + case GL_ALPHA: { + GLint swizzle[] = {GL_ZERO, GL_ZERO, GL_ZERO, GL_RED}; + *pFormat = GL_RED; + glTexParameteriv(target, GL_TEXTURE_SWIZZLE_RGBA, swizzle); + switch (*pInternalformat) { + case GL_ALPHA: + case GL_ALPHA4: + case GL_ALPHA8: + *pInternalformat = GL_R8; + break; + case GL_ALPHA12: + case GL_ALPHA16: + *pInternalformat = GL_R16; + break; } - case GL_LUMINANCE: - { - GLint swizzle[] = {GL_RED, GL_RED, GL_RED, GL_ONE}; - *pFormat = GL_RED; - glTexParameteriv(target, GL_TEXTURE_SWIZZLE_RGBA, swizzle); - switch (*pInternalformat) { - case GL_LUMINANCE: - case GL_LUMINANCE4: - case GL_LUMINANCE8: - *pInternalformat = GL_R8; - break; - case GL_LUMINANCE12: - case GL_LUMINANCE16: - *pInternalformat = GL_R16; - break; + } + case GL_LUMINANCE: { + GLint swizzle[] = {GL_RED, GL_RED, GL_RED, GL_ONE}; + *pFormat = GL_RED; + glTexParameteriv(target, GL_TEXTURE_SWIZZLE_RGBA, swizzle); + switch (*pInternalformat) { + case GL_LUMINANCE: + case GL_LUMINANCE4: + case GL_LUMINANCE8: + *pInternalformat = GL_R8; + break; + case GL_LUMINANCE12: + case GL_LUMINANCE16: + *pInternalformat = GL_R16; + break; #if 0 // XXX Must avoid setting TEXTURE_SWIZZLE in these cases // XXX Must manually swizzle. @@ -376,26 +363,25 @@ static void convertFormat(GLenum target, GLenum* pFormat, GLenum* pInternalforma *pInternalformat = GL_SRGB8; break; #endif - } - break; } - case GL_LUMINANCE_ALPHA: - { - GLint swizzle[] = {GL_RED, GL_RED, GL_RED, GL_GREEN}; - *pFormat = GL_RG; - glTexParameteriv(target, GL_TEXTURE_SWIZZLE_RGBA, swizzle); - switch (*pInternalformat) { - case GL_LUMINANCE_ALPHA: - case GL_LUMINANCE4_ALPHA4: - case GL_LUMINANCE6_ALPHA2: - case GL_LUMINANCE8_ALPHA8: - *pInternalformat = GL_RG8; - break; - case GL_LUMINANCE12_ALPHA4: - case GL_LUMINANCE12_ALPHA12: - case GL_LUMINANCE16_ALPHA16: - *pInternalformat = GL_RG16; - break; + break; + } + case GL_LUMINANCE_ALPHA: { + GLint swizzle[] = {GL_RED, GL_RED, GL_RED, GL_GREEN}; + *pFormat = GL_RG; + glTexParameteriv(target, GL_TEXTURE_SWIZZLE_RGBA, swizzle); + switch (*pInternalformat) { + case GL_LUMINANCE_ALPHA: + case GL_LUMINANCE4_ALPHA4: + case GL_LUMINANCE6_ALPHA2: + case GL_LUMINANCE8_ALPHA8: + *pInternalformat = GL_RG8; + break; + case GL_LUMINANCE12_ALPHA4: + case GL_LUMINANCE12_ALPHA12: + case GL_LUMINANCE16_ALPHA16: + *pInternalformat = GL_RG16; + break; #if 0 // XXX Must avoid setting TEXTURE_SWIZZLE in these cases // XXX Must manually swizzle. @@ -404,38 +390,37 @@ static void convertFormat(GLenum target, GLenum* pFormat, GLenum* pInternalforma *pInternalformat = GL_SRGB8_ALPHA8; break; #endif - } - break; } - case GL_INTENSITY: - { - GLint swizzle[] = {GL_RED, GL_RED, GL_RED, GL_RED}; - *pFormat = GL_RED; - glTexParameteriv(target, GL_TEXTURE_SWIZZLE_RGBA, swizzle); - switch (*pInternalformat) { - case GL_INTENSITY: - case GL_INTENSITY4: - case GL_INTENSITY8: - *pInternalformat = GL_R8; - break; - case GL_INTENSITY12: - case GL_INTENSITY16: - *pInternalformat = GL_R16; - break; - } - break; + break; + } + case GL_INTENSITY: { + GLint swizzle[] = {GL_RED, GL_RED, GL_RED, GL_RED}; + *pFormat = GL_RED; + glTexParameteriv(target, GL_TEXTURE_SWIZZLE_RGBA, swizzle); + switch (*pInternalformat) { + case GL_INTENSITY: + case GL_INTENSITY4: + case GL_INTENSITY8: + *pInternalformat = GL_R8; + break; + case GL_INTENSITY12: + case GL_INTENSITY16: + *pInternalformat = GL_R16; + break; } - default: + break; + } + default: break; } } #endif /* SUPPORT_LEGACY_FORMAT_CONVERSION */ typedef struct ktx_glformatinfo { - ktx_uint32_t glFormat; - ktx_uint32_t glInternalformat; - ktx_uint32_t glBaseInternalformat; - ktx_uint32_t glType; + ktx_uint32_t glFormat; + ktx_uint32_t glInternalformat; + ktx_uint32_t glBaseInternalformat; + ktx_uint32_t glType; } ktx_glformatinfo; /* [cbdata] */ @@ -452,21 +437,16 @@ typedef struct ktx_cbdata { /* [imageCallbacks] */ KTX_error_code -texImage1DCallback(int miplevel, int face, - int width, int height, - int depth, - ktx_uint64_t faceLodSize, - void* pixels, void* userdata) -{ +texImage1DCallback(int miplevel, int face, int width, int height, int depth, ktx_uint64_t faceLodSize, void* pixels, + void* userdata) { ktx_cbdata* cbData = (ktx_cbdata*)userdata; UNUSED(faceLodSize); UNUSED(depth); UNUSED(height); assert(gl.glTexImage1D != NULL); - gl.glTexImage1D(cbData->glTarget + face, miplevel, - cbData->glInternalformat, width, 0, - cbData->glFormat, cbData->glType, pixels); + gl.glTexImage1D(cbData->glTarget + face, miplevel, cbData->glInternalformat, width, 0, cbData->glFormat, cbData->glType, + pixels); if ((cbData->glError = glGetError()) == GL_NO_ERROR) { return KTX_SUCCESS; @@ -476,23 +456,17 @@ texImage1DCallback(int miplevel, int face, } KTX_error_code -compressedTexImage1DCallback(int miplevel, int face, - int width, int height, - int depth, - ktx_uint64_t faceLodSize, - void* pixels, void* userdata) -{ +compressedTexImage1DCallback(int miplevel, int face, int width, int height, int depth, ktx_uint64_t faceLodSize, void* pixels, + void* userdata) { ktx_cbdata* cbData = (ktx_cbdata*)userdata; UNUSED(depth); UNUSED(height); - if (faceLodSize > UINT32_MAX) - return KTX_INVALID_OPERATION; // Too big for OpenGL {,ES}. + if (faceLodSize > UINT32_MAX) return KTX_INVALID_OPERATION; // Too big for OpenGL {,ES}. assert(gl.glCompressedTexImage1D != NULL); - gl.glCompressedTexImage1D(cbData->glTarget + face, miplevel, - cbData->glInternalformat, width, 0, - (ktx_uint32_t)faceLodSize, pixels); + gl.glCompressedTexImage1D(cbData->glTarget + face, miplevel, cbData->glInternalformat, width, 0, (ktx_uint32_t)faceLodSize, + pixels); if ((cbData->glError = glGetError()) == GL_NO_ERROR) { return KTX_SUCCESS; @@ -502,20 +476,14 @@ compressedTexImage1DCallback(int miplevel, int face, } KTX_error_code -texImage2DCallback(int miplevel, int face, - int width, int height, - int depth, - ktx_uint64_t faceLodSize, - void* pixels, void* userdata) -{ +texImage2DCallback(int miplevel, int face, int width, int height, int depth, ktx_uint64_t faceLodSize, void* pixels, + void* userdata) { ktx_cbdata* cbData = (ktx_cbdata*)userdata; UNUSED(depth); UNUSED(faceLodSize); - glTexImage2D(cbData->glTarget + face, miplevel, - cbData->glInternalformat, width, - cbData->numLayers == 0 ? (GLuint)height : cbData->numLayers, 0, - cbData->glFormat, cbData->glType, pixels); + glTexImage2D(cbData->glTarget + face, miplevel, cbData->glInternalformat, width, + cbData->numLayers == 0 ? (GLuint)height : cbData->numLayers, 0, cbData->glFormat, cbData->glType, pixels); if ((cbData->glError = glGetError()) == GL_NO_ERROR) { return KTX_SUCCESS; @@ -524,47 +492,33 @@ texImage2DCallback(int miplevel, int face, } } - KTX_error_code -compressedTexImage2DCallback(int miplevel, int face, - int width, int height, - int depth, - ktx_uint64_t faceLodSize, - void* pixels, void* userdata) -{ +compressedTexImage2DCallback(int miplevel, int face, int width, int height, int depth, ktx_uint64_t faceLodSize, void* pixels, + void* userdata) { ktx_cbdata* cbData = (ktx_cbdata*)userdata; GLenum glerror; KTX_error_code result; UNUSED(depth); - if (faceLodSize > UINT32_MAX) - return KTX_INVALID_OPERATION; // Too big for OpenGL {,ES}. + if (faceLodSize > UINT32_MAX) return KTX_INVALID_OPERATION; // Too big for OpenGL {,ES}. // It is simpler to just attempt to load the format, rather than divine // which formats are supported by the implementation. In the event of an // error, software unpacking can be attempted. - glCompressedTexImage2D(cbData->glTarget + face, miplevel, - cbData->glInternalformat, width, - cbData->numLayers == 0 ? (GLuint)height : cbData->numLayers, - 0, - (ktx_uint32_t)faceLodSize, pixels); + glCompressedTexImage2D(cbData->glTarget + face, miplevel, cbData->glInternalformat, width, + cbData->numLayers == 0 ? (GLuint)height : cbData->numLayers, 0, (ktx_uint32_t)faceLodSize, pixels); glerror = glGetError(); #if SUPPORT_SOFTWARE_ETC_UNPACK // Renderion is returning INVALID_VALUE. Oops!! - if ((glerror == GL_INVALID_ENUM || glerror == GL_INVALID_VALUE) - && (cbData->glInternalformat == GL_ETC1_RGB8_OES - || (cbData->glInternalformat >= GL_COMPRESSED_R11_EAC - && cbData->glInternalformat <= GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC) - )) - { + if ((glerror == GL_INVALID_ENUM || glerror == GL_INVALID_VALUE) && + (cbData->glInternalformat == GL_ETC1_RGB8_OES || + (cbData->glInternalformat >= GL_COMPRESSED_R11_EAC && cbData->glInternalformat <= GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC))) { GLubyte* unpacked; GLenum format, internalformat, type; - result = _ktxUnpackETC((GLubyte*)pixels, cbData->glInternalformat, - width, height, &unpacked, - &format, &internalformat, - &type, R16Formats, supportsSRGB); + result = _ktxUnpackETC((GLubyte*)pixels, cbData->glInternalformat, width, height, &unpacked, &format, &internalformat, + &type, R16Formats, supportsSRGB); if (result != KTX_SUCCESS) { return result; } @@ -574,10 +528,8 @@ compressedTexImage2DCallback(int miplevel, int face, else if (internalformat == GL_RGBA8) internalformat = GL_RGBA; } - glTexImage2D(cbData->glTarget + face, miplevel, - internalformat, width, - cbData->numLayers == 0 ? (GLuint)height : cbData->numLayers, 0, - format, type, unpacked); + glTexImage2D(cbData->glTarget + face, miplevel, internalformat, width, + cbData->numLayers == 0 ? (GLuint)height : cbData->numLayers, 0, format, type, unpacked); free(unpacked); glerror = glGetError(); @@ -592,22 +544,14 @@ compressedTexImage2DCallback(int miplevel, int face, } KTX_error_code -texImage3DCallback(int miplevel, int face, - int width, int height, - int depth, - ktx_uint64_t faceLodSize, - void* pixels, void* userdata) -{ +texImage3DCallback(int miplevel, int face, int width, int height, int depth, ktx_uint64_t faceLodSize, void* pixels, + void* userdata) { ktx_cbdata* cbData = (ktx_cbdata*)userdata; UNUSED(faceLodSize); assert(gl.glTexImage3D != NULL); - gl.glTexImage3D(cbData->glTarget + face, miplevel, - cbData->glInternalformat, - width, height, - cbData->numLayers == 0 ? (GLuint)depth : cbData->numLayers, - 0, - cbData->glFormat, cbData->glType, pixels); + gl.glTexImage3D(cbData->glTarget + face, miplevel, cbData->glInternalformat, width, height, + cbData->numLayers == 0 ? (GLuint)depth : cbData->numLayers, 0, cbData->glFormat, cbData->glType, pixels); if ((cbData->glError = glGetError()) == GL_NO_ERROR) { return KTX_SUCCESS; @@ -617,24 +561,15 @@ texImage3DCallback(int miplevel, int face, } KTX_error_code -compressedTexImage3DCallback(int miplevel, int face, - int width, int height, - int depth, - ktx_uint64_t faceLodSize, - void* pixels, void* userdata) -{ +compressedTexImage3DCallback(int miplevel, int face, int width, int height, int depth, ktx_uint64_t faceLodSize, void* pixels, + void* userdata) { ktx_cbdata* cbData = (ktx_cbdata*)userdata; - if (faceLodSize > UINT32_MAX) - return KTX_INVALID_OPERATION; // Too big for OpenGL {,ES}. + if (faceLodSize > UINT32_MAX) return KTX_INVALID_OPERATION; // Too big for OpenGL {,ES}. assert(gl.glCompressedTexImage3D != NULL); - gl.glCompressedTexImage3D(cbData->glTarget + face, miplevel, - cbData->glInternalformat, - width, height, - cbData->numLayers == 0 ? (GLuint)depth : cbData->numLayers, - 0, - (ktx_uint32_t)faceLodSize, pixels); + gl.glCompressedTexImage3D(cbData->glTarget + face, miplevel, cbData->glInternalformat, width, height, + cbData->numLayers == 0 ? (GLuint)depth : cbData->numLayers, 0, (ktx_uint32_t)faceLodSize, pixels); if ((cbData->glError = glGetError()) == GL_NO_ERROR) { return KTX_SUCCESS; @@ -693,24 +628,20 @@ compressedTexImage3DCallback(int miplevel, int face, */ /* [loadGLTexture] */ KTX_error_code -ktxTexture_GLUploadPrivate(ktxTexture* This, ktx_glformatinfo* formatInfo, - GLuint* pTexture, GLenum* pTarget, GLenum* pGlerror) -{ - GLuint texname; - GLenum target = GL_TEXTURE_2D; - int texnameUser; - KTX_error_code result = KTX_SUCCESS; - ktx_cbdata cbData; - PFNKTXITERCB iterCb = NULL; - int dimensions; - - if (pGlerror) - *pGlerror = GL_NO_ERROR; +ktxTexture_GLUploadPrivate(ktxTexture* This, ktx_glformatinfo* formatInfo, GLuint* pTexture, GLenum* pTarget, GLenum* pGlerror) { + GLuint texname; + GLenum target = GL_TEXTURE_2D; + int texnameUser; + KTX_error_code result = KTX_SUCCESS; + ktx_cbdata cbData; + PFNKTXITERCB iterCb = NULL; + int dimensions; + + if (pGlerror) *pGlerror = GL_NO_ERROR; assert(This && pTarget); - if (contextProfile == 0) - discoverContextCapabilities(); + if (contextProfile == 0) discoverContextCapabilities(); texnameUser = pTexture && *pTexture; if (texnameUser) { @@ -732,10 +663,15 @@ ktxTexture_GLUploadPrivate(ktxTexture* This, ktx_glformatinfo* formatInfo, target = GL_TEXTURE_CUBE_MAP_ARRAY; } else { switch (This->numDimensions) { - case 1: target = GL_TEXTURE_1D_ARRAY; break; - case 2: target = GL_TEXTURE_2D_ARRAY; break; - /* _ktxCheckHeader should have caught this. */ - default: assert(KTX_TRUE); + case 1: + target = GL_TEXTURE_1D_ARRAY; + break; + case 2: + target = GL_TEXTURE_2D_ARRAY; + break; + /* _ktxCheckHeader should have caught this. */ + default: + assert(KTX_TRUE); } } cbData.numLayers = This->numLayers; @@ -746,28 +682,31 @@ ktxTexture_GLUploadPrivate(ktxTexture* This, ktx_glformatinfo* formatInfo, target = GL_TEXTURE_CUBE_MAP; } else { switch (This->numDimensions) { - case 1: target = GL_TEXTURE_1D; break; - case 2: target = GL_TEXTURE_2D; break; - case 3: target = GL_TEXTURE_3D; break; - /* _ktxCheckHeader shold have caught this. */ - default: assert(KTX_TRUE); + case 1: + target = GL_TEXTURE_1D; + break; + case 2: + target = GL_TEXTURE_2D; + break; + case 3: + target = GL_TEXTURE_3D; + break; + /* _ktxCheckHeader shold have caught this. */ + default: + assert(KTX_TRUE); } } cbData.numLayers = 0; } if (target == GL_TEXTURE_1D && - ((This->isCompressed && (gl.glCompressedTexImage1D == NULL)) || - (!This->isCompressed && (gl.glTexImage1D == NULL)))) - { + ((This->isCompressed && (gl.glCompressedTexImage1D == NULL)) || (!This->isCompressed && (gl.glTexImage1D == NULL)))) { return KTX_UNSUPPORTED_TEXTURE_TYPE; } /* Reject 3D texture if unsupported. */ if (target == GL_TEXTURE_3D && - ((This->isCompressed && (gl.glCompressedTexImage3D == NULL)) || - (!This->isCompressed && (gl.glTexImage3D == NULL)))) - { + ((This->isCompressed && (gl.glCompressedTexImage3D == NULL)) || (!This->isCompressed && (gl.glTexImage3D == NULL)))) { return KTX_UNSUPPORTED_TEXTURE_TYPE; } @@ -779,20 +718,17 @@ ktxTexture_GLUploadPrivate(ktxTexture* This, ktx_glformatinfo* formatInfo, /* XXX Need to reject other array textures & cube maps if not supported. */ switch (dimensions) { - case 1: - iterCb = This->isCompressed - ? compressedTexImage1DCallback : texImage1DCallback; + case 1: + iterCb = This->isCompressed ? compressedTexImage1DCallback : texImage1DCallback; break; - case 2: - iterCb = This->isCompressed - ? compressedTexImage2DCallback : texImage2DCallback; - break; - case 3: - iterCb = This->isCompressed - ? compressedTexImage3DCallback : texImage3DCallback; + case 2: + iterCb = This->isCompressed ? compressedTexImage2DCallback : texImage2DCallback; break; - default: - assert(KTX_TRUE); + case 3: + iterCb = This->isCompressed ? compressedTexImage3DCallback : texImage3DCallback; + break; + default: + assert(KTX_TRUE); } glBindTexture(target, texname); @@ -802,8 +738,7 @@ ktxTexture_GLUploadPrivate(ktxTexture* This, ktx_glformatinfo* formatInfo, glTexParameteri(target, GL_GENERATE_MIPMAP, GL_TRUE); } - if (!This->generateMipmaps && supportsMaxLevel) - glTexParameteri(target, GL_TEXTURE_MAX_LEVEL, This->numLevels - 1); + if (!This->generateMipmaps && supportsMaxLevel) glTexParameteri(target, GL_TEXTURE_MAX_LEVEL, This->numLevels - 1); if (target == GL_TEXTURE_CUBE_MAP) { cbData.glTarget = GL_TEXTURE_CUBE_MAP_POSITIVE_X; @@ -823,12 +758,10 @@ ktxTexture_GLUploadPrivate(ktxTexture* This, ktx_glformatinfo* formatInfo, #else // When no sized formats are supported, or legacy sized formats are not // supported, must change internal format. - if (sizedFormats == _NO_SIZED_FORMATS - || (!(sizedFormats & _LEGACY_FORMATS) && - (formatInfo->glBaseInternalformat == GL_ALPHA - || formatInfo->glBaseInternalformat == GL_LUMINANCE - || formatInfo->glBaseInternalformat == GL_LUMINANCE_ALPHA - || formatInfo->glBaseInternalformat == GL_INTENSITY))) { + if (sizedFormats == _NO_SIZED_FORMATS || + (!(sizedFormats & _LEGACY_FORMATS) && + (formatInfo->glBaseInternalformat == GL_ALPHA || formatInfo->glBaseInternalformat == GL_LUMINANCE || + formatInfo->glBaseInternalformat == GL_LUMINANCE_ALPHA || formatInfo->glBaseInternalformat == GL_INTENSITY))) { cbData.glInternalformat = formatInfo->glBaseInternalformat; } #endif @@ -841,12 +774,10 @@ ktxTexture_GLUploadPrivate(ktxTexture* This, ktx_glformatinfo* formatInfo, /* GL errors are the only reason for failure. */ if (result != KTX_SUCCESS && cbData.glError != GL_NO_ERROR) { - if (pGlerror) - *pGlerror = cbData.glError; + if (pGlerror) *pGlerror = cbData.glError; } - if (result == KTX_SUCCESS) - { + if (result == KTX_SUCCESS) { // Prefer glGenerateMipmaps over GL_GENERATE_MIPMAP if (This->generateMipmaps && gl.glGenerateMipmap) { gl.glGenerateMipmap(target); @@ -909,12 +840,10 @@ ktxTexture_GLUploadPrivate(ktxTexture* This, ktx_glformatinfo* formatInfo, * by the current OpenGL context. */ KTX_error_code -ktxTexture1_GLUpload(ktxTexture1* This, GLuint* pTexture, GLenum* pTarget, - GLenum* pGlerror) -{ - GLint previousUnpackAlignment; - KTX_error_code result = KTX_SUCCESS; - ktx_glformatinfo formatInfo; +ktxTexture1_GLUpload(ktxTexture1* This, GLuint* pTexture, GLenum* pTarget, GLenum* pGlerror) { + GLint previousUnpackAlignment; + KTX_error_code result = KTX_SUCCESS; + ktx_glformatinfo formatInfo; if (!This) { return KTX_INVALID_VALUE; @@ -940,9 +869,8 @@ ktxTexture1_GLUpload(ktxTexture1* This, GLuint* pTexture, GLenum* pTarget, formatInfo.glInternalformat = This->glInternalformat; formatInfo.glBaseInternalformat = This->glBaseInternalformat; formatInfo.glType = This->glType; - - result = ktxTexture_GLUploadPrivate(ktxTexture(This), &formatInfo, - pTexture, pTarget, pGlerror); + + result = ktxTexture_GLUploadPrivate(ktxTexture(This), &formatInfo, pTexture, pTarget, pGlerror); /* restore previous GL state */ if (previousUnpackAlignment != KTX_GL_UNPACK_ALIGNMENT) { @@ -995,12 +923,10 @@ ktxTexture1_GLUpload(ktxTexture1* This, GLuint* pTexture, GLenum* pTarget, * by the current OpenGL context. */ KTX_error_code -ktxTexture2_GLUpload(ktxTexture2* This, GLuint* pTexture, GLenum* pTarget, - GLenum* pGlerror) -{ - GLint previousUnpackAlignment; - ktx_error_code_e result = KTX_SUCCESS; - ktx_glformatinfo formatInfo; +ktxTexture2_GLUpload(ktxTexture2* This, GLuint* pTexture, GLenum* pTarget, GLenum* pGlerror) { + GLint previousUnpackAlignment; + ktx_error_code_e result = KTX_SUCCESS; + ktx_glformatinfo formatInfo; if (!This) { return KTX_INVALID_VALUE; @@ -1018,16 +944,15 @@ ktxTexture2_GLUpload(ktxTexture2* This, GLuint* pTexture, GLenum* pTarget, } if (This->vkFormat != VK_FORMAT_UNDEFINED) { - formatInfo.glInternalformat = - vkFormat2glInternalFormat(This->vkFormat); + formatInfo.glInternalformat = vkFormat2glInternalFormat(This->vkFormat); if (formatInfo.glInternalformat == GL_INVALID_VALUE) { // TODO Check for mapping metadata. If none return KTX_INVALID_OPERATION; } } else { - // TODO: Check DFD for ASTC HDR or 3D or RGB[DEM] and figure out format. - return KTX_INVALID_OPERATION; // BasisU textures must be transcoded - // before upload. + // TODO: Check DFD for ASTC HDR or 3D or RGB[DEM] and figure out format. + return KTX_INVALID_OPERATION; // BasisU textures must be transcoded + // before upload. } if (This->isCompressed) { @@ -1040,8 +965,7 @@ ktxTexture2_GLUpload(ktxTexture2* This, GLuint* pTexture, GLenum* pTarget, formatInfo.glType = vkFormat2glType(This->vkFormat); formatInfo.glBaseInternalformat = formatInfo.glInternalformat; - if (formatInfo.glFormat == GL_INVALID_VALUE || formatInfo.glType == GL_INVALID_VALUE) - return KTX_INVALID_OPERATION; + if (formatInfo.glFormat == GL_INVALID_VALUE || formatInfo.glType == GL_INVALID_VALUE) return KTX_INVALID_OPERATION; } /* KTX 2 files require an unpack alignment of 1. OGL default is 4. */ glGetIntegerv(GL_UNPACK_ALIGNMENT, &previousUnpackAlignment); @@ -1049,8 +973,7 @@ ktxTexture2_GLUpload(ktxTexture2* This, GLuint* pTexture, GLenum* pTarget, glPixelStorei(GL_UNPACK_ALIGNMENT, 1); } - result = ktxTexture_GLUploadPrivate(ktxTexture(This), &formatInfo, - pTexture, pTarget, pGlerror); + result = ktxTexture_GLUploadPrivate(ktxTexture(This), &formatInfo, pTexture, pTarget, pGlerror); /* restore previous GL state */ if (previousUnpackAlignment != 1) { @@ -1071,15 +994,11 @@ ktxTexture2_GLUpload(ktxTexture2* This, GLuint* pTexture, GLenum* pTarget, * @copydetails ktxTexture1::ktxTexture1_GLUpload */ KTX_error_code -ktxTexture_GLUpload(ktxTexture* This, GLuint* pTexture, GLenum* pTarget, - GLenum* pGlerror) -{ +ktxTexture_GLUpload(ktxTexture* This, GLuint* pTexture, GLenum* pTarget, GLenum* pGlerror) { if (This->classId == ktxTexture2_c) - return ktxTexture2_GLUpload((ktxTexture2*)This, pTexture, pTarget, - pGlerror); + return ktxTexture2_GLUpload((ktxTexture2*)This, pTexture, pTarget, pGlerror); else - return ktxTexture1_GLUpload((ktxTexture1*)This, pTexture, pTarget, - pGlerror); + return ktxTexture1_GLUpload((ktxTexture1*)This, pTexture, pTarget, pGlerror); } /** @} */ diff --git a/lib/hashlist.c b/lib/hashlist.c index acfe41e5fc..8b2aadc693 100644 --- a/lib/hashlist.c +++ b/lib/hashlist.c @@ -35,21 +35,19 @@ #include "ktx.h" #include "ktxint.h" - /** * @internal * @struct ktxKVListEntry * @brief Hash list entry structure */ typedef struct ktxKVListEntry { - unsigned int keyLen; /*!< Length of the key */ - char* key; /*!< Pointer to key string */ - unsigned int valueLen; /*!< Length of the value */ - void* value; /*!< Pointer to the value */ - UT_hash_handle hh; /*!< handle used by UT hash */ + unsigned int keyLen; /*!< Length of the key */ + char* key; /*!< Pointer to key string */ + unsigned int valueLen; /*!< Length of the value */ + void* value; /*!< Pointer to the value */ + UT_hash_handle hh; /*!< handle used by UT hash */ } ktxKVListEntry; - /** * @memberof ktxHashList @public * @~English @@ -58,12 +56,10 @@ typedef struct ktxKVListEntry { * @param [in] pHead pointer to the location to write the list head. */ void -ktxHashList_Construct(ktxHashList* pHead) -{ +ktxHashList_Construct(ktxHashList* pHead) { *pHead = NULL; } - /** * @memberof ktxHashList @public * @~English @@ -73,17 +69,14 @@ ktxHashList_Construct(ktxHashList* pHead) * @param [in] orig head of the original hash list. */ void -ktxHashList_ConstructCopy(ktxHashList* pHead, ktxHashList orig) -{ +ktxHashList_ConstructCopy(ktxHashList* pHead, ktxHashList orig) { ktxHashListEntry* entry = orig; *pHead = NULL; for (; entry != NULL; entry = ktxHashList_Next(entry)) { - (void)ktxHashList_AddKVPair(pHead, - entry->key, entry->valueLen, entry->value); + (void)ktxHashList_AddKVPair(pHead, entry->key, entry->valueLen, entry->value); } } - /** * @memberof ktxHashList @public * @~English @@ -95,12 +88,11 @@ ktxHashList_ConstructCopy(ktxHashList* pHead, ktxHashList orig) * @param [in] pHead pointer to the hash list to be destroyed. */ void -ktxHashList_Destruct(ktxHashList* pHead) -{ +ktxHashList_Destruct(ktxHashList* pHead) { ktxKVListEntry* kv; ktxKVListEntry* head = *pHead; - for(kv = head; kv != NULL;) { + for (kv = head; kv != NULL;) { ktxKVListEntry* tmp = (ktxKVListEntry*)kv->hh.next; HASH_DELETE(hh, head, kv); free(kv); @@ -108,7 +100,6 @@ ktxHashList_Destruct(ktxHashList* pHead) } } - /** * @memberof ktxHashList @public * @~English @@ -121,18 +112,15 @@ ktxHashList_Destruct(ktxHashList* pHead) * @exception KTX_OUT_OF_MEMORY if not enough memory. */ KTX_error_code -ktxHashList_Create(ktxHashList** ppHl) -{ - ktxHashList* hl = (ktxHashList*)malloc(sizeof (ktxKVListEntry*)); - if (hl == NULL) - return KTX_OUT_OF_MEMORY; +ktxHashList_Create(ktxHashList** ppHl) { + ktxHashList* hl = (ktxHashList*)malloc(sizeof(ktxKVListEntry*)); + if (hl == NULL) return KTX_OUT_OF_MEMORY; ktxHashList_Construct(hl); *ppHl = hl; return KTX_SUCCESS; } - /** * @memberof ktxHashList @public * @~English @@ -146,18 +134,15 @@ ktxHashList_Create(ktxHashList** ppHl) * @exception KTX_OUT_OF_MEMORY if not enough memory. */ KTX_error_code -ktxHashList_CreateCopy(ktxHashList** ppHl, ktxHashList orig) -{ - ktxHashList* hl = (ktxHashList*)malloc(sizeof (ktxKVListEntry*)); - if (hl == NULL) - return KTX_OUT_OF_MEMORY; +ktxHashList_CreateCopy(ktxHashList** ppHl, ktxHashList orig) { + ktxHashList* hl = (ktxHashList*)malloc(sizeof(ktxKVListEntry*)); + if (hl == NULL) return KTX_OUT_OF_MEMORY; ktxHashList_ConstructCopy(hl, orig); *ppHl = hl; return KTX_SUCCESS; } - /** * @memberof ktxHashList @public * @~English @@ -169,13 +154,12 @@ ktxHashList_CreateCopy(ktxHashList** ppHl, ktxHashList orig) * @param [in] pHead pointer to the hash list to be destroyed. */ void -ktxHashList_Destroy(ktxHashList* pHead) -{ +ktxHashList_Destroy(ktxHashList* pHead) { ktxHashList_Destruct(pHead); free(pHead); } -#if !__clang__ && __GNUC__ // Grumble clang grumble +#if !__clang__ && __GNUC__ // Grumble clang grumble // These are in uthash.h macros. I don't want to change that file. #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wimplicit-fallthrough" @@ -198,19 +182,17 @@ ktxHashList_Destroy(ktxHashList* pHead) * empty string or @p valueLen == 0. */ KTX_error_code -ktxHashList_AddKVPair(ktxHashList* pHead, const char* key, unsigned int valueLen, const void* value) -{ +ktxHashList_AddKVPair(ktxHashList* pHead, const char* key, unsigned int valueLen, const void* value) { if (pHead && key && (valueLen == 0 || value)) { unsigned int keyLen = (unsigned int)strlen(key) + 1; ktxKVListEntry* kv; - if (keyLen == 1) - return KTX_INVALID_VALUE; /* Empty string */ + if (keyLen == 1) return KTX_INVALID_VALUE; /* Empty string */ /* Allocate all the memory as a block */ kv = (ktxKVListEntry*)malloc(sizeof(ktxKVListEntry) + keyLen + valueLen); /* Put key first */ - kv->key = (char *)kv + sizeof(ktxKVListEntry); + kv->key = (char*)kv + sizeof(ktxKVListEntry); kv->keyLen = keyLen; memcpy(kv->key, key, keyLen); /* then value */ @@ -222,13 +204,12 @@ ktxHashList_AddKVPair(ktxHashList* pHead, const char* key, unsigned int valueLen kv->value = 0; } - HASH_ADD_KEYPTR( hh, *pHead, kv->key, kv->keyLen-1, kv); + HASH_ADD_KEYPTR(hh, *pHead, kv->key, kv->keyLen - 1, kv); return KTX_SUCCESS; } else return KTX_INVALID_VALUE; } - /** * @memberof ktxHashList @public * @~English @@ -244,20 +225,17 @@ ktxHashList_AddKVPair(ktxHashList* pHead, const char* key, unsigned int valueLen * string. */ KTX_error_code -ktxHashList_DeleteKVPair(ktxHashList* pHead, const char* key) -{ +ktxHashList_DeleteKVPair(ktxHashList* pHead, const char* key) { if (pHead && key) { ktxKVListEntry* kv; - HASH_FIND_STR( *pHead, key, kv ); /* kv: pointer to target entry. */ - if (kv != NULL) - HASH_DEL(*pHead, kv); + HASH_FIND_STR(*pHead, key, kv); /* kv: pointer to target entry. */ + if (kv != NULL) HASH_DEL(*pHead, kv); return KTX_SUCCESS; } else return KTX_INVALID_VALUE; } - /** * @memberof ktxHashList @public * @~English @@ -271,8 +249,7 @@ ktxHashList_DeleteKVPair(ktxHashList* pHead, const char* key) * string. */ KTX_error_code -ktxHashList_DeleteEntry(ktxHashList* pHead, ktxHashListEntry* pEntry) -{ +ktxHashList_DeleteEntry(ktxHashList* pHead, ktxHashListEntry* pEntry) { if (pHead && pEntry) { HASH_DEL(*pHead, pEntry); return KTX_SUCCESS; @@ -280,7 +257,6 @@ ktxHashList_DeleteEntry(ktxHashList* pHead, ktxHashListEntry* pEntry) return KTX_INVALID_VALUE; } - /** * @memberof ktxHashList @public * @~English @@ -298,13 +274,11 @@ ktxHashList_DeleteEntry(ktxHashList* pHead, ktxHashListEntry* pEntry) * @exception KTX_NOT_FOUND an entry matching @p key was not found. */ KTX_error_code -ktxHashList_FindEntry(ktxHashList* pHead, const char* key, - ktxHashListEntry** ppEntry) -{ +ktxHashList_FindEntry(ktxHashList* pHead, const char* key, ktxHashListEntry** ppEntry) { if (pHead && key) { ktxKVListEntry* kv; - HASH_FIND_STR( *pHead, key, kv ); /* kv: output pointer */ + HASH_FIND_STR(*pHead, key, kv); /* kv: output pointer */ if (kv) { *ppEntry = kv; @@ -315,7 +289,6 @@ ktxHashList_FindEntry(ktxHashList* pHead, const char* key, return KTX_INVALID_VALUE; } - /** * @memberof ktxHashList @public * @~English @@ -335,8 +308,7 @@ ktxHashList_FindEntry(ktxHashList* pHead, const char* key, * @exception KTX_NOT_FOUND an entry matching @p key was not found. */ KTX_error_code -ktxHashList_FindValue(ktxHashList *pHead, const char* key, unsigned int* pValueLen, void** ppValue) -{ +ktxHashList_FindValue(ktxHashList* pHead, const char* key, unsigned int* pValueLen, void** ppValue) { if (pValueLen && ppValue) { ktxHashListEntry* pEntry; KTX_error_code result; @@ -378,15 +350,13 @@ ktxHashList_FindValue(ktxHashList *pHead, const char* key, unsigned int* pValueL * */ ktxHashListEntry* -ktxHashList_Next(ktxHashListEntry* entry) -{ +ktxHashList_Next(ktxHashListEntry* entry) { if (entry) { return ((ktxKVListEntry*)entry)->hh.next; } else return NULL; } - /** * @memberof ktxHashList @public * @~English @@ -410,10 +380,7 @@ ktxHashList_Next(ktxHashListEntry* entry) * data. */ KTX_error_code -ktxHashList_Serialize(ktxHashList* pHead, - unsigned int* pKvdLen, unsigned char** ppKvd) -{ - +ktxHashList_Serialize(ktxHashList* pHead, unsigned int* pKvdLen, unsigned char** ppKvd) { if (pHead && pKvdLen && ppKvd) { ktxKVListEntry* kv; unsigned int bytesOfKeyValueData = 0; @@ -434,8 +401,7 @@ ktxHashList_Serialize(ktxHashList* pHead, *ppKvd = NULL; } else { sd = malloc(bytesOfKeyValueData); - if (!sd) - return KTX_OUT_OF_MEMORY; + if (!sd) return KTX_OUT_OF_MEMORY; *pKvdLen = bytesOfKeyValueData; *ppKvd = sd; @@ -448,8 +414,7 @@ ktxHashList_Serialize(ktxHashList* pHead, sd += sizeof(ktx_uint32_t); memcpy(sd, kv->key, kv->keyLen); sd += kv->keyLen; - if (kv->valueLen > 0) - memcpy(sd, kv->value, kv->valueLen); + if (kv->valueLen > 0) memcpy(sd, kv->value, kv->valueLen); sd += kv->valueLen; padLen = _KTX_PAD4_LEN(keyValueLen); memcpy(sd, padding, padLen); @@ -461,9 +426,9 @@ ktxHashList_Serialize(ktxHashList* pHead, return KTX_INVALID_VALUE; } - -int sort_by_key_codepoint(ktxKVListEntry* a, ktxKVListEntry* b) { - return strcmp(a->key, b->key); +int +sort_by_key_codepoint(ktxKVListEntry* a, ktxKVListEntry* b) { + return strcmp(a->key, b->key); } /** @@ -478,10 +443,9 @@ int sort_by_key_codepoint(ktxKVListEntry* a, ktxKVListEntry* b) { * @exception KTX_INVALID_VALUE if @p This is NULL. */ KTX_error_code -ktxHashList_Sort(ktxHashList* pHead) -{ +ktxHashList_Sort(ktxHashList* pHead) { if (pHead) { - //ktxKVListEntry* kv = (ktxKVListEntry*)pHead; + // ktxKVListEntry* kv = (ktxKVListEntry*)pHead; HASH_SORT(*pHead, sort_by_key_codepoint); return KTX_SUCCESS; @@ -490,7 +454,6 @@ ktxHashList_Sort(ktxHashList* pHead) } } - /** * @memberof ktxHashList @public * @~English @@ -512,20 +475,17 @@ ktxHashList_Sort(ktxHashList* pHead) * table. */ KTX_error_code -ktxHashList_Deserialize(ktxHashList* pHead, unsigned int kvdLen, void* pKvd) -{ +ktxHashList_Deserialize(ktxHashList* pHead, unsigned int kvdLen, void* pKvd) { char* src = pKvd; KTX_error_code result; - if (kvdLen == 0 || pKvd == NULL || pHead == NULL) - return KTX_INVALID_VALUE; + if (kvdLen == 0 || pKvd == NULL || pHead == NULL) return KTX_INVALID_VALUE; - if (*pHead != NULL) - return KTX_INVALID_OPERATION; + if (*pHead != NULL) return KTX_INVALID_OPERATION; result = KTX_SUCCESS; - while (result == KTX_SUCCESS && src < (char *)pKvd + kvdLen) { - if (src + 6 > (char *)pKvd + kvdLen) { + while (result == KTX_SUCCESS && src < (char*)pKvd + kvdLen) { + if (src + 6 > (char*)pKvd + kvdLen) { // Not enough space for another entry return KTX_FILE_DATA_ERROR; } @@ -535,7 +495,7 @@ ktxHashList_Deserialize(ktxHashList* pHead, unsigned int kvdLen, void* pKvd) void* value; ktx_uint32_t keyAndValueByteSize = *((ktx_uint32_t*)src); - if (src + 4 + keyAndValueByteSize > (char *)pKvd + kvdLen) { + if (src + 4 + keyAndValueByteSize > (char*)pKvd + kvdLen) { // Not enough space for this entry return KTX_FILE_DATA_ERROR; } @@ -560,8 +520,7 @@ ktxHashList_Deserialize(ktxHashList* pHead, unsigned int kvdLen, void* pKvd) value = key + keyLen; valueLen = keyAndValueByteSize - keyLen; - result = ktxHashList_AddKVPair(pHead, key, valueLen, - valueLen > 0 ? value : NULL); + result = ktxHashList_AddKVPair(pHead, key, valueLen, valueLen > 0 ? value : NULL); if (result == KTX_SUCCESS) { src += _KTX_PAD4(keyAndValueByteSize); } @@ -569,7 +528,6 @@ ktxHashList_Deserialize(ktxHashList* pHead, unsigned int kvdLen, void* pKvd) return result; } - /** * @memberof ktxHashListEntry @public * @~English @@ -586,9 +544,7 @@ ktxHashList_Deserialize(ktxHashList* pHead, unsigned int kvdLen, void* pKvd) * @exception KTX_INVALID_VALUE if @p pKvd or @p pHt is NULL or kvdLen == 0. */ KTX_error_code -ktxHashListEntry_GetKey(ktxHashListEntry* This, - unsigned int* pKeyLen, char** ppKey) -{ +ktxHashListEntry_GetKey(ktxHashListEntry* This, unsigned int* pKeyLen, char** ppKey) { if (pKeyLen && ppKey) { ktxKVListEntry* kv = (ktxKVListEntry*)This; *pKeyLen = kv->keyLen; @@ -598,7 +554,6 @@ ktxHashListEntry_GetKey(ktxHashListEntry* This, return KTX_INVALID_VALUE; } - /** * @memberof ktxHashListEntry @public * @~English @@ -615,9 +570,7 @@ ktxHashListEntry_GetKey(ktxHashListEntry* This, * @exception KTX_INVALID_VALUE if @p pKvd or @p pHt is NULL or kvdLen == 0. */ KTX_error_code -ktxHashListEntry_GetValue(ktxHashListEntry* This, - unsigned int* pValueLen, void** ppValue) -{ +ktxHashListEntry_GetValue(ktxHashListEntry* This, unsigned int* pValueLen, void** ppValue) { if (pValueLen && ppValue) { ktxKVListEntry* kv = (ktxKVListEntry*)This; *pValueLen = kv->valueLen; diff --git a/lib/info.c b/lib/info.c index 7fbb47c8e1..91f595aa97 100644 --- a/lib/info.c +++ b/lib/info.c @@ -23,9 +23,9 @@ #include #if defined(_WIN32) - #define WIN32_LEAN_AND_MEAN - #include - #include +#define WIN32_LEAN_AND_MEAN +#include +#include #endif #include @@ -52,21 +52,20 @@ enum { #define LENGTH_OF_INDENT(INDENT) ((base_indent + INDENT) * indent_width) /** @internal */ -#define PRINT_INDENT(INDENT, FMT, ...) { \ - printf("%*s" FMT, LENGTH_OF_INDENT(INDENT), "", __VA_ARGS__); \ - } +#define PRINT_INDENT(INDENT, FMT, ...) \ + { printf("%*s" FMT, LENGTH_OF_INDENT(INDENT), "", __VA_ARGS__); } /** @internal */ -#define PRINT_INDENT_NOARG(INDENT, FMT) { \ - printf("%*s" FMT, LENGTH_OF_INDENT(INDENT), ""); \ - } +#define PRINT_INDENT_NOARG(INDENT, FMT) \ + { printf("%*s" FMT, LENGTH_OF_INDENT(INDENT), ""); } /** @internal */ -static void printFlagBitsJSON(uint32_t indent, const char* nl, uint32_t flags, const char*(*toStringFn)(uint32_t, bool)) { +static void +printFlagBitsJSON(uint32_t indent, const char* nl, uint32_t flags, const char* (*toStringFn)(uint32_t, bool)) { bool first = true; for (uint32_t bit_index = 0; bit_index < 32; ++bit_index) { uint32_t bit_mask = 1u << bit_index; - bool bit_value = (bit_mask & (uint32_t) flags) != 0; + bool bit_value = (bit_mask & (uint32_t)flags) != 0; const char* str = toStringFn(bit_index, bit_value); if (str) { @@ -77,48 +76,38 @@ static void printFlagBitsJSON(uint32_t indent, const char* nl, uint32_t flags, c first = false; } } - if (!first) - printf("%s", nl); + if (!first) printf("%s", nl); } /** @internal */ -bool isKnownKeyValueUINT32(const char* key) { - if (strcmp(key, "KTXdxgiFormat__") == 0) - return true; - if (strcmp(key, "KTXmetalPixelFormat") == 0) - return true; +bool +isKnownKeyValueUINT32(const char* key) { + if (strcmp(key, "KTXdxgiFormat__") == 0) return true; + if (strcmp(key, "KTXmetalPixelFormat") == 0) return true; return false; } /** @internal */ -bool isKnownKeyValueString(const char* key) { - if (strcmp(key, "KTXorientation") == 0) - return true; - if (strcmp(key, "KTXswizzle") == 0) - return true; - if (strcmp(key, "KTXwriter") == 0) - return true; - if (strcmp(key, "KTXwriterScParams") == 0) - return true; - if (strcmp(key, "KTXastcDecodeMode") == 0) - return true; +bool +isKnownKeyValueString(const char* key) { + if (strcmp(key, "KTXorientation") == 0) return true; + if (strcmp(key, "KTXswizzle") == 0) return true; + if (strcmp(key, "KTXwriter") == 0) return true; + if (strcmp(key, "KTXwriterScParams") == 0) return true; + if (strcmp(key, "KTXastcDecodeMode") == 0) return true; return false; } /** @internal */ -bool isKnownKeyValue(const char* key) { - if (isKnownKeyValueUINT32(key)) - return true; - if (isKnownKeyValueString(key)) - return true; - if (strcmp(key, "KTXglFormat") == 0) - return true; - if (strcmp(key, "KTXanimData") == 0) - return true; - if (strcmp(key, "KTXcubemapIncomplete") == 0) - return true; +bool +isKnownKeyValue(const char* key) { + if (isKnownKeyValueUINT32(key)) return true; + if (isKnownKeyValueString(key)) return true; + if (strcmp(key, "KTXglFormat") == 0) return true; + if (strcmp(key, "KTXanimData") == 0) return true; + if (strcmp(key, "KTXcubemapIncomplete") == 0) return true; return false; } @@ -131,8 +120,7 @@ bool isKnownKeyValue(const char* key) { * @param [in] kvdLen length of the serialized key/value data. */ void -printKVData(ktx_uint8_t* pKvd, ktx_uint32_t kvdLen) -{ +printKVData(ktx_uint8_t* pKvd, ktx_uint32_t kvdLen) { KTX_error_code result; ktxHashList kvDataHead = 0; @@ -144,8 +132,7 @@ printKVData(ktx_uint8_t* pKvd, ktx_uint32_t kvdLen) return; } - if (kvDataHead == NULL) - return; + if (kvDataHead == NULL) return; int entryIndex = 0; ktxHashListEntry* entry = kvDataHead; @@ -164,9 +151,9 @@ printKVData(ktx_uint8_t* pKvd, ktx_uint32_t kvdLen) } else { if (strcmp(key, "KTXglFormat") == 0) { if (valueLen == 3 * sizeof(ktx_uint32_t)) { - ktx_uint32_t glInternalformat = *(const ktx_uint32_t*) (value + 0); - ktx_uint32_t glFormat = *(const ktx_uint32_t*) (value + 4); - ktx_uint32_t glType = *(const ktx_uint32_t*) (value + 8); + ktx_uint32_t glInternalformat = *(const ktx_uint32_t*)(value + 0); + ktx_uint32_t glFormat = *(const ktx_uint32_t*)(value + 4); + ktx_uint32_t glType = *(const ktx_uint32_t*)(value + 8); fprintf(stdout, "\n"); fprintf(stdout, " glInternalformat: 0x%08X\n", glInternalformat); fprintf(stdout, " glFormat: 0x%08X\n", glFormat); @@ -175,9 +162,9 @@ printKVData(ktx_uint8_t* pKvd, ktx_uint32_t kvdLen) } else if (strcmp(key, "KTXanimData") == 0) { if (valueLen == 3 * sizeof(ktx_uint32_t)) { - ktx_uint32_t duration = *(const ktx_uint32_t*) (value + 0); - ktx_uint32_t timescale = *(const ktx_uint32_t*) (value + 4); - ktx_uint32_t loopCount = *(const ktx_uint32_t*) (value + 8); + ktx_uint32_t duration = *(const ktx_uint32_t*)(value + 0); + ktx_uint32_t timescale = *(const ktx_uint32_t*)(value + 4); + ktx_uint32_t loopCount = *(const ktx_uint32_t*)(value + 8); fprintf(stdout, "\n"); fprintf(stdout, " duration: %u\n", duration); fprintf(stdout, " timescale: %u\n", timescale); @@ -198,19 +185,18 @@ printKVData(ktx_uint8_t* pKvd, ktx_uint32_t kvdLen) } else if (isKnownKeyValueUINT32(key)) { if (valueLen == sizeof(ktx_uint32_t)) { - ktx_uint32_t number = *(const ktx_uint32_t*) value; + ktx_uint32_t number = *(const ktx_uint32_t*)value; fprintf(stdout, " %u\n", number); } } else if (isKnownKeyValueString(key)) { - if (value[valueLen-1] == '\0') { + if (value[valueLen - 1] == '\0') { fprintf(stdout, " %s\n", value); } } else { fprintf(stdout, " ["); - for (ktx_uint32_t i = 0; i < valueLen; i++) - fprintf(stdout, "%d%s", (int) value[i], i + 1 == valueLen ? "" : ", "); + for (ktx_uint32_t i = 0; i < valueLen; i++) fprintf(stdout, "%d%s", (int)value[i], i + 1 == valueLen ? "" : ", "); fprintf(stdout, "]\n"); } } @@ -231,8 +217,7 @@ printKVData(ktx_uint8_t* pKvd, ktx_uint32_t kvdLen) * @param [in] minified Specifies whether the JSON output should be minified */ void -printKVDataJSON(ktx_uint8_t* pKvd, ktx_uint32_t kvdLen, ktx_uint32_t base_indent, ktx_uint32_t indent_width, bool minified) -{ +printKVDataJSON(ktx_uint8_t* pKvd, ktx_uint32_t kvdLen, ktx_uint32_t base_indent, ktx_uint32_t indent_width, bool minified) { const char* space = minified ? "" : " "; const char* nl = minified ? "" : "\n"; @@ -248,12 +233,11 @@ printKVDataJSON(ktx_uint8_t* pKvd, ktx_uint32_t kvdLen, ktx_uint32_t base_indent return; } - if (kvDataHead == NULL) - return; + if (kvDataHead == NULL) return; int entryIndex = 0; ktxHashListEntry* entry = kvDataHead; - bool firstPrint = true; // Marks if the first print did not occur yet (first print != first entry) + bool firstPrint = true; // Marks if the first print did not occur yet (first print != first entry) for (; entry != NULL && entryIndex < MAX_NUM_KVD_ENTRIES; entry = ktxHashList_Next(entry), ++entryIndex) { char* key; char* value; @@ -265,20 +249,18 @@ printKVDataJSON(ktx_uint8_t* pKvd, ktx_uint32_t kvdLen, ktx_uint32_t base_indent if (!value) { if (!isKnownKeyValue(key)) { // Known keys are not be printed with null - if (!firstPrint) - fprintf(stdout, ",%s", nl); + if (!firstPrint) fprintf(stdout, ",%s", nl); firstPrint = false; PRINT_INDENT(0, "\"%s\":%snull", key, space) } } else { if (strcmp(key, "KTXglFormat") == 0) { if (valueLen == 3 * sizeof(ktx_uint32_t)) { - if (!firstPrint) - fprintf(stdout, ",%s", nl); + if (!firstPrint) fprintf(stdout, ",%s", nl); firstPrint = false; - ktx_uint32_t glInternalformat = *(const ktx_uint32_t*) (value + 0); - ktx_uint32_t glFormat = *(const ktx_uint32_t*) (value + 4); - ktx_uint32_t glType = *(const ktx_uint32_t*) (value + 8); + ktx_uint32_t glInternalformat = *(const ktx_uint32_t*)(value + 0); + ktx_uint32_t glFormat = *(const ktx_uint32_t*)(value + 4); + ktx_uint32_t glType = *(const ktx_uint32_t*)(value + 8); PRINT_INDENT(0, "\"%s\":%s{%s", key, space, nl) PRINT_INDENT(1, "\"glInternalformat\":%s%u,%s", space, glInternalformat, nl) PRINT_INDENT(1, "\"glFormat\":%s%u,%s", space, glFormat, nl) @@ -287,12 +269,11 @@ printKVDataJSON(ktx_uint8_t* pKvd, ktx_uint32_t kvdLen, ktx_uint32_t base_indent } } else if (strcmp(key, "KTXanimData") == 0) { if (valueLen == 3 * sizeof(ktx_uint32_t)) { - if (!firstPrint) - fprintf(stdout, ",%s", nl); + if (!firstPrint) fprintf(stdout, ",%s", nl); firstPrint = false; - ktx_uint32_t duration = *(const ktx_uint32_t*) (value + 0); - ktx_uint32_t timescale = *(const ktx_uint32_t*) (value + 4); - ktx_uint32_t loopCount = *(const ktx_uint32_t*) (value + 8); + ktx_uint32_t duration = *(const ktx_uint32_t*)(value + 0); + ktx_uint32_t timescale = *(const ktx_uint32_t*)(value + 4); + ktx_uint32_t loopCount = *(const ktx_uint32_t*)(value + 8); PRINT_INDENT(0, "\"%s\":%s{%s", key, space, nl) PRINT_INDENT(1, "\"duration\":%s%u,%s", space, duration, nl) PRINT_INDENT(1, "\"timescale\":%s%u,%s", space, timescale, nl) @@ -301,8 +282,7 @@ printKVDataJSON(ktx_uint8_t* pKvd, ktx_uint32_t kvdLen, ktx_uint32_t base_indent } } else if (strcmp(key, "KTXcubemapIncomplete") == 0) { if (valueLen == sizeof(ktx_uint8_t)) { - if (!firstPrint) - fprintf(stdout, ",%s", nl); + if (!firstPrint) fprintf(stdout, ",%s", nl); firstPrint = false; ktx_uint8_t faces = *value; PRINT_INDENT(0, "\"%s\":%s{%s", key, space, nl) @@ -316,26 +296,22 @@ printKVDataJSON(ktx_uint8_t* pKvd, ktx_uint32_t kvdLen, ktx_uint32_t base_indent } } else if (isKnownKeyValueUINT32(key)) { if (valueLen == sizeof(ktx_uint32_t)) { - if (!firstPrint) - fprintf(stdout, ",%s", nl); + if (!firstPrint) fprintf(stdout, ",%s", nl); firstPrint = false; - ktx_uint32_t number = *(const ktx_uint32_t*) value; + ktx_uint32_t number = *(const ktx_uint32_t*)value; PRINT_INDENT(0, "\"%s\":%s%u", key, space, number) } } else if (isKnownKeyValueString(key)) { - if (value[valueLen-1] == '\0') { - if (!firstPrint) - fprintf(stdout, ",%s", nl); + if (value[valueLen - 1] == '\0') { + if (!firstPrint) fprintf(stdout, ",%s", nl); firstPrint = false; PRINT_INDENT(0, "\"%s\":%s\"%s\"", key, space, value) } } else { - if (!firstPrint) - fprintf(stdout, ",%s", nl); + if (!firstPrint) fprintf(stdout, ",%s", nl); firstPrint = false; PRINT_INDENT(0, "\"%s\":%s[", key, space) - for (ktx_uint32_t i = 0; i < valueLen; i++) - fprintf(stdout, "%d%s", (int) value[i], i + 1 == valueLen ? "" : ", "); + for (ktx_uint32_t i = 0; i < valueLen; i++) fprintf(stdout, "%d%s", (int)value[i], i + 1 == valueLen ? "" : ", "); fprintf(stdout, "]"); } } @@ -354,8 +330,7 @@ printKVDataJSON(ktx_uint8_t* pKvd, ktx_uint32_t kvdLen, ktx_uint32_t base_indent * @param [in] json specifies if "\x1A" should be escaped as "\u001A" to not break most json tools */ void -printIdentifier(const ktx_uint8_t identifier[12], bool json) -{ +printIdentifier(const ktx_uint8_t identifier[12], bool json) { // Convert identifier for better display. uint32_t idlen = 0; char u8identifier[30]; @@ -380,10 +355,7 @@ printIdentifier(const ktx_uint8_t identifier[12], bool json) u8identifier[idlen] = 'r'; break; default: - nchars = snprintf(&u8identifier[idlen], - sizeof(u8identifier) - idlen, - json ? "\\u%04X" : "\\x%02X", - identifier[i]); + nchars = snprintf(&u8identifier[idlen], sizeof(u8identifier) - idlen, json ? "\\u%04X" : "\\x%02X", identifier[i]); idlen += nchars - 1; } } else { @@ -391,8 +363,7 @@ printIdentifier(const ktx_uint8_t identifier[12], bool json) } } #if defined(_WIN32) - if (_isatty(_fileno(stdout))) - SetConsoleOutputCP(CP_UTF8); + if (_isatty(_fileno(stdout))) SetConsoleOutputCP(CP_UTF8); #endif fprintf(stdout, "%.*s", idlen, u8identifier); } @@ -409,8 +380,7 @@ printIdentifier(const ktx_uint8_t identifier[12], bool json) * @param [in] pHeader pointer to the header to print. */ void -printKTXHeader(KTX_header* pHeader) -{ +printKTXHeader(KTX_header* pHeader) { fprintf(stdout, "identifier: "); printIdentifier(pHeader->identifier, false); fprintf(stdout, "\n"); @@ -419,13 +389,11 @@ printKTXHeader(KTX_header* pHeader) fprintf(stdout, "glTypeSize: %u\n", pHeader->glTypeSize); fprintf(stdout, "glFormat: %#x\n", pHeader->glFormat); fprintf(stdout, "glInternalformat: %#x\n", pHeader->glInternalformat); - fprintf(stdout, "glBaseInternalformat: %#x\n", - pHeader->glBaseInternalformat); + fprintf(stdout, "glBaseInternalformat: %#x\n", pHeader->glBaseInternalformat); fprintf(stdout, "pixelWidth: %u\n", pHeader->pixelWidth); fprintf(stdout, "pixelHeight: %u\n", pHeader->pixelHeight); fprintf(stdout, "pixelDepth: %u\n", pHeader->pixelDepth); - fprintf(stdout, "numberOfArrayElements: %u\n", - pHeader->numberOfArrayElements); + fprintf(stdout, "numberOfArrayElements: %u\n", pHeader->numberOfArrayElements); fprintf(stdout, "numberOfFaces: %u\n", pHeader->numberOfFaces); fprintf(stdout, "numberOfMipLevels: %u\n", pHeader->numberOfMipLevels); fprintf(stdout, "bytesOfKeyValueData: %u\n", pHeader->bytesOfKeyValueData); @@ -442,15 +410,15 @@ printKTXHeader(KTX_header* pHeader) * @param [in] pHeader pointer to the header to print. */ void -printKTXInfo2(ktxStream* stream, KTX_header* pHeader) -{ +printKTXInfo2(ktxStream* stream, KTX_header* pHeader) { ktx_uint8_t* metadata; KTX_supplemental_info suppInfo; KTX_error_code result; if (pHeader->endianness == KTX_ENDIAN_REF_REV) { - fprintf(stdout, "This file has opposite endianness to this machine. Following\n" - "are the converted pHeader values\n\n"); + fprintf(stdout, + "This file has opposite endianness to this machine. Following\n" + "are the converted pHeader values\n\n"); } else { fprintf(stdout, "Header\n\n"); } @@ -461,15 +429,15 @@ printKTXInfo2(ktxStream* stream, KTX_header* pHeader) if (result != KTX_SUCCESS) { fprintf(stdout, "The KTX 1 file pHeader is invalid:\n"); switch (result) { - case KTX_FILE_DATA_ERROR: - fprintf(stdout, " it has invalid data such as bad glTypeSize, improper dimensions,\n" - "improper number of faces or too many levels.\n"); + case KTX_FILE_DATA_ERROR: + fprintf(stdout, + " it has invalid data such as bad glTypeSize, improper dimensions,\n" + "improper number of faces or too many levels.\n"); break; - case KTX_UNSUPPORTED_FEATURE: + case KTX_UNSUPPORTED_FEATURE: fprintf(stdout, " it describes an unsupported feature or format\n"); break; - default: - ; // _ktxCheckHeader returns only the above 2 errors. + default:; // _ktxCheckHeader returns only the above 2 errors. } return; } @@ -501,8 +469,7 @@ printKTXInfo2(ktxStream* stream, KTX_header* pHeader) ktx_uint32_t faceLodSize; ktx_uint32_t lodSize; result = stream->read(stream, &faceLodSize, sizeof(ktx_uint32_t)); - if (pHeader->endianness == KTX_ENDIAN_REF_REV) - _ktxSwapEndian32(&faceLodSize, 1); + if (pHeader->endianness == KTX_ENDIAN_REF_REV) _ktxSwapEndian32(&faceLodSize, 1); if (nonArrayCubemap) { lodSize = faceLodSize * 6; } else { @@ -525,15 +492,13 @@ printKTXInfo2(ktxStream* stream, KTX_header* pHeader) * @param [in] stream pointer to the ktxStream reading the file. */ void -printKTXInfo(ktxStream* stream) -{ +printKTXInfo(ktxStream* stream) { KTX_header header; stream->read(stream, &header, KTX_HEADER_SIZE); printKTXInfo2(stream, &header); } - /*===========================================================* * For KTX format version 2 * *===========================================================*/ @@ -552,41 +517,35 @@ const char* ktxBUImageFlagsBitString(ktx_uint32_t bit_index, bool bit_value); * @param [in] pHeader pointer to the header to print. */ void -printKTX2Header(KTX_header2* pHeader) -{ +printKTX2Header(KTX_header2* pHeader) { fprintf(stdout, "identifier: "); printIdentifier(pHeader->identifier, false); fprintf(stdout, "\n"); const char* vkFormatStr = vkFormatString(pHeader->vkFormat); if (strcmp(vkFormatStr, "VK_UNKNOWN_FORMAT") == 0) - fprintf(stdout, "vkFormat: 0x%08X\n", (uint32_t) pHeader->vkFormat); + fprintf(stdout, "vkFormat: 0x%08X\n", (uint32_t)pHeader->vkFormat); else fprintf(stdout, "vkFormat: %s\n", vkFormatStr); fprintf(stdout, "typeSize: %u\n", pHeader->typeSize); fprintf(stdout, "pixelWidth: %u\n", pHeader->pixelWidth); fprintf(stdout, "pixelHeight: %u\n", pHeader->pixelHeight); fprintf(stdout, "pixelDepth: %u\n", pHeader->pixelDepth); - fprintf(stdout, "layerCount: %u\n", - pHeader->layerCount); + fprintf(stdout, "layerCount: %u\n", pHeader->layerCount); fprintf(stdout, "faceCount: %u\n", pHeader->faceCount); fprintf(stdout, "levelCount: %u\n", pHeader->levelCount); const char* scSchemeStr = ktxSupercompressionSchemeString(pHeader->supercompressionScheme); if (strcmp(scSchemeStr, "Invalid scheme value") == 0) - fprintf(stdout, "supercompressionScheme: Invalid scheme (0x%X)\n", (uint32_t) pHeader->supercompressionScheme); + fprintf(stdout, "supercompressionScheme: Invalid scheme (0x%X)\n", (uint32_t)pHeader->supercompressionScheme); else if (strcmp(scSchemeStr, "Vendor or reserved scheme") == 0) - fprintf(stdout, "supercompressionScheme: Vendor or reserved scheme (0x%X)\n", (uint32_t) pHeader->supercompressionScheme); + fprintf(stdout, "supercompressionScheme: Vendor or reserved scheme (0x%X)\n", (uint32_t)pHeader->supercompressionScheme); else fprintf(stdout, "supercompressionScheme: %s\n", scSchemeStr); - fprintf(stdout, "dataFormatDescriptor.byteOffset: %#x\n", - pHeader->dataFormatDescriptor.byteOffset); - fprintf(stdout, "dataFormatDescriptor.byteLength: %u\n", - pHeader->dataFormatDescriptor.byteLength); + fprintf(stdout, "dataFormatDescriptor.byteOffset: %#x\n", pHeader->dataFormatDescriptor.byteOffset); + fprintf(stdout, "dataFormatDescriptor.byteLength: %u\n", pHeader->dataFormatDescriptor.byteLength); fprintf(stdout, "keyValueData.byteOffset: %#x\n", pHeader->keyValueData.byteOffset); fprintf(stdout, "keyValueData.byteLength: %u\n", pHeader->keyValueData.byteLength); - fprintf(stdout, "supercompressionGlobalData.byteOffset: %#" PRIx64 "\n", - pHeader->supercompressionGlobalData.byteOffset); - fprintf(stdout, "supercompressionGlobalData.byteLength: %" PRId64 "\n", - pHeader->supercompressionGlobalData.byteLength); + fprintf(stdout, "supercompressionGlobalData.byteOffset: %#" PRIx64 "\n", pHeader->supercompressionGlobalData.byteOffset); + fprintf(stdout, "supercompressionGlobalData.byteLength: %" PRId64 "\n", pHeader->supercompressionGlobalData.byteLength); } /** @@ -598,16 +557,12 @@ printKTX2Header(KTX_header2* pHeader) * @param [in] numLevels number of entries in the level index. */ void -printLevelIndex(ktxLevelIndexEntry levelIndex[], ktx_uint32_t numLevels) -{ - numLevels = MIN(MAX_NUM_LEVELS, numLevels); // Print at most 64 levels to stop parsing garbage +printLevelIndex(ktxLevelIndexEntry levelIndex[], ktx_uint32_t numLevels) { + numLevels = MIN(MAX_NUM_LEVELS, numLevels); // Print at most 64 levels to stop parsing garbage for (ktx_uint32_t level = 0; level < numLevels; level++) { - fprintf(stdout, "Level%u.byteOffset: %#" PRIx64 "\n", level, - levelIndex[level].byteOffset); - fprintf(stdout, "Level%u.byteLength: %" PRId64 "\n", level, - levelIndex[level].byteLength); - fprintf(stdout, "Level%u.uncompressedByteLength: %" PRId64 "\n", level, - levelIndex[level].uncompressedByteLength); + fprintf(stdout, "Level%u.byteOffset: %#" PRIx64 "\n", level, levelIndex[level].byteOffset); + fprintf(stdout, "Level%u.byteLength: %" PRId64 "\n", level, levelIndex[level].byteLength); + fprintf(stdout, "Level%u.uncompressedByteLength: %" PRId64 "\n", level, levelIndex[level].uncompressedByteLength); } } @@ -620,12 +575,9 @@ printLevelIndex(ktxLevelIndexEntry levelIndex[], ktx_uint32_t numLevels) * @param [in] byteLength byte length of the data pointed to by @p bgd. */ void -printBasisSGDInfo(ktx_uint8_t* bgd, ktx_uint64_t byteLength, - ktx_uint32_t numImages) -{ +printBasisSGDInfo(ktx_uint8_t* bgd, ktx_uint64_t byteLength, ktx_uint32_t numImages) { ktxBasisLzGlobalHeader* bgdh = (ktxBasisLzGlobalHeader*)(bgd); - if (byteLength < sizeof(ktxBasisLzGlobalHeader)) - return; + if (byteLength < sizeof(ktxBasisLzGlobalHeader)) return; fprintf(stdout, "endpointCount: %u\n", bgdh->endpointCount); fprintf(stdout, "selectorCount: %u\n", bgdh->selectorCount); @@ -636,8 +588,7 @@ printBasisSGDInfo(ktx_uint8_t* bgd, ktx_uint64_t byteLength, ktxBasisLzEtc1sImageDesc* slices = (ktxBasisLzEtc1sImageDesc*)(bgd + sizeof(ktxBasisLzGlobalHeader)); for (ktx_uint32_t i = 0; i < numImages; i++) { - if (byteLength < (i + 1) * sizeof(ktxBasisLzEtc1sImageDesc) + sizeof(ktxBasisLzGlobalHeader)) - break; + if (byteLength < (i + 1) * sizeof(ktxBasisLzEtc1sImageDesc) + sizeof(ktxBasisLzGlobalHeader)) break; fprintf(stdout, "\nimageFlags: %#x\n", slices[i].imageFlags); fprintf(stdout, "rgbSliceByteLength: %u\n", slices[i].rgbSliceByteLength); @@ -658,17 +609,10 @@ printBasisSGDInfo(ktx_uint8_t* bgd, ktx_uint64_t byteLength, * @param [in] pHeader pointer to the header to print. */ KTX_error_code -printKTX2Info2(ktxStream* stream, KTX_header2* pHeader) -{ - const bool hasDFD = - pHeader->dataFormatDescriptor.byteOffset != 0 && - pHeader->dataFormatDescriptor.byteLength != 0; - const bool hasKVD = - pHeader->keyValueData.byteOffset != 0 && - pHeader->keyValueData.byteLength != 0; - const bool hasSGD = - pHeader->supercompressionGlobalData.byteOffset != 0 && - pHeader->supercompressionGlobalData.byteLength != 0; +printKTX2Info2(ktxStream* stream, KTX_header2* pHeader) { + const bool hasDFD = pHeader->dataFormatDescriptor.byteOffset != 0 && pHeader->dataFormatDescriptor.byteLength != 0; + const bool hasKVD = pHeader->keyValueData.byteOffset != 0 && pHeader->keyValueData.byteLength != 0; + const bool hasSGD = pHeader->supercompressionGlobalData.byteOffset != 0 && pHeader->supercompressionGlobalData.byteLength != 0; ktx_uint32_t numLevels; ktxLevelIndexEntry* levelIndex; @@ -682,8 +626,7 @@ printKTX2Info2(ktxStream* stream, KTX_header2* pHeader) numLevels = MAX(1, pHeader->levelCount); levelIndexSize = sizeof(ktxLevelIndexEntry) * numLevels; levelIndex = (ktxLevelIndexEntry*)malloc(levelIndexSize); - if (levelIndex == NULL) - return KTX_OUT_OF_MEMORY; + if (levelIndex == NULL) return KTX_OUT_OF_MEMORY; ec = stream->read(stream, levelIndex, levelIndexSize); if (ec != KTX_SUCCESS) { free(levelIndex); @@ -695,8 +638,7 @@ printKTX2Info2(ktxStream* stream, KTX_header2* pHeader) if (hasDFD) { fprintf(stdout, "\nData Format Descriptor\n\n"); ktx_uint32_t* dfd = (ktx_uint32_t*)malloc(pHeader->dataFormatDescriptor.byteLength); - if (dfd == NULL) - return KTX_OUT_OF_MEMORY; + if (dfd == NULL) return KTX_OUT_OF_MEMORY; ec = stream->read(stream, dfd, pHeader->dataFormatDescriptor.byteLength); if (ec != KTX_SUCCESS) { free(dfd); @@ -713,8 +655,7 @@ printKTX2Info2(ktxStream* stream, KTX_header2* pHeader) if (hasKVD) { fprintf(stdout, "\nKey/Value Data\n\n"); ktx_uint8_t* kvd = malloc(pHeader->keyValueData.byteLength); - if (kvd == NULL) - return KTX_OUT_OF_MEMORY; + if (kvd == NULL) return KTX_OUT_OF_MEMORY; ec = stream->read(stream, kvd, pHeader->keyValueData.byteLength); if (ec != KTX_SUCCESS) { free(kvd); @@ -729,8 +670,7 @@ printKTX2Info2(ktxStream* stream, KTX_header2* pHeader) if (hasSGD) { if (pHeader->supercompressionScheme == KTX_SS_BASIS_LZ) { ktx_uint8_t* sgd = malloc(pHeader->supercompressionGlobalData.byteLength); - if (sgd == NULL) - return KTX_OUT_OF_MEMORY; + if (sgd == NULL) return KTX_OUT_OF_MEMORY; ec = stream->setpos(stream, pHeader->supercompressionGlobalData.byteOffset); if (ec != KTX_SUCCESS) { free(sgd); @@ -746,7 +686,7 @@ printKTX2Info2(ktxStream* stream, KTX_header2* pHeader) // uint32_t layersFaces = MAX(pHeader->layerCount, 1) * pHeader->faceCount; uint32_t layerPixelDepth = MAX(pHeader->pixelDepth, 1); - for(uint32_t level = 1; level < MAX(pHeader->levelCount, 1); level++) + for (uint32_t level = 1; level < MAX(pHeader->levelCount, 1); level++) layerPixelDepth += MAX(MAX(pHeader->pixelDepth, 1) >> level, 1U); // NOTA BENE: faceCount * layerPixelDepth is only reasonable because // faceCount and depth can't both be > 1. I.e there are no 3d cubemaps. @@ -776,8 +716,7 @@ printKTX2Info2(ktxStream* stream, KTX_header2* pHeader) * @param [in] minified Specifies whether the JSON output should be minified */ KTX_error_code -printKTX2Info2JSON(ktxStream* stream, KTX_header2* pHeader, ktx_uint32_t base_indent, ktx_uint32_t indent_width, bool minified) -{ +printKTX2Info2JSON(ktxStream* stream, KTX_header2* pHeader, ktx_uint32_t base_indent, ktx_uint32_t indent_width, bool minified) { if (minified) { base_indent = 0; indent_width = 0; @@ -785,15 +724,9 @@ printKTX2Info2JSON(ktxStream* stream, KTX_header2* pHeader, ktx_uint32_t base_in const char* space = minified ? "" : " "; const char* nl = minified ? "" : "\n"; - const bool hasDFD = - pHeader->dataFormatDescriptor.byteOffset != 0 && - pHeader->dataFormatDescriptor.byteLength != 0; - const bool hasKVD = - pHeader->keyValueData.byteOffset != 0 && - pHeader->keyValueData.byteLength != 0; - const bool hasSGD = - pHeader->supercompressionGlobalData.byteOffset != 0 && - pHeader->supercompressionGlobalData.byteLength != 0; + const bool hasDFD = pHeader->dataFormatDescriptor.byteOffset != 0 && pHeader->dataFormatDescriptor.byteLength != 0; + const bool hasKVD = pHeader->keyValueData.byteOffset != 0 && pHeader->keyValueData.byteLength != 0; + const bool hasSGD = pHeader->supercompressionGlobalData.byteOffset != 0 && pHeader->supercompressionGlobalData.byteLength != 0; ktx_uint32_t numLevels; ktxLevelIndexEntry* levelIndex; @@ -807,7 +740,7 @@ printKTX2Info2JSON(ktxStream* stream, KTX_header2* pHeader, ktx_uint32_t base_in printf("\",%s", nl); const char* vkFormatStr = vkFormatString(pHeader->vkFormat); if (strcmp(vkFormatStr, "VK_UNKNOWN_FORMAT") == 0) - PRINT_INDENT(1, "\"vkFormat\":%s%u,%s", space, (uint32_t) pHeader->vkFormat, nl) + PRINT_INDENT(1, "\"vkFormat\":%s%u,%s", space, (uint32_t)pHeader->vkFormat, nl) else PRINT_INDENT(1, "\"vkFormat\":%s\"%s\",%s", space, vkFormatStr, nl) PRINT_INDENT(1, "\"typeSize\":%s%u,%s", space, pHeader->typeSize, nl); @@ -819,7 +752,7 @@ printKTX2Info2JSON(ktxStream* stream, KTX_header2* pHeader, ktx_uint32_t base_in PRINT_INDENT(1, "\"levelCount\":%s%u,%s", space, pHeader->levelCount, nl); const char* scSchemeStr = ktxSupercompressionSchemeString(pHeader->supercompressionScheme); if (strcmp(scSchemeStr, "Invalid scheme value") == 0 || strcmp(scSchemeStr, "Vendor or reserved scheme") == 0) - PRINT_INDENT(1, "\"supercompressionScheme\":%s%u%s", space, (uint32_t) pHeader->supercompressionScheme, nl) + PRINT_INDENT(1, "\"supercompressionScheme\":%s%u%s", space, (uint32_t)pHeader->supercompressionScheme, nl) else PRINT_INDENT(1, "\"supercompressionScheme\":%s\"%s\"%s", space, scSchemeStr, nl) PRINT_INDENT_NOARG(0, "}") @@ -827,8 +760,7 @@ printKTX2Info2JSON(ktxStream* stream, KTX_header2* pHeader, ktx_uint32_t base_in numLevels = MAX(1, pHeader->levelCount); levelIndexSize = sizeof(ktxLevelIndexEntry) * numLevels; levelIndex = (ktxLevelIndexEntry*)malloc(levelIndexSize); - if (levelIndex == NULL) - return KTX_OUT_OF_MEMORY; + if (levelIndex == NULL) return KTX_OUT_OF_MEMORY; ec = stream->read(stream, levelIndex, levelIndexSize); if (ec != KTX_SUCCESS) { printf("%s", nl); @@ -853,7 +785,7 @@ printKTX2Info2JSON(ktxStream* stream, KTX_header2* pHeader, ktx_uint32_t base_in PRINT_INDENT(1, "},%s", nl) PRINT_INDENT(1, "\"levels\":%s[%s", space, nl) - numLevels = MIN(MAX_NUM_LEVELS, numLevels); // Print at most 64 levels to stop parsing garbage + numLevels = MIN(MAX_NUM_LEVELS, numLevels); // Print at most 64 levels to stop parsing garbage for (ktx_uint32_t level = 0; level < numLevels; level++) { PRINT_INDENT(2, "{%s", nl); PRINT_INDENT(3, "\"byteOffset\":%s%" PRId64 ",%s", space, levelIndex[level].byteOffset, nl); @@ -861,15 +793,14 @@ printKTX2Info2JSON(ktxStream* stream, KTX_header2* pHeader, ktx_uint32_t base_in PRINT_INDENT(3, "\"uncompressedByteLength\":%s%" PRId64 "%s", space, levelIndex[level].uncompressedByteLength, nl); PRINT_INDENT(2, "}%s%s", level + 1 == numLevels ? "" : ",", nl); } - PRINT_INDENT(1, "]%s", nl) // End of levels + PRINT_INDENT(1, "]%s", nl) // End of levels free(levelIndex); - PRINT_INDENT_NOARG(0, "}") // End of index + PRINT_INDENT_NOARG(0, "}") // End of index if (hasDFD) { ktx_uint32_t* dfd = (ktx_uint32_t*)malloc(pHeader->dataFormatDescriptor.byteLength); - if (dfd == NULL) - return KTX_OUT_OF_MEMORY; + if (dfd == NULL) return KTX_OUT_OF_MEMORY; ec = stream->read(stream, dfd, pHeader->dataFormatDescriptor.byteLength); if (ec != KTX_SUCCESS) { printf("%s", nl); @@ -885,8 +816,7 @@ printKTX2Info2JSON(ktxStream* stream, KTX_header2* pHeader, ktx_uint32_t base_in if (hasKVD) { ktx_uint8_t* kvd = malloc(pHeader->keyValueData.byteLength); - if (kvd == NULL) - return KTX_OUT_OF_MEMORY; + if (kvd == NULL) return KTX_OUT_OF_MEMORY; ec = stream->read(stream, kvd, pHeader->keyValueData.byteLength); if (ec != KTX_SUCCESS) { printf("%s", nl); @@ -913,8 +843,7 @@ printKTX2Info2JSON(ktxStream* stream, KTX_header2* pHeader, ktx_uint32_t base_in PRINT_INDENT(1, "\"type\":%s\"%s\"", space, "KTX_SS_BASIS_LZ") ktx_size_t sgdByteLength = pHeader->supercompressionGlobalData.byteLength; ktx_uint8_t* sgd = malloc(sgdByteLength); - if (sgd == NULL) - return KTX_OUT_OF_MEMORY; + if (sgd == NULL) return KTX_OUT_OF_MEMORY; ec = stream->setpos(stream, pHeader->supercompressionGlobalData.byteOffset); if (ec != KTX_SUCCESS) { printf("%s", nl); @@ -957,8 +886,7 @@ printKTX2Info2JSON(ktxStream* stream, KTX_header2* pHeader, ktx_uint32_t base_in ktxBasisLzEtc1sImageDesc* slices = (ktxBasisLzEtc1sImageDesc*)(sgd + sizeof(ktxBasisLzGlobalHeader)); for (ktx_uint32_t i = 0; i < numImages; i++) { - if (sgdByteLength < (i + 1) * sizeof(ktxBasisLzEtc1sImageDesc) + sizeof(ktxBasisLzGlobalHeader)) - break; + if (sgdByteLength < (i + 1) * sizeof(ktxBasisLzEtc1sImageDesc) + sizeof(ktxBasisLzGlobalHeader)) break; if (i == 0) printf("%s", nl); @@ -1017,8 +945,7 @@ printKTX2Info2JSON(ktxStream* stream, KTX_header2* pHeader, ktx_uint32_t base_in * @param [in] stream pointer to the ktxStream reading the file. */ void -printKTX2Info(ktxStream* stream) -{ +printKTX2Info(ktxStream* stream) { KTX_header2 header; stream->read(stream, &header, KTX2_HEADER_SIZE); @@ -1040,8 +967,7 @@ printKTX2Info(ktxStream* stream) * @param [in] stream pointer to the ktxStream reading the file. */ KTX_error_code -ktxPrintInfoForStream(ktxStream* stream) -{ +ktxPrintInfoForStream(ktxStream* stream) { enum { KTX, KTX2 } fileType; ktx_uint8_t ktx_ident_ref[12] = KTX_IDENTIFIER_REF; ktx_uint8_t ktx2_ident_ref[12] = KTX2_IDENTIFIER_REF; @@ -1057,23 +983,20 @@ ktxPrintInfoForStream(ktxStream* stream) if (result == KTX_SUCCESS) { // Compare identifier, is this a KTX or KTX2 file? if (!memcmp(header.ktx.identifier, ktx_ident_ref, 12)) { - fileType = KTX; + fileType = KTX; } else if (!memcmp(header.ktx2.identifier, ktx2_ident_ref, 12)) { - fileType = KTX2; + fileType = KTX2; } else { - return KTX_UNKNOWN_FILE_FORMAT; + return KTX_UNKNOWN_FILE_FORMAT; } if (fileType == KTX) { // Read rest of header. - result = stream->read(stream, &header.ktx.endianness, - KTX_HEADER_SIZE - sizeof(ktx_ident_ref)); + result = stream->read(stream, &header.ktx.endianness, KTX_HEADER_SIZE - sizeof(ktx_ident_ref)); printKTXInfo2(stream, &header.ktx); } else { // Read rest of header. - result = stream->read(stream, &header.ktx2.vkFormat, - KTX2_HEADER_SIZE - sizeof(ktx2_ident_ref)); - if (result != KTX_SUCCESS) - return result; + result = stream->read(stream, &header.ktx2.vkFormat, KTX2_HEADER_SIZE - sizeof(ktx2_ident_ref)); + if (result != KTX_SUCCESS) return result; result = printKTX2Info2(stream, &header.ktx2); } } @@ -1090,8 +1013,7 @@ ktxPrintInfoForStream(ktxStream* stream) * @param [in] stream pointer to the ktxStream reading the file. */ KTX_error_code -ktxPrintKTX2InfoJSONForStream(ktxStream* stream, ktx_uint32_t base_indent, ktx_uint32_t indent_width, bool minified) -{ +ktxPrintKTX2InfoJSONForStream(ktxStream* stream, ktx_uint32_t base_indent, ktx_uint32_t indent_width, bool minified) { ktx_uint8_t ktx2_ident_ref[12] = KTX2_IDENTIFIER_REF; KTX_header2 header; KTX_error_code result; @@ -1099,17 +1021,14 @@ ktxPrintKTX2InfoJSONForStream(ktxStream* stream, ktx_uint32_t base_indent, ktx_u assert(stream != NULL); result = stream->read(stream, &header, sizeof(ktx2_ident_ref)); - if (result != KTX_SUCCESS) - return result; + if (result != KTX_SUCCESS) return result; // Compare identifier, is this a KTX2 file? - if (memcmp(header.identifier, ktx2_ident_ref, 12)) - return KTX_UNKNOWN_FILE_FORMAT; + if (memcmp(header.identifier, ktx2_ident_ref, 12)) return KTX_UNKNOWN_FILE_FORMAT; // Read rest of header. result = stream->read(stream, &header.vkFormat, KTX2_HEADER_SIZE - sizeof(ktx2_ident_ref)); - if (result != KTX_SUCCESS) - return result; + if (result != KTX_SUCCESS) return result; result = printKTX2Info2JSON(stream, &header, base_indent, indent_width, minified); return result; @@ -1125,8 +1044,7 @@ ktxPrintKTX2InfoJSONForStream(ktxStream* stream, ktx_uint32_t base_indent, ktx_u * @param [in] stream pointer to the ktxStream reading the file. */ KTX_error_code -ktxPrintKTX2InfoTextForStream(ktxStream* stream) -{ +ktxPrintKTX2InfoTextForStream(ktxStream* stream) { ktx_uint8_t ktx2_ident_ref[12] = KTX2_IDENTIFIER_REF; KTX_header2 header; KTX_error_code result; @@ -1134,17 +1052,14 @@ ktxPrintKTX2InfoTextForStream(ktxStream* stream) assert(stream != NULL); result = stream->read(stream, &header, sizeof(ktx2_ident_ref)); - if (result != KTX_SUCCESS) - return result; + if (result != KTX_SUCCESS) return result; // Compare identifier, is this a KTX2 file? - if (memcmp(header.identifier, ktx2_ident_ref, 12)) - return KTX_UNKNOWN_FILE_FORMAT; + if (memcmp(header.identifier, ktx2_ident_ref, 12)) return KTX_UNKNOWN_FILE_FORMAT; // Read rest of header. result = stream->read(stream, &header.vkFormat, KTX2_HEADER_SIZE - sizeof(ktx2_ident_ref)); - if (result != KTX_SUCCESS) - return result; + if (result != KTX_SUCCESS) return result; result = printKTX2Info2(stream, &header); return result; @@ -1160,17 +1075,14 @@ ktxPrintKTX2InfoTextForStream(ktxStream* stream) * @param [in] stream pointer to the ktxStream reading the file. */ KTX_error_code -ktxPrintInfoForStdioStream(FILE* stdioStream) -{ +ktxPrintInfoForStdioStream(FILE* stdioStream) { KTX_error_code result; ktxStream stream; - if (stdioStream == NULL) - return KTX_INVALID_VALUE; + if (stdioStream == NULL) return KTX_INVALID_VALUE; result = ktxFileStream_construct(&stream, stdioStream, KTX_FALSE); - if (result == KTX_SUCCESS) - result = ktxPrintInfoForStream(&stream); + if (result == KTX_SUCCESS) result = ktxPrintInfoForStream(&stream); return result; } @@ -1183,8 +1095,7 @@ ktxPrintInfoForStdioStream(FILE* stdioStream) * @param [in] filename name of the KTX file. */ KTX_error_code -ktxPrintInfoForNamedFile(const char* const filename) -{ +ktxPrintInfoForNamedFile(const char* const filename) { // TODO: Implement UNUSED(filename); return KTX_SUCCESS; @@ -1200,14 +1111,12 @@ ktxPrintInfoForNamedFile(const char* const filename) * @param [in] size length of the KTX file in bytes. */ KTX_error_code -ktxPrintInfoForMemory(const ktx_uint8_t* bytes, ktx_size_t size) -{ +ktxPrintInfoForMemory(const ktx_uint8_t* bytes, ktx_size_t size) { KTX_error_code result; ktxStream stream; result = ktxMemStream_construct_ro(&stream, bytes, size); - if (result == KTX_SUCCESS) - result = ktxPrintInfoForStream(&stream); + if (result == KTX_SUCCESS) result = ktxPrintInfoForStream(&stream); return result; } @@ -1223,17 +1132,14 @@ ktxPrintInfoForMemory(const ktx_uint8_t* bytes, ktx_size_t size) * @param [in] minified Specifies whether the JSON output should be minified. */ KTX_error_code -ktxPrintKTX2InfoJSONForStdioStream(FILE* stdioStream, ktx_uint32_t base_indent, ktx_uint32_t indent_width, bool minified) -{ +ktxPrintKTX2InfoJSONForStdioStream(FILE* stdioStream, ktx_uint32_t base_indent, ktx_uint32_t indent_width, bool minified) { KTX_error_code result; ktxStream stream; - if (stdioStream == NULL) - return KTX_INVALID_VALUE; + if (stdioStream == NULL) return KTX_INVALID_VALUE; result = ktxFileStream_construct(&stream, stdioStream, KTX_FALSE); - if (result == KTX_SUCCESS) - result = ktxPrintKTX2InfoJSONForStream(&stream, base_indent, indent_width, minified); + if (result == KTX_SUCCESS) result = ktxPrintKTX2InfoJSONForStream(&stream, base_indent, indent_width, minified); return result; } @@ -1247,14 +1153,12 @@ ktxPrintKTX2InfoJSONForStdioStream(FILE* stdioStream, ktx_uint32_t base_indent, * @param [in] minified Specifies whether the JSON output should be minified. */ KTX_error_code -ktxPrintKTX2InfoJSONForNamedFile(const char* const filename, ktx_uint32_t base_indent, ktx_uint32_t indent_width, bool minified) -{ +ktxPrintKTX2InfoJSONForNamedFile(const char* const filename, ktx_uint32_t base_indent, ktx_uint32_t indent_width, bool minified) { FILE* file = NULL; file = ktxFOpenUTF8(filename, "rb"); - if (!file) - return KTX_FILE_OPEN_FAILED; + if (!file) return KTX_FILE_OPEN_FAILED; KTX_error_code result = ktxPrintKTX2InfoJSONForStdioStream(file, base_indent, indent_width, minified); @@ -1273,14 +1177,13 @@ ktxPrintKTX2InfoJSONForNamedFile(const char* const filename, ktx_uint32_t base_i * @param [in] minified Specifies whether the JSON output should be minified. */ KTX_error_code -ktxPrintKTX2InfoJSONForMemory(const ktx_uint8_t* bytes, ktx_size_t size, ktx_uint32_t base_indent, ktx_uint32_t indent_width, bool minified) -{ +ktxPrintKTX2InfoJSONForMemory(const ktx_uint8_t* bytes, ktx_size_t size, ktx_uint32_t base_indent, ktx_uint32_t indent_width, + bool minified) { KTX_error_code result; ktxStream stream; result = ktxMemStream_construct_ro(&stream, bytes, size); - if (result == KTX_SUCCESS) - result = ktxPrintKTX2InfoJSONForStream(&stream, base_indent, indent_width, minified); + if (result == KTX_SUCCESS) result = ktxPrintKTX2InfoJSONForStream(&stream, base_indent, indent_width, minified); return result; } @@ -1293,17 +1196,14 @@ ktxPrintKTX2InfoJSONForMemory(const ktx_uint8_t* bytes, ktx_size_t size, ktx_uin * @param [in] stream pointer to the ktxStream reading the file. */ KTX_error_code -ktxPrintKTX2InfoTextForStdioStream(FILE* stdioStream) -{ +ktxPrintKTX2InfoTextForStdioStream(FILE* stdioStream) { KTX_error_code result; ktxStream stream; - if (stdioStream == NULL) - return KTX_INVALID_VALUE; + if (stdioStream == NULL) return KTX_INVALID_VALUE; result = ktxFileStream_construct(&stream, stdioStream, KTX_FALSE); - if (result == KTX_SUCCESS) - result = ktxPrintKTX2InfoTextForStream(&stream); + if (result == KTX_SUCCESS) result = ktxPrintKTX2InfoTextForStream(&stream); return result; } @@ -1314,8 +1214,7 @@ ktxPrintKTX2InfoTextForStdioStream(FILE* stdioStream) * @param [in] filename Filepath of the KTX2 file. */ KTX_error_code -ktxPrintKTX2InfoTextForNamedFile(const char* const filename) -{ +ktxPrintKTX2InfoTextForNamedFile(const char* const filename) { FILE* file = NULL; #ifdef _WIN32 @@ -1324,8 +1223,7 @@ ktxPrintKTX2InfoTextForNamedFile(const char* const filename) file = fopen(filename, "rb"); #endif - if (!file) - return KTX_FILE_OPEN_FAILED; + if (!file) return KTX_FILE_OPEN_FAILED; KTX_error_code result = ktxPrintKTX2InfoTextForStdioStream(file); @@ -1341,13 +1239,11 @@ ktxPrintKTX2InfoTextForNamedFile(const char* const filename) * @param [in] size length of the KTX file in bytes. */ KTX_error_code -ktxPrintKTX2InfoTextForMemory(const ktx_uint8_t* bytes, ktx_size_t size) -{ +ktxPrintKTX2InfoTextForMemory(const ktx_uint8_t* bytes, ktx_size_t size) { KTX_error_code result; ktxStream stream; result = ktxMemStream_construct_ro(&stream, bytes, size); - if (result == KTX_SUCCESS) - result = ktxPrintKTX2InfoTextForStream(&stream); + if (result == KTX_SUCCESS) result = ktxPrintKTX2InfoTextForStream(&stream); return result; } diff --git a/lib/ktxint.h b/lib/ktxint.h index fdfec56dcb..848e314ffb 100644 --- a/lib/ktxint.h +++ b/lib/ktxint.h @@ -8,7 +8,6 @@ * SPDX-License-Identifier: Apache-2.0 */ - /* * Author: Mark Callow from original code by Georg Kolling */ @@ -20,10 +19,10 @@ /* Define this to include the ETC unpack software in the library. */ #ifndef SUPPORT_SOFTWARE_ETC_UNPACK - /* Include for all GL versions because have seen OpenGL ES 3 - * implementaions that do not support ETC1 (ARM Mali emulator v1.0)! - */ - #define SUPPORT_SOFTWARE_ETC_UNPACK 1 +/* Include for all GL versions because have seen OpenGL ES 3 + * implementaions that do not support ETC1 (ARM Mali emulator v1.0)! + */ +#define SUPPORT_SOFTWARE_ETC_UNPACK 1 #endif #ifndef MAX @@ -36,8 +35,9 @@ #define QUOTE(x) #x #define STR(x) QUOTE(x) -#define KTX2_IDENTIFIER_REF { 0xAB, 0x4B, 0x54, 0x58, 0x20, 0x32, 0x30, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A } -#define KTX2_HEADER_SIZE (80) +#define KTX2_IDENTIFIER_REF \ + { 0xAB, 0x4B, 0x54, 0x58, 0x20, 0x32, 0x30, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A } +#define KTX2_HEADER_SIZE (80) #ifdef __cplusplus extern "C" { @@ -47,9 +47,9 @@ extern "C" { * @internal * @brief used to pass GL context capabilites to subroutines. */ -#define _KTX_NO_R16_FORMATS 0x0 -#define _KTX_R16_FORMATS_NORM 0x1 -#define _KTX_R16_FORMATS_SNORM 0x2 +#define _KTX_NO_R16_FORMATS 0x0 +#define _KTX_R16_FORMATS_NORM 0x1 +#define _KTX_R16_FORMATS_SNORM 0x2 #define _KTX_ALL_R16_FORMATS (_KTX_R16_FORMATS_NORM | _KTX_R16_FORMATS_SNORM) extern GLint _ktxR16Formats; extern GLboolean _ktxSupportsSRGB; @@ -62,7 +62,7 @@ extern GLboolean _ktxSupportsSRGB; * See the KTX specification for descriptions. */ typedef struct KTX_header { - ktx_uint8_t identifier[12]; + ktx_uint8_t identifier[12]; ktx_uint32_t endianness; ktx_uint32_t glType; ktx_uint32_t glTypeSize; @@ -79,7 +79,7 @@ typedef struct KTX_header { } KTX_header; /* This will cause compilation to fail if the struct size doesn't match */ -typedef int KTX_header_SIZE_ASSERT [sizeof(KTX_header) == KTX_HEADER_SIZE]; +typedef int KTX_header_SIZE_ASSERT[sizeof(KTX_header) == KTX_HEADER_SIZE]; /** * @internal @@ -108,7 +108,7 @@ typedef struct ktxIndexEntry64 { * See the KTX 2 specification for descriptions. */ typedef struct KTX_header2 { - ktx_uint8_t identifier[12]; + ktx_uint8_t identifier[12]; ktx_uint32_t vkFormat; ktx_uint32_t typeSize; ktx_uint32_t pixelWidth; @@ -124,7 +124,7 @@ typedef struct KTX_header2 { } KTX_header2; /* This will cause compilation to fail if the struct size doesn't match */ -typedef int KTX_header2_SIZE_ASSERT [sizeof(KTX_header2) == KTX2_HEADER_SIZE]; +typedef int KTX_header2_SIZE_ASSERT[sizeof(KTX_header2) == KTX2_HEADER_SIZE]; /** * @internal @@ -134,9 +134,9 @@ typedef int KTX_header2_SIZE_ASSERT [sizeof(KTX_header2) == KTX2_HEADER_SIZE]; typedef struct ktxLevelIndexEntry { ktx_uint64_t byteOffset; /*!< Offset of level from start of file. */ ktx_uint64_t byteLength; - /*!< Number of bytes of compressed image data in the level. */ + /*!< Number of bytes of compressed image data in the level. */ ktx_uint64_t uncompressedByteLength; - /*!< Number of bytes of uncompressed image data in the level. */ + /*!< Number of bytes of uncompressed image data in the level. */ } ktxLevelIndexEntry; /** @@ -147,8 +147,7 @@ typedef struct ktxLevelIndexEntry { * _ktxCheckHeader returns supplemental information about the texture in this * structure that is derived during checking of the file header. */ -typedef struct KTX_supplemental_info -{ +typedef struct KTX_supplemental_info { ktx_uint8_t compressed; ktx_uint8_t generateMipmaps; ktx_uint16_t textureDimension; @@ -178,8 +177,7 @@ typedef struct KTX_supplemental_info * * Reads the KTX file header and performs some sanity checking on the values */ -KTX_error_code ktxCheckHeader1_(KTX_header* pHeader, - KTX_supplemental_info* pSuppInfo); +KTX_error_code ktxCheckHeader1_(KTX_header* pHeader, KTX_supplemental_info* pSuppInfo); /* * @internal @@ -187,8 +185,7 @@ KTX_error_code ktxCheckHeader1_(KTX_header* pHeader, * * Reads the KTX 2 file header and performs some sanity checking on the values */ -KTX_error_code ktxCheckHeader2_(KTX_header2* pHeader, - KTX_supplemental_info* pSuppInfo); +KTX_error_code ktxCheckHeader2_(KTX_header2* pHeader, KTX_supplemental_info* pSuppInfo); /* * SwapEndian16: Swaps endianness in an array of 16-bit values @@ -208,11 +205,9 @@ void _ktxSwapEndian64(ktx_uint64_t* pData64, ktx_size_t count); /* * UnpackETC: uncompresses an ETC compressed texture image */ -KTX_error_code _ktxUnpackETC(const GLubyte* srcETC, const GLenum srcFormat, - ktx_uint32_t active_width, ktx_uint32_t active_height, - GLubyte** dstImage, - GLenum* format, GLenum* internalFormat, GLenum* type, - GLint R16Formats, GLboolean supportsSRGB); +KTX_error_code _ktxUnpackETC(const GLubyte* srcETC, const GLenum srcFormat, ktx_uint32_t active_width, ktx_uint32_t active_height, + GLubyte** dstImage, GLenum* format, GLenum* internalFormat, GLenum* type, GLint R16Formats, + GLboolean supportsSRGB); /* * @internal @@ -228,10 +223,7 @@ ktx_size_t ktxCompressZLIBBounds(ktx_size_t srcLength); * * Compresses data using miniz (ZLIB) */ -KTX_error_code ktxCompressZLIBInt(unsigned char* pDest, - ktx_size_t* pDestLength, - const unsigned char* pSrc, - ktx_size_t srcLength, +KTX_error_code ktxCompressZLIBInt(unsigned char* pDest, ktx_size_t* pDestLength, const unsigned char* pSrc, ktx_size_t srcLength, ktx_uint32_t level); /* @@ -240,10 +232,7 @@ KTX_error_code ktxCompressZLIBInt(unsigned char* pDest, * * Uncompresses data using miniz (ZLIB) */ -KTX_error_code ktxUncompressZLIBInt(unsigned char* pDest, - ktx_size_t* pDestLength, - const unsigned char* pSrc, - ktx_size_t srcLength); +KTX_error_code ktxUncompressZLIBInt(unsigned char* pDest, ktx_size_t* pDestLength, const unsigned char* pSrc, ktx_size_t srcLength); /* * Pad nbytes to next multiple of n @@ -253,8 +242,7 @@ KTX_error_code ktxUncompressZLIBInt(unsigned char* pDest, * Calculate bytes of of padding needed to reach next multiple of n. */ /* Equivalent to (n * ceil(nbytes / n)) - nbytes */ -#define _KTX_PADN_LEN(n, nbytes) \ - (ktx_uint32_t)((n * ceilf((float)(nbytes) / n)) - (nbytes)) +#define _KTX_PADN_LEN(n, nbytes) (ktx_uint32_t)((n * ceilf((float)(nbytes) / n)) - (nbytes)) /* * Pad nbytes to next multiple of 4 @@ -277,13 +265,11 @@ KTX_error_code ktxUncompressZLIBInt(unsigned char* pDest, /* * Pad nbytes to KTX_GL_UNPACK_ALIGNMENT */ -#define _KTX_PAD_UNPACK_ALIGN(nbytes) \ - _KTX_PADN(KTX_GL_UNPACK_ALIGNMENT, nbytes) +#define _KTX_PAD_UNPACK_ALIGN(nbytes) _KTX_PADN(KTX_GL_UNPACK_ALIGNMENT, nbytes) /* * Calculate bytes of of padding needed to reach KTX_GL_UNPACK_ALIGNMENT. */ -#define _KTX_PAD_UNPACK_ALIGN_LEN(nbytes) \ - _KTX_PADN_LEN(KTX_GL_UNPACK_ALIGNMENT, nbytes) +#define _KTX_PAD_UNPACK_ALIGN_LEN(nbytes) _KTX_PADN_LEN(KTX_GL_UNPACK_ALIGNMENT, nbytes) /* ====================================== @@ -310,12 +296,12 @@ KTX_error_code printKTX2Info2(ktxStream* src, KTX_header2* header); // For Windows, we convert the UTF-8 path and mode to UTF-16 path and use // _wfopen which correctly handles unicode characters. -static inline FILE* ktxFOpenUTF8(char const* path, char const* mode) { +static inline FILE* +ktxFOpenUTF8(char const* path, char const* mode) { int wpLen = MultiByteToWideChar(CP_UTF8, 0, path, -1, NULL, 0); int wmLen = MultiByteToWideChar(CP_UTF8, 0, mode, -1, NULL, 0); FILE* fp = NULL; - if (wpLen > 0 && wmLen > 0) - { + if (wpLen > 0 && wmLen > 0) { wchar_t* wpath = (wchar_t*)malloc(wpLen * sizeof(wchar_t)); wchar_t* wmode = (wchar_t*)malloc(wmLen * sizeof(wchar_t)); MultiByteToWideChar(CP_UTF8, 0, path, -1, wpath, wpLen); @@ -328,15 +314,15 @@ static inline FILE* ktxFOpenUTF8(char const* path, char const* mode) { free(wmode); return fp; } else { - assert(KTX_FALSE - && "ktxFOpenUTF8 called with zero length path or mode."); + assert(KTX_FALSE && "ktxFOpenUTF8 called with zero length path or mode."); return NULL; } } #else // For other platforms there is no need for any conversion, they // support UTF-8 natively. -static inline FILE* ktxFOpenUTF8(char const* path, char const* mode) { +static inline FILE* +ktxFOpenUTF8(char const* path, char const* mode) { return fopen(path, mode); } #endif diff --git a/lib/memstream.c b/lib/memstream.c index b963fa70ca..b263b2ed16 100644 --- a/lib/memstream.c +++ b/lib/memstream.c @@ -26,20 +26,19 @@ #include "memstream.h" /** -* @brief Default allocation size for a ktxMemStream. -*/ + * @brief Default allocation size for a ktxMemStream. + */ #define KTX_MEM_DEFAULT_ALLOCATED_SIZE 256 /** * @brief Structure to store information about data allocated for ktxMemStream. */ -struct ktxMem -{ - const ktx_uint8_t* robytes;/*!< pointer to read-only data */ - ktx_uint8_t* bytes; /*!< pointer to rw data. */ - ktx_size_t alloc_size; /*!< allocated size of the memory block. */ - ktx_size_t used_size; /*!< bytes used. Effectively the write position. */ - ktx_off_t pos; /*!< read/write position. */ +struct ktxMem { + const ktx_uint8_t* robytes; /*!< pointer to read-only data */ + ktx_uint8_t* bytes; /*!< pointer to rw data. */ + ktx_size_t alloc_size; /*!< allocated size of the memory block. */ + ktx_size_t used_size; /*!< bytes used. Effectively the write position. */ + ktx_off_t pos; /*!< read/write position. */ }; static KTX_error_code ktxMem_expand(ktxMem* pMem, const ktx_size_t size); @@ -56,8 +55,7 @@ static KTX_error_code ktxMem_expand(ktxMem* pMem, const ktx_size_t size); * @param [in] pMem pointer to the @c ktxMem to initialize. */ static KTX_error_code -ktxMem_construct(ktxMem* pMem) -{ +ktxMem_construct(ktxMem* pMem) { pMem->pos = 0; pMem->alloc_size = 0; pMem->robytes = 0; @@ -79,16 +77,13 @@ ktxMem_construct(ktxMem* pMem) * @exception KTX_OUT_OF_MEMORY System failed to allocate sufficient pMemory. */ static KTX_error_code -ktxMem_create(ktxMem** ppMem) -{ +ktxMem_create(ktxMem** ppMem) { ktxMem* pNewMem = (ktxMem*)malloc(sizeof(ktxMem)); if (pNewMem) { KTX_error_code result = ktxMem_construct(pNewMem); - if (result == KTX_SUCCESS) - *ppMem = pNewMem; + if (result == KTX_SUCCESS) *ppMem = pNewMem; return result; - } - else { + } else { return KTX_OUT_OF_MEMORY; } } @@ -101,8 +96,7 @@ ktxMem_create(ktxMem** ppMem) * @param [in] numBytes number of bytes of data. */ static void -ktxMem_construct_ro(ktxMem* pMem, const void* bytes, ktx_size_t numBytes) -{ +ktxMem_construct_ro(ktxMem* pMem, const void* bytes, ktx_size_t numBytes) { pMem->pos = 0; pMem->robytes = bytes; pMem->bytes = 0; @@ -125,15 +119,13 @@ ktxMem_construct_ro(ktxMem* pMem, const void* bytes, ktx_size_t numBytes) * @exception KTX_OUT_OF_MEMORY System failed to allocate sufficient pMemory. */ static KTX_error_code -ktxMem_create_ro(ktxMem** ppMem, const void* bytes, ktx_size_t numBytes) -{ +ktxMem_create_ro(ktxMem** ppMem, const void* bytes, ktx_size_t numBytes) { ktxMem* pNewMem = (ktxMem*)malloc(sizeof(ktxMem)); if (pNewMem) { ktxMem_construct_ro(pNewMem, bytes, numBytes); *ppMem = pNewMem; return KTX_SUCCESS; - } - else { + } else { return KTX_OUT_OF_MEMORY; } } @@ -149,8 +141,7 @@ ktxMem_create_ro(ktxMem** ppMem, const void* bytes, ktx_size_t numBytes) * @param pMem pointer to ktxMem to free. */ static void -ktxMem_destroy(ktxMem* pMem, ktx_bool_t freeData) -{ +ktxMem_destroy(ktxMem* pMem, ktx_bool_t freeData) { assert(pMem != NULL); if (freeData) { free(pMem->bytes); @@ -165,8 +156,7 @@ ktxMem_destroy(ktxMem* pMem, ktx_bool_t freeData) * @param pMem pointer to ktxMem to clear. */ static void -ktxMem_clear(ktxMem* pMem) -{ +ktxMem_clear(ktxMem* pMem) { assert(pMem != NULL); memset(pMem, 0, sizeof(ktxMem)); } @@ -184,14 +174,12 @@ ktxMem_clear(ktxMem* pMem) * @exception KTX_OUT_OF_MEMORY System failed to allocate sufficient pMemory. */ static KTX_error_code -ktxMem_expand(ktxMem *pMem, const ktx_size_t newsize) -{ +ktxMem_expand(ktxMem* pMem, const ktx_size_t newsize) { ktx_size_t new_alloc_size; assert(pMem != NULL && newsize != 0); - new_alloc_size = pMem->alloc_size == 0 ? - KTX_MEM_DEFAULT_ALLOCATED_SIZE : pMem->alloc_size; + new_alloc_size = pMem->alloc_size == 0 ? KTX_MEM_DEFAULT_ALLOCATED_SIZE : pMem->alloc_size; while (new_alloc_size < newsize) { ktx_size_t alloc_size = new_alloc_size; new_alloc_size <<= 1; @@ -201,16 +189,14 @@ ktxMem_expand(ktxMem *pMem, const ktx_size_t newsize) } } - if (new_alloc_size == pMem->alloc_size) - return KTX_SUCCESS; + if (new_alloc_size == pMem->alloc_size) return KTX_SUCCESS; if (!pMem->bytes) pMem->bytes = (ktx_uint8_t*)malloc(new_alloc_size); else pMem->bytes = (ktx_uint8_t*)realloc(pMem->bytes, new_alloc_size); - if (!pMem->bytes) - { + if (!pMem->bytes) { pMem->alloc_size = 0; pMem->used_size = 0; return KTX_OUT_OF_MEMORY; @@ -235,21 +221,17 @@ ktxMem_expand(ktxMem *pMem, const ktx_size_t newsize) * @c NULL. * @exception KTX_FILE_UNEXPECTED_EOF not enough data to satisfy the request. */ -static -KTX_error_code ktxMemStream_read(ktxStream* str, void* dst, const ktx_size_t count) -{ +static KTX_error_code +ktxMemStream_read(ktxStream* str, void* dst, const ktx_size_t count) { ktxMem* mem; ktx_off_t newpos; const ktx_uint8_t* bytes; - - if (!str || (mem = str->data.mem)== 0) - return KTX_INVALID_VALUE; + if (!str || (mem = str->data.mem) == 0) return KTX_INVALID_VALUE; newpos = mem->pos + count; /* The first clause checks for overflow. */ - if (newpos < mem->pos || (ktx_uint32_t)newpos > mem->used_size) - return KTX_FILE_UNEXPECTED_EOF; + if (newpos < mem->pos || (ktx_uint32_t)newpos > mem->used_size) return KTX_FILE_UNEXPECTED_EOF; bytes = mem->robytes ? mem->robytes : mem->bytes; memcpy(dst, bytes + mem->pos, count); @@ -271,19 +253,16 @@ KTX_error_code ktxMemStream_read(ktxStream* str, void* dst, const ktx_size_t cou * data is not available in ktxMem. * @exception KTX_FILE_UNEXPECTED_EOF not enough data to satisfy the request. */ -static -KTX_error_code ktxMemStream_skip(ktxStream* str, const ktx_size_t count) -{ +static KTX_error_code +ktxMemStream_skip(ktxStream* str, const ktx_size_t count) { ktxMem* mem; ktx_off_t newpos; - if (!str || (mem = str->data.mem) == 0) - return KTX_INVALID_VALUE; + if (!str || (mem = str->data.mem) == 0) return KTX_INVALID_VALUE; newpos = mem->pos + count; /* The first clause checks for overflow. */ - if (newpos < mem->pos || (ktx_uint32_t)newpos > mem->used_size) - return KTX_FILE_UNEXPECTED_EOF; + if (newpos < mem->pos || (ktx_uint32_t)newpos > mem->used_size) return KTX_FILE_UNEXPECTED_EOF; mem->pos = newpos; @@ -309,36 +288,28 @@ KTX_error_code ktxMemStream_skip(ktxStream* str, const ktx_size_t count) * @exception KTX_INVALID_VALUE @p dst is @c NULL or @p mem is @c NULL. * @exception KTX_OUT_OF_MEMORY See ktxMem_expand() for causes. */ -static -KTX_error_code ktxMemStream_write(ktxStream* str, const void* src, - const ktx_size_t size, const ktx_size_t count) -{ +static KTX_error_code +ktxMemStream_write(ktxStream* str, const void* src, const ktx_size_t size, const ktx_size_t count) { ktxMem* mem; KTX_error_code rc = KTX_SUCCESS; ktx_size_t new_size; - if (!str || (mem = str->data.mem) == 0) - return KTX_INVALID_VALUE; + if (!str || (mem = str->data.mem) == 0) return KTX_INVALID_VALUE; - if (mem->robytes) - return KTX_INVALID_OPERATION; /* read-only */ + if (mem->robytes) return KTX_INVALID_OPERATION; /* read-only */ - new_size = mem->pos + (size*count); - //if (new_size < mem->used_size) - if ((ktx_off_t)new_size < mem->pos) - return KTX_FILE_OVERFLOW; + new_size = mem->pos + (size * count); + // if (new_size < mem->used_size) + if ((ktx_off_t)new_size < mem->pos) return KTX_FILE_OVERFLOW; if (mem->alloc_size < new_size) { rc = ktxMem_expand(mem, new_size); - if (rc != KTX_SUCCESS) - return rc; + if (rc != KTX_SUCCESS) return rc; } - memcpy(mem->bytes + mem->pos, src, size*count); - mem->pos += size*count; - if (mem->pos > (ktx_off_t)mem->used_size) - mem->used_size = mem->pos; - + memcpy(mem->bytes + mem->pos, src, size * count); + mem->pos += size * count; + if (mem->pos > (ktx_off_t)mem->used_size) mem->used_size = mem->pos; return KTX_SUCCESS; } @@ -354,11 +325,9 @@ KTX_error_code ktxMemStream_write(ktxStream* str, const void* src, * * @exception KTX_INVALID_VALUE @p str or @p pos is @c NULL. */ -static -KTX_error_code ktxMemStream_getpos(ktxStream* str, ktx_off_t* const pos) -{ - if (!str || !pos) - return KTX_INVALID_VALUE; +static KTX_error_code +ktxMemStream_getpos(ktxStream* str, ktx_off_t* const pos) { + if (!str || !pos) return KTX_INVALID_VALUE; assert(str->type == eStreamTypeMemory); @@ -380,16 +349,13 @@ KTX_error_code ktxMemStream_getpos(ktxStream* str, ktx_off_t* const pos) * @exception KTX_INVALID_VALUE @p str is @c NULL. * @exception KTX_INVALID_OPERATION @p pos > size of the allocated memory. */ -static -KTX_error_code ktxMemStream_setpos(ktxStream* str, ktx_off_t pos) -{ - if (!str) - return KTX_INVALID_VALUE; +static KTX_error_code +ktxMemStream_setpos(ktxStream* str, ktx_off_t pos) { + if (!str) return KTX_INVALID_VALUE; assert(str->type == eStreamTypeMemory); - if (pos > (ktx_off_t)str->data.mem->alloc_size) - return KTX_INVALID_OPERATION; + if (pos > (ktx_off_t)str->data.mem->alloc_size) return KTX_INVALID_OPERATION; str->data.mem->pos = pos; return KTX_SUCCESS; @@ -411,10 +377,9 @@ KTX_error_code ktxMemStream_setpos(ktxStream* str, ktx_off_t pos) * * @exception KTX_INVALID_VALUE @p str or @p ppBytes is @c NULL. */ -KTX_error_code ktxMemStream_getdata(ktxStream* str, ktx_uint8_t** ppBytes) -{ - if (!str || !ppBytes) - return KTX_INVALID_VALUE; +KTX_error_code +ktxMemStream_getdata(ktxStream* str, ktx_uint8_t** ppBytes) { + if (!str || !ppBytes) return KTX_INVALID_VALUE; assert(str->type == eStreamTypeMemory); @@ -433,11 +398,9 @@ KTX_error_code ktxMemStream_getdata(ktxStream* str, ktx_uint8_t** ppBytes) * * @exception KTX_INVALID_VALUE @p str or @p pSize is @c NULL. */ -static -KTX_error_code ktxMemStream_getsize(ktxStream* str, ktx_size_t* pSize) -{ - if (!str || !pSize) - return KTX_INVALID_VALUE; +static KTX_error_code +ktxMemStream_getsize(ktxStream* str, ktx_size_t* pSize) { + if (!str || !pSize) return KTX_INVALID_VALUE; assert(str->type == eStreamTypeMemory); @@ -450,8 +413,7 @@ KTX_error_code ktxMemStream_getsize(ktxStream* str, ktx_size_t* pSize) * @brief Setup ktxMemStream function pointers. */ void -ktxMemStream_setup(ktxStream* str) -{ +ktxMemStream_setup(ktxStream* str) { str->type = eStreamTypeMemory; str->read = ktxMemStream_read; str->skip = ktxMemStream_skip; @@ -479,14 +441,12 @@ ktxMemStream_setup(ktxStream* str) * @exception KTX_INVALID_VALUE @p str is @c NULL. * @exception KTX_OUT_OF_MEMORY system failed to allocate sufficient memory. */ -KTX_error_code ktxMemStream_construct(ktxStream* str, - ktx_bool_t freeOnDestruct) -{ +KTX_error_code +ktxMemStream_construct(ktxStream* str, ktx_bool_t freeOnDestruct) { ktxMem* mem; KTX_error_code result = KTX_SUCCESS; - if (!str) - return KTX_INVALID_VALUE; + if (!str) return KTX_INVALID_VALUE; result = ktxMem_create(&mem); @@ -514,15 +474,12 @@ KTX_error_code ktxMemStream_construct(ktxStream* str, * or @p size is less than 0. * @exception KTX_OUT_OF_MEMORY system failed to allocate sufficient memory. */ -KTX_error_code ktxMemStream_construct_ro(ktxStream* str, - const ktx_uint8_t* bytes, - const ktx_size_t numBytes) -{ +KTX_error_code +ktxMemStream_construct_ro(ktxStream* str, const ktx_uint8_t* bytes, const ktx_size_t numBytes) { ktxMem* mem; KTX_error_code result = KTX_SUCCESS; - if (!str || !bytes || numBytes == 0) - return KTX_INVALID_VALUE; + if (!str || !bytes || numBytes == 0) return KTX_INVALID_VALUE; result = ktxMem_create_ro(&mem, bytes, numBytes); @@ -551,11 +508,9 @@ KTX_error_code ktxMemStream_construct_ro(ktxStream* str, * to be freed. */ void -ktxMemStream_destruct(ktxStream* str) -{ +ktxMemStream_destruct(ktxStream* str) { assert(str && str->type == eStreamTypeMemory); ktxMem_destroy(str->data.mem, str->closeOnDestruct); str->data.mem = NULL; } - diff --git a/lib/memstream.h b/lib/memstream.h index 4ef8d59cd2..890d14def7 100644 --- a/lib/memstream.h +++ b/lib/memstream.h @@ -27,15 +27,12 @@ * Initialize a ktxStream to a ktxMemStream with internally * allocated memory. Can be read or written. */ -KTX_error_code ktxMemStream_construct(ktxStream* str, - ktx_bool_t freeOnDestruct); +KTX_error_code ktxMemStream_construct(ktxStream* str, ktx_bool_t freeOnDestruct); /* * Initialize a ktxStream to a read-only ktxMemStream reading * from an array of bytes. */ -KTX_error_code ktxMemStream_construct_ro(ktxStream* str, - const ktx_uint8_t* pBytes, - const ktx_size_t size); +KTX_error_code ktxMemStream_construct_ro(ktxStream* str, const ktx_uint8_t* pBytes, const ktx_size_t size); void ktxMemStream_destruct(ktxStream* str); KTX_error_code ktxMemStream_getdata(ktxStream* str, ktx_uint8_t** ppBytes); diff --git a/lib/miniz_wrapper.cpp b/lib/miniz_wrapper.cpp index 07920c4809..6d3590edb5 100644 --- a/lib/miniz_wrapper.cpp +++ b/lib/miniz_wrapper.cpp @@ -40,12 +40,23 @@ // not declaring the functions as static or inline, hence causing multiple // conflicting definitions at link-time. namespace buminiz { - typedef unsigned long mz_ulong; - enum { MZ_OK = 0, MZ_STREAM_END = 1, MZ_NEED_DICT = 2, MZ_ERRNO = -1, MZ_STREAM_ERROR = -2, MZ_DATA_ERROR = -3, MZ_MEM_ERROR = -4, MZ_BUF_ERROR = -5, MZ_VERSION_ERROR = -6, MZ_PARAM_ERROR = -10000 }; - mz_ulong mz_compressBound(mz_ulong source_len); - int mz_compress2(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len, int level); - int mz_uncompress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len); -} +typedef unsigned long mz_ulong; +enum { + MZ_OK = 0, + MZ_STREAM_END = 1, + MZ_NEED_DICT = 2, + MZ_ERRNO = -1, + MZ_STREAM_ERROR = -2, + MZ_DATA_ERROR = -3, + MZ_MEM_ERROR = -4, + MZ_BUF_ERROR = -5, + MZ_VERSION_ERROR = -6, + MZ_PARAM_ERROR = -10000 +}; +mz_ulong mz_compressBound(mz_ulong source_len); +int mz_compress2(unsigned char* pDest, mz_ulong* pDest_len, const unsigned char* pSource, mz_ulong source_len, int level); +int mz_uncompress(unsigned char* pDest, mz_ulong* pDest_len, const unsigned char* pSource, mz_ulong source_len); +} // namespace buminiz #endif using namespace buminiz; @@ -61,7 +72,8 @@ extern "C" { * * @author Daniel Rakos, RasterGrid */ -ktx_size_t ktxCompressZLIBBounds(ktx_size_t srcLength) { +ktx_size_t +ktxCompressZLIBBounds(ktx_size_t srcLength) { return mz_compressBound((mz_ulong)srcLength); } @@ -79,11 +91,9 @@ ktx_size_t ktxCompressZLIBBounds(ktx_size_t srcLength) { * * @author Daniel Rakos, RasterGrid */ -KTX_error_code ktxCompressZLIBInt(unsigned char* pDest, - ktx_size_t* pDestLength, - const unsigned char* pSrc, - ktx_size_t srcLength, - ktx_uint32_t level) { +KTX_error_code +ktxCompressZLIBInt(unsigned char* pDest, ktx_size_t* pDestLength, const unsigned char* pSrc, ktx_size_t srcLength, + ktx_uint32_t level) { if ((srcLength | *pDestLength) > 0xFFFFFFFFU) return KTX_INVALID_VALUE; mz_ulong mzCompressedSize = (mz_ulong)*pDestLength; int status = mz_compress2(pDest, &mzCompressedSize, pSrc, (mz_ulong)srcLength, level); @@ -126,10 +136,8 @@ KTX_error_code ktxCompressZLIBInt(unsigned char* pDest, * * @author Daniel Rakos, RasterGrid */ -KTX_error_code ktxUncompressZLIBInt(unsigned char* pDest, - ktx_size_t* pDestLength, - const unsigned char* pSrc, - ktx_size_t srcLength) { +KTX_error_code +ktxUncompressZLIBInt(unsigned char* pDest, ktx_size_t* pDestLength, const unsigned char* pSrc, ktx_size_t srcLength) { if ((srcLength | *pDestLength) > 0xFFFFFFFFU) return KTX_INVALID_VALUE; mz_ulong mzUncompressedSize = (mz_ulong)*pDestLength; int status = mz_uncompress(pDest, &mzUncompressedSize, pSrc, (mz_ulong)srcLength); @@ -138,12 +146,11 @@ KTX_error_code ktxUncompressZLIBInt(unsigned char* pDest, *pDestLength = mzUncompressedSize; return KTX_SUCCESS; case MZ_BUF_ERROR: - return KTX_DECOMPRESS_LENGTH_ERROR; // buffer too small + return KTX_DECOMPRESS_LENGTH_ERROR; // buffer too small case MZ_MEM_ERROR: return KTX_OUT_OF_MEMORY; default: return KTX_FILE_DATA_ERROR; } } - } diff --git a/lib/strings.c b/lib/strings.c index 1545341bd3..ef6007393e 100644 --- a/lib/strings.c +++ b/lib/strings.c @@ -19,27 +19,27 @@ #include "basis_sgd.h" static const char* const errorStrings[] = { - "Operation succeeded.", /* KTX_SUCCESS */ - "File data is inconsistent with KTX spec.", /* KTX_FILE_DATA_ERROR */ - "File is a pipe; seek operations not possible.", /* KTX_FILE_ISPIPE */ - "File open failed.", /* KTX_FILE_OPEN_FAILED */ - "Operation would exceed the max file size.", /* KTX_FILE_OVERFLOW */ - "File read error.", /* KTX_FILE_READ_ERROR */ - "File seek error.", /* KTX_FILE_SEEK_ERROR */ - "File does not have enough data for request.", /* KTX_FILE_UNEXPECTED_EOF */ - "File write error.", /* KTX_FILE_WRITE_ERROR */ - "GL error occurred.", /* KTX_GL_ERROR */ - "Operation not allowed in the current state.", /* KTX_INVALID_OPERATION */ - "Invalid parameter value.", /* KTX_INVALID_VALUE */ - "Metadata key or loader-required GPU function not found.", /* KTX_NOT_FOUND */ - "Out of memory.", /* KTX_OUT_OF_MEMORY */ - "Transcoding of block compressed texture failed.",/* KTX_TRANSCODE_FAILED */ - "Not a KTX file.", /* KTX_UNKNOWN_FILE_FORMAT */ - "Texture type not supported.", /* KTX_UNSUPPORTED_TEXTURE_TYPE */ - "Feature not included in in-use library or not yet implemented.", /* KTX_UNSUPPORTED_FEATURE */ + "Operation succeeded.", /* KTX_SUCCESS */ + "File data is inconsistent with KTX spec.", /* KTX_FILE_DATA_ERROR */ + "File is a pipe; seek operations not possible.", /* KTX_FILE_ISPIPE */ + "File open failed.", /* KTX_FILE_OPEN_FAILED */ + "Operation would exceed the max file size.", /* KTX_FILE_OVERFLOW */ + "File read error.", /* KTX_FILE_READ_ERROR */ + "File seek error.", /* KTX_FILE_SEEK_ERROR */ + "File does not have enough data for request.", /* KTX_FILE_UNEXPECTED_EOF */ + "File write error.", /* KTX_FILE_WRITE_ERROR */ + "GL error occurred.", /* KTX_GL_ERROR */ + "Operation not allowed in the current state.", /* KTX_INVALID_OPERATION */ + "Invalid parameter value.", /* KTX_INVALID_VALUE */ + "Metadata key or loader-required GPU function not found.", /* KTX_NOT_FOUND */ + "Out of memory.", /* KTX_OUT_OF_MEMORY */ + "Transcoding of block compressed texture failed.", /* KTX_TRANSCODE_FAILED */ + "Not a KTX file.", /* KTX_UNKNOWN_FILE_FORMAT */ + "Texture type not supported.", /* KTX_UNSUPPORTED_TEXTURE_TYPE */ + "Feature not included in in-use library or not yet implemented.", /* KTX_UNSUPPORTED_FEATURE */ "Library dependency (OpenGL or Vulkan) not linked into application.", /* KTX_LIBRARY_NOT_LINKED */ - "Decompressed byte count does not match expected byte size", /* KTX_DECOMPRESS_LENGTH_ERROR */ - "Checksum mismatch when decompressing" /* KTX_DECOMPRESS_CHECKSUM_ERROR */ + "Decompressed byte count does not match expected byte size", /* KTX_DECOMPRESS_LENGTH_ERROR */ + "Checksum mismatch when decompressing" /* KTX_DECOMPRESS_CHECKSUM_ERROR */ }; /* This will cause compilation to fail if number of messages and codes doesn't match */ typedef int errorStrings_SIZE_ASSERT[sizeof(errorStrings) / sizeof(char*) - 1 == KTX_ERROR_MAX_ENUM]; @@ -56,75 +56,97 @@ typedef int errorStrings_SIZE_ASSERT[sizeof(errorStrings) / sizeof(char*) - 1 == * * @author Mark Callow */ -const char* ktxErrorString(KTX_error_code error) -{ - if (error > KTX_ERROR_MAX_ENUM) - return "Unrecognized error code"; +const char* +ktxErrorString(KTX_error_code error) { + if (error > KTX_ERROR_MAX_ENUM) return "Unrecognized error code"; return errorStrings[error]; } /** -* @~English -* @brief Return a string corresponding to a transcode format enumeration. -* -* @param format the transcode format for which to return a string. -* -* @return pointer to the message string. -* -* @internal Use UTF-8 for translated message strings. -* -* @author Mark Callow -*/ -const char* ktxTranscodeFormatString(ktx_transcode_fmt_e format) -{ + * @~English + * @brief Return a string corresponding to a transcode format enumeration. + * + * @param format the transcode format for which to return a string. + * + * @return pointer to the message string. + * + * @internal Use UTF-8 for translated message strings. + * + * @author Mark Callow + */ +const char* +ktxTranscodeFormatString(ktx_transcode_fmt_e format) { switch (format) { - case KTX_TTF_ETC1_RGB: return "ETC1_RGB"; - case KTX_TTF_ETC2_RGBA: return "ETC2_RGBA"; - case KTX_TTF_BC1_RGB: return "BC1_RGB"; - case KTX_TTF_BC3_RGBA: return "BC3_RGBA"; - case KTX_TTF_BC4_R: return "BC4_R"; - case KTX_TTF_BC5_RG: return "BC5_RG"; - case KTX_TTF_BC7_RGBA: return "BC7_RGBA"; - case KTX_TTF_PVRTC1_4_RGB: return "PVRTC1_4_RGB"; - case KTX_TTF_PVRTC1_4_RGBA: return "PVRTC1_4_RGBA"; - case KTX_TTF_ASTC_4x4_RGBA: return "ASTC_4x4_RGBA"; - case KTX_TTF_RGBA32: return "RGBA32"; - case KTX_TTF_RGB565: return "RGB565"; - case KTX_TTF_BGR565: return "BGR565"; - case KTX_TTF_RGBA4444: return "RGBA4444"; - case KTX_TTF_PVRTC2_4_RGB: return "PVRTC2_4_RGB"; - case KTX_TTF_PVRTC2_4_RGBA: return "PVRTC2_4_RGBA"; - case KTX_TTF_ETC2_EAC_R11: return "ETC2_EAC_R11"; - case KTX_TTF_ETC2_EAC_RG11: return "ETC2_EAC_RG11"; - case KTX_TTF_ETC: return "ETC"; - case KTX_TTF_BC1_OR_3: return "BC1 or BC3"; - default: return "Unrecognized format"; + case KTX_TTF_ETC1_RGB: + return "ETC1_RGB"; + case KTX_TTF_ETC2_RGBA: + return "ETC2_RGBA"; + case KTX_TTF_BC1_RGB: + return "BC1_RGB"; + case KTX_TTF_BC3_RGBA: + return "BC3_RGBA"; + case KTX_TTF_BC4_R: + return "BC4_R"; + case KTX_TTF_BC5_RG: + return "BC5_RG"; + case KTX_TTF_BC7_RGBA: + return "BC7_RGBA"; + case KTX_TTF_PVRTC1_4_RGB: + return "PVRTC1_4_RGB"; + case KTX_TTF_PVRTC1_4_RGBA: + return "PVRTC1_4_RGBA"; + case KTX_TTF_ASTC_4x4_RGBA: + return "ASTC_4x4_RGBA"; + case KTX_TTF_RGBA32: + return "RGBA32"; + case KTX_TTF_RGB565: + return "RGB565"; + case KTX_TTF_BGR565: + return "BGR565"; + case KTX_TTF_RGBA4444: + return "RGBA4444"; + case KTX_TTF_PVRTC2_4_RGB: + return "PVRTC2_4_RGB"; + case KTX_TTF_PVRTC2_4_RGBA: + return "PVRTC2_4_RGBA"; + case KTX_TTF_ETC2_EAC_R11: + return "ETC2_EAC_R11"; + case KTX_TTF_ETC2_EAC_RG11: + return "ETC2_EAC_RG11"; + case KTX_TTF_ETC: + return "ETC"; + case KTX_TTF_BC1_OR_3: + return "BC1 or BC3"; + default: + return "Unrecognized format"; } } /** -* @~English -* @brief Return a string corresponding to a supercompressionScheme enumeration. -* -* @param scheme the supercompression scheme for which to return a string. -* -* @return pointer to the message string. -* -* @internal Use UTF-8 for translated message strings. -* -* @author Mark Callow -*/ -const char * -ktxSupercompressionSchemeString(ktxSupercmpScheme scheme) -{ + * @~English + * @brief Return a string corresponding to a supercompressionScheme enumeration. + * + * @param scheme the supercompression scheme for which to return a string. + * + * @return pointer to the message string. + * + * @internal Use UTF-8 for translated message strings. + * + * @author Mark Callow + */ +const char* +ktxSupercompressionSchemeString(ktxSupercmpScheme scheme) { switch (scheme) { - case KTX_SS_NONE: return "KTX_SS_NONE"; - case KTX_SS_BASIS_LZ: return "KTX_SS_BASIS_LZ"; - case KTX_SS_ZSTD: return "KTX_SS_ZSTD"; - case KTX_SS_ZLIB: return "KTX_SS_ZLIB"; - default: - if (scheme < KTX_SS_BEGIN_VENDOR_RANGE - || scheme >= KTX_SS_BEGIN_RESERVED) + case KTX_SS_NONE: + return "KTX_SS_NONE"; + case KTX_SS_BASIS_LZ: + return "KTX_SS_BASIS_LZ"; + case KTX_SS_ZSTD: + return "KTX_SS_ZSTD"; + case KTX_SS_ZLIB: + return "KTX_SS_ZLIB"; + default: + if (scheme < KTX_SS_BEGIN_VENDOR_RANGE || scheme >= KTX_SS_BEGIN_RESERVED) return "Invalid scheme value"; else return "Vendor or reserved scheme"; @@ -132,23 +154,24 @@ ktxSupercompressionSchemeString(ktxSupercmpScheme scheme) } /** -* @~English -* @brief Return a string corresponding to a bu_image_flags bit. -* -* @param bit_index the bu_image_flag bit to test. -* @param bit_value the bu_image_flag bit value. -* -* @return pointer to the message string or NULL otherwise. -* -* @internal Use UTF-8 for translated message strings. -*/ -const char* ktxBUImageFlagsBitString(ktx_uint32_t bit_index, bool bit_value) -{ - if (!bit_value) - return NULL; + * @~English + * @brief Return a string corresponding to a bu_image_flags bit. + * + * @param bit_index the bu_image_flag bit to test. + * @param bit_value the bu_image_flag bit value. + * + * @return pointer to the message string or NULL otherwise. + * + * @internal Use UTF-8 for translated message strings. + */ +const char* +ktxBUImageFlagsBitString(ktx_uint32_t bit_index, bool bit_value) { + if (!bit_value) return NULL; switch (1u << bit_index) { - case ETC1S_P_FRAME: return "ETC1S_P_FRAME"; - default: return NULL; + case ETC1S_P_FRAME: + return "ETC1S_P_FRAME"; + default: + return NULL; } } diff --git a/lib/swap.c b/lib/swap.c index 02ea6de2d8..aed7d1832f 100644 --- a/lib/swap.c +++ b/lib/swap.c @@ -15,10 +15,8 @@ * SwapEndian16: Swaps endianness in an array of 16-bit values */ void -_ktxSwapEndian16(khronos_uint16_t* pData16, ktx_size_t count) -{ - for (ktx_size_t i = 0; i < count; ++i) - { +_ktxSwapEndian16(khronos_uint16_t* pData16, ktx_size_t count) { + for (ktx_size_t i = 0; i < count; ++i) { khronos_uint16_t x = *pData16; *pData16++ = (x << 8) | (x >> 8); } @@ -28,10 +26,8 @@ _ktxSwapEndian16(khronos_uint16_t* pData16, ktx_size_t count) * SwapEndian32: Swaps endianness in an array of 32-bit values */ void -_ktxSwapEndian32(khronos_uint32_t* pData32, ktx_size_t count) -{ - for (ktx_size_t i = 0; i < count; ++i) - { +_ktxSwapEndian32(khronos_uint32_t* pData32, ktx_size_t count) { + for (ktx_size_t i = 0; i < count; ++i) { khronos_uint32_t x = *pData32; *pData32++ = (x << 24) | ((x & 0xFF00) << 8) | ((x & 0xFF0000) >> 8) | (x >> 24); } @@ -41,17 +37,10 @@ _ktxSwapEndian32(khronos_uint32_t* pData32, ktx_size_t count) * SwapEndian364: Swaps endianness in an array of 32-bit values */ void -_ktxSwapEndian64(khronos_uint64_t* pData64, ktx_size_t count) -{ - for (ktx_size_t i = 0; i < count; ++i) - { +_ktxSwapEndian64(khronos_uint64_t* pData64, ktx_size_t count) { + for (ktx_size_t i = 0; i < count; ++i) { khronos_uint64_t x = *pData64; - *pData64++ = (x << 56) | ((x & 0xFF00) << 40) | ((x & 0xFF0000) << 24) - | ((x & 0xFF000000) << 8 ) | ((x & 0xFF00000000) >> 8) - | ((x & 0xFF0000000000) >> 24) - | ((x & 0xFF000000000000) << 40) | (x >> 56); + *pData64++ = (x << 56) | ((x & 0xFF00) << 40) | ((x & 0xFF0000) << 24) | ((x & 0xFF000000) << 8) | + ((x & 0xFF00000000) >> 8) | ((x & 0xFF0000000000) >> 24) | ((x & 0xFF000000000000) << 40) | (x >> 56); } } - - - diff --git a/lib/texture.c b/lib/texture.c index 76821e195b..091d32f4d3 100644 --- a/lib/texture.c +++ b/lib/texture.c @@ -17,11 +17,11 @@ */ #if defined(_WIN32) - #define _CRT_SECURE_NO_WARNINGS - #ifndef __cplusplus - #undef inline - #define inline __inline - #endif // __cplusplus +#define _CRT_SECURE_NO_WARNINGS +#ifndef __cplusplus +#undef inline +#define inline __inline +#endif // __cplusplus #endif #include @@ -81,15 +81,12 @@ static ktx_uint32_t padRow(ktx_uint32_t* rowBytes); * @exception KTX_OUT_OF_MEMORY Not enough memory for the texture. */ KTX_error_code -ktxTexture_construct(ktxTexture* This, ktxTextureCreateInfo* createInfo, - ktxFormatSize* formatSize) -{ +ktxTexture_construct(ktxTexture* This, ktxTextureCreateInfo* createInfo, ktxFormatSize* formatSize) { DECLARE_PROTECTED(ktxTexture); memset(This, 0, sizeof(*This)); This->_protected = (struct ktxTexture_protected*)malloc(sizeof(*prtctd)); - if (!This->_protected) - return KTX_OUT_OF_MEMORY; + if (!This->_protected) return KTX_OUT_OF_MEMORY; prtctd = This->_protected; memset(prtctd, 0, sizeof(*prtctd)); memcpy(&prtctd->_formatSize, formatSize, sizeof(prtctd->_formatSize)); @@ -103,31 +100,24 @@ ktxTexture_construct(ktxTexture* This, ktxTextureCreateInfo* createInfo, /* Check texture dimensions. KTX files can store 8 types of textures: * 1D, 2D, 3D, cube, and array variants of these. */ - if (createInfo->numDimensions < 1 || createInfo->numDimensions > 3) - return KTX_INVALID_VALUE; + if (createInfo->numDimensions < 1 || createInfo->numDimensions > 3) return KTX_INVALID_VALUE; - if (createInfo->baseWidth == 0 || createInfo->baseHeight == 0 - || createInfo->baseDepth == 0) - return KTX_INVALID_VALUE; + if (createInfo->baseWidth == 0 || createInfo->baseHeight == 0 || createInfo->baseDepth == 0) return KTX_INVALID_VALUE; switch (createInfo->numDimensions) { - case 1: - if (createInfo->baseHeight > 1 || createInfo->baseDepth > 1) - return KTX_INVALID_OPERATION; + case 1: + if (createInfo->baseHeight > 1 || createInfo->baseDepth > 1) return KTX_INVALID_OPERATION; break; - case 2: - if (createInfo->baseDepth > 1) - return KTX_INVALID_OPERATION; + case 2: + if (createInfo->baseDepth > 1) return KTX_INVALID_OPERATION; break; - case 3: + case 3: /* 3D array textures and 3D cubemaps are not supported by either * OpenGL or Vulkan. */ - if (createInfo->isArray || createInfo->numFaces != 1 - || createInfo->numLayers != 1) - return KTX_INVALID_OPERATION; + if (createInfo->isArray || createInfo->numFaces != 1 || createInfo->numLayers != 1) return KTX_INVALID_OPERATION; break; } This->numDimensions = createInfo->numDimensions; @@ -135,8 +125,7 @@ ktxTexture_construct(ktxTexture* This, ktxTextureCreateInfo* createInfo, This->baseDepth = createInfo->baseDepth; This->baseHeight = createInfo->baseHeight; - if (createInfo->numLayers == 0) - return KTX_INVALID_VALUE; + if (createInfo->numLayers == 0) return KTX_INVALID_VALUE; This->numLayers = createInfo->numLayers; This->isArray = createInfo->isArray; @@ -157,16 +146,13 @@ ktxTexture_construct(ktxTexture* This, ktxTextureCreateInfo* createInfo, This->numFaces = createInfo->numFaces; /* Check number of mipmap levels */ - if (createInfo->numLevels == 0) - return KTX_INVALID_VALUE; + if (createInfo->numLevels == 0) return KTX_INVALID_VALUE; This->numLevels = createInfo->numLevels; This->generateMipmaps = createInfo->generateMipmaps; if (createInfo->numLevels > 1) { - GLuint max_dim = MAX(MAX(createInfo->baseWidth, createInfo->baseHeight), - createInfo->baseDepth); - if (max_dim < ((GLuint)1 << (This->numLevels - 1))) - { + GLuint max_dim = MAX(MAX(createInfo->baseWidth, createInfo->baseHeight), createInfo->baseDepth); + if (max_dim < ((GLuint)1 << (This->numLevels - 1))) { /* Can't have more mip levels than 1 + log2(max(width, height, depth)) */ return KTX_INVALID_OPERATION; } @@ -188,20 +174,15 @@ ktxTexture_construct(ktxTexture* This, ktxTextureCreateInfo* createInfo, * @return KTX_SUCCESS on success, other KTX_* enum values on error. */ KTX_error_code -ktxTexture_constructFromStream(ktxTexture* This, ktxStream* pStream, - ktxTextureCreateFlags createFlags) -{ +ktxTexture_constructFromStream(ktxTexture* This, ktxStream* pStream, ktxTextureCreateFlags createFlags) { ktxStream* stream; - UNUSED(createFlags); // Reference to keep compiler happy. + UNUSED(createFlags); // Reference to keep compiler happy. assert(This != NULL); assert(pStream->data.mem != NULL); - assert(pStream->type == eStreamTypeFile - || pStream->type == eStreamTypeMemory - || pStream->type == eStreamTypeCustom); + assert(pStream->type == eStreamTypeFile || pStream->type == eStreamTypeMemory || pStream->type == eStreamTypeCustom); - This->_protected = (struct ktxTexture_protected *) - malloc(sizeof(struct ktxTexture_protected)); + This->_protected = (struct ktxTexture_protected*)malloc(sizeof(struct ktxTexture_protected)); stream = ktxTexture_getStream(This); // Copy stream info into struct for later use. *stream = *pStream; @@ -213,7 +194,6 @@ ktxTexture_constructFromStream(ktxTexture* This, ktxStream* pStream, return KTX_SUCCESS; } - /** * @memberof ktxTexture @private * @~English @@ -223,22 +203,16 @@ ktxTexture_constructFromStream(ktxTexture* This, ktxStream* pStream, * to be freed. */ void -ktxTexture_destruct(ktxTexture* This) -{ +ktxTexture_destruct(ktxTexture* This) { ktxStream stream = *(ktxTexture_getStream(This)); - if (stream.data.file != NULL) - stream.destruct(&stream); - if (This->kvDataHead != NULL) - ktxHashList_Destruct(&This->kvDataHead); - if (This->kvData != NULL) - free(This->kvData); - if (This->pData != NULL) - free(This->pData); + if (stream.data.file != NULL) stream.destruct(&stream); + if (This->kvDataHead != NULL) ktxHashList_Destruct(&This->kvDataHead); + if (This->kvData != NULL) free(This->kvData); + if (This->pData != NULL) free(This->pData); free(This->_protected); } - /** * @defgroup reader Reader * @brief Read KTX-formatted data. @@ -263,18 +237,14 @@ typedef union { * written. */ static KTX_error_code -ktxDetermineFileType_(ktxStream* pStream, ktxFileType_* pFileType, - ktxHeaderUnion_* pHeader) -{ +ktxDetermineFileType_(ktxStream* pStream, ktxFileType_* pFileType, ktxHeaderUnion_* pHeader) { ktx_uint8_t ktx_ident_ref[12] = KTX_IDENTIFIER_REF; ktx_uint8_t ktx2_ident_ref[12] = KTX2_IDENTIFIER_REF; KTX_error_code result; assert(pStream != NULL && pFileType != NULL); assert(pStream->data.mem != NULL); - assert(pStream->type == eStreamTypeFile - || pStream->type == eStreamTypeMemory - || pStream->type == eStreamTypeCustom); + assert(pStream->type == eStreamTypeFile || pStream->type == eStreamTypeMemory || pStream->type == eStreamTypeCustom); result = pStream->read(pStream, pHeader, sizeof(ktx2_ident_ref)); if (result == KTX_SUCCESS) { @@ -283,20 +253,18 @@ ktxDetermineFileType_(ktxStream* pStream, ktxFileType_* pFileType, #endif // Compare identifier, is this a KTX or KTX2 file? if (!memcmp(pHeader->ktx.identifier, ktx_ident_ref, 12)) { - *pFileType = KTX1; + *pFileType = KTX1; } else if (!memcmp(pHeader->ktx2.identifier, ktx2_ident_ref, 12)) { - *pFileType = KTX2; + *pFileType = KTX2; } else { - return KTX_UNKNOWN_FILE_FORMAT; + return KTX_UNKNOWN_FILE_FORMAT; } // Read rest of header. if (*pFileType == KTX1) { // Read rest of header. - result = pStream->read(pStream, &pHeader->ktx.endianness, - KTX_HEADER_SIZE - sizeof(ktx_ident_ref)); + result = pStream->read(pStream, &pHeader->ktx.endianness, KTX_HEADER_SIZE - sizeof(ktx_ident_ref)); } else { - result = pStream->read(pStream, &pHeader->ktx2.vkFormat, - KTX2_HEADER_SIZE - sizeof(ktx2_ident_ref)); + result = pStream->read(pStream, &pHeader->ktx2.vkFormat, KTX2_HEADER_SIZE - sizeof(ktx2_ident_ref)); } } return result; @@ -314,36 +282,26 @@ ktxDetermineFileType_(ktxStream* pStream, ktxFileType_* pFileType, * "ktxTexture2_CreateFromStream" for details. */ KTX_error_code -ktxTexture_CreateFromStream(ktxStream* pStream, - ktxTextureCreateFlags createFlags, - ktxTexture** newTex) -{ +ktxTexture_CreateFromStream(ktxStream* pStream, ktxTextureCreateFlags createFlags, ktxTexture** newTex) { ktxHeaderUnion_ header; ktxFileType_ fileType; KTX_error_code result; ktxTexture* tex; result = ktxDetermineFileType_(pStream, &fileType, &header); - if (result != KTX_SUCCESS) - return result; + if (result != KTX_SUCCESS) return result; if (fileType == KTX1) { ktxTexture1* tex1 = (ktxTexture1*)malloc(sizeof(ktxTexture1)); - if (tex1 == NULL) - return KTX_OUT_OF_MEMORY; + if (tex1 == NULL) return KTX_OUT_OF_MEMORY; memset(tex1, 0, sizeof(ktxTexture1)); - result = ktxTexture1_constructFromStreamAndHeader(tex1, pStream, - &header.ktx, - createFlags); + result = ktxTexture1_constructFromStreamAndHeader(tex1, pStream, &header.ktx, createFlags); tex = ktxTexture(tex1); } else { ktxTexture2* tex2 = (ktxTexture2*)malloc(sizeof(ktxTexture2)); - if (tex2 == NULL) - return KTX_OUT_OF_MEMORY; + if (tex2 == NULL) return KTX_OUT_OF_MEMORY; memset(tex2, 0, sizeof(ktxTexture2)); - result = ktxTexture2_constructFromStreamAndHeader(tex2, pStream, - &header.ktx2, - createFlags); + result = ktxTexture2_constructFromStreamAndHeader(tex2, pStream, &header.ktx2, createFlags); tex = ktxTexture(tex2); } @@ -368,15 +326,11 @@ ktxTexture_CreateFromStream(ktxStream* pStream, * "ktxTexture2_CreateFromStdioStream" for details. */ KTX_error_code -ktxTexture_CreateFromStdioStream(FILE* stdioStream, - ktxTextureCreateFlags createFlags, - ktxTexture** newTex) -{ +ktxTexture_CreateFromStdioStream(FILE* stdioStream, ktxTextureCreateFlags createFlags, ktxTexture** newTex) { ktxStream stream; KTX_error_code result; - if (stdioStream == NULL || newTex == NULL) - return KTX_INVALID_VALUE; + if (stdioStream == NULL || newTex == NULL) return KTX_INVALID_VALUE; result = ktxFileStream_construct(&stream, stdioStream, KTX_FALSE); if (result == KTX_SUCCESS) { @@ -397,20 +351,15 @@ ktxTexture_CreateFromStdioStream(FILE* stdioStream, * "ktxTexture2_CreateFromNamedFile" for details. */ KTX_error_code -ktxTexture_CreateFromNamedFile(const char* const filename, - ktxTextureCreateFlags createFlags, - ktxTexture** newTex) -{ +ktxTexture_CreateFromNamedFile(const char* const filename, ktxTextureCreateFlags createFlags, ktxTexture** newTex) { KTX_error_code result; ktxStream stream; FILE* file; - if (filename == NULL || newTex == NULL) - return KTX_INVALID_VALUE; + if (filename == NULL || newTex == NULL) return KTX_INVALID_VALUE; file = ktxFOpenUTF8(filename, "rb"); - if (!file) - return KTX_FILE_OPEN_FAILED; + if (!file) return KTX_FILE_OPEN_FAILED; result = ktxFileStream_construct(&stream, file, KTX_TRUE); if (result == KTX_SUCCESS) { @@ -431,22 +380,18 @@ ktxTexture_CreateFromNamedFile(const char* const filename, * "ktxTexture2_CreateFromMemory" for details. */ KTX_error_code -ktxTexture_CreateFromMemory(const ktx_uint8_t* bytes, ktx_size_t size, - ktxTextureCreateFlags createFlags, - ktxTexture** newTex) -{ +ktxTexture_CreateFromMemory(const ktx_uint8_t* bytes, ktx_size_t size, ktxTextureCreateFlags createFlags, ktxTexture** newTex) { KTX_error_code result; ktxStream stream; - if (bytes == NULL || newTex == NULL || size == 0) - return KTX_INVALID_VALUE; + if (bytes == NULL || newTex == NULL || size == 0) return KTX_INVALID_VALUE; result = ktxMemStream_construct_ro(&stream, bytes, size); if (result == KTX_SUCCESS) { result = ktxTexture_CreateFromStream(&stream, createFlags, newTex); } - return result;} - + return result; +} /** * @memberof ktxTexture @@ -456,8 +401,7 @@ ktxTexture_CreateFromMemory(const ktx_uint8_t* bytes, ktx_size_t size, * @param[in] This pointer to the ktxTexture object of interest. */ ktx_uint8_t* -ktxTexture_GetData(ktxTexture* This) -{ +ktxTexture_GetData(ktxTexture* This) { return This->pData; } @@ -472,8 +416,7 @@ ktxTexture_GetData(ktxTexture* This) * @param[in] This pointer to the ktxTexture object of interest. */ ktx_size_t -ktxTexture_GetDataSize(ktxTexture* This) -{ +ktxTexture_GetDataSize(ktxTexture* This) { assert(This != NULL); return This->dataSize; } @@ -490,9 +433,8 @@ ktxTexture_GetDataSize(ktxTexture* This) * @param[in] This pointer to the ktxTexture object of interest. */ ktx_uint32_t -ktxTexture_GetElementSize(ktxTexture* This) -{ - assert (This != NULL); +ktxTexture_GetElementSize(ktxTexture* This) { + assert(This != NULL); return (This->_protected->_formatSize.blockSizeInBits / 8); } @@ -514,9 +456,7 @@ ktxTexture_GetElementSize(ktxTexture* This) * image size. */ ktx_size_t -ktxTexture_calcImageSize(ktxTexture* This, ktx_uint32_t level, - ktxFormatVersionEnum fv) -{ +ktxTexture_calcImageSize(ktxTexture* This, ktx_uint32_t level, ktxFormatVersionEnum fv) { DECLARE_PROTECTED(ktxTexture); struct blockCount { ktx_uint32_t x, y; @@ -524,16 +464,14 @@ ktxTexture_calcImageSize(ktxTexture* This, ktx_uint32_t level, ktx_uint32_t blockSizeInBytes; ktx_uint32_t rowBytes; - assert (This != NULL); + assert(This != NULL); - float levelWidth = (float)(This->baseWidth >> level); + float levelWidth = (float)(This->baseWidth >> level); float levelHeight = (float)(This->baseHeight >> level); // Round up to next whole block. We can't use KTX_PADN because some of // the block sizes are not powers of 2. - blockCount.x - = (ktx_uint32_t)ceilf(levelWidth / prtctd->_formatSize.blockWidth); - blockCount.y - = (ktx_uint32_t)ceilf(levelHeight / prtctd->_formatSize.blockHeight); + blockCount.x = (ktx_uint32_t)ceilf(levelWidth / prtctd->_formatSize.blockWidth); + blockCount.y = (ktx_uint32_t)ceilf(levelHeight / prtctd->_formatSize.blockHeight); blockCount.x = MAX(prtctd->_formatSize.minBlocksX, blockCount.x); blockCount.y = MAX(prtctd->_formatSize.minBlocksY, blockCount.y); @@ -543,12 +481,10 @@ ktxTexture_calcImageSize(ktxTexture* This, ktx_uint32_t level, assert(This->isCompressed); return blockCount.x * blockCount.y * blockSizeInBytes; } else { - assert(prtctd->_formatSize.blockWidth == 1U - && prtctd->_formatSize.blockHeight == 1U - && prtctd->_formatSize.blockDepth == 1U); + assert(prtctd->_formatSize.blockWidth == 1U && prtctd->_formatSize.blockHeight == 1U && + prtctd->_formatSize.blockDepth == 1U); rowBytes = blockCount.x * blockSizeInBytes; - if (fv == KTX_FORMAT_VERSION_ONE) - (void)padRow(&rowBytes); + if (fv == KTX_FORMAT_VERSION_ONE) (void)padRow(&rowBytes); return rowBytes * blockCount.y; } } @@ -585,32 +521,26 @@ ktxTexture_calcImageSize(ktxTexture* This, ktx_uint32_t level, * */ KTX_error_code -ktxTexture_IterateLevelFaces(ktxTexture* This, PFNKTXITERCB iterCb, - void* userdata) -{ - ktx_uint32_t miplevel; - KTX_error_code result = KTX_SUCCESS; +ktxTexture_IterateLevelFaces(ktxTexture* This, PFNKTXITERCB iterCb, void* userdata) { + ktx_uint32_t miplevel; + KTX_error_code result = KTX_SUCCESS; - if (This == NULL) - return KTX_INVALID_VALUE; + if (This == NULL) return KTX_INVALID_VALUE; - if (iterCb == NULL) - return KTX_INVALID_VALUE; + if (iterCb == NULL) return KTX_INVALID_VALUE; - for (miplevel = 0; miplevel < This->numLevels; ++miplevel) - { + for (miplevel = 0; miplevel < This->numLevels; ++miplevel) { ktx_uint32_t faceLodSize; ktx_uint32_t face; ktx_uint32_t innerIterations; - GLsizei width, height, depth; + GLsizei width, height, depth; /* Array textures have the same number of layers at each mip level. */ - width = MAX(1, This->baseWidth >> miplevel); + width = MAX(1, This->baseWidth >> miplevel); height = MAX(1, This->baseHeight >> miplevel); - depth = MAX(1, This->baseDepth >> miplevel); + depth = MAX(1, This->baseDepth >> miplevel); - faceLodSize = (ktx_uint32_t)ktxTexture_calcFaceLodSize( - This, miplevel); + faceLodSize = (ktx_uint32_t)ktxTexture_calcFaceLodSize(This, miplevel); /* All array layers are passed in a group because that is how * GL & Vulkan need them. Hence no @@ -620,20 +550,16 @@ ktxTexture_IterateLevelFaces(ktxTexture* This, PFNKTXITERCB iterCb, innerIterations = This->numFaces; else innerIterations = 1; - for (face = 0; face < innerIterations; ++face) - { + for (face = 0; face < innerIterations; ++face) { /* And all z_slices are also passed as a group hence no * for (slice = 0; slice < This->depth) */ ktx_size_t offset; ktxTexture_GetImageOffset(This, miplevel, 0, face, &offset); - result = iterCb(miplevel, face, - width, height, depth, - faceLodSize, This->pData + offset, userdata); + result = iterCb(miplevel, face, width, height, depth, faceLodSize, This->pData + offset, userdata); - if (result != KTX_SUCCESS) - break; + if (result != KTX_SUCCESS) break; } } @@ -653,11 +579,10 @@ ktxTexture_IterateLevelFaces(ktxTexture* This, PFNKTXITERCB iterCb, * @return the no. of bytes of padding. */ static ktx_uint32_t -padRow(ktx_uint32_t* rowBytes) -{ +padRow(ktx_uint32_t* rowBytes) { ktx_uint32_t rowPadding; - assert (rowBytes != NULL); + assert(rowBytes != NULL); rowPadding = _KTX_PAD_UNPACK_ALIGN_LEN(*rowBytes); *rowBytes += rowPadding; @@ -680,9 +605,7 @@ padRow(ktx_uint32_t* rowBytes) * @return the layer size in bytes. */ ktx_size_t -ktxTexture_layerSize(ktxTexture* This, ktx_uint32_t level, - ktxFormatVersionEnum fv) -{ +ktxTexture_layerSize(ktxTexture* This, ktx_uint32_t level, ktxFormatVersionEnum fv) { /* * As there are no 3D cubemaps, the image's z block count will always be * 1 for cubemaps and numFaces will always be 1 for 3D textures so the @@ -693,8 +616,8 @@ ktxTexture_layerSize(ktxTexture* This, ktx_uint32_t level, ktx_uint32_t blockCountZ; ktx_size_t imageSize, layerSize; - assert (This != NULL); - assert (prtctd->_formatSize.blockDepth != 0); + assert(This != NULL); + assert(prtctd->_formatSize.blockDepth != 0); blockCountZ = ((This->baseDepth >> level) + prtctd->_formatSize.blockDepth - 1) / prtctd->_formatSize.blockDepth; blockCountZ = MAX(1, blockCountZ); @@ -722,11 +645,9 @@ ktxTexture_layerSize(ktxTexture* This, ktx_uint32_t level, * @return the level size in bytes. */ ktx_size_t -ktxTexture_calcLevelSize(ktxTexture* This, ktx_uint32_t level, - ktxFormatVersionEnum fv) -{ - assert (This != NULL); - assert (level < This->numLevels); +ktxTexture_calcLevelSize(ktxTexture* This, ktx_uint32_t level, ktxFormatVersionEnum fv) { + assert(This != NULL); + assert(level < This->numLevels); return ktxTexture_layerSize(This, level, fv) * This->numLayers; } @@ -747,9 +668,7 @@ ktxTexture_calcLevelSize(ktxTexture* This, ktx_uint32_t level, * @return the faceLodSize size in bytes. */ ktx_size_t -ktxTexture_doCalcFaceLodSize(ktxTexture* This, ktx_uint32_t level, - ktxFormatVersionEnum fv) -{ +ktxTexture_doCalcFaceLodSize(ktxTexture* This, ktx_uint32_t level, ktxFormatVersionEnum fv) { /* * For non-array cubemaps this is the size of a face. For everything * else it is the size of the level. @@ -760,7 +679,6 @@ ktxTexture_doCalcFaceLodSize(ktxTexture* This, ktx_uint32_t level, return ktxTexture_calcLevelSize(This, level, fv); } - /** * @memberof ktxTexture @private * @~English @@ -777,9 +695,8 @@ ktxTexture_doCalcFaceLodSize(ktxTexture* This, ktx_uint32_t level, * @return the data size in bytes. */ ktx_size_t -ktxTexture_calcDataSizeTexture(ktxTexture* This) -{ - assert (This != NULL); +ktxTexture_calcDataSizeTexture(ktxTexture* This) { + assert(This != NULL); return ktxTexture_calcDataSizeLevels(This, This->numLevels); } @@ -802,24 +719,20 @@ ktxTexture_calcDataSizeTexture(ktxTexture* This) * of padding. */ void -ktxTexture_rowInfo(ktxTexture* This, ktx_uint32_t level, - ktx_uint32_t* numRows, ktx_uint32_t* pRowLengthBytes, - ktx_uint32_t* pRowPadding) -{ +ktxTexture_rowInfo(ktxTexture* This, ktx_uint32_t level, ktx_uint32_t* numRows, ktx_uint32_t* pRowLengthBytes, + ktx_uint32_t* pRowPadding) { DECLARE_PROTECTED(ktxTexture); struct blockCount { ktx_uint32_t x; } blockCount; - assert (This != NULL); + assert(This != NULL); assert(!This->isCompressed); - assert(prtctd->_formatSize.blockWidth == 1U - && prtctd->_formatSize.blockHeight == 1U - && prtctd->_formatSize.blockDepth == 1U); + assert(prtctd->_formatSize.blockWidth == 1U && prtctd->_formatSize.blockHeight == 1U && prtctd->_formatSize.blockDepth == 1U); - blockCount.x = MAX(1, (This->baseWidth / prtctd->_formatSize.blockWidth) >> level); - *numRows = MAX(1, (This->baseHeight / prtctd->_formatSize.blockHeight) >> level); + blockCount.x = MAX(1, (This->baseWidth / prtctd->_formatSize.blockWidth) >> level); + *numRows = MAX(1, (This->baseHeight / prtctd->_formatSize.blockHeight) >> level); *pRowLengthBytes = blockCount.x * prtctd->_formatSize.blockSizeInBits / 8; *pRowPadding = padRow(pRowLengthBytes); @@ -841,21 +754,20 @@ ktxTexture_rowInfo(ktxTexture* This, ktx_uint32_t level, * * @return the row pitch in bytes. */ - ktx_uint32_t - ktxTexture_GetRowPitch(ktxTexture* This, ktx_uint32_t level) - { +ktx_uint32_t +ktxTexture_GetRowPitch(ktxTexture* This, ktx_uint32_t level) { DECLARE_PROTECTED(ktxTexture) struct blockCount { ktx_uint32_t x; } blockCount; ktx_uint32_t pitch; - blockCount.x = MAX(1, (This->baseWidth / prtctd->_formatSize.blockWidth) >> level); + blockCount.x = MAX(1, (This->baseWidth / prtctd->_formatSize.blockWidth) >> level); pitch = blockCount.x * prtctd->_formatSize.blockSizeInBits / 8; (void)padRow(&pitch); return pitch; - } +} /** * @memberof ktxTexture @private @@ -870,12 +782,10 @@ ktxTexture_rowInfo(ktxTexture* This, ktx_uint32_t level, * @return KTX_TRUE if there is an active stream, KTX_FALSE otherwise. */ ktx_bool_t -ktxTexture_isActiveStream(ktxTexture* This) -{ +ktxTexture_isActiveStream(ktxTexture* This) { assert(This != NULL); ktxStream* stream = ktxTexture_getStream(This); return stream->data.file != NULL; } /** @} */ - diff --git a/lib/texture.h b/lib/texture.h index e415a09d6a..f3b49418d2 100644 --- a/lib/texture.h +++ b/lib/texture.h @@ -23,34 +23,27 @@ #include "ktx.h" #include "formatsize.h" -#define DECLARE_PRIVATE(class) class ## _private* private = This->_private -#define DECLARE_PROTECTED(class) class ## _protected* prtctd = This->_protected; +#define DECLARE_PRIVATE(class) class##_private* private = This->_private +#define DECLARE_PROTECTED(class) class##_protected* prtctd = This->_protected; #ifdef __cplusplus extern "C" { #endif -typedef enum { - KTX_FORMAT_VERSION_ONE = 1, - KTX_FORMAT_VERSION_TWO = 2 -} ktxFormatVersionEnum; +typedef enum { KTX_FORMAT_VERSION_ONE = 1, KTX_FORMAT_VERSION_TWO = 2 } ktxFormatVersionEnum; -typedef ktx_size_t (* PFNCALCDATASIZELEVELS)(ktxTexture* This, - ktx_uint32_t levels); -typedef ktx_size_t (* PFNCALCFACELODSIZE)(ktxTexture* This, ktx_uint32_t level); -typedef ktx_size_t (* PFNCALCLEVELOFFSET)(ktxTexture* This, ktx_uint32_t level); +typedef ktx_size_t (*PFNCALCDATASIZELEVELS)(ktxTexture* This, ktx_uint32_t levels); +typedef ktx_size_t (*PFNCALCFACELODSIZE)(ktxTexture* This, ktx_uint32_t level); +typedef ktx_size_t (*PFNCALCLEVELOFFSET)(ktxTexture* This, ktx_uint32_t level); typedef struct ktxTexture_vtblInt { PFNCALCDATASIZELEVELS calcDataSizeLevels; PFNCALCFACELODSIZE calcFaceLodSize; PFNCALCLEVELOFFSET calcLevelOffset; } ktxTexture_vtblInt; -#define ktxTexture_calcDataSizeLevels(This, levels) \ - This->_protected->_vtbl.calcDataSizeLevels(This, levels); -#define ktxTexture_calcFaceLodSize(This, level) \ - This->_protected->_vtbl.calcFaceLodSize(This, level); -#define ktxTexture_calcLevelOffset(This, level) \ - This->_protected->_vtbl.calcLevelOffset(This, level); +#define ktxTexture_calcDataSizeLevels(This, levels) This->_protected->_vtbl.calcDataSizeLevels(This, levels); +#define ktxTexture_calcFaceLodSize(This, level) This->_protected->_vtbl.calcFaceLodSize(This, level); +#define ktxTexture_calcLevelOffset(This, level) This->_protected->_vtbl.calcLevelOffset(This, level); /** * @memberof ktxTexture @@ -69,36 +62,22 @@ typedef struct ktxTexture_protected { #define ktxTexture1_getStream(t1) ktxTexture_getStream((ktxTexture*)t1) #define ktxTexture2_getStream(t2) ktxTexture_getStream((ktxTexture*)t2) -KTX_error_code -ktxTexture_iterateLoadedImages(ktxTexture* This, PFNKTXITERCB iterCb, - void* userdata); -KTX_error_code -ktxTexture_iterateSourceImages(ktxTexture* This, PFNKTXITERCB iterCb, - void* userdata); +KTX_error_code ktxTexture_iterateLoadedImages(ktxTexture* This, PFNKTXITERCB iterCb, void* userdata); +KTX_error_code ktxTexture_iterateSourceImages(ktxTexture* This, PFNKTXITERCB iterCb, void* userdata); ktx_size_t ktxTexture_calcDataSizeTexture(ktxTexture* This); -ktx_size_t ktxTexture_calcImageSize(ktxTexture* This, ktx_uint32_t level, - ktxFormatVersionEnum fv); +ktx_size_t ktxTexture_calcImageSize(ktxTexture* This, ktx_uint32_t level, ktxFormatVersionEnum fv); ktx_bool_t ktxTexture_isActiveStream(ktxTexture* This); -ktx_size_t ktxTexture_calcLevelSize(ktxTexture* This, ktx_uint32_t level, - ktxFormatVersionEnum fv); -ktx_size_t ktxTexture_doCalcFaceLodSize(ktxTexture* This, ktx_uint32_t level, - ktxFormatVersionEnum fv); -ktx_size_t ktxTexture_layerSize(ktxTexture* This, ktx_uint32_t level, - ktxFormatVersionEnum fv); -void ktxTexture_rowInfo(ktxTexture* This, ktx_uint32_t level, - ktx_uint32_t* numRows, ktx_uint32_t* rowBytes, +ktx_size_t ktxTexture_calcLevelSize(ktxTexture* This, ktx_uint32_t level, ktxFormatVersionEnum fv); +ktx_size_t ktxTexture_doCalcFaceLodSize(ktxTexture* This, ktx_uint32_t level, ktxFormatVersionEnum fv); +ktx_size_t ktxTexture_layerSize(ktxTexture* This, ktx_uint32_t level, ktxFormatVersionEnum fv); +void ktxTexture_rowInfo(ktxTexture* This, ktx_uint32_t level, ktx_uint32_t* numRows, ktx_uint32_t* rowBytes, ktx_uint32_t* rowPadding); -KTX_error_code -ktxTexture_construct(ktxTexture* This, ktxTextureCreateInfo* createInfo, - ktxFormatSize* formatSize); +KTX_error_code ktxTexture_construct(ktxTexture* This, ktxTextureCreateInfo* createInfo, ktxFormatSize* formatSize); -KTX_error_code -ktxTexture_constructFromStream(ktxTexture* This, ktxStream* pStream, - ktxTextureCreateFlags createFlags); +KTX_error_code ktxTexture_constructFromStream(ktxTexture* This, ktxStream* pStream, ktxTextureCreateFlags createFlags); -void -ktxTexture_destruct(ktxTexture* This); +void ktxTexture_destruct(ktxTexture* This); #ifdef __cplusplus } diff --git a/lib/texture1.c b/lib/texture1.c index 1591f3b6dc..eacb0c02c0 100644 --- a/lib/texture1.c +++ b/lib/texture1.c @@ -33,15 +33,14 @@ #include "gl_format.h" typedef struct ktxTexture1_private { - ktx_bool_t _needSwap; + ktx_bool_t _needSwap; } ktxTexture1_private; struct ktxTexture_vtbl ktxTexture1_vtbl; struct ktxTexture_vtblInt ktxTexture1_vtblInt; static KTX_error_code -ktxTexture1_constructCommon(ktxTexture1* This) -{ +ktxTexture1_constructCommon(ktxTexture1* This) { assert(This != NULL); This->classId = ktxTexture1_c; @@ -51,7 +50,7 @@ ktxTexture1_constructCommon(ktxTexture1* This) if (This->_private == NULL) { return KTX_OUT_OF_MEMORY; } - memset(This->_private, 0, sizeof(*This->_private)); + memset(This->_private, 0, sizeof(*This->_private)); return KTX_SUCCESS; } @@ -61,16 +60,14 @@ ktxTexture1_constructCommon(ktxTexture1* This) * @copydoc ktxTexture2_construct */ static KTX_error_code -ktxTexture1_construct(ktxTexture1* This, ktxTextureCreateInfo* createInfo, - ktxTextureCreateStorageEnum storageAllocation) -{ +ktxTexture1_construct(ktxTexture1* This, ktxTextureCreateInfo* createInfo, ktxTextureCreateStorageEnum storageAllocation) { ktxTexture_protected* prtctd; ktxFormatSize formatSize; GLuint typeSize; GLenum glFormat; KTX_error_code result; - memset(This, 0, sizeof(*This)); + memset(This, 0, sizeof(*This)); This->glInternalformat = createInfo->glInternalformat; glGetFormatSize(This->glInternalformat, &formatSize); @@ -78,21 +75,18 @@ ktxTexture1_construct(ktxTexture1* This, ktxTextureCreateInfo* createInfo, // Most likely a deprecated legacy format. return KTX_UNSUPPORTED_TEXTURE_TYPE; } - glFormat= glGetFormatFromInternalFormat(createInfo->glInternalformat); + glFormat = glGetFormatFromInternalFormat(createInfo->glInternalformat); if (glFormat == GL_INVALID_VALUE) { - return KTX_INVALID_VALUE; + return KTX_INVALID_VALUE; } - result = ktxTexture_construct(ktxTexture(This), createInfo, &formatSize); - if (result != KTX_SUCCESS) - return result; + result = ktxTexture_construct(ktxTexture(This), createInfo, &formatSize); + if (result != KTX_SUCCESS) return result; result = ktxTexture1_constructCommon(This); - if (result != KTX_SUCCESS) - return result; + if (result != KTX_SUCCESS) return result; prtctd = This->_protected; - This->isCompressed - = (formatSize.flags & KTX_FORMAT_SIZE_COMPRESSED_BIT); + This->isCompressed = (formatSize.flags & KTX_FORMAT_SIZE_COMPRESSED_BIT); if (This->isCompressed) { This->glFormat = 0; This->glBaseInternalformat = glFormat; @@ -100,8 +94,7 @@ ktxTexture1_construct(ktxTexture1* This, ktxTextureCreateInfo* createInfo, prtctd->_typeSize = 1; } else { This->glBaseInternalformat = This->glFormat = glFormat; - This->glType - = glGetTypeFromInternalFormat(createInfo->glInternalformat); + This->glType = glGetTypeFromInternalFormat(createInfo->glInternalformat); if (This->glType == GL_INVALID_VALUE) { result = KTX_INVALID_VALUE; goto cleanup; @@ -110,10 +103,7 @@ ktxTexture1_construct(ktxTexture1* This, ktxTextureCreateInfo* createInfo, assert(typeSize != GL_INVALID_VALUE); /* Do some sanity checking */ - if (typeSize != 1 && - typeSize != 2 && - typeSize != 4) - { + if (typeSize != 1 && typeSize != 2 && typeSize != 4) { /* Only 8, 16, and 32-bit types are supported for byte-swapping. * See UNPACK_SWAP_BYTES & table 8.4 in the OpenGL 4.4 spec. */ @@ -124,8 +114,7 @@ ktxTexture1_construct(ktxTexture1* This, ktxTextureCreateInfo* createInfo, } if (storageAllocation == KTX_TEXTURE_CREATE_ALLOC_STORAGE) { - This->dataSize - = ktxTexture_calcDataSizeTexture(ktxTexture(This)); + This->dataSize = ktxTexture_calcDataSizeTexture(ktxTexture(This)); This->pData = malloc(This->dataSize); if (This->pData == NULL) { result = KTX_OUT_OF_MEMORY; @@ -183,10 +172,8 @@ ktxTexture1_construct(ktxTexture1* This, ktxTextureCreateInfo* createInfo, * supported by OpenGL or Vulkan, e.g, a 3D array. */ KTX_error_code -ktxTexture1_constructFromStreamAndHeader(ktxTexture1* This, ktxStream* pStream, - KTX_header* pHeader, - ktxTextureCreateFlags createFlags) -{ +ktxTexture1_constructFromStreamAndHeader(ktxTexture1* This, ktxStream* pStream, KTX_header* pHeader, + ktxTextureCreateFlags createFlags) { ktxTexture1_private* private; KTX_error_code result; KTX_supplemental_info suppInfo; @@ -197,10 +184,9 @@ ktxTexture1_constructFromStreamAndHeader(ktxTexture1* This, ktxStream* pStream, assert(pHeader != NULL && pStream != NULL); - memset(This, 0, sizeof(*This)); + memset(This, 0, sizeof(*This)); result = ktxTexture_constructFromStream(ktxTexture(This), pStream, createFlags); - if (result != KTX_SUCCESS) - return result; + if (result != KTX_SUCCESS) return result; result = ktxTexture1_constructCommon(This); if (result != KTX_SUCCESS) { ktxTexture_destruct(ktxTexture(This)); @@ -211,8 +197,7 @@ ktxTexture1_constructFromStreamAndHeader(ktxTexture1* This, ktxStream* pStream, stream = ktxTexture1_getStream(This); result = ktxCheckHeader1_(pHeader, &suppInfo); - if (result != KTX_SUCCESS) - goto cleanup; + if (result != KTX_SUCCESS) goto cleanup; /* * Initialize from pHeader info. @@ -233,14 +218,14 @@ ktxTexture1_constructFromStreamAndHeader(ktxTexture1* This, ktxStream* pStream, This->baseWidth = pHeader->pixelWidth; assert(suppInfo.textureDimension > 0 && suppInfo.textureDimension < 4); switch (suppInfo.textureDimension) { - case 1: + case 1: This->baseHeight = This->baseDepth = 1; break; - case 2: + case 2: This->baseHeight = pHeader->pixelHeight; This->baseDepth = 1; break; - case 3: + case 3: This->baseHeight = pHeader->pixelHeight; This->baseDepth = pHeader->pixelDepth; break; @@ -260,8 +245,7 @@ ktxTexture1_constructFromStreamAndHeader(ktxTexture1* This, ktxStream* pStream, This->numLevels = pHeader->numberOfMipLevels; This->isCompressed = suppInfo.compressed; This->generateMipmaps = suppInfo.generateMipmaps; - if (pHeader->endianness == KTX_ENDIAN_REF_REV) - private->_needSwap = KTX_TRUE; + if (pHeader->endianness == KTX_ENDIAN_REF_REV) private->_needSwap = KTX_TRUE; This->_protected->_typeSize = pHeader->glTypeSize; /* @@ -283,8 +267,7 @@ ktxTexture1_constructFromStreamAndHeader(ktxTexture1* This, ktxStream* pStream, } result = stream->read(stream, pKvd, kvdLen); - if (result != KTX_SUCCESS) - goto cleanup; + if (result != KTX_SUCCESS) goto cleanup; if (private->_needSwap) { /* Swap the counts inside the key & value data. */ @@ -301,26 +284,19 @@ ktxTexture1_constructFromStreamAndHeader(ktxTexture1* This, ktxStream* pStream, char* orientation; ktx_uint32_t orientationLen; - result = ktxHashList_Deserialize(&This->kvDataHead, - kvdLen, pKvd); + result = ktxHashList_Deserialize(&This->kvDataHead, kvdLen, pKvd); free(pKvd); if (result != KTX_SUCCESS) { goto cleanup; } - result = ktxHashList_FindValue(&This->kvDataHead, - KTX_ORIENTATION_KEY, - &orientationLen, - (void**)&orientation); + result = ktxHashList_FindValue(&This->kvDataHead, KTX_ORIENTATION_KEY, &orientationLen, (void**)&orientation); assert(result != KTX_INVALID_VALUE); if (result == KTX_SUCCESS) { ktx_uint32_t count; char orient[4] = {0, 0, 0, 0}; - count = sscanf(orientation, KTX_ORIENTATION3_FMT, - &orient[0], - &orient[1], - &orient[2]); + count = sscanf(orientation, KTX_ORIENTATION3_FMT, &orient[0], &orient[1], &orient[2]); if (count > This->numDimensions) { // KTX 1 is less strict than KTX2 so there is a chance @@ -328,13 +304,13 @@ ktxTexture1_constructFromStreamAndHeader(ktxTexture1* This, ktxStream* pStream, count = This->numDimensions; } switch (This->numDimensions) { - case 3: + case 3: This->orientation.z = orient[2]; FALLTHROUGH; - case 2: + case 2: This->orientation.y = orient[1]; FALLTHROUGH; - case 1: + case 1: This->orientation.x = orient[0]; } } @@ -351,14 +327,12 @@ ktxTexture1_constructFromStreamAndHeader(ktxTexture1* This, ktxStream* pStream, * Get the size of the image data. */ result = stream->getsize(stream, &size); - if (result != KTX_SUCCESS) - goto cleanup; + if (result != KTX_SUCCESS) goto cleanup; result = stream->getpos(stream, &pos); - if (result != KTX_SUCCESS) - goto cleanup; + if (result != KTX_SUCCESS) goto cleanup; - /* Remove space for faceLodSize fields */ + /* Remove space for faceLodSize fields */ This->dataSize = size - pos - This->numLevels * sizeof(ktx_uint32_t); /* @@ -367,8 +341,7 @@ ktxTexture1_constructFromStreamAndHeader(ktxTexture1* This, ktxStream* pStream, if (createFlags & KTX_TEXTURE_CREATE_LOAD_IMAGE_DATA_BIT) { result = ktxTexture1_LoadImageData(This, NULL, 0); } - if (result == KTX_SUCCESS) - return result; + if (result == KTX_SUCCESS) return result; cleanup: ktxTexture1_destruct(This); @@ -403,19 +376,15 @@ ktxTexture1_constructFromStreamAndHeader(ktxTexture1* This, ktxStream* pStream, * For other exceptions see ktxTexture1_constructFromStreamAndHeader(). */ static KTX_error_code -ktxTexture1_constructFromStream(ktxTexture1* This, ktxStream* pStream, - ktxTextureCreateFlags createFlags) -{ +ktxTexture1_constructFromStream(ktxTexture1* This, ktxStream* pStream, ktxTextureCreateFlags createFlags) { KTX_header header; KTX_error_code result; // Read header. result = pStream->read(pStream, &header, KTX_HEADER_SIZE); - if (result != KTX_SUCCESS) - return result; + if (result != KTX_SUCCESS) return result; - return ktxTexture1_constructFromStreamAndHeader(This, pStream, - &header, createFlags); + return ktxTexture1_constructFromStreamAndHeader(This, pStream, &header, createFlags); } /** @@ -439,18 +408,14 @@ ktxTexture1_constructFromStream(ktxTexture1* This, ktxStream* pStream, * For other exceptions, see ktxTexture_constructFromStream(). */ static KTX_error_code -ktxTexture1_constructFromStdioStream(ktxTexture1* This, FILE* stdioStream, - ktxTextureCreateFlags createFlags) -{ +ktxTexture1_constructFromStdioStream(ktxTexture1* This, FILE* stdioStream, ktxTextureCreateFlags createFlags) { ktxStream stream; KTX_error_code result; - if (stdioStream == NULL || This == NULL) - return KTX_INVALID_VALUE; + if (stdioStream == NULL || This == NULL) return KTX_INVALID_VALUE; result = ktxFileStream_construct(&stream, stdioStream, KTX_FALSE); - if (result == KTX_SUCCESS) - result = ktxTexture1_constructFromStream(This, &stream, createFlags); + if (result == KTX_SUCCESS) result = ktxTexture1_constructFromStream(This, &stream, createFlags); return result; } @@ -476,24 +441,18 @@ ktxTexture1_constructFromStdioStream(ktxTexture1* This, FILE* stdioStream, * For other exceptions, see ktxTexture_constructFromStream(). */ static KTX_error_code -ktxTexture1_constructFromNamedFile(ktxTexture1* This, - const char* const filename, - ktxTextureCreateFlags createFlags) -{ +ktxTexture1_constructFromNamedFile(ktxTexture1* This, const char* const filename, ktxTextureCreateFlags createFlags) { FILE* file; ktxStream stream; KTX_error_code result; - if (This == NULL || filename == NULL) - return KTX_INVALID_VALUE; + if (This == NULL || filename == NULL) return KTX_INVALID_VALUE; file = ktxFOpenUTF8(filename, "rb"); - if (!file) - return KTX_FILE_OPEN_FAILED; + if (!file) return KTX_FILE_OPEN_FAILED; result = ktxFileStream_construct(&stream, file, KTX_TRUE); - if (result == KTX_SUCCESS) - result = ktxTexture1_constructFromStream(This, &stream, createFlags); + if (result == KTX_SUCCESS) result = ktxTexture1_constructFromStream(This, &stream, createFlags); return result; } @@ -517,26 +476,20 @@ ktxTexture1_constructFromNamedFile(ktxTexture1* This, * For other exceptions, see ktxTexture_constructFromStream(). */ static KTX_error_code -ktxTexture1_constructFromMemory(ktxTexture1* This, - const ktx_uint8_t* bytes, ktx_size_t size, - ktxTextureCreateFlags createFlags) -{ +ktxTexture1_constructFromMemory(ktxTexture1* This, const ktx_uint8_t* bytes, ktx_size_t size, ktxTextureCreateFlags createFlags) { ktxStream stream; KTX_error_code result; - if (bytes == NULL || size == 0) - return KTX_INVALID_VALUE; + if (bytes == NULL || size == 0) return KTX_INVALID_VALUE; result = ktxMemStream_construct_ro(&stream, bytes, size); - if (result == KTX_SUCCESS) - result = ktxTexture1_constructFromStream(This, &stream, createFlags); + if (result == KTX_SUCCESS) result = ktxTexture1_constructFromStream(This, &stream, createFlags); return result; } void -ktxTexture1_destruct(ktxTexture1* This) -{ +ktxTexture1_destruct(ktxTexture1* This) { if (This->_private) free(This->_private); ktxTexture_destruct(ktxTexture(This)); } @@ -590,18 +543,13 @@ ktxTexture1_destruct(ktxTexture1* This) * @exception KTX_OUT_OF_MEMORY Not enough memory for the texture's images. */ KTX_error_code -ktxTexture1_Create(ktxTextureCreateInfo* createInfo, - ktxTextureCreateStorageEnum storageAllocation, - ktxTexture1** newTex) -{ +ktxTexture1_Create(ktxTextureCreateInfo* createInfo, ktxTextureCreateStorageEnum storageAllocation, ktxTexture1** newTex) { KTX_error_code result; - if (newTex == NULL) - return KTX_INVALID_VALUE; + if (newTex == NULL) return KTX_INVALID_VALUE; ktxTexture1* tex = (ktxTexture1*)malloc(sizeof(ktxTexture1)); - if (tex == NULL) - return KTX_OUT_OF_MEMORY; + if (tex == NULL) return KTX_OUT_OF_MEMORY; result = ktxTexture1_construct(tex, createInfo, storageAllocation); if (result != KTX_SUCCESS) { @@ -653,20 +601,14 @@ ktxTexture1_Create(ktxTextureCreateInfo* createInfo, * supported by OpenGL or Vulkan, e.g, a 3D array. */ KTX_error_code -ktxTexture1_CreateFromStdioStream(FILE* stdioStream, - ktxTextureCreateFlags createFlags, - ktxTexture1** newTex) -{ +ktxTexture1_CreateFromStdioStream(FILE* stdioStream, ktxTextureCreateFlags createFlags, ktxTexture1** newTex) { KTX_error_code result; - if (newTex == NULL) - return KTX_INVALID_VALUE; + if (newTex == NULL) return KTX_INVALID_VALUE; ktxTexture1* tex = (ktxTexture1*)malloc(sizeof(ktxTexture1)); - if (tex == NULL) - return KTX_OUT_OF_MEMORY; + if (tex == NULL) return KTX_OUT_OF_MEMORY; - result = ktxTexture1_constructFromStdioStream(tex, stdioStream, - createFlags); + result = ktxTexture1_constructFromStdioStream(tex, stdioStream, createFlags); if (result == KTX_SUCCESS) *newTex = (ktxTexture1*)tex; else { @@ -709,18 +651,13 @@ ktxTexture1_CreateFromStdioStream(FILE* stdioStream, * For other exceptions, see ktxTexture1_CreateFromStdioStream(). */ KTX_error_code -ktxTexture1_CreateFromNamedFile(const char* const filename, - ktxTextureCreateFlags createFlags, - ktxTexture1** newTex) -{ +ktxTexture1_CreateFromNamedFile(const char* const filename, ktxTextureCreateFlags createFlags, ktxTexture1** newTex) { KTX_error_code result; - if (newTex == NULL) - return KTX_INVALID_VALUE; + if (newTex == NULL) return KTX_INVALID_VALUE; ktxTexture1* tex = (ktxTexture1*)malloc(sizeof(ktxTexture1)); - if (tex == NULL) - return KTX_OUT_OF_MEMORY; + if (tex == NULL) return KTX_OUT_OF_MEMORY; result = ktxTexture1_constructFromNamedFile(tex, filename, createFlags); if (result == KTX_SUCCESS) @@ -762,20 +699,14 @@ ktxTexture1_CreateFromNamedFile(const char* const filename, * For other exceptions, see ktxTexture1_CreateFromStdioStream(). */ KTX_error_code -ktxTexture1_CreateFromMemory(const ktx_uint8_t* bytes, ktx_size_t size, - ktxTextureCreateFlags createFlags, - ktxTexture1** newTex) -{ +ktxTexture1_CreateFromMemory(const ktx_uint8_t* bytes, ktx_size_t size, ktxTextureCreateFlags createFlags, ktxTexture1** newTex) { KTX_error_code result; - if (newTex == NULL) - return KTX_INVALID_VALUE; + if (newTex == NULL) return KTX_INVALID_VALUE; ktxTexture1* tex = (ktxTexture1*)malloc(sizeof(ktxTexture1)); - if (tex == NULL) - return KTX_OUT_OF_MEMORY; + if (tex == NULL) return KTX_OUT_OF_MEMORY; - result = ktxTexture1_constructFromMemory(tex, bytes, size, - createFlags); + result = ktxTexture1_constructFromMemory(tex, bytes, size, createFlags); if (result == KTX_SUCCESS) *newTex = (ktxTexture1*)tex; else { @@ -812,17 +743,12 @@ ktxTexture1_CreateFromMemory(const ktx_uint8_t* bytes, ktx_size_t size, * For exceptions, see ktxTexture1_CreateFromStdioStream(). */ KTX_error_code -ktxTexture1_CreateFromStream(ktxStream* pStream, - ktxTextureCreateFlags createFlags, - ktxTexture1** newTex) -{ +ktxTexture1_CreateFromStream(ktxStream* pStream, ktxTextureCreateFlags createFlags, ktxTexture1** newTex) { KTX_error_code result; - if (newTex == NULL) - return KTX_INVALID_VALUE; + if (newTex == NULL) return KTX_INVALID_VALUE; ktxTexture1* tex = (ktxTexture1*)malloc(sizeof(ktxTexture1)); - if (tex == NULL) - return KTX_OUT_OF_MEMORY; + if (tex == NULL) return KTX_OUT_OF_MEMORY; result = ktxTexture1_constructFromStream(tex, pStream, createFlags); if (result == KTX_SUCCESS) @@ -846,8 +772,7 @@ ktxTexture1_CreateFromStream(ktxStream* pStream, * @param[in] This pointer to the ktxTexture1 object to destroy */ void -ktxTexture1_Destroy(ktxTexture1* This) -{ +ktxTexture1_Destroy(ktxTexture1* This) { ktxTexture1_destruct(This); free(This); } @@ -867,22 +792,20 @@ ktxTexture1_Destroy(ktxTexture1* This) * @return the data size in bytes. */ ktx_size_t -ktxTexture1_calcDataSizeLevels(ktxTexture1* This, ktx_uint32_t levels) -{ +ktxTexture1_calcDataSizeLevels(ktxTexture1* This, ktx_uint32_t levels) { ktx_uint32_t i; ktx_size_t dataSize = 0; assert(This != NULL); assert(levels <= This->numLevels); for (i = 0; i < levels; i++) { - ktx_size_t levelSize = ktxTexture_calcLevelSize(ktxTexture(This), i, - KTX_FORMAT_VERSION_ONE); - /* mipPadding. NOTE: this adds padding after the last level too. */ - #if KTX_GL_UNPACK_ALIGNMENT != 4 - dataSize += _KTX_PAD4(levelSize); - #else - dataSize += levelSize; - #endif + ktx_size_t levelSize = ktxTexture_calcLevelSize(ktxTexture(This), i, KTX_FORMAT_VERSION_ONE); +/* mipPadding. NOTE: this adds padding after the last level too. */ +#if KTX_GL_UNPACK_ALIGNMENT != 4 + dataSize += _KTX_PAD4(levelSize); +#else + dataSize += levelSize; +#endif } return dataSize; } @@ -894,10 +817,8 @@ ktxTexture1_calcDataSizeLevels(ktxTexture1* This, ktx_uint32_t levels) * @copydoc ktxTexture::ktxTexture_doCalcFaceLodSize */ ktx_size_t -ktxTexture1_calcFaceLodSize(ktxTexture1* This, ktx_uint32_t level) -{ - return ktxTexture_doCalcFaceLodSize(ktxTexture(This), level, - KTX_FORMAT_VERSION_ONE); +ktxTexture1_calcFaceLodSize(ktxTexture1* This, ktx_uint32_t level) { + return ktxTexture_doCalcFaceLodSize(ktxTexture(This), level, KTX_FORMAT_VERSION_ONE); } /** @@ -917,10 +838,9 @@ ktxTexture1_calcFaceLodSize(ktxTexture1* This, ktx_uint32_t level) * @return the data size in bytes. */ ktx_size_t -ktxTexture1_calcLevelOffset(ktxTexture1* This, ktx_uint32_t level) -{ - assert (This != NULL); - assert (level < This->numLevels); +ktxTexture1_calcLevelOffset(ktxTexture1* This, ktx_uint32_t level) { + assert(This != NULL); + assert(level < This->numLevels); return ktxTexture1_calcDataSizeLevels(This, level); } @@ -946,24 +866,16 @@ ktxTexture1_calcLevelOffset(ktxTexture1* This, ktx_uint32_t level) * @exception KTX_INVALID_VALID @p This is NULL. */ KTX_error_code -ktxTexture1_GetImageOffset(ktxTexture1* This, ktx_uint32_t level, - ktx_uint32_t layer, ktx_uint32_t faceSlice, - ktx_size_t* pOffset) -{ +ktxTexture1_GetImageOffset(ktxTexture1* This, ktx_uint32_t level, ktx_uint32_t layer, ktx_uint32_t faceSlice, ktx_size_t* pOffset) { + if (This == NULL) return KTX_INVALID_VALUE; - if (This == NULL) - return KTX_INVALID_VALUE; - - if (level >= This->numLevels || layer >= This->numLayers) - return KTX_INVALID_OPERATION; + if (level >= This->numLevels || layer >= This->numLayers) return KTX_INVALID_OPERATION; if (This->isCubemap) { - if (faceSlice >= This->numFaces) - return KTX_INVALID_OPERATION; + if (faceSlice >= This->numFaces) return KTX_INVALID_OPERATION; } else { ktx_uint32_t maxSlice = MAX(1, This->baseDepth >> level); - if (faceSlice >= maxSlice) - return KTX_INVALID_OPERATION; + if (faceSlice >= maxSlice) return KTX_INVALID_OPERATION; } // Get the size of the data up to the start of the indexed level. @@ -972,16 +884,14 @@ ktxTexture1_GetImageOffset(ktxTexture1* This, ktx_uint32_t level, // All layers, faces & slices within a level are the same size. if (layer != 0) { ktx_size_t layerSize; - layerSize = ktxTexture_layerSize(ktxTexture(This), level, - KTX_FORMAT_VERSION_ONE); + layerSize = ktxTexture_layerSize(ktxTexture(This), level, KTX_FORMAT_VERSION_ONE); *pOffset += layer * layerSize; } if (faceSlice != 0) { ktx_size_t imageSize; imageSize = ktxTexture_GetImageSize(ktxTexture(This), level); #if (KTX_GL_UNPACK_ALIGNMENT != 4) - if (This->isCubemap) - _KTX_PAD4(imageSize); // Account for cubePadding. + if (This->isCubemap) _KTX_PAD4(imageSize); // Account for cubePadding. #endif *pOffset += faceSlice * imageSize; } @@ -1001,8 +911,7 @@ ktxTexture1_GetImageOffset(ktxTexture1* This, ktx_uint32_t level, * @return The size of the data in the texture. */ ktx_size_t -ktxTexture1_GetDataSizeUncompressed(ktxTexture1* This) -{ +ktxTexture1_GetDataSizeUncompressed(ktxTexture1* This) { return This->dataSize; } @@ -1021,10 +930,8 @@ ktxTexture1_GetDataSizeUncompressed(ktxTexture1* This) * @param[in] level level of interest. */ ktx_size_t -ktxTexture1_GetImageSize(ktxTexture1* This, ktx_uint32_t level) -{ - return ktxTexture_calcImageSize(ktxTexture(This), level, - KTX_FORMAT_VERSION_ONE); +ktxTexture1_GetImageSize(ktxTexture1* This, ktx_uint32_t level) { + return ktxTexture_calcImageSize(ktxTexture(This), level, KTX_FORMAT_VERSION_ONE); } /** @@ -1037,8 +944,7 @@ ktxTexture1_GetImageSize(ktxTexture1* This, ktx_uint32_t level) * @return the type size in bytes. */ ktx_uint32_t -ktxTexture1_glTypeSize(ktxTexture1* This) -{ +ktxTexture1_glTypeSize(ktxTexture1* This) { assert(This != NULL); return This->_protected->_typeSize; } @@ -1072,41 +978,33 @@ ktxTexture1_glTypeSize(ktxTexture1* This) * */ KTX_error_code -ktxTexture1_IterateLevels(ktxTexture1* This, PFNKTXITERCB iterCb, void* userdata) -{ - ktx_uint32_t miplevel; - KTX_error_code result = KTX_SUCCESS; +ktxTexture1_IterateLevels(ktxTexture1* This, PFNKTXITERCB iterCb, void* userdata) { + ktx_uint32_t miplevel; + KTX_error_code result = KTX_SUCCESS; - if (This == NULL) - return KTX_INVALID_VALUE; + if (This == NULL) return KTX_INVALID_VALUE; - if (iterCb == NULL) - return KTX_INVALID_VALUE; + if (iterCb == NULL) return KTX_INVALID_VALUE; - for (miplevel = 0; miplevel < This->numLevels; ++miplevel) - { + for (miplevel = 0; miplevel < This->numLevels; ++miplevel) { GLsizei width, height, depth; ktx_uint32_t levelSize; ktx_size_t offset; /* Array textures have the same number of layers at each mip level. */ - width = MAX(1, This->baseWidth >> miplevel); + width = MAX(1, This->baseWidth >> miplevel); height = MAX(1, This->baseHeight >> miplevel); - depth = MAX(1, This->baseDepth >> miplevel); + depth = MAX(1, This->baseDepth >> miplevel); - levelSize = (ktx_uint32_t)ktxTexture_calcLevelSize(ktxTexture(This), - miplevel, - KTX_FORMAT_VERSION_ONE); + levelSize = (ktx_uint32_t)ktxTexture_calcLevelSize(ktxTexture(This), miplevel, KTX_FORMAT_VERSION_ONE); /* All array layers are passed in a group because that is how * GL & Vulkan need them. Hence no * for (layer = 0; layer < This->numLayers) */ ktxTexture_GetImageOffset(ktxTexture(This), miplevel, 0, 0, &offset); - result = iterCb(miplevel, 0, width, height, depth, - levelSize, This->pData + offset, userdata); - if (result != KTX_SUCCESS) - break; + result = iterCb(miplevel, 0, width, height, depth, levelSize, This->pData + offset, userdata); + if (result != KTX_SUCCESS) break; } return result; @@ -1149,42 +1047,36 @@ ktxTexture1_IterateLevels(ktxTexture1* This, PFNKTXITERCB iterCb, void* userdata * hold the base level image. */ KTX_error_code -ktxTexture1_IterateLoadLevelFaces(ktxTexture1* This, PFNKTXITERCB iterCb, - void* userdata) -{ +ktxTexture1_IterateLoadLevelFaces(ktxTexture1* This, PFNKTXITERCB iterCb, void* userdata) { DECLARE_PRIVATE(ktxTexture1); struct ktxTexture_protected* prtctd = This->_protected; - ktxStream* stream = (ktxStream *)&prtctd->_stream; - ktx_uint32_t dataSize = 0; - ktx_uint32_t miplevel; - KTX_error_code result = KTX_SUCCESS; - void* data = NULL; + ktxStream* stream = (ktxStream*)&prtctd->_stream; + ktx_uint32_t dataSize = 0; + ktx_uint32_t miplevel; + KTX_error_code result = KTX_SUCCESS; + void* data = NULL; - if (This == NULL) - return KTX_INVALID_VALUE; + if (This == NULL) return KTX_INVALID_VALUE; - if (This->classId != ktxTexture1_c) - return KTX_INVALID_OPERATION; + if (This->classId != ktxTexture1_c) return KTX_INVALID_OPERATION; - if (iterCb == NULL) - return KTX_INVALID_VALUE; + if (iterCb == NULL) return KTX_INVALID_VALUE; if (prtctd->_stream.data.file == NULL) // This Texture not created from a stream or images are already loaded. return KTX_INVALID_OPERATION; - for (miplevel = 0; miplevel < This->numLevels; ++miplevel) - { + for (miplevel = 0; miplevel < This->numLevels; ++miplevel) { ktx_uint32_t faceLodSize; ktx_uint32_t faceLodSizePadded; ktx_uint32_t face; ktx_uint32_t innerIterations; - GLsizei width, height, depth; + GLsizei width, height, depth; /* Array textures have the same number of layers at each mip level. */ - width = MAX(1, This->baseWidth >> miplevel); + width = MAX(1, This->baseWidth >> miplevel); height = MAX(1, This->baseHeight >> miplevel); - depth = MAX(1, This->baseDepth >> miplevel); + depth = MAX(1, This->baseDepth >> miplevel); result = stream->read(stream, &faceLodSize, sizeof(ktx_uint32_t)); if (result != KTX_SUCCESS) { @@ -1206,8 +1098,7 @@ ktxTexture1_IterateLoadLevelFaces(ktxTexture1* This, PFNKTXITERCB iterCb, goto cleanup; } dataSize = faceLodSizePadded; - } - else if (dataSize < faceLodSizePadded) { + } else if (dataSize < faceLodSizePadded) { /* subsequent miplevels cannot be larger than the base miplevel */ result = KTX_FILE_DATA_ERROR; goto cleanup; @@ -1221,8 +1112,7 @@ ktxTexture1_IterateLoadLevelFaces(ktxTexture1* This, PFNKTXITERCB iterCb, innerIterations = This->numFaces; else innerIterations = 1; - for (face = 0; face < innerIterations; ++face) - { + for (face = 0; face < innerIterations; ++face) { /* And all z_slices are also passed as a group hence no * for (z_slice = 0; z_slice < This->depth) */ @@ -1239,9 +1129,7 @@ ktxTexture1_IterateLoadLevelFaces(ktxTexture1* This, PFNKTXITERCB iterCb, _ktxSwapEndian32((ktx_uint32_t*)data, faceLodSize / 4); } - result = iterCb(miplevel, face, - width, height, depth, - faceLodSize, data, userdata); + result = iterCb(miplevel, face, width, height, depth, faceLodSize, data, userdata); } } @@ -1275,17 +1163,14 @@ ktxTexture1_IterateLoadLevelFaces(ktxTexture1* This, PFNKTXITERCB iterCb, * @exception KTX_OUT_OF_MEMORY Insufficient memory for the image data. */ KTX_error_code -ktxTexture1_LoadImageData(ktxTexture1* This, - ktx_uint8_t* pBuffer, ktx_size_t bufSize) -{ +ktxTexture1_LoadImageData(ktxTexture1* This, ktx_uint8_t* pBuffer, ktx_size_t bufSize) { DECLARE_PROTECTED(ktxTexture); DECLARE_PRIVATE(ktxTexture1); - ktx_uint32_t miplevel; - ktx_uint8_t* pDest; - KTX_error_code result = KTX_SUCCESS; + ktx_uint32_t miplevel; + ktx_uint8_t* pDest; + KTX_error_code result = KTX_SUCCESS; - if (This == NULL) - return KTX_INVALID_VALUE; + if (This == NULL) return KTX_INVALID_VALUE; if (prtctd->_stream.data.file == NULL) // This Texture not created from a stream or images already loaded; @@ -1293,8 +1178,7 @@ ktxTexture1_LoadImageData(ktxTexture1* This, if (pBuffer == NULL) { This->pData = malloc(This->dataSize); - if (This->pData == NULL) - return KTX_OUT_OF_MEMORY; + if (This->pData == NULL) return KTX_OUT_OF_MEMORY; pDest = This->pData; } else if (bufSize < This->dataSize) { return KTX_INVALID_VALUE; @@ -1303,15 +1187,13 @@ ktxTexture1_LoadImageData(ktxTexture1* This, } // Need to loop through for correct byte swapping - for (miplevel = 0; miplevel < This->numLevels; ++miplevel) - { + for (miplevel = 0; miplevel < This->numLevels; ++miplevel) { ktx_uint32_t faceLodSize; ktx_uint32_t faceLodSizePadded; ktx_uint32_t face; ktx_uint32_t innerIterations; - result = prtctd->_stream.read(&prtctd->_stream, &faceLodSize, - sizeof(ktx_uint32_t)); + result = prtctd->_stream.read(&prtctd->_stream, &faceLodSize, sizeof(ktx_uint32_t)); if (result != KTX_SUCCESS) { goto cleanup; } @@ -1328,10 +1210,8 @@ ktxTexture1_LoadImageData(ktxTexture1* This, innerIterations = This->numFaces; else innerIterations = 1; - for (face = 0; face < innerIterations; ++face) - { - result = prtctd->_stream.read(&prtctd->_stream, pDest, - faceLodSizePadded); + for (face = 0; face < innerIterations; ++face) { + result = prtctd->_stream.read(&prtctd->_stream, pDest, faceLodSizePadded); if (result != KTX_SUCCESS) { goto cleanup; } @@ -1355,8 +1235,7 @@ ktxTexture1_LoadImageData(ktxTexture1* This, } ktx_bool_t -ktxTexture1_NeedsTranscoding(ktxTexture1* This) -{ +ktxTexture1_NeedsTranscoding(ktxTexture1* This) { UNUSED(This); return KTX_FALSE; } @@ -1368,10 +1247,8 @@ ktxTexture1_NeedsTranscoding(ktxTexture1* This) */ KTX_error_code -ktxTexture1_SetImageFromMemory(ktxTexture1* This, ktx_uint32_t level, - ktx_uint32_t layer, ktx_uint32_t faceSlice, - const ktx_uint8_t* src, ktx_size_t srcSize) -{ +ktxTexture1_SetImageFromMemory(ktxTexture1* This, ktx_uint32_t level, ktx_uint32_t layer, ktx_uint32_t faceSlice, + const ktx_uint8_t* src, ktx_size_t srcSize) { UNUSED(This); UNUSED(level); UNUSED(layer); @@ -1382,10 +1259,8 @@ ktxTexture1_SetImageFromMemory(ktxTexture1* This, ktx_uint32_t level, } KTX_error_code -ktxTexture1_SetImageFromStdioStream(ktxTexture1* This, ktx_uint32_t level, - ktx_uint32_t layer, ktx_uint32_t faceSlice, - FILE* src, ktx_size_t srcSize) -{ +ktxTexture1_SetImageFromStdioStream(ktxTexture1* This, ktx_uint32_t level, ktx_uint32_t layer, ktx_uint32_t faceSlice, FILE* src, + ktx_size_t srcSize) { UNUSED(This); UNUSED(level); UNUSED(layer); @@ -1396,25 +1271,21 @@ ktxTexture1_SetImageFromStdioStream(ktxTexture1* This, ktx_uint32_t level, } KTX_error_code -ktxTexture1_WriteToStdioStream(ktxTexture1* This, FILE* dstsstr) -{ +ktxTexture1_WriteToStdioStream(ktxTexture1* This, FILE* dstsstr) { UNUSED(This); UNUSED(dstsstr); return KTX_INVALID_OPERATION; } KTX_error_code -ktxTexture1_WriteToNamedFile(ktxTexture1* This, const char* const dstname) -{ +ktxTexture1_WriteToNamedFile(ktxTexture1* This, const char* const dstname) { UNUSED(This); UNUSED(dstname); return KTX_INVALID_OPERATION; } KTX_error_code -ktxTexture1_WriteToMemory(ktxTexture1* This, - ktx_uint8_t** ppDstBytes, ktx_size_t* pSize) -{ +ktxTexture1_WriteToMemory(ktxTexture1* This, ktx_uint8_t** ppDstBytes, ktx_size_t* pSize) { UNUSED(This); UNUSED(ppDstBytes); UNUSED(pSize); @@ -1422,9 +1293,7 @@ ktxTexture1_WriteToMemory(ktxTexture1* This, } KTX_error_code -ktxTexture1_WriteToStream(ktxTexture1* This, - ktxStream* dststr) -{ +ktxTexture1_WriteToStream(ktxTexture1* This, ktxStream* dststr) { UNUSED(This); UNUSED(dststr); return KTX_INVALID_OPERATION; @@ -1437,11 +1306,9 @@ ktxTexture1_WriteToStream(ktxTexture1* This, * these functions. */ -struct ktxTexture_vtblInt ktxTexture1_vtblInt = { - (PFNCALCDATASIZELEVELS)ktxTexture1_calcDataSizeLevels, - (PFNCALCFACELODSIZE)ktxTexture1_calcFaceLodSize, - (PFNCALCLEVELOFFSET)ktxTexture1_calcLevelOffset -}; +struct ktxTexture_vtblInt ktxTexture1_vtblInt = {(PFNCALCDATASIZELEVELS)ktxTexture1_calcDataSizeLevels, + (PFNCALCFACELODSIZE)ktxTexture1_calcFaceLodSize, + (PFNCALCLEVELOFFSET)ktxTexture1_calcLevelOffset}; struct ktxTexture_vtbl ktxTexture1_vtbl = { (PFNKTEXDESTROY)ktxTexture1_Destroy, @@ -1461,4 +1328,3 @@ struct ktxTexture_vtbl ktxTexture1_vtbl = { }; /** @} */ - diff --git a/lib/texture1.h b/lib/texture1.h index 95734cc5f7..24d320605d 100644 --- a/lib/texture1.h +++ b/lib/texture1.h @@ -30,10 +30,8 @@ extern "C" { #include "texture_funcs.inl" #undef CLASS -KTX_error_code -ktxTexture1_constructFromStreamAndHeader(ktxTexture1* This, ktxStream* pStream, - KTX_header* pHeader, - ktxTextureCreateFlags createFlags); +KTX_error_code ktxTexture1_constructFromStreamAndHeader(ktxTexture1* This, ktxStream* pStream, KTX_header* pHeader, + ktxTextureCreateFlags createFlags); ktx_uint64_t ktxTexture1_calcDataSizeTexture(ktxTexture1* This); ktx_size_t ktxTexture1_calcLevelOffset(ktxTexture1* This, ktx_uint32_t level); diff --git a/lib/texture2.c b/lib/texture2.c index 014612fb57..a69527a05b 100644 --- a/lib/texture2.c +++ b/lib/texture2.c @@ -52,169 +52,176 @@ struct ktxTexture_vtblInt ktxTexture2_vtblInt; // These are preferred as they are much easier to manually initialize // and verify. struct sampleType { - uint32_t bitOffset: 16; - uint32_t bitLength: 8; - uint32_t channelType: 8; // Includes qualifiers - uint32_t samplePosition0: 8; - uint32_t samplePosition1: 8; - uint32_t samplePosition2: 8; - uint32_t samplePosition3: 8; + uint32_t bitOffset : 16; + uint32_t bitLength : 8; + uint32_t channelType : 8; // Includes qualifiers + uint32_t samplePosition0 : 8; + uint32_t samplePosition1 : 8; + uint32_t samplePosition2 : 8; + uint32_t samplePosition3 : 8; uint32_t lower; uint32_t upper; }; struct BDFD { - uint32_t vendorId: 17; - uint32_t descriptorType: 15; - uint32_t versionNumber: 16; - uint32_t descriptorBlockSize: 16; - uint32_t model: 8; - uint32_t primaries: 8; - uint32_t transfer: 8; - uint32_t flags: 8; - uint32_t texelBlockDimension0: 8; - uint32_t texelBlockDimension1: 8; - uint32_t texelBlockDimension2: 8; - uint32_t texelBlockDimension3: 8; - uint32_t bytesPlane0: 8; - uint32_t bytesPlane1: 8; - uint32_t bytesPlane2: 8; - uint32_t bytesPlane3: 8; - uint32_t bytesPlane4: 8; - uint32_t bytesPlane5: 8; - uint32_t bytesPlane6: 8; - uint32_t bytesPlane7: 8; + uint32_t vendorId : 17; + uint32_t descriptorType : 15; + uint32_t versionNumber : 16; + uint32_t descriptorBlockSize : 16; + uint32_t model : 8; + uint32_t primaries : 8; + uint32_t transfer : 8; + uint32_t flags : 8; + uint32_t texelBlockDimension0 : 8; + uint32_t texelBlockDimension1 : 8; + uint32_t texelBlockDimension2 : 8; + uint32_t texelBlockDimension3 : 8; + uint32_t bytesPlane0 : 8; + uint32_t bytesPlane1 : 8; + uint32_t bytesPlane2 : 8; + uint32_t bytesPlane3 : 8; + uint32_t bytesPlane4 : 8; + uint32_t bytesPlane5 : 8; + uint32_t bytesPlane6 : 8; + uint32_t bytesPlane7 : 8; struct sampleType samples[6]; }; -struct BDFD e5b9g9r9_ufloat_comparator = { - .vendorId = 0, - .descriptorType = 0, - .versionNumber = 2, - .descriptorBlockSize = sizeof(struct BDFD), - .model = KHR_DF_MODEL_RGBSDA, - .primaries = KHR_DF_PRIMARIES_BT709, - .transfer = KHR_DF_TRANSFER_LINEAR, - .flags = KHR_DF_FLAG_ALPHA_STRAIGHT, - .texelBlockDimension0 = 0, - .texelBlockDimension1 = 0, - .texelBlockDimension2 = 0, - .texelBlockDimension3 = 0, - .bytesPlane0 = 4, - .bytesPlane1 = 0, - .bytesPlane2 = 0, - .bytesPlane3 = 0, - .bytesPlane4 = 0, - .bytesPlane5 = 0, - .bytesPlane6 = 0, - .bytesPlane7 = 0, - // gcc likes this way. It does not like, e.g., - // .samples[0].bitOffset = 0, etc. which is accepted by both clang & msvc. - // I find the standards docs impenetrable so I don't know which is correct. - .samples[0] = { - .bitOffset = 0, - .bitLength = 8, - .channelType = KHR_DF_CHANNEL_RGBSDA_RED, - .samplePosition0 = 0, - .samplePosition1 = 0, - .samplePosition2 = 0, - .samplePosition3 = 0, - .lower = 0, - .upper = 8448, - }, - .samples[1] = { - .bitOffset = 27, - .bitLength = 4, - .channelType = KHR_DF_CHANNEL_RGBSDA_RED | KHR_DF_SAMPLE_DATATYPE_EXPONENT, - .samplePosition0 = 0, - .samplePosition1 = 0, - .samplePosition2 = 0, - .samplePosition3 = 0, - .lower = 15, - .upper = 31, - }, - .samples[2] = { - .bitOffset = 9, - .bitLength = 8, - .channelType = KHR_DF_CHANNEL_RGBSDA_GREEN, - .samplePosition0 = 0, - .samplePosition1 = 0, - .samplePosition2 = 0, - .samplePosition3 = 0, - .lower = 0, - .upper = 8448, - }, - .samples[3] = { - .bitOffset = 27, - .bitLength = 4, - .channelType = KHR_DF_CHANNEL_RGBSDA_GREEN | KHR_DF_SAMPLE_DATATYPE_EXPONENT, - .samplePosition0 = 0, - .samplePosition1 = 0, - .samplePosition2 = 0, - .samplePosition3 = 0, - .lower = 15, - .upper = 31, - }, - .samples[4] = { - .bitOffset = 18, - .bitLength = 8, - .channelType = KHR_DF_CHANNEL_RGBSDA_BLUE, - .samplePosition0 = 0, - .samplePosition1 = 0, - .samplePosition2 = 0, - .samplePosition3 = 0, - .lower = 0, - .upper = 8448, - }, - .samples[5] = { - .bitOffset = 27, - .bitLength = 4, - .channelType = KHR_DF_CHANNEL_RGBSDA_BLUE | KHR_DF_SAMPLE_DATATYPE_EXPONENT, - .samplePosition0 = 0, - .samplePosition1 = 0, - .samplePosition2 = 0, - .samplePosition3 = 0, - .lower = 15, - .upper = 31, - } -}; +struct BDFD e5b9g9r9_ufloat_comparator = {.vendorId = 0, + .descriptorType = 0, + .versionNumber = 2, + .descriptorBlockSize = sizeof(struct BDFD), + .model = KHR_DF_MODEL_RGBSDA, + .primaries = KHR_DF_PRIMARIES_BT709, + .transfer = KHR_DF_TRANSFER_LINEAR, + .flags = KHR_DF_FLAG_ALPHA_STRAIGHT, + .texelBlockDimension0 = 0, + .texelBlockDimension1 = 0, + .texelBlockDimension2 = 0, + .texelBlockDimension3 = 0, + .bytesPlane0 = 4, + .bytesPlane1 = 0, + .bytesPlane2 = 0, + .bytesPlane3 = 0, + .bytesPlane4 = 0, + .bytesPlane5 = 0, + .bytesPlane6 = 0, + .bytesPlane7 = 0, + // gcc likes this way. It does not like, e.g., + // .samples[0].bitOffset = 0, etc. which is accepted by both clang & msvc. + // I find the standards docs impenetrable so I don't know which is correct. + .samples[0] = + { + .bitOffset = 0, + .bitLength = 8, + .channelType = KHR_DF_CHANNEL_RGBSDA_RED, + .samplePosition0 = 0, + .samplePosition1 = 0, + .samplePosition2 = 0, + .samplePosition3 = 0, + .lower = 0, + .upper = 8448, + }, + .samples[1] = + { + .bitOffset = 27, + .bitLength = 4, + .channelType = KHR_DF_CHANNEL_RGBSDA_RED | KHR_DF_SAMPLE_DATATYPE_EXPONENT, + .samplePosition0 = 0, + .samplePosition1 = 0, + .samplePosition2 = 0, + .samplePosition3 = 0, + .lower = 15, + .upper = 31, + }, + .samples[2] = + { + .bitOffset = 9, + .bitLength = 8, + .channelType = KHR_DF_CHANNEL_RGBSDA_GREEN, + .samplePosition0 = 0, + .samplePosition1 = 0, + .samplePosition2 = 0, + .samplePosition3 = 0, + .lower = 0, + .upper = 8448, + }, + .samples[3] = + { + .bitOffset = 27, + .bitLength = 4, + .channelType = KHR_DF_CHANNEL_RGBSDA_GREEN | KHR_DF_SAMPLE_DATATYPE_EXPONENT, + .samplePosition0 = 0, + .samplePosition1 = 0, + .samplePosition2 = 0, + .samplePosition3 = 0, + .lower = 15, + .upper = 31, + }, + .samples[4] = + { + .bitOffset = 18, + .bitLength = 8, + .channelType = KHR_DF_CHANNEL_RGBSDA_BLUE, + .samplePosition0 = 0, + .samplePosition1 = 0, + .samplePosition2 = 0, + .samplePosition3 = 0, + .lower = 0, + .upper = 8448, + }, + .samples[5] = { + .bitOffset = 27, + .bitLength = 4, + .channelType = KHR_DF_CHANNEL_RGBSDA_BLUE | KHR_DF_SAMPLE_DATATYPE_EXPONENT, + .samplePosition0 = 0, + .samplePosition1 = 0, + .samplePosition2 = 0, + .samplePosition3 = 0, + .lower = 15, + .upper = 31, + }}; #else // For compilers which order bitfields from the msb rather than lsb. -#define shift(x,val) ((val) << KHR_DF_SHIFT_ ## x) -#define sampleshift(x,val) ((val) << KHR_DF_SAMPLESHIFT_ ## x) +#define shift(x, val) ((val) << KHR_DF_SHIFT_##x) +#define sampleshift(x, val) ((val) << KHR_DF_SAMPLESHIFT_##x) #define e5b9g9r9_bdbwordcount KHR_DFDSIZEWORDS(6) ktx_uint32_t e5b9g9r9_ufloat_comparator[e5b9g9r9_bdbwordcount] = { - 0, // descriptorType & vendorId + 0, // descriptorType & vendorId shift(DESCRIPTORBLOCKSIZE, e5b9g9r9_bdbwordcount * sizeof(ktx_uint32_t)) | shift(VERSIONNUMBER, 2), // N.B. Allow various values of primaries, transfer & flags - shift(FLAGS, KHR_DF_FLAG_ALPHA_STRAIGHT) | shift(TRANSFER, KHR_DF_TRANSFER_LINEAR) | shift(PRIMARIES, KHR_DF_PRIMARIES_BT709) | shift(MODEL, KHR_DF_MODEL_RGBSDA), - 0, // texelBlockDimension3~0 + shift(FLAGS, KHR_DF_FLAG_ALPHA_STRAIGHT) | shift(TRANSFER, KHR_DF_TRANSFER_LINEAR) | shift(PRIMARIES, KHR_DF_PRIMARIES_BT709) | + shift(MODEL, KHR_DF_MODEL_RGBSDA), + 0, // texelBlockDimension3~0 shift(BYTESPLANE0, 4), // All other bytesPlane fields are 0. - 0, // bytesPlane7~4 + 0, // bytesPlane7~4 sampleshift(CHANNELID, KHR_DF_CHANNEL_RGBSDA_RED) | sampleshift(BITLENGTH, 8) | sampleshift(BITOFFSET, 0), - 0, // samplePosition3~0 - 0, // sampleLower - 8448, // sampleUpper - sampleshift(CHANNELID, KHR_DF_CHANNEL_RGBSDA_RED | KHR_DF_SAMPLE_DATATYPE_EXPONENT) | sampleshift(BITLENGTH, 4) | sampleshift(BITOFFSET, 27), - 0, // samplePosition3~0 - 15, // sampleLower - 31, // sampleUpper + 0, // samplePosition3~0 + 0, // sampleLower + 8448, // sampleUpper + sampleshift(CHANNELID, KHR_DF_CHANNEL_RGBSDA_RED | KHR_DF_SAMPLE_DATATYPE_EXPONENT) | sampleshift(BITLENGTH, 4) | + sampleshift(BITOFFSET, 27), + 0, // samplePosition3~0 + 15, // sampleLower + 31, // sampleUpper sampleshift(CHANNELID, KHR_DF_CHANNEL_RGBSDA_GREEN) | sampleshift(BITLENGTH, 8) | sampleshift(BITOFFSET, 9), - 0, // samplePosition3~0 - 0, // sampleLower - 8448, // sampleUpper - sampleshift(CHANNELID, KHR_DF_CHANNEL_RGBSDA_GREEN | KHR_DF_SAMPLE_DATATYPE_EXPONENT) | sampleshift(BITLENGTH, 4) | sampleshift(BITOFFSET, 27), - 0, // samplePosition3~0 - 15, // sampleLower - 31, // sampleUpper + 0, // samplePosition3~0 + 0, // sampleLower + 8448, // sampleUpper + sampleshift(CHANNELID, KHR_DF_CHANNEL_RGBSDA_GREEN | KHR_DF_SAMPLE_DATATYPE_EXPONENT) | sampleshift(BITLENGTH, 4) | + sampleshift(BITOFFSET, 27), + 0, // samplePosition3~0 + 15, // sampleLower + 31, // sampleUpper sampleshift(CHANNELID, KHR_DF_CHANNEL_RGBSDA_BLUE) | sampleshift(BITLENGTH, 8) | sampleshift(BITOFFSET, 18), - 0, // samplePosition3~0 - 0, // sampleLower - 8448, // sampleUpper - sampleshift(CHANNELID, KHR_DF_CHANNEL_RGBSDA_BLUE | KHR_DF_SAMPLE_DATATYPE_EXPONENT) | sampleshift(BITLENGTH, 4) | sampleshift(BITOFFSET, 27), - 0, // samplePosition3~0 - 15, // sampleLower - 31, // sampleUpper + 0, // samplePosition3~0 + 0, // sampleLower + 8448, // sampleUpper + sampleshift(CHANNELID, KHR_DF_CHANNEL_RGBSDA_BLUE | KHR_DF_SAMPLE_DATATYPE_EXPONENT) | sampleshift(BITLENGTH, 4) | + sampleshift(BITOFFSET, 27), + 0, // samplePosition3~0 + 15, // sampleLower + 31, // sampleUpper }; #endif @@ -232,8 +239,7 @@ ktx_uint32_t e5b9g9r9_ufloat_comparator[e5b9g9r9_bdbwordcount] = { * @return KTX_TRUE on success, otherwise KTX_FALSE. */ bool -ktxFormatSize_initFromDfd(ktxFormatSize* This, ktx_uint32_t* pDfd) -{ +ktxFormatSize_initFromDfd(ktxFormatSize* This, ktx_uint32_t* pDfd) { uint32_t* pBdb = pDfd + 1; // Check the DFD is of the expected type and version. @@ -250,7 +256,7 @@ ktxFormatSize_initFromDfd(ktxFormatSize* This, ktx_uint32_t* pDfd) This->blockHeight = KHR_DFDVAL(pBdb, TEXELBLOCKDIMENSION1) + 1; This->blockDepth = KHR_DFDVAL(pBdb, TEXELBLOCKDIMENSION2) + 1; This->blockSizeInBits = KHR_DFDVAL(pBdb, BYTESPLANE0) * 8; - This->paletteSizeInBits = 0; // No paletted formats in ktx v2. + This->paletteSizeInBits = 0; // No paletted formats in ktx v2. This->flags = 0; This->minBlocksX = This->minBlocksY = 1; if (KHR_DFDVAL(pBdb, MODEL) >= KHR_DF_MODEL_DXT1A) { @@ -277,9 +283,13 @@ ktxFormatSize_initFromDfd(ktxFormatSize* This, ktx_uint32_t* pDfd) This->flags |= KTX_FORMAT_SIZE_STENCIL_BIT; } else if (KHR_DFDSAMPLECOUNT(pBdb) == 6 #if !defined(BITFIELD_ORDER_FROM_MSB) - && !memcmp(((uint32_t*)&e5b9g9r9_ufloat_comparator) + KHR_DF_WORD_TEXELBLOCKDIMENSION0, &pBdb[KHR_DF_WORD_TEXELBLOCKDIMENSION0], sizeof(e5b9g9r9_ufloat_comparator)-(KHR_DF_WORD_TEXELBLOCKDIMENSION0)*sizeof(uint32_t))) { + && !memcmp(((uint32_t*)&e5b9g9r9_ufloat_comparator) + KHR_DF_WORD_TEXELBLOCKDIMENSION0, + &pBdb[KHR_DF_WORD_TEXELBLOCKDIMENSION0], + sizeof(e5b9g9r9_ufloat_comparator) - (KHR_DF_WORD_TEXELBLOCKDIMENSION0) * sizeof(uint32_t))) { #else - && !memcmp(&e5b9g9r9_ufloat_comparator[KHR_DF_WORD_TEXELBLOCKDIMENSION0], &pBdb[KHR_DF_WORD_TEXELBLOCKDIMENSION0], sizeof(e5b9g9r9_ufloat_comparator)-(KHR_DF_WORD_TEXELBLOCKDIMENSION0)*sizeof(uint32_t))) { + && + !memcmp(&e5b9g9r9_ufloat_comparator[KHR_DF_WORD_TEXELBLOCKDIMENSION0], &pBdb[KHR_DF_WORD_TEXELBLOCKDIMENSION0], + sizeof(e5b9g9r9_ufloat_comparator) - (KHR_DF_WORD_TEXELBLOCKDIMENSION0) * sizeof(uint32_t))) { #endif // Special case VK_FORMAT_E5B9G9R9_UFLOAT_PACK32 as interpretDFD // only handles "simple formats", i.e. where channels are described @@ -290,16 +300,11 @@ ktxFormatSize_initFromDfd(ktxFormatSize* This, ktx_uint32_t* pDfd) uint32_t wordBytes; enum InterpretDFDResult result; - result = interpretDFD(pDfd, &rgba[0], &rgba[1], &rgba[2], &rgba[3], - &wordBytes); - if (result >= i_UNSUPPORTED_ERROR_BIT) - return false; - if (result & i_PACKED_FORMAT_BIT) - This->flags |= KTX_FORMAT_SIZE_PACKED_BIT; - if (result & i_COMPRESSED_FORMAT_BIT) - This->flags |= KTX_FORMAT_SIZE_COMPRESSED_BIT; - if (result & i_YUVSDA_FORMAT_BIT) - This->flags |= KTX_FORMAT_SIZE_YUVSDA_BIT; + result = interpretDFD(pDfd, &rgba[0], &rgba[1], &rgba[2], &rgba[3], &wordBytes); + if (result >= i_UNSUPPORTED_ERROR_BIT) return false; + if (result & i_PACKED_FORMAT_BIT) This->flags |= KTX_FORMAT_SIZE_PACKED_BIT; + if (result & i_COMPRESSED_FORMAT_BIT) This->flags |= KTX_FORMAT_SIZE_COMPRESSED_BIT; + if (result & i_YUVSDA_FORMAT_BIT) This->flags |= KTX_FORMAT_SIZE_YUVSDA_BIT; } } if (This->blockSizeInBits == 0) { @@ -331,8 +336,7 @@ ktxFormatSize_initFromDfd(ktxFormatSize* This, ktx_uint32_t* pDfd) * @param[in] vkFormat the format for which to create a DFD. */ static uint32_t* -ktxVk2dfd(ktx_uint32_t vkFormat) -{ +ktxVk2dfd(ktx_uint32_t vkFormat) { return vk2dfd(vkFormat); } @@ -350,16 +354,14 @@ ktxVk2dfd(ktx_uint32_t vkFormat) * @exception KTX_OUT_OF_MEMORY Not enough memory for the texture data. */ static KTX_error_code -ktxTexture2_constructCommon(ktxTexture2* This, ktx_uint32_t numLevels) -{ +ktxTexture2_constructCommon(ktxTexture2* This, ktx_uint32_t numLevels) { assert(This != NULL); ktx_size_t privateSize; This->classId = ktxTexture2_c; This->vtbl = &ktxTexture2_vtbl; This->_protected->_vtbl = ktxTexture2_vtblInt; - privateSize = sizeof(ktxTexture2_private) - + sizeof(ktxLevelIndexEntry) * (numLevels - 1); + privateSize = sizeof(ktxTexture2_private) + sizeof(ktxLevelIndexEntry) * (numLevels - 1); This->_private = (ktxTexture2_private*)malloc(privateSize); if (This->_private == NULL) { return KTX_OUT_OF_MEMORY; @@ -387,9 +389,7 @@ ktxTexture2_constructCommon(ktxTexture2* This, ktx_uint32_t numLevels) * prohibited formats. */ static KTX_error_code -ktxTexture2_construct(ktxTexture2* This, ktxTextureCreateInfo* createInfo, - ktxTextureCreateStorageEnum storageAllocation) -{ +ktxTexture2_construct(ktxTexture2* This, ktxTextureCreateInfo* createInfo, ktxTextureCreateStorageEnum storageAllocation) { ktxFormatSize formatSize; KTX_error_code result; @@ -397,8 +397,7 @@ ktxTexture2_construct(ktxTexture2* This, ktxTextureCreateInfo* createInfo, if (createInfo->vkFormat != VK_FORMAT_UNDEFINED) { This->pDfd = ktxVk2dfd(createInfo->vkFormat); - if (!This->pDfd) - return KTX_INVALID_VALUE; // Format is unknown or unsupported. + if (!This->pDfd) return KTX_INVALID_VALUE; // Format is unknown or unsupported. #ifdef _DEBUG // If this fires, an unsupported format or incorrect DFD @@ -411,8 +410,7 @@ ktxTexture2_construct(ktxTexture2* This, ktxTextureCreateInfo* createInfo, } else { // TODO: Validate createInfo->pDfd. This->pDfd = (ktx_uint32_t*)malloc(*createInfo->pDfd); - if (!This->pDfd) - return KTX_OUT_OF_MEMORY; + if (!This->pDfd) return KTX_OUT_OF_MEMORY; memcpy(This->pDfd, createInfo->pDfd, *createInfo->pDfd); if (!ktxFormatSize_initFromDfd(&formatSize, This->pDfd)) { result = KTX_UNSUPPORTED_TEXTURE_TYPE; @@ -420,13 +418,12 @@ ktxTexture2_construct(ktxTexture2* This, ktxTextureCreateInfo* createInfo, } } - result = ktxTexture_construct(ktxTexture(This), createInfo, &formatSize); + result = ktxTexture_construct(ktxTexture(This), createInfo, &formatSize); - if (result != KTX_SUCCESS) - return result; + if (result != KTX_SUCCESS) return result; result = ktxTexture2_constructCommon(This, createInfo->numLevels); - if (result != KTX_SUCCESS) - goto cleanup;; + if (result != KTX_SUCCESS) goto cleanup; + ; This->vkFormat = createInfo->vkFormat; @@ -438,8 +435,7 @@ ktxTexture2_construct(ktxTexture2* This, ktxTextureCreateInfo* createInfo, This->supercompressionScheme = KTX_SS_NONE; - This->_private->_requiredLevelAlignment - = ktxTexture2_calcRequiredLevelAlignment(This); + This->_private->_requiredLevelAlignment = ktxTexture2_calcRequiredLevelAlignment(This); // Create levelIndex. Offsets are from start of the KTX2 stream. ktxLevelIndexEntry* levelIndex = This->_private->_levelIndex; @@ -447,19 +443,14 @@ ktxTexture2_construct(ktxTexture2* This, ktxTextureCreateInfo* createInfo, This->_private->_firstLevelFileOffset = 0; for (ktx_uint32_t level = 0; level < This->numLevels; level++) { - levelIndex[level].uncompressedByteLength = - ktxTexture_calcLevelSize(ktxTexture(This), level, - KTX_FORMAT_VERSION_TWO); - levelIndex[level].byteLength = - levelIndex[level].uncompressedByteLength; - levelIndex[level].byteOffset = - ktxTexture_calcLevelOffset(ktxTexture(This), level); + levelIndex[level].uncompressedByteLength = ktxTexture_calcLevelSize(ktxTexture(This), level, KTX_FORMAT_VERSION_TWO); + levelIndex[level].byteLength = levelIndex[level].uncompressedByteLength; + levelIndex[level].byteOffset = ktxTexture_calcLevelOffset(ktxTexture(This), level); } // Allocate storage, if requested. if (storageAllocation == KTX_TEXTURE_CREATE_ALLOC_STORAGE) { - This->dataSize - = ktxTexture_calcDataSizeTexture(ktxTexture(This)); + This->dataSize = ktxTexture_calcDataSizeTexture(ktxTexture(This)); This->pData = malloc(This->dataSize); if (This->pData == NULL) { result = KTX_OUT_OF_MEMORY; @@ -487,8 +478,7 @@ ktxTexture2_construct(ktxTexture2* This, ktxTextureCreateInfo* createInfo, * @exception KTX_OUT_OF_MEMORY Not enough memory for the texture data. */ KTX_error_code -ktxTexture2_constructCopy(ktxTexture2* This, ktxTexture2* orig) -{ +ktxTexture2_constructCopy(ktxTexture2* This, ktxTexture2* orig) { KTX_error_code result; memcpy(This, orig, sizeof(ktxTexture2)); @@ -500,17 +490,13 @@ ktxTexture2_constructCopy(ktxTexture2* This, ktxTexture2* orig) This->kvDataHead = NULL; This->pData = NULL; - This->_protected = - (ktxTexture_protected*)malloc(sizeof(ktxTexture_protected)); - if (!This->_protected) - return KTX_OUT_OF_MEMORY; + This->_protected = (ktxTexture_protected*)malloc(sizeof(ktxTexture_protected)); + if (!This->_protected) return KTX_OUT_OF_MEMORY; // Must come before memcpy of _protected so as to close an active stream. - if (!orig->pData && ktxTexture_isActiveStream((ktxTexture*)orig)) - ktxTexture2_LoadImageData(orig, NULL, 0); + if (!orig->pData && ktxTexture_isActiveStream((ktxTexture*)orig)) ktxTexture2_LoadImageData(orig, NULL, 0); memcpy(This->_protected, orig->_protected, sizeof(ktxTexture_protected)); - ktx_size_t privateSize = sizeof(ktxTexture2_private) - + sizeof(ktxLevelIndexEntry) * (orig->numLevels - 1); + ktx_size_t privateSize = sizeof(ktxTexture2_private) + sizeof(ktxLevelIndexEntry) * (orig->numLevels - 1); This->_private = (ktxTexture2_private*)malloc(privateSize); if (This->_private == NULL) { result = KTX_OUT_OF_MEMORY; @@ -518,14 +504,12 @@ ktxTexture2_constructCopy(ktxTexture2* This, ktxTexture2* orig) } memcpy(This->_private, orig->_private, privateSize); if (orig->_private->_sgdByteLength > 0) { - This->_private->_supercompressionGlobalData - = (ktx_uint8_t*)malloc(orig->_private->_sgdByteLength); + This->_private->_supercompressionGlobalData = (ktx_uint8_t*)malloc(orig->_private->_sgdByteLength); if (!This->_private->_supercompressionGlobalData) { result = KTX_OUT_OF_MEMORY; goto cleanup; } - memcpy(This->_private->_supercompressionGlobalData, - orig->_private->_supercompressionGlobalData, + memcpy(This->_private->_supercompressionGlobalData, orig->_private->_supercompressionGlobalData, orig->_private->_sgdByteLength); } @@ -564,11 +548,10 @@ ktxTexture2_constructCopy(ktxTexture2* This, ktxTexture2* orig) cleanup: if (This->_protected) free(This->_protected); if (This->_private) { - if (This->_private->_supercompressionGlobalData) - free(This->_private->_supercompressionGlobalData); + if (This->_private->_supercompressionGlobalData) free(This->_private->_supercompressionGlobalData); free(This->_private); } - if (This->pDfd) free (This->pDfd); + if (This->pDfd) free(This->pDfd); if (This->kvDataHead) ktxHashList_Destruct(&This->kvDataHead); return result; @@ -623,10 +606,8 @@ ktxTexture2_constructCopy(ktxTexture2* This, ktxTexture2* orig) * supported by OpenGL or Vulkan, e.g, a 3D array. */ KTX_error_code -ktxTexture2_constructFromStreamAndHeader(ktxTexture2* This, ktxStream* pStream, - KTX_header2* pHeader, - ktxTextureCreateFlags createFlags) -{ +ktxTexture2_constructFromStreamAndHeader(ktxTexture2* This, ktxStream* pStream, KTX_header2* pHeader, + ktxTextureCreateFlags createFlags) { ktxTexture2_private* private; KTX_error_code result; KTX_supplemental_info suppInfo; @@ -637,18 +618,14 @@ ktxTexture2_constructFromStreamAndHeader(ktxTexture2* This, ktxStream* pStream, assert(pHeader != NULL && pStream != NULL); memset(This, 0, sizeof(*This)); - result = ktxTexture_constructFromStream(ktxTexture(This), pStream, - createFlags); - if (result != KTX_SUCCESS) - return result; + result = ktxTexture_constructFromStream(ktxTexture(This), pStream, createFlags); + if (result != KTX_SUCCESS) return result; result = ktxCheckHeader2_(pHeader, &suppInfo); - if (result != KTX_SUCCESS) - goto cleanup; + if (result != KTX_SUCCESS) goto cleanup; // ktxCheckHeader2_ has done the max(1, levelCount) on pHeader->levelCount. result = ktxTexture2_constructCommon(This, pHeader->levelCount); - if (result != KTX_SUCCESS) - goto cleanup; + if (result != KTX_SUCCESS) goto cleanup; private = This->_private; stream = ktxTexture2_getStream(This); @@ -665,14 +642,14 @@ ktxTexture2_constructFromStreamAndHeader(ktxTexture2* This, ktxStream* pStream, This->baseWidth = pHeader->pixelWidth; assert(suppInfo.textureDimension > 0 && suppInfo.textureDimension < 4); switch (suppInfo.textureDimension) { - case 1: + case 1: This->baseHeight = This->baseDepth = 1; break; - case 2: + case 2: This->baseHeight = pHeader->pixelHeight; This->baseDepth = 1; break; - case 3: + case 3: This->baseHeight = pHeader->pixelHeight; This->baseDepth = pHeader->pixelDepth; break; @@ -697,22 +674,18 @@ ktxTexture2_constructFromStreamAndHeader(ktxTexture2* This, ktxStream* pStream, // Read level index levelIndexSize = sizeof(ktxLevelIndexEntry) * This->numLevels; result = stream->read(stream, &private->_levelIndex, levelIndexSize); - if (result != KTX_SUCCESS) - goto cleanup; + if (result != KTX_SUCCESS) goto cleanup; // Rebase index to start of data and save file offset. - private->_firstLevelFileOffset - = private->_levelIndex[This->numLevels-1].byteOffset; + private->_firstLevelFileOffset = private->_levelIndex[This->numLevels - 1].byteOffset; for (ktx_uint32_t level = 0; level < This->numLevels; level++) { - private->_levelIndex[level].byteOffset - -= private->_firstLevelFileOffset; + private->_levelIndex[level].byteOffset -= private->_firstLevelFileOffset; if (This->supercompressionScheme == KTX_SS_NONE && private->_levelIndex[level].byteLength != private->_levelIndex[level].uncompressedByteLength) { // For non-supercompressed files the levels must have matching byte lengths result = KTX_FILE_DATA_ERROR; } } - if (result != KTX_SUCCESS) - goto cleanup; + if (result != KTX_SUCCESS) goto cleanup; // Read DFD if (pHeader->dataFormatDescriptor.byteOffset == 0 || pHeader->dataFormatDescriptor.byteLength < 16) { @@ -720,16 +693,13 @@ ktxTexture2_constructFromStreamAndHeader(ktxTexture2* This, ktxStream* pStream, result = KTX_FILE_DATA_ERROR; goto cleanup; } - This->pDfd = - (ktx_uint32_t*)malloc(pHeader->dataFormatDescriptor.byteLength); + This->pDfd = (ktx_uint32_t*)malloc(pHeader->dataFormatDescriptor.byteLength); if (!This->pDfd) { result = KTX_OUT_OF_MEMORY; goto cleanup; } - result = stream->read(stream, This->pDfd, - pHeader->dataFormatDescriptor.byteLength); - if (result != KTX_SUCCESS) - goto cleanup; + result = stream->read(stream, This->pDfd, pHeader->dataFormatDescriptor.byteLength); + if (result != KTX_SUCCESS) goto cleanup; if (pHeader->dataFormatDescriptor.byteLength != This->pDfd[0]) { // DFD byteLength does not match dfdTotalSize @@ -783,8 +753,7 @@ ktxTexture2_constructFromStreamAndHeader(ktxTexture2* This, ktxStream* pStream, result = KTX_FILE_DATA_ERROR; goto cleanup; } - if (pBDFD->model == KHR_DF_MODEL_UASTC && - This->supercompressionScheme != KTX_SS_NONE && + if (pBDFD->model == KHR_DF_MODEL_UASTC && This->supercompressionScheme != KTX_SS_NONE && This->supercompressionScheme != KTX_SS_ZSTD) { // KHR_texture_basisu only allows NONE and ZSTD supercompression for UASTC result = KTX_FILE_DATA_ERROR; @@ -804,23 +773,22 @@ ktxTexture2_constructFromStreamAndHeader(ktxTexture2* This, ktxStream* pStream, result = KTX_FILE_DATA_ERROR; goto cleanup; } - if (pBDFD->texelBlockDimension0 != 3 || pBDFD->texelBlockDimension1 != 3 || - pBDFD->texelBlockDimension2 != 0 || pBDFD->texelBlockDimension3 != 0) { + if (pBDFD->texelBlockDimension0 != 3 || pBDFD->texelBlockDimension1 != 3 || pBDFD->texelBlockDimension2 != 0 || + pBDFD->texelBlockDimension3 != 0) { // Texel block dimension must be 4x4x1x1 (offset by one) result = KTX_FILE_DATA_ERROR; goto cleanup; } } - This->_private->_requiredLevelAlignment - = ktxTexture2_calcRequiredLevelAlignment(This); + This->_private->_requiredLevelAlignment = ktxTexture2_calcRequiredLevelAlignment(This); // Make an empty hash list. ktxHashList_Construct(&This->kvDataHead); // Load KVData. if (pHeader->keyValueData.byteLength > 0) { uint32_t expectedOffset = pHeader->dataFormatDescriptor.byteOffset + pHeader->dataFormatDescriptor.byteLength; - expectedOffset = (expectedOffset + 3) & ~0x3; // 4 byte aligned + expectedOffset = (expectedOffset + 3) & ~0x3; // 4 byte aligned if (pHeader->keyValueData.byteOffset != expectedOffset) { result = KTX_FILE_DATA_ERROR; goto cleanup; @@ -836,8 +804,7 @@ ktxTexture2_constructFromStreamAndHeader(ktxTexture2* This, ktxStream* pStream, } result = stream->read(stream, pKvd, kvdLen); - if (result != KTX_SUCCESS) - goto cleanup; + if (result != KTX_SUCCESS) goto cleanup; if (IS_BIG_ENDIAN) { /* Swap the counts inside the key & value data. */ @@ -856,17 +823,13 @@ ktxTexture2_constructFromStreamAndHeader(ktxTexture2* This, ktxStream* pStream, ktx_uint32_t animData[3]; ktx_uint32_t animDataLen; - result = ktxHashList_Deserialize(&This->kvDataHead, - kvdLen, pKvd); + result = ktxHashList_Deserialize(&This->kvDataHead, kvdLen, pKvd); free(pKvd); if (result != KTX_SUCCESS) { goto cleanup; } - result = ktxHashList_FindValue(&This->kvDataHead, - KTX_ORIENTATION_KEY, - &orientationLen, - (void**)&orientationStr); + result = ktxHashList_FindValue(&This->kvDataHead, KTX_ORIENTATION_KEY, &orientationLen, (void**)&orientationStr); assert(result != KTX_INVALID_VALUE); if (result == KTX_SUCCESS) { // Length includes the terminating NUL. @@ -877,23 +840,20 @@ ktxTexture2_constructFromStreamAndHeader(ktxTexture2* This, ktxStream* pStream, goto cleanup; } else { switch (This->numDimensions) { - case 3: + case 3: This->orientation.z = orientationStr[2]; FALLTHROUGH; - case 2: + case 2: This->orientation.y = orientationStr[1]; FALLTHROUGH; - case 1: + case 1: This->orientation.x = orientationStr[0]; } } } else { - result = KTX_SUCCESS; // Not finding orientation is okay. + result = KTX_SUCCESS; // Not finding orientation is okay. } - result = ktxHashList_FindValue(&This->kvDataHead, - KTX_ANIMDATA_KEY, - &animDataLen, - (void**)animData); + result = ktxHashList_FindValue(&This->kvDataHead, KTX_ANIMDATA_KEY, &animDataLen, (void**)animData); assert(result != KTX_INVALID_VALUE); if (result == KTX_SUCCESS) { if (animDataLen != sizeof(animData)) { @@ -911,7 +871,7 @@ ktxTexture2_constructFromStreamAndHeader(ktxTexture2* This, ktxStream* pStream, goto cleanup; } } else { - result = KTX_SUCCESS; // Not finding video is okay. + result = KTX_SUCCESS; // Not finding video is okay. } } else { This->kvDataLen = kvdLen; @@ -928,40 +888,34 @@ ktxTexture2_constructFromStreamAndHeader(ktxTexture2* This, ktxStream* pStream, if (pHeader->supercompressionGlobalData.byteLength > 0) { switch (This->supercompressionScheme) { - case KTX_SS_BASIS_LZ: + case KTX_SS_BASIS_LZ: break; - case KTX_SS_NONE: - case KTX_SS_ZSTD: - case KTX_SS_ZLIB: + case KTX_SS_NONE: + case KTX_SS_ZSTD: + case KTX_SS_ZLIB: // In these cases SGD is not allowed result = KTX_FILE_DATA_ERROR; break; - default: + default: // We don't support other supercompression schemes result = KTX_UNSUPPORTED_FEATURE; break; } - if (result != KTX_SUCCESS) - goto cleanup; + if (result != KTX_SUCCESS) goto cleanup; // There could be padding here so seek to the next item. - (void)stream->setpos(stream, - pHeader->supercompressionGlobalData.byteOffset); + (void)stream->setpos(stream, pHeader->supercompressionGlobalData.byteOffset); // Read supercompressionGlobalData - private->_supercompressionGlobalData = - (ktx_uint8_t*)malloc(pHeader->supercompressionGlobalData.byteLength); + private->_supercompressionGlobalData = (ktx_uint8_t*)malloc(pHeader->supercompressionGlobalData.byteLength); if (!private->_supercompressionGlobalData) { result = KTX_OUT_OF_MEMORY; goto cleanup; } - private->_sgdByteLength - = pHeader->supercompressionGlobalData.byteLength; - result = stream->read(stream, private->_supercompressionGlobalData, - private->_sgdByteLength); + private->_sgdByteLength = pHeader->supercompressionGlobalData.byteLength; + result = stream->read(stream, private->_supercompressionGlobalData, private->_sgdByteLength); - if (result != KTX_SUCCESS) - goto cleanup; + if (result != KTX_SUCCESS) goto cleanup; } else if (pHeader->supercompressionGlobalData.byteOffset != 0) { // Non-zero SGD byteOffset with zero byteLength result = KTX_FILE_DATA_ERROR; @@ -973,8 +927,7 @@ ktxTexture2_constructFromStreamAndHeader(ktxTexture2* This, ktxStream* pStream, } // Calculate size of the image data. Level 0 is the last level in the data. - This->dataSize = private->_levelIndex[0].byteOffset - + private->_levelIndex[0].byteLength; + This->dataSize = private->_levelIndex[0].byteOffset + private->_levelIndex[0].byteLength; /* * Load the images, if requested. @@ -982,8 +935,7 @@ ktxTexture2_constructFromStreamAndHeader(ktxTexture2* This, ktxStream* pStream, if (createFlags & KTX_TEXTURE_CREATE_LOAD_IMAGE_DATA_BIT) { result = ktxTexture2_LoadImageData(This, NULL, 0); } - if (result != KTX_SUCCESS) - goto cleanup; + if (result != KTX_SUCCESS) goto cleanup; return result; @@ -1021,22 +973,18 @@ ktxTexture2_constructFromStreamAndHeader(ktxTexture2* This, ktxStream* pStream, * For other exceptions see ktxTexture2_constructFromStreamAndHeader(). */ static KTX_error_code -ktxTexture2_constructFromStream(ktxTexture2* This, ktxStream* pStream, - ktxTextureCreateFlags createFlags) -{ +ktxTexture2_constructFromStream(ktxTexture2* This, ktxStream* pStream, ktxTextureCreateFlags createFlags) { KTX_header2 header; KTX_error_code result; // Read header. result = pStream->read(pStream, &header, KTX2_HEADER_SIZE); - if (result != KTX_SUCCESS) - return result; + if (result != KTX_SUCCESS) return result; #if IS_BIG_ENDIAN - // byte swap the header + // byte swap the header #endif - return ktxTexture2_constructFromStreamAndHeader(This, pStream, - &header, createFlags); + return ktxTexture2_constructFromStreamAndHeader(This, pStream, &header, createFlags); } /** @@ -1061,18 +1009,14 @@ ktxTexture2_constructFromStream(ktxTexture2* This, ktxStream* pStream, * For other exceptions, see ktxTexture_constructFromStream(). */ static KTX_error_code -ktxTexture2_constructFromStdioStream(ktxTexture2* This, FILE* stdioStream, - ktxTextureCreateFlags createFlags) -{ +ktxTexture2_constructFromStdioStream(ktxTexture2* This, FILE* stdioStream, ktxTextureCreateFlags createFlags) { KTX_error_code result; ktxStream stream; - if (stdioStream == NULL || This == NULL) - return KTX_INVALID_VALUE; + if (stdioStream == NULL || This == NULL) return KTX_INVALID_VALUE; result = ktxFileStream_construct(&stream, stdioStream, KTX_FALSE); - if (result == KTX_SUCCESS) - result = ktxTexture2_constructFromStream(This, &stream, createFlags); + if (result == KTX_SUCCESS) result = ktxTexture2_constructFromStream(This, &stream, createFlags); return result; } @@ -1099,24 +1043,18 @@ ktxTexture2_constructFromStdioStream(ktxTexture2* This, FILE* stdioStream, * For other exceptions, see ktxTexture_constructFromStream(). */ static KTX_error_code -ktxTexture2_constructFromNamedFile(ktxTexture2* This, - const char* const filename, - ktxTextureCreateFlags createFlags) -{ +ktxTexture2_constructFromNamedFile(ktxTexture2* This, const char* const filename, ktxTextureCreateFlags createFlags) { KTX_error_code result; ktxStream stream; FILE* file; - if (This == NULL || filename == NULL) - return KTX_INVALID_VALUE; + if (This == NULL || filename == NULL) return KTX_INVALID_VALUE; file = ktxFOpenUTF8(filename, "rb"); - if (!file) - return KTX_FILE_OPEN_FAILED; + if (!file) return KTX_FILE_OPEN_FAILED; result = ktxFileStream_construct(&stream, file, KTX_TRUE); - if (result == KTX_SUCCESS) - result = ktxTexture2_constructFromStream(This, &stream, createFlags); + if (result == KTX_SUCCESS) result = ktxTexture2_constructFromStream(This, &stream, createFlags); return result; } @@ -1141,19 +1079,14 @@ ktxTexture2_constructFromNamedFile(ktxTexture2* This, * For other exceptions, see ktxTexture_constructFromStream(). */ static KTX_error_code -ktxTexture2_constructFromMemory(ktxTexture2* This, - const ktx_uint8_t* bytes, ktx_size_t size, - ktxTextureCreateFlags createFlags) -{ +ktxTexture2_constructFromMemory(ktxTexture2* This, const ktx_uint8_t* bytes, ktx_size_t size, ktxTextureCreateFlags createFlags) { KTX_error_code result; ktxStream stream; - if (bytes == NULL || size == 0) - return KTX_INVALID_VALUE; + if (bytes == NULL || size == 0) return KTX_INVALID_VALUE; result = ktxMemStream_construct_ro(&stream, bytes, size); - if (result == KTX_SUCCESS) - result = ktxTexture2_constructFromStream(This, &stream, createFlags); + if (result == KTX_SUCCESS) result = ktxTexture2_constructFromStream(This, &stream, createFlags); return result; } @@ -1167,13 +1100,12 @@ ktxTexture2_constructFromMemory(ktxTexture2* This, * initialize. */ void -ktxTexture2_destruct(ktxTexture2* This) -{ +ktxTexture2_destruct(ktxTexture2* This) { if (This->pDfd) free(This->pDfd); if (This->_private) { - ktx_uint8_t* sgd = This->_private->_supercompressionGlobalData; - if (sgd) free(sgd); - free(This->_private); + ktx_uint8_t* sgd = This->_private->_supercompressionGlobalData; + if (sgd) free(sgd); + free(This->_private); } ktxTexture_destruct(ktxTexture(This)); } @@ -1222,18 +1154,13 @@ ktxTexture2_destruct(ktxTexture2* This) * @exception KTX_OUT_OF_MEMORY Not enough memory for the texture's images. */ KTX_error_code -ktxTexture2_Create(ktxTextureCreateInfo* createInfo, - ktxTextureCreateStorageEnum storageAllocation, - ktxTexture2** newTex) -{ +ktxTexture2_Create(ktxTextureCreateInfo* createInfo, ktxTextureCreateStorageEnum storageAllocation, ktxTexture2** newTex) { KTX_error_code result; - if (newTex == NULL) - return KTX_INVALID_VALUE; + if (newTex == NULL) return KTX_INVALID_VALUE; ktxTexture2* tex = (ktxTexture2*)malloc(sizeof(ktxTexture2)); - if (tex == NULL) - return KTX_OUT_OF_MEMORY; + if (tex == NULL) return KTX_OUT_OF_MEMORY; result = ktxTexture2_construct(tex, createInfo, storageAllocation); if (result != KTX_SUCCESS) { @@ -1261,17 +1188,14 @@ ktxTexture2_Create(ktxTextureCreateInfo* createInfo, * * @exception KTX_OUT_OF_MEMORY Not enough memory for the texture data. */ - KTX_error_code - ktxTexture2_CreateCopy(ktxTexture2* orig, ktxTexture2** newTex) - { +KTX_error_code +ktxTexture2_CreateCopy(ktxTexture2* orig, ktxTexture2** newTex) { KTX_error_code result; - if (newTex == NULL) - return KTX_INVALID_VALUE; + if (newTex == NULL) return KTX_INVALID_VALUE; ktxTexture2* tex = (ktxTexture2*)malloc(sizeof(ktxTexture2)); - if (tex == NULL) - return KTX_OUT_OF_MEMORY; + if (tex == NULL) return KTX_OUT_OF_MEMORY; result = ktxTexture2_constructCopy(tex, orig); if (result != KTX_SUCCESS) { @@ -1280,8 +1204,7 @@ ktxTexture2_Create(ktxTextureCreateInfo* createInfo, *newTex = tex; } return result; - - } +} /** * @defgroup reader Reader @@ -1330,20 +1253,14 @@ ktxTexture2_Create(ktxTextureCreateInfo* createInfo, * supported by OpenGL or Vulkan, e.g, a 3D array. */ KTX_error_code -ktxTexture2_CreateFromStdioStream(FILE* stdioStream, - ktxTextureCreateFlags createFlags, - ktxTexture2** newTex) -{ +ktxTexture2_CreateFromStdioStream(FILE* stdioStream, ktxTextureCreateFlags createFlags, ktxTexture2** newTex) { KTX_error_code result; - if (newTex == NULL) - return KTX_INVALID_VALUE; + if (newTex == NULL) return KTX_INVALID_VALUE; ktxTexture2* tex = (ktxTexture2*)malloc(sizeof(ktxTexture2)); - if (tex == NULL) - return KTX_OUT_OF_MEMORY; + if (tex == NULL) return KTX_OUT_OF_MEMORY; - result = ktxTexture2_constructFromStdioStream(tex, stdioStream, - createFlags); + result = ktxTexture2_constructFromStdioStream(tex, stdioStream, createFlags); if (result == KTX_SUCCESS) *newTex = (ktxTexture2*)tex; else { @@ -1386,18 +1303,13 @@ ktxTexture2_CreateFromStdioStream(FILE* stdioStream, * For other exceptions, see ktxTexture_CreateFromStdioStream(). */ KTX_error_code -ktxTexture2_CreateFromNamedFile(const char* const filename, - ktxTextureCreateFlags createFlags, - ktxTexture2** newTex) -{ +ktxTexture2_CreateFromNamedFile(const char* const filename, ktxTextureCreateFlags createFlags, ktxTexture2** newTex) { KTX_error_code result; - if (newTex == NULL) - return KTX_INVALID_VALUE; + if (newTex == NULL) return KTX_INVALID_VALUE; ktxTexture2* tex = (ktxTexture2*)malloc(sizeof(ktxTexture2)); - if (tex == NULL) - return KTX_OUT_OF_MEMORY; + if (tex == NULL) return KTX_OUT_OF_MEMORY; result = ktxTexture2_constructFromNamedFile(tex, filename, createFlags); if (result == KTX_SUCCESS) @@ -1439,20 +1351,14 @@ ktxTexture2_CreateFromNamedFile(const char* const filename, * For other exceptions, see ktxTexture_CreateFromStdioStream(). */ KTX_error_code -ktxTexture2_CreateFromMemory(const ktx_uint8_t* bytes, ktx_size_t size, - ktxTextureCreateFlags createFlags, - ktxTexture2** newTex) -{ +ktxTexture2_CreateFromMemory(const ktx_uint8_t* bytes, ktx_size_t size, ktxTextureCreateFlags createFlags, ktxTexture2** newTex) { KTX_error_code result; - if (newTex == NULL) - return KTX_INVALID_VALUE; + if (newTex == NULL) return KTX_INVALID_VALUE; ktxTexture2* tex = (ktxTexture2*)malloc(sizeof(ktxTexture2)); - if (tex == NULL) - return KTX_OUT_OF_MEMORY; + if (tex == NULL) return KTX_OUT_OF_MEMORY; - result = ktxTexture2_constructFromMemory(tex, bytes, size, - createFlags); + result = ktxTexture2_constructFromMemory(tex, bytes, size, createFlags); if (result == KTX_SUCCESS) *newTex = (ktxTexture2*)tex; else { @@ -1491,17 +1397,12 @@ ktxTexture2_CreateFromMemory(const ktx_uint8_t* bytes, ktx_size_t size, * For other exceptions, see ktxTexture_CreateFromStdioStream(). */ KTX_error_code -ktxTexture2_CreateFromStream(ktxStream* stream, - ktxTextureCreateFlags createFlags, - ktxTexture2** newTex) -{ +ktxTexture2_CreateFromStream(ktxStream* stream, ktxTextureCreateFlags createFlags, ktxTexture2** newTex) { KTX_error_code result; - if (newTex == NULL) - return KTX_INVALID_VALUE; + if (newTex == NULL) return KTX_INVALID_VALUE; ktxTexture2* tex = (ktxTexture2*)malloc(sizeof(ktxTexture2)); - if (tex == NULL) - return KTX_OUT_OF_MEMORY; + if (tex == NULL) return KTX_OUT_OF_MEMORY; result = ktxTexture2_constructFromStream(tex, stream, createFlags); if (result == KTX_SUCCESS) @@ -1525,8 +1426,7 @@ ktxTexture2_CreateFromStream(ktxStream* stream, * @param[in] This pointer to the ktxTexture2 object to destroy */ void -ktxTexture2_Destroy(ktxTexture2* This) -{ +ktxTexture2_Destroy(ktxTexture2* This) { ktxTexture2_destruct(This); free(This); } @@ -1547,21 +1447,17 @@ ktxTexture2_Destroy(ktxTexture2* This) * @return the data size in bytes. */ ktx_size_t -ktxTexture2_calcDataSizeLevels(ktxTexture2* This, ktx_uint32_t levels) -{ +ktxTexture2_calcDataSizeLevels(ktxTexture2* This, ktx_uint32_t levels) { ktx_size_t dataSize = 0; assert(This != NULL); assert(This->supercompressionScheme == KTX_SS_NONE); assert(levels <= This->numLevels); for (ktx_uint32_t i = levels - 1; i > 0; i--) { - ktx_size_t levelSize = ktxTexture_calcLevelSize(ktxTexture(This), i, - KTX_FORMAT_VERSION_TWO); - dataSize += _KTX_PADN(This->_private->_requiredLevelAlignment, - levelSize); + ktx_size_t levelSize = ktxTexture_calcLevelSize(ktxTexture(This), i, KTX_FORMAT_VERSION_TWO); + dataSize += _KTX_PADN(This->_private->_requiredLevelAlignment, levelSize); } - dataSize += ktxTexture_calcLevelSize(ktxTexture(This), 0, - KTX_FORMAT_VERSION_TWO); + dataSize += ktxTexture_calcLevelSize(ktxTexture(This), 0, KTX_FORMAT_VERSION_TWO); return dataSize; } @@ -1572,8 +1468,7 @@ ktxTexture2_calcDataSizeLevels(ktxTexture2* This, ktx_uint32_t levels) * @copydoc ktxTexture::ktxTexture_doCalcFaceLodSize */ ktx_size_t -ktxTexture2_calcFaceLodSize(ktxTexture2* This, ktx_uint32_t level) -{ +ktxTexture2_calcFaceLodSize(ktxTexture2* This, ktx_uint32_t level) { assert(This != NULL); assert(This->supercompressionScheme == KTX_SS_NONE); /* @@ -1581,8 +1476,7 @@ ktxTexture2_calcFaceLodSize(ktxTexture2* This, ktx_uint32_t level) * else it is the size of the level. */ if (This->isCubemap && !This->isArray) - return ktxTexture_calcImageSize(ktxTexture(This), level, - KTX_FORMAT_VERSION_TWO); + return ktxTexture_calcImageSize(ktxTexture(This), level, KTX_FORMAT_VERSION_TWO); else return This->_private->_levelIndex[level].uncompressedByteLength; } @@ -1602,23 +1496,19 @@ ktxTexture2_calcFaceLodSize(ktxTexture2* This, ktx_uint32_t level) * @return the data size in bytes. */ ktx_size_t -ktxTexture2_calcLevelOffset(ktxTexture2* This, ktx_uint32_t level) -{ - assert (This != NULL); - assert(This->supercompressionScheme == KTX_SS_NONE); - assert (level < This->numLevels); - ktx_size_t levelOffset = 0; - for (ktx_uint32_t i = This->numLevels - 1; i > level; i--) { - ktx_size_t levelSize; - levelSize = ktxTexture_calcLevelSize(ktxTexture(This), i, - KTX_FORMAT_VERSION_TWO); - levelOffset += _KTX_PADN(This->_private->_requiredLevelAlignment, - levelSize); - } - return levelOffset; +ktxTexture2_calcLevelOffset(ktxTexture2* This, ktx_uint32_t level) { + assert(This != NULL); + assert(This->supercompressionScheme == KTX_SS_NONE); + assert(level < This->numLevels); + ktx_size_t levelOffset = 0; + for (ktx_uint32_t i = This->numLevels - 1; i > level; i--) { + ktx_size_t levelSize; + levelSize = ktxTexture_calcLevelSize(ktxTexture(This), i, KTX_FORMAT_VERSION_TWO); + levelOffset += _KTX_PADN(This->_private->_requiredLevelAlignment, levelSize); + } + return levelOffset; } - /** * @memberof ktxTexture2 @private * @~English @@ -1626,28 +1516,24 @@ ktxTexture2_calcLevelOffset(ktxTexture2* This, ktx_uint32_t level) * * @param[in] This pointer to the ktxTexture object of interest. */ -ktx_uint64_t ktxTexture2_levelFileOffset(ktxTexture2* This, ktx_uint32_t level) -{ +ktx_uint64_t +ktxTexture2_levelFileOffset(ktxTexture2* This, ktx_uint32_t level) { assert(This->_private->_firstLevelFileOffset != 0); - return This->_private->_levelIndex[level].byteOffset - + This->_private->_firstLevelFileOffset; + return This->_private->_levelIndex[level].byteOffset + This->_private->_firstLevelFileOffset; } // Recursive function to return the greatest common divisor of a and b. static uint32_t gcd(uint32_t a, uint32_t b) { - if (a == 0) - return b; + if (a == 0) return b; return gcd(b % a, a); } // Function to return the least common multiple of a & 4. uint32_t -lcm4(uint32_t a) -{ - if (!(a & 0x03)) - return a; // a is a multiple of 4. - return (a*4) / gcd(a, 4); +lcm4(uint32_t a) { + if (!(a & 0x03)) return a; // a is a multiple of 4. + return (a * 4) / gcd(a, 4); } /** @@ -1659,16 +1545,15 @@ lcm4(uint32_t a) * * @return The required alignment for levels. */ - ktx_uint32_t - ktxTexture2_calcRequiredLevelAlignment(ktxTexture2* This) - { +ktx_uint32_t +ktxTexture2_calcRequiredLevelAlignment(ktxTexture2* This) { ktx_uint32_t alignment; if (This->supercompressionScheme != KTX_SS_NONE) alignment = 1; else alignment = lcm4(This->_protected->_formatSize.blockSizeInBits / 8); return alignment; - } +} /** * @memberof ktxTexture2 @private @@ -1680,8 +1565,7 @@ lcm4(uint32_t a) * @return The required alignment for levels. */ ktx_uint32_t -ktxTexture2_calcPostInflationLevelAlignment(ktxTexture2* This) -{ +ktxTexture2_calcPostInflationLevelAlignment(ktxTexture2* This) { ktx_uint32_t alignment; // Should actually work for none supercompressed but don't want to @@ -1696,7 +1580,6 @@ ktxTexture2_calcPostInflationLevelAlignment(ktxTexture2* This) return alignment; } - /** * @memberof ktxTexture2 * @~English @@ -1710,12 +1593,9 @@ ktxTexture2_calcPostInflationLevelAlignment(ktxTexture2* This) * byte length of a component. */ void -ktxTexture2_GetComponentInfo(ktxTexture2* This, uint32_t* pNumComponents, - uint32_t* pComponentByteLength) -{ +ktxTexture2_GetComponentInfo(ktxTexture2* This, uint32_t* pNumComponents, uint32_t* pComponentByteLength) { // FIXME Need to handle packed case. - getDFDComponentInfoUnpacked(This->pDfd, pNumComponents, - pComponentByteLength); + getDFDComponentInfoUnpacked(This->pDfd, pNumComponents, pComponentByteLength); } /** @@ -1737,8 +1617,7 @@ ktxTexture2_GetComponentInfo(ktxTexture2* This, uint32_t* pNumComponents, * @return the number of components. */ ktx_uint32_t -ktxTexture2_GetNumComponents(ktxTexture2* This) -{ +ktxTexture2_GetNumComponents(ktxTexture2* This) { uint32_t* pBdb = This->pDfd + 1; uint32_t dfdNumComponents = getDFDNumComponents(This->pDfd); uint32_t colorModel = KHR_DFDVAL(pBdb, MODEL); @@ -1746,8 +1625,7 @@ ktxTexture2_GetNumComponents(ktxTexture2* This) return dfdNumComponents; } else { switch (colorModel) { - case KHR_DF_MODEL_ETC1S: - { + case KHR_DF_MODEL_ETC1S: { uint32_t channel0Id = KHR_DFDSVAL(pBdb, 0, CHANNELID); if (dfdNumComponents == 1) { if (channel0Id == KHR_DF_CHANNEL_ETC1S_RGB) @@ -1756,37 +1634,35 @@ ktxTexture2_GetNumComponents(ktxTexture2* This) return 1; } else { uint32_t channel1Id = KHR_DFDSVAL(pBdb, 1, CHANNELID); - if (channel0Id == KHR_DF_CHANNEL_ETC1S_RGB - && channel1Id == KHR_DF_CHANNEL_ETC1S_AAA) + if (channel0Id == KHR_DF_CHANNEL_ETC1S_RGB && channel1Id == KHR_DF_CHANNEL_ETC1S_AAA) return 4; else { // An invalid combination of channel Ids should never // have been set during creation or should have been // caught when the file was loaded. - assert(channel0Id == KHR_DF_CHANNEL_ETC1S_RRR - && channel1Id == KHR_DF_CHANNEL_ETC1S_GGG); + assert(channel0Id == KHR_DF_CHANNEL_ETC1S_RRR && channel1Id == KHR_DF_CHANNEL_ETC1S_GGG); return 2; } } break; - } - case KHR_DF_MODEL_UASTC: + } + case KHR_DF_MODEL_UASTC: switch (KHR_DFDSVAL(pBdb, 0, CHANNELID)) { - case KHR_DF_CHANNEL_UASTC_RRR: + case KHR_DF_CHANNEL_UASTC_RRR: return 1; - case KHR_DF_CHANNEL_UASTC_RRRG: + case KHR_DF_CHANNEL_UASTC_RRRG: return 2; - case KHR_DF_CHANNEL_UASTC_RGB: + case KHR_DF_CHANNEL_UASTC_RGB: return 3; - case KHR_DF_CHANNEL_UASTC_RGBA: + case KHR_DF_CHANNEL_UASTC_RGBA: return 4; - default: + default: // Same comment as for the assert in the ETC1 case. assert(false); return 1; } break; - default: + default: return dfdNumComponents; } } @@ -1816,26 +1692,18 @@ ktxTexture2_GetNumComponents(ktxTexture2* This) * @exception KTX_INVALID_VALID @p This is NULL. */ KTX_error_code -ktxTexture2_GetImageOffset(ktxTexture2* This, ktx_uint32_t level, - ktx_uint32_t layer, ktx_uint32_t faceSlice, - ktx_size_t* pOffset) -{ - if (This == NULL) - return KTX_INVALID_VALUE; +ktxTexture2_GetImageOffset(ktxTexture2* This, ktx_uint32_t level, ktx_uint32_t layer, ktx_uint32_t faceSlice, ktx_size_t* pOffset) { + if (This == NULL) return KTX_INVALID_VALUE; - if (level >= This->numLevels || layer >= This->numLayers) - return KTX_INVALID_OPERATION; + if (level >= This->numLevels || layer >= This->numLayers) return KTX_INVALID_OPERATION; - if (This->supercompressionScheme != KTX_SS_NONE) - return KTX_INVALID_OPERATION; + if (This->supercompressionScheme != KTX_SS_NONE) return KTX_INVALID_OPERATION; if (This->isCubemap) { - if (faceSlice >= This->numFaces) - return KTX_INVALID_OPERATION; + if (faceSlice >= This->numFaces) return KTX_INVALID_OPERATION; } else { ktx_uint32_t maxSlice = MAX(1, This->baseDepth >> level); - if (faceSlice >= maxSlice) - return KTX_INVALID_OPERATION; + if (faceSlice >= maxSlice) return KTX_INVALID_OPERATION; } // Get the offset of the start of the level. @@ -1844,8 +1712,7 @@ ktxTexture2_GetImageOffset(ktxTexture2* This, ktx_uint32_t level, // All layers, faces & slices within a level are the same size. if (layer != 0) { ktx_size_t layerSize; - layerSize = ktxTexture_layerSize(ktxTexture(This), level, - KTX_FORMAT_VERSION_TWO); + layerSize = ktxTexture_layerSize(ktxTexture(This), level, KTX_FORMAT_VERSION_TWO); *pOffset += layer * layerSize; } if (faceSlice != 0) { @@ -1866,9 +1733,8 @@ ktxTexture2_GetImageOffset(ktxTexture2* This, ktx_uint32_t level, * @return A @c khr_df_transfer enum value specifying the OETF. */ khr_df_transfer_e -ktxTexture2_GetOETF_e(ktxTexture2* This) -{ - return KHR_DFDVAL(This->pDfd+1, TRANSFER); +ktxTexture2_GetOETF_e(ktxTexture2* This) { + return KHR_DFDVAL(This->pDfd + 1, TRANSFER); } /** @@ -1883,9 +1749,8 @@ ktxTexture2_GetOETF_e(ktxTexture2* This) * @c ktx_uint32_t. */ ktx_uint32_t -ktxTexture2_GetOETF(ktxTexture2* This) -{ - return KHR_DFDVAL(This->pDfd+1, TRANSFER); +ktxTexture2_GetOETF(ktxTexture2* This) { + return KHR_DFDVAL(This->pDfd + 1, TRANSFER); } /** @@ -1898,9 +1763,8 @@ ktxTexture2_GetOETF(ktxTexture2* This) * @return A @c khr_df_transfer enum value specifying the color model. */ khr_df_model_e -ktxTexture2_GetColorModel_e(ktxTexture2* This) -{ - return KHR_DFDVAL(This->pDfd+1, MODEL); +ktxTexture2_GetColorModel_e(ktxTexture2* This) { + return KHR_DFDVAL(This->pDfd + 1, MODEL); } /** @@ -1913,9 +1777,8 @@ ktxTexture2_GetColorModel_e(ktxTexture2* This) * @return KTX\_TRUE if the components are premultiplied, KTX_FALSE otherwise. */ ktx_bool_t -ktxTexture2_GetPremultipliedAlpha(ktxTexture2* This) -{ - return KHR_DFDVAL(This->pDfd+1, FLAGS) & KHR_DF_FLAG_ALPHA_PREMULTIPLIED; +ktxTexture2_GetPremultipliedAlpha(ktxTexture2* This) { + return KHR_DFDVAL(This->pDfd + 1, FLAGS) & KHR_DF_FLAG_ALPHA_PREMULTIPLIED; } /** @@ -1926,8 +1789,7 @@ ktxTexture2_GetPremultipliedAlpha(ktxTexture2* This) * @param[in] This pointer to the ktxTexture2 object of interest. */ ktx_bool_t -ktxTexture2_NeedsTranscoding(ktxTexture2* This) -{ +ktxTexture2_NeedsTranscoding(ktxTexture2* This) { if (KHR_DFDVAL(This->pDfd + 1, MODEL) == KHR_DF_MODEL_ETC1S) return true; else if (KHR_DFDVAL(This->pDfd + 1, MODEL) == KHR_DF_MODEL_UASTC) @@ -1954,36 +1816,32 @@ ktxTexture2_NeedsTranscoding(ktxTexture2* This) * @param[in] This pointer to the ktxTexture1 object of interest. */ ktx_size_t -ktxTexture2_GetDataSizeUncompressed(ktxTexture2* This) -{ +ktxTexture2_GetDataSizeUncompressed(ktxTexture2* This) { switch (This->supercompressionScheme) { - case KTX_SS_BASIS_LZ: - case KTX_SS_NONE: + case KTX_SS_BASIS_LZ: + case KTX_SS_NONE: return This->dataSize; - case KTX_SS_ZSTD: - case KTX_SS_ZLIB: - { - ktx_size_t uncompressedSize = 0; - ktx_uint32_t uncompressedLevelAlignment; - ktxLevelIndexEntry* levelIndex = This->_private->_levelIndex; - - uncompressedLevelAlignment = - ktxTexture2_calcPostInflationLevelAlignment(This); - - for (ktx_int32_t level = This->numLevels - 1; level >= 1; level--) { - ktx_size_t uncompressedLevelSize; - uncompressedLevelSize = levelIndex[level].uncompressedByteLength; - uncompressedLevelSize = _KTX_PADN(uncompressedLevelAlignment, - uncompressedLevelSize); - uncompressedSize += uncompressedLevelSize; - } - uncompressedSize += levelIndex[0].uncompressedByteLength; - return uncompressedSize; - } - case KTX_SS_BEGIN_VENDOR_RANGE: - case KTX_SS_END_VENDOR_RANGE: - case KTX_SS_BEGIN_RESERVED: - default: + case KTX_SS_ZSTD: + case KTX_SS_ZLIB: { + ktx_size_t uncompressedSize = 0; + ktx_uint32_t uncompressedLevelAlignment; + ktxLevelIndexEntry* levelIndex = This->_private->_levelIndex; + + uncompressedLevelAlignment = ktxTexture2_calcPostInflationLevelAlignment(This); + + for (ktx_int32_t level = This->numLevels - 1; level >= 1; level--) { + ktx_size_t uncompressedLevelSize; + uncompressedLevelSize = levelIndex[level].uncompressedByteLength; + uncompressedLevelSize = _KTX_PADN(uncompressedLevelAlignment, uncompressedLevelSize); + uncompressedSize += uncompressedLevelSize; + } + uncompressedSize += levelIndex[0].uncompressedByteLength; + return uncompressedSize; + } + case KTX_SS_BEGIN_VENDOR_RANGE: + case KTX_SS_END_VENDOR_RANGE: + case KTX_SS_BEGIN_RESERVED: + default: return 0; } } @@ -2003,10 +1861,8 @@ ktxTexture2_GetDataSizeUncompressed(ktxTexture2* This) * @param[in] level level of interest. * */ ktx_size_t -ktxTexture2_GetImageSize(ktxTexture2* This, ktx_uint32_t level) -{ - return ktxTexture_calcImageSize(ktxTexture(This), level, - KTX_FORMAT_VERSION_TWO); +ktxTexture2_GetImageSize(ktxTexture2* This, ktx_uint32_t level) { + return ktxTexture_calcImageSize(ktxTexture(This), level, KTX_FORMAT_VERSION_TWO); } /** @@ -2041,32 +1897,27 @@ ktxTexture2_GetImageSize(ktxTexture2* This, ktx_uint32_t level) * */ KTX_error_code -ktxTexture2_IterateLevels(ktxTexture2* This, PFNKTXITERCB iterCb, void* userdata) -{ - KTX_error_code result = KTX_SUCCESS; - //ZSTD_DCtx* dctx; - //ktx_uint8_t* decompBuf; +ktxTexture2_IterateLevels(ktxTexture2* This, PFNKTXITERCB iterCb, void* userdata) { + KTX_error_code result = KTX_SUCCESS; + // ZSTD_DCtx* dctx; + // ktx_uint8_t* decompBuf; ktxLevelIndexEntry* levelIndex = This->_private->_levelIndex; - if (This == NULL) - return KTX_INVALID_VALUE; + if (This == NULL) return KTX_INVALID_VALUE; - if (iterCb == NULL) - return KTX_INVALID_VALUE; + if (iterCb == NULL) return KTX_INVALID_VALUE; - if (This->supercompressionScheme != KTX_SS_NONE) - return KTX_INVALID_OPERATION; + if (This->supercompressionScheme != KTX_SS_NONE) return KTX_INVALID_OPERATION; - for (ktx_int32_t level = This->numLevels - 1; level >= 0; level--) - { + for (ktx_int32_t level = This->numLevels - 1; level >= 0; level--) { ktx_uint32_t width, height, depth; ktx_uint64_t levelSize; ktx_uint64_t offset; /* Array textures have the same number of layers at each mip level. */ - width = MAX(1, This->baseWidth >> level); + width = MAX(1, This->baseWidth >> level); height = MAX(1, This->baseHeight >> level); - depth = MAX(1, This->baseDepth >> level); + depth = MAX(1, This->baseDepth >> level); levelSize = levelIndex[level].uncompressedByteLength; offset = ktxTexture2_levelDataOffset(This, level); @@ -2075,10 +1926,8 @@ ktxTexture2_IterateLevels(ktxTexture2* This, PFNKTXITERCB iterCb, void* userdata * GL & Vulkan need them. Hence no * for (layer = 0; layer < This->numLayers) */ - result = iterCb(level, 0, width, height, depth, - levelSize, This->pData + offset, userdata); - if (result != KTX_SUCCESS) - break; + result = iterCb(level, 0, width, height, depth, levelSize, This->pData + offset, userdata); + if (result != KTX_SUCCESS) break; } return result; @@ -2129,32 +1978,26 @@ ktxTexture2_IterateLevels(ktxTexture2* This, PFNKTXITERCB iterCb, void* userdata * hold the base level image. */ KTX_error_code -ktxTexture2_IterateLoadLevelFaces(ktxTexture2* This, PFNKTXITERCB iterCb, - void* userdata) -{ +ktxTexture2_IterateLoadLevelFaces(ktxTexture2* This, PFNKTXITERCB iterCb, void* userdata) { DECLARE_PROTECTED(ktxTexture); - ktxStream* stream = (ktxStream *)&prtctd->_stream; + ktxStream* stream = (ktxStream*)&prtctd->_stream; ktxLevelIndexEntry* levelIndex; - ktx_size_t dataSize = 0, uncompressedDataSize = 0; - KTX_error_code result = KTX_SUCCESS; - ktx_uint8_t* dataBuf = NULL; - ktx_uint8_t* uncompressedDataBuf = NULL; - ktx_uint8_t* pData; - ZSTD_DCtx* dctx = NULL; - - if (This == NULL) - return KTX_INVALID_VALUE; + ktx_size_t dataSize = 0, uncompressedDataSize = 0; + KTX_error_code result = KTX_SUCCESS; + ktx_uint8_t* dataBuf = NULL; + ktx_uint8_t* uncompressedDataBuf = NULL; + ktx_uint8_t* pData; + ZSTD_DCtx* dctx = NULL; - if (This->classId != ktxTexture2_c) - return KTX_INVALID_OPERATION; + if (This == NULL) return KTX_INVALID_VALUE; - if (This->supercompressionScheme != KTX_SS_NONE && - This->supercompressionScheme != KTX_SS_ZSTD && + if (This->classId != ktxTexture2_c) return KTX_INVALID_OPERATION; + + if (This->supercompressionScheme != KTX_SS_NONE && This->supercompressionScheme != KTX_SS_ZSTD && This->supercompressionScheme != KTX_SS_ZLIB) return KTX_INVALID_OPERATION; - if (iterCb == NULL) - return KTX_INVALID_VALUE; + if (iterCb == NULL) return KTX_INVALID_VALUE; if (prtctd->_stream.data.file == NULL) // This Texture not created from a stream or images are already loaded. @@ -2165,8 +2008,7 @@ ktxTexture2_IterateLoadLevelFaces(ktxTexture2* This, PFNKTXITERCB iterCb, // Allocate memory sufficient for the base level dataSize = levelIndex[0].byteLength; dataBuf = malloc(dataSize); - if (!dataBuf) - return KTX_OUT_OF_MEMORY; + if (!dataBuf) return KTX_OUT_OF_MEMORY; if (This->supercompressionScheme == KTX_SS_ZSTD || This->supercompressionScheme == KTX_SS_ZLIB) { uncompressedDataSize = levelIndex[0].uncompressedByteLength; uncompressedDataBuf = malloc(uncompressedDataSize); @@ -2182,15 +2024,14 @@ ktxTexture2_IterateLoadLevelFaces(ktxTexture2* This, PFNKTXITERCB iterCb, pData = dataBuf; } - for (ktx_int32_t level = This->numLevels - 1; level >= 0; --level) - { - ktx_size_t levelSize; - GLsizei width, height, depth; + for (ktx_int32_t level = This->numLevels - 1; level >= 0; --level) { + ktx_size_t levelSize; + GLsizei width, height, depth; // Array textures have the same number of layers at each mip level. - width = MAX(1, This->baseWidth >> level); + width = MAX(1, This->baseWidth >> level); height = MAX(1, This->baseHeight >> level); - depth = MAX(1, This->baseDepth >> level); + depth = MAX(1, This->baseDepth >> level); levelSize = levelIndex[level].byteLength; if (dataSize < levelSize) { @@ -2200,31 +2041,24 @@ ktxTexture2_IterateLoadLevelFaces(ktxTexture2* This, PFNKTXITERCB iterCb, } // Use setpos so we skip any padding. - result = stream->setpos(stream, - ktxTexture2_levelFileOffset(This, level)); - if (result != KTX_SUCCESS) - goto cleanup; + result = stream->setpos(stream, ktxTexture2_levelFileOffset(This, level)); + if (result != KTX_SUCCESS) goto cleanup; result = stream->read(stream, dataBuf, levelSize); - if (result != KTX_SUCCESS) - goto cleanup; + if (result != KTX_SUCCESS) goto cleanup; if (This->supercompressionScheme == KTX_SS_ZSTD) { - levelSize = - ZSTD_decompressDCtx(dctx, uncompressedDataBuf, - uncompressedDataSize, - dataBuf, - levelSize); + levelSize = ZSTD_decompressDCtx(dctx, uncompressedDataBuf, uncompressedDataSize, dataBuf, levelSize); if (ZSTD_isError(levelSize)) { ZSTD_ErrorCode error = ZSTD_getErrorCode(levelSize); - switch(error) { - case ZSTD_error_dstSize_tooSmall: - return KTX_DECOMPRESS_LENGTH_ERROR; // inflatedDataCapacity too small. - case ZSTD_error_checksum_wrong: + switch (error) { + case ZSTD_error_dstSize_tooSmall: + return KTX_DECOMPRESS_LENGTH_ERROR; // inflatedDataCapacity too small. + case ZSTD_error_checksum_wrong: return KTX_DECOMPRESS_CHECKSUM_ERROR; - case ZSTD_error_memory_allocation: + case ZSTD_error_memory_allocation: return KTX_OUT_OF_MEMORY; - default: + default: return KTX_FILE_DATA_ERROR; } } @@ -2232,30 +2066,25 @@ ktxTexture2_IterateLoadLevelFaces(ktxTexture2* This, PFNKTXITERCB iterCb, // We don't fix up the texture's dataSize, levelIndex or // _requiredAlignment because after this function completes there // is no way to get at the texture's data. - //nindex[level].byteOffset = levelOffset; - //nindex[level].uncompressedByteLength = nindex[level].byteLength = - //levelByteLength; + // nindex[level].byteOffset = levelOffset; + // nindex[level].uncompressedByteLength = nindex[level].byteLength = + // levelByteLength; } else if (This->supercompressionScheme == KTX_SS_ZLIB) { - result = ktxUncompressZLIBInt(uncompressedDataBuf, - &uncompressedDataSize, - dataBuf, - levelSize); - if (result != KTX_SUCCESS) - return result; + result = ktxUncompressZLIBInt(uncompressedDataBuf, &uncompressedDataSize, dataBuf, levelSize); + if (result != KTX_SUCCESS) return result; } - if (levelIndex[level].uncompressedByteLength != levelSize) - return KTX_DECOMPRESS_LENGTH_ERROR; + if (levelIndex[level].uncompressedByteLength != levelSize) return KTX_DECOMPRESS_LENGTH_ERROR; #if IS_BIG_ENDIAN switch (prtctd->_typeSize) { - case 2: + case 2: _ktxSwapEndian16((ktx_uint16_t*)pData, levelSize / 2); break; - case 4: + case 4: _ktxSwapEndian32((ktx_uint32_t*)pDest, levelSize / 4); break; - case 8: + case 8: _ktxSwapEndian64((ktx_uint64_t*)pDest, levelSize / 8); break; } @@ -2272,30 +2101,21 @@ ktxTexture2_IterateLoadLevelFaces(ktxTexture2* This, PFNKTXITERCB iterCb, } blockCount; ktx_size_t faceSize; - blockCount.x - = (uint32_t)ceilf((float)width / prtctd->_formatSize.blockWidth); - blockCount.y - = (uint32_t)ceilf((float)height / prtctd->_formatSize.blockHeight); + blockCount.x = (uint32_t)ceilf((float)width / prtctd->_formatSize.blockWidth); + blockCount.y = (uint32_t)ceilf((float)height / prtctd->_formatSize.blockHeight); blockCount.x = MAX(prtctd->_formatSize.minBlocksX, blockCount.x); blockCount.y = MAX(prtctd->_formatSize.minBlocksX, blockCount.y); - faceSize = blockCount.x * blockCount.y - * prtctd->_formatSize.blockSizeInBits / 8; + faceSize = blockCount.x * blockCount.y * prtctd->_formatSize.blockSizeInBits / 8; for (ktx_uint32_t face = 0; face < This->numFaces; ++face) { - result = iterCb(level, face, - width, height, depth, - (ktx_uint32_t)faceSize, pFace, userdata); + result = iterCb(level, face, width, height, depth, (ktx_uint32_t)faceSize, pFace, userdata); pFace += faceSize; - if (result != KTX_SUCCESS) - goto cleanup; + if (result != KTX_SUCCESS) goto cleanup; } } else { - result = iterCb(level, 0, - width, height, depth, - (ktx_uint32_t)levelSize, pData, userdata); - if (result != KTX_SUCCESS) - goto cleanup; - } + result = iterCb(level, 0, width, height, depth, (ktx_uint32_t)levelSize, pData, userdata); + if (result != KTX_SUCCESS) goto cleanup; + } } // No further need for this. @@ -2309,15 +2129,11 @@ ktxTexture2_IterateLoadLevelFaces(ktxTexture2* This, PFNKTXITERCB iterCb, return result; } -KTX_error_code -ktxTexture2_inflateZstdInt(ktxTexture2* This, ktx_uint8_t* pDeflatedData, - ktx_uint8_t* pInflatedData, - ktx_size_t inflatedDataCapacity); +KTX_error_code ktxTexture2_inflateZstdInt(ktxTexture2* This, ktx_uint8_t* pDeflatedData, ktx_uint8_t* pInflatedData, + ktx_size_t inflatedDataCapacity); -KTX_error_code -ktxTexture2_inflateZLIBInt(ktxTexture2* This, ktx_uint8_t* pDeflatedData, - ktx_uint8_t* pInflatedData, - ktx_size_t inflatedDataCapacity); +KTX_error_code ktxTexture2_inflateZLIBInt(ktxTexture2* This, ktx_uint8_t* pDeflatedData, ktx_uint8_t* pInflatedData, + ktx_size_t inflatedDataCapacity); /** * @memberof ktxTexture2 @@ -2348,22 +2164,18 @@ ktxTexture2_inflateZLIBInt(ktxTexture2* This, ktx_uint8_t* pDeflatedData, * @exception KTX_OUT_OF_MEMORY Insufficient memory for the image data. */ KTX_error_code -ktxTexture2_LoadImageData(ktxTexture2* This, - ktx_uint8_t* pBuffer, ktx_size_t bufSize) -{ +ktxTexture2_LoadImageData(ktxTexture2* This, ktx_uint8_t* pBuffer, ktx_size_t bufSize) { DECLARE_PROTECTED(ktxTexture); DECLARE_PRIVATE(ktxTexture2); - ktx_uint8_t* pDest; - ktx_uint8_t* pDeflatedData = 0; - ktx_uint8_t* pReadBuf; - KTX_error_code result = KTX_SUCCESS; + ktx_uint8_t* pDest; + ktx_uint8_t* pDeflatedData = 0; + ktx_uint8_t* pReadBuf; + KTX_error_code result = KTX_SUCCESS; ktx_size_t inflatedDataCapacity = ktxTexture2_GetDataSizeUncompressed(This); - if (This == NULL) - return KTX_INVALID_VALUE; + if (This == NULL) return KTX_INVALID_VALUE; - if (This->pData != NULL) - return KTX_INVALID_OPERATION; // Data already loaded. + if (This->pData != NULL) return KTX_INVALID_OPERATION; // Data already loaded. if (prtctd->_stream.data.file == NULL) // This Texture not created from a stream or images already loaded; @@ -2371,8 +2183,7 @@ ktxTexture2_LoadImageData(ktxTexture2* This, if (pBuffer == NULL) { This->pData = malloc(inflatedDataCapacity); - if (This->pData == NULL) - return KTX_OUT_OF_MEMORY; + if (This->pData == NULL) return KTX_OUT_OF_MEMORY; pDest = This->pData; } else if (bufSize < inflatedDataCapacity) { return KTX_INVALID_VALUE; @@ -2383,8 +2194,7 @@ ktxTexture2_LoadImageData(ktxTexture2* This, if (This->supercompressionScheme == KTX_SS_ZSTD || This->supercompressionScheme == KTX_SS_ZLIB) { // Create buffer to hold deflated data. pDeflatedData = malloc(This->dataSize); - if (pDeflatedData == NULL) - return KTX_OUT_OF_MEMORY; + if (pDeflatedData == NULL) return KTX_OUT_OF_MEMORY; pReadBuf = pDeflatedData; } else { pReadBuf = pDest; @@ -2393,24 +2203,18 @@ ktxTexture2_LoadImageData(ktxTexture2* This, // Seek to data for first level as there may be padding between the // metadata/sgd and the image data. - result = prtctd->_stream.setpos(&prtctd->_stream, - private->_firstLevelFileOffset); - if (result != KTX_SUCCESS) - return result; + result = prtctd->_stream.setpos(&prtctd->_stream, private->_firstLevelFileOffset); + if (result != KTX_SUCCESS) return result; - result = prtctd->_stream.read(&prtctd->_stream, pReadBuf, - This->dataSize); - if (result != KTX_SUCCESS) - return result; + result = prtctd->_stream.read(&prtctd->_stream, pReadBuf, This->dataSize); + if (result != KTX_SUCCESS) return result; if (This->supercompressionScheme == KTX_SS_ZSTD || This->supercompressionScheme == KTX_SS_ZLIB) { assert(pDeflatedData != NULL); if (This->supercompressionScheme == KTX_SS_ZSTD) { - result = ktxTexture2_inflateZstdInt(This, pDeflatedData, pDest, - inflatedDataCapacity); + result = ktxTexture2_inflateZstdInt(This, pDeflatedData, pDest, inflatedDataCapacity); } else if (This->supercompressionScheme == KTX_SS_ZLIB) { - result = ktxTexture2_inflateZLIBInt(This, pDeflatedData, pDest, - inflatedDataCapacity); + result = ktxTexture2_inflateZLIBInt(This, pDeflatedData, pDest, inflatedDataCapacity); } free(pDeflatedData); if (result != KTX_SUCCESS) { @@ -2425,8 +2229,7 @@ ktxTexture2_LoadImageData(ktxTexture2* This, if (IS_BIG_ENDIAN) { // Perform endianness conversion on texture data. // To avoid mip padding, need to convert each level individually. - for (ktx_uint32_t level = 0; level < This->numLevels; ++level) - { + for (ktx_uint32_t level = 0; level < This->numLevels; ++level) { ktx_size_t levelOffset; ktx_size_t levelByteLength; @@ -2434,13 +2237,13 @@ ktxTexture2_LoadImageData(ktxTexture2* This, levelOffset = ktxTexture2_levelDataOffset(This, level); pDest = This->pData + levelOffset; switch (prtctd->_typeSize) { - case 2: + case 2: _ktxSwapEndian16((ktx_uint16_t*)pDest, levelByteLength / 2); break; - case 4: + case 4: _ktxSwapEndian32((ktx_uint32_t*)pDest, levelByteLength / 4); break; - case 8: + case 8: _ktxSwapEndian64((ktx_uint64_t*)pDest, levelByteLength / 8); break; } @@ -2461,8 +2264,8 @@ ktxTexture2_LoadImageData(ktxTexture2* This, * * @param[in] This pointer to the ktxTexture2 object of interest. */ -ktx_uint64_t ktxTexture2_levelDataOffset(ktxTexture2* This, ktx_uint32_t level) -{ +ktx_uint64_t +ktxTexture2_levelDataOffset(ktxTexture2* This, ktx_uint32_t level) { return This->_private->_levelIndex[level].byteOffset; } @@ -2483,13 +2286,10 @@ ktx_uint64_t ktxTexture2_levelDataOffset(ktxTexture2* This, ktx_uint32_t level) * @p pInflatedData. */ KTX_error_code -ktxTexture2_inflateZstdInt(ktxTexture2* This, ktx_uint8_t* pDeflatedData, - ktx_uint8_t* pInflatedData, - ktx_size_t inflatedDataCapacity) -{ +ktxTexture2_inflateZstdInt(ktxTexture2* This, ktx_uint8_t* pDeflatedData, ktx_uint8_t* pInflatedData, + ktx_size_t inflatedDataCapacity) { DECLARE_PROTECTED(ktxTexture); - ktx_uint32_t levelIndexByteLength = - This->numLevels * sizeof(ktxLevelIndexEntry); + ktx_uint32_t levelIndexByteLength = This->numLevels * sizeof(ktxLevelIndexEntry); uint64_t levelOffset = 0; ktxLevelIndexEntry* cindex = This->_private->_levelIndex; ktxLevelIndexEntry* nindex; @@ -2497,52 +2297,41 @@ ktxTexture2_inflateZstdInt(ktxTexture2* This, ktx_uint8_t* pDeflatedData, ZSTD_DCtx* dctx; - if (pDeflatedData == NULL) - return KTX_INVALID_VALUE; + if (pDeflatedData == NULL) return KTX_INVALID_VALUE; - if (pInflatedData == NULL) - return KTX_INVALID_VALUE; + if (pInflatedData == NULL) return KTX_INVALID_VALUE; - if (This->supercompressionScheme != KTX_SS_ZSTD) - return KTX_INVALID_OPERATION; + if (This->supercompressionScheme != KTX_SS_ZSTD) return KTX_INVALID_OPERATION; nindex = malloc(levelIndexByteLength); - if (nindex == NULL) - return KTX_OUT_OF_MEMORY; + if (nindex == NULL) return KTX_OUT_OF_MEMORY; - uncompressedLevelAlignment = - ktxTexture2_calcPostInflationLevelAlignment(This); + uncompressedLevelAlignment = ktxTexture2_calcPostInflationLevelAlignment(This); ktx_size_t inflatedByteLength = 0; dctx = ZSTD_createDCtx(); for (int32_t level = This->numLevels - 1; level >= 0; level--) { - size_t levelByteLength = - ZSTD_decompressDCtx(dctx, pInflatedData + levelOffset, - inflatedDataCapacity, - &pDeflatedData[cindex[level].byteOffset], - cindex[level].byteLength); + size_t levelByteLength = ZSTD_decompressDCtx(dctx, pInflatedData + levelOffset, inflatedDataCapacity, + &pDeflatedData[cindex[level].byteOffset], cindex[level].byteLength); if (ZSTD_isError(levelByteLength)) { ZSTD_ErrorCode error = ZSTD_getErrorCode(levelByteLength); - switch(error) { - case ZSTD_error_dstSize_tooSmall: - return KTX_DECOMPRESS_LENGTH_ERROR; // inflatedDataCapacity too small. - case ZSTD_error_checksum_wrong: + switch (error) { + case ZSTD_error_dstSize_tooSmall: + return KTX_DECOMPRESS_LENGTH_ERROR; // inflatedDataCapacity too small. + case ZSTD_error_checksum_wrong: return KTX_DECOMPRESS_CHECKSUM_ERROR; - case ZSTD_error_memory_allocation: + case ZSTD_error_memory_allocation: return KTX_OUT_OF_MEMORY; - default: + default: return KTX_FILE_DATA_ERROR; } } - if (This->_private->_levelIndex[level].uncompressedByteLength != levelByteLength) - return KTX_DECOMPRESS_LENGTH_ERROR; + if (This->_private->_levelIndex[level].uncompressedByteLength != levelByteLength) return KTX_DECOMPRESS_LENGTH_ERROR; nindex[level].byteOffset = levelOffset; - nindex[level].uncompressedByteLength = nindex[level].byteLength = - levelByteLength; - ktx_size_t paddedLevelByteLength - = _KTX_PADN(uncompressedLevelAlignment, levelByteLength); + nindex[level].uncompressedByteLength = nindex[level].byteLength = levelByteLength; + ktx_size_t paddedLevelByteLength = _KTX_PADN(uncompressedLevelAlignment, levelByteLength); inflatedByteLength += paddedLevelByteLength; levelOffset += paddedLevelByteLength; inflatedDataCapacity -= paddedLevelByteLength; @@ -2553,7 +2342,7 @@ ktxTexture2_inflateZstdInt(ktxTexture2* This, ktx_uint8_t* pDeflatedData, This->dataSize = inflatedByteLength; This->supercompressionScheme = KTX_SS_NONE; - memcpy(cindex, nindex, levelIndexByteLength); // Update level index + memcpy(cindex, nindex, levelIndexByteLength); // Update level index free(nindex); This->_private->_requiredLevelAlignment = uncompressedLevelAlignment; // Set bytesPlane as we're now sized. @@ -2581,52 +2370,38 @@ ktxTexture2_inflateZstdInt(ktxTexture2* This, ktx_uint8_t* pDeflatedData, * @p pInflatedData. */ KTX_error_code -ktxTexture2_inflateZLIBInt(ktxTexture2* This, ktx_uint8_t* pDeflatedData, - ktx_uint8_t* pInflatedData, - ktx_size_t inflatedDataCapacity) -{ +ktxTexture2_inflateZLIBInt(ktxTexture2* This, ktx_uint8_t* pDeflatedData, ktx_uint8_t* pInflatedData, + ktx_size_t inflatedDataCapacity) { DECLARE_PROTECTED(ktxTexture); - ktx_uint32_t levelIndexByteLength = - This->numLevels * sizeof(ktxLevelIndexEntry); + ktx_uint32_t levelIndexByteLength = This->numLevels * sizeof(ktxLevelIndexEntry); uint64_t levelOffset = 0; ktxLevelIndexEntry* cindex = This->_private->_levelIndex; ktxLevelIndexEntry* nindex; ktx_uint32_t uncompressedLevelAlignment; - if (pDeflatedData == NULL) - return KTX_INVALID_VALUE; + if (pDeflatedData == NULL) return KTX_INVALID_VALUE; - if (pInflatedData == NULL) - return KTX_INVALID_VALUE; + if (pInflatedData == NULL) return KTX_INVALID_VALUE; - if (This->supercompressionScheme != KTX_SS_ZLIB) - return KTX_INVALID_OPERATION; + if (This->supercompressionScheme != KTX_SS_ZLIB) return KTX_INVALID_OPERATION; nindex = malloc(levelIndexByteLength); - if (nindex == NULL) - return KTX_OUT_OF_MEMORY; + if (nindex == NULL) return KTX_OUT_OF_MEMORY; - uncompressedLevelAlignment = - ktxTexture2_calcPostInflationLevelAlignment(This); + uncompressedLevelAlignment = ktxTexture2_calcPostInflationLevelAlignment(This); ktx_size_t inflatedByteLength = 0; for (int32_t level = This->numLevels - 1; level >= 0; level--) { size_t levelByteLength = inflatedDataCapacity; - KTX_error_code result = ktxUncompressZLIBInt(pInflatedData + levelOffset, - &levelByteLength, - &pDeflatedData[cindex[level].byteOffset], - cindex[level].byteLength); - if (result != KTX_SUCCESS) - return result; + KTX_error_code result = ktxUncompressZLIBInt(pInflatedData + levelOffset, &levelByteLength, + &pDeflatedData[cindex[level].byteOffset], cindex[level].byteLength); + if (result != KTX_SUCCESS) return result; - if (This->_private->_levelIndex[level].uncompressedByteLength != levelByteLength) - return KTX_DECOMPRESS_LENGTH_ERROR; + if (This->_private->_levelIndex[level].uncompressedByteLength != levelByteLength) return KTX_DECOMPRESS_LENGTH_ERROR; nindex[level].byteOffset = levelOffset; - nindex[level].uncompressedByteLength = nindex[level].byteLength = - levelByteLength; - ktx_size_t paddedLevelByteLength - = _KTX_PADN(uncompressedLevelAlignment, levelByteLength); + nindex[level].uncompressedByteLength = nindex[level].byteLength = levelByteLength; + ktx_size_t paddedLevelByteLength = _KTX_PADN(uncompressedLevelAlignment, levelByteLength); inflatedByteLength += paddedLevelByteLength; levelOffset += paddedLevelByteLength; inflatedDataCapacity -= paddedLevelByteLength; @@ -2636,7 +2411,7 @@ ktxTexture2_inflateZLIBInt(ktxTexture2* This, ktx_uint8_t* pDeflatedData, This->dataSize = inflatedByteLength; This->supercompressionScheme = KTX_SS_NONE; - memcpy(cindex, nindex, levelIndexByteLength); // Update level index + memcpy(cindex, nindex, levelIndexByteLength); // Update level index free(nindex); This->_private->_requiredLevelAlignment = uncompressedLevelAlignment; // Set bytesPlane as we're now sized. @@ -2654,10 +2429,8 @@ ktxTexture2_inflateZLIBInt(ktxTexture2* This, ktx_uint8_t* pDeflatedData, */ KTX_error_code -ktxTexture2_SetImageFromMemory(ktxTexture2* This, ktx_uint32_t level, - ktx_uint32_t layer, ktx_uint32_t faceSlice, - const ktx_uint8_t* src, ktx_size_t srcSize) -{ +ktxTexture2_SetImageFromMemory(ktxTexture2* This, ktx_uint32_t level, ktx_uint32_t layer, ktx_uint32_t faceSlice, + const ktx_uint8_t* src, ktx_size_t srcSize) { UNUSED(This); UNUSED(level); UNUSED(layer); @@ -2668,10 +2441,8 @@ ktxTexture2_SetImageFromMemory(ktxTexture2* This, ktx_uint32_t level, } KTX_error_code -ktxTexture2_SetImageFromStdioStream(ktxTexture2* This, ktx_uint32_t level, - ktx_uint32_t layer, ktx_uint32_t faceSlice, - FILE* src, ktx_size_t srcSize) -{ +ktxTexture2_SetImageFromStdioStream(ktxTexture2* This, ktx_uint32_t level, ktx_uint32_t layer, ktx_uint32_t faceSlice, FILE* src, + ktx_size_t srcSize) { UNUSED(This); UNUSED(level); UNUSED(layer); @@ -2682,25 +2453,21 @@ ktxTexture2_SetImageFromStdioStream(ktxTexture2* This, ktx_uint32_t level, } KTX_error_code -ktxTexture2_WriteToStdioStream(ktxTexture2* This, FILE* dstsstr) -{ +ktxTexture2_WriteToStdioStream(ktxTexture2* This, FILE* dstsstr) { UNUSED(This); UNUSED(dstsstr); return KTX_INVALID_OPERATION; } KTX_error_code -ktxTexture2_WriteToNamedFile(ktxTexture2* This, const char* const dstname) -{ +ktxTexture2_WriteToNamedFile(ktxTexture2* This, const char* const dstname) { UNUSED(This); UNUSED(dstname); return KTX_INVALID_OPERATION; } KTX_error_code -ktxTexture2_WriteToMemory(ktxTexture2* This, - ktx_uint8_t** ppDstBytes, ktx_size_t* pSize) -{ +ktxTexture2_WriteToMemory(ktxTexture2* This, ktx_uint8_t** ppDstBytes, ktx_size_t* pSize) { UNUSED(This); UNUSED(ppDstBytes); UNUSED(pSize); @@ -2708,9 +2475,7 @@ ktxTexture2_WriteToMemory(ktxTexture2* This, } KTX_error_code -ktxTexture2_WriteToStream(ktxTexture2* This, - ktxStream* dststr) -{ +ktxTexture2_WriteToStream(ktxTexture2* This, ktxStream* dststr) { UNUSED(This); UNUSED(dststr); return KTX_INVALID_OPERATION; @@ -2723,11 +2488,9 @@ ktxTexture2_WriteToStream(ktxTexture2* This, * the virtual functions. */ -struct ktxTexture_vtblInt ktxTexture2_vtblInt = { - (PFNCALCDATASIZELEVELS)ktxTexture2_calcDataSizeLevels, - (PFNCALCFACELODSIZE)ktxTexture2_calcFaceLodSize, - (PFNCALCLEVELOFFSET)ktxTexture2_calcLevelOffset -}; +struct ktxTexture_vtblInt ktxTexture2_vtblInt = {(PFNCALCDATASIZELEVELS)ktxTexture2_calcDataSizeLevels, + (PFNCALCFACELODSIZE)ktxTexture2_calcFaceLodSize, + (PFNCALCLEVELOFFSET)ktxTexture2_calcLevelOffset}; struct ktxTexture_vtbl ktxTexture2_vtbl = { (PFNKTEXDESTROY)ktxTexture2_Destroy, @@ -2747,4 +2510,3 @@ struct ktxTexture_vtbl ktxTexture2_vtbl = { }; /** @} */ - diff --git a/lib/texture2.h b/lib/texture2.h index 08507804d9..795782bfd5 100644 --- a/lib/texture2.h +++ b/lib/texture2.h @@ -46,16 +46,11 @@ typedef struct ktxTexture2_private { index offset. */ } ktxTexture2_private; -KTX_error_code -ktxTexture2_LoadImageData(ktxTexture2* This, - ktx_uint8_t* pBuffer, ktx_size_t bufSize); +KTX_error_code ktxTexture2_LoadImageData(ktxTexture2* This, ktx_uint8_t* pBuffer, ktx_size_t bufSize); -KTX_error_code -ktxTexture2_constructCopy(ktxTexture2* This, ktxTexture2* orig); -KTX_error_code -ktxTexture2_constructFromStreamAndHeader(ktxTexture2* This, ktxStream* pStream, - KTX_header2* pHeader, - ktxTextureCreateFlags createFlags); +KTX_error_code ktxTexture2_constructCopy(ktxTexture2* This, ktxTexture2* orig); +KTX_error_code ktxTexture2_constructFromStreamAndHeader(ktxTexture2* This, ktxStream* pStream, KTX_header2* pHeader, + ktxTextureCreateFlags createFlags); ktx_uint64_t ktxTexture2_calcDataSizeTexture(ktxTexture2* This); ktx_size_t ktxTexture2_calcLevelOffset(ktxTexture2* This, ktx_uint32_t level); diff --git a/lib/uthash.h b/lib/uthash.h index aa4729027c..d7beda7e64 100644 --- a/lib/uthash.h +++ b/lib/uthash.h @@ -6,158 +6,156 @@ SPDX-License-Identifier: BSD-1-Clause #ifndef UTHASH_H #define UTHASH_H -#include /* memcmp,strlen */ -#include /* ptrdiff_t */ +#include /* memcmp,strlen */ +#include /* ptrdiff_t */ /* These macros use decltype or the earlier __typeof GNU extension. As decltype is only available in newer compilers (VS2010 or gcc 4.3+ when compiling c++ source) this code uses whatever method is needed or, for VS2008 where neither is available, uses casting workarounds. */ -#ifdef _MSC_VER /* MS compiler */ -#if _MSC_VER >= 1600 && __cplusplus /* VS2010 or newer in C++ mode */ +#ifdef _MSC_VER /* MS compiler */ +#if _MSC_VER >= 1600 && __cplusplus /* VS2010 or newer in C++ mode */ #define DECLTYPE(x) (decltype(x)) -#else /* VS2008 or older (or VS2010 in C mode) */ +#else /* VS2008 or older (or VS2010 in C mode) */ #define NO_DECLTYPE #define DECLTYPE(x) #endif -#else /* GNU, Sun and other compilers */ +#else /* GNU, Sun and other compilers */ #define DECLTYPE(x) (__typeof(x)) #endif #ifdef NO_DECLTYPE -#define DECLTYPE_ASSIGN(dst,src) \ -do { \ - char **_da_dst = (char**)(&(dst)); \ - *_da_dst = (char*)(src); \ -} while(0) +#define DECLTYPE_ASSIGN(dst, src) \ + do { \ + char **_da_dst = (char **)(&(dst)); \ + *_da_dst = (char *)(src); \ + } while (0) #else -#define DECLTYPE_ASSIGN(dst,src) \ -do { \ - (dst) = DECLTYPE(dst)(src); \ -} while(0) +#define DECLTYPE_ASSIGN(dst, src) \ + do { \ + (dst) = DECLTYPE(dst)(src); \ + } while (0) #endif /* a number of the hash function use uint32_t which isn't defined on win32 */ #ifdef _MSC_VER typedef unsigned int uint32_t; #else -#include /* uint32_t */ +#include /* uint32_t */ #endif #define UTHASH_VERSION 1.9.1 -#define uthash_fatal(msg) exit(-1) /* fatal error (out of memory,etc) */ -#define uthash_malloc(sz) malloc(sz) /* malloc fcn */ -#define uthash_free(ptr) free(ptr) /* free fcn */ +#define uthash_fatal(msg) exit(-1) /* fatal error (out of memory,etc) */ +#define uthash_malloc(sz) malloc(sz) /* malloc fcn */ +#define uthash_free(ptr) free(ptr) /* free fcn */ -#define uthash_noexpand_fyi(tbl) /* can be defined to log noexpand */ -#define uthash_expand_fyi(tbl) /* can be defined to log expands */ +#define uthash_noexpand_fyi(tbl) /* can be defined to log noexpand */ +#define uthash_expand_fyi(tbl) /* can be defined to log expands */ /* initial number of buckets */ -#define HASH_INITIAL_NUM_BUCKETS 32 /* initial number of buckets */ -#define HASH_INITIAL_NUM_BUCKETS_LOG2 5 /* lg2 of initial number of buckets */ -#define HASH_BKT_CAPACITY_THRESH 10 /* expand when bucket count reaches */ +#define HASH_INITIAL_NUM_BUCKETS 32 /* initial number of buckets */ +#define HASH_INITIAL_NUM_BUCKETS_LOG2 5 /* lg2 of initial number of buckets */ +#define HASH_BKT_CAPACITY_THRESH 10 /* expand when bucket count reaches */ /* calculate the element whose hash handle address is hhe */ -#define ELMT_FROM_HH(tbl,hhp) ((void*)(((char*)(hhp)) - ((tbl)->hho))) - -#define HASH_FIND(hh,head,keyptr,keylen,out) \ -do { \ - unsigned _hf_bkt,_hf_hashv; \ - out=NULL; \ - if (head) { \ - HASH_FCN(keyptr,keylen, (head)->hh.tbl->num_buckets, _hf_hashv, _hf_bkt); \ - if (HASH_BLOOM_TEST((head)->hh.tbl, _hf_hashv)) { \ - HASH_FIND_IN_BKT((head)->hh.tbl, hh, (head)->hh.tbl->buckets[ _hf_bkt ], \ - keyptr,keylen,out); \ - } \ - } \ -} while (0) +#define ELMT_FROM_HH(tbl, hhp) ((void *)(((char *)(hhp)) - ((tbl)->hho))) + +#define HASH_FIND(hh, head, keyptr, keylen, out) \ + do { \ + unsigned _hf_bkt, _hf_hashv; \ + out = NULL; \ + if (head) { \ + HASH_FCN(keyptr, keylen, (head)->hh.tbl->num_buckets, _hf_hashv, _hf_bkt); \ + if (HASH_BLOOM_TEST((head)->hh.tbl, _hf_hashv)) { \ + HASH_FIND_IN_BKT((head)->hh.tbl, hh, (head)->hh.tbl->buckets[_hf_bkt], keyptr, keylen, out); \ + } \ + } \ + } while (0) #ifdef HASH_BLOOM #define HASH_BLOOM_BITLEN (1ULL << HASH_BLOOM) -#define HASH_BLOOM_BYTELEN (HASH_BLOOM_BITLEN/8) + ((HASH_BLOOM_BITLEN%8) ? 1:0) -#define HASH_BLOOM_MAKE(tbl) \ -do { \ - (tbl)->bloom_nbits = HASH_BLOOM; \ - (tbl)->bloom_bv = (uint8_t*)uthash_malloc(HASH_BLOOM_BYTELEN); \ - if (!((tbl)->bloom_bv)) { uthash_fatal( "out of memory"); } \ - memset((tbl)->bloom_bv, 0, HASH_BLOOM_BYTELEN); \ - (tbl)->bloom_sig = HASH_BLOOM_SIGNATURE; \ -} while (0); - -#define HASH_BLOOM_FREE(tbl) \ -do { \ - uthash_free((tbl)->bloom_bv); \ -} while (0); - -#define HASH_BLOOM_BITSET(bv,idx) (bv[(idx)/8] |= (1U << ((idx)%8))) -#define HASH_BLOOM_BITTEST(bv,idx) (bv[(idx)/8] & (1U << ((idx)%8))) - -#define HASH_BLOOM_ADD(tbl,hashv) \ - HASH_BLOOM_BITSET((tbl)->bloom_bv, (hashv & (uint32_t)((1ULL << (tbl)->bloom_nbits) - 1))) - -#define HASH_BLOOM_TEST(tbl,hashv) \ - HASH_BLOOM_BITTEST((tbl)->bloom_bv, (hashv & (uint32_t)((1ULL << (tbl)->bloom_nbits) - 1))) +#define HASH_BLOOM_BYTELEN (HASH_BLOOM_BITLEN / 8) + ((HASH_BLOOM_BITLEN % 8) ? 1 : 0) +#define HASH_BLOOM_MAKE(tbl) \ + do { \ + (tbl)->bloom_nbits = HASH_BLOOM; \ + (tbl)->bloom_bv = (uint8_t *)uthash_malloc(HASH_BLOOM_BYTELEN); \ + if (!((tbl)->bloom_bv)) { \ + uthash_fatal("out of memory"); \ + } \ + memset((tbl)->bloom_bv, 0, HASH_BLOOM_BYTELEN); \ + (tbl)->bloom_sig = HASH_BLOOM_SIGNATURE; \ + } while (0); + +#define HASH_BLOOM_FREE(tbl) \ + do { \ + uthash_free((tbl)->bloom_bv); \ + } while (0); + +#define HASH_BLOOM_BITSET(bv, idx) (bv[(idx) / 8] |= (1U << ((idx) % 8))) +#define HASH_BLOOM_BITTEST(bv, idx) (bv[(idx) / 8] & (1U << ((idx) % 8))) + +#define HASH_BLOOM_ADD(tbl, hashv) HASH_BLOOM_BITSET((tbl)->bloom_bv, (hashv & (uint32_t)((1ULL << (tbl)->bloom_nbits) - 1))) + +#define HASH_BLOOM_TEST(tbl, hashv) HASH_BLOOM_BITTEST((tbl)->bloom_bv, (hashv & (uint32_t)((1ULL << (tbl)->bloom_nbits) - 1))) #else #define HASH_BLOOM_MAKE(tbl) #define HASH_BLOOM_FREE(tbl) -#define HASH_BLOOM_ADD(tbl,hashv) -#define HASH_BLOOM_TEST(tbl,hashv) (1) +#define HASH_BLOOM_ADD(tbl, hashv) +#define HASH_BLOOM_TEST(tbl, hashv) (1) #endif -#define HASH_MAKE_TABLE(hh,head) \ -do { \ - (head)->hh.tbl = (UT_hash_table*)uthash_malloc( \ - sizeof(UT_hash_table)); \ - if (!((head)->hh.tbl)) { uthash_fatal( "out of memory"); } \ - memset((head)->hh.tbl, 0, sizeof(UT_hash_table)); \ - (head)->hh.tbl->tail = &((head)->hh); \ - (head)->hh.tbl->num_buckets = HASH_INITIAL_NUM_BUCKETS; \ - (head)->hh.tbl->log2_num_buckets = HASH_INITIAL_NUM_BUCKETS_LOG2; \ - (head)->hh.tbl->hho = (char*)(&(head)->hh) - (char*)(head); \ - (head)->hh.tbl->buckets = (UT_hash_bucket*)uthash_malloc( \ - HASH_INITIAL_NUM_BUCKETS*sizeof(struct UT_hash_bucket)); \ - if (! (head)->hh.tbl->buckets) { uthash_fatal( "out of memory"); } \ - memset((head)->hh.tbl->buckets, 0, \ - HASH_INITIAL_NUM_BUCKETS*sizeof(struct UT_hash_bucket)); \ - HASH_BLOOM_MAKE((head)->hh.tbl); \ - (head)->hh.tbl->signature = HASH_SIGNATURE; \ -} while(0) - -#define HASH_ADD(hh,head,fieldname,keylen_in,add) \ - HASH_ADD_KEYPTR(hh,head,&add->fieldname,keylen_in,add) - -#define HASH_ADD_KEYPTR(hh,head,keyptr,keylen_in,add) \ -do { \ - unsigned _ha_bkt; \ - (add)->hh.next = NULL; \ - (add)->hh.key = (char*)keyptr; \ - (add)->hh.keylen = keylen_in; \ - if (!(head)) { \ - head = (add); \ - (head)->hh.prev = NULL; \ - HASH_MAKE_TABLE(hh,head); \ - } else { \ - (head)->hh.tbl->tail->next = (add); \ - (add)->hh.prev = ELMT_FROM_HH((head)->hh.tbl, (head)->hh.tbl->tail); \ - (head)->hh.tbl->tail = &((add)->hh); \ - } \ - (head)->hh.tbl->num_items++; \ - (add)->hh.tbl = (head)->hh.tbl; \ - HASH_FCN(keyptr,keylen_in, (head)->hh.tbl->num_buckets, \ - (add)->hh.hashv, _ha_bkt); \ - HASH_ADD_TO_BKT((head)->hh.tbl->buckets[_ha_bkt],&(add)->hh); \ - HASH_BLOOM_ADD((head)->hh.tbl,(add)->hh.hashv); \ - HASH_EMIT_KEY(hh,head,keyptr,keylen_in); \ - HASH_FSCK(hh,head); \ -} while(0) - -#define HASH_TO_BKT( hashv, num_bkts, bkt ) \ -do { \ - bkt = ((hashv) & ((num_bkts) - 1)); \ -} while(0) +#define HASH_MAKE_TABLE(hh, head) \ + do { \ + (head)->hh.tbl = (UT_hash_table *)uthash_malloc(sizeof(UT_hash_table)); \ + if (!((head)->hh.tbl)) { \ + uthash_fatal("out of memory"); \ + } \ + memset((head)->hh.tbl, 0, sizeof(UT_hash_table)); \ + (head)->hh.tbl->tail = &((head)->hh); \ + (head)->hh.tbl->num_buckets = HASH_INITIAL_NUM_BUCKETS; \ + (head)->hh.tbl->log2_num_buckets = HASH_INITIAL_NUM_BUCKETS_LOG2; \ + (head)->hh.tbl->hho = (char *)(&(head)->hh) - (char *)(head); \ + (head)->hh.tbl->buckets = (UT_hash_bucket *)uthash_malloc(HASH_INITIAL_NUM_BUCKETS * sizeof(struct UT_hash_bucket)); \ + if (!(head)->hh.tbl->buckets) { \ + uthash_fatal("out of memory"); \ + } \ + memset((head)->hh.tbl->buckets, 0, HASH_INITIAL_NUM_BUCKETS * sizeof(struct UT_hash_bucket)); \ + HASH_BLOOM_MAKE((head)->hh.tbl); \ + (head)->hh.tbl->signature = HASH_SIGNATURE; \ + } while (0) + +#define HASH_ADD(hh, head, fieldname, keylen_in, add) HASH_ADD_KEYPTR(hh, head, &add->fieldname, keylen_in, add) + +#define HASH_ADD_KEYPTR(hh, head, keyptr, keylen_in, add) \ + do { \ + unsigned _ha_bkt; \ + (add)->hh.next = NULL; \ + (add)->hh.key = (char *)keyptr; \ + (add)->hh.keylen = keylen_in; \ + if (!(head)) { \ + head = (add); \ + (head)->hh.prev = NULL; \ + HASH_MAKE_TABLE(hh, head); \ + } else { \ + (head)->hh.tbl->tail->next = (add); \ + (add)->hh.prev = ELMT_FROM_HH((head)->hh.tbl, (head)->hh.tbl->tail); \ + (head)->hh.tbl->tail = &((add)->hh); \ + } \ + (head)->hh.tbl->num_items++; \ + (add)->hh.tbl = (head)->hh.tbl; \ + HASH_FCN(keyptr, keylen_in, (head)->hh.tbl->num_buckets, (add)->hh.hashv, _ha_bkt); \ + HASH_ADD_TO_BKT((head)->hh.tbl->buckets[_ha_bkt], &(add)->hh); \ + HASH_BLOOM_ADD((head)->hh.tbl, (add)->hh.hashv); \ + HASH_EMIT_KEY(hh, head, keyptr, keylen_in); \ + HASH_FSCK(hh, head); \ + } while (0) + +#define HASH_TO_BKT(hashv, num_bkts, bkt) \ + do { \ + bkt = ((hashv) & ((num_bkts)-1)); \ + } while (0) /* delete "delptr" from the hash table. * "the usual" patch-up process for the app-order doubly-linked-list. @@ -171,129 +169,114 @@ do { * copy the deletee pointer, then the latter references are via that * scratch pointer rather than through the repointed (users) symbol. */ -#define HASH_DELETE(hh,head,delptr) \ -do { \ - unsigned _hd_bkt; \ - struct UT_hash_handle *_hd_hh_del; \ - if ( ((delptr)->hh.prev == NULL) && ((delptr)->hh.next == NULL) ) { \ - uthash_free((head)->hh.tbl->buckets ); \ - HASH_BLOOM_FREE((head)->hh.tbl); \ - uthash_free((head)->hh.tbl); \ - head = NULL; \ - } else { \ - _hd_hh_del = &((delptr)->hh); \ - if ((delptr) == ELMT_FROM_HH((head)->hh.tbl,(head)->hh.tbl->tail)) { \ - (head)->hh.tbl->tail = \ - (UT_hash_handle*)((char*)((delptr)->hh.prev) + \ - (head)->hh.tbl->hho); \ - } \ - if ((delptr)->hh.prev) { \ - ((UT_hash_handle*)((char*)((delptr)->hh.prev) + \ - (head)->hh.tbl->hho))->next = (delptr)->hh.next; \ - } else { \ - DECLTYPE_ASSIGN(head,(delptr)->hh.next); \ - } \ - if (_hd_hh_del->next) { \ - ((UT_hash_handle*)((char*)_hd_hh_del->next + \ - (head)->hh.tbl->hho))->prev = \ - _hd_hh_del->prev; \ - } \ - HASH_TO_BKT( _hd_hh_del->hashv, (head)->hh.tbl->num_buckets, _hd_bkt); \ - HASH_DEL_IN_BKT(hh,(head)->hh.tbl->buckets[_hd_bkt], _hd_hh_del); \ - (head)->hh.tbl->num_items--; \ - } \ - HASH_FSCK(hh,head); \ -} while (0) - +#define HASH_DELETE(hh, head, delptr) \ + do { \ + unsigned _hd_bkt; \ + struct UT_hash_handle *_hd_hh_del; \ + if (((delptr)->hh.prev == NULL) && ((delptr)->hh.next == NULL)) { \ + uthash_free((head)->hh.tbl->buckets); \ + HASH_BLOOM_FREE((head)->hh.tbl); \ + uthash_free((head)->hh.tbl); \ + head = NULL; \ + } else { \ + _hd_hh_del = &((delptr)->hh); \ + if ((delptr) == ELMT_FROM_HH((head)->hh.tbl, (head)->hh.tbl->tail)) { \ + (head)->hh.tbl->tail = (UT_hash_handle *)((char *)((delptr)->hh.prev) + (head)->hh.tbl->hho); \ + } \ + if ((delptr)->hh.prev) { \ + ((UT_hash_handle *)((char *)((delptr)->hh.prev) + (head)->hh.tbl->hho))->next = (delptr)->hh.next; \ + } else { \ + DECLTYPE_ASSIGN(head, (delptr)->hh.next); \ + } \ + if (_hd_hh_del->next) { \ + ((UT_hash_handle *)((char *)_hd_hh_del->next + (head)->hh.tbl->hho))->prev = _hd_hh_del->prev; \ + } \ + HASH_TO_BKT(_hd_hh_del->hashv, (head)->hh.tbl->num_buckets, _hd_bkt); \ + HASH_DEL_IN_BKT(hh, (head)->hh.tbl->buckets[_hd_bkt], _hd_hh_del); \ + (head)->hh.tbl->num_items--; \ + } \ + HASH_FSCK(hh, head); \ + } while (0) /* convenience forms of HASH_FIND/HASH_ADD/HASH_DEL */ -#define HASH_FIND_STR(head,findstr,out) \ - HASH_FIND(hh,head,findstr,strlen(findstr),out) -#define HASH_ADD_STR(head,strfield,add) \ - HASH_ADD(hh,head,strfield,strlen(add->strfield),add) -#define HASH_FIND_INT(head,findint,out) \ - HASH_FIND(hh,head,findint,sizeof(int),out) -#define HASH_ADD_INT(head,intfield,add) \ - HASH_ADD(hh,head,intfield,sizeof(int),add) -#define HASH_FIND_PTR(head,findptr,out) \ - HASH_FIND(hh,head,findptr,sizeof(void *),out) -#define HASH_ADD_PTR(head,ptrfield,add) \ - HASH_ADD(hh,head,ptrfield,sizeof(void *),add) -#define HASH_DEL(head,delptr) \ - HASH_DELETE(hh,head,delptr) +#define HASH_FIND_STR(head, findstr, out) HASH_FIND(hh, head, findstr, strlen(findstr), out) +#define HASH_ADD_STR(head, strfield, add) HASH_ADD(hh, head, strfield, strlen(add->strfield), add) +#define HASH_FIND_INT(head, findint, out) HASH_FIND(hh, head, findint, sizeof(int), out) +#define HASH_ADD_INT(head, intfield, add) HASH_ADD(hh, head, intfield, sizeof(int), add) +#define HASH_FIND_PTR(head, findptr, out) HASH_FIND(hh, head, findptr, sizeof(void *), out) +#define HASH_ADD_PTR(head, ptrfield, add) HASH_ADD(hh, head, ptrfield, sizeof(void *), add) +#define HASH_DEL(head, delptr) HASH_DELETE(hh, head, delptr) /* HASH_FSCK checks hash integrity on every add/delete when HASH_DEBUG is defined. * This is for uthash developer only; it compiles away if HASH_DEBUG isn't defined. */ #ifdef HASH_DEBUG -#define HASH_OOPS(...) do { fprintf(stderr,__VA_ARGS__); exit(-1); } while (0) -#define HASH_FSCK(hh,head) \ -do { \ - unsigned _bkt_i; \ - unsigned _count, _bkt_count; \ - char *_prev; \ - struct UT_hash_handle *_thh; \ - if (head) { \ - _count = 0; \ - for( _bkt_i = 0; _bkt_i < (head)->hh.tbl->num_buckets; _bkt_i++) { \ - _bkt_count = 0; \ - _thh = (head)->hh.tbl->buckets[_bkt_i].hh_head; \ - _prev = NULL; \ - while (_thh) { \ - if (_prev != (char*)(_thh->hh_prev)) { \ - HASH_OOPS("invalid hh_prev %p, actual %p\n", \ - _thh->hh_prev, _prev ); \ - } \ - _bkt_count++; \ - _prev = (char*)(_thh); \ - _thh = _thh->hh_next; \ - } \ - _count += _bkt_count; \ - if ((head)->hh.tbl->buckets[_bkt_i].count != _bkt_count) { \ - HASH_OOPS("invalid bucket count %d, actual %d\n", \ - (head)->hh.tbl->buckets[_bkt_i].count, _bkt_count); \ - } \ - } \ - if (_count != (head)->hh.tbl->num_items) { \ - HASH_OOPS("invalid hh item count %d, actual %d\n", \ - (head)->hh.tbl->num_items, _count ); \ - } \ - /* traverse hh in app order; check next/prev integrity, count */ \ - _count = 0; \ - _prev = NULL; \ - _thh = &(head)->hh; \ - while (_thh) { \ - _count++; \ - if (_prev !=(char*)(_thh->prev)) { \ - HASH_OOPS("invalid prev %p, actual %p\n", \ - _thh->prev, _prev ); \ - } \ - _prev = (char*)ELMT_FROM_HH((head)->hh.tbl, _thh); \ - _thh = ( _thh->next ? (UT_hash_handle*)((char*)(_thh->next) + \ - (head)->hh.tbl->hho) : NULL ); \ - } \ - if (_count != (head)->hh.tbl->num_items) { \ - HASH_OOPS("invalid app item count %d, actual %d\n", \ - (head)->hh.tbl->num_items, _count ); \ - } \ - } \ -} while (0) +#define HASH_OOPS(...) \ + do { \ + fprintf(stderr, __VA_ARGS__); \ + exit(-1); \ + } while (0) +#define HASH_FSCK(hh, head) \ + do { \ + unsigned _bkt_i; \ + unsigned _count, _bkt_count; \ + char *_prev; \ + struct UT_hash_handle *_thh; \ + if (head) { \ + _count = 0; \ + for (_bkt_i = 0; _bkt_i < (head)->hh.tbl->num_buckets; _bkt_i++) { \ + _bkt_count = 0; \ + _thh = (head)->hh.tbl->buckets[_bkt_i].hh_head; \ + _prev = NULL; \ + while (_thh) { \ + if (_prev != (char *)(_thh->hh_prev)) { \ + HASH_OOPS("invalid hh_prev %p, actual %p\n", _thh->hh_prev, _prev); \ + } \ + _bkt_count++; \ + _prev = (char *)(_thh); \ + _thh = _thh->hh_next; \ + } \ + _count += _bkt_count; \ + if ((head)->hh.tbl->buckets[_bkt_i].count != _bkt_count) { \ + HASH_OOPS("invalid bucket count %d, actual %d\n", (head)->hh.tbl->buckets[_bkt_i].count, _bkt_count); \ + } \ + } \ + if (_count != (head)->hh.tbl->num_items) { \ + HASH_OOPS("invalid hh item count %d, actual %d\n", (head)->hh.tbl->num_items, _count); \ + } \ + /* traverse hh in app order; check next/prev integrity, count */ \ + _count = 0; \ + _prev = NULL; \ + _thh = &(head)->hh; \ + while (_thh) { \ + _count++; \ + if (_prev != (char *)(_thh->prev)) { \ + HASH_OOPS("invalid prev %p, actual %p\n", _thh->prev, _prev); \ + } \ + _prev = (char *)ELMT_FROM_HH((head)->hh.tbl, _thh); \ + _thh = (_thh->next ? (UT_hash_handle *)((char *)(_thh->next) + (head)->hh.tbl->hho) : NULL); \ + } \ + if (_count != (head)->hh.tbl->num_items) { \ + HASH_OOPS("invalid app item count %d, actual %d\n", (head)->hh.tbl->num_items, _count); \ + } \ + } \ + } while (0) #else -#define HASH_FSCK(hh,head) +#define HASH_FSCK(hh, head) #endif /* When compiled with -DHASH_EMIT_KEYS, length-prefixed keys are emitted to * the descriptor to which this macro is defined for tuning the hash function. * The app can #include to get the prototype for write(2). */ #ifdef HASH_EMIT_KEYS -#define HASH_EMIT_KEY(hh,head,keyptr,fieldlen) \ -do { \ - unsigned _klen = fieldlen; \ - write(HASH_EMIT_KEYS, &_klen, sizeof(_klen)); \ - write(HASH_EMIT_KEYS, keyptr, fieldlen); \ -} while (0) +#define HASH_EMIT_KEY(hh, head, keyptr, fieldlen) \ + do { \ + unsigned _klen = fieldlen; \ + write(HASH_EMIT_KEYS, &_klen, sizeof(_klen)); \ + write(HASH_EMIT_KEYS, keyptr, fieldlen); \ + } while (0) #else -#define HASH_EMIT_KEY(hh,head,keyptr,fieldlen) +#define HASH_EMIT_KEY(hh, head, keyptr, fieldlen) #endif /* default to Jenkin's hash unless overridden e.g. DHASH_FUNCTION=HASH_SAX */ @@ -304,162 +287,186 @@ do { #endif /* The Bernstein hash function, used in Perl prior to v5.6 */ -#define HASH_BER(key,keylen,num_bkts,hashv,bkt) \ -do { \ - unsigned _hb_keylen=keylen; \ - char *_hb_key=(char*)key; \ - (hashv) = 0; \ - while (_hb_keylen--) { (hashv) = ((hashv) * 33) + *_hb_key++; } \ - bkt = (hashv) & (num_bkts-1); \ -} while (0) - +#define HASH_BER(key, keylen, num_bkts, hashv, bkt) \ + do { \ + unsigned _hb_keylen = keylen; \ + char *_hb_key = (char *)key; \ + (hashv) = 0; \ + while (_hb_keylen--) { \ + (hashv) = ((hashv)*33) + *_hb_key++; \ + } \ + bkt = (hashv) & (num_bkts - 1); \ + } while (0) /* SAX/FNV/OAT/JEN hash functions are macro variants of those listed at * http://eternallyconfuzzled.com/tuts/algorithms/jsw_tut_hashing.aspx */ -#define HASH_SAX(key,keylen,num_bkts,hashv,bkt) \ -do { \ - unsigned _sx_i; \ - char *_hs_key=(char*)key; \ - hashv = 0; \ - for(_sx_i=0; _sx_i < keylen; _sx_i++) \ - hashv ^= (hashv << 5) + (hashv >> 2) + _hs_key[_sx_i]; \ - bkt = hashv & (num_bkts-1); \ -} while (0) - -#define HASH_FNV(key,keylen,num_bkts,hashv,bkt) \ -do { \ - unsigned _fn_i; \ - char *_hf_key=(char*)key; \ - hashv = 2166136261UL; \ - for(_fn_i=0; _fn_i < keylen; _fn_i++) \ - hashv = (hashv * 16777619) ^ _hf_key[_fn_i]; \ - bkt = hashv & (num_bkts-1); \ -} while(0); - -#define HASH_OAT(key,keylen,num_bkts,hashv,bkt) \ -do { \ - unsigned _ho_i; \ - char *_ho_key=(char*)key; \ - hashv = 0; \ - for(_ho_i=0; _ho_i < keylen; _ho_i++) { \ - hashv += _ho_key[_ho_i]; \ - hashv += (hashv << 10); \ - hashv ^= (hashv >> 6); \ - } \ - hashv += (hashv << 3); \ - hashv ^= (hashv >> 11); \ - hashv += (hashv << 15); \ - bkt = hashv & (num_bkts-1); \ -} while(0) - -#define HASH_JEN_MIX(a,b,c) \ -do { \ - a -= b; a -= c; a ^= ( c >> 13 ); \ - b -= c; b -= a; b ^= ( a << 8 ); \ - c -= a; c -= b; c ^= ( b >> 13 ); \ - a -= b; a -= c; a ^= ( c >> 12 ); \ - b -= c; b -= a; b ^= ( a << 16 ); \ - c -= a; c -= b; c ^= ( b >> 5 ); \ - a -= b; a -= c; a ^= ( c >> 3 ); \ - b -= c; b -= a; b ^= ( a << 10 ); \ - c -= a; c -= b; c ^= ( b >> 15 ); \ -} while (0) - -#define HASH_JEN(key,keylen,num_bkts,hashv,bkt) \ -do { \ - unsigned _hj_i,_hj_j,_hj_k; \ - char *_hj_key=(char*)key; \ - hashv = 0xfeedbeef; \ - _hj_i = _hj_j = 0x9e3779b9; \ - _hj_k = keylen; \ - while (_hj_k >= 12) { \ - _hj_i += (_hj_key[0] + ( (unsigned)_hj_key[1] << 8 ) \ - + ( (unsigned)_hj_key[2] << 16 ) \ - + ( (unsigned)_hj_key[3] << 24 ) ); \ - _hj_j += (_hj_key[4] + ( (unsigned)_hj_key[5] << 8 ) \ - + ( (unsigned)_hj_key[6] << 16 ) \ - + ( (unsigned)_hj_key[7] << 24 ) ); \ - hashv += (_hj_key[8] + ( (unsigned)_hj_key[9] << 8 ) \ - + ( (unsigned)_hj_key[10] << 16 ) \ - + ( (unsigned)_hj_key[11] << 24 ) ); \ - \ - HASH_JEN_MIX(_hj_i, _hj_j, hashv); \ - \ - _hj_key += 12; \ - _hj_k -= 12; \ - } \ - hashv += keylen; \ - switch ( _hj_k ) { \ - case 11: hashv += ( (unsigned)_hj_key[10] << 24 ); \ - case 10: hashv += ( (unsigned)_hj_key[9] << 16 ); \ - case 9: hashv += ( (unsigned)_hj_key[8] << 8 ); \ - case 8: _hj_j += ( (unsigned)_hj_key[7] << 24 ); \ - case 7: _hj_j += ( (unsigned)_hj_key[6] << 16 ); \ - case 6: _hj_j += ( (unsigned)_hj_key[5] << 8 ); \ - case 5: _hj_j += _hj_key[4]; \ - case 4: _hj_i += ( (unsigned)_hj_key[3] << 24 ); \ - case 3: _hj_i += ( (unsigned)_hj_key[2] << 16 ); \ - case 2: _hj_i += ( (unsigned)_hj_key[1] << 8 ); \ - case 1: _hj_i += _hj_key[0]; \ - } \ - HASH_JEN_MIX(_hj_i, _hj_j, hashv); \ - bkt = hashv & (num_bkts-1); \ -} while(0) +#define HASH_SAX(key, keylen, num_bkts, hashv, bkt) \ + do { \ + unsigned _sx_i; \ + char *_hs_key = (char *)key; \ + hashv = 0; \ + for (_sx_i = 0; _sx_i < keylen; _sx_i++) hashv ^= (hashv << 5) + (hashv >> 2) + _hs_key[_sx_i]; \ + bkt = hashv & (num_bkts - 1); \ + } while (0) + +#define HASH_FNV(key, keylen, num_bkts, hashv, bkt) \ + do { \ + unsigned _fn_i; \ + char *_hf_key = (char *)key; \ + hashv = 2166136261UL; \ + for (_fn_i = 0; _fn_i < keylen; _fn_i++) hashv = (hashv * 16777619) ^ _hf_key[_fn_i]; \ + bkt = hashv & (num_bkts - 1); \ + } while (0); + +#define HASH_OAT(key, keylen, num_bkts, hashv, bkt) \ + do { \ + unsigned _ho_i; \ + char *_ho_key = (char *)key; \ + hashv = 0; \ + for (_ho_i = 0; _ho_i < keylen; _ho_i++) { \ + hashv += _ho_key[_ho_i]; \ + hashv += (hashv << 10); \ + hashv ^= (hashv >> 6); \ + } \ + hashv += (hashv << 3); \ + hashv ^= (hashv >> 11); \ + hashv += (hashv << 15); \ + bkt = hashv & (num_bkts - 1); \ + } while (0) + +#define HASH_JEN_MIX(a, b, c) \ + do { \ + a -= b; \ + a -= c; \ + a ^= (c >> 13); \ + b -= c; \ + b -= a; \ + b ^= (a << 8); \ + c -= a; \ + c -= b; \ + c ^= (b >> 13); \ + a -= b; \ + a -= c; \ + a ^= (c >> 12); \ + b -= c; \ + b -= a; \ + b ^= (a << 16); \ + c -= a; \ + c -= b; \ + c ^= (b >> 5); \ + a -= b; \ + a -= c; \ + a ^= (c >> 3); \ + b -= c; \ + b -= a; \ + b ^= (a << 10); \ + c -= a; \ + c -= b; \ + c ^= (b >> 15); \ + } while (0) + +#define HASH_JEN(key, keylen, num_bkts, hashv, bkt) \ + do { \ + unsigned _hj_i, _hj_j, _hj_k; \ + char *_hj_key = (char *)key; \ + hashv = 0xfeedbeef; \ + _hj_i = _hj_j = 0x9e3779b9; \ + _hj_k = keylen; \ + while (_hj_k >= 12) { \ + _hj_i += (_hj_key[0] + ((unsigned)_hj_key[1] << 8) + ((unsigned)_hj_key[2] << 16) + ((unsigned)_hj_key[3] << 24)); \ + _hj_j += (_hj_key[4] + ((unsigned)_hj_key[5] << 8) + ((unsigned)_hj_key[6] << 16) + ((unsigned)_hj_key[7] << 24)); \ + hashv += (_hj_key[8] + ((unsigned)_hj_key[9] << 8) + ((unsigned)_hj_key[10] << 16) + ((unsigned)_hj_key[11] << 24)); \ + \ + HASH_JEN_MIX(_hj_i, _hj_j, hashv); \ + \ + _hj_key += 12; \ + _hj_k -= 12; \ + } \ + hashv += keylen; \ + switch (_hj_k) { \ + case 11: \ + hashv += ((unsigned)_hj_key[10] << 24); \ + case 10: \ + hashv += ((unsigned)_hj_key[9] << 16); \ + case 9: \ + hashv += ((unsigned)_hj_key[8] << 8); \ + case 8: \ + _hj_j += ((unsigned)_hj_key[7] << 24); \ + case 7: \ + _hj_j += ((unsigned)_hj_key[6] << 16); \ + case 6: \ + _hj_j += ((unsigned)_hj_key[5] << 8); \ + case 5: \ + _hj_j += _hj_key[4]; \ + case 4: \ + _hj_i += ((unsigned)_hj_key[3] << 24); \ + case 3: \ + _hj_i += ((unsigned)_hj_key[2] << 16); \ + case 2: \ + _hj_i += ((unsigned)_hj_key[1] << 8); \ + case 1: \ + _hj_i += _hj_key[0]; \ + } \ + HASH_JEN_MIX(_hj_i, _hj_j, hashv); \ + bkt = hashv & (num_bkts - 1); \ + } while (0) /* The Paul Hsieh hash function */ #undef get16bits -#if (defined(__GNUC__) && defined(__i386__)) || defined(__WATCOMC__) \ - || defined(_MSC_VER) || defined (__BORLANDC__) || defined (__TURBOC__) -#define get16bits(d) (*((const uint16_t *) (d))) +#if (defined(__GNUC__) && defined(__i386__)) || defined(__WATCOMC__) || defined(_MSC_VER) || defined(__BORLANDC__) || \ + defined(__TURBOC__) +#define get16bits(d) (*((const uint16_t *)(d))) #endif -#if !defined (get16bits) -#define get16bits(d) ((((uint32_t)(((const uint8_t *)(d))[1])) << 8) \ - +(uint32_t)(((const uint8_t *)(d))[0]) ) +#if !defined(get16bits) +#define get16bits(d) ((((uint32_t)(((const uint8_t *)(d))[1])) << 8) + (uint32_t)(((const uint8_t *)(d))[0])) #endif -#define HASH_SFH(key,keylen,num_bkts,hashv,bkt) \ -do { \ - char *_sfh_key=(char*)key; \ - uint32_t _sfh_tmp, _sfh_len = keylen; \ - \ - int _sfh_rem = _sfh_len & 3; \ - _sfh_len >>= 2; \ - hashv = 0xcafebabe; \ - \ - /* Main loop */ \ - for (;_sfh_len > 0; _sfh_len--) { \ - hashv += get16bits (_sfh_key); \ - _sfh_tmp = (get16bits (_sfh_key+2) << 11) ^ hashv; \ - hashv = (hashv << 16) ^ _sfh_tmp; \ - _sfh_key += 2*sizeof (uint16_t); \ - hashv += hashv >> 11; \ - } \ - \ - /* Handle end cases */ \ - switch (_sfh_rem) { \ - case 3: hashv += get16bits (_sfh_key); \ - hashv ^= hashv << 16; \ - hashv ^= _sfh_key[sizeof (uint16_t)] << 18; \ - hashv += hashv >> 11; \ - break; \ - case 2: hashv += get16bits (_sfh_key); \ - hashv ^= hashv << 11; \ - hashv += hashv >> 17; \ - break; \ - case 1: hashv += *_sfh_key; \ - hashv ^= hashv << 10; \ - hashv += hashv >> 1; \ - } \ - \ - /* Force "avalanching" of final 127 bits */ \ - hashv ^= hashv << 3; \ - hashv += hashv >> 5; \ - hashv ^= hashv << 4; \ - hashv += hashv >> 17; \ - hashv ^= hashv << 25; \ - hashv += hashv >> 6; \ - bkt = hashv & (num_bkts-1); \ -} while(0); +#define HASH_SFH(key, keylen, num_bkts, hashv, bkt) \ + do { \ + char *_sfh_key = (char *)key; \ + uint32_t _sfh_tmp, _sfh_len = keylen; \ + \ + int _sfh_rem = _sfh_len & 3; \ + _sfh_len >>= 2; \ + hashv = 0xcafebabe; \ + \ + /* Main loop */ \ + for (; _sfh_len > 0; _sfh_len--) { \ + hashv += get16bits(_sfh_key); \ + _sfh_tmp = (get16bits(_sfh_key + 2) << 11) ^ hashv; \ + hashv = (hashv << 16) ^ _sfh_tmp; \ + _sfh_key += 2 * sizeof(uint16_t); \ + hashv += hashv >> 11; \ + } \ + \ + /* Handle end cases */ \ + switch (_sfh_rem) { \ + case 3: \ + hashv += get16bits(_sfh_key); \ + hashv ^= hashv << 16; \ + hashv ^= _sfh_key[sizeof(uint16_t)] << 18; \ + hashv += hashv >> 11; \ + break; \ + case 2: \ + hashv += get16bits(_sfh_key); \ + hashv ^= hashv << 11; \ + hashv += hashv >> 17; \ + break; \ + case 1: \ + hashv += *_sfh_key; \ + hashv ^= hashv << 10; \ + hashv += hashv >> 1; \ + } \ + \ + /* Force "avalanching" of final 127 bits */ \ + hashv ^= hashv << 3; \ + hashv += hashv >> 5; \ + hashv ^= hashv << 4; \ + hashv += hashv >> 17; \ + hashv ^= hashv << 25; \ + hashv += hashv >> 6; \ + bkt = hashv & (num_bkts - 1); \ + } while (0); #ifdef HASH_USING_NO_STRICT_ALIASING /* The MurmurHash exploits some CPU's (e.g. x86) tolerance for unaligned reads. @@ -479,179 +486,199 @@ do { #endif /* Appleby's MurmurHash fast version for unaligned-tolerant archs like i386 */ -#define HASH_MUR_UNALIGNED(key,keylen,num_bkts,hashv,bkt) \ -do { \ - const unsigned int _mur_m = 0x5bd1e995; \ - const int _mur_r = 24; \ - hashv = 0xcafebabe ^ keylen; \ - char *_mur_key = (char *)key; \ - uint32_t _mur_tmp, _mur_len = keylen; \ - \ - for (;_mur_len >= 4; _mur_len-=4) { \ - _mur_tmp = *(uint32_t *)_mur_key; \ - _mur_tmp *= _mur_m; \ - _mur_tmp ^= _mur_tmp >> _mur_r; \ - _mur_tmp *= _mur_m; \ - hashv *= _mur_m; \ - hashv ^= _mur_tmp; \ - _mur_key += 4; \ - } \ - \ - switch(_mur_len) \ - { \ - case 3: hashv ^= _mur_key[2] << 16; \ - case 2: hashv ^= _mur_key[1] << 8; \ - case 1: hashv ^= _mur_key[0]; \ - hashv *= _mur_m; \ - }; \ - \ - hashv ^= hashv >> 13; \ - hashv *= _mur_m; \ - hashv ^= hashv >> 15; \ - \ - bkt = hashv & (num_bkts-1); \ -} while(0) +#define HASH_MUR_UNALIGNED(key, keylen, num_bkts, hashv, bkt) \ + do { \ + const unsigned int _mur_m = 0x5bd1e995; \ + const int _mur_r = 24; \ + hashv = 0xcafebabe ^ keylen; \ + char *_mur_key = (char *)key; \ + uint32_t _mur_tmp, _mur_len = keylen; \ + \ + for (; _mur_len >= 4; _mur_len -= 4) { \ + _mur_tmp = *(uint32_t *)_mur_key; \ + _mur_tmp *= _mur_m; \ + _mur_tmp ^= _mur_tmp >> _mur_r; \ + _mur_tmp *= _mur_m; \ + hashv *= _mur_m; \ + hashv ^= _mur_tmp; \ + _mur_key += 4; \ + } \ + \ + switch (_mur_len) { \ + case 3: \ + hashv ^= _mur_key[2] << 16; \ + case 2: \ + hashv ^= _mur_key[1] << 8; \ + case 1: \ + hashv ^= _mur_key[0]; \ + hashv *= _mur_m; \ + }; \ + \ + hashv ^= hashv >> 13; \ + hashv *= _mur_m; \ + hashv ^= hashv >> 15; \ + \ + bkt = hashv & (num_bkts - 1); \ + } while (0) /* Appleby's MurmurHash version for alignment-sensitive archs like Sparc */ -#define HASH_MUR_ALIGNED(key,keylen,num_bkts,hashv,bkt) \ -do { \ - const unsigned int _mur_m = 0x5bd1e995; \ - const int _mur_r = 24; \ - hashv = 0xcafebabe ^ keylen; \ - char *_mur_key = (char *)key; \ - uint32_t _mur_len = keylen; \ - int _mur_align = (int)_mur_key & 3; \ - \ - if (_mur_align && (_mur_len >= 4)) { \ - unsigned _mur_t = 0, _mur_d = 0; \ - switch(_mur_align) { \ - case 1: _mur_t |= _mur_key[2] << 16; \ - case 2: _mur_t |= _mur_key[1] << 8; \ - case 3: _mur_t |= _mur_key[0]; \ - } \ - _mur_t <<= (8 * _mur_align); \ - _mur_key += 4-_mur_align; \ - _mur_len -= 4-_mur_align; \ - int _mur_sl = 8 * (4-_mur_align); \ - int _mur_sr = 8 * _mur_align; \ - \ - for (;_mur_len >= 4; _mur_len-=4) { \ - _mur_d = *(unsigned *)_mur_key; \ - _mur_t = (_mur_t >> _mur_sr) | (_mur_d << _mur_sl); \ - unsigned _mur_k = _mur_t; \ - _mur_k *= _mur_m; \ - _mur_k ^= _mur_k >> _mur_r; \ - _mur_k *= _mur_m; \ - hashv *= _mur_m; \ - hashv ^= _mur_k; \ - _mur_t = _mur_d; \ - _mur_key += 4; \ - } \ - _mur_d = 0; \ - if(_mur_len >= _mur_align) { \ - switch(_mur_align) { \ - case 3: _mur_d |= _mur_key[2] << 16; \ - case 2: _mur_d |= _mur_key[1] << 8; \ - case 1: _mur_d |= _mur_key[0]; \ - } \ - unsigned _mur_k = (_mur_t >> _mur_sr) | (_mur_d << _mur_sl); \ - _mur_k *= _mur_m; \ - _mur_k ^= _mur_k >> _mur_r; \ - _mur_k *= _mur_m; \ - hashv *= _mur_m; \ - hashv ^= _mur_k; \ - _mur_k += _mur_align; \ - _mur_len -= _mur_align; \ - \ - switch(_mur_len) \ - { \ - case 3: hashv ^= _mur_key[2] << 16; \ - case 2: hashv ^= _mur_key[1] << 8; \ - case 1: hashv ^= _mur_key[0]; \ - hashv *= _mur_m; \ - } \ - } else { \ - switch(_mur_len) \ - { \ - case 3: _mur_d ^= _mur_key[2] << 16; \ - case 2: _mur_d ^= _mur_key[1] << 8; \ - case 1: _mur_d ^= _mur_key[0]; \ - case 0: hashv ^= (_mur_t >> _mur_sr) | (_mur_d << _mur_sl); \ - hashv *= _mur_m; \ - } \ - } \ - \ - hashv ^= hashv >> 13; \ - hashv *= _mur_m; \ - hashv ^= hashv >> 15; \ - } else { \ - for (;_mur_len >= 4; _mur_len-=4) { \ - unsigned _mur_k = *(unsigned*)_mur_key; \ - _mur_k *= _mur_m; \ - _mur_k ^= _mur_k >> _mur_r; \ - _mur_k *= _mur_m; \ - hashv *= _mur_m; \ - hashv ^= _mur_k; \ - _mur_key += 4; \ - } \ - switch(_mur_len) \ - { \ - case 3: hashv ^= _mur_key[2] << 16; \ - case 2: hashv ^= _mur_key[1] << 8; \ - case 1: hashv ^= _mur_key[0]; \ - hashv *= _mur_m; \ - } \ - \ - hashv ^= hashv >> 13; \ - hashv *= _mur_m; \ - hashv ^= hashv >> 15; \ - } \ - bkt = hashv & (num_bkts-1); \ -} while(0) -#endif /* HASH_USING_NO_STRICT_ALIASING */ +#define HASH_MUR_ALIGNED(key, keylen, num_bkts, hashv, bkt) \ + do { \ + const unsigned int _mur_m = 0x5bd1e995; \ + const int _mur_r = 24; \ + hashv = 0xcafebabe ^ keylen; \ + char *_mur_key = (char *)key; \ + uint32_t _mur_len = keylen; \ + int _mur_align = (int)_mur_key & 3; \ + \ + if (_mur_align && (_mur_len >= 4)) { \ + unsigned _mur_t = 0, _mur_d = 0; \ + switch (_mur_align) { \ + case 1: \ + _mur_t |= _mur_key[2] << 16; \ + case 2: \ + _mur_t |= _mur_key[1] << 8; \ + case 3: \ + _mur_t |= _mur_key[0]; \ + } \ + _mur_t <<= (8 * _mur_align); \ + _mur_key += 4 - _mur_align; \ + _mur_len -= 4 - _mur_align; \ + int _mur_sl = 8 * (4 - _mur_align); \ + int _mur_sr = 8 * _mur_align; \ + \ + for (; _mur_len >= 4; _mur_len -= 4) { \ + _mur_d = *(unsigned *)_mur_key; \ + _mur_t = (_mur_t >> _mur_sr) | (_mur_d << _mur_sl); \ + unsigned _mur_k = _mur_t; \ + _mur_k *= _mur_m; \ + _mur_k ^= _mur_k >> _mur_r; \ + _mur_k *= _mur_m; \ + hashv *= _mur_m; \ + hashv ^= _mur_k; \ + _mur_t = _mur_d; \ + _mur_key += 4; \ + } \ + _mur_d = 0; \ + if (_mur_len >= _mur_align) { \ + switch (_mur_align) { \ + case 3: \ + _mur_d |= _mur_key[2] << 16; \ + case 2: \ + _mur_d |= _mur_key[1] << 8; \ + case 1: \ + _mur_d |= _mur_key[0]; \ + } \ + unsigned _mur_k = (_mur_t >> _mur_sr) | (_mur_d << _mur_sl); \ + _mur_k *= _mur_m; \ + _mur_k ^= _mur_k >> _mur_r; \ + _mur_k *= _mur_m; \ + hashv *= _mur_m; \ + hashv ^= _mur_k; \ + _mur_k += _mur_align; \ + _mur_len -= _mur_align; \ + \ + switch (_mur_len) { \ + case 3: \ + hashv ^= _mur_key[2] << 16; \ + case 2: \ + hashv ^= _mur_key[1] << 8; \ + case 1: \ + hashv ^= _mur_key[0]; \ + hashv *= _mur_m; \ + } \ + } else { \ + switch (_mur_len) { \ + case 3: \ + _mur_d ^= _mur_key[2] << 16; \ + case 2: \ + _mur_d ^= _mur_key[1] << 8; \ + case 1: \ + _mur_d ^= _mur_key[0]; \ + case 0: \ + hashv ^= (_mur_t >> _mur_sr) | (_mur_d << _mur_sl); \ + hashv *= _mur_m; \ + } \ + } \ + \ + hashv ^= hashv >> 13; \ + hashv *= _mur_m; \ + hashv ^= hashv >> 15; \ + } else { \ + for (; _mur_len >= 4; _mur_len -= 4) { \ + unsigned _mur_k = *(unsigned *)_mur_key; \ + _mur_k *= _mur_m; \ + _mur_k ^= _mur_k >> _mur_r; \ + _mur_k *= _mur_m; \ + hashv *= _mur_m; \ + hashv ^= _mur_k; \ + _mur_key += 4; \ + } \ + switch (_mur_len) { \ + case 3: \ + hashv ^= _mur_key[2] << 16; \ + case 2: \ + hashv ^= _mur_key[1] << 8; \ + case 1: \ + hashv ^= _mur_key[0]; \ + hashv *= _mur_m; \ + } \ + \ + hashv ^= hashv >> 13; \ + hashv *= _mur_m; \ + hashv ^= hashv >> 15; \ + } \ + bkt = hashv & (num_bkts - 1); \ + } while (0) +#endif /* HASH_USING_NO_STRICT_ALIASING */ /* key comparison function; return 0 if keys equal */ -#define HASH_KEYCMP(a,b,len) memcmp(a,b,len) +#define HASH_KEYCMP(a, b, len) memcmp(a, b, len) /* iterate over items in a known bucket to find desired item */ -#define HASH_FIND_IN_BKT(tbl,hh,head,keyptr,keylen_in,out) \ -do { \ - if (head.hh_head) DECLTYPE_ASSIGN(out,ELMT_FROM_HH(tbl,head.hh_head)); \ - else out=NULL; \ - while (out) { \ - if (out->hh.keylen == keylen_in) { \ - if ((HASH_KEYCMP(out->hh.key,keyptr,keylen_in)) == 0) break; \ - } \ - if (out->hh.hh_next) DECLTYPE_ASSIGN(out,ELMT_FROM_HH(tbl,out->hh.hh_next)); \ - else out = NULL; \ - } \ -} while(0) +#define HASH_FIND_IN_BKT(tbl, hh, head, keyptr, keylen_in, out) \ + do { \ + if (head.hh_head) \ + DECLTYPE_ASSIGN(out, ELMT_FROM_HH(tbl, head.hh_head)); \ + else \ + out = NULL; \ + while (out) { \ + if (out->hh.keylen == keylen_in) { \ + if ((HASH_KEYCMP(out->hh.key, keyptr, keylen_in)) == 0) break; \ + } \ + if (out->hh.hh_next) \ + DECLTYPE_ASSIGN(out, ELMT_FROM_HH(tbl, out->hh.hh_next)); \ + else \ + out = NULL; \ + } \ + } while (0) /* add an item to a bucket */ -#define HASH_ADD_TO_BKT(head,addhh) \ -do { \ - head.count++; \ - (addhh)->hh_next = head.hh_head; \ - (addhh)->hh_prev = NULL; \ - if (head.hh_head) { (head).hh_head->hh_prev = (addhh); } \ - (head).hh_head=addhh; \ - if (head.count >= ((head.expand_mult+1) * HASH_BKT_CAPACITY_THRESH) \ - && (addhh)->tbl->noexpand != 1) { \ - HASH_EXPAND_BUCKETS((addhh)->tbl); \ - } \ -} while(0) +#define HASH_ADD_TO_BKT(head, addhh) \ + do { \ + head.count++; \ + (addhh)->hh_next = head.hh_head; \ + (addhh)->hh_prev = NULL; \ + if (head.hh_head) { \ + (head).hh_head->hh_prev = (addhh); \ + } \ + (head).hh_head = addhh; \ + if (head.count >= ((head.expand_mult + 1) * HASH_BKT_CAPACITY_THRESH) && (addhh)->tbl->noexpand != 1) { \ + HASH_EXPAND_BUCKETS((addhh)->tbl); \ + } \ + } while (0) /* remove an item from a given bucket */ -#define HASH_DEL_IN_BKT(hh,head,hh_del) \ - (head).count--; \ - if ((head).hh_head == hh_del) { \ - (head).hh_head = hh_del->hh_next; \ - } \ - if (hh_del->hh_prev) { \ - hh_del->hh_prev->hh_next = hh_del->hh_next; \ - } \ - if (hh_del->hh_next) { \ - hh_del->hh_next->hh_prev = hh_del->hh_prev; \ +#define HASH_DEL_IN_BKT(hh, head, hh_del) \ + (head).count--; \ + if ((head).hh_head == hh_del) { \ + (head).hh_head = hh_del->hh_next; \ + } \ + if (hh_del->hh_prev) { \ + hh_del->hh_prev->hh_next = hh_del->hh_next; \ + } \ + if (hh_del->hh_next) { \ + hh_del->hh_next->hh_prev = hh_del->hh_prev; \ } /* Bucket expansion has the effect of doubling the number of buckets @@ -683,211 +710,196 @@ do { * ceil(n/b) = (n>>lb) + ( (n & (b-1)) ? 1:0) * */ -#define HASH_EXPAND_BUCKETS(tbl) \ -do { \ - unsigned _he_bkt; \ - unsigned _he_bkt_i; \ - struct UT_hash_handle *_he_thh, *_he_hh_nxt; \ - UT_hash_bucket *_he_new_buckets, *_he_newbkt; \ - _he_new_buckets = (UT_hash_bucket*)uthash_malloc( \ - 2 * tbl->num_buckets * sizeof(struct UT_hash_bucket)); \ - if (!_he_new_buckets) { uthash_fatal( "out of memory"); } \ - memset(_he_new_buckets, 0, \ - 2 * tbl->num_buckets * sizeof(struct UT_hash_bucket)); \ - tbl->ideal_chain_maxlen = \ - (tbl->num_items >> (tbl->log2_num_buckets+1)) + \ - ((tbl->num_items & ((tbl->num_buckets*2)-1)) ? 1 : 0); \ - tbl->nonideal_items = 0; \ - for(_he_bkt_i = 0; _he_bkt_i < tbl->num_buckets; _he_bkt_i++) \ - { \ - _he_thh = tbl->buckets[ _he_bkt_i ].hh_head; \ - while (_he_thh) { \ - _he_hh_nxt = _he_thh->hh_next; \ - HASH_TO_BKT( _he_thh->hashv, tbl->num_buckets*2, _he_bkt); \ - _he_newbkt = &(_he_new_buckets[ _he_bkt ]); \ - if (++(_he_newbkt->count) > tbl->ideal_chain_maxlen) { \ - tbl->nonideal_items++; \ - _he_newbkt->expand_mult = _he_newbkt->count / \ - tbl->ideal_chain_maxlen; \ - } \ - _he_thh->hh_prev = NULL; \ - _he_thh->hh_next = _he_newbkt->hh_head; \ - if (_he_newbkt->hh_head) _he_newbkt->hh_head->hh_prev = \ - _he_thh; \ - _he_newbkt->hh_head = _he_thh; \ - _he_thh = _he_hh_nxt; \ - } \ - } \ - tbl->num_buckets *= 2; \ - tbl->log2_num_buckets++; \ - uthash_free( tbl->buckets ); \ - tbl->buckets = _he_new_buckets; \ - tbl->ineff_expands = (tbl->nonideal_items > (tbl->num_items >> 1)) ? \ - (tbl->ineff_expands+1) : 0; \ - if (tbl->ineff_expands > 1) { \ - tbl->noexpand=1; \ - uthash_noexpand_fyi(tbl); \ - } \ - uthash_expand_fyi(tbl); \ -} while(0) - +#define HASH_EXPAND_BUCKETS(tbl) \ + do { \ + unsigned _he_bkt; \ + unsigned _he_bkt_i; \ + struct UT_hash_handle *_he_thh, *_he_hh_nxt; \ + UT_hash_bucket *_he_new_buckets, *_he_newbkt; \ + _he_new_buckets = (UT_hash_bucket *)uthash_malloc(2 * tbl->num_buckets * sizeof(struct UT_hash_bucket)); \ + if (!_he_new_buckets) { \ + uthash_fatal("out of memory"); \ + } \ + memset(_he_new_buckets, 0, 2 * tbl->num_buckets * sizeof(struct UT_hash_bucket)); \ + tbl->ideal_chain_maxlen = \ + (tbl->num_items >> (tbl->log2_num_buckets + 1)) + ((tbl->num_items & ((tbl->num_buckets * 2) - 1)) ? 1 : 0); \ + tbl->nonideal_items = 0; \ + for (_he_bkt_i = 0; _he_bkt_i < tbl->num_buckets; _he_bkt_i++) { \ + _he_thh = tbl->buckets[_he_bkt_i].hh_head; \ + while (_he_thh) { \ + _he_hh_nxt = _he_thh->hh_next; \ + HASH_TO_BKT(_he_thh->hashv, tbl->num_buckets * 2, _he_bkt); \ + _he_newbkt = &(_he_new_buckets[_he_bkt]); \ + if (++(_he_newbkt->count) > tbl->ideal_chain_maxlen) { \ + tbl->nonideal_items++; \ + _he_newbkt->expand_mult = _he_newbkt->count / tbl->ideal_chain_maxlen; \ + } \ + _he_thh->hh_prev = NULL; \ + _he_thh->hh_next = _he_newbkt->hh_head; \ + if (_he_newbkt->hh_head) _he_newbkt->hh_head->hh_prev = _he_thh; \ + _he_newbkt->hh_head = _he_thh; \ + _he_thh = _he_hh_nxt; \ + } \ + } \ + tbl->num_buckets *= 2; \ + tbl->log2_num_buckets++; \ + uthash_free(tbl->buckets); \ + tbl->buckets = _he_new_buckets; \ + tbl->ineff_expands = (tbl->nonideal_items > (tbl->num_items >> 1)) ? (tbl->ineff_expands + 1) : 0; \ + if (tbl->ineff_expands > 1) { \ + tbl->noexpand = 1; \ + uthash_noexpand_fyi(tbl); \ + } \ + uthash_expand_fyi(tbl); \ + } while (0) /* This is an adaptation of Simon Tatham's O(n log(n)) mergesort */ /* Note that HASH_SORT assumes the hash handle name to be hh. * HASH_SRT was added to allow the hash handle name to be passed in. */ -#define HASH_SORT(head,cmpfcn) HASH_SRT(hh,head,cmpfcn) -#define HASH_SRT(hh,head,cmpfcn) \ -do { \ - unsigned _hs_i; \ - unsigned _hs_looping,_hs_nmerges,_hs_insize,_hs_psize,_hs_qsize; \ - struct UT_hash_handle *_hs_p, *_hs_q, *_hs_e, *_hs_list, *_hs_tail; \ - if (head) { \ - _hs_insize = 1; \ - _hs_looping = 1; \ - _hs_list = &((head)->hh); \ - while (_hs_looping) { \ - _hs_p = _hs_list; \ - _hs_list = NULL; \ - _hs_tail = NULL; \ - _hs_nmerges = 0; \ - while (_hs_p) { \ - _hs_nmerges++; \ - _hs_q = _hs_p; \ - _hs_psize = 0; \ - for ( _hs_i = 0; _hs_i < _hs_insize; _hs_i++ ) { \ - _hs_psize++; \ - _hs_q = (UT_hash_handle*)((_hs_q->next) ? \ - ((void*)((char*)(_hs_q->next) + \ - (head)->hh.tbl->hho)) : NULL); \ - if (! (_hs_q) ) break; \ - } \ - _hs_qsize = _hs_insize; \ - while ((_hs_psize > 0) || ((_hs_qsize > 0) && _hs_q )) { \ - if (_hs_psize == 0) { \ - _hs_e = _hs_q; \ - _hs_q = (UT_hash_handle*)((_hs_q->next) ? \ - ((void*)((char*)(_hs_q->next) + \ - (head)->hh.tbl->hho)) : NULL); \ - _hs_qsize--; \ - } else if ( (_hs_qsize == 0) || !(_hs_q) ) { \ - _hs_e = _hs_p; \ - _hs_p = (UT_hash_handle*)((_hs_p->next) ? \ - ((void*)((char*)(_hs_p->next) + \ - (head)->hh.tbl->hho)) : NULL); \ - _hs_psize--; \ - } else if (( \ - cmpfcn(DECLTYPE(head)(ELMT_FROM_HH((head)->hh.tbl,_hs_p)), \ - DECLTYPE(head)(ELMT_FROM_HH((head)->hh.tbl,_hs_q))) \ - ) <= 0) { \ - _hs_e = _hs_p; \ - _hs_p = (UT_hash_handle*)((_hs_p->next) ? \ - ((void*)((char*)(_hs_p->next) + \ - (head)->hh.tbl->hho)) : NULL); \ - _hs_psize--; \ - } else { \ - _hs_e = _hs_q; \ - _hs_q = (UT_hash_handle*)((_hs_q->next) ? \ - ((void*)((char*)(_hs_q->next) + \ - (head)->hh.tbl->hho)) : NULL); \ - _hs_qsize--; \ - } \ - if ( _hs_tail ) { \ - _hs_tail->next = ((_hs_e) ? \ - ELMT_FROM_HH((head)->hh.tbl,_hs_e) : NULL); \ - } else { \ - _hs_list = _hs_e; \ - } \ - _hs_e->prev = ((_hs_tail) ? \ - ELMT_FROM_HH((head)->hh.tbl,_hs_tail) : NULL); \ - _hs_tail = _hs_e; \ - } \ - _hs_p = _hs_q; \ - } \ - _hs_tail->next = NULL; \ - if ( _hs_nmerges <= 1 ) { \ - _hs_looping=0; \ - (head)->hh.tbl->tail = _hs_tail; \ - DECLTYPE_ASSIGN(head,ELMT_FROM_HH((head)->hh.tbl, _hs_list)); \ - } \ - _hs_insize *= 2; \ - } \ - HASH_FSCK(hh,head); \ - } \ -} while (0) +#define HASH_SORT(head, cmpfcn) HASH_SRT(hh, head, cmpfcn) +#define HASH_SRT(hh, head, cmpfcn) \ + do { \ + unsigned _hs_i; \ + unsigned _hs_looping, _hs_nmerges, _hs_insize, _hs_psize, _hs_qsize; \ + struct UT_hash_handle *_hs_p, *_hs_q, *_hs_e, *_hs_list, *_hs_tail; \ + if (head) { \ + _hs_insize = 1; \ + _hs_looping = 1; \ + _hs_list = &((head)->hh); \ + while (_hs_looping) { \ + _hs_p = _hs_list; \ + _hs_list = NULL; \ + _hs_tail = NULL; \ + _hs_nmerges = 0; \ + while (_hs_p) { \ + _hs_nmerges++; \ + _hs_q = _hs_p; \ + _hs_psize = 0; \ + for (_hs_i = 0; _hs_i < _hs_insize; _hs_i++) { \ + _hs_psize++; \ + _hs_q = \ + (UT_hash_handle *)((_hs_q->next) ? ((void *)((char *)(_hs_q->next) + (head)->hh.tbl->hho)) : NULL); \ + if (!(_hs_q)) break; \ + } \ + _hs_qsize = _hs_insize; \ + while ((_hs_psize > 0) || ((_hs_qsize > 0) && _hs_q)) { \ + if (_hs_psize == 0) { \ + _hs_e = _hs_q; \ + _hs_q = (UT_hash_handle *)((_hs_q->next) ? ((void *)((char *)(_hs_q->next) + (head)->hh.tbl->hho)) \ + : NULL); \ + _hs_qsize--; \ + } else if ((_hs_qsize == 0) || !(_hs_q)) { \ + _hs_e = _hs_p; \ + _hs_p = (UT_hash_handle *)((_hs_p->next) ? ((void *)((char *)(_hs_p->next) + (head)->hh.tbl->hho)) \ + : NULL); \ + _hs_psize--; \ + } else if ((cmpfcn(DECLTYPE(head)(ELMT_FROM_HH((head)->hh.tbl, _hs_p)), \ + DECLTYPE(head)(ELMT_FROM_HH((head)->hh.tbl, _hs_q)))) <= 0) { \ + _hs_e = _hs_p; \ + _hs_p = (UT_hash_handle *)((_hs_p->next) ? ((void *)((char *)(_hs_p->next) + (head)->hh.tbl->hho)) \ + : NULL); \ + _hs_psize--; \ + } else { \ + _hs_e = _hs_q; \ + _hs_q = (UT_hash_handle *)((_hs_q->next) ? ((void *)((char *)(_hs_q->next) + (head)->hh.tbl->hho)) \ + : NULL); \ + _hs_qsize--; \ + } \ + if (_hs_tail) { \ + _hs_tail->next = ((_hs_e) ? ELMT_FROM_HH((head)->hh.tbl, _hs_e) : NULL); \ + } else { \ + _hs_list = _hs_e; \ + } \ + _hs_e->prev = ((_hs_tail) ? ELMT_FROM_HH((head)->hh.tbl, _hs_tail) : NULL); \ + _hs_tail = _hs_e; \ + } \ + _hs_p = _hs_q; \ + } \ + _hs_tail->next = NULL; \ + if (_hs_nmerges <= 1) { \ + _hs_looping = 0; \ + (head)->hh.tbl->tail = _hs_tail; \ + DECLTYPE_ASSIGN(head, ELMT_FROM_HH((head)->hh.tbl, _hs_list)); \ + } \ + _hs_insize *= 2; \ + } \ + HASH_FSCK(hh, head); \ + } \ + } while (0) /* This function selects items from one hash into another hash. * The end result is that the selected items have dual presence * in both hashes. There is no copy of the items made; rather * they are added into the new hash through a secondary hash * hash handle that must be present in the structure. */ -#define HASH_SELECT(hh_dst, dst, hh_src, src, cond) \ -do { \ - unsigned _src_bkt, _dst_bkt; \ - void *_last_elt=NULL, *_elt; \ - UT_hash_handle *_src_hh, *_dst_hh, *_last_elt_hh=NULL; \ - ptrdiff_t _dst_hho = ((char*)(&(dst)->hh_dst) - (char*)(dst)); \ - if (src) { \ - for(_src_bkt=0; _src_bkt < (src)->hh_src.tbl->num_buckets; _src_bkt++) { \ - for(_src_hh = (src)->hh_src.tbl->buckets[_src_bkt].hh_head; \ - _src_hh; \ - _src_hh = _src_hh->hh_next) { \ - _elt = ELMT_FROM_HH((src)->hh_src.tbl, _src_hh); \ - if (cond(_elt)) { \ - _dst_hh = (UT_hash_handle*)(((char*)_elt) + _dst_hho); \ - _dst_hh->key = _src_hh->key; \ - _dst_hh->keylen = _src_hh->keylen; \ - _dst_hh->hashv = _src_hh->hashv; \ - _dst_hh->prev = _last_elt; \ - _dst_hh->next = NULL; \ - if (_last_elt_hh) { _last_elt_hh->next = _elt; } \ - if (!dst) { \ - DECLTYPE_ASSIGN(dst,_elt); \ - HASH_MAKE_TABLE(hh_dst,dst); \ - } else { \ - _dst_hh->tbl = (dst)->hh_dst.tbl; \ - } \ - HASH_TO_BKT(_dst_hh->hashv, _dst_hh->tbl->num_buckets, _dst_bkt); \ - HASH_ADD_TO_BKT(_dst_hh->tbl->buckets[_dst_bkt],_dst_hh); \ - (dst)->hh_dst.tbl->num_items++; \ - _last_elt = _elt; \ - _last_elt_hh = _dst_hh; \ - } \ - } \ - } \ - } \ - HASH_FSCK(hh_dst,dst); \ -} while (0) - -#define HASH_CLEAR(hh,head) \ -do { \ - if (head) { \ - uthash_free((head)->hh.tbl->buckets ); \ - uthash_free((head)->hh.tbl); \ - (head)=NULL; \ - } \ -} while(0) +#define HASH_SELECT(hh_dst, dst, hh_src, src, cond) \ + do { \ + unsigned _src_bkt, _dst_bkt; \ + void *_last_elt = NULL, *_elt; \ + UT_hash_handle *_src_hh, *_dst_hh, *_last_elt_hh = NULL; \ + ptrdiff_t _dst_hho = ((char *)(&(dst)->hh_dst) - (char *)(dst)); \ + if (src) { \ + for (_src_bkt = 0; _src_bkt < (src)->hh_src.tbl->num_buckets; _src_bkt++) { \ + for (_src_hh = (src)->hh_src.tbl->buckets[_src_bkt].hh_head; _src_hh; _src_hh = _src_hh->hh_next) { \ + _elt = ELMT_FROM_HH((src)->hh_src.tbl, _src_hh); \ + if (cond(_elt)) { \ + _dst_hh = (UT_hash_handle *)(((char *)_elt) + _dst_hho); \ + _dst_hh->key = _src_hh->key; \ + _dst_hh->keylen = _src_hh->keylen; \ + _dst_hh->hashv = _src_hh->hashv; \ + _dst_hh->prev = _last_elt; \ + _dst_hh->next = NULL; \ + if (_last_elt_hh) { \ + _last_elt_hh->next = _elt; \ + } \ + if (!dst) { \ + DECLTYPE_ASSIGN(dst, _elt); \ + HASH_MAKE_TABLE(hh_dst, dst); \ + } else { \ + _dst_hh->tbl = (dst)->hh_dst.tbl; \ + } \ + HASH_TO_BKT(_dst_hh->hashv, _dst_hh->tbl->num_buckets, _dst_bkt); \ + HASH_ADD_TO_BKT(_dst_hh->tbl->buckets[_dst_bkt], _dst_hh); \ + (dst)->hh_dst.tbl->num_items++; \ + _last_elt = _elt; \ + _last_elt_hh = _dst_hh; \ + } \ + } \ + } \ + } \ + HASH_FSCK(hh_dst, dst); \ + } while (0) + +#define HASH_CLEAR(hh, head) \ + do { \ + if (head) { \ + uthash_free((head)->hh.tbl->buckets); \ + uthash_free((head)->hh.tbl); \ + (head) = NULL; \ + } \ + } while (0) /* obtain a count of items in the hash */ -#define HASH_COUNT(head) HASH_CNT(hh,head) -#define HASH_CNT(hh,head) (head?(head->hh.tbl->num_items):0) +#define HASH_COUNT(head) HASH_CNT(hh, head) +#define HASH_CNT(hh, head) (head ? (head->hh.tbl->num_items) : 0) typedef struct UT_hash_bucket { - struct UT_hash_handle *hh_head; - unsigned count; - - /* expand_mult is normally set to 0. In this situation, the max chain length - * threshold is enforced at its default value, HASH_BKT_CAPACITY_THRESH. (If - * the bucket's chain exceeds this length, bucket expansion is triggered). - * However, setting expand_mult to a non-zero value delays bucket expansion - * (that would be triggered by additions to this particular bucket) - * until its chain length reaches a *multiple* of HASH_BKT_CAPACITY_THRESH. - * (The multiplier is simply expand_mult+1). The whole idea of this - * multiplier is to reduce bucket expansions, since they are expensive, in - * situations where we know that a particular bucket tends to be overused. - * It is better to let its chain length grow to a longer yet-still-bounded - * value, than to do an O(n) bucket expansion too often. - */ - unsigned expand_mult; + struct UT_hash_handle *hh_head; + unsigned count; + + /* expand_mult is normally set to 0. In this situation, the max chain length + * threshold is enforced at its default value, HASH_BKT_CAPACITY_THRESH. (If + * the bucket's chain exceeds this length, bucket expansion is triggered). + * However, setting expand_mult to a non-zero value delays bucket expansion + * (that would be triggered by additions to this particular bucket) + * until its chain length reaches a *multiple* of HASH_BKT_CAPACITY_THRESH. + * (The multiplier is simply expand_mult+1). The whole idea of this + * multiplier is to reduce bucket expansions, since they are expensive, in + * situations where we know that a particular bucket tends to be overused. + * It is better to let its chain length grow to a longer yet-still-bounded + * value, than to do an O(n) bucket expansion too often. + */ + unsigned expand_mult; } UT_hash_bucket; @@ -896,47 +908,47 @@ typedef struct UT_hash_bucket { #define HASH_BLOOM_SIGNATURE 0xb12220f2 typedef struct UT_hash_table { - UT_hash_bucket *buckets; - unsigned num_buckets, log2_num_buckets; - unsigned num_items; - struct UT_hash_handle *tail; /* tail hh in app order, for fast append */ - ptrdiff_t hho; /* hash handle offset (byte pos of hash handle in element */ - - /* in an ideal situation (all buckets used equally), no bucket would have - * more than ceil(#items/#buckets) items. that's the ideal chain length. */ - unsigned ideal_chain_maxlen; - - /* nonideal_items is the number of items in the hash whose chain position - * exceeds the ideal chain maxlen. these items pay the penalty for an uneven - * hash distribution; reaching them in a chain traversal takes >ideal steps */ - unsigned nonideal_items; - - /* ineffective expands occur when a bucket doubling was performed, but - * afterward, more than half the items in the hash had nonideal chain - * positions. If this happens on two consecutive expansions we inhibit any - * further expansion, as it's not helping; this happens when the hash - * function isn't a good fit for the key domain. When expansion is inhibited - * the hash will still work, albeit no longer in constant time. */ - unsigned ineff_expands, noexpand; - - uint32_t signature; /* used only to find hash tables in external analysis */ + UT_hash_bucket *buckets; + unsigned num_buckets, log2_num_buckets; + unsigned num_items; + struct UT_hash_handle *tail; /* tail hh in app order, for fast append */ + ptrdiff_t hho; /* hash handle offset (byte pos of hash handle in element */ + + /* in an ideal situation (all buckets used equally), no bucket would have + * more than ceil(#items/#buckets) items. that's the ideal chain length. */ + unsigned ideal_chain_maxlen; + + /* nonideal_items is the number of items in the hash whose chain position + * exceeds the ideal chain maxlen. these items pay the penalty for an uneven + * hash distribution; reaching them in a chain traversal takes >ideal steps */ + unsigned nonideal_items; + + /* ineffective expands occur when a bucket doubling was performed, but + * afterward, more than half the items in the hash had nonideal chain + * positions. If this happens on two consecutive expansions we inhibit any + * further expansion, as it's not helping; this happens when the hash + * function isn't a good fit for the key domain. When expansion is inhibited + * the hash will still work, albeit no longer in constant time. */ + unsigned ineff_expands, noexpand; + + uint32_t signature; /* used only to find hash tables in external analysis */ #ifdef HASH_BLOOM - uint32_t bloom_sig; /* used only to test bloom exists in external analysis */ - uint8_t *bloom_bv; - char bloom_nbits; + uint32_t bloom_sig; /* used only to test bloom exists in external analysis */ + uint8_t *bloom_bv; + char bloom_nbits; #endif } UT_hash_table; typedef struct UT_hash_handle { - struct UT_hash_table *tbl; - void *prev; /* prev element in app order */ - void *next; /* next element in app order */ - struct UT_hash_handle *hh_prev; /* previous hh in bucket order */ - struct UT_hash_handle *hh_next; /* next hh in bucket order */ - void *key; /* ptr to enclosing struct's key */ - unsigned keylen; /* enclosing struct's key len */ - unsigned hashv; /* result of hash-fcn(key) */ + struct UT_hash_table *tbl; + void *prev; /* prev element in app order */ + void *next; /* next element in app order */ + struct UT_hash_handle *hh_prev; /* previous hh in bucket order */ + struct UT_hash_handle *hh_next; /* next hh in bucket order */ + void *key; /* ptr to enclosing struct's key */ + unsigned keylen; /* enclosing struct's key len */ + unsigned hashv; /* result of hash-fcn(key) */ } UT_hash_handle; #endif /* UTHASH_H */ diff --git a/lib/vk2gl.h b/lib/vk2gl.h index 9b85ffebe5..6d5d1bebe2 100644 --- a/lib/vk2gl.h +++ b/lib/vk2gl.h @@ -22,17 +22,17 @@ #include "GL/glcorearb.h" // These are only in glext.h. -#if !defined( GL_COMPRESSED_SRGB_S3TC_DXT1_EXT ) -#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C +#if !defined(GL_COMPRESSED_SRGB_S3TC_DXT1_EXT) +#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C #endif -#if !defined( GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT ) -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D +#if !defined(GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT) +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D #endif -#if !defined( GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT ) -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E +#if !defined(GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT) +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E #endif -#if !defined( GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT ) -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F +#if !defined(GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT) +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F #endif // These are only in GLES headers not in glcorearb.h or glext.h. @@ -41,92 +41,90 @@ // ETC // -#if !defined( GL_ETC1_RGB8_OES ) -#define GL_ETC1_RGB8_OES 0x8D64 +#if !defined(GL_ETC1_RGB8_OES) +#define GL_ETC1_RGB8_OES 0x8D64 #endif // // PVRTC // -#if !defined( GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG ) -#define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01 -#define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00 -#define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03 -#define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02 +#if !defined(GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG) +#define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01 +#define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00 +#define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03 +#define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02 #endif -#if !defined( GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG ) -#define GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG 0x9137 -#define GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG 0x9138 +#if !defined(GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG) +#define GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG 0x9137 +#define GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG 0x9138 #endif -#if !defined( GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT ) -#define GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT 0x8A54 -#define GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT 0x8A55 -#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT 0x8A56 -#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT 0x8A57 +#if !defined(GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT) +#define GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT 0x8A54 +#define GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT 0x8A55 +#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT 0x8A56 +#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT 0x8A57 #endif -#if !defined( GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV2_IMG ) -#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV2_IMG 0x93F0 -#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV2_IMG 0x93F1 +#if !defined(GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV2_IMG) +#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV2_IMG 0x93F0 +#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV2_IMG 0x93F1 #endif // // ASTC // -#if !defined( GL_COMPRESSED_RGBA_ASTC_3x3x3_OES ) -#define GL_COMPRESSED_RGBA_ASTC_3x3x3_OES 0x93C0 -#define GL_COMPRESSED_RGBA_ASTC_4x3x3_OES 0x93C1 -#define GL_COMPRESSED_RGBA_ASTC_4x4x3_OES 0x93C2 -#define GL_COMPRESSED_RGBA_ASTC_4x4x4_OES 0x93C3 -#define GL_COMPRESSED_RGBA_ASTC_5x4x4_OES 0x93C4 -#define GL_COMPRESSED_RGBA_ASTC_5x5x4_OES 0x93C5 -#define GL_COMPRESSED_RGBA_ASTC_5x5x5_OES 0x93C6 -#define GL_COMPRESSED_RGBA_ASTC_6x5x5_OES 0x93C7 -#define GL_COMPRESSED_RGBA_ASTC_6x6x5_OES 0x93C8 -#define GL_COMPRESSED_RGBA_ASTC_6x6x6_OES 0x93C9 +#if !defined(GL_COMPRESSED_RGBA_ASTC_3x3x3_OES) +#define GL_COMPRESSED_RGBA_ASTC_3x3x3_OES 0x93C0 +#define GL_COMPRESSED_RGBA_ASTC_4x3x3_OES 0x93C1 +#define GL_COMPRESSED_RGBA_ASTC_4x4x3_OES 0x93C2 +#define GL_COMPRESSED_RGBA_ASTC_4x4x4_OES 0x93C3 +#define GL_COMPRESSED_RGBA_ASTC_5x4x4_OES 0x93C4 +#define GL_COMPRESSED_RGBA_ASTC_5x5x4_OES 0x93C5 +#define GL_COMPRESSED_RGBA_ASTC_5x5x5_OES 0x93C6 +#define GL_COMPRESSED_RGBA_ASTC_6x5x5_OES 0x93C7 +#define GL_COMPRESSED_RGBA_ASTC_6x6x5_OES 0x93C8 +#define GL_COMPRESSED_RGBA_ASTC_6x6x6_OES 0x93C9 #endif -#if !defined( GL_COMPRESSED_SRGB8_ALPHA8_ASTC_3x3x3_OES ) -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_3x3x3_OES 0x93E0 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x3x3_OES 0x93E1 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x3_OES 0x93E2 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x4_OES 0x93E3 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4x4_OES 0x93E4 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x4_OES 0x93E5 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x5_OES 0x93E6 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5x5_OES 0x93E7 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x5_OES 0x93E8 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x6_OES 0x93E9 +#if !defined(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_3x3x3_OES) +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_3x3x3_OES 0x93E0 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x3x3_OES 0x93E1 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x3_OES 0x93E2 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x4_OES 0x93E3 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4x4_OES 0x93E4 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x4_OES 0x93E5 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x5_OES 0x93E6 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5x5_OES 0x93E7 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x5_OES 0x93E8 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x6_OES 0x93E9 #endif -static inline GLenum vkFormat2glInternalFormat( VkFormat vkFormat ) -{ - switch ( vkFormat ) - { +static inline GLenum +vkFormat2glInternalFormat(VkFormat vkFormat) { + switch (vkFormat) { #include "vkFormat2glInternalFormat.inl" - default: return GL_INVALID_VALUE; + default: + return GL_INVALID_VALUE; } } - -static inline GLenum vkFormat2glFormat( VkFormat vkFormat ) -{ - switch ( vkFormat ) - { +static inline GLenum +vkFormat2glFormat(VkFormat vkFormat) { + switch (vkFormat) { #include "vkFormat2glFormat.inl" - default: return GL_INVALID_VALUE; + default: + return GL_INVALID_VALUE; } } -static inline GLenum vkFormat2glType( VkFormat vkFormat ) -{ - switch ( vkFormat ) - { +static inline GLenum +vkFormat2glType(VkFormat vkFormat) { + switch (vkFormat) { #include "vkFormat2glType.inl" - default: return GL_INVALID_VALUE; + default: + return GL_INVALID_VALUE; } } #endif /* _VK2GL_H_ */ - diff --git a/lib/vk_format.h b/lib/vk_format.h index ab8a1ecbb6..841f32e283 100644 --- a/lib/vk_format.h +++ b/lib/vk_format.h @@ -27,23 +27,23 @@ The functions in this header file convert the format, internalFormat and type that are used as parameters to the following OpenGL functions: void glTexImage2D( GLenum target, GLint level, GLint internalFormat, - GLsizei width, GLsizei height, GLint border, - GLenum format, GLenum type, const GLvoid * data ); + GLsizei width, GLsizei height, GLint border, + GLenum format, GLenum type, const GLvoid * data ); void glTexImage3D( GLenum target, GLint level, GLint internalFormat, - GLsizei width, GLsizei height, GLsizei depth, GLint border, - GLenum format, GLenum type, const GLvoid * data ); + GLsizei width, GLsizei height, GLsizei depth, GLint border, + GLenum format, GLenum type, const GLvoid * data ); void glCompressedTexImage2D( GLenum target, GLint level, GLenum internalformat, - GLsizei width, GLsizei height, GLint border, - GLsizei imageSize, const GLvoid * data ); + GLsizei width, GLsizei height, GLint border, + GLsizei imageSize, const GLvoid * data ); void glCompressedTexImage3D( GLenum target, GLint level, GLenum internalformat, - GLsizei width, GLsizei height, GLsizei depth, GLint border, - GLsizei imageSize, const GLvoid * data ); + GLsizei width, GLsizei height, GLsizei depth, GLint border, + GLsizei imageSize, const GLvoid * data ); void glTexStorage2D( GLenum target, GLsizei levels, GLenum internalformat, - GLsizei width, GLsizei height ); + GLsizei width, GLsizei height ); void glTexStorage3D( GLenum target, GLsizei levels, GLenum internalformat, - GLsizei width, GLsizei height, GLsizei depth ); + GLsizei width, GLsizei height, GLsizei depth ); void glVertexAttribPointer( GLuint index, GLint size, GLenum type, GLboolean normalized, - GLsizei stride, const GLvoid * pointer); + GLsizei stride, const GLvoid * pointer); IMPLEMENTATION @@ -77,1316 +77,1679 @@ MODIFICATIONS for use in libktx ================================================================================================ */ -#if !defined( VK_FORMAT_H ) +#if !defined(VK_FORMAT_H) #define VK_FORMAT_H #include "gl_format.h" -static inline VkFormat vkGetFormatFromOpenGLFormat( const GLenum format, const GLenum type ) -{ - switch ( type ) - { - // - // 8 bits per component - // - case GL_UNSIGNED_BYTE: - { - switch ( format ) - { - case GL_RED: return VK_FORMAT_R8_UNORM; - case GL_RG: return VK_FORMAT_R8G8_UNORM; - case GL_RGB: return VK_FORMAT_R8G8B8_UNORM; - case GL_BGR: return VK_FORMAT_B8G8R8_UNORM; - case GL_RGBA: return VK_FORMAT_R8G8B8A8_UNORM; - case GL_BGRA: return VK_FORMAT_B8G8R8A8_UNORM; - case GL_RED_INTEGER: return VK_FORMAT_R8_UINT; - case GL_RG_INTEGER: return VK_FORMAT_R8G8_UINT; - case GL_RGB_INTEGER: return VK_FORMAT_R8G8B8_UINT; - case GL_BGR_INTEGER: return VK_FORMAT_B8G8R8_UINT; - case GL_RGBA_INTEGER: return VK_FORMAT_R8G8B8A8_UINT; - case GL_BGRA_INTEGER: return VK_FORMAT_B8G8R8A8_UINT; - case GL_STENCIL_INDEX: return VK_FORMAT_S8_UINT; - case GL_DEPTH_COMPONENT: return VK_FORMAT_UNDEFINED; - case GL_DEPTH_STENCIL: return VK_FORMAT_UNDEFINED; - } - break; - } - case GL_BYTE: - { - switch ( format ) - { - case GL_RED: return VK_FORMAT_R8_SNORM; - case GL_RG: return VK_FORMAT_R8G8_SNORM; - case GL_RGB: return VK_FORMAT_R8G8B8_SNORM; - case GL_BGR: return VK_FORMAT_B8G8R8_SNORM; - case GL_RGBA: return VK_FORMAT_R8G8B8A8_SNORM; - case GL_BGRA: return VK_FORMAT_B8G8R8A8_SNORM; - case GL_RED_INTEGER: return VK_FORMAT_R8_SINT; - case GL_RG_INTEGER: return VK_FORMAT_R8G8_SINT; - case GL_RGB_INTEGER: return VK_FORMAT_R8G8B8_SINT; - case GL_BGR_INTEGER: return VK_FORMAT_B8G8R8_SINT; - case GL_RGBA_INTEGER: return VK_FORMAT_R8G8B8A8_SINT; - case GL_BGRA_INTEGER: return VK_FORMAT_B8G8R8A8_SINT; - case GL_STENCIL_INDEX: return VK_FORMAT_UNDEFINED; - case GL_DEPTH_COMPONENT: return VK_FORMAT_UNDEFINED; - case GL_DEPTH_STENCIL: return VK_FORMAT_UNDEFINED; - } - break; - } - - // - // 16 bits per component - // - case GL_UNSIGNED_SHORT: - { - switch ( format ) - { - case GL_RED: return VK_FORMAT_R16_UNORM; - case GL_RG: return VK_FORMAT_R16G16_UNORM; - case GL_RGB: return VK_FORMAT_R16G16B16_UNORM; - case GL_BGR: return VK_FORMAT_UNDEFINED; - case GL_RGBA: return VK_FORMAT_R16G16B16A16_UNORM; - case GL_BGRA: return VK_FORMAT_UNDEFINED; - case GL_RED_INTEGER: return VK_FORMAT_R16_UINT; - case GL_RG_INTEGER: return VK_FORMAT_R16G16_UINT; - case GL_RGB_INTEGER: return VK_FORMAT_R16G16B16_UINT; - case GL_BGR_INTEGER: return VK_FORMAT_UNDEFINED; - case GL_RGBA_INTEGER: return VK_FORMAT_R16G16B16A16_UINT; - case GL_BGRA_INTEGER: return VK_FORMAT_UNDEFINED; - case GL_STENCIL_INDEX: return VK_FORMAT_UNDEFINED; - case GL_DEPTH_COMPONENT: return VK_FORMAT_D16_UNORM; - case GL_DEPTH_STENCIL: return VK_FORMAT_D16_UNORM_S8_UINT; - } - break; - } - case GL_SHORT: - { - switch ( format ) - { - case GL_RED: return VK_FORMAT_R16_SNORM; - case GL_RG: return VK_FORMAT_R16G16_SNORM; - case GL_RGB: return VK_FORMAT_R16G16B16_SNORM; - case GL_BGR: return VK_FORMAT_UNDEFINED; - case GL_RGBA: return VK_FORMAT_R16G16B16A16_SNORM; - case GL_BGRA: return VK_FORMAT_UNDEFINED; - case GL_RED_INTEGER: return VK_FORMAT_R16_SINT; - case GL_RG_INTEGER: return VK_FORMAT_R16G16_SINT; - case GL_RGB_INTEGER: return VK_FORMAT_R16G16B16_SINT; - case GL_BGR_INTEGER: return VK_FORMAT_UNDEFINED; - case GL_RGBA_INTEGER: return VK_FORMAT_R16G16B16A16_SINT; - case GL_BGRA_INTEGER: return VK_FORMAT_UNDEFINED; - case GL_STENCIL_INDEX: return VK_FORMAT_UNDEFINED; - case GL_DEPTH_COMPONENT: return VK_FORMAT_UNDEFINED; - case GL_DEPTH_STENCIL: return VK_FORMAT_UNDEFINED; - } - break; - } - case GL_HALF_FLOAT: - case GL_HALF_FLOAT_OES: - { - switch ( format ) - { - case GL_RED: return VK_FORMAT_R16_SFLOAT; - case GL_RG: return VK_FORMAT_R16G16_SFLOAT; - case GL_RGB: return VK_FORMAT_R16G16B16_SFLOAT; - case GL_BGR: return VK_FORMAT_UNDEFINED; - case GL_RGBA: return VK_FORMAT_R16G16B16A16_SFLOAT; - case GL_BGRA: return VK_FORMAT_UNDEFINED; - case GL_RED_INTEGER: return VK_FORMAT_UNDEFINED; - case GL_RG_INTEGER: return VK_FORMAT_UNDEFINED; - case GL_RGB_INTEGER: return VK_FORMAT_UNDEFINED; - case GL_BGR_INTEGER: return VK_FORMAT_UNDEFINED; - case GL_RGBA_INTEGER: return VK_FORMAT_UNDEFINED; - case GL_BGRA_INTEGER: return VK_FORMAT_UNDEFINED; - case GL_STENCIL_INDEX: return VK_FORMAT_UNDEFINED; - case GL_DEPTH_COMPONENT: return VK_FORMAT_UNDEFINED; - case GL_DEPTH_STENCIL: return VK_FORMAT_UNDEFINED; - } - break; - } - - // - // 32 bits per component - // - case GL_UNSIGNED_INT: - { - switch ( format ) - { - case GL_RED: return VK_FORMAT_R32_UINT; - case GL_RG: return VK_FORMAT_R32G32_UINT; - case GL_RGB: return VK_FORMAT_R32G32B32_UINT; - case GL_BGR: return VK_FORMAT_UNDEFINED; - case GL_RGBA: return VK_FORMAT_R32G32B32A32_UINT; - case GL_BGRA: return VK_FORMAT_UNDEFINED; - case GL_RED_INTEGER: return VK_FORMAT_R32_UINT; - case GL_RG_INTEGER: return VK_FORMAT_R32G32_UINT; - case GL_RGB_INTEGER: return VK_FORMAT_R32G32B32_UINT; - case GL_BGR_INTEGER: return VK_FORMAT_UNDEFINED; - case GL_RGBA_INTEGER: return VK_FORMAT_R32G32B32A32_UINT; - case GL_BGRA_INTEGER: return VK_FORMAT_UNDEFINED; - case GL_STENCIL_INDEX: return VK_FORMAT_UNDEFINED; - case GL_DEPTH_COMPONENT: return VK_FORMAT_X8_D24_UNORM_PACK32; - case GL_DEPTH_STENCIL: return VK_FORMAT_D24_UNORM_S8_UINT; - } - break; - } - case GL_INT: - { - switch ( format ) - { - case GL_RED: return VK_FORMAT_R32_SINT; - case GL_RG: return VK_FORMAT_R32G32_SINT; - case GL_RGB: return VK_FORMAT_R32G32B32_SINT; - case GL_BGR: return VK_FORMAT_UNDEFINED; - case GL_RGBA: return VK_FORMAT_R32G32B32A32_SINT; - case GL_BGRA: return VK_FORMAT_UNDEFINED; - case GL_RED_INTEGER: return VK_FORMAT_R32_SINT; - case GL_RG_INTEGER: return VK_FORMAT_R32G32_SINT; - case GL_RGB_INTEGER: return VK_FORMAT_R32G32B32_SINT; - case GL_BGR_INTEGER: return VK_FORMAT_UNDEFINED; - case GL_RGBA_INTEGER: return VK_FORMAT_R32G32B32A32_SINT; - case GL_BGRA_INTEGER: return VK_FORMAT_UNDEFINED; - case GL_STENCIL_INDEX: return VK_FORMAT_UNDEFINED; - case GL_DEPTH_COMPONENT: return VK_FORMAT_UNDEFINED; - case GL_DEPTH_STENCIL: return VK_FORMAT_UNDEFINED; - } - break; - } - case GL_FLOAT: - { - switch ( format ) - { - case GL_RED: return VK_FORMAT_R32_SFLOAT; - case GL_RG: return VK_FORMAT_R32G32_SFLOAT; - case GL_RGB: return VK_FORMAT_R32G32B32_SFLOAT; - case GL_BGR: return VK_FORMAT_UNDEFINED; - case GL_RGBA: return VK_FORMAT_R32G32B32A32_SFLOAT; - case GL_BGRA: return VK_FORMAT_UNDEFINED; - case GL_RED_INTEGER: return VK_FORMAT_UNDEFINED; - case GL_RG_INTEGER: return VK_FORMAT_UNDEFINED; - case GL_RGB_INTEGER: return VK_FORMAT_UNDEFINED; - case GL_BGR_INTEGER: return VK_FORMAT_UNDEFINED; - case GL_RGBA_INTEGER: return VK_FORMAT_UNDEFINED; - case GL_BGRA_INTEGER: return VK_FORMAT_UNDEFINED; - case GL_STENCIL_INDEX: return VK_FORMAT_UNDEFINED; - case GL_DEPTH_COMPONENT: return VK_FORMAT_D32_SFLOAT; - case GL_DEPTH_STENCIL: return VK_FORMAT_D32_SFLOAT_S8_UINT; - } - break; - } - - // - // 64 bits per component - // - case GL_UNSIGNED_INT64: - { - switch ( format ) - { - case GL_RED: return VK_FORMAT_R64_UINT; - case GL_RG: return VK_FORMAT_R64G64_UINT; - case GL_RGB: return VK_FORMAT_R64G64B64_UINT; - case GL_BGR: return VK_FORMAT_UNDEFINED; - case GL_RGBA: return VK_FORMAT_R64G64B64A64_UINT; - case GL_BGRA: return VK_FORMAT_UNDEFINED; - case GL_RED_INTEGER: return VK_FORMAT_UNDEFINED; - case GL_RG_INTEGER: return VK_FORMAT_UNDEFINED; - case GL_RGB_INTEGER: return VK_FORMAT_UNDEFINED; - case GL_BGR_INTEGER: return VK_FORMAT_UNDEFINED; - case GL_RGBA_INTEGER: return VK_FORMAT_UNDEFINED; - case GL_BGRA_INTEGER: return VK_FORMAT_UNDEFINED; - case GL_STENCIL_INDEX: return VK_FORMAT_UNDEFINED; - case GL_DEPTH_COMPONENT: return VK_FORMAT_UNDEFINED; - case GL_DEPTH_STENCIL: return VK_FORMAT_UNDEFINED; - } - break; - } - case GL_INT64: - { - switch ( format ) - { - case GL_RED: return VK_FORMAT_R64_SINT; - case GL_RG: return VK_FORMAT_R64G64_SINT; - case GL_RGB: return VK_FORMAT_R64G64B64_SINT; - case GL_BGR: return VK_FORMAT_UNDEFINED; - case GL_RGBA: return VK_FORMAT_R64G64B64A64_SINT; - case GL_BGRA: return VK_FORMAT_UNDEFINED; - case GL_RED_INTEGER: return VK_FORMAT_R64_SINT; - case GL_RG_INTEGER: return VK_FORMAT_R64G64_SINT; - case GL_RGB_INTEGER: return VK_FORMAT_R64G64B64_SINT; - case GL_BGR_INTEGER: return VK_FORMAT_UNDEFINED; - case GL_RGBA_INTEGER: return VK_FORMAT_R64G64B64A64_SINT; - case GL_BGRA_INTEGER: return VK_FORMAT_UNDEFINED; - case GL_STENCIL_INDEX: return VK_FORMAT_UNDEFINED; - case GL_DEPTH_COMPONENT: return VK_FORMAT_UNDEFINED; - case GL_DEPTH_STENCIL: return VK_FORMAT_UNDEFINED; - } - break; - } - case GL_DOUBLE: - { - switch ( format ) - { - case GL_RED: return VK_FORMAT_R64_SFLOAT; - case GL_RG: return VK_FORMAT_R64G64_SFLOAT; - case GL_RGB: return VK_FORMAT_R64G64B64_SFLOAT; - case GL_BGR: return VK_FORMAT_UNDEFINED; - case GL_RGBA: return VK_FORMAT_R64G64B64A64_SFLOAT; - case GL_BGRA: return VK_FORMAT_UNDEFINED; - case GL_RED_INTEGER: return VK_FORMAT_R64_SFLOAT; - case GL_RG_INTEGER: return VK_FORMAT_R64G64_SFLOAT; - case GL_RGB_INTEGER: return VK_FORMAT_R64G64B64_SFLOAT; - case GL_BGR_INTEGER: return VK_FORMAT_UNDEFINED; - case GL_RGBA_INTEGER: return VK_FORMAT_R64G64B64A64_SFLOAT; - case GL_BGRA_INTEGER: return VK_FORMAT_UNDEFINED; - case GL_STENCIL_INDEX: return VK_FORMAT_UNDEFINED; - case GL_DEPTH_COMPONENT: return VK_FORMAT_UNDEFINED; - case GL_DEPTH_STENCIL: return VK_FORMAT_UNDEFINED; - } - break; - } - - // - // Packed - // - case GL_UNSIGNED_BYTE_3_3_2: - assert( format == GL_RGB || format == GL_RGB_INTEGER ); - return VK_FORMAT_UNDEFINED; - case GL_UNSIGNED_BYTE_2_3_3_REV: - assert( format == GL_BGR || format == GL_BGR_INTEGER ); - return VK_FORMAT_UNDEFINED; - case GL_UNSIGNED_SHORT_5_6_5: - assert( format == GL_RGB || format == GL_RGB_INTEGER ); - return VK_FORMAT_R5G6B5_UNORM_PACK16; - case GL_UNSIGNED_SHORT_5_6_5_REV: - assert( format == GL_BGR || format == GL_BGR_INTEGER ); - return VK_FORMAT_B5G6R5_UNORM_PACK16; - case GL_UNSIGNED_SHORT_4_4_4_4: - assert( format == GL_RGB || format == GL_BGRA || format == GL_RGB_INTEGER || format == GL_BGRA_INTEGER ); - return VK_FORMAT_R4G4B4A4_UNORM_PACK16; - case GL_UNSIGNED_SHORT_4_4_4_4_REV: - assert( format == GL_RGB || format == GL_BGRA || format == GL_RGB_INTEGER || format == GL_BGRA_INTEGER ); - return VK_FORMAT_B4G4R4A4_UNORM_PACK16; - case GL_UNSIGNED_SHORT_5_5_5_1: - assert( format == GL_RGB || format == GL_BGRA || format == GL_RGB_INTEGER || format == GL_BGRA_INTEGER ); - return VK_FORMAT_R5G5B5A1_UNORM_PACK16; - case GL_UNSIGNED_SHORT_1_5_5_5_REV: - assert( format == GL_RGB || format == GL_BGRA || format == GL_RGB_INTEGER || format == GL_BGRA_INTEGER ); - return VK_FORMAT_A1R5G5B5_UNORM_PACK16; - case GL_UNSIGNED_INT_8_8_8_8: - assert( format == GL_RGB || format == GL_BGRA || format == GL_RGB_INTEGER || format == GL_BGRA_INTEGER ); - return ( format == GL_RGB_INTEGER || format == GL_BGRA_INTEGER ) ? VK_FORMAT_R8G8B8A8_UINT : VK_FORMAT_R8G8B8A8_UNORM; - case GL_UNSIGNED_INT_8_8_8_8_REV: - assert( format == GL_RGB || format == GL_BGRA || format == GL_RGB_INTEGER || format == GL_BGRA_INTEGER ); - return ( format == GL_RGB_INTEGER || format == GL_BGRA_INTEGER ) ? VK_FORMAT_A8B8G8R8_UINT_PACK32 : VK_FORMAT_A8B8G8R8_UNORM_PACK32; - case GL_UNSIGNED_INT_10_10_10_2: - assert( format == GL_RGB || format == GL_BGRA || format == GL_RGB_INTEGER || format == GL_BGRA_INTEGER ); - return ( format == GL_RGB_INTEGER || format == GL_BGRA_INTEGER ) ? VK_FORMAT_A2R10G10B10_UINT_PACK32 : VK_FORMAT_A2R10G10B10_UNORM_PACK32; - case GL_UNSIGNED_INT_2_10_10_10_REV: - assert( format == GL_RGB || format == GL_BGRA || format == GL_RGB_INTEGER || format == GL_BGRA_INTEGER ); - return ( format == GL_RGB_INTEGER || format == GL_BGRA_INTEGER ) ? VK_FORMAT_A2B10G10R10_UINT_PACK32 : VK_FORMAT_A2B10G10R10_UNORM_PACK32; - case GL_UNSIGNED_INT_10F_11F_11F_REV: - assert( format == GL_RGB || format == GL_BGR ); - return VK_FORMAT_B10G11R11_UFLOAT_PACK32; - case GL_UNSIGNED_INT_5_9_9_9_REV: - assert( format == GL_RGB || format == GL_BGR ); - return VK_FORMAT_E5B9G9R9_UFLOAT_PACK32; - case GL_UNSIGNED_INT_24_8: - assert( format == GL_DEPTH_STENCIL ); - return VK_FORMAT_D24_UNORM_S8_UINT; - case GL_FLOAT_32_UNSIGNED_INT_24_8_REV: - assert( format == GL_DEPTH_STENCIL ); - return VK_FORMAT_D32_SFLOAT_S8_UINT; - } - - return VK_FORMAT_UNDEFINED; +static inline VkFormat +vkGetFormatFromOpenGLFormat(const GLenum format, const GLenum type) { + switch (type) { + // + // 8 bits per component + // + case GL_UNSIGNED_BYTE: { + switch (format) { + case GL_RED: + return VK_FORMAT_R8_UNORM; + case GL_RG: + return VK_FORMAT_R8G8_UNORM; + case GL_RGB: + return VK_FORMAT_R8G8B8_UNORM; + case GL_BGR: + return VK_FORMAT_B8G8R8_UNORM; + case GL_RGBA: + return VK_FORMAT_R8G8B8A8_UNORM; + case GL_BGRA: + return VK_FORMAT_B8G8R8A8_UNORM; + case GL_RED_INTEGER: + return VK_FORMAT_R8_UINT; + case GL_RG_INTEGER: + return VK_FORMAT_R8G8_UINT; + case GL_RGB_INTEGER: + return VK_FORMAT_R8G8B8_UINT; + case GL_BGR_INTEGER: + return VK_FORMAT_B8G8R8_UINT; + case GL_RGBA_INTEGER: + return VK_FORMAT_R8G8B8A8_UINT; + case GL_BGRA_INTEGER: + return VK_FORMAT_B8G8R8A8_UINT; + case GL_STENCIL_INDEX: + return VK_FORMAT_S8_UINT; + case GL_DEPTH_COMPONENT: + return VK_FORMAT_UNDEFINED; + case GL_DEPTH_STENCIL: + return VK_FORMAT_UNDEFINED; + } + break; + } + case GL_BYTE: { + switch (format) { + case GL_RED: + return VK_FORMAT_R8_SNORM; + case GL_RG: + return VK_FORMAT_R8G8_SNORM; + case GL_RGB: + return VK_FORMAT_R8G8B8_SNORM; + case GL_BGR: + return VK_FORMAT_B8G8R8_SNORM; + case GL_RGBA: + return VK_FORMAT_R8G8B8A8_SNORM; + case GL_BGRA: + return VK_FORMAT_B8G8R8A8_SNORM; + case GL_RED_INTEGER: + return VK_FORMAT_R8_SINT; + case GL_RG_INTEGER: + return VK_FORMAT_R8G8_SINT; + case GL_RGB_INTEGER: + return VK_FORMAT_R8G8B8_SINT; + case GL_BGR_INTEGER: + return VK_FORMAT_B8G8R8_SINT; + case GL_RGBA_INTEGER: + return VK_FORMAT_R8G8B8A8_SINT; + case GL_BGRA_INTEGER: + return VK_FORMAT_B8G8R8A8_SINT; + case GL_STENCIL_INDEX: + return VK_FORMAT_UNDEFINED; + case GL_DEPTH_COMPONENT: + return VK_FORMAT_UNDEFINED; + case GL_DEPTH_STENCIL: + return VK_FORMAT_UNDEFINED; + } + break; + } + + // + // 16 bits per component + // + case GL_UNSIGNED_SHORT: { + switch (format) { + case GL_RED: + return VK_FORMAT_R16_UNORM; + case GL_RG: + return VK_FORMAT_R16G16_UNORM; + case GL_RGB: + return VK_FORMAT_R16G16B16_UNORM; + case GL_BGR: + return VK_FORMAT_UNDEFINED; + case GL_RGBA: + return VK_FORMAT_R16G16B16A16_UNORM; + case GL_BGRA: + return VK_FORMAT_UNDEFINED; + case GL_RED_INTEGER: + return VK_FORMAT_R16_UINT; + case GL_RG_INTEGER: + return VK_FORMAT_R16G16_UINT; + case GL_RGB_INTEGER: + return VK_FORMAT_R16G16B16_UINT; + case GL_BGR_INTEGER: + return VK_FORMAT_UNDEFINED; + case GL_RGBA_INTEGER: + return VK_FORMAT_R16G16B16A16_UINT; + case GL_BGRA_INTEGER: + return VK_FORMAT_UNDEFINED; + case GL_STENCIL_INDEX: + return VK_FORMAT_UNDEFINED; + case GL_DEPTH_COMPONENT: + return VK_FORMAT_D16_UNORM; + case GL_DEPTH_STENCIL: + return VK_FORMAT_D16_UNORM_S8_UINT; + } + break; + } + case GL_SHORT: { + switch (format) { + case GL_RED: + return VK_FORMAT_R16_SNORM; + case GL_RG: + return VK_FORMAT_R16G16_SNORM; + case GL_RGB: + return VK_FORMAT_R16G16B16_SNORM; + case GL_BGR: + return VK_FORMAT_UNDEFINED; + case GL_RGBA: + return VK_FORMAT_R16G16B16A16_SNORM; + case GL_BGRA: + return VK_FORMAT_UNDEFINED; + case GL_RED_INTEGER: + return VK_FORMAT_R16_SINT; + case GL_RG_INTEGER: + return VK_FORMAT_R16G16_SINT; + case GL_RGB_INTEGER: + return VK_FORMAT_R16G16B16_SINT; + case GL_BGR_INTEGER: + return VK_FORMAT_UNDEFINED; + case GL_RGBA_INTEGER: + return VK_FORMAT_R16G16B16A16_SINT; + case GL_BGRA_INTEGER: + return VK_FORMAT_UNDEFINED; + case GL_STENCIL_INDEX: + return VK_FORMAT_UNDEFINED; + case GL_DEPTH_COMPONENT: + return VK_FORMAT_UNDEFINED; + case GL_DEPTH_STENCIL: + return VK_FORMAT_UNDEFINED; + } + break; + } + case GL_HALF_FLOAT: + case GL_HALF_FLOAT_OES: { + switch (format) { + case GL_RED: + return VK_FORMAT_R16_SFLOAT; + case GL_RG: + return VK_FORMAT_R16G16_SFLOAT; + case GL_RGB: + return VK_FORMAT_R16G16B16_SFLOAT; + case GL_BGR: + return VK_FORMAT_UNDEFINED; + case GL_RGBA: + return VK_FORMAT_R16G16B16A16_SFLOAT; + case GL_BGRA: + return VK_FORMAT_UNDEFINED; + case GL_RED_INTEGER: + return VK_FORMAT_UNDEFINED; + case GL_RG_INTEGER: + return VK_FORMAT_UNDEFINED; + case GL_RGB_INTEGER: + return VK_FORMAT_UNDEFINED; + case GL_BGR_INTEGER: + return VK_FORMAT_UNDEFINED; + case GL_RGBA_INTEGER: + return VK_FORMAT_UNDEFINED; + case GL_BGRA_INTEGER: + return VK_FORMAT_UNDEFINED; + case GL_STENCIL_INDEX: + return VK_FORMAT_UNDEFINED; + case GL_DEPTH_COMPONENT: + return VK_FORMAT_UNDEFINED; + case GL_DEPTH_STENCIL: + return VK_FORMAT_UNDEFINED; + } + break; + } + + // + // 32 bits per component + // + case GL_UNSIGNED_INT: { + switch (format) { + case GL_RED: + return VK_FORMAT_R32_UINT; + case GL_RG: + return VK_FORMAT_R32G32_UINT; + case GL_RGB: + return VK_FORMAT_R32G32B32_UINT; + case GL_BGR: + return VK_FORMAT_UNDEFINED; + case GL_RGBA: + return VK_FORMAT_R32G32B32A32_UINT; + case GL_BGRA: + return VK_FORMAT_UNDEFINED; + case GL_RED_INTEGER: + return VK_FORMAT_R32_UINT; + case GL_RG_INTEGER: + return VK_FORMAT_R32G32_UINT; + case GL_RGB_INTEGER: + return VK_FORMAT_R32G32B32_UINT; + case GL_BGR_INTEGER: + return VK_FORMAT_UNDEFINED; + case GL_RGBA_INTEGER: + return VK_FORMAT_R32G32B32A32_UINT; + case GL_BGRA_INTEGER: + return VK_FORMAT_UNDEFINED; + case GL_STENCIL_INDEX: + return VK_FORMAT_UNDEFINED; + case GL_DEPTH_COMPONENT: + return VK_FORMAT_X8_D24_UNORM_PACK32; + case GL_DEPTH_STENCIL: + return VK_FORMAT_D24_UNORM_S8_UINT; + } + break; + } + case GL_INT: { + switch (format) { + case GL_RED: + return VK_FORMAT_R32_SINT; + case GL_RG: + return VK_FORMAT_R32G32_SINT; + case GL_RGB: + return VK_FORMAT_R32G32B32_SINT; + case GL_BGR: + return VK_FORMAT_UNDEFINED; + case GL_RGBA: + return VK_FORMAT_R32G32B32A32_SINT; + case GL_BGRA: + return VK_FORMAT_UNDEFINED; + case GL_RED_INTEGER: + return VK_FORMAT_R32_SINT; + case GL_RG_INTEGER: + return VK_FORMAT_R32G32_SINT; + case GL_RGB_INTEGER: + return VK_FORMAT_R32G32B32_SINT; + case GL_BGR_INTEGER: + return VK_FORMAT_UNDEFINED; + case GL_RGBA_INTEGER: + return VK_FORMAT_R32G32B32A32_SINT; + case GL_BGRA_INTEGER: + return VK_FORMAT_UNDEFINED; + case GL_STENCIL_INDEX: + return VK_FORMAT_UNDEFINED; + case GL_DEPTH_COMPONENT: + return VK_FORMAT_UNDEFINED; + case GL_DEPTH_STENCIL: + return VK_FORMAT_UNDEFINED; + } + break; + } + case GL_FLOAT: { + switch (format) { + case GL_RED: + return VK_FORMAT_R32_SFLOAT; + case GL_RG: + return VK_FORMAT_R32G32_SFLOAT; + case GL_RGB: + return VK_FORMAT_R32G32B32_SFLOAT; + case GL_BGR: + return VK_FORMAT_UNDEFINED; + case GL_RGBA: + return VK_FORMAT_R32G32B32A32_SFLOAT; + case GL_BGRA: + return VK_FORMAT_UNDEFINED; + case GL_RED_INTEGER: + return VK_FORMAT_UNDEFINED; + case GL_RG_INTEGER: + return VK_FORMAT_UNDEFINED; + case GL_RGB_INTEGER: + return VK_FORMAT_UNDEFINED; + case GL_BGR_INTEGER: + return VK_FORMAT_UNDEFINED; + case GL_RGBA_INTEGER: + return VK_FORMAT_UNDEFINED; + case GL_BGRA_INTEGER: + return VK_FORMAT_UNDEFINED; + case GL_STENCIL_INDEX: + return VK_FORMAT_UNDEFINED; + case GL_DEPTH_COMPONENT: + return VK_FORMAT_D32_SFLOAT; + case GL_DEPTH_STENCIL: + return VK_FORMAT_D32_SFLOAT_S8_UINT; + } + break; + } + + // + // 64 bits per component + // + case GL_UNSIGNED_INT64: { + switch (format) { + case GL_RED: + return VK_FORMAT_R64_UINT; + case GL_RG: + return VK_FORMAT_R64G64_UINT; + case GL_RGB: + return VK_FORMAT_R64G64B64_UINT; + case GL_BGR: + return VK_FORMAT_UNDEFINED; + case GL_RGBA: + return VK_FORMAT_R64G64B64A64_UINT; + case GL_BGRA: + return VK_FORMAT_UNDEFINED; + case GL_RED_INTEGER: + return VK_FORMAT_UNDEFINED; + case GL_RG_INTEGER: + return VK_FORMAT_UNDEFINED; + case GL_RGB_INTEGER: + return VK_FORMAT_UNDEFINED; + case GL_BGR_INTEGER: + return VK_FORMAT_UNDEFINED; + case GL_RGBA_INTEGER: + return VK_FORMAT_UNDEFINED; + case GL_BGRA_INTEGER: + return VK_FORMAT_UNDEFINED; + case GL_STENCIL_INDEX: + return VK_FORMAT_UNDEFINED; + case GL_DEPTH_COMPONENT: + return VK_FORMAT_UNDEFINED; + case GL_DEPTH_STENCIL: + return VK_FORMAT_UNDEFINED; + } + break; + } + case GL_INT64: { + switch (format) { + case GL_RED: + return VK_FORMAT_R64_SINT; + case GL_RG: + return VK_FORMAT_R64G64_SINT; + case GL_RGB: + return VK_FORMAT_R64G64B64_SINT; + case GL_BGR: + return VK_FORMAT_UNDEFINED; + case GL_RGBA: + return VK_FORMAT_R64G64B64A64_SINT; + case GL_BGRA: + return VK_FORMAT_UNDEFINED; + case GL_RED_INTEGER: + return VK_FORMAT_R64_SINT; + case GL_RG_INTEGER: + return VK_FORMAT_R64G64_SINT; + case GL_RGB_INTEGER: + return VK_FORMAT_R64G64B64_SINT; + case GL_BGR_INTEGER: + return VK_FORMAT_UNDEFINED; + case GL_RGBA_INTEGER: + return VK_FORMAT_R64G64B64A64_SINT; + case GL_BGRA_INTEGER: + return VK_FORMAT_UNDEFINED; + case GL_STENCIL_INDEX: + return VK_FORMAT_UNDEFINED; + case GL_DEPTH_COMPONENT: + return VK_FORMAT_UNDEFINED; + case GL_DEPTH_STENCIL: + return VK_FORMAT_UNDEFINED; + } + break; + } + case GL_DOUBLE: { + switch (format) { + case GL_RED: + return VK_FORMAT_R64_SFLOAT; + case GL_RG: + return VK_FORMAT_R64G64_SFLOAT; + case GL_RGB: + return VK_FORMAT_R64G64B64_SFLOAT; + case GL_BGR: + return VK_FORMAT_UNDEFINED; + case GL_RGBA: + return VK_FORMAT_R64G64B64A64_SFLOAT; + case GL_BGRA: + return VK_FORMAT_UNDEFINED; + case GL_RED_INTEGER: + return VK_FORMAT_R64_SFLOAT; + case GL_RG_INTEGER: + return VK_FORMAT_R64G64_SFLOAT; + case GL_RGB_INTEGER: + return VK_FORMAT_R64G64B64_SFLOAT; + case GL_BGR_INTEGER: + return VK_FORMAT_UNDEFINED; + case GL_RGBA_INTEGER: + return VK_FORMAT_R64G64B64A64_SFLOAT; + case GL_BGRA_INTEGER: + return VK_FORMAT_UNDEFINED; + case GL_STENCIL_INDEX: + return VK_FORMAT_UNDEFINED; + case GL_DEPTH_COMPONENT: + return VK_FORMAT_UNDEFINED; + case GL_DEPTH_STENCIL: + return VK_FORMAT_UNDEFINED; + } + break; + } + + // + // Packed + // + case GL_UNSIGNED_BYTE_3_3_2: + assert(format == GL_RGB || format == GL_RGB_INTEGER); + return VK_FORMAT_UNDEFINED; + case GL_UNSIGNED_BYTE_2_3_3_REV: + assert(format == GL_BGR || format == GL_BGR_INTEGER); + return VK_FORMAT_UNDEFINED; + case GL_UNSIGNED_SHORT_5_6_5: + assert(format == GL_RGB || format == GL_RGB_INTEGER); + return VK_FORMAT_R5G6B5_UNORM_PACK16; + case GL_UNSIGNED_SHORT_5_6_5_REV: + assert(format == GL_BGR || format == GL_BGR_INTEGER); + return VK_FORMAT_B5G6R5_UNORM_PACK16; + case GL_UNSIGNED_SHORT_4_4_4_4: + assert(format == GL_RGB || format == GL_BGRA || format == GL_RGB_INTEGER || format == GL_BGRA_INTEGER); + return VK_FORMAT_R4G4B4A4_UNORM_PACK16; + case GL_UNSIGNED_SHORT_4_4_4_4_REV: + assert(format == GL_RGB || format == GL_BGRA || format == GL_RGB_INTEGER || format == GL_BGRA_INTEGER); + return VK_FORMAT_B4G4R4A4_UNORM_PACK16; + case GL_UNSIGNED_SHORT_5_5_5_1: + assert(format == GL_RGB || format == GL_BGRA || format == GL_RGB_INTEGER || format == GL_BGRA_INTEGER); + return VK_FORMAT_R5G5B5A1_UNORM_PACK16; + case GL_UNSIGNED_SHORT_1_5_5_5_REV: + assert(format == GL_RGB || format == GL_BGRA || format == GL_RGB_INTEGER || format == GL_BGRA_INTEGER); + return VK_FORMAT_A1R5G5B5_UNORM_PACK16; + case GL_UNSIGNED_INT_8_8_8_8: + assert(format == GL_RGB || format == GL_BGRA || format == GL_RGB_INTEGER || format == GL_BGRA_INTEGER); + return (format == GL_RGB_INTEGER || format == GL_BGRA_INTEGER) ? VK_FORMAT_R8G8B8A8_UINT : VK_FORMAT_R8G8B8A8_UNORM; + case GL_UNSIGNED_INT_8_8_8_8_REV: + assert(format == GL_RGB || format == GL_BGRA || format == GL_RGB_INTEGER || format == GL_BGRA_INTEGER); + return (format == GL_RGB_INTEGER || format == GL_BGRA_INTEGER) ? VK_FORMAT_A8B8G8R8_UINT_PACK32 + : VK_FORMAT_A8B8G8R8_UNORM_PACK32; + case GL_UNSIGNED_INT_10_10_10_2: + assert(format == GL_RGB || format == GL_BGRA || format == GL_RGB_INTEGER || format == GL_BGRA_INTEGER); + return (format == GL_RGB_INTEGER || format == GL_BGRA_INTEGER) ? VK_FORMAT_A2R10G10B10_UINT_PACK32 + : VK_FORMAT_A2R10G10B10_UNORM_PACK32; + case GL_UNSIGNED_INT_2_10_10_10_REV: + assert(format == GL_RGB || format == GL_BGRA || format == GL_RGB_INTEGER || format == GL_BGRA_INTEGER); + return (format == GL_RGB_INTEGER || format == GL_BGRA_INTEGER) ? VK_FORMAT_A2B10G10R10_UINT_PACK32 + : VK_FORMAT_A2B10G10R10_UNORM_PACK32; + case GL_UNSIGNED_INT_10F_11F_11F_REV: + assert(format == GL_RGB || format == GL_BGR); + return VK_FORMAT_B10G11R11_UFLOAT_PACK32; + case GL_UNSIGNED_INT_5_9_9_9_REV: + assert(format == GL_RGB || format == GL_BGR); + return VK_FORMAT_E5B9G9R9_UFLOAT_PACK32; + case GL_UNSIGNED_INT_24_8: + assert(format == GL_DEPTH_STENCIL); + return VK_FORMAT_D24_UNORM_S8_UINT; + case GL_FLOAT_32_UNSIGNED_INT_24_8_REV: + assert(format == GL_DEPTH_STENCIL); + return VK_FORMAT_D32_SFLOAT_S8_UINT; + } + + return VK_FORMAT_UNDEFINED; } #if defined(NEED_VK_GET_FORMAT_FROM_OPENGL_TYPE) -static inline VkFormat vkGetFormatFromOpenGLType( const GLenum type, const GLuint numComponents, const GLboolean normalized ) -{ - switch ( type ) - { - // - // 8 bits per component - // - case GL_UNSIGNED_BYTE: - { - switch ( numComponents ) - { - case 1: return normalized ? VK_FORMAT_R8_UNORM : VK_FORMAT_R8_UINT; - case 2: return normalized ? VK_FORMAT_R8G8_UNORM : VK_FORMAT_R8G8_UINT; - case 3: return normalized ? VK_FORMAT_R8G8B8_UNORM : VK_FORMAT_R8G8B8_UINT; - case 4: return normalized ? VK_FORMAT_R8G8B8A8_UNORM : VK_FORMAT_R8G8B8A8_UINT; - } - break; - } - case GL_BYTE: - { - switch ( numComponents ) - { - case 1: return normalized ? VK_FORMAT_R8_SNORM : VK_FORMAT_R8_SINT; - case 2: return normalized ? VK_FORMAT_R8G8_SNORM : VK_FORMAT_R8G8_SINT; - case 3: return normalized ? VK_FORMAT_R8G8B8_SNORM : VK_FORMAT_R8G8B8_SINT; - case 4: return normalized ? VK_FORMAT_R8G8B8A8_SNORM : VK_FORMAT_R8G8B8A8_SINT; - } - break; - } - - // - // 16 bits per component - // - case GL_UNSIGNED_SHORT: - { - switch ( numComponents ) - { - case 1: return normalized ? VK_FORMAT_R16_UNORM : VK_FORMAT_R16_UINT; - case 2: return normalized ? VK_FORMAT_R16G16_UNORM : VK_FORMAT_R16G16_UINT; - case 3: return normalized ? VK_FORMAT_R16G16B16_UNORM : VK_FORMAT_R16G16B16_UINT; - case 4: return normalized ? VK_FORMAT_R16G16B16A16_UNORM : VK_FORMAT_R16G16B16A16_UINT; - } - break; - } - case GL_SHORT: - { - switch ( numComponents ) - { - case 1: return normalized ? VK_FORMAT_R16_SNORM : VK_FORMAT_R16_SINT; - case 2: return normalized ? VK_FORMAT_R16G16_SNORM : VK_FORMAT_R16G16_SINT; - case 3: return normalized ? VK_FORMAT_R16G16B16_SNORM : VK_FORMAT_R16G16B16_SINT; - case 4: return normalized ? VK_FORMAT_R16G16B16A16_SNORM : VK_FORMAT_R16G16B16A16_SINT; - } - break; - } - case GL_HALF_FLOAT: - case GL_HALF_FLOAT_OES: - { - switch ( numComponents ) - { - case 1: return VK_FORMAT_R16_SFLOAT; - case 2: return VK_FORMAT_R16G16_SFLOAT; - case 3: return VK_FORMAT_R16G16B16_SFLOAT; - case 4: return VK_FORMAT_R16G16B16A16_SFLOAT; - } - break; - } - - // - // 32 bits per component - // - case GL_UNSIGNED_INT: - { - switch ( numComponents ) - { - case 1: return VK_FORMAT_R32_UINT; - case 2: return VK_FORMAT_R32G32_UINT; - case 3: return VK_FORMAT_R32G32B32_UINT; - case 4: return VK_FORMAT_R32G32B32A32_UINT; - } - break; - } - case GL_INT: - { - switch ( numComponents ) - { - case 1: return VK_FORMAT_R32_SINT; - case 2: return VK_FORMAT_R32G32_SINT; - case 3: return VK_FORMAT_R32G32B32_SINT; - case 4: return VK_FORMAT_R32G32B32A32_SINT; - } - break; - } - case GL_FLOAT: - { - switch ( numComponents ) - { - case 1: return VK_FORMAT_R32_SFLOAT; - case 2: return VK_FORMAT_R32G32_SFLOAT; - case 3: return VK_FORMAT_R32G32B32_SFLOAT; - case 4: return VK_FORMAT_R32G32B32A32_SFLOAT; - } - break; - } - - // - // 64 bits per component - // - case GL_UNSIGNED_INT64: - { - switch ( numComponents ) - { - case 1: return VK_FORMAT_R64_UINT; - case 2: return VK_FORMAT_R64G64_UINT; - case 3: return VK_FORMAT_R64G64B64_UINT; - case 4: return VK_FORMAT_R64G64B64A64_UINT; - } - break; - } - case GL_INT64: - { - switch ( numComponents ) - { - case 1: return VK_FORMAT_R64_SINT; - case 2: return VK_FORMAT_R64G64_SINT; - case 3: return VK_FORMAT_R64G64B64_SINT; - case 4: return VK_FORMAT_R64G64B64A64_SINT; - } - break; - } - case GL_DOUBLE: - { - switch ( numComponents ) - { - case 1: return VK_FORMAT_R64_SFLOAT; - case 2: return VK_FORMAT_R64G64_SFLOAT; - case 3: return VK_FORMAT_R64G64B64_SFLOAT; - case 4: return VK_FORMAT_R64G64B64A64_SFLOAT; - } - break; - } - - // - // Packed - // - case GL_UNSIGNED_BYTE_3_3_2: return VK_FORMAT_UNDEFINED; - case GL_UNSIGNED_BYTE_2_3_3_REV: return VK_FORMAT_UNDEFINED; - case GL_UNSIGNED_SHORT_5_6_5: return VK_FORMAT_R5G6B5_UNORM_PACK16; - case GL_UNSIGNED_SHORT_5_6_5_REV: return VK_FORMAT_B5G6R5_UNORM_PACK16; - case GL_UNSIGNED_SHORT_4_4_4_4: return VK_FORMAT_R4G4B4A4_UNORM_PACK16; - case GL_UNSIGNED_SHORT_4_4_4_4_REV: return VK_FORMAT_B4G4R4A4_UNORM_PACK16; - case GL_UNSIGNED_SHORT_5_5_5_1: return VK_FORMAT_R5G5B5A1_UNORM_PACK16; - case GL_UNSIGNED_SHORT_1_5_5_5_REV: return VK_FORMAT_A1R5G5B5_UNORM_PACK16; - case GL_UNSIGNED_INT_8_8_8_8: return normalized ? VK_FORMAT_R8G8B8A8_UNORM : VK_FORMAT_R8G8B8A8_UINT; - case GL_UNSIGNED_INT_8_8_8_8_REV: return normalized ? VK_FORMAT_A8B8G8R8_UNORM_PACK32 : VK_FORMAT_A8B8G8R8_UINT_PACK32; - case GL_UNSIGNED_INT_10_10_10_2: return normalized ? VK_FORMAT_A2R10G10B10_UNORM_PACK32 : VK_FORMAT_A2R10G10B10_UINT_PACK32; - case GL_UNSIGNED_INT_2_10_10_10_REV: return normalized ? VK_FORMAT_A2B10G10R10_UNORM_PACK32 : VK_FORMAT_A2B10G10R10_UINT_PACK32; - case GL_UNSIGNED_INT_10F_11F_11F_REV: return VK_FORMAT_B10G11R11_UFLOAT_PACK32; - case GL_UNSIGNED_INT_5_9_9_9_REV: return VK_FORMAT_E5B9G9R9_UFLOAT_PACK32; - case GL_UNSIGNED_INT_24_8: return VK_FORMAT_D24_UNORM_S8_UINT; - case GL_FLOAT_32_UNSIGNED_INT_24_8_REV: return VK_FORMAT_D32_SFLOAT_S8_UINT; - } - - return VK_FORMAT_UNDEFINED; +static inline VkFormat +vkGetFormatFromOpenGLType(const GLenum type, const GLuint numComponents, const GLboolean normalized) { + switch (type) { + // + // 8 bits per component + // + case GL_UNSIGNED_BYTE: { + switch (numComponents) { + case 1: + return normalized ? VK_FORMAT_R8_UNORM : VK_FORMAT_R8_UINT; + case 2: + return normalized ? VK_FORMAT_R8G8_UNORM : VK_FORMAT_R8G8_UINT; + case 3: + return normalized ? VK_FORMAT_R8G8B8_UNORM : VK_FORMAT_R8G8B8_UINT; + case 4: + return normalized ? VK_FORMAT_R8G8B8A8_UNORM : VK_FORMAT_R8G8B8A8_UINT; + } + break; + } + case GL_BYTE: { + switch (numComponents) { + case 1: + return normalized ? VK_FORMAT_R8_SNORM : VK_FORMAT_R8_SINT; + case 2: + return normalized ? VK_FORMAT_R8G8_SNORM : VK_FORMAT_R8G8_SINT; + case 3: + return normalized ? VK_FORMAT_R8G8B8_SNORM : VK_FORMAT_R8G8B8_SINT; + case 4: + return normalized ? VK_FORMAT_R8G8B8A8_SNORM : VK_FORMAT_R8G8B8A8_SINT; + } + break; + } + + // + // 16 bits per component + // + case GL_UNSIGNED_SHORT: { + switch (numComponents) { + case 1: + return normalized ? VK_FORMAT_R16_UNORM : VK_FORMAT_R16_UINT; + case 2: + return normalized ? VK_FORMAT_R16G16_UNORM : VK_FORMAT_R16G16_UINT; + case 3: + return normalized ? VK_FORMAT_R16G16B16_UNORM : VK_FORMAT_R16G16B16_UINT; + case 4: + return normalized ? VK_FORMAT_R16G16B16A16_UNORM : VK_FORMAT_R16G16B16A16_UINT; + } + break; + } + case GL_SHORT: { + switch (numComponents) { + case 1: + return normalized ? VK_FORMAT_R16_SNORM : VK_FORMAT_R16_SINT; + case 2: + return normalized ? VK_FORMAT_R16G16_SNORM : VK_FORMAT_R16G16_SINT; + case 3: + return normalized ? VK_FORMAT_R16G16B16_SNORM : VK_FORMAT_R16G16B16_SINT; + case 4: + return normalized ? VK_FORMAT_R16G16B16A16_SNORM : VK_FORMAT_R16G16B16A16_SINT; + } + break; + } + case GL_HALF_FLOAT: + case GL_HALF_FLOAT_OES: { + switch (numComponents) { + case 1: + return VK_FORMAT_R16_SFLOAT; + case 2: + return VK_FORMAT_R16G16_SFLOAT; + case 3: + return VK_FORMAT_R16G16B16_SFLOAT; + case 4: + return VK_FORMAT_R16G16B16A16_SFLOAT; + } + break; + } + + // + // 32 bits per component + // + case GL_UNSIGNED_INT: { + switch (numComponents) { + case 1: + return VK_FORMAT_R32_UINT; + case 2: + return VK_FORMAT_R32G32_UINT; + case 3: + return VK_FORMAT_R32G32B32_UINT; + case 4: + return VK_FORMAT_R32G32B32A32_UINT; + } + break; + } + case GL_INT: { + switch (numComponents) { + case 1: + return VK_FORMAT_R32_SINT; + case 2: + return VK_FORMAT_R32G32_SINT; + case 3: + return VK_FORMAT_R32G32B32_SINT; + case 4: + return VK_FORMAT_R32G32B32A32_SINT; + } + break; + } + case GL_FLOAT: { + switch (numComponents) { + case 1: + return VK_FORMAT_R32_SFLOAT; + case 2: + return VK_FORMAT_R32G32_SFLOAT; + case 3: + return VK_FORMAT_R32G32B32_SFLOAT; + case 4: + return VK_FORMAT_R32G32B32A32_SFLOAT; + } + break; + } + + // + // 64 bits per component + // + case GL_UNSIGNED_INT64: { + switch (numComponents) { + case 1: + return VK_FORMAT_R64_UINT; + case 2: + return VK_FORMAT_R64G64_UINT; + case 3: + return VK_FORMAT_R64G64B64_UINT; + case 4: + return VK_FORMAT_R64G64B64A64_UINT; + } + break; + } + case GL_INT64: { + switch (numComponents) { + case 1: + return VK_FORMAT_R64_SINT; + case 2: + return VK_FORMAT_R64G64_SINT; + case 3: + return VK_FORMAT_R64G64B64_SINT; + case 4: + return VK_FORMAT_R64G64B64A64_SINT; + } + break; + } + case GL_DOUBLE: { + switch (numComponents) { + case 1: + return VK_FORMAT_R64_SFLOAT; + case 2: + return VK_FORMAT_R64G64_SFLOAT; + case 3: + return VK_FORMAT_R64G64B64_SFLOAT; + case 4: + return VK_FORMAT_R64G64B64A64_SFLOAT; + } + break; + } + + // + // Packed + // + case GL_UNSIGNED_BYTE_3_3_2: + return VK_FORMAT_UNDEFINED; + case GL_UNSIGNED_BYTE_2_3_3_REV: + return VK_FORMAT_UNDEFINED; + case GL_UNSIGNED_SHORT_5_6_5: + return VK_FORMAT_R5G6B5_UNORM_PACK16; + case GL_UNSIGNED_SHORT_5_6_5_REV: + return VK_FORMAT_B5G6R5_UNORM_PACK16; + case GL_UNSIGNED_SHORT_4_4_4_4: + return VK_FORMAT_R4G4B4A4_UNORM_PACK16; + case GL_UNSIGNED_SHORT_4_4_4_4_REV: + return VK_FORMAT_B4G4R4A4_UNORM_PACK16; + case GL_UNSIGNED_SHORT_5_5_5_1: + return VK_FORMAT_R5G5B5A1_UNORM_PACK16; + case GL_UNSIGNED_SHORT_1_5_5_5_REV: + return VK_FORMAT_A1R5G5B5_UNORM_PACK16; + case GL_UNSIGNED_INT_8_8_8_8: + return normalized ? VK_FORMAT_R8G8B8A8_UNORM : VK_FORMAT_R8G8B8A8_UINT; + case GL_UNSIGNED_INT_8_8_8_8_REV: + return normalized ? VK_FORMAT_A8B8G8R8_UNORM_PACK32 : VK_FORMAT_A8B8G8R8_UINT_PACK32; + case GL_UNSIGNED_INT_10_10_10_2: + return normalized ? VK_FORMAT_A2R10G10B10_UNORM_PACK32 : VK_FORMAT_A2R10G10B10_UINT_PACK32; + case GL_UNSIGNED_INT_2_10_10_10_REV: + return normalized ? VK_FORMAT_A2B10G10R10_UNORM_PACK32 : VK_FORMAT_A2B10G10R10_UINT_PACK32; + case GL_UNSIGNED_INT_10F_11F_11F_REV: + return VK_FORMAT_B10G11R11_UFLOAT_PACK32; + case GL_UNSIGNED_INT_5_9_9_9_REV: + return VK_FORMAT_E5B9G9R9_UFLOAT_PACK32; + case GL_UNSIGNED_INT_24_8: + return VK_FORMAT_D24_UNORM_S8_UINT; + case GL_FLOAT_32_UNSIGNED_INT_24_8_REV: + return VK_FORMAT_D32_SFLOAT_S8_UINT; + } + + return VK_FORMAT_UNDEFINED; } #endif -static inline VkFormat vkGetFormatFromOpenGLInternalFormat( const GLenum internalFormat ) -{ - switch ( internalFormat ) - { - // - // 8 bits per component - // - case GL_R8: return VK_FORMAT_R8_UNORM; // 1-component, 8-bit unsigned normalized - case GL_RG8: return VK_FORMAT_R8G8_UNORM; // 2-component, 8-bit unsigned normalized - case GL_RGB8: return VK_FORMAT_R8G8B8_UNORM; // 3-component, 8-bit unsigned normalized - case GL_RGBA8: return VK_FORMAT_R8G8B8A8_UNORM; // 4-component, 8-bit unsigned normalized - - case GL_R8_SNORM: return VK_FORMAT_R8_SNORM; // 1-component, 8-bit signed normalized - case GL_RG8_SNORM: return VK_FORMAT_R8G8_SNORM; // 2-component, 8-bit signed normalized - case GL_RGB8_SNORM: return VK_FORMAT_R8G8B8_SNORM; // 3-component, 8-bit signed normalized - case GL_RGBA8_SNORM: return VK_FORMAT_R8G8B8A8_SNORM; // 4-component, 8-bit signed normalized - - case GL_R8UI: return VK_FORMAT_R8_UINT; // 1-component, 8-bit unsigned integer - case GL_RG8UI: return VK_FORMAT_R8G8_UINT; // 2-component, 8-bit unsigned integer - case GL_RGB8UI: return VK_FORMAT_R8G8B8_UINT; // 3-component, 8-bit unsigned integer - case GL_RGBA8UI: return VK_FORMAT_R8G8B8A8_UINT; // 4-component, 8-bit unsigned integer - - case GL_R8I: return VK_FORMAT_R8_SINT; // 1-component, 8-bit signed integer - case GL_RG8I: return VK_FORMAT_R8G8_SINT; // 2-component, 8-bit signed integer - case GL_RGB8I: return VK_FORMAT_R8G8B8_SINT; // 3-component, 8-bit signed integer - case GL_RGBA8I: return VK_FORMAT_R8G8B8A8_SINT; // 4-component, 8-bit signed integer - - case GL_SR8: return VK_FORMAT_R8_SRGB; // 1-component, 8-bit sRGB - case GL_SRG8: return VK_FORMAT_R8G8_SRGB; // 2-component, 8-bit sRGB - case GL_SRGB8: return VK_FORMAT_R8G8B8_SRGB; // 3-component, 8-bit sRGB - case GL_SRGB8_ALPHA8: return VK_FORMAT_R8G8B8A8_SRGB; // 4-component, 8-bit sRGB - - // - // 16 bits per component - // - case GL_R16: return VK_FORMAT_R16_UNORM; // 1-component, 16-bit unsigned normalized - case GL_RG16: return VK_FORMAT_R16G16_UNORM; // 2-component, 16-bit unsigned normalized - case GL_RGB16: return VK_FORMAT_R16G16B16_UNORM; // 3-component, 16-bit unsigned normalized - case GL_RGBA16: return VK_FORMAT_R16G16B16A16_UNORM; // 4-component, 16-bit unsigned normalized - - case GL_R16_SNORM: return VK_FORMAT_R16_SNORM; // 1-component, 16-bit signed normalized - case GL_RG16_SNORM: return VK_FORMAT_R16G16_SNORM; // 2-component, 16-bit signed normalized - case GL_RGB16_SNORM: return VK_FORMAT_R16G16B16_SNORM; // 3-component, 16-bit signed normalized - case GL_RGBA16_SNORM: return VK_FORMAT_R16G16B16A16_SNORM; // 4-component, 16-bit signed normalized - - case GL_R16UI: return VK_FORMAT_R16_UINT; // 1-component, 16-bit unsigned integer - case GL_RG16UI: return VK_FORMAT_R16G16_UINT; // 2-component, 16-bit unsigned integer - case GL_RGB16UI: return VK_FORMAT_R16G16B16_UINT; // 3-component, 16-bit unsigned integer - case GL_RGBA16UI: return VK_FORMAT_R16G16B16A16_UINT; // 4-component, 16-bit unsigned integer - - case GL_R16I: return VK_FORMAT_R16_SINT; // 1-component, 16-bit signed integer - case GL_RG16I: return VK_FORMAT_R16G16_SINT; // 2-component, 16-bit signed integer - case GL_RGB16I: return VK_FORMAT_R16G16B16_SINT; // 3-component, 16-bit signed integer - case GL_RGBA16I: return VK_FORMAT_R16G16B16A16_SINT; // 4-component, 16-bit signed integer - - case GL_R16F: return VK_FORMAT_R16_SFLOAT; // 1-component, 16-bit floating-point - case GL_RG16F: return VK_FORMAT_R16G16_SFLOAT; // 2-component, 16-bit floating-point - case GL_RGB16F: return VK_FORMAT_R16G16B16_SFLOAT; // 3-component, 16-bit floating-point - case GL_RGBA16F: return VK_FORMAT_R16G16B16A16_SFLOAT; // 4-component, 16-bit floating-point - - // - // 32 bits per component - // - case GL_R32UI: return VK_FORMAT_R32_UINT; // 1-component, 32-bit unsigned integer - case GL_RG32UI: return VK_FORMAT_R32G32_UINT; // 2-component, 32-bit unsigned integer - case GL_RGB32UI: return VK_FORMAT_R32G32B32_UINT; // 3-component, 32-bit unsigned integer - case GL_RGBA32UI: return VK_FORMAT_R32G32B32A32_UINT; // 4-component, 32-bit unsigned integer - - case GL_R32I: return VK_FORMAT_R32_SINT; // 1-component, 32-bit signed integer - case GL_RG32I: return VK_FORMAT_R32G32_SINT; // 2-component, 32-bit signed integer - case GL_RGB32I: return VK_FORMAT_R32G32B32_SINT; // 3-component, 32-bit signed integer - case GL_RGBA32I: return VK_FORMAT_R32G32B32A32_SINT; // 4-component, 32-bit signed integer - - case GL_R32F: return VK_FORMAT_R32_SFLOAT; // 1-component, 32-bit floating-point - case GL_RG32F: return VK_FORMAT_R32G32_SFLOAT; // 2-component, 32-bit floating-point - case GL_RGB32F: return VK_FORMAT_R32G32B32_SFLOAT; // 3-component, 32-bit floating-point - case GL_RGBA32F: return VK_FORMAT_R32G32B32A32_SFLOAT; // 4-component, 32-bit floating-point - - // - // Packed - // - case GL_R3_G3_B2: return VK_FORMAT_UNDEFINED; // 3-component 3:3:2, unsigned normalized - case GL_RGB4: return VK_FORMAT_UNDEFINED; // 3-component 4:4:4, unsigned normalized - case GL_RGB5: return VK_FORMAT_R5G5B5A1_UNORM_PACK16; // 3-component 5:5:5, unsigned normalized - case GL_RGB565: return VK_FORMAT_R5G6B5_UNORM_PACK16; // 3-component 5:6:5, unsigned normalized - case GL_RGB10: return VK_FORMAT_A2R10G10B10_UNORM_PACK32; // 3-component 10:10:10, unsigned normalized - case GL_RGB12: return VK_FORMAT_UNDEFINED; // 3-component 12:12:12, unsigned normalized - case GL_RGBA2: return VK_FORMAT_UNDEFINED; // 4-component 2:2:2:2, unsigned normalized - case GL_RGBA4: return VK_FORMAT_R4G4B4A4_UNORM_PACK16; // 4-component 4:4:4:4, unsigned normalized - case GL_RGBA12: return VK_FORMAT_UNDEFINED; // 4-component 12:12:12:12, unsigned normalized - case GL_RGB5_A1: return VK_FORMAT_A1R5G5B5_UNORM_PACK16; // 4-component 5:5:5:1, unsigned normalized - case GL_RGB10_A2: return VK_FORMAT_A2R10G10B10_UNORM_PACK32; // 4-component 10:10:10:2, unsigned normalized - case GL_RGB10_A2UI: return VK_FORMAT_A2R10G10B10_UINT_PACK32; // 4-component 10:10:10:2, unsigned integer - case GL_R11F_G11F_B10F: return VK_FORMAT_B10G11R11_UFLOAT_PACK32; // 3-component 11:11:10, floating-point - case GL_RGB9_E5: return VK_FORMAT_E5B9G9R9_UFLOAT_PACK32; // 3-component/exp 9:9:9/5, floating-point - - // - // S3TC/DXT/BC - // - - case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: return VK_FORMAT_BC1_RGB_UNORM_BLOCK; // line through 3D space, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: return VK_FORMAT_BC1_RGBA_UNORM_BLOCK; // line through 3D space plus 1-bit alpha, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: return VK_FORMAT_BC2_UNORM_BLOCK; // line through 3D space plus line through 1D space, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: return VK_FORMAT_BC3_UNORM_BLOCK; // line through 3D space plus 4-bit alpha, 4x4 blocks, unsigned normalized - - case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: return VK_FORMAT_BC1_RGB_SRGB_BLOCK; // line through 3D space, 4x4 blocks, sRGB - case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: return VK_FORMAT_BC1_RGBA_SRGB_BLOCK; // line through 3D space plus 1-bit alpha, 4x4 blocks, sRGB - case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: return VK_FORMAT_BC2_SRGB_BLOCK; // line through 3D space plus line through 1D space, 4x4 blocks, sRGB - case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: return VK_FORMAT_BC3_SRGB_BLOCK; // line through 3D space plus 4-bit alpha, 4x4 blocks, sRGB - - case GL_COMPRESSED_LUMINANCE_LATC1_EXT: return VK_FORMAT_BC4_UNORM_BLOCK; // line through 1D space, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT: return VK_FORMAT_BC5_UNORM_BLOCK; // two lines through 1D space, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT: return VK_FORMAT_BC4_SNORM_BLOCK; // line through 1D space, 4x4 blocks, signed normalized - case GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT: return VK_FORMAT_BC5_SNORM_BLOCK; // two lines through 1D space, 4x4 blocks, signed normalized - - case GL_COMPRESSED_RED_RGTC1: return VK_FORMAT_BC4_UNORM_BLOCK; // line through 1D space, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_RG_RGTC2: return VK_FORMAT_BC5_UNORM_BLOCK; // two lines through 1D space, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_SIGNED_RED_RGTC1: return VK_FORMAT_BC4_SNORM_BLOCK; // line through 1D space, 4x4 blocks, signed normalized - case GL_COMPRESSED_SIGNED_RG_RGTC2: return VK_FORMAT_BC5_SNORM_BLOCK; // two lines through 1D space, 4x4 blocks, signed normalized - - case GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT: return VK_FORMAT_BC6H_UFLOAT_BLOCK; // 3-component, 4x4 blocks, unsigned floating-point - case GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT: return VK_FORMAT_BC6H_SFLOAT_BLOCK; // 3-component, 4x4 blocks, signed floating-point - case GL_COMPRESSED_RGBA_BPTC_UNORM: return VK_FORMAT_BC7_UNORM_BLOCK; // 4-component, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM: return VK_FORMAT_BC7_SRGB_BLOCK; // 4-component, 4x4 blocks, sRGB - - // - // ETC - // - case GL_ETC1_RGB8_OES: return VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK; // 3-component ETC1, 4x4 blocks, unsigned normalized - - case GL_COMPRESSED_RGB8_ETC2: return VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK; // 3-component ETC2, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: return VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK; // 4-component ETC2 with 1-bit alpha, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_RGBA8_ETC2_EAC: return VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK; // 4-component ETC2, 4x4 blocks, unsigned normalized - - case GL_COMPRESSED_SRGB8_ETC2: return VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK; // 3-component ETC2, 4x4 blocks, sRGB - case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: return VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK; // 4-component ETC2 with 1-bit alpha, 4x4 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: return VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK; // 4-component ETC2, 4x4 blocks, sRGB - - case GL_COMPRESSED_R11_EAC: return VK_FORMAT_EAC_R11_UNORM_BLOCK; // 1-component ETC, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_RG11_EAC: return VK_FORMAT_EAC_R11G11_UNORM_BLOCK; // 2-component ETC, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_SIGNED_R11_EAC: return VK_FORMAT_EAC_R11_SNORM_BLOCK; // 1-component ETC, 4x4 blocks, signed normalized - case GL_COMPRESSED_SIGNED_RG11_EAC: return VK_FORMAT_EAC_R11G11_SNORM_BLOCK; // 2-component ETC, 4x4 blocks, signed normalized - - // - // PVRTC - // - case GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG: return VK_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG; // 3-component PVRTC, 16x8 blocks, unsigned normalized - case GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG: return VK_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG; // 3-component PVRTC, 8x8 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: return VK_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG; // 4-component PVRTC, 16x8 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: return VK_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG; // 4-component PVRTC, 8x8 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG: return VK_FORMAT_PVRTC2_2BPP_UNORM_BLOCK_IMG; // 4-component PVRTC, 8x4 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG: return VK_FORMAT_PVRTC2_4BPP_UNORM_BLOCK_IMG; // 4-component PVRTC, 4x4 blocks, unsigned normalized - - case GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT: return VK_FORMAT_PVRTC1_2BPP_SRGB_BLOCK_IMG; // 3-component PVRTC, 16x8 blocks, sRGB - case GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT: return VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG; // 3-component PVRTC, 8x8 blocks, sRGB - case GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT: return VK_FORMAT_PVRTC1_2BPP_SRGB_BLOCK_IMG; // 4-component PVRTC, 16x8 blocks, sRGB - case GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT: return VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG; // 4-component PVRTC, 8x8 blocks, sRGB - case GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV2_IMG: return VK_FORMAT_PVRTC2_2BPP_SRGB_BLOCK_IMG; // 4-component PVRTC, 8x4 blocks, sRGB - case GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV2_IMG: return VK_FORMAT_PVRTC2_4BPP_SRGB_BLOCK_IMG; // 4-component PVRTC, 4x4 blocks, sRGB - - // - // ASTC - // - case GL_COMPRESSED_RGBA_ASTC_4x4_KHR: return VK_FORMAT_ASTC_4x4_UNORM_BLOCK; // 4-component ASTC, 4x4 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_5x4_KHR: return VK_FORMAT_ASTC_5x4_UNORM_BLOCK; // 4-component ASTC, 5x4 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_5x5_KHR: return VK_FORMAT_ASTC_5x5_UNORM_BLOCK; // 4-component ASTC, 5x5 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_6x5_KHR: return VK_FORMAT_ASTC_6x5_UNORM_BLOCK; // 4-component ASTC, 6x5 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_6x6_KHR: return VK_FORMAT_ASTC_6x6_UNORM_BLOCK; // 4-component ASTC, 6x6 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_8x5_KHR: return VK_FORMAT_ASTC_8x5_UNORM_BLOCK; // 4-component ASTC, 8x5 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_8x6_KHR: return VK_FORMAT_ASTC_8x6_UNORM_BLOCK; // 4-component ASTC, 8x6 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_8x8_KHR: return VK_FORMAT_ASTC_8x8_UNORM_BLOCK; // 4-component ASTC, 8x8 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_10x5_KHR: return VK_FORMAT_ASTC_10x5_UNORM_BLOCK; // 4-component ASTC, 10x5 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_10x6_KHR: return VK_FORMAT_ASTC_10x6_UNORM_BLOCK; // 4-component ASTC, 10x6 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_10x8_KHR: return VK_FORMAT_ASTC_10x8_UNORM_BLOCK; // 4-component ASTC, 10x8 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_10x10_KHR: return VK_FORMAT_ASTC_10x10_UNORM_BLOCK; // 4-component ASTC, 10x10 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_12x10_KHR: return VK_FORMAT_ASTC_12x10_UNORM_BLOCK; // 4-component ASTC, 12x10 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_12x12_KHR: return VK_FORMAT_ASTC_12x12_UNORM_BLOCK; // 4-component ASTC, 12x12 blocks, unsigned normalized - - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR: return VK_FORMAT_ASTC_4x4_SRGB_BLOCK; // 4-component ASTC, 4x4 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR: return VK_FORMAT_ASTC_5x4_SRGB_BLOCK; // 4-component ASTC, 5x4 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR: return VK_FORMAT_ASTC_5x5_SRGB_BLOCK; // 4-component ASTC, 5x5 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR: return VK_FORMAT_ASTC_6x5_SRGB_BLOCK; // 4-component ASTC, 6x5 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR: return VK_FORMAT_ASTC_6x6_SRGB_BLOCK; // 4-component ASTC, 6x6 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR: return VK_FORMAT_ASTC_8x5_SRGB_BLOCK; // 4-component ASTC, 8x5 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR: return VK_FORMAT_ASTC_8x6_SRGB_BLOCK; // 4-component ASTC, 8x6 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR: return VK_FORMAT_ASTC_8x8_SRGB_BLOCK; // 4-component ASTC, 8x8 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR: return VK_FORMAT_ASTC_10x5_SRGB_BLOCK; // 4-component ASTC, 10x5 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR: return VK_FORMAT_ASTC_10x6_SRGB_BLOCK; // 4-component ASTC, 10x6 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR: return VK_FORMAT_ASTC_10x8_SRGB_BLOCK; // 4-component ASTC, 10x8 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR: return VK_FORMAT_ASTC_10x10_SRGB_BLOCK; // 4-component ASTC, 10x10 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR: return VK_FORMAT_ASTC_12x10_SRGB_BLOCK; // 4-component ASTC, 12x10 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR: return VK_FORMAT_ASTC_12x12_SRGB_BLOCK; // 4-component ASTC, 12x12 blocks, sRGB - - case GL_COMPRESSED_RGBA_ASTC_3x3x3_OES: return VK_FORMAT_UNDEFINED; // 4-component ASTC, 3x3x3 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_4x3x3_OES: return VK_FORMAT_UNDEFINED; // 4-component ASTC, 4x3x3 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_4x4x3_OES: return VK_FORMAT_UNDEFINED; // 4-component ASTC, 4x4x3 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_4x4x4_OES: return VK_FORMAT_UNDEFINED; // 4-component ASTC, 4x4x4 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_5x4x4_OES: return VK_FORMAT_UNDEFINED; // 4-component ASTC, 5x4x4 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_5x5x4_OES: return VK_FORMAT_UNDEFINED; // 4-component ASTC, 5x5x4 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_5x5x5_OES: return VK_FORMAT_UNDEFINED; // 4-component ASTC, 5x5x5 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_6x5x5_OES: return VK_FORMAT_UNDEFINED; // 4-component ASTC, 6x5x5 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_6x6x5_OES: return VK_FORMAT_UNDEFINED; // 4-component ASTC, 6x6x5 blocks, unsigned normalized - case GL_COMPRESSED_RGBA_ASTC_6x6x6_OES: return VK_FORMAT_UNDEFINED; // 4-component ASTC, 6x6x6 blocks, unsigned normalized - - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_3x3x3_OES: return VK_FORMAT_UNDEFINED; // 4-component ASTC, 3x3x3 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x3x3_OES: return VK_FORMAT_UNDEFINED; // 4-component ASTC, 4x3x3 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x3_OES: return VK_FORMAT_UNDEFINED; // 4-component ASTC, 4x4x3 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x4_OES: return VK_FORMAT_UNDEFINED; // 4-component ASTC, 4x4x4 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4x4_OES: return VK_FORMAT_UNDEFINED; // 4-component ASTC, 5x4x4 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x4_OES: return VK_FORMAT_UNDEFINED; // 4-component ASTC, 5x5x4 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x5_OES: return VK_FORMAT_UNDEFINED; // 4-component ASTC, 5x5x5 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5x5_OES: return VK_FORMAT_UNDEFINED; // 4-component ASTC, 6x5x5 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x5_OES: return VK_FORMAT_UNDEFINED; // 4-component ASTC, 6x6x5 blocks, sRGB - case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x6_OES: return VK_FORMAT_UNDEFINED; // 4-component ASTC, 6x6x6 blocks, sRGB - - // - // ATC - // - case GL_ATC_RGB_AMD: return VK_FORMAT_UNDEFINED; // 3-component, 4x4 blocks, unsigned normalized - case GL_ATC_RGBA_EXPLICIT_ALPHA_AMD: return VK_FORMAT_UNDEFINED; // 4-component, 4x4 blocks, unsigned normalized - case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD: return VK_FORMAT_UNDEFINED; // 4-component, 4x4 blocks, unsigned normalized - - // - // Palletized - // - case GL_PALETTE4_RGB8_OES: return VK_FORMAT_UNDEFINED; // 3-component 8:8:8, 4-bit palette, unsigned normalized - case GL_PALETTE4_RGBA8_OES: return VK_FORMAT_UNDEFINED; // 4-component 8:8:8:8, 4-bit palette, unsigned normalized - case GL_PALETTE4_R5_G6_B5_OES: return VK_FORMAT_UNDEFINED; // 3-component 5:6:5, 4-bit palette, unsigned normalized - case GL_PALETTE4_RGBA4_OES: return VK_FORMAT_UNDEFINED; // 4-component 4:4:4:4, 4-bit palette, unsigned normalized - case GL_PALETTE4_RGB5_A1_OES: return VK_FORMAT_UNDEFINED; // 4-component 5:5:5:1, 4-bit palette, unsigned normalized - case GL_PALETTE8_RGB8_OES: return VK_FORMAT_UNDEFINED; // 3-component 8:8:8, 8-bit palette, unsigned normalized - case GL_PALETTE8_RGBA8_OES: return VK_FORMAT_UNDEFINED; // 4-component 8:8:8:8, 8-bit palette, unsigned normalized - case GL_PALETTE8_R5_G6_B5_OES: return VK_FORMAT_UNDEFINED; // 3-component 5:6:5, 8-bit palette, unsigned normalized - case GL_PALETTE8_RGBA4_OES: return VK_FORMAT_UNDEFINED; // 4-component 4:4:4:4, 8-bit palette, unsigned normalized - case GL_PALETTE8_RGB5_A1_OES: return VK_FORMAT_UNDEFINED; // 4-component 5:5:5:1, 8-bit palette, unsigned normalized - - // - // Depth/stencil - // - case GL_DEPTH_COMPONENT16: return VK_FORMAT_D16_UNORM; - case GL_DEPTH_COMPONENT24: return VK_FORMAT_X8_D24_UNORM_PACK32; - case GL_DEPTH_COMPONENT32: return VK_FORMAT_UNDEFINED; - case GL_DEPTH_COMPONENT32F: return VK_FORMAT_D32_SFLOAT; - case GL_DEPTH_COMPONENT32F_NV: return VK_FORMAT_D32_SFLOAT; - case GL_STENCIL_INDEX1: return VK_FORMAT_UNDEFINED; - case GL_STENCIL_INDEX4: return VK_FORMAT_UNDEFINED; - case GL_STENCIL_INDEX8: return VK_FORMAT_S8_UINT; - case GL_STENCIL_INDEX16: return VK_FORMAT_UNDEFINED; - case GL_DEPTH24_STENCIL8: return VK_FORMAT_D24_UNORM_S8_UINT; - case GL_DEPTH32F_STENCIL8: return VK_FORMAT_D32_SFLOAT_S8_UINT; - case GL_DEPTH32F_STENCIL8_NV: return VK_FORMAT_D32_SFLOAT_S8_UINT; - - default: return VK_FORMAT_UNDEFINED; - } +static inline VkFormat +vkGetFormatFromOpenGLInternalFormat(const GLenum internalFormat) { + switch (internalFormat) { + // + // 8 bits per component + // + case GL_R8: + return VK_FORMAT_R8_UNORM; // 1-component, 8-bit unsigned normalized + case GL_RG8: + return VK_FORMAT_R8G8_UNORM; // 2-component, 8-bit unsigned normalized + case GL_RGB8: + return VK_FORMAT_R8G8B8_UNORM; // 3-component, 8-bit unsigned normalized + case GL_RGBA8: + return VK_FORMAT_R8G8B8A8_UNORM; // 4-component, 8-bit unsigned normalized + + case GL_R8_SNORM: + return VK_FORMAT_R8_SNORM; // 1-component, 8-bit signed normalized + case GL_RG8_SNORM: + return VK_FORMAT_R8G8_SNORM; // 2-component, 8-bit signed normalized + case GL_RGB8_SNORM: + return VK_FORMAT_R8G8B8_SNORM; // 3-component, 8-bit signed normalized + case GL_RGBA8_SNORM: + return VK_FORMAT_R8G8B8A8_SNORM; // 4-component, 8-bit signed normalized + + case GL_R8UI: + return VK_FORMAT_R8_UINT; // 1-component, 8-bit unsigned integer + case GL_RG8UI: + return VK_FORMAT_R8G8_UINT; // 2-component, 8-bit unsigned integer + case GL_RGB8UI: + return VK_FORMAT_R8G8B8_UINT; // 3-component, 8-bit unsigned integer + case GL_RGBA8UI: + return VK_FORMAT_R8G8B8A8_UINT; // 4-component, 8-bit unsigned integer + + case GL_R8I: + return VK_FORMAT_R8_SINT; // 1-component, 8-bit signed integer + case GL_RG8I: + return VK_FORMAT_R8G8_SINT; // 2-component, 8-bit signed integer + case GL_RGB8I: + return VK_FORMAT_R8G8B8_SINT; // 3-component, 8-bit signed integer + case GL_RGBA8I: + return VK_FORMAT_R8G8B8A8_SINT; // 4-component, 8-bit signed integer + + case GL_SR8: + return VK_FORMAT_R8_SRGB; // 1-component, 8-bit sRGB + case GL_SRG8: + return VK_FORMAT_R8G8_SRGB; // 2-component, 8-bit sRGB + case GL_SRGB8: + return VK_FORMAT_R8G8B8_SRGB; // 3-component, 8-bit sRGB + case GL_SRGB8_ALPHA8: + return VK_FORMAT_R8G8B8A8_SRGB; // 4-component, 8-bit sRGB + + // + // 16 bits per component + // + case GL_R16: + return VK_FORMAT_R16_UNORM; // 1-component, 16-bit unsigned normalized + case GL_RG16: + return VK_FORMAT_R16G16_UNORM; // 2-component, 16-bit unsigned normalized + case GL_RGB16: + return VK_FORMAT_R16G16B16_UNORM; // 3-component, 16-bit unsigned normalized + case GL_RGBA16: + return VK_FORMAT_R16G16B16A16_UNORM; // 4-component, 16-bit unsigned normalized + + case GL_R16_SNORM: + return VK_FORMAT_R16_SNORM; // 1-component, 16-bit signed normalized + case GL_RG16_SNORM: + return VK_FORMAT_R16G16_SNORM; // 2-component, 16-bit signed normalized + case GL_RGB16_SNORM: + return VK_FORMAT_R16G16B16_SNORM; // 3-component, 16-bit signed normalized + case GL_RGBA16_SNORM: + return VK_FORMAT_R16G16B16A16_SNORM; // 4-component, 16-bit signed normalized + + case GL_R16UI: + return VK_FORMAT_R16_UINT; // 1-component, 16-bit unsigned integer + case GL_RG16UI: + return VK_FORMAT_R16G16_UINT; // 2-component, 16-bit unsigned integer + case GL_RGB16UI: + return VK_FORMAT_R16G16B16_UINT; // 3-component, 16-bit unsigned integer + case GL_RGBA16UI: + return VK_FORMAT_R16G16B16A16_UINT; // 4-component, 16-bit unsigned integer + + case GL_R16I: + return VK_FORMAT_R16_SINT; // 1-component, 16-bit signed integer + case GL_RG16I: + return VK_FORMAT_R16G16_SINT; // 2-component, 16-bit signed integer + case GL_RGB16I: + return VK_FORMAT_R16G16B16_SINT; // 3-component, 16-bit signed integer + case GL_RGBA16I: + return VK_FORMAT_R16G16B16A16_SINT; // 4-component, 16-bit signed integer + + case GL_R16F: + return VK_FORMAT_R16_SFLOAT; // 1-component, 16-bit floating-point + case GL_RG16F: + return VK_FORMAT_R16G16_SFLOAT; // 2-component, 16-bit floating-point + case GL_RGB16F: + return VK_FORMAT_R16G16B16_SFLOAT; // 3-component, 16-bit floating-point + case GL_RGBA16F: + return VK_FORMAT_R16G16B16A16_SFLOAT; // 4-component, 16-bit floating-point + + // + // 32 bits per component + // + case GL_R32UI: + return VK_FORMAT_R32_UINT; // 1-component, 32-bit unsigned integer + case GL_RG32UI: + return VK_FORMAT_R32G32_UINT; // 2-component, 32-bit unsigned integer + case GL_RGB32UI: + return VK_FORMAT_R32G32B32_UINT; // 3-component, 32-bit unsigned integer + case GL_RGBA32UI: + return VK_FORMAT_R32G32B32A32_UINT; // 4-component, 32-bit unsigned integer + + case GL_R32I: + return VK_FORMAT_R32_SINT; // 1-component, 32-bit signed integer + case GL_RG32I: + return VK_FORMAT_R32G32_SINT; // 2-component, 32-bit signed integer + case GL_RGB32I: + return VK_FORMAT_R32G32B32_SINT; // 3-component, 32-bit signed integer + case GL_RGBA32I: + return VK_FORMAT_R32G32B32A32_SINT; // 4-component, 32-bit signed integer + + case GL_R32F: + return VK_FORMAT_R32_SFLOAT; // 1-component, 32-bit floating-point + case GL_RG32F: + return VK_FORMAT_R32G32_SFLOAT; // 2-component, 32-bit floating-point + case GL_RGB32F: + return VK_FORMAT_R32G32B32_SFLOAT; // 3-component, 32-bit floating-point + case GL_RGBA32F: + return VK_FORMAT_R32G32B32A32_SFLOAT; // 4-component, 32-bit floating-point + + // + // Packed + // + case GL_R3_G3_B2: + return VK_FORMAT_UNDEFINED; // 3-component 3:3:2, unsigned normalized + case GL_RGB4: + return VK_FORMAT_UNDEFINED; // 3-component 4:4:4, unsigned normalized + case GL_RGB5: + return VK_FORMAT_R5G5B5A1_UNORM_PACK16; // 3-component 5:5:5, unsigned normalized + case GL_RGB565: + return VK_FORMAT_R5G6B5_UNORM_PACK16; // 3-component 5:6:5, unsigned normalized + case GL_RGB10: + return VK_FORMAT_A2R10G10B10_UNORM_PACK32; // 3-component 10:10:10, unsigned normalized + case GL_RGB12: + return VK_FORMAT_UNDEFINED; // 3-component 12:12:12, unsigned normalized + case GL_RGBA2: + return VK_FORMAT_UNDEFINED; // 4-component 2:2:2:2, unsigned normalized + case GL_RGBA4: + return VK_FORMAT_R4G4B4A4_UNORM_PACK16; // 4-component 4:4:4:4, unsigned normalized + case GL_RGBA12: + return VK_FORMAT_UNDEFINED; // 4-component 12:12:12:12, unsigned normalized + case GL_RGB5_A1: + return VK_FORMAT_A1R5G5B5_UNORM_PACK16; // 4-component 5:5:5:1, unsigned normalized + case GL_RGB10_A2: + return VK_FORMAT_A2R10G10B10_UNORM_PACK32; // 4-component 10:10:10:2, unsigned normalized + case GL_RGB10_A2UI: + return VK_FORMAT_A2R10G10B10_UINT_PACK32; // 4-component 10:10:10:2, unsigned integer + case GL_R11F_G11F_B10F: + return VK_FORMAT_B10G11R11_UFLOAT_PACK32; // 3-component 11:11:10, floating-point + case GL_RGB9_E5: + return VK_FORMAT_E5B9G9R9_UFLOAT_PACK32; // 3-component/exp 9:9:9/5, floating-point + + // + // S3TC/DXT/BC + // + + case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: + return VK_FORMAT_BC1_RGB_UNORM_BLOCK; // line through 3D space, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: + return VK_FORMAT_BC1_RGBA_UNORM_BLOCK; // line through 3D space plus 1-bit alpha, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: + return VK_FORMAT_BC2_UNORM_BLOCK; // line through 3D space plus line through 1D space, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: + return VK_FORMAT_BC3_UNORM_BLOCK; // line through 3D space plus 4-bit alpha, 4x4 blocks, unsigned normalized + + case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: + return VK_FORMAT_BC1_RGB_SRGB_BLOCK; // line through 3D space, 4x4 blocks, sRGB + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: + return VK_FORMAT_BC1_RGBA_SRGB_BLOCK; // line through 3D space plus 1-bit alpha, 4x4 blocks, sRGB + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: + return VK_FORMAT_BC2_SRGB_BLOCK; // line through 3D space plus line through 1D space, 4x4 blocks, sRGB + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: + return VK_FORMAT_BC3_SRGB_BLOCK; // line through 3D space plus 4-bit alpha, 4x4 blocks, sRGB + + case GL_COMPRESSED_LUMINANCE_LATC1_EXT: + return VK_FORMAT_BC4_UNORM_BLOCK; // line through 1D space, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT: + return VK_FORMAT_BC5_UNORM_BLOCK; // two lines through 1D space, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT: + return VK_FORMAT_BC4_SNORM_BLOCK; // line through 1D space, 4x4 blocks, signed normalized + case GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT: + return VK_FORMAT_BC5_SNORM_BLOCK; // two lines through 1D space, 4x4 blocks, signed normalized + + case GL_COMPRESSED_RED_RGTC1: + return VK_FORMAT_BC4_UNORM_BLOCK; // line through 1D space, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_RG_RGTC2: + return VK_FORMAT_BC5_UNORM_BLOCK; // two lines through 1D space, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_SIGNED_RED_RGTC1: + return VK_FORMAT_BC4_SNORM_BLOCK; // line through 1D space, 4x4 blocks, signed normalized + case GL_COMPRESSED_SIGNED_RG_RGTC2: + return VK_FORMAT_BC5_SNORM_BLOCK; // two lines through 1D space, 4x4 blocks, signed normalized + + case GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT: + return VK_FORMAT_BC6H_UFLOAT_BLOCK; // 3-component, 4x4 blocks, unsigned floating-point + case GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT: + return VK_FORMAT_BC6H_SFLOAT_BLOCK; // 3-component, 4x4 blocks, signed floating-point + case GL_COMPRESSED_RGBA_BPTC_UNORM: + return VK_FORMAT_BC7_UNORM_BLOCK; // 4-component, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM: + return VK_FORMAT_BC7_SRGB_BLOCK; // 4-component, 4x4 blocks, sRGB + + // + // ETC + // + case GL_ETC1_RGB8_OES: + return VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK; // 3-component ETC1, 4x4 blocks, unsigned normalized + + case GL_COMPRESSED_RGB8_ETC2: + return VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK; // 3-component ETC2, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: + return VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK; // 4-component ETC2 with 1-bit alpha, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_RGBA8_ETC2_EAC: + return VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK; // 4-component ETC2, 4x4 blocks, unsigned normalized + + case GL_COMPRESSED_SRGB8_ETC2: + return VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK; // 3-component ETC2, 4x4 blocks, sRGB + case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: + return VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK; // 4-component ETC2 with 1-bit alpha, 4x4 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: + return VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK; // 4-component ETC2, 4x4 blocks, sRGB + + case GL_COMPRESSED_R11_EAC: + return VK_FORMAT_EAC_R11_UNORM_BLOCK; // 1-component ETC, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_RG11_EAC: + return VK_FORMAT_EAC_R11G11_UNORM_BLOCK; // 2-component ETC, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_SIGNED_R11_EAC: + return VK_FORMAT_EAC_R11_SNORM_BLOCK; // 1-component ETC, 4x4 blocks, signed normalized + case GL_COMPRESSED_SIGNED_RG11_EAC: + return VK_FORMAT_EAC_R11G11_SNORM_BLOCK; // 2-component ETC, 4x4 blocks, signed normalized + + // + // PVRTC + // + case GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG: + return VK_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG; // 3-component PVRTC, 16x8 blocks, unsigned normalized + case GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG: + return VK_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG; // 3-component PVRTC, 8x8 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: + return VK_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG; // 4-component PVRTC, 16x8 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: + return VK_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG; // 4-component PVRTC, 8x8 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG: + return VK_FORMAT_PVRTC2_2BPP_UNORM_BLOCK_IMG; // 4-component PVRTC, 8x4 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG: + return VK_FORMAT_PVRTC2_4BPP_UNORM_BLOCK_IMG; // 4-component PVRTC, 4x4 blocks, unsigned normalized + + case GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT: + return VK_FORMAT_PVRTC1_2BPP_SRGB_BLOCK_IMG; // 3-component PVRTC, 16x8 blocks, sRGB + case GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT: + return VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG; // 3-component PVRTC, 8x8 blocks, sRGB + case GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT: + return VK_FORMAT_PVRTC1_2BPP_SRGB_BLOCK_IMG; // 4-component PVRTC, 16x8 blocks, sRGB + case GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT: + return VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG; // 4-component PVRTC, 8x8 blocks, sRGB + case GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV2_IMG: + return VK_FORMAT_PVRTC2_2BPP_SRGB_BLOCK_IMG; // 4-component PVRTC, 8x4 blocks, sRGB + case GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV2_IMG: + return VK_FORMAT_PVRTC2_4BPP_SRGB_BLOCK_IMG; // 4-component PVRTC, 4x4 blocks, sRGB + + // + // ASTC + // + case GL_COMPRESSED_RGBA_ASTC_4x4_KHR: + return VK_FORMAT_ASTC_4x4_UNORM_BLOCK; // 4-component ASTC, 4x4 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_5x4_KHR: + return VK_FORMAT_ASTC_5x4_UNORM_BLOCK; // 4-component ASTC, 5x4 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_5x5_KHR: + return VK_FORMAT_ASTC_5x5_UNORM_BLOCK; // 4-component ASTC, 5x5 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_6x5_KHR: + return VK_FORMAT_ASTC_6x5_UNORM_BLOCK; // 4-component ASTC, 6x5 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_6x6_KHR: + return VK_FORMAT_ASTC_6x6_UNORM_BLOCK; // 4-component ASTC, 6x6 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_8x5_KHR: + return VK_FORMAT_ASTC_8x5_UNORM_BLOCK; // 4-component ASTC, 8x5 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_8x6_KHR: + return VK_FORMAT_ASTC_8x6_UNORM_BLOCK; // 4-component ASTC, 8x6 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_8x8_KHR: + return VK_FORMAT_ASTC_8x8_UNORM_BLOCK; // 4-component ASTC, 8x8 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_10x5_KHR: + return VK_FORMAT_ASTC_10x5_UNORM_BLOCK; // 4-component ASTC, 10x5 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_10x6_KHR: + return VK_FORMAT_ASTC_10x6_UNORM_BLOCK; // 4-component ASTC, 10x6 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_10x8_KHR: + return VK_FORMAT_ASTC_10x8_UNORM_BLOCK; // 4-component ASTC, 10x8 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_10x10_KHR: + return VK_FORMAT_ASTC_10x10_UNORM_BLOCK; // 4-component ASTC, 10x10 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_12x10_KHR: + return VK_FORMAT_ASTC_12x10_UNORM_BLOCK; // 4-component ASTC, 12x10 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_12x12_KHR: + return VK_FORMAT_ASTC_12x12_UNORM_BLOCK; // 4-component ASTC, 12x12 blocks, unsigned normalized + + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR: + return VK_FORMAT_ASTC_4x4_SRGB_BLOCK; // 4-component ASTC, 4x4 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR: + return VK_FORMAT_ASTC_5x4_SRGB_BLOCK; // 4-component ASTC, 5x4 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR: + return VK_FORMAT_ASTC_5x5_SRGB_BLOCK; // 4-component ASTC, 5x5 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR: + return VK_FORMAT_ASTC_6x5_SRGB_BLOCK; // 4-component ASTC, 6x5 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR: + return VK_FORMAT_ASTC_6x6_SRGB_BLOCK; // 4-component ASTC, 6x6 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR: + return VK_FORMAT_ASTC_8x5_SRGB_BLOCK; // 4-component ASTC, 8x5 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR: + return VK_FORMAT_ASTC_8x6_SRGB_BLOCK; // 4-component ASTC, 8x6 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR: + return VK_FORMAT_ASTC_8x8_SRGB_BLOCK; // 4-component ASTC, 8x8 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR: + return VK_FORMAT_ASTC_10x5_SRGB_BLOCK; // 4-component ASTC, 10x5 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR: + return VK_FORMAT_ASTC_10x6_SRGB_BLOCK; // 4-component ASTC, 10x6 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR: + return VK_FORMAT_ASTC_10x8_SRGB_BLOCK; // 4-component ASTC, 10x8 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR: + return VK_FORMAT_ASTC_10x10_SRGB_BLOCK; // 4-component ASTC, 10x10 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR: + return VK_FORMAT_ASTC_12x10_SRGB_BLOCK; // 4-component ASTC, 12x10 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR: + return VK_FORMAT_ASTC_12x12_SRGB_BLOCK; // 4-component ASTC, 12x12 blocks, sRGB + + case GL_COMPRESSED_RGBA_ASTC_3x3x3_OES: + return VK_FORMAT_UNDEFINED; // 4-component ASTC, 3x3x3 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_4x3x3_OES: + return VK_FORMAT_UNDEFINED; // 4-component ASTC, 4x3x3 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_4x4x3_OES: + return VK_FORMAT_UNDEFINED; // 4-component ASTC, 4x4x3 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_4x4x4_OES: + return VK_FORMAT_UNDEFINED; // 4-component ASTC, 4x4x4 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_5x4x4_OES: + return VK_FORMAT_UNDEFINED; // 4-component ASTC, 5x4x4 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_5x5x4_OES: + return VK_FORMAT_UNDEFINED; // 4-component ASTC, 5x5x4 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_5x5x5_OES: + return VK_FORMAT_UNDEFINED; // 4-component ASTC, 5x5x5 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_6x5x5_OES: + return VK_FORMAT_UNDEFINED; // 4-component ASTC, 6x5x5 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_6x6x5_OES: + return VK_FORMAT_UNDEFINED; // 4-component ASTC, 6x6x5 blocks, unsigned normalized + case GL_COMPRESSED_RGBA_ASTC_6x6x6_OES: + return VK_FORMAT_UNDEFINED; // 4-component ASTC, 6x6x6 blocks, unsigned normalized + + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_3x3x3_OES: + return VK_FORMAT_UNDEFINED; // 4-component ASTC, 3x3x3 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x3x3_OES: + return VK_FORMAT_UNDEFINED; // 4-component ASTC, 4x3x3 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x3_OES: + return VK_FORMAT_UNDEFINED; // 4-component ASTC, 4x4x3 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x4_OES: + return VK_FORMAT_UNDEFINED; // 4-component ASTC, 4x4x4 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4x4_OES: + return VK_FORMAT_UNDEFINED; // 4-component ASTC, 5x4x4 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x4_OES: + return VK_FORMAT_UNDEFINED; // 4-component ASTC, 5x5x4 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x5_OES: + return VK_FORMAT_UNDEFINED; // 4-component ASTC, 5x5x5 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5x5_OES: + return VK_FORMAT_UNDEFINED; // 4-component ASTC, 6x5x5 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x5_OES: + return VK_FORMAT_UNDEFINED; // 4-component ASTC, 6x6x5 blocks, sRGB + case GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x6_OES: + return VK_FORMAT_UNDEFINED; // 4-component ASTC, 6x6x6 blocks, sRGB + + // + // ATC + // + case GL_ATC_RGB_AMD: + return VK_FORMAT_UNDEFINED; // 3-component, 4x4 blocks, unsigned normalized + case GL_ATC_RGBA_EXPLICIT_ALPHA_AMD: + return VK_FORMAT_UNDEFINED; // 4-component, 4x4 blocks, unsigned normalized + case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD: + return VK_FORMAT_UNDEFINED; // 4-component, 4x4 blocks, unsigned normalized + + // + // Palletized + // + case GL_PALETTE4_RGB8_OES: + return VK_FORMAT_UNDEFINED; // 3-component 8:8:8, 4-bit palette, unsigned normalized + case GL_PALETTE4_RGBA8_OES: + return VK_FORMAT_UNDEFINED; // 4-component 8:8:8:8, 4-bit palette, unsigned normalized + case GL_PALETTE4_R5_G6_B5_OES: + return VK_FORMAT_UNDEFINED; // 3-component 5:6:5, 4-bit palette, unsigned normalized + case GL_PALETTE4_RGBA4_OES: + return VK_FORMAT_UNDEFINED; // 4-component 4:4:4:4, 4-bit palette, unsigned normalized + case GL_PALETTE4_RGB5_A1_OES: + return VK_FORMAT_UNDEFINED; // 4-component 5:5:5:1, 4-bit palette, unsigned normalized + case GL_PALETTE8_RGB8_OES: + return VK_FORMAT_UNDEFINED; // 3-component 8:8:8, 8-bit palette, unsigned normalized + case GL_PALETTE8_RGBA8_OES: + return VK_FORMAT_UNDEFINED; // 4-component 8:8:8:8, 8-bit palette, unsigned normalized + case GL_PALETTE8_R5_G6_B5_OES: + return VK_FORMAT_UNDEFINED; // 3-component 5:6:5, 8-bit palette, unsigned normalized + case GL_PALETTE8_RGBA4_OES: + return VK_FORMAT_UNDEFINED; // 4-component 4:4:4:4, 8-bit palette, unsigned normalized + case GL_PALETTE8_RGB5_A1_OES: + return VK_FORMAT_UNDEFINED; // 4-component 5:5:5:1, 8-bit palette, unsigned normalized + + // + // Depth/stencil + // + case GL_DEPTH_COMPONENT16: + return VK_FORMAT_D16_UNORM; + case GL_DEPTH_COMPONENT24: + return VK_FORMAT_X8_D24_UNORM_PACK32; + case GL_DEPTH_COMPONENT32: + return VK_FORMAT_UNDEFINED; + case GL_DEPTH_COMPONENT32F: + return VK_FORMAT_D32_SFLOAT; + case GL_DEPTH_COMPONENT32F_NV: + return VK_FORMAT_D32_SFLOAT; + case GL_STENCIL_INDEX1: + return VK_FORMAT_UNDEFINED; + case GL_STENCIL_INDEX4: + return VK_FORMAT_UNDEFINED; + case GL_STENCIL_INDEX8: + return VK_FORMAT_S8_UINT; + case GL_STENCIL_INDEX16: + return VK_FORMAT_UNDEFINED; + case GL_DEPTH24_STENCIL8: + return VK_FORMAT_D24_UNORM_S8_UINT; + case GL_DEPTH32F_STENCIL8: + return VK_FORMAT_D32_SFLOAT_S8_UINT; + case GL_DEPTH32F_STENCIL8_NV: + return VK_FORMAT_D32_SFLOAT_S8_UINT; + + default: + return VK_FORMAT_UNDEFINED; + } } #if defined(NEED_VK_GET_FORMAT_SIZE) -static inline void vkGetFormatSize( const VkFormat format, ktxFormatSize * pFormatSize ) -{ - pFormatSize->minBlocksX = pFormatSize->minBlocksY = 1; - switch ( format ) - { - case VK_FORMAT_R4G4_UNORM_PACK8: - pFormatSize->flags = KTX_FORMAT_SIZE_PACKED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 1 * 8; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case VK_FORMAT_R4G4B4A4_UNORM_PACK16: - case VK_FORMAT_B4G4R4A4_UNORM_PACK16: - case VK_FORMAT_R5G6B5_UNORM_PACK16: - case VK_FORMAT_B5G6R5_UNORM_PACK16: - case VK_FORMAT_R5G5B5A1_UNORM_PACK16: - case VK_FORMAT_B5G5R5A1_UNORM_PACK16: - case VK_FORMAT_A1R5G5B5_UNORM_PACK16: - pFormatSize->flags = KTX_FORMAT_SIZE_PACKED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 2 * 8; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case VK_FORMAT_R8_UNORM: - case VK_FORMAT_R8_SNORM: - case VK_FORMAT_R8_USCALED: - case VK_FORMAT_R8_SSCALED: - case VK_FORMAT_R8_UINT: - case VK_FORMAT_R8_SINT: - case VK_FORMAT_R8_SRGB: - pFormatSize->flags = 0; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 1 * 8; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case VK_FORMAT_R8G8_UNORM: - case VK_FORMAT_R8G8_SNORM: - case VK_FORMAT_R8G8_USCALED: - case VK_FORMAT_R8G8_SSCALED: - case VK_FORMAT_R8G8_UINT: - case VK_FORMAT_R8G8_SINT: - case VK_FORMAT_R8G8_SRGB: - pFormatSize->flags = 0; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 2 * 8; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case VK_FORMAT_R8G8B8_UNORM: - case VK_FORMAT_R8G8B8_SNORM: - case VK_FORMAT_R8G8B8_USCALED: - case VK_FORMAT_R8G8B8_SSCALED: - case VK_FORMAT_R8G8B8_UINT: - case VK_FORMAT_R8G8B8_SINT: - case VK_FORMAT_R8G8B8_SRGB: - case VK_FORMAT_B8G8R8_UNORM: - case VK_FORMAT_B8G8R8_SNORM: - case VK_FORMAT_B8G8R8_USCALED: - case VK_FORMAT_B8G8R8_SSCALED: - case VK_FORMAT_B8G8R8_UINT: - case VK_FORMAT_B8G8R8_SINT: - case VK_FORMAT_B8G8R8_SRGB: - pFormatSize->flags = 0; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 3 * 8; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case VK_FORMAT_R8G8B8A8_UNORM: - case VK_FORMAT_R8G8B8A8_SNORM: - case VK_FORMAT_R8G8B8A8_USCALED: - case VK_FORMAT_R8G8B8A8_SSCALED: - case VK_FORMAT_R8G8B8A8_UINT: - case VK_FORMAT_R8G8B8A8_SINT: - case VK_FORMAT_R8G8B8A8_SRGB: - case VK_FORMAT_B8G8R8A8_UNORM: - case VK_FORMAT_B8G8R8A8_SNORM: - case VK_FORMAT_B8G8R8A8_USCALED: - case VK_FORMAT_B8G8R8A8_SSCALED: - case VK_FORMAT_B8G8R8A8_UINT: - case VK_FORMAT_B8G8R8A8_SINT: - case VK_FORMAT_B8G8R8A8_SRGB: - pFormatSize->flags = 0; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 4 * 8; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case VK_FORMAT_A8B8G8R8_UNORM_PACK32: - case VK_FORMAT_A8B8G8R8_SNORM_PACK32: - case VK_FORMAT_A8B8G8R8_USCALED_PACK32: - case VK_FORMAT_A8B8G8R8_SSCALED_PACK32: - case VK_FORMAT_A8B8G8R8_UINT_PACK32: - case VK_FORMAT_A8B8G8R8_SINT_PACK32: - case VK_FORMAT_A8B8G8R8_SRGB_PACK32: - pFormatSize->flags = KTX_FORMAT_SIZE_PACKED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 4 * 8; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case VK_FORMAT_A2R10G10B10_UNORM_PACK32: - case VK_FORMAT_A2R10G10B10_SNORM_PACK32: - case VK_FORMAT_A2R10G10B10_USCALED_PACK32: - case VK_FORMAT_A2R10G10B10_SSCALED_PACK32: - case VK_FORMAT_A2R10G10B10_UINT_PACK32: - case VK_FORMAT_A2R10G10B10_SINT_PACK32: - case VK_FORMAT_A2B10G10R10_UNORM_PACK32: - case VK_FORMAT_A2B10G10R10_SNORM_PACK32: - case VK_FORMAT_A2B10G10R10_USCALED_PACK32: - case VK_FORMAT_A2B10G10R10_SSCALED_PACK32: - case VK_FORMAT_A2B10G10R10_UINT_PACK32: - case VK_FORMAT_A2B10G10R10_SINT_PACK32: - pFormatSize->flags = KTX_FORMAT_SIZE_PACKED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 4 * 8; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case VK_FORMAT_R16_UNORM: - case VK_FORMAT_R16_SNORM: - case VK_FORMAT_R16_USCALED: - case VK_FORMAT_R16_SSCALED: - case VK_FORMAT_R16_UINT: - case VK_FORMAT_R16_SINT: - case VK_FORMAT_R16_SFLOAT: - pFormatSize->flags = 0; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 2 * 8; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case VK_FORMAT_R16G16_UNORM: - case VK_FORMAT_R16G16_SNORM: - case VK_FORMAT_R16G16_USCALED: - case VK_FORMAT_R16G16_SSCALED: - case VK_FORMAT_R16G16_UINT: - case VK_FORMAT_R16G16_SINT: - case VK_FORMAT_R16G16_SFLOAT: - pFormatSize->flags = 0; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 4 * 8; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case VK_FORMAT_R16G16B16_UNORM: - case VK_FORMAT_R16G16B16_SNORM: - case VK_FORMAT_R16G16B16_USCALED: - case VK_FORMAT_R16G16B16_SSCALED: - case VK_FORMAT_R16G16B16_UINT: - case VK_FORMAT_R16G16B16_SINT: - case VK_FORMAT_R16G16B16_SFLOAT: - pFormatSize->flags = 0; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 6 * 8; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case VK_FORMAT_R16G16B16A16_UNORM: - case VK_FORMAT_R16G16B16A16_SNORM: - case VK_FORMAT_R16G16B16A16_USCALED: - case VK_FORMAT_R16G16B16A16_SSCALED: - case VK_FORMAT_R16G16B16A16_UINT: - case VK_FORMAT_R16G16B16A16_SINT: - case VK_FORMAT_R16G16B16A16_SFLOAT: - pFormatSize->flags = 0; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 8 * 8; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case VK_FORMAT_R32_UINT: - case VK_FORMAT_R32_SINT: - case VK_FORMAT_R32_SFLOAT: - pFormatSize->flags = 0; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 4 * 8; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case VK_FORMAT_R32G32_UINT: - case VK_FORMAT_R32G32_SINT: - case VK_FORMAT_R32G32_SFLOAT: - pFormatSize->flags = 0; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 8 * 8; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case VK_FORMAT_R32G32B32_UINT: - case VK_FORMAT_R32G32B32_SINT: - case VK_FORMAT_R32G32B32_SFLOAT: - pFormatSize->flags = 0; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 12 * 8; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case VK_FORMAT_R32G32B32A32_UINT: - case VK_FORMAT_R32G32B32A32_SINT: - case VK_FORMAT_R32G32B32A32_SFLOAT: - pFormatSize->flags = 0; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 16 * 8; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case VK_FORMAT_R64_UINT: - case VK_FORMAT_R64_SINT: - case VK_FORMAT_R64_SFLOAT: - pFormatSize->flags = 0; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 8 * 8; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case VK_FORMAT_R64G64_UINT: - case VK_FORMAT_R64G64_SINT: - case VK_FORMAT_R64G64_SFLOAT: - pFormatSize->flags = 0; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 16 * 8; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case VK_FORMAT_R64G64B64_UINT: - case VK_FORMAT_R64G64B64_SINT: - case VK_FORMAT_R64G64B64_SFLOAT: - pFormatSize->flags = 0; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 24 * 8; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case VK_FORMAT_R64G64B64A64_UINT: - case VK_FORMAT_R64G64B64A64_SINT: - case VK_FORMAT_R64G64B64A64_SFLOAT: - pFormatSize->flags = 0; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 32 * 8; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case VK_FORMAT_B10G11R11_UFLOAT_PACK32: - case VK_FORMAT_E5B9G9R9_UFLOAT_PACK32: - pFormatSize->flags = KTX_FORMAT_SIZE_PACKED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 4 * 8; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case VK_FORMAT_D16_UNORM: - pFormatSize->flags = KTX_FORMAT_SIZE_DEPTH_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 2 * 8; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case VK_FORMAT_X8_D24_UNORM_PACK32: - pFormatSize->flags = KTX_FORMAT_SIZE_PACKED_BIT | KTX_FORMAT_SIZE_DEPTH_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 4 * 8; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case VK_FORMAT_D32_SFLOAT: - pFormatSize->flags = KTX_FORMAT_SIZE_DEPTH_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 4 * 8; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case VK_FORMAT_S8_UINT: - pFormatSize->flags = KTX_FORMAT_SIZE_STENCIL_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 1 * 8; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case VK_FORMAT_D16_UNORM_S8_UINT: - pFormatSize->flags = KTX_FORMAT_SIZE_DEPTH_BIT | KTX_FORMAT_SIZE_STENCIL_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 3 * 8; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case VK_FORMAT_D24_UNORM_S8_UINT: - pFormatSize->flags = KTX_FORMAT_SIZE_DEPTH_BIT | KTX_FORMAT_SIZE_STENCIL_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 4 * 8; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case VK_FORMAT_D32_SFLOAT_S8_UINT: - pFormatSize->flags = KTX_FORMAT_SIZE_DEPTH_BIT | KTX_FORMAT_SIZE_STENCIL_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 8 * 8; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - case VK_FORMAT_BC1_RGB_UNORM_BLOCK: - case VK_FORMAT_BC1_RGB_SRGB_BLOCK: - case VK_FORMAT_BC1_RGBA_UNORM_BLOCK: - case VK_FORMAT_BC1_RGBA_SRGB_BLOCK: - case VK_FORMAT_BC4_UNORM_BLOCK: - case VK_FORMAT_BC4_SNORM_BLOCK: - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 8 * 8; - pFormatSize->blockWidth = 4; - pFormatSize->blockHeight = 4; - pFormatSize->blockDepth = 1; - break; - case VK_FORMAT_BC2_UNORM_BLOCK: - case VK_FORMAT_BC2_SRGB_BLOCK: - case VK_FORMAT_BC3_UNORM_BLOCK: - case VK_FORMAT_BC3_SRGB_BLOCK: - case VK_FORMAT_BC5_UNORM_BLOCK: - case VK_FORMAT_BC5_SNORM_BLOCK: - case VK_FORMAT_BC6H_UFLOAT_BLOCK: - case VK_FORMAT_BC6H_SFLOAT_BLOCK: - case VK_FORMAT_BC7_UNORM_BLOCK: - case VK_FORMAT_BC7_SRGB_BLOCK: - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 16 * 8; - pFormatSize->blockWidth = 4; - pFormatSize->blockHeight = 4; - pFormatSize->blockDepth = 1; - break; - case VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK: - case VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK: - case VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK: - case VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK: - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 8 * 8; - pFormatSize->blockWidth = 4; - pFormatSize->blockHeight = 4; - pFormatSize->blockDepth = 1; - break; - case VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK: - case VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK: - case VK_FORMAT_EAC_R11_UNORM_BLOCK: - case VK_FORMAT_EAC_R11_SNORM_BLOCK: - case VK_FORMAT_EAC_R11G11_UNORM_BLOCK: - case VK_FORMAT_EAC_R11G11_SNORM_BLOCK: - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 16 * 8; - pFormatSize->blockWidth = 4; - pFormatSize->blockHeight = 4; - pFormatSize->blockDepth = 1; - break; - case VK_FORMAT_PVRTC1_2BPP_SRGB_BLOCK_IMG: - case VK_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG: - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 8 * 8; - pFormatSize->blockWidth = 8; - pFormatSize->blockHeight = 4; - pFormatSize->blockDepth = 1; - pFormatSize->minBlocksX = 2; - pFormatSize->minBlocksY = 2; - break; - case VK_FORMAT_PVRTC2_2BPP_SRGB_BLOCK_IMG: - case VK_FORMAT_PVRTC2_2BPP_UNORM_BLOCK_IMG: - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 8 * 8; - pFormatSize->blockWidth = 8; - pFormatSize->blockHeight = 4; - pFormatSize->blockDepth = 1; - break; - case VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG: - case VK_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG: - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 8 * 8; - pFormatSize->blockWidth = 4; - pFormatSize->blockHeight = 4; - pFormatSize->blockDepth = 1; - pFormatSize->minBlocksX = 2; - pFormatSize->minBlocksY = 2; - break; - case VK_FORMAT_PVRTC2_4BPP_SRGB_BLOCK_IMG: - case VK_FORMAT_PVRTC2_4BPP_UNORM_BLOCK_IMG: - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 8 * 8; - pFormatSize->blockWidth = 4; - pFormatSize->blockHeight = 4; - pFormatSize->blockDepth = 1; - break; - case VK_FORMAT_ASTC_4x4_UNORM_BLOCK: - case VK_FORMAT_ASTC_4x4_SRGB_BLOCK: - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 16 * 8; - pFormatSize->blockWidth = 4; - pFormatSize->blockHeight = 4; - pFormatSize->blockDepth = 1; - break; - case VK_FORMAT_ASTC_5x4_UNORM_BLOCK: - case VK_FORMAT_ASTC_5x4_SRGB_BLOCK: - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 16 * 8; - pFormatSize->blockWidth = 5; - pFormatSize->blockHeight = 4; - pFormatSize->blockDepth = 1; - break; - case VK_FORMAT_ASTC_5x5_UNORM_BLOCK: - case VK_FORMAT_ASTC_5x5_SRGB_BLOCK: - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 16 * 8; - pFormatSize->blockWidth = 5; - pFormatSize->blockHeight = 5; - pFormatSize->blockDepth = 1; - break; - case VK_FORMAT_ASTC_6x5_UNORM_BLOCK: - case VK_FORMAT_ASTC_6x5_SRGB_BLOCK: - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 16 * 8; - pFormatSize->blockWidth = 6; - pFormatSize->blockHeight = 5; - pFormatSize->blockDepth = 1; - break; - case VK_FORMAT_ASTC_6x6_UNORM_BLOCK: - case VK_FORMAT_ASTC_6x6_SRGB_BLOCK: - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 16 * 8; - pFormatSize->blockWidth = 6; - pFormatSize->blockHeight = 6; - pFormatSize->blockDepth = 1; - break; - case VK_FORMAT_ASTC_8x5_UNORM_BLOCK: - case VK_FORMAT_ASTC_8x5_SRGB_BLOCK: - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 16 * 8; - pFormatSize->blockWidth = 8; - pFormatSize->blockHeight = 5; - pFormatSize->blockDepth = 1; - break; - case VK_FORMAT_ASTC_8x6_UNORM_BLOCK: - case VK_FORMAT_ASTC_8x6_SRGB_BLOCK: - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 16 * 8; - pFormatSize->blockWidth = 8; - pFormatSize->blockHeight = 6; - pFormatSize->blockDepth = 1; - break; - case VK_FORMAT_ASTC_8x8_UNORM_BLOCK: - case VK_FORMAT_ASTC_8x8_SRGB_BLOCK: - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 16 * 8; - pFormatSize->blockWidth = 8; - pFormatSize->blockHeight = 8; - pFormatSize->blockDepth = 1; - break; - case VK_FORMAT_ASTC_10x5_UNORM_BLOCK: - case VK_FORMAT_ASTC_10x5_SRGB_BLOCK: - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 16 * 8; - pFormatSize->blockWidth = 10; - pFormatSize->blockHeight = 5; - pFormatSize->blockDepth = 1; - break; - case VK_FORMAT_ASTC_10x6_UNORM_BLOCK: - case VK_FORMAT_ASTC_10x6_SRGB_BLOCK: - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 16 * 8; - pFormatSize->blockWidth = 10; - pFormatSize->blockHeight = 6; - pFormatSize->blockDepth = 1; - break; - case VK_FORMAT_ASTC_10x8_UNORM_BLOCK: - case VK_FORMAT_ASTC_10x8_SRGB_BLOCK: - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 16 * 8; - pFormatSize->blockWidth = 10; - pFormatSize->blockHeight = 8; - pFormatSize->blockDepth = 1; - break; - case VK_FORMAT_ASTC_10x10_UNORM_BLOCK: - case VK_FORMAT_ASTC_10x10_SRGB_BLOCK: - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 16 * 8; - pFormatSize->blockWidth = 10; - pFormatSize->blockHeight = 10; - pFormatSize->blockDepth = 1; - break; - case VK_FORMAT_ASTC_12x10_UNORM_BLOCK: - case VK_FORMAT_ASTC_12x10_SRGB_BLOCK: - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 16 * 8; - pFormatSize->blockWidth = 12; - pFormatSize->blockHeight = 10; - pFormatSize->blockDepth = 1; - break; - case VK_FORMAT_ASTC_12x12_UNORM_BLOCK: - case VK_FORMAT_ASTC_12x12_SRGB_BLOCK: - pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 16 * 8; - pFormatSize->blockWidth = 12; - pFormatSize->blockHeight = 12; - pFormatSize->blockDepth = 1; - break; - default: - pFormatSize->flags = 0; - pFormatSize->paletteSizeInBits = 0; - pFormatSize->blockSizeInBits = 0 * 8; - pFormatSize->blockWidth = 1; - pFormatSize->blockHeight = 1; - pFormatSize->blockDepth = 1; - break; - } +static inline void +vkGetFormatSize(const VkFormat format, ktxFormatSize* pFormatSize) { + pFormatSize->minBlocksX = pFormatSize->minBlocksY = 1; + switch (format) { + case VK_FORMAT_R4G4_UNORM_PACK8: + pFormatSize->flags = KTX_FORMAT_SIZE_PACKED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 1 * 8; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case VK_FORMAT_R4G4B4A4_UNORM_PACK16: + case VK_FORMAT_B4G4R4A4_UNORM_PACK16: + case VK_FORMAT_R5G6B5_UNORM_PACK16: + case VK_FORMAT_B5G6R5_UNORM_PACK16: + case VK_FORMAT_R5G5B5A1_UNORM_PACK16: + case VK_FORMAT_B5G5R5A1_UNORM_PACK16: + case VK_FORMAT_A1R5G5B5_UNORM_PACK16: + pFormatSize->flags = KTX_FORMAT_SIZE_PACKED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 2 * 8; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case VK_FORMAT_R8_UNORM: + case VK_FORMAT_R8_SNORM: + case VK_FORMAT_R8_USCALED: + case VK_FORMAT_R8_SSCALED: + case VK_FORMAT_R8_UINT: + case VK_FORMAT_R8_SINT: + case VK_FORMAT_R8_SRGB: + pFormatSize->flags = 0; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 1 * 8; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case VK_FORMAT_R8G8_UNORM: + case VK_FORMAT_R8G8_SNORM: + case VK_FORMAT_R8G8_USCALED: + case VK_FORMAT_R8G8_SSCALED: + case VK_FORMAT_R8G8_UINT: + case VK_FORMAT_R8G8_SINT: + case VK_FORMAT_R8G8_SRGB: + pFormatSize->flags = 0; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 2 * 8; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case VK_FORMAT_R8G8B8_UNORM: + case VK_FORMAT_R8G8B8_SNORM: + case VK_FORMAT_R8G8B8_USCALED: + case VK_FORMAT_R8G8B8_SSCALED: + case VK_FORMAT_R8G8B8_UINT: + case VK_FORMAT_R8G8B8_SINT: + case VK_FORMAT_R8G8B8_SRGB: + case VK_FORMAT_B8G8R8_UNORM: + case VK_FORMAT_B8G8R8_SNORM: + case VK_FORMAT_B8G8R8_USCALED: + case VK_FORMAT_B8G8R8_SSCALED: + case VK_FORMAT_B8G8R8_UINT: + case VK_FORMAT_B8G8R8_SINT: + case VK_FORMAT_B8G8R8_SRGB: + pFormatSize->flags = 0; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 3 * 8; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case VK_FORMAT_R8G8B8A8_UNORM: + case VK_FORMAT_R8G8B8A8_SNORM: + case VK_FORMAT_R8G8B8A8_USCALED: + case VK_FORMAT_R8G8B8A8_SSCALED: + case VK_FORMAT_R8G8B8A8_UINT: + case VK_FORMAT_R8G8B8A8_SINT: + case VK_FORMAT_R8G8B8A8_SRGB: + case VK_FORMAT_B8G8R8A8_UNORM: + case VK_FORMAT_B8G8R8A8_SNORM: + case VK_FORMAT_B8G8R8A8_USCALED: + case VK_FORMAT_B8G8R8A8_SSCALED: + case VK_FORMAT_B8G8R8A8_UINT: + case VK_FORMAT_B8G8R8A8_SINT: + case VK_FORMAT_B8G8R8A8_SRGB: + pFormatSize->flags = 0; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 4 * 8; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case VK_FORMAT_A8B8G8R8_UNORM_PACK32: + case VK_FORMAT_A8B8G8R8_SNORM_PACK32: + case VK_FORMAT_A8B8G8R8_USCALED_PACK32: + case VK_FORMAT_A8B8G8R8_SSCALED_PACK32: + case VK_FORMAT_A8B8G8R8_UINT_PACK32: + case VK_FORMAT_A8B8G8R8_SINT_PACK32: + case VK_FORMAT_A8B8G8R8_SRGB_PACK32: + pFormatSize->flags = KTX_FORMAT_SIZE_PACKED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 4 * 8; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case VK_FORMAT_A2R10G10B10_UNORM_PACK32: + case VK_FORMAT_A2R10G10B10_SNORM_PACK32: + case VK_FORMAT_A2R10G10B10_USCALED_PACK32: + case VK_FORMAT_A2R10G10B10_SSCALED_PACK32: + case VK_FORMAT_A2R10G10B10_UINT_PACK32: + case VK_FORMAT_A2R10G10B10_SINT_PACK32: + case VK_FORMAT_A2B10G10R10_UNORM_PACK32: + case VK_FORMAT_A2B10G10R10_SNORM_PACK32: + case VK_FORMAT_A2B10G10R10_USCALED_PACK32: + case VK_FORMAT_A2B10G10R10_SSCALED_PACK32: + case VK_FORMAT_A2B10G10R10_UINT_PACK32: + case VK_FORMAT_A2B10G10R10_SINT_PACK32: + pFormatSize->flags = KTX_FORMAT_SIZE_PACKED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 4 * 8; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case VK_FORMAT_R16_UNORM: + case VK_FORMAT_R16_SNORM: + case VK_FORMAT_R16_USCALED: + case VK_FORMAT_R16_SSCALED: + case VK_FORMAT_R16_UINT: + case VK_FORMAT_R16_SINT: + case VK_FORMAT_R16_SFLOAT: + pFormatSize->flags = 0; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 2 * 8; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case VK_FORMAT_R16G16_UNORM: + case VK_FORMAT_R16G16_SNORM: + case VK_FORMAT_R16G16_USCALED: + case VK_FORMAT_R16G16_SSCALED: + case VK_FORMAT_R16G16_UINT: + case VK_FORMAT_R16G16_SINT: + case VK_FORMAT_R16G16_SFLOAT: + pFormatSize->flags = 0; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 4 * 8; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case VK_FORMAT_R16G16B16_UNORM: + case VK_FORMAT_R16G16B16_SNORM: + case VK_FORMAT_R16G16B16_USCALED: + case VK_FORMAT_R16G16B16_SSCALED: + case VK_FORMAT_R16G16B16_UINT: + case VK_FORMAT_R16G16B16_SINT: + case VK_FORMAT_R16G16B16_SFLOAT: + pFormatSize->flags = 0; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 6 * 8; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case VK_FORMAT_R16G16B16A16_UNORM: + case VK_FORMAT_R16G16B16A16_SNORM: + case VK_FORMAT_R16G16B16A16_USCALED: + case VK_FORMAT_R16G16B16A16_SSCALED: + case VK_FORMAT_R16G16B16A16_UINT: + case VK_FORMAT_R16G16B16A16_SINT: + case VK_FORMAT_R16G16B16A16_SFLOAT: + pFormatSize->flags = 0; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 8 * 8; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case VK_FORMAT_R32_UINT: + case VK_FORMAT_R32_SINT: + case VK_FORMAT_R32_SFLOAT: + pFormatSize->flags = 0; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 4 * 8; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case VK_FORMAT_R32G32_UINT: + case VK_FORMAT_R32G32_SINT: + case VK_FORMAT_R32G32_SFLOAT: + pFormatSize->flags = 0; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 8 * 8; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case VK_FORMAT_R32G32B32_UINT: + case VK_FORMAT_R32G32B32_SINT: + case VK_FORMAT_R32G32B32_SFLOAT: + pFormatSize->flags = 0; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 12 * 8; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case VK_FORMAT_R32G32B32A32_UINT: + case VK_FORMAT_R32G32B32A32_SINT: + case VK_FORMAT_R32G32B32A32_SFLOAT: + pFormatSize->flags = 0; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 16 * 8; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case VK_FORMAT_R64_UINT: + case VK_FORMAT_R64_SINT: + case VK_FORMAT_R64_SFLOAT: + pFormatSize->flags = 0; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 8 * 8; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case VK_FORMAT_R64G64_UINT: + case VK_FORMAT_R64G64_SINT: + case VK_FORMAT_R64G64_SFLOAT: + pFormatSize->flags = 0; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 16 * 8; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case VK_FORMAT_R64G64B64_UINT: + case VK_FORMAT_R64G64B64_SINT: + case VK_FORMAT_R64G64B64_SFLOAT: + pFormatSize->flags = 0; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 24 * 8; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case VK_FORMAT_R64G64B64A64_UINT: + case VK_FORMAT_R64G64B64A64_SINT: + case VK_FORMAT_R64G64B64A64_SFLOAT: + pFormatSize->flags = 0; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 32 * 8; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case VK_FORMAT_B10G11R11_UFLOAT_PACK32: + case VK_FORMAT_E5B9G9R9_UFLOAT_PACK32: + pFormatSize->flags = KTX_FORMAT_SIZE_PACKED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 4 * 8; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case VK_FORMAT_D16_UNORM: + pFormatSize->flags = KTX_FORMAT_SIZE_DEPTH_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 2 * 8; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case VK_FORMAT_X8_D24_UNORM_PACK32: + pFormatSize->flags = KTX_FORMAT_SIZE_PACKED_BIT | KTX_FORMAT_SIZE_DEPTH_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 4 * 8; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case VK_FORMAT_D32_SFLOAT: + pFormatSize->flags = KTX_FORMAT_SIZE_DEPTH_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 4 * 8; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case VK_FORMAT_S8_UINT: + pFormatSize->flags = KTX_FORMAT_SIZE_STENCIL_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 1 * 8; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case VK_FORMAT_D16_UNORM_S8_UINT: + pFormatSize->flags = KTX_FORMAT_SIZE_DEPTH_BIT | KTX_FORMAT_SIZE_STENCIL_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 3 * 8; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case VK_FORMAT_D24_UNORM_S8_UINT: + pFormatSize->flags = KTX_FORMAT_SIZE_DEPTH_BIT | KTX_FORMAT_SIZE_STENCIL_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 4 * 8; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case VK_FORMAT_D32_SFLOAT_S8_UINT: + pFormatSize->flags = KTX_FORMAT_SIZE_DEPTH_BIT | KTX_FORMAT_SIZE_STENCIL_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 8 * 8; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + case VK_FORMAT_BC1_RGB_UNORM_BLOCK: + case VK_FORMAT_BC1_RGB_SRGB_BLOCK: + case VK_FORMAT_BC1_RGBA_UNORM_BLOCK: + case VK_FORMAT_BC1_RGBA_SRGB_BLOCK: + case VK_FORMAT_BC4_UNORM_BLOCK: + case VK_FORMAT_BC4_SNORM_BLOCK: + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 8 * 8; + pFormatSize->blockWidth = 4; + pFormatSize->blockHeight = 4; + pFormatSize->blockDepth = 1; + break; + case VK_FORMAT_BC2_UNORM_BLOCK: + case VK_FORMAT_BC2_SRGB_BLOCK: + case VK_FORMAT_BC3_UNORM_BLOCK: + case VK_FORMAT_BC3_SRGB_BLOCK: + case VK_FORMAT_BC5_UNORM_BLOCK: + case VK_FORMAT_BC5_SNORM_BLOCK: + case VK_FORMAT_BC6H_UFLOAT_BLOCK: + case VK_FORMAT_BC6H_SFLOAT_BLOCK: + case VK_FORMAT_BC7_UNORM_BLOCK: + case VK_FORMAT_BC7_SRGB_BLOCK: + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 16 * 8; + pFormatSize->blockWidth = 4; + pFormatSize->blockHeight = 4; + pFormatSize->blockDepth = 1; + break; + case VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK: + case VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK: + case VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK: + case VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK: + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 8 * 8; + pFormatSize->blockWidth = 4; + pFormatSize->blockHeight = 4; + pFormatSize->blockDepth = 1; + break; + case VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK: + case VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK: + case VK_FORMAT_EAC_R11_UNORM_BLOCK: + case VK_FORMAT_EAC_R11_SNORM_BLOCK: + case VK_FORMAT_EAC_R11G11_UNORM_BLOCK: + case VK_FORMAT_EAC_R11G11_SNORM_BLOCK: + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 16 * 8; + pFormatSize->blockWidth = 4; + pFormatSize->blockHeight = 4; + pFormatSize->blockDepth = 1; + break; + case VK_FORMAT_PVRTC1_2BPP_SRGB_BLOCK_IMG: + case VK_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG: + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 8 * 8; + pFormatSize->blockWidth = 8; + pFormatSize->blockHeight = 4; + pFormatSize->blockDepth = 1; + pFormatSize->minBlocksX = 2; + pFormatSize->minBlocksY = 2; + break; + case VK_FORMAT_PVRTC2_2BPP_SRGB_BLOCK_IMG: + case VK_FORMAT_PVRTC2_2BPP_UNORM_BLOCK_IMG: + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 8 * 8; + pFormatSize->blockWidth = 8; + pFormatSize->blockHeight = 4; + pFormatSize->blockDepth = 1; + break; + case VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG: + case VK_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG: + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 8 * 8; + pFormatSize->blockWidth = 4; + pFormatSize->blockHeight = 4; + pFormatSize->blockDepth = 1; + pFormatSize->minBlocksX = 2; + pFormatSize->minBlocksY = 2; + break; + case VK_FORMAT_PVRTC2_4BPP_SRGB_BLOCK_IMG: + case VK_FORMAT_PVRTC2_4BPP_UNORM_BLOCK_IMG: + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 8 * 8; + pFormatSize->blockWidth = 4; + pFormatSize->blockHeight = 4; + pFormatSize->blockDepth = 1; + break; + case VK_FORMAT_ASTC_4x4_UNORM_BLOCK: + case VK_FORMAT_ASTC_4x4_SRGB_BLOCK: + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 16 * 8; + pFormatSize->blockWidth = 4; + pFormatSize->blockHeight = 4; + pFormatSize->blockDepth = 1; + break; + case VK_FORMAT_ASTC_5x4_UNORM_BLOCK: + case VK_FORMAT_ASTC_5x4_SRGB_BLOCK: + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 16 * 8; + pFormatSize->blockWidth = 5; + pFormatSize->blockHeight = 4; + pFormatSize->blockDepth = 1; + break; + case VK_FORMAT_ASTC_5x5_UNORM_BLOCK: + case VK_FORMAT_ASTC_5x5_SRGB_BLOCK: + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 16 * 8; + pFormatSize->blockWidth = 5; + pFormatSize->blockHeight = 5; + pFormatSize->blockDepth = 1; + break; + case VK_FORMAT_ASTC_6x5_UNORM_BLOCK: + case VK_FORMAT_ASTC_6x5_SRGB_BLOCK: + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 16 * 8; + pFormatSize->blockWidth = 6; + pFormatSize->blockHeight = 5; + pFormatSize->blockDepth = 1; + break; + case VK_FORMAT_ASTC_6x6_UNORM_BLOCK: + case VK_FORMAT_ASTC_6x6_SRGB_BLOCK: + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 16 * 8; + pFormatSize->blockWidth = 6; + pFormatSize->blockHeight = 6; + pFormatSize->blockDepth = 1; + break; + case VK_FORMAT_ASTC_8x5_UNORM_BLOCK: + case VK_FORMAT_ASTC_8x5_SRGB_BLOCK: + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 16 * 8; + pFormatSize->blockWidth = 8; + pFormatSize->blockHeight = 5; + pFormatSize->blockDepth = 1; + break; + case VK_FORMAT_ASTC_8x6_UNORM_BLOCK: + case VK_FORMAT_ASTC_8x6_SRGB_BLOCK: + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 16 * 8; + pFormatSize->blockWidth = 8; + pFormatSize->blockHeight = 6; + pFormatSize->blockDepth = 1; + break; + case VK_FORMAT_ASTC_8x8_UNORM_BLOCK: + case VK_FORMAT_ASTC_8x8_SRGB_BLOCK: + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 16 * 8; + pFormatSize->blockWidth = 8; + pFormatSize->blockHeight = 8; + pFormatSize->blockDepth = 1; + break; + case VK_FORMAT_ASTC_10x5_UNORM_BLOCK: + case VK_FORMAT_ASTC_10x5_SRGB_BLOCK: + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 16 * 8; + pFormatSize->blockWidth = 10; + pFormatSize->blockHeight = 5; + pFormatSize->blockDepth = 1; + break; + case VK_FORMAT_ASTC_10x6_UNORM_BLOCK: + case VK_FORMAT_ASTC_10x6_SRGB_BLOCK: + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 16 * 8; + pFormatSize->blockWidth = 10; + pFormatSize->blockHeight = 6; + pFormatSize->blockDepth = 1; + break; + case VK_FORMAT_ASTC_10x8_UNORM_BLOCK: + case VK_FORMAT_ASTC_10x8_SRGB_BLOCK: + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 16 * 8; + pFormatSize->blockWidth = 10; + pFormatSize->blockHeight = 8; + pFormatSize->blockDepth = 1; + break; + case VK_FORMAT_ASTC_10x10_UNORM_BLOCK: + case VK_FORMAT_ASTC_10x10_SRGB_BLOCK: + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 16 * 8; + pFormatSize->blockWidth = 10; + pFormatSize->blockHeight = 10; + pFormatSize->blockDepth = 1; + break; + case VK_FORMAT_ASTC_12x10_UNORM_BLOCK: + case VK_FORMAT_ASTC_12x10_SRGB_BLOCK: + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 16 * 8; + pFormatSize->blockWidth = 12; + pFormatSize->blockHeight = 10; + pFormatSize->blockDepth = 1; + break; + case VK_FORMAT_ASTC_12x12_UNORM_BLOCK: + case VK_FORMAT_ASTC_12x12_SRGB_BLOCK: + pFormatSize->flags = KTX_FORMAT_SIZE_COMPRESSED_BIT; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 16 * 8; + pFormatSize->blockWidth = 12; + pFormatSize->blockHeight = 12; + pFormatSize->blockDepth = 1; + break; + default: + pFormatSize->flags = 0; + pFormatSize->paletteSizeInBits = 0; + pFormatSize->blockSizeInBits = 0 * 8; + pFormatSize->blockWidth = 1; + pFormatSize->blockHeight = 1; + pFormatSize->blockDepth = 1; + break; + } } #endif -#endif // !VK_FORMAT_H +#endif // !VK_FORMAT_H diff --git a/lib/vk_funcs.c b/lib/vk_funcs.c index 98961aa93b..86d66f9f74 100644 --- a/lib/vk_funcs.c +++ b/lib/vk_funcs.c @@ -35,7 +35,7 @@ #undef MACOS #define MACOS 1 #endif -#if defined(__APPLE__) && (defined(__arm64__) || defined (__arm__)) +#if defined(__APPLE__) && (defined(__arm64__) || defined(__arm__)) #undef IOS #define IOS 1 #endif @@ -45,7 +45,6 @@ #include "vk_funcs.h" - #if WINDOWS #define WINDOWS_LEAN_AND_MEAN #include @@ -74,23 +73,16 @@ void* ktxVulkanModuleHandle; #if WINDOWS #define VULKANLIB "vulkan-1.dll" static HMODULE -ktxGetVulkanModuleHandle() -{ +ktxGetVulkanModuleHandle() { HMODULE module = NULL; - GetModuleHandleExA( - 0, - VULKANLIB, - &module - ); - return module; + GetModuleHandleExA(0, VULKANLIB, &module); + return module; } #endif ktx_error_code_e -ktxLoadVulkanLibrary(void) -{ - if (ktxVulkanModuleHandle) - return KTX_SUCCESS; +ktxLoadVulkanLibrary(void) { + if (ktxVulkanModuleHandle) return KTX_SUCCESS; ktxVulkanModuleHandle = GetVulkanModuleHandle(RTLD_LAZY); if (ktxVulkanModuleHandle == NULL) { @@ -103,7 +95,7 @@ ktxLoadVulkanLibrary(void) #if defined(DEBUG) abort(); #else - return KTX_LIBRARY_NOT_LINKED; // So release version doesn't crash. + return KTX_LIBRARY_NOT_LINKED; // So release version doesn't crash. #endif } @@ -117,14 +109,10 @@ ktxLoadVulkanFunction(const char* pName) { return NULL; } - PFN_vkVoidFunction pfn - = (PFN_vkVoidFunction)LoadProcAddr(ktxVulkanModuleHandle, pName); + PFN_vkVoidFunction pfn = (PFN_vkVoidFunction)LoadProcAddr(ktxVulkanModuleHandle, pName); if (pfn == NULL) { fprintf(stderr, "Couldn't load Vulkan command: %s\n", pName); return NULL; } return pfn; } - - - diff --git a/lib/vk_funcs.h b/lib/vk_funcs.h index 8f73fbd859..87857f3732 100644 --- a/lib/vk_funcs.h +++ b/lib/vk_funcs.h @@ -29,7 +29,6 @@ #include "vulkan/vulkan_core.h" #include "ktx.h" - #if WINDOWS #define WINDOWS_LEAN_AND_MEAN #include @@ -43,6 +42,4 @@ ktx_error_code_e ktxLoadVulkanLibrary(void); // This is used to load instance functions through libktx's methods. PFN_vkVoidFunction ktxLoadVulkanFunction(const char* pName); - #endif /* _VK_FUNCS_H_ */ - diff --git a/lib/vkformat_check.c b/lib/vkformat_check.c index 5b86e3c8fe..b0ebe5b26d 100644 --- a/lib/vkformat_check.c +++ b/lib/vkformat_check.c @@ -15,72 +15,71 @@ #include "vkformat_enum.h" bool -isProhibitedFormat(VkFormat format) -{ +isProhibitedFormat(VkFormat format) { switch (format) { - case VK_FORMAT_R8_USCALED: - case VK_FORMAT_R8_SSCALED: - case VK_FORMAT_R8G8_USCALED: - case VK_FORMAT_R8G8_SSCALED: - case VK_FORMAT_R8G8B8_USCALED: - case VK_FORMAT_R8G8B8_SSCALED: - case VK_FORMAT_B8G8R8_USCALED: - case VK_FORMAT_B8G8R8_SSCALED: - case VK_FORMAT_R8G8B8A8_USCALED: - case VK_FORMAT_R8G8B8A8_SSCALED: - case VK_FORMAT_B8G8R8A8_USCALED: - case VK_FORMAT_B8G8R8A8_SSCALED: - case VK_FORMAT_A8B8G8R8_USCALED_PACK32: - case VK_FORMAT_A8B8G8R8_SSCALED_PACK32: - case VK_FORMAT_A2R10G10B10_USCALED_PACK32: - case VK_FORMAT_A2R10G10B10_SSCALED_PACK32: - case VK_FORMAT_A2B10G10R10_USCALED_PACK32: - case VK_FORMAT_A2B10G10R10_SSCALED_PACK32: - case VK_FORMAT_R16_USCALED: - case VK_FORMAT_R16_SSCALED: - case VK_FORMAT_R16G16_USCALED: - case VK_FORMAT_R16G16_SSCALED: - case VK_FORMAT_R16G16B16_USCALED: - case VK_FORMAT_R16G16B16_SSCALED: - case VK_FORMAT_R16G16B16A16_USCALED: - case VK_FORMAT_R16G16B16A16_SSCALED: - case VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM: - case VK_FORMAT_G8_B8R8_2PLANE_420_UNORM: - case VK_FORMAT_G8_B8_R8_3PLANE_422_UNORM: - case VK_FORMAT_G8_B8R8_2PLANE_422_UNORM: - case VK_FORMAT_G8_B8_R8_3PLANE_444_UNORM: - case VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16: - case VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16: - case VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16: - case VK_FORMAT_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16: - case VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16: - case VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16: - case VK_FORMAT_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16: - case VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16: - case VK_FORMAT_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16: - case VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16: - case VK_FORMAT_G16_B16_R16_3PLANE_420_UNORM: - case VK_FORMAT_G16_B16R16_2PLANE_420_UNORM: - case VK_FORMAT_G16_B16_R16_3PLANE_422_UNORM: - case VK_FORMAT_G16_B16R16_2PLANE_422_UNORM: - case VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM: - case VK_FORMAT_G8_B8R8_2PLANE_444_UNORM: - case VK_FORMAT_G10X6_B10X6R10X6_2PLANE_444_UNORM_3PACK16: - case VK_FORMAT_G12X4_B12X4R12X4_2PLANE_444_UNORM_3PACK16: - case VK_FORMAT_G16_B16R16_2PLANE_444_UNORM: + case VK_FORMAT_R8_USCALED: + case VK_FORMAT_R8_SSCALED: + case VK_FORMAT_R8G8_USCALED: + case VK_FORMAT_R8G8_SSCALED: + case VK_FORMAT_R8G8B8_USCALED: + case VK_FORMAT_R8G8B8_SSCALED: + case VK_FORMAT_B8G8R8_USCALED: + case VK_FORMAT_B8G8R8_SSCALED: + case VK_FORMAT_R8G8B8A8_USCALED: + case VK_FORMAT_R8G8B8A8_SSCALED: + case VK_FORMAT_B8G8R8A8_USCALED: + case VK_FORMAT_B8G8R8A8_SSCALED: + case VK_FORMAT_A8B8G8R8_USCALED_PACK32: + case VK_FORMAT_A8B8G8R8_SSCALED_PACK32: + case VK_FORMAT_A2R10G10B10_USCALED_PACK32: + case VK_FORMAT_A2R10G10B10_SSCALED_PACK32: + case VK_FORMAT_A2B10G10R10_USCALED_PACK32: + case VK_FORMAT_A2B10G10R10_SSCALED_PACK32: + case VK_FORMAT_R16_USCALED: + case VK_FORMAT_R16_SSCALED: + case VK_FORMAT_R16G16_USCALED: + case VK_FORMAT_R16G16_SSCALED: + case VK_FORMAT_R16G16B16_USCALED: + case VK_FORMAT_R16G16B16_SSCALED: + case VK_FORMAT_R16G16B16A16_USCALED: + case VK_FORMAT_R16G16B16A16_SSCALED: + case VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM: + case VK_FORMAT_G8_B8R8_2PLANE_420_UNORM: + case VK_FORMAT_G8_B8_R8_3PLANE_422_UNORM: + case VK_FORMAT_G8_B8R8_2PLANE_422_UNORM: + case VK_FORMAT_G8_B8_R8_3PLANE_444_UNORM: + case VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16: + case VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16: + case VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16: + case VK_FORMAT_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16: + case VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16: + case VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16: + case VK_FORMAT_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16: + case VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16: + case VK_FORMAT_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16: + case VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16: + case VK_FORMAT_G16_B16_R16_3PLANE_420_UNORM: + case VK_FORMAT_G16_B16R16_2PLANE_420_UNORM: + case VK_FORMAT_G16_B16_R16_3PLANE_422_UNORM: + case VK_FORMAT_G16_B16R16_2PLANE_422_UNORM: + case VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM: + case VK_FORMAT_G8_B8R8_2PLANE_444_UNORM: + case VK_FORMAT_G10X6_B10X6R10X6_2PLANE_444_UNORM_3PACK16: + case VK_FORMAT_G12X4_B12X4R12X4_2PLANE_444_UNORM_3PACK16: + case VK_FORMAT_G16_B16R16_2PLANE_444_UNORM: return true; - default: + default: return false; } } bool -isValidFormat(VkFormat format) -{ +isValidFormat(VkFormat format) { // On MSVC VkFormat can be a signed integer - if ((uint32_t) format <= VK_FORMAT_MAX_STANDARD_ENUM) + if ((uint32_t)format <= VK_FORMAT_MAX_STANDARD_ENUM) return true; - else switch(format) { + else + switch (format) { case VK_FORMAT_G8B8G8R8_422_UNORM: case VK_FORMAT_B8G8R8G8_422_UNORM: case VK_FORMAT_R10X6_UNORM_PACK16: @@ -152,9 +151,8 @@ isValidFormat(VkFormat format) case VK_FORMAT_R16G16_S10_5_NV: case VK_FORMAT_A1B5G5R5_UNORM_PACK16_KHR: case VK_FORMAT_A8_UNORM_KHR: - return true; - default: - return false; - } + return true; + default: + return false; + } } - diff --git a/lib/vkformat_enum.h b/lib/vkformat_enum.h index 62279bb009..a1a345c2e1 100644 --- a/lib/vkformat_enum.h +++ b/lib/vkformat_enum.h @@ -11,7 +11,7 @@ ** SPDX-License-Identifier: Apache-2.0 */ -#if defined(_MSC_VER) && _MSC_VER < 1900 // Older than VS 2015. +#if defined(_MSC_VER) && _MSC_VER < 1900 // Older than VS 2015. typedef unsigned __int32 VkFlags; #else #include @@ -301,14 +301,13 @@ typedef enum VkFormat { VK_FORMAT_A8_UNORM_KHR = 1000470001, VK_FORMAT_MAX_ENUM = 0x7FFFFFFF } VkFormat; -#if defined(_MSC_VER) && _MSC_VER < 1900 // Older than VS 2015. +#if defined(_MSC_VER) && _MSC_VER < 1900 // Older than VS 2015. typedef unsigned __int32 VkFlags; #else #include typedef uint64_t VkFlags64; #endif - #define VK_FORMAT_MAX_STANDARD_ENUM 184 #endif /* _VKFORMAT_ENUM_H_ */ diff --git a/lib/vkformat_str.c b/lib/vkformat_str.c index e852206aac..f7f8c24319 100644 --- a/lib/vkformat_str.c +++ b/lib/vkformat_str.c @@ -9,1011 +9,809 @@ ** SPDX-License-Identifier: Apache-2.0 */ - #include #include #include "vkformat_enum.h" const char* -vkFormatString(VkFormat format) -{ +vkFormatString(VkFormat format) { switch (format) { - case VK_FORMAT_UNDEFINED: + case VK_FORMAT_UNDEFINED: return "VK_FORMAT_UNDEFINED"; - case VK_FORMAT_R4G4_UNORM_PACK8: + case VK_FORMAT_R4G4_UNORM_PACK8: return "VK_FORMAT_R4G4_UNORM_PACK8"; - case VK_FORMAT_R4G4B4A4_UNORM_PACK16: + case VK_FORMAT_R4G4B4A4_UNORM_PACK16: return "VK_FORMAT_R4G4B4A4_UNORM_PACK16"; - case VK_FORMAT_B4G4R4A4_UNORM_PACK16: + case VK_FORMAT_B4G4R4A4_UNORM_PACK16: return "VK_FORMAT_B4G4R4A4_UNORM_PACK16"; - case VK_FORMAT_R5G6B5_UNORM_PACK16: + case VK_FORMAT_R5G6B5_UNORM_PACK16: return "VK_FORMAT_R5G6B5_UNORM_PACK16"; - case VK_FORMAT_B5G6R5_UNORM_PACK16: + case VK_FORMAT_B5G6R5_UNORM_PACK16: return "VK_FORMAT_B5G6R5_UNORM_PACK16"; - case VK_FORMAT_R5G5B5A1_UNORM_PACK16: + case VK_FORMAT_R5G5B5A1_UNORM_PACK16: return "VK_FORMAT_R5G5B5A1_UNORM_PACK16"; - case VK_FORMAT_B5G5R5A1_UNORM_PACK16: + case VK_FORMAT_B5G5R5A1_UNORM_PACK16: return "VK_FORMAT_B5G5R5A1_UNORM_PACK16"; - case VK_FORMAT_A1R5G5B5_UNORM_PACK16: + case VK_FORMAT_A1R5G5B5_UNORM_PACK16: return "VK_FORMAT_A1R5G5B5_UNORM_PACK16"; - case VK_FORMAT_R8_UNORM: + case VK_FORMAT_R8_UNORM: return "VK_FORMAT_R8_UNORM"; - case VK_FORMAT_R8_SNORM: + case VK_FORMAT_R8_SNORM: return "VK_FORMAT_R8_SNORM"; - case VK_FORMAT_R8_USCALED: + case VK_FORMAT_R8_USCALED: return "VK_FORMAT_R8_USCALED"; - case VK_FORMAT_R8_SSCALED: + case VK_FORMAT_R8_SSCALED: return "VK_FORMAT_R8_SSCALED"; - case VK_FORMAT_R8_UINT: + case VK_FORMAT_R8_UINT: return "VK_FORMAT_R8_UINT"; - case VK_FORMAT_R8_SINT: + case VK_FORMAT_R8_SINT: return "VK_FORMAT_R8_SINT"; - case VK_FORMAT_R8_SRGB: + case VK_FORMAT_R8_SRGB: return "VK_FORMAT_R8_SRGB"; - case VK_FORMAT_R8G8_UNORM: + case VK_FORMAT_R8G8_UNORM: return "VK_FORMAT_R8G8_UNORM"; - case VK_FORMAT_R8G8_SNORM: + case VK_FORMAT_R8G8_SNORM: return "VK_FORMAT_R8G8_SNORM"; - case VK_FORMAT_R8G8_USCALED: + case VK_FORMAT_R8G8_USCALED: return "VK_FORMAT_R8G8_USCALED"; - case VK_FORMAT_R8G8_SSCALED: + case VK_FORMAT_R8G8_SSCALED: return "VK_FORMAT_R8G8_SSCALED"; - case VK_FORMAT_R8G8_UINT: + case VK_FORMAT_R8G8_UINT: return "VK_FORMAT_R8G8_UINT"; - case VK_FORMAT_R8G8_SINT: + case VK_FORMAT_R8G8_SINT: return "VK_FORMAT_R8G8_SINT"; - case VK_FORMAT_R8G8_SRGB: + case VK_FORMAT_R8G8_SRGB: return "VK_FORMAT_R8G8_SRGB"; - case VK_FORMAT_R8G8B8_UNORM: + case VK_FORMAT_R8G8B8_UNORM: return "VK_FORMAT_R8G8B8_UNORM"; - case VK_FORMAT_R8G8B8_SNORM: + case VK_FORMAT_R8G8B8_SNORM: return "VK_FORMAT_R8G8B8_SNORM"; - case VK_FORMAT_R8G8B8_USCALED: + case VK_FORMAT_R8G8B8_USCALED: return "VK_FORMAT_R8G8B8_USCALED"; - case VK_FORMAT_R8G8B8_SSCALED: + case VK_FORMAT_R8G8B8_SSCALED: return "VK_FORMAT_R8G8B8_SSCALED"; - case VK_FORMAT_R8G8B8_UINT: + case VK_FORMAT_R8G8B8_UINT: return "VK_FORMAT_R8G8B8_UINT"; - case VK_FORMAT_R8G8B8_SINT: + case VK_FORMAT_R8G8B8_SINT: return "VK_FORMAT_R8G8B8_SINT"; - case VK_FORMAT_R8G8B8_SRGB: + case VK_FORMAT_R8G8B8_SRGB: return "VK_FORMAT_R8G8B8_SRGB"; - case VK_FORMAT_B8G8R8_UNORM: + case VK_FORMAT_B8G8R8_UNORM: return "VK_FORMAT_B8G8R8_UNORM"; - case VK_FORMAT_B8G8R8_SNORM: + case VK_FORMAT_B8G8R8_SNORM: return "VK_FORMAT_B8G8R8_SNORM"; - case VK_FORMAT_B8G8R8_USCALED: + case VK_FORMAT_B8G8R8_USCALED: return "VK_FORMAT_B8G8R8_USCALED"; - case VK_FORMAT_B8G8R8_SSCALED: + case VK_FORMAT_B8G8R8_SSCALED: return "VK_FORMAT_B8G8R8_SSCALED"; - case VK_FORMAT_B8G8R8_UINT: + case VK_FORMAT_B8G8R8_UINT: return "VK_FORMAT_B8G8R8_UINT"; - case VK_FORMAT_B8G8R8_SINT: + case VK_FORMAT_B8G8R8_SINT: return "VK_FORMAT_B8G8R8_SINT"; - case VK_FORMAT_B8G8R8_SRGB: + case VK_FORMAT_B8G8R8_SRGB: return "VK_FORMAT_B8G8R8_SRGB"; - case VK_FORMAT_R8G8B8A8_UNORM: + case VK_FORMAT_R8G8B8A8_UNORM: return "VK_FORMAT_R8G8B8A8_UNORM"; - case VK_FORMAT_R8G8B8A8_SNORM: + case VK_FORMAT_R8G8B8A8_SNORM: return "VK_FORMAT_R8G8B8A8_SNORM"; - case VK_FORMAT_R8G8B8A8_USCALED: + case VK_FORMAT_R8G8B8A8_USCALED: return "VK_FORMAT_R8G8B8A8_USCALED"; - case VK_FORMAT_R8G8B8A8_SSCALED: + case VK_FORMAT_R8G8B8A8_SSCALED: return "VK_FORMAT_R8G8B8A8_SSCALED"; - case VK_FORMAT_R8G8B8A8_UINT: + case VK_FORMAT_R8G8B8A8_UINT: return "VK_FORMAT_R8G8B8A8_UINT"; - case VK_FORMAT_R8G8B8A8_SINT: + case VK_FORMAT_R8G8B8A8_SINT: return "VK_FORMAT_R8G8B8A8_SINT"; - case VK_FORMAT_R8G8B8A8_SRGB: + case VK_FORMAT_R8G8B8A8_SRGB: return "VK_FORMAT_R8G8B8A8_SRGB"; - case VK_FORMAT_B8G8R8A8_UNORM: + case VK_FORMAT_B8G8R8A8_UNORM: return "VK_FORMAT_B8G8R8A8_UNORM"; - case VK_FORMAT_B8G8R8A8_SNORM: + case VK_FORMAT_B8G8R8A8_SNORM: return "VK_FORMAT_B8G8R8A8_SNORM"; - case VK_FORMAT_B8G8R8A8_USCALED: + case VK_FORMAT_B8G8R8A8_USCALED: return "VK_FORMAT_B8G8R8A8_USCALED"; - case VK_FORMAT_B8G8R8A8_SSCALED: + case VK_FORMAT_B8G8R8A8_SSCALED: return "VK_FORMAT_B8G8R8A8_SSCALED"; - case VK_FORMAT_B8G8R8A8_UINT: + case VK_FORMAT_B8G8R8A8_UINT: return "VK_FORMAT_B8G8R8A8_UINT"; - case VK_FORMAT_B8G8R8A8_SINT: + case VK_FORMAT_B8G8R8A8_SINT: return "VK_FORMAT_B8G8R8A8_SINT"; - case VK_FORMAT_B8G8R8A8_SRGB: + case VK_FORMAT_B8G8R8A8_SRGB: return "VK_FORMAT_B8G8R8A8_SRGB"; - case VK_FORMAT_A8B8G8R8_UNORM_PACK32: + case VK_FORMAT_A8B8G8R8_UNORM_PACK32: return "VK_FORMAT_A8B8G8R8_UNORM_PACK32"; - case VK_FORMAT_A8B8G8R8_SNORM_PACK32: + case VK_FORMAT_A8B8G8R8_SNORM_PACK32: return "VK_FORMAT_A8B8G8R8_SNORM_PACK32"; - case VK_FORMAT_A8B8G8R8_USCALED_PACK32: + case VK_FORMAT_A8B8G8R8_USCALED_PACK32: return "VK_FORMAT_A8B8G8R8_USCALED_PACK32"; - case VK_FORMAT_A8B8G8R8_SSCALED_PACK32: + case VK_FORMAT_A8B8G8R8_SSCALED_PACK32: return "VK_FORMAT_A8B8G8R8_SSCALED_PACK32"; - case VK_FORMAT_A8B8G8R8_UINT_PACK32: + case VK_FORMAT_A8B8G8R8_UINT_PACK32: return "VK_FORMAT_A8B8G8R8_UINT_PACK32"; - case VK_FORMAT_A8B8G8R8_SINT_PACK32: + case VK_FORMAT_A8B8G8R8_SINT_PACK32: return "VK_FORMAT_A8B8G8R8_SINT_PACK32"; - case VK_FORMAT_A8B8G8R8_SRGB_PACK32: + case VK_FORMAT_A8B8G8R8_SRGB_PACK32: return "VK_FORMAT_A8B8G8R8_SRGB_PACK32"; - case VK_FORMAT_A2R10G10B10_UNORM_PACK32: + case VK_FORMAT_A2R10G10B10_UNORM_PACK32: return "VK_FORMAT_A2R10G10B10_UNORM_PACK32"; - case VK_FORMAT_A2R10G10B10_SNORM_PACK32: + case VK_FORMAT_A2R10G10B10_SNORM_PACK32: return "VK_FORMAT_A2R10G10B10_SNORM_PACK32"; - case VK_FORMAT_A2R10G10B10_USCALED_PACK32: + case VK_FORMAT_A2R10G10B10_USCALED_PACK32: return "VK_FORMAT_A2R10G10B10_USCALED_PACK32"; - case VK_FORMAT_A2R10G10B10_SSCALED_PACK32: + case VK_FORMAT_A2R10G10B10_SSCALED_PACK32: return "VK_FORMAT_A2R10G10B10_SSCALED_PACK32"; - case VK_FORMAT_A2R10G10B10_UINT_PACK32: + case VK_FORMAT_A2R10G10B10_UINT_PACK32: return "VK_FORMAT_A2R10G10B10_UINT_PACK32"; - case VK_FORMAT_A2R10G10B10_SINT_PACK32: + case VK_FORMAT_A2R10G10B10_SINT_PACK32: return "VK_FORMAT_A2R10G10B10_SINT_PACK32"; - case VK_FORMAT_A2B10G10R10_UNORM_PACK32: + case VK_FORMAT_A2B10G10R10_UNORM_PACK32: return "VK_FORMAT_A2B10G10R10_UNORM_PACK32"; - case VK_FORMAT_A2B10G10R10_SNORM_PACK32: + case VK_FORMAT_A2B10G10R10_SNORM_PACK32: return "VK_FORMAT_A2B10G10R10_SNORM_PACK32"; - case VK_FORMAT_A2B10G10R10_USCALED_PACK32: + case VK_FORMAT_A2B10G10R10_USCALED_PACK32: return "VK_FORMAT_A2B10G10R10_USCALED_PACK32"; - case VK_FORMAT_A2B10G10R10_SSCALED_PACK32: + case VK_FORMAT_A2B10G10R10_SSCALED_PACK32: return "VK_FORMAT_A2B10G10R10_SSCALED_PACK32"; - case VK_FORMAT_A2B10G10R10_UINT_PACK32: + case VK_FORMAT_A2B10G10R10_UINT_PACK32: return "VK_FORMAT_A2B10G10R10_UINT_PACK32"; - case VK_FORMAT_A2B10G10R10_SINT_PACK32: + case VK_FORMAT_A2B10G10R10_SINT_PACK32: return "VK_FORMAT_A2B10G10R10_SINT_PACK32"; - case VK_FORMAT_R16_UNORM: + case VK_FORMAT_R16_UNORM: return "VK_FORMAT_R16_UNORM"; - case VK_FORMAT_R16_SNORM: + case VK_FORMAT_R16_SNORM: return "VK_FORMAT_R16_SNORM"; - case VK_FORMAT_R16_USCALED: + case VK_FORMAT_R16_USCALED: return "VK_FORMAT_R16_USCALED"; - case VK_FORMAT_R16_SSCALED: + case VK_FORMAT_R16_SSCALED: return "VK_FORMAT_R16_SSCALED"; - case VK_FORMAT_R16_UINT: + case VK_FORMAT_R16_UINT: return "VK_FORMAT_R16_UINT"; - case VK_FORMAT_R16_SINT: + case VK_FORMAT_R16_SINT: return "VK_FORMAT_R16_SINT"; - case VK_FORMAT_R16_SFLOAT: + case VK_FORMAT_R16_SFLOAT: return "VK_FORMAT_R16_SFLOAT"; - case VK_FORMAT_R16G16_UNORM: + case VK_FORMAT_R16G16_UNORM: return "VK_FORMAT_R16G16_UNORM"; - case VK_FORMAT_R16G16_SNORM: + case VK_FORMAT_R16G16_SNORM: return "VK_FORMAT_R16G16_SNORM"; - case VK_FORMAT_R16G16_USCALED: + case VK_FORMAT_R16G16_USCALED: return "VK_FORMAT_R16G16_USCALED"; - case VK_FORMAT_R16G16_SSCALED: + case VK_FORMAT_R16G16_SSCALED: return "VK_FORMAT_R16G16_SSCALED"; - case VK_FORMAT_R16G16_UINT: + case VK_FORMAT_R16G16_UINT: return "VK_FORMAT_R16G16_UINT"; - case VK_FORMAT_R16G16_SINT: + case VK_FORMAT_R16G16_SINT: return "VK_FORMAT_R16G16_SINT"; - case VK_FORMAT_R16G16_SFLOAT: + case VK_FORMAT_R16G16_SFLOAT: return "VK_FORMAT_R16G16_SFLOAT"; - case VK_FORMAT_R16G16B16_UNORM: + case VK_FORMAT_R16G16B16_UNORM: return "VK_FORMAT_R16G16B16_UNORM"; - case VK_FORMAT_R16G16B16_SNORM: + case VK_FORMAT_R16G16B16_SNORM: return "VK_FORMAT_R16G16B16_SNORM"; - case VK_FORMAT_R16G16B16_USCALED: + case VK_FORMAT_R16G16B16_USCALED: return "VK_FORMAT_R16G16B16_USCALED"; - case VK_FORMAT_R16G16B16_SSCALED: + case VK_FORMAT_R16G16B16_SSCALED: return "VK_FORMAT_R16G16B16_SSCALED"; - case VK_FORMAT_R16G16B16_UINT: + case VK_FORMAT_R16G16B16_UINT: return "VK_FORMAT_R16G16B16_UINT"; - case VK_FORMAT_R16G16B16_SINT: + case VK_FORMAT_R16G16B16_SINT: return "VK_FORMAT_R16G16B16_SINT"; - case VK_FORMAT_R16G16B16_SFLOAT: + case VK_FORMAT_R16G16B16_SFLOAT: return "VK_FORMAT_R16G16B16_SFLOAT"; - case VK_FORMAT_R16G16B16A16_UNORM: + case VK_FORMAT_R16G16B16A16_UNORM: return "VK_FORMAT_R16G16B16A16_UNORM"; - case VK_FORMAT_R16G16B16A16_SNORM: + case VK_FORMAT_R16G16B16A16_SNORM: return "VK_FORMAT_R16G16B16A16_SNORM"; - case VK_FORMAT_R16G16B16A16_USCALED: + case VK_FORMAT_R16G16B16A16_USCALED: return "VK_FORMAT_R16G16B16A16_USCALED"; - case VK_FORMAT_R16G16B16A16_SSCALED: + case VK_FORMAT_R16G16B16A16_SSCALED: return "VK_FORMAT_R16G16B16A16_SSCALED"; - case VK_FORMAT_R16G16B16A16_UINT: + case VK_FORMAT_R16G16B16A16_UINT: return "VK_FORMAT_R16G16B16A16_UINT"; - case VK_FORMAT_R16G16B16A16_SINT: + case VK_FORMAT_R16G16B16A16_SINT: return "VK_FORMAT_R16G16B16A16_SINT"; - case VK_FORMAT_R16G16B16A16_SFLOAT: + case VK_FORMAT_R16G16B16A16_SFLOAT: return "VK_FORMAT_R16G16B16A16_SFLOAT"; - case VK_FORMAT_R32_UINT: + case VK_FORMAT_R32_UINT: return "VK_FORMAT_R32_UINT"; - case VK_FORMAT_R32_SINT: + case VK_FORMAT_R32_SINT: return "VK_FORMAT_R32_SINT"; - case VK_FORMAT_R32_SFLOAT: + case VK_FORMAT_R32_SFLOAT: return "VK_FORMAT_R32_SFLOAT"; - case VK_FORMAT_R32G32_UINT: + case VK_FORMAT_R32G32_UINT: return "VK_FORMAT_R32G32_UINT"; - case VK_FORMAT_R32G32_SINT: + case VK_FORMAT_R32G32_SINT: return "VK_FORMAT_R32G32_SINT"; - case VK_FORMAT_R32G32_SFLOAT: + case VK_FORMAT_R32G32_SFLOAT: return "VK_FORMAT_R32G32_SFLOAT"; - case VK_FORMAT_R32G32B32_UINT: + case VK_FORMAT_R32G32B32_UINT: return "VK_FORMAT_R32G32B32_UINT"; - case VK_FORMAT_R32G32B32_SINT: + case VK_FORMAT_R32G32B32_SINT: return "VK_FORMAT_R32G32B32_SINT"; - case VK_FORMAT_R32G32B32_SFLOAT: + case VK_FORMAT_R32G32B32_SFLOAT: return "VK_FORMAT_R32G32B32_SFLOAT"; - case VK_FORMAT_R32G32B32A32_UINT: + case VK_FORMAT_R32G32B32A32_UINT: return "VK_FORMAT_R32G32B32A32_UINT"; - case VK_FORMAT_R32G32B32A32_SINT: + case VK_FORMAT_R32G32B32A32_SINT: return "VK_FORMAT_R32G32B32A32_SINT"; - case VK_FORMAT_R32G32B32A32_SFLOAT: + case VK_FORMAT_R32G32B32A32_SFLOAT: return "VK_FORMAT_R32G32B32A32_SFLOAT"; - case VK_FORMAT_R64_UINT: + case VK_FORMAT_R64_UINT: return "VK_FORMAT_R64_UINT"; - case VK_FORMAT_R64_SINT: + case VK_FORMAT_R64_SINT: return "VK_FORMAT_R64_SINT"; - case VK_FORMAT_R64_SFLOAT: + case VK_FORMAT_R64_SFLOAT: return "VK_FORMAT_R64_SFLOAT"; - case VK_FORMAT_R64G64_UINT: + case VK_FORMAT_R64G64_UINT: return "VK_FORMAT_R64G64_UINT"; - case VK_FORMAT_R64G64_SINT: + case VK_FORMAT_R64G64_SINT: return "VK_FORMAT_R64G64_SINT"; - case VK_FORMAT_R64G64_SFLOAT: + case VK_FORMAT_R64G64_SFLOAT: return "VK_FORMAT_R64G64_SFLOAT"; - case VK_FORMAT_R64G64B64_UINT: + case VK_FORMAT_R64G64B64_UINT: return "VK_FORMAT_R64G64B64_UINT"; - case VK_FORMAT_R64G64B64_SINT: + case VK_FORMAT_R64G64B64_SINT: return "VK_FORMAT_R64G64B64_SINT"; - case VK_FORMAT_R64G64B64_SFLOAT: + case VK_FORMAT_R64G64B64_SFLOAT: return "VK_FORMAT_R64G64B64_SFLOAT"; - case VK_FORMAT_R64G64B64A64_UINT: + case VK_FORMAT_R64G64B64A64_UINT: return "VK_FORMAT_R64G64B64A64_UINT"; - case VK_FORMAT_R64G64B64A64_SINT: + case VK_FORMAT_R64G64B64A64_SINT: return "VK_FORMAT_R64G64B64A64_SINT"; - case VK_FORMAT_R64G64B64A64_SFLOAT: + case VK_FORMAT_R64G64B64A64_SFLOAT: return "VK_FORMAT_R64G64B64A64_SFLOAT"; - case VK_FORMAT_B10G11R11_UFLOAT_PACK32: + case VK_FORMAT_B10G11R11_UFLOAT_PACK32: return "VK_FORMAT_B10G11R11_UFLOAT_PACK32"; - case VK_FORMAT_E5B9G9R9_UFLOAT_PACK32: + case VK_FORMAT_E5B9G9R9_UFLOAT_PACK32: return "VK_FORMAT_E5B9G9R9_UFLOAT_PACK32"; - case VK_FORMAT_D16_UNORM: + case VK_FORMAT_D16_UNORM: return "VK_FORMAT_D16_UNORM"; - case VK_FORMAT_X8_D24_UNORM_PACK32: + case VK_FORMAT_X8_D24_UNORM_PACK32: return "VK_FORMAT_X8_D24_UNORM_PACK32"; - case VK_FORMAT_D32_SFLOAT: + case VK_FORMAT_D32_SFLOAT: return "VK_FORMAT_D32_SFLOAT"; - case VK_FORMAT_S8_UINT: + case VK_FORMAT_S8_UINT: return "VK_FORMAT_S8_UINT"; - case VK_FORMAT_D16_UNORM_S8_UINT: + case VK_FORMAT_D16_UNORM_S8_UINT: return "VK_FORMAT_D16_UNORM_S8_UINT"; - case VK_FORMAT_D24_UNORM_S8_UINT: + case VK_FORMAT_D24_UNORM_S8_UINT: return "VK_FORMAT_D24_UNORM_S8_UINT"; - case VK_FORMAT_D32_SFLOAT_S8_UINT: + case VK_FORMAT_D32_SFLOAT_S8_UINT: return "VK_FORMAT_D32_SFLOAT_S8_UINT"; - case VK_FORMAT_BC1_RGB_UNORM_BLOCK: + case VK_FORMAT_BC1_RGB_UNORM_BLOCK: return "VK_FORMAT_BC1_RGB_UNORM_BLOCK"; - case VK_FORMAT_BC1_RGB_SRGB_BLOCK: + case VK_FORMAT_BC1_RGB_SRGB_BLOCK: return "VK_FORMAT_BC1_RGB_SRGB_BLOCK"; - case VK_FORMAT_BC1_RGBA_UNORM_BLOCK: + case VK_FORMAT_BC1_RGBA_UNORM_BLOCK: return "VK_FORMAT_BC1_RGBA_UNORM_BLOCK"; - case VK_FORMAT_BC1_RGBA_SRGB_BLOCK: + case VK_FORMAT_BC1_RGBA_SRGB_BLOCK: return "VK_FORMAT_BC1_RGBA_SRGB_BLOCK"; - case VK_FORMAT_BC2_UNORM_BLOCK: + case VK_FORMAT_BC2_UNORM_BLOCK: return "VK_FORMAT_BC2_UNORM_BLOCK"; - case VK_FORMAT_BC2_SRGB_BLOCK: + case VK_FORMAT_BC2_SRGB_BLOCK: return "VK_FORMAT_BC2_SRGB_BLOCK"; - case VK_FORMAT_BC3_UNORM_BLOCK: + case VK_FORMAT_BC3_UNORM_BLOCK: return "VK_FORMAT_BC3_UNORM_BLOCK"; - case VK_FORMAT_BC3_SRGB_BLOCK: + case VK_FORMAT_BC3_SRGB_BLOCK: return "VK_FORMAT_BC3_SRGB_BLOCK"; - case VK_FORMAT_BC4_UNORM_BLOCK: + case VK_FORMAT_BC4_UNORM_BLOCK: return "VK_FORMAT_BC4_UNORM_BLOCK"; - case VK_FORMAT_BC4_SNORM_BLOCK: + case VK_FORMAT_BC4_SNORM_BLOCK: return "VK_FORMAT_BC4_SNORM_BLOCK"; - case VK_FORMAT_BC5_UNORM_BLOCK: + case VK_FORMAT_BC5_UNORM_BLOCK: return "VK_FORMAT_BC5_UNORM_BLOCK"; - case VK_FORMAT_BC5_SNORM_BLOCK: + case VK_FORMAT_BC5_SNORM_BLOCK: return "VK_FORMAT_BC5_SNORM_BLOCK"; - case VK_FORMAT_BC6H_UFLOAT_BLOCK: + case VK_FORMAT_BC6H_UFLOAT_BLOCK: return "VK_FORMAT_BC6H_UFLOAT_BLOCK"; - case VK_FORMAT_BC6H_SFLOAT_BLOCK: + case VK_FORMAT_BC6H_SFLOAT_BLOCK: return "VK_FORMAT_BC6H_SFLOAT_BLOCK"; - case VK_FORMAT_BC7_UNORM_BLOCK: + case VK_FORMAT_BC7_UNORM_BLOCK: return "VK_FORMAT_BC7_UNORM_BLOCK"; - case VK_FORMAT_BC7_SRGB_BLOCK: + case VK_FORMAT_BC7_SRGB_BLOCK: return "VK_FORMAT_BC7_SRGB_BLOCK"; - case VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK: + case VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK: return "VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK"; - case VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK: + case VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK: return "VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK"; - case VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK: + case VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK: return "VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK"; - case VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK: + case VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK: return "VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK"; - case VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK: + case VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK: return "VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK"; - case VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK: + case VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK: return "VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK"; - case VK_FORMAT_EAC_R11_UNORM_BLOCK: + case VK_FORMAT_EAC_R11_UNORM_BLOCK: return "VK_FORMAT_EAC_R11_UNORM_BLOCK"; - case VK_FORMAT_EAC_R11_SNORM_BLOCK: + case VK_FORMAT_EAC_R11_SNORM_BLOCK: return "VK_FORMAT_EAC_R11_SNORM_BLOCK"; - case VK_FORMAT_EAC_R11G11_UNORM_BLOCK: + case VK_FORMAT_EAC_R11G11_UNORM_BLOCK: return "VK_FORMAT_EAC_R11G11_UNORM_BLOCK"; - case VK_FORMAT_EAC_R11G11_SNORM_BLOCK: + case VK_FORMAT_EAC_R11G11_SNORM_BLOCK: return "VK_FORMAT_EAC_R11G11_SNORM_BLOCK"; - case VK_FORMAT_ASTC_4x4_UNORM_BLOCK: + case VK_FORMAT_ASTC_4x4_UNORM_BLOCK: return "VK_FORMAT_ASTC_4x4_UNORM_BLOCK"; - case VK_FORMAT_ASTC_4x4_SRGB_BLOCK: + case VK_FORMAT_ASTC_4x4_SRGB_BLOCK: return "VK_FORMAT_ASTC_4x4_SRGB_BLOCK"; - case VK_FORMAT_ASTC_5x4_UNORM_BLOCK: + case VK_FORMAT_ASTC_5x4_UNORM_BLOCK: return "VK_FORMAT_ASTC_5x4_UNORM_BLOCK"; - case VK_FORMAT_ASTC_5x4_SRGB_BLOCK: + case VK_FORMAT_ASTC_5x4_SRGB_BLOCK: return "VK_FORMAT_ASTC_5x4_SRGB_BLOCK"; - case VK_FORMAT_ASTC_5x5_UNORM_BLOCK: + case VK_FORMAT_ASTC_5x5_UNORM_BLOCK: return "VK_FORMAT_ASTC_5x5_UNORM_BLOCK"; - case VK_FORMAT_ASTC_5x5_SRGB_BLOCK: + case VK_FORMAT_ASTC_5x5_SRGB_BLOCK: return "VK_FORMAT_ASTC_5x5_SRGB_BLOCK"; - case VK_FORMAT_ASTC_6x5_UNORM_BLOCK: + case VK_FORMAT_ASTC_6x5_UNORM_BLOCK: return "VK_FORMAT_ASTC_6x5_UNORM_BLOCK"; - case VK_FORMAT_ASTC_6x5_SRGB_BLOCK: + case VK_FORMAT_ASTC_6x5_SRGB_BLOCK: return "VK_FORMAT_ASTC_6x5_SRGB_BLOCK"; - case VK_FORMAT_ASTC_6x6_UNORM_BLOCK: + case VK_FORMAT_ASTC_6x6_UNORM_BLOCK: return "VK_FORMAT_ASTC_6x6_UNORM_BLOCK"; - case VK_FORMAT_ASTC_6x6_SRGB_BLOCK: + case VK_FORMAT_ASTC_6x6_SRGB_BLOCK: return "VK_FORMAT_ASTC_6x6_SRGB_BLOCK"; - case VK_FORMAT_ASTC_8x5_UNORM_BLOCK: + case VK_FORMAT_ASTC_8x5_UNORM_BLOCK: return "VK_FORMAT_ASTC_8x5_UNORM_BLOCK"; - case VK_FORMAT_ASTC_8x5_SRGB_BLOCK: + case VK_FORMAT_ASTC_8x5_SRGB_BLOCK: return "VK_FORMAT_ASTC_8x5_SRGB_BLOCK"; - case VK_FORMAT_ASTC_8x6_UNORM_BLOCK: + case VK_FORMAT_ASTC_8x6_UNORM_BLOCK: return "VK_FORMAT_ASTC_8x6_UNORM_BLOCK"; - case VK_FORMAT_ASTC_8x6_SRGB_BLOCK: + case VK_FORMAT_ASTC_8x6_SRGB_BLOCK: return "VK_FORMAT_ASTC_8x6_SRGB_BLOCK"; - case VK_FORMAT_ASTC_8x8_UNORM_BLOCK: + case VK_FORMAT_ASTC_8x8_UNORM_BLOCK: return "VK_FORMAT_ASTC_8x8_UNORM_BLOCK"; - case VK_FORMAT_ASTC_8x8_SRGB_BLOCK: + case VK_FORMAT_ASTC_8x8_SRGB_BLOCK: return "VK_FORMAT_ASTC_8x8_SRGB_BLOCK"; - case VK_FORMAT_ASTC_10x5_UNORM_BLOCK: + case VK_FORMAT_ASTC_10x5_UNORM_BLOCK: return "VK_FORMAT_ASTC_10x5_UNORM_BLOCK"; - case VK_FORMAT_ASTC_10x5_SRGB_BLOCK: + case VK_FORMAT_ASTC_10x5_SRGB_BLOCK: return "VK_FORMAT_ASTC_10x5_SRGB_BLOCK"; - case VK_FORMAT_ASTC_10x6_UNORM_BLOCK: + case VK_FORMAT_ASTC_10x6_UNORM_BLOCK: return "VK_FORMAT_ASTC_10x6_UNORM_BLOCK"; - case VK_FORMAT_ASTC_10x6_SRGB_BLOCK: + case VK_FORMAT_ASTC_10x6_SRGB_BLOCK: return "VK_FORMAT_ASTC_10x6_SRGB_BLOCK"; - case VK_FORMAT_ASTC_10x8_UNORM_BLOCK: + case VK_FORMAT_ASTC_10x8_UNORM_BLOCK: return "VK_FORMAT_ASTC_10x8_UNORM_BLOCK"; - case VK_FORMAT_ASTC_10x8_SRGB_BLOCK: + case VK_FORMAT_ASTC_10x8_SRGB_BLOCK: return "VK_FORMAT_ASTC_10x8_SRGB_BLOCK"; - case VK_FORMAT_ASTC_10x10_UNORM_BLOCK: + case VK_FORMAT_ASTC_10x10_UNORM_BLOCK: return "VK_FORMAT_ASTC_10x10_UNORM_BLOCK"; - case VK_FORMAT_ASTC_10x10_SRGB_BLOCK: + case VK_FORMAT_ASTC_10x10_SRGB_BLOCK: return "VK_FORMAT_ASTC_10x10_SRGB_BLOCK"; - case VK_FORMAT_ASTC_12x10_UNORM_BLOCK: + case VK_FORMAT_ASTC_12x10_UNORM_BLOCK: return "VK_FORMAT_ASTC_12x10_UNORM_BLOCK"; - case VK_FORMAT_ASTC_12x10_SRGB_BLOCK: + case VK_FORMAT_ASTC_12x10_SRGB_BLOCK: return "VK_FORMAT_ASTC_12x10_SRGB_BLOCK"; - case VK_FORMAT_ASTC_12x12_UNORM_BLOCK: + case VK_FORMAT_ASTC_12x12_UNORM_BLOCK: return "VK_FORMAT_ASTC_12x12_UNORM_BLOCK"; - case VK_FORMAT_ASTC_12x12_SRGB_BLOCK: + case VK_FORMAT_ASTC_12x12_SRGB_BLOCK: return "VK_FORMAT_ASTC_12x12_SRGB_BLOCK"; - case VK_FORMAT_G8B8G8R8_422_UNORM: + case VK_FORMAT_G8B8G8R8_422_UNORM: return "VK_FORMAT_G8B8G8R8_422_UNORM"; - case VK_FORMAT_B8G8R8G8_422_UNORM: + case VK_FORMAT_B8G8R8G8_422_UNORM: return "VK_FORMAT_B8G8R8G8_422_UNORM"; - case VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM: + case VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM: return "VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM"; - case VK_FORMAT_G8_B8R8_2PLANE_420_UNORM: + case VK_FORMAT_G8_B8R8_2PLANE_420_UNORM: return "VK_FORMAT_G8_B8R8_2PLANE_420_UNORM"; - case VK_FORMAT_G8_B8_R8_3PLANE_422_UNORM: + case VK_FORMAT_G8_B8_R8_3PLANE_422_UNORM: return "VK_FORMAT_G8_B8_R8_3PLANE_422_UNORM"; - case VK_FORMAT_G8_B8R8_2PLANE_422_UNORM: + case VK_FORMAT_G8_B8R8_2PLANE_422_UNORM: return "VK_FORMAT_G8_B8R8_2PLANE_422_UNORM"; - case VK_FORMAT_G8_B8_R8_3PLANE_444_UNORM: + case VK_FORMAT_G8_B8_R8_3PLANE_444_UNORM: return "VK_FORMAT_G8_B8_R8_3PLANE_444_UNORM"; - case VK_FORMAT_R10X6_UNORM_PACK16: + case VK_FORMAT_R10X6_UNORM_PACK16: return "VK_FORMAT_R10X6_UNORM_PACK16"; - case VK_FORMAT_R10X6G10X6_UNORM_2PACK16: + case VK_FORMAT_R10X6G10X6_UNORM_2PACK16: return "VK_FORMAT_R10X6G10X6_UNORM_2PACK16"; - case VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16: + case VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16: return "VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16"; - case VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16: + case VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16: return "VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16"; - case VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16: + case VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16: return "VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16"; - case VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16: + case VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16: return "VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16"; - case VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16: + case VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16: return "VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16"; - case VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16: + case VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16: return "VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16"; - case VK_FORMAT_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16: + case VK_FORMAT_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16: return "VK_FORMAT_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16"; - case VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16: + case VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16: return "VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16"; - case VK_FORMAT_R12X4_UNORM_PACK16: + case VK_FORMAT_R12X4_UNORM_PACK16: return "VK_FORMAT_R12X4_UNORM_PACK16"; - case VK_FORMAT_R12X4G12X4_UNORM_2PACK16: + case VK_FORMAT_R12X4G12X4_UNORM_2PACK16: return "VK_FORMAT_R12X4G12X4_UNORM_2PACK16"; - case VK_FORMAT_R12X4G12X4B12X4A12X4_UNORM_4PACK16: + case VK_FORMAT_R12X4G12X4B12X4A12X4_UNORM_4PACK16: return "VK_FORMAT_R12X4G12X4B12X4A12X4_UNORM_4PACK16"; - case VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16: + case VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16: return "VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16"; - case VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16: + case VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16: return "VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16"; - case VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16: + case VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16: return "VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16"; - case VK_FORMAT_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16: + case VK_FORMAT_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16: return "VK_FORMAT_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16"; - case VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16: + case VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16: return "VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16"; - case VK_FORMAT_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16: + case VK_FORMAT_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16: return "VK_FORMAT_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16"; - case VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16: + case VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16: return "VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16"; - case VK_FORMAT_G16B16G16R16_422_UNORM: + case VK_FORMAT_G16B16G16R16_422_UNORM: return "VK_FORMAT_G16B16G16R16_422_UNORM"; - case VK_FORMAT_B16G16R16G16_422_UNORM: + case VK_FORMAT_B16G16R16G16_422_UNORM: return "VK_FORMAT_B16G16R16G16_422_UNORM"; - case VK_FORMAT_G16_B16_R16_3PLANE_420_UNORM: + case VK_FORMAT_G16_B16_R16_3PLANE_420_UNORM: return "VK_FORMAT_G16_B16_R16_3PLANE_420_UNORM"; - case VK_FORMAT_G16_B16R16_2PLANE_420_UNORM: + case VK_FORMAT_G16_B16R16_2PLANE_420_UNORM: return "VK_FORMAT_G16_B16R16_2PLANE_420_UNORM"; - case VK_FORMAT_G16_B16_R16_3PLANE_422_UNORM: + case VK_FORMAT_G16_B16_R16_3PLANE_422_UNORM: return "VK_FORMAT_G16_B16_R16_3PLANE_422_UNORM"; - case VK_FORMAT_G16_B16R16_2PLANE_422_UNORM: + case VK_FORMAT_G16_B16R16_2PLANE_422_UNORM: return "VK_FORMAT_G16_B16R16_2PLANE_422_UNORM"; - case VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM: + case VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM: return "VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM"; - case VK_FORMAT_G8_B8R8_2PLANE_444_UNORM: + case VK_FORMAT_G8_B8R8_2PLANE_444_UNORM: return "VK_FORMAT_G8_B8R8_2PLANE_444_UNORM"; - case VK_FORMAT_G10X6_B10X6R10X6_2PLANE_444_UNORM_3PACK16: + case VK_FORMAT_G10X6_B10X6R10X6_2PLANE_444_UNORM_3PACK16: return "VK_FORMAT_G10X6_B10X6R10X6_2PLANE_444_UNORM_3PACK16"; - case VK_FORMAT_G12X4_B12X4R12X4_2PLANE_444_UNORM_3PACK16: + case VK_FORMAT_G12X4_B12X4R12X4_2PLANE_444_UNORM_3PACK16: return "VK_FORMAT_G12X4_B12X4R12X4_2PLANE_444_UNORM_3PACK16"; - case VK_FORMAT_G16_B16R16_2PLANE_444_UNORM: + case VK_FORMAT_G16_B16R16_2PLANE_444_UNORM: return "VK_FORMAT_G16_B16R16_2PLANE_444_UNORM"; - case VK_FORMAT_A4R4G4B4_UNORM_PACK16: + case VK_FORMAT_A4R4G4B4_UNORM_PACK16: return "VK_FORMAT_A4R4G4B4_UNORM_PACK16"; - case VK_FORMAT_A4B4G4R4_UNORM_PACK16: + case VK_FORMAT_A4B4G4R4_UNORM_PACK16: return "VK_FORMAT_A4B4G4R4_UNORM_PACK16"; - case VK_FORMAT_ASTC_4x4_SFLOAT_BLOCK: + case VK_FORMAT_ASTC_4x4_SFLOAT_BLOCK: return "VK_FORMAT_ASTC_4x4_SFLOAT_BLOCK"; - case VK_FORMAT_ASTC_5x4_SFLOAT_BLOCK: + case VK_FORMAT_ASTC_5x4_SFLOAT_BLOCK: return "VK_FORMAT_ASTC_5x4_SFLOAT_BLOCK"; - case VK_FORMAT_ASTC_5x5_SFLOAT_BLOCK: + case VK_FORMAT_ASTC_5x5_SFLOAT_BLOCK: return "VK_FORMAT_ASTC_5x5_SFLOAT_BLOCK"; - case VK_FORMAT_ASTC_6x5_SFLOAT_BLOCK: + case VK_FORMAT_ASTC_6x5_SFLOAT_BLOCK: return "VK_FORMAT_ASTC_6x5_SFLOAT_BLOCK"; - case VK_FORMAT_ASTC_6x6_SFLOAT_BLOCK: + case VK_FORMAT_ASTC_6x6_SFLOAT_BLOCK: return "VK_FORMAT_ASTC_6x6_SFLOAT_BLOCK"; - case VK_FORMAT_ASTC_8x5_SFLOAT_BLOCK: + case VK_FORMAT_ASTC_8x5_SFLOAT_BLOCK: return "VK_FORMAT_ASTC_8x5_SFLOAT_BLOCK"; - case VK_FORMAT_ASTC_8x6_SFLOAT_BLOCK: + case VK_FORMAT_ASTC_8x6_SFLOAT_BLOCK: return "VK_FORMAT_ASTC_8x6_SFLOAT_BLOCK"; - case VK_FORMAT_ASTC_8x8_SFLOAT_BLOCK: + case VK_FORMAT_ASTC_8x8_SFLOAT_BLOCK: return "VK_FORMAT_ASTC_8x8_SFLOAT_BLOCK"; - case VK_FORMAT_ASTC_10x5_SFLOAT_BLOCK: + case VK_FORMAT_ASTC_10x5_SFLOAT_BLOCK: return "VK_FORMAT_ASTC_10x5_SFLOAT_BLOCK"; - case VK_FORMAT_ASTC_10x6_SFLOAT_BLOCK: + case VK_FORMAT_ASTC_10x6_SFLOAT_BLOCK: return "VK_FORMAT_ASTC_10x6_SFLOAT_BLOCK"; - case VK_FORMAT_ASTC_10x8_SFLOAT_BLOCK: + case VK_FORMAT_ASTC_10x8_SFLOAT_BLOCK: return "VK_FORMAT_ASTC_10x8_SFLOAT_BLOCK"; - case VK_FORMAT_ASTC_10x10_SFLOAT_BLOCK: + case VK_FORMAT_ASTC_10x10_SFLOAT_BLOCK: return "VK_FORMAT_ASTC_10x10_SFLOAT_BLOCK"; - case VK_FORMAT_ASTC_12x10_SFLOAT_BLOCK: + case VK_FORMAT_ASTC_12x10_SFLOAT_BLOCK: return "VK_FORMAT_ASTC_12x10_SFLOAT_BLOCK"; - case VK_FORMAT_ASTC_12x12_SFLOAT_BLOCK: + case VK_FORMAT_ASTC_12x12_SFLOAT_BLOCK: return "VK_FORMAT_ASTC_12x12_SFLOAT_BLOCK"; - case VK_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG: + case VK_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG: return "VK_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG"; - case VK_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG: + case VK_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG: return "VK_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG"; - case VK_FORMAT_PVRTC2_2BPP_UNORM_BLOCK_IMG: + case VK_FORMAT_PVRTC2_2BPP_UNORM_BLOCK_IMG: return "VK_FORMAT_PVRTC2_2BPP_UNORM_BLOCK_IMG"; - case VK_FORMAT_PVRTC2_4BPP_UNORM_BLOCK_IMG: + case VK_FORMAT_PVRTC2_4BPP_UNORM_BLOCK_IMG: return "VK_FORMAT_PVRTC2_4BPP_UNORM_BLOCK_IMG"; - case VK_FORMAT_PVRTC1_2BPP_SRGB_BLOCK_IMG: + case VK_FORMAT_PVRTC1_2BPP_SRGB_BLOCK_IMG: return "VK_FORMAT_PVRTC1_2BPP_SRGB_BLOCK_IMG"; - case VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG: + case VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG: return "VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG"; - case VK_FORMAT_PVRTC2_2BPP_SRGB_BLOCK_IMG: + case VK_FORMAT_PVRTC2_2BPP_SRGB_BLOCK_IMG: return "VK_FORMAT_PVRTC2_2BPP_SRGB_BLOCK_IMG"; - case VK_FORMAT_PVRTC2_4BPP_SRGB_BLOCK_IMG: + case VK_FORMAT_PVRTC2_4BPP_SRGB_BLOCK_IMG: return "VK_FORMAT_PVRTC2_4BPP_SRGB_BLOCK_IMG"; - case VK_FORMAT_ASTC_3x3x3_UNORM_BLOCK_EXT: + case VK_FORMAT_ASTC_3x3x3_UNORM_BLOCK_EXT: return "VK_FORMAT_ASTC_3x3x3_UNORM_BLOCK_EXT"; - case VK_FORMAT_ASTC_3x3x3_SRGB_BLOCK_EXT: + case VK_FORMAT_ASTC_3x3x3_SRGB_BLOCK_EXT: return "VK_FORMAT_ASTC_3x3x3_SRGB_BLOCK_EXT"; - case VK_FORMAT_ASTC_3x3x3_SFLOAT_BLOCK_EXT: + case VK_FORMAT_ASTC_3x3x3_SFLOAT_BLOCK_EXT: return "VK_FORMAT_ASTC_3x3x3_SFLOAT_BLOCK_EXT"; - case VK_FORMAT_ASTC_4x3x3_UNORM_BLOCK_EXT: + case VK_FORMAT_ASTC_4x3x3_UNORM_BLOCK_EXT: return "VK_FORMAT_ASTC_4x3x3_UNORM_BLOCK_EXT"; - case VK_FORMAT_ASTC_4x3x3_SRGB_BLOCK_EXT: + case VK_FORMAT_ASTC_4x3x3_SRGB_BLOCK_EXT: return "VK_FORMAT_ASTC_4x3x3_SRGB_BLOCK_EXT"; - case VK_FORMAT_ASTC_4x3x3_SFLOAT_BLOCK_EXT: + case VK_FORMAT_ASTC_4x3x3_SFLOAT_BLOCK_EXT: return "VK_FORMAT_ASTC_4x3x3_SFLOAT_BLOCK_EXT"; - case VK_FORMAT_ASTC_4x4x3_UNORM_BLOCK_EXT: + case VK_FORMAT_ASTC_4x4x3_UNORM_BLOCK_EXT: return "VK_FORMAT_ASTC_4x4x3_UNORM_BLOCK_EXT"; - case VK_FORMAT_ASTC_4x4x3_SRGB_BLOCK_EXT: + case VK_FORMAT_ASTC_4x4x3_SRGB_BLOCK_EXT: return "VK_FORMAT_ASTC_4x4x3_SRGB_BLOCK_EXT"; - case VK_FORMAT_ASTC_4x4x3_SFLOAT_BLOCK_EXT: + case VK_FORMAT_ASTC_4x4x3_SFLOAT_BLOCK_EXT: return "VK_FORMAT_ASTC_4x4x3_SFLOAT_BLOCK_EXT"; - case VK_FORMAT_ASTC_4x4x4_UNORM_BLOCK_EXT: + case VK_FORMAT_ASTC_4x4x4_UNORM_BLOCK_EXT: return "VK_FORMAT_ASTC_4x4x4_UNORM_BLOCK_EXT"; - case VK_FORMAT_ASTC_4x4x4_SRGB_BLOCK_EXT: + case VK_FORMAT_ASTC_4x4x4_SRGB_BLOCK_EXT: return "VK_FORMAT_ASTC_4x4x4_SRGB_BLOCK_EXT"; - case VK_FORMAT_ASTC_4x4x4_SFLOAT_BLOCK_EXT: + case VK_FORMAT_ASTC_4x4x4_SFLOAT_BLOCK_EXT: return "VK_FORMAT_ASTC_4x4x4_SFLOAT_BLOCK_EXT"; - case VK_FORMAT_ASTC_5x4x4_UNORM_BLOCK_EXT: + case VK_FORMAT_ASTC_5x4x4_UNORM_BLOCK_EXT: return "VK_FORMAT_ASTC_5x4x4_UNORM_BLOCK_EXT"; - case VK_FORMAT_ASTC_5x4x4_SRGB_BLOCK_EXT: + case VK_FORMAT_ASTC_5x4x4_SRGB_BLOCK_EXT: return "VK_FORMAT_ASTC_5x4x4_SRGB_BLOCK_EXT"; - case VK_FORMAT_ASTC_5x4x4_SFLOAT_BLOCK_EXT: + case VK_FORMAT_ASTC_5x4x4_SFLOAT_BLOCK_EXT: return "VK_FORMAT_ASTC_5x4x4_SFLOAT_BLOCK_EXT"; - case VK_FORMAT_ASTC_5x5x4_UNORM_BLOCK_EXT: + case VK_FORMAT_ASTC_5x5x4_UNORM_BLOCK_EXT: return "VK_FORMAT_ASTC_5x5x4_UNORM_BLOCK_EXT"; - case VK_FORMAT_ASTC_5x5x4_SRGB_BLOCK_EXT: + case VK_FORMAT_ASTC_5x5x4_SRGB_BLOCK_EXT: return "VK_FORMAT_ASTC_5x5x4_SRGB_BLOCK_EXT"; - case VK_FORMAT_ASTC_5x5x4_SFLOAT_BLOCK_EXT: + case VK_FORMAT_ASTC_5x5x4_SFLOAT_BLOCK_EXT: return "VK_FORMAT_ASTC_5x5x4_SFLOAT_BLOCK_EXT"; - case VK_FORMAT_ASTC_5x5x5_UNORM_BLOCK_EXT: + case VK_FORMAT_ASTC_5x5x5_UNORM_BLOCK_EXT: return "VK_FORMAT_ASTC_5x5x5_UNORM_BLOCK_EXT"; - case VK_FORMAT_ASTC_5x5x5_SRGB_BLOCK_EXT: + case VK_FORMAT_ASTC_5x5x5_SRGB_BLOCK_EXT: return "VK_FORMAT_ASTC_5x5x5_SRGB_BLOCK_EXT"; - case VK_FORMAT_ASTC_5x5x5_SFLOAT_BLOCK_EXT: + case VK_FORMAT_ASTC_5x5x5_SFLOAT_BLOCK_EXT: return "VK_FORMAT_ASTC_5x5x5_SFLOAT_BLOCK_EXT"; - case VK_FORMAT_ASTC_6x5x5_UNORM_BLOCK_EXT: + case VK_FORMAT_ASTC_6x5x5_UNORM_BLOCK_EXT: return "VK_FORMAT_ASTC_6x5x5_UNORM_BLOCK_EXT"; - case VK_FORMAT_ASTC_6x5x5_SRGB_BLOCK_EXT: + case VK_FORMAT_ASTC_6x5x5_SRGB_BLOCK_EXT: return "VK_FORMAT_ASTC_6x5x5_SRGB_BLOCK_EXT"; - case VK_FORMAT_ASTC_6x5x5_SFLOAT_BLOCK_EXT: + case VK_FORMAT_ASTC_6x5x5_SFLOAT_BLOCK_EXT: return "VK_FORMAT_ASTC_6x5x5_SFLOAT_BLOCK_EXT"; - case VK_FORMAT_ASTC_6x6x5_UNORM_BLOCK_EXT: + case VK_FORMAT_ASTC_6x6x5_UNORM_BLOCK_EXT: return "VK_FORMAT_ASTC_6x6x5_UNORM_BLOCK_EXT"; - case VK_FORMAT_ASTC_6x6x5_SRGB_BLOCK_EXT: + case VK_FORMAT_ASTC_6x6x5_SRGB_BLOCK_EXT: return "VK_FORMAT_ASTC_6x6x5_SRGB_BLOCK_EXT"; - case VK_FORMAT_ASTC_6x6x5_SFLOAT_BLOCK_EXT: + case VK_FORMAT_ASTC_6x6x5_SFLOAT_BLOCK_EXT: return "VK_FORMAT_ASTC_6x6x5_SFLOAT_BLOCK_EXT"; - case VK_FORMAT_ASTC_6x6x6_UNORM_BLOCK_EXT: + case VK_FORMAT_ASTC_6x6x6_UNORM_BLOCK_EXT: return "VK_FORMAT_ASTC_6x6x6_UNORM_BLOCK_EXT"; - case VK_FORMAT_ASTC_6x6x6_SRGB_BLOCK_EXT: + case VK_FORMAT_ASTC_6x6x6_SRGB_BLOCK_EXT: return "VK_FORMAT_ASTC_6x6x6_SRGB_BLOCK_EXT"; - case VK_FORMAT_ASTC_6x6x6_SFLOAT_BLOCK_EXT: + case VK_FORMAT_ASTC_6x6x6_SFLOAT_BLOCK_EXT: return "VK_FORMAT_ASTC_6x6x6_SFLOAT_BLOCK_EXT"; - case VK_FORMAT_R16G16_S10_5_NV: + case VK_FORMAT_R16G16_S10_5_NV: return "VK_FORMAT_R16G16_S10_5_NV"; - case VK_FORMAT_A1B5G5R5_UNORM_PACK16_KHR: + case VK_FORMAT_A1B5G5R5_UNORM_PACK16_KHR: return "VK_FORMAT_A1B5G5R5_UNORM_PACK16_KHR"; - case VK_FORMAT_A8_UNORM_KHR: + case VK_FORMAT_A8_UNORM_KHR: return "VK_FORMAT_A8_UNORM_KHR"; - default: + default: return "VK_UNKNOWN_FORMAT"; } } -static int ktx_strcasecmp(const char* s1, const char* s2) { - const unsigned char* us1 = (const unsigned char*) s1; - const unsigned char* us2 = (const unsigned char*) s2; +static int +ktx_strcasecmp(const char* s1, const char* s2) { + const unsigned char* us1 = (const unsigned char*)s1; + const unsigned char* us2 = (const unsigned char*)s2; while (tolower(*us1) == tolower(*us2)) { - if (*us1 == '\0') - return 0; + if (*us1 == '\0') return 0; ++us1; ++us2; } return tolower(*us1) - tolower(*us2); } -static int ktx_strncasecmp(const char* s1, const char* s2, int length) { - const unsigned char* us1 = (const unsigned char*) s1; - const unsigned char* us2 = (const unsigned char*) s2; +static int +ktx_strncasecmp(const char* s1, const char* s2, int length) { + const unsigned char* us1 = (const unsigned char*)s1; + const unsigned char* us2 = (const unsigned char*)s2; while (length > 0 && tolower(*us1) == tolower(*us2)) { - if (*us1 == '\0') - return 0; + if (*us1 == '\0') return 0; ++us1; ++us2; --length; } - if (length == 0) - return 0; + if (length == 0) return 0; return tolower(*us1) - tolower(*us2); } /// Parses a VkFormat. VK_FORMAT_ prefix is optional. Case insensitive. VkFormat -stringToVkFormat(const char* str) -{ - if (ktx_strncasecmp(str, "VK_FORMAT_", sizeof("VK_FORMAT_") - 1) == 0) - str += sizeof("VK_FORMAT_") - 1; +stringToVkFormat(const char* str) { + if (ktx_strncasecmp(str, "VK_FORMAT_", sizeof("VK_FORMAT_") - 1) == 0) str += sizeof("VK_FORMAT_") - 1; - if (ktx_strcasecmp(str, "UNDEFINED") == 0) - return VK_FORMAT_UNDEFINED; - if (ktx_strcasecmp(str, "R4G4_UNORM_PACK8") == 0) - return VK_FORMAT_R4G4_UNORM_PACK8; - if (ktx_strcasecmp(str, "R4G4B4A4_UNORM_PACK16") == 0) - return VK_FORMAT_R4G4B4A4_UNORM_PACK16; - if (ktx_strcasecmp(str, "B4G4R4A4_UNORM_PACK16") == 0) - return VK_FORMAT_B4G4R4A4_UNORM_PACK16; - if (ktx_strcasecmp(str, "R5G6B5_UNORM_PACK16") == 0) - return VK_FORMAT_R5G6B5_UNORM_PACK16; - if (ktx_strcasecmp(str, "B5G6R5_UNORM_PACK16") == 0) - return VK_FORMAT_B5G6R5_UNORM_PACK16; - if (ktx_strcasecmp(str, "R5G5B5A1_UNORM_PACK16") == 0) - return VK_FORMAT_R5G5B5A1_UNORM_PACK16; - if (ktx_strcasecmp(str, "B5G5R5A1_UNORM_PACK16") == 0) - return VK_FORMAT_B5G5R5A1_UNORM_PACK16; - if (ktx_strcasecmp(str, "A1R5G5B5_UNORM_PACK16") == 0) - return VK_FORMAT_A1R5G5B5_UNORM_PACK16; - if (ktx_strcasecmp(str, "R8_UNORM") == 0) - return VK_FORMAT_R8_UNORM; - if (ktx_strcasecmp(str, "R8_SNORM") == 0) - return VK_FORMAT_R8_SNORM; - if (ktx_strcasecmp(str, "R8_USCALED") == 0) - return VK_FORMAT_R8_USCALED; - if (ktx_strcasecmp(str, "R8_SSCALED") == 0) - return VK_FORMAT_R8_SSCALED; - if (ktx_strcasecmp(str, "R8_UINT") == 0) - return VK_FORMAT_R8_UINT; - if (ktx_strcasecmp(str, "R8_SINT") == 0) - return VK_FORMAT_R8_SINT; - if (ktx_strcasecmp(str, "R8_SRGB") == 0) - return VK_FORMAT_R8_SRGB; - if (ktx_strcasecmp(str, "R8G8_UNORM") == 0) - return VK_FORMAT_R8G8_UNORM; - if (ktx_strcasecmp(str, "R8G8_SNORM") == 0) - return VK_FORMAT_R8G8_SNORM; - if (ktx_strcasecmp(str, "R8G8_USCALED") == 0) - return VK_FORMAT_R8G8_USCALED; - if (ktx_strcasecmp(str, "R8G8_SSCALED") == 0) - return VK_FORMAT_R8G8_SSCALED; - if (ktx_strcasecmp(str, "R8G8_UINT") == 0) - return VK_FORMAT_R8G8_UINT; - if (ktx_strcasecmp(str, "R8G8_SINT") == 0) - return VK_FORMAT_R8G8_SINT; - if (ktx_strcasecmp(str, "R8G8_SRGB") == 0) - return VK_FORMAT_R8G8_SRGB; - if (ktx_strcasecmp(str, "R8G8B8_UNORM") == 0) - return VK_FORMAT_R8G8B8_UNORM; - if (ktx_strcasecmp(str, "R8G8B8_SNORM") == 0) - return VK_FORMAT_R8G8B8_SNORM; - if (ktx_strcasecmp(str, "R8G8B8_USCALED") == 0) - return VK_FORMAT_R8G8B8_USCALED; - if (ktx_strcasecmp(str, "R8G8B8_SSCALED") == 0) - return VK_FORMAT_R8G8B8_SSCALED; - if (ktx_strcasecmp(str, "R8G8B8_UINT") == 0) - return VK_FORMAT_R8G8B8_UINT; - if (ktx_strcasecmp(str, "R8G8B8_SINT") == 0) - return VK_FORMAT_R8G8B8_SINT; - if (ktx_strcasecmp(str, "R8G8B8_SRGB") == 0) - return VK_FORMAT_R8G8B8_SRGB; - if (ktx_strcasecmp(str, "B8G8R8_UNORM") == 0) - return VK_FORMAT_B8G8R8_UNORM; - if (ktx_strcasecmp(str, "B8G8R8_SNORM") == 0) - return VK_FORMAT_B8G8R8_SNORM; - if (ktx_strcasecmp(str, "B8G8R8_USCALED") == 0) - return VK_FORMAT_B8G8R8_USCALED; - if (ktx_strcasecmp(str, "B8G8R8_SSCALED") == 0) - return VK_FORMAT_B8G8R8_SSCALED; - if (ktx_strcasecmp(str, "B8G8R8_UINT") == 0) - return VK_FORMAT_B8G8R8_UINT; - if (ktx_strcasecmp(str, "B8G8R8_SINT") == 0) - return VK_FORMAT_B8G8R8_SINT; - if (ktx_strcasecmp(str, "B8G8R8_SRGB") == 0) - return VK_FORMAT_B8G8R8_SRGB; - if (ktx_strcasecmp(str, "R8G8B8A8_UNORM") == 0) - return VK_FORMAT_R8G8B8A8_UNORM; - if (ktx_strcasecmp(str, "R8G8B8A8_SNORM") == 0) - return VK_FORMAT_R8G8B8A8_SNORM; - if (ktx_strcasecmp(str, "R8G8B8A8_USCALED") == 0) - return VK_FORMAT_R8G8B8A8_USCALED; - if (ktx_strcasecmp(str, "R8G8B8A8_SSCALED") == 0) - return VK_FORMAT_R8G8B8A8_SSCALED; - if (ktx_strcasecmp(str, "R8G8B8A8_UINT") == 0) - return VK_FORMAT_R8G8B8A8_UINT; - if (ktx_strcasecmp(str, "R8G8B8A8_SINT") == 0) - return VK_FORMAT_R8G8B8A8_SINT; - if (ktx_strcasecmp(str, "R8G8B8A8_SRGB") == 0) - return VK_FORMAT_R8G8B8A8_SRGB; - if (ktx_strcasecmp(str, "B8G8R8A8_UNORM") == 0) - return VK_FORMAT_B8G8R8A8_UNORM; - if (ktx_strcasecmp(str, "B8G8R8A8_SNORM") == 0) - return VK_FORMAT_B8G8R8A8_SNORM; - if (ktx_strcasecmp(str, "B8G8R8A8_USCALED") == 0) - return VK_FORMAT_B8G8R8A8_USCALED; - if (ktx_strcasecmp(str, "B8G8R8A8_SSCALED") == 0) - return VK_FORMAT_B8G8R8A8_SSCALED; - if (ktx_strcasecmp(str, "B8G8R8A8_UINT") == 0) - return VK_FORMAT_B8G8R8A8_UINT; - if (ktx_strcasecmp(str, "B8G8R8A8_SINT") == 0) - return VK_FORMAT_B8G8R8A8_SINT; - if (ktx_strcasecmp(str, "B8G8R8A8_SRGB") == 0) - return VK_FORMAT_B8G8R8A8_SRGB; - if (ktx_strcasecmp(str, "A8B8G8R8_UNORM_PACK32") == 0) - return VK_FORMAT_A8B8G8R8_UNORM_PACK32; - if (ktx_strcasecmp(str, "A8B8G8R8_SNORM_PACK32") == 0) - return VK_FORMAT_A8B8G8R8_SNORM_PACK32; - if (ktx_strcasecmp(str, "A8B8G8R8_USCALED_PACK32") == 0) - return VK_FORMAT_A8B8G8R8_USCALED_PACK32; - if (ktx_strcasecmp(str, "A8B8G8R8_SSCALED_PACK32") == 0) - return VK_FORMAT_A8B8G8R8_SSCALED_PACK32; - if (ktx_strcasecmp(str, "A8B8G8R8_UINT_PACK32") == 0) - return VK_FORMAT_A8B8G8R8_UINT_PACK32; - if (ktx_strcasecmp(str, "A8B8G8R8_SINT_PACK32") == 0) - return VK_FORMAT_A8B8G8R8_SINT_PACK32; - if (ktx_strcasecmp(str, "A8B8G8R8_SRGB_PACK32") == 0) - return VK_FORMAT_A8B8G8R8_SRGB_PACK32; - if (ktx_strcasecmp(str, "A2R10G10B10_UNORM_PACK32") == 0) - return VK_FORMAT_A2R10G10B10_UNORM_PACK32; - if (ktx_strcasecmp(str, "A2R10G10B10_SNORM_PACK32") == 0) - return VK_FORMAT_A2R10G10B10_SNORM_PACK32; - if (ktx_strcasecmp(str, "A2R10G10B10_USCALED_PACK32") == 0) - return VK_FORMAT_A2R10G10B10_USCALED_PACK32; - if (ktx_strcasecmp(str, "A2R10G10B10_SSCALED_PACK32") == 0) - return VK_FORMAT_A2R10G10B10_SSCALED_PACK32; - if (ktx_strcasecmp(str, "A2R10G10B10_UINT_PACK32") == 0) - return VK_FORMAT_A2R10G10B10_UINT_PACK32; - if (ktx_strcasecmp(str, "A2R10G10B10_SINT_PACK32") == 0) - return VK_FORMAT_A2R10G10B10_SINT_PACK32; - if (ktx_strcasecmp(str, "A2B10G10R10_UNORM_PACK32") == 0) - return VK_FORMAT_A2B10G10R10_UNORM_PACK32; - if (ktx_strcasecmp(str, "A2B10G10R10_SNORM_PACK32") == 0) - return VK_FORMAT_A2B10G10R10_SNORM_PACK32; - if (ktx_strcasecmp(str, "A2B10G10R10_USCALED_PACK32") == 0) - return VK_FORMAT_A2B10G10R10_USCALED_PACK32; - if (ktx_strcasecmp(str, "A2B10G10R10_SSCALED_PACK32") == 0) - return VK_FORMAT_A2B10G10R10_SSCALED_PACK32; - if (ktx_strcasecmp(str, "A2B10G10R10_UINT_PACK32") == 0) - return VK_FORMAT_A2B10G10R10_UINT_PACK32; - if (ktx_strcasecmp(str, "A2B10G10R10_SINT_PACK32") == 0) - return VK_FORMAT_A2B10G10R10_SINT_PACK32; - if (ktx_strcasecmp(str, "R16_UNORM") == 0) - return VK_FORMAT_R16_UNORM; - if (ktx_strcasecmp(str, "R16_SNORM") == 0) - return VK_FORMAT_R16_SNORM; - if (ktx_strcasecmp(str, "R16_USCALED") == 0) - return VK_FORMAT_R16_USCALED; - if (ktx_strcasecmp(str, "R16_SSCALED") == 0) - return VK_FORMAT_R16_SSCALED; - if (ktx_strcasecmp(str, "R16_UINT") == 0) - return VK_FORMAT_R16_UINT; - if (ktx_strcasecmp(str, "R16_SINT") == 0) - return VK_FORMAT_R16_SINT; - if (ktx_strcasecmp(str, "R16_SFLOAT") == 0) - return VK_FORMAT_R16_SFLOAT; - if (ktx_strcasecmp(str, "R16G16_UNORM") == 0) - return VK_FORMAT_R16G16_UNORM; - if (ktx_strcasecmp(str, "R16G16_SNORM") == 0) - return VK_FORMAT_R16G16_SNORM; - if (ktx_strcasecmp(str, "R16G16_USCALED") == 0) - return VK_FORMAT_R16G16_USCALED; - if (ktx_strcasecmp(str, "R16G16_SSCALED") == 0) - return VK_FORMAT_R16G16_SSCALED; - if (ktx_strcasecmp(str, "R16G16_UINT") == 0) - return VK_FORMAT_R16G16_UINT; - if (ktx_strcasecmp(str, "R16G16_SINT") == 0) - return VK_FORMAT_R16G16_SINT; - if (ktx_strcasecmp(str, "R16G16_SFLOAT") == 0) - return VK_FORMAT_R16G16_SFLOAT; - if (ktx_strcasecmp(str, "R16G16B16_UNORM") == 0) - return VK_FORMAT_R16G16B16_UNORM; - if (ktx_strcasecmp(str, "R16G16B16_SNORM") == 0) - return VK_FORMAT_R16G16B16_SNORM; - if (ktx_strcasecmp(str, "R16G16B16_USCALED") == 0) - return VK_FORMAT_R16G16B16_USCALED; - if (ktx_strcasecmp(str, "R16G16B16_SSCALED") == 0) - return VK_FORMAT_R16G16B16_SSCALED; - if (ktx_strcasecmp(str, "R16G16B16_UINT") == 0) - return VK_FORMAT_R16G16B16_UINT; - if (ktx_strcasecmp(str, "R16G16B16_SINT") == 0) - return VK_FORMAT_R16G16B16_SINT; - if (ktx_strcasecmp(str, "R16G16B16_SFLOAT") == 0) - return VK_FORMAT_R16G16B16_SFLOAT; - if (ktx_strcasecmp(str, "R16G16B16A16_UNORM") == 0) - return VK_FORMAT_R16G16B16A16_UNORM; - if (ktx_strcasecmp(str, "R16G16B16A16_SNORM") == 0) - return VK_FORMAT_R16G16B16A16_SNORM; - if (ktx_strcasecmp(str, "R16G16B16A16_USCALED") == 0) - return VK_FORMAT_R16G16B16A16_USCALED; - if (ktx_strcasecmp(str, "R16G16B16A16_SSCALED") == 0) - return VK_FORMAT_R16G16B16A16_SSCALED; - if (ktx_strcasecmp(str, "R16G16B16A16_UINT") == 0) - return VK_FORMAT_R16G16B16A16_UINT; - if (ktx_strcasecmp(str, "R16G16B16A16_SINT") == 0) - return VK_FORMAT_R16G16B16A16_SINT; - if (ktx_strcasecmp(str, "R16G16B16A16_SFLOAT") == 0) - return VK_FORMAT_R16G16B16A16_SFLOAT; - if (ktx_strcasecmp(str, "R32_UINT") == 0) - return VK_FORMAT_R32_UINT; - if (ktx_strcasecmp(str, "R32_SINT") == 0) - return VK_FORMAT_R32_SINT; - if (ktx_strcasecmp(str, "R32_SFLOAT") == 0) - return VK_FORMAT_R32_SFLOAT; - if (ktx_strcasecmp(str, "R32G32_UINT") == 0) - return VK_FORMAT_R32G32_UINT; - if (ktx_strcasecmp(str, "R32G32_SINT") == 0) - return VK_FORMAT_R32G32_SINT; - if (ktx_strcasecmp(str, "R32G32_SFLOAT") == 0) - return VK_FORMAT_R32G32_SFLOAT; - if (ktx_strcasecmp(str, "R32G32B32_UINT") == 0) - return VK_FORMAT_R32G32B32_UINT; - if (ktx_strcasecmp(str, "R32G32B32_SINT") == 0) - return VK_FORMAT_R32G32B32_SINT; - if (ktx_strcasecmp(str, "R32G32B32_SFLOAT") == 0) - return VK_FORMAT_R32G32B32_SFLOAT; - if (ktx_strcasecmp(str, "R32G32B32A32_UINT") == 0) - return VK_FORMAT_R32G32B32A32_UINT; - if (ktx_strcasecmp(str, "R32G32B32A32_SINT") == 0) - return VK_FORMAT_R32G32B32A32_SINT; - if (ktx_strcasecmp(str, "R32G32B32A32_SFLOAT") == 0) - return VK_FORMAT_R32G32B32A32_SFLOAT; - if (ktx_strcasecmp(str, "R64_UINT") == 0) - return VK_FORMAT_R64_UINT; - if (ktx_strcasecmp(str, "R64_SINT") == 0) - return VK_FORMAT_R64_SINT; - if (ktx_strcasecmp(str, "R64_SFLOAT") == 0) - return VK_FORMAT_R64_SFLOAT; - if (ktx_strcasecmp(str, "R64G64_UINT") == 0) - return VK_FORMAT_R64G64_UINT; - if (ktx_strcasecmp(str, "R64G64_SINT") == 0) - return VK_FORMAT_R64G64_SINT; - if (ktx_strcasecmp(str, "R64G64_SFLOAT") == 0) - return VK_FORMAT_R64G64_SFLOAT; - if (ktx_strcasecmp(str, "R64G64B64_UINT") == 0) - return VK_FORMAT_R64G64B64_UINT; - if (ktx_strcasecmp(str, "R64G64B64_SINT") == 0) - return VK_FORMAT_R64G64B64_SINT; - if (ktx_strcasecmp(str, "R64G64B64_SFLOAT") == 0) - return VK_FORMAT_R64G64B64_SFLOAT; - if (ktx_strcasecmp(str, "R64G64B64A64_UINT") == 0) - return VK_FORMAT_R64G64B64A64_UINT; - if (ktx_strcasecmp(str, "R64G64B64A64_SINT") == 0) - return VK_FORMAT_R64G64B64A64_SINT; - if (ktx_strcasecmp(str, "R64G64B64A64_SFLOAT") == 0) - return VK_FORMAT_R64G64B64A64_SFLOAT; - if (ktx_strcasecmp(str, "B10G11R11_UFLOAT_PACK32") == 0) - return VK_FORMAT_B10G11R11_UFLOAT_PACK32; - if (ktx_strcasecmp(str, "E5B9G9R9_UFLOAT_PACK32") == 0) - return VK_FORMAT_E5B9G9R9_UFLOAT_PACK32; - if (ktx_strcasecmp(str, "D16_UNORM") == 0) - return VK_FORMAT_D16_UNORM; - if (ktx_strcasecmp(str, "X8_D24_UNORM_PACK32") == 0) - return VK_FORMAT_X8_D24_UNORM_PACK32; - if (ktx_strcasecmp(str, "D32_SFLOAT") == 0) - return VK_FORMAT_D32_SFLOAT; - if (ktx_strcasecmp(str, "S8_UINT") == 0) - return VK_FORMAT_S8_UINT; - if (ktx_strcasecmp(str, "D16_UNORM_S8_UINT") == 0) - return VK_FORMAT_D16_UNORM_S8_UINT; - if (ktx_strcasecmp(str, "D24_UNORM_S8_UINT") == 0) - return VK_FORMAT_D24_UNORM_S8_UINT; - if (ktx_strcasecmp(str, "D32_SFLOAT_S8_UINT") == 0) - return VK_FORMAT_D32_SFLOAT_S8_UINT; - if (ktx_strcasecmp(str, "BC1_RGB_UNORM_BLOCK") == 0) - return VK_FORMAT_BC1_RGB_UNORM_BLOCK; - if (ktx_strcasecmp(str, "BC1_RGB_SRGB_BLOCK") == 0) - return VK_FORMAT_BC1_RGB_SRGB_BLOCK; - if (ktx_strcasecmp(str, "BC1_RGBA_UNORM_BLOCK") == 0) - return VK_FORMAT_BC1_RGBA_UNORM_BLOCK; - if (ktx_strcasecmp(str, "BC1_RGBA_SRGB_BLOCK") == 0) - return VK_FORMAT_BC1_RGBA_SRGB_BLOCK; - if (ktx_strcasecmp(str, "BC2_UNORM_BLOCK") == 0) - return VK_FORMAT_BC2_UNORM_BLOCK; - if (ktx_strcasecmp(str, "BC2_SRGB_BLOCK") == 0) - return VK_FORMAT_BC2_SRGB_BLOCK; - if (ktx_strcasecmp(str, "BC3_UNORM_BLOCK") == 0) - return VK_FORMAT_BC3_UNORM_BLOCK; - if (ktx_strcasecmp(str, "BC3_SRGB_BLOCK") == 0) - return VK_FORMAT_BC3_SRGB_BLOCK; - if (ktx_strcasecmp(str, "BC4_UNORM_BLOCK") == 0) - return VK_FORMAT_BC4_UNORM_BLOCK; - if (ktx_strcasecmp(str, "BC4_SNORM_BLOCK") == 0) - return VK_FORMAT_BC4_SNORM_BLOCK; - if (ktx_strcasecmp(str, "BC5_UNORM_BLOCK") == 0) - return VK_FORMAT_BC5_UNORM_BLOCK; - if (ktx_strcasecmp(str, "BC5_SNORM_BLOCK") == 0) - return VK_FORMAT_BC5_SNORM_BLOCK; - if (ktx_strcasecmp(str, "BC6H_UFLOAT_BLOCK") == 0) - return VK_FORMAT_BC6H_UFLOAT_BLOCK; - if (ktx_strcasecmp(str, "BC6H_SFLOAT_BLOCK") == 0) - return VK_FORMAT_BC6H_SFLOAT_BLOCK; - if (ktx_strcasecmp(str, "BC7_UNORM_BLOCK") == 0) - return VK_FORMAT_BC7_UNORM_BLOCK; - if (ktx_strcasecmp(str, "BC7_SRGB_BLOCK") == 0) - return VK_FORMAT_BC7_SRGB_BLOCK; - if (ktx_strcasecmp(str, "ETC2_R8G8B8_UNORM_BLOCK") == 0) - return VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK; - if (ktx_strcasecmp(str, "ETC2_R8G8B8_SRGB_BLOCK") == 0) - return VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK; - if (ktx_strcasecmp(str, "ETC2_R8G8B8A1_UNORM_BLOCK") == 0) - return VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK; - if (ktx_strcasecmp(str, "ETC2_R8G8B8A1_SRGB_BLOCK") == 0) - return VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK; - if (ktx_strcasecmp(str, "ETC2_R8G8B8A8_UNORM_BLOCK") == 0) - return VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK; - if (ktx_strcasecmp(str, "ETC2_R8G8B8A8_SRGB_BLOCK") == 0) - return VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK; - if (ktx_strcasecmp(str, "EAC_R11_UNORM_BLOCK") == 0) - return VK_FORMAT_EAC_R11_UNORM_BLOCK; - if (ktx_strcasecmp(str, "EAC_R11_SNORM_BLOCK") == 0) - return VK_FORMAT_EAC_R11_SNORM_BLOCK; - if (ktx_strcasecmp(str, "EAC_R11G11_UNORM_BLOCK") == 0) - return VK_FORMAT_EAC_R11G11_UNORM_BLOCK; - if (ktx_strcasecmp(str, "EAC_R11G11_SNORM_BLOCK") == 0) - return VK_FORMAT_EAC_R11G11_SNORM_BLOCK; - if (ktx_strcasecmp(str, "ASTC_4x4_UNORM_BLOCK") == 0) - return VK_FORMAT_ASTC_4x4_UNORM_BLOCK; - if (ktx_strcasecmp(str, "ASTC_4x4_SRGB_BLOCK") == 0) - return VK_FORMAT_ASTC_4x4_SRGB_BLOCK; - if (ktx_strcasecmp(str, "ASTC_5x4_UNORM_BLOCK") == 0) - return VK_FORMAT_ASTC_5x4_UNORM_BLOCK; - if (ktx_strcasecmp(str, "ASTC_5x4_SRGB_BLOCK") == 0) - return VK_FORMAT_ASTC_5x4_SRGB_BLOCK; - if (ktx_strcasecmp(str, "ASTC_5x5_UNORM_BLOCK") == 0) - return VK_FORMAT_ASTC_5x5_UNORM_BLOCK; - if (ktx_strcasecmp(str, "ASTC_5x5_SRGB_BLOCK") == 0) - return VK_FORMAT_ASTC_5x5_SRGB_BLOCK; - if (ktx_strcasecmp(str, "ASTC_6x5_UNORM_BLOCK") == 0) - return VK_FORMAT_ASTC_6x5_UNORM_BLOCK; - if (ktx_strcasecmp(str, "ASTC_6x5_SRGB_BLOCK") == 0) - return VK_FORMAT_ASTC_6x5_SRGB_BLOCK; - if (ktx_strcasecmp(str, "ASTC_6x6_UNORM_BLOCK") == 0) - return VK_FORMAT_ASTC_6x6_UNORM_BLOCK; - if (ktx_strcasecmp(str, "ASTC_6x6_SRGB_BLOCK") == 0) - return VK_FORMAT_ASTC_6x6_SRGB_BLOCK; - if (ktx_strcasecmp(str, "ASTC_8x5_UNORM_BLOCK") == 0) - return VK_FORMAT_ASTC_8x5_UNORM_BLOCK; - if (ktx_strcasecmp(str, "ASTC_8x5_SRGB_BLOCK") == 0) - return VK_FORMAT_ASTC_8x5_SRGB_BLOCK; - if (ktx_strcasecmp(str, "ASTC_8x6_UNORM_BLOCK") == 0) - return VK_FORMAT_ASTC_8x6_UNORM_BLOCK; - if (ktx_strcasecmp(str, "ASTC_8x6_SRGB_BLOCK") == 0) - return VK_FORMAT_ASTC_8x6_SRGB_BLOCK; - if (ktx_strcasecmp(str, "ASTC_8x8_UNORM_BLOCK") == 0) - return VK_FORMAT_ASTC_8x8_UNORM_BLOCK; - if (ktx_strcasecmp(str, "ASTC_8x8_SRGB_BLOCK") == 0) - return VK_FORMAT_ASTC_8x8_SRGB_BLOCK; - if (ktx_strcasecmp(str, "ASTC_10x5_UNORM_BLOCK") == 0) - return VK_FORMAT_ASTC_10x5_UNORM_BLOCK; - if (ktx_strcasecmp(str, "ASTC_10x5_SRGB_BLOCK") == 0) - return VK_FORMAT_ASTC_10x5_SRGB_BLOCK; - if (ktx_strcasecmp(str, "ASTC_10x6_UNORM_BLOCK") == 0) - return VK_FORMAT_ASTC_10x6_UNORM_BLOCK; - if (ktx_strcasecmp(str, "ASTC_10x6_SRGB_BLOCK") == 0) - return VK_FORMAT_ASTC_10x6_SRGB_BLOCK; - if (ktx_strcasecmp(str, "ASTC_10x8_UNORM_BLOCK") == 0) - return VK_FORMAT_ASTC_10x8_UNORM_BLOCK; - if (ktx_strcasecmp(str, "ASTC_10x8_SRGB_BLOCK") == 0) - return VK_FORMAT_ASTC_10x8_SRGB_BLOCK; - if (ktx_strcasecmp(str, "ASTC_10x10_UNORM_BLOCK") == 0) - return VK_FORMAT_ASTC_10x10_UNORM_BLOCK; - if (ktx_strcasecmp(str, "ASTC_10x10_SRGB_BLOCK") == 0) - return VK_FORMAT_ASTC_10x10_SRGB_BLOCK; - if (ktx_strcasecmp(str, "ASTC_12x10_UNORM_BLOCK") == 0) - return VK_FORMAT_ASTC_12x10_UNORM_BLOCK; - if (ktx_strcasecmp(str, "ASTC_12x10_SRGB_BLOCK") == 0) - return VK_FORMAT_ASTC_12x10_SRGB_BLOCK; - if (ktx_strcasecmp(str, "ASTC_12x12_UNORM_BLOCK") == 0) - return VK_FORMAT_ASTC_12x12_UNORM_BLOCK; - if (ktx_strcasecmp(str, "ASTC_12x12_SRGB_BLOCK") == 0) - return VK_FORMAT_ASTC_12x12_SRGB_BLOCK; - if (ktx_strcasecmp(str, "G8B8G8R8_422_UNORM") == 0) - return VK_FORMAT_G8B8G8R8_422_UNORM; - if (ktx_strcasecmp(str, "B8G8R8G8_422_UNORM") == 0) - return VK_FORMAT_B8G8R8G8_422_UNORM; - if (ktx_strcasecmp(str, "G8_B8_R8_3PLANE_420_UNORM") == 0) - return VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM; - if (ktx_strcasecmp(str, "G8_B8R8_2PLANE_420_UNORM") == 0) - return VK_FORMAT_G8_B8R8_2PLANE_420_UNORM; - if (ktx_strcasecmp(str, "G8_B8_R8_3PLANE_422_UNORM") == 0) - return VK_FORMAT_G8_B8_R8_3PLANE_422_UNORM; - if (ktx_strcasecmp(str, "G8_B8R8_2PLANE_422_UNORM") == 0) - return VK_FORMAT_G8_B8R8_2PLANE_422_UNORM; - if (ktx_strcasecmp(str, "G8_B8_R8_3PLANE_444_UNORM") == 0) - return VK_FORMAT_G8_B8_R8_3PLANE_444_UNORM; - if (ktx_strcasecmp(str, "R10X6_UNORM_PACK16") == 0) - return VK_FORMAT_R10X6_UNORM_PACK16; - if (ktx_strcasecmp(str, "R10X6G10X6_UNORM_2PACK16") == 0) - return VK_FORMAT_R10X6G10X6_UNORM_2PACK16; - if (ktx_strcasecmp(str, "R10X6G10X6B10X6A10X6_UNORM_4PACK16") == 0) - return VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16; - if (ktx_strcasecmp(str, "G10X6B10X6G10X6R10X6_422_UNORM_4PACK16") == 0) - return VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16; - if (ktx_strcasecmp(str, "B10X6G10X6R10X6G10X6_422_UNORM_4PACK16") == 0) - return VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16; + if (ktx_strcasecmp(str, "UNDEFINED") == 0) return VK_FORMAT_UNDEFINED; + if (ktx_strcasecmp(str, "R4G4_UNORM_PACK8") == 0) return VK_FORMAT_R4G4_UNORM_PACK8; + if (ktx_strcasecmp(str, "R4G4B4A4_UNORM_PACK16") == 0) return VK_FORMAT_R4G4B4A4_UNORM_PACK16; + if (ktx_strcasecmp(str, "B4G4R4A4_UNORM_PACK16") == 0) return VK_FORMAT_B4G4R4A4_UNORM_PACK16; + if (ktx_strcasecmp(str, "R5G6B5_UNORM_PACK16") == 0) return VK_FORMAT_R5G6B5_UNORM_PACK16; + if (ktx_strcasecmp(str, "B5G6R5_UNORM_PACK16") == 0) return VK_FORMAT_B5G6R5_UNORM_PACK16; + if (ktx_strcasecmp(str, "R5G5B5A1_UNORM_PACK16") == 0) return VK_FORMAT_R5G5B5A1_UNORM_PACK16; + if (ktx_strcasecmp(str, "B5G5R5A1_UNORM_PACK16") == 0) return VK_FORMAT_B5G5R5A1_UNORM_PACK16; + if (ktx_strcasecmp(str, "A1R5G5B5_UNORM_PACK16") == 0) return VK_FORMAT_A1R5G5B5_UNORM_PACK16; + if (ktx_strcasecmp(str, "R8_UNORM") == 0) return VK_FORMAT_R8_UNORM; + if (ktx_strcasecmp(str, "R8_SNORM") == 0) return VK_FORMAT_R8_SNORM; + if (ktx_strcasecmp(str, "R8_USCALED") == 0) return VK_FORMAT_R8_USCALED; + if (ktx_strcasecmp(str, "R8_SSCALED") == 0) return VK_FORMAT_R8_SSCALED; + if (ktx_strcasecmp(str, "R8_UINT") == 0) return VK_FORMAT_R8_UINT; + if (ktx_strcasecmp(str, "R8_SINT") == 0) return VK_FORMAT_R8_SINT; + if (ktx_strcasecmp(str, "R8_SRGB") == 0) return VK_FORMAT_R8_SRGB; + if (ktx_strcasecmp(str, "R8G8_UNORM") == 0) return VK_FORMAT_R8G8_UNORM; + if (ktx_strcasecmp(str, "R8G8_SNORM") == 0) return VK_FORMAT_R8G8_SNORM; + if (ktx_strcasecmp(str, "R8G8_USCALED") == 0) return VK_FORMAT_R8G8_USCALED; + if (ktx_strcasecmp(str, "R8G8_SSCALED") == 0) return VK_FORMAT_R8G8_SSCALED; + if (ktx_strcasecmp(str, "R8G8_UINT") == 0) return VK_FORMAT_R8G8_UINT; + if (ktx_strcasecmp(str, "R8G8_SINT") == 0) return VK_FORMAT_R8G8_SINT; + if (ktx_strcasecmp(str, "R8G8_SRGB") == 0) return VK_FORMAT_R8G8_SRGB; + if (ktx_strcasecmp(str, "R8G8B8_UNORM") == 0) return VK_FORMAT_R8G8B8_UNORM; + if (ktx_strcasecmp(str, "R8G8B8_SNORM") == 0) return VK_FORMAT_R8G8B8_SNORM; + if (ktx_strcasecmp(str, "R8G8B8_USCALED") == 0) return VK_FORMAT_R8G8B8_USCALED; + if (ktx_strcasecmp(str, "R8G8B8_SSCALED") == 0) return VK_FORMAT_R8G8B8_SSCALED; + if (ktx_strcasecmp(str, "R8G8B8_UINT") == 0) return VK_FORMAT_R8G8B8_UINT; + if (ktx_strcasecmp(str, "R8G8B8_SINT") == 0) return VK_FORMAT_R8G8B8_SINT; + if (ktx_strcasecmp(str, "R8G8B8_SRGB") == 0) return VK_FORMAT_R8G8B8_SRGB; + if (ktx_strcasecmp(str, "B8G8R8_UNORM") == 0) return VK_FORMAT_B8G8R8_UNORM; + if (ktx_strcasecmp(str, "B8G8R8_SNORM") == 0) return VK_FORMAT_B8G8R8_SNORM; + if (ktx_strcasecmp(str, "B8G8R8_USCALED") == 0) return VK_FORMAT_B8G8R8_USCALED; + if (ktx_strcasecmp(str, "B8G8R8_SSCALED") == 0) return VK_FORMAT_B8G8R8_SSCALED; + if (ktx_strcasecmp(str, "B8G8R8_UINT") == 0) return VK_FORMAT_B8G8R8_UINT; + if (ktx_strcasecmp(str, "B8G8R8_SINT") == 0) return VK_FORMAT_B8G8R8_SINT; + if (ktx_strcasecmp(str, "B8G8R8_SRGB") == 0) return VK_FORMAT_B8G8R8_SRGB; + if (ktx_strcasecmp(str, "R8G8B8A8_UNORM") == 0) return VK_FORMAT_R8G8B8A8_UNORM; + if (ktx_strcasecmp(str, "R8G8B8A8_SNORM") == 0) return VK_FORMAT_R8G8B8A8_SNORM; + if (ktx_strcasecmp(str, "R8G8B8A8_USCALED") == 0) return VK_FORMAT_R8G8B8A8_USCALED; + if (ktx_strcasecmp(str, "R8G8B8A8_SSCALED") == 0) return VK_FORMAT_R8G8B8A8_SSCALED; + if (ktx_strcasecmp(str, "R8G8B8A8_UINT") == 0) return VK_FORMAT_R8G8B8A8_UINT; + if (ktx_strcasecmp(str, "R8G8B8A8_SINT") == 0) return VK_FORMAT_R8G8B8A8_SINT; + if (ktx_strcasecmp(str, "R8G8B8A8_SRGB") == 0) return VK_FORMAT_R8G8B8A8_SRGB; + if (ktx_strcasecmp(str, "B8G8R8A8_UNORM") == 0) return VK_FORMAT_B8G8R8A8_UNORM; + if (ktx_strcasecmp(str, "B8G8R8A8_SNORM") == 0) return VK_FORMAT_B8G8R8A8_SNORM; + if (ktx_strcasecmp(str, "B8G8R8A8_USCALED") == 0) return VK_FORMAT_B8G8R8A8_USCALED; + if (ktx_strcasecmp(str, "B8G8R8A8_SSCALED") == 0) return VK_FORMAT_B8G8R8A8_SSCALED; + if (ktx_strcasecmp(str, "B8G8R8A8_UINT") == 0) return VK_FORMAT_B8G8R8A8_UINT; + if (ktx_strcasecmp(str, "B8G8R8A8_SINT") == 0) return VK_FORMAT_B8G8R8A8_SINT; + if (ktx_strcasecmp(str, "B8G8R8A8_SRGB") == 0) return VK_FORMAT_B8G8R8A8_SRGB; + if (ktx_strcasecmp(str, "A8B8G8R8_UNORM_PACK32") == 0) return VK_FORMAT_A8B8G8R8_UNORM_PACK32; + if (ktx_strcasecmp(str, "A8B8G8R8_SNORM_PACK32") == 0) return VK_FORMAT_A8B8G8R8_SNORM_PACK32; + if (ktx_strcasecmp(str, "A8B8G8R8_USCALED_PACK32") == 0) return VK_FORMAT_A8B8G8R8_USCALED_PACK32; + if (ktx_strcasecmp(str, "A8B8G8R8_SSCALED_PACK32") == 0) return VK_FORMAT_A8B8G8R8_SSCALED_PACK32; + if (ktx_strcasecmp(str, "A8B8G8R8_UINT_PACK32") == 0) return VK_FORMAT_A8B8G8R8_UINT_PACK32; + if (ktx_strcasecmp(str, "A8B8G8R8_SINT_PACK32") == 0) return VK_FORMAT_A8B8G8R8_SINT_PACK32; + if (ktx_strcasecmp(str, "A8B8G8R8_SRGB_PACK32") == 0) return VK_FORMAT_A8B8G8R8_SRGB_PACK32; + if (ktx_strcasecmp(str, "A2R10G10B10_UNORM_PACK32") == 0) return VK_FORMAT_A2R10G10B10_UNORM_PACK32; + if (ktx_strcasecmp(str, "A2R10G10B10_SNORM_PACK32") == 0) return VK_FORMAT_A2R10G10B10_SNORM_PACK32; + if (ktx_strcasecmp(str, "A2R10G10B10_USCALED_PACK32") == 0) return VK_FORMAT_A2R10G10B10_USCALED_PACK32; + if (ktx_strcasecmp(str, "A2R10G10B10_SSCALED_PACK32") == 0) return VK_FORMAT_A2R10G10B10_SSCALED_PACK32; + if (ktx_strcasecmp(str, "A2R10G10B10_UINT_PACK32") == 0) return VK_FORMAT_A2R10G10B10_UINT_PACK32; + if (ktx_strcasecmp(str, "A2R10G10B10_SINT_PACK32") == 0) return VK_FORMAT_A2R10G10B10_SINT_PACK32; + if (ktx_strcasecmp(str, "A2B10G10R10_UNORM_PACK32") == 0) return VK_FORMAT_A2B10G10R10_UNORM_PACK32; + if (ktx_strcasecmp(str, "A2B10G10R10_SNORM_PACK32") == 0) return VK_FORMAT_A2B10G10R10_SNORM_PACK32; + if (ktx_strcasecmp(str, "A2B10G10R10_USCALED_PACK32") == 0) return VK_FORMAT_A2B10G10R10_USCALED_PACK32; + if (ktx_strcasecmp(str, "A2B10G10R10_SSCALED_PACK32") == 0) return VK_FORMAT_A2B10G10R10_SSCALED_PACK32; + if (ktx_strcasecmp(str, "A2B10G10R10_UINT_PACK32") == 0) return VK_FORMAT_A2B10G10R10_UINT_PACK32; + if (ktx_strcasecmp(str, "A2B10G10R10_SINT_PACK32") == 0) return VK_FORMAT_A2B10G10R10_SINT_PACK32; + if (ktx_strcasecmp(str, "R16_UNORM") == 0) return VK_FORMAT_R16_UNORM; + if (ktx_strcasecmp(str, "R16_SNORM") == 0) return VK_FORMAT_R16_SNORM; + if (ktx_strcasecmp(str, "R16_USCALED") == 0) return VK_FORMAT_R16_USCALED; + if (ktx_strcasecmp(str, "R16_SSCALED") == 0) return VK_FORMAT_R16_SSCALED; + if (ktx_strcasecmp(str, "R16_UINT") == 0) return VK_FORMAT_R16_UINT; + if (ktx_strcasecmp(str, "R16_SINT") == 0) return VK_FORMAT_R16_SINT; + if (ktx_strcasecmp(str, "R16_SFLOAT") == 0) return VK_FORMAT_R16_SFLOAT; + if (ktx_strcasecmp(str, "R16G16_UNORM") == 0) return VK_FORMAT_R16G16_UNORM; + if (ktx_strcasecmp(str, "R16G16_SNORM") == 0) return VK_FORMAT_R16G16_SNORM; + if (ktx_strcasecmp(str, "R16G16_USCALED") == 0) return VK_FORMAT_R16G16_USCALED; + if (ktx_strcasecmp(str, "R16G16_SSCALED") == 0) return VK_FORMAT_R16G16_SSCALED; + if (ktx_strcasecmp(str, "R16G16_UINT") == 0) return VK_FORMAT_R16G16_UINT; + if (ktx_strcasecmp(str, "R16G16_SINT") == 0) return VK_FORMAT_R16G16_SINT; + if (ktx_strcasecmp(str, "R16G16_SFLOAT") == 0) return VK_FORMAT_R16G16_SFLOAT; + if (ktx_strcasecmp(str, "R16G16B16_UNORM") == 0) return VK_FORMAT_R16G16B16_UNORM; + if (ktx_strcasecmp(str, "R16G16B16_SNORM") == 0) return VK_FORMAT_R16G16B16_SNORM; + if (ktx_strcasecmp(str, "R16G16B16_USCALED") == 0) return VK_FORMAT_R16G16B16_USCALED; + if (ktx_strcasecmp(str, "R16G16B16_SSCALED") == 0) return VK_FORMAT_R16G16B16_SSCALED; + if (ktx_strcasecmp(str, "R16G16B16_UINT") == 0) return VK_FORMAT_R16G16B16_UINT; + if (ktx_strcasecmp(str, "R16G16B16_SINT") == 0) return VK_FORMAT_R16G16B16_SINT; + if (ktx_strcasecmp(str, "R16G16B16_SFLOAT") == 0) return VK_FORMAT_R16G16B16_SFLOAT; + if (ktx_strcasecmp(str, "R16G16B16A16_UNORM") == 0) return VK_FORMAT_R16G16B16A16_UNORM; + if (ktx_strcasecmp(str, "R16G16B16A16_SNORM") == 0) return VK_FORMAT_R16G16B16A16_SNORM; + if (ktx_strcasecmp(str, "R16G16B16A16_USCALED") == 0) return VK_FORMAT_R16G16B16A16_USCALED; + if (ktx_strcasecmp(str, "R16G16B16A16_SSCALED") == 0) return VK_FORMAT_R16G16B16A16_SSCALED; + if (ktx_strcasecmp(str, "R16G16B16A16_UINT") == 0) return VK_FORMAT_R16G16B16A16_UINT; + if (ktx_strcasecmp(str, "R16G16B16A16_SINT") == 0) return VK_FORMAT_R16G16B16A16_SINT; + if (ktx_strcasecmp(str, "R16G16B16A16_SFLOAT") == 0) return VK_FORMAT_R16G16B16A16_SFLOAT; + if (ktx_strcasecmp(str, "R32_UINT") == 0) return VK_FORMAT_R32_UINT; + if (ktx_strcasecmp(str, "R32_SINT") == 0) return VK_FORMAT_R32_SINT; + if (ktx_strcasecmp(str, "R32_SFLOAT") == 0) return VK_FORMAT_R32_SFLOAT; + if (ktx_strcasecmp(str, "R32G32_UINT") == 0) return VK_FORMAT_R32G32_UINT; + if (ktx_strcasecmp(str, "R32G32_SINT") == 0) return VK_FORMAT_R32G32_SINT; + if (ktx_strcasecmp(str, "R32G32_SFLOAT") == 0) return VK_FORMAT_R32G32_SFLOAT; + if (ktx_strcasecmp(str, "R32G32B32_UINT") == 0) return VK_FORMAT_R32G32B32_UINT; + if (ktx_strcasecmp(str, "R32G32B32_SINT") == 0) return VK_FORMAT_R32G32B32_SINT; + if (ktx_strcasecmp(str, "R32G32B32_SFLOAT") == 0) return VK_FORMAT_R32G32B32_SFLOAT; + if (ktx_strcasecmp(str, "R32G32B32A32_UINT") == 0) return VK_FORMAT_R32G32B32A32_UINT; + if (ktx_strcasecmp(str, "R32G32B32A32_SINT") == 0) return VK_FORMAT_R32G32B32A32_SINT; + if (ktx_strcasecmp(str, "R32G32B32A32_SFLOAT") == 0) return VK_FORMAT_R32G32B32A32_SFLOAT; + if (ktx_strcasecmp(str, "R64_UINT") == 0) return VK_FORMAT_R64_UINT; + if (ktx_strcasecmp(str, "R64_SINT") == 0) return VK_FORMAT_R64_SINT; + if (ktx_strcasecmp(str, "R64_SFLOAT") == 0) return VK_FORMAT_R64_SFLOAT; + if (ktx_strcasecmp(str, "R64G64_UINT") == 0) return VK_FORMAT_R64G64_UINT; + if (ktx_strcasecmp(str, "R64G64_SINT") == 0) return VK_FORMAT_R64G64_SINT; + if (ktx_strcasecmp(str, "R64G64_SFLOAT") == 0) return VK_FORMAT_R64G64_SFLOAT; + if (ktx_strcasecmp(str, "R64G64B64_UINT") == 0) return VK_FORMAT_R64G64B64_UINT; + if (ktx_strcasecmp(str, "R64G64B64_SINT") == 0) return VK_FORMAT_R64G64B64_SINT; + if (ktx_strcasecmp(str, "R64G64B64_SFLOAT") == 0) return VK_FORMAT_R64G64B64_SFLOAT; + if (ktx_strcasecmp(str, "R64G64B64A64_UINT") == 0) return VK_FORMAT_R64G64B64A64_UINT; + if (ktx_strcasecmp(str, "R64G64B64A64_SINT") == 0) return VK_FORMAT_R64G64B64A64_SINT; + if (ktx_strcasecmp(str, "R64G64B64A64_SFLOAT") == 0) return VK_FORMAT_R64G64B64A64_SFLOAT; + if (ktx_strcasecmp(str, "B10G11R11_UFLOAT_PACK32") == 0) return VK_FORMAT_B10G11R11_UFLOAT_PACK32; + if (ktx_strcasecmp(str, "E5B9G9R9_UFLOAT_PACK32") == 0) return VK_FORMAT_E5B9G9R9_UFLOAT_PACK32; + if (ktx_strcasecmp(str, "D16_UNORM") == 0) return VK_FORMAT_D16_UNORM; + if (ktx_strcasecmp(str, "X8_D24_UNORM_PACK32") == 0) return VK_FORMAT_X8_D24_UNORM_PACK32; + if (ktx_strcasecmp(str, "D32_SFLOAT") == 0) return VK_FORMAT_D32_SFLOAT; + if (ktx_strcasecmp(str, "S8_UINT") == 0) return VK_FORMAT_S8_UINT; + if (ktx_strcasecmp(str, "D16_UNORM_S8_UINT") == 0) return VK_FORMAT_D16_UNORM_S8_UINT; + if (ktx_strcasecmp(str, "D24_UNORM_S8_UINT") == 0) return VK_FORMAT_D24_UNORM_S8_UINT; + if (ktx_strcasecmp(str, "D32_SFLOAT_S8_UINT") == 0) return VK_FORMAT_D32_SFLOAT_S8_UINT; + if (ktx_strcasecmp(str, "BC1_RGB_UNORM_BLOCK") == 0) return VK_FORMAT_BC1_RGB_UNORM_BLOCK; + if (ktx_strcasecmp(str, "BC1_RGB_SRGB_BLOCK") == 0) return VK_FORMAT_BC1_RGB_SRGB_BLOCK; + if (ktx_strcasecmp(str, "BC1_RGBA_UNORM_BLOCK") == 0) return VK_FORMAT_BC1_RGBA_UNORM_BLOCK; + if (ktx_strcasecmp(str, "BC1_RGBA_SRGB_BLOCK") == 0) return VK_FORMAT_BC1_RGBA_SRGB_BLOCK; + if (ktx_strcasecmp(str, "BC2_UNORM_BLOCK") == 0) return VK_FORMAT_BC2_UNORM_BLOCK; + if (ktx_strcasecmp(str, "BC2_SRGB_BLOCK") == 0) return VK_FORMAT_BC2_SRGB_BLOCK; + if (ktx_strcasecmp(str, "BC3_UNORM_BLOCK") == 0) return VK_FORMAT_BC3_UNORM_BLOCK; + if (ktx_strcasecmp(str, "BC3_SRGB_BLOCK") == 0) return VK_FORMAT_BC3_SRGB_BLOCK; + if (ktx_strcasecmp(str, "BC4_UNORM_BLOCK") == 0) return VK_FORMAT_BC4_UNORM_BLOCK; + if (ktx_strcasecmp(str, "BC4_SNORM_BLOCK") == 0) return VK_FORMAT_BC4_SNORM_BLOCK; + if (ktx_strcasecmp(str, "BC5_UNORM_BLOCK") == 0) return VK_FORMAT_BC5_UNORM_BLOCK; + if (ktx_strcasecmp(str, "BC5_SNORM_BLOCK") == 0) return VK_FORMAT_BC5_SNORM_BLOCK; + if (ktx_strcasecmp(str, "BC6H_UFLOAT_BLOCK") == 0) return VK_FORMAT_BC6H_UFLOAT_BLOCK; + if (ktx_strcasecmp(str, "BC6H_SFLOAT_BLOCK") == 0) return VK_FORMAT_BC6H_SFLOAT_BLOCK; + if (ktx_strcasecmp(str, "BC7_UNORM_BLOCK") == 0) return VK_FORMAT_BC7_UNORM_BLOCK; + if (ktx_strcasecmp(str, "BC7_SRGB_BLOCK") == 0) return VK_FORMAT_BC7_SRGB_BLOCK; + if (ktx_strcasecmp(str, "ETC2_R8G8B8_UNORM_BLOCK") == 0) return VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK; + if (ktx_strcasecmp(str, "ETC2_R8G8B8_SRGB_BLOCK") == 0) return VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK; + if (ktx_strcasecmp(str, "ETC2_R8G8B8A1_UNORM_BLOCK") == 0) return VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK; + if (ktx_strcasecmp(str, "ETC2_R8G8B8A1_SRGB_BLOCK") == 0) return VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK; + if (ktx_strcasecmp(str, "ETC2_R8G8B8A8_UNORM_BLOCK") == 0) return VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK; + if (ktx_strcasecmp(str, "ETC2_R8G8B8A8_SRGB_BLOCK") == 0) return VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK; + if (ktx_strcasecmp(str, "EAC_R11_UNORM_BLOCK") == 0) return VK_FORMAT_EAC_R11_UNORM_BLOCK; + if (ktx_strcasecmp(str, "EAC_R11_SNORM_BLOCK") == 0) return VK_FORMAT_EAC_R11_SNORM_BLOCK; + if (ktx_strcasecmp(str, "EAC_R11G11_UNORM_BLOCK") == 0) return VK_FORMAT_EAC_R11G11_UNORM_BLOCK; + if (ktx_strcasecmp(str, "EAC_R11G11_SNORM_BLOCK") == 0) return VK_FORMAT_EAC_R11G11_SNORM_BLOCK; + if (ktx_strcasecmp(str, "ASTC_4x4_UNORM_BLOCK") == 0) return VK_FORMAT_ASTC_4x4_UNORM_BLOCK; + if (ktx_strcasecmp(str, "ASTC_4x4_SRGB_BLOCK") == 0) return VK_FORMAT_ASTC_4x4_SRGB_BLOCK; + if (ktx_strcasecmp(str, "ASTC_5x4_UNORM_BLOCK") == 0) return VK_FORMAT_ASTC_5x4_UNORM_BLOCK; + if (ktx_strcasecmp(str, "ASTC_5x4_SRGB_BLOCK") == 0) return VK_FORMAT_ASTC_5x4_SRGB_BLOCK; + if (ktx_strcasecmp(str, "ASTC_5x5_UNORM_BLOCK") == 0) return VK_FORMAT_ASTC_5x5_UNORM_BLOCK; + if (ktx_strcasecmp(str, "ASTC_5x5_SRGB_BLOCK") == 0) return VK_FORMAT_ASTC_5x5_SRGB_BLOCK; + if (ktx_strcasecmp(str, "ASTC_6x5_UNORM_BLOCK") == 0) return VK_FORMAT_ASTC_6x5_UNORM_BLOCK; + if (ktx_strcasecmp(str, "ASTC_6x5_SRGB_BLOCK") == 0) return VK_FORMAT_ASTC_6x5_SRGB_BLOCK; + if (ktx_strcasecmp(str, "ASTC_6x6_UNORM_BLOCK") == 0) return VK_FORMAT_ASTC_6x6_UNORM_BLOCK; + if (ktx_strcasecmp(str, "ASTC_6x6_SRGB_BLOCK") == 0) return VK_FORMAT_ASTC_6x6_SRGB_BLOCK; + if (ktx_strcasecmp(str, "ASTC_8x5_UNORM_BLOCK") == 0) return VK_FORMAT_ASTC_8x5_UNORM_BLOCK; + if (ktx_strcasecmp(str, "ASTC_8x5_SRGB_BLOCK") == 0) return VK_FORMAT_ASTC_8x5_SRGB_BLOCK; + if (ktx_strcasecmp(str, "ASTC_8x6_UNORM_BLOCK") == 0) return VK_FORMAT_ASTC_8x6_UNORM_BLOCK; + if (ktx_strcasecmp(str, "ASTC_8x6_SRGB_BLOCK") == 0) return VK_FORMAT_ASTC_8x6_SRGB_BLOCK; + if (ktx_strcasecmp(str, "ASTC_8x8_UNORM_BLOCK") == 0) return VK_FORMAT_ASTC_8x8_UNORM_BLOCK; + if (ktx_strcasecmp(str, "ASTC_8x8_SRGB_BLOCK") == 0) return VK_FORMAT_ASTC_8x8_SRGB_BLOCK; + if (ktx_strcasecmp(str, "ASTC_10x5_UNORM_BLOCK") == 0) return VK_FORMAT_ASTC_10x5_UNORM_BLOCK; + if (ktx_strcasecmp(str, "ASTC_10x5_SRGB_BLOCK") == 0) return VK_FORMAT_ASTC_10x5_SRGB_BLOCK; + if (ktx_strcasecmp(str, "ASTC_10x6_UNORM_BLOCK") == 0) return VK_FORMAT_ASTC_10x6_UNORM_BLOCK; + if (ktx_strcasecmp(str, "ASTC_10x6_SRGB_BLOCK") == 0) return VK_FORMAT_ASTC_10x6_SRGB_BLOCK; + if (ktx_strcasecmp(str, "ASTC_10x8_UNORM_BLOCK") == 0) return VK_FORMAT_ASTC_10x8_UNORM_BLOCK; + if (ktx_strcasecmp(str, "ASTC_10x8_SRGB_BLOCK") == 0) return VK_FORMAT_ASTC_10x8_SRGB_BLOCK; + if (ktx_strcasecmp(str, "ASTC_10x10_UNORM_BLOCK") == 0) return VK_FORMAT_ASTC_10x10_UNORM_BLOCK; + if (ktx_strcasecmp(str, "ASTC_10x10_SRGB_BLOCK") == 0) return VK_FORMAT_ASTC_10x10_SRGB_BLOCK; + if (ktx_strcasecmp(str, "ASTC_12x10_UNORM_BLOCK") == 0) return VK_FORMAT_ASTC_12x10_UNORM_BLOCK; + if (ktx_strcasecmp(str, "ASTC_12x10_SRGB_BLOCK") == 0) return VK_FORMAT_ASTC_12x10_SRGB_BLOCK; + if (ktx_strcasecmp(str, "ASTC_12x12_UNORM_BLOCK") == 0) return VK_FORMAT_ASTC_12x12_UNORM_BLOCK; + if (ktx_strcasecmp(str, "ASTC_12x12_SRGB_BLOCK") == 0) return VK_FORMAT_ASTC_12x12_SRGB_BLOCK; + if (ktx_strcasecmp(str, "G8B8G8R8_422_UNORM") == 0) return VK_FORMAT_G8B8G8R8_422_UNORM; + if (ktx_strcasecmp(str, "B8G8R8G8_422_UNORM") == 0) return VK_FORMAT_B8G8R8G8_422_UNORM; + if (ktx_strcasecmp(str, "G8_B8_R8_3PLANE_420_UNORM") == 0) return VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM; + if (ktx_strcasecmp(str, "G8_B8R8_2PLANE_420_UNORM") == 0) return VK_FORMAT_G8_B8R8_2PLANE_420_UNORM; + if (ktx_strcasecmp(str, "G8_B8_R8_3PLANE_422_UNORM") == 0) return VK_FORMAT_G8_B8_R8_3PLANE_422_UNORM; + if (ktx_strcasecmp(str, "G8_B8R8_2PLANE_422_UNORM") == 0) return VK_FORMAT_G8_B8R8_2PLANE_422_UNORM; + if (ktx_strcasecmp(str, "G8_B8_R8_3PLANE_444_UNORM") == 0) return VK_FORMAT_G8_B8_R8_3PLANE_444_UNORM; + if (ktx_strcasecmp(str, "R10X6_UNORM_PACK16") == 0) return VK_FORMAT_R10X6_UNORM_PACK16; + if (ktx_strcasecmp(str, "R10X6G10X6_UNORM_2PACK16") == 0) return VK_FORMAT_R10X6G10X6_UNORM_2PACK16; + if (ktx_strcasecmp(str, "R10X6G10X6B10X6A10X6_UNORM_4PACK16") == 0) return VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16; + if (ktx_strcasecmp(str, "G10X6B10X6G10X6R10X6_422_UNORM_4PACK16") == 0) return VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16; + if (ktx_strcasecmp(str, "B10X6G10X6R10X6G10X6_422_UNORM_4PACK16") == 0) return VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16; if (ktx_strcasecmp(str, "G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16") == 0) return VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16; if (ktx_strcasecmp(str, "G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16") == 0) @@ -1024,16 +822,11 @@ stringToVkFormat(const char* str) return VK_FORMAT_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16; if (ktx_strcasecmp(str, "G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16") == 0) return VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16; - if (ktx_strcasecmp(str, "R12X4_UNORM_PACK16") == 0) - return VK_FORMAT_R12X4_UNORM_PACK16; - if (ktx_strcasecmp(str, "R12X4G12X4_UNORM_2PACK16") == 0) - return VK_FORMAT_R12X4G12X4_UNORM_2PACK16; - if (ktx_strcasecmp(str, "R12X4G12X4B12X4A12X4_UNORM_4PACK16") == 0) - return VK_FORMAT_R12X4G12X4B12X4A12X4_UNORM_4PACK16; - if (ktx_strcasecmp(str, "G12X4B12X4G12X4R12X4_422_UNORM_4PACK16") == 0) - return VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16; - if (ktx_strcasecmp(str, "B12X4G12X4R12X4G12X4_422_UNORM_4PACK16") == 0) - return VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16; + if (ktx_strcasecmp(str, "R12X4_UNORM_PACK16") == 0) return VK_FORMAT_R12X4_UNORM_PACK16; + if (ktx_strcasecmp(str, "R12X4G12X4_UNORM_2PACK16") == 0) return VK_FORMAT_R12X4G12X4_UNORM_2PACK16; + if (ktx_strcasecmp(str, "R12X4G12X4B12X4A12X4_UNORM_4PACK16") == 0) return VK_FORMAT_R12X4G12X4B12X4A12X4_UNORM_4PACK16; + if (ktx_strcasecmp(str, "G12X4B12X4G12X4R12X4_422_UNORM_4PACK16") == 0) return VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16; + if (ktx_strcasecmp(str, "B12X4G12X4R12X4G12X4_422_UNORM_4PACK16") == 0) return VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16; if (ktx_strcasecmp(str, "G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16") == 0) return VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16; if (ktx_strcasecmp(str, "G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16") == 0) @@ -1044,190 +837,100 @@ stringToVkFormat(const char* str) return VK_FORMAT_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16; if (ktx_strcasecmp(str, "G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16") == 0) return VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16; - if (ktx_strcasecmp(str, "G16B16G16R16_422_UNORM") == 0) - return VK_FORMAT_G16B16G16R16_422_UNORM; - if (ktx_strcasecmp(str, "B16G16R16G16_422_UNORM") == 0) - return VK_FORMAT_B16G16R16G16_422_UNORM; - if (ktx_strcasecmp(str, "G16_B16_R16_3PLANE_420_UNORM") == 0) - return VK_FORMAT_G16_B16_R16_3PLANE_420_UNORM; - if (ktx_strcasecmp(str, "G16_B16R16_2PLANE_420_UNORM") == 0) - return VK_FORMAT_G16_B16R16_2PLANE_420_UNORM; - if (ktx_strcasecmp(str, "G16_B16_R16_3PLANE_422_UNORM") == 0) - return VK_FORMAT_G16_B16_R16_3PLANE_422_UNORM; - if (ktx_strcasecmp(str, "G16_B16R16_2PLANE_422_UNORM") == 0) - return VK_FORMAT_G16_B16R16_2PLANE_422_UNORM; - if (ktx_strcasecmp(str, "G16_B16_R16_3PLANE_444_UNORM") == 0) - return VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM; - if (ktx_strcasecmp(str, "G8_B8R8_2PLANE_444_UNORM") == 0) - return VK_FORMAT_G8_B8R8_2PLANE_444_UNORM; + if (ktx_strcasecmp(str, "G16B16G16R16_422_UNORM") == 0) return VK_FORMAT_G16B16G16R16_422_UNORM; + if (ktx_strcasecmp(str, "B16G16R16G16_422_UNORM") == 0) return VK_FORMAT_B16G16R16G16_422_UNORM; + if (ktx_strcasecmp(str, "G16_B16_R16_3PLANE_420_UNORM") == 0) return VK_FORMAT_G16_B16_R16_3PLANE_420_UNORM; + if (ktx_strcasecmp(str, "G16_B16R16_2PLANE_420_UNORM") == 0) return VK_FORMAT_G16_B16R16_2PLANE_420_UNORM; + if (ktx_strcasecmp(str, "G16_B16_R16_3PLANE_422_UNORM") == 0) return VK_FORMAT_G16_B16_R16_3PLANE_422_UNORM; + if (ktx_strcasecmp(str, "G16_B16R16_2PLANE_422_UNORM") == 0) return VK_FORMAT_G16_B16R16_2PLANE_422_UNORM; + if (ktx_strcasecmp(str, "G16_B16_R16_3PLANE_444_UNORM") == 0) return VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM; + if (ktx_strcasecmp(str, "G8_B8R8_2PLANE_444_UNORM") == 0) return VK_FORMAT_G8_B8R8_2PLANE_444_UNORM; if (ktx_strcasecmp(str, "G10X6_B10X6R10X6_2PLANE_444_UNORM_3PACK16") == 0) return VK_FORMAT_G10X6_B10X6R10X6_2PLANE_444_UNORM_3PACK16; if (ktx_strcasecmp(str, "G12X4_B12X4R12X4_2PLANE_444_UNORM_3PACK16") == 0) return VK_FORMAT_G12X4_B12X4R12X4_2PLANE_444_UNORM_3PACK16; - if (ktx_strcasecmp(str, "G16_B16R16_2PLANE_444_UNORM") == 0) - return VK_FORMAT_G16_B16R16_2PLANE_444_UNORM; - if (ktx_strcasecmp(str, "A4R4G4B4_UNORM_PACK16") == 0) - return VK_FORMAT_A4R4G4B4_UNORM_PACK16; - if (ktx_strcasecmp(str, "A4B4G4R4_UNORM_PACK16") == 0) - return VK_FORMAT_A4B4G4R4_UNORM_PACK16; - if (ktx_strcasecmp(str, "ASTC_4x4_SFLOAT_BLOCK") == 0) - return VK_FORMAT_ASTC_4x4_SFLOAT_BLOCK; - if (ktx_strcasecmp(str, "ASTC_5x4_SFLOAT_BLOCK") == 0) - return VK_FORMAT_ASTC_5x4_SFLOAT_BLOCK; - if (ktx_strcasecmp(str, "ASTC_5x5_SFLOAT_BLOCK") == 0) - return VK_FORMAT_ASTC_5x5_SFLOAT_BLOCK; - if (ktx_strcasecmp(str, "ASTC_6x5_SFLOAT_BLOCK") == 0) - return VK_FORMAT_ASTC_6x5_SFLOAT_BLOCK; - if (ktx_strcasecmp(str, "ASTC_6x6_SFLOAT_BLOCK") == 0) - return VK_FORMAT_ASTC_6x6_SFLOAT_BLOCK; - if (ktx_strcasecmp(str, "ASTC_8x5_SFLOAT_BLOCK") == 0) - return VK_FORMAT_ASTC_8x5_SFLOAT_BLOCK; - if (ktx_strcasecmp(str, "ASTC_8x6_SFLOAT_BLOCK") == 0) - return VK_FORMAT_ASTC_8x6_SFLOAT_BLOCK; - if (ktx_strcasecmp(str, "ASTC_8x8_SFLOAT_BLOCK") == 0) - return VK_FORMAT_ASTC_8x8_SFLOAT_BLOCK; - if (ktx_strcasecmp(str, "ASTC_10x5_SFLOAT_BLOCK") == 0) - return VK_FORMAT_ASTC_10x5_SFLOAT_BLOCK; - if (ktx_strcasecmp(str, "ASTC_10x6_SFLOAT_BLOCK") == 0) - return VK_FORMAT_ASTC_10x6_SFLOAT_BLOCK; - if (ktx_strcasecmp(str, "ASTC_10x8_SFLOAT_BLOCK") == 0) - return VK_FORMAT_ASTC_10x8_SFLOAT_BLOCK; - if (ktx_strcasecmp(str, "ASTC_10x10_SFLOAT_BLOCK") == 0) - return VK_FORMAT_ASTC_10x10_SFLOAT_BLOCK; - if (ktx_strcasecmp(str, "ASTC_12x10_SFLOAT_BLOCK") == 0) - return VK_FORMAT_ASTC_12x10_SFLOAT_BLOCK; - if (ktx_strcasecmp(str, "ASTC_12x12_SFLOAT_BLOCK") == 0) - return VK_FORMAT_ASTC_12x12_SFLOAT_BLOCK; - if (ktx_strcasecmp(str, "PVRTC1_2BPP_UNORM_BLOCK_IMG") == 0) - return VK_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG; - if (ktx_strcasecmp(str, "PVRTC1_4BPP_UNORM_BLOCK_IMG") == 0) - return VK_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG; - if (ktx_strcasecmp(str, "PVRTC2_2BPP_UNORM_BLOCK_IMG") == 0) - return VK_FORMAT_PVRTC2_2BPP_UNORM_BLOCK_IMG; - if (ktx_strcasecmp(str, "PVRTC2_4BPP_UNORM_BLOCK_IMG") == 0) - return VK_FORMAT_PVRTC2_4BPP_UNORM_BLOCK_IMG; - if (ktx_strcasecmp(str, "PVRTC1_2BPP_SRGB_BLOCK_IMG") == 0) - return VK_FORMAT_PVRTC1_2BPP_SRGB_BLOCK_IMG; - if (ktx_strcasecmp(str, "PVRTC1_4BPP_SRGB_BLOCK_IMG") == 0) - return VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG; - if (ktx_strcasecmp(str, "PVRTC2_2BPP_SRGB_BLOCK_IMG") == 0) - return VK_FORMAT_PVRTC2_2BPP_SRGB_BLOCK_IMG; - if (ktx_strcasecmp(str, "PVRTC2_4BPP_SRGB_BLOCK_IMG") == 0) - return VK_FORMAT_PVRTC2_4BPP_SRGB_BLOCK_IMG; - if (ktx_strcasecmp(str, "ASTC_3x3x3_UNORM_BLOCK_EXT") == 0) - return VK_FORMAT_ASTC_3x3x3_UNORM_BLOCK_EXT; - if (ktx_strcasecmp(str, "ASTC_3x3x3_SRGB_BLOCK_EXT") == 0) - return VK_FORMAT_ASTC_3x3x3_SRGB_BLOCK_EXT; - if (ktx_strcasecmp(str, "ASTC_3x3x3_SFLOAT_BLOCK_EXT") == 0) - return VK_FORMAT_ASTC_3x3x3_SFLOAT_BLOCK_EXT; - if (ktx_strcasecmp(str, "ASTC_4x3x3_UNORM_BLOCK_EXT") == 0) - return VK_FORMAT_ASTC_4x3x3_UNORM_BLOCK_EXT; - if (ktx_strcasecmp(str, "ASTC_4x3x3_SRGB_BLOCK_EXT") == 0) - return VK_FORMAT_ASTC_4x3x3_SRGB_BLOCK_EXT; - if (ktx_strcasecmp(str, "ASTC_4x3x3_SFLOAT_BLOCK_EXT") == 0) - return VK_FORMAT_ASTC_4x3x3_SFLOAT_BLOCK_EXT; - if (ktx_strcasecmp(str, "ASTC_4x4x3_UNORM_BLOCK_EXT") == 0) - return VK_FORMAT_ASTC_4x4x3_UNORM_BLOCK_EXT; - if (ktx_strcasecmp(str, "ASTC_4x4x3_SRGB_BLOCK_EXT") == 0) - return VK_FORMAT_ASTC_4x4x3_SRGB_BLOCK_EXT; - if (ktx_strcasecmp(str, "ASTC_4x4x3_SFLOAT_BLOCK_EXT") == 0) - return VK_FORMAT_ASTC_4x4x3_SFLOAT_BLOCK_EXT; - if (ktx_strcasecmp(str, "ASTC_4x4x4_UNORM_BLOCK_EXT") == 0) - return VK_FORMAT_ASTC_4x4x4_UNORM_BLOCK_EXT; - if (ktx_strcasecmp(str, "ASTC_4x4x4_SRGB_BLOCK_EXT") == 0) - return VK_FORMAT_ASTC_4x4x4_SRGB_BLOCK_EXT; - if (ktx_strcasecmp(str, "ASTC_4x4x4_SFLOAT_BLOCK_EXT") == 0) - return VK_FORMAT_ASTC_4x4x4_SFLOAT_BLOCK_EXT; - if (ktx_strcasecmp(str, "ASTC_5x4x4_UNORM_BLOCK_EXT") == 0) - return VK_FORMAT_ASTC_5x4x4_UNORM_BLOCK_EXT; - if (ktx_strcasecmp(str, "ASTC_5x4x4_SRGB_BLOCK_EXT") == 0) - return VK_FORMAT_ASTC_5x4x4_SRGB_BLOCK_EXT; - if (ktx_strcasecmp(str, "ASTC_5x4x4_SFLOAT_BLOCK_EXT") == 0) - return VK_FORMAT_ASTC_5x4x4_SFLOAT_BLOCK_EXT; - if (ktx_strcasecmp(str, "ASTC_5x5x4_UNORM_BLOCK_EXT") == 0) - return VK_FORMAT_ASTC_5x5x4_UNORM_BLOCK_EXT; - if (ktx_strcasecmp(str, "ASTC_5x5x4_SRGB_BLOCK_EXT") == 0) - return VK_FORMAT_ASTC_5x5x4_SRGB_BLOCK_EXT; - if (ktx_strcasecmp(str, "ASTC_5x5x4_SFLOAT_BLOCK_EXT") == 0) - return VK_FORMAT_ASTC_5x5x4_SFLOAT_BLOCK_EXT; - if (ktx_strcasecmp(str, "ASTC_5x5x5_UNORM_BLOCK_EXT") == 0) - return VK_FORMAT_ASTC_5x5x5_UNORM_BLOCK_EXT; - if (ktx_strcasecmp(str, "ASTC_5x5x5_SRGB_BLOCK_EXT") == 0) - return VK_FORMAT_ASTC_5x5x5_SRGB_BLOCK_EXT; - if (ktx_strcasecmp(str, "ASTC_5x5x5_SFLOAT_BLOCK_EXT") == 0) - return VK_FORMAT_ASTC_5x5x5_SFLOAT_BLOCK_EXT; - if (ktx_strcasecmp(str, "ASTC_6x5x5_UNORM_BLOCK_EXT") == 0) - return VK_FORMAT_ASTC_6x5x5_UNORM_BLOCK_EXT; - if (ktx_strcasecmp(str, "ASTC_6x5x5_SRGB_BLOCK_EXT") == 0) - return VK_FORMAT_ASTC_6x5x5_SRGB_BLOCK_EXT; - if (ktx_strcasecmp(str, "ASTC_6x5x5_SFLOAT_BLOCK_EXT") == 0) - return VK_FORMAT_ASTC_6x5x5_SFLOAT_BLOCK_EXT; - if (ktx_strcasecmp(str, "ASTC_6x6x5_UNORM_BLOCK_EXT") == 0) - return VK_FORMAT_ASTC_6x6x5_UNORM_BLOCK_EXT; - if (ktx_strcasecmp(str, "ASTC_6x6x5_SRGB_BLOCK_EXT") == 0) - return VK_FORMAT_ASTC_6x6x5_SRGB_BLOCK_EXT; - if (ktx_strcasecmp(str, "ASTC_6x6x5_SFLOAT_BLOCK_EXT") == 0) - return VK_FORMAT_ASTC_6x6x5_SFLOAT_BLOCK_EXT; - if (ktx_strcasecmp(str, "ASTC_6x6x6_UNORM_BLOCK_EXT") == 0) - return VK_FORMAT_ASTC_6x6x6_UNORM_BLOCK_EXT; - if (ktx_strcasecmp(str, "ASTC_6x6x6_SRGB_BLOCK_EXT") == 0) - return VK_FORMAT_ASTC_6x6x6_SRGB_BLOCK_EXT; - if (ktx_strcasecmp(str, "ASTC_6x6x6_SFLOAT_BLOCK_EXT") == 0) - return VK_FORMAT_ASTC_6x6x6_SFLOAT_BLOCK_EXT; - if (ktx_strcasecmp(str, "R16G16_S10_5_NV") == 0) - return VK_FORMAT_R16G16_S10_5_NV; - if (ktx_strcasecmp(str, "A1B5G5R5_UNORM_PACK16_KHR") == 0) - return VK_FORMAT_A1B5G5R5_UNORM_PACK16_KHR; - if (ktx_strcasecmp(str, "A8_UNORM_KHR") == 0) - return VK_FORMAT_A8_UNORM_KHR; - if (ktx_strcasecmp(str, "ASTC_4x4_SFLOAT_BLOCK_EXT") == 0) - return VK_FORMAT_ASTC_4x4_SFLOAT_BLOCK; - if (ktx_strcasecmp(str, "ASTC_5x4_SFLOAT_BLOCK_EXT") == 0) - return VK_FORMAT_ASTC_5x4_SFLOAT_BLOCK; - if (ktx_strcasecmp(str, "ASTC_5x5_SFLOAT_BLOCK_EXT") == 0) - return VK_FORMAT_ASTC_5x5_SFLOAT_BLOCK; - if (ktx_strcasecmp(str, "ASTC_6x5_SFLOAT_BLOCK_EXT") == 0) - return VK_FORMAT_ASTC_6x5_SFLOAT_BLOCK; - if (ktx_strcasecmp(str, "ASTC_6x6_SFLOAT_BLOCK_EXT") == 0) - return VK_FORMAT_ASTC_6x6_SFLOAT_BLOCK; - if (ktx_strcasecmp(str, "ASTC_8x5_SFLOAT_BLOCK_EXT") == 0) - return VK_FORMAT_ASTC_8x5_SFLOAT_BLOCK; - if (ktx_strcasecmp(str, "ASTC_8x6_SFLOAT_BLOCK_EXT") == 0) - return VK_FORMAT_ASTC_8x6_SFLOAT_BLOCK; - if (ktx_strcasecmp(str, "ASTC_8x8_SFLOAT_BLOCK_EXT") == 0) - return VK_FORMAT_ASTC_8x8_SFLOAT_BLOCK; - if (ktx_strcasecmp(str, "ASTC_10x5_SFLOAT_BLOCK_EXT") == 0) - return VK_FORMAT_ASTC_10x5_SFLOAT_BLOCK; - if (ktx_strcasecmp(str, "ASTC_10x6_SFLOAT_BLOCK_EXT") == 0) - return VK_FORMAT_ASTC_10x6_SFLOAT_BLOCK; - if (ktx_strcasecmp(str, "ASTC_10x8_SFLOAT_BLOCK_EXT") == 0) - return VK_FORMAT_ASTC_10x8_SFLOAT_BLOCK; - if (ktx_strcasecmp(str, "ASTC_10x10_SFLOAT_BLOCK_EXT") == 0) - return VK_FORMAT_ASTC_10x10_SFLOAT_BLOCK; - if (ktx_strcasecmp(str, "ASTC_12x10_SFLOAT_BLOCK_EXT") == 0) - return VK_FORMAT_ASTC_12x10_SFLOAT_BLOCK; - if (ktx_strcasecmp(str, "ASTC_12x12_SFLOAT_BLOCK_EXT") == 0) - return VK_FORMAT_ASTC_12x12_SFLOAT_BLOCK; - if (ktx_strcasecmp(str, "G8B8G8R8_422_UNORM_KHR") == 0) - return VK_FORMAT_G8B8G8R8_422_UNORM; - if (ktx_strcasecmp(str, "B8G8R8G8_422_UNORM_KHR") == 0) - return VK_FORMAT_B8G8R8G8_422_UNORM; - if (ktx_strcasecmp(str, "G8_B8_R8_3PLANE_420_UNORM_KHR") == 0) - return VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM; - if (ktx_strcasecmp(str, "G8_B8R8_2PLANE_420_UNORM_KHR") == 0) - return VK_FORMAT_G8_B8R8_2PLANE_420_UNORM; - if (ktx_strcasecmp(str, "G8_B8_R8_3PLANE_422_UNORM_KHR") == 0) - return VK_FORMAT_G8_B8_R8_3PLANE_422_UNORM; - if (ktx_strcasecmp(str, "G8_B8R8_2PLANE_422_UNORM_KHR") == 0) - return VK_FORMAT_G8_B8R8_2PLANE_422_UNORM; - if (ktx_strcasecmp(str, "G8_B8_R8_3PLANE_444_UNORM_KHR") == 0) - return VK_FORMAT_G8_B8_R8_3PLANE_444_UNORM; - if (ktx_strcasecmp(str, "R10X6_UNORM_PACK16_KHR") == 0) - return VK_FORMAT_R10X6_UNORM_PACK16; - if (ktx_strcasecmp(str, "R10X6G10X6_UNORM_2PACK16_KHR") == 0) - return VK_FORMAT_R10X6G10X6_UNORM_2PACK16; - if (ktx_strcasecmp(str, "R10X6G10X6B10X6A10X6_UNORM_4PACK16_KHR") == 0) - return VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16; + if (ktx_strcasecmp(str, "G16_B16R16_2PLANE_444_UNORM") == 0) return VK_FORMAT_G16_B16R16_2PLANE_444_UNORM; + if (ktx_strcasecmp(str, "A4R4G4B4_UNORM_PACK16") == 0) return VK_FORMAT_A4R4G4B4_UNORM_PACK16; + if (ktx_strcasecmp(str, "A4B4G4R4_UNORM_PACK16") == 0) return VK_FORMAT_A4B4G4R4_UNORM_PACK16; + if (ktx_strcasecmp(str, "ASTC_4x4_SFLOAT_BLOCK") == 0) return VK_FORMAT_ASTC_4x4_SFLOAT_BLOCK; + if (ktx_strcasecmp(str, "ASTC_5x4_SFLOAT_BLOCK") == 0) return VK_FORMAT_ASTC_5x4_SFLOAT_BLOCK; + if (ktx_strcasecmp(str, "ASTC_5x5_SFLOAT_BLOCK") == 0) return VK_FORMAT_ASTC_5x5_SFLOAT_BLOCK; + if (ktx_strcasecmp(str, "ASTC_6x5_SFLOAT_BLOCK") == 0) return VK_FORMAT_ASTC_6x5_SFLOAT_BLOCK; + if (ktx_strcasecmp(str, "ASTC_6x6_SFLOAT_BLOCK") == 0) return VK_FORMAT_ASTC_6x6_SFLOAT_BLOCK; + if (ktx_strcasecmp(str, "ASTC_8x5_SFLOAT_BLOCK") == 0) return VK_FORMAT_ASTC_8x5_SFLOAT_BLOCK; + if (ktx_strcasecmp(str, "ASTC_8x6_SFLOAT_BLOCK") == 0) return VK_FORMAT_ASTC_8x6_SFLOAT_BLOCK; + if (ktx_strcasecmp(str, "ASTC_8x8_SFLOAT_BLOCK") == 0) return VK_FORMAT_ASTC_8x8_SFLOAT_BLOCK; + if (ktx_strcasecmp(str, "ASTC_10x5_SFLOAT_BLOCK") == 0) return VK_FORMAT_ASTC_10x5_SFLOAT_BLOCK; + if (ktx_strcasecmp(str, "ASTC_10x6_SFLOAT_BLOCK") == 0) return VK_FORMAT_ASTC_10x6_SFLOAT_BLOCK; + if (ktx_strcasecmp(str, "ASTC_10x8_SFLOAT_BLOCK") == 0) return VK_FORMAT_ASTC_10x8_SFLOAT_BLOCK; + if (ktx_strcasecmp(str, "ASTC_10x10_SFLOAT_BLOCK") == 0) return VK_FORMAT_ASTC_10x10_SFLOAT_BLOCK; + if (ktx_strcasecmp(str, "ASTC_12x10_SFLOAT_BLOCK") == 0) return VK_FORMAT_ASTC_12x10_SFLOAT_BLOCK; + if (ktx_strcasecmp(str, "ASTC_12x12_SFLOAT_BLOCK") == 0) return VK_FORMAT_ASTC_12x12_SFLOAT_BLOCK; + if (ktx_strcasecmp(str, "PVRTC1_2BPP_UNORM_BLOCK_IMG") == 0) return VK_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG; + if (ktx_strcasecmp(str, "PVRTC1_4BPP_UNORM_BLOCK_IMG") == 0) return VK_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG; + if (ktx_strcasecmp(str, "PVRTC2_2BPP_UNORM_BLOCK_IMG") == 0) return VK_FORMAT_PVRTC2_2BPP_UNORM_BLOCK_IMG; + if (ktx_strcasecmp(str, "PVRTC2_4BPP_UNORM_BLOCK_IMG") == 0) return VK_FORMAT_PVRTC2_4BPP_UNORM_BLOCK_IMG; + if (ktx_strcasecmp(str, "PVRTC1_2BPP_SRGB_BLOCK_IMG") == 0) return VK_FORMAT_PVRTC1_2BPP_SRGB_BLOCK_IMG; + if (ktx_strcasecmp(str, "PVRTC1_4BPP_SRGB_BLOCK_IMG") == 0) return VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG; + if (ktx_strcasecmp(str, "PVRTC2_2BPP_SRGB_BLOCK_IMG") == 0) return VK_FORMAT_PVRTC2_2BPP_SRGB_BLOCK_IMG; + if (ktx_strcasecmp(str, "PVRTC2_4BPP_SRGB_BLOCK_IMG") == 0) return VK_FORMAT_PVRTC2_4BPP_SRGB_BLOCK_IMG; + if (ktx_strcasecmp(str, "ASTC_3x3x3_UNORM_BLOCK_EXT") == 0) return VK_FORMAT_ASTC_3x3x3_UNORM_BLOCK_EXT; + if (ktx_strcasecmp(str, "ASTC_3x3x3_SRGB_BLOCK_EXT") == 0) return VK_FORMAT_ASTC_3x3x3_SRGB_BLOCK_EXT; + if (ktx_strcasecmp(str, "ASTC_3x3x3_SFLOAT_BLOCK_EXT") == 0) return VK_FORMAT_ASTC_3x3x3_SFLOAT_BLOCK_EXT; + if (ktx_strcasecmp(str, "ASTC_4x3x3_UNORM_BLOCK_EXT") == 0) return VK_FORMAT_ASTC_4x3x3_UNORM_BLOCK_EXT; + if (ktx_strcasecmp(str, "ASTC_4x3x3_SRGB_BLOCK_EXT") == 0) return VK_FORMAT_ASTC_4x3x3_SRGB_BLOCK_EXT; + if (ktx_strcasecmp(str, "ASTC_4x3x3_SFLOAT_BLOCK_EXT") == 0) return VK_FORMAT_ASTC_4x3x3_SFLOAT_BLOCK_EXT; + if (ktx_strcasecmp(str, "ASTC_4x4x3_UNORM_BLOCK_EXT") == 0) return VK_FORMAT_ASTC_4x4x3_UNORM_BLOCK_EXT; + if (ktx_strcasecmp(str, "ASTC_4x4x3_SRGB_BLOCK_EXT") == 0) return VK_FORMAT_ASTC_4x4x3_SRGB_BLOCK_EXT; + if (ktx_strcasecmp(str, "ASTC_4x4x3_SFLOAT_BLOCK_EXT") == 0) return VK_FORMAT_ASTC_4x4x3_SFLOAT_BLOCK_EXT; + if (ktx_strcasecmp(str, "ASTC_4x4x4_UNORM_BLOCK_EXT") == 0) return VK_FORMAT_ASTC_4x4x4_UNORM_BLOCK_EXT; + if (ktx_strcasecmp(str, "ASTC_4x4x4_SRGB_BLOCK_EXT") == 0) return VK_FORMAT_ASTC_4x4x4_SRGB_BLOCK_EXT; + if (ktx_strcasecmp(str, "ASTC_4x4x4_SFLOAT_BLOCK_EXT") == 0) return VK_FORMAT_ASTC_4x4x4_SFLOAT_BLOCK_EXT; + if (ktx_strcasecmp(str, "ASTC_5x4x4_UNORM_BLOCK_EXT") == 0) return VK_FORMAT_ASTC_5x4x4_UNORM_BLOCK_EXT; + if (ktx_strcasecmp(str, "ASTC_5x4x4_SRGB_BLOCK_EXT") == 0) return VK_FORMAT_ASTC_5x4x4_SRGB_BLOCK_EXT; + if (ktx_strcasecmp(str, "ASTC_5x4x4_SFLOAT_BLOCK_EXT") == 0) return VK_FORMAT_ASTC_5x4x4_SFLOAT_BLOCK_EXT; + if (ktx_strcasecmp(str, "ASTC_5x5x4_UNORM_BLOCK_EXT") == 0) return VK_FORMAT_ASTC_5x5x4_UNORM_BLOCK_EXT; + if (ktx_strcasecmp(str, "ASTC_5x5x4_SRGB_BLOCK_EXT") == 0) return VK_FORMAT_ASTC_5x5x4_SRGB_BLOCK_EXT; + if (ktx_strcasecmp(str, "ASTC_5x5x4_SFLOAT_BLOCK_EXT") == 0) return VK_FORMAT_ASTC_5x5x4_SFLOAT_BLOCK_EXT; + if (ktx_strcasecmp(str, "ASTC_5x5x5_UNORM_BLOCK_EXT") == 0) return VK_FORMAT_ASTC_5x5x5_UNORM_BLOCK_EXT; + if (ktx_strcasecmp(str, "ASTC_5x5x5_SRGB_BLOCK_EXT") == 0) return VK_FORMAT_ASTC_5x5x5_SRGB_BLOCK_EXT; + if (ktx_strcasecmp(str, "ASTC_5x5x5_SFLOAT_BLOCK_EXT") == 0) return VK_FORMAT_ASTC_5x5x5_SFLOAT_BLOCK_EXT; + if (ktx_strcasecmp(str, "ASTC_6x5x5_UNORM_BLOCK_EXT") == 0) return VK_FORMAT_ASTC_6x5x5_UNORM_BLOCK_EXT; + if (ktx_strcasecmp(str, "ASTC_6x5x5_SRGB_BLOCK_EXT") == 0) return VK_FORMAT_ASTC_6x5x5_SRGB_BLOCK_EXT; + if (ktx_strcasecmp(str, "ASTC_6x5x5_SFLOAT_BLOCK_EXT") == 0) return VK_FORMAT_ASTC_6x5x5_SFLOAT_BLOCK_EXT; + if (ktx_strcasecmp(str, "ASTC_6x6x5_UNORM_BLOCK_EXT") == 0) return VK_FORMAT_ASTC_6x6x5_UNORM_BLOCK_EXT; + if (ktx_strcasecmp(str, "ASTC_6x6x5_SRGB_BLOCK_EXT") == 0) return VK_FORMAT_ASTC_6x6x5_SRGB_BLOCK_EXT; + if (ktx_strcasecmp(str, "ASTC_6x6x5_SFLOAT_BLOCK_EXT") == 0) return VK_FORMAT_ASTC_6x6x5_SFLOAT_BLOCK_EXT; + if (ktx_strcasecmp(str, "ASTC_6x6x6_UNORM_BLOCK_EXT") == 0) return VK_FORMAT_ASTC_6x6x6_UNORM_BLOCK_EXT; + if (ktx_strcasecmp(str, "ASTC_6x6x6_SRGB_BLOCK_EXT") == 0) return VK_FORMAT_ASTC_6x6x6_SRGB_BLOCK_EXT; + if (ktx_strcasecmp(str, "ASTC_6x6x6_SFLOAT_BLOCK_EXT") == 0) return VK_FORMAT_ASTC_6x6x6_SFLOAT_BLOCK_EXT; + if (ktx_strcasecmp(str, "R16G16_S10_5_NV") == 0) return VK_FORMAT_R16G16_S10_5_NV; + if (ktx_strcasecmp(str, "A1B5G5R5_UNORM_PACK16_KHR") == 0) return VK_FORMAT_A1B5G5R5_UNORM_PACK16_KHR; + if (ktx_strcasecmp(str, "A8_UNORM_KHR") == 0) return VK_FORMAT_A8_UNORM_KHR; + if (ktx_strcasecmp(str, "ASTC_4x4_SFLOAT_BLOCK_EXT") == 0) return VK_FORMAT_ASTC_4x4_SFLOAT_BLOCK; + if (ktx_strcasecmp(str, "ASTC_5x4_SFLOAT_BLOCK_EXT") == 0) return VK_FORMAT_ASTC_5x4_SFLOAT_BLOCK; + if (ktx_strcasecmp(str, "ASTC_5x5_SFLOAT_BLOCK_EXT") == 0) return VK_FORMAT_ASTC_5x5_SFLOAT_BLOCK; + if (ktx_strcasecmp(str, "ASTC_6x5_SFLOAT_BLOCK_EXT") == 0) return VK_FORMAT_ASTC_6x5_SFLOAT_BLOCK; + if (ktx_strcasecmp(str, "ASTC_6x6_SFLOAT_BLOCK_EXT") == 0) return VK_FORMAT_ASTC_6x6_SFLOAT_BLOCK; + if (ktx_strcasecmp(str, "ASTC_8x5_SFLOAT_BLOCK_EXT") == 0) return VK_FORMAT_ASTC_8x5_SFLOAT_BLOCK; + if (ktx_strcasecmp(str, "ASTC_8x6_SFLOAT_BLOCK_EXT") == 0) return VK_FORMAT_ASTC_8x6_SFLOAT_BLOCK; + if (ktx_strcasecmp(str, "ASTC_8x8_SFLOAT_BLOCK_EXT") == 0) return VK_FORMAT_ASTC_8x8_SFLOAT_BLOCK; + if (ktx_strcasecmp(str, "ASTC_10x5_SFLOAT_BLOCK_EXT") == 0) return VK_FORMAT_ASTC_10x5_SFLOAT_BLOCK; + if (ktx_strcasecmp(str, "ASTC_10x6_SFLOAT_BLOCK_EXT") == 0) return VK_FORMAT_ASTC_10x6_SFLOAT_BLOCK; + if (ktx_strcasecmp(str, "ASTC_10x8_SFLOAT_BLOCK_EXT") == 0) return VK_FORMAT_ASTC_10x8_SFLOAT_BLOCK; + if (ktx_strcasecmp(str, "ASTC_10x10_SFLOAT_BLOCK_EXT") == 0) return VK_FORMAT_ASTC_10x10_SFLOAT_BLOCK; + if (ktx_strcasecmp(str, "ASTC_12x10_SFLOAT_BLOCK_EXT") == 0) return VK_FORMAT_ASTC_12x10_SFLOAT_BLOCK; + if (ktx_strcasecmp(str, "ASTC_12x12_SFLOAT_BLOCK_EXT") == 0) return VK_FORMAT_ASTC_12x12_SFLOAT_BLOCK; + if (ktx_strcasecmp(str, "G8B8G8R8_422_UNORM_KHR") == 0) return VK_FORMAT_G8B8G8R8_422_UNORM; + if (ktx_strcasecmp(str, "B8G8R8G8_422_UNORM_KHR") == 0) return VK_FORMAT_B8G8R8G8_422_UNORM; + if (ktx_strcasecmp(str, "G8_B8_R8_3PLANE_420_UNORM_KHR") == 0) return VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM; + if (ktx_strcasecmp(str, "G8_B8R8_2PLANE_420_UNORM_KHR") == 0) return VK_FORMAT_G8_B8R8_2PLANE_420_UNORM; + if (ktx_strcasecmp(str, "G8_B8_R8_3PLANE_422_UNORM_KHR") == 0) return VK_FORMAT_G8_B8_R8_3PLANE_422_UNORM; + if (ktx_strcasecmp(str, "G8_B8R8_2PLANE_422_UNORM_KHR") == 0) return VK_FORMAT_G8_B8R8_2PLANE_422_UNORM; + if (ktx_strcasecmp(str, "G8_B8_R8_3PLANE_444_UNORM_KHR") == 0) return VK_FORMAT_G8_B8_R8_3PLANE_444_UNORM; + if (ktx_strcasecmp(str, "R10X6_UNORM_PACK16_KHR") == 0) return VK_FORMAT_R10X6_UNORM_PACK16; + if (ktx_strcasecmp(str, "R10X6G10X6_UNORM_2PACK16_KHR") == 0) return VK_FORMAT_R10X6G10X6_UNORM_2PACK16; + if (ktx_strcasecmp(str, "R10X6G10X6B10X6A10X6_UNORM_4PACK16_KHR") == 0) return VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16; if (ktx_strcasecmp(str, "G10X6B10X6G10X6R10X6_422_UNORM_4PACK16_KHR") == 0) return VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16; if (ktx_strcasecmp(str, "B10X6G10X6R10X6G10X6_422_UNORM_4PACK16_KHR") == 0) @@ -1242,12 +945,9 @@ stringToVkFormat(const char* str) return VK_FORMAT_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16; if (ktx_strcasecmp(str, "G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16_KHR") == 0) return VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16; - if (ktx_strcasecmp(str, "R12X4_UNORM_PACK16_KHR") == 0) - return VK_FORMAT_R12X4_UNORM_PACK16; - if (ktx_strcasecmp(str, "R12X4G12X4_UNORM_2PACK16_KHR") == 0) - return VK_FORMAT_R12X4G12X4_UNORM_2PACK16; - if (ktx_strcasecmp(str, "R12X4G12X4B12X4A12X4_UNORM_4PACK16_KHR") == 0) - return VK_FORMAT_R12X4G12X4B12X4A12X4_UNORM_4PACK16; + if (ktx_strcasecmp(str, "R12X4_UNORM_PACK16_KHR") == 0) return VK_FORMAT_R12X4_UNORM_PACK16; + if (ktx_strcasecmp(str, "R12X4G12X4_UNORM_2PACK16_KHR") == 0) return VK_FORMAT_R12X4G12X4_UNORM_2PACK16; + if (ktx_strcasecmp(str, "R12X4G12X4B12X4A12X4_UNORM_4PACK16_KHR") == 0) return VK_FORMAT_R12X4G12X4B12X4A12X4_UNORM_4PACK16; if (ktx_strcasecmp(str, "G12X4B12X4G12X4R12X4_422_UNORM_4PACK16_KHR") == 0) return VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16; if (ktx_strcasecmp(str, "B12X4G12X4R12X4G12X4_422_UNORM_4PACK16_KHR") == 0) @@ -1262,31 +962,20 @@ stringToVkFormat(const char* str) return VK_FORMAT_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16; if (ktx_strcasecmp(str, "G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16_KHR") == 0) return VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16; - if (ktx_strcasecmp(str, "G16B16G16R16_422_UNORM_KHR") == 0) - return VK_FORMAT_G16B16G16R16_422_UNORM; - if (ktx_strcasecmp(str, "B16G16R16G16_422_UNORM_KHR") == 0) - return VK_FORMAT_B16G16R16G16_422_UNORM; - if (ktx_strcasecmp(str, "G16_B16_R16_3PLANE_420_UNORM_KHR") == 0) - return VK_FORMAT_G16_B16_R16_3PLANE_420_UNORM; - if (ktx_strcasecmp(str, "G16_B16R16_2PLANE_420_UNORM_KHR") == 0) - return VK_FORMAT_G16_B16R16_2PLANE_420_UNORM; - if (ktx_strcasecmp(str, "G16_B16_R16_3PLANE_422_UNORM_KHR") == 0) - return VK_FORMAT_G16_B16_R16_3PLANE_422_UNORM; - if (ktx_strcasecmp(str, "G16_B16R16_2PLANE_422_UNORM_KHR") == 0) - return VK_FORMAT_G16_B16R16_2PLANE_422_UNORM; - if (ktx_strcasecmp(str, "G16_B16_R16_3PLANE_444_UNORM_KHR") == 0) - return VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM; - if (ktx_strcasecmp(str, "G8_B8R8_2PLANE_444_UNORM_EXT") == 0) - return VK_FORMAT_G8_B8R8_2PLANE_444_UNORM; + if (ktx_strcasecmp(str, "G16B16G16R16_422_UNORM_KHR") == 0) return VK_FORMAT_G16B16G16R16_422_UNORM; + if (ktx_strcasecmp(str, "B16G16R16G16_422_UNORM_KHR") == 0) return VK_FORMAT_B16G16R16G16_422_UNORM; + if (ktx_strcasecmp(str, "G16_B16_R16_3PLANE_420_UNORM_KHR") == 0) return VK_FORMAT_G16_B16_R16_3PLANE_420_UNORM; + if (ktx_strcasecmp(str, "G16_B16R16_2PLANE_420_UNORM_KHR") == 0) return VK_FORMAT_G16_B16R16_2PLANE_420_UNORM; + if (ktx_strcasecmp(str, "G16_B16_R16_3PLANE_422_UNORM_KHR") == 0) return VK_FORMAT_G16_B16_R16_3PLANE_422_UNORM; + if (ktx_strcasecmp(str, "G16_B16R16_2PLANE_422_UNORM_KHR") == 0) return VK_FORMAT_G16_B16R16_2PLANE_422_UNORM; + if (ktx_strcasecmp(str, "G16_B16_R16_3PLANE_444_UNORM_KHR") == 0) return VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM; + if (ktx_strcasecmp(str, "G8_B8R8_2PLANE_444_UNORM_EXT") == 0) return VK_FORMAT_G8_B8R8_2PLANE_444_UNORM; if (ktx_strcasecmp(str, "G10X6_B10X6R10X6_2PLANE_444_UNORM_3PACK16_EXT") == 0) return VK_FORMAT_G10X6_B10X6R10X6_2PLANE_444_UNORM_3PACK16; if (ktx_strcasecmp(str, "G12X4_B12X4R12X4_2PLANE_444_UNORM_3PACK16_EXT") == 0) return VK_FORMAT_G12X4_B12X4R12X4_2PLANE_444_UNORM_3PACK16; - if (ktx_strcasecmp(str, "G16_B16R16_2PLANE_444_UNORM_EXT") == 0) - return VK_FORMAT_G16_B16R16_2PLANE_444_UNORM; - if (ktx_strcasecmp(str, "A4R4G4B4_UNORM_PACK16_EXT") == 0) - return VK_FORMAT_A4R4G4B4_UNORM_PACK16; - if (ktx_strcasecmp(str, "A4B4G4R4_UNORM_PACK16_EXT") == 0) - return VK_FORMAT_A4B4G4R4_UNORM_PACK16; + if (ktx_strcasecmp(str, "G16_B16R16_2PLANE_444_UNORM_EXT") == 0) return VK_FORMAT_G16_B16R16_2PLANE_444_UNORM; + if (ktx_strcasecmp(str, "A4R4G4B4_UNORM_PACK16_EXT") == 0) return VK_FORMAT_A4R4G4B4_UNORM_PACK16; + if (ktx_strcasecmp(str, "A4B4G4R4_UNORM_PACK16_EXT") == 0) return VK_FORMAT_A4B4G4R4_UNORM_PACK16; return VK_FORMAT_UNDEFINED; } diff --git a/lib/vkformat_typesize.c b/lib/vkformat_typesize.c index 92fb468045..5164d837ef 100644 --- a/lib/vkformat_typesize.c +++ b/lib/vkformat_typesize.c @@ -9,576 +9,574 @@ ** SPDX-License-Identifier: Apache-2.0 */ - #include #include "vkformat_enum.h" uint32_t -vkFormatTypeSize(VkFormat format) -{ +vkFormatTypeSize(VkFormat format) { switch (format) { - case VK_FORMAT_UNDEFINED: + case VK_FORMAT_UNDEFINED: return 1; - case VK_FORMAT_R4G4_UNORM_PACK8: + case VK_FORMAT_R4G4_UNORM_PACK8: return 1; - case VK_FORMAT_R4G4B4A4_UNORM_PACK16: + case VK_FORMAT_R4G4B4A4_UNORM_PACK16: return 2; - case VK_FORMAT_B4G4R4A4_UNORM_PACK16: + case VK_FORMAT_B4G4R4A4_UNORM_PACK16: return 2; - case VK_FORMAT_R5G6B5_UNORM_PACK16: + case VK_FORMAT_R5G6B5_UNORM_PACK16: return 2; - case VK_FORMAT_B5G6R5_UNORM_PACK16: + case VK_FORMAT_B5G6R5_UNORM_PACK16: return 2; - case VK_FORMAT_R5G5B5A1_UNORM_PACK16: + case VK_FORMAT_R5G5B5A1_UNORM_PACK16: return 2; - case VK_FORMAT_B5G5R5A1_UNORM_PACK16: + case VK_FORMAT_B5G5R5A1_UNORM_PACK16: return 2; - case VK_FORMAT_A1R5G5B5_UNORM_PACK16: + case VK_FORMAT_A1R5G5B5_UNORM_PACK16: return 2; - case VK_FORMAT_R8_UNORM: + case VK_FORMAT_R8_UNORM: return 1; - case VK_FORMAT_R8_SNORM: + case VK_FORMAT_R8_SNORM: return 1; - case VK_FORMAT_R8_USCALED: + case VK_FORMAT_R8_USCALED: return 1; - case VK_FORMAT_R8_SSCALED: + case VK_FORMAT_R8_SSCALED: return 1; - case VK_FORMAT_R8_UINT: + case VK_FORMAT_R8_UINT: return 1; - case VK_FORMAT_R8_SINT: + case VK_FORMAT_R8_SINT: return 1; - case VK_FORMAT_R8_SRGB: + case VK_FORMAT_R8_SRGB: return 1; - case VK_FORMAT_R8G8_UNORM: + case VK_FORMAT_R8G8_UNORM: return 1; - case VK_FORMAT_R8G8_SNORM: + case VK_FORMAT_R8G8_SNORM: return 1; - case VK_FORMAT_R8G8_USCALED: + case VK_FORMAT_R8G8_USCALED: return 1; - case VK_FORMAT_R8G8_SSCALED: + case VK_FORMAT_R8G8_SSCALED: return 1; - case VK_FORMAT_R8G8_UINT: + case VK_FORMAT_R8G8_UINT: return 1; - case VK_FORMAT_R8G8_SINT: + case VK_FORMAT_R8G8_SINT: return 1; - case VK_FORMAT_R8G8_SRGB: + case VK_FORMAT_R8G8_SRGB: return 1; - case VK_FORMAT_R8G8B8_UNORM: + case VK_FORMAT_R8G8B8_UNORM: return 1; - case VK_FORMAT_R8G8B8_SNORM: + case VK_FORMAT_R8G8B8_SNORM: return 1; - case VK_FORMAT_R8G8B8_USCALED: + case VK_FORMAT_R8G8B8_USCALED: return 1; - case VK_FORMAT_R8G8B8_SSCALED: + case VK_FORMAT_R8G8B8_SSCALED: return 1; - case VK_FORMAT_R8G8B8_UINT: + case VK_FORMAT_R8G8B8_UINT: return 1; - case VK_FORMAT_R8G8B8_SINT: + case VK_FORMAT_R8G8B8_SINT: return 1; - case VK_FORMAT_R8G8B8_SRGB: + case VK_FORMAT_R8G8B8_SRGB: return 1; - case VK_FORMAT_B8G8R8_UNORM: + case VK_FORMAT_B8G8R8_UNORM: return 1; - case VK_FORMAT_B8G8R8_SNORM: + case VK_FORMAT_B8G8R8_SNORM: return 1; - case VK_FORMAT_B8G8R8_USCALED: + case VK_FORMAT_B8G8R8_USCALED: return 1; - case VK_FORMAT_B8G8R8_SSCALED: + case VK_FORMAT_B8G8R8_SSCALED: return 1; - case VK_FORMAT_B8G8R8_UINT: + case VK_FORMAT_B8G8R8_UINT: return 1; - case VK_FORMAT_B8G8R8_SINT: + case VK_FORMAT_B8G8R8_SINT: return 1; - case VK_FORMAT_B8G8R8_SRGB: + case VK_FORMAT_B8G8R8_SRGB: return 1; - case VK_FORMAT_R8G8B8A8_UNORM: + case VK_FORMAT_R8G8B8A8_UNORM: return 1; - case VK_FORMAT_R8G8B8A8_SNORM: + case VK_FORMAT_R8G8B8A8_SNORM: return 1; - case VK_FORMAT_R8G8B8A8_USCALED: + case VK_FORMAT_R8G8B8A8_USCALED: return 1; - case VK_FORMAT_R8G8B8A8_SSCALED: + case VK_FORMAT_R8G8B8A8_SSCALED: return 1; - case VK_FORMAT_R8G8B8A8_UINT: + case VK_FORMAT_R8G8B8A8_UINT: return 1; - case VK_FORMAT_R8G8B8A8_SINT: + case VK_FORMAT_R8G8B8A8_SINT: return 1; - case VK_FORMAT_R8G8B8A8_SRGB: + case VK_FORMAT_R8G8B8A8_SRGB: return 1; - case VK_FORMAT_B8G8R8A8_UNORM: + case VK_FORMAT_B8G8R8A8_UNORM: return 1; - case VK_FORMAT_B8G8R8A8_SNORM: + case VK_FORMAT_B8G8R8A8_SNORM: return 1; - case VK_FORMAT_B8G8R8A8_USCALED: + case VK_FORMAT_B8G8R8A8_USCALED: return 1; - case VK_FORMAT_B8G8R8A8_SSCALED: + case VK_FORMAT_B8G8R8A8_SSCALED: return 1; - case VK_FORMAT_B8G8R8A8_UINT: + case VK_FORMAT_B8G8R8A8_UINT: return 1; - case VK_FORMAT_B8G8R8A8_SINT: + case VK_FORMAT_B8G8R8A8_SINT: return 1; - case VK_FORMAT_B8G8R8A8_SRGB: + case VK_FORMAT_B8G8R8A8_SRGB: return 1; - case VK_FORMAT_A8B8G8R8_UNORM_PACK32: + case VK_FORMAT_A8B8G8R8_UNORM_PACK32: return 4; - case VK_FORMAT_A8B8G8R8_SNORM_PACK32: + case VK_FORMAT_A8B8G8R8_SNORM_PACK32: return 4; - case VK_FORMAT_A8B8G8R8_USCALED_PACK32: + case VK_FORMAT_A8B8G8R8_USCALED_PACK32: return 4; - case VK_FORMAT_A8B8G8R8_SSCALED_PACK32: + case VK_FORMAT_A8B8G8R8_SSCALED_PACK32: return 4; - case VK_FORMAT_A8B8G8R8_UINT_PACK32: + case VK_FORMAT_A8B8G8R8_UINT_PACK32: return 4; - case VK_FORMAT_A8B8G8R8_SINT_PACK32: + case VK_FORMAT_A8B8G8R8_SINT_PACK32: return 4; - case VK_FORMAT_A8B8G8R8_SRGB_PACK32: + case VK_FORMAT_A8B8G8R8_SRGB_PACK32: return 4; - case VK_FORMAT_A2R10G10B10_UNORM_PACK32: + case VK_FORMAT_A2R10G10B10_UNORM_PACK32: return 4; - case VK_FORMAT_A2R10G10B10_SNORM_PACK32: + case VK_FORMAT_A2R10G10B10_SNORM_PACK32: return 4; - case VK_FORMAT_A2R10G10B10_USCALED_PACK32: + case VK_FORMAT_A2R10G10B10_USCALED_PACK32: return 4; - case VK_FORMAT_A2R10G10B10_SSCALED_PACK32: + case VK_FORMAT_A2R10G10B10_SSCALED_PACK32: return 4; - case VK_FORMAT_A2R10G10B10_UINT_PACK32: + case VK_FORMAT_A2R10G10B10_UINT_PACK32: return 4; - case VK_FORMAT_A2R10G10B10_SINT_PACK32: + case VK_FORMAT_A2R10G10B10_SINT_PACK32: return 4; - case VK_FORMAT_A2B10G10R10_UNORM_PACK32: + case VK_FORMAT_A2B10G10R10_UNORM_PACK32: return 4; - case VK_FORMAT_A2B10G10R10_SNORM_PACK32: + case VK_FORMAT_A2B10G10R10_SNORM_PACK32: return 4; - case VK_FORMAT_A2B10G10R10_USCALED_PACK32: + case VK_FORMAT_A2B10G10R10_USCALED_PACK32: return 4; - case VK_FORMAT_A2B10G10R10_SSCALED_PACK32: + case VK_FORMAT_A2B10G10R10_SSCALED_PACK32: return 4; - case VK_FORMAT_A2B10G10R10_UINT_PACK32: + case VK_FORMAT_A2B10G10R10_UINT_PACK32: return 4; - case VK_FORMAT_A2B10G10R10_SINT_PACK32: + case VK_FORMAT_A2B10G10R10_SINT_PACK32: return 4; - case VK_FORMAT_R16_UNORM: + case VK_FORMAT_R16_UNORM: return 2; - case VK_FORMAT_R16_SNORM: + case VK_FORMAT_R16_SNORM: return 2; - case VK_FORMAT_R16_USCALED: + case VK_FORMAT_R16_USCALED: return 2; - case VK_FORMAT_R16_SSCALED: + case VK_FORMAT_R16_SSCALED: return 2; - case VK_FORMAT_R16_UINT: + case VK_FORMAT_R16_UINT: return 2; - case VK_FORMAT_R16_SINT: + case VK_FORMAT_R16_SINT: return 2; - case VK_FORMAT_R16_SFLOAT: + case VK_FORMAT_R16_SFLOAT: return 2; - case VK_FORMAT_R16G16_UNORM: + case VK_FORMAT_R16G16_UNORM: return 2; - case VK_FORMAT_R16G16_SNORM: + case VK_FORMAT_R16G16_SNORM: return 2; - case VK_FORMAT_R16G16_USCALED: + case VK_FORMAT_R16G16_USCALED: return 2; - case VK_FORMAT_R16G16_SSCALED: + case VK_FORMAT_R16G16_SSCALED: return 2; - case VK_FORMAT_R16G16_UINT: + case VK_FORMAT_R16G16_UINT: return 2; - case VK_FORMAT_R16G16_SINT: + case VK_FORMAT_R16G16_SINT: return 2; - case VK_FORMAT_R16G16_SFLOAT: + case VK_FORMAT_R16G16_SFLOAT: return 2; - case VK_FORMAT_R16G16B16_UNORM: + case VK_FORMAT_R16G16B16_UNORM: return 2; - case VK_FORMAT_R16G16B16_SNORM: + case VK_FORMAT_R16G16B16_SNORM: return 2; - case VK_FORMAT_R16G16B16_USCALED: + case VK_FORMAT_R16G16B16_USCALED: return 2; - case VK_FORMAT_R16G16B16_SSCALED: + case VK_FORMAT_R16G16B16_SSCALED: return 2; - case VK_FORMAT_R16G16B16_UINT: + case VK_FORMAT_R16G16B16_UINT: return 2; - case VK_FORMAT_R16G16B16_SINT: + case VK_FORMAT_R16G16B16_SINT: return 2; - case VK_FORMAT_R16G16B16_SFLOAT: + case VK_FORMAT_R16G16B16_SFLOAT: return 2; - case VK_FORMAT_R16G16B16A16_UNORM: + case VK_FORMAT_R16G16B16A16_UNORM: return 2; - case VK_FORMAT_R16G16B16A16_SNORM: + case VK_FORMAT_R16G16B16A16_SNORM: return 2; - case VK_FORMAT_R16G16B16A16_USCALED: + case VK_FORMAT_R16G16B16A16_USCALED: return 2; - case VK_FORMAT_R16G16B16A16_SSCALED: + case VK_FORMAT_R16G16B16A16_SSCALED: return 2; - case VK_FORMAT_R16G16B16A16_UINT: + case VK_FORMAT_R16G16B16A16_UINT: return 2; - case VK_FORMAT_R16G16B16A16_SINT: + case VK_FORMAT_R16G16B16A16_SINT: return 2; - case VK_FORMAT_R16G16B16A16_SFLOAT: + case VK_FORMAT_R16G16B16A16_SFLOAT: return 2; - case VK_FORMAT_R32_UINT: + case VK_FORMAT_R32_UINT: return 4; - case VK_FORMAT_R32_SINT: + case VK_FORMAT_R32_SINT: return 4; - case VK_FORMAT_R32_SFLOAT: + case VK_FORMAT_R32_SFLOAT: return 4; - case VK_FORMAT_R32G32_UINT: + case VK_FORMAT_R32G32_UINT: return 4; - case VK_FORMAT_R32G32_SINT: + case VK_FORMAT_R32G32_SINT: return 4; - case VK_FORMAT_R32G32_SFLOAT: + case VK_FORMAT_R32G32_SFLOAT: return 4; - case VK_FORMAT_R32G32B32_UINT: + case VK_FORMAT_R32G32B32_UINT: return 4; - case VK_FORMAT_R32G32B32_SINT: + case VK_FORMAT_R32G32B32_SINT: return 4; - case VK_FORMAT_R32G32B32_SFLOAT: + case VK_FORMAT_R32G32B32_SFLOAT: return 4; - case VK_FORMAT_R32G32B32A32_UINT: + case VK_FORMAT_R32G32B32A32_UINT: return 4; - case VK_FORMAT_R32G32B32A32_SINT: + case VK_FORMAT_R32G32B32A32_SINT: return 4; - case VK_FORMAT_R32G32B32A32_SFLOAT: + case VK_FORMAT_R32G32B32A32_SFLOAT: return 4; - case VK_FORMAT_R64_UINT: + case VK_FORMAT_R64_UINT: return 8; - case VK_FORMAT_R64_SINT: + case VK_FORMAT_R64_SINT: return 8; - case VK_FORMAT_R64_SFLOAT: + case VK_FORMAT_R64_SFLOAT: return 8; - case VK_FORMAT_R64G64_UINT: + case VK_FORMAT_R64G64_UINT: return 8; - case VK_FORMAT_R64G64_SINT: + case VK_FORMAT_R64G64_SINT: return 8; - case VK_FORMAT_R64G64_SFLOAT: + case VK_FORMAT_R64G64_SFLOAT: return 8; - case VK_FORMAT_R64G64B64_UINT: + case VK_FORMAT_R64G64B64_UINT: return 8; - case VK_FORMAT_R64G64B64_SINT: + case VK_FORMAT_R64G64B64_SINT: return 8; - case VK_FORMAT_R64G64B64_SFLOAT: + case VK_FORMAT_R64G64B64_SFLOAT: return 8; - case VK_FORMAT_R64G64B64A64_UINT: + case VK_FORMAT_R64G64B64A64_UINT: return 8; - case VK_FORMAT_R64G64B64A64_SINT: + case VK_FORMAT_R64G64B64A64_SINT: return 8; - case VK_FORMAT_R64G64B64A64_SFLOAT: + case VK_FORMAT_R64G64B64A64_SFLOAT: return 8; - case VK_FORMAT_B10G11R11_UFLOAT_PACK32: + case VK_FORMAT_B10G11R11_UFLOAT_PACK32: return 4; - case VK_FORMAT_E5B9G9R9_UFLOAT_PACK32: + case VK_FORMAT_E5B9G9R9_UFLOAT_PACK32: return 4; - case VK_FORMAT_D16_UNORM: + case VK_FORMAT_D16_UNORM: return 2; - case VK_FORMAT_X8_D24_UNORM_PACK32: + case VK_FORMAT_X8_D24_UNORM_PACK32: return 4; - case VK_FORMAT_D32_SFLOAT: + case VK_FORMAT_D32_SFLOAT: return 4; - case VK_FORMAT_S8_UINT: + case VK_FORMAT_S8_UINT: return 1; - case VK_FORMAT_D16_UNORM_S8_UINT: + case VK_FORMAT_D16_UNORM_S8_UINT: return 2; - case VK_FORMAT_D24_UNORM_S8_UINT: + case VK_FORMAT_D24_UNORM_S8_UINT: return 4; - case VK_FORMAT_D32_SFLOAT_S8_UINT: + case VK_FORMAT_D32_SFLOAT_S8_UINT: return 4; - case VK_FORMAT_BC1_RGB_UNORM_BLOCK: + case VK_FORMAT_BC1_RGB_UNORM_BLOCK: return 1; - case VK_FORMAT_BC1_RGB_SRGB_BLOCK: + case VK_FORMAT_BC1_RGB_SRGB_BLOCK: return 1; - case VK_FORMAT_BC1_RGBA_UNORM_BLOCK: + case VK_FORMAT_BC1_RGBA_UNORM_BLOCK: return 1; - case VK_FORMAT_BC1_RGBA_SRGB_BLOCK: + case VK_FORMAT_BC1_RGBA_SRGB_BLOCK: return 1; - case VK_FORMAT_BC2_UNORM_BLOCK: + case VK_FORMAT_BC2_UNORM_BLOCK: return 1; - case VK_FORMAT_BC2_SRGB_BLOCK: + case VK_FORMAT_BC2_SRGB_BLOCK: return 1; - case VK_FORMAT_BC3_UNORM_BLOCK: + case VK_FORMAT_BC3_UNORM_BLOCK: return 1; - case VK_FORMAT_BC3_SRGB_BLOCK: + case VK_FORMAT_BC3_SRGB_BLOCK: return 1; - case VK_FORMAT_BC4_UNORM_BLOCK: + case VK_FORMAT_BC4_UNORM_BLOCK: return 1; - case VK_FORMAT_BC4_SNORM_BLOCK: + case VK_FORMAT_BC4_SNORM_BLOCK: return 1; - case VK_FORMAT_BC5_UNORM_BLOCK: + case VK_FORMAT_BC5_UNORM_BLOCK: return 1; - case VK_FORMAT_BC5_SNORM_BLOCK: + case VK_FORMAT_BC5_SNORM_BLOCK: return 1; - case VK_FORMAT_BC6H_UFLOAT_BLOCK: + case VK_FORMAT_BC6H_UFLOAT_BLOCK: return 1; - case VK_FORMAT_BC6H_SFLOAT_BLOCK: + case VK_FORMAT_BC6H_SFLOAT_BLOCK: return 1; - case VK_FORMAT_BC7_UNORM_BLOCK: + case VK_FORMAT_BC7_UNORM_BLOCK: return 1; - case VK_FORMAT_BC7_SRGB_BLOCK: + case VK_FORMAT_BC7_SRGB_BLOCK: return 1; - case VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK: + case VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK: return 1; - case VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK: + case VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK: return 1; - case VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK: + case VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK: return 1; - case VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK: + case VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK: return 1; - case VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK: + case VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK: return 1; - case VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK: + case VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK: return 1; - case VK_FORMAT_EAC_R11_UNORM_BLOCK: + case VK_FORMAT_EAC_R11_UNORM_BLOCK: return 1; - case VK_FORMAT_EAC_R11_SNORM_BLOCK: + case VK_FORMAT_EAC_R11_SNORM_BLOCK: return 1; - case VK_FORMAT_EAC_R11G11_UNORM_BLOCK: + case VK_FORMAT_EAC_R11G11_UNORM_BLOCK: return 1; - case VK_FORMAT_EAC_R11G11_SNORM_BLOCK: + case VK_FORMAT_EAC_R11G11_SNORM_BLOCK: return 1; - case VK_FORMAT_ASTC_4x4_UNORM_BLOCK: + case VK_FORMAT_ASTC_4x4_UNORM_BLOCK: return 1; - case VK_FORMAT_ASTC_4x4_SRGB_BLOCK: + case VK_FORMAT_ASTC_4x4_SRGB_BLOCK: return 1; - case VK_FORMAT_ASTC_5x4_UNORM_BLOCK: + case VK_FORMAT_ASTC_5x4_UNORM_BLOCK: return 1; - case VK_FORMAT_ASTC_5x4_SRGB_BLOCK: + case VK_FORMAT_ASTC_5x4_SRGB_BLOCK: return 1; - case VK_FORMAT_ASTC_5x5_UNORM_BLOCK: + case VK_FORMAT_ASTC_5x5_UNORM_BLOCK: return 1; - case VK_FORMAT_ASTC_5x5_SRGB_BLOCK: + case VK_FORMAT_ASTC_5x5_SRGB_BLOCK: return 1; - case VK_FORMAT_ASTC_6x5_UNORM_BLOCK: + case VK_FORMAT_ASTC_6x5_UNORM_BLOCK: return 1; - case VK_FORMAT_ASTC_6x5_SRGB_BLOCK: + case VK_FORMAT_ASTC_6x5_SRGB_BLOCK: return 1; - case VK_FORMAT_ASTC_6x6_UNORM_BLOCK: + case VK_FORMAT_ASTC_6x6_UNORM_BLOCK: return 1; - case VK_FORMAT_ASTC_6x6_SRGB_BLOCK: + case VK_FORMAT_ASTC_6x6_SRGB_BLOCK: return 1; - case VK_FORMAT_ASTC_8x5_UNORM_BLOCK: + case VK_FORMAT_ASTC_8x5_UNORM_BLOCK: return 1; - case VK_FORMAT_ASTC_8x5_SRGB_BLOCK: + case VK_FORMAT_ASTC_8x5_SRGB_BLOCK: return 1; - case VK_FORMAT_ASTC_8x6_UNORM_BLOCK: + case VK_FORMAT_ASTC_8x6_UNORM_BLOCK: return 1; - case VK_FORMAT_ASTC_8x6_SRGB_BLOCK: + case VK_FORMAT_ASTC_8x6_SRGB_BLOCK: return 1; - case VK_FORMAT_ASTC_8x8_UNORM_BLOCK: + case VK_FORMAT_ASTC_8x8_UNORM_BLOCK: return 1; - case VK_FORMAT_ASTC_8x8_SRGB_BLOCK: + case VK_FORMAT_ASTC_8x8_SRGB_BLOCK: return 1; - case VK_FORMAT_ASTC_10x5_UNORM_BLOCK: + case VK_FORMAT_ASTC_10x5_UNORM_BLOCK: return 1; - case VK_FORMAT_ASTC_10x5_SRGB_BLOCK: + case VK_FORMAT_ASTC_10x5_SRGB_BLOCK: return 1; - case VK_FORMAT_ASTC_10x6_UNORM_BLOCK: + case VK_FORMAT_ASTC_10x6_UNORM_BLOCK: return 1; - case VK_FORMAT_ASTC_10x6_SRGB_BLOCK: + case VK_FORMAT_ASTC_10x6_SRGB_BLOCK: return 1; - case VK_FORMAT_ASTC_10x8_UNORM_BLOCK: + case VK_FORMAT_ASTC_10x8_UNORM_BLOCK: return 1; - case VK_FORMAT_ASTC_10x8_SRGB_BLOCK: + case VK_FORMAT_ASTC_10x8_SRGB_BLOCK: return 1; - case VK_FORMAT_ASTC_10x10_UNORM_BLOCK: + case VK_FORMAT_ASTC_10x10_UNORM_BLOCK: return 1; - case VK_FORMAT_ASTC_10x10_SRGB_BLOCK: + case VK_FORMAT_ASTC_10x10_SRGB_BLOCK: return 1; - case VK_FORMAT_ASTC_12x10_UNORM_BLOCK: + case VK_FORMAT_ASTC_12x10_UNORM_BLOCK: return 1; - case VK_FORMAT_ASTC_12x10_SRGB_BLOCK: + case VK_FORMAT_ASTC_12x10_SRGB_BLOCK: return 1; - case VK_FORMAT_ASTC_12x12_UNORM_BLOCK: + case VK_FORMAT_ASTC_12x12_UNORM_BLOCK: return 1; - case VK_FORMAT_ASTC_12x12_SRGB_BLOCK: + case VK_FORMAT_ASTC_12x12_SRGB_BLOCK: return 1; - case VK_FORMAT_G8B8G8R8_422_UNORM: + case VK_FORMAT_G8B8G8R8_422_UNORM: return 1; - case VK_FORMAT_B8G8R8G8_422_UNORM: + case VK_FORMAT_B8G8R8G8_422_UNORM: return 1; - case VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM: + case VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM: return 1; - case VK_FORMAT_G8_B8R8_2PLANE_420_UNORM: + case VK_FORMAT_G8_B8R8_2PLANE_420_UNORM: return 1; - case VK_FORMAT_G8_B8_R8_3PLANE_422_UNORM: + case VK_FORMAT_G8_B8_R8_3PLANE_422_UNORM: return 1; - case VK_FORMAT_G8_B8R8_2PLANE_422_UNORM: + case VK_FORMAT_G8_B8R8_2PLANE_422_UNORM: return 1; - case VK_FORMAT_G8_B8_R8_3PLANE_444_UNORM: + case VK_FORMAT_G8_B8_R8_3PLANE_444_UNORM: return 1; - case VK_FORMAT_R10X6_UNORM_PACK16: + case VK_FORMAT_R10X6_UNORM_PACK16: return 2; - case VK_FORMAT_R10X6G10X6_UNORM_2PACK16: + case VK_FORMAT_R10X6G10X6_UNORM_2PACK16: return 2; - case VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16: + case VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16: return 2; - case VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16: + case VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16: return 2; - case VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16: + case VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16: return 2; - case VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16: + case VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16: return 2; - case VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16: + case VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16: return 2; - case VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16: + case VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16: return 2; - case VK_FORMAT_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16: + case VK_FORMAT_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16: return 2; - case VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16: + case VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16: return 2; - case VK_FORMAT_R12X4_UNORM_PACK16: + case VK_FORMAT_R12X4_UNORM_PACK16: return 2; - case VK_FORMAT_R12X4G12X4_UNORM_2PACK16: + case VK_FORMAT_R12X4G12X4_UNORM_2PACK16: return 2; - case VK_FORMAT_R12X4G12X4B12X4A12X4_UNORM_4PACK16: + case VK_FORMAT_R12X4G12X4B12X4A12X4_UNORM_4PACK16: return 2; - case VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16: + case VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16: return 2; - case VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16: + case VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16: return 2; - case VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16: + case VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16: return 2; - case VK_FORMAT_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16: + case VK_FORMAT_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16: return 2; - case VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16: + case VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16: return 2; - case VK_FORMAT_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16: + case VK_FORMAT_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16: return 2; - case VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16: + case VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16: return 2; - case VK_FORMAT_G16B16G16R16_422_UNORM: + case VK_FORMAT_G16B16G16R16_422_UNORM: return 2; - case VK_FORMAT_B16G16R16G16_422_UNORM: + case VK_FORMAT_B16G16R16G16_422_UNORM: return 2; - case VK_FORMAT_G16_B16_R16_3PLANE_420_UNORM: + case VK_FORMAT_G16_B16_R16_3PLANE_420_UNORM: return 2; - case VK_FORMAT_G16_B16R16_2PLANE_420_UNORM: + case VK_FORMAT_G16_B16R16_2PLANE_420_UNORM: return 2; - case VK_FORMAT_G16_B16_R16_3PLANE_422_UNORM: + case VK_FORMAT_G16_B16_R16_3PLANE_422_UNORM: return 2; - case VK_FORMAT_G16_B16R16_2PLANE_422_UNORM: + case VK_FORMAT_G16_B16R16_2PLANE_422_UNORM: return 2; - case VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM: + case VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM: return 2; - case VK_FORMAT_G8_B8R8_2PLANE_444_UNORM: + case VK_FORMAT_G8_B8R8_2PLANE_444_UNORM: return 1; - case VK_FORMAT_G10X6_B10X6R10X6_2PLANE_444_UNORM_3PACK16: + case VK_FORMAT_G10X6_B10X6R10X6_2PLANE_444_UNORM_3PACK16: return 2; - case VK_FORMAT_G12X4_B12X4R12X4_2PLANE_444_UNORM_3PACK16: + case VK_FORMAT_G12X4_B12X4R12X4_2PLANE_444_UNORM_3PACK16: return 2; - case VK_FORMAT_G16_B16R16_2PLANE_444_UNORM: + case VK_FORMAT_G16_B16R16_2PLANE_444_UNORM: return 2; - case VK_FORMAT_A4R4G4B4_UNORM_PACK16: + case VK_FORMAT_A4R4G4B4_UNORM_PACK16: return 2; - case VK_FORMAT_A4B4G4R4_UNORM_PACK16: + case VK_FORMAT_A4B4G4R4_UNORM_PACK16: return 2; - case VK_FORMAT_ASTC_4x4_SFLOAT_BLOCK: + case VK_FORMAT_ASTC_4x4_SFLOAT_BLOCK: return 1; - case VK_FORMAT_ASTC_5x4_SFLOAT_BLOCK: + case VK_FORMAT_ASTC_5x4_SFLOAT_BLOCK: return 1; - case VK_FORMAT_ASTC_5x5_SFLOAT_BLOCK: + case VK_FORMAT_ASTC_5x5_SFLOAT_BLOCK: return 1; - case VK_FORMAT_ASTC_6x5_SFLOAT_BLOCK: + case VK_FORMAT_ASTC_6x5_SFLOAT_BLOCK: return 1; - case VK_FORMAT_ASTC_6x6_SFLOAT_BLOCK: + case VK_FORMAT_ASTC_6x6_SFLOAT_BLOCK: return 1; - case VK_FORMAT_ASTC_8x5_SFLOAT_BLOCK: + case VK_FORMAT_ASTC_8x5_SFLOAT_BLOCK: return 1; - case VK_FORMAT_ASTC_8x6_SFLOAT_BLOCK: + case VK_FORMAT_ASTC_8x6_SFLOAT_BLOCK: return 1; - case VK_FORMAT_ASTC_8x8_SFLOAT_BLOCK: + case VK_FORMAT_ASTC_8x8_SFLOAT_BLOCK: return 1; - case VK_FORMAT_ASTC_10x5_SFLOAT_BLOCK: + case VK_FORMAT_ASTC_10x5_SFLOAT_BLOCK: return 1; - case VK_FORMAT_ASTC_10x6_SFLOAT_BLOCK: + case VK_FORMAT_ASTC_10x6_SFLOAT_BLOCK: return 1; - case VK_FORMAT_ASTC_10x8_SFLOAT_BLOCK: + case VK_FORMAT_ASTC_10x8_SFLOAT_BLOCK: return 1; - case VK_FORMAT_ASTC_10x10_SFLOAT_BLOCK: + case VK_FORMAT_ASTC_10x10_SFLOAT_BLOCK: return 1; - case VK_FORMAT_ASTC_12x10_SFLOAT_BLOCK: + case VK_FORMAT_ASTC_12x10_SFLOAT_BLOCK: return 1; - case VK_FORMAT_ASTC_12x12_SFLOAT_BLOCK: + case VK_FORMAT_ASTC_12x12_SFLOAT_BLOCK: return 1; - case VK_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG: + case VK_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG: return 1; - case VK_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG: + case VK_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG: return 1; - case VK_FORMAT_PVRTC2_2BPP_UNORM_BLOCK_IMG: + case VK_FORMAT_PVRTC2_2BPP_UNORM_BLOCK_IMG: return 1; - case VK_FORMAT_PVRTC2_4BPP_UNORM_BLOCK_IMG: + case VK_FORMAT_PVRTC2_4BPP_UNORM_BLOCK_IMG: return 1; - case VK_FORMAT_PVRTC1_2BPP_SRGB_BLOCK_IMG: + case VK_FORMAT_PVRTC1_2BPP_SRGB_BLOCK_IMG: return 1; - case VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG: + case VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG: return 1; - case VK_FORMAT_PVRTC2_2BPP_SRGB_BLOCK_IMG: + case VK_FORMAT_PVRTC2_2BPP_SRGB_BLOCK_IMG: return 1; - case VK_FORMAT_PVRTC2_4BPP_SRGB_BLOCK_IMG: + case VK_FORMAT_PVRTC2_4BPP_SRGB_BLOCK_IMG: return 1; - case VK_FORMAT_ASTC_3x3x3_UNORM_BLOCK_EXT: + case VK_FORMAT_ASTC_3x3x3_UNORM_BLOCK_EXT: return 1; - case VK_FORMAT_ASTC_3x3x3_SRGB_BLOCK_EXT: + case VK_FORMAT_ASTC_3x3x3_SRGB_BLOCK_EXT: return 1; - case VK_FORMAT_ASTC_3x3x3_SFLOAT_BLOCK_EXT: + case VK_FORMAT_ASTC_3x3x3_SFLOAT_BLOCK_EXT: return 1; - case VK_FORMAT_ASTC_4x3x3_UNORM_BLOCK_EXT: + case VK_FORMAT_ASTC_4x3x3_UNORM_BLOCK_EXT: return 1; - case VK_FORMAT_ASTC_4x3x3_SRGB_BLOCK_EXT: + case VK_FORMAT_ASTC_4x3x3_SRGB_BLOCK_EXT: return 1; - case VK_FORMAT_ASTC_4x3x3_SFLOAT_BLOCK_EXT: + case VK_FORMAT_ASTC_4x3x3_SFLOAT_BLOCK_EXT: return 1; - case VK_FORMAT_ASTC_4x4x3_UNORM_BLOCK_EXT: + case VK_FORMAT_ASTC_4x4x3_UNORM_BLOCK_EXT: return 1; - case VK_FORMAT_ASTC_4x4x3_SRGB_BLOCK_EXT: + case VK_FORMAT_ASTC_4x4x3_SRGB_BLOCK_EXT: return 1; - case VK_FORMAT_ASTC_4x4x3_SFLOAT_BLOCK_EXT: + case VK_FORMAT_ASTC_4x4x3_SFLOAT_BLOCK_EXT: return 1; - case VK_FORMAT_ASTC_4x4x4_UNORM_BLOCK_EXT: + case VK_FORMAT_ASTC_4x4x4_UNORM_BLOCK_EXT: return 1; - case VK_FORMAT_ASTC_4x4x4_SRGB_BLOCK_EXT: + case VK_FORMAT_ASTC_4x4x4_SRGB_BLOCK_EXT: return 1; - case VK_FORMAT_ASTC_4x4x4_SFLOAT_BLOCK_EXT: + case VK_FORMAT_ASTC_4x4x4_SFLOAT_BLOCK_EXT: return 1; - case VK_FORMAT_ASTC_5x4x4_UNORM_BLOCK_EXT: + case VK_FORMAT_ASTC_5x4x4_UNORM_BLOCK_EXT: return 1; - case VK_FORMAT_ASTC_5x4x4_SRGB_BLOCK_EXT: + case VK_FORMAT_ASTC_5x4x4_SRGB_BLOCK_EXT: return 1; - case VK_FORMAT_ASTC_5x4x4_SFLOAT_BLOCK_EXT: + case VK_FORMAT_ASTC_5x4x4_SFLOAT_BLOCK_EXT: return 1; - case VK_FORMAT_ASTC_5x5x4_UNORM_BLOCK_EXT: + case VK_FORMAT_ASTC_5x5x4_UNORM_BLOCK_EXT: return 1; - case VK_FORMAT_ASTC_5x5x4_SRGB_BLOCK_EXT: + case VK_FORMAT_ASTC_5x5x4_SRGB_BLOCK_EXT: return 1; - case VK_FORMAT_ASTC_5x5x4_SFLOAT_BLOCK_EXT: + case VK_FORMAT_ASTC_5x5x4_SFLOAT_BLOCK_EXT: return 1; - case VK_FORMAT_ASTC_5x5x5_UNORM_BLOCK_EXT: + case VK_FORMAT_ASTC_5x5x5_UNORM_BLOCK_EXT: return 1; - case VK_FORMAT_ASTC_5x5x5_SRGB_BLOCK_EXT: + case VK_FORMAT_ASTC_5x5x5_SRGB_BLOCK_EXT: return 1; - case VK_FORMAT_ASTC_5x5x5_SFLOAT_BLOCK_EXT: + case VK_FORMAT_ASTC_5x5x5_SFLOAT_BLOCK_EXT: return 1; - case VK_FORMAT_ASTC_6x5x5_UNORM_BLOCK_EXT: + case VK_FORMAT_ASTC_6x5x5_UNORM_BLOCK_EXT: return 1; - case VK_FORMAT_ASTC_6x5x5_SRGB_BLOCK_EXT: + case VK_FORMAT_ASTC_6x5x5_SRGB_BLOCK_EXT: return 1; - case VK_FORMAT_ASTC_6x5x5_SFLOAT_BLOCK_EXT: + case VK_FORMAT_ASTC_6x5x5_SFLOAT_BLOCK_EXT: return 1; - case VK_FORMAT_ASTC_6x6x5_UNORM_BLOCK_EXT: + case VK_FORMAT_ASTC_6x6x5_UNORM_BLOCK_EXT: return 1; - case VK_FORMAT_ASTC_6x6x5_SRGB_BLOCK_EXT: + case VK_FORMAT_ASTC_6x6x5_SRGB_BLOCK_EXT: return 1; - case VK_FORMAT_ASTC_6x6x5_SFLOAT_BLOCK_EXT: + case VK_FORMAT_ASTC_6x6x5_SFLOAT_BLOCK_EXT: return 1; - case VK_FORMAT_ASTC_6x6x6_UNORM_BLOCK_EXT: + case VK_FORMAT_ASTC_6x6x6_UNORM_BLOCK_EXT: return 1; - case VK_FORMAT_ASTC_6x6x6_SRGB_BLOCK_EXT: + case VK_FORMAT_ASTC_6x6x6_SRGB_BLOCK_EXT: return 1; - case VK_FORMAT_ASTC_6x6x6_SFLOAT_BLOCK_EXT: + case VK_FORMAT_ASTC_6x6x6_SFLOAT_BLOCK_EXT: return 1; - case VK_FORMAT_R16G16_S10_5_NV: + case VK_FORMAT_R16G16_S10_5_NV: return 2; - case VK_FORMAT_A1B5G5R5_UNORM_PACK16_KHR: + case VK_FORMAT_A1B5G5R5_UNORM_PACK16_KHR: return 2; - case VK_FORMAT_A8_UNORM_KHR: + case VK_FORMAT_A8_UNORM_KHR: return 1; - default: + default: return 0; } } diff --git a/lib/vkloader.c b/lib/vkloader.c index 145bc32ff6..185f9330e8 100644 --- a/lib/vkloader.c +++ b/lib/vkloader.c @@ -20,13 +20,12 @@ #define _CRT_SECURE_NO_WARNINGS #endif - #include #include #include #include -#include "vk_funcs.h" // Must be included before ktxvulkan.h. +#include "vk_funcs.h" // Must be included before ktxvulkan.h. #include "ktxvulkan.h" #include "ktxint.h" #include "unused.h" @@ -42,18 +41,18 @@ // Macro to check and display Vulkan return results. // Use when the only possible errors are caused by invalid usage by this loader. #if defined(_DEBUG) -#define VK_CHECK_RESULT(f) \ -{ \ - VkResult res = (f); \ - if (res != VK_SUCCESS) \ - { \ - /* XXX Find an errorString function. */ \ - fprintf(stderr, "Fatal error in ktxLoadVkTexture*: " \ - "VkResult is \"%d\" in %s at line %d\n", \ - res, __FILE__, __LINE__); \ - assert(res == VK_SUCCESS); \ - } \ -} +#define VK_CHECK_RESULT(f) \ + { \ + VkResult res = (f); \ + if (res != VK_SUCCESS) { \ + /* XXX Find an errorString function. */ \ + fprintf(stderr, \ + "Fatal error in ktxLoadVkTexture*: " \ + "VkResult is \"%d\" in %s at line %d\n", \ + res, __FILE__, __LINE__); \ + assert(res == VK_SUCCESS); \ + } \ + } #else #define VK_CHECK_RESULT(f) ((void)f) #endif @@ -63,18 +62,10 @@ #define DEFAULT_FENCE_TIMEOUT 100000000000 #define VK_FLAGS_NONE 0 -static void -setImageLayout( - ktxVulkanFunctions vkFuncs, - VkCommandBuffer cmdBuffer, - VkImage image, - VkImageLayout oldLayout, - VkImageLayout newLayout, - VkImageSubresourceRange subresourceRange); +static void setImageLayout(ktxVulkanFunctions vkFuncs, VkCommandBuffer cmdBuffer, VkImage image, VkImageLayout oldLayout, + VkImageLayout newLayout, VkImageSubresourceRange subresourceRange); -static void -generateMipmaps(ktxVulkanTexture* vkTexture, ktxVulkanDeviceInfo* vdi, - VkFilter filter, VkImageLayout initialLayout); +static void generateMipmaps(ktxVulkanTexture* vkTexture, ktxVulkanDeviceInfo* vdi, VkFilter filter, VkImageLayout initialLayout); /** * @defgroup ktx_vkloader Vulkan Texture Image Loader @@ -103,12 +94,9 @@ generateMipmaps(ktxVulkanTexture* vkTexture, ktxVulkanDeviceInfo* vdi, * @sa ktxVulkanDeviceInfo\_Destroy() */ ktxVulkanDeviceInfo* -ktxVulkanDeviceInfo_Create(VkPhysicalDevice physicalDevice, VkDevice device, - VkQueue queue, VkCommandPool cmdPool, - const VkAllocationCallbacks* pAllocator) -{ - return ktxVulkanDeviceInfo_CreateEx(VK_NULL_HANDLE, physicalDevice, device, - queue, cmdPool, pAllocator, NULL); +ktxVulkanDeviceInfo_Create(VkPhysicalDevice physicalDevice, VkDevice device, VkQueue queue, VkCommandPool cmdPool, + const VkAllocationCallbacks* pAllocator) { + return ktxVulkanDeviceInfo_CreateEx(VK_NULL_HANDLE, physicalDevice, device, queue, cmdPool, pAllocator, NULL); } /** @@ -126,19 +114,13 @@ ktxVulkanDeviceInfo_Create(VkPhysicalDevice physicalDevice, VkDevice device, * @sa ktxVulkanDeviceInfo\_Destroy() */ ktxVulkanDeviceInfo* -ktxVulkanDeviceInfo_CreateEx(VkInstance instance, - VkPhysicalDevice physicalDevice, VkDevice device, - VkQueue queue, VkCommandPool cmdPool, - const VkAllocationCallbacks* pAllocator, - const ktxVulkanFunctions* pFuncs) -{ +ktxVulkanDeviceInfo_CreateEx(VkInstance instance, VkPhysicalDevice physicalDevice, VkDevice device, VkQueue queue, + VkCommandPool cmdPool, const VkAllocationCallbacks* pAllocator, const ktxVulkanFunctions* pFuncs) { ktxVulkanDeviceInfo* newvdi; newvdi = (ktxVulkanDeviceInfo*)malloc(sizeof(ktxVulkanDeviceInfo)); if (newvdi != NULL) { - if (ktxVulkanDeviceInfo_ConstructEx(newvdi, instance, physicalDevice, - device, queue, cmdPool, pAllocator, - pFuncs) != KTX_SUCCESS) - { + if (ktxVulkanDeviceInfo_ConstructEx(newvdi, instance, physicalDevice, device, queue, cmdPool, pAllocator, pFuncs) != + KTX_SUCCESS) { free(newvdi); newvdi = 0; } @@ -192,13 +174,9 @@ ktxVulkanDeviceInfo_CreateEx(VkInstance instance, * */ KTX_error_code -ktxVulkanDeviceInfo_Construct(ktxVulkanDeviceInfo* This, - VkPhysicalDevice physicalDevice, VkDevice device, - VkQueue queue, VkCommandPool cmdPool, - const VkAllocationCallbacks* pAllocator) -{ - return ktxVulkanDeviceInfo_ConstructEx(This, VK_NULL_HANDLE, physicalDevice, device, queue, - cmdPool, pAllocator, NULL); +ktxVulkanDeviceInfo_Construct(ktxVulkanDeviceInfo* This, VkPhysicalDevice physicalDevice, VkDevice device, VkQueue queue, + VkCommandPool cmdPool, const VkAllocationCallbacks* pAllocator) { + return ktxVulkanDeviceInfo_ConstructEx(This, VK_NULL_HANDLE, physicalDevice, device, queue, cmdPool, pAllocator, NULL); } /** @@ -216,44 +194,38 @@ ktxVulkanDeviceInfo_Construct(ktxVulkanDeviceInfo* This, * will retrieve the proc addresses itself. */ KTX_error_code -ktxVulkanDeviceInfo_ConstructEx(ktxVulkanDeviceInfo* This, - VkInstance instance, - VkPhysicalDevice physicalDevice, VkDevice device, - VkQueue queue, VkCommandPool cmdPool, - const VkAllocationCallbacks* pAllocator, - const ktxVulkanFunctions* pFunctions) -{ - -#define LOAD_EXT_FUNC(member, fun) \ -do { \ - if ((member).fun == NULL) { \ - (member).fun = (PFN_##fun)ktxLoadVulkanFunction(#fun); \ - if ((member).fun == NULL) { \ - return KTX_NOT_FOUND; \ - }\ - } \ -} while (0) - -#define LOAD_INST_FUNC(member, instance, fun) \ -do { \ - if ((member).fun == NULL) { \ - (member).fun = (PFN_##fun)((member).vkGetInstanceProcAddr)((instance), #fun); \ - if ((member).fun == NULL) { \ - return KTX_NOT_FOUND; \ - }\ - } \ -} while (0) - -#define LOAD_DEVICE_FUNC(member, device, fun) \ -do { \ - if ((member).fun == NULL) { \ - (member).fun = (PFN_##fun)((member).vkGetDeviceProcAddr)((device), #fun); \ - if ((member).fun == NULL) { \ - return KTX_NOT_FOUND; \ - }\ - } \ -} while (0) - +ktxVulkanDeviceInfo_ConstructEx(ktxVulkanDeviceInfo* This, VkInstance instance, VkPhysicalDevice physicalDevice, VkDevice device, + VkQueue queue, VkCommandPool cmdPool, const VkAllocationCallbacks* pAllocator, + const ktxVulkanFunctions* pFunctions) { +#define LOAD_EXT_FUNC(member, fun) \ + do { \ + if ((member).fun == NULL) { \ + (member).fun = (PFN_##fun)ktxLoadVulkanFunction(#fun); \ + if ((member).fun == NULL) { \ + return KTX_NOT_FOUND; \ + } \ + } \ + } while (0) + +#define LOAD_INST_FUNC(member, instance, fun) \ + do { \ + if ((member).fun == NULL) { \ + (member).fun = (PFN_##fun)((member).vkGetInstanceProcAddr)((instance), #fun); \ + if ((member).fun == NULL) { \ + return KTX_NOT_FOUND; \ + } \ + } \ + } while (0) + +#define LOAD_DEVICE_FUNC(member, device, fun) \ + do { \ + if ((member).fun == NULL) { \ + (member).fun = (PFN_##fun)((member).vkGetDeviceProcAddr)((device), #fun); \ + if ((member).fun == NULL) { \ + return KTX_NOT_FOUND; \ + } \ + } \ + } while (0) This->instance = instance; This->physicalDevice = physicalDevice; @@ -265,8 +237,7 @@ do { \ ktxVulkanFunctions funcs; memset(&funcs, 0, sizeof(ktxVulkanFunctions)); - if (pFunctions != NULL) - funcs = *pFunctions; + if (pFunctions != NULL) funcs = *pFunctions; if (instance == VK_NULL_HANDLE || pFunctions == NULL) { // This is the old behavior, where no functions where specified. We @@ -275,8 +246,7 @@ do { \ // The reason we check this here, is that ktxLoadVulkanFunction doesn't // give us a proper error code. ktx_error_code_e kresult = ktxLoadVulkanLibrary(); - if (kresult != KTX_SUCCESS) - return kresult; + if (kresult != KTX_SUCCESS) return kresult; // If pFunctions are null, then we try to load the minimum number of // required functions. @@ -302,7 +272,6 @@ do { \ LOAD_INST_FUNC(funcs, instance, vkGetPhysicalDeviceMemoryProperties); LOAD_INST_FUNC(funcs, instance, vkGetPhysicalDeviceImageFormatProperties); - // We now get to device functions. LOAD_INST_FUNC(funcs, instance, vkGetDeviceProcAddr); @@ -332,26 +301,21 @@ do { \ LOAD_DEVICE_FUNC(funcs, device, vkGetImageMemoryRequirements); LOAD_DEVICE_FUNC(funcs, device, vkGetImageSubresourceLayout); - This->vkFuncs = funcs; - VkCommandBufferAllocateInfo cmdBufInfo = { - .sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO - }; + VkCommandBufferAllocateInfo cmdBufInfo = {.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO}; VkResult result; - This->vkFuncs.vkGetPhysicalDeviceMemoryProperties(physicalDevice, - &This->deviceMemoryProperties); + This->vkFuncs.vkGetPhysicalDeviceMemoryProperties(physicalDevice, &This->deviceMemoryProperties); // Use a separate command buffer for texture loading. Needed for // submitting image barriers and converting tilings. cmdBufInfo.commandPool = cmdPool; cmdBufInfo.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; cmdBufInfo.commandBufferCount = 1; - result = This->vkFuncs.vkAllocateCommandBuffers(device, &cmdBufInfo, - &This->cmdBuffer); + result = This->vkFuncs.vkAllocateCommandBuffers(device, &cmdBufInfo, &This->cmdBuffer); if (result != VK_SUCCESS) { - return KTX_OUT_OF_MEMORY; // TODO: Consider an equivalent to pGlError + return KTX_OUT_OF_MEMORY; // TODO: Consider an equivalent to pGlError } return KTX_SUCCESS; @@ -370,10 +334,8 @@ do { \ * @param This pointer to the ktxVulkanDeviceInfo to destruct. */ void -ktxVulkanDeviceInfo_Destruct(ktxVulkanDeviceInfo* This) -{ - This->vkFuncs.vkFreeCommandBuffers(This->device, This->cmdPool, 1, - &This->cmdBuffer); +ktxVulkanDeviceInfo_Destruct(ktxVulkanDeviceInfo* This) { + This->vkFuncs.vkFreeCommandBuffers(This->device, This->cmdPool, 1, &This->cmdBuffer); } /** @@ -386,8 +348,7 @@ ktxVulkanDeviceInfo_Destruct(ktxVulkanDeviceInfo* This) * @param This pointer to the ktxVulkanDeviceInfo to destroy. */ void -ktxVulkanDeviceInfo_Destroy(ktxVulkanDeviceInfo* This) -{ +ktxVulkanDeviceInfo_Destroy(ktxVulkanDeviceInfo* This) { assert(This != NULL); ktxVulkanDeviceInfo_Destruct(This); free(This); @@ -395,15 +356,10 @@ ktxVulkanDeviceInfo_Destroy(ktxVulkanDeviceInfo* This) /* Get appropriate memory type index for a memory allocation. */ static uint32_t -ktxVulkanDeviceInfo_getMemoryType(ktxVulkanDeviceInfo* This, - uint32_t typeBits, VkFlags properties) -{ - for (uint32_t i = 0; i < 32; i++) - { - if ((typeBits & 1) == 1) - { - if ((This->deviceMemoryProperties.memoryTypes[i].propertyFlags & properties) == properties) - { +ktxVulkanDeviceInfo_getMemoryType(ktxVulkanDeviceInfo* This, uint32_t typeBits, VkFlags properties) { + for (uint32_t i = 0; i < 32; i++) { + if ((typeBits & 1) == 1) { + if ((This->deviceMemoryProperties.memoryTypes[i].propertyFlags & properties) == properties) { return i; } } @@ -419,12 +375,12 @@ ktxVulkanDeviceInfo_getMemoryType(ktxVulkanDeviceInfo* This, //====================================================================== typedef struct user_cbdata_optimal { - VkBufferImageCopy* region; // Specify destination region in final image. - VkDeviceSize offset; // Offset of current level in staging buffer + VkBufferImageCopy* region; // Specify destination region in final image. + VkDeviceSize offset; // Offset of current level in staging buffer ktx_uint32_t numFaces; ktx_uint32_t numLayers; // The following are used only by optimalTilingPadCallback - ktx_uint8_t* dest; // Pointer to mapped staging buffer. + ktx_uint8_t* dest; // Pointer to mapped staging buffer. ktx_uint32_t elementSize; ktx_uint32_t numDimensions; #if defined(_DEBUG) @@ -449,11 +405,8 @@ typedef struct user_cbdata_optimal { * @copydetails PFNKTXITERCB */ static KTX_error_code -optimalTilingCallback(int miplevel, int face, - int width, int height, int depth, - ktx_uint64_t faceLodSize, - void* pixels, void* userdata) -{ +optimalTilingCallback(int miplevel, int face, int width, int height, int depth, ktx_uint64_t faceLodSize, void* pixels, + void* userdata) { user_cbdata_optimal* ud = (user_cbdata_optimal*)userdata; UNUSED(pixels); @@ -506,15 +459,12 @@ uint32_t lcm4(uint32_t a); * selected to minimize the buffering needed between reading the file and * copying the data into the staging buffer. Obviously when * @c ktx_Texture_IterateFaceLevels is being used, this is a moot point. -* + * * @copydetails PFNKTXITERCB */ KTX_error_code -optimalTilingPadCallback(int miplevel, int face, - int width, int height, int depth, - ktx_uint64_t faceLodSize, - void* pixels, void* userdata) -{ +optimalTilingPadCallback(int miplevel, int face, int width, int height, int depth, ktx_uint64_t faceLodSize, void* pixels, + void* userdata) { user_cbdata_optimal* ud = (user_cbdata_optimal*)userdata; ktx_uint32_t rowPitch = width * ud->elementSize; @@ -531,8 +481,8 @@ optimalTilingPadCallback(int miplevel, int face, ud->offset += faceLodSize; } else { // Must remove padding. Copy a row at a time. - ktx_uint32_t image, imageIterations; - ktx_int32_t row; + ktx_uint32_t image, imageIterations; + ktx_int32_t row; ktx_uint32_t paddedRowPitch; if (ud->numDimensions == 3) @@ -582,7 +532,7 @@ typedef struct user_cbdata_linear { ktxVulkanFunctions vkFuncs; VkImage destImage; VkDevice device; - uint8_t* dest; // Pointer to mapped Image memory + uint8_t* dest; // Pointer to mapped Image memory ktxTexture* texture; } user_cbdata_linear; @@ -594,19 +544,12 @@ typedef struct user_cbdata_linear { * Copy the image data into the mapped Vulkan image. */ KTX_error_code -linearTilingCallback(int miplevel, int face, - int width, int height, int depth, - ktx_uint64_t faceLodSize, - void* pixels, void* userdata) -{ +linearTilingCallback(int miplevel, int face, int width, int height, int depth, ktx_uint64_t faceLodSize, void* pixels, + void* userdata) { user_cbdata_linear* ud = (user_cbdata_linear*)userdata; VkSubresourceLayout subResLayout; #if !defined(_MSC_VER) || _MSC_VER >= 1920 - VkImageSubresource subRes = { - .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, - .mipLevel = miplevel, - .arrayLayer = face - }; + VkImageSubresource subRes = {.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, .mipLevel = miplevel, .arrayLayer = face}; #else VkImageSubresource subRes = {0}; subRes.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; @@ -620,8 +563,7 @@ linearTilingCallback(int miplevel, int face, // Get sub resources layout. Includes row pitch, size, // offsets, etc. - ud->vkFuncs.vkGetImageSubresourceLayout(ud->device, ud->destImage, &subRes, - &subResLayout); + ud->vkFuncs.vkGetImageSubresourceLayout(ud->device, ud->destImage, &subRes, &subResLayout); // Copies all images of the miplevel (for array & 3d) or a single face. memcpy(ud->dest + subResLayout.offset, pixels, faceLodSize); return KTX_SUCCESS; @@ -645,28 +587,21 @@ linearTilingCallback(int miplevel, int face, * strides appears to be for an R8G8B8A8_UNORM of the same texel size. */ KTX_error_code -linearTilingPadCallback(int miplevel, int face, - int width, int height, int depth, - ktx_uint64_t faceLodSize, - void* pixels, void* userdata) -{ +linearTilingPadCallback(int miplevel, int face, int width, int height, int depth, ktx_uint64_t faceLodSize, void* pixels, + void* userdata) { user_cbdata_linear* ud = (user_cbdata_linear*)userdata; VkDeviceSize offset; - ktx_size_t imageSize = 0; + ktx_size_t imageSize = 0; VkDeviceSize imagePitch = 0; ktx_uint32_t srcRowPitch; ktx_uint32_t rowIterations; ktx_uint32_t imageIterations; ktx_uint32_t row, image; ktx_uint8_t* pSrc; - ktx_size_t copySize; + ktx_size_t copySize; VkSubresourceLayout subResLayout; #if !defined(_MSC_VER) || _MSC_VER >= 1920 - VkImageSubresource subRes = { - .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, - .mipLevel = miplevel, - .arrayLayer = face - }; + VkImageSubresource subRes = {.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, .mipLevel = miplevel, .arrayLayer = face}; #else VkImageSubresource subRes = {0}; subRes.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; @@ -678,8 +613,7 @@ linearTilingPadCallback(int miplevel, int face, // Get sub resources layout. Includes row pitch, size, // offsets, etc. - ud->vkFuncs.vkGetImageSubresourceLayout(ud->device, ud->destImage, &subRes, - &subResLayout); + ud->vkFuncs.vkGetImageSubresourceLayout(ud->device, ud->destImage, &subRes, &subResLayout); srcRowPitch = ktxTexture_GetRowPitch(ud->texture, miplevel); @@ -698,13 +632,10 @@ linearTilingPadCallback(int miplevel, int face, imageSize = ktxTexture_GetImageSize(ud->texture, miplevel); if (ud->texture->numLayers > 1) { imagePitch = subResLayout.arrayPitch; - if (imagePitch != imageSize) - imageIterations - = ud->texture->numLayers * ud->texture->numFaces; + if (imagePitch != imageSize) imageIterations = ud->texture->numLayers * ud->texture->numFaces; } else { imagePitch = subResLayout.depthPitch; - if (imagePitch != imageSize) - imageIterations = depth; + if (imagePitch != imageSize) imageIterations = depth; } assert(imageSize <= imagePitch); } @@ -729,7 +660,7 @@ linearTilingPadCallback(int miplevel, int face, memcpy(ud->dest + offset, pSrc, copySize); offset += subResLayout.rowPitch; pSrc += srcRowPitch; - } + } offset += imagePitch; } return KTX_SUCCESS; @@ -761,10 +692,10 @@ linearTilingPadCallback(int miplevel, int face, * limited number of formats and features. Generally @c VK_IMAGE_TILING_OPTIMAL * is preferred. The latter requires a staging buffer so will use more memory * during loading. - * + * * If a pointer to a set of suballocator callbacks is provided, they * will be used instead of manual allocation of VkDeviceMemory. A 64 bit uint - * that references the suballocated page(s) is returned on memory procurement + * that references the suballocated page(s) is returned on memory procurement * and saved in the @c allocationId field of the structure pointed to by @a vkTexture. * * @param[in] This pointer to the ktxTexture from which to upload. @@ -780,8 +711,8 @@ linearTilingPadCallback(int miplevel, int face, * intended usage of the destination image. * @param [in] finalLayout a VkImageLayout value indicating the desired * final layout of the created image. - * @param [in] subAllocatorCallbacks pointer to a set of suballocator callbacks - * that wrap around suballocator calls: alloc, + * @param [in] subAllocatorCallbacks pointer to a set of suballocator callbacks + * that wrap around suballocator calls: alloc, * bindbuffer, bindimage, map, unmap and free. * They use a uint64_t stored in the @c allocationId * field of the structure pointed at by @a vkTexture @@ -789,7 +720,7 @@ linearTilingPadCallback(int miplevel, int face, * * @return KTX_SUCCESS on success, other KTX_* enum values on error. * - * @exception KTX_INVALID_VALUE An incomplete set of callbacks are provided in + * @exception KTX_INVALID_VALUE An incomplete set of callbacks are provided in * subAllocatorCallbacks. * @exception KTX_INVALID_VALUE @p This, @p vdi or @p vkTexture is @c NULL. * @exception KTX_INVALID_OPERATION The ktxTexture contains neither images nor @@ -811,47 +742,30 @@ linearTilingPadCallback(int miplevel, int face, * @sa @ref ktxVulkanDeviceInfo::ktxVulkanDeviceInfo\_Construct "ktxVulkanDeviceInfo_Construct()" */ KTX_error_code -ktxTexture_VkUploadEx_WithSuballocator(ktxTexture* This, ktxVulkanDeviceInfo* vdi, - ktxVulkanTexture* vkTexture, - VkImageTiling tiling, - VkImageUsageFlags usageFlags, - VkImageLayout finalLayout, - ktxVulkanTexture_subAllocatorCallbacks* subAllocatorCallbacks) -{ - KTX_error_code kResult; - VkFilter blitFilter = VK_FILTER_LINEAR; - VkFormat vkFormat; - VkImageType imageType; - VkImageViewType viewType; - VkImageCreateFlags createFlags = 0; - VkImageFormatProperties imageFormatProperties; - VkResult vResult; - VkCommandBufferBeginInfo cmdBufBeginInfo = { - .sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, - .pNext = NULL - }; - VkImageCreateInfo imageCreateInfo = { - .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, - .pNext = NULL - }; - VkMemoryAllocateInfo memAllocInfo = { - .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, - .pNext = NULL, - .allocationSize = 0, - .memoryTypeIndex = 0 - }; - VkMemoryRequirements memReqs; - ktx_uint32_t numImageLayers, numImageLevels; +ktxTexture_VkUploadEx_WithSuballocator(ktxTexture* This, ktxVulkanDeviceInfo* vdi, ktxVulkanTexture* vkTexture, + VkImageTiling tiling, VkImageUsageFlags usageFlags, VkImageLayout finalLayout, + ktxVulkanTexture_subAllocatorCallbacks* subAllocatorCallbacks) { + KTX_error_code kResult; + VkFilter blitFilter = VK_FILTER_LINEAR; + VkFormat vkFormat; + VkImageType imageType; + VkImageViewType viewType; + VkImageCreateFlags createFlags = 0; + VkImageFormatProperties imageFormatProperties; + VkResult vResult; + VkCommandBufferBeginInfo cmdBufBeginInfo = {.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, .pNext = NULL}; + VkImageCreateInfo imageCreateInfo = {.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, .pNext = NULL}; + VkMemoryAllocateInfo memAllocInfo = { + .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, .pNext = NULL, .allocationSize = 0, .memoryTypeIndex = 0}; + VkMemoryRequirements memReqs; + ktx_uint32_t numImageLayers, numImageLevels; ktx_uint32_t elementSize = ktxTexture_GetElementSize(This); - ktx_bool_t canUseFasterPath; - ktx_bool_t useSuballocator = false; + ktx_bool_t canUseFasterPath; + ktx_bool_t useSuballocator = false; if (subAllocatorCallbacks) { - if (subAllocatorCallbacks->allocMemFuncPtr && - subAllocatorCallbacks->bindBufferFuncPtr && - subAllocatorCallbacks->bindImageFuncPtr && - subAllocatorCallbacks->memoryMapFuncPtr && - subAllocatorCallbacks->memoryUnmapFuncPtr && - subAllocatorCallbacks->freeMemFuncPtr) + if (subAllocatorCallbacks->allocMemFuncPtr && subAllocatorCallbacks->bindBufferFuncPtr && + subAllocatorCallbacks->bindImageFuncPtr && subAllocatorCallbacks->memoryMapFuncPtr && + subAllocatorCallbacks->memoryUnmapFuncPtr && subAllocatorCallbacks->freeMemFuncPtr) useSuballocator = true; else return KTX_INVALID_VALUE; @@ -877,22 +791,19 @@ ktxTexture_VkUploadEx_WithSuballocator(ktxTexture* This, ktxVulkanDeviceInfo* vd assert(This->numDimensions >= 1 && This->numDimensions <= 3); switch (This->numDimensions) { - case 1: + case 1: imageType = VK_IMAGE_TYPE_1D; - viewType = This->isArray ? - VK_IMAGE_VIEW_TYPE_1D_ARRAY : VK_IMAGE_VIEW_TYPE_1D; + viewType = This->isArray ? VK_IMAGE_VIEW_TYPE_1D_ARRAY : VK_IMAGE_VIEW_TYPE_1D; break; - case 2: - default: // To keep compilers happy. + case 2: + default: // To keep compilers happy. imageType = VK_IMAGE_TYPE_2D; if (This->isCubemap) - viewType = This->isArray ? - VK_IMAGE_VIEW_TYPE_CUBE_ARRAY : VK_IMAGE_VIEW_TYPE_CUBE; + viewType = This->isArray ? VK_IMAGE_VIEW_TYPE_CUBE_ARRAY : VK_IMAGE_VIEW_TYPE_CUBE; else - viewType = This->isArray ? - VK_IMAGE_VIEW_TYPE_2D_ARRAY : VK_IMAGE_VIEW_TYPE_2D; + viewType = This->isArray ? VK_IMAGE_VIEW_TYPE_2D_ARRAY : VK_IMAGE_VIEW_TYPE_2D; break; - case 3: + case 3: imageType = VK_IMAGE_TYPE_3D; /* 3D array textures not supported in Vulkan. Attempts to create or * load them should have been trapped long before this. @@ -916,13 +827,8 @@ ktxTexture_VkUploadEx_WithSuballocator(ktxTexture* This, ktxVulkanDeviceInfo* vd // Ensure we can blit between levels. usageFlags |= (VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT); } - vResult = vdi->vkFuncs.vkGetPhysicalDeviceImageFormatProperties(vdi->physicalDevice, - vkFormat, - imageType, - tiling, - usageFlags, - createFlags, - &imageFormatProperties); + vResult = vdi->vkFuncs.vkGetPhysicalDeviceImageFormatProperties(vdi->physicalDevice, vkFormat, imageType, tiling, usageFlags, + createFlags, &imageFormatProperties); if (vResult == VK_ERROR_FORMAT_NOT_SUPPORTED) { return KTX_INVALID_OPERATION; } @@ -932,26 +838,22 @@ ktxTexture_VkUploadEx_WithSuballocator(ktxTexture* This, ktxVulkanDeviceInfo* vd if (This->generateMipmaps) { uint32_t max_dim; - VkFormatProperties formatProperties; - VkFormatFeatureFlags formatFeatureFlags; - VkFormatFeatureFlags neededFeatures - = VK_FORMAT_FEATURE_BLIT_DST_BIT | VK_FORMAT_FEATURE_BLIT_SRC_BIT; - vdi->vkFuncs.vkGetPhysicalDeviceFormatProperties(vdi->physicalDevice, - vkFormat, - &formatProperties); + VkFormatProperties formatProperties; + VkFormatFeatureFlags formatFeatureFlags; + VkFormatFeatureFlags neededFeatures = VK_FORMAT_FEATURE_BLIT_DST_BIT | VK_FORMAT_FEATURE_BLIT_SRC_BIT; + vdi->vkFuncs.vkGetPhysicalDeviceFormatProperties(vdi->physicalDevice, vkFormat, &formatProperties); assert(vResult == VK_SUCCESS); if (tiling == VK_IMAGE_TILING_OPTIMAL) formatFeatureFlags = formatProperties.optimalTilingFeatures; else formatFeatureFlags = formatProperties.linearTilingFeatures; - if ((formatFeatureFlags & neededFeatures) != neededFeatures) - return KTX_INVALID_OPERATION; + if ((formatFeatureFlags & neededFeatures) != neededFeatures) return KTX_INVALID_OPERATION; if (formatFeatureFlags & VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT) blitFilter = VK_FILTER_LINEAR; else - blitFilter = VK_FILTER_NEAREST; // XXX INVALID_OP? + blitFilter = VK_FILTER_NEAREST; // XXX INVALID_OP? max_dim = MAX(MAX(This->baseWidth, This->baseHeight), This->baseDepth); numImageLevels = (uint32_t)floor(log2(max_dim)) + 1; @@ -982,8 +884,8 @@ ktxTexture_VkUploadEx_WithSuballocator(ktxTexture* This, ktxVulkanDeviceInfo* vd // // Note all elementSizes > 4 Will be a multiple of 4, so only // elementSizes of 1, 2 & 3 are a concern here. - if (elementSize % 4 == 0 /* There'll be no padding at any level. */ - /* There is no padding at level 0 and no other levels. */ + if (elementSize % 4 == 0 /* There'll be no padding at any level. */ + /* There is no padding at level 0 and no other levels. */ || (This->numLevels == 1 && actualRowPitch == tightRowPitch)) canUseFasterPath = KTX_TRUE; else @@ -1001,37 +903,23 @@ ktxTexture_VkUploadEx_WithSuballocator(ktxTexture* This, ktxVulkanDeviceInfo* vd vkTexture->vkDestroyImage = vdi->vkFuncs.vkDestroyImage; vkTexture->vkFreeMemory = vdi->vkFuncs.vkFreeMemory; - VK_CHECK_RESULT( - vdi->vkFuncs.vkBeginCommandBuffer(vdi->cmdBuffer, &cmdBufBeginInfo) - ); + VK_CHECK_RESULT(vdi->vkFuncs.vkBeginCommandBuffer(vdi->cmdBuffer, &cmdBufBeginInfo)); - if (tiling == VK_IMAGE_TILING_OPTIMAL) - { + if (tiling == VK_IMAGE_TILING_OPTIMAL) { // Create a host-visible staging buffer that contains the raw image data VkBuffer stagingBuffer; VkDeviceMemory stagingMemory = VK_NULL_HANDLE; VkBufferImageCopy* copyRegions; VkDeviceSize textureSize; - VkBufferCreateInfo bufferCreateInfo = { - .sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, - .pNext = NULL - }; + VkBufferCreateInfo bufferCreateInfo = {.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, .pNext = NULL}; VkImageSubresourceRange subresourceRange; VkFence copyFence; - VkFenceCreateInfo fenceCreateInfo = { - .sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, - .pNext = NULL, - .flags = VK_FLAGS_NONE - }; - VkSubmitInfo submitInfo = { - .sType = VK_STRUCTURE_TYPE_SUBMIT_INFO, - .pNext = NULL - }; + VkFenceCreateInfo fenceCreateInfo = {.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, .pNext = NULL, .flags = VK_FLAGS_NONE}; + VkSubmitInfo submitInfo = {.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO, .pNext = NULL}; ktx_uint8_t* pMappedStagingBuffer; ktx_uint32_t numCopyRegions; user_cbdata_optimal cbData; - textureSize = ktxTexture_GetDataSizeUncompressed(This); bufferCreateInfo.size = textureSize; if (canUseFasterPath) { @@ -1048,8 +936,7 @@ ktxTexture_VkUploadEx_WithSuballocator(ktxTexture* This, ktxVulkanDeviceInfo* vd * elementSize and 4 and also need a copy region per image * in case they end up with padding between them. */ - numCopyRegions = This->isArray ? This->numLevels - : This->numLevels * This->numFaces; + numCopyRegions = This->isArray ? This->numLevels : This->numLevels * This->numFaces; /* * Add extra space to allow for possible padding described * above. A bit ad-hoc but it's only a small amount of @@ -1057,8 +944,7 @@ ktxTexture_VkUploadEx_WithSuballocator(ktxTexture* This, ktxVulkanDeviceInfo* vd */ bufferCreateInfo.size += numCopyRegions * elementSize * 4; } - copyRegions = (VkBufferImageCopy*)malloc(sizeof(VkBufferImageCopy) - * numCopyRegions); + copyRegions = (VkBufferImageCopy*)malloc(sizeof(VkBufferImageCopy) * numCopyRegions); if (copyRegions == NULL) { return KTX_OUT_OF_MEMORY; } @@ -1067,9 +953,7 @@ ktxTexture_VkUploadEx_WithSuballocator(ktxTexture* This, ktxVulkanDeviceInfo* vd bufferCreateInfo.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT; bufferCreateInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE; - VK_CHECK_RESULT( - vdi->vkFuncs.vkCreateBuffer(vdi->device, &bufferCreateInfo, - vdi->pAllocator, &stagingBuffer)); + VK_CHECK_RESULT(vdi->vkFuncs.vkCreateBuffer(vdi->device, &bufferCreateInfo, vdi->pAllocator, &stagingBuffer)); // Get memory requirements for the staging buffer (alignment, // memory type bits) @@ -1078,43 +962,30 @@ ktxTexture_VkUploadEx_WithSuballocator(ktxTexture* This, ktxVulkanDeviceInfo* vd memAllocInfo.allocationSize = memReqs.size; // Get memory type index for a host visible buffer memAllocInfo.memoryTypeIndex = ktxVulkanDeviceInfo_getMemoryType( - vdi, - memReqs.memoryTypeBits, - VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT - | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT - ); + vdi, memReqs.memoryTypeBits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT); uint64_t stagingAllocId = 0ull; if (!useSuballocator) { - vResult = vdi->vkFuncs.vkAllocateMemory(vdi->device, &memAllocInfo, - vdi->pAllocator, &stagingMemory); + vResult = vdi->vkFuncs.vkAllocateMemory(vdi->device, &memAllocInfo, vdi->pAllocator, &stagingMemory); if (vResult != VK_SUCCESS) { return KTX_OUT_OF_MEMORY; } - VK_CHECK_RESULT( - vdi->vkFuncs.vkBindBufferMemory(vdi->device, stagingBuffer, - stagingMemory, 0)); + VK_CHECK_RESULT(vdi->vkFuncs.vkBindBufferMemory(vdi->device, stagingBuffer, stagingMemory, 0)); VK_CHECK_RESULT( - vdi->vkFuncs.vkMapMemory(vdi->device, stagingMemory, 0, - memReqs.size, 0, - (void**)&pMappedStagingBuffer)); - } - else { + vdi->vkFuncs.vkMapMemory(vdi->device, stagingMemory, 0, memReqs.size, 0, (void**)&pMappedStagingBuffer)); + } else { uint64_t numPages = 0ull; stagingAllocId = subAllocatorCallbacks->allocMemFuncPtr(&memAllocInfo, &memReqs, &numPages); if (stagingAllocId == 0ull) { return KTX_OUT_OF_MEMORY; } - if (numPages > 1ull) { // Sparse binding of KTX textures is unsupported for the moment + if (numPages > 1ull) { // Sparse binding of KTX textures is unsupported for the moment return KTX_UNSUPPORTED_FEATURE; } + VK_CHECK_RESULT(subAllocatorCallbacks->bindBufferFuncPtr(stagingBuffer, stagingAllocId)); VK_CHECK_RESULT( - subAllocatorCallbacks->bindBufferFuncPtr(stagingBuffer, stagingAllocId)); - VK_CHECK_RESULT( - subAllocatorCallbacks->memoryMapFuncPtr(stagingAllocId, 0ull, - &memReqs.size, - (void**)&pMappedStagingBuffer)); + subAllocatorCallbacks->memoryMapFuncPtr(stagingAllocId, 0ull, &memReqs.size, (void**)&pMappedStagingBuffer)); } cbData.offset = 0; @@ -1141,17 +1012,12 @@ ktxTexture_VkUploadEx_WithSuballocator(ktxTexture* This, ktxVulkanDeviceInfo* vd /* The strange cast quiets an Xcode warning when building * for the Generic iOS Device where size_t is 32-bit even * when building for arm64. */ - kResult = ktxTexture_LoadImageData(This, - pMappedStagingBuffer, - (ktx_size_t)memAllocInfo.allocationSize); - if (kResult != KTX_SUCCESS) - return kResult; + kResult = ktxTexture_LoadImageData(This, pMappedStagingBuffer, (ktx_size_t)memAllocInfo.allocationSize); + if (kResult != KTX_SUCCESS) return kResult; } // Iterate over mip levels to set up the copy regions. - kResult = ktxTexture_IterateLevels(This, - optimalTilingCallback, - &cbData); + kResult = ktxTexture_IterateLevels(This, optimalTilingCallback, &cbData); // XXX Check for possible errors. } else { // Iterate over face-levels with callback that copies the @@ -1159,15 +1025,9 @@ ktxTexture_VkUploadEx_WithSuballocator(ktxTexture* This, ktxVulkanDeviceInfo* vd // removing padding. Using face-levels minimizes pre-staging-buffer // buffering, in the event the data is not already loaded. if (This->pData) { - kResult = ktxTexture_IterateLevelFaces( - This, - optimalTilingPadCallback, - &cbData); + kResult = ktxTexture_IterateLevelFaces(This, optimalTilingPadCallback, &cbData); } else { - kResult = ktxTexture_IterateLoadLevelFaces( - This, - optimalTilingPadCallback, - &cbData); + kResult = ktxTexture_IterateLoadLevelFaces(This, optimalTilingPadCallback, &cbData); // XXX Check for possible errors. } } @@ -1193,37 +1053,27 @@ ktxTexture_VkUploadEx_WithSuballocator(ktxTexture* This, ktxVulkanDeviceInfo* vd imageCreateInfo.extent.height = vkTexture->height; imageCreateInfo.extent.depth = vkTexture->depth; - VK_CHECK_RESULT( - vdi->vkFuncs.vkCreateImage(vdi->device, &imageCreateInfo, - vdi->pAllocator, &vkTexture->image)); + VK_CHECK_RESULT(vdi->vkFuncs.vkCreateImage(vdi->device, &imageCreateInfo, vdi->pAllocator, &vkTexture->image)); vdi->vkFuncs.vkGetImageMemoryRequirements(vdi->device, vkTexture->image, &memReqs); memAllocInfo.allocationSize = memReqs.size; - memAllocInfo.memoryTypeIndex = ktxVulkanDeviceInfo_getMemoryType( - vdi, memReqs.memoryTypeBits, - VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT); + memAllocInfo.memoryTypeIndex = + ktxVulkanDeviceInfo_getMemoryType(vdi, memReqs.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT); if (!useSuballocator) { - VK_CHECK_RESULT( - vdi->vkFuncs.vkAllocateMemory(vdi->device, &memAllocInfo, - vdi->pAllocator, - &vkTexture->deviceMemory)); - VK_CHECK_RESULT( - vdi->vkFuncs.vkBindImageMemory(vdi->device, vkTexture->image, - vkTexture->deviceMemory, 0)); - } - else { + VK_CHECK_RESULT(vdi->vkFuncs.vkAllocateMemory(vdi->device, &memAllocInfo, vdi->pAllocator, &vkTexture->deviceMemory)); + VK_CHECK_RESULT(vdi->vkFuncs.vkBindImageMemory(vdi->device, vkTexture->image, vkTexture->deviceMemory, 0)); + } else { uint64_t numPages = 0ull; vkTexture->allocationId = subAllocatorCallbacks->allocMemFuncPtr(&memAllocInfo, &memReqs, &numPages); if (vkTexture->allocationId == 0ull) { return KTX_OUT_OF_MEMORY; } - if(numPages > 1ull) { // Sparse binding of KTX textures is unsupported for the moment + if (numPages > 1ull) { // Sparse binding of KTX textures is unsupported for the moment return KTX_UNSUPPORTED_FEATURE; } - VK_CHECK_RESULT( - subAllocatorCallbacks->bindImageFuncPtr(vkTexture->image, vkTexture->allocationId)); + VK_CHECK_RESULT(subAllocatorCallbacks->bindImageFuncPtr(vkTexture->image, vkTexture->allocationId)); } subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; @@ -1235,59 +1085,39 @@ ktxTexture_VkUploadEx_WithSuballocator(ktxTexture* This, ktxVulkanDeviceInfo* vd // Image barrier to transition, possibly only the base level, image // layout to TRANSFER_DST_OPTIMAL so it can be used as the copy // destination. - setImageLayout( - vdi->vkFuncs, - vdi->cmdBuffer, - vkTexture->image, - VK_IMAGE_LAYOUT_UNDEFINED, - VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, - subresourceRange); + setImageLayout(vdi->vkFuncs, vdi->cmdBuffer, vkTexture->image, VK_IMAGE_LAYOUT_UNDEFINED, + VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, subresourceRange); // Copy mip levels from staging buffer - vdi->vkFuncs.vkCmdCopyBufferToImage( - vdi->cmdBuffer, stagingBuffer, - vkTexture->image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, - numCopyRegions, copyRegions - ); + vdi->vkFuncs.vkCmdCopyBufferToImage(vdi->cmdBuffer, stagingBuffer, vkTexture->image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, + numCopyRegions, copyRegions); free(copyRegions); if (This->generateMipmaps) { - generateMipmaps(vkTexture, vdi, - blitFilter, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL); + generateMipmaps(vkTexture, vdi, blitFilter, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL); } else { // Transition image layout to finalLayout after all mip levels // have been copied. // In this case numImageLevels == This->numLevels - //subresourceRange.levelCount = numImageLevels; - setImageLayout( - vdi->vkFuncs, - vdi->cmdBuffer, - vkTexture->image, - VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, - finalLayout, - subresourceRange); + // subresourceRange.levelCount = numImageLevels; + setImageLayout(vdi->vkFuncs, vdi->cmdBuffer, vkTexture->image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, finalLayout, + subresourceRange); } // Submit command buffer containing copy and image layout commands - VK_CHECK_RESULT( - vdi->vkFuncs.vkEndCommandBuffer(vdi->cmdBuffer)); + VK_CHECK_RESULT(vdi->vkFuncs.vkEndCommandBuffer(vdi->cmdBuffer)); // Create a fence to make sure that the copies have finished before // continuing - VK_CHECK_RESULT( - vdi->vkFuncs.vkCreateFence(vdi->device, &fenceCreateInfo, - vdi->pAllocator, ©Fence)); + VK_CHECK_RESULT(vdi->vkFuncs.vkCreateFence(vdi->device, &fenceCreateInfo, vdi->pAllocator, ©Fence)); submitInfo.commandBufferCount = 1; submitInfo.pCommandBuffers = &vdi->cmdBuffer; - VK_CHECK_RESULT( - vdi->vkFuncs.vkQueueSubmit(vdi->queue, 1, &submitInfo, copyFence)); + VK_CHECK_RESULT(vdi->vkFuncs.vkQueueSubmit(vdi->queue, 1, &submitInfo, copyFence)); - VK_CHECK_RESULT( - vdi->vkFuncs.vkWaitForFences(vdi->device, 1, ©Fence, - VK_TRUE, DEFAULT_FENCE_TIMEOUT)); + VK_CHECK_RESULT(vdi->vkFuncs.vkWaitForFences(vdi->device, 1, ©Fence, VK_TRUE, DEFAULT_FENCE_TIMEOUT)); vdi->vkFuncs.vkDestroyFence(vdi->device, copyFence, vdi->pAllocator); @@ -1297,16 +1127,11 @@ ktxTexture_VkUploadEx_WithSuballocator(ktxTexture* This, ktxVulkanDeviceInfo* vd else subAllocatorCallbacks->freeMemFuncPtr(stagingAllocId); vdi->vkFuncs.vkDestroyBuffer(vdi->device, stagingBuffer, vdi->pAllocator); - } - else - { + } else { VkImage mappableImage; VkDeviceMemory mappableMemory = VK_NULL_HANDLE; - VkFence nullFence = { VK_NULL_HANDLE }; - VkSubmitInfo submitInfo = { - .sType = VK_STRUCTURE_TYPE_SUBMIT_INFO, - .pNext = NULL - }; + VkFence nullFence = {VK_NULL_HANDLE}; + VkSubmitInfo submitInfo = {.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO, .pNext = NULL}; user_cbdata_linear cbData; PFNKTXITERCB callback; @@ -1326,9 +1151,7 @@ ktxTexture_VkUploadEx_WithSuballocator(ktxTexture* This, ktxVulkanDeviceInfo* vd imageCreateInfo.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; // Load mip map level 0 to linear tiling image - VK_CHECK_RESULT( - vdi->vkFuncs.vkCreateImage(vdi->device, &imageCreateInfo, - vdi->pAllocator, &mappableImage)); + VK_CHECK_RESULT(vdi->vkFuncs.vkCreateImage(vdi->device, &imageCreateInfo, vdi->pAllocator, &mappableImage)); // Get memory requirements for this image // like size and alignment @@ -1338,62 +1161,46 @@ ktxTexture_VkUploadEx_WithSuballocator(ktxTexture* This, ktxVulkanDeviceInfo* vd // Get memory type that can be mapped to host memory memAllocInfo.memoryTypeIndex = ktxVulkanDeviceInfo_getMemoryType( - vdi, - memReqs.memoryTypeBits, - VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT); + vdi, memReqs.memoryTypeBits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT); // Allocate host memory if (!useSuballocator) { - vResult = vdi->vkFuncs.vkAllocateMemory(vdi->device, &memAllocInfo, vdi->pAllocator, - &mappableMemory); + vResult = vdi->vkFuncs.vkAllocateMemory(vdi->device, &memAllocInfo, vdi->pAllocator, &mappableMemory); if (vResult != VK_SUCCESS) { return KTX_OUT_OF_MEMORY; } - VK_CHECK_RESULT( - vdi->vkFuncs.vkBindImageMemory(vdi->device, mappableImage, - mappableMemory, 0)); - } - else { + VK_CHECK_RESULT(vdi->vkFuncs.vkBindImageMemory(vdi->device, mappableImage, mappableMemory, 0)); + } else { uint64_t numPages = 0ull; vkTexture->allocationId = subAllocatorCallbacks->allocMemFuncPtr(&memAllocInfo, &memReqs, &numPages); if (vkTexture->allocationId == 0ull) { return KTX_OUT_OF_MEMORY; } - if (numPages > 1ull) { // Sparse binding of KTX textures is unsupported for the moment + if (numPages > 1ull) { // Sparse binding of KTX textures is unsupported for the moment return KTX_UNSUPPORTED_FEATURE; } - VK_CHECK_RESULT( - subAllocatorCallbacks->bindImageFuncPtr(mappableImage, vkTexture->allocationId)); + VK_CHECK_RESULT(subAllocatorCallbacks->bindImageFuncPtr(mappableImage, vkTexture->allocationId)); } cbData.vkFuncs = vdi->vkFuncs; cbData.destImage = mappableImage; cbData.device = vdi->device; cbData.texture = This; - callback = canUseFasterPath ? - linearTilingCallback : linearTilingPadCallback; + callback = canUseFasterPath ? linearTilingCallback : linearTilingPadCallback; // Map image memory if (!useSuballocator) { + VK_CHECK_RESULT(vdi->vkFuncs.vkMapMemory(vdi->device, mappableMemory, 0, memReqs.size, 0, (void**)&cbData.dest)); + } else { VK_CHECK_RESULT( - vdi->vkFuncs.vkMapMemory(vdi->device, mappableMemory, 0, - memReqs.size, 0, (void**)&cbData.dest)); - } - else { - VK_CHECK_RESULT( - subAllocatorCallbacks->memoryMapFuncPtr(vkTexture->allocationId, 0ull, - &memReqs.size, (void**)&cbData.dest)); + subAllocatorCallbacks->memoryMapFuncPtr(vkTexture->allocationId, 0ull, &memReqs.size, (void**)&cbData.dest)); } // Iterate over images to copy texture data into mapped image memory. if (ktxTexture_isActiveStream(This)) { - kResult = ktxTexture_IterateLoadLevelFaces(This, - callback, - &cbData); + kResult = ktxTexture_IterateLoadLevelFaces(This, callback, &cbData); } else { - kResult = ktxTexture_IterateLevelFaces(This, - callback, - &cbData); + kResult = ktxTexture_IterateLevelFaces(This, callback, &cbData); } // XXX Check for possible errors if (!useSuballocator) @@ -1406,9 +1213,7 @@ ktxTexture_VkUploadEx_WithSuballocator(ktxTexture* This, ktxVulkanDeviceInfo* vd if (!useSuballocator) vkTexture->deviceMemory = mappableMemory; if (This->generateMipmaps) { - generateMipmaps(vkTexture, vdi, - blitFilter, - VK_IMAGE_LAYOUT_PREINITIALIZED); + generateMipmaps(vkTexture, vdi, blitFilter, VK_IMAGE_LAYOUT_PREINITIALIZED); } else { VkImageSubresourceRange subresourceRange; subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; @@ -1417,14 +1222,9 @@ ktxTexture_VkUploadEx_WithSuballocator(ktxTexture* This, ktxVulkanDeviceInfo* vd subresourceRange.baseArrayLayer = 0; subresourceRange.layerCount = numImageLayers; - // Transition image layout to finalLayout. - setImageLayout( - vdi->vkFuncs, - vdi->cmdBuffer, - vkTexture->image, - VK_IMAGE_LAYOUT_PREINITIALIZED, - finalLayout, - subresourceRange); + // Transition image layout to finalLayout. + setImageLayout(vdi->vkFuncs, vdi->cmdBuffer, vkTexture->image, VK_IMAGE_LAYOUT_PREINITIALIZED, finalLayout, + subresourceRange); } // Submit command buffer containing image layout commands @@ -1449,14 +1249,9 @@ ktxTexture_VkUploadEx_WithSuballocator(ktxTexture* This, ktxVulkanDeviceInfo* vd * callbacks. Use that for complete control. */ KTX_error_code -ktxTexture_VkUploadEx(ktxTexture* This, ktxVulkanDeviceInfo* vdi, - ktxVulkanTexture* vkTexture, - VkImageTiling tiling, - VkImageUsageFlags usageFlags, - VkImageLayout finalLayout) -{ - return ktxTexture_VkUploadEx_WithSuballocator(This, vdi, vkTexture, - tiling, usageFlags, finalLayout, NULL); +ktxTexture_VkUploadEx(ktxTexture* This, ktxVulkanDeviceInfo* vdi, ktxVulkanTexture* vkTexture, VkImageTiling tiling, + VkImageUsageFlags usageFlags, VkImageLayout finalLayout) { + return ktxTexture_VkUploadEx_WithSuballocator(This, vdi, vkTexture, tiling, usageFlags, finalLayout, NULL); } /** @@ -1471,12 +1266,8 @@ ktxTexture_VkUploadEx(ktxTexture* This, ktxVulkanDeviceInfo* vdi, * control. */ KTX_error_code -ktxTexture_VkUpload(ktxTexture* texture, ktxVulkanDeviceInfo* vdi, - ktxVulkanTexture *vkTexture) -{ - return ktxTexture_VkUploadEx(ktxTexture(texture), vdi, vkTexture, - VK_IMAGE_TILING_OPTIMAL, - VK_IMAGE_USAGE_SAMPLED_BIT, +ktxTexture_VkUpload(ktxTexture* texture, ktxVulkanDeviceInfo* vdi, ktxVulkanTexture* vkTexture) { + return ktxTexture_VkUploadEx(ktxTexture(texture), vdi, vkTexture, VK_IMAGE_TILING_OPTIMAL, VK_IMAGE_USAGE_SAMPLED_BIT, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); } @@ -1490,15 +1281,10 @@ ktxTexture_VkUpload(ktxTexture* texture, ktxVulkanDeviceInfo* vdi, * @copydetails ktxTexture::ktxTexture_VkUploadEx_WithSuballocator */ KTX_error_code -ktxTexture1_VkUploadEx_WithSuballocator(ktxTexture1* This, ktxVulkanDeviceInfo* vdi, - ktxVulkanTexture* vkTexture, - VkImageTiling tiling, - VkImageUsageFlags usageFlags, - VkImageLayout finalLayout, - ktxVulkanTexture_subAllocatorCallbacks* subAllocatorCallbacks) -{ - return ktxTexture_VkUploadEx_WithSuballocator(ktxTexture(This), vdi, vkTexture, - tiling, usageFlags, finalLayout, +ktxTexture1_VkUploadEx_WithSuballocator(ktxTexture1* This, ktxVulkanDeviceInfo* vdi, ktxVulkanTexture* vkTexture, + VkImageTiling tiling, VkImageUsageFlags usageFlags, VkImageLayout finalLayout, + ktxVulkanTexture_subAllocatorCallbacks* subAllocatorCallbacks) { + return ktxTexture_VkUploadEx_WithSuballocator(ktxTexture(This), vdi, vkTexture, tiling, usageFlags, finalLayout, subAllocatorCallbacks); } @@ -1509,14 +1295,9 @@ ktxTexture1_VkUploadEx_WithSuballocator(ktxTexture1* This, ktxVulkanDeviceInfo* * @copydetails ktxTexture::ktxTexture_VkUploadEx */ KTX_error_code -ktxTexture1_VkUploadEx(ktxTexture1* This, ktxVulkanDeviceInfo* vdi, - ktxVulkanTexture* vkTexture, - VkImageTiling tiling, - VkImageUsageFlags usageFlags, - VkImageLayout finalLayout) -{ - return ktxTexture_VkUploadEx(ktxTexture(This), vdi, vkTexture, - tiling, usageFlags, finalLayout); +ktxTexture1_VkUploadEx(ktxTexture1* This, ktxVulkanDeviceInfo* vdi, ktxVulkanTexture* vkTexture, VkImageTiling tiling, + VkImageUsageFlags usageFlags, VkImageLayout finalLayout) { + return ktxTexture_VkUploadEx(ktxTexture(This), vdi, vkTexture, tiling, usageFlags, finalLayout); } /** @memberof ktxTexture1 @@ -1529,12 +1310,8 @@ ktxTexture1_VkUploadEx(ktxTexture1* This, ktxVulkanDeviceInfo* vdi, * @c VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL. Use that for complete control. */ KTX_error_code -ktxTexture1_VkUpload(ktxTexture1* texture, ktxVulkanDeviceInfo* vdi, - ktxVulkanTexture *vkTexture) -{ - return ktxTexture_VkUploadEx(ktxTexture(texture), vdi, vkTexture, - VK_IMAGE_TILING_OPTIMAL, - VK_IMAGE_USAGE_SAMPLED_BIT, +ktxTexture1_VkUpload(ktxTexture1* texture, ktxVulkanDeviceInfo* vdi, ktxVulkanTexture* vkTexture) { + return ktxTexture_VkUploadEx(ktxTexture(texture), vdi, vkTexture, VK_IMAGE_TILING_OPTIMAL, VK_IMAGE_USAGE_SAMPLED_BIT, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); } @@ -1548,15 +1325,10 @@ ktxTexture1_VkUpload(ktxTexture1* texture, ktxVulkanDeviceInfo* vdi, * @copydetails ktxTexture::ktxTexture_VkUploadEx_WithSuballocator */ KTX_error_code -ktxTexture2_VkUploadEx_WithSuballocator(ktxTexture2* This, ktxVulkanDeviceInfo* vdi, - ktxVulkanTexture* vkTexture, - VkImageTiling tiling, - VkImageUsageFlags usageFlags, - VkImageLayout finalLayout, - ktxVulkanTexture_subAllocatorCallbacks* subAllocatorCallbacks) -{ - return ktxTexture_VkUploadEx_WithSuballocator(ktxTexture(This), vdi, vkTexture, - tiling, usageFlags, finalLayout, +ktxTexture2_VkUploadEx_WithSuballocator(ktxTexture2* This, ktxVulkanDeviceInfo* vdi, ktxVulkanTexture* vkTexture, + VkImageTiling tiling, VkImageUsageFlags usageFlags, VkImageLayout finalLayout, + ktxVulkanTexture_subAllocatorCallbacks* subAllocatorCallbacks) { + return ktxTexture_VkUploadEx_WithSuballocator(ktxTexture(This), vdi, vkTexture, tiling, usageFlags, finalLayout, subAllocatorCallbacks); } @@ -1569,14 +1341,9 @@ ktxTexture2_VkUploadEx_WithSuballocator(ktxTexture2* This, ktxVulkanDeviceInfo* * @copydetails ktxTexture::ktxTexture_VkUploadEx */ KTX_error_code -ktxTexture2_VkUploadEx(ktxTexture2* This, ktxVulkanDeviceInfo* vdi, - ktxVulkanTexture* vkTexture, - VkImageTiling tiling, - VkImageUsageFlags usageFlags, - VkImageLayout finalLayout) -{ - return ktxTexture_VkUploadEx(ktxTexture(This), vdi, vkTexture, - tiling, usageFlags, finalLayout); +ktxTexture2_VkUploadEx(ktxTexture2* This, ktxVulkanDeviceInfo* vdi, ktxVulkanTexture* vkTexture, VkImageTiling tiling, + VkImageUsageFlags usageFlags, VkImageLayout finalLayout) { + return ktxTexture_VkUploadEx(ktxTexture(This), vdi, vkTexture, tiling, usageFlags, finalLayout); } /** @memberof ktxTexture2 @@ -1589,12 +1356,8 @@ ktxTexture2_VkUploadEx(ktxTexture2* This, ktxVulkanDeviceInfo* vdi, * @c VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL. Use that for complete control. */ KTX_error_code -ktxTexture2_VkUpload(ktxTexture2* This, ktxVulkanDeviceInfo* vdi, - ktxVulkanTexture *vkTexture) -{ - return ktxTexture_VkUploadEx(ktxTexture(This), vdi, vkTexture, - VK_IMAGE_TILING_OPTIMAL, - VK_IMAGE_USAGE_SAMPLED_BIT, +ktxTexture2_VkUpload(ktxTexture2* This, ktxVulkanDeviceInfo* vdi, ktxVulkanTexture* vkTexture) { + return ktxTexture_VkUploadEx(ktxTexture(This), vdi, vkTexture, VK_IMAGE_TILING_OPTIMAL, VK_IMAGE_USAGE_SAMPLED_BIT, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); } @@ -1606,14 +1369,12 @@ ktxTexture2_VkUpload(ktxTexture2* This, ktxVulkanDeviceInfo* vdi, * there is no mapping from the GL internalformat and format. */ VkFormat -ktxTexture1_GetVkFormat(ktxTexture1* This) -{ +ktxTexture1_GetVkFormat(ktxTexture1* This) { VkFormat vkFormat; vkFormat = vkGetFormatFromOpenGLInternalFormat(This->glInternalformat); if (vkFormat == VK_FORMAT_UNDEFINED) { - vkFormat = vkGetFormatFromOpenGLFormat(This->glFormat, - This->glType); + vkFormat = vkGetFormatFromOpenGLFormat(This->glFormat, This->glType); } return vkFormat; } @@ -1625,8 +1386,7 @@ ktxTexture1_GetVkFormat(ktxTexture1* This) * @return The VkFormat of the texture object. */ VkFormat -ktxTexture2_GetVkFormat(ktxTexture2* This) -{ +ktxTexture2_GetVkFormat(ktxTexture2* This) { return This->vkFormat; } @@ -1640,8 +1400,7 @@ ktxTexture2_GetVkFormat(ktxTexture2* This) * @sa @ref ktxTexture2::ktxTexture2_GetVkFormat "ktxTexture2_GetVkFormat()" */ VkFormat -ktxTexture_GetVkFormat(ktxTexture* This) -{ +ktxTexture_GetVkFormat(ktxTexture* This) { if (This->classId == ktxTexture2_c) return ktxTexture2_GetVkFormat((ktxTexture2*)This); else @@ -1661,22 +1420,14 @@ ktxTexture_GetVkFormat(ktxTexture* This) * chapter 11.4 "Image Layout" for details. */ static void -setImageLayout( - ktxVulkanFunctions vkFuncs, - VkCommandBuffer cmdBuffer, - VkImage image, - VkImageLayout oldLayout, - VkImageLayout newLayout, - VkImageSubresourceRange subresourceRange) -{ +setImageLayout(ktxVulkanFunctions vkFuncs, VkCommandBuffer cmdBuffer, VkImage image, VkImageLayout oldLayout, + VkImageLayout newLayout, VkImageSubresourceRange subresourceRange) { // Create an image barrier object - VkImageMemoryBarrier imageMemoryBarrier = { - .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, - .pNext = NULL, - // Some default values - .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, - .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED - }; + VkImageMemoryBarrier imageMemoryBarrier = {.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, + .pNext = NULL, + // Some default values + .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, + .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED}; imageMemoryBarrier.oldLayout = oldLayout; imageMemoryBarrier.newLayout = newLayout; @@ -1686,8 +1437,7 @@ setImageLayout( // Source layouts (old) // The source access mask controls actions to be finished on the old // layout before it will be transitioned to the new layout. - switch (oldLayout) - { + switch (oldLayout) { case VK_IMAGE_LAYOUT_UNDEFINED: // Image layout is undefined (or does not matter). // Only valid as initial layout. No flags required. @@ -1710,8 +1460,7 @@ setImageLayout( case VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL: // Image is a depth/stencil attachment. // Make sure any writes to the depth/stencil buffer have finished. - imageMemoryBarrier.srcAccessMask - = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT; + imageMemoryBarrier.srcAccessMask = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT; break; case VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL: @@ -1740,8 +1489,7 @@ setImageLayout( // Target layouts (new) // The destination access mask controls the dependency for the new image // layout. - switch (newLayout) - { + switch (newLayout) { case VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL: // Image will be used as a transfer destination. // Make sure any writes to the image have finished. @@ -1765,17 +1513,14 @@ setImageLayout( case VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL: // Image layout will be used as a depth/stencil attachment. // Make sure any writes to depth/stencil buffer have finished. - imageMemoryBarrier.dstAccessMask - = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT; + imageMemoryBarrier.dstAccessMask = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT; break; case VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL: // Image will be read in a shader (sampler, input attachment). // Make sure any writes to the image have finished. - if (imageMemoryBarrier.srcAccessMask == 0) - { - imageMemoryBarrier.srcAccessMask - = VK_ACCESS_HOST_WRITE_BIT | VK_ACCESS_TRANSFER_WRITE_BIT; + if (imageMemoryBarrier.srcAccessMask == 0) { + imageMemoryBarrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT | VK_ACCESS_TRANSFER_WRITE_BIT; } imageMemoryBarrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; break; @@ -1789,14 +1534,7 @@ setImageLayout( VkPipelineStageFlags destStageFlags = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT; // Add the barrier to the passed command buffer - vkFuncs.vkCmdPipelineBarrier( - cmdBuffer, - srcStageFlags, - destStageFlags, - 0, - 0, NULL, - 0, NULL, - 1, &imageMemoryBarrier); + vkFuncs.vkCmdPipelineBarrier(cmdBuffer, srcStageFlags, destStageFlags, 0, 0, NULL, 0, NULL, 1, &imageMemoryBarrier); } /** @internal @@ -1817,9 +1555,7 @@ setImageLayout( * @param[in] initialLayout the layout of the image on entry to the function. */ static void -generateMipmaps(ktxVulkanTexture* vkTexture, ktxVulkanDeviceInfo* vdi, - VkFilter blitFilter, VkImageLayout initialLayout) -{ +generateMipmaps(ktxVulkanTexture* vkTexture, ktxVulkanDeviceInfo* vdi, VkFilter blitFilter, VkImageLayout initialLayout) { VkImageSubresourceRange subresourceRange; memset(&subresourceRange, 0, sizeof(subresourceRange)); subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; @@ -1829,29 +1565,24 @@ generateMipmaps(ktxVulkanTexture* vkTexture, ktxVulkanDeviceInfo* vdi, subresourceRange.layerCount = vkTexture->layerCount; // Transition base level to SRC_OPTIMAL for blitting. - setImageLayout( - vdi->vkFuncs, - vdi->cmdBuffer, - vkTexture->image, - initialLayout, - VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, - subresourceRange); + setImageLayout(vdi->vkFuncs, vdi->cmdBuffer, vkTexture->image, initialLayout, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, + subresourceRange); // Generate the mip chain // ---------------------- // Blit level n from level n-1. - for (uint32_t i = 1; i < vkTexture->levelCount; i++) - { + for (uint32_t i = 1; i < vkTexture->levelCount; i++) { VkImageBlit imageBlit; memset(&imageBlit, 0, sizeof(imageBlit)); // Source imageBlit.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; imageBlit.srcSubresource.layerCount = vkTexture->layerCount; - imageBlit.srcSubresource.mipLevel = i-1; + imageBlit.srcSubresource.mipLevel = i - 1; imageBlit.srcOffsets[1].x = MAX(1, vkTexture->width >> (i - 1)); imageBlit.srcOffsets[1].y = MAX(1, vkTexture->height >> (i - 1)); - imageBlit.srcOffsets[1].z = MAX(1, vkTexture->depth >> (i - 1));; + imageBlit.srcOffsets[1].z = MAX(1, vkTexture->depth >> (i - 1)); + ; // Destination imageBlit.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; @@ -1870,46 +1601,24 @@ generateMipmaps(ktxVulkanTexture* vkTexture, ktxVulkanDeviceInfo* vdi, mipSubRange.layerCount = vkTexture->layerCount; // Transiton current mip level to transfer dest - setImageLayout( - vdi->vkFuncs, - vdi->cmdBuffer, - vkTexture->image, - VK_IMAGE_LAYOUT_UNDEFINED, - VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, - mipSubRange); + setImageLayout(vdi->vkFuncs, vdi->cmdBuffer, vkTexture->image, VK_IMAGE_LAYOUT_UNDEFINED, + VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, mipSubRange); // Blit from previous level - vdi->vkFuncs.vkCmdBlitImage( - vdi->cmdBuffer, - vkTexture->image, - VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, - vkTexture->image, - VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, - 1, - &imageBlit, - blitFilter); + vdi->vkFuncs.vkCmdBlitImage(vdi->cmdBuffer, vkTexture->image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, vkTexture->image, + VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &imageBlit, blitFilter); // Transiton current mip level to transfer source for read in // next iteration. - setImageLayout( - vdi->vkFuncs, - vdi->cmdBuffer, - vkTexture->image, - VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, - VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, - mipSubRange); + setImageLayout(vdi->vkFuncs, vdi->cmdBuffer, vkTexture->image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, + VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, mipSubRange); } // After the loop, all mip layers are in TRANSFER_SRC layout. // Transition all to final layout. subresourceRange.levelCount = vkTexture->levelCount; - setImageLayout( - vdi->vkFuncs, - vdi->cmdBuffer, - vkTexture->image, - VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, - vkTexture->imageLayout, - subresourceRange); + setImageLayout(vdi->vkFuncs, vdi->cmdBuffer, vkTexture->image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, vkTexture->imageLayout, + subresourceRange); } //====================================================================== @@ -1935,18 +1644,13 @@ generateMipmaps(ktxVulkanTexture* vkTexture, ktxVulkanDeviceInfo* vdi, * supplied subAllocatorCallbacks structure is incomplete. */ ktx_error_code_e -ktxVulkanTexture_Destruct_WithSuballocator(ktxVulkanTexture* vkTexture, VkDevice device, - const VkAllocationCallbacks* pAllocator, - ktxVulkanTexture_subAllocatorCallbacks* subAllocatorCallbacks) -{ +ktxVulkanTexture_Destruct_WithSuballocator(ktxVulkanTexture* vkTexture, VkDevice device, const VkAllocationCallbacks* pAllocator, + ktxVulkanTexture_subAllocatorCallbacks* subAllocatorCallbacks) { ktx_bool_t useSuballocator = false; if (subAllocatorCallbacks) { - if (subAllocatorCallbacks->allocMemFuncPtr && - subAllocatorCallbacks->bindBufferFuncPtr && - subAllocatorCallbacks->bindImageFuncPtr && - subAllocatorCallbacks->memoryMapFuncPtr && - subAllocatorCallbacks->memoryUnmapFuncPtr && - subAllocatorCallbacks->freeMemFuncPtr) + if (subAllocatorCallbacks->allocMemFuncPtr && subAllocatorCallbacks->bindBufferFuncPtr && + subAllocatorCallbacks->bindImageFuncPtr && subAllocatorCallbacks->memoryMapFuncPtr && + subAllocatorCallbacks->memoryUnmapFuncPtr && subAllocatorCallbacks->freeMemFuncPtr) useSuballocator = true; else return KTX_INVALID_VALUE; @@ -1973,11 +1677,8 @@ ktxVulkanTexture_Destruct_WithSuballocator(ktxVulkanTexture* vkTexture, VkDevice * control. */ void -ktxVulkanTexture_Destruct(ktxVulkanTexture* vkTexture, VkDevice device, - const VkAllocationCallbacks* pAllocator) -{ +ktxVulkanTexture_Destruct(ktxVulkanTexture* vkTexture, VkDevice device, const VkAllocationCallbacks* pAllocator) { (void)ktxVulkanTexture_Destruct_WithSuballocator(vkTexture, device, pAllocator, NULL); } - /** @} */ diff --git a/lib/writer1.c b/lib/writer1.c index 8865e5634d..b316c8dec8 100644 --- a/lib/writer1.c +++ b/lib/writer1.c @@ -71,10 +71,8 @@ * created. */ KTX_error_code -ktxTexture1_setImageFromStream(ktxTexture1* This, ktx_uint32_t level, - ktx_uint32_t layer, ktx_uint32_t faceSlice, - ktxStream* src, ktx_size_t srcSize) -{ +ktxTexture1_setImageFromStream(ktxTexture1* This, ktx_uint32_t level, ktx_uint32_t layer, ktx_uint32_t faceSlice, ktxStream* src, + ktx_size_t srcSize) { ktx_uint32_t packedRowBytes, rowBytes, rowPadding, numRows = 0; ktx_size_t packedBytes, unpackedBytes; ktx_size_t imageOffset; @@ -82,11 +80,9 @@ ktxTexture1_setImageFromStream(ktxTexture1* This, ktx_uint32_t level, ktx_uint32_t faceLodPadding; #endif - if (!This || !src) - return KTX_INVALID_VALUE; + if (!This || !src) return KTX_INVALID_VALUE; - if (!This->pData) - return KTX_INVALID_OPERATION; + if (!This->pData) return KTX_INVALID_OPERATION; ktxTexture_GetImageOffset(ktxTexture(This), level, layer, faceSlice, &imageOffset); @@ -108,11 +104,10 @@ ktxTexture1_setImageFromStream(ktxTexture1* This, ktx_uint32_t level, } } - if (srcSize != packedBytes) - return KTX_INVALID_OPERATION; + if (srcSize != packedBytes) return KTX_INVALID_OPERATION; // The above will catch a flagrantly invalid srcSize. This is an // additional check of the internal calculations. - assert (imageOffset + srcSize <= This->dataSize); + assert(imageOffset + srcSize <= This->dataSize); #if (KTX_GL_UNPACK_ALIGNMENT != 4) faceLodPadding = _KTX_PAD4_LEN(faceLodSize); @@ -125,7 +120,7 @@ ktxTexture1_setImageFromStream(ktxTexture1* This, ktx_uint32_t level, /* Copy the rows individually, padding each one */ ktx_uint32_t row; ktx_uint8_t* dst = This->pData + imageOffset; - ktx_uint8_t pad[4] = { 0, 0, 0, 0 }; + ktx_uint8_t pad[4] = {0, 0, 0, 0}; for (row = 0; row < numRows; row++) { ktx_uint32_t rowOffset = rowBytes * row; src->read(src, dst + rowOffset, packedRowBytes); @@ -139,8 +134,7 @@ ktxTexture1_setImageFromStream(ktxTexture1* This, ktx_uint32_t level, * 0 for compressed formats too because they all have multiple-of-4 block * sizes. */ - if (faceLodPadding) - memcpy(This->pData + faceLodSize, pad, faceLodPadding); + if (faceLodPadding) memcpy(This->pData + faceLodSize, pad, faceLodPadding); #endif return KTX_SUCCESS; } @@ -175,18 +169,14 @@ ktxTexture1_setImageFromStream(ktxTexture1* This, ktx_uint32_t level, * created. */ KTX_error_code -ktxTexture1_SetImageFromStdioStream(ktxTexture1* This, ktx_uint32_t level, - ktx_uint32_t layer, ktx_uint32_t faceSlice, - FILE* src, ktx_size_t srcSize) -{ +ktxTexture1_SetImageFromStdioStream(ktxTexture1* This, ktx_uint32_t level, ktx_uint32_t layer, ktx_uint32_t faceSlice, FILE* src, + ktx_size_t srcSize) { ktxStream srcstr; KTX_error_code result; result = ktxFileStream_construct(&srcstr, src, KTX_FALSE); - if (result != KTX_SUCCESS) - return result; - result = ktxTexture1_setImageFromStream(This, level, layer, faceSlice, - &srcstr, srcSize); + if (result != KTX_SUCCESS) return result; + result = ktxTexture1_setImageFromStream(This, level, layer, faceSlice, &srcstr, srcSize); ktxFileStream_destruct(&srcstr); return result; } @@ -223,18 +213,14 @@ ktxTexture1_SetImageFromStdioStream(ktxTexture1* This, ktx_uint32_t level, * created. */ KTX_error_code -ktxTexture1_SetImageFromMemory(ktxTexture1* This, ktx_uint32_t level, - ktx_uint32_t layer, ktx_uint32_t faceSlice, - const ktx_uint8_t* src, ktx_size_t srcSize) -{ +ktxTexture1_SetImageFromMemory(ktxTexture1* This, ktx_uint32_t level, ktx_uint32_t layer, ktx_uint32_t faceSlice, + const ktx_uint8_t* src, ktx_size_t srcSize) { ktxStream srcstr; KTX_error_code result; result = ktxMemStream_construct_ro(&srcstr, src, srcSize); - if (result != KTX_SUCCESS) - return result; - result = ktxTexture1_setImageFromStream(This, level, layer, faceSlice, - &srcstr, srcSize); + if (result != KTX_SUCCESS) return result; + result = ktxTexture1_setImageFromStream(This, level, layer, faceSlice, &srcstr, srcSize); ktxMemStream_destruct(&srcstr); return result; } @@ -261,9 +247,8 @@ ktxTexture1_SetImageFromMemory(ktxTexture1* This, ktx_uint32_t level, * An error occurred while writing the file. */ KTX_error_code -ktxTexture1_WriteToStream(ktxTexture1* This, ktxStream* dststr) -{ - KTX_header header = { .identifier = KTX_IDENTIFIER_REF }; +ktxTexture1_WriteToStream(ktxTexture1* This, ktxStream* dststr) { + KTX_header header = {.identifier = KTX_IDENTIFIER_REF}; KTX_error_code result = KTX_SUCCESS; ktx_uint8_t* pKvd = 0; ktx_uint32_t level, levelOffset; @@ -272,13 +257,11 @@ ktxTexture1_WriteToStream(ktxTexture1* This, ktxStream* dststr) return KTX_INVALID_VALUE; } - if (This->pData == NULL) - return KTX_INVALID_OPERATION; + if (This->pData == NULL) return KTX_INVALID_OPERATION; - if (This->kvDataHead && This->kvData) - return KTX_INVALID_OPERATION; + if (This->kvDataHead && This->kvData) return KTX_INVALID_OPERATION; - //endianess int.. if this comes out reversed, all of the other ints will too. + // endianess int.. if this comes out reversed, all of the other ints will too. header.endianness = KTX_ENDIAN_REF; header.glInternalformat = This->glInternalformat; header.glFormat = This->glFormat; @@ -289,14 +272,13 @@ ktxTexture1_WriteToStream(ktxTexture1* This, ktxStream* dststr) header.pixelHeight = This->numDimensions > 1 ? This->baseHeight : 0; header.pixelDepth = This->numDimensions > 2 ? This->baseDepth : 0; header.numberOfArrayElements = This->isArray ? This->numLayers : 0; - assert (This->isCubemap ? This->numFaces == 6 : This->numFaces == 1); + assert(This->isCubemap ? This->numFaces == 6 : This->numFaces == 1); header.numberOfFaces = This->numFaces; - assert (This->generateMipmaps ? This->numLevels == 1 : This->numLevels >= 1); + assert(This->generateMipmaps ? This->numLevels == 1 : This->numLevels >= 1); header.numberOfMipLevels = This->generateMipmaps ? 0 : This->numLevels; if (This->kvDataHead != NULL) { - ktxHashList_Serialize(&This->kvDataHead, - &header.bytesOfKeyValueData, &pKvd); + ktxHashList_Serialize(&This->kvDataHead, &header.bytesOfKeyValueData, &pKvd); } else if (This->kvData) { pKvd = This->kvData; header.bytesOfKeyValueData = This->kvDataLen; @@ -304,31 +286,25 @@ ktxTexture1_WriteToStream(ktxTexture1* This, ktxStream* dststr) header.bytesOfKeyValueData = 0; } - //write header + // write header result = dststr->write(dststr, &header, sizeof(KTX_header), 1); - if (result != KTX_SUCCESS) - return result; + if (result != KTX_SUCCESS) return result; - //write keyValueData + // write keyValueData if (header.bytesOfKeyValueData != 0) { assert(pKvd != NULL); result = dststr->write(dststr, pKvd, 1, header.bytesOfKeyValueData); - if (This->kvDataHead != NULL) - free(pKvd); - if (result != KTX_SUCCESS) - return result; + if (This->kvDataHead != NULL) free(pKvd); + if (result != KTX_SUCCESS) return result; } /* Write the image data */ - for (level = 0, levelOffset=0; level < This->numLevels; ++level) - { + for (level = 0, levelOffset = 0; level < This->numLevels; ++level) { ktx_uint32_t faceLodSize, layer, levelDepth, numImages; ktx_size_t imageSize; - faceLodSize = (ktx_uint32_t)ktxTexture_doCalcFaceLodSize(ktxTexture(This), - level, - KTX_FORMAT_VERSION_ONE); + faceLodSize = (ktx_uint32_t)ktxTexture_doCalcFaceLodSize(ktxTexture(This), level, KTX_FORMAT_VERSION_ONE); imageSize = ktxTexture_GetImageSize(ktxTexture(This), level); levelDepth = MAX(1, This->baseDepth >> level); if (This->isCubemap && !This->isArray) @@ -337,15 +313,13 @@ ktxTexture1_WriteToStream(ktxTexture1* This, ktxStream* dststr) numImages = This->isCubemap ? This->numFaces : levelDepth; result = dststr->write(dststr, &faceLodSize, sizeof(faceLodSize), 1); - if (result != KTX_SUCCESS) - goto cleanup; + if (result != KTX_SUCCESS) goto cleanup; for (layer = 0; layer < This->numLayers; layer++) { ktx_uint32_t faceSlice; for (faceSlice = 0; faceSlice < numImages; faceSlice++) { - result = dststr->write(dststr, This->pData + levelOffset, - imageSize, 1); + result = dststr->write(dststr, This->pData + levelOffset, imageSize, 1); levelOffset += (ktx_uint32_t)imageSize; } } @@ -377,17 +351,14 @@ ktxTexture1_WriteToStream(ktxTexture1* This, ktxStream* dststr) * An error occurred while writing the file. */ KTX_error_code -ktxTexture1_WriteToStdioStream(ktxTexture1* This, FILE* dstsstr) -{ +ktxTexture1_WriteToStdioStream(ktxTexture1* This, FILE* dstsstr) { ktxStream stream; KTX_error_code result = KTX_SUCCESS; - if (!This) - return KTX_INVALID_VALUE; + if (!This) return KTX_INVALID_VALUE; result = ktxFileStream_construct(&stream, dstsstr, KTX_FALSE); - if (result != KTX_SUCCESS) - return result; + if (result != KTX_SUCCESS) return result; return ktxTexture1_WriteToStream(This, &stream); } @@ -417,13 +388,11 @@ ktxTexture1_WriteToStdioStream(ktxTexture1* This, FILE* dstsstr) * An error occurred while writing the file. */ KTX_error_code -ktxTexture1_WriteToNamedFile(ktxTexture1* This, const char* const dstname) -{ +ktxTexture1_WriteToNamedFile(ktxTexture1* This, const char* const dstname) { KTX_error_code result; FILE* dst; - if (!This) - return KTX_INVALID_VALUE; + if (!This) return KTX_INVALID_VALUE; dst = ktxFOpenUTF8(dstname, "wb"); if (dst) { @@ -464,25 +433,20 @@ ktxTexture1_WriteToNamedFile(ktxTexture1* This, const char* const dstname) * An error occurred while writing the file. */ KTX_error_code -ktxTexture1_WriteToMemory(ktxTexture1* This, - ktx_uint8_t** ppDstBytes, ktx_size_t* pSize) -{ +ktxTexture1_WriteToMemory(ktxTexture1* This, ktx_uint8_t** ppDstBytes, ktx_size_t* pSize) { struct ktxStream dststr; KTX_error_code result; ktx_size_t strSize; - if (!This || !ppDstBytes || !pSize) - return KTX_INVALID_VALUE; + if (!This || !ppDstBytes || !pSize) return KTX_INVALID_VALUE; *ppDstBytes = NULL; result = ktxMemStream_construct(&dststr, KTX_FALSE); - if (result != KTX_SUCCESS) - return result; + if (result != KTX_SUCCESS) return result; result = ktxTexture1_WriteToStream(This, &dststr); - if(result != KTX_SUCCESS) - { + if (result != KTX_SUCCESS) { ktxMemStream_destruct(&dststr); return result; } @@ -496,12 +460,10 @@ ktxTexture1_WriteToMemory(ktxTexture1* This, */ ktxMemStream_destruct(&dststr); return KTX_SUCCESS; - } ktx_uint32_t lcm4(uint32_t a); -KTX_error_code appendLibId(ktxHashList* head, - ktxHashListEntry* writerEntry); +KTX_error_code appendLibId(ktxHashList* head, ktxHashListEntry* writerEntry); /** * @memberof ktxTexture1 @@ -529,9 +491,8 @@ KTX_error_code appendLibId(ktxHashList* head, * An error occurred while writing the file. */ KTX_error_code -ktxTexture1_WriteKTX2ToStream(ktxTexture1* This, ktxStream* dststr) -{ - KTX_header2 header = { .identifier = KTX2_IDENTIFIER_REF }; +ktxTexture1_WriteKTX2ToStream(ktxTexture1* This, ktxStream* dststr) { + KTX_header2 header = {.identifier = KTX2_IDENTIFIER_REF}; KTX_error_code result; ktx_uint32_t kvdLen; ktx_uint8_t* pKvd; @@ -545,11 +506,9 @@ ktxTexture1_WriteKTX2ToStream(ktxTexture1* This, ktxStream* dststr) return KTX_INVALID_VALUE; } - if (This->pData == NULL) - return KTX_INVALID_OPERATION; + if (This->pData == NULL) return KTX_INVALID_OPERATION; - header.vkFormat - = vkGetFormatFromOpenGLInternalFormat(This->glInternalformat); + header.vkFormat = vkGetFormatFromOpenGLInternalFormat(This->glInternalformat); // The above function does not return any formats in the prohibited list. if (header.vkFormat == VK_FORMAT_UNDEFINED) { // XXX TODO. Handle ASTC HDR & 3D. @@ -560,19 +519,18 @@ ktxTexture1_WriteKTX2ToStream(ktxTexture1* This, ktxStream* dststr) header.pixelHeight = This->numDimensions > 1 ? This->baseHeight : 0; header.pixelDepth = This->numDimensions > 2 ? This->baseDepth : 0; header.layerCount = This->isArray ? This->numLayers : 0; - assert (This->isCubemap ? This->numFaces == 6 : This->numFaces == 1); + assert(This->isCubemap ? This->numFaces == 6 : This->numFaces == 1); header.faceCount = This->numFaces; - assert (This->generateMipmaps? This->numLevels == 1 : This->numLevels >= 1); + assert(This->generateMipmaps ? This->numLevels == 1 : This->numLevels >= 1); header.levelCount = This->generateMipmaps ? 0 : This->numLevels; levelIndexSize = sizeof(ktxLevelIndexEntry) * This->numLevels; - levelIndex = (ktxLevelIndexEntry*) malloc(levelIndexSize); + levelIndex = (ktxLevelIndexEntry*)malloc(levelIndexSize); offset = sizeof(header) + levelIndexSize; ktx_uint32_t* dfd = vk2dfd(header.vkFormat); - if (!dfd) - return KTX_UNSUPPORTED_TEXTURE_TYPE; + if (!dfd) return KTX_UNSUPPORTED_TEXTURE_TYPE; header.dataFormatDescriptor.byteOffset = offset; header.dataFormatDescriptor.byteLength = *dfd; @@ -596,8 +554,7 @@ ktxTexture1_WriteKTX2ToStream(ktxTexture1* This, ktxStream* dststr) } } - result = ktxHashList_FindEntry(&This->kvDataHead, KTX_ORIENTATION_KEY, - &pEntry); + result = ktxHashList_FindEntry(&This->kvDataHead, KTX_ORIENTATION_KEY, &pEntry); // Rewrite the orientation value in the KTX2 form. if (result == KTX_SUCCESS) { unsigned int count; @@ -605,12 +562,8 @@ ktxTexture1_WriteKTX2ToStream(ktxTexture1* This, ktxStream* dststr) ktx_uint32_t orientationLen; char newOrient[4] = {0, 0, 0, 0}; - result = ktxHashListEntry_GetValue(pEntry, - &orientationLen, (void**)&orientation); - count = sscanf(orientation, "S=%c,T=%c,R=%c", - &newOrient[0], - &newOrient[1], - &newOrient[2]); + result = ktxHashListEntry_GetValue(pEntry, &orientationLen, (void**)&orientation); + count = sscanf(orientation, "S=%c,T=%c,R=%c", &newOrient[0], &newOrient[1], &newOrient[2]); if (count < This->numDimensions) { // There needs to be an entry for each dimension of the texture. @@ -624,18 +577,15 @@ ktxTexture1_WriteKTX2ToStream(ktxTexture1* This, ktxStream* dststr) } ktxHashList_DeleteEntry(&This->kvDataHead, pEntry); - ktxHashList_AddKVPair(&This->kvDataHead, KTX_ORIENTATION_KEY, - count+1, newOrient); + ktxHashList_AddKVPair(&This->kvDataHead, KTX_ORIENTATION_KEY, count + 1, newOrient); } pEntry = NULL; // See comment at valid metadata check at line 582. - result = ktxHashList_FindEntry(&This->kvDataHead, KTX_WRITER_KEY, - &pEntry); + result = ktxHashList_FindEntry(&This->kvDataHead, KTX_WRITER_KEY, &pEntry); result = appendLibId(&This->kvDataHead, pEntry); - if (result != KTX_SUCCESS) - goto cleanup; + if (result != KTX_SUCCESS) goto cleanup; - ktxHashList_Sort(&This->kvDataHead); // KTX2 requires sorted metadata. + ktxHashList_Sort(&This->kvDataHead); // KTX2 requires sorted metadata. ktxHashList_Serialize(&This->kvDataHead, &kvdLen, &pKvd); header.keyValueData.byteOffset = kvdLen != 0 ? offset : 0; header.keyValueData.byteLength = kvdLen; @@ -644,15 +594,12 @@ ktxTexture1_WriteKTX2ToStream(ktxTexture1* This, ktxStream* dststr) header.supercompressionGlobalData.byteOffset = 0; header.supercompressionGlobalData.byteLength = 0; - requiredLevelAlignment - = lcm4(This->_protected->_formatSize.blockSizeInBits / 8); + requiredLevelAlignment = lcm4(This->_protected->_formatSize.blockSizeInBits / 8); initialLevelPadLen = _KTX_PADN_LEN(requiredLevelAlignment, offset); offset += initialLevelPadLen; for (ktx_int32_t level = This->numLevels - 1; level >= 0; level--) { - ktx_size_t levelSize = - ktxTexture_calcLevelSize(ktxTexture(This), level, - KTX_FORMAT_VERSION_TWO); + ktx_size_t levelSize = ktxTexture_calcLevelSize(ktxTexture(This), level, KTX_FORMAT_VERSION_TWO); levelIndex[level].uncompressedByteLength = levelSize; levelIndex[level].byteLength = levelSize; @@ -662,43 +609,39 @@ ktxTexture1_WriteKTX2ToStream(ktxTexture1* This, ktxStream* dststr) // write header and indices result = dststr->write(dststr, &header, sizeof(header), 1); - if (result != KTX_SUCCESS) - return result; + if (result != KTX_SUCCESS) return result; // write level index result = dststr->write(dststr, levelIndex, levelIndexSize, 1); - if (result != KTX_SUCCESS) - return result; + if (result != KTX_SUCCESS) return result; - // write data format descriptor - result = dststr->write(dststr, dfd, 1, *dfd); + // write data format descriptor + result = dststr->write(dststr, dfd, 1, *dfd); - // write keyValueData + // write keyValueData if (kvdLen != 0) { assert(pKvd != NULL); result = dststr->write(dststr, pKvd, 1, kvdLen); free(pKvd); if (result != KTX_SUCCESS) { - return result; + return result; } } - char padding[32] = { 0 }; + char padding[32] = {0}; // write supercompressionGlobalData & sgdPadding if (initialLevelPadLen) { result = dststr->write(dststr, padding, 1, initialLevelPadLen); if (result != KTX_SUCCESS) { - return result; + return result; } } // Write the image data - for (ktx_int32_t level = This->numLevels - 1; - level >= 0 && result == KTX_SUCCESS; --level) - { - //ktx_uint64_t faceLodSize; + for (ktx_int32_t level = This->numLevels - 1; level >= 0 && result == KTX_SUCCESS; --level) { + // ktx_uint64_t faceLodSize; ktx_uint32_t layer, levelDepth, numImages; ktx_uint32_t srcLevelOffset, srcOffset; ktx_size_t imageSize, dstLevelSize = 0; @@ -706,8 +649,7 @@ ktxTexture1_WriteKTX2ToStream(ktxTexture1* This, ktxStream* dststr) #if defined(DEBUG) || DUMP_IMAGE ktx_size_t pos; #endif - imageSize = ktxTexture_calcImageSize(ktxTexture(This), level, - KTX_FORMAT_VERSION_TWO); + imageSize = ktxTexture_calcImageSize(ktxTexture(This), level, KTX_FORMAT_VERSION_TWO); #if defined(DEBUG) result = dststr->getpos(dststr, (ktx_off_t*)&pos); // Could fail if stdout is a pipe @@ -723,14 +665,11 @@ ktxTexture1_WriteKTX2ToStream(ktxTexture1* This, ktxStream* dststr) else numImages = This->isCubemap ? This->numFaces : levelDepth; - ktx_uint32_t numRows = 0, rowBytes = 0, rowPadding = 0; + ktx_uint32_t numRows = 0, rowBytes = 0, rowPadding = 0; if (!This->isCompressed) { - ktxTexture_rowInfo(ktxTexture(This), level, &numRows, &rowBytes, - &rowPadding); + ktxTexture_rowInfo(ktxTexture(This), level, &numRows, &rowBytes, &rowPadding); } - srcLevelOffset = (ktx_uint32_t)ktxTexture_calcLevelOffset( - ktxTexture(This), - level); + srcLevelOffset = (ktx_uint32_t)ktxTexture_calcLevelOffset(ktxTexture(This), level); srcOffset = srcLevelOffset; for (layer = 0; layer < This->numLayers; layer++) { ktx_uint32_t faceSlice; @@ -738,23 +677,20 @@ ktxTexture1_WriteKTX2ToStream(ktxTexture1* This, ktxStream* dststr) for (faceSlice = 0; faceSlice < numImages; faceSlice++) { #if DUMP_IMAGE dststr->getsize(dststr, &pos); - fprintf(stdout, "Writing level %d, layer %d, faceSlice %d to offset %#zx\n", - level, layer, faceSlice, pos); + fprintf(stdout, "Writing level %d, layer %d, faceSlice %d to offset %#zx\n", level, layer, faceSlice, pos); #endif if (rowPadding == 0) { #if DUMP_IMAGE - if (!This->isCompressed) - for (uint32_t y = 0; y < (This->baseHeight >> level); y++) { - for (uint32_t x = 0; x < rowBytes; x++) { - fprintf(stdout, "%#x, ", - *(This->pData + srcOffset + y * rowBytes + x)); + if (!This->isCompressed) + for (uint32_t y = 0; y < (This->baseHeight >> level); y++) { + for (uint32_t x = 0; x < rowBytes; x++) { + fprintf(stdout, "%#x, ", *(This->pData + srcOffset + y * rowBytes + x)); + } + fprintf(stdout, "\n"); } - fprintf(stdout, "\n"); - } #endif // Write entire image. - result = dststr->write(dststr, This->pData + srcOffset, - imageSize, 1); + result = dststr->write(dststr, This->pData + srcOffset, imageSize, 1); dstLevelSize += imageSize; } else { /* Copy the rows individually, removing padding. */ @@ -764,11 +700,9 @@ ktxTexture1_WriteKTX2ToStream(ktxTexture1* This, ktxStream* dststr) for (row = 0; row < numRows; row++) { ktx_uint32_t rowOffset = rowBytes * row; #if DUMP_IMAGE - for (uint32_t i = 0; i < packedRowBytes; i++) - fprintf(stdout, "%#x, ", *(src + rowOffset + i)); + for (uint32_t i = 0; i < packedRowBytes; i++) fprintf(stdout, "%#x, ", *(src + rowOffset + i)); #endif - result = dststr->write(dststr, src + rowOffset, - packedRowBytes, 1); + result = dststr->write(dststr, src + rowOffset, packedRowBytes, 1); dstLevelSize += packedRowBytes; } } @@ -779,10 +713,8 @@ ktxTexture1_WriteKTX2ToStream(ktxTexture1* This, ktxStream* dststr) } } if (result == KTX_SUCCESS && level != 0) { - uint32_t levelPadLen = _KTX_PADN_LEN(requiredLevelAlignment, - dstLevelSize); - if (levelPadLen) - result = dststr->write(dststr, padding, 1, levelPadLen); + uint32_t levelPadLen = _KTX_PADN_LEN(requiredLevelAlignment, dstLevelSize); + if (levelPadLen) result = dststr->write(dststr, padding, 1, levelPadLen); } } @@ -825,17 +757,14 @@ ktxTexture1_WriteKTX2ToStream(ktxTexture1* This, ktxStream* dststr) * An error occurred while writing the file. */ KTX_error_code -ktxTexture1_WriteKTX2ToStdioStream(ktxTexture1* This, FILE* dstsstr) -{ +ktxTexture1_WriteKTX2ToStdioStream(ktxTexture1* This, FILE* dstsstr) { ktxStream stream; KTX_error_code result = KTX_SUCCESS; - if (!This) - return KTX_INVALID_VALUE; + if (!This) return KTX_INVALID_VALUE; result = ktxFileStream_construct(&stream, dstsstr, KTX_FALSE); - if (result != KTX_SUCCESS) - return result; + if (result != KTX_SUCCESS) return result; return ktxTexture1_WriteKTX2ToStream(This, &stream); } @@ -876,13 +805,11 @@ ktxTexture1_WriteKTX2ToStdioStream(ktxTexture1* This, FILE* dstsstr) * An error occurred while writing the file. */ KTX_error_code -ktxTexture1_WriteKTX2ToNamedFile(ktxTexture1* This, const char* const dstname) -{ +ktxTexture1_WriteKTX2ToNamedFile(ktxTexture1* This, const char* const dstname) { KTX_error_code result; FILE* dst; - if (!This) - return KTX_INVALID_VALUE; + if (!This) return KTX_INVALID_VALUE; dst = ktxFOpenUTF8(dstname, "wb"); if (dst) { @@ -934,25 +861,20 @@ ktxTexture1_WriteKTX2ToNamedFile(ktxTexture1* This, const char* const dstname) * An error occurred while writing the file. */ KTX_error_code -ktxTexture1_WriteKTX2ToMemory(ktxTexture1* This, - ktx_uint8_t** ppDstBytes, ktx_size_t* pSize) -{ +ktxTexture1_WriteKTX2ToMemory(ktxTexture1* This, ktx_uint8_t** ppDstBytes, ktx_size_t* pSize) { struct ktxStream dststr; KTX_error_code result; ktx_size_t strSize; - if (!This || !ppDstBytes || !pSize) - return KTX_INVALID_VALUE; + if (!This || !ppDstBytes || !pSize) return KTX_INVALID_VALUE; *ppDstBytes = NULL; result = ktxMemStream_construct(&dststr, KTX_FALSE); - if (result != KTX_SUCCESS) - return result; + if (result != KTX_SUCCESS) return result; result = ktxTexture1_WriteKTX2ToStream(This, &dststr); - if(result != KTX_SUCCESS) - { + if (result != KTX_SUCCESS) { ktxMemStream_destruct(&dststr); return result; } @@ -966,8 +888,6 @@ ktxTexture1_WriteKTX2ToMemory(ktxTexture1* This, */ ktxMemStream_destruct(&dststr); return KTX_SUCCESS; - } /** @} */ - diff --git a/lib/writer2.c b/lib/writer2.c index 12ec3d4673..ffcd6ebf19 100644 --- a/lib/writer2.c +++ b/lib/writer2.c @@ -72,20 +72,15 @@ * first character of the first occurrence of @p needle. */ static char* -strnstr(const char *haystack, const char *needle, size_t len) -{ +strnstr(const char* haystack, const char* needle, size_t len) { size_t i; size_t needleLen; needleLen = strnlen(needle, len); - if (needleLen == 0) - return (char *)haystack; - - for (i = 0; i <= len - needleLen; i++) - { - if (haystack[0] == needle[0] - && strncmp(haystack, needle, needleLen) == 0) - return (char *)haystack; + if (needleLen == 0) return (char*)haystack; + + for (i = 0; i <= len - needleLen; i++) { + if (haystack[0] == needle[0] && strncmp(haystack, needle, needleLen) == 0) return (char*)haystack; haystack++; } return NULL; @@ -108,8 +103,7 @@ strnstr(const char *haystack, const char *needle, size_t len) * maximum allowed. */ KTX_error_code -appendLibId(ktxHashList* head, ktxHashListEntry* writerEntry) -{ +appendLibId(ktxHashList* head, ktxHashListEntry* writerEntry) { KTX_error_code result; const char* id; const char* libVer; @@ -135,11 +129,9 @@ appendLibId(ktxHashList* head, ktxHashListEntry* writerEntry) // overwrite so no need for +1 after strlen. libIdLen = sizeof(libIdIntro) + (ktx_uint32_t)strlen(libVer); char* libId = malloc(libIdLen); - if (!libId) - return KTX_OUT_OF_MEMORY; + if (!libId) return KTX_OUT_OF_MEMORY; strncpy(libId, libIdIntro, libIdLen); - strncpy(&libId[sizeof(libIdIntro)-1], libVer, - libIdLen-(sizeof(libIdIntro)-1)); + strncpy(&libId[sizeof(libIdIntro) - 1], libVer, libIdLen - (sizeof(libIdIntro) - 1)); if (strnstr(id, libId, idLen) != NULL) { // This lib id is already in the writer value. @@ -150,23 +142,20 @@ appendLibId(ktxHashList* head, ktxHashListEntry* writerEntry) if (libVerPos != NULL) { // There is a libktx version but not the current version. idLen = libVerPos - id; - } else if (id[idLen-1] == '\0') { + } else if (id[idLen - 1] == '\0') { idLen--; } size_t fullIdLen = idLen + strlen(libId) + 1; - if (fullIdLen > UINT_MAX) - return KTX_INVALID_OPERATION; + if (fullIdLen > UINT_MAX) return KTX_INVALID_OPERATION; char* fullId = malloc(fullIdLen); - if (!fullId) - return KTX_OUT_OF_MEMORY; + if (!fullId) return KTX_OUT_OF_MEMORY; strncpy(fullId, id, idLen); strncpy(&fullId[idLen], libId, libIdLen); - assert(fullId[fullIdLen-1] == '\0'); + assert(fullId[fullIdLen - 1] == '\0'); ktxHashList_DeleteEntry(head, writerEntry); - result = ktxHashList_AddKVPair(head, KTX_WRITER_KEY, - (ktx_uint32_t)fullIdLen, fullId); + result = ktxHashList_AddKVPair(head, KTX_WRITER_KEY, (ktx_uint32_t)fullIdLen, fullId); free(libId); free(fullId); return result; @@ -195,19 +184,15 @@ appendLibId(ktxHashList* head, ktxHashListEntry* writerEntry) * created. */ KTX_error_code -ktxTexture2_setImageFromStream(ktxTexture2* This, ktx_uint32_t level, - ktx_uint32_t layer, ktx_uint32_t faceSlice, - ktxStream* src, ktx_size_t srcSize) -{ +ktxTexture2_setImageFromStream(ktxTexture2* This, ktx_uint32_t level, ktx_uint32_t layer, ktx_uint32_t faceSlice, ktxStream* src, + ktx_size_t srcSize) { ktx_size_t imageByteLength; ktx_size_t imageByteOffset; ktx_error_code_e result; - if (!This || !src) - return KTX_INVALID_VALUE; + if (!This || !src) return KTX_INVALID_VALUE; - if (!This->pData) - return KTX_INVALID_OPERATION; + if (!This->pData) return KTX_INVALID_OPERATION; if (faceSlice == KTX_FACESLICE_WHOLE_LEVEL) { result = ktxTexture_GetImageOffset(ktxTexture(This), level, layer, 0, &imageByteOffset); @@ -223,11 +208,10 @@ ktxTexture2_setImageFromStream(ktxTexture2* This, ktx_uint32_t level, imageByteLength = ktxTexture_GetImageSize(ktxTexture(This), level); } - if (srcSize != imageByteLength) - return KTX_INVALID_OPERATION; + if (srcSize != imageByteLength) return KTX_INVALID_OPERATION; // The above will catch a flagrantly invalid srcSize. This is an // additional check of the internal calculations. - assert (imageByteOffset + srcSize <= This->dataSize); + assert(imageByteOffset + srcSize <= This->dataSize); /* Can copy whole image at once */ src->read(src, This->pData + imageByteOffset, srcSize); @@ -264,18 +248,14 @@ ktxTexture2_setImageFromStream(ktxTexture2* This, ktx_uint32_t level, * created. */ KTX_error_code -ktxTexture2_SetImageFromStdioStream(ktxTexture2* This, ktx_uint32_t level, - ktx_uint32_t layer, ktx_uint32_t faceSlice, - FILE* src, ktx_size_t srcSize) -{ +ktxTexture2_SetImageFromStdioStream(ktxTexture2* This, ktx_uint32_t level, ktx_uint32_t layer, ktx_uint32_t faceSlice, FILE* src, + ktx_size_t srcSize) { ktxStream srcstr; KTX_error_code result; result = ktxFileStream_construct(&srcstr, src, KTX_FALSE); - if (result != KTX_SUCCESS) - return result; - result = ktxTexture2_setImageFromStream(This, level, layer, faceSlice, - &srcstr, srcSize); + if (result != KTX_SUCCESS) return result; + result = ktxTexture2_setImageFromStream(This, level, layer, faceSlice, &srcstr, srcSize); ktxFileStream_destruct(&srcstr); return result; } @@ -310,18 +290,14 @@ ktxTexture2_SetImageFromStdioStream(ktxTexture2* This, ktx_uint32_t level, * created. */ KTX_error_code -ktxTexture2_SetImageFromMemory(ktxTexture2* This, ktx_uint32_t level, - ktx_uint32_t layer, ktx_uint32_t faceSlice, - const ktx_uint8_t* src, ktx_size_t srcSize) -{ +ktxTexture2_SetImageFromMemory(ktxTexture2* This, ktx_uint32_t level, ktx_uint32_t layer, ktx_uint32_t faceSlice, + const ktx_uint8_t* src, ktx_size_t srcSize) { ktxStream srcstr; KTX_error_code result; result = ktxMemStream_construct_ro(&srcstr, src, srcSize); - if (result != KTX_SUCCESS) - return result; - result = ktxTexture2_setImageFromStream(This, level, layer, faceSlice, - &srcstr, srcSize); + if (result != KTX_SUCCESS) return result; + result = ktxTexture2_setImageFromStream(This, level, layer, faceSlice, &srcstr, srcSize); ktxMemStream_destruct(&srcstr); return result; } @@ -357,10 +333,9 @@ ktx_bool_t __disableWriterMetadata__ = KTX_FALSE; * An error occurred while writing the file. */ KTX_error_code -ktxTexture2_WriteToStream(ktxTexture2* This, ktxStream* dststr) -{ +ktxTexture2_WriteToStream(ktxTexture2* This, ktxStream* dststr) { DECLARE_PRIVATE(ktxTexture2); - KTX_header2 header = { .identifier = KTX2_IDENTIFIER_REF }; + KTX_header2 header = {.identifier = KTX2_IDENTIFIER_REF}; KTX_error_code result; ktx_uint32_t kvdLen; ktx_uint8_t* pKvd; @@ -374,8 +349,7 @@ ktxTexture2_WriteToStream(ktxTexture2* This, ktxStream* dststr) return KTX_INVALID_VALUE; } - if (This->pData == NULL) - return KTX_INVALID_OPERATION; + if (This->pData == NULL) return KTX_INVALID_OPERATION; header.vkFormat = This->vkFormat; header.typeSize = This->_protected->_typeSize; @@ -383,9 +357,9 @@ ktxTexture2_WriteToStream(ktxTexture2* This, ktxStream* dststr) header.pixelHeight = This->numDimensions > 1 ? This->baseHeight : 0; header.pixelDepth = This->numDimensions > 2 ? This->baseDepth : 0; header.layerCount = This->isArray ? This->numLayers : 0; - assert (This->isCubemap ? This->numFaces == 6 : This->numFaces == 1); + assert(This->isCubemap ? This->numFaces == 6 : This->numFaces == 1); header.faceCount = This->numFaces; - assert (This->generateMipmaps? This->numLevels == 1 : This->numLevels >= 1); + assert(This->generateMipmaps ? This->numLevels == 1 : This->numLevels >= 1); header.levelCount = This->generateMipmaps ? 0 : This->numLevels; header.supercompressionScheme = This->supercompressionScheme; @@ -406,27 +380,15 @@ ktxTexture2_WriteToStream(ktxTexture2* This, ktxStream* dststr) ktxHashListEntry_GetKey(pEntry, &keyLen, &key); if (strncasecmp(key, "KTX", 3) == 0) { ktx_uint32_t i; - const char* knownKeys[] = { - "KTXcubemapIncomplete", - "KTXorientation", - "KTXglFormat", - "KTXdxgiFormat__", - "KTXmetalPixelFormat", - "KTXswizzle", - "KTXwriter", - "KTXwriterScParams", - "KTXastcDecodeMode", - "KTXanimData" - }; - if (strncmp(key, "ktx", 3) == 0) - return KTX_INVALID_OPERATION; + const char* knownKeys[] = {"KTXcubemapIncomplete", "KTXorientation", "KTXglFormat", "KTXdxgiFormat__", + "KTXmetalPixelFormat", "KTXswizzle", "KTXwriter", "KTXwriterScParams", + "KTXastcDecodeMode", "KTXanimData"}; + if (strncmp(key, "ktx", 3) == 0) return KTX_INVALID_OPERATION; // Check for unrecognized KTX keys. - for (i = 0; i < sizeof(knownKeys)/sizeof(char*); i++) { - if (strcmp(key, knownKeys[i]) == 0) - break; + for (i = 0; i < sizeof(knownKeys) / sizeof(char*); i++) { + if (strcmp(key, knownKeys[i]) == 0) break; } - if (i == sizeof(knownKeys)/sizeof(char*)) - return KTX_INVALID_OPERATION; + if (i == sizeof(knownKeys) / sizeof(char*)) return KTX_INVALID_OPERATION; } } @@ -434,16 +396,14 @@ ktxTexture2_WriteToStream(ktxTexture2* This, ktxStream* dststr) if (!__disableWriterMetadata__) { #endif pEntry = NULL; - result = ktxHashList_FindEntry(&This->kvDataHead, KTX_WRITER_KEY, - &pEntry); + result = ktxHashList_FindEntry(&This->kvDataHead, KTX_WRITER_KEY, &pEntry); result = appendLibId(&This->kvDataHead, pEntry); - if (result != KTX_SUCCESS) - return result; + if (result != KTX_SUCCESS) return result; #if defined(TestNoMetadata) } #endif - ktxHashList_Sort(&This->kvDataHead); // KTX2 requires sorted metadata. + ktxHashList_Sort(&This->kvDataHead); // KTX2 requires sorted metadata. ktxHashList_Serialize(&This->kvDataHead, &kvdLen, &pKvd); header.keyValueData.byteOffset = kvdLen != 0 ? (uint32_t)baseOffset : 0; header.keyValueData.byteLength = kvdLen; @@ -459,58 +419,51 @@ ktxTexture2_WriteToStream(ktxTexture2* This, ktxStream* dststr) header.supercompressionGlobalData.byteLength = sgdLen; baseOffset += sgdLen; - initialLevelPadLen = _KTX_PADN_LEN(This->_private->_requiredLevelAlignment, - baseOffset); + initialLevelPadLen = _KTX_PADN_LEN(This->_private->_requiredLevelAlignment, baseOffset); baseOffset += initialLevelPadLen; // write header and indices result = dststr->write(dststr, &header, sizeof(header), 1); - if (result != KTX_SUCCESS) - return result; + if (result != KTX_SUCCESS) return result; // Create a copy of the level index with file-adjusted offsets and write it. - ktxLevelIndexEntry* levelIndex - = (ktxLevelIndexEntry*)malloc(levelIndexSize); - if (!levelIndex) - return KTX_OUT_OF_MEMORY; + ktxLevelIndexEntry* levelIndex = (ktxLevelIndexEntry*)malloc(levelIndexSize); + if (!levelIndex) return KTX_OUT_OF_MEMORY; for (ktx_uint32_t level = 0; level < This->numLevels; level++) { levelIndex[level].byteLength = private->_levelIndex[level].byteLength; - levelIndex[level].uncompressedByteLength - = private->_levelIndex[level].uncompressedByteLength; + levelIndex[level].uncompressedByteLength = private->_levelIndex[level].uncompressedByteLength; levelIndex[level].byteOffset = private->_levelIndex[level].byteOffset; levelIndex[level].byteOffset += baseOffset; } result = dststr->write(dststr, levelIndex, levelIndexSize, 1); free(levelIndex); - if (result != KTX_SUCCESS) - return result; + if (result != KTX_SUCCESS) return result; - // write data format descriptor - result = dststr->write(dststr, This->pDfd, 1, *This->pDfd); + // write data format descriptor + result = dststr->write(dststr, This->pDfd, 1, *This->pDfd); - // write keyValueData + // write keyValueData if (kvdLen != 0) { assert(pKvd != NULL); result = dststr->write(dststr, pKvd, 1, kvdLen); free(pKvd); if (result != KTX_SUCCESS) { - return result; + return result; } } - char padding[32] = { 0 }; + char padding[32] = {0}; // write supercompressionGlobalData & sgdPadding if (private->_sgdByteLength != 0) { if (align8PadLen) { result = dststr->write(dststr, padding, 1, align8PadLen); if (result != KTX_SUCCESS) { - return result; + return result; } } - result = dststr->write(dststr, private->_supercompressionGlobalData, - 1, private->_sgdByteLength); + result = dststr->write(dststr, private->_supercompressionGlobalData, 1, private->_sgdByteLength); if (result != KTX_SUCCESS) { return result; } @@ -519,13 +472,12 @@ ktxTexture2_WriteToStream(ktxTexture2* This, ktxStream* dststr) if (initialLevelPadLen) { result = dststr->write(dststr, padding, 1, initialLevelPadLen); if (result != KTX_SUCCESS) { - return result; + return result; } } // write the image data - for (ktx_int32_t level = This->numLevels-1; level >= 0 && result == KTX_SUCCESS; --level) - { + for (ktx_int32_t level = This->numLevels - 1; level >= 0 && result == KTX_SUCCESS; --level) { ktx_uint64_t srcLevelOffset, levelSize; #define DUMP_IMAGE 0 #if defined(DEBUG) || DUMP_IMAGE @@ -550,12 +502,10 @@ ktxTexture2_WriteToStream(ktxTexture2* This, ktxStream* dststr) ktx_uint32_t faceSlice; for (faceSlice = 0; faceSlice < numImages; faceSlice++) { dststr->getsize(dststr, &pos); - fprintf(stdout, "Writing level %d, layer %d, faceSlice %d to baseOffset %#zx\n", - level, layer, faceSlice, pos); + fprintf(stdout, "Writing level %d, layer %d, faceSlice %d to baseOffset %#zx\n", level, layer, faceSlice, pos); for (uint32_t y = 0; y < (This->baseHeight >> level); y++) { for (uint32_t x = 0; x < rowBytes; x++) { - fprintf(stdout, "%#x, ", - *(This->pData + srcOffset + y * rowBytes + x)); + fprintf(stdout, "%#x, ", *(This->pData + srcOffset + y * rowBytes + x)); } fprintf(stdout, "\n"); } @@ -565,14 +515,10 @@ ktxTexture2_WriteToStream(ktxTexture2* This, ktxStream* dststr) fprintf(stdout, "\n"); #endif // Write entire level. - result = dststr->write(dststr, This->pData + srcLevelOffset, - levelSize, 1); - if (result == KTX_SUCCESS && level > 0) { // No padding at end. - ktx_uint32_t levelPadLen - = _KTX_PADN_LEN(This->_private->_requiredLevelAlignment, - levelSize); - if (levelPadLen != 0) - result = dststr->write(dststr, padding, 1, levelPadLen); + result = dststr->write(dststr, This->pData + srcLevelOffset, levelSize, 1); + if (result == KTX_SUCCESS && level > 0) { // No padding at end. + ktx_uint32_t levelPadLen = _KTX_PADN_LEN(This->_private->_requiredLevelAlignment, levelSize); + if (levelPadLen != 0) result = dststr->write(dststr, padding, 1, levelPadLen); } } @@ -612,17 +558,14 @@ ktxTexture2_WriteToStream(ktxTexture2* This, ktxStream* dststr) * An error occurred while writing the file. */ KTX_error_code -ktxTexture2_WriteToStdioStream(ktxTexture2* This, FILE* dstsstr) -{ +ktxTexture2_WriteToStdioStream(ktxTexture2* This, FILE* dstsstr) { ktxStream stream; KTX_error_code result = KTX_SUCCESS; - if (!This) - return KTX_INVALID_VALUE; + if (!This) return KTX_INVALID_VALUE; result = ktxFileStream_construct(&stream, dstsstr, KTX_FALSE); - if (result != KTX_SUCCESS) - return result; + if (result != KTX_SUCCESS) return result; return ktxTexture2_WriteToStream(This, &stream); } @@ -663,13 +606,11 @@ ktxTexture2_WriteToStdioStream(ktxTexture2* This, FILE* dstsstr) * An error occurred while writing the file. */ KTX_error_code -ktxTexture2_WriteToNamedFile(ktxTexture2* This, const char* const dstname) -{ +ktxTexture2_WriteToNamedFile(ktxTexture2* This, const char* const dstname) { KTX_error_code result; FILE* dst; - if (!This) - return KTX_INVALID_VALUE; + if (!This) return KTX_INVALID_VALUE; dst = ktxFOpenUTF8(dstname, "wb"); if (dst) { @@ -721,25 +662,20 @@ ktxTexture2_WriteToNamedFile(ktxTexture2* This, const char* const dstname) * An error occurred while writing the file. */ KTX_error_code -ktxTexture2_WriteToMemory(ktxTexture2* This, - ktx_uint8_t** ppDstBytes, ktx_size_t* pSize) -{ +ktxTexture2_WriteToMemory(ktxTexture2* This, ktx_uint8_t** ppDstBytes, ktx_size_t* pSize) { struct ktxStream dststr; KTX_error_code result; ktx_size_t strSize; - if (!This || !ppDstBytes || !pSize) - return KTX_INVALID_VALUE; + if (!This || !ppDstBytes || !pSize) return KTX_INVALID_VALUE; *ppDstBytes = NULL; result = ktxMemStream_construct(&dststr, KTX_FALSE); - if (result != KTX_SUCCESS) - return result; + if (result != KTX_SUCCESS) return result; result = ktxTexture2_WriteToStream(This, &dststr); - if(result != KTX_SUCCESS) - { + if (result != KTX_SUCCESS) { ktxMemStream_destruct(&dststr); return result; } @@ -753,7 +689,6 @@ ktxTexture2_WriteToMemory(ktxTexture2* This, */ ktxMemStream_destruct(&dststr); return KTX_SUCCESS; - } /** @@ -770,10 +705,8 @@ ktxTexture2_WriteToMemory(ktxTexture2* This, * above 20 should be used with caution as they require more memory. */ KTX_error_code -ktxTexture2_DeflateZstd(ktxTexture2* This, ktx_uint32_t compressionLevel) -{ - ktx_uint32_t levelIndexByteLength = - This->numLevels * sizeof(ktxLevelIndexEntry); +ktxTexture2_DeflateZstd(ktxTexture2* This, ktx_uint32_t compressionLevel) { + ktx_uint32_t levelIndexByteLength = This->numLevels * sizeof(ktxLevelIndexEntry); ktx_uint8_t* workBuf; ktx_uint8_t* cmpData; ktx_size_t dstRemainingByteLength = 0; @@ -785,8 +718,7 @@ ktxTexture2_DeflateZstd(ktxTexture2* This, ktx_uint32_t compressionLevel) ZSTD_CCtx* cctx = ZSTD_createCCtx(); - if (This->supercompressionScheme != KTX_SS_NONE) - return KTX_INVALID_OPERATION; + if (This->supercompressionScheme != KTX_SS_NONE) return KTX_INVALID_OPERATION; // On rare occasions the deflated data can be a few bytes larger than // the source data. Calculating the dst buffer size using @@ -797,39 +729,35 @@ ktxTexture2_DeflateZstd(ktxTexture2* This, ktx_uint32_t compressionLevel) } workBuf = malloc(dstRemainingByteLength + levelIndexByteLength); - if (workBuf == NULL) - return KTX_OUT_OF_MEMORY; + if (workBuf == NULL) return KTX_OUT_OF_MEMORY; nindex = (ktxLevelIndexEntry*)workBuf; pCmpDst = &workBuf[levelIndexByteLength]; for (int32_t level = This->numLevels - 1; level >= 0; level--) { size_t levelByteLengthCmp = - ZSTD_compressCCtx(cctx, pCmpDst + levelOffset, - dstRemainingByteLength, - &This->pData[cindex[level].byteOffset], - cindex[level].byteLength, - compressionLevel); + ZSTD_compressCCtx(cctx, pCmpDst + levelOffset, dstRemainingByteLength, &This->pData[cindex[level].byteOffset], + cindex[level].byteLength, compressionLevel); if (ZSTD_isError(levelByteLengthCmp)) { free(workBuf); ZSTD_ErrorCode error = ZSTD_getErrorCode(levelByteLengthCmp); - switch(error) { - case ZSTD_error_parameter_outOfBound: + switch (error) { + case ZSTD_error_parameter_outOfBound: return KTX_INVALID_VALUE; - case ZSTD_error_dstSize_tooSmall: + case ZSTD_error_dstSize_tooSmall: #ifdef DEBUG assert(false && "Deflate dstSize too small."); #else return KTX_OUT_OF_MEMORY; #endif - case ZSTD_error_workSpace_tooSmall: + case ZSTD_error_workSpace_tooSmall: #ifdef DEBUG assert(false && "Deflate workspace too small."); #else return KTX_OUT_OF_MEMORY; #endif - case ZSTD_error_memory_allocation: + case ZSTD_error_memory_allocation: return KTX_OUT_OF_MEMORY; - default: + default: // The remaining errors look like they should only // occur during decompression but just in case. #ifdef DEBUG @@ -855,8 +783,8 @@ ktxTexture2_DeflateZstd(ktxTexture2* This, ktx_uint32_t compressionLevel) return KTX_OUT_OF_MEMORY; } // Now modify the texture. - memcpy(cmpData, pCmpDst, byteLengthCmp); // Copy data to sized buffer. - memcpy(cindex, nindex, levelIndexByteLength); // Update level index + memcpy(cmpData, pCmpDst, byteLengthCmp); // Copy data to sized buffer. + memcpy(cindex, nindex, levelIndexByteLength); // Update level index free(workBuf); free(This->pData); This->pData = cmpData; @@ -883,10 +811,8 @@ ktxTexture2_DeflateZstd(ktxTexture2* This, ktx_uint32_t compressionLevel) * between 1 and 9 are accepted. The lower the level the faster. */ KTX_error_code -ktxTexture2_DeflateZLIB(ktxTexture2* This, ktx_uint32_t compressionLevel) -{ - ktx_uint32_t levelIndexByteLength = - This->numLevels * sizeof(ktxLevelIndexEntry); +ktxTexture2_DeflateZLIB(ktxTexture2* This, ktx_uint32_t compressionLevel) { + ktx_uint32_t levelIndexByteLength = This->numLevels * sizeof(ktxLevelIndexEntry); ktx_uint8_t* workBuf; ktx_uint8_t* cmpData; ktx_size_t dstRemainingByteLength = 0; @@ -896,8 +822,7 @@ ktxTexture2_DeflateZLIB(ktxTexture2* This, ktx_uint32_t compressionLevel) ktxLevelIndexEntry* nindex; ktx_uint8_t* pCmpDst; - if (This->supercompressionScheme != KTX_SS_NONE) - return KTX_INVALID_OPERATION; + if (This->supercompressionScheme != KTX_SS_NONE) return KTX_INVALID_OPERATION; // On rare occasions the deflated data can be a few bytes larger than // the source data. Calculating the dst buffer size using @@ -907,20 +832,16 @@ ktxTexture2_DeflateZLIB(ktxTexture2* This, ktx_uint32_t compressionLevel) } workBuf = malloc(dstRemainingByteLength + levelIndexByteLength); - if (workBuf == NULL) - return KTX_OUT_OF_MEMORY; + if (workBuf == NULL) return KTX_OUT_OF_MEMORY; nindex = (ktxLevelIndexEntry*)workBuf; pCmpDst = &workBuf[levelIndexByteLength]; for (int32_t level = This->numLevels - 1; level >= 0; level--) { size_t levelByteLengthCmp = dstRemainingByteLength; - KTX_error_code result = ktxCompressZLIBInt(pCmpDst + levelOffset, - &levelByteLengthCmp, - &This->pData[cindex[level].byteOffset], - cindex[level].byteLength, - compressionLevel); - if (result != KTX_SUCCESS) - return result; + KTX_error_code result = + ktxCompressZLIBInt(pCmpDst + levelOffset, &levelByteLengthCmp, &This->pData[cindex[level].byteOffset], + cindex[level].byteLength, compressionLevel); + if (result != KTX_SUCCESS) return result; nindex[level].byteOffset = levelOffset; nindex[level].uncompressedByteLength = cindex[level].byteLength; @@ -937,8 +858,8 @@ ktxTexture2_DeflateZLIB(ktxTexture2* This, ktx_uint32_t compressionLevel) return KTX_OUT_OF_MEMORY; } // Now modify the texture. - memcpy(cmpData, pCmpDst, byteLengthCmp); // Copy data to sized buffer. - memcpy(cindex, nindex, levelIndexByteLength); // Update level index + memcpy(cmpData, pCmpDst, byteLengthCmp); // Copy data to sized buffer. + memcpy(cindex, nindex, levelIndexByteLength); // Update level index free(workBuf); free(This->pData); This->pData = cmpData; diff --git a/other_include/.clang-format b/other_include/.clang-format new file mode 100644 index 0000000000..ddf42b4634 --- /dev/null +++ b/other_include/.clang-format @@ -0,0 +1,7 @@ +# Copyright 2024 The Khronos Group Inc. +# SPDX-License-Identifier: Apache-2.0 +--- +# Disable clang-format in this directory +DisableFormat: true +SortIncludes: false +--- diff --git a/other_projects/fmt/.clang-format b/other_projects/fmt/.clang-format deleted file mode 100644 index df55d340f0..0000000000 --- a/other_projects/fmt/.clang-format +++ /dev/null @@ -1,8 +0,0 @@ -# Run manually to reformat a file: -# clang-format -i --style=file -Language: Cpp -BasedOnStyle: Google -IndentPPDirectives: AfterHash -IndentCaseLabels: false -AlwaysBreakTemplateDeclarations: false -DerivePointerAlignment: false diff --git a/tests/gtest/.clang-format b/tests/gtest/.clang-format new file mode 100644 index 0000000000..ddf42b4634 --- /dev/null +++ b/tests/gtest/.clang-format @@ -0,0 +1,7 @@ +# Copyright 2024 The Khronos Group Inc. +# SPDX-License-Identifier: Apache-2.0 +--- +# Disable clang-format in this directory +DisableFormat: true +SortIncludes: false +--- diff --git a/tests/gtest/include/gtest/.clang-format b/tests/gtest/include/gtest/.clang-format new file mode 100644 index 0000000000..ddf42b4634 --- /dev/null +++ b/tests/gtest/include/gtest/.clang-format @@ -0,0 +1,7 @@ +# Copyright 2024 The Khronos Group Inc. +# SPDX-License-Identifier: Apache-2.0 +--- +# Disable clang-format in this directory +DisableFormat: true +SortIncludes: false +--- diff --git a/tests/tests.cmake b/tests/tests.cmake index c3d445dfa2..4787e2585a 100644 --- a/tests/tests.cmake +++ b/tests/tests.cmake @@ -31,7 +31,7 @@ add_subdirectory(transcodetests) add_subdirectory(streamtests) add_executable( unittests - ${PROJECT_SOURCE_DIR}/lib/dfdutils/dfd2vk.c + ${PROJECT_SOURCE_DIR}/external/dfdutils/dfd2vk.c unittests/image_unittests.cc unittests/test_fragment_uri.cc unittests/test_string_to_vkformat.cc diff --git a/tests/transcodetests/CMakeLists.txt b/tests/transcodetests/CMakeLists.txt index ed8bed7c21..4c24c66308 100644 --- a/tests/transcodetests/CMakeLists.txt +++ b/tests/transcodetests/CMakeLists.txt @@ -47,21 +47,21 @@ if(WIN32) # See comment in ../../CMakeLists.txt around line 625. if (transcoder_options) set_source_files_properties( - ${PROJECT_SOURCE_DIR}/lib/basisu/transcoder/basisu_transcoder.cpp + ${PROJECT_SOURCE_DIR}/external/basisu/transcoder/basisu_transcoder.cpp PROPERTIES COMPILE_OPTIONS "${transcoder_options}" ) endif() if (zstd_options) set_source_files_properties( - ${PROJECT_SOURCE_DIR}/lib/basisu/zstd/zstd.c + ${PROJECT_SOURCE_DIR}/external/basisu/zstd/zstd.c PROPERTIES COMPILE_OPTIONS "${zstd_options}" ) endif() # The Windows ktx.dll does not export needed symbols. This is a workaround to get it linking. add_library(obj_tmp_basisu OBJECT - $<$>:${PROJECT_SOURCE_DIR}/lib/basisu/transcoder/basisu_transcoder.cpp> - ${PROJECT_SOURCE_DIR}/lib/basisu/zstd/zstd.c + $<$>:${PROJECT_SOURCE_DIR}/external/basisu/transcoder/basisu_transcoder.cpp> + ${PROJECT_SOURCE_DIR}/external/basisu/zstd/zstd.c ) target_compile_definitions( obj_tmp_basisu diff --git a/tools/imageio/CMakeLists.txt b/tools/imageio/CMakeLists.txt index 711ad68abf..cc97d67f7b 100644 --- a/tools/imageio/CMakeLists.txt +++ b/tools/imageio/CMakeLists.txt @@ -23,9 +23,9 @@ add_library( imageio STATIC imageio.h imageio_utility.h imageoutput.cc - ${PROJECT_SOURCE_DIR}/lib/astc-encoder/Source/tinyexr.h - ${PROJECT_SOURCE_DIR}/lib/basisu/encoder/jpgd.cpp - ${PROJECT_SOURCE_DIR}/lib/basisu/encoder/jpgd.h + ${PROJECT_SOURCE_DIR}/external/astc-encoder/Source/tinyexr.h + ${PROJECT_SOURCE_DIR}/external/basisu/encoder/jpgd.cpp + ${PROJECT_SOURCE_DIR}/external/basisu/encoder/jpgd.h ${PLUGIN_HEADERS} ${PLUGIN_SOURCES} ) @@ -33,13 +33,13 @@ add_library( imageio STATIC source_group(TREE "${CMAKE_CURRENT_LIST_DIR}" PREFIX "Source Files" FILES ${PLUGIN_SOURCES}) source_group(TREE "${CMAKE_CURRENT_LIST_DIR}" PREFIX "Header Files" FILES ${PLUGIN_HEADERS}) source_group("Source Files/jpg.imageio" FILES - ${PROJECT_SOURCE_DIR}/lib/basisu/encoder/jpgd.cpp + ${PROJECT_SOURCE_DIR}/external/basisu/encoder/jpgd.cpp ) source_group("Header Files/jpg.imageio" FILES - ${PROJECT_SOURCE_DIR}/lib/basisu/encoder/jpgd.h + ${PROJECT_SOURCE_DIR}/external/basisu/encoder/jpgd.h ) source_group("Header Files/exr.imageio" FILES - ${PROJECT_SOURCE_DIR}/lib/astc-encoder/Source/tinyexr.h + ${PROJECT_SOURCE_DIR}/external/astc-encoder/Source/tinyexr.h ) target_include_directories( @@ -56,9 +56,9 @@ target_include_directories( PUBLIC ${PROJECT_SOURCE_DIR}/other_include PRIVATE - ${PROJECT_SOURCE_DIR}/lib/astc-encoder/Source - ${PROJECT_SOURCE_DIR}/lib/basisu - ${PROJECT_SOURCE_DIR}/lib/dfdutils + ${PROJECT_SOURCE_DIR}/external/astc-encoder/Source + ${PROJECT_SOURCE_DIR}/external/basisu + ${PROJECT_SOURCE_DIR}/external/dfdutils ) target_compile_definitions( diff --git a/tools/toktx/CMakeLists.txt b/tools/toktx/CMakeLists.txt index ddd32ac8af..c4759909a1 100644 --- a/tools/toktx/CMakeLists.txt +++ b/tools/toktx/CMakeLists.txt @@ -22,7 +22,7 @@ target_include_directories( PRIVATE $ ${PROJECT_SOURCE_DIR}/lib - ${PROJECT_SOURCE_DIR}/lib/dfdutils + ${PROJECT_SOURCE_DIR}/external/dfdutils ) target_link_libraries( diff --git a/utils/argparser.cpp b/utils/argparser.cpp index 48620971f7..ae16f6e872 100644 --- a/utils/argparser.cpp +++ b/utils/argparser.cpp @@ -28,8 +28,7 @@ using namespace std; /* * Construct from a string of arguments. */ -argvector::argvector(const string& sArgs) -{ +argvector::argvector(const string& sArgs) { const string sep(" \t\n\r\v\f"); size_t pos; @@ -47,8 +46,7 @@ argvector::argvector(const string& sArgs) /* * Construct from an array of C strings */ -argvector::argvector(int argc, const char* const* argv) -{ +argvector::argvector(int argc, const char* const* argv) { for (int i = 0; i < argc; i++) { push_back(argv[i]); } @@ -57,22 +55,17 @@ argvector::argvector(int argc, const char* const* argv) /* * Functions the same as getopt_long. See `man 3 getopt_long`. */ -int -argparser::getopt(string* shortopts, const struct option* longopts, - int* /*longindex*/) -{ - if (optind == argv.size()) - return -1; +int argparser::getopt(string* shortopts, const struct option* longopts, int* /*longindex*/) { + if (optind == argv.size()) return -1; string arg; arg = argv[optind]; - if (arg[0] != '-' || (arg[0] == '-' && arg.size() == 1)) - return -1; + if (arg[0] != '-' || (arg[0] == '-' && arg.size() == 1)) return -1; optind++; int retval = '?'; if (arg.compare(0, 2, "--") == 0) { - if (arg.size() == 2) return -1; // " -- " separates options and files + if (arg.size() == 2) return -1; // " -- " separates options and files const struct option* opt = longopts; while (opt->name != nullptr) { if (arg.compare(2, string::npos, opt->name) == 0) { @@ -81,8 +74,7 @@ argparser::getopt(string* shortopts, const struct option* longopts, if (optind >= argv.size() || (optarg = argv[optind++])[0] == '-') { optarg.clear(); optind--; - if (opt->has_arg == option::required_argument) - retval = ':'; + if (opt->has_arg == option::required_argument) retval = ':'; } } if (opt->flag != nullptr) { @@ -97,13 +89,12 @@ argparser::getopt(string* shortopts, const struct option* longopts, size_t pos = shortopts->find(arg.substr(1, 1)); if (pos != string::npos) { retval = (*shortopts)[pos]; - if (pos < shortopts->length() - && ((*shortopts)[++pos] == ':' || (*shortopts)[pos] == ';')) { + if (pos < shortopts->length() && ((*shortopts)[++pos] == ':' || (*shortopts)[pos] == ';')) { if (optind >= argv.size() || (optarg = argv[optind++])[0] == '-') { optarg.clear(); optind--; - if ((*shortopts)[pos] == ':') // required argument - retval = ':'; + if ((*shortopts)[pos] == ':') // required argument + retval = ':'; } } } @@ -114,17 +105,14 @@ argparser::getopt(string* shortopts, const struct option* longopts, //================== Helper for apps' processArgs ======================== -std::istream& operator >> (std::istream& stream, const skip& x) -{ +std::istream& operator>>(std::istream& stream, const skip& x) { std::ios_base::fmtflags f = stream.flags(); stream >> std::noskipws; char c; const char* text = x.text; - while (stream && *text++) - stream >> c; + while (stream && *text++) stream >> c; stream.flags(f); return stream; } - diff --git a/utils/argparser.h b/utils/argparser.h index d977bc3936..952978acfc 100644 --- a/utils/argparser.h +++ b/utils/argparser.h @@ -16,7 +16,7 @@ class argvector : public std::vector { public: - argvector() { }; + argvector(){}; argvector(const std::string& argstring); argvector(int argc, const char* const* argv); }; @@ -25,7 +25,7 @@ class argparser { public: struct option { const char* name; - enum has_arg_t {no_argument, required_argument, optional_argument} has_arg; + enum has_arg_t { no_argument, required_argument, optional_argument } has_arg; int* flag; int val; @@ -36,26 +36,22 @@ class argparser { unsigned int optind; argvector argv; - argparser(argvector& argv, unsigned int startindex = 0) - : optind(startindex), argv(argv) { } + argparser(argvector& argv, unsigned int startindex = 0) : optind(startindex), argv(argv) {} - argparser(int argc, const char* const* argv1) - : optind(1), argv(argc, argv1) { } + argparser(int argc, const char* const* argv1) : optind(1), argv(argc, argv1) {} - int getopt(std::string* shortopts, const struct option* longopts, - int* longindex = nullptr); + int getopt(std::string* shortopts, const struct option* longopts, int* longindex = nullptr); }; //================== Helper for apps' processArgs ======================== // skips the number of characters equal to the length of given text // does not check whether the skipped characters are the same as it -struct skip -{ +struct skip { const char* text; skip(const char* text) : text(text) {} }; -std::istream& operator >> (std::istream& stream, const skip& x); +std::istream& operator>>(std::istream& stream, const skip& x); #endif /* ARGPARSER_H */ diff --git a/utils/ktxapp.h b/utils/ktxapp.h index 09c9f45678..7613437d16 100644 --- a/utils/ktxapp.h +++ b/utils/ktxapp.h @@ -6,10 +6,10 @@ #include "stdafx.h" -#if defined (_WIN32) - #define _CRT_SECURE_NO_WARNINGS - #define WINDOWS_LEAN_AND_MEAN - #include +#if defined(_WIN32) +#define _CRT_SECURE_NO_WARNINGS +#define WINDOWS_LEAN_AND_MEAN +#include #endif #include @@ -29,52 +29,39 @@ // Thanks Windows!!! #if defined(min) - #undef min +#undef min #endif #if defined(max) - #undef max +#undef max #endif using namespace std; // clamp is in std:: from c++17. #if !(_MSVC_LANG >= 201703L || __cplusplus >= 201703L) -template inline T clamp(T value, T low, T high) { +template +inline T clamp(T value, T low, T high) { return (value < low) ? low : ((value > high) ? high : value); } #endif -template -struct clamped -{ - clamped(T def_v, T min_v, T max_v) : - def(def_v), - min(min_v), - max(max_v), - value(def_v) - { - } - - void clear() - { - value = def; - } - - operator T() const - { - return value; - } - - T operator= (T v) - { - value = clamp(v, min, max); - return value; - } - - T def; - T min; - T max; - T value; +template +struct clamped { + clamped(T def_v, T min_v, T max_v) : def(def_v), min(min_v), max(max_v), value(def_v) {} + + void clear() { value = def; } + + operator T() const { return value; } + + T operator=(T v) { + value = clamp(v, min, max); + return value; + } + + T def; + T min; + T max; + T value; }; /** @@ -93,15 +80,14 @@ class ktxApp { public: virtual int main(int argc, char* argv[]) = 0; virtual void usage() { - cerr << - " -h, --help Print this usage message and exit.\n" - " -v, --version Print the version number of this program and exit.\n" + cerr << " -h, --help Print this usage message and exit.\n" + " -v, --version Print the version number of this program and exit.\n" #if defined(_WIN32) && defined(DEBUG) - " --ld Launch Visual Studio deugger at start up.\n" + " --ld Launch Visual Studio deugger at start up.\n" #endif ; }; - string& getName() { return name; } + string& getName() { return name; } protected: struct commandOptions { @@ -111,15 +97,13 @@ class ktxApp { int warn; int launchDebugger; - commandOptions() : test(false), warn(1), launchDebugger(0) { } + commandOptions() : test(false), warn(1), launchDebugger(0) {} }; - ktxApp(std::string& version, std::string& defaultVersion, - commandOptions& options) - : version(version), defaultVersion(defaultVersion), - options(options) { } + ktxApp(std::string& version, std::string& defaultVersion, commandOptions& options) + : version(version), defaultVersion(defaultVersion), options(options) {} - void error(const char *pFmt, ...) { + void error(const char* pFmt, ...) { va_list args; va_start(args, pFmt); @@ -129,7 +113,7 @@ class ktxApp { cerr << "\n"; } - void warning(const char *pFmt, va_list args) { + void warning(const char* pFmt, va_list args) { if (options.warn) { cerr << name << " warning! "; vfprintf(stderr, pFmt, args); @@ -137,7 +121,7 @@ class ktxApp { } } - void warning(const char *pFmt, ...) { + void warning(const char* pFmt, ...) { if (options.warn) { va_list args; va_start(args, pFmt); @@ -185,8 +169,7 @@ class ktxApp { return file; } - int strtoi(const char* str) - { + int strtoi(const char* str) { char* endptr; int value = (int)strtol(str, &endptr, 0); // Some implementations set errno == EINVAL but we can't rely on it. @@ -200,37 +183,28 @@ class ktxApp { enum StdinUse { eDisallowStdin, eAllowStdin }; enum OutfilePos { eNone, eFirst, eLast }; - void processCommandLine(int argc, char* argv[], - StdinUse stdinStat = eAllowStdin, - OutfilePos outfilePos = eNone) - { + void processCommandLine(int argc, char* argv[], StdinUse stdinStat = eAllowStdin, OutfilePos outfilePos = eNone) { uint32_t i; size_t slash, dot; name = argv[0]; // For consistent Id, only use the stem of name; slash = name.find_last_of('\\'); - if (slash == string::npos) - slash = name.find_last_of('/'); - if (slash != string::npos) - name.erase(0, slash+1); // Remove directory name. + if (slash == string::npos) slash = name.find_last_of('/'); + if (slash != string::npos) name.erase(0, slash + 1); // Remove directory name. dot = name.find_last_of('.'); - if (dot != string::npos) - name.erase(dot, string::npos); // Remove extension. + if (dot != string::npos) name.erase(dot, string::npos); // Remove extension. argparser parser(argc, argv); processOptions(parser); i = parser.optind; if (argc - i > 0) { - if (outfilePos == eFirst) - options.outfile = parser.argv[i++]; + if (outfilePos == eFirst) options.outfile = parser.argv[i++]; uint32_t infileCount = outfilePos == eLast ? argc - 1 : argc; for (; i < infileCount; i++) { if (parser.argv[i][0] == '@') { - if (!loadFileList(parser.argv[i], - parser.argv[i][1] == '@', - options.infiles)) { + if (!loadFileList(parser.argv[i], parser.argv[i][1] == '@', options.infiles)) { exit(1); } } else { @@ -247,13 +221,12 @@ class ktxApp { } } } - if (outfilePos == eLast) - options.outfile = parser.argv[i]; + if (outfilePos == eLast) options.outfile = parser.argv[i]; } if (options.infiles.size() == 0) { if (stdinStat == eAllowStdin) { - options.infiles.push_back("-"); // Use stdin as 0 files. + options.infiles.push_back("-"); // Use stdin as 0 files. } else { error("need some input files."); usage(); @@ -265,17 +238,14 @@ class ktxApp { } } - bool loadFileList(const string &f, bool relativize, - vector& filenames) - { + bool loadFileList(const string& f, bool relativize, vector& filenames) { string listName(f); listName.erase(0, relativize ? 2 : 1); - FILE *lf = nullptr; + FILE* lf = nullptr; lf = fopenUTF8(listName, "r"); if (!lf) { - error("failed opening filename list: \"%s\": %s\n", - listName.c_str(), strerror(errno)); + error("failed opening filename list: \"%s\": %s\n", listName.c_str(), strerror(errno)); return false; } @@ -295,31 +265,30 @@ class ktxApp { char buf[4096]; buf[0] = '\0'; - char *p = fgets(buf, sizeof(buf), lf); + char* p = fgets(buf, sizeof(buf), lf); if (!p) { - if (ferror(lf)) { - error("failed reading filename list: \"%s\": %s\n", - listName.c_str(), strerror(errno)); - fclose(lf); - return false; - } else - break; + if (ferror(lf)) { + error("failed reading filename list: \"%s\": %s\n", listName.c_str(), strerror(errno)); + fclose(lf); + return false; + } else + break; } string readFilename(p); while (readFilename.size()) { if (readFilename[0] == ' ') - readFilename.erase(0, 1); + readFilename.erase(0, 1); else - break; + break; } while (readFilename.size()) { const char c = readFilename.back(); if ((c == ' ') || (c == '\n') || (c == '\r')) - readFilename.erase(readFilename.size() - 1, 1); + readFilename.erase(readFilename.size() - 1, 1); else - break; + break; } if (readFilename.size()) { @@ -339,21 +308,21 @@ class ktxApp { int opt; while ((opt = parser.getopt(&short_opts, option_list.data(), NULL)) != -1) { switch (opt) { - case 0: + case 0: break; - case 10000: + case 10000: break; - case 'h': + case 'h': usage(); exit(0); - case 'v': + case 'v': printVersion(); exit(0); - case ':': + case ':': error("missing required option argument."); usage(); exit(0); - default: + default: if (!processOption(parser, opt)) { usage(); exit(1); @@ -361,8 +330,7 @@ class ktxApp { } } #if defined(_WIN32) && defined(DEBUG) - if (options.launchDebugger) - launchDebugger(); + if (options.launchDebugger) launchDebugger(); #endif } @@ -381,13 +349,11 @@ class ktxApp { #if defined(_WIN32) && defined(DEBUG) // For use when debugging stdin with Visual Studio which does not have a // "wait for executable to be launched" choice in its debugger settings. - bool launchDebugger() - { + bool launchDebugger() { // Get System directory, typically c:\windows\system32 std::wstring systemDir(MAX_PATH + 1, '\0'); - UINT nChars = GetSystemDirectoryW(&systemDir[0], - static_cast(systemDir.length())); - if (nChars == 0) return false; // failed to get system directory + UINT nChars = GetSystemDirectoryW(&systemDir[0], static_cast(systemDir.length())); + if (nChars == 0) return false; // failed to get system directory systemDir.resize(nChars); // Get process ID and create the command line @@ -419,29 +385,29 @@ class ktxApp { } #endif - string name; - string& version; - string& defaultVersion; + string name; + string& version; + string& defaultVersion; commandOptions& options; - virtual void validateOptions() { } + virtual void validateOptions() {} std::vector option_list { - { "help", argparser::option::no_argument, NULL, 'h' }, - { "version", argparser::option::no_argument, NULL, 'v' }, - { "test", argparser::option::no_argument, &options.test, 1}, + {"help", argparser::option::no_argument, NULL, 'h'}, {"version", argparser::option::no_argument, NULL, 'v'}, + {"test", argparser::option::no_argument, &options.test, 1}, #if defined(_WIN32) && defined(DEBUG) - { "ld", argparser::option::no_argument, &options.launchDebugger, 1}, + {"ld", argparser::option::no_argument, &options.launchDebugger, 1}, #endif - // -NSDocumentRevisionsDebugMode YES is appended to the end - // of the command by Xcode when debugging and "Allow debugging when - // using document Versions Browser" is checked in the scheme. It - // defaults to checked and is saved in a user-specific file not the - // pbxproj file so it can't be disabled in a generated project. - // Remove these from the arguments under consideration. - { "-NSDocumentRevisionsDebugMode", argparser::option::required_argument, NULL, 10000 }, - { nullptr, argparser::option::no_argument, nullptr, 0 } + // -NSDocumentRevisionsDebugMode YES is appended to the end + // of the command by Xcode when debugging and "Allow debugging when + // using document Versions Browser" is checked in the scheme. It + // defaults to checked and is saved in a user-specific file not the + // pbxproj file so it can't be disabled in a generated project. + // Remove these from the arguments under consideration. + {"-NSDocumentRevisionsDebugMode", argparser::option::required_argument, NULL, 10000}, { + nullptr, argparser::option::no_argument, nullptr, 0 + } }; string short_opts = "hv"; @@ -452,13 +418,12 @@ extern ktxApp& theApp; /** @internal * @~English * @brief Common main for all derived classes. - * + * * Handles rewriting of argv to UTF-8 on Windows. * Each app needs to initialize @c theApp to * point to an instance of itself. */ -int main(int argc, char* argv[]) -{ +int main(int argc, char* argv[]) { InitUTF8CLI(argc, argv); #if 0 if (!SetConsoleOutputCP(CP_UTF8)) { @@ -468,5 +433,3 @@ int main(int argc, char* argv[]) #endif return theApp.main(argc, argv); } - - diff --git a/utils/platform_utils.h b/utils/platform_utils.h index c5e2fb32ec..a5eb70122a 100644 --- a/utils/platform_utils.h +++ b/utils/platform_utils.h @@ -27,8 +27,7 @@ inline std::wstring DecodeUTF8Path(std::string path) { std::wstring result; int len = MultiByteToWideChar(CP_UTF8, 0, path.c_str(), static_cast(path.length()), NULL, 0); - if (len > 0) - { + if (len > 0) { result.resize(len); MultiByteToWideChar(CP_UTF8, 0, path.c_str(), static_cast(path.length()), &result[0], len); } @@ -37,9 +36,7 @@ inline std::wstring DecodeUTF8Path(std::string path) { #else // For other platforms there is no need for any conversion, they // support UTF-8 natively. -inline std::string DecodeUTF8Path(std::string path) { - return path; -} +inline std::string DecodeUTF8Path(std::string path) { return path; } #endif inline void InitUTF8CLI(int& argc, char* argv[]) { diff --git a/utils/sbufstream.h b/utils/sbufstream.h index fa97c9c97e..b7a0c90ec3 100644 --- a/utils/sbufstream.h +++ b/utils/sbufstream.h @@ -29,7 +29,7 @@ static std::ostream cnull(0); static std::ostream& logstream = cnull; -//static std::ostream logstream = std::cerr; +// static std::ostream logstream = std::cerr; /// @brief Template for a ktxStream that wraps a C++ std::streambuf. /// @@ -47,66 +47,45 @@ static std::ostream& logstream = cnull; /// /// template -class StreambufStream -{ +class StreambufStream { // Doubt this will ever get triggered - static_assert(sizeof(char) == sizeof(uint8_t), - "Chars are != 1 byte in this platform"); - -public: - StreambufStream(T streambuf, - std::ios::openmode seek_mode = std::ios::in | std::ios::out) - : _streambuf{std::move(streambuf)} - , _seek_mode{seek_mode} - , _stream{std::make_unique()} - , _destructed{false} - { + static_assert(sizeof(char) == sizeof(uint8_t), "Chars are != 1 byte in this platform"); + + public: + StreambufStream(T streambuf, std::ios::openmode seek_mode = std::ios::in | std::ios::out) + : _streambuf{std::move(streambuf)}, _seek_mode{seek_mode}, _stream{std::make_unique()}, _destructed{false} { initialize_stream(); } StreambufStream(const StreambufStream&) = delete; - StreambufStream &operator=(const StreambufStream&) = delete; + StreambufStream& operator=(const StreambufStream&) = delete; StreambufStream(StreambufStream&&) = delete; - StreambufStream &operator=(StreambufStream&&) = delete; + StreambufStream& operator=(StreambufStream&&) = delete; - virtual ~StreambufStream() - { - if (!_destructed) - stream()->destruct(stream()); + virtual ~StreambufStream() { + if (!_destructed) stream()->destruct(stream()); } - inline ktxStream* stream() const - { - return _stream.get(); - } + inline ktxStream* stream() const { return _stream.get(); } std::streambuf* streambuf() const; - inline std::ios::openmode seek_mode() const - { - return _seek_mode; - } + inline std::ios::openmode seek_mode() const { return _seek_mode; } - inline void seek_mode(std::ios::openmode newmode) - { - _seek_mode = newmode; - } + inline void seek_mode(std::ios::openmode newmode) { _seek_mode = newmode; } - inline bool destructed() const - { - return _destructed; - } + inline bool destructed() const { return _destructed; } -protected: + protected: void initialize_stream() { _stream->type = eStreamTypeCustom; _stream->closeOnDestruct = false; auto& custom_ptr = _stream->data.custom_ptr; custom_ptr.address = this; - custom_ptr.allocatorAddress = nullptr; // N/A - custom_ptr.size = 0; // N/A + custom_ptr.allocatorAddress = nullptr; // N/A + custom_ptr.size = 0; // N/A _stream->read = read; _stream->skip = skip; @@ -121,16 +100,13 @@ class StreambufStream // ktxStream vtable implementations - inline static StreambufStream* parent(ktxStream *str) - { + inline static StreambufStream* parent(ktxStream* str) { return reinterpret_cast(str->data.custom_ptr.address); } - static KTX_error_code read(ktxStream* str, void* dst, ktx_size_t count) - { + static KTX_error_code read(ktxStream* str, void* dst, ktx_size_t count) { auto self = parent(str); - if (count == 0) - { + if (count == 0) { return KTX_SUCCESS; } logstream << "\t read: " << count << 'B' << std::endl; @@ -140,11 +116,9 @@ class StreambufStream return (nread == stdcount) ? KTX_SUCCESS : KTX_FILE_UNEXPECTED_EOF; } - static KTX_error_code skip(ktxStream* str, ktx_size_t count) - { + static KTX_error_code skip(ktxStream* str, ktx_size_t count) { auto self = parent(str); - if (count == 0) - { + if (count == 0) { return KTX_SUCCESS; } logstream << "\t skip: " << count << 'B' << std::endl; @@ -154,11 +128,9 @@ class StreambufStream return (curpos > newpos) ? KTX_SUCCESS : KTX_FILE_SEEK_ERROR; } - static KTX_error_code write(ktxStream* str, const void* src, ktx_size_t size, ktx_size_t count) - { + static KTX_error_code write(ktxStream* str, const void* src, ktx_size_t size, ktx_size_t count) { auto self = parent(str); - if (size == 0 || count == 0) - { + if (size == 0 || count == 0) { return KTX_SUCCESS; } logstream << "\t write: " << count << "*" << size << "B" << std::endl; @@ -168,16 +140,14 @@ class StreambufStream return (nput == ntotal) ? KTX_SUCCESS : KTX_FILE_WRITE_ERROR; } - static KTX_error_code getpos(ktxStream* str, ktx_off_t *offset) - { + static KTX_error_code getpos(ktxStream* str, ktx_off_t* offset) { auto self = parent(str); *offset = ktx_off_t(self->_streambuf->pubseekoff(0, std::ios::cur, self->_seek_mode)); logstream << "\tgetpos: " << *offset << std::endl; return KTX_SUCCESS; } - static KTX_error_code setpos(ktxStream* str, ktx_off_t offset) - { + static KTX_error_code setpos(ktxStream* str, ktx_off_t offset) { auto self = parent(str); const auto newpos = std::streamoff(offset); const std::streampos setpos = self->_streambuf->pubseekoff(newpos, std::ios::beg, self->_seek_mode); @@ -185,8 +155,7 @@ class StreambufStream return (setpos == newpos) ? KTX_SUCCESS : KTX_FILE_SEEK_ERROR; } - static KTX_error_code getsize(ktxStream* str, ktx_size_t* size) - { + static KTX_error_code getsize(ktxStream* str, ktx_size_t* size) { auto self = parent(str); const std::streampos oldpos = self->_streambuf->pubseekoff(0, std::ios::cur, self->_seek_mode); *size = ktx_size_t(self->_streambuf->pubseekoff(0, std::ios::end)); @@ -195,8 +164,7 @@ class StreambufStream return (oldpos == newpos) ? KTX_SUCCESS : KTX_FILE_SEEK_ERROR; } - static void destruct(ktxStream* str) - { + static void destruct(ktxStream* str) { auto self = parent(str); self->_destructed = true; } @@ -212,14 +180,12 @@ class StreambufStream // I have not yet found a way to do this inside the template definition. // However `inline` should prevent any multiple definition errors. -template<> -inline std::streambuf* StreambufStream::streambuf() const -{ +template <> +inline std::streambuf* StreambufStream::streambuf() const { return _streambuf; } -template<> -inline std::streambuf* StreambufStream>::streambuf() const -{ +template <> +inline std::streambuf* StreambufStream>::streambuf() const { return _streambuf.get(); } diff --git a/utils/scapp.h b/utils/scapp.h index 24ca263790..162a78fe9e 100644 --- a/utils/scapp.h +++ b/utils/scapp.h @@ -13,35 +13,22 @@ #include -template -struct clampedOption -{ - clampedOption(T& option, T min_v, T max_v) : - option(option), - min(min_v), - max(max_v) - { - } +template +struct clampedOption { + clampedOption(T& option, T min_v, T max_v) : option(option), min(min_v), max(max_v) {} - void clear() - { - option = 0; - } + void clear() { option = 0; } - operator T() const - { - return option; - } + operator T() const { return option; } - T operator= (T v) - { - option = clamp(v, min, max); - return option; - } + T operator=(T v) { + option = clamp(v, min, max); + return option; + } - T& option; - T min; - T max; + T& option; + T min; + T max; }; /** @@ -52,40 +39,26 @@ struct clampedOption * * @return Valid ktx_pack_astc_block_dimension_e from string */ -ktx_pack_astc_block_dimension_e -astcBlockDimension(const char* block_size) { - static std::unordered_map - astc_blocks_mapping{{"4x4", KTX_PACK_ASTC_BLOCK_DIMENSION_4x4}, - {"5x4", KTX_PACK_ASTC_BLOCK_DIMENSION_5x4}, - {"5x5", KTX_PACK_ASTC_BLOCK_DIMENSION_5x5}, - {"6x5", KTX_PACK_ASTC_BLOCK_DIMENSION_6x5}, - {"6x6", KTX_PACK_ASTC_BLOCK_DIMENSION_6x6}, - {"8x5", KTX_PACK_ASTC_BLOCK_DIMENSION_8x5}, - {"8x6", KTX_PACK_ASTC_BLOCK_DIMENSION_8x6}, - {"10x5", KTX_PACK_ASTC_BLOCK_DIMENSION_10x5}, - {"10x6", KTX_PACK_ASTC_BLOCK_DIMENSION_10x6}, - {"8x8", KTX_PACK_ASTC_BLOCK_DIMENSION_8x8}, - {"10x8", KTX_PACK_ASTC_BLOCK_DIMENSION_10x8}, - {"10x10", KTX_PACK_ASTC_BLOCK_DIMENSION_10x10}, - {"12x10", KTX_PACK_ASTC_BLOCK_DIMENSION_12x10}, - {"12x12", KTX_PACK_ASTC_BLOCK_DIMENSION_12x12}, - {"3x3x3", KTX_PACK_ASTC_BLOCK_DIMENSION_3x3x3}, - {"4x3x3", KTX_PACK_ASTC_BLOCK_DIMENSION_4x3x3}, - {"4x4x3", KTX_PACK_ASTC_BLOCK_DIMENSION_4x4x3}, - {"4x4x4", KTX_PACK_ASTC_BLOCK_DIMENSION_4x4x4}, - {"5x4x4", KTX_PACK_ASTC_BLOCK_DIMENSION_5x4x4}, - {"5x5x4", KTX_PACK_ASTC_BLOCK_DIMENSION_5x5x4}, - {"5x5x5", KTX_PACK_ASTC_BLOCK_DIMENSION_5x5x5}, - {"6x5x5", KTX_PACK_ASTC_BLOCK_DIMENSION_6x5x5}, - {"6x6x5", KTX_PACK_ASTC_BLOCK_DIMENSION_6x6x5}, - {"6x6x6", KTX_PACK_ASTC_BLOCK_DIMENSION_6x6x6}}; +ktx_pack_astc_block_dimension_e astcBlockDimension(const char* block_size) { + static std::unordered_map astc_blocks_mapping{ + {"4x4", KTX_PACK_ASTC_BLOCK_DIMENSION_4x4}, {"5x4", KTX_PACK_ASTC_BLOCK_DIMENSION_5x4}, + {"5x5", KTX_PACK_ASTC_BLOCK_DIMENSION_5x5}, {"6x5", KTX_PACK_ASTC_BLOCK_DIMENSION_6x5}, + {"6x6", KTX_PACK_ASTC_BLOCK_DIMENSION_6x6}, {"8x5", KTX_PACK_ASTC_BLOCK_DIMENSION_8x5}, + {"8x6", KTX_PACK_ASTC_BLOCK_DIMENSION_8x6}, {"10x5", KTX_PACK_ASTC_BLOCK_DIMENSION_10x5}, + {"10x6", KTX_PACK_ASTC_BLOCK_DIMENSION_10x6}, {"8x8", KTX_PACK_ASTC_BLOCK_DIMENSION_8x8}, + {"10x8", KTX_PACK_ASTC_BLOCK_DIMENSION_10x8}, {"10x10", KTX_PACK_ASTC_BLOCK_DIMENSION_10x10}, + {"12x10", KTX_PACK_ASTC_BLOCK_DIMENSION_12x10}, {"12x12", KTX_PACK_ASTC_BLOCK_DIMENSION_12x12}, + {"3x3x3", KTX_PACK_ASTC_BLOCK_DIMENSION_3x3x3}, {"4x3x3", KTX_PACK_ASTC_BLOCK_DIMENSION_4x3x3}, + {"4x4x3", KTX_PACK_ASTC_BLOCK_DIMENSION_4x4x3}, {"4x4x4", KTX_PACK_ASTC_BLOCK_DIMENSION_4x4x4}, + {"5x4x4", KTX_PACK_ASTC_BLOCK_DIMENSION_5x4x4}, {"5x5x4", KTX_PACK_ASTC_BLOCK_DIMENSION_5x5x4}, + {"5x5x5", KTX_PACK_ASTC_BLOCK_DIMENSION_5x5x5}, {"6x5x5", KTX_PACK_ASTC_BLOCK_DIMENSION_6x5x5}, + {"6x6x5", KTX_PACK_ASTC_BLOCK_DIMENSION_6x6x5}, {"6x6x6", KTX_PACK_ASTC_BLOCK_DIMENSION_6x6x6}}; - auto opt = astc_blocks_mapping.find(block_size); + auto opt = astc_blocks_mapping.find(block_size); - if (opt != astc_blocks_mapping.end()) - return opt->second; + if (opt != astc_blocks_mapping.end()) return opt->second; - return KTX_PACK_ASTC_BLOCK_DIMENSION_6x6; + return KTX_PACK_ASTC_BLOCK_DIMENSION_6x6; } /** @@ -96,24 +69,19 @@ astcBlockDimension(const char* block_size) { * * @return Valid ktx_pack_astc_quality_e from string */ -ktx_pack_astc_quality_levels_e -astcQualityLevel(const char *quality) { - - static std::unordered_map astc_quality_mapping{ +ktx_pack_astc_quality_levels_e astcQualityLevel(const char* quality) { + static std::unordered_map astc_quality_mapping{ {"fastest", KTX_PACK_ASTC_QUALITY_LEVEL_FASTEST}, {"fast", KTX_PACK_ASTC_QUALITY_LEVEL_FAST}, {"medium", KTX_PACK_ASTC_QUALITY_LEVEL_MEDIUM}, {"thorough", KTX_PACK_ASTC_QUALITY_LEVEL_THOROUGH}, - {"exhaustive", KTX_PACK_ASTC_QUALITY_LEVEL_EXHAUSTIVE} - }; + {"exhaustive", KTX_PACK_ASTC_QUALITY_LEVEL_EXHAUSTIVE}}; - auto opt = astc_quality_mapping.find(quality); + auto opt = astc_quality_mapping.find(quality); - if (opt != astc_quality_mapping.end()) - return opt->second; + if (opt != astc_quality_mapping.end()) return opt->second; - return KTX_PACK_ASTC_QUALITY_LEVEL_MEDIUM; + return KTX_PACK_ASTC_QUALITY_LEVEL_MEDIUM; } /** @@ -124,14 +92,13 @@ astcQualityLevel(const char *quality) { * * @return Valid ktx_pack_astc_mode_e from string */ -ktx_pack_astc_encoder_mode_e -astcEncoderMode(const char* mode) { +ktx_pack_astc_encoder_mode_e astcEncoderMode(const char* mode) { if (strcmp(mode, "ldr") == 0) return KTX_PACK_ASTC_ENCODER_MODE_LDR; else if (strcmp(mode, "hdr") == 0) return KTX_PACK_ASTC_ENCODER_MODE_HDR; - return KTX_PACK_ASTC_ENCODER_MODE_DEFAULT; + return KTX_PACK_ASTC_ENCODER_MODE_DEFAULT; } /* @@ -405,21 +372,15 @@ class scApp : public ktxApp { clampedOption uastcRDOMaxSmoothBlockErrorScale; clampedOption uastcRDOMaxSmoothBlockStdDev; - basisOptions() : - threadCount(ktxBasisParams::threadCount, 1, 10000), - qualityLevel(ktxBasisParams::qualityLevel, 1, 255), - maxEndpoints(ktxBasisParams::maxEndpoints, 1, 16128), - maxSelectors(ktxBasisParams::maxSelectors, 1, 16128), - uastcRDODictSize(ktxBasisParams::uastcRDODictSize, 256, 65536), - uastcRDOQualityScalar(ktxBasisParams::uastcRDOQualityScalar, - 0.001f, 50.0f), - uastcRDOMaxSmoothBlockErrorScale( - ktxBasisParams::uastcRDOMaxSmoothBlockErrorScale, - 1.0f, 300.0f), - uastcRDOMaxSmoothBlockStdDev( - ktxBasisParams::uastcRDOMaxSmoothBlockStdDev, - 0.01f, 65536.0f) - { + basisOptions() + : threadCount(ktxBasisParams::threadCount, 1, 10000), + qualityLevel(ktxBasisParams::qualityLevel, 1, 255), + maxEndpoints(ktxBasisParams::maxEndpoints, 1, 16128), + maxSelectors(ktxBasisParams::maxSelectors, 1, 16128), + uastcRDODictSize(ktxBasisParams::uastcRDODictSize, 256, 65536), + uastcRDOQualityScalar(ktxBasisParams::uastcRDOQualityScalar, 0.001f, 50.0f), + uastcRDOMaxSmoothBlockErrorScale(ktxBasisParams::uastcRDOMaxSmoothBlockErrorScale, 1.0f, 300.0f), + uastcRDOMaxSmoothBlockStdDev(ktxBasisParams::uastcRDOMaxSmoothBlockStdDev, 0.01f, 65536.0f) { uint32_t tc = thread::hardware_concurrency(); if (tc == 0) tc = 1; threadCount.max = tc; @@ -438,7 +399,7 @@ class scApp : public ktxApp { preSwizzle = false; noEndpointRDO = false; noSelectorRDO = false; - uastc = false; // Default to ETC1S. + uastc = false; // Default to ETC1S. uastcRDO = false; uastcFlags = KTX_PACK_UASTC_LEVEL_DEFAULT; uastcRDODictSize.clear(); @@ -446,7 +407,7 @@ class scApp : public ktxApp { uastcRDODontFavorSimplerModes = false; uastcRDONoMultithreading = false; noSSE = false; - verbose = false; // Default to quiet operation. + verbose = false; // Default to quiet operation. for (int i = 0; i < 4; i++) inputSwizzle[i] = 0; } #define TRAVIS_DEBUG 0 @@ -485,12 +446,11 @@ class scApp : public ktxApp { clampedOption mode; clampedOption qualityLevel; - astcOptions() : - threadCount(ktxAstcParams::threadCount, 1, 10000), - blockDimension(ktxAstcParams::blockDimension, 0, KTX_PACK_ASTC_BLOCK_DIMENSION_MAX), - mode(ktxAstcParams::mode, 0, KTX_PACK_ASTC_ENCODER_MODE_MAX), - qualityLevel(ktxAstcParams::qualityLevel, 0, KTX_PACK_ASTC_QUALITY_LEVEL_MAX) - { + astcOptions() + : threadCount(ktxAstcParams::threadCount, 1, 10000), + blockDimension(ktxAstcParams::blockDimension, 0, KTX_PACK_ASTC_BLOCK_DIMENSION_MAX), + mode(ktxAstcParams::mode, 0, KTX_PACK_ASTC_ENCODER_MODE_MAX), + qualityLevel(ktxAstcParams::qualityLevel, 0, KTX_PACK_ASTC_QUALITY_LEVEL_MAX) { uint32_t tc = thread::hardware_concurrency(); if (tc == 0) tc = 1; threadCount.max = tc; @@ -505,22 +465,20 @@ class scApp : public ktxApp { for (int i = 0; i < 4; i++) inputSwizzle[i] = 0; } }; - int ktx2; - int etc1s; - int zcmp; - int astc; - ktx_bool_t normalMode; - ktx_bool_t normalize; + int ktx2; + int etc1s; + int zcmp; + int astc; + ktx_bool_t normalMode; + ktx_bool_t normalize; clamped zcmpLevel; clamped threadCount; string inputSwizzle; struct basisOptions bopts; struct astcOptions astcopts; - commandOptions() : - zcmpLevel(ZSTD_CLEVEL_DEFAULT, 1U, 22U), - threadCount(std::max(1U, thread::hardware_concurrency()) , 1U, 10000U) - { + commandOptions() + : zcmpLevel(ZSTD_CLEVEL_DEFAULT, 1U, 22U), threadCount(std::max(1U, thread::hardware_concurrency()), 1U, 10000U) { ktx2 = false; etc1s = false; zcmp = false; @@ -543,8 +501,7 @@ class scApp : public ktxApp { public: scApp(string& version, string& defaultVersion, scApp::commandOptions& options); const string& getParamsStr() { - if (!scparams.empty() && *(scparams.end()-1) == ' ') - scparams.erase(scparams.end()-1); + if (!scparams.empty() && *(scparams.end() - 1) == ' ') scparams.erase(scparams.end() - 1); return scparams; } @@ -557,314 +514,291 @@ class scApp : public ktxApp { options.bopts.uastc = 1; } - int encode(ktxTexture2* texture, const string& swizzle, - const string& filename); + int encode(ktxTexture2* texture, const string& swizzle, const string& filename); - void usage() - { - cerr << - " --encode \n" - " Compress the image data to ASTC, transcodable ETC1S / BasisLZ or\n" - " high-quality transcodable UASTC format. Implies --t2.\n" - " With each encoding option the following encoder specific options\n" - " become valid, otherwise they are ignored.\n\n" - " astc:\n" - " Create a texture in high-quality ASTC format.\n" - " --astc_blk_d \n" - " Specify block dimension to use for compressing the textures.\n" - " e.g. --astc_blk_d 6x5 for 2D or --astc_blk_d 6x6x6 for 3D.\n" - " 6x6 is the default for 2D.\n\n" - " Supported 2D block dimensions are:\n\n" - " 4x4: 8.00 bpp 10x5: 2.56 bpp\n" - " 5x4: 6.40 bpp 10x6: 2.13 bpp\n" - " 5x5: 5.12 bpp 8x8: 2.00 bpp\n" - " 6x5: 4.27 bpp 10x8: 1.60 bpp\n" - " 6x6: 3.56 bpp 10x10: 1.28 bpp\n" - " 8x5: 3.20 bpp 12x10: 1.07 bpp\n" - " 8x6: 2.67 bpp 12x12: 0.89 bpp\n\n" - " Supported 3D block dimensions are:\n\n" - " 3x3x3: 4.74 bpp 5x5x4: 1.28 bpp\n" - " 4x3x3: 3.56 bpp 5x5x5: 1.02 bpp\n" - " 4x4x3: 2.67 bpp 6x5x5: 0.85 bpp\n" - " 4x4x4: 2.00 bpp 6x6x5: 0.71 bpp\n" - " 5x4x4: 1.60 bpp 6x6x6: 0.59 bpp\n" - " --astc_mode \n" - " Specify which encoding mode to use. LDR is the default unless the\n" - " input image is 16-bit in which case the default is HDR.\n" - " --astc_quality \n" - " The quality level configures the quality-performance tradeoff for\n" - " the compressor; more complete searches of the search space\n" - " improve image quality at the expense of compression time. Default\n" - " is 'medium'. The quality level can be set between fastest (0) and\n" - " exhaustive (100) via the following fixed quality presets:\n\n" - " Level | Quality\n" - " ---------- | -----------------------------\n" - " fastest | (equivalent to quality = 0)\n" - " fast | (equivalent to quality = 10)\n" - " medium | (equivalent to quality = 60)\n" - " thorough | (equivalent to quality = 98)\n" - " exhaustive | (equivalent to quality = 100)\n" - " --astc_perceptual\n" - " The codec should optimize for perceptual error, instead of direct\n" - " RMS error. This aims to improve perceived image quality, but\n" - " typically lowers the measured PSNR score. Perceptual methods are\n" - " currently only available for normal maps and RGB color data.\n" - " etc1s:\n" - " Supercompress the image data with ETC1S / BasisLZ.\n" - " RED images will become RGB with RED in each component. RG images\n" - " will have R in the RGB part and G in the alpha part of the\n" - " compressed texture. When set, the following BasisLZ-related\n" - " options become valid, otherwise they are ignored.\n\n" - " --no_multithreading\n" - " Disable multithreading. Deprecated. For backward compatibility.\n" - " Use --threads 1 instead.\n" - " --clevel \n" - " ETC1S / BasisLZ compression level, an encoding speed vs. quality\n" - " tradeoff. Range is [0,5], default is 1. Higher values are slower\n" - " but give higher quality.\n" - " --qlevel \n" - " ETC1S / BasisLZ quality level. Range is [1,255]. Lower gives\n" - " better compression/lower quality/faster. Higher gives less\n" - " compression/higher quality/slower. --qlevel automatically\n" - " determines values for --max_endpoints, --max-selectors,\n" - " --endpoint_rdo_threshold and --selector_rdo_threshold for the\n" - " target quality level. Setting these options overrides the values\n" - " determined by -qlevel which defaults to 128 if neither it nor\n" - " both of --max_endpoints and --max_selectors have been set.\n" - "\n" - " Note that both of --max_endpoints and --max_selectors\n" - " must be set for them to have any effect. If all three options\n" - " are set, a warning will be issued that --qlevel will be ignored.\n" - "\n" - " Note also that --qlevel will only determine values for\n" - " --endpoint_rdo_threshold and --selector_rdo_threshold when\n" - " its value exceeds 128, otherwise their defaults will be used.\n" - " --max_endpoints \n" - " Manually set the maximum number of color endpoint clusters. Range\n" - " is [1,16128]. Default is 0, unset.\n" - " --endpoint_rdo_threshold \n" - " Set endpoint RDO quality threshold. The default is 1.25. Lower\n" - " is higher quality but less quality per output bit (try\n" - " [1.0,3.0]). This will override the value chosen by --qlevel.\n" - " --max_selectors \n" - " Manually set the maximum number of color selector clusters from\n" - " [1,16128]. Default is 0, unset.\n" - " --selector_rdo_threshold \n" - " Set selector RDO quality threshold. The default is 1.25. Lower\n" - " is higher quality but less quality per output bit (try\n" - " [1.0,3.0]). This will override the value chosen by --qlevel.\n" - " --no_endpoint_rdo\n" - " Disable endpoint rate distortion optimizations. Slightly faster,\n" - " less noisy output, but lower quality per output bit. Default is\n" - " to do endpoint RDO.\n" - " --no_selector_rdo\n" - " Disable selector rate distortion optimizations. Slightly faster,\n" - " less noisy output, but lower quality per output bit. Default is\n" - " to do selector RDO.\n\n" - " uastc:\n" - " Create a texture in high-quality transcodable UASTC format.\n" - " --uastc_quality \n" - " This optional parameter selects a speed vs quality\n" - " tradeoff as shown in the following table:\n" - "\n" - " Level | Speed | Quality\n" - " ----- | --------- | -------\n" - " 0 | Fastest | 43.45dB\n" - " 1 | Faster | 46.49dB\n" - " 2 | Default | 47.47dB\n" - " 3 | Slower | 48.01dB\n" - " 4 | Very slow | 48.24dB\n" - "\n" - " You are strongly encouraged to also specify --zcmp to losslessly\n" - " compress the UASTC data. This and any LZ-style compression can\n" - " be made more effective by conditioning the UASTC texture data\n" - " using the Rate Distortion Optimization (RDO) post-process stage.\n" - " When uastc encoding is set the following options become available\n" - " for controlling RDO:\n\n" - " --uastc_rdo_l []\n" - " Enable UASTC RDO post-processing and optionally set UASTC RDO\n" - " quality scalar (lambda) to @e lambda. Lower values yield higher\n" - " quality/larger LZ compressed files, higher values yield lower\n" - " quality/smaller LZ compressed files. A good range to try is\n" - " [.25,10]. For normal maps a good range is [.25,.75]. The full\n" - " range is [.001,10.0]. Default is 1.0.\n" - "\n" - " Note that previous versions used the --uastc_rdo_q option which\n" - " was removed because the RDO algorithm changed.\n" - " --uastc_rdo_d \n" - " Set UASTC RDO dictionary size in bytes. Default is 4096. Lower\n" - " values=faster, but give less compression. Range is [64,65536].\n" - " --uastc_rdo_b \n" - " Set UASTC RDO max smooth block error scale. Range is [1.0,300.0].\n" - " Default is 10.0, 1.0 is disabled. Larger values suppress more\n" - " artifacts (and allocate more bits) on smooth blocks.\n" - " --uastc_rdo_s \n" - " Set UASTC RDO max smooth block standard deviation. Range is\n" - " [.01,65536.0]. Default is 18.0. Larger values expand the range\n" - " of blocks considered smooth.
\n" - " --uastc_rdo_f\n" - " Do not favor simpler UASTC modes in RDO mode.\n" - " --uastc_rdo_m\n" - " Disable RDO multithreading (slightly higher compression,\n" - " deterministic).\n\n" - " --input_swizzle \n" - " Swizzle the input components according to swizzle which is an\n" - " alhpanumeric sequence matching the regular expression\n" - " ^[rgba01]{4}$.\n" - " --normal_mode\n" - " Only valid for linear textures with two or more components. If\n" - " the input texture has three or four linear components it is\n" - " assumed to be a three component linear normal map storing unit\n" - " length normals as (R=X, G=Y, B=Z). A fourth component will be\n" - " ignored. The map will be converted to a two component X+Y normal\n" - " map stored as (RGB=X, A=Y) prior to encoding. If unsure that\n" - " your normals are unit length, use @b --normalize. If the input\n" - " has 2 linear components it is assumed to be an X+Y map of unit\n" - " normals.\n\n" - " The Z component can be recovered programmatically in shader\n" - " code by using the equations:\n\n" - " nml.xy = texture(...).ga; // Load in [0,1]\n" - " nml.xy = nml.xy * 2.0 - 1.0; // Unpack to [-1,1]\n" - " nml.z = sqrt(1 - dot(nml.xy, nml.xy)); // Compute Z\n\n" - " Encoding is optimized for normal maps. For ASTC encoding,\n" - " '--encode astc', encoder parameters are tuned for better quality\n" - " on normal maps. . For ETC1S encoding, '--encode etc1s',i RDO is\n" - " disabled (no selector RDO, no endpoint RDO) to provide better\n" - " quality.\n\n" - " You can prevent conversion of the normal map to two components\n" - " by specifying '--input_swizzle rgb1'.\n\n" - " --normalize\n" - " Normalize input normals to have a unit length. Only valid for\n" - " linear textures with 2 or more components. For 2-component inputs\n" - " 2D unit normals are calculated. Do not use these 2D unit normals\n" - " to generate X+Y normals for --normal_mode. For 4-component inputs\n" - " a 3D unit normal is calculated. 1.0 is used for the value of the\n" - " 4th component.\n" - " --no_sse\n" - " Forbid use of the SSE instruction set. Ignored if CPU does not\n" - " support SSE. Only the Basis Universal compressor uses SSE.\n" - " --bcmp\n" - " Deprecated. Use '--encode etc1s' instead.\n" - " --uastc []\n" - " Deprecated. Use '--encode uastc' instead.\n" - " --zcmp []\n" - " Supercompress the data with Zstandard. Implies --t2. Can be used\n" - " with data in any format except ETC1S / BasisLZ. Most\n" - " effective with RDO-conditioned UASTC or uncompressed formats. The\n" - " optional compressionLevel range is 1 - 22 and the default is 3.\n" - " Lower values=faster but give less compression. Values above 20\n" - " should be used with caution as they require more memory.\n" - " --threads \n" - " Explicitly set the number of threads to use during compression.\n" - " By default, ETC1S / BasisLZ and ASTC compression will use the\n" - " number of threads reported by thread::hardware_concurrency or 1\n" - " if value returned is 0.\n" - " --verbose\n" - " Print encoder/compressor activity status to stdout. Currently\n" - " only the astc, etc1s and uastc encoders emit status.\n" - "\n"; - ktxApp::usage(); - cerr << endl << - "In case of ambiguity, such as when the last option is one with an optional\n" - "parameter, options can be separated from file names with \" -- \".\n" - "\n" - "Any specified ASTC, ETC1S / BasisLZ, UASTC and supercompression options are\n" - "recorded in the metadata item @c KTXwriterScParams in the output file.\n" - << endl; + void usage() { + cerr << " --encode \n" + " Compress the image data to ASTC, transcodable ETC1S / BasisLZ or\n" + " high-quality transcodable UASTC format. Implies --t2.\n" + " With each encoding option the following encoder specific options\n" + " become valid, otherwise they are ignored.\n\n" + " astc:\n" + " Create a texture in high-quality ASTC format.\n" + " --astc_blk_d \n" + " Specify block dimension to use for compressing the textures.\n" + " e.g. --astc_blk_d 6x5 for 2D or --astc_blk_d 6x6x6 for 3D.\n" + " 6x6 is the default for 2D.\n\n" + " Supported 2D block dimensions are:\n\n" + " 4x4: 8.00 bpp 10x5: 2.56 bpp\n" + " 5x4: 6.40 bpp 10x6: 2.13 bpp\n" + " 5x5: 5.12 bpp 8x8: 2.00 bpp\n" + " 6x5: 4.27 bpp 10x8: 1.60 bpp\n" + " 6x6: 3.56 bpp 10x10: 1.28 bpp\n" + " 8x5: 3.20 bpp 12x10: 1.07 bpp\n" + " 8x6: 2.67 bpp 12x12: 0.89 bpp\n\n" + " Supported 3D block dimensions are:\n\n" + " 3x3x3: 4.74 bpp 5x5x4: 1.28 bpp\n" + " 4x3x3: 3.56 bpp 5x5x5: 1.02 bpp\n" + " 4x4x3: 2.67 bpp 6x5x5: 0.85 bpp\n" + " 4x4x4: 2.00 bpp 6x6x5: 0.71 bpp\n" + " 5x4x4: 1.60 bpp 6x6x6: 0.59 bpp\n" + " --astc_mode \n" + " Specify which encoding mode to use. LDR is the default unless the\n" + " input image is 16-bit in which case the default is HDR.\n" + " --astc_quality \n" + " The quality level configures the quality-performance tradeoff for\n" + " the compressor; more complete searches of the search space\n" + " improve image quality at the expense of compression time. Default\n" + " is 'medium'. The quality level can be set between fastest (0) and\n" + " exhaustive (100) via the following fixed quality presets:\n\n" + " Level | Quality\n" + " ---------- | -----------------------------\n" + " fastest | (equivalent to quality = 0)\n" + " fast | (equivalent to quality = 10)\n" + " medium | (equivalent to quality = 60)\n" + " thorough | (equivalent to quality = 98)\n" + " exhaustive | (equivalent to quality = 100)\n" + " --astc_perceptual\n" + " The codec should optimize for perceptual error, instead of direct\n" + " RMS error. This aims to improve perceived image quality, but\n" + " typically lowers the measured PSNR score. Perceptual methods are\n" + " currently only available for normal maps and RGB color data.\n" + " etc1s:\n" + " Supercompress the image data with ETC1S / BasisLZ.\n" + " RED images will become RGB with RED in each component. RG images\n" + " will have R in the RGB part and G in the alpha part of the\n" + " compressed texture. When set, the following BasisLZ-related\n" + " options become valid, otherwise they are ignored.\n\n" + " --no_multithreading\n" + " Disable multithreading. Deprecated. For backward compatibility.\n" + " Use --threads 1 instead.\n" + " --clevel \n" + " ETC1S / BasisLZ compression level, an encoding speed vs. quality\n" + " tradeoff. Range is [0,5], default is 1. Higher values are slower\n" + " but give higher quality.\n" + " --qlevel \n" + " ETC1S / BasisLZ quality level. Range is [1,255]. Lower gives\n" + " better compression/lower quality/faster. Higher gives less\n" + " compression/higher quality/slower. --qlevel automatically\n" + " determines values for --max_endpoints, --max-selectors,\n" + " --endpoint_rdo_threshold and --selector_rdo_threshold for the\n" + " target quality level. Setting these options overrides the values\n" + " determined by -qlevel which defaults to 128 if neither it nor\n" + " both of --max_endpoints and --max_selectors have been set.\n" + "\n" + " Note that both of --max_endpoints and --max_selectors\n" + " must be set for them to have any effect. If all three options\n" + " are set, a warning will be issued that --qlevel will be ignored.\n" + "\n" + " Note also that --qlevel will only determine values for\n" + " --endpoint_rdo_threshold and --selector_rdo_threshold when\n" + " its value exceeds 128, otherwise their defaults will be used.\n" + " --max_endpoints \n" + " Manually set the maximum number of color endpoint clusters. Range\n" + " is [1,16128]. Default is 0, unset.\n" + " --endpoint_rdo_threshold \n" + " Set endpoint RDO quality threshold. The default is 1.25. Lower\n" + " is higher quality but less quality per output bit (try\n" + " [1.0,3.0]). This will override the value chosen by --qlevel.\n" + " --max_selectors \n" + " Manually set the maximum number of color selector clusters from\n" + " [1,16128]. Default is 0, unset.\n" + " --selector_rdo_threshold \n" + " Set selector RDO quality threshold. The default is 1.25. Lower\n" + " is higher quality but less quality per output bit (try\n" + " [1.0,3.0]). This will override the value chosen by --qlevel.\n" + " --no_endpoint_rdo\n" + " Disable endpoint rate distortion optimizations. Slightly faster,\n" + " less noisy output, but lower quality per output bit. Default is\n" + " to do endpoint RDO.\n" + " --no_selector_rdo\n" + " Disable selector rate distortion optimizations. Slightly faster,\n" + " less noisy output, but lower quality per output bit. Default is\n" + " to do selector RDO.\n\n" + " uastc:\n" + " Create a texture in high-quality transcodable UASTC format.\n" + " --uastc_quality \n" + " This optional parameter selects a speed vs quality\n" + " tradeoff as shown in the following table:\n" + "\n" + " Level | Speed | Quality\n" + " ----- | --------- | -------\n" + " 0 | Fastest | 43.45dB\n" + " 1 | Faster | 46.49dB\n" + " 2 | Default | 47.47dB\n" + " 3 | Slower | 48.01dB\n" + " 4 | Very slow | 48.24dB\n" + "\n" + " You are strongly encouraged to also specify --zcmp to losslessly\n" + " compress the UASTC data. This and any LZ-style compression can\n" + " be made more effective by conditioning the UASTC texture data\n" + " using the Rate Distortion Optimization (RDO) post-process stage.\n" + " When uastc encoding is set the following options become available\n" + " for controlling RDO:\n\n" + " --uastc_rdo_l []\n" + " Enable UASTC RDO post-processing and optionally set UASTC RDO\n" + " quality scalar (lambda) to @e lambda. Lower values yield higher\n" + " quality/larger LZ compressed files, higher values yield lower\n" + " quality/smaller LZ compressed files. A good range to try is\n" + " [.25,10]. For normal maps a good range is [.25,.75]. The full\n" + " range is [.001,10.0]. Default is 1.0.\n" + "\n" + " Note that previous versions used the --uastc_rdo_q option which\n" + " was removed because the RDO algorithm changed.\n" + " --uastc_rdo_d \n" + " Set UASTC RDO dictionary size in bytes. Default is 4096. Lower\n" + " values=faster, but give less compression. Range is [64,65536].\n" + " --uastc_rdo_b \n" + " Set UASTC RDO max smooth block error scale. Range is [1.0,300.0].\n" + " Default is 10.0, 1.0 is disabled. Larger values suppress more\n" + " artifacts (and allocate more bits) on smooth blocks.\n" + " --uastc_rdo_s \n" + " Set UASTC RDO max smooth block standard deviation. Range is\n" + " [.01,65536.0]. Default is 18.0. Larger values expand the range\n" + " of blocks considered smooth.
\n" + " --uastc_rdo_f\n" + " Do not favor simpler UASTC modes in RDO mode.\n" + " --uastc_rdo_m\n" + " Disable RDO multithreading (slightly higher compression,\n" + " deterministic).\n\n" + " --input_swizzle \n" + " Swizzle the input components according to swizzle which is an\n" + " alhpanumeric sequence matching the regular expression\n" + " ^[rgba01]{4}$.\n" + " --normal_mode\n" + " Only valid for linear textures with two or more components. If\n" + " the input texture has three or four linear components it is\n" + " assumed to be a three component linear normal map storing unit\n" + " length normals as (R=X, G=Y, B=Z). A fourth component will be\n" + " ignored. The map will be converted to a two component X+Y normal\n" + " map stored as (RGB=X, A=Y) prior to encoding. If unsure that\n" + " your normals are unit length, use @b --normalize. If the input\n" + " has 2 linear components it is assumed to be an X+Y map of unit\n" + " normals.\n\n" + " The Z component can be recovered programmatically in shader\n" + " code by using the equations:\n\n" + " nml.xy = texture(...).ga; // Load in [0,1]\n" + " nml.xy = nml.xy * 2.0 - 1.0; // Unpack to [-1,1]\n" + " nml.z = sqrt(1 - dot(nml.xy, nml.xy)); // Compute Z\n\n" + " Encoding is optimized for normal maps. For ASTC encoding,\n" + " '--encode astc', encoder parameters are tuned for better quality\n" + " on normal maps. . For ETC1S encoding, '--encode etc1s',i RDO is\n" + " disabled (no selector RDO, no endpoint RDO) to provide better\n" + " quality.\n\n" + " You can prevent conversion of the normal map to two components\n" + " by specifying '--input_swizzle rgb1'.\n\n" + " --normalize\n" + " Normalize input normals to have a unit length. Only valid for\n" + " linear textures with 2 or more components. For 2-component inputs\n" + " 2D unit normals are calculated. Do not use these 2D unit normals\n" + " to generate X+Y normals for --normal_mode. For 4-component inputs\n" + " a 3D unit normal is calculated. 1.0 is used for the value of the\n" + " 4th component.\n" + " --no_sse\n" + " Forbid use of the SSE instruction set. Ignored if CPU does not\n" + " support SSE. Only the Basis Universal compressor uses SSE.\n" + " --bcmp\n" + " Deprecated. Use '--encode etc1s' instead.\n" + " --uastc []\n" + " Deprecated. Use '--encode uastc' instead.\n" + " --zcmp []\n" + " Supercompress the data with Zstandard. Implies --t2. Can be used\n" + " with data in any format except ETC1S / BasisLZ. Most\n" + " effective with RDO-conditioned UASTC or uncompressed formats. The\n" + " optional compressionLevel range is 1 - 22 and the default is 3.\n" + " Lower values=faster but give less compression. Values above 20\n" + " should be used with caution as they require more memory.\n" + " --threads \n" + " Explicitly set the number of threads to use during compression.\n" + " By default, ETC1S / BasisLZ and ASTC compression will use the\n" + " number of threads reported by thread::hardware_concurrency or 1\n" + " if value returned is 0.\n" + " --verbose\n" + " Print encoder/compressor activity status to stdout. Currently\n" + " only the astc, etc1s and uastc encoders emit status.\n" + "\n"; + ktxApp::usage(); + cerr << endl + << "In case of ambiguity, such as when the last option is one with an optional\n" + "parameter, options can be separated from file names with \" -- \".\n" + "\n" + "Any specified ASTC, ETC1S / BasisLZ, UASTC and supercompression options are\n" + "recorded in the metadata item @c KTXwriterScParams in the output file.\n" + << endl; } }; -scApp::scApp(string& version, string& defaultVersion, - scApp::commandOptions& options) - : ktxApp(version, defaultVersion, options), options(options) -{ - argparser::option my_option_list[] = { - { "zcmp", argparser::option::optional_argument, NULL, 'z' }, - { "no_multithreading", argparser::option::no_argument, NULL, 'N' }, - { "threads", argparser::option::required_argument, NULL, 't' }, - { "clevel", argparser::option::required_argument, NULL, 'c' }, - { "qlevel", argparser::option::required_argument, NULL, 'q' }, - { "max_endpoints", argparser::option::required_argument, NULL, 'e' }, - { "endpoint_rdo_threshold", argparser::option::required_argument, NULL, 'E' }, - { "max_selectors", argparser::option::required_argument, NULL, 'u' }, - { "selector_rdo_threshold", argparser::option::required_argument, NULL, 'S' }, - { "normal_mode", argparser::option::no_argument, NULL, 'n' }, - { "separate_rg_to_color_alpha", argparser::option::no_argument, NULL, 1000 }, - { "no_endpoint_rdo", argparser::option::no_argument, NULL, 1001 }, - { "no_selector_rdo", argparser::option::no_argument, NULL, 1002 }, - { "no_sse", argparser::option::no_argument, NULL, 1011 }, - { "uastc_quality", argparser::option::required_argument, NULL, 1003 }, - { "uastc_rdo_l", argparser::option::optional_argument, NULL, 1004 }, - { "uastc_rdo_d", argparser::option::required_argument, NULL, 1005 }, - { "uastc_rdo_b", argparser::option::optional_argument, NULL, 1006 }, - { "uastc_rdo_s", argparser::option::optional_argument, NULL, 1007 }, - { "uastc_rdo_f", argparser::option::no_argument, NULL, 1008 }, - { "uastc_rdo_m", argparser::option::no_argument, NULL, 1009 }, - { "verbose", argparser::option::no_argument, NULL, 1010 }, - { "astc_blk_d", argparser::option::required_argument, NULL, 1012 }, - { "astc_mode", argparser::option::required_argument, NULL, 1013 }, - { "astc_quality", argparser::option::required_argument, NULL, 1014 }, - { "astc_perceptual", argparser::option::no_argument, NULL, 1015 }, - { "encode", argparser::option::required_argument, NULL, 1016 }, - { "input_swizzle", argparser::option::required_argument, NULL, 1100}, - { "normalize", argparser::option::no_argument, NULL, 1017 }, - // Deprecated options - { "bcmp", argparser::option::no_argument, NULL, 'b' }, - { "uastc", argparser::option::optional_argument, NULL, 1018 } - }; - const int lastOptionIndex = sizeof(my_option_list) - / sizeof(argparser::option); - option_list.insert(option_list.begin(), my_option_list, - my_option_list + lastOptionIndex); - short_opts += "z;Nt:c:q:e:E:u:S:nb"; +scApp::scApp(string& version, string& defaultVersion, scApp::commandOptions& options) + : ktxApp(version, defaultVersion, options), options(options) { + argparser::option my_option_list[] = {{"zcmp", argparser::option::optional_argument, NULL, 'z'}, + {"no_multithreading", argparser::option::no_argument, NULL, 'N'}, + {"threads", argparser::option::required_argument, NULL, 't'}, + {"clevel", argparser::option::required_argument, NULL, 'c'}, + {"qlevel", argparser::option::required_argument, NULL, 'q'}, + {"max_endpoints", argparser::option::required_argument, NULL, 'e'}, + {"endpoint_rdo_threshold", argparser::option::required_argument, NULL, 'E'}, + {"max_selectors", argparser::option::required_argument, NULL, 'u'}, + {"selector_rdo_threshold", argparser::option::required_argument, NULL, 'S'}, + {"normal_mode", argparser::option::no_argument, NULL, 'n'}, + {"separate_rg_to_color_alpha", argparser::option::no_argument, NULL, 1000}, + {"no_endpoint_rdo", argparser::option::no_argument, NULL, 1001}, + {"no_selector_rdo", argparser::option::no_argument, NULL, 1002}, + {"no_sse", argparser::option::no_argument, NULL, 1011}, + {"uastc_quality", argparser::option::required_argument, NULL, 1003}, + {"uastc_rdo_l", argparser::option::optional_argument, NULL, 1004}, + {"uastc_rdo_d", argparser::option::required_argument, NULL, 1005}, + {"uastc_rdo_b", argparser::option::optional_argument, NULL, 1006}, + {"uastc_rdo_s", argparser::option::optional_argument, NULL, 1007}, + {"uastc_rdo_f", argparser::option::no_argument, NULL, 1008}, + {"uastc_rdo_m", argparser::option::no_argument, NULL, 1009}, + {"verbose", argparser::option::no_argument, NULL, 1010}, + {"astc_blk_d", argparser::option::required_argument, NULL, 1012}, + {"astc_mode", argparser::option::required_argument, NULL, 1013}, + {"astc_quality", argparser::option::required_argument, NULL, 1014}, + {"astc_perceptual", argparser::option::no_argument, NULL, 1015}, + {"encode", argparser::option::required_argument, NULL, 1016}, + {"input_swizzle", argparser::option::required_argument, NULL, 1100}, + {"normalize", argparser::option::no_argument, NULL, 1017}, + // Deprecated options + {"bcmp", argparser::option::no_argument, NULL, 'b'}, + {"uastc", argparser::option::optional_argument, NULL, 1018}}; + const int lastOptionIndex = sizeof(my_option_list) / sizeof(argparser::option); + option_list.insert(option_list.begin(), my_option_list, my_option_list + lastOptionIndex); + short_opts += "z;Nt:c:q:e:E:u:S:nb"; } -void -scApp::captureOption(const argparser& parser, HasArg hasArg) -{ +void scApp::captureOption(const argparser& parser, HasArg hasArg) { uint32_t indexDecrement = 1; bool captureArg = false; - if ((hasArg == eOptional && parser.optarg.size() > 0) || hasArg == eRequired) - indexDecrement = 2; + if ((hasArg == eOptional && parser.optarg.size() > 0) || hasArg == eRequired) indexDecrement = 2; scparams += parser.argv[parser.optind - indexDecrement] + " "; - if (captureArg) - scparams += parser.optarg + " "; + if (captureArg) scparams += parser.optarg + " "; } -void -scApp::validateOptions() { +void scApp::validateOptions() { if ((options.bopts.maxEndpoints == 0) ^ (options.bopts.maxSelectors == 0)) { cerr << name << ": Both or neither of --max_endpoints and" << " --max_selectors must be specified." << endl; usage(); exit(1); } - if (options.bopts.qualityLevel - && (options.bopts.maxEndpoints + options.bopts.maxSelectors)) { + if (options.bopts.qualityLevel && (options.bopts.maxEndpoints + options.bopts.maxSelectors)) { cerr << name << ": Warning: ignoring --qlevel as it, --max_endpoints" << " and --max_selectors are all set." << endl; } } -void -scApp::validateSwizzle(string& swizzle) -{ +void scApp::validateSwizzle(string& swizzle) { if (swizzle.size() != 4) { error("a swizzle parameter must have 4 characters."); exit(1); } - std::for_each(swizzle.begin(), swizzle.end(), [](char & c) { - c = (char)::tolower(c); - }); + std::for_each(swizzle.begin(), swizzle.end(), [](char& c) { c = (char)::tolower(c); }); for (int i = 0; i < 4; i++) { - if (swizzle[i] != 'r' - && swizzle[i] != 'g' - && swizzle[i] != 'b' - && swizzle[i] != 'a' - && swizzle[i] != '0' - && swizzle[i] != '1') { + if (swizzle[i] != 'r' && swizzle[i] != 'g' && swizzle[i] != 'b' && swizzle[i] != 'a' && swizzle[i] != '0' && + swizzle[i] != '1') { error("invalid character in swizzle."); usage(); exit(1); @@ -874,17 +808,14 @@ scApp::validateSwizzle(string& swizzle) // Derived classes' processOption will have to explicitly call this one // and should call it after processing their own options. -bool -scApp::processOption(argparser& parser, int opt) -{ +bool scApp::processOption(argparser& parser, int opt) { bool hasArg = false; bool capture = true; switch (opt) { - case 'z': + case 'z': if (options.etc1s) { - cerr << "Only one of '--encode etc1s | --bcmp' and --zcmp can be specified." - << endl; + cerr << "Only one of '--encode etc1s | --bcmp' and --zcmp can be specified." << endl; usage(); exit(1); } @@ -895,144 +826,136 @@ scApp::processOption(argparser& parser, int opt) hasArg = true; } break; - case 'c': + case 'c': options.bopts.compressionLevel = strtoi(parser.optarg.c_str()); hasArg = true; break; - case 'e': + case 'e': options.bopts.maxEndpoints = strtoi(parser.optarg.c_str()); hasArg = true; break; - case 'E': + case 'E': options.bopts.endpointRDOThreshold = strtof(parser.optarg.c_str(), nullptr); hasArg = true; break; - case 'N': + case 'N': options.threadCount = 1; capture = false; break; - case 'n': + case 'n': options.normalMode = true; break; - case 1001: + case 1001: options.bopts.noEndpointRDO = 1; break; - case 1002: + case 1002: options.bopts.noSelectorRDO = 1; break; - case 'q': + case 'q': options.bopts.qualityLevel = strtoi(parser.optarg.c_str()); hasArg = true; break; - case 1000: + case 1000: options.bopts.separateRGToRGB_A = 1; break; - case 'u': + case 'u': options.bopts.maxSelectors = strtoi(parser.optarg.c_str()); hasArg = true; break; - case 'S': + case 'S': options.bopts.selectorRDOThreshold = strtof(parser.optarg.c_str(), nullptr); hasArg = true; break; - case 't': + case 't': options.threadCount = strtoi(parser.optarg.c_str()); capture = false; break; - case 1003: - { - ktx_uint32_t level = strtoi(parser.optarg.c_str()); - level = clamp(level, 0, KTX_PACK_UASTC_MAX_LEVEL); - // Ensure the last one wins in case of multiple of these args. - options.bopts.uastcFlags = (unsigned int)~KTX_PACK_UASTC_LEVEL_MASK; - options.bopts.uastcFlags |= level; - hasArg = true; - } - break; - case 1004: + case 1003: { + ktx_uint32_t level = strtoi(parser.optarg.c_str()); + level = clamp(level, 0, KTX_PACK_UASTC_MAX_LEVEL); + // Ensure the last one wins in case of multiple of these args. + options.bopts.uastcFlags = (unsigned int)~KTX_PACK_UASTC_LEVEL_MASK; + options.bopts.uastcFlags |= level; + hasArg = true; + } break; + case 1004: options.bopts.uastcRDO = true; if (parser.optarg.size() > 0) { - options.bopts.uastcRDOQualityScalar = - strtof(parser.optarg.c_str(), nullptr); + options.bopts.uastcRDOQualityScalar = strtof(parser.optarg.c_str(), nullptr); hasArg = true; } break; - case 1005: + case 1005: options.bopts.uastcRDODictSize = strtoi(parser.optarg.c_str()); hasArg = true; break; - case 1006: - options.bopts.uastcRDOMaxSmoothBlockErrorScale = - strtof(parser.optarg.c_str(), nullptr); + case 1006: + options.bopts.uastcRDOMaxSmoothBlockErrorScale = strtof(parser.optarg.c_str(), nullptr); hasArg = true; break; - case 1007: - options.bopts.uastcRDOMaxSmoothBlockStdDev = - strtof(parser.optarg.c_str(), nullptr); + case 1007: + options.bopts.uastcRDOMaxSmoothBlockStdDev = strtof(parser.optarg.c_str(), nullptr); hasArg = true; break; - case 1008: + case 1008: options.bopts.uastcRDODontFavorSimplerModes = true; break; - case 1009: + case 1009: options.bopts.uastcRDONoMultithreading = true; break; - case 1010: + case 1010: options.bopts.verbose = true; options.astcopts.verbose = true; capture = false; break; - case 1011: + case 1011: options.bopts.noSSE = true; capture = true; break; - case 1012: // astc_blk_d + case 1012: // astc_blk_d options.astcopts.blockDimension = astcBlockDimension(parser.optarg.c_str()); hasArg = true; break; - case 1013: // astc_mode + case 1013: // astc_mode options.astcopts.mode = astcEncoderMode(parser.optarg.c_str()); hasArg = true; break; - case 1014: // astc_quality + case 1014: // astc_quality options.astcopts.qualityLevel = astcQualityLevel(parser.optarg.c_str()); hasArg = true; break; - case 'b': + case 'b': if (options.zcmp) { cerr << "Only one of --bcmp and --zcmp can be specified.\n" - << "--bcmp is deprecated, use '--encode etc1s' instead." - << endl; + << "--bcmp is deprecated, use '--encode etc1s' instead." << endl; usage(); exit(1); } if (options.bopts.uastc) { cerr << "Only one of --bcmp and '--encode etc1s | --uastc' can be specified.\n" - << "--bcmp is deprecated, use '--encode etc1s' instead." - << endl; + << "--bcmp is deprecated, use '--encode etc1s' instead." << endl; usage(); exit(1); } options.etc1s = 1; options.ktx2 = 1; break; - case 1015: + case 1015: options.astcopts.perceptual = true; break; - case 1016: + case 1016: setEncoder(parser.optarg); options.ktx2 = 1; hasArg = true; break; - case 1017: + case 1017: options.normalize = true; break; - case 1018: + case 1018: if (options.etc1s) { - cerr << "Only one of `--encode etc1s | --bcmp` and `--uastc []` can be specified." - << endl; - usage(); - exit(1); + cerr << "Only one of `--encode etc1s | --bcmp` and `--uastc []` can be specified." << endl; + usage(); + exit(1); } options.bopts.uastc = 1; options.ktx2 = 1; @@ -1045,20 +968,19 @@ scApp::processOption(argparser& parser, int opt) hasArg = true; } break; - case 1100: + case 1100: validateSwizzle(parser.optarg); options.inputSwizzle = parser.optarg; hasArg = true; - capture = false; // Not a compression parameter. + capture = false; // Not a compression parameter. break; - default: + default: return false; } if (capture) { scparams += parser.argv[parser.optind - (hasArg ? 2 : 1)] + " "; - if (hasArg) - scparams += parser.optarg + " "; + if (hasArg) scparams += parser.optarg + " "; } return true; @@ -1073,10 +995,7 @@ scApp::processOption(argparser& parser, int opt) * * @return 0 on success, an exit code on error. */ -int -scApp::encode(ktxTexture2* texture, const string& swizzle, - const string& filename) -{ +int scApp::encode(ktxTexture2* texture, const string& swizzle, const string& filename) { ktx_error_code_e result; khr_df_transfer_e oetf = ktxTexture2_GetOETF_e(texture); @@ -1085,13 +1004,12 @@ scApp::encode(ktxTexture2* texture, const string& swizzle, << "--normal_mode specified but input file(s) are not " << "linear." << endl; return 1; - } if (options.etc1s || options.bopts.uastc) { commandOptions::basisOptions& bopts = options.bopts; if (swizzle.size()) { for (uint32_t i = 0; i < swizzle.size(); i++) { - bopts.inputSwizzle[i] = swizzle[i]; + bopts.inputSwizzle[i] = swizzle[i]; } } @@ -1103,30 +1021,25 @@ scApp::encode(ktxTexture2* texture, const string& swizzle, #endif result = ktxTexture2_CompressBasisEx(texture, &bopts); if (KTX_SUCCESS != result) { - cerr << name - << " failed to compress KTX file \"" << filename - << "\" with Basis Universal; KTX error: " - << ktxErrorString(result) << endl; + cerr << name << " failed to compress KTX file \"" << filename + << "\" with Basis Universal; KTX error: " << ktxErrorString(result) << endl; return 2; } } else if (options.astc) { commandOptions::astcOptions& astcopts = options.astcopts; if (swizzle.size()) { for (uint32_t i = 0; i < swizzle.size(); i++) { - astcopts.inputSwizzle[i] = swizzle[i]; + astcopts.inputSwizzle[i] = swizzle[i]; } } astcopts.threadCount = options.threadCount; astcopts.normalMap = options.normalMode; - result = ktxTexture2_CompressAstcEx((ktxTexture2*)texture, - &astcopts); + result = ktxTexture2_CompressAstcEx((ktxTexture2*)texture, &astcopts); if (KTX_SUCCESS != result) { - cerr << name - << " failed to compress KTX file \"" << filename - << "\" with ASTC; KTX error: " - << ktxErrorString(result) << endl; + cerr << name << " failed to compress KTX file \"" << filename << "\" with ASTC; KTX error: " << ktxErrorString(result) + << endl; return 2; } } else { @@ -1134,21 +1047,16 @@ scApp::encode(ktxTexture2* texture, const string& swizzle, } if (KTX_SUCCESS == result) { if (options.zcmp) { - result = ktxTexture2_DeflateZstd((ktxTexture2*)texture, - options.zcmpLevel); + result = ktxTexture2_DeflateZstd((ktxTexture2*)texture, options.zcmpLevel); if (KTX_SUCCESS != result) { - cerr << name << ": Zstd deflation of \"" << filename - << "\" failed; KTX error: " - << ktxErrorString(result) << endl; + cerr << name << ": Zstd deflation of \"" << filename << "\" failed; KTX error: " << ktxErrorString(result) << endl; return 2; } } } if (!getParamsStr().empty()) { - ktxHashList_AddKVPair(&texture->kvDataHead, - scparamKey.c_str(), - (ktx_uint32_t)getParamsStr().length() + 1, - getParamsStr().c_str()); + ktxHashList_AddKVPair(&texture->kvDataHead, scparamKey.c_str(), (ktx_uint32_t)getParamsStr().length() + 1, + getParamsStr().c_str()); } return 0; } diff --git a/utils/stdafx.h b/utils/stdafx.h index e6a68716a1..3dff76c035 100644 --- a/utils/stdafx.h +++ b/utils/stdafx.h @@ -6,21 +6,21 @@ #pragma once #if defined(_WIN32) - // _CRT_SECURE_NO_WARNINGS must be defined before , - // and and - #define _CRT_SECURE_NO_WARNINGS +// _CRT_SECURE_NO_WARNINGS must be defined before , +// and and +#define _CRT_SECURE_NO_WARNINGS #endif #include #include #ifdef _WIN32 - #include - #if _MSC_VER < 1900 - #define snprintf _snprintf - #endif +#include +#if _MSC_VER < 1900 +#define snprintf _snprintf +#endif #else - #include - #define _setmode(x, y) 0 +#include +#define _setmode(x, y) 0 #endif #include diff --git a/utils/unused.h b/utils/unused.h index 31870ab639..45ba073cf5 100644 --- a/utils/unused.h +++ b/utils/unused.h @@ -17,10 +17,10 @@ #if (__cplusplus >= 201703L) #define MAYBE_UNUSED [[maybe_unused]] #elif __GNUC__ || __clang__ - #define MAYBE_UNUSED __attribute__((unused)) +#define MAYBE_UNUSED __attribute__((unused)) #else - // Boohoo. VC++ has no equivalent - #define MAYBE_UNUSED +// Boohoo. VC++ has no equivalent +#define MAYBE_UNUSED #endif #define U_ASSERT_ONLY MAYBE_UNUSED @@ -28,7 +28,7 @@ // For unused parameters of c functions. Portable. #define UNUSED(x) (void)(x) -#if !__clang__ && __GNUC__ // grumble ... clang ... grumble +#if !__clang__ && __GNUC__ // grumble ... clang ... grumble #define FALLTHROUGH __attribute__((fallthrough)) #else #define FALLTHROUGH