From 7e4007d427cbd1d1ca670af170b81aada5e62570 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Fri, 18 Nov 2016 23:16:29 +0100 Subject: [PATCH] Updated GLI version used in GLM tests --- test/external/gli/CMakeLists.txt | 13 +- test/external/gli/clear.hpp | 47 ++ test/external/gli/comparison.hpp | 30 + test/external/gli/convert.hpp | 25 + test/external/gli/copy.hpp | 62 ++ test/external/gli/core/clear.hpp | 25 + test/external/gli/core/clear.inl | 71 ++ test/external/gli/core/comparison.inl | 100 +++ test/external/gli/core/convert.inl | 45 + test/external/gli/core/convert_func.hpp | 767 +++++++++++++++++ test/external/gli/core/coord.hpp | 87 ++ test/external/gli/core/copy.inl | 112 +++ test/external/gli/core/duplicate.inl | 267 ++++++ test/external/gli/core/dx.inl | 311 +++++++ test/external/gli/core/file.hpp | 15 + test/external/gli/core/file.inl | 19 + test/external/gli/core/filter.hpp | 23 + test/external/gli/core/filter.inl | 8 + test/external/gli/core/filter_compute.hpp | 390 +++++++++ test/external/gli/core/flip.hpp | 17 + test/external/gli/core/flip.inl | 338 ++++++++ test/external/gli/core/format.inl | 376 +++++++++ test/external/gli/core/generate_mipmaps.hpp | 25 - test/external/gli/core/generate_mipmaps.inl | 184 ++-- test/external/gli/core/gl.inl | 366 ++++++++ test/external/gli/core/image.inl | 251 ++++++ test/external/gli/core/image2d.hpp | 169 ---- test/external/gli/core/image2d.inl | 229 ----- test/external/gli/core/levels.inl | 23 + test/external/gli/core/load.inl | 55 ++ test/external/gli/core/load_dds.inl | 324 +++++++ test/external/gli/core/load_kmg.inl | 103 +++ test/external/gli/core/load_ktx.inl | 137 +++ test/external/gli/core/make_texture.inl | 72 ++ test/external/gli/core/mipmaps_compute.hpp | 116 +++ test/external/gli/core/operation.hpp | 82 -- test/external/gli/core/operation.inl | 233 ------ test/external/gli/core/operator.hpp | 28 - test/external/gli/core/operator.inl | 210 ----- test/external/gli/core/reduce.inl | 533 ++++++++++++ test/external/gli/core/sampler.inl | 34 + test/external/gli/core/sampler1d.inl | 82 ++ test/external/gli/core/sampler1d_array.inl | 83 ++ test/external/gli/core/sampler2d.inl | 82 ++ test/external/gli/core/sampler2d_array.inl | 83 ++ test/external/gli/core/sampler3d.inl | 82 ++ test/external/gli/core/sampler_cube.inl | 84 ++ test/external/gli/core/sampler_cube_array.inl | 84 ++ test/external/gli/core/save.inl | 22 + test/external/gli/core/save_dds.inl | 139 +++ test/external/gli/core/save_kmg.inl | 80 ++ test/external/gli/core/save_ktx.inl | 114 +++ test/external/gli/core/shared_array.hpp | 48 -- test/external/gli/core/shared_array.inl | 151 ---- test/external/gli/core/shared_ptr.hpp | 41 - test/external/gli/core/shared_ptr.inl | 125 --- test/external/gli/core/size.hpp | 31 - test/external/gli/core/size.inl | 47 -- test/external/gli/core/storage.hpp | 92 ++ test/external/gli/core/storage.inl | 170 ++++ test/external/gli/core/storage_linear.hpp | 98 +++ test/external/gli/core/storage_linear.inl | 186 +++++ test/external/gli/core/texture.inl | 410 +++++++++ test/external/gli/core/texture1d.inl | 79 ++ test/external/gli/core/texture1d_array.inl | 81 ++ test/external/gli/core/texture2d.hpp | 122 --- test/external/gli/core/texture2d.inl | 337 ++------ test/external/gli/core/texture2d_array.hpp | 59 -- test/external/gli/core/texture2d_array.inl | 125 +-- test/external/gli/core/texture3d.inl | 77 ++ test/external/gli/core/texture_cube.hpp | 65 -- test/external/gli/core/texture_cube.inl | 115 +-- test/external/gli/core/texture_cube_array.hpp | 59 -- test/external/gli/core/texture_cube_array.inl | 119 +-- test/external/gli/core/transform.inl | 257 ++++++ test/external/gli/core/view.inl | 169 ++++ test/external/gli/core/workaround.hpp | 392 +++++++++ test/external/gli/duplicate.hpp | 70 ++ test/external/gli/dx.hpp | 490 +++++++++++ test/external/gli/format.hpp | 340 ++++++++ test/external/gli/generate_mipmaps.hpp | 69 ++ test/external/gli/gl.hpp | 373 +++++++++ test/external/gli/gli.hpp | 95 ++- test/external/gli/gtx/compression.hpp | 27 - test/external/gli/gtx/compression.inl | 8 - test/external/gli/gtx/fetch.hpp | 46 - test/external/gli/gtx/fetch.inl | 91 -- test/external/gli/gtx/gl_texture2d.hpp | 33 - test/external/gli/gtx/gl_texture2d.inl | 210 ----- test/external/gli/gtx/gradient.hpp | 38 - test/external/gli/gtx/gradient.inl | 74 -- test/external/gli/gtx/loader.hpp | 37 - test/external/gli/gtx/loader.inl | 46 - test/external/gli/gtx/loader_dds10.hpp | 35 - test/external/gli/gtx/loader_dds10.inl | 595 ------------- test/external/gli/gtx/loader_dds9.hpp | 39 - test/external/gli/gtx/loader_dds9.inl | 790 ------------------ test/external/gli/gtx/loader_tga.hpp | 36 - test/external/gli/gtx/loader_tga.inl | 159 ---- test/external/gli/gtx/wavelet.hpp | 27 - test/external/gli/gtx/wavelet.inl | 8 - test/external/gli/image.hpp | 111 +++ test/external/gli/levels.hpp | 48 ++ test/external/gli/load.hpp | 27 + test/external/gli/load_dds.hpp | 27 + test/external/gli/load_kmg.hpp | 27 + test/external/gli/load_ktx.hpp | 27 + test/external/gli/make_texture.hpp | 51 ++ test/external/gli/reduce.hpp | 95 +++ test/external/gli/sampler.hpp | 49 ++ test/external/gli/sampler1d.hpp | 71 ++ test/external/gli/sampler1d_array.hpp | 72 ++ test/external/gli/sampler2d.hpp | 72 ++ test/external/gli/sampler2d_array.hpp | 72 ++ test/external/gli/sampler3d.hpp | 71 ++ test/external/gli/sampler_cube.hpp | 72 ++ test/external/gli/sampler_cube_array.hpp | 72 ++ test/external/gli/save.hpp | 28 + test/external/gli/save_dds.hpp | 34 + test/external/gli/save_kmg.hpp | 34 + test/external/gli/save_ktx.hpp | 34 + test/external/gli/target.hpp | 51 ++ test/external/gli/texture.hpp | 297 +++++++ test/external/gli/texture1d.hpp | 67 ++ test/external/gli/texture1d_array.hpp | 70 ++ test/external/gli/texture2d.hpp | 67 ++ test/external/gli/texture2d_array.hpp | 70 ++ test/external/gli/texture3d.hpp | 68 ++ test/external/gli/texture_cube.hpp | 68 ++ test/external/gli/texture_cube_array.hpp | 72 ++ test/external/gli/transform.hpp | 87 ++ test/external/gli/type.hpp | 65 ++ test/external/gli/view.hpp | 81 ++ test/gtc/gtc_noise.cpp | 140 ++-- 134 files changed, 12089 insertions(+), 4656 deletions(-) create mode 100644 test/external/gli/clear.hpp create mode 100644 test/external/gli/comparison.hpp create mode 100644 test/external/gli/convert.hpp create mode 100644 test/external/gli/copy.hpp create mode 100644 test/external/gli/core/clear.hpp create mode 100644 test/external/gli/core/clear.inl create mode 100644 test/external/gli/core/comparison.inl create mode 100644 test/external/gli/core/convert.inl create mode 100644 test/external/gli/core/convert_func.hpp create mode 100644 test/external/gli/core/coord.hpp create mode 100644 test/external/gli/core/copy.inl create mode 100644 test/external/gli/core/duplicate.inl create mode 100644 test/external/gli/core/dx.inl create mode 100644 test/external/gli/core/file.hpp create mode 100644 test/external/gli/core/file.inl create mode 100644 test/external/gli/core/filter.hpp create mode 100644 test/external/gli/core/filter.inl create mode 100644 test/external/gli/core/filter_compute.hpp create mode 100644 test/external/gli/core/flip.hpp create mode 100644 test/external/gli/core/flip.inl create mode 100644 test/external/gli/core/format.inl delete mode 100644 test/external/gli/core/generate_mipmaps.hpp create mode 100644 test/external/gli/core/gl.inl create mode 100644 test/external/gli/core/image.inl delete mode 100644 test/external/gli/core/image2d.hpp delete mode 100644 test/external/gli/core/image2d.inl create mode 100644 test/external/gli/core/levels.inl create mode 100644 test/external/gli/core/load.inl create mode 100644 test/external/gli/core/load_dds.inl create mode 100644 test/external/gli/core/load_kmg.inl create mode 100644 test/external/gli/core/load_ktx.inl create mode 100644 test/external/gli/core/make_texture.inl create mode 100644 test/external/gli/core/mipmaps_compute.hpp delete mode 100644 test/external/gli/core/operation.hpp delete mode 100644 test/external/gli/core/operation.inl delete mode 100644 test/external/gli/core/operator.hpp delete mode 100644 test/external/gli/core/operator.inl create mode 100644 test/external/gli/core/reduce.inl create mode 100644 test/external/gli/core/sampler.inl create mode 100644 test/external/gli/core/sampler1d.inl create mode 100644 test/external/gli/core/sampler1d_array.inl create mode 100644 test/external/gli/core/sampler2d.inl create mode 100644 test/external/gli/core/sampler2d_array.inl create mode 100644 test/external/gli/core/sampler3d.inl create mode 100644 test/external/gli/core/sampler_cube.inl create mode 100644 test/external/gli/core/sampler_cube_array.inl create mode 100644 test/external/gli/core/save.inl create mode 100644 test/external/gli/core/save_dds.inl create mode 100644 test/external/gli/core/save_kmg.inl create mode 100644 test/external/gli/core/save_ktx.inl delete mode 100644 test/external/gli/core/shared_array.hpp delete mode 100644 test/external/gli/core/shared_array.inl delete mode 100644 test/external/gli/core/shared_ptr.hpp delete mode 100644 test/external/gli/core/shared_ptr.inl delete mode 100644 test/external/gli/core/size.hpp delete mode 100644 test/external/gli/core/size.inl create mode 100644 test/external/gli/core/storage.hpp create mode 100644 test/external/gli/core/storage.inl create mode 100644 test/external/gli/core/storage_linear.hpp create mode 100644 test/external/gli/core/storage_linear.inl create mode 100644 test/external/gli/core/texture.inl create mode 100644 test/external/gli/core/texture1d.inl create mode 100644 test/external/gli/core/texture1d_array.inl delete mode 100644 test/external/gli/core/texture2d.hpp delete mode 100644 test/external/gli/core/texture2d_array.hpp create mode 100644 test/external/gli/core/texture3d.inl delete mode 100644 test/external/gli/core/texture_cube.hpp delete mode 100644 test/external/gli/core/texture_cube_array.hpp create mode 100644 test/external/gli/core/transform.inl create mode 100644 test/external/gli/core/view.inl create mode 100644 test/external/gli/core/workaround.hpp create mode 100644 test/external/gli/duplicate.hpp create mode 100644 test/external/gli/dx.hpp create mode 100644 test/external/gli/format.hpp create mode 100644 test/external/gli/generate_mipmaps.hpp create mode 100644 test/external/gli/gl.hpp delete mode 100644 test/external/gli/gtx/compression.hpp delete mode 100644 test/external/gli/gtx/compression.inl delete mode 100644 test/external/gli/gtx/fetch.hpp delete mode 100644 test/external/gli/gtx/fetch.inl delete mode 100644 test/external/gli/gtx/gl_texture2d.hpp delete mode 100644 test/external/gli/gtx/gl_texture2d.inl delete mode 100644 test/external/gli/gtx/gradient.hpp delete mode 100644 test/external/gli/gtx/gradient.inl delete mode 100644 test/external/gli/gtx/loader.hpp delete mode 100644 test/external/gli/gtx/loader.inl delete mode 100644 test/external/gli/gtx/loader_dds10.hpp delete mode 100644 test/external/gli/gtx/loader_dds10.inl delete mode 100644 test/external/gli/gtx/loader_dds9.hpp delete mode 100644 test/external/gli/gtx/loader_dds9.inl delete mode 100644 test/external/gli/gtx/loader_tga.hpp delete mode 100644 test/external/gli/gtx/loader_tga.inl delete mode 100644 test/external/gli/gtx/wavelet.hpp delete mode 100644 test/external/gli/gtx/wavelet.inl create mode 100644 test/external/gli/image.hpp create mode 100644 test/external/gli/levels.hpp create mode 100644 test/external/gli/load.hpp create mode 100644 test/external/gli/load_dds.hpp create mode 100644 test/external/gli/load_kmg.hpp create mode 100644 test/external/gli/load_ktx.hpp create mode 100644 test/external/gli/make_texture.hpp create mode 100644 test/external/gli/reduce.hpp create mode 100644 test/external/gli/sampler.hpp create mode 100644 test/external/gli/sampler1d.hpp create mode 100644 test/external/gli/sampler1d_array.hpp create mode 100644 test/external/gli/sampler2d.hpp create mode 100644 test/external/gli/sampler2d_array.hpp create mode 100644 test/external/gli/sampler3d.hpp create mode 100644 test/external/gli/sampler_cube.hpp create mode 100644 test/external/gli/sampler_cube_array.hpp create mode 100644 test/external/gli/save.hpp create mode 100644 test/external/gli/save_dds.hpp create mode 100644 test/external/gli/save_kmg.hpp create mode 100644 test/external/gli/save_ktx.hpp create mode 100644 test/external/gli/target.hpp create mode 100644 test/external/gli/texture.hpp create mode 100644 test/external/gli/texture1d.hpp create mode 100644 test/external/gli/texture1d_array.hpp create mode 100644 test/external/gli/texture2d.hpp create mode 100644 test/external/gli/texture2d_array.hpp create mode 100644 test/external/gli/texture3d.hpp create mode 100644 test/external/gli/texture_cube.hpp create mode 100644 test/external/gli/texture_cube_array.hpp create mode 100644 test/external/gli/transform.hpp create mode 100644 test/external/gli/type.hpp create mode 100644 test/external/gli/view.hpp diff --git a/test/external/gli/CMakeLists.txt b/test/external/gli/CMakeLists.txt index 6b91c288..46d803d1 100644 --- a/test/external/gli/CMakeLists.txt +++ b/test/external/gli/CMakeLists.txt @@ -1,8 +1,11 @@ -set(NAME gli) +set(NAME gli_dummy) file(GLOB ROOT_SOURCE *.cpp) file(GLOB ROOT_INLINE *.inl) file(GLOB ROOT_HEADER *.hpp) +file(GLOB ROOT_TEXT ../*.txt) +file(GLOB ROOT_MD ../*.md) +file(GLOB ROOT_KMG ../doc/spec/*.html) file(GLOB_RECURSE CORE_SOURCE ./core/*.cpp) file(GLOB_RECURSE CORE_INLINE ./core/*.inl) @@ -12,6 +15,8 @@ file(GLOB_RECURSE GTX_SOURCE ./gtx/*.cpp) file(GLOB_RECURSE GTX_INLINE ./gtx/*.inl) file(GLOB_RECURSE GTX_HEADER ./gtx/*.hpp) +source_group("KMG Spec" FILES ${ROOT_KMG}) +source_group("Text Files" FILES ${ROOT_TEXT} ${ROOT_MD}) source_group("Core Files" FILES ${CORE_SOURCE}) source_group("Core Files" FILES ${CORE_INLINE}) source_group("Core Files" FILES ${CORE_HEADER}) @@ -21,7 +26,7 @@ source_group("GTX Files" FILES ${GTX_HEADER}) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..) -add_executable(${NAME} - ${ROOT_SOURCE} ${ROOT_INLINE} ${ROOT_HEADER} +add_executable(${NAME} ${ROOT_TEXT} ${ROOT_MD} ${ROOT_KMG} + ${ROOT_SOURCE} ${ROOT_INLINE} ${ROOT_HEADER} ${CORE_SOURCE} ${CORE_INLINE} ${CORE_HEADER} - ${GTX_SOURCE} ${GTX_INLINE} ${GTX_HEADER} ) + ${GTX_SOURCE} ${GTX_INLINE} ${GTX_HEADER}) diff --git a/test/external/gli/clear.hpp b/test/external/gli/clear.hpp new file mode 100644 index 00000000..a109cc7f --- /dev/null +++ b/test/external/gli/clear.hpp @@ -0,0 +1,47 @@ +/// @brief Include to copy textures or a subset of either textures. These operations are performed without memory allocations. +/// @file gli/clear.hpp + +#pragma once + +namespace gli +{ + /// Clear a complete texture + template + void clear(texture_type& Texture); + + /// Clear a complete texture + template + void clear(texture_type& Texture, gen_type const& BlockData); + + /// Clear a specific image of a texture + template + void clear(texture_type& Texture, size_t Layer, size_t Face, size_t Level, gen_type const& BlockData); + + // Clear an entire level of a texture + template + void clear_level(texture_type& Texture, size_t BaseLevel, gen_type const& BlockData); + + // Clear multiple levels of a texture + template + void clear_level(texture_type& Texture, size_t BaseLevel, size_t LevelCount, gen_type const& BlockData); + + // Clear an entire face of a texture + template + void clear_face(texture_type& Texture, size_t BaseFace, gen_type const& BlockData); + + // Clear multiple faces of a texture + template + void clear_face(texture_type& Texture, size_t BaseFace, size_t FaceCount, gen_type const& BlockData); + + // Clear an entire layer of a texture + template + void clear_layer(texture_type& Texture, size_t BaseLayer, gen_type const& BlockData); + + // Clear multiple layers of a texture + template + void clear_layer(texture_type& Texture, size_t BaseLayer, size_t LayerCount, gen_type const& BlockData); + +}//namespace gli + +#include "./core/clear.inl" + diff --git a/test/external/gli/comparison.hpp b/test/external/gli/comparison.hpp new file mode 100644 index 00000000..687cca4e --- /dev/null +++ b/test/external/gli/comparison.hpp @@ -0,0 +1,30 @@ +/// @brief Include to use operators to compare whether two textures or images are equal +/// @file gli/comparison.hpp + +#pragma once + +#include "image.hpp" +#include "texture1d.hpp" +#include "texture1d_array.hpp" +#include "texture2d.hpp" +#include "texture2d_array.hpp" +#include "texture3d.hpp" +#include "texture_cube.hpp" +#include "texture_cube_array.hpp" + +namespace gli +{ + /// Compare two images. Two images are equal when the date is the same. + bool operator==(image const& ImageA, image const& ImageB); + + /// Compare two images. Two images are equal when the date is the same. + bool operator!=(image const& ImageA, image const& ImageB); + + /// Compare two textures. Two textures are the same when the data, the format and the targets are the same. + bool operator==(texture const& A, texture const& B); + + /// Compare two textures. Two textures are the same when the data, the format and the targets are the same. + bool operator!=(texture const& A, texture const& B); +}//namespace gli + +#include "./core/comparison.inl" diff --git a/test/external/gli/convert.hpp b/test/external/gli/convert.hpp new file mode 100644 index 00000000..36ea2bd7 --- /dev/null +++ b/test/external/gli/convert.hpp @@ -0,0 +1,25 @@ +/// @brief Include to copy textures, images or a subset of either textures or an images. These operations will cause memory allocations. +/// @file gli/convert.hpp + +#pragma once + +#include "texture1d.hpp" +#include "texture1d_array.hpp" +#include "texture2d.hpp" +#include "texture2d_array.hpp" +#include "texture3d.hpp" +#include "texture_cube.hpp" +#include "texture_cube_array.hpp" + +namespace gli +{ + /// Convert texture data to a new format + /// + /// @param Texture Source texture, the format must be uncompressed. + /// @param Format Destination Texture format, it must be uncompressed. + template + texture_type convert(texture_type const& Texture, format Format); + +}//namespace gli + +#include "./core/convert.inl" diff --git a/test/external/gli/copy.hpp b/test/external/gli/copy.hpp new file mode 100644 index 00000000..ec32f87a --- /dev/null +++ b/test/external/gli/copy.hpp @@ -0,0 +1,62 @@ +/// @brief Include to copy textures or a subset of either textures. These operations are performed without memory allocations. +/// @file gli/copy.hpp + +#pragma once + +#include "type.hpp" + +namespace gli +{ + /// Copy a specific image of a texture + template + void copy( + texture_src_type const& TextureSrc, size_t LayerSrc, size_t FaceSrc, size_t LevelSrc, + texture_dst_type& TextureDst, size_t LayerDst, size_t FaceDst, size_t LevelDst); + + /// Copy a texture + template + void copy( + texture_src_type const& TextureSrc, + texture_dst_type& TextureDst); + + // Copy an entire level of a texture + template + void copy_level( + texture_src_type const& TextureSrc, size_t BaseLevelSrc, + texture_dst_type& TextureDst, size_t BaseLevelDst); + + // Copy multiple levels of a texture + template + void copy_level( + texture_src_type const& TextureSrc, size_t BaseLevelSrc, + texture_dst_type& TextureDst, size_t BaseLevelDst, + size_t LevelCount); + + // Copy an entire face of a texture + template + void copy_face( + texture_src_type const& TextureSrc, size_t BaseFaceSrc, + texture_dst_type& TextureDst, size_t BaseFaceDst); + + // Copy multiple faces of a texture + template + void copy_face( + texture_src_type const& TextureSrc, size_t BaseFaceSrc, + texture_dst_type& TextureDst, size_t BaseFaceDst, + size_t FaceCount); + + // Copy an entire layer of a texture + template + void copy_layer( + texture_src_type const& TextureSrc, size_t BaseLayerSrc, + texture_dst_type& TextureDst, size_t BaseLayerDst); + + // Copy multiple layers of a texture + template + void copy_layer( + texture_src_type const& TextureSrc, size_t BaseLayerSrc, + texture_dst_type& TextureDst, size_t BaseLayerDst, + size_t LayerCount); +}//namespace gli + +#include "./core/copy.inl" diff --git a/test/external/gli/core/clear.hpp b/test/external/gli/core/clear.hpp new file mode 100644 index 00000000..20c94221 --- /dev/null +++ b/test/external/gli/core/clear.hpp @@ -0,0 +1,25 @@ +#pragma once + +#include "convert_func.hpp" + +namespace gli{ +namespace detail +{ + template + struct clear + { + static void call(textureType & Texture, typename convert::writeFunc Write, tvec4 const & Color) + { + GLI_ASSERT(Write); + + texture const ConvertTexel(Texture.target(), Texture.format(), texture::extent_type(1), 1, 1, 1); + textureType Texel(ConvertTexel); + Write(Texel, typename textureType::extent_type(0), 0, 0, 0, Color); + + size_t const BlockSize(block_size(Texture.format())); + for(size_t BlockIndex = 0, BlockCount = Texture.size() / BlockSize; BlockIndex < BlockCount; ++BlockIndex) + memcpy(static_cast(Texture.data()) + BlockSize * BlockIndex, Texel.data(), BlockSize); + } + }; +}//namespace detail +}//namespace gli diff --git a/test/external/gli/core/clear.inl b/test/external/gli/core/clear.inl new file mode 100644 index 00000000..d7c682d8 --- /dev/null +++ b/test/external/gli/core/clear.inl @@ -0,0 +1,71 @@ +namespace gli +{ + template + inline void clear(texture_type& Texture) + { + Texture.clear(); + } + + template + inline void clear(texture_type& Texture, gen_type const& BlockData) + { + Texture.clear(BlockData); + } + + template + inline void clear(texture_type& Texture, size_t Layer, size_t Face, size_t Level, gen_type const& BlockData) + { + Texture.clear(Layer, Face, Level, BlockData); + } + + template + inline void clear_level(texture_type& Texture, size_t BaseLevel, size_t LevelCount, gen_type const& BlockData) + { + for(size_t LayerIndex = 0, LayerCount = Texture.layers(); LayerIndex < LayerCount; ++LayerIndex) + for(size_t FaceIndex = 0, FaceCount = Texture.faces(); FaceIndex < FaceCount; ++FaceIndex) + for(size_t LevelIndex = 0; LevelIndex < LevelCount; ++LevelIndex) + { + Texture.template clear(LayerIndex, FaceIndex, BaseLevel + LevelIndex, BlockData); + } + } + + template + inline void clear_level(texture_type& Texture, size_t BaseLevel, gen_type const& BlockData) + { + clear_level(Texture, BaseLevel, 1, BlockData); + } + + template + inline void clear_face(texture_type& Texture, size_t BaseFace, size_t FaceCount, gen_type const& BlockData) + { + for(size_t LayerIndex = 0, LayerCount = Texture.layers(); LayerIndex < LayerCount; ++LayerIndex) + for(size_t FaceIndex = 0; FaceIndex < FaceCount; ++FaceIndex) + for(size_t LevelIndex = 0, LevelCount = Texture.levels(); LevelIndex < LevelCount; ++LevelIndex) + { + Texture.template clear(LayerIndex, BaseFace + FaceIndex, LevelIndex, BlockData); + } + } + + template + inline void clear_face(texture_type& Texture, size_t BaseFace, gen_type const& BlockData) + { + clear_face(Texture, BaseFace, 1, BlockData); + } + + template + inline void clear_layer(texture_type& Texture, size_t BaseLayer, size_t LayerCount, gen_type const& BlockData) + { + for(size_t LayerIndex = 0; LayerIndex < LayerCount; ++LayerIndex) + for(size_t FaceIndex = 0, FaceCount = Texture.faces(); FaceIndex < FaceCount; ++FaceIndex) + for(size_t LevelIndex = 0, LevelCount = Texture.levels(); LevelIndex < LevelCount; ++LevelIndex) + { + Texture.template clear(LayerIndex + BaseLayer, FaceIndex, LevelIndex, BlockData); + } + } + + template + inline void clear_layer(texture_type& Texture, size_t BaseLayer, gen_type const& BlockData) + { + clear_layer(Texture, BaseLayer, 1, BlockData); + } +}//namespace gli diff --git a/test/external/gli/core/comparison.inl b/test/external/gli/core/comparison.inl new file mode 100644 index 00000000..df920b48 --- /dev/null +++ b/test/external/gli/core/comparison.inl @@ -0,0 +1,100 @@ +#include + +namespace gli{ +namespace detail +{ + inline bool equalData(texture const & TextureA, texture const & TextureB) + { + GLI_ASSERT(TextureA.size() == TextureB.size()); + + if(TextureA.data() == TextureB.data()) + return true; + + for(texture::size_type LayerIndex = 0, LayerCount = TextureA.layers(); LayerIndex < LayerCount; ++LayerIndex) + for(texture::size_type FaceIndex = 0, FaceCount = TextureA.faces(); FaceIndex < FaceCount; ++FaceIndex) + for(texture::size_type LevelIndex = 0, LevelCount = TextureA.levels(); LevelIndex < LevelCount; ++LevelIndex) + { + void const* PointerA = TextureA.data(LayerIndex, FaceIndex, LevelIndex); + void const* PointerB = TextureB.data(LayerIndex, FaceIndex, LevelIndex); + if(std::memcmp(PointerA, PointerB, TextureA.size(LevelIndex)) != 0) + return false; + } + + return true; + } +}//namespace detail + + inline bool operator==(image const & ImageA, image const & ImageB) + { + if(!glm::all(glm::equal(ImageA.extent(), ImageB.extent()))) + return false; + if(ImageA.size() != ImageB.size()) + return false; + + return std::memcmp(ImageA.data(), ImageB.data(), ImageA.size()) == 0; + } + + inline bool operator!=(image const & ImageA, image const & ImageB) + { + if(!glm::all(glm::equal(ImageA.extent(), ImageB.extent()))) + return true; + if(ImageA.size() != ImageB.size()) + return true; + + return std::memcmp(ImageA.data(), ImageB.data(), ImageA.size()) != 0; + } + + inline bool equal(texture const & TextureA, texture const & TextureB) + { + if(TextureA.empty() && TextureB.empty()) + return true; + if(TextureA.empty() != TextureB.empty()) + return false; + if(TextureA.target() != TextureB.target()) + return false; + if(TextureA.layers() != TextureB.layers()) + return false; + if(TextureA.faces() != TextureB.faces()) + return false; + if(TextureA.levels() != TextureB.levels()) + return false; + if(TextureA.format() != TextureB.format()) + return false; + if(TextureA.size() != TextureB.size()) + return false; + + return detail::equalData(TextureA, TextureB); + } + + inline bool notEqual(texture const & TextureA, texture const & TextureB) + { + if(TextureA.empty() && TextureB.empty()) + return false; + if(TextureA.empty() != TextureB.empty()) + return true; + if(TextureA.target() != TextureB.target()) + return true; + if(TextureA.layers() != TextureB.layers()) + return true; + if(TextureA.faces() != TextureB.faces()) + return true; + if(TextureA.levels() != TextureB.levels()) + return true; + if(TextureA.format() != TextureB.format()) + return true; + if(TextureA.size() != TextureB.size()) + return true; + + return !detail::equalData(TextureA, TextureB); + } + + inline bool operator==(texture const & A, texture const & B) + { + return gli::equal(A, B); + } + + inline bool operator!=(texture const & A, texture const & B) + { + return gli::notEqual(A, B); + } +}//namespace gli diff --git a/test/external/gli/core/convert.inl b/test/external/gli/core/convert.inl new file mode 100644 index 00000000..b9e5d2e8 --- /dev/null +++ b/test/external/gli/core/convert.inl @@ -0,0 +1,45 @@ +#include "../core/convert_func.hpp" + +namespace gli +{ + template + inline texture_type convert(texture_type const& Texture, format Format) + { + typedef float T; + typedef typename texture::extent_type extent_type; + typedef typename texture_type::size_type size_type; + typedef typename extent_type::value_type component_type; + typedef typename detail::convert::fetchFunc fetch_type; + typedef typename detail::convert::writeFunc write_type; + + GLI_ASSERT(!Texture.empty()); + GLI_ASSERT(!is_compressed(Texture.format()) && !is_compressed(Format)); + + fetch_type Fetch = detail::convert::call(Texture.format()).Fetch; + write_type Write = detail::convert::call(Format).Write; + + texture Storage(Texture.target(), Format, Texture.texture::extent(), Texture.layers(), Texture.faces(), Texture.levels(), Texture.swizzles()); + texture_type Copy(Storage); + + for(size_type Layer = 0; Layer < Texture.layers(); ++Layer) + for(size_type Face = 0; Face < Texture.faces(); ++Face) + for(size_type Level = 0; Level < Texture.levels(); ++Level) + { + extent_type const& Dimensions = Texture.texture::extent(Level); + + for(component_type k = 0; k < Dimensions.z; ++k) + for(component_type j = 0; j < Dimensions.y; ++j) + for(component_type i = 0; i < Dimensions.x; ++i) + { + typename texture_type::extent_type const Texelcoord(extent_type(i, j, k)); + Write( + Copy, Texelcoord, Layer, Face, Level, + Fetch(Texture, Texelcoord, Layer, Face, Level)); + } + } + + return texture_type(Copy); + } + +}//namespace gli + diff --git a/test/external/gli/core/convert_func.hpp b/test/external/gli/core/convert_func.hpp new file mode 100644 index 00000000..d660e573 --- /dev/null +++ b/test/external/gli/core/convert_func.hpp @@ -0,0 +1,767 @@ +#pragma once + +#include "../type.hpp" +#include "../texture1d.hpp" +#include "../texture1d_array.hpp" +#include "../texture2d.hpp" +#include "../texture2d_array.hpp" +#include "../texture3d.hpp" +#include "../texture_cube.hpp" +#include "../texture_cube_array.hpp" +#include +#include +#include + +namespace gli{ +namespace detail +{ + enum convertMode + { + CONVERT_MODE_DEFAULT, + CONVERT_MODE_CAST, + CONVERT_MODE_NORM, + CONVERT_MODE_SRGB, + CONVERT_MODE_HALF, + CONVERT_MODE_RGB9E5, + CONVERT_MODE_RG11B10F, + CONVERT_MODE_RGB10A2UNORM, + CONVERT_MODE_RGB10A2SNORM, + CONVERT_MODE_RGB10A2USCALE, + CONVERT_MODE_RGB10A2SSCALE, + CONVERT_MODE_RGB10A2UINT, + CONVERT_MODE_RGB10A2SINT, + CONVERT_MODE_44UNORM, + CONVERT_MODE_44SCALED, + CONVERT_MODE_4444UNORM, + CONVERT_MODE_4444SCALED, + CONVERT_MODE_565UNORM, + CONVERT_MODE_565SCALED, + CONVERT_MODE_5551UNORM, + CONVERT_MODE_5551SCALED, + CONVERT_MODE_332UNORM + }; + + template + struct accessFunc + {}; + + template + struct accessFunc + { + static genType load(texture1d const & Texture, texture1d::extent_type const & TexelCoord, texture1d::size_type Layer, texture1d::size_type Face, texture1d::size_type Level) + { + GLI_ASSERT(Layer == 0 && Face == 0); + return Texture.load(TexelCoord, Level); + } + + static void store(texture1d & Texture, texture1d::extent_type const & TexelCoord, texture1d::size_type Layer, texture1d::size_type Face, texture1d::size_type Level, genType const & Texel) + { + GLI_ASSERT(Layer == 0 && Face == 0); + Texture.store(TexelCoord, Level, Texel); + } + }; + + template + struct accessFunc + { + static genType load(texture1d_array const& Texture, texture1d_array::extent_type const& TexelCoord, texture1d_array::size_type Layer, texture1d_array::size_type Face, texture1d_array::size_type Level) + { + GLI_ASSERT(Face == 0); + return Texture.load(TexelCoord, Layer, Level); + } + + static void store(texture1d_array& Texture, texture1d_array::extent_type const& TexelCoord, texture1d_array::size_type Layer, texture1d_array::size_type Face, texture1d_array::size_type Level, genType const& Texel) + { + GLI_ASSERT(Face == 0); + Texture.store(TexelCoord, Layer, Level, Texel); + } + }; + + template + struct accessFunc + { + static genType load(texture2d const & Texture, texture2d::extent_type const & TexelCoord, texture2d::size_type Layer, texture2d::size_type Face, texture2d::size_type Level) + { + GLI_ASSERT(Layer == 0 && Face == 0); + return Texture.load(TexelCoord, Level); + } + + static void store(texture2d & Texture, texture2d::extent_type const & TexelCoord, texture2d::size_type Layer, texture2d::size_type Face, texture2d::size_type Level, genType const & Texel) + { + GLI_ASSERT(Layer == 0 && Face == 0); + Texture.store(TexelCoord, Level, Texel); + } + }; + + template + struct accessFunc + { + static genType load(texture2d_array const & Texture, texture2d_array::extent_type const & TexelCoord, texture2d_array::size_type Layer, texture2d_array::size_type Face, texture2d_array::size_type Level) + { + GLI_ASSERT(Face == 0); + return Texture.load(TexelCoord, Layer, Level); + } + + static void store(texture2d_array & Texture, texture2d_array::extent_type const & TexelCoord, texture2d_array::size_type Layer, texture2d_array::size_type Face, texture2d_array::size_type Level, genType const & Texel) + { + GLI_ASSERT(Face == 0); + Texture.store(TexelCoord, Layer, Level, Texel); + } + }; + + template + struct accessFunc + { + static genType load(texture3d const & Texture, texture3d::extent_type const & TexelCoord, texture3d::size_type Layer, texture3d::size_type Face, texture3d::size_type Level) + { + GLI_ASSERT(Layer == 0 && Face == 0); + return Texture.load(TexelCoord, Level); + } + + static void store(texture3d & Texture, texture3d::extent_type const & TexelCoord, texture3d::size_type Layer, texture3d::size_type Face, texture3d::size_type Level, genType const & Texel) + { + GLI_ASSERT(Layer == 0 && Face == 0); + Texture.store(TexelCoord, Level, Texel); + } + }; + + template + struct accessFunc + { + static genType load(texture_cube const& Texture, texture_cube::extent_type const& TexelCoord, texture_cube::size_type Layer, texture_cube::size_type Face, texture_cube::size_type Level) + { + GLI_ASSERT(Layer == 0); + return Texture.load(TexelCoord, Face, Level); + } + + static void store(texture_cube& Texture, texture_cube::extent_type const& TexelCoord, texture_cube::size_type Layer, texture_cube::size_type Face, texture_cube::size_type Level, genType const& Texel) + { + GLI_ASSERT(Layer == 0); + Texture.store(TexelCoord, Face, Level, Texel); + } + }; + + template + struct accessFunc + { + static genType load(texture_cube_array const & Texture, texture_cube_array::extent_type const & TexelCoord, texture_cube_array::size_type Layer, texture_cube_array::size_type Face, texture_cube_array::size_type Level) + { + return Texture.load(TexelCoord, Layer, Face, Level); + } + + static void store(texture_cube_array & Texture, texture_cube_array::extent_type const & TexelCoord, texture_cube_array::size_type Layer, texture_cube_array::size_type Face, texture_cube_array::size_type Level, genType const & Texel) + { + Texture.store(TexelCoord, Layer, Face, Level, Texel); + } + }; + + // convertFunc class + + template class vecType, convertMode mode = CONVERT_MODE_CAST, bool isSamplerFloat = false> + struct convertFunc + { + typedef accessFunc > access; + + static tvec4 fetch(textureType const & Texture, typename textureType::extent_type const & TexelCoord, typename textureType::size_type Layer, typename textureType::size_type Face, typename textureType::size_type Level) + { + return make_vec4(vecType(access::load(Texture, TexelCoord, Layer, Face, Level))); + } + + static void write(textureType & Texture, typename textureType::extent_type const & TexelCoord, typename textureType::size_type Layer, typename textureType::size_type Face, typename textureType::size_type Level, tvec4 const & Texel) + { + access::store(Texture, TexelCoord, Layer, Face, Level, vecType(Texel)); + } + }; + + template class vecType, bool isSamplerFloat> + struct convertFunc + { + static tvec4 fetch(textureType const & Texture, typename textureType::extent_type const & TexelCoord, typename textureType::size_type Layer, typename textureType::size_type Face, typename textureType::size_type Level) + { + return tvec4(0, 0, 0, 1); + } + + static void write(textureType & Texture, typename textureType::extent_type const & TexelCoord, typename textureType::size_type Layer, typename textureType::size_type Face, typename textureType::size_type Level, tvec4 const & Texel) + {} + }; + + template class vecType> + struct convertFunc + { + typedef accessFunc > access; + + static tvec4 fetch(textureType const & Texture, typename textureType::extent_type const & TexelCoord, typename textureType::size_type Layer, typename textureType::size_type Face, typename textureType::size_type Level) + { + static_assert(std::numeric_limits::is_iec559, "CONVERT_MODE_NORM requires a float sampler"); + return make_vec4(compNormalize(access::load(Texture, TexelCoord, Layer, Face, Level))); + } + + static void write(textureType & Texture, typename textureType::extent_type const & TexelCoord, typename textureType::size_type Layer, typename textureType::size_type Face, typename textureType::size_type Level, tvec4 const & Texel) + { + static_assert(std::numeric_limits::is_iec559, "CONVERT_MODE_NORM requires a float sampler"); + access::store(Texture, TexelCoord, Layer, Face, Level, compScale(vecType(Texel))); + } + }; + + template class vecType> + struct convertFunc + { + typedef accessFunc > access; + + static tvec4 fetch(textureType const & Texture, typename textureType::extent_type const & TexelCoord, typename textureType::size_type Layer, typename textureType::size_type Face, typename textureType::size_type Level) + { + static_assert(std::numeric_limits::is_iec559, "CONVERT_MODE_SRGB requires a float sampler"); + return make_vec4(convertSRGBToLinear(compNormalize(access::load(Texture, TexelCoord, Layer, Face, Level)))); + } + + static void write(textureType & Texture, typename textureType::extent_type const & TexelCoord, typename textureType::size_type Layer, typename textureType::size_type Face, typename textureType::size_type Level, tvec4 const & Texel) + { + static_assert(std::numeric_limits::is_iec559, "CONVERT_MODE_SRGB requires a float sampler"); + access::store(Texture, TexelCoord, Layer, Face, Level, gli::compScale(convertLinearToSRGB(vecType(Texel)))); + } + }; + + template class vecType> + struct convertFunc + { + typedef accessFunc access; + + static tvec4 fetch(textureType const & Texture, typename textureType::extent_type const & TexelCoord, typename textureType::size_type Layer, typename textureType::size_type Face, typename textureType::size_type Level) + { + static_assert(std::numeric_limits::is_iec559, "CONVERT_MODE_RGB9E5 requires a float sampler"); + return tvec4(unpackF3x9_E1x5(access::load(Texture, TexelCoord, Layer, Face, Level)), static_cast(1)); + } + + static void write(textureType & Texture, typename textureType::extent_type const & TexelCoord, typename textureType::size_type Layer, typename textureType::size_type Face, typename textureType::size_type Level, tvec4 const & Texel) + { + static_assert(std::numeric_limits::is_iec559, "CONVERT_MODE_RGB9E5 requires a float sampler"); + access::store(Texture, TexelCoord, Layer, Face, Level, packF3x9_E1x5(tvec3(Texel))); + } + }; + + template class vecType> + struct convertFunc + { + typedef accessFunc access; + + static tvec4 fetch(textureType const & Texture, typename textureType::extent_type const & TexelCoord, typename textureType::size_type Layer, typename textureType::size_type Face, typename textureType::size_type Level) + { + static_assert(std::numeric_limits::is_iec559, "CONVERT_MODE_RG11B10F requires a float sampler"); + return tvec4(unpackF2x11_1x10(access::load(Texture, TexelCoord, Layer, Face, Level)), static_cast(1)); + } + + static void write(textureType & Texture, typename textureType::extent_type const & TexelCoord, typename textureType::size_type Layer, typename textureType::size_type Face, typename textureType::size_type Level, tvec4 const & Texel) + { + static_assert(std::numeric_limits::is_iec559, "CONVERT_MODE_RG11B10F requires a float sampler"); + access::store(Texture, TexelCoord, Layer, Face, Level, packF2x11_1x10(tvec3(Texel))); + } + }; + + template class vecType> + struct convertFunc + { + typedef accessFunc > access; + + static tvec4 fetch(textureType const & Texture, typename textureType::extent_type const & TexelCoord, typename textureType::size_type Layer, typename textureType::size_type Face, typename textureType::size_type Level) + { + static_assert(std::numeric_limits::is_iec559, "CONVERT_MODE_HALF requires a float sampler"); + return make_vec4(vecType(unpackHalf(access::load(Texture, TexelCoord, Layer, Face, Level)))); + } + + static void write(textureType & Texture, typename textureType::extent_type const & TexelCoord, typename textureType::size_type Layer, typename textureType::size_type Face, typename textureType::size_type Level, tvec4 const & Texel) + { + static_assert(std::numeric_limits::is_iec559, "CONVERT_MODE_HALF requires a float sampler"); + access::store(Texture, TexelCoord, Layer, Face, Level, packHalf(vecType(Texel))); + } + }; + + template class vecType> + struct convertFunc + { + typedef accessFunc access; + + static tvec4 fetch(textureType const & Texture, typename textureType::extent_type const & TexelCoord, typename textureType::size_type Layer, typename textureType::size_type Face, typename textureType::size_type Level) + { + static_assert(std::numeric_limits::is_iec559, "CONVERT_MODE_44UNORM requires a float sampler"); + return tvec4(tvec2(unpackUnorm2x4(access::load(Texture, TexelCoord, Layer, Face, Level))), static_cast(0), static_cast(1)); + } + + static void write(textureType & Texture, typename textureType::extent_type const & TexelCoord, typename textureType::size_type Layer, typename textureType::size_type Face, typename textureType::size_type Level, tvec4 const & Texel) + { + static_assert(std::numeric_limits::is_iec559, "CONVERT_MODE_44UNORM requires a float sampler"); + access::store(Texture, TexelCoord, Layer, Face, Level, packUnorm2x4(tvec2(Texel))); + } + }; + + template class vecType> + struct convertFunc + { + typedef accessFunc access; + + static tvec4 fetch(textureType const & Texture, typename textureType::extent_type const & TexelCoord, typename textureType::size_type Layer, typename textureType::size_type Face, typename textureType::size_type Level) + { + static_assert(std::numeric_limits::is_iec559, "CONVERT_MODE_4444UNORM requires a float sampler"); + return tvec4(unpackUnorm4x4(access::load(Texture, TexelCoord, Layer, Face, Level))); + } + + static void write(textureType & Texture, typename textureType::extent_type const & TexelCoord, typename textureType::size_type Layer, typename textureType::size_type Face, typename textureType::size_type Level, tvec4 const & Texel) + { + static_assert(std::numeric_limits::is_iec559, "CONVERT_MODE_4444UNORM requires a float sampler"); + access::store(Texture, TexelCoord, Layer, Face, Level, packUnorm4x4(tvec4(Texel))); + } + }; + + template class vecType> + struct convertFunc + { + typedef accessFunc access; + + static tvec4 fetch(textureType const & Texture, typename textureType::extent_type const & TexelCoord, typename textureType::size_type Layer, typename textureType::size_type Face, typename textureType::size_type Level) + { + static_assert(std::numeric_limits::is_iec559, "CONVERT_MODE_565UNORM requires a float sampler"); + return tvec4(unpackUnorm1x5_1x6_1x5(access::load(Texture, TexelCoord, Layer, Face, Level)), static_cast(1)); + } + + static void write(textureType & Texture, typename textureType::extent_type const & TexelCoord, typename textureType::size_type Layer, typename textureType::size_type Face, typename textureType::size_type Level, tvec4 const & Texel) + { + static_assert(std::numeric_limits::is_iec559, "CONVERT_MODE_565UNORM requires a float sampler"); + access::store(Texture, TexelCoord, Layer, Face, Level, packUnorm1x5_1x6_1x5(tvec3(Texel))); + } + }; + + template class vecType> + struct convertFunc + { + typedef accessFunc access; + + static tvec4 fetch(textureType const & Texture, typename textureType::extent_type const & TexelCoord, typename textureType::size_type Layer, typename textureType::size_type Face, typename textureType::size_type Level) + { + static_assert(std::numeric_limits::is_iec559, "CONVERT_MODE_5551UNORM requires a float sampler"); + return tvec4(unpackUnorm3x5_1x1(access::load(Texture, TexelCoord, Layer, Face, Level))); + } + + static void write(textureType & Texture, typename textureType::extent_type const & TexelCoord, typename textureType::size_type Layer, typename textureType::size_type Face, typename textureType::size_type Level, tvec4 const & Texel) + { + static_assert(std::numeric_limits::is_iec559, "CONVERT_MODE_5551UNORM requires a float sampler"); + access::store(Texture, TexelCoord, Layer, Face, Level, packUnorm3x5_1x1(tvec4(Texel))); + } + }; + + template class vecType> + struct convertFunc + { + typedef accessFunc access; + + static tvec4 fetch(textureType const & Texture, typename textureType::extent_type const & TexelCoord, typename textureType::size_type Layer, typename textureType::size_type Face, typename textureType::size_type Level) + { + static_assert(std::numeric_limits::is_iec559, "CONVERT_MODE_332UNORM requires a float sampler"); + return tvec4(unpackUnorm2x3_1x2(access::load(Texture, TexelCoord, Layer, Face, Level)), static_cast(1)); + } + + static void write(textureType & Texture, typename textureType::extent_type const & TexelCoord, typename textureType::size_type Layer, typename textureType::size_type Face, typename textureType::size_type Level, tvec4 const & Texel) + { + static_assert(std::numeric_limits::is_iec559, "CONVERT_MODE_332UNORM requires a float sampler"); + access::store(Texture, TexelCoord, Layer, Face, Level, packUnorm2x3_1x2(tvec3(Texel))); + } + }; + + template class vecType> + struct convertFunc + { + typedef accessFunc access; + + static tvec4 fetch(textureType const & Texture, typename textureType::extent_type const & TexelCoord, typename textureType::size_type Layer, typename textureType::size_type Face, typename textureType::size_type Level) + { + static_assert(std::numeric_limits::is_iec559, "CONVERT_MODE_RGB10A2UNORM requires a float sampler"); + return tvec4(unpackUnorm3x10_1x2(access::load(Texture, TexelCoord, Layer, Face, Level))); + } + + static void write(textureType & Texture, typename textureType::extent_type const & TexelCoord, typename textureType::size_type Layer, typename textureType::size_type Face, typename textureType::size_type Level, tvec4 const & Texel) + { + static_assert(std::numeric_limits::is_iec559, "CONVERT_MODE_RGB10A2UNORM requires a float sampler"); + access::store(Texture, TexelCoord, Layer, Face, Level, packUnorm3x10_1x2(tvec4(Texel))); + } + }; + + template class vecType> + struct convertFunc + { + typedef accessFunc access; + + static tvec4 fetch(textureType const & Texture, typename textureType::extent_type const & TexelCoord, typename textureType::size_type Layer, typename textureType::size_type Face, typename textureType::size_type Level) + { + static_assert(std::numeric_limits::is_iec559, "CONVERT_MODE_RGB10A2SNORM requires a float sampler"); + return tvec4(unpackSnorm3x10_1x2(access::load(Texture, TexelCoord, Layer, Face, Level))); + } + + static void write(textureType & Texture, typename textureType::extent_type const & TexelCoord, typename textureType::size_type Layer, typename textureType::size_type Face, typename textureType::size_type Level, tvec4 const & Texel) + { + static_assert(std::numeric_limits::is_iec559, "CONVERT_MODE_RGB10A2SNORM requires a float sampler"); + access::store(Texture, TexelCoord, Layer, Face, Level, packSnorm3x10_1x2(Texel)); + } + }; + + template class vecType> + struct convertFunc + { + typedef accessFunc access; + + static tvec4 fetch(textureType const & Texture, typename textureType::extent_type const & TexelCoord, typename textureType::size_type Layer, typename textureType::size_type Face, typename textureType::size_type Level) + { + static_assert(std::numeric_limits::is_iec559, "CONVERT_MODE_RGB10A2USCALE requires a float sampler"); + glm::detail::u10u10u10u2 Unpack; + Unpack.pack = access::load(Texture, TexelCoord, Layer, Face, Level); + return tvec4(Unpack.data.x, Unpack.data.y, Unpack.data.z, Unpack.data.w); + } + + static void write(textureType & Texture, typename textureType::extent_type const & TexelCoord, typename textureType::size_type Layer, typename textureType::size_type Face, typename textureType::size_type Level, tvec4 const & Texel) + { + static_assert(std::numeric_limits::is_iec559, "CONVERT_MODE_RGB10A2USCALE requires a float sampler"); + glm::detail::u10u10u10u2 Unpack; + Unpack.data.x = static_cast(Texel.x); + Unpack.data.y = static_cast(Texel.y); + Unpack.data.z = static_cast(Texel.z); + Unpack.data.w = static_cast(Texel.w); + access::store(Texture, TexelCoord, Layer, Face, Level, Unpack.pack); + } + }; + + template class vecType> + struct convertFunc + { + typedef accessFunc access; + + static tvec4 fetch(textureType const & Texture, typename textureType::extent_type const & TexelCoord, typename textureType::size_type Layer, typename textureType::size_type Face, typename textureType::size_type Level) + { + static_assert(std::numeric_limits::is_iec559, "CONVERT_MODE_RGB10A2SSCALE requires a float sampler"); + glm::detail::i10i10i10i2 Unpack; + Unpack.pack = access::load(Texture, TexelCoord, Layer, Face, Level); + return tvec4(Unpack.data.x, Unpack.data.y, Unpack.data.z, Unpack.data.w); + } + + static void write(textureType & Texture, typename textureType::extent_type const & TexelCoord, typename textureType::size_type Layer, typename textureType::size_type Face, typename textureType::size_type Level, tvec4 const & Texel) + { + static_assert(std::numeric_limits::is_iec559, "CONVERT_MODE_RGB10A2SSCALE requires a float sampler"); + glm::detail::i10i10i10i2 Unpack; + Unpack.data.x = static_cast(Texel.x); + Unpack.data.y = static_cast(Texel.y); + Unpack.data.z = static_cast(Texel.z); + Unpack.data.w = static_cast(Texel.w); + access::store(Texture, TexelCoord, Layer, Face, Level, Unpack.pack); + } + }; + + template class vecType> + struct convertFunc + { + typedef accessFunc access; + + static tvec4 fetch(textureType const & Texture, typename textureType::extent_type const & TexelCoord, typename textureType::size_type Layer, typename textureType::size_type Face, typename textureType::size_type Level) + { + static_assert(std::numeric_limits::is_integer, "CONVERT_MODE_RGB10A2UINT requires an integer sampler"); + return tvec4(unpackU3x10_1x2(access::load(Texture, TexelCoord, Layer, Face, Level))); + } + + static void write(textureType & Texture, typename textureType::extent_type const & TexelCoord, typename textureType::size_type Layer, typename textureType::size_type Face, typename textureType::size_type Level, tvec4 const & Texel) + { + static_assert(std::numeric_limits::is_integer, "CONVERT_MODE_RGB10A2UINT requires an integer sampler"); + access::store(Texture, TexelCoord, Layer, Face, Level, packU3x10_1x2(Texel)); + } + }; + + template class vecType> + struct convertFunc + { + typedef accessFunc access; + + static tvec4 fetch(textureType const & Texture, typename textureType::extent_type const & TexelCoord, typename textureType::size_type Layer, typename textureType::size_type Face, typename textureType::size_type Level) + { + static_assert(std::numeric_limits::is_integer, "CONVERT_MODE_RGB10A2SINT requires an integer sampler"); + return tvec4(unpackI3x10_1x2(access::load(Texture, TexelCoord, Layer, Face, Level))); + } + + static void write(textureType & Texture, typename textureType::extent_type const & TexelCoord, typename textureType::size_type Layer, typename textureType::size_type Face, typename textureType::size_type Level, tvec4 const & Texel) + { + static_assert(std::numeric_limits::is_integer, "CONVERT_MODE_RGB10A2SINT requires an integer sampler"); + access::store(Texture, TexelCoord, Layer, Face, Level, packI3x10_1x2(Texel)); + } + }; + + template + struct convert + { + typedef glm::tvec4(*fetchFunc)(textureType const & Texture, typename textureType::extent_type const & TexelCoord, typename textureType::size_type Layer, typename textureType::size_type Face, typename textureType::size_type Level); + typedef void(*writeFunc)(textureType & Texture, typename textureType::extent_type const & TexelCoord, typename textureType::size_type Layer, typename textureType::size_type Face, typename textureType::size_type Level, glm::tvec4 const & Texel); + + template class vecType, convertMode mode> + struct conv + { + static tvec4 fetch(textureType const & Texture, typename textureType::extent_type const & TexelCoord, typename textureType::size_type Layer, typename textureType::size_type Face, typename textureType::size_type Level) + { + return convertFunc::is_iec559>::fetch(Texture, TexelCoord, Layer, Face, Level); + } + + static void write(textureType & Texture, typename textureType::extent_type const & TexelCoord, typename textureType::size_type Layer, typename textureType::size_type Face, typename textureType::size_type Level, tvec4 const & Texel) + { + convertFunc::is_iec559>::write(Texture, TexelCoord, Layer, Face, Level, Texel); + } + }; + + struct func + { + fetchFunc Fetch; + writeFunc Write; + }; + + static func call(format Format) + { + static func Table[] = + { + {conv::fetch, conv::write}, // FORMAT_RG4_UNORM + {conv::fetch, conv::write}, // FORMAT_RGBA4_UNORM + {conv::fetch, conv::write}, // FORMAT_BGRA4_UNORM + {conv::fetch, conv::write}, // FORMAT_R5G6B5_UNORM + {conv::fetch, conv::write}, // FORMAT_B5G6R5_UNORM + {conv::fetch, conv::write}, // FORMAT_RGB5A1_UNORM + {conv::fetch, conv::write}, // FORMAT_BGR5A1_UNORM + {conv::fetch, conv::write}, // FORMAT_A1RGB5_UNORM + + {conv::fetch, conv::write}, // FORMAT_R8_UNORM + {conv::fetch, conv::write}, // FORMAT_R8_SNORM + {conv::fetch, conv::write}, // FORMAT_R8_USCALED + {conv::fetch, conv::write}, // FORMAT_R8_SSCALED + {conv::fetch, conv::write}, // FORMAT_R8_UINT + {conv::fetch, conv::write}, // FORMAT_R8_SINT + {conv::fetch, conv::write}, // FORMAT_R8_SRGB + + {conv::fetch, conv::write}, // FORMAT_RG8_UNORM + {conv::fetch, conv::write}, // FORMAT_RG8_SNORM + {conv::fetch, conv::write}, // FORMAT_RG8_USCALED + {conv::fetch, conv::write}, // FORMAT_RG8_SSCALED + {conv::fetch, conv::write}, // FORMAT_RG8_UINT + {conv::fetch, conv::write}, // FORMAT_RG8_SINT + {conv::fetch, conv::write}, // FORMAT_RG8_SRGB + + {conv::fetch, conv::write}, // FORMAT_RGB8_UNORM + {conv::fetch, conv::write}, // FORMAT_RGB8_SNORM + {conv::fetch, conv::write}, // FORMAT_RGB8_USCALED + {conv::fetch, conv::write}, // FORMAT_RGB8_SSCALED + {conv::fetch, conv::write}, // FORMAT_RGB8_UINT + {conv::fetch, conv::write}, // FORMAT_RGB8_SINT + {conv::fetch, conv::write}, // FORMAT_RGB8_SRGB + + {conv::fetch, conv::write}, // FORMAT_BGR8_UNORM + {conv::fetch, conv::write}, // FORMAT_BGR8_SNORM + {conv::fetch, conv::write}, // FORMAT_BGR8_USCALED + {conv::fetch, conv::write}, // FORMAT_BGR8_SSCALED + {conv::fetch, conv::write}, // FORMAT_BGR8_UINT + {conv::fetch, conv::write}, // FORMAT_BGR8_SINT + {conv::fetch, conv::write}, // FORMAT_BGR8_SRGB + + {conv::fetch, conv::write}, // FORMAT_RGBA8_UNORM + {conv::fetch, conv::write}, // FORMAT_RGBA8_SNORM + {conv::fetch, conv::write}, // FORMAT_RGBA8_USCALED + {conv::fetch, conv::write}, // FORMAT_RGBA8_SSCALED + {conv::fetch, conv::write}, // FORMAT_RGBA8_UINT + {conv::fetch, conv::write}, // FORMAT_RGBA8_SINT + {conv::fetch, conv::write}, // FORMAT_RGBA8_SRGB + + {conv::fetch, conv::write}, // FORMAT_BGRA8_UNORM + {conv::fetch, conv::write}, // FORMAT_BGRA8_SNORM + {conv::fetch, conv::write}, // FORMAT_BGRA8_USCALED + {conv::fetch, conv::write}, // FORMAT_BGRA8_SSCALED + {conv::fetch, conv::write}, // FORMAT_BGRA8_UINT + {conv::fetch, conv::write}, // FORMAT_BGRA8_SINT + {conv::fetch, conv::write}, // FORMAT_BGRA8_SRGB + + {conv::fetch, conv::write}, // FORMAT_ABGR8_UNORM + {conv::fetch, conv::write}, // FORMAT_ABGR8_SNORM + {conv::fetch, conv::write}, // FORMAT_ABGR8_USCALED + {conv::fetch, conv::write}, // FORMAT_ABGR8_SSCALED + {conv::fetch, conv::write}, // FORMAT_ABGR8_UINT + {conv::fetch, conv::write}, // FORMAT_ABGR8_SINT + {conv::fetch, conv::write}, // FORMAT_ABGR8_SRGB + + {conv::fetch, conv::write}, // FORMAT_RGB10A2_UNORM + {conv::fetch, conv::write}, // FORMAT_RGB10A2_SNORM + {conv::fetch, conv::write}, // FORMAT_RGB10A2_USCALED + {conv::fetch, conv::write}, // FORMAT_RGB10A2_SSCALED + {conv::fetch, conv::write}, // FORMAT_RGB10A2_UINT + {conv::fetch, conv::write}, // FORMAT_RGB10A2_SINT + + {conv::fetch, conv::write}, // FORMAT_BGR10A2_UNORM + {conv::fetch, conv::write}, // FORMAT_BGR10A2_SNORM + {conv::fetch, conv::write}, // FORMAT_BGR10A2_USCALED + {conv::fetch, conv::write}, // FORMAT_BGR10A2_SSCALED + {conv::fetch, conv::write}, // FORMAT_BGR10A2_UINT + {conv::fetch, conv::write}, // FORMAT_BGR10A2_SINT + + {conv::fetch, conv::write}, // FORMAT_R16_UNORM_PACK16 + {conv::fetch, conv::write}, // FORMAT_R16_SNORM_PACK16 + {conv::fetch, conv::write}, // FORMAT_R16_USCALED_PACK16 + {conv::fetch, conv::write}, // FORMAT_R16_SSCALED_PACK16 + {conv::fetch, conv::write}, // FORMAT_R16_UINT_PACK16 + {conv::fetch, conv::write}, // FORMAT_R16_SINT_PACK16 + {conv::fetch, conv::write}, // FORMAT_R16_SFLOAT_PACK16 + + {conv::fetch, conv::write}, // FORMAT_RG16_UNORM_PACK16 + {conv::fetch, conv::write}, // FORMAT_RG16_SNORM_PACK16 + {conv::fetch, conv::write}, // FORMAT_RG16_USCALED_PACK16 + {conv::fetch, conv::write}, // FORMAT_RG16_SSCALED_PACK16 + {conv::fetch, conv::write}, // FORMAT_RG16_UINT_PACK16 + {conv::fetch, conv::write}, // FORMAT_RG16_SINT_PACK16 + {conv::fetch, conv::write}, // FORMAT_RG16_SFLOAT_PACK16 + + {conv::fetch, conv::write}, // FORMAT_RGB16_UNORM_PACK16 + {conv::fetch, conv::write}, // FORMAT_RGB16_SNORM_PACK16 + {conv::fetch, conv::write}, // FORMAT_RGB16_USCALED_PACK16 + {conv::fetch, conv::write}, // FORMAT_RGB16_SSCALED_PACK16 + {conv::fetch, conv::write}, // FORMAT_RGB16_UINT_PACK16 + {conv::fetch, conv::write}, // FORMAT_RGB16_SINT_PACK16 + {conv::fetch, conv::write}, // FORMAT_RGB16_SFLOAT_PACK16 + + {conv::fetch, conv::write}, // FORMAT_RGBA16_UNORM_PACK16 + {conv::fetch, conv::write}, // FORMAT_RGBA16_SNORM_PACK16 + {conv::fetch, conv::write}, // FORMAT_RGBA16_USCALED_PACK16 + {conv::fetch, conv::write}, // FORMAT_RGBA16_SSCALED_PACK16 + {conv::fetch, conv::write}, // FORMAT_RGBA16_UINT_PACK16 + {conv::fetch, conv::write}, // FORMAT_RGBA16_SINT_PACK16 + {conv::fetch, conv::write}, // FORMAT_RGBA16_SFLOAT_PACK16 + + {conv::fetch, conv::write}, // FORMAT_R32_UINT_PACK32 + {conv::fetch, conv::write}, // FORMAT_R32_SINT_PACK32 + {conv::fetch, conv::write}, // FORMAT_R32_SFLOAT_PACK32 + + {conv::fetch, conv::write}, // FORMAT_RG32_UINT_PACK32 + {conv::fetch, conv::write}, // FORMAT_RG32_SINT_PACK32 + {conv::fetch, conv::write}, // FORMAT_RG32_SFLOAT_PACK32 + + {conv::fetch, conv::write}, // FORMAT_RGB32_UINT_PACK32 + {conv::fetch, conv::write}, // FORMAT_RGB32_SINT_PACK32 + {conv::fetch, conv::write}, // FORMAT_RGB32_SFLOAT_PACK32 + + {conv::fetch, conv::write}, // FORMAT_RGBA32_UINT_PACK32 + {conv::fetch, conv::write}, // FORMAT_RGBA32_SINT_PACK32 + {conv::fetch, conv::write}, // FORMAT_RGBA32_SFLOAT_PACK32 + + {conv::fetch, conv::write}, // FORMAT_R64_UINT_PACK64 + {conv::fetch, conv::write}, // FORMAT_R64_SINT_PACK64 + {conv::fetch, conv::write}, // FORMAT_R64_SFLOAT_PACK64 + + {conv::fetch, conv::write}, // FORMAT_RG64_UINT_PACK64 + {conv::fetch, conv::write}, // FORMAT_RG64_SINT_PACK64 + {conv::fetch, conv::write}, // FORMAT_RG64_SFLOAT_PACK64 + + {conv::fetch, conv::write}, // FORMAT_RGB64_UINT_PACK64 + {conv::fetch, conv::write}, // FORMAT_RGB64_SINT_PACK64 + {conv::fetch, conv::write}, // FORMAT_RGB64_SFLOAT_PACK64 + + {conv::fetch, conv::write}, // FORMAT_RGBA64_UINT_PACK64 + {conv::fetch, conv::write}, // FORMAT_RGBA64_SINT_PACK64 + {conv::fetch, conv::write}, // FORMAT_RGBA64_SFLOAT_PACK64 + + {conv::fetch, conv::write}, // FORMAT_RG11B10_UFLOAT + {conv::fetch, conv::write}, // FORMAT_RGB9E5_UFLOAT + + {conv::fetch, conv::write}, // FORMAT_D16_UNORM_PACK16 + {conv::fetch, conv::write}, // FORMAT_D24_UNORM + {conv::fetch, conv::write}, // FORMAT_D32_SFLOAT_PACK32 + {conv::fetch, conv::write}, // FORMAT_S8_UINT_PACK8 + {conv::fetch, conv::write}, // FORMAT_D16_UNORM_S8_UINT_PACK32 + {conv::fetch, conv::write}, // FORMAT_D24_UNORM_S8_UINT_PACK32 + {conv::fetch, conv::write}, // FORMAT_D32_SFLOAT_S8_UINT_PACK64 + + {conv::fetch, conv::write}, // FORMAT_RGB_DXT1_UNORM_BLOCK8 + {conv::fetch, conv::write}, // FORMAT_RGB_DXT1_SRGB_BLOCK8 + {conv::fetch, conv::write}, // FORMAT_RGBA_DXT1_UNORM_BLOCK8 + {conv::fetch, conv::write}, // FORMAT_RGBA_DXT1_SRGB_BLOCK8 + {conv::fetch, conv::write}, // FORMAT_RGBA_DXT3_UNORM_BLOCK16 + {conv::fetch, conv::write}, // FORMAT_RGBA_DXT3_SRGB_BLOCK16 + {conv::fetch, conv::write}, // FORMAT_RGBA_DXT5_UNORM_BLOCK16 + {conv::fetch, conv::write}, // FORMAT_RGBA_DXT5_SRGB_BLOCK16 + {conv::fetch, conv::write}, // FORMAT_R_ATI1N_UNORM_BLOCK8 + {conv::fetch, conv::write}, // FORMAT_R_ATI1N_SNORM_BLOCK8 + {conv::fetch, conv::write}, // FORMAT_RG_ATI2N_UNORM_BLOCK16 + {conv::fetch, conv::write}, // FORMAT_RG_ATI2N_SNORM_BLOCK16 + {conv::fetch, conv::write}, // FORMAT_RGB_BP_UFLOAT_BLOCK16 + {conv::fetch, conv::write}, // FORMAT_RGB_BP_SFLOAT_BLOCK16 + {conv::fetch, conv::write}, // FORMAT_RGBA_BP_UNORM_BLOCK16 + {conv::fetch, conv::write}, // FORMAT_RGBA_BP_SRGB_BLOCK16 + + {conv::fetch, conv::write}, // FORMAT_RGB_ETC2_UNORM_BLOCK8 + {conv::fetch, conv::write}, // FORMAT_RGB_ETC2_SRGB_BLOCK8 + {conv::fetch, conv::write}, // FORMAT_RGBA_ETC2_A1_UNORM_BLOCK8 + {conv::fetch, conv::write}, // FORMAT_RGBA_ETC2_A1_SRGB_BLOCK8 + {conv::fetch, conv::write}, // FORMAT_RGBA_ETC2_UNORM_BLOCK16 + {conv::fetch, conv::write}, // FORMAT_RGBA_ETC2_SRGB_BLOCK16 + {conv::fetch, conv::write}, // FORMAT_R_EAC_UNORM_BLOCK8 + {conv::fetch, conv::write}, // FORMAT_R_EAC_SNORM_BLOCK8 + {conv::fetch, conv::write}, // FORMAT_RG_EAC_UNORM_BLOCK16 + {conv::fetch, conv::write}, // FORMAT_RG_EAC_SNORM_BLOCK16 + + {conv::fetch, conv::write}, // FORMAT_ASTC_4x4_UNORM + {conv::fetch, conv::write}, // FORMAT_ASTC_4x4_SRGB + {conv::fetch, conv::write}, // FORMAT_ASTC_5x4_UNORM + {conv::fetch, conv::write}, // FORMAT_ASTC_5x4_SRGB + {conv::fetch, conv::write}, // FORMAT_ASTC_5x5_UNORM + {conv::fetch, conv::write}, // FORMAT_ASTC_5x5_SRGB + {conv::fetch, conv::write}, // FORMAT_ASTC_6x5_UNORM + {conv::fetch, conv::write}, // FORMAT_ASTC_6x5_SRGB + {conv::fetch, conv::write}, // FORMAT_ASTC_6x6_UNORM + {conv::fetch, conv::write}, // FORMAT_ASTC_6x6_SRGB + {conv::fetch, conv::write}, // FORMAT_ASTC_8x5_UNORM + {conv::fetch, conv::write}, // FORMAT_ASTC_8x5_SRGB + {conv::fetch, conv::write}, // FORMAT_ASTC_8x6_UNORM + {conv::fetch, conv::write}, // FORMAT_ASTC_8x6_SRGB + {conv::fetch, conv::write}, // FORMAT_ASTC_8x8_UNORM + {conv::fetch, conv::write}, // FORMAT_ASTC_8x8_SRGB + {conv::fetch, conv::write}, // FORMAT_ASTC_10x5_UNORM + {conv::fetch, conv::write}, // FORMAT_ASTC_10x5_SRGB + {conv::fetch, conv::write}, // FORMAT_ASTC_10x6_UNORM + {conv::fetch, conv::write}, // FORMAT_ASTC_10x6_SRGB + {conv::fetch, conv::write}, // FORMAT_ASTC_10x8_UNORM + {conv::fetch, conv::write}, // FORMAT_ASTC_10x8_SRGB + {conv::fetch, conv::write}, // FORMAT_ASTC_10x10_UNORM + {conv::fetch, conv::write}, // FORMAT_ASTC_10x10_SRGB + {conv::fetch, conv::write}, // FORMAT_ASTC_12x10_UNORM + {conv::fetch, conv::write}, // FORMAT_ASTC_12x10_SRGB + {conv::fetch, conv::write}, // FORMAT_ASTC_12x12_UNORM + {conv::fetch, conv::write}, // FORMAT_ASTC_12x12_SRGB + + {conv::fetch, conv::write}, // FORMAT_RGB_PVRTC1_8X8_UNORM_BLOCK32 + {conv::fetch, conv::write}, // FORMAT_RGB_PVRTC1_8X8_SRGB_BLOCK32 + {conv::fetch, conv::write}, // FORMAT_RGB_PVRTC1_16X8_UNORM_BLOCK32 + {conv::fetch, conv::write}, // FORMAT_RGB_PVRTC1_16X8_SRGB_BLOCK32 + {conv::fetch, conv::write}, // FORMAT_RGBA_PVRTC1_8X8_UNORM_BLOCK32 + {conv::fetch, conv::write}, // FORMAT_RGBA_PVRTC1_8X8_SRGB_BLOCK32 + {conv::fetch, conv::write}, // FORMAT_RGBA_PVRTC1_16X8_UNORM_BLOCK32 + {conv::fetch, conv::write}, // FORMAT_RGBA_PVRTC1_16X8_SRGB_BLOCK32 + {conv::fetch, conv::write}, // FORMAT_RGBA_PVRTC2_4X4_UNORM_BLOCK8 + {conv::fetch, conv::write}, // FORMAT_RGBA_PVRTC2_4X4_SRGB_BLOCK8 + {conv::fetch, conv::write}, // FORMAT_RGBA_PVRTC2_8X4_UNORM_BLOCK8 + {conv::fetch, conv::write}, // FORMAT_RGBA_PVRTC2_8X4_SRGB_BLOCK8 + + {conv::fetch, conv::write}, // FORMAT_RGB_ETC_UNORM_BLOCK8 + {conv::fetch, conv::write}, // FORMAT_RGB_ATC_UNORM_BLOCK8 + {conv::fetch, conv::write}, // FORMAT_RGBA_ATCA_UNORM_BLOCK16 + {conv::fetch, conv::write}, // FORMAT_RGBA_ATCI_UNORM_BLOCK16 + + {conv::fetch, conv::write}, // FORMAT_L8_UNORM_PACK8 + {conv::fetch, conv::write}, // FORMAT_A8_UNORM_PACK8 + {conv::fetch, conv::write}, // FORMAT_LA8_UNORM_PACK8 + {conv::fetch, conv::write}, // FORMAT_L16_UNORM_PACK16 + {conv::fetch, conv::write}, // FORMAT_A16_UNORM_PACK16 + {conv::fetch, conv::write}, // FORMAT_LA16_UNORM_PACK16 + + {conv::fetch, conv::write}, // FORMAT_BGRX8_UNORM + {conv::fetch, conv::write}, // FORMAT_BGRX8_SRGB + + {conv::fetch, conv::write} // FORMAT_RG3B2_UNORM + }; + static_assert(sizeof(Table) / sizeof(Table[0]) == FORMAT_COUNT, "Texel functions need to be updated"); + + return Table[Format - FORMAT_FIRST]; + } + }; +}//namespace detail +}//namespace gli diff --git a/test/external/gli/core/coord.hpp b/test/external/gli/core/coord.hpp new file mode 100644 index 00000000..aede0f20 --- /dev/null +++ b/test/external/gli/core/coord.hpp @@ -0,0 +1,87 @@ +#pragma once + +#include "../type.hpp" + +namespace gli{ +namespace detail +{ + template class vecType> + inline vecType in_interval(vecType const& Value, vecType const& Min, vecType const& Max) + { + return greaterThanEqual(Value, Min) && lessThanEqual(Value, Max); + } + + template + struct coord_nearest + { + extent_type Texel; + typename extent_type::bool_type UseTexel; + }; + + template + inline coord_nearest make_coord_nearest(extent_type const& TexelExtent, normalized_type const& SampleCoord) + { + normalized_type const TexelLast(normalized_type(TexelExtent) - normalized_type(1)); + + coord_nearest Coord; + Coord.Texel = extent_type(round(SampleCoord * TexelLast)); + Coord.UseTexel = in_interval(Coord.Texel, extent_type(0), TexelExtent - 1); + return Coord; + } + + template + struct coord_linear + { + extent_type TexelFloor; + extent_type TexelCeil; + normalized_type Blend; + }; + + template + struct coord_linear_border : public coord_linear + { + typename extent_type::bool_type UseTexelFloor; + typename extent_type::bool_type UseTexelCeil; + }; + + template + GLI_FORCE_INLINE coord_linear make_coord_linear(extent_type const& TexelExtent, normalized_type const& SampleCoord) + { + coord_linear Coord; + + normalized_type const TexelExtentF(TexelExtent); + normalized_type const TexelLast = TexelExtentF - normalized_type(1); + normalized_type const ScaledCoord(SampleCoord * TexelLast); + normalized_type const ScaledCoordFloor = normalized_type(extent_type(ScaledCoord)); + normalized_type const ScaledCoordCeil = normalized_type(extent_type(ScaledCoord + normalized_type(0.5))); + //normalized_type const ScaledCoordFloor(floor(ScaledCoord)); + //normalized_type const ScaledCoordCeil(ceil(ScaledCoord)); + + Coord.Blend = ScaledCoord - ScaledCoordFloor; + Coord.TexelFloor = extent_type(ScaledCoordFloor); + Coord.TexelCeil = extent_type(ScaledCoordCeil); + + return Coord; + } + + template + GLI_FORCE_INLINE coord_linear_border make_coord_linear_border(extent_type const& TexelExtent, normalized_type const& SampleCoord) + { + coord_linear_border Coord; + + normalized_type const TexelExtentF(TexelExtent); + normalized_type const TexelLast = TexelExtentF - normalized_type(1); + normalized_type const ScaledCoord(SampleCoord * TexelLast); + normalized_type const ScaledCoordFloor(floor(ScaledCoord)); + normalized_type const ScaledCoordCeil(ceil(ScaledCoord)); + + Coord.Blend = ScaledCoord - ScaledCoordFloor; + Coord.TexelFloor = extent_type(ScaledCoordFloor); + Coord.TexelCeil = extent_type(ScaledCoordCeil); + Coord.UseTexelFloor = in_interval(Coord.TexelFloor, extent_type(0), TexelExtent - 1); + Coord.UseTexelCeil = in_interval(Coord.TexelCeil, extent_type(0), TexelExtent - 1); + + return Coord; + } +}//namespace detail +}//namespace gli diff --git a/test/external/gli/core/copy.inl b/test/external/gli/core/copy.inl new file mode 100644 index 00000000..9aea05d9 --- /dev/null +++ b/test/external/gli/core/copy.inl @@ -0,0 +1,112 @@ +#include "../type.hpp" +#include + +namespace gli +{ + template + void copy + ( + texture_src_type const& TextureSrc, size_t LayerSrc, size_t FaceSrc, size_t LevelSrc, + texture_dst_type& TextureDst, size_t LayerDst, size_t FaceDst, size_t LevelDst + ) + { + TextureDst.copy(TextureSrc, LayerSrc, FaceSrc, LevelSrc, LayerDst, FaceDst, LevelDst); + } + + template + void copy + ( + texture_src_type const& TextureSrc, + texture_dst_type& TextureDst + ) + { + copy_layer(TextureSrc, 0, TextureDst, 0, TextureDst.layers()); + } + + template + void copy_level + ( + texture_src_type const& TextureSrc, size_t BaseLevelSrc, + texture_dst_type& TextureDst, size_t BaseLevelDst, + size_t LevelCount + ) + { + for(size_t LayerIndex = 0, LayerCount = TextureSrc.layers(); LayerIndex < LayerCount; ++LayerIndex) + for(size_t FaceIndex = 0, FaceCount = TextureSrc.faces(); FaceIndex < FaceCount; ++FaceIndex) + for(size_t LevelIndex = 0; LevelIndex < LevelCount; ++LevelIndex) + { + TextureDst.copy( + TextureSrc, + LayerIndex, FaceIndex, BaseLevelSrc + LevelIndex, + LayerIndex, FaceIndex, BaseLevelDst + LevelIndex); + } + } + + template + void copy_level + ( + texture_src_type const& TextureSrc, size_t BaseLevelSrc, + texture_dst_type& TextureDst, size_t BaseLevelDst + ) + { + copy_level(TextureSrc, BaseLevelSrc, TextureDst, BaseLevelDst, 1); + } + + template + void copy_face + ( + texture_src_type const& TextureSrc, size_t BaseFaceSrc, + texture_dst_type& TextureDst, size_t BaseFaceDst, + size_t FaceCount + ) + { + for(size_t LayerIndex = 0, LayerCount = TextureSrc.layers(); LayerIndex < LayerCount; ++LayerIndex) + for(size_t FaceIndex = 0; FaceIndex < FaceCount; ++FaceIndex) + for(size_t LevelIndex = 0, LevelCount = TextureSrc.levels(); LevelIndex < LevelCount; ++LevelIndex) + { + TextureDst.copy( + TextureSrc, + LayerIndex, BaseFaceSrc + FaceIndex, LevelIndex, + LayerIndex, BaseFaceDst + FaceIndex, LevelIndex); + } + } + + template + void copy_face + ( + texture_src_type const& TextureSrc, size_t BaseFaceSrc, + texture_dst_type& TextureDst, size_t BaseFaceDst + ) + { + copy_face(TextureSrc, BaseFaceSrc, TextureDst, BaseFaceDst, 1); + } + + template + void copy_layer + ( + texture_src_type const& TextureSrc, size_t BaseLayerSrc, + texture_dst_type& TextureDst, size_t BaseLayerDst, + size_t LayerCount + ) + { + for(size_t LayerIndex = 0; LayerIndex < LayerCount; ++LayerIndex) + for(size_t FaceIndex = 0, FaceCount = TextureSrc.faces(); FaceIndex < FaceCount; ++FaceIndex) + for(size_t LevelIndex = 0, LevelCount = TextureSrc.levels(); LevelIndex < LevelCount; ++LevelIndex) + { + TextureDst.copy( + TextureSrc, + BaseLayerSrc + LayerIndex, FaceIndex, LevelIndex, + BaseLayerDst + LayerIndex, FaceIndex, LevelIndex); + } + } + + template + void copy_layer + ( + texture_src_type const& TextureSrc, size_t BaseLayerSrc, + texture_dst_type& TextureDst, size_t BaseLayerDst + ) + { + copy_layer(TextureSrc, BaseLayerSrc, TextureDst, BaseLayerDst, 1); + } +}//namespace gli diff --git a/test/external/gli/core/duplicate.inl b/test/external/gli/core/duplicate.inl new file mode 100644 index 00000000..7b9efda5 --- /dev/null +++ b/test/external/gli/core/duplicate.inl @@ -0,0 +1,267 @@ +namespace gli{ +namespace detail +{ + inline void duplicate_images + ( + texture const & Src, texture & Dst, + texture::size_type BaseLayer, texture::size_type MaxLayer, + texture::size_type BaseFace, texture::size_type MaxFace, + texture::size_type BaseLevel, texture::size_type MaxLevel + ) + { + GLI_ASSERT(BaseLayer >= 0 && BaseLayer <= MaxLayer && MaxLayer < Src.layers()); + GLI_ASSERT(BaseFace >= 0 && BaseFace <= MaxFace && MaxFace < Src.faces()); + GLI_ASSERT(BaseLevel >= 0 && BaseLevel <= MaxLevel && MaxLevel < Src.levels()); + + texture::size_type LevelsSize = 0; + for(texture::size_type LevelIndex = 0; LevelIndex < MaxLevel - BaseLevel + 1; ++LevelIndex) + { + GLI_ASSERT(Dst.size(LevelIndex) == Src.size(LevelIndex)); + LevelsSize += Dst.size(LevelIndex); + } + + for(texture::size_type LayerIndex = 0, LayerCount = MaxLayer - BaseLayer + 1; LayerIndex < LayerCount; ++LayerIndex) + for(texture::size_type FaceIndex = 0, FaceCount = MaxFace - BaseFace + 1; FaceIndex < FaceCount; ++FaceIndex) + { + memcpy(Dst.data(LayerIndex, FaceIndex, BaseLevel), Src.data(BaseLayer + LayerIndex, BaseFace + FaceIndex, BaseLevel), LevelsSize); + } + } +}//namespace detail + + inline image duplicate(image const & Image) + { + image Result(Image.format(), Image.extent()); + + memcpy(Result.data(), Image.data(), Image.size()); + + return Result; + } + + template <> + inline texture duplicate(texture const & Texture) + { + texture Duplicate( + Texture.target(), + Texture.format(), + Texture.extent(), + Texture.layers(), + Texture.faces(), + Texture.levels()); + + detail::duplicate_images( + Texture, Duplicate, + 0, Texture.layers() - 1, + 0, Texture.faces() - 1, + 0, Texture.levels() - 1); + + return Duplicate; + } + + template + inline texture duplicate(texType const & Texture) + { + texture Duplicate( + Texture.target(), + Texture.format(), + Texture.texture::extent(), + Texture.layers(), + Texture.faces(), + Texture.levels()); + + detail::duplicate_images( + Texture, Duplicate, + 0, Texture.layers() - 1, + 0, Texture.faces() - 1, + 0, Texture.levels() - 1); + + return Duplicate; + } + + template + inline texture duplicate(texType const & Texture, typename texType::format_type Format) + { + GLI_ASSERT(block_size(Texture.format()) == block_size(Format)); + + texture Duplicate( + Texture.target(), + Format, + Texture.extent(), + Texture.layers(), + Texture.faces(), + Texture.levels()); + + detail::duplicate_images( + Texture, Duplicate, + 0, Texture.layers() - 1, + 0, Texture.faces() - 1, + 0, Texture.levels() - 1); + + return Duplicate; + } + + inline texture duplicate + ( + texture1d const & Texture, + texture1d::size_type BaseLevel, texture1d::size_type MaxLevel + ) + { + GLI_ASSERT(BaseLevel <= MaxLevel); + GLI_ASSERT(BaseLevel < Texture.levels()); + GLI_ASSERT(MaxLevel < Texture.levels()); + + texture1d Duplicate( + Texture.format(), + Texture.extent(BaseLevel), + MaxLevel - BaseLevel + 1); + + memcpy(Duplicate.data(), Texture.data(0, 0, BaseLevel), Duplicate.size()); + + return Duplicate; + } + + inline texture duplicate + ( + texture1d_array const & Texture, + texture1d_array::size_type BaseLayer, texture1d_array::size_type MaxMayer, + texture1d_array::size_type BaseLevel, texture1d_array::size_type MaxLevel + ) + { + GLI_ASSERT(BaseLevel <= MaxLevel); + GLI_ASSERT(BaseLevel < Texture.levels()); + GLI_ASSERT(MaxLevel < Texture.levels()); + GLI_ASSERT(BaseLayer <= MaxMayer); + GLI_ASSERT(BaseLayer < Texture.layers()); + GLI_ASSERT(MaxMayer < Texture.layers()); + + texture1d_array Duplicate( + Texture.format(), + Texture[BaseLayer].extent(BaseLevel), + MaxMayer - BaseLayer + 1, + MaxLevel - BaseLevel + 1); + + for(texture1d_array::size_type Layer = 0; Layer < Duplicate.layers(); ++Layer) + memcpy(Duplicate.data(Layer, 0, 0), Texture.data(Layer + BaseLayer, 0, BaseLevel), Duplicate[Layer].size()); + + return Duplicate; + } + + inline texture duplicate + ( + texture2d const & Texture, + texture2d::size_type BaseLevel, texture2d::size_type MaxLevel + ) + { + GLI_ASSERT(BaseLevel <= MaxLevel); + GLI_ASSERT(BaseLevel < Texture.levels()); + GLI_ASSERT(MaxLevel < Texture.levels()); + + texture2d Duplicate( + Texture.format(), + Texture.extent(BaseLevel), + MaxLevel - BaseLevel + 1); + + memcpy(Duplicate.data(), Texture.data(0, 0, BaseLevel), Duplicate.size()); + + return Duplicate; + } + + inline texture duplicate + ( + texture2d_array const & Texture, + texture2d_array::size_type BaseLayer, texture2d_array::size_type MaxMayer, + texture2d_array::size_type BaseLevel, texture2d_array::size_type MaxLevel + ) + { + GLI_ASSERT(BaseLevel <= MaxLevel); + GLI_ASSERT(BaseLevel < Texture.levels()); + GLI_ASSERT(MaxLevel < Texture.levels()); + GLI_ASSERT(BaseLayer <= MaxMayer); + GLI_ASSERT(BaseLayer < Texture.layers()); + GLI_ASSERT(MaxMayer < Texture.layers()); + + texture2d_array Duplicate( + Texture.format(), + Texture.extent(BaseLevel), + MaxMayer - BaseLayer + 1, + MaxLevel - BaseLevel + 1); + + for(texture2d_array::size_type Layer = 0; Layer < Duplicate.layers(); ++Layer) + memcpy(Duplicate.data(Layer, 0, 0), Texture.data(Layer + BaseLayer, 0, BaseLevel), Duplicate[Layer].size()); + + return Duplicate; + } + + inline texture duplicate + ( + texture3d const & Texture, + texture3d::size_type BaseLevel, texture3d::size_type MaxLevel + ) + { + GLI_ASSERT(BaseLevel <= MaxLevel); + GLI_ASSERT(BaseLevel < Texture.levels()); + GLI_ASSERT(MaxLevel < Texture.levels()); + + texture3d Duplicate( + Texture.format(), + Texture.extent(BaseLevel), + MaxLevel - BaseLevel + 1); + + memcpy(Duplicate.data(), Texture.data(0, 0, BaseLevel), Duplicate.size()); + + return Duplicate; + } + + inline texture duplicate + ( + texture_cube const & Texture, + texture_cube::size_type BaseFace, texture_cube::size_type MaxFace, + texture_cube::size_type BaseLevel, texture_cube::size_type MaxLevel + ) + { + GLI_ASSERT(BaseLevel >= 0 && BaseLevel < Texture.levels() && BaseLevel <= MaxLevel && MaxLevel < Texture.levels()); + GLI_ASSERT(BaseFace <= MaxFace); + GLI_ASSERT(BaseFace < Texture.faces()); + GLI_ASSERT(MaxFace < Texture.faces()); + + texture_cube Duplicate( + Texture.format(), + Texture[BaseFace].extent(BaseLevel), + MaxLevel - BaseLevel + 1); + + for(texture_cube::size_type Face = 0; Face < Duplicate.faces(); ++Face) + memcpy(Duplicate[Face].data(), Texture[Face + BaseFace][BaseLevel].data(), Duplicate[Face].size()); + + return Duplicate; + } + + inline texture duplicate + ( + texture_cube_array const & Texture, + texture_cube_array::size_type BaseLayer, texture_cube_array::size_type MaxLayer, + texture_cube_array::size_type BaseFace, texture_cube_array::size_type MaxFace, + texture_cube_array::size_type BaseLevel, texture_cube_array::size_type MaxLevel + ) + { + GLI_ASSERT(BaseLevel <= MaxLevel); + GLI_ASSERT(BaseLevel < Texture.levels()); + GLI_ASSERT(MaxLevel < Texture.levels()); + GLI_ASSERT(BaseFace <= MaxFace); + GLI_ASSERT(BaseFace < Texture.faces()); + GLI_ASSERT(MaxFace < Texture.faces()); + GLI_ASSERT(BaseLayer <= MaxLayer); + GLI_ASSERT(BaseLayer < Texture.layers()); + GLI_ASSERT(MaxLayer < Texture.layers()); + + texture_cube_array Duplicate( + Texture.format(), + Texture[BaseLayer][BaseFace].extent(BaseLevel), + MaxLayer - BaseLayer + 1, + MaxLevel - BaseLevel + 1); + + for(texture_cube_array::size_type Layer = 0; Layer < Duplicate.layers(); ++Layer) + for(texture_cube_array::size_type Face = 0; Face < Duplicate[Layer].faces(); ++Face) + memcpy(Duplicate[Layer][Face].data(), Texture[Layer + BaseLayer][Face + BaseFace][BaseLevel].data(), Duplicate[Layer][Face].size()); + + return Duplicate; + } +}//namespace gli diff --git a/test/external/gli/core/dx.inl b/test/external/gli/core/dx.inl new file mode 100644 index 00000000..d39a72cb --- /dev/null +++ b/test/external/gli/core/dx.inl @@ -0,0 +1,311 @@ +#include + +namespace gli +{ + inline dx::dx() + { + static format const Table[] = + { + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_RG4_UNORM_GLI, glm::u32vec4(0x000F, 0x00F0, 0x0000, 0x0000)}, //FORMAT_RG4_UNORM, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_RGBA4_UNORM_GLI, glm::u32vec4(0x000F, 0x00F0, 0x0F00, 0xF000)}, //FORMAT_RGBA4_UNORM, + {DDPF_FOURCC, D3DFMT_A4R4G4B4, DXGI_FORMAT_B4G4R4A4_UNORM, glm::u32vec4(0x0F00, 0x00F0, 0x000F, 0xF000)}, //FORMAT_BGRA4_UNORM, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_R5G6B5_UNORM_GLI, glm::u32vec4(0x001f, 0x07e0, 0xf800, 0x0000)}, //FORMAT_R5G6B5_UNORM, + {DDPF_FOURCC, D3DFMT_R5G6B5, DXGI_FORMAT_B5G6R5_UNORM, glm::u32vec4(0xf800, 0x07e0, 0x001f, 0x0000)}, //FORMAT_B5G6R5_UNORM, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_R5G5B5A1_UNORM_GLI, glm::u32vec4(0x001f, 0x03e0, 0x7c00, 0x8000)}, //FORMAT_RGB5A1_UNORM, + {DDPF_FOURCC, D3DFMT_A1R5G5B5, DXGI_FORMAT_B5G5R5A1_UNORM, glm::u32vec4(0x7c00, 0x03e0, 0x001f, 0x8000)}, //FORMAT_BGR5A1_UNORM, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_A1B5G5R5_UNORM_GLI, glm::u32vec4(0x7c00, 0x03e0, 0x001f, 0x8000)}, //FORMAT_A1RGB5_UNORM, + + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R8_UNORM, glm::u32vec4(0x00FF0000, 0x00000000, 0x00000000, 0x00000000)}, //FORMAT_R8_UNORM, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R8_SNORM, glm::u32vec4(0)}, //FORMAT_R8_SNORM, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_R8_USCALED_GLI, glm::u32vec4(0x00FF0000, 0x00000000, 0x00000000, 0x00000000)}, //FORMAT_R8_USCALED, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_R8_SSCALED_GLI, glm::u32vec4(0)}, //FORMAT_R8_SSCALED, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R8_UINT, glm::u32vec4(0)}, //FORMAT_R8_UINT, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R8_SINT, glm::u32vec4(0)}, //FORMAT_R8_SINT, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_R8_SRGB_GLI, glm::u32vec4(0)}, //FORMAT_R8_SRGB, + + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R8G8_UNORM, glm::u32vec4(0x00FF0000, 0x0000FF00, 0x00000000, 0x00000000)}, //FORMAT_RG8_UNORM, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R8G8_SNORM, glm::u32vec4(0)}, //FORMAT_RG8_SNORM, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_R8G8_USCALED_GLI, glm::u32vec4(0x00FF0000, 0x0000FF00, 0x00000000, 0x00000000)}, //FORMAT_RG8_USCALED, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_R8G8_SSCALED_GLI, glm::u32vec4(0)}, //FORMAT_RG8_SSCALED, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R8G8_UINT, glm::u32vec4(0)}, //FORMAT_RG8_UINT, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R8G8_SINT, glm::u32vec4(0)}, //FORMAT_RG8_SINT, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_R8G8_SRGB_GLI, glm::u32vec4(0)}, //FORMAT_RG8_SRGB, + + {DDPF_RGB, D3DFMT_GLI1, DXGI_FORMAT_R8G8B8_UNORM_GLI, glm::u32vec4(0x000000FF, 0x0000FF00, 0x00FF0000, 0x00000000)}, //FORMAT_RGB8_UNORM, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_R8G8B8_SNORM_GLI, glm::u32vec4(0)}, //FORMAT_RGB8_SNORM, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_R8G8B8_USCALED_GLI, glm::u32vec4(0)}, //FORMAT_RGB8_USCALED, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_R8G8B8_SSCALED_GLI, glm::u32vec4(0)}, //FORMAT_RGB8_SSCALED, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_R8G8B8_UINT_GLI, glm::u32vec4(0)}, //FORMAT_RGB8_UINT, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_R8G8B8_SINT_GLI, glm::u32vec4(0)}, //FORMAT_RGB8_SINT, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_R8G8B8_SRGB_GLI, glm::u32vec4(0)}, //FORMAT_RGB8_SRGB, + + {DDPF_RGB, D3DFMT_R8G8B8, DXGI_FORMAT_B8G8R8_UNORM_GLI, glm::u32vec4(0x00FF0000, 0x0000FF00, 0x000000FF, 0x00000000)}, //FORMAT_BGR8_UNORM, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_B8G8R8_SNORM_GLI, glm::u32vec4(0)}, //FORMAT_BGR8_SNORM, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_B8G8R8_USCALED_GLI, glm::u32vec4(0)}, //FORMAT_BGR8_USCALED, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_B8G8R8_SSCALED_GLI, glm::u32vec4(0)}, //FORMAT_BGR8_SSCALED, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_B8G8R8_UINT_GLI, glm::u32vec4(0)}, //FORMAT_BGR8_UINT, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_B8G8R8_SINT_GLI, glm::u32vec4(0)}, //FORMAT_BGR8_SINT, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_B8G8R8_SRGB_GLI, glm::u32vec4(0)}, //FORMAT_BGR8_SRGB, + + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R8G8B8A8_UNORM, glm::u32vec4(0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000)}, //FORMAT_RGBA8_UNORM, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R8G8B8A8_SNORM, glm::u32vec4(0)}, //FORMAT_RGBA8_SNORM, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_R8G8B8A8_USCALED_GLI, glm::u32vec4(0)}, //FORMAT_RGBA8_USCALED, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_R8G8B8A8_SSCALED_GLI, glm::u32vec4(0)}, //FORMAT_RGBA8_SSCALED, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R8G8B8A8_UINT, glm::u32vec4(0)}, //FORMAT_RGBA8_UINT, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R8G8B8A8_SINT, glm::u32vec4(0)}, //FORMAT_RGBA8_SINT, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, glm::u32vec4(0)}, //FORMAT_RGBA8_SRGB, + + {DDPF_FOURCC, D3DFMT_A8R8G8B8, DXGI_FORMAT_B8G8R8A8_UNORM, glm::u32vec4(0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000)}, //FORMAT_BGRA8_UNORM, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_B8G8R8A8_SNORM_GLI, glm::u32vec4(0)}, //FORMAT_BGRA8_SNORM, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_B8G8R8A8_USCALED_GLI, glm::u32vec4(0)}, //FORMAT_BGRA8_USCALED, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_B8G8R8A8_SSCALED_GLI, glm::u32vec4(0)}, //FORMAT_BGRA8_SSCALED, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_B8G8R8A8_UINT_GLI, glm::u32vec4(0)}, //FORMAT_BGRA8_UINT, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_B8G8R8A8_SINT_GLI, glm::u32vec4(0)}, //FORMAT_BGRA8_SINT, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_B8G8R8A8_UNORM_SRGB, glm::u32vec4(0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000)}, //FORMAT_BGRA8_SRGB, + + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_R8G8B8A8_PACK_UNORM_GLI, glm::u32vec4(0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000)}, //FORMAT_ABGR8_UNORM, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_R8G8B8A8_PACK_SNORM_GLI, glm::u32vec4(0)}, //FORMAT_ABGR8_SNORM, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_R8G8B8A8_PACK_USCALED_GLI, glm::u32vec4(0)}, //FORMAT_ABGR8_USCALED, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_R8G8B8A8_PACK_SSCALED_GLI, glm::u32vec4(0)}, //FORMAT_ABGR8_SSCALED, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_R8G8B8A8_PACK_UINT_GLI, glm::u32vec4(0)}, //FORMAT_ABGR8_UINT, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_R8G8B8A8_PACK_SINT_GLI, glm::u32vec4(0)}, //FORMAT_ABGR8_SINT, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_R8G8B8A8_PACK_SRGB_GLI, glm::u32vec4(0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000)}, //FORMAT_ABGR8_SRGB, + + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R10G10B10A2_UNORM, glm::u32vec4(0x000003FF, 0x000FFC00, 0x3FF00000, 0xC0000000)}, //FORMAT_RGB10A2_UNORM_PACK32, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_R10G10B10A2_SNORM_GLI, glm::u32vec4(0x000003FF, 0x000FFC00, 0x3FF00000, 0xC0000000)}, //FORMAT_RGB10A2_SNORM_PACK32, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_R10G10B10A2_USCALED_GLI, glm::u32vec4(0x000003FF, 0x000FFC00, 0x3FF00000, 0xC0000000)}, //FORMAT_RGB10A2_USCALED_PACK32, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_R10G10B10A2_SSCALED_GLI, glm::u32vec4(0x000003FF, 0x000FFC00, 0x3FF00000, 0xC0000000)}, //FORMAT_RGB10A2_SSCALED_PACK32, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R10G10B10A2_UINT, glm::u32vec4(0x000003FF, 0x000FFC00, 0x3FF00000, 0xC0000000)}, //FORMAT_RGB10A2_UINT_PACK32, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_R10G10B10A2_SINT_GLI, glm::u32vec4(0x000003FF, 0x000FFC00, 0x3FF00000, 0xC0000000)}, //FORMAT_RGB10A2_SINT_PACK32, + + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_B10G10R10A2_UNORM_GLI, glm::u32vec4(0x3FF00000, 0x000FFC00, 0x000003FF, 0xC0000000)}, //FORMAT_BGR10A2_UNORM_PACK32, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_B10G10R10A2_SNORM_GLI, glm::u32vec4(0x3FF00000, 0x000FFC00, 0x000003FF, 0xC0000000)}, //FORMAT_BGR10A2_SNORM_PACK32, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_B10G10R10A2_USCALED_GLI, glm::u32vec4(0x3FF00000, 0x000FFC00, 0x000003FF, 0xC0000000)}, //FORMAT_BGR10A2_USCALED_PACK32, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_B10G10R10A2_SSCALED_GLI, glm::u32vec4(0x3FF00000, 0x000FFC00, 0x000003FF, 0xC0000000)}, //FORMAT_BGR10A2_SSCALED_PACK32, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_B10G10R10A2_UINT_GLI, glm::u32vec4(0x3FF00000, 0x000FFC00, 0x000003FF, 0xC0000000)}, //FORMAT_BGR10A2_UINT_PACK32, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_B10G10R10A2_SINT_GLI, glm::u32vec4(0x3FF00000, 0x000FFC00, 0x000003FF, 0xC0000000)}, //FORMAT_BGR10A2_SINT_PACK32, + + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R16_UNORM, glm::u32vec4(0x0000FFFF, 0x00000000, 0x00000000, 0x00000000)}, //FORMAT_R16_UNORM_PACK16, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R16_SNORM, glm::u32vec4(0x0000FFFF, 0x00000000, 0x00000000, 0x00000000)}, //FORMAT_R16_SNORM_PACK16, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_R16_USCALED_GLI, glm::u32vec4(0x0000FFFF, 0x00000000, 0x00000000, 0x00000000)}, //FORMAT_R16_USCALED_PACK16, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_R16_SSCALED_GLI, glm::u32vec4(0x0000FFFF, 0x00000000, 0x00000000, 0x00000000)}, //FORMAT_R16_SSCALED_PACK16, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R16_UINT, glm::u32vec4(0x0000FFFF, 0x00000000, 0x00000000, 0x0000000)}, //FORMAT_R16_UINT_PACK16, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R16_SINT, glm::u32vec4(0x0000FFFF, 0x00000000, 0x00000000, 0x0000000)}, //FORMAT_R16_SINT_PACK16, + {DDPF_FOURCC, D3DFMT_R16F, DXGI_FORMAT_R16_FLOAT, glm::u32vec4(0x0000FFFF, 0x00000000, 0x00000000, 0x0000000)}, //FORMAT_R16_SFLOAT_PACK16, + + {DDPF_FOURCC, D3DFMT_G16R16, DXGI_FORMAT_R16G16_UNORM, glm::u32vec4(0x0000FFFF, 0xFFFF0000, 0x00000000, 0x00000000)}, //FORMAT_RG16_UNORM_PACK16, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R16G16_SNORM, glm::u32vec4(0x0000FFFF, 0xFFFF0000, 0x00000000, 0x00000000)}, //FORMAT_RG16_SNORM_PACK16, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_R16G16_USCALED_GLI, glm::u32vec4(0x0000FFFF, 0xFFFF0000, 0x00000000, 0x00000000)}, //FORMAT_RG16_USCALED_PACK16, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_R16G16_SSCALED_GLI, glm::u32vec4(0x0000FFFF, 0xFFFF0000, 0x00000000, 0x00000000)}, //FORMAT_RG16_SSCALED_PACK16, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R16G16_UINT, glm::u32vec4(0x0000FFFF, 0xFFFF0000, 0x00000000, 0x00000000)}, //FORMAT_RG16_UINT_PACK16, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R16G16_SINT, glm::u32vec4(0x0000FFFF, 0xFFFF0000, 0x00000000, 0x00000000)}, //FORMAT_RG16_SINT_PACK16, + {DDPF_FOURCC, D3DFMT_G16R16F, DXGI_FORMAT_R16G16_FLOAT, glm::u32vec4(0x0000FFFF, 0xFFFF0000, 0x00000000, 0x00000000)}, //FORMAT_RG16_SFLOAT_PACK16, + + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_R16G16B16_UNORM_GLI, glm::u32vec4(0)}, //FORMAT_RGB16_UNORM_PACK16, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_R16G16B16_SNORM_GLI, glm::u32vec4(0)}, //FORMAT_RGB16_SNORM_PACK16, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_R16G16B16_USCALED_GLI, glm::u32vec4(0)}, //FORMAT_RGB16_USCALED_PACK16, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_R16G16B16_SSCALED_GLI, glm::u32vec4(0)}, //FORMAT_RGB16_SSCALED_PACK16, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_R16G16B16_UINT_GLI, glm::u32vec4(0)}, //FORMAT_RGB16_UINT_PACK16, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_R16G16B16_SINT_GLI, glm::u32vec4(0)}, //FORMAT_RGB16_SINT_PACK16, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_R16G16B16_FLOAT_GLI, glm::u32vec4(0)}, //FORMAT_RGB16_SFLOAT_PACK16, + + {DDPF_FOURCC, D3DFMT_A16B16G16R16, DXGI_FORMAT_R16G16B16A16_UNORM, glm::u32vec4(0)}, //FORMAT_RGBA16_UNORM_PACK16, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R16G16B16A16_SNORM, glm::u32vec4(0)}, //FORMAT_RGBA16_SNORM_PACK16, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_R16G16B16A16_USCALED_GLI, glm::u32vec4(0)}, //FORMAT_RGBA16_USCALED_PACK16, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_R16G16B16A16_SSCALED_GLI, glm::u32vec4(0)}, //FORMAT_RGBA16_SSCALED_PACK16, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R16G16B16A16_UINT, glm::u32vec4(0)}, //FORMAT_RGBA16_UINT_PACK16, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R16G16B16A16_SINT, glm::u32vec4(0)}, //FORMAT_RGBA16_SINT_PACK16, + {DDPF_FOURCC, D3DFMT_A16B16G16R16F, DXGI_FORMAT_R16G16B16A16_FLOAT, glm::u32vec4(0)}, //FORMAT_RGBA16_SFLOAT_PACK16, + + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R32_UINT, glm::u32vec4(0)}, //FORMAT_R32_UINT_PACK32, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R32_SINT, glm::u32vec4(0)}, //FORMAT_R32_SINT_PACK32, + {DDPF_FOURCC, D3DFMT_R32F, DXGI_FORMAT_R32_FLOAT, glm::u32vec4(0xFFFFFFFF, 0x0000000, 0x0000000, 0x0000000)}, //FORMAT_R32_SFLOAT_PACK32, + + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R32G32_UINT, glm::u32vec4(0)}, //FORMAT_RG32_UINT_PACK32 + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R32G32_SINT, glm::u32vec4(0)}, //FORMAT_RG32_SINT_PACK32, + {DDPF_FOURCC, D3DFMT_G32R32F, DXGI_FORMAT_R32G32_FLOAT, glm::u32vec4(0)}, //FORMAT_RG32_SFLOAT_PACK32, + + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R32G32B32_UINT, glm::u32vec4(0)}, //FORMAT_RGB32_UINT_PACK32, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R32G32B32_SINT, glm::u32vec4(0)}, //FORMAT_RGB32_SINT_PACK32, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R32G32B32_FLOAT, glm::u32vec4(0)}, //FORMAT_RGB32_SFLOAT_PACK32, + + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R32G32B32A32_UINT, glm::u32vec4(0)}, //FORMAT_RGBA32_UINT_PACK32, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R32G32B32A32_SINT, glm::u32vec4(0)}, //FORMAT_RGBA32_SINT_PACK32, + {DDPF_FOURCC, D3DFMT_A32B32G32R32F, DXGI_FORMAT_R32G32B32A32_FLOAT, glm::u32vec4(0)}, //FORMAT_RGBA32_SFLOAT_PACK32, + + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_R64_UINT_GLI, glm::u32vec4(0)}, //FORMAT_R64_UINT_PACK64, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_R64_SINT_GLI, glm::u32vec4(0)}, //FORMAT_R64_SINT_PACK64, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_R64_FLOAT_GLI, glm::u32vec4(0)}, //FORMAT_R64_SFLOAT_PACK64, + + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_R64G64_UINT_GLI, glm::u32vec4(0)}, //FORMAT_RG64_UINT_PACK64, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_R64G64_SINT_GLI, glm::u32vec4(0)}, //FORMAT_RG64_SINT_PACK64, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_R64G64_FLOAT_GLI, glm::u32vec4(0)}, //FORMAT_RG64_SFLOAT_PACK64, + + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_R64G64B64_UINT_GLI, glm::u32vec4(0)}, //FORMAT_RGB64_UINT_PACK64, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_R64G64B64_SINT_GLI, glm::u32vec4(0)}, //FORMAT_RGB64_SINT_PACK64, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_R64G64B64_FLOAT_GLI, glm::u32vec4(0)}, //FORMAT_RGB64_SFLOAT_PACK64, + + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_R64G64B64A64_UINT_GLI, glm::u32vec4(0)}, //FORMAT_RGBA64_UINT_PACK64, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_R64G64B64A64_SINT_GLI, glm::u32vec4(0)}, //FORMAT_RGBA64_SINT_PACK64, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_R64G64B64A64_FLOAT_GLI, glm::u32vec4(0)}, //FORMAT_RGBA64_SFLOAT_PACK64, + + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R11G11B10_FLOAT, glm::u32vec4(0)}, //FORMAT_RG11B10_UFLOAT, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_R9G9B9E5_SHAREDEXP, glm::u32vec4(0)}, //FORMAT_RGB9E5_UFLOAT, + + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_D16_UNORM, glm::u32vec4(0)}, //FORMAT_D16_UNORM_PACK16, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_D24_UNORM_GLI, glm::u32vec4(0)}, //FORMAT_D24_UNORM, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_D32_FLOAT, glm::u32vec4(0)}, //FORMAT_D32_SFLOAT_PACK32, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_S8_UINT_GLI, glm::u32vec4(0)}, //FORMAT_S8_UINT_PACK8, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_D16_UNORM_S8_UINT_GLI, glm::u32vec4(0)}, //FORMAT_D16_UNORM_S8_UINT_PACK32, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_D24_UNORM_S8_UINT, glm::u32vec4(0)}, //FORMAT_D24_UNORM_S8_UINT_PACK32, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_D32_FLOAT_S8X24_UINT, glm::u32vec4(0)}, //FORMAT_D32_SFLOAT_S8_UINT_PACK64, + + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_BC1_RGB_UNORM_GLI, glm::u32vec4(0)}, //FORMAT_RGB_DXT1_UNORM_BLOCK8, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_BC1_RGB_SRGB_GLI, glm::u32vec4(0)}, //FORMAT_RGB_DXT1_SRGB_BLOCK8, + {DDPF_FOURCC, D3DFMT_DXT1, DXGI_FORMAT_BC1_UNORM, glm::u32vec4(0)}, //FORMAT_RGBA_DXT1_UNORM_BLOCK8, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_BC1_UNORM_SRGB, glm::u32vec4(0)}, //FORMAT_RGBA_DXT1_SRGB_BLOCK8, + {DDPF_FOURCC, D3DFMT_DXT3, DXGI_FORMAT_BC2_UNORM, glm::u32vec4(0)}, //FORMAT_RGBA_DXT3_UNORM_BLOCK16, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_BC2_UNORM_SRGB, glm::u32vec4(0)}, //FORMAT_RGBA_DXT3_SRGB_BLOCK16, + {DDPF_FOURCC, D3DFMT_DXT5, DXGI_FORMAT_BC3_UNORM, glm::u32vec4(0)}, //FORMAT_RGBA_DXT5_UNORM_BLOCK16, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_BC3_UNORM_SRGB, glm::u32vec4(0)}, //FORMAT_RGBA_DXT5_SRGB_BLOCK16, + {DDPF_FOURCC, D3DFMT_ATI1, DXGI_FORMAT_BC4_UNORM, glm::u32vec4(0)}, //FORMAT_R_ATI1N_UNORM_BLOCK8, + {DDPF_FOURCC, D3DFMT_AT1N, DXGI_FORMAT_BC4_SNORM, glm::u32vec4(0)}, //FORMAT_R_ATI1N_SNORM_BLOCK8, + {DDPF_FOURCC, D3DFMT_ATI2, DXGI_FORMAT_BC5_UNORM, glm::u32vec4(0)}, //FORMAT_RG_ATI2N_UNORM_BLOCK16, + {DDPF_FOURCC, D3DFMT_AT2N, DXGI_FORMAT_BC5_SNORM, glm::u32vec4(0)}, //FORMAT_RG_ATI2N_SNORM_BLOCK16, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_BC6H_UF16, glm::u32vec4(0)}, //FORMAT_RGB_BP_UFLOAT_BLOCK16, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_BC6H_SF16, glm::u32vec4(0)}, //FORMAT_RGB_BP_SFLOAT_BLOCK16, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_BC7_UNORM, glm::u32vec4(0)}, //FORMAT_RGB_BP_UNORM, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_BC7_UNORM_SRGB, glm::u32vec4(0)}, //FORMAT_RGB_BP_SRGB, + + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_RGB_ETC2_UNORM_GLI, glm::u32vec4(0)}, //FORMAT_RGB_ETC2_UNORM_BLOCK8, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_RGB_ETC2_SRGB_GLI, glm::u32vec4(0)}, //FORMAT_RGB_ETC2_SRGB_BLOCK8, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_RGBA_ETC2_A1_UNORM_GLI, glm::u32vec4(0)}, //FORMAT_RGBA_ETC2_A1_UNORM_BLOCK8, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_RGBA_ETC2_A1_SRGB_GLI, glm::u32vec4(0)}, //FORMAT_RGBA_ETC2_A1_SRGB_BLOCK8, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_RGBA_ETC2_UNORM_GLI, glm::u32vec4(0)}, //FORMAT_RGBA_ETC2_UNORM_BLOCK16, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_RGBA_ETC2_SRGB_GLI, glm::u32vec4(0)}, //FORMAT_RGBA_ETC2_SRGB_BLOCK16, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_R11_EAC_UNORM_GLI, glm::u32vec4(0)}, //FORMAT_R_EAC_UNORM_BLOCK8, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_R11_EAC_SNORM_GLI, glm::u32vec4(0)}, //FORMAT_R_EAC_SNORM_BLOCK8, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_RG11_EAC_UNORM_GLI, glm::u32vec4(0)}, //FORMAT_RG_EAC_UNORM_BLOCK8, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_RG11_EAC_SNORM_GLI, glm::u32vec4(0)}, //FORMAT_RG_EAC_SNORM_BLOCK8, + + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_4X4_UNORM, glm::u32vec4(0)}, //FORMAT_ASTC_4x4_UNORM, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_4X4_UNORM_SRGB, glm::u32vec4(0)}, //FORMAT_ASTC_4x4_SRGB, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_5X4_UNORM, glm::u32vec4(0)}, //RGBA_ASTC_5x4, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_5X4_UNORM_SRGB, glm::u32vec4(0)}, //SRGB_ALPHA_ASTC_5x4, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_5X5_UNORM, glm::u32vec4(0)}, //RGBA_ASTC_5x5, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_5X5_UNORM_SRGB, glm::u32vec4(0)}, //SRGB_ALPHA_ASTC_5x5, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_6X5_UNORM, glm::u32vec4(0)}, //RGBA_ASTC_6x5, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_6X5_UNORM_SRGB, glm::u32vec4(0)}, //SRGB_ALPHA_ASTC_6x5, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_6X6_UNORM, glm::u32vec4(0)}, //RGBA_ASTC_6x6, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_6X6_UNORM_SRGB, glm::u32vec4(0)}, //SRGB_ALPHA_ASTC_6x6, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_8X5_UNORM, glm::u32vec4(0)}, //RGBA_ASTC_8x5, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_8X5_UNORM_SRGB, glm::u32vec4(0)}, //SRGB_ALPHA_ASTC_8x5, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_8X6_UNORM, glm::u32vec4(0)}, //RGBA_ASTC_8x6, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_8X6_UNORM_SRGB, glm::u32vec4(0)}, //SRGB_ALPHA_ASTC_8x6, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_8X8_UNORM, glm::u32vec4(0)}, //RGBA_ASTC_8x8, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_8X8_UNORM_SRGB, glm::u32vec4(0)}, //SRGB_ALPHA_ASTC_8x8, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_10X5_UNORM, glm::u32vec4(0)}, //RGBA_ASTC_10x5, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_10X5_UNORM_SRGB, glm::u32vec4(0)}, //SRGB_ALPHA_ASTC_10x5, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_10X6_UNORM, glm::u32vec4(0)}, //RGBA_ASTC_10x6, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_10X6_UNORM_SRGB, glm::u32vec4(0)}, //SRGB_ALPHA_ASTC_10x6, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_10X8_UNORM, glm::u32vec4(0)}, //RGBA_ASTC_10x8, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_10X8_UNORM_SRGB, glm::u32vec4(0)}, //SRGB_ALPHA_ASTC_10x8, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_10X10_UNORM_SRGB, glm::u32vec4(0)}, //SRGB_ALPHA_ASTC_10x10, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_10X10_UNORM, glm::u32vec4(0)}, //RGBA_ASTC_10x10, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_12X10_UNORM, glm::u32vec4(0)}, //RGBA_ASTC_12x10, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_12X10_UNORM_SRGB, glm::u32vec4(0)}, //SRGB_ALPHA_ASTC_12x10, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_12X12_UNORM, glm::u32vec4(0)}, //RGBA_ASTC_12x12, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_ASTC_12X12_UNORM_SRGB, glm::u32vec4(0)}, //SRGB_ALPHA_ASTC_12x12, + + {DDPF_FOURCC, D3DFMT_POWERVR_4BPP, DXGI_FORMAT_RGB_PVRTC1_8X8_UNORM_GLI, glm::u32vec4(0)}, //FORMAT_RGB_PVRTC1_8X8_UNORM_BLOCK32, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_RGB_PVRTC1_8X8_SRGB_GLI, glm::u32vec4(0)}, //FORMAT_RGB_PVRTC1_8X8_SRGB_BLOCK32, + {DDPF_FOURCC, D3DFMT_POWERVR_2BPP, DXGI_FORMAT_RGB_PVRTC1_16X8_UNORM_GLI, glm::u32vec4(0)}, //FORMAT_RGB_PVRTC1_16X8_UNORM_BLOCK32, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_RGB_PVRTC1_16X8_SRGB_GLI, glm::u32vec4(0)}, //FORMAT_RGB_PVRTC1_16X8_SRGB_BLOCK32, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_RGBA_PVRTC1_8X8_UNORM_GLI, glm::u32vec4(0)}, //FORMAT_RGBA_PVRTC1_8X8_UNORM_BLOCK32, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_RGBA_PVRTC1_8X8_SRGB_GLI, glm::u32vec4(0)}, //FORMAT_RGBA_PVRTC1_8X8_SRGB_BLOCK32, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_RGBA_PVRTC1_16X8_UNORM_GLI, glm::u32vec4(0)}, //FORMAT_RGBA_PVRTC1_16X8_UNORM_BLOCK32, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_RGBA_PVRTC1_16X8_SRGB_GLI, glm::u32vec4(0)}, //FORMAT_RGBA_PVRTC1_16X8_SRGB_BLOCK32, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_RGBA_PVRTC2_8X8_UNORM_GLI, glm::u32vec4(0)}, //FORMAT_RGBA_PVRTC2_8X8_UNORM, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_RGBA_PVRTC2_8X8_SRGB_GLI, glm::u32vec4(0)}, //FORMAT_RGBA_PVRTC2_8X8_SRGB, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_RGBA_PVRTC2_16X8_UNORM_GLI, glm::u32vec4(0)}, //FORMAT_RGBA_PVRTC2_16X8_UNORM, + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_RGBA_PVRTC2_16X8_SRGB_GLI, glm::u32vec4(0)}, //FORMAT_RGBA_PVRTC2_16X8_SRGB, + + {DDPF_FOURCC, D3DFMT_ETC, DXGI_FORMAT_RGB_ETC_UNORM_GLI, glm::u32vec4(0)}, //FORMAT_RGB_ETC_UNORM_BLOCK8, + {DDPF_FOURCC, D3DFMT_ATC, DXGI_FORMAT_RGB_ATC_UNORM_GLI, glm::u32vec4(0)}, //FORMAT_RGB_ATC_UNORM_BLOCK8, + {DDPF_FOURCC, D3DFMT_ATCA, DXGI_FORMAT_RGBA_ATCA_UNORM_GLI, glm::u32vec4(0)}, //FORMAT_RGBA_ATCA_UNORM_BLOCK16, + {DDPF_FOURCC, D3DFMT_ATCI, DXGI_FORMAT_RGBA_ATCI_UNORM_GLI, glm::u32vec4(0)}, //FORMAT_RGBA_ATCI_UNORM_BLOCK16, + + {DDPF_LUMINANCE, D3DFMT_L8, DXGI_FORMAT_L8_UNORM_GLI, glm::u32vec4(0x000000FF, 0x00000000, 0x00000000, 0x00000000)}, //L8_UNORM, + {DDPF_ALPHA, D3DFMT_A8, DXGI_FORMAT_A8_UNORM_GLI, glm::u32vec4(0x00000000, 0x00000000, 0x00000000, 0x000000FF)}, //A8_UNORM, + {DDPF_LUMINANCE_ALPHA, D3DFMT_A8L8, DXGI_FORMAT_LA8_UNORM_GLI, glm::u32vec4(0x000000FF, 0x00000000, 0x00000000, 0x0000FF00)}, //LA8_UNORM, + {DDPF_LUMINANCE, D3DFMT_L16, DXGI_FORMAT_L16_UNORM_GLI, glm::u32vec4(0x0000FFFF, 0x00000000, 0x00000000, 0x00000000)}, //L16_UNORM, + {DDPF_ALPHA, D3DFMT_GLI1, DXGI_FORMAT_A16_UNORM_GLI, glm::u32vec4(0x00000000, 0x00000000, 0x00000000, 0x0000FFFF)}, //A16_UNORM, + {DDPF_LUMINANCE_ALPHA, D3DFMT_GLI1, DXGI_FORMAT_LA16_UNORM_GLI, glm::u32vec4(0x0000FFFF, 0x00000000, 0x00000000, 0xFFFF0000)}, //LA16_UNORM, + + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_B8G8R8X8_UNORM, glm::u32vec4(0x00FF0000, 0x0000FF00, 0x000000FF, 0x00000000)}, //FORMAT_BGR8_UNORM_PACK32, + {DDPF_FOURCC, D3DFMT_DX10, DXGI_FORMAT_B8G8R8X8_UNORM_SRGB, glm::u32vec4(0x00FF0000, 0x0000FF00, 0x000000FF, 0x00000000)}, //FORMAT_BGR8_SRGB_PACK32, + + {DDPF_FOURCC, D3DFMT_GLI1, DXGI_FORMAT_R3G3B2_UNORM_GLI, glm::u32vec4(0x70, 0x38, 0xC0, 0x00)}, //FORMAT_RG3B2_UNORM, + }; + static_assert(sizeof(Table) / sizeof(Table[0]) == FORMAT_COUNT, "GLI error: format descriptor list doesn't match number of supported formats"); + + std::copy(&Table[0], &Table[0] + FORMAT_COUNT, this->Translation.begin()); + } + + inline dx::format const& dx::translate(gli::format Format) const + { + GLI_ASSERT(Format >= FORMAT_FIRST && Format <= FORMAT_LAST); + return Translation[Format - FORMAT_FIRST]; + } + + inline gli::format dx::find(dx::d3dfmt FourCC) const + { + gli::format FormatResult = static_cast(FORMAT_INVALID); + for(int FormatIndex = FORMAT_FIRST; FormatIndex <= FORMAT_LAST; ++FormatIndex) + { + if(this->Translation[FormatIndex - FORMAT_FIRST].D3DFormat != FourCC) + continue; + + FormatResult = static_cast(FormatIndex); + break; + } + return FormatResult; + } + + inline gli::format dx::find(dx::d3dfmt FourCC, dx::dxgiFormat Format) const + { + GLI_ASSERT(FourCC == D3DFMT_DX10 || FourCC == D3DFMT_GLI1); + + gli::format FormatResult = static_cast(FORMAT_INVALID); + for(int FormatIndex = FORMAT_FIRST; FormatIndex <= FORMAT_LAST; ++FormatIndex) + { + gli::format CurrentFormat = static_cast(FormatIndex); + detail::formatInfo const & FormatInfo = detail::get_format_info(CurrentFormat); + + dx::format const & DXFormat = this->Translation[FormatIndex - FORMAT_FIRST]; + + if(FourCC == D3DFMT_GLI1 && (FormatInfo.Flags & detail::CAP_DDS_GLI_EXT_BIT) && DXFormat.DXGIFormat.GLI == Format.GLI) + { + FormatResult = static_cast(FormatIndex); + break; + } + + if(FourCC == D3DFMT_DX10 && !(FormatInfo.Flags & detail::CAP_DDS_GLI_EXT_BIT) && DXFormat.DXGIFormat.DDS == Format.DDS) + { + FormatResult = static_cast(FormatIndex); + break; + } + } + return FormatResult; + } + + inline bool is_dds_ext(target Target, format Format) + { + dx DX; + dx::format const & DXFormat = DX.translate(Format); + + bool const UseDDSExt = detail::get_format_info(Format).Flags & detail::CAP_DDS_GLI_EXT_BIT ? true : false; + + return ((DXFormat.DDPixelFormat & dx::DDPF_FOURCC) && DXFormat.D3DFormat == dx::D3DFMT_GLI1) || ((is_target_array(Target) || is_target_1d(Target)) && UseDDSExt); + } +}//namespace gli diff --git a/test/external/gli/core/file.hpp b/test/external/gli/core/file.hpp new file mode 100644 index 00000000..b61e7ba9 --- /dev/null +++ b/test/external/gli/core/file.hpp @@ -0,0 +1,15 @@ +/// @brief File helper functions +/// @file gli/core/file.hpp + +#pragma once + +#include + +namespace gli{ +namespace detail +{ + FILE* open_file(const char *Filename, const char *mode); +}//namespace detail +}//namespace gli + +#include "./file.inl" diff --git a/test/external/gli/core/file.inl b/test/external/gli/core/file.inl new file mode 100644 index 00000000..018358fa --- /dev/null +++ b/test/external/gli/core/file.inl @@ -0,0 +1,19 @@ +#pragma once + +#include + +namespace gli{ +namespace detail +{ + inline FILE* open_file(const char *Filename, const char *Mode) + { +# if GLM_COMPILER & GLM_COMPILER_VC + FILE *File = nullptr; + fopen_s(&File, Filename, Mode); + return File; +# else + return std::fopen(Filename, Mode); +# endif + } +}//namespace detail +}//namespace gli diff --git a/test/external/gli/core/filter.hpp b/test/external/gli/core/filter.hpp new file mode 100644 index 00000000..5176ae98 --- /dev/null +++ b/test/external/gli/core/filter.hpp @@ -0,0 +1,23 @@ +/// @brief Include to use filter enum, to select filtering methods. +/// @file gli/core/filter.hpp + +#pragma once + +namespace gli +{ + /// Texture filtring modes + enum filter + { + FILTER_NONE = 0, + FILTER_NEAREST, FILTER_FIRST = FILTER_NEAREST, + FILTER_LINEAR, FILTER_LAST = FILTER_LINEAR + }; + + enum + { + FILTER_COUNT = FILTER_LAST - FILTER_FIRST + 1, + FILTER_INVALID = -1 + }; +}//namespace gli + +#include "filter.inl" diff --git a/test/external/gli/core/filter.inl b/test/external/gli/core/filter.inl new file mode 100644 index 00000000..fd0ab9b0 --- /dev/null +++ b/test/external/gli/core/filter.inl @@ -0,0 +1,8 @@ +#pragma once + +namespace gli{ +namespace detail +{ + +}//namespace detail +}//namespace gli diff --git a/test/external/gli/core/filter_compute.hpp b/test/external/gli/core/filter_compute.hpp new file mode 100644 index 00000000..a3956e53 --- /dev/null +++ b/test/external/gli/core/filter_compute.hpp @@ -0,0 +1,390 @@ +#pragma once + +#include "filter.hpp" +#include "coord.hpp" +#include + +namespace gli{ +namespace detail +{ + enum dimension + { + DIMENSION_1D, + DIMENSION_2D, + DIMENSION_3D + }; + + template + struct interpolate + { + typedef float type; + }; + + template <> + struct interpolate + { + typedef double type; + }; + + template <> + struct interpolate + { + typedef long double type; + }; + + template + struct filterBase + { + typedef typename texture_type::size_type size_type; + typedef typename texture_type::extent_type extent_type; + + typedef texel_type(*filterFunc)( + texture_type const & Texture, fetch_type Fetch, normalized_type const & SampleCoordWrap, + size_type Layer, size_type Face, interpolate_type Level, + texel_type const & BorderColor); + }; + + template + struct nearest : public filterBase + { + typedef filterBase base_type; + typedef typename base_type::size_type size_type; + typedef typename base_type::extent_type extent_type; + typedef coord_nearest coord_type; + + static texel_type call(texture_type const & Texture, fetch_type Fetch, normalized_type const & SampleCoordWrap, size_type Layer, size_type Face, size_type Level, texel_type const & BorderColor) + { + extent_type const TexelDim(Texture.extent(Level)); + normalized_type const TexelLast(normalized_type(TexelDim) - normalized_type(1)); + + //extent_type const TexelCoord(SampleCoordWrap * TexelLast + interpolate_type(0.5)); + extent_type const TexelCoord = extent_type(round(SampleCoordWrap * TexelLast)); + typename extent_type::bool_type const UseTexelCoord = in_interval(TexelCoord, extent_type(0), TexelDim - 1); + + texel_type Texel(BorderColor); + if(all(UseTexelCoord)) + Texel = Fetch(Texture, TexelCoord, Layer, Face, Level); + + return Texel; + } + }; + + template + struct nearest : public filterBase + { + typedef filterBase base_type; + typedef typename base_type::size_type size_type; + typedef typename base_type::extent_type extent_type; + typedef coord_nearest coord_type; + + static texel_type call(texture_type const & Texture, fetch_type Fetch, normalized_type const & SampleCoordWrap, size_type Layer, size_type Face, size_type Level, texel_type const & BorderColor) + { + normalized_type const TexelLast(normalized_type(Texture.extent(Level)) - normalized_type(1)); + extent_type const TexelCoord(SampleCoordWrap * TexelLast + interpolate_type(0.5)); + //extent_type const TexelCoord = extent_type(round(SampleCoordWrap * TexelLast)); + + return Fetch(Texture, TexelCoord, Layer, Face, Level); + } + }; + + template + struct linear : public filterBase + { + typedef filterBase base_type; + typedef typename base_type::size_type size_type; + typedef typename base_type::extent_type extent_type; + + static texel_type call(texture_type const & Texture, fetch_type Fetch, normalized_type const & SampleCoordWrap, size_type Layer, size_type Face, size_type Level, texel_type const& BorderColor) + { + return texel_type(0); + } + }; + + template + struct linear : public filterBase + { + typedef filterBase base_type; + typedef typename base_type::size_type size_type; + typedef typename base_type::extent_type extent_type; + typedef coord_linear_border coord_type; + + static texel_type call(texture_type const & Texture, fetch_type Fetch, normalized_type const & SampleCoordWrap, size_type Layer, size_type Face, size_type Level, texel_type const & BorderColor) + { + coord_type const& Coord = make_coord_linear_border(Texture.extent(Level), SampleCoordWrap); + + texel_type Texel0(BorderColor); + if(Coord.UseTexelFloor.s) + Texel0 = Fetch(Texture, extent_type(Coord.TexelFloor.s), Layer, Face, Level); + + texel_type Texel1(BorderColor); + if(Coord.UseTexelCeil.s) + Texel1 = Fetch(Texture, extent_type(Coord.TexelCeil.s), Layer, Face, Level); + + return mix(Texel0, Texel1, Coord.Blend.s); + } + }; + + template + struct linear : public filterBase + { + typedef filterBase base_type; + typedef typename base_type::size_type size_type; + typedef typename base_type::extent_type extent_type; + typedef coord_linear coord_type; + + static texel_type call(texture_type const & Texture, fetch_type Fetch, normalized_type const & SampleCoordWrap, size_type Layer, size_type Face, size_type Level, texel_type const & BorderColor) + { + coord_type const& Coord = make_coord_linear(Texture.extent(Level), SampleCoordWrap); + + texel_type const Texel0 = Fetch(Texture, extent_type(Coord.TexelFloor.s), Layer, Face, Level); + texel_type const Texel1 = Fetch(Texture, extent_type(Coord.TexelCeil.s), Layer, Face, Level); + + return mix(Texel0, Texel1, Coord.Blend.s); + } + }; + + template + struct linear : public filterBase + { + typedef filterBase base_type; + typedef typename base_type::size_type size_type; + typedef typename base_type::extent_type extent_type; + typedef coord_linear_border coord_type; + + static texel_type call(texture_type const& Texture, fetch_type Fetch, normalized_type const& SampleCoordWrap, size_type Layer, size_type Face, size_type Level, texel_type const& BorderColor) + { + coord_type const& Coord = make_coord_linear_border(Texture.extent(Level), SampleCoordWrap); + + texel_type Texel00(BorderColor); + if(Coord.UseTexelFloor.s && Coord.UseTexelFloor.t) + Texel00 = Fetch(Texture, extent_type(Coord.TexelFloor.s, Coord.TexelFloor.t), Layer, Face, Level); + + texel_type Texel10(BorderColor); + if(Coord.UseTexelCeil.s && Coord.UseTexelFloor.t) + Texel10 = Fetch(Texture, extent_type(Coord.TexelCeil.s, Coord.TexelFloor.t), Layer, Face, Level); + + texel_type Texel11(BorderColor); + if(Coord.UseTexelCeil.s && Coord.UseTexelCeil.t) + Texel11 = Fetch(Texture, extent_type(Coord.TexelCeil.s, Coord.TexelCeil.t), Layer, Face, Level); + + texel_type Texel01(BorderColor); + if(Coord.UseTexelFloor.s && Coord.UseTexelCeil.t) + Texel01 = Fetch(Texture, extent_type(Coord.TexelFloor.s, Coord.TexelCeil.t), Layer, Face, Level); + + texel_type const ValueA(mix(Texel00, Texel10, Coord.Blend.s)); + texel_type const ValueB(mix(Texel01, Texel11, Coord.Blend.s)); + return mix(ValueA, ValueB, Coord.Blend.t); + } + }; + + template + struct linear : public filterBase + { + typedef filterBase base_type; + typedef typename base_type::size_type size_type; + typedef typename base_type::extent_type extent_type; + typedef coord_linear coord_type; + + static texel_type call(texture_type const& Texture, fetch_type Fetch, normalized_type const& SampleCoordWrap, size_type Layer, size_type Face, size_type Level, texel_type const& BorderColor) + { + coord_type const& Coord = make_coord_linear(Texture.extent(Level), SampleCoordWrap); + + texel_type const& Texel00 = Fetch(Texture, extent_type(Coord.TexelFloor.s, Coord.TexelFloor.t), Layer, Face, Level); + texel_type const& Texel10 = Fetch(Texture, extent_type(Coord.TexelCeil.s, Coord.TexelFloor.t), Layer, Face, Level); + texel_type const& Texel11 = Fetch(Texture, extent_type(Coord.TexelCeil.s, Coord.TexelCeil.t), Layer, Face, Level); + texel_type const& Texel01 = Fetch(Texture, extent_type(Coord.TexelFloor.s, Coord.TexelCeil.t), Layer, Face, Level); + + texel_type const ValueA(mix(Texel00, Texel10, Coord.Blend.s)); + texel_type const ValueB(mix(Texel01, Texel11, Coord.Blend.s)); + return mix(ValueA, ValueB, Coord.Blend.t); + } + }; + + template + struct linear : public filterBase + { + typedef filterBase base_type; + typedef typename base_type::size_type size_type; + typedef typename base_type::extent_type extent_type; + typedef coord_linear_border coord_type; + + static texel_type call(texture_type const& Texture, fetch_type Fetch, normalized_type const& SampleCoordWrap, size_type Layer, size_type Face, size_type Level, texel_type const& BorderColor) + { + coord_type const& Coord = make_coord_linear_border(Texture.extent(Level), SampleCoordWrap); + + texel_type Texel000(BorderColor); + if(Coord.UseTexelFloor.s && Coord.UseTexelFloor.t && Coord.UseTexelFloor.p) + Texel000 = Fetch(Texture, extent_type(Coord.TexelFloor.s, Coord.TexelFloor.t, Coord.TexelFloor.p), Layer, Face, Level); + + texel_type Texel100(BorderColor); + if(Coord.UseTexelCeil.s && Coord.UseTexelFloor.t && Coord.UseTexelFloor.p) + Texel100 = Fetch(Texture, extent_type(Coord.TexelCeil.s, Coord.TexelFloor.t, Coord.TexelFloor.p), Layer, Face, Level); + + texel_type Texel110(BorderColor); + if(Coord.UseTexelCeil.s && Coord.UseTexelCeil.t && Coord.UseTexelFloor.p) + Texel110 = Fetch(Texture, extent_type(Coord.TexelCeil.s, Coord.TexelCeil.t, Coord.TexelFloor.p), Layer, Face, Level); + + texel_type Texel010(BorderColor); + if(Coord.UseTexelFloor.s && Coord.UseTexelCeil.t && Coord.UseTexelFloor.p) + Texel010 = Fetch(Texture, extent_type(Coord.TexelFloor.s, Coord.TexelCeil.t, Coord.TexelFloor.p), Layer, Face, Level); + + texel_type Texel001(BorderColor); + if (Coord.UseTexelFloor.s && Coord.UseTexelFloor.t && Coord.UseTexelCeil.p) + Texel001 = Fetch(Texture, extent_type(Coord.TexelFloor.s, Coord.TexelFloor.t, Coord.TexelCeil.p), Layer, Face, Level); + + texel_type Texel101(BorderColor); + if(Coord.UseTexelCeil.s && Coord.UseTexelFloor.t && Coord.UseTexelCeil.p) + Texel101 = Fetch(Texture, extent_type(Coord.TexelCeil.s, Coord.TexelFloor.t, Coord.TexelCeil.p), Layer, Face, Level); + + texel_type Texel111(BorderColor); + if(Coord.UseTexelCeil.s && Coord.UseTexelCeil.t && Coord.UseTexelCeil.p) + Texel111 = Fetch(Texture, extent_type(Coord.TexelCeil.s, Coord.TexelCeil.t, Coord.TexelCeil.p), Layer, Face, Level); + + texel_type Texel011(BorderColor); + if(Coord.UseTexelFloor.s && Coord.UseTexelCeil.t && Coord.UseTexelCeil.p) + Texel011 = Fetch(Texture, extent_type(Coord.TexelFloor.s, Coord.TexelCeil.t, Coord.TexelCeil.p), Layer, Face, Level); + + texel_type const ValueA(mix(Texel000, Texel100, Coord.Blend.s)); + texel_type const ValueB(mix(Texel010, Texel110, Coord.Blend.s)); + + texel_type const ValueC(mix(Texel001, Texel101, Coord.Blend.s)); + texel_type const ValueD(mix(Texel011, Texel111, Coord.Blend.s)); + + texel_type const ValueE(mix(ValueA, ValueB, Coord.Blend.t)); + texel_type const ValueF(mix(ValueC, ValueD, Coord.Blend.t)); + + return mix(ValueE, ValueF, Coord.Blend.p); + } + }; + + template + struct linear : public filterBase + { + typedef filterBase base_type; + typedef typename base_type::size_type size_type; + typedef typename base_type::extent_type extent_type; + typedef coord_linear coord_type; + + static texel_type call(texture_type const & Texture, fetch_type Fetch, normalized_type const & SampleCoordWrap, size_type Layer, size_type Face, size_type Level, texel_type const & BorderColor) + { + coord_type const & Coord = make_coord_linear(Texture.extent(Level), SampleCoordWrap); + + texel_type const & Texel000 = Fetch(Texture, extent_type(Coord.TexelFloor.s, Coord.TexelFloor.t, Coord.TexelFloor.p), Layer, Face, Level); + texel_type const & Texel100 = Fetch(Texture, extent_type(Coord.TexelCeil.s, Coord.TexelFloor.t, Coord.TexelFloor.p), Layer, Face, Level); + texel_type const & Texel110 = Fetch(Texture, extent_type(Coord.TexelCeil.s, Coord.TexelCeil.t, Coord.TexelFloor.p), Layer, Face, Level); + texel_type const & Texel010 = Fetch(Texture, extent_type(Coord.TexelFloor.s, Coord.TexelCeil.t, Coord.TexelFloor.p), Layer, Face, Level); + texel_type const & Texel001 = Fetch(Texture, extent_type(Coord.TexelFloor.s, Coord.TexelFloor.t, Coord.TexelCeil.p), Layer, Face, Level); + texel_type const & Texel101 = Fetch(Texture, extent_type(Coord.TexelCeil.s, Coord.TexelFloor.t, Coord.TexelCeil.p), Layer, Face, Level); + texel_type const & Texel111 = Fetch(Texture, extent_type(Coord.TexelCeil.s, Coord.TexelCeil.t, Coord.TexelCeil.p), Layer, Face, Level); + texel_type const & Texel011 = Fetch(Texture, extent_type(Coord.TexelFloor.s, Coord.TexelCeil.t, Coord.TexelCeil.p), Layer, Face, Level); + + texel_type const ValueA(mix(Texel000, Texel100, Coord.Blend.s)); + texel_type const ValueB(mix(Texel010, Texel110, Coord.Blend.s)); + + texel_type const ValueC(mix(Texel001, Texel101, Coord.Blend.s)); + texel_type const ValueD(mix(Texel011, Texel111, Coord.Blend.s)); + + texel_type const ValueE(mix(ValueA, ValueB, Coord.Blend.t)); + texel_type const ValueF(mix(ValueC, ValueD, Coord.Blend.t)); + + return mix(ValueE, ValueF, Coord.Blend.p); + } + }; + + template + struct nearest_mipmap_nearest : public filterBase + { + typedef filterBase base_type; + typedef typename base_type::size_type size_type; + typedef typename base_type::extent_type extent_type; + typedef coord_linear_border coord_type; + + static texel_type call(texture_type const & Texture, fetch_type Fetch, normalized_type const & SampleCoordWrap, size_type Layer, size_type Face, interpolate_type Level, texel_type const & BorderColor) + { + return nearest::call(Texture, Fetch, SampleCoordWrap, Layer, Face, glm::iround(Level), BorderColor); + } + }; + + template + struct nearest_mipmap_linear : public filterBase + { + typedef filterBase base_type; + typedef typename base_type::size_type size_type; + typedef typename base_type::extent_type extent_type; + typedef coord_linear_border coord_type; + + static texel_type call(texture_type const & Texture, fetch_type Fetch, normalized_type const & SampleCoordWrap, size_type Layer, size_type Face, interpolate_type Level, texel_type const & BorderColor) + { + texel_type const MinTexel = nearest::call(Texture, Fetch, SampleCoordWrap, Layer, Face, static_cast(floor(Level)), BorderColor); + texel_type const MaxTexel = nearest::call(Texture, Fetch, SampleCoordWrap, Layer, Face, static_cast(ceil(Level)), BorderColor); + return mix(MinTexel, MaxTexel, fract(Level)); + } + }; + + template + struct linear_mipmap_nearest : public filterBase + { + typedef filterBase base_type; + typedef typename base_type::size_type size_type; + typedef typename base_type::extent_type extent_type; + typedef coord_linear_border coord_type; + + static texel_type call(texture_type const & Texture, fetch_type Fetch, normalized_type const & SampleCoordWrap, size_type Layer, size_type Face, interpolate_type Level, texel_type const & BorderColor) + { + return linear::call(Texture, Fetch, SampleCoordWrap, Layer, Face, glm::iround(Level), BorderColor); + } + }; + + template + struct linear_mipmap_linear : public filterBase + { + typedef filterBase base_type; + typedef typename base_type::size_type size_type; + typedef typename base_type::extent_type extent_type; + typedef coord_linear_border coord_type; + + static texel_type call(texture_type const & Texture, fetch_type Fetch, normalized_type const & SampleCoordWrap, size_type Layer, size_type Face, interpolate_type Level, texel_type const & BorderColor) + { + size_type const FloorLevel = static_cast(floor(Level)); + size_type const CeilLevel = static_cast(ceil(Level)); + texel_type const MinTexel = linear::call(Texture, Fetch, SampleCoordWrap, Layer, Face, FloorLevel, BorderColor); + texel_type const MaxTexel = linear::call(Texture, Fetch, SampleCoordWrap, Layer, Face, CeilLevel, BorderColor); + return mix(MinTexel, MaxTexel, fract(Level)); + } + }; + + template + inline filter_type get_filter(filter Mip, filter Min, bool Border) + { + static filter_type Table[][FILTER_COUNT][2] = + { + { + { + nearest_mipmap_nearest::is_iec559, false>::call, + nearest_mipmap_nearest::is_iec559, true>::call + }, + { + linear_mipmap_nearest::is_iec559, false>::call, + linear_mipmap_nearest::is_iec559, true>::call + } + }, + { + { + nearest_mipmap_linear::is_iec559, false>::call, + nearest_mipmap_linear::is_iec559, true>::call + }, + { + linear_mipmap_linear::is_iec559, false>::call, + linear_mipmap_linear::is_iec559, true>::call + } + } + }; + static_assert(sizeof(Table) / sizeof(Table[0]) == FILTER_COUNT, "GLI ERROR: 'Table' doesn't match the number of supported filters"); + + GLI_ASSERT(Table[Mip - FILTER_FIRST][Min - FILTER_FIRST][Border ? 1 : 0]); + + return Table[Mip - FILTER_FIRST][Min - FILTER_FIRST][Border ? 1 : 0]; + } +}//namespace detail +}//namespace gli + diff --git a/test/external/gli/core/flip.hpp b/test/external/gli/core/flip.hpp new file mode 100644 index 00000000..f2885425 --- /dev/null +++ b/test/external/gli/core/flip.hpp @@ -0,0 +1,17 @@ +#pragma once + +#include + +#include "../texture2d.hpp" +#include "../texture2d_array.hpp" +#include "../texture_cube.hpp" +#include "../texture_cube_array.hpp" + +namespace gli +{ + template + texture flip(texture const & Texture); + +}//namespace gli + +#include "flip.inl" diff --git a/test/external/gli/core/flip.inl b/test/external/gli/core/flip.inl new file mode 100644 index 00000000..d58813c7 --- /dev/null +++ b/test/external/gli/core/flip.inl @@ -0,0 +1,338 @@ +namespace gli{ +namespace detail +{ + inline void flip(image ImageDst, image ImageSrc, size_t BlockSize) + { + size_t const LineSize = BlockSize * ImageDst.extent().x; + + for(int y = 0; y < ImageDst.extent().y; ++y) + { + size_t OffsetDst = LineSize * y; + size_t OffsetSrc = ImageSrc.size() - (LineSize * (y + 1)); + + memcpy( + ImageDst.data() + OffsetDst, + ImageSrc.data() + OffsetSrc, + LineSize); + } + } + + struct dxt1_block + { + uint16_t Color0; + uint16_t Color1; + uint8_t Row0; + uint8_t Row1; + uint8_t Row2; + uint8_t Row3; + }; + + struct dxt3_block + { + uint16_t AlphaRow0; + uint16_t AlphaRow1; + uint16_t AlphaRow2; + uint16_t AlphaRow3; + uint16_t Color0; + uint16_t Color1; + uint8_t Row0; + uint8_t Row1; + uint8_t Row2; + uint8_t Row3; + }; + + struct dxt5_block + { + uint8_t Alpha0; + uint8_t Alpha1; + uint8_t AlphaR0; + uint8_t AlphaR1; + uint8_t AlphaR2; + uint8_t AlphaR3; + uint8_t AlphaR4; + uint8_t AlphaR5; + uint16_t Color0; + uint16_t Color1; + uint8_t Row0; + uint8_t Row1; + uint8_t Row2; + uint8_t Row3; + }; + + inline void flip_block_s3tc(uint8_t* BlockDst, uint8_t* BlockSrc, format Format, bool HeightTwo) + { + // There is no distinction between RGB and RGBA in DXT-compressed textures, + // it is used only to tell OpenGL how to interpret the data. + // Moreover, in DXT1 (which does not contain an alpha channel), transparency can be emulated + // using Color0 and Color1 on a per-compression-block basis. + // There is no difference in how textures with and without transparency are laid out in the file, + // so they can be flipped using the same method. + if(Format == FORMAT_RGB_DXT1_UNORM_BLOCK8 || Format == FORMAT_RGB_DXT1_SRGB_BLOCK8 + || Format == FORMAT_RGBA_DXT1_UNORM_BLOCK8 || Format == FORMAT_RGBA_DXT1_SRGB_BLOCK8) + { + dxt1_block* Src = reinterpret_cast(BlockSrc); + dxt1_block* Dst = reinterpret_cast(BlockDst); + + if(HeightTwo) + { + Dst->Color0 = Src->Color0; + Dst->Color1 = Src->Color1; + Dst->Row0 = Src->Row1; + Dst->Row1 = Src->Row0; + Dst->Row2 = Src->Row2; + Dst->Row3 = Src->Row3; + + return; + } + + Dst->Color0 = Src->Color0; + Dst->Color1 = Src->Color1; + Dst->Row0 = Src->Row3; + Dst->Row1 = Src->Row2; + Dst->Row2 = Src->Row1; + Dst->Row3 = Src->Row0; + + return; + } + + // DXT3 + if(Format == FORMAT_RGBA_DXT3_UNORM_BLOCK16 || Format == FORMAT_RGBA_DXT3_SRGB_BLOCK16) + { + dxt3_block* Src = reinterpret_cast(BlockSrc); + dxt3_block* Dst = reinterpret_cast(BlockDst); + + if(HeightTwo) + { + Dst->AlphaRow0 = Src->AlphaRow1; + Dst->AlphaRow1 = Src->AlphaRow0; + Dst->AlphaRow2 = Src->AlphaRow2; + Dst->AlphaRow3 = Src->AlphaRow3; + Dst->Color0 = Src->Color0; + Dst->Color1 = Src->Color1; + Dst->Row0 = Src->Row1; + Dst->Row1 = Src->Row0; + Dst->Row2 = Src->Row2; + Dst->Row3 = Src->Row3; + + return; + } + + Dst->AlphaRow0 = Src->AlphaRow3; + Dst->AlphaRow1 = Src->AlphaRow2; + Dst->AlphaRow2 = Src->AlphaRow1; + Dst->AlphaRow3 = Src->AlphaRow0; + Dst->Color0 = Src->Color0; + Dst->Color1 = Src->Color1; + Dst->Row0 = Src->Row3; + Dst->Row1 = Src->Row2; + Dst->Row2 = Src->Row1; + Dst->Row3 = Src->Row0; + + return; + } + + // DXT5 + if(Format == FORMAT_RGBA_DXT5_UNORM_BLOCK16 || Format == FORMAT_RGBA_DXT5_SRGB_BLOCK16) + { + dxt5_block* Src = reinterpret_cast(BlockSrc); + dxt5_block* Dst = reinterpret_cast(BlockDst); + + if(HeightTwo) + { + Dst->Alpha0 = Src->Alpha0; + Dst->Alpha1 = Src->Alpha1; + // operator+ has precedence over operator>> and operator<<, hence the parentheses. very important! + // the values below are bitmasks used to retrieve alpha values according to the DXT specification + // 0xF0 == 0b11110000 and 0xF == 0b1111 + Dst->AlphaR0 = ((Src->AlphaR1 & 0xF0) >> 4) + ((Src->AlphaR2 & 0xF) << 4); + Dst->AlphaR1 = ((Src->AlphaR2 & 0xF0) >> 4) + ((Src->AlphaR0 & 0xF) << 4); + Dst->AlphaR2 = ((Src->AlphaR0 & 0xF0) >> 4) + ((Src->AlphaR1 & 0xF) << 4); + Dst->AlphaR3 = Src->AlphaR3; + Dst->AlphaR4 = Src->AlphaR4; + Dst->AlphaR5 = Src->AlphaR5; + Dst->Color0 = Src->Color0; + Dst->Color1 = Src->Color1; + Dst->Row0 = Src->Row1; + Dst->Row1 = Src->Row0; + Dst->Row2 = Src->Row2; + Dst->Row3 = Src->Row3; + + return; + } + + Dst->Alpha0 = Src->Alpha0; + Dst->Alpha1 = Src->Alpha1; + // operator+ has precedence over operator>> and operator<<, hence the parentheses. very important! + // the values below are bitmasks used to retrieve alpha values according to the DXT specification + // 0xF0 == 0b11110000 and 0xF == 0b1111 + Dst->AlphaR0 = ((Src->AlphaR4 & 0xF0) >> 4) + ((Src->AlphaR5 & 0xF) << 4); + Dst->AlphaR1 = ((Src->AlphaR5 & 0xF0) >> 4) + ((Src->AlphaR3 & 0xF) << 4); + Dst->AlphaR2 = ((Src->AlphaR3 & 0xF0) >> 4) + ((Src->AlphaR4 & 0xF) << 4); + Dst->AlphaR3 = ((Src->AlphaR1 & 0xF0) >> 4) + ((Src->AlphaR2 & 0xF) << 4); + Dst->AlphaR4 = ((Src->AlphaR2 & 0xF0) >> 4) + ((Src->AlphaR0 & 0xF) << 4); + Dst->AlphaR5 = ((Src->AlphaR0 & 0xF0) >> 4) + ((Src->AlphaR1 & 0xF) << 4); + Dst->Color0 = Src->Color0; + Dst->Color1 = Src->Color1; + Dst->Row0 = Src->Row3; + Dst->Row1 = Src->Row2; + Dst->Row2 = Src->Row1; + Dst->Row3 = Src->Row0; + + return; + } + + // invalid format specified (unknown S3TC format?) + assert(false); + } + + inline void flip_s3tc(image ImageDst, image ImageSrc, format Format) + { + if(ImageSrc.extent().y == 1) + { + memcpy(ImageDst.data(), + ImageSrc.data(), + ImageSrc.size()); + return; + } + + std::size_t const XBlocks = ImageSrc.extent().x <= 4 ? 1 : ImageSrc.extent().x / 4; + if(ImageSrc.extent().y == 2) + { + for(std::size_t i_block = 0; i_block < XBlocks; ++i_block) + flip_block_s3tc(ImageDst.data() + i_block * block_size(Format), ImageSrc.data() + i_block * block_size(Format), Format, true); + + return; + } + + std::size_t const MaxYBlock = ImageSrc.extent().y / 4 - 1; + for(std::size_t i_row = 0; i_row <= MaxYBlock; ++i_row) + for(std::size_t i_block = 0; i_block < XBlocks; ++i_block) + flip_block_s3tc(ImageDst.data() + (MaxYBlock - i_row) * block_size(Format) * XBlocks + i_block * block_size(Format), ImageSrc.data() + i_row * block_size(Format) * XBlocks + i_block * block_size(Format), Format, false); + } + +}//namespace detail + +/* +template <> +inline image flip(image const & Image) +{ + +} +*/ + +template <> +inline texture2d flip(texture2d const& Texture) +{ + GLI_ASSERT(!gli::is_compressed(Texture.format()) || gli::is_s3tc_compressed(Texture.format())); + + texture2d Flip(Texture.format(), Texture.extent(), Texture.levels()); + + if(!is_compressed(Texture.format())) + { + texture2d::size_type const BlockSize = block_size(Texture.format()); + + for(texture2d::size_type Level = 0; Level < Flip.levels(); ++Level) + detail::flip(Flip[Level], Texture[Level], BlockSize); + } + else + for(texture2d::size_type Level = 0; Level < Flip.levels(); ++Level) + detail::flip_s3tc(Flip[Level], Texture[Level], Texture.format()); + + return Flip; +} + +template <> +inline texture2d_array flip(texture2d_array const& Texture) +{ + GLI_ASSERT(!gli::is_compressed(Texture.format()) || gli::is_s3tc_compressed(Texture.format())); + + texture2d_array Flip(Texture.format(), Texture.extent(), Texture.layers(), Texture.levels()); + + if(!gli::is_compressed(Texture.format())) + { + texture2d_array::size_type const BlockSize = block_size(Texture.format()); + + for(texture2d_array::size_type Layer = 0; Layer < Flip.layers(); ++Layer) + for(texture2d_array::size_type Level = 0; Level < Flip.levels(); ++Level) + detail::flip(Flip[Layer][Level], Texture[Layer][Level], BlockSize); + } + else + for(texture2d_array::size_type Layer = 0; Layer < Flip.layers(); ++Layer) + for(texture2d_array::size_type Level = 0; Level < Flip.levels(); ++Level) + detail::flip_s3tc(Flip[Layer][Level], Texture[Layer][Level], Texture.format()); + + return Flip; +} + +template <> +inline texture_cube flip(texture_cube const & Texture) +{ + GLI_ASSERT(!gli::is_compressed(Texture.format()) || gli::is_s3tc_compressed(Texture.format())); + + texture_cube Flip(Texture.format(), Texture.extent(), Texture.levels()); + + if(!gli::is_compressed(Texture.format())) + { + texture_cube::size_type const BlockSize = block_size(Texture.format()); + + for(texture_cube::size_type Face = 0; Face < Flip.faces(); ++Face) + for(texture_cube::size_type Level = 0; Level < Flip.levels(); ++Level) + detail::flip(Flip[Face][Level], Texture[Face][Level], BlockSize); + } + else + for(texture_cube::size_type Face = 0; Face < Flip.faces(); ++Face) + for(texture_cube::size_type Level = 0; Level < Flip.levels(); ++Level) + detail::flip_s3tc(Flip[Face][Level], Texture[Face][Level], Texture.format()); + + return Flip; +} + +template <> +inline texture_cube_array flip(texture_cube_array const & Texture) +{ + assert(!is_compressed(Texture.format()) || is_s3tc_compressed(Texture.format())); + + texture_cube_array Flip(Texture.format(), Texture.extent(), Texture.layers(), Texture.levels()); + + if(!is_compressed(Texture.format())) + { + gli::size_t const BlockSize = block_size(Texture.format()); + + for(std::size_t Layer = 0; Layer < Flip.layers(); ++Layer) + for(std::size_t Face = 0; Face < Flip.faces(); ++Face) + for(std::size_t Level = 0; Level < Flip.levels(); ++Level) + detail::flip(Flip[Layer][Face][Level], Texture[Layer][Face][Level], BlockSize); + } + else + for(std::size_t Layer = 0; Layer < Flip.layers(); ++Layer) + for(std::size_t Face = 0; Face < Flip.faces(); ++Face) + for(std::size_t Level = 0; Level < Flip.levels(); ++Level) + detail::flip_s3tc(Flip[Layer][Face][Level], Texture[Layer][Face][Level], Texture.format()); + + return Flip; +} + +template <> +inline texture flip(texture const & Texture) +{ + switch(Texture.target()) + { + case TARGET_2D: + return flip(texture2d(Texture)); + + case TARGET_2D_ARRAY: + return flip(texture2d_array(Texture)); + + case TARGET_CUBE: + return flip(texture_cube(Texture)); + + case TARGET_CUBE_ARRAY: + return flip(texture_cube_array(Texture)); + + default: + assert(false && "Texture target does not support flipping."); + return Texture; + } +} + +}//namespace gli diff --git a/test/external/gli/core/format.inl b/test/external/gli/core/format.inl new file mode 100644 index 00000000..1a77f14d --- /dev/null +++ b/test/external/gli/core/format.inl @@ -0,0 +1,376 @@ +namespace gli{ +namespace detail +{ + enum + { + CAP_COMPRESSED_BIT = (1 << 0), + CAP_COLORSPACE_SRGB_BIT = (1 << 1), + CAP_NORMALIZED_BIT = (1 << 2), + CAP_SCALED_BIT = (1 << 3), + CAP_UNSIGNED_BIT = (1 << 4), + CAP_SIGNED_BIT = (1 << 5), + CAP_INTEGER_BIT = (1 << 6), + CAP_FLOAT_BIT = (1 << 7), + CAP_DEPTH_BIT = (1 << 8), + CAP_STENCIL_BIT = (1 << 9), + CAP_SWIZZLE_BIT = (1 << 10), + CAP_LUMINANCE_ALPHA_BIT = (1 << 11), + CAP_PACKED8_BIT = (1 << 12), + CAP_PACKED16_BIT = (1 << 13), + CAP_PACKED32_BIT = (1 << 14), + CAP_DDS_GLI_EXT_BIT = (1 << 15) + }; + + struct formatInfo + { + std::uint8_t BlockSize; + glm::u8vec3 BlockExtent; + std::uint8_t Component; + swizzles Swizzles; + std::uint16_t Flags; + }; + + inline formatInfo const & get_format_info(format Format) + { + GLI_ASSERT(Format >= FORMAT_FIRST && Format <= FORMAT_LAST); + + static formatInfo const Table[] = + { + { 1, glm::u8vec3(1, 1, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_PACKED8_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_R4G4_UNORM, + { 2, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_PACKED16_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA4_UNORM, + { 2, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ALPHA), CAP_PACKED16_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_BGRA4_UNORM, + { 2, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_PACKED16_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_R5G6B5_UNORM, + { 2, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ONE), CAP_PACKED16_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_B5G6R5_UNORM, + { 2, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_PACKED16_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB5A1_UNORM, + { 2, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ALPHA), CAP_PACKED16_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_BGR5A1_UNORM, + { 2, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_ALPHA, SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE), CAP_PACKED16_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_A1RGB5_UNORM, + + { 1, glm::u8vec3(1, 1, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_R8_UNORM, + { 1, glm::u8vec3(1, 1, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_NORMALIZED_BIT | CAP_SIGNED_BIT}, //FORMAT_R8_SNORM, + { 1, glm::u8vec3(1, 1, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_SCALED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_R8_USCALED, + { 1, glm::u8vec3(1, 1, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_SCALED_BIT | CAP_SIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_R8_SSCALED, + { 1, glm::u8vec3(1, 1, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_INTEGER_BIT | CAP_UNSIGNED_BIT}, //FORMAT_R8_UINT, + { 1, glm::u8vec3(1, 1, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_INTEGER_BIT | CAP_SIGNED_BIT}, //FORMAT_R8_SINT, + { 1, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_R8_SRGB, + + { 2, glm::u8vec3(1, 1, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RG8_UNORM, + { 2, glm::u8vec3(1, 1, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_NORMALIZED_BIT | CAP_SIGNED_BIT}, //FORMAT_RG8_SNORM, + { 2, glm::u8vec3(1, 1, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_SCALED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RG8_USCALED, + { 2, glm::u8vec3(1, 1, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_SCALED_BIT | CAP_SIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RG8_SSCALED, + { 2, glm::u8vec3(1, 1, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_INTEGER_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RG8_UINT, + { 2, glm::u8vec3(1, 1, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_INTEGER_BIT | CAP_SIGNED_BIT}, //FORMAT_RG8_SINT, + { 2, glm::u8vec3(1, 1, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_NORMALIZED_BIT | CAP_SIGNED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RG8_SRGB, + + { 3, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB8_UNORM, + { 3, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_NORMALIZED_BIT | CAP_SIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB8_SNORM, + { 3, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_SCALED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB8_USCALED, + { 3, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_SCALED_BIT | CAP_SIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB8_SSCALED, + { 3, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_INTEGER_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB8_UINT, + { 3, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_INTEGER_BIT | CAP_SIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB8_SINT, + { 3, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB8_SRGB, + + { 3, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ONE), CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_SWIZZLE_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_BGR8_UNORM, + { 3, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ONE), CAP_NORMALIZED_BIT | CAP_SIGNED_BIT | CAP_SWIZZLE_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_BGR8_SNORM, + { 3, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ONE), CAP_SCALED_BIT | CAP_UNSIGNED_BIT | CAP_SWIZZLE_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_BGR8_USCALED, + { 3, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ONE), CAP_SCALED_BIT | CAP_SIGNED_BIT | CAP_SWIZZLE_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_BGR8_SSCALED, + { 3, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ONE), CAP_INTEGER_BIT | CAP_UNSIGNED_BIT | CAP_SWIZZLE_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_BGR8_UINT, + { 3, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ONE), CAP_INTEGER_BIT | CAP_SIGNED_BIT | CAP_SWIZZLE_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_BGR8_SINT, + { 3, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ONE), CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_SWIZZLE_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_BGR8_SRGB, + + { 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA8_UNORM, + { 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_NORMALIZED_BIT | CAP_SIGNED_BIT}, //FORMAT_RGBA8_SNORM, + { 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_SCALED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA8_USCALED, + { 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_SCALED_BIT | CAP_SIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA8_SSCALED, + { 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_INTEGER_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA8_UINT, + { 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_INTEGER_BIT | CAP_SIGNED_BIT}, //FORMAT_RGBA8_SINT, + { 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_COLORSPACE_SRGB_BIT}, //FORMAT_RGBA8_SRGB, + + { 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ALPHA), CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_SWIZZLE_BIT}, //FORMAT_BGRA8_UNORM, + { 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ALPHA), CAP_NORMALIZED_BIT | CAP_SIGNED_BIT | CAP_SWIZZLE_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_BGRA8_SNORM, + { 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ALPHA), CAP_SCALED_BIT | CAP_UNSIGNED_BIT | CAP_SWIZZLE_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_BGRA8_USCALED, + { 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ALPHA), CAP_SCALED_BIT | CAP_SIGNED_BIT | CAP_SWIZZLE_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_BGRA8_SSCALED, + { 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ALPHA), CAP_INTEGER_BIT | CAP_UNSIGNED_BIT | CAP_SWIZZLE_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_BGRA8_UINT, + { 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ALPHA), CAP_INTEGER_BIT | CAP_SIGNED_BIT | CAP_SWIZZLE_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_BGRA8_SINT, + { 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ALPHA), CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_SWIZZLE_BIT}, //FORMAT_BGRA8_SRGB, + + { 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ALPHA), CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_SWIZZLE_BIT | CAP_PACKED32_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA8_UNORM_PACK32, + { 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ALPHA), CAP_NORMALIZED_BIT | CAP_SIGNED_BIT | CAP_SWIZZLE_BIT | CAP_PACKED32_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA8_SNORM_PACK32, + { 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ALPHA), CAP_SCALED_BIT | CAP_UNSIGNED_BIT | CAP_SWIZZLE_BIT | CAP_PACKED32_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA8_USCALED_PACK32, + { 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ALPHA), CAP_SCALED_BIT | CAP_SIGNED_BIT | CAP_SWIZZLE_BIT | CAP_PACKED32_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA8_SSCALED_PACK32, + { 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ALPHA), CAP_INTEGER_BIT | CAP_UNSIGNED_BIT | CAP_SWIZZLE_BIT | CAP_PACKED32_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA8_UINT_PACK32, + { 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ALPHA), CAP_INTEGER_BIT | CAP_SIGNED_BIT | CAP_SWIZZLE_BIT | CAP_PACKED32_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA8_SINT_PACK32, + { 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ALPHA), CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_SWIZZLE_BIT | CAP_PACKED32_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA8_SRGB_PACK32, + + { 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_PACKED32_BIT}, //FORMAT_RGB10A2_UNORM, + { 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_NORMALIZED_BIT | CAP_SIGNED_BIT | CAP_PACKED32_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB10A2_SNORM, + { 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_SCALED_BIT | CAP_UNSIGNED_BIT | CAP_PACKED32_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB10A2_USCALE, + { 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_SCALED_BIT | CAP_SIGNED_BIT | CAP_PACKED32_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB10A2_SSCALE, + { 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_INTEGER_BIT | CAP_UNSIGNED_BIT | CAP_PACKED32_BIT}, //FORMAT_RGB10A2_UINT, + { 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_INTEGER_BIT | CAP_SIGNED_BIT | CAP_PACKED32_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB10A2_SINT, + + { 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ALPHA), CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_PACKED32_BIT | CAP_SWIZZLE_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_BGR10A2_UNORM, + { 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ALPHA), CAP_NORMALIZED_BIT | CAP_SIGNED_BIT | CAP_PACKED32_BIT | CAP_SWIZZLE_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_BGR10A2_SNORM, + { 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ALPHA), CAP_SCALED_BIT | CAP_UNSIGNED_BIT | CAP_PACKED32_BIT | CAP_SWIZZLE_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_BGR10A2_USCALE, + { 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ALPHA), CAP_SCALED_BIT | CAP_SIGNED_BIT | CAP_PACKED32_BIT | CAP_SWIZZLE_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_BGR10A2_SSCALE, + { 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ALPHA), CAP_INTEGER_BIT | CAP_UNSIGNED_BIT | CAP_PACKED32_BIT | CAP_SWIZZLE_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_BGR10A2_UINT, + { 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ALPHA), CAP_INTEGER_BIT | CAP_SIGNED_BIT | CAP_PACKED32_BIT | CAP_SWIZZLE_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_BGR10A2_SINT, + + { 2, glm::u8vec3(1, 1, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_R16_UNORM_PACK16, + { 2, glm::u8vec3(1, 1, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_NORMALIZED_BIT | CAP_SIGNED_BIT}, //FORMAT_R16_SNORM_PACK16, + { 2, glm::u8vec3(1, 1, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_SCALED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_R16_USCALE, + { 2, glm::u8vec3(1, 1, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_SCALED_BIT | CAP_SIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_R16_SSCALE, + { 2, glm::u8vec3(1, 1, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_INTEGER_BIT | CAP_UNSIGNED_BIT}, //FORMAT_R16_UINT_PACK16, + { 2, glm::u8vec3(1, 1, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_INTEGER_BIT | CAP_SIGNED_BIT}, //FORMAT_R16_SINT_PACK16, + { 2, glm::u8vec3(1, 1, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_FLOAT_BIT | CAP_SIGNED_BIT}, //FORMAT_R16_SFLOAT_PACK16, + + { 4, glm::u8vec3(1, 1, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RG16_UNORM_PACK16, + { 4, glm::u8vec3(1, 1, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_NORMALIZED_BIT | CAP_SIGNED_BIT}, //FORMAT_RG16_SNORM_PACK16, + { 4, glm::u8vec3(1, 1, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_SCALED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RG16_USCALE, + { 4, glm::u8vec3(1, 1, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_SCALED_BIT | CAP_SIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RG16_SSCALE, + { 4, glm::u8vec3(1, 1, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_INTEGER_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RG16_UINT_PACK16, + { 4, glm::u8vec3(1, 1, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_INTEGER_BIT | CAP_SIGNED_BIT}, //FORMAT_RG16_SINT_PACK16, + { 4, glm::u8vec3(1, 1, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_FLOAT_BIT | CAP_SIGNED_BIT}, //FORMAT_RG16_SFLOAT_PACK16, + + { 6, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB16_UNORM_PACK16, + { 6, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_NORMALIZED_BIT | CAP_SIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB16_SNORM_PACK16, + { 6, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_SCALED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB16_USCALE, + { 6, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_SCALED_BIT | CAP_SIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB16_SSCALE, + { 6, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_INTEGER_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB16_UINT_PACK16, + { 6, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_INTEGER_BIT | CAP_SIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB16_SINT_PACK16, + { 6, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_FLOAT_BIT | CAP_SIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB16_SFLOAT_PACK16, + + { 8, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA16_UNORM_PACK16, + { 8, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_NORMALIZED_BIT | CAP_SIGNED_BIT}, //FORMAT_RGBA16_SNORM_PACK16, + { 8, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_SCALED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA16_USCALE, + { 8, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_SCALED_BIT | CAP_SIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA16_SSCALE, + { 8, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_INTEGER_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA16_UINT_PACK16, + { 8, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_INTEGER_BIT | CAP_SIGNED_BIT}, //FORMAT_RGBA16_SINT_PACK16, + { 8, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_FLOAT_BIT | CAP_SIGNED_BIT}, //FORMAT_RGBA16_SFLOAT_PACK16, + + { 4, glm::u8vec3(1, 1, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_INTEGER_BIT | CAP_UNSIGNED_BIT}, //FORMAT_R32_UINT_PACK32, + { 4, glm::u8vec3(1, 1, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_INTEGER_BIT | CAP_SIGNED_BIT}, //FORMAT_R32_SINT_PACK32, + { 4, glm::u8vec3(1, 1, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_FLOAT_BIT | CAP_SIGNED_BIT}, //FORMAT_R32_SFLOAT_PACK32, + + { 8, glm::u8vec3(1, 1, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_INTEGER_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RG32_UINT_PACK32, + { 8, glm::u8vec3(1, 1, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_INTEGER_BIT | CAP_SIGNED_BIT}, //FORMAT_RG32_SINT_PACK32, + { 8, glm::u8vec3(1, 1, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_FLOAT_BIT | CAP_SIGNED_BIT}, //FORMAT_RG32_SFLOAT_PACK32, + + { 12, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_INTEGER_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGB32_UINT_PACK32, + { 12, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_INTEGER_BIT | CAP_SIGNED_BIT}, //FORMAT_RGB32_SINT_PACK32, + { 12, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_FLOAT_BIT | CAP_SIGNED_BIT}, //FORMAT_RGB32_SFLOAT_PACK32, + + { 16, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_INTEGER_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA32_UINT_PACK32, + { 16, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_INTEGER_BIT | CAP_SIGNED_BIT}, //FORMAT_RGBA32_SINT_PACK32, + { 16, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_FLOAT_BIT | CAP_SIGNED_BIT}, //FORMAT_RGBA32_SFLOAT_PACK32, + + { 8, glm::u8vec3(1, 1, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_INTEGER_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_R64_UINT_PACK64, + { 8, glm::u8vec3(1, 1, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_INTEGER_BIT | CAP_SIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_R64_SINT_PACK64, + { 8, glm::u8vec3(1, 1, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_FLOAT_BIT | CAP_SIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_R64_SFLOAT_PACK64, + + { 16, glm::u8vec3(1, 1, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_INTEGER_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RG64_UINT_PACK64, + { 16, glm::u8vec3(1, 1, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_INTEGER_BIT | CAP_SIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RG64_SINT_PACK64, + { 16, glm::u8vec3(1, 1, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_FLOAT_BIT | CAP_SIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RG64_SFLOAT_PACK64, + + { 24, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_INTEGER_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB64_UINT_PACK64, + { 24, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_INTEGER_BIT | CAP_SIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB64_SINT_PACK64, + { 24, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_FLOAT_BIT | CAP_SIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB64_SFLOAT_PACK64, + + { 32, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_INTEGER_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA64_UINT_PACK64, + { 32, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_INTEGER_BIT | CAP_SIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA64_SINT_PACK64, + { 32, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_FLOAT_BIT | CAP_SIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA64_SFLOAT_PACK64, + + { 4, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_PACKED32_BIT | CAP_FLOAT_BIT | CAP_SIGNED_BIT}, //FORMAT_RG11B10_UFLOAT_PACK32, + { 4, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_PACKED32_BIT | CAP_FLOAT_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGB9E5_UFLOAT_PACK32, + + { 2, glm::u8vec3(1, 1, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_DEPTH_BIT | CAP_INTEGER_BIT}, //FORMAT_D16_UNORM_PACK16, + { 4, glm::u8vec3(1, 1, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_DEPTH_BIT | CAP_INTEGER_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_D24_UNORM_PACK32, + { 4, glm::u8vec3(1, 1, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_DEPTH_BIT | CAP_FLOAT_BIT}, //FORMAT_D32_UFLOAT_PACK32, + { 1, glm::u8vec3(1, 1, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_DEPTH_BIT | CAP_STENCIL_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_S8_UNORM_PACK8, + { 3, glm::u8vec3(1, 1, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_DEPTH_BIT | CAP_INTEGER_BIT | CAP_STENCIL_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_D16_UNORM_S8_UINT_PACK32, + { 4, glm::u8vec3(1, 1, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_DEPTH_BIT | CAP_INTEGER_BIT | CAP_STENCIL_BIT}, //FORMAT_D24_UNORM_S8_UINT_PACK32, + { 5, glm::u8vec3(1, 1, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_DEPTH_BIT | CAP_FLOAT_BIT | CAP_STENCIL_BIT}, //FORMAT_D32_SFLOAT_S8_UINT_PACK64, + + { 8, glm::u8vec3(4, 4, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB_DXT1_UNORM_BLOCK8, + { 8, glm::u8vec3(4, 4, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB_DXT1_SRGB_BLOCK8, + { 8, glm::u8vec3(4, 4, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_DXT1_UNORM_BLOCK8, + { 8, glm::u8vec3(4, 4, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_DXT1_SRGB_BLOCK8, + { 16, glm::u8vec3(4, 4, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_DXT3_UNORM_BLOCK16, + { 16, glm::u8vec3(4, 4, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_DXT3_SRGB_BLOCK16, + { 16, glm::u8vec3(4, 4, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_DXT5_UNORM_BLOCK16, + { 16, glm::u8vec3(4, 4, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_DXT5_SRGB_BLOCK16, + { 8, glm::u8vec3(4, 4, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_R_ATI1N_UNORM_BLOCK8, + { 8, glm::u8vec3(4, 4, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_SIGNED_BIT}, //FORMAT_R_ATI1N_SNORM_BLOCK8, + { 16, glm::u8vec3(4, 4, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RG_ATI2N_UNORM_BLOCK16, + { 16, glm::u8vec3(4, 4, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_SIGNED_BIT}, //FORMAT_RG_ATI2N_SNORM_BLOCK16, + { 16, glm::u8vec3(4, 4, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_COMPRESSED_BIT | CAP_FLOAT_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGB_BP_UFLOAT_BLOCK16, + { 16, glm::u8vec3(4, 4, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_COMPRESSED_BIT | CAP_FLOAT_BIT | CAP_SIGNED_BIT}, //FORMAT_RGB_BP_SFLOAT_BLOCK16, + { 16, glm::u8vec3(4, 4, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_BP_UNORM_BLOCK16, + { 16, glm::u8vec3(4, 4, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_BP_SRGB_BLOCK16, + + { 8, glm::u8vec3(4, 4, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB_ETC2_UNORM_BLOCK8, + { 8, glm::u8vec3(4, 4, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB_ETC2_SRGB_BLOCK8, + { 8, glm::u8vec3(4, 4, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA_ETC2_UNORM_BLOCK8, + { 8, glm::u8vec3(4, 4, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA_ETC2_SRGB_BLOCK8, + { 16, glm::u8vec3(4, 4, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA_ETC2_UNORM_BLOCK16, + { 16, glm::u8vec3(4, 4, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA_ETC2_SRGB_BLOCK16, + { 8, glm::u8vec3(4, 4, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_R_EAC_UNORM_BLOCK8, + { 8, glm::u8vec3(4, 4, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_SIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_R_EAC_SNORM_BLOCK8, + { 16, glm::u8vec3(4, 4, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RG_EAC_UNORM_BLOCK16, + { 16, glm::u8vec3(4, 4, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_SIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RG_EAC_SNORM_BLOCK16, + + { 16, glm::u8vec3(4, 4, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_4X4_UNORM_BLOCK16, + { 16, glm::u8vec3(4, 4, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_4X4_SRGB_BLOCK16, + { 16, glm::u8vec3(5, 4, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_5X4_UNORM_BLOCK16, + { 16, glm::u8vec3(5, 4, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_5X4_SRGB_BLOCK16, + { 16, glm::u8vec3(5, 5, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_5X5_UNORM_BLOCK16, + { 16, glm::u8vec3(5, 5, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_5X5_SRGB_BLOCK16, + { 16, glm::u8vec3(6, 5, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_6X5_UNORM_BLOCK16, + { 16, glm::u8vec3(6, 5, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_6X5_SRGB_BLOCK16, + { 16, glm::u8vec3(6, 6, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_6X6_UNORM_BLOCK16, + { 16, glm::u8vec3(6, 6, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_6X6_SRGB_BLOCK16, + { 16, glm::u8vec3(8, 5, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_8X5_UNORM_BLOCK16, + { 16, glm::u8vec3(8, 5, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_8X5_SRGB_BLOCK16, + { 16, glm::u8vec3(8, 6, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_8X6_UNORM_BLOCK16, + { 16, glm::u8vec3(8, 6, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_8X6_SRGB_BLOCK16, + { 16, glm::u8vec3(8, 8, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_8X8_UNORM_BLOCK16, + { 16, glm::u8vec3(8, 8, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_8X8_SRGB_BLOCK16, + { 16, glm::u8vec3(10, 5, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_10X5_UNORM_BLOCK16, + { 16, glm::u8vec3(10, 5, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_10X5_SRGB_BLOCK16, + { 16, glm::u8vec3(10, 6, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_10X6_UNORM_BLOCK16, + { 16, glm::u8vec3(10, 6, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_10X6_SRGB_BLOCK16, + { 16, glm::u8vec3(10, 8, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_10X8_UNORM_BLOCK16, + { 16, glm::u8vec3(10, 8, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_10X8_SRGB_BLOCK16, + { 16, glm::u8vec3(10, 10, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_10X10_UNORM_BLOCK16, + { 16, glm::u8vec3(10, 10, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_10X10_SRGB_BLOCK16, + { 16, glm::u8vec3(12, 10, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_12X10_UNORM_BLOCK16, + { 16, glm::u8vec3(12, 10, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_12X10_SRGB_BLOCK16, + { 16, glm::u8vec3(12, 12, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_12X12_UNORM_BLOCK16, + { 16, glm::u8vec3(12, 12, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_12X12_SRGB_BLOCK16, + + { 32, glm::u8vec3(8, 8, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB_PVRTC1_8X8_UNORM_BLOCK32, + { 32, glm::u8vec3(8, 8, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB_PVRTC1_8X8_SRGB_BLOCK32, + { 32, glm::u8vec3(16, 8, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB_PVRTC1_16X8_UNORM_BLOCK32, + { 32, glm::u8vec3(16, 8, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB_PVRTC1_16X8_SRGB_BLOCK32, + { 32, glm::u8vec3(8, 8, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA_PVRTC1_8X8_UNORM_BLOCK32, + { 32, glm::u8vec3(8, 8, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA_PVRTC1_8X8_SRGB_BLOCK32, + { 32, glm::u8vec3(16, 8, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA_PVRTC1_16X8_UNORM_BLOCK32, + { 32, glm::u8vec3(16, 8, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA_PVRTC1_16X8_SRGB_BLOCK32, + { 8, glm::u8vec3(4, 4, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA_PVRTC2_4X4_UNORM_BLOCK8, + { 8, glm::u8vec3(4, 4, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA_PVRTC2_4X4_SRGB_BLOCK8, + { 8, glm::u8vec3(8, 4, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA_PVRTC2_8X4_UNORM_BLOCK8, + { 8, glm::u8vec3(8, 4, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA_PVRTC2_8X4_SRGB_BLOCK8, + + { 8, glm::u8vec3(4, 4, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB_ETC_UNORM_BLOCK8, + { 8, glm::u8vec3(4, 4, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB_ATC_UNORM_BLOCK8, + { 16, glm::u8vec3(4, 4, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA_ATCA_UNORM_BLOCK16, + { 16, glm::u8vec3(4, 4, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA_ATCI_UNORM_BLOCK16, + + { 1, glm::u8vec3(1, 1, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_RED, SWIZZLE_RED, SWIZZLE_ONE), CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_LUMINANCE_ALPHA_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_L8_UNORM_PACK8, + { 1, glm::u8vec3(1, 1, 1), 1, swizzles(SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_RED), CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_LUMINANCE_ALPHA_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_A8_UNORM_PACK8, + { 2, glm::u8vec3(1, 1, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_RED, SWIZZLE_RED, SWIZZLE_GREEN), CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_LUMINANCE_ALPHA_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_LA8_UNORM_PACK8, + { 2, glm::u8vec3(1, 1, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_RED, SWIZZLE_RED, SWIZZLE_ONE), CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_LUMINANCE_ALPHA_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_L16_UNORM_PACK16, + { 2, glm::u8vec3(1, 1, 1), 1, swizzles(SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_RED), CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_LUMINANCE_ALPHA_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_A16_UNORM_PACK16, + { 4, glm::u8vec3(1, 1, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_RED, SWIZZLE_RED, SWIZZLE_GREEN), CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_LUMINANCE_ALPHA_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_LA16_UNORM_PACK16, + + { 4, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ONE), CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_SWIZZLE_BIT}, //FORMAT_BGR8_UNORM_PACK32, + { 4, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ONE), CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_SWIZZLE_BIT | CAP_COLORSPACE_SRGB_BIT}, //FORMAT_BGR8_SRGB_PACK32, + + { 1, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_PACKED8_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RG3B2_UNORM_PACK8, + }; + + GLM_STATIC_ASSERT(sizeof(Table) / sizeof(Table[0]) == FORMAT_COUNT, "GLI error: format descriptor list doesn't match number of supported formats"); + GLI_ASSERT(Format != static_cast(FORMAT_INVALID)); + + return Table[Format - FORMAT_FIRST]; + }; + + inline std::uint32_t bits_per_pixel(format Format) + { + detail::formatInfo const & Info = detail::get_format_info(Format); + + return Info.BlockSize * 8 / (Info.BlockExtent.x * Info.BlockExtent.y * Info.BlockExtent.z); + } +}//namespace detail + + inline bool is_compressed(format Format) + { + return detail::get_format_info(Format).Flags & detail::CAP_COMPRESSED_BIT ? true : false; + } + + inline bool is_s3tc_compressed(format Format) + { + return Format >= FORMAT_RGB_DXT1_UNORM_BLOCK8 && Format <= FORMAT_RGBA_DXT5_SRGB_BLOCK16; + } + + inline bool is_srgb(format Format) + { + return detail::get_format_info(Format).Flags & detail::CAP_COLORSPACE_SRGB_BIT ? true : false; + } + + inline size_t block_size(format Format) + { + return detail::get_format_info(Format).BlockSize; + } + + inline ivec3 block_extent(format Format) + { + return gli::ivec3(detail::get_format_info(Format).BlockExtent); + } + + inline size_t component_count(format Format) + { + return detail::get_format_info(Format).Component; + } + + inline bool is_unsigned(format Format) + { + return detail::get_format_info(Format).Flags & detail::CAP_UNSIGNED_BIT ? true : false; + } + + inline bool is_signed(format Format) + { + return detail::get_format_info(Format).Flags & detail::CAP_SIGNED_BIT ? true : false; + } + + inline bool is_integer(format Format) + { + return detail::get_format_info(Format).Flags & detail::CAP_INTEGER_BIT ? true : false; + } + + inline bool is_signed_integer(format Format) + { + return is_integer(Format) && is_signed(Format); + } + + inline bool is_unsigned_integer(format Format) + { + return is_integer(Format) && is_unsigned(Format); + } + + inline bool is_float(format Format) + { + return detail::get_format_info(Format).Flags & detail::CAP_FLOAT_BIT ? true : false; + } + + inline bool is_normalized(format Format) + { + return detail::get_format_info(Format).Flags & detail::CAP_NORMALIZED_BIT ? true : false; + } + + inline bool is_unorm(format Format) + { + return is_normalized(Format) && is_unsigned(Format); + } + + inline bool is_snorm(format Format) + { + return is_normalized(Format) && is_signed(Format); + } + + inline bool is_packed(format Format) + { + uint16_t flags = detail::get_format_info(Format).Flags; + + return (flags & detail::CAP_PACKED8_BIT) != 0 || (flags & detail::CAP_PACKED16_BIT) != 0 || (flags & detail::CAP_PACKED32_BIT) != 0; + } +}//namespace gli diff --git a/test/external/gli/core/generate_mipmaps.hpp b/test/external/gli/core/generate_mipmaps.hpp deleted file mode 100644 index 43409360..00000000 --- a/test/external/gli/core/generate_mipmaps.hpp +++ /dev/null @@ -1,25 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////// -// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net) -/////////////////////////////////////////////////////////////////////////////////////////////////// -// Created : 2010-09-27 -// Updated : 2010-09-27 -// Licence : This source is under MIT License -// File : gli/core/generate_mipmaps.hpp -/////////////////////////////////////////////////////////////////////////////////////////////////// - -#ifndef GLI_GENERATE_MIPMAPS_INCLUDED -#define GLI_GENERATE_MIPMAPS_INCLUDED - -#include "texture2d.hpp" - -namespace gli -{ - texture2D generateMipmaps( - texture2D const & Texture, - texture2D::level_type const & BaseLevel); - -}//namespace gli - -#include "generate_mipmaps.inl" - -#endif//GLI_GENERATE_MIPMAPS_INCLUDED diff --git a/test/external/gli/core/generate_mipmaps.inl b/test/external/gli/core/generate_mipmaps.inl index bbc6e4c4..e91dca22 100644 --- a/test/external/gli/core/generate_mipmaps.inl +++ b/test/external/gli/core/generate_mipmaps.inl @@ -1,69 +1,127 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////// -// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net) -/////////////////////////////////////////////////////////////////////////////////////////////////// -// Created : 2010-09-27 -// Updated : 2010-09-27 -// Licence : This source is under MIT License -// File : gli/core/generate_mipmaps.inl -/////////////////////////////////////////////////////////////////////////////////////////////////// +#include "../sampler1d.hpp" +#include "../sampler1d_array.hpp" +#include "../sampler2d.hpp" +#include "../sampler2d_array.hpp" +#include "../sampler3d.hpp" +#include "../sampler_cube.hpp" +#include "../sampler_cube_array.hpp" namespace gli { -/* - inline texture2D generateMipmaps - ( - texture2D const & Image, - texture2D::level_type const & BaseLevel - ) + inline texture1d generate_mipmaps( + texture1d const& Texture, + texture1d::size_type BaseLevel, texture1d::size_type MaxLevel, + filter Minification) { - assert(BaseLevel < Image.levels()); - texture2D::format_type Format = Image[BaseLevel].format(); - - assert(Format == R8U || Format == RG8U || Format == RGB8U || Format == RGBA8U); - texture2D::level_type Levels = std::size_t(glm::log2(float(glm::compMax(Image[0].dimensions())))) + 1; - - texture2D Result(Levels); - for(texture2D::level_type Level = 0; Level <= BaseLevel; ++Level) - Result[Level] = detail::duplicate(Image[Level]); - - for(texture2D::level_type Level = BaseLevel; Level < Levels - 1; ++Level) - { - std::size_t BaseWidth = Result[Level + 0].dimensions().x; - texture2D::value_type * DataSrc = Result[Level + 0].data(); - - texture2D::dimensions_type LevelDimensions = Result[Level + 0].dimensions() >> texture2D::dimensions_type(1); - LevelDimensions = glm::max(LevelDimensions, texture2D::dimensions_type(1)); - texture2D::size_type Components = Result[Level + 0].components(); - - texture2D::data_type DataDst(glm::compMul(LevelDimensions) * Components); - - for(std::size_t j = 0; j < LevelDimensions.y; ++j) - for(std::size_t i = 0; i < LevelDimensions.x; ++i) - for(std::size_t c = 0; c < Components; ++c) - { - std::size_t x = (i << 1); - std::size_t y = (j << 1); - - std::size_t Index00 = ((x + 0) + (y + 0) * BaseWidth) * Components + c; - std::size_t Index01 = ((x + 0) + (y + 1) * BaseWidth) * Components + c; - std::size_t Index11 = ((x + 1) + (y + 1) * BaseWidth) * Components + c; - std::size_t Index10 = ((x + 1) + (y + 0) * BaseWidth) * Components + c; - - glm::u32 Data00 = reinterpret_cast(DataSrc)[Index00]; - glm::u32 Data01 = reinterpret_cast(DataSrc)[Index01]; - glm::u32 Data11 = reinterpret_cast(DataSrc)[Index11]; - glm::u32 Data10 = reinterpret_cast(DataSrc)[Index10]; - - texture2D::value_type Result = (Data00 + Data01 + Data11 + Data10) >> 2; - texture2D::value_type * Data = reinterpret_cast(DataDst.data()); - - *(Data + ((i + j * LevelDimensions.x) * Components + c)) = Result; - } - - Result[Level + 1] = image2D(LevelDimensions, Format, DataDst); - } - - return Result; + fsampler1D Sampler(Texture, WRAP_CLAMP_TO_EDGE); + Sampler.generate_mipmaps(BaseLevel, MaxLevel, Minification); + return Sampler(); + } + + inline texture1d_array generate_mipmaps( + texture1d_array const& Texture, + texture1d_array::size_type BaseLayer, texture1d_array::size_type MaxLayer, + texture1d_array::size_type BaseLevel, texture1d_array::size_type MaxLevel, + filter Minification) + { + fsampler1DArray Sampler(Texture, WRAP_CLAMP_TO_EDGE); + Sampler.generate_mipmaps(BaseLayer, MaxLayer, BaseLevel, MaxLevel, Minification); + return Sampler(); + } + + inline texture2d generate_mipmaps( + texture2d const& Texture, + texture2d::size_type BaseLevel, texture2d::size_type MaxLevel, + filter Minification) + { + fsampler2D Sampler(Texture, WRAP_CLAMP_TO_EDGE); + Sampler.generate_mipmaps(BaseLevel, MaxLevel, Minification); + return Sampler(); + } + + inline texture2d_array generate_mipmaps( + texture2d_array const& Texture, + texture2d_array::size_type BaseLayer, texture2d_array::size_type MaxLayer, + texture2d_array::size_type BaseLevel, texture2d_array::size_type MaxLevel, + filter Minification) + { + fsampler2DArray Sampler(Texture, WRAP_CLAMP_TO_EDGE); + Sampler.generate_mipmaps(BaseLayer, MaxLayer, BaseLevel, MaxLevel, Minification); + return Sampler(); + } + + inline texture3d generate_mipmaps( + texture3d const& Texture, + texture3d::size_type BaseLevel, texture3d::size_type MaxLevel, + filter Minification) + { + fsampler3D Sampler(Texture, WRAP_CLAMP_TO_EDGE); + Sampler.generate_mipmaps(BaseLevel, MaxLevel, Minification); + return Sampler(); + } + + inline texture_cube generate_mipmaps( + texture_cube const& Texture, + texture_cube::size_type BaseFace, texture_cube::size_type MaxFace, + texture_cube::size_type BaseLevel, texture_cube::size_type MaxLevel, + filter Minification) + { + fsamplerCube Sampler(Texture, WRAP_CLAMP_TO_EDGE); + Sampler.generate_mipmaps(BaseFace, MaxFace, BaseLevel, MaxLevel, Minification); + return Sampler(); + } + + inline texture_cube_array generate_mipmaps( + texture_cube_array const& Texture, + texture_cube_array::size_type BaseLayer, texture_cube_array::size_type MaxLayer, + texture_cube_array::size_type BaseFace, texture_cube_array::size_type MaxFace, + texture_cube_array::size_type BaseLevel, texture_cube_array::size_type MaxLevel, + filter Minification) + { + fsamplerCubeArray Sampler(Texture, WRAP_CLAMP_TO_EDGE); + Sampler.generate_mipmaps(BaseLayer, MaxLayer, BaseFace, MaxFace, BaseLevel, MaxLevel, Minification); + return Sampler(); + } + + template <> + inline texture1d generate_mipmaps(texture1d const& Texture, filter Minification) + { + return generate_mipmaps(Texture, Texture.base_level(), Texture.max_level(), Minification); + } + + template <> + inline texture1d_array generate_mipmaps(texture1d_array const& Texture, filter Minification) + { + return generate_mipmaps(Texture, Texture.base_layer(), Texture.max_layer(), Texture.base_level(), Texture.max_level(), Minification); + } + + template <> + inline texture2d generate_mipmaps(texture2d const& Texture, filter Minification) + { + return generate_mipmaps(Texture, Texture.base_level(), Texture.max_level(), Minification); + } + + template <> + inline texture2d_array generate_mipmaps(texture2d_array const& Texture, filter Minification) + { + return generate_mipmaps(Texture, Texture.base_layer(), Texture.max_layer(), Texture.base_level(), Texture.max_level(), Minification); + } + + template <> + inline texture3d generate_mipmaps(texture3d const& Texture, filter Minification) + { + return generate_mipmaps(Texture, Texture.base_level(), Texture.max_level(), Minification); + } + + template <> + inline texture_cube generate_mipmaps(texture_cube const& Texture, filter Minification) + { + return generate_mipmaps(Texture, Texture.base_face(), Texture.max_face(), Texture.base_level(), Texture.max_level(), Minification); + } + + template <> + inline texture_cube_array generate_mipmaps(texture_cube_array const& Texture, filter Minification) + { + return generate_mipmaps(Texture, Texture.base_layer(), Texture.max_layer(), Texture.base_face(), Texture.max_face(), Texture.base_level(), Texture.max_level(), Minification); } -*/ }//namespace gli diff --git a/test/external/gli/core/gl.inl b/test/external/gli/core/gl.inl new file mode 100644 index 00000000..779ade57 --- /dev/null +++ b/test/external/gli/core/gl.inl @@ -0,0 +1,366 @@ +#include + +namespace gli{ +namespace detail +{ + inline gl::swizzles translate(gli::swizzles const& Swizzles) + { + static gl::swizzle const Table[] = + { + gl::SWIZZLE_RED, + gl::SWIZZLE_GREEN, + gl::SWIZZLE_BLUE, + gl::SWIZZLE_ALPHA, + gl::SWIZZLE_ZERO, + gl::SWIZZLE_ONE + }; + static_assert(sizeof(Table) / sizeof(Table[0]) == SWIZZLE_COUNT, "GLI error: swizzle descriptor list doesn't match number of supported swizzles"); + + return gl::swizzles(Table[Swizzles.r], Table[Swizzles.g], Table[Swizzles.b], Table[Swizzles.a]); + } + + enum format_property + { + FORMAT_PROPERTY_BGRA_FORMAT_BIT = (1 << 0), + FORMAT_PROPERTY_BGRA_TYPE_BIT = (1 << 1) + }; +}//namespace detail + + inline gl::gl(profile Profile) + : Profile(Profile) + { + bool const HasSwizzle = has_swizzle(Profile); + external_format const ExternalBGR = HasSwizzle ? EXTERNAL_RGB : EXTERNAL_BGR; + external_format const ExternalBGRA = HasSwizzle ? EXTERNAL_RGBA : EXTERNAL_BGRA; + external_format const ExternalBGRInt = HasSwizzle ? EXTERNAL_RGB_INTEGER : EXTERNAL_BGR_INTEGER; + external_format const ExternalBGRAInt = HasSwizzle ? EXTERNAL_RGBA_INTEGER : EXTERNAL_BGRA_INTEGER; + + external_format const ExternalSRGB8 = Profile != PROFILE_ES20 ? EXTERNAL_RGB : EXTERNAL_SRGB_EXT; + external_format const ExternalSRGB8_A8 = Profile != PROFILE_ES20 ? EXTERNAL_RGBA : EXTERNAL_SRGB_ALPHA_EXT; + + internal_format const InternalBGRA = Profile == PROFILE_ES20 ? INTERNAL_BGRA8_UNORM : INTERNAL_RGBA8_UNORM; + internal_format const InternalRGBETC = Profile == PROFILE_ES20 ? INTERNAL_RGB_ETC : INTERNAL_RGB_ETC2; + + internal_format const InternalLuminance8 = HasSwizzle ? INTERNAL_R8_UNORM : INTERNAL_LUMINANCE8; + internal_format const InternalAlpha8 = HasSwizzle ? INTERNAL_R8_UNORM : INTERNAL_ALPHA8; + internal_format const InternalLuminanceAlpha8 = HasSwizzle ? INTERNAL_RG8_UNORM : INTERNAL_LUMINANCE8_ALPHA8; + + internal_format const InternalLuminance16 = HasSwizzle ? INTERNAL_R16_UNORM : INTERNAL_LUMINANCE16; + internal_format const InternalAlpha16 = HasSwizzle ? INTERNAL_R16_UNORM : INTERNAL_ALPHA16; + internal_format const InternalLuminanceAlpha16 = HasSwizzle ? INTERNAL_RG16_UNORM : INTERNAL_LUMINANCE16_ALPHA16; + + external_format const ExternalLuminance = HasSwizzle ? EXTERNAL_RED : EXTERNAL_LUMINANCE; + external_format const ExternalAlpha = HasSwizzle ? EXTERNAL_RED : EXTERNAL_ALPHA; + external_format const ExternalLuminanceAlpha = HasSwizzle ? EXTERNAL_RG : EXTERNAL_LUMINANCE_ALPHA; + + type_format const TypeF16 = Profile == PROFILE_ES20 ? TYPE_F16_OES : TYPE_F16; + + format_desc const Table[] = + { + {INTERNAL_RG4_EXT, EXTERNAL_RG, TYPE_UINT8_RG4_REV_GTC, 0}, //FORMAT_R4G4_UNORM, + {INTERNAL_RGBA4, EXTERNAL_RGBA, TYPE_UINT16_RGBA4_REV, 0}, //FORMAT_RGBA4_UNORM, + {INTERNAL_RGBA4, EXTERNAL_RGBA, TYPE_UINT16_RGBA4, detail::FORMAT_PROPERTY_BGRA_TYPE_BIT}, //FORMAT_BGRA4_UNORM, + {INTERNAL_R5G6B5, EXTERNAL_RGB, TYPE_UINT16_R5G6B5_REV, 0}, //FORMAT_R5G6B5_UNORM, + {INTERNAL_R5G6B5, EXTERNAL_RGB, TYPE_UINT16_R5G6B5, detail::FORMAT_PROPERTY_BGRA_TYPE_BIT}, //FORMAT_B5G6R5_UNORM, + {INTERNAL_RGB5A1, EXTERNAL_RGBA, TYPE_UINT16_RGB5A1_REV, 0}, //FORMAT_RGB5A1_UNORM, + {INTERNAL_RGB5A1, EXTERNAL_RGBA, TYPE_UINT16_RGB5A1, detail::FORMAT_PROPERTY_BGRA_TYPE_BIT}, //FORMAT_BGR5A1_UNORM, + {INTERNAL_RGB5A1, EXTERNAL_RGBA, TYPE_UINT16_A1RGB5_GTC, 0}, //FORMAT_A1RGB5_UNORM, + + {INTERNAL_R8_UNORM, EXTERNAL_RED, TYPE_U8, 0}, //FORMAT_R8_UNORM, + {INTERNAL_R8_SNORM, EXTERNAL_RED, TYPE_I8, 0}, //FORMAT_R8_SNORM, + {INTERNAL_R8_USCALED_GTC, EXTERNAL_RED, TYPE_U8, 0}, //FORMAT_R8_USCALED, + {INTERNAL_R8_SSCALED_GTC, EXTERNAL_RED, TYPE_I8, 0}, //FORMAT_R8_SSCALED, + {INTERNAL_R8U, EXTERNAL_RED_INTEGER, TYPE_U8, 0}, //FORMAT_R8_UINT, + {INTERNAL_R8I, EXTERNAL_RED_INTEGER, TYPE_I8, 0}, //FORMAT_R8_SINT, + {INTERNAL_SR8, EXTERNAL_RED, TYPE_U8, 0}, //FORMAT_R8_SRGB, + + {INTERNAL_RG8_UNORM, EXTERNAL_RG, TYPE_U8, 0}, //FORMAT_RG8_UNORM, + {INTERNAL_RG8_SNORM, EXTERNAL_RG, TYPE_I8, 0}, //FORMAT_RG8_SNORM, + {INTERNAL_RG8_USCALED_GTC, EXTERNAL_RG, TYPE_U8, 0}, //FORMAT_RG8_USCALED, + {INTERNAL_RG8_SSCALED_GTC, EXTERNAL_RG, TYPE_I8, 0}, //FORMAT_RG8_SSCALED, + {INTERNAL_RG8U, EXTERNAL_RG_INTEGER, TYPE_U8, 0}, //FORMAT_RG8_UINT, + {INTERNAL_RG8I, EXTERNAL_RG_INTEGER, TYPE_I8, 0}, //FORMAT_RG8_SINT, + {INTERNAL_SRG8, EXTERNAL_RG, TYPE_U8, 0}, //FORMAT_RG8_SRGB, + + {INTERNAL_RGB8_UNORM, EXTERNAL_RGB, TYPE_U8, 0}, //FORMAT_RGB8_UNORM, + {INTERNAL_RGB8_SNORM, EXTERNAL_RGB, TYPE_I8, 0}, //FORMAT_RGB8_SNORM, + {INTERNAL_RGB8_USCALED_GTC, EXTERNAL_RGB, TYPE_U8, 0}, //FORMAT_RGB8_USCALED, + {INTERNAL_RGB8_SSCALED_GTC, EXTERNAL_RGB, TYPE_I8, 0}, //FORMAT_RGB8_SSCALED, + {INTERNAL_RGB8U, EXTERNAL_RGB_INTEGER, TYPE_U8, 0}, //FORMAT_RGB8_UINT, + {INTERNAL_RGB8I, EXTERNAL_RGB_INTEGER, TYPE_I8, 0}, //FORMAT_RGB8_SINT, + {INTERNAL_SRGB8, ExternalSRGB8, TYPE_U8, 0}, //FORMAT_RGB8_SRGB, + + {INTERNAL_RGB8_UNORM, ExternalBGR, TYPE_U8, detail::FORMAT_PROPERTY_BGRA_FORMAT_BIT}, //FORMAT_BGR8_UNORM_PACK8, + {INTERNAL_RGB8_SNORM, ExternalBGR, TYPE_I8, detail::FORMAT_PROPERTY_BGRA_FORMAT_BIT}, //FORMAT_BGR8_SNORM_PACK8, + {INTERNAL_RGB8_USCALED_GTC, ExternalBGR, TYPE_U8, detail::FORMAT_PROPERTY_BGRA_FORMAT_BIT}, //FORMAT_BGR8_USCALED_PACK8, + {INTERNAL_RGB8_SSCALED_GTC, ExternalBGR, TYPE_I8, detail::FORMAT_PROPERTY_BGRA_FORMAT_BIT}, //FORMAT_BGR8_SSCALED_PACK8, + {INTERNAL_RGB8U, ExternalBGRInt, TYPE_U8, detail::FORMAT_PROPERTY_BGRA_FORMAT_BIT}, //FORMAT_BGR8_UINT_PACK8, + {INTERNAL_RGB8I, ExternalBGRInt, TYPE_I8, detail::FORMAT_PROPERTY_BGRA_FORMAT_BIT}, //FORMAT_BGR8_SINT_PACK8, + {INTERNAL_SRGB8, ExternalBGR, TYPE_U8, detail::FORMAT_PROPERTY_BGRA_FORMAT_BIT}, //FORMAT_BGR8_SRGB_PACK8, + + {INTERNAL_RGBA8_UNORM, EXTERNAL_RGBA, TYPE_U8, 0}, //FORMAT_RGBA8_UNORM_PACK8, + {INTERNAL_RGBA8_SNORM, EXTERNAL_RGBA, TYPE_I8, 0}, //FORMAT_RGBA8_SNORM_PACK8, + {INTERNAL_RGBA8_USCALED_GTC, EXTERNAL_RGBA, TYPE_U8, 0}, //FORMAT_RGBA8_USCALED_PACK8, + {INTERNAL_RGBA8_SSCALED_GTC, EXTERNAL_RGBA, TYPE_I8, 0}, //FORMAT_RGBA8_SSCALED_PACK8, + {INTERNAL_RGBA8U, EXTERNAL_RGBA_INTEGER, TYPE_U8, 0}, //FORMAT_RGBA8_UINT_PACK8, + {INTERNAL_RGBA8I, EXTERNAL_RGBA_INTEGER, TYPE_I8, 0}, //FORMAT_RGBA8_SINT_PACK8, + {INTERNAL_SRGB8_ALPHA8, ExternalSRGB8_A8, TYPE_U8, 0}, //FORMAT_RGBA8_SRGB_PACK8, + + {InternalBGRA, ExternalBGRA, TYPE_U8, detail::FORMAT_PROPERTY_BGRA_FORMAT_BIT}, //FORMAT_BGRA8_UNORM_PACK8, + {INTERNAL_RGBA8_SNORM, ExternalBGRA, TYPE_I8, detail::FORMAT_PROPERTY_BGRA_FORMAT_BIT}, //FORMAT_BGRA8_SNORM_PACK8, + {INTERNAL_RGBA8_USCALED_GTC, ExternalBGRA, TYPE_U8, detail::FORMAT_PROPERTY_BGRA_FORMAT_BIT}, //FORMAT_BGRA8_USCALED_PACK8, + {INTERNAL_RGBA8_SSCALED_GTC, ExternalBGRA, TYPE_I8, detail::FORMAT_PROPERTY_BGRA_FORMAT_BIT}, //FORMAT_BGRA8_SSCALED_PACK8, + {INTERNAL_RGBA8U, ExternalBGRAInt, TYPE_U8, detail::FORMAT_PROPERTY_BGRA_FORMAT_BIT}, //FORMAT_BGRA8_UINT_PACK8, + {INTERNAL_RGBA8I, ExternalBGRAInt, TYPE_I8, detail::FORMAT_PROPERTY_BGRA_FORMAT_BIT}, //FORMAT_BGRA8_SINT_PACK8, + {INTERNAL_SRGB8_ALPHA8, ExternalBGRA, TYPE_U8, detail::FORMAT_PROPERTY_BGRA_FORMAT_BIT}, //FORMAT_BGRA8_SRGB_PACK8, + + {INTERNAL_RGBA8_UNORM, EXTERNAL_RGBA, TYPE_UINT32_RGBA8_REV, 0}, //FORMAT_ABGR8_UNORM_PACK32, + {INTERNAL_RGBA8_SNORM, EXTERNAL_RGBA, TYPE_UINT32_RGBA8_REV, 0}, //FORMAT_ABGR8_SNORM_PACK32, + {INTERNAL_RGBA8_USCALED_GTC, EXTERNAL_RGBA, TYPE_UINT32_RGBA8_REV, 0}, //FORMAT_ABGR8_USCALED_PACK32, + {INTERNAL_RGBA8_SSCALED_GTC, EXTERNAL_RGBA, TYPE_UINT32_RGBA8_REV, 0}, //FORMAT_ABGR8_SSCALED_PACK32, + {INTERNAL_RGBA8U, EXTERNAL_RGBA_INTEGER, TYPE_UINT32_RGBA8_REV, 0}, //FORMAT_ABGR8_UINT_PACK32, + {INTERNAL_RGBA8I, EXTERNAL_RGBA_INTEGER, TYPE_UINT32_RGBA8_REV, 0}, //FORMAT_ABGR8_SINT_PACK32, + {INTERNAL_SRGB8_ALPHA8, EXTERNAL_RGBA, TYPE_UINT32_RGBA8_REV, 0}, //FORMAT_ABGR8_SRGB_PACK32, + + {INTERNAL_RGB10A2_UNORM, EXTERNAL_RGBA, TYPE_UINT32_RGB10A2_REV, 0}, //FORMAT_RGB10A2_UNORM_PACK32, + {INTERNAL_RGB10A2_SNORM_EXT, EXTERNAL_RGBA, TYPE_UINT32_RGB10A2_REV, 0}, //FORMAT_RGB10A2_SNORM_PACK32, + {INTERNAL_RGB10A2_USCALED_GTC, EXTERNAL_RGBA, TYPE_UINT32_RGB10A2_REV, 0}, //FORMAT_RGB10A2_USCALE_PACK32, + {INTERNAL_RGB10A2_SSCALED_GTC, EXTERNAL_RGBA, TYPE_UINT32_RGB10A2_REV, 0}, //FORMAT_RGB10A2_SSCALE_PACK32, + {INTERNAL_RGB10A2U, EXTERNAL_RGBA_INTEGER, TYPE_UINT32_RGB10A2_REV, 0}, //FORMAT_RGB10A2_UINT_PACK32, + {INTERNAL_RGB10A2I_EXT, EXTERNAL_RGBA_INTEGER, TYPE_UINT32_RGB10A2_REV, 0}, //FORMAT_RGB10A2_SINT_PACK32, + + {INTERNAL_RGB10A2_UNORM, EXTERNAL_RGBA, TYPE_UINT32_RGB10A2, detail::FORMAT_PROPERTY_BGRA_TYPE_BIT}, //FORMAT_BGR10A2_UNORM_PACK32, + {INTERNAL_RGB10A2_SNORM_EXT, EXTERNAL_RGBA, TYPE_UINT32_RGB10A2, detail::FORMAT_PROPERTY_BGRA_TYPE_BIT}, //FORMAT_BGR10A2_SNORM_PACK32, + {INTERNAL_RGB10A2_USCALED_GTC, EXTERNAL_RGBA, TYPE_UINT32_RGB10A2, detail::FORMAT_PROPERTY_BGRA_TYPE_BIT}, //FORMAT_BGR10A2_USCALE_PACK32, + {INTERNAL_RGB10A2_SSCALED_GTC, EXTERNAL_RGBA, TYPE_UINT32_RGB10A2, detail::FORMAT_PROPERTY_BGRA_TYPE_BIT}, //FORMAT_BGR10A2_SSCALE_PACK32, + {INTERNAL_RGB10A2U, EXTERNAL_RGBA_INTEGER, TYPE_UINT32_RGB10A2, detail::FORMAT_PROPERTY_BGRA_TYPE_BIT}, //FORMAT_BGR10A2_UINT_PACK32, + {INTERNAL_RGB10A2I_EXT, EXTERNAL_RGBA_INTEGER, TYPE_UINT32_RGB10A2, detail::FORMAT_PROPERTY_BGRA_TYPE_BIT}, //FORMAT_BGR10A2_SINT_PACK32, + + {INTERNAL_R16_UNORM, EXTERNAL_RED, TYPE_U16, 0}, //FORMAT_R16_UNORM_PACK16, + {INTERNAL_R16_SNORM, EXTERNAL_RED, TYPE_I16, 0}, //FORMAT_R16_SNORM_PACK16, + {INTERNAL_R16_USCALED_GTC, EXTERNAL_RED, TYPE_U16, 0}, //FORMAT_R16_USCALED_PACK16, + {INTERNAL_R16_SSCALED_GTC, EXTERNAL_RED, TYPE_I16, 0}, //FORMAT_R16_SSCALED_PACK16, + {INTERNAL_R16U, EXTERNAL_RED_INTEGER, TYPE_U16, 0}, //FORMAT_R16_UINT_PACK16, + {INTERNAL_R16I, EXTERNAL_RED_INTEGER, TYPE_I16, 0}, //FORMAT_R16_SINT_PACK16, + {INTERNAL_R16F, EXTERNAL_RED, TypeF16, 0}, //FORMAT_R16_SFLOAT_PACK16, + + {INTERNAL_RG16_UNORM, EXTERNAL_RG, TYPE_U16, 0}, //FORMAT_RG16_UNORM_PACK16, + {INTERNAL_RG16_SNORM, EXTERNAL_RG, TYPE_I16, 0}, //FORMAT_RG16_SNORM_PACK16, + {INTERNAL_RG16_USCALED_GTC, EXTERNAL_RG, TYPE_U16, 0}, //FORMAT_RG16_USCALED_PACK16, + {INTERNAL_RG16_SSCALED_GTC, EXTERNAL_RG, TYPE_I16, 0}, //FORMAT_RG16_SSCALED_PACK16, + {INTERNAL_RG16U, EXTERNAL_RG_INTEGER, TYPE_U16, 0}, //FORMAT_RG16_UINT_PACK16, + {INTERNAL_RG16I, EXTERNAL_RG_INTEGER, TYPE_I16, 0}, //FORMAT_RG16_SINT_PACK16, + {INTERNAL_RG16F, EXTERNAL_RG, TypeF16, 0}, //FORMAT_RG16_SFLOAT_PACK16, + + {INTERNAL_RGB16_UNORM, EXTERNAL_RGB, TYPE_U16, 0}, //FORMAT_RGB16_UNORM_PACK16, + {INTERNAL_RGB16_SNORM, EXTERNAL_RGB, TYPE_I16, 0}, //FORMAT_RGB16_SNORM_PACK16, + {INTERNAL_RGB16_USCALED_GTC, EXTERNAL_RGB, TYPE_U16, 0}, //FORMAT_RGB16_USCALED_PACK16, + {INTERNAL_RGB16_SSCALED_GTC, EXTERNAL_RGB, TYPE_I16, 0}, //FORMAT_RGB16_USCALED_PACK16, + {INTERNAL_RGB16U, EXTERNAL_RGB_INTEGER, TYPE_U16, 0}, //FORMAT_RGB16_UINT_PACK16, + {INTERNAL_RGB16I, EXTERNAL_RGB_INTEGER, TYPE_I16, 0}, //FORMAT_RGB16_SINT_PACK16, + {INTERNAL_RGB16F, EXTERNAL_RGB, TypeF16, 0}, //FORMAT_RGB16_SFLOAT_PACK16, + + {INTERNAL_RGBA16_UNORM, EXTERNAL_RGBA, TYPE_U16, 0}, //FORMAT_RGBA16_UNORM_PACK16, + {INTERNAL_RGBA16_SNORM, EXTERNAL_RGBA, TYPE_I16, 0}, //FORMAT_RGBA16_SNORM_PACK16, + {INTERNAL_RGBA16_USCALED_GTC, EXTERNAL_RGBA, TYPE_U16, 0}, //FORMAT_RGBA16_USCALED_PACK16, + {INTERNAL_RGBA16_SSCALED_GTC, EXTERNAL_RGBA, TYPE_I16, 0}, //FORMAT_RGBA16_SSCALED_PACK16, + {INTERNAL_RGBA16U, EXTERNAL_RGBA_INTEGER, TYPE_U16, 0}, //FORMAT_RGBA16_UINT_PACK16, + {INTERNAL_RGBA16I, EXTERNAL_RGBA_INTEGER, TYPE_I16, 0}, //FORMAT_RGBA16_SINT_PACK16, + {INTERNAL_RGBA16F, EXTERNAL_RGBA, TypeF16, 0}, //FORMAT_RGBA16_SFLOAT_PACK16, + + {INTERNAL_R32U, EXTERNAL_RED_INTEGER, TYPE_U32, 0}, //FORMAT_R32_UINT_PACK32, + {INTERNAL_R32I, EXTERNAL_RED_INTEGER, TYPE_I32, 0}, //FORMAT_R32_SINT_PACK32, + {INTERNAL_R32F, EXTERNAL_RED, TYPE_F32, 0}, //FORMAT_R32_SFLOAT_PACK32, + + {INTERNAL_RG32U, EXTERNAL_RG_INTEGER, TYPE_U32, 0}, //FORMAT_RG32_UINT_PACK32, + {INTERNAL_RG32I, EXTERNAL_RG_INTEGER, TYPE_I32, 0}, //FORMAT_RG32_SINT_PACK32, + {INTERNAL_RG32F, EXTERNAL_RG, TYPE_F32, 0}, //FORMAT_RG32_SFLOAT_PACK32, + + {INTERNAL_RGB32U, EXTERNAL_RGB_INTEGER, TYPE_U32, 0}, //FORMAT_RGB32_UINT_PACK32, + {INTERNAL_RGB32I, EXTERNAL_RGB_INTEGER, TYPE_I32, 0}, //FORMAT_RGB32_SINT_PACK32, + {INTERNAL_RGB32F, EXTERNAL_RGB, TYPE_F32, 0}, //FORMAT_RGB32_SFLOAT_PACK32, + + {INTERNAL_RGBA32U, EXTERNAL_RGBA_INTEGER, TYPE_U32, 0}, //FORMAT_RGBA32_UINT_PACK32, + {INTERNAL_RGBA32I, EXTERNAL_RGBA_INTEGER, TYPE_I32, 0}, //FORMAT_RGBA32_SINT_PACK32, + {INTERNAL_RGBA32F, EXTERNAL_RGBA, TYPE_F32, 0}, //FORMAT_RGBA32_SFLOAT_PACK32, + + {INTERNAL_R64F_EXT, EXTERNAL_RED, TYPE_U64, 0}, //FORMAT_R64_UINT_PACK64, + {INTERNAL_R64F_EXT, EXTERNAL_RED, TYPE_I64, 0}, //FORMAT_R64_SINT_PACK64, + {INTERNAL_R64F_EXT, EXTERNAL_RED, TYPE_F64, 0}, //FORMAT_R64_SFLOAT_PACK64, + + {INTERNAL_RG64F_EXT, EXTERNAL_RG, TYPE_U64, 0}, //FORMAT_RG64_UINT_PACK64, + {INTERNAL_RG64F_EXT, EXTERNAL_RG, TYPE_I64, 0}, //FORMAT_RG64_SINT_PACK64, + {INTERNAL_RG64F_EXT, EXTERNAL_RG, TYPE_F64, 0}, //FORMAT_RG64_SFLOAT_PACK64, + + {INTERNAL_RGB64F_EXT, EXTERNAL_RGB, TYPE_U64, 0}, //FORMAT_RGB64_UINT_PACK64, + {INTERNAL_RGB64F_EXT, EXTERNAL_RGB, TYPE_I64, 0}, //FORMAT_RGB64_SINT_PACK64, + {INTERNAL_RGB64F_EXT, EXTERNAL_RGB, TYPE_F64, 0}, //FORMAT_RGB64_SFLOAT_PACK64, + + {INTERNAL_RGBA64F_EXT, EXTERNAL_RGBA, TYPE_U64, 0}, //FORMAT_RGBA64_UINT_PACK64, + {INTERNAL_RGBA64F_EXT, EXTERNAL_RGBA, TYPE_I64, 0}, //FORMAT_RGBA64_SINT_PACK64, + {INTERNAL_RGBA64F_EXT, EXTERNAL_RGBA, TYPE_F64, 0}, //FORMAT_RGBA64_SFLOAT_PACK64, + + {INTERNAL_RG11B10F, EXTERNAL_RGB, TYPE_UINT32_RG11B10F_REV, 0}, //FORMAT_RG11B10_UFLOAT_PACK32, + {INTERNAL_RGB9E5, EXTERNAL_RGB, TYPE_UINT32_RGB9_E5_REV, 0}, //FORMAT_RGB9E5_UFLOAT_PACK32, + + {INTERNAL_D16, EXTERNAL_DEPTH, TYPE_NONE, 0}, //FORMAT_D16_UNORM_PACK16, + {INTERNAL_D24, EXTERNAL_DEPTH, TYPE_NONE, 0}, //FORMAT_D24_UNORM, + {INTERNAL_D32F, EXTERNAL_DEPTH, TYPE_NONE, 0}, //FORMAT_D32_UFLOAT, + {INTERNAL_S8_EXT, EXTERNAL_STENCIL, TYPE_NONE, 0}, //FORMAT_S8_UNORM, + {INTERNAL_D16S8_EXT, EXTERNAL_DEPTH, TYPE_NONE, 0}, //FORMAT_D16_UNORM_S8_UINT_PACK32, + {INTERNAL_D24S8, EXTERNAL_DEPTH_STENCIL, TYPE_NONE, 0}, //FORMAT_D24_UNORM_S8_UINT_PACK32, + {INTERNAL_D32FS8X24, EXTERNAL_DEPTH_STENCIL, TYPE_NONE, 0}, //FORMAT_D32_SFLOAT_S8_UINT_PACK64, + + {INTERNAL_RGB_DXT1, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGB_DXT1_UNORM_BLOCK8, + {INTERNAL_SRGB_DXT1, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGB_DXT1_SRGB_BLOCK8, + {INTERNAL_RGBA_DXT1, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGBA_DXT1_UNORM_BLOCK8, + {INTERNAL_SRGB_ALPHA_DXT1, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGBA_DXT1_SRGB_BLOCK8, + {INTERNAL_RGBA_DXT3, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGBA_DXT3_UNORM_BLOCK16, + {INTERNAL_SRGB_ALPHA_DXT3, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGBA_DXT3_SRGB_BLOCK16, + {INTERNAL_RGBA_DXT5, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGBA_DXT5_UNORM_BLOCK16, + {INTERNAL_SRGB_ALPHA_DXT5, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGBA_DXT5_SRGB_BLOCK16, + {INTERNAL_R_ATI1N_UNORM, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_R_ATI1N_UNORM_BLOCK8, + {INTERNAL_R_ATI1N_SNORM, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_R_ATI1N_SNORM_BLOCK8, + {INTERNAL_RG_ATI2N_UNORM, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RG_ATI2N_UNORM_BLOCK16, + {INTERNAL_RG_ATI2N_SNORM, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RG_ATI2N_SNORM_BLOCK16, + {INTERNAL_RGB_BP_UNSIGNED_FLOAT, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGB_BP_UFLOAT_BLOCK16, + {INTERNAL_RGB_BP_SIGNED_FLOAT, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGB_BP_SFLOAT_BLOCK16, + {INTERNAL_RGB_BP_UNORM, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGB_BP_UNORM, + {INTERNAL_SRGB_BP_UNORM, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGB_BP_SRGB, + + {InternalRGBETC, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGB_ETC2_UNORM_BLOCK8, + {INTERNAL_SRGB8_ETC2, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGB_ETC2_SRGB_BLOCK8, + {INTERNAL_RGBA_PUNCHTHROUGH_ETC2, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGBA_ETC2_PUNCHTHROUGH_UNORM, + {INTERNAL_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGBA_ETC2_PUNCHTHROUGH_SRGB, + {INTERNAL_RGBA_ETC2, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGBA_ETC2_UNORM_BLOCK16, + {INTERNAL_SRGB8_ALPHA8_ETC2_EAC, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGBA_ETC2_SRGB_BLOCK16, + {INTERNAL_R11_EAC, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_R11_EAC_UNORM, + {INTERNAL_SIGNED_R11_EAC, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_R11_EAC_SNORM, + {INTERNAL_RG11_EAC, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RG11_EAC_UNORM, + {INTERNAL_SIGNED_RG11_EAC, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RG11_EAC_SNORM, + + {INTERNAL_RGBA_ASTC_4x4, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGBA_ASTC4X4_UNORM, + {INTERNAL_SRGB8_ALPHA8_ASTC_4x4, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGBA_ASTC4X4_SRGB, + {INTERNAL_RGBA_ASTC_5x4, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGBA_ASTC5X4_UNORM, + {INTERNAL_SRGB8_ALPHA8_ASTC_5x4, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGBA_ASTC5X4_SRGB, + {INTERNAL_RGBA_ASTC_5x5, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGBA_ASTC5X5_UNORM, + {INTERNAL_SRGB8_ALPHA8_ASTC_5x5, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGBA_ASTC5X5_SRGB, + {INTERNAL_RGBA_ASTC_6x5, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGBA_ASTC6X5_UNORM, + {INTERNAL_SRGB8_ALPHA8_ASTC_6x5, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGBA_ASTC6X5_SRGB, + {INTERNAL_RGBA_ASTC_6x6, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGBA_ASTC6X6_UNORM, + {INTERNAL_SRGB8_ALPHA8_ASTC_6x6, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGBA_ASTC6X6_SRGB, + {INTERNAL_RGBA_ASTC_8x5, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGBA_ASTC8X5_UNORM, + {INTERNAL_SRGB8_ALPHA8_ASTC_8x5, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGBA_ASTC8X5_SRGB, + {INTERNAL_RGBA_ASTC_8x6, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGBA_ASTC8X6_UNORM, + {INTERNAL_SRGB8_ALPHA8_ASTC_8x6, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGBA_ASTC8X6_SRGB, + {INTERNAL_RGBA_ASTC_8x8, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGBA_ASTC8X8_UNORM, + {INTERNAL_SRGB8_ALPHA8_ASTC_8x8, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGBA_ASTC8X8_SRGB, + {INTERNAL_RGBA_ASTC_10x5, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGBA_ASTC10X5_UNORM, + {INTERNAL_SRGB8_ALPHA8_ASTC_10x5, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGBA_ASTC10X5_SRGB, + {INTERNAL_RGBA_ASTC_10x6, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGBA_ASTC10X6_UNORM, + {INTERNAL_SRGB8_ALPHA8_ASTC_10x6, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGBA_ASTC10X6_SRGB, + {INTERNAL_RGBA_ASTC_10x8, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGBA_ASTC10X8_UNORM, + {INTERNAL_SRGB8_ALPHA8_ASTC_10x8, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGBA_ASTC10X8_SRGB, + {INTERNAL_RGBA_ASTC_10x10, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGBA_ASTC10X10_UNORM, + {INTERNAL_SRGB8_ALPHA8_ASTC_10x10, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGBA_ASTC10X10_SRGB, + {INTERNAL_RGBA_ASTC_12x10, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGBA_ASTC12X10_UNORM, + {INTERNAL_SRGB8_ALPHA8_ASTC_12x10, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGBA_ASTC12X10_SRGB, + {INTERNAL_RGBA_ASTC_12x12, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGBA_ASTC12X12_UNORM, + {INTERNAL_SRGB8_ALPHA8_ASTC_12x12, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGBA_ASTC12X12_SRGB, + + {INTERNAL_RGB_PVRTC_4BPPV1, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGB_PVRTC1_8X8_UNORM_BLOCK32, + {INTERNAL_SRGB_PVRTC_2BPPV1, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGB_PVRTC1_8X8_SRGB_BLOCK32, + {INTERNAL_RGB_PVRTC_2BPPV1, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGB_PVRTC1_16X8_UNORM_BLOCK32, + {INTERNAL_SRGB_PVRTC_4BPPV1, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGB_PVRTC1_16X8_SRGB_BLOCK32, + {INTERNAL_RGBA_PVRTC_4BPPV1, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGBA_PVRTC1_8X8_UNORM_BLOCK32, + {INTERNAL_SRGB_ALPHA_PVRTC_2BPPV1, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGBA_PVRTC1_8X8_SRGB_BLOCK32, + {INTERNAL_RGBA_PVRTC_2BPPV1, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGBA_PVRTC1_16X8_UNORM_BLOCK32, + {INTERNAL_SRGB_ALPHA_PVRTC_4BPPV1, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGBA_PVRTC1_16X8_SRGB_BLOCK32, + {INTERNAL_RGBA_PVRTC_4BPPV2, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGBA_PVRTC2_4X4_UNORM_BLOCK8, + {INTERNAL_SRGB_ALPHA_PVRTC_4BPPV2, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGBA_PVRTC2_4X4_SRGB_BLOCK8, + {INTERNAL_RGBA_PVRTC_2BPPV2, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGBA_PVRTC2_8X4_UNORM_BLOCK8, + {INTERNAL_SRGB_ALPHA_PVRTC_2BPPV2, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGBA_PVRTC2_8X4_SRGB_BLOCK8, + + {INTERNAL_RGB_ETC, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGB_ETC_UNORM_BLOCK8, + {INTERNAL_ATC_RGB, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGB_ATC_UNORM_BLOCK8, + {INTERNAL_ATC_RGBA_EXPLICIT_ALPHA, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGBA_ATCA_UNORM_BLOCK16, + {INTERNAL_ATC_RGBA_INTERPOLATED_ALPHA, EXTERNAL_NONE, TYPE_NONE, 0}, //FORMAT_RGBA_ATCI_UNORM_BLOCK16, + + {InternalLuminance8, ExternalLuminance, TYPE_U8, 0}, //FORMAT_L8_UNORM_PACK8, + {InternalAlpha8, ExternalAlpha, TYPE_U8, 0}, //FORMAT_A8_UNORM_PACK8, + {InternalLuminanceAlpha8, ExternalLuminanceAlpha, TYPE_U8, 0}, //FORMAT_LA8_UNORM_PACK8, + {InternalLuminance16, ExternalLuminance, TYPE_U16, 0}, //FORMAT_L16_UNORM_PACK16, + {InternalAlpha16, ExternalAlpha, TYPE_U16, 0}, //FORMAT_A16_UNORM_PACK16, + {InternalLuminanceAlpha16, ExternalLuminanceAlpha, TYPE_U16, 0}, //FORMAT_LA16_UNORM_PACK16, + + {INTERNAL_RGB8_UNORM, ExternalBGRA, TYPE_U8, 0}, //FORMAT_BGRX8_UNORM, + {INTERNAL_SRGB8, ExternalBGRA, TYPE_U8, 0}, //FORMAT_BGRX8_SRGB, + + {INTERNAL_RG3B2, EXTERNAL_RGB, TYPE_UINT8_RG3B2_REV, 0}, //FORMAT_RG3B2_UNORM, + }; + + static_assert(sizeof(Table) / sizeof(Table[0]) == FORMAT_COUNT, "GLI error: format descriptor list doesn't match number of supported formats"); + + std::copy(&Table[0], &Table[0] + FORMAT_COUNT, this->FormatDesc.begin()); + } + + inline gl::target const& gl::translate(gli::target Target) const + { + static gl::target const Table[] = + { + gl::TARGET_1D, + gl::TARGET_1D_ARRAY, + gl::TARGET_2D, + gl::TARGET_2D_ARRAY, + gl::TARGET_3D, + gl::TARGET_RECT, + gl::TARGET_RECT_ARRAY, + gl::TARGET_CUBE, + gl::TARGET_CUBE_ARRAY + }; + static_assert(sizeof(Table) / sizeof(Table[0]) == TARGET_COUNT, "GLI error: target descriptor list doesn't match number of supported targets"); + + return Table[Target]; + } + + inline gl::format gl::translate(gli::format Format, gli::swizzles const& Swizzles) const + { + GLI_ASSERT(Format >= FORMAT_FIRST && Format <= FORMAT_LAST); + + gl::format_desc const& FormatDesc = this->FormatDesc[Format - FORMAT_FIRST]; + + gl::format FormatGL; + FormatGL.Internal = FormatDesc.Internal; + FormatGL.External = FormatDesc.External; + FormatGL.Type = FormatDesc.Type; + FormatGL.Swizzles = this->compute_swizzle(FormatDesc, Swizzles); + return FormatGL; + } + + inline gli::format gl::find(gl::internal_format InternalFormat, gl::external_format ExternalFormat, gl::type_format Type) + { + for(int FormatIndex = FORMAT_FIRST; FormatIndex <= FORMAT_LAST; ++FormatIndex) + { + std::size_t const Index = FormatIndex - FORMAT_FIRST; + if (this->FormatDesc[Index].Internal != InternalFormat) + continue; + if (this->FormatDesc[Index].External != ExternalFormat) + continue; + if (this->FormatDesc[Index].Type != Type) + continue; + + return static_cast(FormatIndex); + } + return static_cast(FORMAT_INVALID); + } + + inline gl::swizzles gl::compute_swizzle(format_desc const& FormatDesc, gli::swizzles const& Swizzles) const + { + if (!this->has_swizzle(this->Profile)) + return swizzles(gl::SWIZZLE_RED, gl::SWIZZLE_GREEN, gl::SWIZZLE_BLUE, gl::SWIZZLE_ALPHA); + + bool const IsExternalBGRA = ((FormatDesc.Properties & detail::FORMAT_PROPERTY_BGRA_FORMAT_BIT) && !has_swizzle(this->Profile)) || (FormatDesc.Properties & detail::FORMAT_PROPERTY_BGRA_TYPE_BIT); + + return detail::translate(IsExternalBGRA ? gli::swizzles(Swizzles.b, Swizzles.g, Swizzles.r, Swizzles.a) : Swizzles); + } +}//namespace gli diff --git a/test/external/gli/core/image.inl b/test/external/gli/core/image.inl new file mode 100644 index 00000000..595a6d9b --- /dev/null +++ b/test/external/gli/core/image.inl @@ -0,0 +1,251 @@ +namespace gli{ +namespace detail +{ + inline size_t texel_linear_aAdressing + ( + extent1d const& Extent, + extent1d const& TexelCoord + ) + { + GLI_ASSERT(glm::all(glm::lessThan(TexelCoord, Extent))); + + return static_cast(TexelCoord.x); + } + + inline size_t texel_linear_adressing + ( + extent2d const& Extent, + extent2d const& TexelCoord + ) + { + GLI_ASSERT(TexelCoord.x < Extent.x); + GLI_ASSERT(TexelCoord.y < Extent.y); + + return static_cast(TexelCoord.x + Extent.x * TexelCoord.y); + } + + inline size_t texel_linear_adressing + ( + extent3d const& Extent, + extent3d const& TexelCoord + ) + { + GLI_ASSERT(TexelCoord.x < Extent.x); + GLI_ASSERT(TexelCoord.y < Extent.y); + GLI_ASSERT(TexelCoord.z < Extent.z); + + return static_cast(TexelCoord.x + Extent.x * (TexelCoord.y + Extent.y * TexelCoord.z)); + } + + inline size_t texel_morton_adressing + ( + extent1d const& Extent, + extent1d const& TexelCoord + ) + { + GLI_ASSERT(TexelCoord.x < Extent.x); + + return TexelCoord.x; + } + + inline size_t texel_morton_adressing + ( + extent2d const& Extent, + extent2d const& TexelCoord + ) + { + GLI_ASSERT(TexelCoord.x < Extent.x && TexelCoord.x >= 0 && TexelCoord.x < std::numeric_limits::max()); + GLI_ASSERT(TexelCoord.y < Extent.y && TexelCoord.y >= 0 && TexelCoord.y < std::numeric_limits::max()); + + glm::u32vec2 const Input(TexelCoord); + + return static_cast(glm::bitfieldInterleave(Input.x, Input.y)); + } + + inline size_t texel_morton_adressing + ( + extent3d const& Extent, + extent3d const& TexelCoord + ) + { + GLI_ASSERT(TexelCoord.x < Extent.x); + GLI_ASSERT(TexelCoord.y < Extent.y); + GLI_ASSERT(TexelCoord.z < Extent.z); + + glm::u32vec3 const Input(TexelCoord); + + return static_cast(glm::bitfieldInterleave(Input.x, Input.y, Input.z)); + } +}//namespace detail + + inline image::image() + : Format(static_cast(FORMAT_INVALID)) + , BaseLevel(0) + , Data(nullptr) + , Size(0) + {} + + inline image::image + ( + format_type Format, + extent_type const& Extent + ) + : Storage(std::make_shared(Format, Extent, 1, 1, 1)) + , Format(Format) + , BaseLevel(0) + , Data(Storage->data()) + , Size(compute_size(0)) + {} + + inline image::image + ( + std::shared_ptr Storage, + format_type Format, + size_type BaseLayer, + size_type BaseFace, + size_type BaseLevel + ) + : Storage(Storage) + , Format(Format) + , BaseLevel(BaseLevel) + , Data(compute_data(BaseLayer, BaseFace, BaseLevel)) + , Size(compute_size(BaseLevel)) + {} + + inline image::image + ( + image const & Image, + format_type Format + ) + : Storage(Image.Storage) + , Format(Format) + , BaseLevel(Image.BaseLevel) + , Data(Image.Data) + , Size(Image.Size) + { + GLI_ASSERT(block_size(Format) == block_size(Image.format())); + } + + inline bool image::empty() const + { + if(this->Storage.get() == nullptr) + return true; + + return this->Storage->empty(); + } + + inline image::size_type image::size() const + { + GLI_ASSERT(!this->empty()); + + return this->Size; + } + + template + inline image::size_type image::size() const + { + GLI_ASSERT(sizeof(genType) <= this->Storage->block_size()); + + return this->size() / sizeof(genType); + } + + inline image::format_type image::format() const + { + return this->Format; + } + + inline image::extent_type image::extent() const + { + GLI_ASSERT(!this->empty()); + + storage_linear::extent_type const& SrcExtent = this->Storage->extent(this->BaseLevel); + storage_linear::extent_type const& DstExtent = SrcExtent * block_extent(this->format()) / this->Storage->block_extent(); + + return glm::max(DstExtent, storage_linear::extent_type(1)); + } + + inline void* image::data() + { + GLI_ASSERT(!this->empty()); + + return this->Data; + } + + inline void const* image::data() const + { + GLI_ASSERT(!this->empty()); + + return this->Data; + } + + template + inline genType* image::data() + { + GLI_ASSERT(!this->empty()); + GLI_ASSERT(this->Storage->block_size() >= sizeof(genType)); + + return reinterpret_cast(this->data()); + } + + template + inline genType const* image::data() const + { + GLI_ASSERT(!this->empty()); + GLI_ASSERT(this->Storage->block_size() >= sizeof(genType)); + + return reinterpret_cast(this->data()); + } + + inline void image::clear() + { + GLI_ASSERT(!this->empty()); + + memset(this->data(), 0, this->size()); + } + + template + inline void image::clear(genType const& Texel) + { + GLI_ASSERT(!this->empty()); + GLI_ASSERT(this->Storage->block_size() == sizeof(genType)); + + for(size_type TexelIndex = 0; TexelIndex < this->size(); ++TexelIndex) + *(this->data() + TexelIndex) = Texel; + } + + inline image::data_type* image::compute_data(size_type BaseLayer, size_type BaseFace, size_type BaseLevel) + { + size_type const BaseOffset = this->Storage->base_offset(BaseLayer, BaseFace, BaseLevel); + + return this->Storage->data() + BaseOffset; + } + + inline image::size_type image::compute_size(size_type Level) const + { + GLI_ASSERT(!this->empty()); + + return this->Storage->level_size(Level); + } + + template + genType image::load(extent_type const& TexelCoord) + { + GLI_ASSERT(!this->empty()); + GLI_ASSERT(!is_compressed(this->format())); + GLI_ASSERT(this->Storage->block_size() == sizeof(genType)); + GLI_ASSERT(glm::all(glm::lessThan(TexelCoord, this->extent()))); + + return *(this->data() + detail::texel_linear_adressing(this->extent(), TexelCoord)); + } + + template + void image::store(extent_type const& TexelCoord, genType const& Data) + { + GLI_ASSERT(!this->empty()); + GLI_ASSERT(!is_compressed(this->format())); + GLI_ASSERT(this->Storage->block_size() == sizeof(genType)); + GLI_ASSERT(glm::all(glm::lessThan(TexelCoord, this->extent()))); + + *(this->data() + detail::texel_linear_adressing(this->extent(), TexelCoord)) = Data; + } +}//namespace gli diff --git a/test/external/gli/core/image2d.hpp b/test/external/gli/core/image2d.hpp deleted file mode 100644 index 918514d5..00000000 --- a/test/external/gli/core/image2d.hpp +++ /dev/null @@ -1,169 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////// -// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net) -/////////////////////////////////////////////////////////////////////////////////////////////////// -// Created : 2011-04-05 -// Updated : 2011-04-05 -// Licence : This source is under MIT License -// File : gli/core/image2d.hpp -/////////////////////////////////////////////////////////////////////////////////////////////////// - -#ifndef GLI_CORE_IMAGE2D_INCLUDED -#define GLI_CORE_IMAGE2D_INCLUDED - -// STD -#include -#include -#include -#include - -// GLM -#include -#include -#include -#include -#include - -namespace gli -{ - enum format - { - FORMAT_NULL, - - // Unsigned integer formats - R8U, - RG8U, - RGB8U, - RGBA8U, - - R16U, - RG16U, - RGB16U, - RGBA16U, - - R32U, - RG32U, - RGB32U, - RGBA32U, - - // Signed integer formats - R8I, - RG8I, - RGB8I, - RGBA8I, - - R16I, - RG16I, - RGB16I, - RGBA16I, - - R32I, - RG32I, - RGB32I, - RGBA32I, - - // Floating formats - R16F, - RG16F, - RGB16F, - RGBA16F, - - R32F, - RG32F, - RGB32F, - RGBA32F, - - // Packed formats - RGBE8, - RGB9E5, - RG11B10F, - R5G6B5, - RGBA4, - RGB10A2, - - // Depth formats - D16, - D24X8, - D24S8, - D32F, - D32FS8X24, - - // Compressed formats - DXT1, - DXT3, - DXT5, - ATI1N_UNORM, - ATI1N_SNORM, - ATI2N_UNORM, - ATI2N_SNORM, - BP_UF16, - BP_SF16, - BP, - - FORMAT_MAX - }; - - enum size_type - { - LINEAR_SIZE, - BLOCK_SIZE, - BIT_PER_PIXEL, - COMPONENT - }; - - class image2D - { - public: - typedef glm::uvec2 dimensions_type; - typedef glm::vec2 texcoord_type; - typedef glm::uint32 size_type; - typedef glm::byte value_type; - typedef gli::format format_type; - typedef std::vector data_type; - - public: - image2D(); - image2D( - image2D const & Image); - - explicit image2D( - dimensions_type const & Dimensions, - format_type const & Format); - - template - explicit image2D( - dimensions_type const & Dimensions, - format_type const & Format, - genType const & Value); - - explicit image2D( - dimensions_type const & Dimensions, - format_type const & Format, - std::vector const & Data); - - ~image2D(); - - template - void setPixel( - dimensions_type const & TexelCoord, - genType const & TexelData); - - size_type value_size() const; - size_type capacity() const; - dimensions_type dimensions() const; - size_type components() const; - format_type format() const; - - value_type * data(); - value_type const * const data() const; - - private: - data_type Data; - dimensions_type Dimensions; - format_type Format; - }; - -}//namespace gli - -#include "image2d.inl" - -#endif//GLI_CORE_IMAGE2D_INCLUDED diff --git a/test/external/gli/core/image2d.inl b/test/external/gli/core/image2d.inl deleted file mode 100644 index 3781be83..00000000 --- a/test/external/gli/core/image2d.inl +++ /dev/null @@ -1,229 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////// -// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net) -/////////////////////////////////////////////////////////////////////////////////////////////////// -// Created : 2011-04-05 -// Updated : 2011-04-05 -// Licence : This source is under MIT License -// File : gli/core/image2d.inl -/////////////////////////////////////////////////////////////////////////////////////////////////// - -namespace gli -{ - namespace detail - { - struct format_desc - { - image2D::size_type BlockSize; - image2D::size_type BBP; - image2D::size_type Component; - }; - - inline format_desc getFormatInfo(format const & Format) - { - format_desc Desc[FORMAT_MAX] = - { - { 0, 0, 0}, //FORMAT_NULL - - // Unsigned integer formats - { 1, 8, 1}, //R8U, - { 2, 16, 2}, //RG8U, - { 3, 24, 3}, //RGB8U, - { 4, 32, 4}, //RGBA8U, - - { 2, 16, 1}, //R16U, - { 4, 32, 2}, //RG16U, - { 6, 48, 3}, //RGB16U, - { 8, 64, 4}, //RGBA16U, - - { 4, 32, 1}, //R32U, - { 8, 64, 2}, //RG32U, - { 12, 96, 3}, //RGB32U, - { 16, 128, 4}, //RGBA32U, - - //// Signed integer formats - { 4, 32, 1}, //R8I, - { 8, 64, 2}, //RG8I, - { 12, 96, 3}, //RGB8I, - { 16, 128, 4}, //RGBA8I, - - { 2, 16, 1}, //R16I, - { 4, 32, 2}, //RG16I, - { 6, 48, 3}, //RGB16I, - { 8, 64, 4}, //RGBA16I, - - { 4, 32, 1}, //R32I, - { 8, 64, 2}, //RG32I, - { 12, 96, 3}, //RGB32I, - { 16, 128, 4}, //RGBA32I, - - //// Floating formats - { 2, 16, 1}, //R16F, - { 4, 32, 2}, //RG16F, - { 6, 48, 3}, //RGB16F, - { 8, 64, 4}, //RGBA16F, - - { 4, 32, 1}, //R32F, - { 8, 64, 2}, //RG32F, - { 12, 96, 3}, //RGB32F, - { 16, 128, 4}, //RGBA32F, - - //// Packed formats - { 4, 32, 3}, //RGBE8, - { 4, 32, 3}, //RGB9E5, - { 4, 32, 3}, //RG11B10F, - { 2, 16, 3}, //R5G6B5, - { 2, 16, 4}, //RGBA4, - { 4, 32, 3}, //RGB10A2, - - //// Depth formats - { 2, 16, 1}, //D16, - { 4, 32, 1}, //D24X8, - { 4, 32, 2}, //D24S8, - { 4, 32, 1}, //D32F, - { 8, 64, 2}, //D32FS8X24, - - //// Compressed formats - { 8, 4, 4}, //DXT1, - { 16, 8, 4}, //DXT3, - { 16, 8, 4}, //DXT5, - { 8, 4, 1}, //ATI1N_UNORM, - { 8, 4, 1}, //ATI1N_SNORM, - { 16, 8, 2}, //ATI2N_UNORM, - { 16, 8, 2}, //ATI2N_SNORM, - { 16, 8, 3}, //BP_UF16, - { 16, 8, 3}, //BP_SF16, - { 16, 8, 4}, //BP, - }; - - return Desc[Format]; - } - - inline image2D::size_type sizeBlock - ( - format const & Format - ) - { - return getFormatInfo(Format).BlockSize; - } - - inline image2D::size_type sizeBitPerPixel - ( - format const & Format - ) - { - return getFormatInfo(Format).BBP; - } - - inline image2D::size_type sizeComponent - ( - format const & Format - ) - { - return getFormatInfo(Format).Component; - } - - inline image2D::size_type sizeLinear - ( - image2D const & Image - ) - { - image2D::dimensions_type Dimension = Image.dimensions(); - Dimension = glm::max(Dimension, image2D::dimensions_type(1)); - - image2D::size_type BlockSize = sizeBlock(Image.format()); - image2D::size_type BPP = sizeBitPerPixel(Image.format()); - image2D::size_type BlockCount = 0; - if((BlockSize << 3) == BPP) - BlockCount = Dimension.x * Dimension.y; - else - BlockCount = ((Dimension.x + 3) >> 2) * ((Dimension.y + 3) >> 2); - - return BlockCount * BlockSize; - } - }//namespace detail - - inline image2D::image2D() : - Data(0), - Dimensions(0), - Format(FORMAT_NULL) - {} - - inline image2D::image2D - ( - image2D const & Image - ) : - Data(Image.Data), - Dimensions(Image.Dimensions), - Format(Image.Format) - {} - - inline image2D::image2D - ( - dimensions_type const & Dimensions, - format_type const & Format - ) : - Data((glm::compMul(Dimensions) * detail::sizeBitPerPixel(Format)) >> 3), - Dimensions(Dimensions), - Format(Format) - {} - - inline image2D::image2D - ( - dimensions_type const & Dimensions, - format_type const & Format, - std::vector const & Data - ) : - Data(Data), - Dimensions(Dimensions), - Format(Format) - {} - - inline image2D::~image2D() - {} - - template - inline void image2D::setPixel - ( - dimensions_type const & TexelCoord, - genType const & TexelData - ) - { - size_type Index = this->dimensions().x * sizeof(genType) * TexelCoord.y + sizeof(genType) * TexelCoord.x; - memcpy(this->data() + Index, &TexelData[0], sizeof(genType)); - } - - inline image2D::size_type image2D::value_size() const - { - return detail::sizeBitPerPixel(this->format()); - } - - inline image2D::size_type image2D::capacity() const - { - return detail::sizeLinear(*this); - } - - inline image2D::dimensions_type image2D::dimensions() const - { - return this->Dimensions; - } - - inline image2D::size_type image2D::components() const - { - return detail::sizeComponent(this->format()); - } - - inline image2D::format_type image2D::format() const - { - return this->Format; - } - - inline image2D::value_type * image2D::data() - { - return &this->Data[0]; - } - - inline image2D::value_type const * const image2D::data() const - { - return &this->Data[0]; - } -}//namespace gli diff --git a/test/external/gli/core/levels.inl b/test/external/gli/core/levels.inl new file mode 100644 index 00000000..50043b4c --- /dev/null +++ b/test/external/gli/core/levels.inl @@ -0,0 +1,23 @@ +#include +#include + +namespace gli +{ + template class vecType> + inline T levels(vecType const& Extent) + { + return glm::log2(compMax(Extent)) + static_cast(1); + } + + template + inline T levels(T Extent) + { + return static_cast(glm::log2(Extent) + static_cast(1)); + } +/* + inline int levels(int Extent) + { + return glm::log2(Extent) + static_cast(1); + } +*/ +}//namespace gli diff --git a/test/external/gli/core/load.inl b/test/external/gli/core/load.inl new file mode 100644 index 00000000..dc47722f --- /dev/null +++ b/test/external/gli/core/load.inl @@ -0,0 +1,55 @@ +#include "../load_dds.hpp" +#include "../load_kmg.hpp" +#include "../load_ktx.hpp" +#include "file.hpp" + +namespace gli +{ + /// Load a texture (DDS, KTX or KMG) from memory + inline texture load(char const * Data, std::size_t Size) + { + { + texture Texture = load_dds(Data, Size); + if(!Texture.empty()) + return Texture; + } + { + texture Texture = load_kmg(Data, Size); + if(!Texture.empty()) + return Texture; + } + { + texture Texture = load_ktx(Data, Size); + if(!Texture.empty()) + return Texture; + } + + return texture(); + } + + /// Load a texture (DDS, KTX or KMG) from file + inline texture load(char const * Filename) + { + FILE* File = detail::open_file(Filename, "rb"); + if(!File) + return texture(); + + long Beg = std::ftell(File); + std::fseek(File, 0, SEEK_END); + long End = std::ftell(File); + std::fseek(File, 0, SEEK_SET); + + std::vector Data(static_cast(End - Beg)); + + std::fread(&Data[0], 1, Data.size(), File); + std::fclose(File); + + return load(&Data[0], Data.size()); + } + + /// Load a texture (DDS, KTX or KMG) from file + inline texture load(std::string const & Filename) + { + return load(Filename.c_str()); + } +}//namespace gli diff --git a/test/external/gli/core/load_dds.inl b/test/external/gli/core/load_dds.inl new file mode 100644 index 00000000..ba62c9b3 --- /dev/null +++ b/test/external/gli/core/load_dds.inl @@ -0,0 +1,324 @@ +#include "../dx.hpp" +#include "file.hpp" +#include +#include + +namespace gli{ +namespace detail +{ + static char const FOURCC_DDS[] = {'D', 'D', 'S', ' '}; + + enum dds_cubemap_flag + { + DDSCAPS2_CUBEMAP = 0x00000200, + DDSCAPS2_CUBEMAP_POSITIVEX = 0x00000400, + DDSCAPS2_CUBEMAP_NEGATIVEX = 0x00000800, + DDSCAPS2_CUBEMAP_POSITIVEY = 0x00001000, + DDSCAPS2_CUBEMAP_NEGATIVEY = 0x00002000, + DDSCAPS2_CUBEMAP_POSITIVEZ = 0x00004000, + DDSCAPS2_CUBEMAP_NEGATIVEZ = 0x00008000, + DDSCAPS2_VOLUME = 0x00200000 + }; + + enum + { + DDSCAPS2_CUBEMAP_ALLFACES = DDSCAPS2_CUBEMAP_POSITIVEX | DDSCAPS2_CUBEMAP_NEGATIVEX | DDSCAPS2_CUBEMAP_POSITIVEY | DDSCAPS2_CUBEMAP_NEGATIVEY | DDSCAPS2_CUBEMAP_POSITIVEZ | DDSCAPS2_CUBEMAP_NEGATIVEZ + }; + + enum dds_flag + { + DDSD_CAPS = 0x00000001, + DDSD_HEIGHT = 0x00000002, + DDSD_WIDTH = 0x00000004, + DDSD_PITCH = 0x00000008, + DDSD_PIXELFORMAT = 0x00001000, + DDSD_MIPMAPCOUNT = 0x00020000, + DDSD_LINEARSIZE = 0x00080000, + DDSD_DEPTH = 0x00800000 + }; + + enum dds_surface_flag + { + DDSCAPS_COMPLEX = 0x00000008, + DDSCAPS_MIPMAP = 0x00400000, + DDSCAPS_TEXTURE = 0x00001000 + }; + + struct dds_pixel_format + { + std::uint32_t size; // 32 + dx::ddpf flags; + dx::d3dfmt fourCC; + std::uint32_t bpp; + glm::u32vec4 Mask; + }; + + struct dds_header + { + std::uint32_t Size; + std::uint32_t Flags; + std::uint32_t Height; + std::uint32_t Width; + std::uint32_t Pitch; + std::uint32_t Depth; + std::uint32_t MipMapLevels; + std::uint32_t Reserved1[11]; + dds_pixel_format Format; + std::uint32_t SurfaceFlags; + std::uint32_t CubemapFlags; + std::uint32_t Reserved2[3]; + }; + + static_assert(sizeof(dds_header) == 124, "DDS Header size mismatch"); + + enum d3d10_resource_dimension + { + D3D10_RESOURCE_DIMENSION_UNKNOWN = 0, + D3D10_RESOURCE_DIMENSION_BUFFER = 1, + D3D10_RESOURCE_DIMENSION_TEXTURE1D = 2, + D3D10_RESOURCE_DIMENSION_TEXTURE2D = 3, + D3D10_RESOURCE_DIMENSION_TEXTURE3D = 4 + }; + + enum d3d10_resource_misc_flag + { + D3D10_RESOURCE_MISC_GENERATE_MIPS = 0x01, + D3D10_RESOURCE_MISC_SHARED = 0x02, + D3D10_RESOURCE_MISC_TEXTURECUBE = 0x04, + D3D10_RESOURCE_MISC_SHARED_KEYEDMUTEX = 0x10, + D3D10_RESOURCE_MISC_GDI_COMPATIBLE = 0x20, + }; + + enum dds_alpha_mode + { + DDS_ALPHA_MODE_UNKNOWN = 0x0, + DDS_ALPHA_MODE_STRAIGHT = 0x1, + DDS_ALPHA_MODE_PREMULTIPLIED = 0x2, + DDS_ALPHA_MODE_OPAQUE = 0x3, + DDS_ALPHA_MODE_CUSTOM = 0x4 + }; + + struct dds_header10 + { + dds_header10() : + Format(dx::DXGI_FORMAT_UNKNOWN), + ResourceDimension(D3D10_RESOURCE_DIMENSION_UNKNOWN), + MiscFlag(0), + ArraySize(0), + AlphaFlags(DDS_ALPHA_MODE_UNKNOWN) + {} + + dx::dxgiFormat Format; + d3d10_resource_dimension ResourceDimension; + std::uint32_t MiscFlag; // D3D10_RESOURCE_MISC_GENERATE_MIPS + std::uint32_t ArraySize; + dds_alpha_mode AlphaFlags; // Should be 0 whenever possible to avoid D3D utility library to fail + }; + + static_assert(sizeof(dds_header10) == 20, "DDS DX10 Extended Header size mismatch"); + + inline target get_target(dds_header const& Header, dds_header10 const& Header10) + { + if(Header.CubemapFlags & detail::DDSCAPS2_CUBEMAP) + { + if(Header10.ArraySize > 1) + return TARGET_CUBE_ARRAY; + else + return TARGET_CUBE; + } + else if(Header10.ArraySize > 1) + { + if(Header.Flags & detail::DDSD_HEIGHT) + return TARGET_2D_ARRAY; + else + return TARGET_1D_ARRAY; + } + else if(Header10.ResourceDimension == D3D10_RESOURCE_DIMENSION_TEXTURE1D) + return TARGET_1D; + else if(Header10.ResourceDimension == D3D10_RESOURCE_DIMENSION_TEXTURE3D || Header.Flags & detail::DDSD_DEPTH || Header.CubemapFlags & detail::DDSCAPS2_VOLUME) + return TARGET_3D; + else + return TARGET_2D; + } + + // Some formats have multiple fourcc values. This function allows remapping to the default fourcc value of a format + inline dx::d3dfmt remap_four_cc(dx::d3dfmt FourCC) + { + switch(FourCC) + { + default: + return FourCC; + case dx::D3DFMT_BC4U: + return dx::D3DFMT_ATI1; + case dx::D3DFMT_BC4S: + return dx::D3DFMT_AT1N; + case dx::D3DFMT_BC5U: + return dx::D3DFMT_ATI2; + case dx::D3DFMT_BC5S: + return dx::D3DFMT_AT2N; + } + } +}//namespace detail + + inline texture load_dds(char const * Data, std::size_t Size) + { + GLI_ASSERT(Data && (Size >= sizeof(detail::FOURCC_DDS))); + + if(strncmp(Data, detail::FOURCC_DDS, 4) != 0) + return texture(); + std::size_t Offset = sizeof(detail::FOURCC_DDS); + + GLI_ASSERT(Size >= sizeof(detail::dds_header)); + + detail::dds_header const & Header(*reinterpret_cast(Data + Offset)); + Offset += sizeof(detail::dds_header); + + detail::dds_header10 Header10; + if((Header.Format.flags & dx::DDPF_FOURCC) && (Header.Format.fourCC == dx::D3DFMT_DX10 || Header.Format.fourCC == dx::D3DFMT_GLI1)) + { + std::memcpy(&Header10, Data + Offset, sizeof(Header10)); + Offset += sizeof(detail::dds_header10); + } + + dx DX; + + gli::format Format(static_cast(gli::FORMAT_INVALID)); + if((Header.Format.flags & (dx::DDPF_RGB | dx::DDPF_ALPHAPIXELS | dx::DDPF_ALPHA | dx::DDPF_YUV | dx::DDPF_LUMINANCE)) && Format == static_cast(gli::FORMAT_INVALID) && Header.Format.bpp != 0) + { + switch(Header.Format.bpp) + { + default: + GLI_ASSERT(0); + break; + case 8: + { + if(glm::all(glm::equal(Header.Format.Mask, DX.translate(FORMAT_RG4_UNORM_PACK8).Mask))) + Format = FORMAT_RG4_UNORM_PACK8; + else if(glm::all(glm::equal(Header.Format.Mask, DX.translate(FORMAT_L8_UNORM_PACK8).Mask))) + Format = FORMAT_L8_UNORM_PACK8; + else if(glm::all(glm::equal(Header.Format.Mask, DX.translate(FORMAT_A8_UNORM_PACK8).Mask))) + Format = FORMAT_A8_UNORM_PACK8; + else if(glm::all(glm::equal(Header.Format.Mask, DX.translate(FORMAT_R8_UNORM_PACK8).Mask))) + Format = FORMAT_R8_UNORM_PACK8; + else if(glm::all(glm::equal(Header.Format.Mask, DX.translate(FORMAT_RG3B2_UNORM_PACK8).Mask))) + Format = FORMAT_RG3B2_UNORM_PACK8; + else + GLI_ASSERT(0); + break; + } + case 16: + { + if(glm::all(glm::equal(Header.Format.Mask, DX.translate(FORMAT_RGBA4_UNORM_PACK16).Mask))) + Format = FORMAT_RGBA4_UNORM_PACK16; + else if(glm::all(glm::equal(Header.Format.Mask, DX.translate(FORMAT_BGRA4_UNORM_PACK16).Mask))) + Format = FORMAT_BGRA4_UNORM_PACK16; + else if(glm::all(glm::equal(Header.Format.Mask, DX.translate(FORMAT_R5G6B5_UNORM_PACK16).Mask))) + Format = FORMAT_R5G6B5_UNORM_PACK16; + else if(glm::all(glm::equal(Header.Format.Mask, DX.translate(FORMAT_B5G6R5_UNORM_PACK16).Mask))) + Format = FORMAT_B5G6R5_UNORM_PACK16; + else if(glm::all(glm::equal(Header.Format.Mask, DX.translate(FORMAT_RGB5A1_UNORM_PACK16).Mask))) + Format = FORMAT_RGB5A1_UNORM_PACK16; + else if(glm::all(glm::equal(Header.Format.Mask, DX.translate(FORMAT_BGR5A1_UNORM_PACK16).Mask))) + Format = FORMAT_BGR5A1_UNORM_PACK16; + else if(glm::all(glm::equal(Header.Format.Mask, DX.translate(FORMAT_LA8_UNORM_PACK8).Mask))) + Format = FORMAT_LA8_UNORM_PACK8; + else if(glm::all(glm::equal(Header.Format.Mask, DX.translate(FORMAT_RG8_UNORM_PACK8).Mask))) + Format = FORMAT_RG8_UNORM_PACK8; + else if(glm::all(glm::equal(Header.Format.Mask, DX.translate(FORMAT_L16_UNORM_PACK16).Mask))) + Format = FORMAT_L16_UNORM_PACK16; + else if(glm::all(glm::equal(Header.Format.Mask, DX.translate(FORMAT_A16_UNORM_PACK16).Mask))) + Format = FORMAT_A16_UNORM_PACK16; + else if(glm::all(glm::equal(Header.Format.Mask, DX.translate(FORMAT_R16_UNORM_PACK16).Mask))) + Format = FORMAT_R16_UNORM_PACK16; + else + GLI_ASSERT(0); + break; + } + case 24: + { + if(glm::all(glm::equal(Header.Format.Mask, DX.translate(FORMAT_RGB8_UNORM_PACK8).Mask))) + Format = FORMAT_RGB8_UNORM_PACK8; + else if(glm::all(glm::equal(Header.Format.Mask, DX.translate(FORMAT_BGR8_UNORM_PACK8).Mask))) + Format = FORMAT_BGR8_UNORM_PACK8; + else + GLI_ASSERT(0); + break; + } + case 32: + { + if(glm::all(glm::equal(Header.Format.Mask, DX.translate(FORMAT_BGR8_UNORM_PACK32).Mask))) + Format = FORMAT_BGR8_UNORM_PACK32; + else if(glm::all(glm::equal(Header.Format.Mask, DX.translate(FORMAT_BGRA8_UNORM_PACK8).Mask))) + Format = FORMAT_BGRA8_UNORM_PACK8; + else if(glm::all(glm::equal(Header.Format.Mask, DX.translate(FORMAT_RGBA8_UNORM_PACK8).Mask))) + Format = FORMAT_RGBA8_UNORM_PACK8; + else if(glm::all(glm::equal(Header.Format.Mask, DX.translate(FORMAT_RGB10A2_UNORM_PACK32).Mask))) + Format = FORMAT_RGB10A2_UNORM_PACK32; + else if(glm::all(glm::equal(Header.Format.Mask, DX.translate(FORMAT_LA16_UNORM_PACK16).Mask))) + Format = FORMAT_LA16_UNORM_PACK16; + else if(glm::all(glm::equal(Header.Format.Mask, DX.translate(FORMAT_RG16_UNORM_PACK16).Mask))) + Format = FORMAT_RG16_UNORM_PACK16; + else if(glm::all(glm::equal(Header.Format.Mask, DX.translate(FORMAT_R32_SFLOAT_PACK32).Mask))) + Format = FORMAT_R32_SFLOAT_PACK32; + else + GLI_ASSERT(0); + break; + } + } + } + else if((Header.Format.flags & dx::DDPF_FOURCC) && (Header.Format.fourCC != dx::D3DFMT_DX10) && (Header.Format.fourCC != dx::D3DFMT_GLI1) && (Format == static_cast(gli::FORMAT_INVALID))) + { + dx::d3dfmt const FourCC = detail::remap_four_cc(Header.Format.fourCC); + Format = DX.find(FourCC); + } + else if(Header.Format.fourCC == dx::D3DFMT_DX10 || Header.Format.fourCC == dx::D3DFMT_GLI1) + Format = DX.find(Header.Format.fourCC, Header10.Format); + + GLI_ASSERT(Format != static_cast(gli::FORMAT_INVALID)); + + size_t const MipMapCount = (Header.Flags & detail::DDSD_MIPMAPCOUNT) ? Header.MipMapLevels : 1; + size_t FaceCount = 1; + if(Header.CubemapFlags & detail::DDSCAPS2_CUBEMAP) + FaceCount = int(glm::bitCount(Header.CubemapFlags & detail::DDSCAPS2_CUBEMAP_ALLFACES)); + + size_t DepthCount = 1; + if(Header.CubemapFlags & detail::DDSCAPS2_VOLUME) + DepthCount = Header.Depth; + + texture Texture( + get_target(Header, Header10), Format, + texture::extent_type(Header.Width, Header.Height, DepthCount), + std::max(Header10.ArraySize, 1), FaceCount, MipMapCount); + + std::size_t const SourceSize = Offset + Texture.size(); + GLI_ASSERT(SourceSize == Size); + + std::memcpy(Texture.data(), Data + Offset, Texture.size()); + + return Texture; + } + + inline texture load_dds(char const * Filename) + { + FILE* File = detail::open_file(Filename, "rb"); + if(!File) + return texture(); + + long Beg = std::ftell(File); + std::fseek(File, 0, SEEK_END); + long End = std::ftell(File); + std::fseek(File, 0, SEEK_SET); + + std::vector Data(static_cast(End - Beg)); + + std::fread(&Data[0], 1, Data.size(), File); + std::fclose(File); + + return load_dds(&Data[0], Data.size()); + } + + inline texture load_dds(std::string const & Filename) + { + return load_dds(Filename.c_str()); + } +}//namespace gli diff --git a/test/external/gli/core/load_kmg.inl b/test/external/gli/core/load_kmg.inl new file mode 100644 index 00000000..e2b8a111 --- /dev/null +++ b/test/external/gli/core/load_kmg.inl @@ -0,0 +1,103 @@ +#include "file.hpp" +#include +#include + +namespace gli{ +namespace detail +{ + static unsigned char const FOURCC_KMG100[] = {0xAB, 0x4B, 0x49, 0x4D, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A}; + + struct kmgHeader10 + { + std::uint32_t Endianness; + std::uint32_t Format; + std::uint32_t Target; + std::uint32_t SwizzleRed; + std::uint32_t SwizzleGreen; + std::uint32_t SwizzleBlue; + std::uint32_t SwizzleAlpha; + std::uint32_t PixelWidth; + std::uint32_t PixelHeight; + std::uint32_t PixelDepth; + std::uint32_t Layers; + std::uint32_t Levels; + std::uint32_t Faces; + std::uint32_t GenerateMipmaps; + std::uint32_t BaseLevel; + std::uint32_t MaxLevel; + }; + + inline texture load_kmg100(char const * Data, std::size_t Size) + { + detail::kmgHeader10 const & Header(*reinterpret_cast(Data)); + + size_t Offset = sizeof(detail::kmgHeader10); + + texture Texture( + static_cast(Header.Target), + static_cast(Header.Format), + texture::extent_type(Header.PixelWidth, Header.PixelHeight, Header.PixelDepth), + Header.Layers, + Header.Faces, + Header.Levels, + texture::swizzles_type(Header.SwizzleRed, Header.SwizzleGreen, Header.SwizzleBlue, Header.SwizzleAlpha)); + + for(texture::size_type Layer = 0, Layers = Texture.layers(); Layer < Layers; ++Layer) + for(texture::size_type Level = 0, Levels = Texture.levels(); Level < Levels; ++Level) + { + texture::size_type const FaceSize = static_cast(Texture.size(Level)); + for(texture::size_type Face = 0, Faces = Texture.faces(); Face < Faces; ++Face) + { + std::memcpy(Texture.data(Layer, Face, Level), Data + Offset, FaceSize); + + Offset += FaceSize; + GLI_ASSERT(Offset <= Size); + } + } + + return texture( + Texture, Texture.target(), Texture.format(), + Texture.base_layer(), Texture.max_layer(), + Texture.base_face(), Texture.max_face(), + Header.BaseLevel, Header.MaxLevel, + Texture.swizzles()); + } +}//namespace detail + + inline texture load_kmg(char const * Data, std::size_t Size) + { + GLI_ASSERT(Data && (Size >= sizeof(detail::kmgHeader10))); + + // KMG100 + { + if(memcmp(Data, detail::FOURCC_KMG100, sizeof(detail::FOURCC_KMG100)) == 0) + return detail::load_kmg100(Data + sizeof(detail::FOURCC_KMG100), Size - sizeof(detail::FOURCC_KMG100)); + } + + return texture(); + } + + inline texture load_kmg(char const * Filename) + { + FILE* File = detail::open_file(Filename, "rb"); + if(!File) + return texture(); + + long Beg = std::ftell(File); + std::fseek(File, 0, SEEK_END); + long End = std::ftell(File); + std::fseek(File, 0, SEEK_SET); + + std::vector Data(static_cast(End - Beg)); + + std::fread(&Data[0], 1, Data.size(), File); + std::fclose(File); + + return load_kmg(&Data[0], Data.size()); + } + + inline texture load_kmg(std::string const & Filename) + { + return load_kmg(Filename.c_str()); + } +}//namespace gli diff --git a/test/external/gli/core/load_ktx.inl b/test/external/gli/core/load_ktx.inl new file mode 100644 index 00000000..4b79ce5b --- /dev/null +++ b/test/external/gli/core/load_ktx.inl @@ -0,0 +1,137 @@ +#include "../gl.hpp" +#include "file.hpp" +#include +#include + +namespace gli{ +namespace detail +{ + static unsigned char const FOURCC_KTX10[] = {0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A}; + static unsigned char const FOURCC_KTX20[] = {0xAB, 0x4B, 0x54, 0x58, 0x20, 0x32, 0x30, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A}; + + struct ktx_header10 + { + std::uint32_t Endianness; + std::uint32_t GLType; + std::uint32_t GLTypeSize; + std::uint32_t GLFormat; + std::uint32_t GLInternalFormat; + std::uint32_t GLBaseInternalFormat; + std::uint32_t PixelWidth; + std::uint32_t PixelHeight; + std::uint32_t PixelDepth; + std::uint32_t NumberOfArrayElements; + std::uint32_t NumberOfFaces; + std::uint32_t NumberOfMipmapLevels; + std::uint32_t BytesOfKeyValueData; + }; + + inline target get_target(ktx_header10 const& Header) + { + if(Header.NumberOfFaces > 1) + { + if(Header.NumberOfArrayElements > 0) + return TARGET_CUBE_ARRAY; + else + return TARGET_CUBE; + } + else if(Header.NumberOfArrayElements > 0) + { + if(Header.PixelHeight == 0) + return TARGET_1D_ARRAY; + else + return TARGET_2D_ARRAY; + } + else if(Header.PixelHeight == 0) + return TARGET_1D; + else if(Header.PixelDepth > 0) + return TARGET_3D; + else + return TARGET_2D; + } + + inline texture load_ktx10(char const* Data, std::size_t Size) + { + detail::ktx_header10 const & Header(*reinterpret_cast(Data)); + + size_t Offset = sizeof(detail::ktx_header10); + + // Skip key value data + Offset += Header.BytesOfKeyValueData; + + gl GL(gl::PROFILE_KTX); + gli::format const Format = GL.find( + static_cast(Header.GLInternalFormat), + static_cast(Header.GLFormat), + static_cast(Header.GLType)); + GLI_ASSERT(Format != static_cast(gli::FORMAT_INVALID)); + + texture::size_type const BlockSize = block_size(Format); + + texture Texture( + detail::get_target(Header), + Format, + texture::extent_type( + Header.PixelWidth, + std::max(Header.PixelHeight, 1), + std::max(Header.PixelDepth, 1)), + std::max(Header.NumberOfArrayElements, 1), + std::max(Header.NumberOfFaces, 1), + std::max(Header.NumberOfMipmapLevels, 1)); + + for(texture::size_type Level = 0, Levels = Texture.levels(); Level < Levels; ++Level) + { + Offset += sizeof(std::uint32_t); + + for(texture::size_type Layer = 0, Layers = Texture.layers(); Layer < Layers; ++Layer) + for(texture::size_type Face = 0, Faces = Texture.faces(); Face < Faces; ++Face) + { + texture::size_type const FaceSize = Texture.size(Level); + + std::memcpy(Texture.data(Layer, Face, Level), Data + Offset, FaceSize); + + Offset += std::max(BlockSize, glm::ceilMultiple(FaceSize, static_cast(4))); + } + } + + return Texture; + } +}//namespace detail + + inline texture load_ktx(char const* Data, std::size_t Size) + { + GLI_ASSERT(Data && (Size >= sizeof(detail::ktx_header10))); + + // KTX10 + { + if(memcmp(Data, detail::FOURCC_KTX10, sizeof(detail::FOURCC_KTX10)) == 0) + return detail::load_ktx10(Data + sizeof(detail::FOURCC_KTX10), Size - sizeof(detail::FOURCC_KTX10)); + } + + return texture(); + } + + inline texture load_ktx(char const* Filename) + { + FILE* File = detail::open_file(Filename, "rb"); + if(!File) + return texture(); + + long Beg = std::ftell(File); + std::fseek(File, 0, SEEK_END); + long End = std::ftell(File); + std::fseek(File, 0, SEEK_SET); + + std::vector Data(static_cast(End - Beg)); + + std::fread(&Data[0], 1, Data.size(), File); + std::fclose(File); + + return load_ktx(&Data[0], Data.size()); + } + + inline texture load_ktx(std::string const& Filename) + { + return load_ktx(Filename.c_str()); + } +}//namespace gli diff --git a/test/external/gli/core/make_texture.inl b/test/external/gli/core/make_texture.inl new file mode 100644 index 00000000..f0eb84de --- /dev/null +++ b/test/external/gli/core/make_texture.inl @@ -0,0 +1,72 @@ +namespace gli +{ + inline gli::texture make_texture1d(format Format, extent1d const& Extent, size_t Levels) + { + return gli::texture(TARGET_1D, Format, texture::extent_type(Extent.x, 1, 1), 1, 1, Levels); + } + + inline gli::texture make_texture1d(format Format, extent1d const& Extent) + { + return gli::texture(TARGET_1D, Format, texture::extent_type(Extent.x, 1, 1), 1, 1, gli::levels(texture::extent_type(Extent.x, 1, 1))); + } + + inline gli::texture make_texture1d_array(format Format, extent1d const& Extent, size_t Layers, size_t Levels) + { + return gli::texture(TARGET_1D_ARRAY, Format, texture::extent_type(Extent.x, 1, 1), Layers, 1, Levels); + } + + inline gli::texture make_texture1d_array(format Format, extent1d const& Extent, size_t Layers) + { + return gli::texture(TARGET_1D_ARRAY, Format, texture::extent_type(Extent.x, 1, 1), Layers, 1, gli::levels(texture::extent_type(Extent.x, 1, 1))); + } + + inline gli::texture make_texture2d(format Format, extent2d const& Extent, size_t Levels) + { + return gli::texture(TARGET_2D, Format, texture::extent_type(Extent, 1), 1, 1, Levels); + } + + inline gli::texture make_texture2d(format Format, extent2d const& Extent) + { + return gli::texture(TARGET_2D, Format, texture::extent_type(Extent, 1), 1, 1, gli::levels(texture::extent_type(Extent, 1))); + } + + inline gli::texture make_texture2d_array(format Format, extent2d const& Extent, size_t Layer, size_t Levels) + { + return gli::texture(TARGET_2D_ARRAY, Format, texture::extent_type(Extent, 1), Layer, 1, Levels); + } + + inline gli::texture make_texture2d_array(format Format, extent2d const& Extent, size_t Layer) + { + return gli::texture(TARGET_2D_ARRAY, Format, texture::extent_type(Extent, 1), Layer, 1, gli::levels(texture::extent_type(Extent, 1))); + } + + inline gli::texture make_texture3d(format Format, extent3d const& Extent, size_t Levels) + { + return gli::texture(TARGET_3D, Format, texture::extent_type(Extent), 1, 1, Levels); + } + + inline gli::texture make_texture3d(format Format, extent3d const& Extent) + { + return gli::texture(TARGET_3D, Format, texture::extent_type(Extent), 1, 1, gli::levels(texture::extent_type(Extent))); + } + + inline gli::texture make_texture_cube(format Format, extent2d const& Extent, size_t Levels) + { + return gli::texture(TARGET_CUBE, Format, texture::extent_type(Extent, 1), 1, 6, Levels); + } + + inline gli::texture make_texture_cube(format Format, extent2d const& Extent) + { + return gli::texture(TARGET_CUBE, Format, texture::extent_type(Extent, 1), 1, 6, gli::levels(texture::extent_type(Extent, 1))); + } + + inline gli::texture make_texture_cube_array(format Format, extent2d const& Extent, size_t Layer, size_t Levels) + { + return gli::texture(TARGET_CUBE_ARRAY, Format, texture::extent_type(Extent, 1), Layer, 6, Levels); + } + + inline gli::texture make_texture_cube_array(format Format, extent2d const& Extent, size_t Layer) + { + return gli::texture(TARGET_CUBE_ARRAY, Format, texture::extent_type(Extent, 1), Layer, 6, gli::levels(texture::extent_type(Extent, 1))); + } +}//namespace gli diff --git a/test/external/gli/core/mipmaps_compute.hpp b/test/external/gli/core/mipmaps_compute.hpp new file mode 100644 index 00000000..3c025e86 --- /dev/null +++ b/test/external/gli/core/mipmaps_compute.hpp @@ -0,0 +1,116 @@ +#pragma once + +#include "filter_compute.hpp" + +namespace gli{ +namespace detail +{ + template + inline void generate_mipmaps_1d + ( + texture_type & Texture, fetch_func Fetch, write_func Write, + typename texture_type::size_type BaseLayer, typename texture_type::size_type MaxLayer, + typename texture_type::size_type BaseFace, typename texture_type::size_type MaxFace, + typename texture_type::size_type BaseLevel, typename texture_type::size_type MaxLevel, + filter Min + ) + { + typedef typename detail::interpolate::type interpolate_type; + typedef typename texture_type::extent_type extent_type; + typedef typename texture_type::size_type size_type; + typedef typename extent_type::value_type component_type; + typedef typename detail::filterBase::filterFunc filter_func; + + filter_func const Filter = detail::get_filter(FILTER_NEAREST, Min, false); + GLI_ASSERT(Filter); + + for(size_type Layer = BaseLayer; Layer <= MaxLayer; ++Layer) + for(size_type Face = BaseFace; Face <= MaxFace; ++Face) + for(size_type Level = BaseLevel; Level < MaxLevel; ++Level) + { + extent_type const& ExtentDst = Texture.extent(Level + 1); + normalized_type const& Scale = normalized_type(1) / normalized_type(max(ExtentDst - extent_type(1), extent_type(1))); + + for(component_type i = 0; i < ExtentDst.x; ++i) + { + normalized_type const& SamplePosition(normalized_type(static_cast(i)) * Scale); + texel_type const& Texel = Filter(Texture, Fetch, SamplePosition, Layer, Face, static_cast(Level), texel_type(0)); + Write(Texture, extent_type(i), Layer, Face, Level + 1, Texel); + } + } + } + + template + inline void generate_mipmaps_2d + ( + texture_type & Texture, fetch_func Fetch, write_func Write, + typename texture_type::size_type BaseLayer, typename texture_type::size_type MaxLayer, + typename texture_type::size_type BaseFace, typename texture_type::size_type MaxFace, + typename texture_type::size_type BaseLevel, typename texture_type::size_type MaxLevel, + filter Min + ) + { + typedef typename detail::interpolate::type interpolate_type; + typedef typename texture_type::extent_type extent_type; + typedef typename texture_type::size_type size_type; + typedef typename extent_type::value_type component_type; + typedef typename detail::filterBase::filterFunc filter_func; + + filter_func const Filter = detail::get_filter(FILTER_NEAREST, Min, false); + GLI_ASSERT(Filter); + + for(size_type Layer = BaseLayer; Layer <= MaxLayer; ++Layer) + for(size_type Face = BaseFace; Face <= MaxFace; ++Face) + for(size_type Level = BaseLevel; Level < MaxLevel; ++Level) + { + extent_type const& ExtentDst = Texture.extent(Level + 1); + normalized_type const& Scale = normalized_type(1) / normalized_type(max(ExtentDst - extent_type(1), extent_type(1))); + + for(component_type j = 0; j < ExtentDst.y; ++j) + for(component_type i = 0; i < ExtentDst.x; ++i) + { + normalized_type const& SamplePosition(normalized_type(i, j) * Scale); + texel_type const& Texel = Filter(Texture, Fetch, SamplePosition, Layer, Face, static_cast(Level), texel_type(0)); + Write(Texture, extent_type(i, j), Layer, Face, Level + 1, Texel); + } + } + } + + template + inline void generate_mipmaps_3d + ( + texture_type & Texture, fetch_func Fetch, write_func Write, + typename texture_type::size_type BaseLayer, typename texture_type::size_type MaxLayer, + typename texture_type::size_type BaseFace, typename texture_type::size_type MaxFace, + typename texture_type::size_type BaseLevel, typename texture_type::size_type MaxLevel, + filter Min + ) + { + typedef typename detail::interpolate::type interpolate_type; + typedef typename texture_type::extent_type extent_type; + typedef typename texture_type::size_type size_type; + typedef typename extent_type::value_type component_type; + typedef typename detail::filterBase::filterFunc filter_func; + + filter_func const Filter = detail::get_filter(FILTER_NEAREST, Min, false); + GLI_ASSERT(Filter); + + for(size_type Layer = BaseLayer; Layer <= MaxLayer; ++Layer) + for(size_type Face = BaseFace; Face <= MaxFace; ++Face) + for(size_type Level = BaseLevel; Level < MaxLevel; ++Level) + { + extent_type const& ExtentDst = Texture.extent(Level + 1); + normalized_type const& Scale = normalized_type(1) / normalized_type(max(ExtentDst - extent_type(1), extent_type(1))); + + for(component_type k = 0; k < ExtentDst.z; ++k) + for(component_type j = 0; j < ExtentDst.y; ++j) + for(component_type i = 0; i < ExtentDst.x; ++i) + { + normalized_type const& SamplePosition(normalized_type(i, j, k) * Scale); + texel_type const& Texel = Filter(Texture, Fetch, SamplePosition, Layer, Face, static_cast(Level), texel_type(0)); + Write(Texture, extent_type(i, j, k), Layer, Face, Level + 1, Texel); + } + } + } +}//namespace detail +}//namespace gli diff --git a/test/external/gli/core/operation.hpp b/test/external/gli/core/operation.hpp deleted file mode 100644 index c23c29d7..00000000 --- a/test/external/gli/core/operation.hpp +++ /dev/null @@ -1,82 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////// -// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net) -/////////////////////////////////////////////////////////////////////////////////////////////////// -// Created : 2008-12-19 -// Updated : 2010-01-09 -// Licence : This source is under MIT License -// File : gli/operation.hpp -/////////////////////////////////////////////////////////////////////////////////////////////////// - -#ifndef GLI_OPERATION_INCLUDED -#define GLI_OPERATION_INCLUDED - -#include "texture2d.hpp" - -namespace gli -{ - texture2D duplicate(texture2D const & Texture); - texture2D flip(texture2D const & Texture); - texture2D mirror(texture2D const & Texture); - texture2D swizzle( - texture2D const & Texture, - glm::uvec4 const & Channel); - texture2D crop( - texture2D const & Texture, - texture2D::dimensions_type const & Position, - texture2D::dimensions_type const & Size); - - image2D crop( - image2D const & Image, - texture2D::dimensions_type const & Position, - texture2D::dimensions_type const & Size); - - image2D copy( - image2D const & SrcImage, - image2D::dimensions_type const & SrcPosition, - image2D::dimensions_type const & SrcSize, - image2D & DstImage, - image2D::dimensions_type const & DstPosition); - - //image operator+(image const & MipmapA, image const & MipmapB); - //image operator-(image const & MipmapA, image const & MipmapB); - //image operator*(image const & MipmapA, image const & MipmapB); - //image operator/(image const & MipmapA, image const & MipmapB); - - //namespace wip - //{ - // template class SURFACE> - // GENTYPE fetch(SURFACE const & Image) - // { - // return GENTYPE(); - // } - - // template - // < - // typename GENTYPE, - // template - // < - // typename - // > - // class SURFACE, - // template - // < - // typename, - // template - // < - // typename - // > - // class - // > - // class IMAGE - // > - // GENTYPE fetch(IMAGE const & Image) - // { - // return GENTYPE(); - // } - //}//namespace wip - -}//namespace gli - -#include "operation.inl" - -#endif//GLI_OPERATION_INCLUDED diff --git a/test/external/gli/core/operation.inl b/test/external/gli/core/operation.inl deleted file mode 100644 index ef3394ef..00000000 --- a/test/external/gli/core/operation.inl +++ /dev/null @@ -1,233 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////// -// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net) -/////////////////////////////////////////////////////////////////////////////////////////////////// -// Created : 2008-12-19 -// Updated : 2010-09-08 -// Licence : This source is under MIT License -// File : gli/core/operation.inl -/////////////////////////////////////////////////////////////////////////////////////////////////// - -#include - -namespace gli -{ - namespace detail - { - inline image2D duplicate(image2D const & Mipmap2D) - { - image2D Result(Mipmap2D.dimensions(), Mipmap2D.format()); - memcpy(Result.data(), Mipmap2D.data(), Mipmap2D.capacity()); - return Result; - } - - inline image2D flip(image2D const & Mipmap2D) - { - image2D Result(Mipmap2D.dimensions(), Mipmap2D.format()); - - std::size_t ValueSize = Result.value_size(); - glm::byte * DstPtr = Result.data(); - glm::byte const * const SrcPtr = Mipmap2D.data(); - - for(std::size_t j = 0; j < Result.dimensions().y; ++j) - for(std::size_t i = 0; i < Result.dimensions().x; ++i) - { - std::size_t DstIndex = (i + j * Result.dimensions().y) * ValueSize; - std::size_t SrcIndex = (i + (Result.dimensions().y - j) * Result.dimensions().x) * ValueSize; - memcpy(DstPtr + DstIndex, SrcPtr + SrcIndex, ValueSize); - } - - return Result; - } - - inline image2D mirror(image2D const & Mipmap2D) - { - image2D Result(Mipmap2D.dimensions(), Mipmap2D.format()); - - std::size_t ValueSize = Mipmap2D.value_size(); - glm::byte * DstPtr = Result.data(); - glm::byte const * const SrcPtr = Mipmap2D.data(); - - for(std::size_t j = 0; j < Result.dimensions().y; ++j) - for(std::size_t i = 0; i < Result.dimensions().x; ++i) - { - std::size_t DstIndex = (i + j * Result.dimensions().x) * ValueSize; - std::size_t SrcIndex = ((Result.dimensions().x - i) + j * Result.dimensions().x) * ValueSize; - memcpy(DstPtr + DstIndex, SrcPtr + SrcIndex, ValueSize); - } - - return Result; - } - - inline image2D swizzle - ( - image2D const & Mipmap, - glm::uvec4 const & Channel - ) - { - image2D Result = detail::duplicate(Mipmap); - - glm::byte * DataDst = Result.data(); - glm::byte const * const DataSrc = Mipmap.data(); - - gli::texture2D::size_type CompSize = Mipmap.value_size() / Mipmap.components(); - gli::texture2D::size_type TexelCount = Mipmap.capacity() / Mipmap.value_size(); - - for(gli::texture2D::size_type t = 0; t < TexelCount; ++t) - for(gli::texture2D::size_type c = 0; c < Mipmap.components(); ++c) - { - gli::texture2D::size_type IndexSrc = t * Mipmap.components() + Channel[static_cast(c)]; - gli::texture2D::size_type IndexDst = t * Mipmap.components() + c; - - memcpy(DataDst + IndexDst, DataSrc + IndexSrc, CompSize); - } - - return Result; - } - - inline image2D crop - ( - image2D const & Image, - image2D::dimensions_type const & Position, - image2D::dimensions_type const & Size - ) - { - assert((Position.x + Size.x) <= Image.dimensions().x && (Position.y + Size.y) <= Image.dimensions().y); - - image2D Result(Size, Image.format()); - - glm::byte* DstData = Result.data(); - glm::byte const * const SrcData = Image.data(); - - for(std::size_t j = 0; j < Size.y; ++j) - { - std::size_t DstIndex = 0 + (0 + j) * Size.x * Image.value_size(); - std::size_t SrcIndex = Position.x * Image.value_size() + (Position.y + j) * Image.dimensions().x * Image.value_size(); - memcpy(DstData + DstIndex, SrcData + SrcIndex, Image.value_size() * Size.x); - } - - return Result; - } - - inline image2D copy - ( - image2D const & SrcMipmap, - image2D::dimensions_type const & SrcPosition, - image2D::dimensions_type const & SrcSize, - image2D & DstMipmap, - image2D::dimensions_type const & DstPosition - ) - { - assert((SrcPosition.x + SrcSize.x) <= SrcMipmap.dimensions().x && (SrcPosition.y + SrcSize.y) <= SrcMipmap.dimensions().y); - assert(SrcMipmap.format() == DstMipmap.format()); - - glm::byte * DstData = DstMipmap.data(); - glm::byte const * const SrcData = SrcMipmap.data(); - - std::size_t SizeX = glm::min(std::size_t(SrcSize.x + SrcPosition.x), std::size_t(DstMipmap.dimensions().x + DstPosition.x)); - std::size_t SizeY = glm::min(std::size_t(SrcSize.y + SrcPosition.y), std::size_t(DstMipmap.dimensions().y + DstPosition.y)); - - for(std::size_t j = 0; j < SizeY; ++j) - { - std::size_t DstIndex = DstPosition.x * DstMipmap.value_size() + (DstPosition.y + j) * DstMipmap.dimensions().x * DstMipmap.value_size(); - std::size_t SrcIndex = SrcPosition.x * SrcMipmap.value_size() + (SrcPosition.y + j) * SrcMipmap.dimensions().x * SrcMipmap.value_size(); - memcpy(DstData + DstIndex, SrcData + SrcIndex, SrcMipmap.value_size() * SizeX); - } - - return DstMipmap; - } - - }//namespace detail - - inline texture2D duplicate(texture2D const & Texture2D) - { - texture2D Result(Texture2D.levels()); - for(texture2D::level_type Level = 0; Level < Texture2D.levels(); ++Level) - Result[Level] = detail::duplicate(Texture2D[Level]); - return Result; - } - - inline texture2D flip(texture2D const & Texture2D) - { - texture2D Result(Texture2D.levels()); - for(texture2D::level_type Level = 0; Level < Texture2D.levels(); ++Level) - Result[Level] = detail::flip(Texture2D[Level]); - return Result; - } - - inline texture2D mirror(texture2D const & Texture2D) - { - texture2D Result(Texture2D.levels()); - for(texture2D::level_type Level = 0; Level < Texture2D.levels(); ++Level) - Result[Level] = detail::mirror(Texture2D[Level]); - return Result; - } - - inline texture2D crop - ( - texture2D const & Texture2D, - texture2D::dimensions_type const & Position, - texture2D::dimensions_type const & Size - ) - { - texture2D Result(Texture2D.levels()); - for(texture2D::level_type Level = 0; Level < Texture2D.levels(); ++Level) - Result[Level] = detail::crop( - Texture2D[Level], - Position >> texture2D::dimensions_type(Level), - Size >> texture2D::dimensions_type(Level)); - return Result; - } - - inline texture2D swizzle - ( - texture2D const & Texture2D, - glm::uvec4 const & Channel - ) - { - texture2D Result(Texture2D.levels()); - for(texture2D::level_type Level = 0; Level < Texture2D.levels(); ++Level) - Result[Level] = detail::swizzle(Texture2D[Level], Channel); - return Result; - } - - inline texture2D copy - ( - texture2D const & SrcImage, - texture2D::level_type const & SrcLevel, - texture2D::dimensions_type const & SrcPosition, - texture2D::dimensions_type const & SrcDimensions, - texture2D & DstMipmap, - texture2D::level_type const & DstLevel, - texture2D::dimensions_type const & DstDimensions - ) - { - detail::copy( - SrcImage[SrcLevel], - SrcPosition, - SrcDimensions, - DstMipmap[DstLevel], - DstDimensions); - return DstMipmap; - } - - //inline image operator+(image const & MipmapA, image const & MipmapB) - //{ - // - //} - - //inline image operator-(image const & MipmapA, image const & MipmapB) - //{ - // - //} - - //inline image operator*(image const & MipmapA, image const & MipmapB) - //{ - // - //} - - //inline image operator/(image const & MipmapA, image const & MipmapB) - //{ - // - //} - -}//namespace gli diff --git a/test/external/gli/core/operator.hpp b/test/external/gli/core/operator.hpp deleted file mode 100644 index 46f27321..00000000 --- a/test/external/gli/core/operator.hpp +++ /dev/null @@ -1,28 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////// -// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net) -/////////////////////////////////////////////////////////////////////////////////////////////////// -// Created : 2010-01-19 -// Updated : 2010-01-19 -// Licence : This source is under MIT License -// File : gli/core/operator.hpp -/////////////////////////////////////////////////////////////////////////////////////////////////// - -#ifndef GLI_OPERATOR_INCLUDED -#define GLI_OPERATOR_INCLUDED - -#include "texture2d.hpp" - -namespace gli{ -namespace detail -{ - -}//namespace detail - - texture2D operator+(texture2D const & TextureA, texture2D const & TextureB); - texture2D operator-(texture2D const & TextureA, texture2D const & TextureB); - -}//namespace gli - -#include "operator.inl" - -#endif//GLI_OPERATOR_INCLUDED diff --git a/test/external/gli/core/operator.inl b/test/external/gli/core/operator.inl deleted file mode 100644 index 1ac83281..00000000 --- a/test/external/gli/core/operator.inl +++ /dev/null @@ -1,210 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////// -// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net) -/////////////////////////////////////////////////////////////////////////////////////////////////// -// Created : 2010-01-19 -// Updated : 2010-01-19 -// Licence : This source is under MIT License -// File : gli/core/operator.inl -/////////////////////////////////////////////////////////////////////////////////////////////////// - -namespace gli -{ - namespace detail - { - template - void element - ( - T & DataDst, - T const & DataSrcA, - T const & DataSrcB, - std::binary_function const & Func - ) - { - *DataDst = Func(DataSrcA, DataSrcB); - } - - void op - ( - texture2D::value_type * DataDst, - texture2D::value_type const * const DataSrcA, - texture2D::value_type const * const DataSrcB, - format Format - ) - { - std::plus<>() - switch(Format) - { - case R8U: - *((glm::u8*)DataDst) = *((glm::u8*)DataSrcA) + *((glm::u8*)DataSrcB); - break; - case RG8U: - *((glm::u8vec2*)DataDst) = *((glm::u8vec2*)DataSrcA) + *((glm::u8vec2*)DataSrcB); - break; - case RGB8U: - *((glm::u8vec3*)DataDst) = *((glm::u8vec3*)DataSrcA) + *((glm::u8vec3*)DataSrcB); - break; - case RGBA8U: - *((glm::u8vec4*)DataDst) = *((glm::u8vec4*)DataSrcA) + *((glm::u8vec4*)DataSrcB); - break; - - case R16U: - *((glm::u16*)DataDst) = *((glm::u16*)DataSrcA) + *((glm::u16*)DataSrcB); - break; - case RG16U: - *((glm::u16vec2*)DataDst) = *((glm::u16vec2*)DataSrcA) + *((glm::u16vec2*)DataSrcB); - break; - case RGB16U: - *((glm::u16vec3*)DataDst) = *((glm::u16vec3*)DataSrcA) + *((glm::u16vec3*)DataSrcB); - break; - case RGBA16U: - *((glm::u16vec4*)DataDst) = *((glm::u16vec4*)DataSrcA) + *((glm::u16vec4*)DataSrcB); - break; - - case R32U: - *((glm::u32*)DataDst) = *((glm::u32*)DataSrcA) + *((glm::u32*)DataSrcB); - break; - case RG32U: - *((glm::u32vec2*)DataDst) = *((glm::u32vec2*)DataSrcA) + *((glm::u32vec2*)DataSrcB); - break; - case RGB32U: - *((glm::u32vec3*)DataDst) = *((glm::u32vec3*)DataSrcA) + *((glm::u32vec3*)DataSrcB); - break; - case RGBA32U: - *((glm::u32vec4*)DataDst) = *((glm::u32vec4*)DataSrcA) + *((glm::u32vec4*)DataSrcB); - break; - - case R8I: - *((glm::i8*)DataDst) = *((glm::i8*)DataSrcA) + *((glm::i8*)DataSrcB); - break; - case RG8I: - *((glm::i8vec2*)DataDst) = *((glm::i8vec2*)DataSrcA) + *((glm::i8vec2*)DataSrcB); - break; - case RGB8I: - *((glm::i8vec3*)DataDst) = *((glm::i8vec3*)DataSrcA) + *((glm::i8vec3*)DataSrcB); - break; - case RGBA8I: - *((glm::i8vec4*)DataDst) = *((glm::i8vec4*)DataSrcA) + *((glm::i8vec4*)DataSrcB); - break; - - case R16I: - *((glm::i16*)DataDst) = *((glm::i16*)DataSrcA) + *((glm::i16*)DataSrcB); - break; - case RG16I: - *((glm::i16vec2*)DataDst) = *((glm::i16vec2*)DataSrcA) + *((glm::i16vec2*)DataSrcB); - break; - case RGB16I: - *((glm::i16vec3*)DataDst) = *((glm::i16vec3*)DataSrcA) + *((glm::i16vec3*)DataSrcB); - break; - case RGBA16I: - *((glm::i16vec4*)DataDst) = *((glm::i16vec4*)DataSrcA) + *((glm::i16vec4*)DataSrcB); - break; - - case R32I: - *((glm::i32*)DataDst) = *((glm::i32*)DataSrcA) + *((glm::i32*)DataSrcB); - break; - case RG32I: - *((glm::i32vec2*)DataDst) = *((glm::i32vec2*)DataSrcA) + *((glm::i32vec2*)DataSrcB); - break; - case RGB32I: - *((glm::i32vec3*)DataDst) = *((glm::i32vec3*)DataSrcA) + *((glm::i32vec3*)DataSrcB); - break; - case RGBA32I: - *((glm::i32vec4*)DataDst) = *((glm::i32vec4*)DataSrcA) + *((glm::i32vec4*)DataSrcB); - break; - - case R16F: - *((glm::f16*)DataDst) = *((glm::f16*)DataSrcA) + *((glm::f16*)DataSrcB); - break; - case RG16F: - *((glm::f16vec2*)DataDst) = *((glm::f16vec2*)DataSrcA) + *((glm::f16vec2*)DataSrcB); - break; - case RGB16F: - *((glm::f16vec3*)DataDst) = *((glm::f16vec3*)DataSrcA) + *((glm::f16vec3*)DataSrcB); - break; - case RGBA16F: - *((glm::f16vec4*)DataDst) = *((glm::f16vec4*)DataSrcA) + *((glm::f16vec4*)DataSrcB); - break; - - case R32F: - *((glm::f32*)DataDst) = *((glm::f32*)DataSrcA) + *((glm::f32*)DataSrcB); - break; - case RG32F: - *((glm::f32vec2*)DataDst) = *((glm::f32vec2*)DataSrcA) + *((glm::f32vec2*)DataSrcB); - break; - case RGB32F: - *((glm::f32vec3*)DataDst) = *((glm::f32vec3*)DataSrcA) + *((glm::f32vec3*)DataSrcB); - break; - case RGBA32F: - *((glm::f32vec4*)DataDst) = *((glm::f32vec4*)DataSrcA) + *((glm::f32vec4*)DataSrcB); - break; - default: - assert(0); - } - } - - void add - ( - texture2D::image & Result, - texture2D::image const & ImageA, - texture2D::image const & ImageB, - ) - { - - } - - }//namespace detail - - texture2D operator+ - ( - texture2D const & ImageA, - texture2D const & ImageB - ) - { - assert(ImageA.levels() == ImageB.levels()); - texture2D Result[ImageA.levels()]; - - for(texture2D::level_type Level = 0; Level < Result.levels(); ++Level) - { - assert(ImageA.capacity() == ImageB.capacity()); - assert(ImageA.format() == ImageB.format()); - - Result[Level] = texture2D::image(ImageA[Level].dimensions(), ImageA[Level].format()); - - add(Result[Level], ImageA[Level], ImageB[Level]); - - texture2D::size_type ValueSize = Result.value_size(); - texture2D::size_type TexelCount = this->capacity() / ValueSize; - for(texture2D::size_type Texel = 0; Texel < TexelCount; ++Texel) - { - texture2D::value_type * DataDst = Result[Level].data() + Texel * ValueSize; - texture2D::value_type const * const DataSrcA = ImageA[Level].data() + Texel * ValueSize; - texture2D::value_type const * const DataSrcB = ImageB[Level].data() + Texel * ValueSize; - - detail::op(DataDst, DataSrcA, DataSrcB, Result.format(), std::plus); - } - } - - return Result; - } - - texture2D operator- - ( - texture2D const & ImageA, - texture2D const & ImageB - ) - { - assert(ImageA.levels() == ImageB.levels()); - texture2D Result[ImageA.levels()]; - - - for(texture2D::level_type Level = 0; Level < ImageA.levels(); ++Level) - { - assert(ImageA.capacity() == ImageB.capacity()); - - - } - - return Result; - } - -}//namespace gli diff --git a/test/external/gli/core/reduce.inl b/test/external/gli/core/reduce.inl new file mode 100644 index 00000000..0830aa6b --- /dev/null +++ b/test/external/gli/core/reduce.inl @@ -0,0 +1,533 @@ +#include "../sampler1d.hpp" +#include "../sampler1d_array.hpp" +#include "../sampler2d.hpp" +#include "../sampler2d_array.hpp" +#include "../sampler3d.hpp" +#include "../sampler_cube.hpp" +#include "../sampler_cube_array.hpp" + +namespace gli +{ + template + struct binary_func + { + typedef tvec4(*type)(tvec4 const& A, tvec4 const& B); + }; + +namespace detail +{ + inline bool are_compatible(texture const& A, texture const& B) + { + return all(equal(A.extent(), B.extent())) && A.levels() == B.levels() && A.faces() == B.faces() && A.layers() == B.layers(); + } + + template + struct compute_sampler_reduce_1d + { + typedef typename binary_func::type func_type; + typedef texture1d::size_type size_type; + typedef texture1d::extent_type extent_type; + + static tvec4 call(texture1d const& A, texture1d const& B, binary_func TexelFunc, binary_func ReduceFunc) + { + GLI_ASSERT(are_compatible(A, B)); + + sampler1d const SamplerA(A, gli::WRAP_CLAMP_TO_EDGE), SamplerB(B, gli::WRAP_CLAMP_TO_EDGE); + extent_type TexelIndex(0); + tvec4 Result(TexelFunc(SamplerA.template fetch(TexelIndex, 0), SamplerB.template fetch(TexelIndex, 0))); + + for(size_type LevelIndex = 0, LevelCount = A.levels(); LevelIndex < LevelCount; ++LevelIndex) + { + extent_type const TexelCount(A.extent(LevelIndex)); + for(TexelIndex.x = 0; TexelIndex.x < TexelCount.x; ++TexelIndex.x) + { + Result = ReduceFunc(Result, TexelFunc( + SamplerA.template fetch(TexelIndex, LevelIndex), + SamplerB.template fetch(TexelIndex, LevelIndex))); + } + } + + return Result; + } + }; + + template + struct compute_sampler_reduce_1d_array + { + typedef typename binary_func::type func_type; + typedef texture1d_array::size_type size_type; + typedef texture1d_array::extent_type extent_type; + + static tvec4 call(texture1d_array const& A, texture1d_array const& B, binary_func TexelFunc, binary_func ReduceFunc) + { + GLI_ASSERT(are_compatible(A, B)); + + sampler1d_array const SamplerA(A, gli::WRAP_CLAMP_TO_EDGE), SamplerB(B, gli::WRAP_CLAMP_TO_EDGE); + extent_type TexelIndex(0); + tvec4 Result(TexelFunc(SamplerA.template fetch(TexelIndex, 0, 0), SamplerB.template fetch(TexelIndex, 0, 0))); + + for(size_type LayerIndex = 0, LayerCount = A.layers(); LayerIndex < LayerCount; ++LayerIndex) + for(size_type LevelIndex = 0, LevelCount = A.levels(); LevelIndex < LevelCount; ++LevelIndex) + { + extent_type const TexelCount(A.extent(LevelIndex)); + for(TexelIndex.x = 0; TexelIndex.x < TexelCount.x; ++TexelIndex.x) + { + Result = ReduceFunc(Result, TexelFunc( + SamplerA.template fetch(TexelIndex, LayerIndex, LevelIndex), + SamplerB.template fetch(TexelIndex, LayerIndex, LevelIndex))); + } + } + + return Result; + } + }; + + template + struct compute_sampler_reduce_2d + { + typedef typename binary_func::type func_type; + typedef texture2d::size_type size_type; + typedef texture2d::extent_type extent_type; + + static tvec4 call(texture2d const& A, texture2d const& B, binary_func TexelFunc, binary_func ReduceFunc) + { + GLI_ASSERT(are_compatible(A, B)); + + sampler2d const SamplerA(A, gli::WRAP_CLAMP_TO_EDGE), SamplerB(B, gli::WRAP_CLAMP_TO_EDGE); + extent_type TexelIndex(0); + tvec4 Result(TexelFunc(SamplerA.template fetch(TexelIndex, 0), SamplerB.template fetch(TexelIndex, 0))); + + for(size_type LevelIndex = 0, LevelCount = A.levels(); LevelIndex < LevelCount; ++LevelIndex) + { + extent_type const TexelCount(A.extent(LevelIndex)); + for(TexelIndex.y = 0; TexelIndex.y < TexelCount.y; ++TexelIndex.y) + for(TexelIndex.x = 0; TexelIndex.x < TexelCount.x; ++TexelIndex.x) + { + Result = ReduceFunc(Result, TexelFunc( + SamplerA.template fetch(TexelIndex, LevelIndex), + SamplerB.template fetch(TexelIndex, LevelIndex))); + } + } + + return Result; + } + }; + + template + struct compute_sampler_reduce_2d_array + { + typedef typename binary_func::type func_type; + typedef texture2d_array::size_type size_type; + typedef texture2d_array::extent_type extent_type; + + static tvec4 call(texture2d_array const& A, texture2d_array const& B, binary_func TexelFunc, binary_func ReduceFunc) + { + GLI_ASSERT(are_compatible(A, B)); + + sampler2d_array const SamplerA(A, gli::WRAP_CLAMP_TO_EDGE), SamplerB(B, gli::WRAP_CLAMP_TO_EDGE); + extent_type TexelIndex(0); + tvec4 Result(TexelFunc(SamplerA.template fetch(TexelIndex, 0, 0), SamplerB.template fetch(TexelIndex, 0, 0))); + + for(size_type LayerIndex = 0, LayerCount = A.layers(); LayerIndex < LayerCount; ++LayerIndex) + for(size_type LevelIndex = 0, LevelCount = A.levels(); LevelIndex < LevelCount; ++LevelIndex) + { + extent_type const TexelCount(A.extent(LevelIndex)); + for(TexelIndex.y = 0; TexelIndex.y < TexelCount.y; ++TexelIndex.y) + for(TexelIndex.x = 0; TexelIndex.x < TexelCount.x; ++TexelIndex.x) + { + Result = ReduceFunc(Result, TexelFunc( + SamplerA.template fetch(TexelIndex, LayerIndex, LevelIndex), + SamplerB.template fetch(TexelIndex, LayerIndex, LevelIndex))); + } + } + + return Result; + } + }; + + template + struct compute_sampler_reduce_3d + { + typedef typename binary_func::type func_type; + typedef texture3d::size_type size_type; + typedef texture3d::extent_type extent_type; + + static tvec4 call(texture3d const& A, texture3d const& B, binary_func TexelFunc, binary_func ReduceFunc) + { + GLI_ASSERT(are_compatible(A, B)); + + sampler3d const SamplerA(A, gli::WRAP_CLAMP_TO_EDGE), SamplerB(B, gli::WRAP_CLAMP_TO_EDGE); + extent_type TexelIndex(0); + tvec4 Result(TexelFunc(SamplerA.template fetch(TexelIndex, 0), SamplerB.template fetch(TexelIndex, 0))); + + for(size_type LevelIndex = 0, LevelCount = A.levels(); LevelIndex < LevelCount; ++LevelIndex) + { + extent_type const TexelCount(A.extent(LevelIndex)); + for(TexelIndex.z = 0; TexelIndex.z < TexelCount.z; ++TexelIndex.z) + for(TexelIndex.y = 0; TexelIndex.y < TexelCount.y; ++TexelIndex.y) + for(TexelIndex.x = 0; TexelIndex.x < TexelCount.x; ++TexelIndex.x) + { + Result = ReduceFunc(Result, TexelFunc( + SamplerA.template fetch(TexelIndex, LevelIndex), + SamplerB.template fetch(TexelIndex, LevelIndex))); + } + } + + return Result; + } + }; + + template + struct compute_sampler_reduce_cube + { + typedef typename binary_func::type func_type; + typedef texture_cube::size_type size_type; + typedef texture_cube::extent_type extent_type; + + static tvec4 call(texture_cube const& A, texture_cube const& B, binary_func TexelFunc, binary_func ReduceFunc) + { + GLI_ASSERT(are_compatible(A, B)); + + sampler_cube const SamplerA(A, gli::WRAP_CLAMP_TO_EDGE), SamplerB(B, gli::WRAP_CLAMP_TO_EDGE); + extent_type TexelIndex(0); + tvec4 Result(TexelFunc(SamplerA.template fetch(TexelIndex, 0, 0), SamplerB.template fetch(TexelIndex, 0, 0))); + + for(size_type FaceIndex = 0, FaceCount = A.faces(); FaceIndex < FaceCount; ++FaceIndex) + for(size_type LevelIndex = 0, LevelCount = A.levels(); LevelIndex < LevelCount; ++LevelIndex) + { + extent_type const TexelCount(A.extent(LevelIndex)); + for(TexelIndex.y = 0; TexelIndex.y < TexelCount.y; ++TexelIndex.y) + for(TexelIndex.x = 0; TexelIndex.x < TexelCount.x; ++TexelIndex.x) + { + Result = ReduceFunc(Result, TexelFunc( + SamplerA.template fetch(TexelIndex, FaceIndex, LevelIndex), + SamplerB.template fetch(TexelIndex, FaceIndex, LevelIndex))); + } + } + + return Result; + } + }; + + template + struct compute_sampler_reduce_cube_array + { + typedef typename binary_func::type func_type; + typedef texture_cube_array::size_type size_type; + typedef texture_cube_array::extent_type extent_type; + + static tvec4 call(texture_cube_array const& A, texture_cube_array const& B, binary_func TexelFunc, binary_func ReduceFunc) + { + GLI_ASSERT(are_compatible(A, B)); + + sampler_cube_array const SamplerA(A, gli::WRAP_CLAMP_TO_EDGE), SamplerB(B, gli::WRAP_CLAMP_TO_EDGE); + extent_type TexelIndex(0); + tvec4 Result(TexelFunc(SamplerA.template fetch(TexelIndex, 0, 0, 0), SamplerB.template fetch(TexelIndex, 0, 0, 0))); + + for(size_type LayerIndex = 0, LayerCount = A.layers(); LayerIndex < LayerCount; ++LayerIndex) + for(size_type FaceIndex = 0, FaceCount = A.faces(); FaceIndex < FaceCount; ++FaceIndex) + for(size_type LevelIndex = 0, LevelCount = A.levels(); LevelIndex < LevelCount; ++LevelIndex) + { + extent_type const TexelCount(A.extent(LevelIndex)); + for(TexelIndex.y = 0; TexelIndex.y < TexelCount.y; ++TexelIndex.y) + for(TexelIndex.x = 0; TexelIndex.x < TexelCount.x; ++TexelIndex.x) + { + Result = ReduceFunc(Result, TexelFunc( + SamplerA.template fetch(TexelIndex, LayerIndex, FaceIndex, LevelIndex), + SamplerB.template fetch(TexelIndex, LayerIndex, FaceIndex, LevelIndex))); + } + } + + return Result; + } + }; +}//namespace detail + +namespace detail +{ + template + struct compute_reduce_1d + { + typedef typename reduce_func::type func_type; + typedef texture1d::size_type size_type; + typedef texture1d::extent_type extent_type; + + static vec_type call(texture1d const& A, texture1d const& B, func_type TexelFunc, func_type ReduceFunc) + { + GLI_ASSERT(all(equal(A.extent(), B.extent()))); + GLI_ASSERT(A.levels() == B.levels()); + GLI_ASSERT(A.size() == B.size()); + + extent_type TexelIndex(0); + vec_type Result(TexelFunc( + A.template load(TexelIndex, 0), + B.template load(TexelIndex, 0))); + + for(size_type LevelIndex = 0, LevelCount = A.levels(); LevelIndex < LevelCount; ++LevelIndex) + { + extent_type const TexelCount(A.extent(LevelIndex)); + for(TexelIndex.x = 0; TexelIndex.x < TexelCount.x; ++TexelIndex.x) + { + Result = ReduceFunc(Result, TexelFunc( + A.template load(TexelIndex, LevelIndex), + B.template load(TexelIndex, LevelIndex))); + } + } + + return Result; + } + }; + + template + struct compute_reduce_1d_array + { + typedef typename reduce_func::type func_type; + typedef texture1d_array::size_type size_type; + typedef texture1d_array::extent_type extent_type; + + static vec_type call(texture1d_array const& A, texture1d_array const& B, func_type TexelFunc, func_type ReduceFunc) + { + GLI_ASSERT(all(equal(A.extent(), B.extent()))); + GLI_ASSERT(A.levels() == B.levels()); + GLI_ASSERT(A.size() == B.size()); + + extent_type TexelIndex(0); + vec_type Result(TexelFunc( + A.template load(TexelIndex, 0), + B.template load(TexelIndex, 0))); + + for(size_type LayerIndex = 0, LayerCount = A.layers(); LayerIndex < LayerCount; ++LayerIndex) + for(size_type LevelIndex = 0, LevelCount = A.levels(); LevelIndex < LevelCount; ++LevelIndex) + { + extent_type const TexelCount(A.extent(LevelIndex)); + for(TexelIndex.x = 0; TexelIndex.x < TexelCount.x; ++TexelIndex.x) + { + Result = ReduceFunc(Result, TexelFunc( + A.template load(TexelIndex, LayerIndex, LevelIndex), + B.template load(TexelIndex, LayerIndex, LevelIndex))); + } + } + + return Result; + } + }; + + template + struct compute_reduce_2d + { + typedef typename reduce_func::type func_type; + typedef texture2d::size_type size_type; + typedef texture2d::extent_type extent_type; + + static vec_type call(texture2d const& A, texture2d const& B, func_type TexelFunc, func_type ReduceFunc) + { + GLI_ASSERT(all(equal(A.extent(), B.extent()))); + GLI_ASSERT(A.levels() == B.levels()); + GLI_ASSERT(A.size() == B.size()); + + extent_type TexelIndex(0); + vec_type Result(TexelFunc( + A.template load(TexelIndex, 0), + B.template load(TexelIndex, 0))); + + for(size_type LevelIndex = 0, LevelCount = A.levels(); LevelIndex < LevelCount; ++LevelIndex) + { + extent_type const TexelCount(A.extent(LevelIndex)); + for(TexelIndex.y = 0; TexelIndex.y < TexelCount.y; ++TexelIndex.y) + for(TexelIndex.x = 0; TexelIndex.x < TexelCount.x; ++TexelIndex.x) + { + Result = ReduceFunc(Result, TexelFunc( + A.template load(TexelIndex, LevelIndex), + B.template load(TexelIndex, LevelIndex))); + } + } + + return Result; + } + }; + + template + struct compute_reduce_2d_array + { + typedef typename reduce_func::type func_type; + typedef texture2d_array::size_type size_type; + typedef texture2d_array::extent_type extent_type; + + static vec_type call(texture2d_array const& A, texture2d_array const& B, func_type TexelFunc, func_type ReduceFunc) + { + GLI_ASSERT(all(equal(A.extent(), B.extent()))); + GLI_ASSERT(A.levels() == B.levels()); + GLI_ASSERT(A.size() == B.size()); + + extent_type TexelIndex(0); + vec_type Result(TexelFunc( + A.template load(TexelIndex, 0, 0), + B.template load(TexelIndex, 0, 0))); + + for(size_type LayerIndex = 0, LayerCount = A.layers(); LayerIndex < LayerCount; ++LayerIndex) + for(size_type LevelIndex = 0, LevelCount = A.levels(); LevelIndex < LevelCount; ++LevelIndex) + { + extent_type const TexelCount(A.extent(LevelIndex)); + for(TexelIndex.y = 0; TexelIndex.y < TexelCount.y; ++TexelIndex.y) + for(TexelIndex.x = 0; TexelIndex.x < TexelCount.x; ++TexelIndex.x) + { + Result = ReduceFunc(Result, TexelFunc( + A.template load(TexelIndex, LayerIndex, LevelIndex), + B.template load(TexelIndex, LayerIndex, LevelIndex))); + } + } + + return Result; + } + }; + + template + struct compute_reduce_3d + { + typedef typename reduce_func::type func_type; + typedef texture3d::size_type size_type; + typedef texture3d::extent_type extent_type; + + static vec_type call(texture3d const& A, texture3d const& B, func_type TexelFunc, func_type ReduceFunc) + { + GLI_ASSERT(all(equal(A.extent(), B.extent()))); + GLI_ASSERT(A.levels() == B.levels()); + GLI_ASSERT(A.size() == B.size()); + + extent_type TexelIndex(0); + vec_type Result(TexelFunc( + A.template load(TexelIndex, 0), + B.template load(TexelIndex, 0))); + + for(size_type LevelIndex = 0, LevelCount = A.levels(); LevelIndex < LevelCount; ++LevelIndex) + { + extent_type const TexelCount(A.extent(LevelIndex)); + for(TexelIndex.z = 0; TexelIndex.z < TexelCount.z; ++TexelIndex.z) + for(TexelIndex.y = 0; TexelIndex.y < TexelCount.y; ++TexelIndex.y) + for(TexelIndex.x = 0; TexelIndex.x < TexelCount.x; ++TexelIndex.x) + { + Result = ReduceFunc(Result, TexelFunc( + A.template load(TexelIndex, LevelIndex), + B.template load(TexelIndex, LevelIndex))); + } + } + + return Result; + } + }; + + template + struct compute_reduce_cube + { + typedef typename reduce_func::type func_type; + typedef texture_cube::size_type size_type; + typedef texture_cube::extent_type extent_type; + + static vec_type call(texture_cube const& A, texture_cube const& B, func_type TexelFunc, func_type ReduceFunc) + { + GLI_ASSERT(all(equal(A.extent(), B.extent()))); + GLI_ASSERT(A.levels() == B.levels()); + GLI_ASSERT(A.size() == B.size()); + + extent_type TexelIndex(0); + vec_type Result(TexelFunc( + A.load(TexelIndex, 0, 0), + B.load(TexelIndex, 0, 0))); + + for(size_type FaceIndex = 0, FaceCount = A.faces(); FaceIndex < FaceCount; ++FaceIndex) + for(size_type LevelIndex = 0, LevelCount = A.levels(); LevelIndex < LevelCount; ++LevelIndex) + { + extent_type const TexelCount(A.extent(LevelIndex)); + for(TexelIndex.y = 0; TexelIndex.y < TexelCount.y; ++TexelIndex.y) + for(TexelIndex.x = 0; TexelIndex.x < TexelCount.x; ++TexelIndex.x) + { + Result = ReduceFunc(Result, TexelFunc( + A.template load(TexelIndex, FaceIndex, LevelIndex), + B.template load(TexelIndex, FaceIndex, LevelIndex))); + } + } + + return Result; + } + }; + + template + struct compute_reduce_cube_array + { + typedef typename reduce_func::type func_type; + typedef texture_cube_array::size_type size_type; + typedef texture_cube_array::extent_type extent_type; + + static vec_type call(texture_cube_array const& A, texture_cube_array const& B, func_type TexelFunc, func_type ReduceFunc) + { + GLI_ASSERT(all(equal(A.extent(), B.extent()))); + GLI_ASSERT(A.levels() == B.levels()); + GLI_ASSERT(A.size() == B.size()); + + extent_type TexelIndex(0); + vec_type Result(TexelFunc( + A.load(TexelIndex, 0, 0, 0), + B.load(TexelIndex, 0, 0 ,0))); + + for(size_type LayerIndex = 0, LayerCount = A.layers(); LayerIndex < LayerCount; ++LayerIndex) + for(size_type FaceIndex = 0, FaceCount = A.faces(); FaceIndex < FaceCount; ++FaceIndex) + for(size_type LevelIndex = 0, LevelCount = A.levels(); LevelIndex < LevelCount; ++LevelIndex) + { + extent_type const TexelCount(A.extent(LevelIndex)); + for(TexelIndex.y = 0; TexelIndex.y < TexelCount.y; ++TexelIndex.y) + for(TexelIndex.x = 0; TexelIndex.x < TexelCount.x; ++TexelIndex.x) + { + Result = ReduceFunc(Result, TexelFunc( + A.template load(TexelIndex, LayerIndex, FaceIndex, LevelIndex), + B.template load(TexelIndex, LayerIndex, FaceIndex, LevelIndex))); + } + } + + return Result; + } + }; +}//namepsace detail + +template +inline vec_type reduce(texture1d const& In0, texture1d const& In1, typename reduce_func::type TexelFunc, typename reduce_func::type ReduceFunc) +{ + return detail::compute_reduce_1d::call(In0, In1, TexelFunc, ReduceFunc); +} + +template +inline vec_type reduce(texture1d_array const& In0, texture1d_array const& In1, typename reduce_func::type TexelFunc, typename reduce_func::type ReduceFunc) +{ + return detail::compute_reduce_1d_array::call(In0, In1, TexelFunc, ReduceFunc); +} + +template +inline vec_type reduce(texture2d const& In0, texture2d const& In1, typename reduce_func::type TexelFunc, typename reduce_func::type ReduceFunc) +{ + return detail::compute_reduce_2d::call(In0, In1, TexelFunc, ReduceFunc); +} + +template +inline vec_type reduce(texture2d_array const& In0, texture2d_array const& In1, typename reduce_func::type TexelFunc, typename reduce_func::type ReduceFunc) +{ + return detail::compute_reduce_2d_array::call(In0, In1, TexelFunc, ReduceFunc); +} + +template +inline vec_type reduce(texture3d const& In0, texture3d const& In1, typename reduce_func::type TexelFunc, typename reduce_func::type ReduceFunc) +{ + return detail::compute_reduce_3d::call(In0, In1, TexelFunc, ReduceFunc); +} + +template +inline vec_type reduce(texture_cube const& In0, texture_cube const& In1, typename reduce_func::type TexelFunc, typename reduce_func::type ReduceFunc) +{ + return detail::compute_reduce_cube::call(In0, In1, TexelFunc, ReduceFunc); +} + +template +inline vec_type reduce(texture_cube_array const& In0, texture_cube_array const& In1, typename reduce_func::type TexelFunc, typename reduce_func::type ReduceFunc) +{ + return detail::compute_reduce_cube_array::call(In0, In1, TexelFunc, ReduceFunc); +} +}//namespace gli + diff --git a/test/external/gli/core/sampler.inl b/test/external/gli/core/sampler.inl new file mode 100644 index 00000000..bd73cc07 --- /dev/null +++ b/test/external/gli/core/sampler.inl @@ -0,0 +1,34 @@ +#include + +namespace gli{ +namespace detail +{ + template + inline T passThrought(T const & SampleCoord) + { + return SampleCoord; + } +}//namespace detail + + inline sampler::sampler(wrap Wrap, filter Mip, filter Min) + : Wrap(get_func(Wrap)) + , Mip(Mip) + , Min(Min) + {} + + inline sampler::wrap_type sampler::get_func(wrap WrapMode) const + { + static wrap_type Table[] = + { + glm::clamp, + detail::passThrought, + glm::repeat, + glm::mirrorRepeat, + glm::mirrorClamp, + glm::mirrorClamp + }; + static_assert(sizeof(Table) / sizeof(Table[0]) == WRAP_COUNT, "Table needs to be updated"); + + return Table[WrapMode]; + } +}//namespace gli diff --git a/test/external/gli/core/sampler1d.inl b/test/external/gli/core/sampler1d.inl new file mode 100644 index 00000000..c0fac39f --- /dev/null +++ b/test/external/gli/core/sampler1d.inl @@ -0,0 +1,82 @@ +#include "clear.hpp" +#include + +namespace gli +{ + template + inline sampler1d::sampler1d(texture_type const & Texture, wrap Wrap, filter Mip, filter Min, texel_type const & BorderColor) + : sampler(Wrap, Texture.levels() > 1 ? Mip : FILTER_NEAREST, Min) + , Texture(Texture) + , Convert(detail::convert::call(this->Texture.format())) + , BorderColor(BorderColor) + , Filter(detail::get_filter(Mip, Min, is_border(Wrap))) + { + GLI_ASSERT(!Texture.empty()); + GLI_ASSERT(!is_compressed(Texture.format())); + GLI_ASSERT((!std::numeric_limits::is_iec559 && Mip == FILTER_NEAREST && Min == FILTER_NEAREST) || std::numeric_limits::is_iec559); + } + + template + inline typename sampler1d::texture_type const & sampler1d::operator()() const + { + return this->Texture; + } + + template + inline typename sampler1d::texel_type sampler1d::texel_fetch(extent_type const & TexelCoord, size_type const & Level) const + { + GLI_ASSERT(!this->Texture.empty()); + GLI_ASSERT(this->Convert.Fetch); + + return this->Convert.Fetch(this->Texture, TexelCoord, 0, 0, Level); + } + + template + inline void sampler1d::texel_write(extent_type const & TexelCoord, size_type const & Level, texel_type const & Texel) + { + GLI_ASSERT(!this->Texture.empty()); + GLI_ASSERT(this->Convert.Write); + + this->Convert.Write(this->Texture, TexelCoord, 0, 0, Level, Texel); + } + + template + inline void sampler1d::clear(texel_type const & Color) + { + GLI_ASSERT(!this->Texture.empty()); + GLI_ASSERT(this->Convert.Write); + + detail::clear::call(this->Texture, this->Convert.Write, Color); + } + + template + inline typename sampler1d::texel_type sampler1d::texture_lod(normalized_type const & SampleCoord, level_type Level) const + { + GLI_ASSERT(!this->Texture.empty()); + GLI_ASSERT(std::numeric_limits::is_iec559); + GLI_ASSERT(this->Filter && this->Convert.Fetch); + + normalized_type const SampleCoordWrap(this->Wrap(SampleCoord.x)); + return this->Filter(this->Texture, this->Convert.Fetch, SampleCoordWrap, size_type(0), size_type(0), Level, this->BorderColor); + } + + template + inline void sampler1d::generate_mipmaps(filter Minification) + { + this->generate_mipmaps(this->Texture.base_level(), this->Texture.max_level(), Minification); + } + + template + inline void sampler1d::generate_mipmaps(size_type BaseLevel, size_type MaxLevel, filter Minification) + { + GLI_ASSERT(!this->Texture.empty()); + GLI_ASSERT(!is_compressed(this->Texture.format())); + GLI_ASSERT(this->Texture.base_level() <= BaseLevel && BaseLevel <= MaxLevel && MaxLevel <= this->Texture.max_level()); + GLI_ASSERT(this->Convert.Fetch && this->Convert.Write); + GLI_ASSERT(Minification >= FILTER_FIRST && Minification <= FILTER_LAST); + + detail::generate_mipmaps_1d( + this->Texture, this->Convert.Fetch, this->Convert.Write, 0, 0, 0, 0, BaseLevel, MaxLevel, Minification); + } +}//namespace gli + diff --git a/test/external/gli/core/sampler1d_array.inl b/test/external/gli/core/sampler1d_array.inl new file mode 100644 index 00000000..0f4b1c61 --- /dev/null +++ b/test/external/gli/core/sampler1d_array.inl @@ -0,0 +1,83 @@ +#include "clear.hpp" +#include + +namespace gli +{ + template + inline sampler1d_array::sampler1d_array(texture_type const & Texture, gli::wrap Wrap, filter Mip, filter Min, texel_type const & BorderColor) + : sampler(Wrap, Texture.levels() > 1 ? Mip : FILTER_NEAREST, Min) + , Texture(Texture) + , Convert(detail::convert::call(this->Texture.format())) + , BorderColor(BorderColor) + , Filter(detail::get_filter(Mip, Min, is_border(Wrap))) + { + GLI_ASSERT(!Texture.empty()); + GLI_ASSERT(!is_compressed(Texture.format())); + GLI_ASSERT((!std::numeric_limits::is_iec559 && Mip == FILTER_NEAREST && Min == FILTER_NEAREST) || std::numeric_limits::is_iec559); + } + + template + inline typename sampler1d_array::texture_type const & sampler1d_array::operator()() const + { + return this->Texture; + } + + template + inline typename sampler1d_array::texel_type sampler1d_array::texel_fetch(extent_type const & TexelCoord, size_type layer, size_type Level) const + { + GLI_ASSERT(!this->Texture.empty()); + GLI_ASSERT(this->Convert.Fetch); + + return this->Convert.Fetch(this->Texture, TexelCoord, layer, 0, Level); + } + + template + inline void sampler1d_array::texel_write(extent_type const & TexelCoord, size_type layer, size_type Level, texel_type const & Texel) + { + GLI_ASSERT(!this->Texture.empty()); + GLI_ASSERT(this->Convert.Write); + + this->Convert.Write(this->Texture, TexelCoord, layer, 0, Level, Texel); + } + + template + inline void sampler1d_array::clear(texel_type const & Color) + { + GLI_ASSERT(!this->Texture.empty()); + GLI_ASSERT(this->Convert.Write); + + detail::clear::call(this->Texture, this->Convert.Write, Color); + } + + template + inline typename sampler1d_array::texel_type sampler1d_array::texture_lod(normalized_type const & SampleCoord, size_type Layer, level_type Level) const + { + GLI_ASSERT(!this->Texture.empty()); + GLI_ASSERT(std::numeric_limits::is_iec559); + GLI_ASSERT(this->Filter && this->Convert.Fetch); + + normalized_type const SampleCoordWrap(this->Wrap(SampleCoord.x)); + return this->Filter(this->Texture, this->Convert.Fetch, SampleCoordWrap, Layer, size_type(0), Level, this->BorderColor); + } + + template + inline void sampler1d_array::generate_mipmaps(filter Minification) + { + this->generate_mipmaps(this->Texture.base_layer(), this->Texture.max_layer(), this->Texture.base_level(), this->Texture.max_level(), Minification); + } + + template + inline void sampler1d_array::generate_mipmaps(size_type BaseLayer, size_type MaxLayer, size_type BaseLevel, size_type MaxLevel, filter Minification) + { + GLI_ASSERT(!this->Texture.empty()); + GLI_ASSERT(!is_compressed(this->Texture.format())); + GLI_ASSERT(this->Texture.base_layer() <= BaseLayer && BaseLayer <= MaxLayer && MaxLayer <= this->Texture.max_layer()); + GLI_ASSERT(this->Texture.base_level() <= BaseLevel && BaseLevel <= MaxLevel && MaxLevel <= this->Texture.max_level()); + GLI_ASSERT(this->Convert.Fetch && this->Convert.Write); + GLI_ASSERT(Minification >= FILTER_FIRST && Minification <= FILTER_LAST); + + detail::generate_mipmaps_1d( + this->Texture, this->Convert.Fetch, this->Convert.Write, BaseLayer, MaxLayer, 0, 0, BaseLevel, MaxLevel, Minification); + } +}//namespace gli + diff --git a/test/external/gli/core/sampler2d.inl b/test/external/gli/core/sampler2d.inl new file mode 100644 index 00000000..880c6550 --- /dev/null +++ b/test/external/gli/core/sampler2d.inl @@ -0,0 +1,82 @@ +#include "clear.hpp" +#include + +namespace gli +{ + template + inline sampler2d::sampler2d(texture_type const & Texture, wrap Wrap, filter Mip, filter Min, texel_type const & BorderColor) + : sampler(Wrap, Texture.levels() > 1 ? Mip : FILTER_NEAREST, Min) + , Texture(Texture) + , Convert(detail::convert::call(this->Texture.format())) + , BorderColor(BorderColor) + , Filter(detail::get_filter(Mip, Min, is_border(Wrap))) + { + GLI_ASSERT(!Texture.empty()); + GLI_ASSERT(!is_compressed(Texture.format())); + GLI_ASSERT((!std::numeric_limits::is_iec559 && Mip == FILTER_NEAREST && Min == FILTER_NEAREST) || std::numeric_limits::is_iec559); + } + + template + inline typename sampler2d::texture_type const & sampler2d::operator()() const + { + return this->Texture; + } + + template + inline typename sampler2d::texel_type sampler2d::texel_fetch(extent_type const & TexelCoord, size_type const & Level) const + { + GLI_ASSERT(!this->Texture.empty()); + GLI_ASSERT(this->Convert.Fetch); + + return this->Convert.Fetch(this->Texture, TexelCoord, 0, 0, Level); + } + + template + inline void sampler2d::texel_write(extent_type const & TexelCoord, size_type const & Level, texel_type const & Texel) + { + GLI_ASSERT(!this->Texture.empty()); + GLI_ASSERT(this->Convert.Write); + + this->Convert.Write(this->Texture, TexelCoord, 0, 0, Level, Texel); + } + + template + inline void sampler2d::clear(texel_type const & Color) + { + GLI_ASSERT(!this->Texture.empty()); + GLI_ASSERT(this->Convert.Write); + + detail::clear::call(this->Texture, this->Convert.Write, Color); + } + + template + inline typename sampler2d::texel_type sampler2d::texture_lod(normalized_type const & SampleCoord, level_type Level) const + { + GLI_ASSERT(!this->Texture.empty()); + GLI_ASSERT(std::numeric_limits::is_iec559); + GLI_ASSERT(this->Filter && this->Convert.Fetch); + + normalized_type const SampleCoordWrap(this->Wrap(SampleCoord.x), this->Wrap(SampleCoord.y)); + return this->Filter(this->Texture, this->Convert.Fetch, SampleCoordWrap, size_type(0), size_type(0), Level, this->BorderColor); + } + + template + inline void sampler2d::generate_mipmaps(filter Minification) + { + this->generate_mipmaps(this->Texture.base_level(), this->Texture.max_level(), Minification); + } + + template + inline void sampler2d::generate_mipmaps(size_type BaseLevel, size_type MaxLevel, filter Minification) + { + GLI_ASSERT(!this->Texture.empty()); + GLI_ASSERT(!is_compressed(this->Texture.format())); + GLI_ASSERT(this->Texture.base_level() <= BaseLevel && BaseLevel <= MaxLevel && MaxLevel <= this->Texture.max_level()); + GLI_ASSERT(this->Convert.Fetch && this->Convert.Write); + GLI_ASSERT(Minification >= FILTER_FIRST && Minification <= FILTER_LAST); + + detail::generate_mipmaps_2d( + this->Texture, this->Convert.Fetch, this->Convert.Write, 0, 0, 0, 0, BaseLevel, MaxLevel, Minification); + } +}//namespace gli + diff --git a/test/external/gli/core/sampler2d_array.inl b/test/external/gli/core/sampler2d_array.inl new file mode 100644 index 00000000..27aae9f9 --- /dev/null +++ b/test/external/gli/core/sampler2d_array.inl @@ -0,0 +1,83 @@ +#include "clear.hpp" +#include + +namespace gli +{ + template + inline sampler2d_array::sampler2d_array(texture_type const & Texture, gli::wrap Wrap, filter Mip, filter Min, texel_type const & BorderColor) + : sampler(Wrap, Texture.levels() > 1 ? Mip : FILTER_NEAREST, Min) + , Texture(Texture) + , Convert(detail::convert::call(this->Texture.format())) + , BorderColor(BorderColor) + , Filter(detail::get_filter(Mip, Min, is_border(Wrap))) + { + GLI_ASSERT(!Texture.empty()); + GLI_ASSERT(!is_compressed(Texture.format())); + GLI_ASSERT((!std::numeric_limits::is_iec559 && Mip == FILTER_NEAREST && Min == FILTER_NEAREST) || std::numeric_limits::is_iec559); + } + + template + inline typename sampler2d_array::texture_type const & sampler2d_array::operator()() const + { + return this->Texture; + } + + template + inline typename sampler2d_array::texel_type sampler2d_array::texel_fetch(extent_type const & TexelCoord, size_type layer, size_type Level) const + { + GLI_ASSERT(!this->Texture.empty()); + GLI_ASSERT(this->Convert.Fetch); + + return this->Convert.Fetch(this->Texture, TexelCoord, layer, 0, Level); + } + + template + inline void sampler2d_array::texel_write(extent_type const & TexelCoord, size_type layer, size_type Level, texel_type const & Texel) + { + GLI_ASSERT(!this->Texture.empty()); + GLI_ASSERT(this->Convert.Write); + + this->Convert.Write(this->Texture, TexelCoord, layer, 0, Level, Texel); + } + + template + inline void sampler2d_array::clear(texel_type const & Color) + { + GLI_ASSERT(!this->Texture.empty()); + GLI_ASSERT(this->Convert.Write); + + detail::clear::call(this->Texture, this->Convert.Write, Color); + } + + template + inline typename sampler2d_array::texel_type sampler2d_array::texture_lod(normalized_type const & SampleCoord, size_type Layer, level_type Level) const + { + GLI_ASSERT(!this->Texture.empty()); + GLI_ASSERT(std::numeric_limits::is_iec559); + GLI_ASSERT(this->Filter && this->Convert.Fetch); + + normalized_type const SampleCoordWrap(this->Wrap(SampleCoord.x), this->Wrap(SampleCoord.y)); + return this->Filter(this->Texture, this->Convert.Fetch, SampleCoordWrap, Layer, size_type(0), Level, this->BorderColor); + } + + template + inline void sampler2d_array::generate_mipmaps(filter Minification) + { + this->generate_mipmaps(this->Texture.base_layer(), this->Texture.max_layer(), this->Texture.base_level(), this->Texture.max_level(), Minification); + } + + template + inline void sampler2d_array::generate_mipmaps(size_type BaseLayer, size_type MaxLayer, size_type BaseLevel, size_type MaxLevel, filter Minification) + { + GLI_ASSERT(!this->Texture.empty()); + GLI_ASSERT(!is_compressed(this->Texture.format())); + GLI_ASSERT(this->Texture.base_layer() <= BaseLayer && BaseLayer <= MaxLayer && MaxLayer <= this->Texture.max_layer()); + GLI_ASSERT(this->Texture.base_level() <= BaseLevel && BaseLevel <= MaxLevel && MaxLevel <= this->Texture.max_level()); + GLI_ASSERT(this->Convert.Fetch && this->Convert.Write); + GLI_ASSERT(Minification >= FILTER_FIRST && Minification <= FILTER_LAST); + + detail::generate_mipmaps_2d( + this->Texture, this->Convert.Fetch, this->Convert.Write, BaseLayer, MaxLayer, 0, 0, BaseLevel, MaxLevel, Minification); + } +}//namespace gli + diff --git a/test/external/gli/core/sampler3d.inl b/test/external/gli/core/sampler3d.inl new file mode 100644 index 00000000..acf9fcd5 --- /dev/null +++ b/test/external/gli/core/sampler3d.inl @@ -0,0 +1,82 @@ +#include "clear.hpp" +#include + +namespace gli +{ + template + inline sampler3d::sampler3d(texture_type const & Texture, wrap Wrap, filter Mip, filter Min, texel_type const & BorderColor) + : sampler(Wrap, Texture.levels() > 1 ? Mip : FILTER_NEAREST, Min) + , Texture(Texture) + , Convert(detail::convert::call(this->Texture.format())) + , BorderColor(BorderColor) + , Filter(detail::get_filter(Mip, Min, is_border(Wrap))) + { + GLI_ASSERT(!Texture.empty()); + GLI_ASSERT(!is_compressed(Texture.format())); + GLI_ASSERT((!std::numeric_limits::is_iec559 && Mip == FILTER_NEAREST && Min == FILTER_NEAREST) || std::numeric_limits::is_iec559); + } + + template + inline typename sampler3d::texture_type const & sampler3d::operator()() const + { + return this->Texture; + } + + template + inline typename sampler3d::texel_type sampler3d::texel_fetch(extent_type const & TexelCoord, size_type const & Level) const + { + GLI_ASSERT(!this->Texture.empty()); + GLI_ASSERT(this->Convert.Fetch); + + return this->Convert.Fetch(this->Texture, TexelCoord, 0, 0, Level); + } + + template + inline void sampler3d::texel_write(extent_type const & TexelCoord, size_type const & Level, texel_type const & Texel) + { + GLI_ASSERT(!this->Texture.empty()); + GLI_ASSERT(this->Convert.Write); + + this->Convert.Write(this->Texture, TexelCoord, 0, 0, Level, Texel); + } + + template + inline void sampler3d::clear(texel_type const & Color) + { + GLI_ASSERT(!this->Texture.empty()); + GLI_ASSERT(this->Convert.Write); + + detail::clear::call(this->Texture, this->Convert.Write, Color); + } + + template + GLI_FORCE_INLINE typename sampler3d::texel_type sampler3d::texture_lod(normalized_type const & SampleCoord, level_type Level) const + { + GLI_ASSERT(!this->Texture.empty()); + GLI_ASSERT(std::numeric_limits::is_iec559); + GLI_ASSERT(this->Filter && this->Convert.Fetch); + + normalized_type const SampleCoordWrap(this->Wrap(SampleCoord.x), this->Wrap(SampleCoord.y), this->Wrap(SampleCoord.z)); + return this->Filter(this->Texture, this->Convert.Fetch, SampleCoordWrap, size_type(0), size_type(0), Level, this->BorderColor); + } + + template + inline void sampler3d::generate_mipmaps(filter Minification) + { + this->generate_mipmaps(this->Texture.base_level(), this->Texture.max_level(), Minification); + } + + template + inline void sampler3d::generate_mipmaps(size_type BaseLevel, size_type MaxLevel, filter Minification) + { + GLI_ASSERT(!this->Texture.empty()); + GLI_ASSERT(!is_compressed(this->Texture.format())); + GLI_ASSERT(this->Texture.base_level() <= BaseLevel && BaseLevel <= MaxLevel && MaxLevel <= this->Texture.max_level()); + GLI_ASSERT(this->Convert.Fetch && this->Convert.Write); + GLI_ASSERT(Minification >= FILTER_FIRST && Minification <= FILTER_LAST); + + detail::generate_mipmaps_3d( + this->Texture, this->Convert.Fetch, this->Convert.Write, 0, 0, 0, 0, BaseLevel, MaxLevel, Minification); + } +}//namespace gli + diff --git a/test/external/gli/core/sampler_cube.inl b/test/external/gli/core/sampler_cube.inl new file mode 100644 index 00000000..c392efe4 --- /dev/null +++ b/test/external/gli/core/sampler_cube.inl @@ -0,0 +1,84 @@ +#include "clear.hpp" +#include + +namespace gli +{ + template + inline sampler_cube::sampler_cube(texture_cube const & Texture, gli::wrap Wrap, filter Mip, filter Min, texel_type const & BorderColor) + : sampler(Wrap, Texture.levels() > 1 ? Mip : FILTER_NEAREST, Min) + , Texture(Texture) + , Convert(detail::convert::call(this->Texture.format())) + , BorderColor(BorderColor) + , Filter(detail::get_filter(Mip, Min, is_border(Wrap))) + { + GLI_ASSERT(!Texture.empty()); + GLI_ASSERT(!is_compressed(Texture.format())); + GLI_ASSERT((!std::numeric_limits::is_iec559 && Mip == FILTER_NEAREST && Min == FILTER_NEAREST) || std::numeric_limits::is_iec559); + } + + template + inline texture_cube const & sampler_cube::operator()() const + { + return this->Texture; + } + + template + inline typename sampler_cube::texel_type sampler_cube::texel_fetch(extent_type const & TexelCoord, size_type Face, size_type Level) const + { + GLI_ASSERT(!this->Texture.empty()); + GLI_ASSERT(this->Convert.Fetch); + + return this->Convert.Fetch(this->Texture, TexelCoord, 0, Face, Level); + } + + template + inline void sampler_cube::texel_write(extent_type const & TexelCoord, size_type Face, size_type Level, texel_type const & Texel) + { + GLI_ASSERT(!this->Texture.empty()); + GLI_ASSERT(this->Convert.Write); + + this->Convert.Write(this->Texture, TexelCoord, 0, Face, Level, Texel); + } + + template + inline void sampler_cube::clear(texel_type const & Color) + { + GLI_ASSERT(!this->Texture.empty()); + GLI_ASSERT(this->Convert.Write); + + detail::clear::call(this->Texture, this->Convert.Write, Color); + } + + template + inline typename sampler_cube::texel_type sampler_cube::texture_lod(normalized_type const & SampleCoord, size_type Face, level_type Level) const + { + GLI_ASSERT(!this->Texture.empty()); + GLI_ASSERT(std::numeric_limits::is_iec559); + GLI_ASSERT(this->Filter && this->Convert.Fetch); + + normalized_type const SampleCoordWrap(this->Wrap(SampleCoord.x), this->Wrap(SampleCoord.y)); + + return this->Filter(this->Texture, this->Convert.Fetch, SampleCoordWrap, size_type(0), Face, Level, this->BorderColor); + } + + template + inline void sampler_cube::generate_mipmaps(filter Minification) + { + this->generate_mipmaps(this->Texture.base_face(), this->Texture.max_face(), this->Texture.base_level(), this->Texture.max_level(), Minification); + } + + template + inline void sampler_cube::generate_mipmaps(size_type BaseFace, size_type MaxFace, size_type BaseLevel, size_type MaxLevel, filter Minification) + { + GLI_ASSERT(!this->Texture.empty()); + GLI_ASSERT(!is_compressed(this->Texture.format())); + GLI_ASSERT(this->Texture.base_face() <= BaseFace && BaseFace <= MaxFace && MaxFace <= this->Texture.max_face()); + GLI_ASSERT(this->Texture.base_level() <= BaseLevel && BaseLevel <= MaxLevel && MaxLevel <= this->Texture.max_level()); + GLI_ASSERT(this->Convert.Fetch && this->Convert.Write); + GLI_ASSERT(Minification >= FILTER_FIRST && Minification <= FILTER_LAST); + + detail::generate_mipmaps_2d( + this->Texture, this->Convert.Fetch, this->Convert.Write, 0, 0, BaseFace, MaxFace, BaseLevel, MaxLevel, Minification); + } +}//namespace gli + diff --git a/test/external/gli/core/sampler_cube_array.inl b/test/external/gli/core/sampler_cube_array.inl new file mode 100644 index 00000000..e1f49d82 --- /dev/null +++ b/test/external/gli/core/sampler_cube_array.inl @@ -0,0 +1,84 @@ +#include "clear.hpp" +#include + +namespace gli +{ + template + inline sampler_cube_array::sampler_cube_array(texture_type const & Texture, gli::wrap Wrap, filter Mip, filter Min, texel_type const & BorderColor) + : sampler(Wrap, Texture.levels() > 1 ? Mip : FILTER_NEAREST, Min) + , Texture(Texture) + , Convert(detail::convert::call(this->Texture.format())) + , BorderColor(BorderColor) + , Filter(detail::get_filter(Mip, Min, is_border(Wrap))) + { + GLI_ASSERT(!Texture.empty()); + GLI_ASSERT(!is_compressed(Texture.format())); + GLI_ASSERT((!std::numeric_limits::is_iec559 && Mip == FILTER_NEAREST && Min == FILTER_NEAREST) || std::numeric_limits::is_iec559); + } + + template + inline typename sampler_cube_array::texture_type const & sampler_cube_array::operator()() const + { + return this->Texture; + } + + template + inline typename sampler_cube_array::texel_type sampler_cube_array::texel_fetch(extent_type const & TexelCoord, size_type layer, size_type Face, size_type Level) const + { + GLI_ASSERT(!this->Texture.empty()); + GLI_ASSERT(this->Convert.Fetch); + + return this->Convert.Fetch(this->Texture, TexelCoord, layer, Face, Level); + } + + template + inline void sampler_cube_array::texel_write(extent_type const & TexelCoord, size_type layer, size_type Face, size_type Level, texel_type const & Texel) + { + GLI_ASSERT(!this->Texture.empty()); + GLI_ASSERT(this->Convert.Write); + + this->Convert.Write(this->Texture, TexelCoord, layer, Face, Level, Texel); + } + + template + inline void sampler_cube_array::clear(texel_type const & Color) + { + GLI_ASSERT(!this->Texture.empty()); + GLI_ASSERT(this->Convert.Write); + + detail::clear::call(this->Texture, this->Convert.Write, Color); + } + + template + inline typename sampler_cube_array::texel_type sampler_cube_array::texture_lod(normalized_type const & SampleCoord, size_type Layer, size_type Face, level_type Level) const + { + GLI_ASSERT(!this->Texture.empty()); + GLI_ASSERT(std::numeric_limits::is_iec559); + GLI_ASSERT(this->Filter && this->Convert.Fetch); + + normalized_type const SampleCoordWrap(this->Wrap(SampleCoord.x), this->Wrap(SampleCoord.y)); + return this->Filter(this->Texture, this->Convert.Fetch, SampleCoordWrap, Layer, Face, Level, this->BorderColor); + } + + template + inline void sampler_cube_array::generate_mipmaps(filter Minification) + { + this->generate_mipmaps(this->Texture.base_layer(), this->Texture.max_layer(), this->Texture.base_face(), this->Texture.max_face(), this->Texture.base_level(), this->Texture.max_level(), Minification); + } + + template + inline void sampler_cube_array::generate_mipmaps(size_type BaseLayer, size_type MaxLayer, size_type BaseFace, size_type MaxFace, size_type BaseLevel, size_type MaxLevel, filter Minification) + { + GLI_ASSERT(!this->Texture.empty()); + GLI_ASSERT(!is_compressed(this->Texture.format())); + GLI_ASSERT(this->Texture.base_layer() <= BaseLayer && BaseLayer <= MaxLayer && MaxLayer <= this->Texture.max_layer()); + GLI_ASSERT(this->Texture.base_face() <= BaseFace && BaseFace <= MaxFace && MaxFace <= this->Texture.max_face()); + GLI_ASSERT(this->Texture.base_level() <= BaseLevel && BaseLevel <= MaxLevel && MaxLevel <= this->Texture.max_level()); + GLI_ASSERT(this->Convert.Fetch && this->Convert.Write); + GLI_ASSERT(Minification >= FILTER_FIRST && Minification <= FILTER_LAST); + + detail::generate_mipmaps_2d( + this->Texture, this->Convert.Fetch, this->Convert.Write, BaseLayer, MaxLayer, BaseFace, MaxFace, BaseLevel, MaxLevel, Minification); + } +}//namespace gli + diff --git a/test/external/gli/core/save.inl b/test/external/gli/core/save.inl new file mode 100644 index 00000000..0d4b44ff --- /dev/null +++ b/test/external/gli/core/save.inl @@ -0,0 +1,22 @@ +#include "../save_dds.hpp" +#include "../save_kmg.hpp" +#include "../save_ktx.hpp" + +namespace gli +{ + inline bool save(texture const & Texture, char const * Path) + { + return save(Texture, std::string(Path)); + } + + inline bool save(texture const & Texture, std::string const & Path) + { + if(Path.rfind(".dds") != std::string::npos) + return save_dds(Texture, Path); + if(Path.rfind(".kmg") != std::string::npos) + return save_kmg(Texture, Path); + if(Path.rfind(".ktx") != std::string::npos) + return save_ktx(Texture, Path); + return false; + } +}//namespace gli diff --git a/test/external/gli/core/save_dds.inl b/test/external/gli/core/save_dds.inl new file mode 100644 index 00000000..018238bd --- /dev/null +++ b/test/external/gli/core/save_dds.inl @@ -0,0 +1,139 @@ +#include +#include "../load_dds.hpp" +#include "file.hpp" + +namespace gli{ +namespace detail +{ + inline d3d10_resource_dimension get_dimension(gli::target Target) + { + static d3d10_resource_dimension Table[] = //TARGET_COUNT + { + D3D10_RESOURCE_DIMENSION_TEXTURE1D, //TARGET_1D, + D3D10_RESOURCE_DIMENSION_TEXTURE1D, //TARGET_1D_ARRAY, + D3D10_RESOURCE_DIMENSION_TEXTURE2D, //TARGET_2D, + D3D10_RESOURCE_DIMENSION_TEXTURE2D, //TARGET_2D_ARRAY, + D3D10_RESOURCE_DIMENSION_TEXTURE3D, //TARGET_3D, + D3D10_RESOURCE_DIMENSION_TEXTURE2D, //TARGET_RECT, + D3D10_RESOURCE_DIMENSION_TEXTURE2D, //TARGET_RECT_ARRAY, + D3D10_RESOURCE_DIMENSION_TEXTURE2D, //TARGET_CUBE, + D3D10_RESOURCE_DIMENSION_TEXTURE2D //TARGET_CUBE_ARRAY + }; + static_assert(sizeof(Table) / sizeof(Table[0]) == TARGET_COUNT, "Table needs to be updated"); + + return Table[Target]; + } + + inline dx::d3dfmt get_fourcc(bool RequireDX10Header, gli::format Format, dx::format const& DXFormat) + { + if(RequireDX10Header) + { + detail::formatInfo const & FormatInfo = detail::get_format_info(Format); + + if(FormatInfo.Flags & detail::CAP_DDS_GLI_EXT_BIT) + return dx::D3DFMT_GLI1; + else + return dx::D3DFMT_DX10; + } + else + { + return (DXFormat.DDPixelFormat & dx::DDPF_FOURCC) ? DXFormat.D3DFormat : dx::D3DFMT_UNKNOWN; + } + } +}//namespace detail + + inline bool save_dds(texture const& Texture, std::vector& Memory) + { + if(Texture.empty()) + return false; + + dx DX; + dx::format const& DXFormat = DX.translate(Texture.format()); + + bool const RequireDX10Header = DXFormat.D3DFormat == dx::D3DFMT_GLI1 || DXFormat.D3DFormat == dx::D3DFMT_DX10 || is_target_array(Texture.target()) || is_target_1d(Texture.target()); + + Memory.resize(Texture.size() + sizeof(detail::FOURCC_DDS) + sizeof(detail::dds_header) + (RequireDX10Header ? sizeof(detail::dds_header10) : 0)); + + memcpy(&Memory[0], detail::FOURCC_DDS, sizeof(detail::FOURCC_DDS)); + std::size_t Offset = sizeof(detail::FOURCC_DDS); + + detail::dds_header& Header = *reinterpret_cast(&Memory[0] + Offset); + Offset += sizeof(detail::dds_header); + + detail::formatInfo const& Desc = detail::get_format_info(Texture.format()); + + std::uint32_t Caps = detail::DDSD_CAPS | detail::DDSD_WIDTH | detail::DDSD_PIXELFORMAT | detail::DDSD_MIPMAPCOUNT; + Caps |= !is_target_1d(Texture.target()) ? detail::DDSD_HEIGHT : 0; + Caps |= Texture.target() == TARGET_3D ? detail::DDSD_DEPTH : 0; + //Caps |= Storage.levels() > 1 ? detail::DDSD_MIPMAPCOUNT : 0; + Caps |= (Desc.Flags & detail::CAP_COMPRESSED_BIT) ? detail::DDSD_LINEARSIZE : detail::DDSD_PITCH; + + memset(Header.Reserved1, 0, sizeof(Header.Reserved1)); + memset(Header.Reserved2, 0, sizeof(Header.Reserved2)); + Header.Size = sizeof(detail::dds_header); + Header.Flags = Caps; + Header.Width = static_cast(Texture.extent().x); + Header.Height = static_cast(Texture.extent().y); + Header.Pitch = static_cast((Desc.Flags & detail::CAP_COMPRESSED_BIT) ? Texture.size() / Texture.faces() : 32); + Header.Depth = static_cast(Texture.extent().z > 1 ? Texture.extent().z : 0); + Header.MipMapLevels = static_cast(Texture.levels()); + Header.Format.size = sizeof(detail::dds_pixel_format); + Header.Format.flags = RequireDX10Header ? dx::DDPF_FOURCC : DXFormat.DDPixelFormat; + Header.Format.fourCC = detail::get_fourcc(RequireDX10Header, Texture.format(), DXFormat); + Header.Format.bpp = static_cast(detail::bits_per_pixel(Texture.format())); + Header.Format.Mask = DXFormat.Mask; + //Header.surfaceFlags = detail::DDSCAPS_TEXTURE | (Storage.levels() > 1 ? detail::DDSCAPS_MIPMAP : 0); + Header.SurfaceFlags = detail::DDSCAPS_TEXTURE | detail::DDSCAPS_MIPMAP; + Header.CubemapFlags = 0; + + // Cubemap + if(Texture.faces() > 1) + { + GLI_ASSERT(Texture.faces() == 6); + Header.CubemapFlags |= detail::DDSCAPS2_CUBEMAP_ALLFACES | detail::DDSCAPS2_CUBEMAP; + } + + // Texture3D + if(Texture.extent().z > 1) + Header.CubemapFlags |= detail::DDSCAPS2_VOLUME; + + if(RequireDX10Header) + { + detail::dds_header10& Header10 = *reinterpret_cast(&Memory[0] + Offset); + Offset += sizeof(detail::dds_header10); + + Header10.ArraySize = static_cast(Texture.layers()); + Header10.ResourceDimension = detail::get_dimension(Texture.target()); + Header10.MiscFlag = 0;//Storage.levels() > 0 ? detail::D3D10_RESOURCE_MISC_GENERATE_MIPS : 0; + Header10.Format = DXFormat.DXGIFormat; + Header10.AlphaFlags = detail::DDS_ALPHA_MODE_UNKNOWN; + } + + std::memcpy(&Memory[0] + Offset, Texture.data(), Texture.size()); + + return true; + } + + inline bool save_dds(texture const& Texture, char const* Filename) + { + if(Texture.empty()) + return false; + + FILE* File = detail::open_file(Filename, "wb"); + if(!File) + return false; + + std::vector Memory; + bool const Result = save_dds(Texture, Memory); + + std::fwrite(&Memory[0], 1, Memory.size(), File); + std::fclose(File); + + return Result; + } + + inline bool save_dds(texture const& Texture, std::string const& Filename) + { + return save_dds(Texture, Filename.c_str()); + } +}//namespace gli diff --git a/test/external/gli/core/save_kmg.inl b/test/external/gli/core/save_kmg.inl new file mode 100644 index 00000000..f03d976d --- /dev/null +++ b/test/external/gli/core/save_kmg.inl @@ -0,0 +1,80 @@ +#include +#include +#include "../load_kmg.hpp" +#include "filter.hpp" +#include "file.hpp" + +namespace gli +{ + inline bool save_kmg(texture const & Texture, std::vector & Memory) + { + if(Texture.empty()) + return false; + + Memory.resize(sizeof(detail::FOURCC_KMG100) + sizeof(detail::kmgHeader10) + Texture.size()); + + std::memcpy(&Memory[0], detail::FOURCC_KMG100, sizeof(detail::FOURCC_KMG100)); + + std::size_t Offset = sizeof(detail::FOURCC_KMG100); + + texture::swizzles_type Swizzle = Texture.swizzles(); + + detail::kmgHeader10 & Header = *reinterpret_cast(&Memory[0] + Offset); + Header.Endianness = 0x04030201; + Header.Format = Texture.format(); + Header.Target = Texture.target(); + Header.SwizzleRed = Swizzle[0]; + Header.SwizzleGreen = Swizzle[1]; + Header.SwizzleBlue = Swizzle[2]; + Header.SwizzleAlpha = Swizzle[3]; + Header.PixelWidth = static_cast(Texture.extent().x); + Header.PixelHeight = static_cast(Texture.extent().y); + Header.PixelDepth = static_cast(Texture.extent().z); + Header.Layers = static_cast(Texture.layers()); + Header.Levels = static_cast(Texture.levels()); + Header.Faces = static_cast(Texture.faces()); + Header.GenerateMipmaps = FILTER_NONE; + Header.BaseLevel = static_cast(Texture.base_level()); + Header.MaxLevel = static_cast(Texture.max_level()); + + Offset += sizeof(detail::kmgHeader10); + + for(texture::size_type Layer = 0, Layers = Texture.layers(); Layer < Layers; ++Layer) + for(texture::size_type Level = 0, Levels = Texture.levels(); Level < Levels; ++Level) + { + texture::size_type const FaceSize = Texture.size(Level); + for(texture::size_type Face = 0, Faces = Texture.faces(); Face < Faces; ++Face) + { + std::memcpy(&Memory[0] + Offset, Texture.data(Layer, Face, Level), FaceSize); + + Offset += FaceSize; + GLI_ASSERT(Offset <= Memory.size()); + } + } + + return true; + } + + inline bool save_kmg(texture const & Texture, char const * Filename) + { + if(Texture.empty()) + return false; + + FILE* File = detail::open_file(Filename, "wb"); + if(!File) + return false; + + std::vector Memory; + bool const Result = save_kmg(Texture, Memory); + + std::fwrite(&Memory[0], 1, Memory.size(), File); + std::fclose(File); + + return Result; + } + + inline bool save_kmg(texture const & Texture, std::string const & Filename) + { + return save_kmg(Texture, Filename.c_str()); + } +}//namespace gli diff --git a/test/external/gli/core/save_ktx.inl b/test/external/gli/core/save_ktx.inl new file mode 100644 index 00000000..4bb4d603 --- /dev/null +++ b/test/external/gli/core/save_ktx.inl @@ -0,0 +1,114 @@ +#include +#include +#include "../load_ktx.hpp" +#include "file.hpp" + +namespace gli{ +namespace detail +{ + inline texture::size_type compute_ktx_storage_size(texture const & Texture) + { + texture::size_type const BlockSize = block_size(Texture.format()); + texture::size_type TotalSize = sizeof(detail::FOURCC_KTX10) + sizeof(detail::ktx_header10); + + for(texture::size_type Level = 0, Levels = Texture.levels(); Level < Levels; ++Level) + { + TotalSize += sizeof(std::uint32_t); + + for(texture::size_type Layer = 0, Layers = Texture.layers(); Layer < Layers; ++Layer) + for(texture::size_type Face = 0, Faces = Texture.faces(); Face < Faces; ++Face) + { + texture::size_type const FaceSize = Texture.size(Level); + texture::size_type const PaddedSize = std::max(BlockSize, glm::ceilMultiple(FaceSize, static_cast(4))); + + TotalSize += PaddedSize; + } + } + + return TotalSize; + } +}//namespace detail + + inline bool save_ktx(texture const& Texture, std::vector& Memory) + { + if(Texture.empty()) + return false; + + gl GL(gl::PROFILE_KTX); + gl::format const& Format = GL.translate(Texture.format(), Texture.swizzles()); + target const Target = Texture.target(); + + detail::formatInfo const& Desc = detail::get_format_info(Texture.format()); + + Memory.resize(detail::compute_ktx_storage_size(Texture)); + + std::memcpy(&Memory[0], detail::FOURCC_KTX10, sizeof(detail::FOURCC_KTX10)); + + std::size_t Offset = sizeof(detail::FOURCC_KTX10); + + detail::ktx_header10& Header = *reinterpret_cast(&Memory[0] + Offset); + Header.Endianness = 0x04030201; + Header.GLType = Format.Type; + Header.GLTypeSize = Format.Type == gl::TYPE_NONE ? 1 : Desc.BlockSize; + Header.GLFormat = Format.External; + Header.GLInternalFormat = Format.Internal; + Header.GLBaseInternalFormat = Format.External; + Header.PixelWidth = static_cast(Texture.extent().x); + Header.PixelHeight = !is_target_1d(Target) ? static_cast(Texture.extent().y) : 0; + Header.PixelDepth = Target == TARGET_3D ? static_cast(Texture.extent().z) : 0; + Header.NumberOfArrayElements = is_target_array(Target) ? static_cast(Texture.layers()) : 0; + Header.NumberOfFaces = is_target_cube(Target) ? static_cast(Texture.faces()) : 1; + Header.NumberOfMipmapLevels = static_cast(Texture.levels()); + Header.BytesOfKeyValueData = 0; + + Offset += sizeof(detail::ktx_header10); + + for(texture::size_type Level = 0, Levels = Texture.levels(); Level < Levels; ++Level) + { + std::uint32_t& ImageSize = *reinterpret_cast(&Memory[0] + Offset); + Offset += sizeof(std::uint32_t); + + for(texture::size_type Layer = 0, Layers = Texture.layers(); Layer < Layers; ++Layer) + for(texture::size_type Face = 0, Faces = Texture.faces(); Face < Faces; ++Face) + { + texture::size_type const FaceSize = Texture.size(Level); + + std::memcpy(&Memory[0] + Offset, Texture.data(Layer, Face, Level), FaceSize); + + texture::size_type const PaddedSize = glm::ceilMultiple(FaceSize, static_cast(4)); + + ImageSize += static_cast(PaddedSize); + Offset += PaddedSize; + + GLI_ASSERT(Offset <= Memory.size()); + } + + ImageSize = glm::ceilMultiple(ImageSize, static_cast(4)); + } + + return true; + } + + inline bool save_ktx(texture const& Texture, char const* Filename) + { + if(Texture.empty()) + return false; + + FILE* File = detail::open_file(Filename, "wb"); + if(!File) + return false; + + std::vector Memory; + bool const Result = save_ktx(Texture, Memory); + + std::fwrite(&Memory[0], 1, Memory.size(), File); + std::fclose(File); + + return Result; + } + + inline bool save_ktx(texture const& Texture, std::string const& Filename) + { + return save_ktx(Texture, Filename.c_str()); + } +}//namespace gli diff --git a/test/external/gli/core/shared_array.hpp b/test/external/gli/core/shared_array.hpp deleted file mode 100644 index 326a54af..00000000 --- a/test/external/gli/core/shared_array.hpp +++ /dev/null @@ -1,48 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////// -// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net) -/////////////////////////////////////////////////////////////////////////////////////////////////// -// Created : 2008-12-19 -// Updated : 2005-06-13 -// Licence : This source is under MIT License -// File : gli/shared_array.hpp -/////////////////////////////////////////////////////////////////////////////////////////////////// - -#ifndef GLI_SHARED_ARRAY_INCLUDED -#define GLI_SHARED_ARRAY_INCLUDED - -namespace gli -{ - template - class shared_array - { - public: - - shared_array(); - shared_array(shared_array const & SharedArray); - shared_array(T * Pointer); - virtual ~shared_array(); - - void reset(); - void reset(T * Pointer); - - T & operator*(); - T * operator->(); - T const & operator*() const; - T const * const operator->() const; - - T * get(); - T const * const get() const; - - shared_array & operator=(shared_array const & SharedArray); - bool operator==(shared_array const & SharedArray) const; - bool operator!=(shared_array const & SharedArray) const; - - private: - int * Counter; - T * Pointer; - }; -}//namespace gli - -#include "shared_array.inl" - -#endif //GLI_SHARED_ARRAY_INCLUDED diff --git a/test/external/gli/core/shared_array.inl b/test/external/gli/core/shared_array.inl deleted file mode 100644 index 74edbb4a..00000000 --- a/test/external/gli/core/shared_array.inl +++ /dev/null @@ -1,151 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////// -// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net) -/////////////////////////////////////////////////////////////////////////////////////////////////// -// Created : 2008-12-19 -// Updated : 2005-06-13 -// Licence : This source is under MIT License -// File : gli/shared_array.inl -/////////////////////////////////////////////////////////////////////////////////////////////////// - -namespace gli -{ - template - shared_array::shared_array() : - Counter(0), - Pointer(0) - {} - - template - shared_array::shared_array - ( - shared_array const & SharedArray - ) - { - this->Counter = SharedArray.Counter; - this->Pointer = SharedArray.Pointer; - (*this->Counter)++; - } - - template - shared_array::shared_array - ( - T * Pointer - ) - { - this->reset(Pointer); - } - - template - shared_array::~shared_array() - { - this->reset(); - } - - template - void shared_array::reset() - { - if(this->Pointer) - { - (*this->Counter)--; - if(*this->Counter <= 0) - { - delete this->Counter; - this->Counter = 0; - delete[] this->Pointer; - this->Pointer = 0; - } - } - } - - template - void shared_array::reset(T * Pointer) - { - this->Counter = new int; - this->Pointer = Pointer; - *this->Counter = 1; - } - - template - shared_array& shared_array::operator= - ( - shared_array const & SharedArray - ) - { - this->reset(); - - this->Counter = SharedArray.Counter; - this->Pointer = SharedArray.Pointer; - (*this->Counter)++; - - return *this; - } - - //template - //shared_array & shared_array::operator=(T * Pointer) - //{ - // if(this->Pointer) - // { - // (*this->Counter)--; - // if(*this->Counter <= 0) - // { - // delete this->Counter; - // delete[] this->Pointer; - // } - // } - - // this->Counter = new int; - // this->Pointer = this->Pointer; - // (*this->Counter) = 1; - - // return *this; - //} - - template - bool shared_array::operator==(shared_array const & SharedArray) const - { - return this->Pointer == SharedArray.Pointer; - } - - template - bool shared_array::operator!=(shared_array const & SharedArray) const - { - return this->Pointer != SharedArray.Pointer; - } - - template - T & shared_array::operator*() - { - return *this->Pointer; - } - - template - T * shared_array::operator->() - { - return this->Pointer; - } - - template - T const & shared_array::operator*() const - { - return * this->Pointer; - } - - template - T const * const shared_array::operator->() const - { - return this->Pointer; - } - - template - T * shared_array::get() - { - return this->Pointer; - } - - template - T const * const shared_array::get() const - { - return this->Pointer; - } - -}//namespace gli diff --git a/test/external/gli/core/shared_ptr.hpp b/test/external/gli/core/shared_ptr.hpp deleted file mode 100644 index 533e33f5..00000000 --- a/test/external/gli/core/shared_ptr.hpp +++ /dev/null @@ -1,41 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////// -// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net) -/////////////////////////////////////////////////////////////////////////////////////////////////// -// Created : 2008-12-19 -// Updated : 2005-06-13 -// Licence : This source is under MIT License -// File : gli/fetch.hpp -/////////////////////////////////////////////////////////////////////////////////////////////////// - -#ifndef GLI_SHARED_PTR_INCLUDED -#define GLI_SHARED_PTR_INCLUDED - -namespace gli -{ - template - class shared_ptr - { - public: - shared_ptr(); - shared_ptr(shared_ptr const & SmartPtr); - shared_ptr(T* pPointer); - ~shared_ptr(); - - T& operator*(); - T* operator->(); - const T& operator*() const; - const T* operator->() const; - shared_ptr& operator=(shared_ptr const & SmartPtr); - shared_ptr& operator=(T* pPointer); - bool operator==(shared_ptr const & SmartPtr) const; - bool operator!=(shared_ptr const & SmartPtr) const; - - private: - int* m_pReference; - T* m_pPointer; - }; -}//namespace gli - -#include "shared_ptr.inl" - -#endif //GLI_SHARED_PTR_INCLUDED diff --git a/test/external/gli/core/shared_ptr.inl b/test/external/gli/core/shared_ptr.inl deleted file mode 100644 index 43974110..00000000 --- a/test/external/gli/core/shared_ptr.inl +++ /dev/null @@ -1,125 +0,0 @@ -/////////////////////////////////////////////////////////////////////////// -// Interstate Gangs : smart_ptr.inl -/////////////////////////////////////////////////////////////////////////// -// This file is under GPL licence -/////////////////////////////////////////////////////////////////////////// -// CHANGELOG -// Groove - 13/06/2005 : -// - Create file -/////////////////////////////////////////////////////////////////////////// - -namespace gli -{ - template - util::CSmartPtr::CSmartPtr() - { - m_pPointer = 0; - } - - template - util::CSmartPtr::CSmartPtr(const util::CSmartPtr & SmartPtr) - { - m_pReference = SmartPtr.m_pReference; - m_pPointer = SmartPtr.m_pPointer; - (*m_pReference)++; - } - - template - util::CSmartPtr::CSmartPtr(T* pPointer) - { - m_pReference = new int; - m_pPointer = pPointer; - (*m_pReference) = 1; - } - - template - util::CSmartPtr::~CSmartPtr() - { - if(!m_pPointer) - return; - - (*m_pReference)--; - if(*m_pReference <= 0) - { - delete m_pReference; - delete m_pPointer; - } - } - - template - util::CSmartPtr& util::CSmartPtr::operator=(const util::CSmartPtr & SmartPtr) - { - if(m_pPointer) - { - (*m_pReference)--; - if(*m_pReference <= 0) - { - delete m_pReference; - delete m_pPointer; - } - } - - m_pReference = SmartPtr.m_pReference; - m_pPointer = SmartPtr.m_pPointer; - (*m_pReference)++; - - return *this; - } - - template - util::CSmartPtr& util::CSmartPtr::operator=(T* pPointer) - { - if(m_pPointer) - { - (*m_pReference)--; - if(*m_pReference <= 0) - { - delete m_pReference; - delete m_pPointer; - } - } - - m_pReference = new int; - m_pPointer = pPointer; - (*m_pReference) = 1; - - return *this; - } - - template - bool util::CSmartPtr::operator==(const util::CSmartPtr & SmartPtr) const - { - return m_pPointer == SmartPtr.m_pPointer; - } - - template - bool util::CSmartPtr::operator!=(const util::CSmartPtr & SmartPtr) const - { - return m_pPointer != SmartPtr.m_pPointer; - } - - template - T& util::CSmartPtr::operator*() - { - return *m_pPointer; - } - - template - T* util::CSmartPtr::operator->() - { - return m_pPointer; - } - - template - const T& util::CSmartPtr::operator*() const - { - return *m_pPointer; - } - - template - const T* util::CSmartPtr::operator->() const - { - return m_pPointer; - } - -}//namespace gli diff --git a/test/external/gli/core/size.hpp b/test/external/gli/core/size.hpp deleted file mode 100644 index 3fe461ba..00000000 --- a/test/external/gli/core/size.hpp +++ /dev/null @@ -1,31 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////// -// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net) -/////////////////////////////////////////////////////////////////////////////////////////////////// -// Created : 2010-09-08 -// Updated : 2010-09-08 -// Licence : This source is under MIT License -// File : gli/core/size.hpp -/////////////////////////////////////////////////////////////////////////////////////////////////// - -#ifndef GLI_CORE_SIZE_INCLUDED -#define GLI_CORE_SIZE_INCLUDED - -#include "texture2d.hpp" - -namespace gli -{ - //template - image2D::size_type size( - image2D const & Image, - image2D::size_type const & SizeType); - - //template - texture2D::size_type size( - texture2D const & Texture, - texture2D::size_type const & SizeType); - -}//namespace gli - -#include "size.inl" - -#endif//GLI_CORE_SIZE_INCLUDED diff --git a/test/external/gli/core/size.inl b/test/external/gli/core/size.inl deleted file mode 100644 index dfb61238..00000000 --- a/test/external/gli/core/size.inl +++ /dev/null @@ -1,47 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////// -// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net) -/////////////////////////////////////////////////////////////////////////////////////////////////// -// Created : 2008-12-19 -// Updated : 2010-09-08 -// Licence : This source is under MIT License -// File : gli/core/size.inl -/////////////////////////////////////////////////////////////////////////////////////////////////// - -namespace gli -{ - inline image2D::size_type size - ( - image2D const & Image, - image2D::size_type const & SizeType - ) - { - switch(SizeType) - { - case LINEAR_SIZE: - return detail::sizeLinear(Image); - case BLOCK_SIZE: - return detail::sizeBlock(Image.format()); - case BIT_PER_PIXEL: - return detail::sizeBitPerPixel(Image.format()); - case COMPONENT: - return detail::sizeComponent(Image.format()); - default: - assert(0); - return 0; - }; - } - - inline texture2D::size_type size - ( - texture2D const & Texture, - texture2D::size_type const & SizeType - ) - { - texture2D::size_type Size = 0; - for(texture2D::level_type Level = 0; Level < Texture.levels(); ++Level) - Size += size(Texture[Level], SizeType); - - return Size; - } - -}//namespace diff --git a/test/external/gli/core/storage.hpp b/test/external/gli/core/storage.hpp new file mode 100644 index 00000000..d9fa3c97 --- /dev/null +++ b/test/external/gli/core/storage.hpp @@ -0,0 +1,92 @@ +#pragma once + +// STD +#include +#include +#include +#include +#include +#include +#include + +#include "../type.hpp" +#include "../format.hpp" + +// GLM +#include +#include +#include +#include +#include +#include + +static_assert(GLM_VERSION >= 97, "GLI requires at least GLM 0.9.7"); + +namespace gli +{ + class storage_linear + { + public: + typedef extent3d extent_type; + typedef size_t size_type; + typedef gli::format format_type; + typedef glm::byte data_type; + + public: + storage_linear(); + + storage_linear( + format_type Format, + extent_type const & Extent, + size_type Layers, + size_type Faces, + size_type Levels); + + bool empty() const; + size_type size() const; // Express is bytes + size_type layers() const; + size_type levels() const; + size_type faces() const; + + size_type block_size() const; + extent_type block_extent() const; + extent_type block_count(size_type Level) const; + extent_type extent(size_type Level) const; + + data_type* data(); + data_type const* const data() const; + + /// Compute the relative memory offset to access the data for a specific layer, face and level + size_type base_offset( + size_type Layer, + size_type Face, + size_type Level) const; + + /// Copy a subset of a specific image of a texture + void copy( + storage_linear const& StorageSrc, + size_t LayerSrc, size_t FaceSrc, size_t LevelSrc, extent_type const& BlockIndexSrc, + size_t LayerDst, size_t FaceDst, size_t LevelDst, extent_type const& BlockIndexDst, + extent_type const& BlockCount); + + size_type level_size( + size_type Level) const; + size_type face_size( + size_type BaseLevel, size_type MaxLevel) const; + size_type layer_size( + size_type BaseFace, size_type MaxFace, + size_type BaseLevel, size_type MaxLevel) const; + + private: + size_type const Layers; + size_type const Faces; + size_type const Levels; + size_type const BlockSize; + extent_type const BlockCount; + extent_type const BlockExtent; + extent_type const Extent; + std::vector Data; + }; +}//namespace gli + +#include "storage_linear.inl" diff --git a/test/external/gli/core/storage.inl b/test/external/gli/core/storage.inl new file mode 100644 index 00000000..92f7e740 --- /dev/null +++ b/test/external/gli/core/storage.inl @@ -0,0 +1,170 @@ +#include "../index.hpp" + +namespace gli +{ + inline storage_linear::storage_linear() + : Layers(0) + , Faces(0) + , Levels(0) + , BlockSize(0) + , BlockCount(0) + , BlockExtent(0) + , Extent(0) + {} + + inline storage_linear::storage_linear(format_type Format, extent_type const & Extent, size_type Layers, size_type Faces, size_type Levels) + : Layers(Layers) + , Faces(Faces) + , Levels(Levels) + , BlockSize(gli::block_size(Format)) + , BlockCount(glm::max(Extent / gli::block_extent(Format), extent_type(1))) + , BlockExtent(gli::block_extent(Format)) + , Extent(Extent) + { + GLI_ASSERT(Layers > 0); + GLI_ASSERT(Faces > 0); + GLI_ASSERT(Levels > 0); + GLI_ASSERT(glm::all(glm::greaterThan(Extent, extent_type(0)))); + + this->Data.resize(this->layer_size(0, Faces - 1, 0, Levels - 1) * Layers, 0); + } + + inline bool storage_linear::empty() const + { + return this->Data.empty(); + } + + inline storage_linear::size_type storage_linear::layers() const + { + return this->Layers; + } + + inline storage_linear::size_type storage_linear::faces() const + { + return this->Faces; + } + + inline storage_linear::size_type storage_linear::levels() const + { + return this->Levels; + } + + inline storage_linear::size_type storage_linear::block_size() const + { + return this->BlockSize; + } + + inline storage_linear::extent_type storage_linear::block_extent() const + { + return this->BlockExtent; + } + + inline storage_linear::extent_type storage_linear::block_count(size_type Level) const + { + GLI_ASSERT(Level >= 0 && Level < this->Levels); + + return glm::max(this->BlockCount >> storage_linear::extent_type(static_cast(Level)), storage_linear::extent_type(1)); + } + + inline storage_linear::extent_type storage_linear::extent(size_type Level) const + { + GLI_ASSERT(Level >= 0 && Level < this->Levels); + + return glm::max(this->Extent >> storage_linear::extent_type(static_cast(Level)), storage_linear::extent_type(1)); + } + + inline storage_linear::size_type storage_linear::size() const + { + GLI_ASSERT(!this->empty()); + + return static_cast(this->Data.size()); + } + + inline storage_linear::data_type* storage_linear::data() + { + GLI_ASSERT(!this->empty()); + + return &this->Data[0]; + } + + inline storage_linear::data_type const* const storage_linear::data() const + { + GLI_ASSERT(!this->empty()); + + return &this->Data[0]; + } + + inline storage_linear::size_type storage_linear::base_offset(size_type Layer, size_type Face, size_type Level) const + { + GLI_ASSERT(!this->empty()); + GLI_ASSERT(Layer >= 0 && Layer < this->layers() && Face >= 0 && Face < this->faces() && Level >= 0 && Level < this->levels()); + + size_type const LayerSize = this->layer_size(0, this->faces() - 1, 0, this->levels() - 1); + size_type const FaceSize = this->face_size(0, this->levels() - 1); + size_type BaseOffset = LayerSize * Layer + FaceSize * Face; + + for(size_type LevelIndex = 0, LevelCount = Level; LevelIndex < LevelCount; ++LevelIndex) + BaseOffset += this->level_size(LevelIndex); + + return BaseOffset; + } + + inline void storage_linear::copy( + storage_linear const& StorageSrc, + size_t LayerSrc, size_t FaceSrc, size_t LevelSrc, extent_type const& BlockIndexSrc, + size_t LayerDst, size_t FaceDst, size_t LevelDst, extent_type const& BlockIndexDst, + extent_type const& BlockCount) + { + storage_linear::size_type const BaseOffsetSrc = StorageSrc.base_offset(LayerSrc, FaceSrc, LevelSrc); + storage_linear::size_type const BaseOffsetDst = this->base_offset(LayerDst, FaceDst, LevelDst); + storage_linear::data_type const* const ImageSrc = StorageSrc.data() + BaseOffsetSrc; + storage_linear::data_type* const ImageDst = this->data() + BaseOffsetDst; + + for(size_t BlockIndexZ = 0, BlockCountZ = BlockCount.z; BlockIndexZ < BlockCountZ; ++BlockIndexZ) + for(size_t BlockIndexY = 0, BlockCountY = BlockCount.y; BlockIndexY < BlockCountY; ++BlockIndexY) + { + extent_type const BlockIndex(0, BlockIndexY, BlockIndexZ); + gli::size_t const OffsetSrc = linear_index(BlockIndexSrc + BlockIndex, this->extent(LevelSrc)) * this->block_size(); + gli::size_t const OffsetDst = linear_index(BlockIndexDst + BlockIndex, this->extent(LevelDst)) * this->block_size(); + storage_linear::data_type const* const DataSrc = ImageSrc + OffsetSrc; + storage_linear::data_type* DataDst = ImageDst + OffsetDst; + memcpy(DataDst, DataSrc, this->block_size() * BlockCount.x); + } + } + + inline storage_linear::size_type storage_linear::level_size(size_type Level) const + { + GLI_ASSERT(Level >= 0 && Level < this->levels()); + + return this->BlockSize * glm::compMul(this->block_count(Level)); + } + + inline storage_linear::size_type storage_linear::face_size(size_type BaseLevel, size_type MaxLevel) const + { + GLI_ASSERT(MaxLevel >= 0 && MaxLevel < this->levels()); + GLI_ASSERT(BaseLevel >= 0 && BaseLevel < this->levels()); + GLI_ASSERT(BaseLevel <= MaxLevel); + + size_type FaceSize(0); + + // The size of a face is the sum of the size of each level. + for(storage_linear::size_type Level(BaseLevel); Level <= MaxLevel; ++Level) + FaceSize += this->level_size(Level); + + return FaceSize; + } + + inline storage_linear::size_type storage_linear::layer_size( + size_type BaseFace, size_type MaxFace, + size_type BaseLevel, size_type MaxLevel) const + { + GLI_ASSERT(BaseFace >= 0 && MaxFace < this->faces()); + GLI_ASSERT(BaseFace >= 0 && BaseFace < this->faces()); + GLI_ASSERT(MaxLevel >= 0 && MaxLevel < this->levels()); + GLI_ASSERT(BaseLevel >= 0 && BaseLevel < this->levels()); + + // The size of a layer is the sum of the size of each face. + // All the faces have the same size. + return this->face_size(BaseLevel, MaxLevel) * (MaxFace - BaseFace + 1); + } +}//namespace gli diff --git a/test/external/gli/core/storage_linear.hpp b/test/external/gli/core/storage_linear.hpp new file mode 100644 index 00000000..d1e3265e --- /dev/null +++ b/test/external/gli/core/storage_linear.hpp @@ -0,0 +1,98 @@ +#pragma once + +// STD +#include +#include +#include +#include +#include +#include +#include + +#include "../type.hpp" +#include "../format.hpp" + +// GLM +#include +#include +#include +#include +#include +#include + +static_assert(GLM_VERSION >= 97, "GLI requires at least GLM 0.9.7"); + +namespace gli +{ + class storage_linear + { + public: + typedef extent3d extent_type; + typedef size_t size_type; + typedef gli::format format_type; + typedef glm::byte data_type; + + public: + storage_linear(); + + storage_linear( + format_type Format, + extent_type const & Extent, + size_type Layers, + size_type Faces, + size_type Levels); + + bool empty() const; + size_type size() const; // Express is bytes + size_type layers() const; + size_type levels() const; + size_type faces() const; + + size_type block_size() const; + extent_type block_extent() const; + extent_type block_count(size_type Level) const; + extent_type extent(size_type Level) const; + + data_type* data(); + data_type const* const data() const; + + /// Compute the relative memory offset to access the data for a specific layer, face and level + size_type base_offset( + size_type Layer, + size_type Face, + size_type Level) const; + + size_type image_offset(extent1d const& Coord, extent1d const& Extent) const; + + size_type image_offset(extent2d const& Coord, extent2d const& Extent) const; + + size_type image_offset(extent3d const& Coord, extent3d const& Extent) const; + + /// Copy a subset of a specific image of a texture + void copy( + storage_linear const& StorageSrc, + size_t LayerSrc, size_t FaceSrc, size_t LevelSrc, extent_type const& BlockIndexSrc, + size_t LayerDst, size_t FaceDst, size_t LevelDst, extent_type const& BlockIndexDst, + extent_type const& BlockCount); + + size_type level_size( + size_type Level) const; + size_type face_size( + size_type BaseLevel, size_type MaxLevel) const; + size_type layer_size( + size_type BaseFace, size_type MaxFace, + size_type BaseLevel, size_type MaxLevel) const; + + private: + size_type const Layers; + size_type const Faces; + size_type const Levels; + size_type const BlockSize; + extent_type const BlockCount; + extent_type const BlockExtent; + extent_type const Extent; + std::vector Data; + }; +}//namespace gli + +#include "storage_linear.inl" diff --git a/test/external/gli/core/storage_linear.inl b/test/external/gli/core/storage_linear.inl new file mode 100644 index 00000000..497f2b16 --- /dev/null +++ b/test/external/gli/core/storage_linear.inl @@ -0,0 +1,186 @@ +namespace gli +{ + inline storage_linear::storage_linear() + : Layers(0) + , Faces(0) + , Levels(0) + , BlockSize(0) + , BlockCount(0) + , BlockExtent(0) + , Extent(0) + {} + + inline storage_linear::storage_linear(format_type Format, extent_type const& Extent, size_type Layers, size_type Faces, size_type Levels) + : Layers(Layers) + , Faces(Faces) + , Levels(Levels) + , BlockSize(gli::block_size(Format)) + , BlockCount(glm::ceilMultiple(Extent, gli::block_extent(Format)) / gli::block_extent(Format)) + , BlockExtent(gli::block_extent(Format)) + , Extent(Extent) + { + GLI_ASSERT(Layers > 0); + GLI_ASSERT(Faces > 0); + GLI_ASSERT(Levels > 0); + GLI_ASSERT(glm::all(glm::greaterThan(Extent, extent_type(0)))); + + this->Data.resize(this->layer_size(0, Faces - 1, 0, Levels - 1) * Layers, 0); + } + + inline bool storage_linear::empty() const + { + return this->Data.empty(); + } + + inline storage_linear::size_type storage_linear::layers() const + { + return this->Layers; + } + + inline storage_linear::size_type storage_linear::faces() const + { + return this->Faces; + } + + inline storage_linear::size_type storage_linear::levels() const + { + return this->Levels; + } + + inline storage_linear::size_type storage_linear::block_size() const + { + return this->BlockSize; + } + + inline storage_linear::extent_type storage_linear::block_extent() const + { + return this->BlockExtent; + } + + inline storage_linear::extent_type storage_linear::block_count(size_type Level) const + { + GLI_ASSERT(Level >= 0 && Level < this->Levels); + + return glm::ceilMultiple(this->extent(Level), BlockExtent) / BlockExtent; + } + + inline storage_linear::extent_type storage_linear::extent(size_type Level) const + { + GLI_ASSERT(Level >= 0 && Level < this->Levels); + + return glm::max(this->Extent >> storage_linear::extent_type(static_cast(Level)), storage_linear::extent_type(1)); + } + + inline storage_linear::size_type storage_linear::size() const + { + GLI_ASSERT(!this->empty()); + + return static_cast(this->Data.size()); + } + + inline storage_linear::data_type* storage_linear::data() + { + GLI_ASSERT(!this->empty()); + + return &this->Data[0]; + } + + inline storage_linear::data_type const* const storage_linear::data() const + { + GLI_ASSERT(!this->empty()); + + return &this->Data[0]; + } + + inline storage_linear::size_type storage_linear::base_offset(size_type Layer, size_type Face, size_type Level) const + { + GLI_ASSERT(!this->empty()); + GLI_ASSERT(Layer >= 0 && Layer < this->layers() && Face >= 0 && Face < this->faces() && Level >= 0 && Level < this->levels()); + + size_type const LayerSize = this->layer_size(0, this->faces() - 1, 0, this->levels() - 1); + size_type const FaceSize = this->face_size(0, this->levels() - 1); + size_type BaseOffset = LayerSize * Layer + FaceSize * Face; + + for(size_type LevelIndex = 0, LevelCount = Level; LevelIndex < LevelCount; ++LevelIndex) + BaseOffset += this->level_size(LevelIndex); + + return BaseOffset; + } + + inline storage_linear::size_type storage_linear::image_offset(extent1d const& Coord, extent1d const& Extent) const + { + GLI_ASSERT(glm::all(glm::lessThan(Coord, Extent))); + return static_cast(Coord.x); + } + + inline storage_linear::size_type storage_linear::image_offset(extent2d const& Coord, extent2d const& Extent) const + { + GLI_ASSERT(glm::all(glm::lessThan(Coord, Extent))); + return static_cast(Coord.x + Coord.y * Extent.x); + } + + inline storage_linear::size_type storage_linear::image_offset(extent3d const& Coord, extent3d const& Extent) const + { + GLI_ASSERT(glm::all(glm::lessThan(Coord, Extent))); + return static_cast(Coord.x + Coord.y * Extent.x + Coord.z * Extent.x * Extent.y); + } + + inline void storage_linear::copy( + storage_linear const& StorageSrc, + size_t LayerSrc, size_t FaceSrc, size_t LevelSrc, extent_type const& BlockIndexSrc, + size_t LayerDst, size_t FaceDst, size_t LevelDst, extent_type const& BlockIndexDst, + extent_type const& BlockCount) + { + storage_linear::size_type const BaseOffsetSrc = StorageSrc.base_offset(LayerSrc, FaceSrc, LevelSrc); + storage_linear::size_type const BaseOffsetDst = this->base_offset(LayerDst, FaceDst, LevelDst); + storage_linear::data_type const* const ImageSrc = StorageSrc.data() + BaseOffsetSrc; + storage_linear::data_type* const ImageDst = this->data() + BaseOffsetDst; + + for(size_t BlockIndexZ = 0, BlockCountZ = BlockCount.z; BlockIndexZ < BlockCountZ; ++BlockIndexZ) + for(size_t BlockIndexY = 0, BlockCountY = BlockCount.y; BlockIndexY < BlockCountY; ++BlockIndexY) + { + extent_type const BlockIndex(0, BlockIndexY, BlockIndexZ); + gli::size_t const OffsetSrc = this->image_offset(BlockIndexSrc + BlockIndex, this->extent(LevelSrc)) * this->block_size(); + gli::size_t const OffsetDst = this->image_offset(BlockIndexDst + BlockIndex, this->extent(LevelDst)) * this->block_size(); + storage_linear::data_type const* const DataSrc = ImageSrc + OffsetSrc; + storage_linear::data_type* DataDst = ImageDst + OffsetDst; + memcpy(DataDst, DataSrc, this->block_size() * BlockCount.x); + } + } + + inline storage_linear::size_type storage_linear::level_size(size_type Level) const + { + GLI_ASSERT(Level >= 0 && Level < this->levels()); + + return this->BlockSize * glm::compMul(this->block_count(Level)); + } + + inline storage_linear::size_type storage_linear::face_size(size_type BaseLevel, size_type MaxLevel) const + { + GLI_ASSERT(MaxLevel >= 0 && MaxLevel < this->levels()); + GLI_ASSERT(BaseLevel >= 0 && BaseLevel < this->levels()); + GLI_ASSERT(BaseLevel <= MaxLevel); + + size_type FaceSize(0); + + // The size of a face is the sum of the size of each level. + for(storage_linear::size_type Level(BaseLevel); Level <= MaxLevel; ++Level) + FaceSize += this->level_size(Level); + + return FaceSize; + } + + inline storage_linear::size_type storage_linear::layer_size( + size_type BaseFace, size_type MaxFace, + size_type BaseLevel, size_type MaxLevel) const + { + GLI_ASSERT(BaseFace >= 0 && MaxFace < this->faces()); + GLI_ASSERT(BaseFace >= 0 && BaseFace < this->faces()); + GLI_ASSERT(MaxLevel >= 0 && MaxLevel < this->levels()); + GLI_ASSERT(BaseLevel >= 0 && BaseLevel < this->levels()); + + // The size of a layer is the sum of the size of each face. + // All the faces have the same size. + return this->face_size(BaseLevel, MaxLevel) * (MaxFace - BaseFace + 1); + } +}//namespace gli diff --git a/test/external/gli/core/texture.inl b/test/external/gli/core/texture.inl new file mode 100644 index 00000000..dc6e892e --- /dev/null +++ b/test/external/gli/core/texture.inl @@ -0,0 +1,410 @@ +#include + +namespace gli +{ + inline texture::texture() + : Storage(nullptr) + , Target(static_cast(TARGET_INVALID)) + , Format(static_cast(FORMAT_INVALID)) + , BaseLayer(0), MaxLayer(0) + , BaseFace(0), MaxFace(0) + , BaseLevel(0), MaxLevel(0) + , Swizzles(SWIZZLE_ZERO) + , Cache(cache::DEFAULT) + {} + + inline texture::texture + ( + target_type Target, + format_type Format, + extent_type const& Extent, + size_type Layers, + size_type Faces, + size_type Levels, + swizzles_type const& Swizzles + ) + : Storage(std::make_shared(Format, Extent, Layers, Faces, Levels)) + , Target(Target) + , Format(Format) + , BaseLayer(0), MaxLayer(Layers - 1) + , BaseFace(0), MaxFace(Faces - 1) + , BaseLevel(0), MaxLevel(Levels - 1) + , Swizzles(Swizzles) + , Cache(*Storage, Format, this->base_layer(), this->layers(), this->base_face(), this->max_face(), this->base_level(), this->max_level()) + { + GLI_ASSERT(Target != TARGET_CUBE || (Target == TARGET_CUBE && Extent.x == Extent.y)); + GLI_ASSERT(Target != TARGET_CUBE_ARRAY || (Target == TARGET_CUBE_ARRAY && Extent.x == Extent.y)); + } + + inline texture::texture + ( + texture const& Texture, + target_type Target, + format_type Format, + size_type BaseLayer, size_type MaxLayer, + size_type BaseFace, size_type MaxFace, + size_type BaseLevel, size_type MaxLevel, + swizzles_type const& Swizzles + ) + : Storage(Texture.Storage) + , Target(Target) + , Format(Format) + , BaseLayer(BaseLayer), MaxLayer(MaxLayer) + , BaseFace(BaseFace), MaxFace(MaxFace) + , BaseLevel(BaseLevel), MaxLevel(MaxLevel) + , Swizzles(Swizzles) + , Cache(*Storage, Format, this->base_layer(), this->layers(), this->base_face(), this->max_face(), this->base_level(), this->max_level()) + { + GLI_ASSERT(block_size(Format) == block_size(Texture.format())); + GLI_ASSERT(Target != TARGET_1D || (Target == TARGET_1D && this->layers() == 1 && this->faces() == 1 && this->extent().y == 1 && this->extent().z == 1)); + GLI_ASSERT(Target != TARGET_1D_ARRAY || (Target == TARGET_1D_ARRAY && this->layers() >= 1 && this->faces() == 1 && this->extent().y == 1 && this->extent().z == 1)); + GLI_ASSERT(Target != TARGET_2D || (Target == TARGET_2D && this->layers() == 1 && this->faces() == 1 && this->extent().y >= 1 && this->extent().z == 1)); + GLI_ASSERT(Target != TARGET_2D_ARRAY || (Target == TARGET_2D_ARRAY && this->layers() >= 1 && this->faces() == 1 && this->extent().y >= 1 && this->extent().z == 1)); + GLI_ASSERT(Target != TARGET_3D || (Target == TARGET_3D && this->layers() == 1 && this->faces() == 1 && this->extent().y >= 1 && this->extent().z >= 1)); + GLI_ASSERT(Target != TARGET_CUBE || (Target == TARGET_CUBE && this->layers() == 1 && this->faces() >= 1 && this->extent().y >= 1 && this->extent().z == 1)); + GLI_ASSERT(Target != TARGET_CUBE_ARRAY || (Target == TARGET_CUBE_ARRAY && this->layers() >= 1 && this->faces() >= 1 && this->extent().y >= 1 && this->extent().z == 1)); + } + + inline texture::texture + ( + texture const& Texture, + target_type Target, + format_type Format, + swizzles_type const& Swizzles + ) + : Storage(Texture.Storage) + , Target(Target) + , Format(Format) + , BaseLayer(Texture.base_layer()), MaxLayer(Texture.max_layer()) + , BaseFace(Texture.base_face()), MaxFace(Texture.max_face()) + , BaseLevel(Texture.base_level()), MaxLevel(Texture.max_level()) + , Swizzles(Swizzles) + , Cache(*Storage, Format, this->base_layer(), this->layers(), this->base_face(), this->max_face(), this->base_level(), this->max_level()) + { + if(this->empty()) + return; + + GLI_ASSERT(Target != TARGET_1D || (Target == TARGET_1D && this->layers() == 1 && this->faces() == 1 && this->extent().y == 1 && this->extent().z == 1)); + GLI_ASSERT(Target != TARGET_1D_ARRAY || (Target == TARGET_1D_ARRAY && this->layers() >= 1 && this->faces() == 1 && this->extent().y == 1 && this->extent().z == 1)); + GLI_ASSERT(Target != TARGET_2D || (Target == TARGET_2D && this->layers() == 1 && this->faces() == 1 && this->extent().y >= 1 && this->extent().z == 1)); + GLI_ASSERT(Target != TARGET_2D_ARRAY || (Target == TARGET_2D_ARRAY && this->layers() >= 1 && this->faces() == 1 && this->extent().y >= 1 && this->extent().z == 1)); + GLI_ASSERT(Target != TARGET_3D || (Target == TARGET_3D && this->layers() == 1 && this->faces() == 1 && this->extent().y >= 1 && this->extent().z >= 1)); + GLI_ASSERT(Target != TARGET_CUBE || (Target == TARGET_CUBE && this->layers() == 1 && this->faces() >= 1 && this->extent().y >= 1 && this->extent().z == 1)); + GLI_ASSERT(Target != TARGET_CUBE_ARRAY || (Target == TARGET_CUBE_ARRAY && this->layers() >= 1 && this->faces() >= 1 && this->extent().y >= 1 && this->extent().z == 1)); + } + + inline bool texture::empty() const + { + if(this->Storage.get() == nullptr) + return true; + + return this->Storage->empty(); + } + + inline texture::format_type texture::format() const + { + return this->Format; + } + + inline texture::swizzles_type texture::swizzles() const + { + swizzles_type const FormatSwizzle = detail::get_format_info(this->format()).Swizzles; + swizzles_type const CustomSwizzle = this->Swizzles; + + swizzles_type ResultSwizzle(SWIZZLE_ZERO); + ResultSwizzle.r = is_channel(CustomSwizzle.r) ? FormatSwizzle[CustomSwizzle.r] : CustomSwizzle.r; + ResultSwizzle.g = is_channel(CustomSwizzle.g) ? FormatSwizzle[CustomSwizzle.g] : CustomSwizzle.g; + ResultSwizzle.b = is_channel(CustomSwizzle.b) ? FormatSwizzle[CustomSwizzle.b] : CustomSwizzle.b; + ResultSwizzle.a = is_channel(CustomSwizzle.a) ? FormatSwizzle[CustomSwizzle.a] : CustomSwizzle.a; + return ResultSwizzle; + } + + inline texture::size_type texture::base_layer() const + { + return this->BaseLayer; + } + + inline texture::size_type texture::max_layer() const + { + return this->MaxLayer; + } + + inline texture::size_type texture::layers() const + { + if(this->empty()) + return 0; + return this->max_layer() - this->base_layer() + 1; + } + + inline texture::size_type texture::base_face() const + { + return this->BaseFace; + } + + inline texture::size_type texture::max_face() const + { + return this->MaxFace; + } + + inline texture::size_type texture::faces() const + { + if(this->empty()) + return 0; + return this->max_face() - this->base_face() + 1; + } + + inline texture::size_type texture::base_level() const + { + return this->BaseLevel; + } + + inline texture::size_type texture::max_level() const + { + return this->MaxLevel; + } + + inline texture::size_type texture::levels() const + { + if(this->empty()) + return 0; + return this->max_level() - this->base_level() + 1; + } + + inline texture::size_type texture::size() const + { + GLI_ASSERT(!this->empty()); + + return this->Cache.get_memory_size(); + } + + template + inline texture::size_type texture::size() const + { + GLI_ASSERT(!this->empty()); + GLI_ASSERT(block_size(this->format()) == sizeof(gen_type)); + + return this->size() / sizeof(gen_type); + } + + inline texture::size_type texture::size(size_type Level) const + { + GLI_ASSERT(!this->empty()); + GLI_ASSERT(Level >= 0 && Level < this->levels()); + + return this->Cache.get_memory_size(Level); + } + + template + inline texture::size_type texture::size(size_type Level) const + { + GLI_ASSERT(block_size(this->format()) == sizeof(gen_type)); + + return this->size(Level) / sizeof(gen_type); + } + + inline void* texture::data() + { + GLI_ASSERT(!this->empty()); + + return this->Cache.get_base_address(0, 0, 0); + } + + inline void const* texture::data() const + { + GLI_ASSERT(!this->empty()); + + return this->Cache.get_base_address(0, 0, 0); + } + + template + inline gen_type* texture::data() + { + GLI_ASSERT(block_size(this->format()) >= sizeof(gen_type)); + + return reinterpret_cast(this->data()); + } + + template + inline gen_type const* texture::data() const + { + GLI_ASSERT(block_size(this->format()) >= sizeof(gen_type)); + + return reinterpret_cast(this->data()); + } + + inline void* texture::data(size_type Layer, size_type Face, size_type Level) + { + GLI_ASSERT(!this->empty()); + GLI_ASSERT(Layer >= 0 && Layer < this->layers() && Face >= 0 && Face < this->faces() && Level >= 0 && Level < this->levels()); + + return this->Cache.get_base_address(Layer, Face, Level); + } + + inline void const* const texture::data(size_type Layer, size_type Face, size_type Level) const + { + GLI_ASSERT(!this->empty()); + GLI_ASSERT(Layer >= 0 && Layer < this->layers() && Face >= 0 && Face < this->faces() && Level >= 0 && Level < this->levels()); + + return this->Cache.get_base_address(Layer, Face, Level); + } + + template + inline gen_type* texture::data(size_type Layer, size_type Face, size_type Level) + { + GLI_ASSERT(block_size(this->format()) >= sizeof(gen_type)); + + return reinterpret_cast(this->data(Layer, Face, Level)); + } + + template + inline gen_type const* const texture::data(size_type Layer, size_type Face, size_type Level) const + { + GLI_ASSERT(block_size(this->format()) >= sizeof(gen_type)); + + return reinterpret_cast(this->data(Layer, Face, Level)); + } + + inline texture::extent_type texture::extent(size_type Level) const + { + GLI_ASSERT(!this->empty()); + GLI_ASSERT(Level >= 0 && Level < this->levels()); + + return this->Cache.get_extent(Level); + } + + inline void texture::clear() + { + GLI_ASSERT(!this->empty()); + + memset(this->data(), 0, this->size()); + } + + template + inline void texture::clear(gen_type const& Texel) + { + GLI_ASSERT(!this->empty()); + GLI_ASSERT(block_size(this->format()) == sizeof(gen_type)); + + gen_type* Data = this->data(); + size_type const BlockCount = this->size(); + + for(size_type BlockIndex = 0; BlockIndex < BlockCount; ++BlockIndex) + *(Data + BlockIndex) = Texel; + } + + template + inline void texture::clear(size_type Layer, size_type Face, size_type Level, gen_type const& BlockData) + { + GLI_ASSERT(!this->empty()); + GLI_ASSERT(block_size(this->format()) == sizeof(gen_type)); + GLI_ASSERT(Layer >= 0 && Layer < this->layers() && Face >= 0 && Face < this->faces() && Level >= 0 && Level < this->levels()); + + size_type const BlockCount = this->Storage->level_size(Level) / sizeof(gen_type); + gen_type* Data = this->data(Layer, Face, Level); + for(size_type BlockIndex = 0; BlockIndex < BlockCount; ++BlockIndex) + *(Data + BlockIndex) = BlockData; + } + + template + inline void texture::clear + ( + size_type Layer, size_type Face, size_type Level, + extent_type const& TexelOffset, extent_type const& TexelExtent, + gen_type const& BlockData + ) + { + storage_type::size_type const BaseOffset = this->Storage->base_offset(Layer, Face, Level); + storage_type::data_type* const BaseAddress = this->Storage->data() + BaseOffset; + + extent_type BlockOffset(TexelOffset / this->Storage->block_extent()); + extent_type const BlockExtent(TexelExtent / this->Storage->block_extent() + BlockOffset); + for(; BlockOffset.z < BlockExtent.z; ++BlockOffset.z) + for(; BlockOffset.y < BlockExtent.y; ++BlockOffset.y) + for(; BlockOffset.x < BlockExtent.x; ++BlockOffset.x) + { + gli::size_t const Offset = this->Storage->image_offset(BlockOffset, this->extent(Level)) * this->Storage->block_size(); + gen_type* const BlockAddress = reinterpret_cast(BaseAddress + Offset); + *BlockAddress = BlockData; + } + } + + inline void texture::copy + ( + texture const& TextureSrc, + size_t LayerSrc, size_t FaceSrc, size_t LevelSrc, + size_t LayerDst, size_t FaceDst, size_t LevelDst + ) + { + GLI_ASSERT(this->size(LevelDst) == TextureSrc.size(LevelSrc)); + GLI_ASSERT(LayerSrc < TextureSrc.layers()); + GLI_ASSERT(LayerDst < this->layers()); + GLI_ASSERT(FaceSrc < TextureSrc.faces()); + GLI_ASSERT(FaceDst < this->faces()); + GLI_ASSERT(LevelSrc < TextureSrc.levels()); + GLI_ASSERT(LevelDst < this->levels()); + + memcpy( + this->data(LayerDst, FaceDst, LevelDst), + TextureSrc.data(LayerSrc, FaceSrc, LevelSrc), + this->size(LevelDst)); + } + + inline void texture::copy + ( + texture const& TextureSrc, + size_t LayerSrc, size_t FaceSrc, size_t LevelSrc, texture::extent_type const& OffsetSrc, + size_t LayerDst, size_t FaceDst, size_t LevelDst, texture::extent_type const& OffsetDst, + texture::extent_type const& Extent + ) + { + storage_type::extent_type const BlockExtent = this->Storage->block_extent(); + this->Storage->copy( + *TextureSrc.Storage, + LayerSrc, FaceSrc, LevelSrc, OffsetSrc / BlockExtent, + LayerSrc, FaceSrc, LevelSrc, OffsetSrc / BlockExtent, + Extent / BlockExtent); + } + + template + inline void texture::swizzle(gli::swizzles const& Swizzles) + { + for(size_type TexelIndex = 0, TexelCount = this->size(); TexelIndex < TexelCount; ++TexelIndex) + { + gen_type& TexelDst = *(this->data() + TexelIndex); + gen_type const TexelSrc = TexelDst; + for(typename gen_type::length_type Component = 0; Component < TexelDst.length(); ++Component) + { + GLI_ASSERT(static_cast(Swizzles[Component]) < TexelDst.length()); + TexelDst[Component] = TexelSrc[Swizzles[Component]]; + } + } + } + + template + inline gen_type texture::load(extent_type const& TexelCoord, size_type Layer, size_type Face, size_type Level) const + { + GLI_ASSERT(!this->empty()); + GLI_ASSERT(!is_compressed(this->format())); + GLI_ASSERT(block_size(this->format()) == sizeof(gen_type)); + + size_type const ImageOffset = this->Storage->image_offset(TexelCoord, this->extent(Level)); + GLI_ASSERT(ImageOffset < this->size(Level)); + + return *(this->data(Layer, Face, Level) + ImageOffset); + } + + template + inline void texture::store(extent_type const& TexelCoord, size_type Layer, size_type Face, size_type Level, gen_type const& Texel) + { + GLI_ASSERT(!this->empty()); + GLI_ASSERT(!is_compressed(this->format())); + GLI_ASSERT(block_size(this->format()) == sizeof(gen_type)); + GLI_ASSERT(glm::all(glm::lessThan(TexelCoord, this->extent(Level)))); + + size_type const ImageOffset = this->Storage->image_offset(TexelCoord, this->extent(Level)); + GLI_ASSERT(ImageOffset < this->size(Level)); + + *(this->data(Layer, Face, Level) + ImageOffset) = Texel; + } +}//namespace gli + diff --git a/test/external/gli/core/texture1d.inl b/test/external/gli/core/texture1d.inl new file mode 100644 index 00000000..152fbb9e --- /dev/null +++ b/test/external/gli/core/texture1d.inl @@ -0,0 +1,79 @@ +#include "../levels.hpp" + +namespace gli +{ + inline texture1d::texture1d() + {} + + inline texture1d::texture1d(format_type Format, extent_type const& Extent, swizzles_type const& Swizzles) + : texture(TARGET_1D, Format, texture::extent_type(Extent.x, 1, 1), 1, 1, gli::levels(Extent), Swizzles) + {} + + inline texture1d::texture1d(format_type Format, extent_type const& Extent, size_type Levels, swizzles_type const& Swizzles) + : texture(TARGET_1D, Format, texture::extent_type(Extent.x, 1, 1), 1, 1, Levels, Swizzles) + {} + + inline texture1d::texture1d(texture const& Texture) + : texture(Texture, TARGET_1D, Texture.format()) + {} + + inline texture1d::texture1d + ( + texture const& Texture, + format_type Format, + size_type BaseLayer, size_type MaxLayer, + size_type BaseFace, size_type MaxFace, + size_type BaseLevel, size_type MaxLevel, + swizzles_type const& Swizzles + ) + : texture( + Texture, TARGET_1D, + Format, + BaseLayer, MaxLayer, + BaseFace, MaxFace, + BaseLevel, MaxLevel, + Swizzles) + {} + + inline texture1d::texture1d + ( + texture1d const& Texture, + size_type BaseLevel, size_type MaxLevel + ) + : texture( + Texture, TARGET_1D, + Texture.format(), + Texture.base_layer(), Texture.max_layer(), + Texture.base_face(), Texture.max_face(), + Texture.base_level() + BaseLevel, Texture.base_level() + MaxLevel) + {} + + inline image texture1d::operator[](texture1d::size_type Level) const + { + GLI_ASSERT(Level < this->levels()); + + return image( + this->Storage, + this->format(), + this->base_layer(), + this->base_face(), + this->base_level() + Level); + } + + inline texture1d::extent_type texture1d::extent(size_type Level) const + { + return extent_type(this->texture::extent(Level)); + } + + template + inline gen_type texture1d::load(extent_type const& TexelCoord, size_type Level) const + { + return this->texture::load(texture::extent_type(TexelCoord.x, 0, 0), 0, 0, Level); + } + + template + inline void texture1d::store(extent_type const& TexelCoord, size_type Level, gen_type const& Texel) + { + this->texture::store(texture::extent_type(TexelCoord.x, 0, 0), 0, 0, Level, Texel); + } +}//namespace gli diff --git a/test/external/gli/core/texture1d_array.inl b/test/external/gli/core/texture1d_array.inl new file mode 100644 index 00000000..9c1c7a36 --- /dev/null +++ b/test/external/gli/core/texture1d_array.inl @@ -0,0 +1,81 @@ +#include "../levels.hpp" + +namespace gli +{ + inline texture1d_array::texture1d_array() + {} + + inline texture1d_array::texture1d_array(format_type Format, extent_type const& Extent, size_type Layers, swizzles_type const& Swizzles) + : texture(TARGET_1D_ARRAY, Format, texture::extent_type(Extent.x, 1, 1), Layers, 1, gli::levels(Extent), Swizzles) + {} + + inline texture1d_array::texture1d_array(format_type Format, extent_type const& Extent, size_type Layers, size_type Levels, swizzles_type const& Swizzles) + : texture(TARGET_1D_ARRAY, Format, texture::extent_type(Extent.x, 1, 1), Layers, 1, Levels, Swizzles) + {} + + inline texture1d_array::texture1d_array(texture const& Texture) + : texture(Texture, TARGET_1D_ARRAY, Texture.format()) + {} + + inline texture1d_array::texture1d_array + ( + texture const& Texture, + format_type Format, + size_type BaseLayer, size_type MaxLayer, + size_type BaseFace, size_type MaxFace, + size_type BaseLevel, size_type MaxLevel, + swizzles_type const& Swizzles + ) + : texture( + Texture, TARGET_1D_ARRAY, Format, + BaseLayer, MaxLayer, + BaseFace, MaxFace, + BaseLevel, MaxLevel, + Swizzles) + {} + + inline texture1d_array::texture1d_array + ( + texture1d_array const& Texture, + size_type BaseLayer, size_type MaxLayer, + size_type BaseLevel, size_type MaxLevel + ) + : texture( + Texture, TARGET_1D_ARRAY, + Texture.format(), + Texture.base_layer() + BaseLayer, Texture.base_layer() + MaxLayer, + Texture.base_face(), Texture.max_face(), + Texture.base_level() + BaseLevel, Texture.base_level() + MaxLevel) + {} + + inline texture1d texture1d_array::operator[](size_type Layer) const + { + GLI_ASSERT(!this->empty()); + GLI_ASSERT(Layer < this->layers()); + + return texture1d( + *this, this->format(), + this->base_layer() + Layer, this->base_layer() + Layer, + this->base_face(), this->max_face(), + this->base_level(), this->max_level()); + } + + inline texture1d_array::extent_type texture1d_array::extent(size_type Level) const + { + return extent_type(this->texture::extent(Level)); + } + + template + inline gen_type texture1d_array::load(extent_type const& TexelCoord, size_type Layer, size_type Level) const + { + return this->texture::load(texture::extent_type(TexelCoord.x, 0, 0), Layer, 0, Level); + } + + template + inline void texture1d_array::store(extent_type const& TexelCoord, size_type Layer, size_type Level, gen_type const& Texel) + { + this->texture::store(texture::extent_type(TexelCoord.x, 0, 0), Layer, 0, Level, Texel); + } +}//namespace gli + + diff --git a/test/external/gli/core/texture2d.hpp b/test/external/gli/core/texture2d.hpp deleted file mode 100644 index b5327c29..00000000 --- a/test/external/gli/core/texture2d.hpp +++ /dev/null @@ -1,122 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////////////////////////// -// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net) -/////////////////////////////////////////////////////////////////////////////////////////////////// -// Created : 2010-01-09 -// Updated : 2010-01-09 -// Licence : This source is under MIT License -// File : gli/core/texture2d.hpp -/////////////////////////////////////////////////////////////////////////////////////////////////// - -#ifndef GLI_CORE_TEXTURE2D_INCLUDED -#define GLI_CORE_TEXTURE2D_INCLUDED - -#include "image2d.hpp" - -namespace gli -{ - enum comp - { - X = 0, - R = 0, - S = 0, - Y = 1, - G = 1, - T = 1, - Z = 2, - B = 2, - P = 2, - W = 3, - A = 3, - Q = 3 - }; - - //template