Removed GLI

This commit is contained in:
Christophe Riccio 2017-08-09 22:42:56 +02:00
parent 5d77861141
commit e079fa0569
99 changed files with 0 additions and 12140 deletions

View file

@ -1,32 +0,0 @@
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)
file(GLOB_RECURSE CORE_HEADER ./core/*.hpp)
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})
source_group("GTX Files" FILES ${GTX_SOURCE})
source_group("GTX Files" FILES ${GTX_INLINE})
source_group("GTX Files" FILES ${GTX_HEADER})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
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})

View file

@ -1,46 +0,0 @@
/// @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 <typename texture_type>
void clear(texture_type& Texture);
/// Clear a complete texture
template <typename texture_type, typename gen_type>
void clear(texture_type& Texture, gen_type const& BlockData);
/// Clear a specific image of a texture
template <typename texture_type, typename gen_type>
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 <typename texture_type, typename gen_type>
void clear_level(texture_type& Texture, size_t BaseLevel, gen_type const& BlockData);
// Clear multiple levels of a texture
template <typename texture_type, typename gen_type>
void clear_level(texture_type& Texture, size_t BaseLevel, size_t LevelCount, gen_type const& BlockData);
// Clear an entire face of a texture
template <typename texture_type, typename gen_type>
void clear_face(texture_type& Texture, size_t BaseFace, gen_type const& BlockData);
// Clear multiple faces of a texture
template <typename texture_type, typename gen_type>
void clear_face(texture_type& Texture, size_t BaseFace, size_t FaceCount, gen_type const& BlockData);
// Clear an entire layer of a texture
template <typename texture_type, typename gen_type>
void clear_layer(texture_type& Texture, size_t BaseLayer, gen_type const& BlockData);
// Clear multiple layers of a texture
template <typename texture_type, typename gen_type>
void clear_layer(texture_type& Texture, size_t BaseLayer, size_t LayerCount, gen_type const& BlockData);
}//namespace gli
#include "./core/clear.inl"

View file

@ -1,30 +0,0 @@
/// @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"

View file

@ -1,24 +0,0 @@
/// @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 <typename texture_type>
texture_type convert(texture_type const& Texture, format Format);
}//namespace gli
#include "./core/convert.inl"

View file

@ -1,62 +0,0 @@
/// @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 <typename texture_src_type, typename texture_dst_type>
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 <typename texture_src_type, typename texture_dst_type>
void copy(
texture_src_type const& TextureSrc,
texture_dst_type& TextureDst);
// Copy an entire level of a texture
template <typename texture_src_type, typename texture_dst_type>
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 <typename texture_src_type, typename texture_dst_type>
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 <typename texture_src_type, typename texture_dst_type>
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 <typename texture_src_type, typename texture_dst_type>
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 <typename texture_src_type, typename texture_dst_type>
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 <typename texture_src_type, typename texture_dst_type>
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"

View file

@ -1,25 +0,0 @@
#pragma once
#include "convert_func.hpp"
namespace gli{
namespace detail
{
template <typename textureType, typename T, precision P>
struct clear
{
static void call(textureType & Texture, typename convert<textureType, T, P>::writeFunc Write, vec<4, T, P> 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<std::uint8_t*>(Texture.data()) + BlockSize * BlockIndex, Texel.data(), BlockSize);
}
};
}//namespace detail
}//namespace gli

View file

@ -1,71 +0,0 @@
namespace gli
{
template <typename texture_type>
inline void clear(texture_type& Texture)
{
Texture.clear();
}
template <typename texture_type, typename gen_type>
inline void clear(texture_type& Texture, gen_type const& BlockData)
{
Texture.clear(BlockData);
}
template <typename texture_type, typename gen_type>
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 <typename texture_type, typename gen_type>
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<gen_type>(LayerIndex, FaceIndex, BaseLevel + LevelIndex, BlockData);
}
}
template <typename texture_type, typename gen_type>
inline void clear_level(texture_type& Texture, size_t BaseLevel, gen_type const& BlockData)
{
clear_level(Texture, BaseLevel, 1, BlockData);
}
template <typename texture_type, typename gen_type>
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<gen_type>(LayerIndex, BaseFace + FaceIndex, LevelIndex, BlockData);
}
}
template <typename texture_type, typename gen_type>
inline void clear_face(texture_type& Texture, size_t BaseFace, gen_type const& BlockData)
{
clear_face(Texture, BaseFace, 1, BlockData);
}
template <typename texture_type, typename gen_type>
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<gen_type>(LayerIndex + BaseLayer, FaceIndex, LevelIndex, BlockData);
}
}
template <typename texture_type, typename gen_type>
inline void clear_layer(texture_type& Texture, size_t BaseLayer, gen_type const& BlockData)
{
clear_layer(Texture, BaseLayer, 1, BlockData);
}
}//namespace gli

View file

@ -1,100 +0,0 @@
#include <cstring>
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

View file

@ -1,45 +0,0 @@
#include "../core/convert_func.hpp"
namespace gli
{
template <typename texture_type>
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<texture_type, T, defaultp>::fetchFunc fetch_type;
typedef typename detail::convert<texture_type, T, defaultp>::writeFunc write_type;
GLI_ASSERT(!Texture.empty());
GLI_ASSERT(!is_compressed(Texture.format()) && !is_compressed(Format));
fetch_type Fetch = detail::convert<texture_type, T, defaultp>::call(Texture.format()).Fetch;
write_type Write = detail::convert<texture_type, T, defaultp>::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

View file

@ -1,767 +0,0 @@
#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 <glm/gtc/packing.hpp>
#include <glm/gtc/color_space.hpp>
#include <limits>
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 <typename textureType, typename genType>
struct accessFunc
{};
template <typename genType>
struct accessFunc<texture1d, genType>
{
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<genType>(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<genType>(TexelCoord, Level, Texel);
}
};
template <typename genType>
struct accessFunc<texture1d_array, genType>
{
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<genType>(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<genType>(TexelCoord, Layer, Level, Texel);
}
};
template <typename genType>
struct accessFunc<texture2d, genType>
{
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<genType>(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<genType>(TexelCoord, Level, Texel);
}
};
template <typename genType>
struct accessFunc<texture2d_array, genType>
{
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<genType>(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<genType>(TexelCoord, Layer, Level, Texel);
}
};
template <typename genType>
struct accessFunc<texture3d, genType>
{
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<genType>(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<genType>(TexelCoord, Level, Texel);
}
};
template <typename genType>
struct accessFunc<texture_cube, genType>
{
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<genType>(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<genType>(TexelCoord, Face, Level, Texel);
}
};
template <typename genType>
struct accessFunc<texture_cube_array, genType>
{
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<genType>(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<genType>(TexelCoord, Layer, Face, Level, Texel);
}
};
// convertFunc class
template <typename textureType, typename retType, length_t L, typename T, precision P, convertMode mode = CONVERT_MODE_CAST, bool isSamplerFloat = false>
struct convertFunc
{
typedef accessFunc<textureType, vec<L, T, P> > access;
static vec<4, retType, P> 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<retType, P>(vec<L, retType, P>(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, vec<4, retType, P> const & Texel)
{
access::store(Texture, TexelCoord, Layer, Face, Level, vec<L, T, P>(Texel));
}
};
template <typename textureType, typename retType, length_t L, typename T, precision P, bool isSamplerFloat>
struct convertFunc<textureType, retType, L, T, P, CONVERT_MODE_DEFAULT, isSamplerFloat>
{
static vec<4, retType, P> 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 vec<4, retType, P>(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, vec<4, retType, P> const & Texel)
{}
};
template <typename textureType, typename retType, length_t L, typename T, precision P>
struct convertFunc<textureType, retType, L, T, P, CONVERT_MODE_NORM, true>
{
typedef accessFunc<textureType, vec<L, T, P> > access;
static vec<4, retType, P> 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<retType>::is_iec559, "CONVERT_MODE_NORM requires a float sampler");
return make_vec4<retType, P>(compNormalize<retType>(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, vec<4, retType, P> const & Texel)
{
static_assert(std::numeric_limits<retType>::is_iec559, "CONVERT_MODE_NORM requires a float sampler");
access::store(Texture, TexelCoord, Layer, Face, Level, compScale<T>(vec<L, retType, P>(Texel)));
}
};
template <typename textureType, typename retType, length_t L, typename T, precision P>
struct convertFunc<textureType, retType, L, T, P, CONVERT_MODE_SRGB, true>
{
typedef accessFunc<textureType, vec<L, T, P> > access;
static vec<4, retType, P> 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<retType>::is_iec559, "CONVERT_MODE_SRGB requires a float sampler");
return make_vec4<retType, P>(convertSRGBToLinear(compNormalize<retType>(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, vec<4, retType, P> const & Texel)
{
static_assert(std::numeric_limits<retType>::is_iec559, "CONVERT_MODE_SRGB requires a float sampler");
access::store(Texture, TexelCoord, Layer, Face, Level, gli::compScale<T>(convertLinearToSRGB(vec<L, retType, P>(Texel))));
}
};
template <typename textureType, typename retType, length_t L, typename T, precision P>
struct convertFunc<textureType, retType, L, T, P, CONVERT_MODE_RGB9E5, true>
{
typedef accessFunc<textureType, uint32> access;
static vec<4, retType, P> 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<retType>::is_iec559, "CONVERT_MODE_RGB9E5 requires a float sampler");
return vec<4, retType, P>(unpackF3x9_E1x5(access::load(Texture, TexelCoord, Layer, Face, Level)), static_cast<retType>(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, vec<4, retType, P> const & Texel)
{
static_assert(std::numeric_limits<retType>::is_iec559, "CONVERT_MODE_RGB9E5 requires a float sampler");
access::store(Texture, TexelCoord, Layer, Face, Level, packF3x9_E1x5(vec<3, float, P>(Texel)));
}
};
template <typename textureType, typename retType, length_t L, typename T, precision P>
struct convertFunc<textureType, retType, L, T, P, CONVERT_MODE_RG11B10F, true>
{
typedef accessFunc<textureType, uint32> access;
static vec<4, retType, P> 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<retType>::is_iec559, "CONVERT_MODE_RG11B10F requires a float sampler");
return vec<4, retType, P>(unpackF2x11_1x10(access::load(Texture, TexelCoord, Layer, Face, Level)), static_cast<retType>(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, vec<4, retType, P> const & Texel)
{
static_assert(std::numeric_limits<retType>::is_iec559, "CONVERT_MODE_RG11B10F requires a float sampler");
access::store(Texture, TexelCoord, Layer, Face, Level, packF2x11_1x10(vec<3, float, P>(Texel)));
}
};
template <typename textureType, typename retType, length_t L, typename T, precision P>
struct convertFunc<textureType, retType, L, T, P, CONVERT_MODE_HALF, true>
{
typedef accessFunc<textureType, vec<L, uint16, P> > access;
static vec<4, retType, P> 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<retType>::is_iec559, "CONVERT_MODE_HALF requires a float sampler");
return make_vec4<retType, P>(vec<L, retType, P>(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, vec<4, retType, P> const & Texel)
{
static_assert(std::numeric_limits<retType>::is_iec559, "CONVERT_MODE_HALF requires a float sampler");
access::store(Texture, TexelCoord, Layer, Face, Level, packHalf(vec<L, float, P>(Texel)));
}
};
template <typename textureType, typename retType, length_t L, typename T, precision P>
struct convertFunc<textureType, retType, L, T, P, CONVERT_MODE_44UNORM, true>
{
typedef accessFunc<textureType, uint8> access;
static vec<4, retType, P> 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<retType>::is_iec559, "CONVERT_MODE_44UNORM requires a float sampler");
return vec<4, retType, P>(vec<2, retType, P>(unpackUnorm2x4(access::load(Texture, TexelCoord, Layer, Face, Level))), static_cast<retType>(0), static_cast<retType>(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, vec<4, retType, P> const & Texel)
{
static_assert(std::numeric_limits<retType>::is_iec559, "CONVERT_MODE_44UNORM requires a float sampler");
access::store(Texture, TexelCoord, Layer, Face, Level, packUnorm2x4(vec<2, float, P>(Texel)));
}
};
template <typename textureType, typename retType, length_t L, typename T, precision P>
struct convertFunc<textureType, retType, L, T, P, CONVERT_MODE_4444UNORM, true>
{
typedef accessFunc<textureType, uint16> access;
static vec<4, retType, P> 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<retType>::is_iec559, "CONVERT_MODE_4444UNORM requires a float sampler");
return vec<4, retType, P>(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, vec<4, retType, P> const & Texel)
{
static_assert(std::numeric_limits<retType>::is_iec559, "CONVERT_MODE_4444UNORM requires a float sampler");
access::store(Texture, TexelCoord, Layer, Face, Level, packUnorm4x4(vec<4, float, P>(Texel)));
}
};
template <typename textureType, typename retType, length_t L, typename T, precision P>
struct convertFunc<textureType, retType, L, T, P, CONVERT_MODE_565UNORM, true>
{
typedef accessFunc<textureType, uint16> access;
static vec<4, retType, P> 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<retType>::is_iec559, "CONVERT_MODE_565UNORM requires a float sampler");
return vec<4, retType, P>(unpackUnorm1x5_1x6_1x5(access::load(Texture, TexelCoord, Layer, Face, Level)), static_cast<retType>(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, vec<4, retType, P> const & Texel)
{
static_assert(std::numeric_limits<retType>::is_iec559, "CONVERT_MODE_565UNORM requires a float sampler");
access::store(Texture, TexelCoord, Layer, Face, Level, packUnorm1x5_1x6_1x5(vec<3, float, P>(Texel)));
}
};
template <typename textureType, typename retType, length_t L, typename T, precision P>
struct convertFunc<textureType, retType, L, T, P, CONVERT_MODE_5551UNORM, true>
{
typedef accessFunc<textureType, uint16> access;
static vec<4, retType, P> 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<retType>::is_iec559, "CONVERT_MODE_5551UNORM requires a float sampler");
return vec<4, retType, P>(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, vec<4, retType, P> const & Texel)
{
static_assert(std::numeric_limits<retType>::is_iec559, "CONVERT_MODE_5551UNORM requires a float sampler");
access::store(Texture, TexelCoord, Layer, Face, Level, packUnorm3x5_1x1(vec<4, float, P>(Texel)));
}
};
template <typename textureType, typename retType, length_t L, typename T, precision P>
struct convertFunc<textureType, retType, L, T, P, CONVERT_MODE_332UNORM, true>
{
typedef accessFunc<textureType, uint8> access;
static vec<4, retType, P> 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<retType>::is_iec559, "CONVERT_MODE_332UNORM requires a float sampler");
return vec<4, retType, P>(unpackUnorm2x3_1x2(access::load(Texture, TexelCoord, Layer, Face, Level)), static_cast<retType>(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, vec<4, retType, P> const & Texel)
{
static_assert(std::numeric_limits<retType>::is_iec559, "CONVERT_MODE_332UNORM requires a float sampler");
access::store(Texture, TexelCoord, Layer, Face, Level, packUnorm2x3_1x2(vec<3, float, P>(Texel)));
}
};
template <typename textureType, typename retType, length_t L, typename T, precision P>
struct convertFunc<textureType, retType, L, T, P, CONVERT_MODE_RGB10A2UNORM, true>
{
typedef accessFunc<textureType, uint32> access;
static vec<4, retType, P> 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<retType>::is_iec559, "CONVERT_MODE_RGB10A2UNORM requires a float sampler");
return vec<4, retType, P>(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, vec<4, retType, P> const & Texel)
{
static_assert(std::numeric_limits<retType>::is_iec559, "CONVERT_MODE_RGB10A2UNORM requires a float sampler");
access::store(Texture, TexelCoord, Layer, Face, Level, packUnorm3x10_1x2(vec<4, float, P>(Texel)));
}
};
template <typename textureType, typename retType, length_t L, typename T, precision P>
struct convertFunc<textureType, retType, L, T, P, CONVERT_MODE_RGB10A2SNORM, true>
{
typedef accessFunc<textureType, uint32> access;
static vec<4, retType, P> 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<retType>::is_iec559, "CONVERT_MODE_RGB10A2SNORM requires a float sampler");
return vec<4, retType, P>(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, vec<4, retType, P> const & Texel)
{
static_assert(std::numeric_limits<retType>::is_iec559, "CONVERT_MODE_RGB10A2SNORM requires a float sampler");
access::store(Texture, TexelCoord, Layer, Face, Level, packSnorm3x10_1x2(Texel));
}
};
template <typename textureType, typename retType, length_t L, typename T, precision P>
struct convertFunc<textureType, retType, L, T, P, CONVERT_MODE_RGB10A2USCALE, true>
{
typedef accessFunc<textureType, uint32> access;
static vec<4, retType, P> 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<retType>::is_iec559, "CONVERT_MODE_RGB10A2USCALE requires a float sampler");
glm::detail::u10u10u10u2 Unpack;
Unpack.pack = access::load(Texture, TexelCoord, Layer, Face, Level);
return vec<4, retType, P>(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, vec<4, retType, P> const & Texel)
{
static_assert(std::numeric_limits<retType>::is_iec559, "CONVERT_MODE_RGB10A2USCALE requires a float sampler");
glm::detail::u10u10u10u2 Unpack;
Unpack.data.x = static_cast<uint>(Texel.x);
Unpack.data.y = static_cast<uint>(Texel.y);
Unpack.data.z = static_cast<uint>(Texel.z);
Unpack.data.w = static_cast<uint>(Texel.w);
access::store(Texture, TexelCoord, Layer, Face, Level, Unpack.pack);
}
};
template <typename textureType, typename retType, length_t L, typename T, precision P>
struct convertFunc<textureType, retType, L, T, P, CONVERT_MODE_RGB10A2SSCALE, true>
{
typedef accessFunc<textureType, uint32> access;
static vec<4, retType, P> 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<retType>::is_iec559, "CONVERT_MODE_RGB10A2SSCALE requires a float sampler");
glm::detail::i10i10i10i2 Unpack;
Unpack.pack = access::load(Texture, TexelCoord, Layer, Face, Level);
return vec<4, retType, P>(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, vec<4, retType, P> const & Texel)
{
static_assert(std::numeric_limits<retType>::is_iec559, "CONVERT_MODE_RGB10A2SSCALE requires a float sampler");
glm::detail::i10i10i10i2 Unpack;
Unpack.data.x = static_cast<int>(Texel.x);
Unpack.data.y = static_cast<int>(Texel.y);
Unpack.data.z = static_cast<int>(Texel.z);
Unpack.data.w = static_cast<int>(Texel.w);
access::store(Texture, TexelCoord, Layer, Face, Level, Unpack.pack);
}
};
template <typename textureType, typename retType, length_t L, typename T, precision P>
struct convertFunc<textureType, retType, L, T, P, CONVERT_MODE_RGB10A2UINT, false>
{
typedef accessFunc<textureType, uint32> access;
static vec<4, retType, P> 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<retType>::is_integer, "CONVERT_MODE_RGB10A2UINT requires an integer sampler");
return vec<4, retType, P>(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, vec<4, retType, P> const & Texel)
{
static_assert(std::numeric_limits<retType>::is_integer, "CONVERT_MODE_RGB10A2UINT requires an integer sampler");
access::store(Texture, TexelCoord, Layer, Face, Level, packU3x10_1x2(Texel));
}
};
template <typename textureType, typename retType, length_t L, typename T, precision P>
struct convertFunc<textureType, retType, L, T, P, CONVERT_MODE_RGB10A2SINT, false>
{
typedef accessFunc<textureType, uint32> access;
static vec<4, retType, P> 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<retType>::is_integer, "CONVERT_MODE_RGB10A2SINT requires an integer sampler");
return vec<4, retType, P>(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, vec<4, retType, P> const & Texel)
{
static_assert(std::numeric_limits<retType>::is_integer, "CONVERT_MODE_RGB10A2SINT requires an integer sampler");
access::store(Texture, TexelCoord, Layer, Face, Level, packI3x10_1x2(Texel));
}
};
template <typename textureType, typename samplerValType, precision P>
struct convert
{
typedef vec<4, samplerValType, P>(*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, vec<4, samplerValType, P> const & Texel);
template <length_t L, typename T, convertMode mode>
struct conv
{
static vec<4, samplerValType, P> 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<textureType, samplerValType, L, T, P, mode, std::numeric_limits<samplerValType>::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, vec<4, samplerValType, P> const & Texel)
{
convertFunc<textureType, samplerValType, L, T, P, mode, std::numeric_limits<samplerValType>::is_iec559>::write(Texture, TexelCoord, Layer, Face, Level, Texel);
}
};
struct func
{
fetchFunc Fetch;
writeFunc Write;
};
static func call(format Format)
{
static func Table[] =
{
{conv<2, u8, CONVERT_MODE_44UNORM>::fetch, conv<2, u8, CONVERT_MODE_44UNORM>::write}, // FORMAT_RG4_UNORM
{conv<4, u8, CONVERT_MODE_4444UNORM>::fetch, conv<4, u8, CONVERT_MODE_4444UNORM>::write}, // FORMAT_RGBA4_UNORM
{conv<4, u8, CONVERT_MODE_4444UNORM>::fetch, conv<4, u8, CONVERT_MODE_4444UNORM>::write}, // FORMAT_BGRA4_UNORM
{conv<3, u8, CONVERT_MODE_565UNORM>::fetch, conv<3, u8, CONVERT_MODE_565UNORM>::write}, // FORMAT_R5G6B5_UNORM
{conv<3, u8, CONVERT_MODE_565UNORM>::fetch, conv<3, u8, CONVERT_MODE_565UNORM>::write}, // FORMAT_B5G6R5_UNORM
{conv<4, u8, CONVERT_MODE_5551UNORM>::fetch, conv<4, u8, CONVERT_MODE_5551UNORM>::write}, // FORMAT_RGB5A1_UNORM
{conv<4, u8, CONVERT_MODE_5551UNORM>::fetch, conv<4, u8, CONVERT_MODE_5551UNORM>::write}, // FORMAT_BGR5A1_UNORM
{conv<4, u8, CONVERT_MODE_5551UNORM>::fetch, conv<4, u8, CONVERT_MODE_5551UNORM>::write}, // FORMAT_A1RGB5_UNORM
{conv<1, u8, CONVERT_MODE_NORM>::fetch, conv<1, u8, CONVERT_MODE_NORM>::write}, // FORMAT_R8_UNORM
{conv<1, i8, CONVERT_MODE_NORM>::fetch, conv<1, i8, CONVERT_MODE_NORM>::write}, // FORMAT_R8_SNORM
{conv<1, u8, CONVERT_MODE_CAST>::fetch, conv<1, u8, CONVERT_MODE_CAST>::write}, // FORMAT_R8_USCALED
{conv<1, i8, CONVERT_MODE_CAST>::fetch, conv<1, i8, CONVERT_MODE_CAST>::write}, // FORMAT_R8_SSCALED
{conv<1, u8, CONVERT_MODE_CAST>::fetch, conv<1, u8, CONVERT_MODE_CAST>::write}, // FORMAT_R8_UINT
{conv<1, i8, CONVERT_MODE_CAST>::fetch, conv<1, i8, CONVERT_MODE_CAST>::write}, // FORMAT_R8_SINT
{conv<1, u8, CONVERT_MODE_SRGB>::fetch, conv<1, u8, CONVERT_MODE_SRGB>::write}, // FORMAT_R8_SRGB
{conv<2, u8, CONVERT_MODE_NORM>::fetch, conv<2, u8, CONVERT_MODE_NORM>::write}, // FORMAT_RG8_UNORM
{conv<2, i8, CONVERT_MODE_NORM>::fetch, conv<2, i8, CONVERT_MODE_NORM>::write}, // FORMAT_RG8_SNORM
{conv<2, u8, CONVERT_MODE_CAST>::fetch, conv<2, u8, CONVERT_MODE_CAST>::write}, // FORMAT_RG8_USCALED
{conv<2, i8, CONVERT_MODE_CAST>::fetch, conv<2, i8, CONVERT_MODE_CAST>::write}, // FORMAT_RG8_SSCALED
{conv<2, u8, CONVERT_MODE_CAST>::fetch, conv<2, u8, CONVERT_MODE_CAST>::write}, // FORMAT_RG8_UINT
{conv<2, i8, CONVERT_MODE_CAST>::fetch, conv<2, i8, CONVERT_MODE_CAST>::write}, // FORMAT_RG8_SINT
{conv<2, u8, CONVERT_MODE_SRGB>::fetch, conv<2, u8, CONVERT_MODE_SRGB>::write}, // FORMAT_RG8_SRGB
{conv<3, u8, CONVERT_MODE_NORM>::fetch, conv<3, u8, CONVERT_MODE_NORM>::write}, // FORMAT_RGB8_UNORM
{conv<3, i8, CONVERT_MODE_NORM>::fetch, conv<3, i8, CONVERT_MODE_NORM>::write}, // FORMAT_RGB8_SNORM
{conv<3, u8, CONVERT_MODE_CAST>::fetch, conv<3, u8, CONVERT_MODE_CAST>::write}, // FORMAT_RGB8_USCALED
{conv<3, i8, CONVERT_MODE_CAST>::fetch, conv<3, i8, CONVERT_MODE_CAST>::write}, // FORMAT_RGB8_SSCALED
{conv<3, u8, CONVERT_MODE_CAST>::fetch, conv<3, u8, CONVERT_MODE_CAST>::write}, // FORMAT_RGB8_UINT
{conv<3, i8, CONVERT_MODE_CAST>::fetch, conv<3, i8, CONVERT_MODE_CAST>::write}, // FORMAT_RGB8_SINT
{conv<3, u8, CONVERT_MODE_SRGB>::fetch, conv<3, u8, CONVERT_MODE_SRGB>::write}, // FORMAT_RGB8_SRGB
{conv<3, u8, CONVERT_MODE_NORM>::fetch, conv<3, u8, CONVERT_MODE_NORM>::write}, // FORMAT_BGR8_UNORM
{conv<3, i8, CONVERT_MODE_NORM>::fetch, conv<3, i8, CONVERT_MODE_NORM>::write}, // FORMAT_BGR8_SNORM
{conv<3, u8, CONVERT_MODE_CAST>::fetch, conv<3, u8, CONVERT_MODE_CAST>::write}, // FORMAT_BGR8_USCALED
{conv<3, i8, CONVERT_MODE_CAST>::fetch, conv<3, i8, CONVERT_MODE_CAST>::write}, // FORMAT_BGR8_SSCALED
{conv<3, u32, CONVERT_MODE_CAST>::fetch, conv<3, u32, CONVERT_MODE_CAST>::write}, // FORMAT_BGR8_UINT
{conv<3, i32, CONVERT_MODE_CAST>::fetch, conv<3, i32, CONVERT_MODE_CAST>::write}, // FORMAT_BGR8_SINT
{conv<3, u8, CONVERT_MODE_SRGB>::fetch, conv<3, u8, CONVERT_MODE_SRGB>::write}, // FORMAT_BGR8_SRGB
{conv<4, u8, CONVERT_MODE_NORM>::fetch, conv<4, u8, CONVERT_MODE_NORM>::write}, // FORMAT_RGBA8_UNORM
{conv<4, i8, CONVERT_MODE_NORM>::fetch, conv<4, i8, CONVERT_MODE_NORM>::write}, // FORMAT_RGBA8_SNORM
{conv<4, u8, CONVERT_MODE_CAST>::fetch, conv<4, u8, CONVERT_MODE_CAST>::write}, // FORMAT_RGBA8_USCALED
{conv<4, i8, CONVERT_MODE_CAST>::fetch, conv<4, i8, CONVERT_MODE_CAST>::write}, // FORMAT_RGBA8_SSCALED
{conv<4, u8, CONVERT_MODE_CAST>::fetch, conv<4, u8, CONVERT_MODE_CAST>::write}, // FORMAT_RGBA8_UINT
{conv<4, i8, CONVERT_MODE_CAST>::fetch, conv<4, i8, CONVERT_MODE_CAST>::write}, // FORMAT_RGBA8_SINT
{conv<4, u8, CONVERT_MODE_SRGB>::fetch, conv<4, u8, CONVERT_MODE_SRGB>::write}, // FORMAT_RGBA8_SRGB
{conv<4, u8, CONVERT_MODE_NORM>::fetch, conv<4, u8, CONVERT_MODE_NORM>::write}, // FORMAT_BGRA8_UNORM
{conv<4, i8, CONVERT_MODE_NORM>::fetch, conv<4, i8, CONVERT_MODE_NORM>::write}, // FORMAT_BGRA8_SNORM
{conv<4, u8, CONVERT_MODE_CAST>::fetch, conv<4, u8, CONVERT_MODE_CAST>::write}, // FORMAT_BGRA8_USCALED
{conv<4, i8, CONVERT_MODE_CAST>::fetch, conv<4, i8, CONVERT_MODE_CAST>::write}, // FORMAT_BGRA8_SSCALED
{conv<4, u8, CONVERT_MODE_CAST>::fetch, conv<4, u8, CONVERT_MODE_CAST>::write}, // FORMAT_BGRA8_UINT
{conv<4, i8, CONVERT_MODE_CAST>::fetch, conv<4, i8, CONVERT_MODE_CAST>::write}, // FORMAT_BGRA8_SINT
{conv<4, u8, CONVERT_MODE_SRGB>::fetch, conv<4, u8, CONVERT_MODE_SRGB>::write}, // FORMAT_BGRA8_SRGB
{conv<4, u8, CONVERT_MODE_NORM>::fetch, conv<4, u8, CONVERT_MODE_NORM>::write}, // FORMAT_ABGR8_UNORM
{conv<4, i8, CONVERT_MODE_NORM>::fetch, conv<4, i8, CONVERT_MODE_NORM>::write}, // FORMAT_ABGR8_SNORM
{conv<4, u8, CONVERT_MODE_CAST>::fetch, conv<4, u8, CONVERT_MODE_CAST>::write}, // FORMAT_ABGR8_USCALED
{conv<4, i8, CONVERT_MODE_CAST>::fetch, conv<4, i8, CONVERT_MODE_CAST>::write}, // FORMAT_ABGR8_SSCALED
{conv<4, u8, CONVERT_MODE_CAST>::fetch, conv<4, u8, CONVERT_MODE_CAST>::write}, // FORMAT_ABGR8_UINT
{conv<4, i8, CONVERT_MODE_CAST>::fetch, conv<4, i8, CONVERT_MODE_CAST>::write}, // FORMAT_ABGR8_SINT
{conv<4, u8, CONVERT_MODE_SRGB>::fetch, conv<4, u8, CONVERT_MODE_SRGB>::write}, // FORMAT_ABGR8_SRGB
{conv<4, u8, CONVERT_MODE_RGB10A2UNORM>::fetch, conv<4, u8, CONVERT_MODE_RGB10A2UNORM>::write}, // FORMAT_RGB10A2_UNORM
{conv<4, i8, CONVERT_MODE_RGB10A2SNORM>::fetch, conv<4, i8, CONVERT_MODE_RGB10A2SNORM>::write}, // FORMAT_RGB10A2_SNORM
{conv<4, u8, CONVERT_MODE_RGB10A2USCALE>::fetch, conv<4, u8, CONVERT_MODE_RGB10A2USCALE>::write}, // FORMAT_RGB10A2_USCALED
{conv<4, i8, CONVERT_MODE_RGB10A2SSCALE>::fetch, conv<4, i8, CONVERT_MODE_RGB10A2SSCALE>::write}, // FORMAT_RGB10A2_SSCALED
{conv<4, u8, CONVERT_MODE_RGB10A2UINT>::fetch, conv<4, u8, CONVERT_MODE_RGB10A2UINT>::write}, // FORMAT_RGB10A2_UINT
{conv<4, i8, CONVERT_MODE_RGB10A2SINT>::fetch, conv<4, i8, CONVERT_MODE_RGB10A2SINT>::write}, // FORMAT_RGB10A2_SINT
{conv<4, u8, CONVERT_MODE_RGB10A2UNORM>::fetch, conv<4, u8, CONVERT_MODE_RGB10A2UNORM>::write}, // FORMAT_BGR10A2_UNORM
{conv<4, i8, CONVERT_MODE_RGB10A2SNORM>::fetch, conv<4, i8, CONVERT_MODE_RGB10A2SNORM>::write}, // FORMAT_BGR10A2_SNORM
{conv<4, u8, CONVERT_MODE_RGB10A2USCALE>::fetch, conv<4, u8, CONVERT_MODE_RGB10A2USCALE>::write}, // FORMAT_BGR10A2_USCALED
{conv<4, i8, CONVERT_MODE_RGB10A2SSCALE>::fetch, conv<4, i8, CONVERT_MODE_RGB10A2SSCALE>::write}, // FORMAT_BGR10A2_SSCALED
{conv<4, u8, CONVERT_MODE_RGB10A2UINT>::fetch, conv<4, u8, CONVERT_MODE_RGB10A2UINT>::write}, // FORMAT_BGR10A2_UINT
{conv<4, i8, CONVERT_MODE_RGB10A2SINT>::fetch, conv<4, i8, CONVERT_MODE_RGB10A2SINT>::write}, // FORMAT_BGR10A2_SINT
{conv<1, u16, CONVERT_MODE_NORM>::fetch, conv<1, u16, CONVERT_MODE_NORM>::write}, // FORMAT_R16_UNORM_PACK16
{conv<1, i16, CONVERT_MODE_NORM>::fetch, conv<1, i16, CONVERT_MODE_NORM>::write}, // FORMAT_R16_SNORM_PACK16
{conv<1, u16, CONVERT_MODE_CAST>::fetch, conv<1, u16, CONVERT_MODE_CAST>::write}, // FORMAT_R16_USCALED_PACK16
{conv<1, i16, CONVERT_MODE_CAST>::fetch, conv<1, i16, CONVERT_MODE_CAST>::write}, // FORMAT_R16_SSCALED_PACK16
{conv<1, u16, CONVERT_MODE_CAST>::fetch, conv<1, u16, CONVERT_MODE_CAST>::write}, // FORMAT_R16_UINT_PACK16
{conv<1, i16, CONVERT_MODE_CAST>::fetch, conv<1, i16, CONVERT_MODE_CAST>::write}, // FORMAT_R16_SINT_PACK16
{conv<1, u16, CONVERT_MODE_HALF>::fetch, conv<1, u16, CONVERT_MODE_HALF>::write}, // FORMAT_R16_SFLOAT_PACK16
{conv<2, u16, CONVERT_MODE_NORM>::fetch, conv<2, u16, CONVERT_MODE_NORM>::write}, // FORMAT_RG16_UNORM_PACK16
{conv<2, i16, CONVERT_MODE_NORM>::fetch, conv<2, i16, CONVERT_MODE_NORM>::write}, // FORMAT_RG16_SNORM_PACK16
{conv<2, u16, CONVERT_MODE_CAST>::fetch, conv<2, u16, CONVERT_MODE_CAST>::write}, // FORMAT_RG16_USCALED_PACK16
{conv<2, i16, CONVERT_MODE_CAST>::fetch, conv<2, i16, CONVERT_MODE_CAST>::write}, // FORMAT_RG16_SSCALED_PACK16
{conv<2, u16, CONVERT_MODE_CAST>::fetch, conv<2, u16, CONVERT_MODE_CAST>::write}, // FORMAT_RG16_UINT_PACK16
{conv<2, i16, CONVERT_MODE_CAST>::fetch, conv<2, i16, CONVERT_MODE_CAST>::write}, // FORMAT_RG16_SINT_PACK16
{conv<2, u16, CONVERT_MODE_HALF>::fetch, conv<2, u16, CONVERT_MODE_HALF>::write}, // FORMAT_RG16_SFLOAT_PACK16
{conv<3, u16, CONVERT_MODE_NORM>::fetch, conv<3, u16, CONVERT_MODE_NORM>::write}, // FORMAT_RGB16_UNORM_PACK16
{conv<3, i16, CONVERT_MODE_NORM>::fetch, conv<3, i16, CONVERT_MODE_NORM>::write}, // FORMAT_RGB16_SNORM_PACK16
{conv<3, u16, CONVERT_MODE_CAST>::fetch, conv<3, u16, CONVERT_MODE_CAST>::write}, // FORMAT_RGB16_USCALED_PACK16
{conv<3, i16, CONVERT_MODE_CAST>::fetch, conv<3, i16, CONVERT_MODE_CAST>::write}, // FORMAT_RGB16_SSCALED_PACK16
{conv<3, u16, CONVERT_MODE_CAST>::fetch, conv<3, u16, CONVERT_MODE_CAST>::write}, // FORMAT_RGB16_UINT_PACK16
{conv<3, i16, CONVERT_MODE_CAST>::fetch, conv<3, i16, CONVERT_MODE_CAST>::write}, // FORMAT_RGB16_SINT_PACK16
{conv<3, u16, CONVERT_MODE_HALF>::fetch, conv<3, u16, CONVERT_MODE_HALF>::write}, // FORMAT_RGB16_SFLOAT_PACK16
{conv<4, u16, CONVERT_MODE_NORM>::fetch, conv<4, u16, CONVERT_MODE_NORM>::write}, // FORMAT_RGBA16_UNORM_PACK16
{conv<4, i16, CONVERT_MODE_NORM>::fetch, conv<4, i16, CONVERT_MODE_NORM>::write}, // FORMAT_RGBA16_SNORM_PACK16
{conv<4, u16, CONVERT_MODE_CAST>::fetch, conv<4, u16, CONVERT_MODE_CAST>::write}, // FORMAT_RGBA16_USCALED_PACK16
{conv<4, i16, CONVERT_MODE_CAST>::fetch, conv<4, i16, CONVERT_MODE_CAST>::write}, // FORMAT_RGBA16_SSCALED_PACK16
{conv<4, u16, CONVERT_MODE_CAST>::fetch, conv<4, u16, CONVERT_MODE_CAST>::write}, // FORMAT_RGBA16_UINT_PACK16
{conv<4, i16, CONVERT_MODE_CAST>::fetch, conv<4, i16, CONVERT_MODE_CAST>::write}, // FORMAT_RGBA16_SINT_PACK16
{conv<4, u16, CONVERT_MODE_HALF>::fetch, conv<4, u16, CONVERT_MODE_HALF>::write}, // FORMAT_RGBA16_SFLOAT_PACK16
{conv<1, u32, CONVERT_MODE_CAST>::fetch, conv<1, u32, CONVERT_MODE_CAST>::write}, // FORMAT_R32_UINT_PACK32
{conv<1, i32, CONVERT_MODE_CAST>::fetch, conv<1, i32, CONVERT_MODE_CAST>::write}, // FORMAT_R32_SINT_PACK32
{conv<1, f32, CONVERT_MODE_CAST>::fetch, conv<1, f32, CONVERT_MODE_CAST>::write}, // FORMAT_R32_SFLOAT_PACK32
{conv<2, u32, CONVERT_MODE_CAST>::fetch, conv<2, u32, CONVERT_MODE_CAST>::write}, // FORMAT_RG32_UINT_PACK32
{conv<2, i32, CONVERT_MODE_CAST>::fetch, conv<2, i32, CONVERT_MODE_CAST>::write}, // FORMAT_RG32_SINT_PACK32
{conv<2, f32, CONVERT_MODE_CAST>::fetch, conv<2, f32, CONVERT_MODE_CAST>::write}, // FORMAT_RG32_SFLOAT_PACK32
{conv<3, u32, CONVERT_MODE_CAST>::fetch, conv<3, u32, CONVERT_MODE_CAST>::write}, // FORMAT_RGB32_UINT_PACK32
{conv<3, i32, CONVERT_MODE_CAST>::fetch, conv<3, i32, CONVERT_MODE_CAST>::write}, // FORMAT_RGB32_SINT_PACK32
{conv<3, f32, CONVERT_MODE_CAST>::fetch, conv<3, f32, CONVERT_MODE_CAST>::write}, // FORMAT_RGB32_SFLOAT_PACK32
{conv<4, u32, CONVERT_MODE_CAST>::fetch, conv<4, u32, CONVERT_MODE_CAST>::write}, // FORMAT_RGBA32_UINT_PACK32
{conv<4, i32, CONVERT_MODE_CAST>::fetch, conv<4, i32, CONVERT_MODE_CAST>::write}, // FORMAT_RGBA32_SINT_PACK32
{conv<4, f32, CONVERT_MODE_CAST>::fetch, conv<4, f32, CONVERT_MODE_CAST>::write}, // FORMAT_RGBA32_SFLOAT_PACK32
{conv<1, u64, CONVERT_MODE_CAST>::fetch, conv<1, u64, CONVERT_MODE_CAST>::write}, // FORMAT_R64_UINT_PACK64
{conv<1, i64, CONVERT_MODE_CAST>::fetch, conv<1, i64, CONVERT_MODE_CAST>::write}, // FORMAT_R64_SINT_PACK64
{conv<1, f64, CONVERT_MODE_CAST>::fetch, conv<1, f64, CONVERT_MODE_CAST>::write}, // FORMAT_R64_SFLOAT_PACK64
{conv<2, u64, CONVERT_MODE_CAST>::fetch, conv<2, u64, CONVERT_MODE_CAST>::write}, // FORMAT_RG64_UINT_PACK64
{conv<2, i64, CONVERT_MODE_CAST>::fetch, conv<2, i64, CONVERT_MODE_CAST>::write}, // FORMAT_RG64_SINT_PACK64
{conv<2, f64, CONVERT_MODE_CAST>::fetch, conv<2, f64, CONVERT_MODE_CAST>::write}, // FORMAT_RG64_SFLOAT_PACK64
{conv<3, u64, CONVERT_MODE_CAST>::fetch, conv<3, u64, CONVERT_MODE_CAST>::write}, // FORMAT_RGB64_UINT_PACK64
{conv<3, i64, CONVERT_MODE_CAST>::fetch, conv<3, i64, CONVERT_MODE_CAST>::write}, // FORMAT_RGB64_SINT_PACK64
{conv<3, f64, CONVERT_MODE_CAST>::fetch, conv<3, f64, CONVERT_MODE_CAST>::write}, // FORMAT_RGB64_SFLOAT_PACK64
{conv<4, u64, CONVERT_MODE_CAST>::fetch, conv<4, u64, CONVERT_MODE_CAST>::write}, // FORMAT_RGBA64_UINT_PACK64
{conv<4, i64, CONVERT_MODE_CAST>::fetch, conv<4, i64, CONVERT_MODE_CAST>::write}, // FORMAT_RGBA64_SINT_PACK64
{conv<4, f64, CONVERT_MODE_CAST>::fetch, conv<4, f64, CONVERT_MODE_CAST>::write}, // FORMAT_RGBA64_SFLOAT_PACK64
{conv<1, u32, CONVERT_MODE_RG11B10F>::fetch, conv<1, u32, CONVERT_MODE_RG11B10F>::write}, // FORMAT_RG11B10_UFLOAT
{conv<1, u32, CONVERT_MODE_RGB9E5>::fetch, conv<1, u32, CONVERT_MODE_RGB9E5>::write}, // FORMAT_RGB9E5_UFLOAT
{conv<1, u16, CONVERT_MODE_DEFAULT>::fetch, conv<1, u16, CONVERT_MODE_DEFAULT>::write}, // FORMAT_D16_UNORM_PACK16
{conv<1, u32, CONVERT_MODE_DEFAULT>::fetch, conv<1, u32, CONVERT_MODE_DEFAULT>::write}, // FORMAT_D24_UNORM
{conv<1, f32, CONVERT_MODE_DEFAULT>::fetch, conv<1, f32, CONVERT_MODE_DEFAULT>::write}, // FORMAT_D32_SFLOAT_PACK32
{conv<1, u8, CONVERT_MODE_DEFAULT>::fetch, conv<1, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_S8_UINT_PACK8
{conv<2, u16, CONVERT_MODE_DEFAULT>::fetch, conv<2, u16, CONVERT_MODE_DEFAULT>::write}, // FORMAT_D16_UNORM_S8_UINT_PACK32
{conv<2, u32, CONVERT_MODE_DEFAULT>::fetch, conv<2, u32, CONVERT_MODE_DEFAULT>::write}, // FORMAT_D24_UNORM_S8_UINT_PACK32
{conv<2, u32, CONVERT_MODE_DEFAULT>::fetch, conv<2, u32, CONVERT_MODE_DEFAULT>::write}, // FORMAT_D32_SFLOAT_S8_UINT_PACK64
{conv<3, u8, CONVERT_MODE_DEFAULT>::fetch, conv<3, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGB_DXT1_UNORM_BLOCK8
{conv<3, u8, CONVERT_MODE_DEFAULT>::fetch, conv<3, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGB_DXT1_SRGB_BLOCK8
{conv<4, u8, CONVERT_MODE_DEFAULT>::fetch, conv<4, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGBA_DXT1_UNORM_BLOCK8
{conv<4, u8, CONVERT_MODE_DEFAULT>::fetch, conv<4, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGBA_DXT1_SRGB_BLOCK8
{conv<4, u8, CONVERT_MODE_DEFAULT>::fetch, conv<4, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGBA_DXT3_UNORM_BLOCK16
{conv<4, u8, CONVERT_MODE_DEFAULT>::fetch, conv<4, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGBA_DXT3_SRGB_BLOCK16
{conv<4, u8, CONVERT_MODE_DEFAULT>::fetch, conv<4, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGBA_DXT5_UNORM_BLOCK16
{conv<4, u8, CONVERT_MODE_DEFAULT>::fetch, conv<4, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGBA_DXT5_SRGB_BLOCK16
{conv<1, u8, CONVERT_MODE_DEFAULT>::fetch, conv<1, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_R_ATI1N_UNORM_BLOCK8
{conv<1, u8, CONVERT_MODE_DEFAULT>::fetch, conv<1, i8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_R_ATI1N_SNORM_BLOCK8
{conv<2, u8, CONVERT_MODE_DEFAULT>::fetch, conv<2, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RG_ATI2N_UNORM_BLOCK16
{conv<2, u8, CONVERT_MODE_DEFAULT>::fetch, conv<2, i8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RG_ATI2N_SNORM_BLOCK16
{conv<3, f32, CONVERT_MODE_DEFAULT>::fetch, conv<3, f32, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGB_BP_UFLOAT_BLOCK16
{conv<3, f32, CONVERT_MODE_DEFAULT>::fetch, conv<3, f32, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGB_BP_SFLOAT_BLOCK16
{conv<4, u8, CONVERT_MODE_DEFAULT>::fetch, conv<4, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGBA_BP_UNORM_BLOCK16
{conv<4, u8, CONVERT_MODE_DEFAULT>::fetch, conv<4, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGBA_BP_SRGB_BLOCK16
{conv<3, u8, CONVERT_MODE_DEFAULT>::fetch, conv<3, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGB_ETC2_UNORM_BLOCK8
{conv<3, u8, CONVERT_MODE_DEFAULT>::fetch, conv<3, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGB_ETC2_SRGB_BLOCK8
{conv<4, u8, CONVERT_MODE_DEFAULT>::fetch, conv<4, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGBA_ETC2_A1_UNORM_BLOCK8
{conv<4, u8, CONVERT_MODE_DEFAULT>::fetch, conv<4, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGBA_ETC2_A1_SRGB_BLOCK8
{conv<4, u8, CONVERT_MODE_DEFAULT>::fetch, conv<4, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGBA_ETC2_UNORM_BLOCK16
{conv<4, u8, CONVERT_MODE_DEFAULT>::fetch, conv<4, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGBA_ETC2_SRGB_BLOCK16
{conv<1, u8, CONVERT_MODE_DEFAULT>::fetch, conv<1, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_R_EAC_UNORM_BLOCK8
{conv<1, u8, CONVERT_MODE_DEFAULT>::fetch, conv<1, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_R_EAC_SNORM_BLOCK8
{conv<2, u8, CONVERT_MODE_DEFAULT>::fetch, conv<2, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RG_EAC_UNORM_BLOCK16
{conv<2, u8, CONVERT_MODE_DEFAULT>::fetch, conv<2, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RG_EAC_SNORM_BLOCK16
{conv<4, u8, CONVERT_MODE_DEFAULT>::fetch, conv<4, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_4x4_UNORM
{conv<4, u8, CONVERT_MODE_DEFAULT>::fetch, conv<4, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_4x4_SRGB
{conv<4, u8, CONVERT_MODE_DEFAULT>::fetch, conv<4, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_5x4_UNORM
{conv<4, u8, CONVERT_MODE_DEFAULT>::fetch, conv<4, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_5x4_SRGB
{conv<4, u8, CONVERT_MODE_DEFAULT>::fetch, conv<4, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_5x5_UNORM
{conv<4, u8, CONVERT_MODE_DEFAULT>::fetch, conv<4, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_5x5_SRGB
{conv<4, u8, CONVERT_MODE_DEFAULT>::fetch, conv<4, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_6x5_UNORM
{conv<4, u8, CONVERT_MODE_DEFAULT>::fetch, conv<4, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_6x5_SRGB
{conv<4, u8, CONVERT_MODE_DEFAULT>::fetch, conv<4, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_6x6_UNORM
{conv<4, u8, CONVERT_MODE_DEFAULT>::fetch, conv<4, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_6x6_SRGB
{conv<4, u8, CONVERT_MODE_DEFAULT>::fetch, conv<4, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_8x5_UNORM
{conv<4, u8, CONVERT_MODE_DEFAULT>::fetch, conv<4, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_8x5_SRGB
{conv<4, u8, CONVERT_MODE_DEFAULT>::fetch, conv<4, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_8x6_UNORM
{conv<4, u8, CONVERT_MODE_DEFAULT>::fetch, conv<4, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_8x6_SRGB
{conv<4, u8, CONVERT_MODE_DEFAULT>::fetch, conv<4, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_8x8_UNORM
{conv<4, u8, CONVERT_MODE_DEFAULT>::fetch, conv<4, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_8x8_SRGB
{conv<4, u8, CONVERT_MODE_DEFAULT>::fetch, conv<4, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_10x5_UNORM
{conv<4, u8, CONVERT_MODE_DEFAULT>::fetch, conv<4, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_10x5_SRGB
{conv<4, u8, CONVERT_MODE_DEFAULT>::fetch, conv<4, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_10x6_UNORM
{conv<4, u8, CONVERT_MODE_DEFAULT>::fetch, conv<4, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_10x6_SRGB
{conv<4, u8, CONVERT_MODE_DEFAULT>::fetch, conv<4, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_10x8_UNORM
{conv<4, u8, CONVERT_MODE_DEFAULT>::fetch, conv<4, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_10x8_SRGB
{conv<4, u8, CONVERT_MODE_DEFAULT>::fetch, conv<4, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_10x10_UNORM
{conv<4, u8, CONVERT_MODE_DEFAULT>::fetch, conv<4, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_10x10_SRGB
{conv<4, u8, CONVERT_MODE_DEFAULT>::fetch, conv<4, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_12x10_UNORM
{conv<4, u8, CONVERT_MODE_DEFAULT>::fetch, conv<4, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_12x10_SRGB
{conv<4, u8, CONVERT_MODE_DEFAULT>::fetch, conv<4, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_12x12_UNORM
{conv<4, u8, CONVERT_MODE_DEFAULT>::fetch, conv<4, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_12x12_SRGB
{conv<3, u8, CONVERT_MODE_DEFAULT>::fetch, conv<3, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGB_PVRTC1_8X8_UNORM_BLOCK32
{conv<3, u8, CONVERT_MODE_DEFAULT>::fetch, conv<3, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGB_PVRTC1_8X8_SRGB_BLOCK32
{conv<3, u8, CONVERT_MODE_DEFAULT>::fetch, conv<3, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGB_PVRTC1_16X8_UNORM_BLOCK32
{conv<3, u8, CONVERT_MODE_DEFAULT>::fetch, conv<3, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGB_PVRTC1_16X8_SRGB_BLOCK32
{conv<4, u8, CONVERT_MODE_DEFAULT>::fetch, conv<4, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGBA_PVRTC1_8X8_UNORM_BLOCK32
{conv<4, u8, CONVERT_MODE_DEFAULT>::fetch, conv<4, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGBA_PVRTC1_8X8_SRGB_BLOCK32
{conv<4, u8, CONVERT_MODE_DEFAULT>::fetch, conv<4, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGBA_PVRTC1_16X8_UNORM_BLOCK32
{conv<4, u8, CONVERT_MODE_DEFAULT>::fetch, conv<4, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGBA_PVRTC1_16X8_SRGB_BLOCK32
{conv<4, u8, CONVERT_MODE_DEFAULT>::fetch, conv<4, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGBA_PVRTC2_4X4_UNORM_BLOCK8
{conv<4, u8, CONVERT_MODE_DEFAULT>::fetch, conv<4, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGBA_PVRTC2_4X4_SRGB_BLOCK8
{conv<4, u8, CONVERT_MODE_DEFAULT>::fetch, conv<4, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGBA_PVRTC2_8X4_UNORM_BLOCK8
{conv<4, u8, CONVERT_MODE_DEFAULT>::fetch, conv<4, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGBA_PVRTC2_8X4_SRGB_BLOCK8
{conv<3, u8, CONVERT_MODE_DEFAULT>::fetch, conv<3, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGB_ETC_UNORM_BLOCK8
{conv<3, u8, CONVERT_MODE_DEFAULT>::fetch, conv<3, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGB_ATC_UNORM_BLOCK8
{conv<4, u8, CONVERT_MODE_DEFAULT>::fetch, conv<4, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGBA_ATCA_UNORM_BLOCK16
{conv<4, u8, CONVERT_MODE_DEFAULT>::fetch, conv<4, u8, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGBA_ATCI_UNORM_BLOCK16
{conv<1, u8, CONVERT_MODE_NORM>::fetch, conv<1, u8, CONVERT_MODE_NORM>::write}, // FORMAT_L8_UNORM_PACK8
{conv<1, u8, CONVERT_MODE_NORM>::fetch, conv<1, u8, CONVERT_MODE_NORM>::write}, // FORMAT_A8_UNORM_PACK8
{conv<2, u8, CONVERT_MODE_NORM>::fetch, conv<2, u8, CONVERT_MODE_NORM>::write}, // FORMAT_LA8_UNORM_PACK8
{conv<1, u16, CONVERT_MODE_NORM>::fetch, conv<1, u16, CONVERT_MODE_NORM>::write}, // FORMAT_L16_UNORM_PACK16
{conv<1, u16, CONVERT_MODE_NORM>::fetch, conv<1, u16, CONVERT_MODE_NORM>::write}, // FORMAT_A16_UNORM_PACK16
{conv<2, u16, CONVERT_MODE_NORM>::fetch, conv<2, u16, CONVERT_MODE_NORM>::write}, // FORMAT_LA16_UNORM_PACK16
{conv<4, u8, CONVERT_MODE_NORM>::fetch, conv<4, u8, CONVERT_MODE_NORM>::write}, // FORMAT_BGRX8_UNORM
{conv<4, u8, CONVERT_MODE_SRGB>::fetch, conv<4, u8, CONVERT_MODE_SRGB>::write}, // FORMAT_BGRX8_SRGB
{conv<3, u8, CONVERT_MODE_332UNORM>::fetch, conv<3, u8, CONVERT_MODE_332UNORM>::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

View file

@ -1,87 +0,0 @@
#pragma once
#include "../type.hpp"
namespace gli{
namespace detail
{
template <length_t L, typename T, precision P>
inline vec<L, bool, P> in_interval(vec<L, T, P> const& Value, vec<L, T, P> const& Min, vec<L, T, P> const& Max)
{
return greaterThanEqual(Value, Min) && lessThanEqual(Value, Max);
}
template <typename extent_type, typename normalized_type>
struct coord_nearest
{
extent_type Texel;
typename extent_type::bool_type UseTexel;
};
template <typename extent_type, typename normalized_type>
inline coord_nearest<extent_type, normalized_type> make_coord_nearest(extent_type const& TexelExtent, normalized_type const& SampleCoord)
{
normalized_type const TexelLast(normalized_type(TexelExtent) - normalized_type(1));
coord_nearest<extent_type, normalized_type> Coord;
Coord.Texel = extent_type(round(SampleCoord * TexelLast));
Coord.UseTexel = in_interval(Coord.Texel, extent_type(0), TexelExtent - 1);
return Coord;
}
template <typename extent_type, typename normalized_type>
struct coord_linear
{
extent_type TexelFloor;
extent_type TexelCeil;
normalized_type Blend;
};
template <typename extent_type, typename normalized_type>
struct coord_linear_border : public coord_linear<extent_type, normalized_type>
{
typename extent_type::bool_type UseTexelFloor;
typename extent_type::bool_type UseTexelCeil;
};
template <typename extent_type, typename normalized_type>
GLI_FORCE_INLINE coord_linear<extent_type, normalized_type> make_coord_linear(extent_type const& TexelExtent, normalized_type const& SampleCoord)
{
coord_linear<extent_type, normalized_type> 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 <typename extent_type, typename normalized_type>
GLI_FORCE_INLINE coord_linear_border<extent_type, normalized_type> make_coord_linear_border(extent_type const& TexelExtent, normalized_type const& SampleCoord)
{
coord_linear_border<extent_type, normalized_type> 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

View file

@ -1,112 +0,0 @@
#include "../type.hpp"
#include <cstring>
namespace gli
{
template <typename texture_src_type, typename texture_dst_type>
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 <typename texture_src_type, typename texture_dst_type>
void copy
(
texture_src_type const& TextureSrc,
texture_dst_type& TextureDst
)
{
copy_layer(TextureSrc, 0, TextureDst, 0, TextureDst.layers());
}
template <typename texture_src_type, typename texture_dst_type>
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 <typename texture_src_type, typename texture_dst_type>
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 <typename texture_src_type, typename texture_dst_type>
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 <typename texture_src_type, typename texture_dst_type>
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 <typename texture_src_type, typename texture_dst_type>
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 <typename texture_src_type, typename texture_dst_type>
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

View file

@ -1,4 +0,0 @@
int main()
{
}

View file

@ -1,267 +0,0 @@
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 <typename texType>
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 <typename texType>
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

View file

@ -1,311 +0,0 @@
#include <functional>
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<gli::format>(FORMAT_INVALID);
for(int FormatIndex = FORMAT_FIRST; FormatIndex <= FORMAT_LAST; ++FormatIndex)
{
if(this->Translation[FormatIndex - FORMAT_FIRST].D3DFormat != FourCC)
continue;
FormatResult = static_cast<gli::format>(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<gli::format>(FORMAT_INVALID);
for(int FormatIndex = FORMAT_FIRST; FormatIndex <= FORMAT_LAST; ++FormatIndex)
{
gli::format CurrentFormat = static_cast<gli::format>(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<gli::format>(FormatIndex);
break;
}
if(FourCC == D3DFMT_DX10 && !(FormatInfo.Flags & detail::CAP_DDS_GLI_EXT_BIT) && DXFormat.DXGIFormat.DDS == Format.DDS)
{
FormatResult = static_cast<gli::format>(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

View file

@ -1,15 +0,0 @@
/// @brief File helper functions
/// @file gli/core/file.hpp
#pragma once
#include <cstdio>
namespace gli{
namespace detail
{
FILE* open_file(const char *Filename, const char *mode);
}//namespace detail
}//namespace gli
#include "./file.inl"

View file

@ -1,19 +0,0 @@
#pragma once
#include <glm/simd/platform.h>
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

View file

@ -1,23 +0,0 @@
/// @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"

View file

@ -1,8 +0,0 @@
#pragma once
namespace gli{
namespace detail
{
}//namespace detail
}//namespace gli

View file

@ -1,390 +0,0 @@
#pragma once
#include "filter.hpp"
#include "coord.hpp"
#include <glm/gtc/integer.hpp>
namespace gli{
namespace detail
{
enum dimension
{
DIMENSION_1D,
DIMENSION_2D,
DIMENSION_3D
};
template <typename T>
struct interpolate
{
typedef float type;
};
template <>
struct interpolate<double>
{
typedef double type;
};
template <>
struct interpolate<long double>
{
typedef long double type;
};
template <dimension Dimension, typename texture_type, typename interpolate_type, typename normalized_type, typename fetch_type, typename texel_type>
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 <dimension Dimension, typename texture_type, typename interpolate_type, typename normalized_type, typename fetch_type, typename texel_type, bool is_float = true, bool support_border = true>
struct nearest : public filterBase<Dimension, texture_type, interpolate_type, normalized_type, fetch_type, texel_type>
{
typedef filterBase<Dimension, texture_type, interpolate_type, normalized_type, fetch_type, texel_type> base_type;
typedef typename base_type::size_type size_type;
typedef typename base_type::extent_type extent_type;
typedef coord_nearest<extent_type, normalized_type> 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 <dimension Dimension, typename texture_type, typename interpolate_type, typename normalized_type, typename fetch_type, typename texel_type>
struct nearest<Dimension, texture_type, interpolate_type, normalized_type, fetch_type, texel_type, true, false> : public filterBase<Dimension, texture_type, interpolate_type, normalized_type, fetch_type, texel_type>
{
typedef filterBase<Dimension, texture_type, interpolate_type, normalized_type, fetch_type, texel_type> base_type;
typedef typename base_type::size_type size_type;
typedef typename base_type::extent_type extent_type;
typedef coord_nearest<extent_type, normalized_type> 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 <dimension Dimension, typename texture_type, typename interpolate_type, typename normalized_type, typename fetch_type, typename texel_type, bool is_float = true, bool support_border = true>
struct linear : public filterBase<Dimension, texture_type, interpolate_type, normalized_type, fetch_type, texel_type>
{
typedef filterBase<Dimension, texture_type, interpolate_type, normalized_type, fetch_type, texel_type> 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 <typename texture_type, typename interpolate_type, typename normalized_type, typename fetch_type, typename texel_type>
struct linear<DIMENSION_1D, texture_type, interpolate_type, normalized_type, fetch_type, texel_type, true, true> : public filterBase<DIMENSION_1D, texture_type, interpolate_type, normalized_type, fetch_type, texel_type>
{
typedef filterBase<DIMENSION_1D, texture_type, interpolate_type, normalized_type, fetch_type, texel_type> base_type;
typedef typename base_type::size_type size_type;
typedef typename base_type::extent_type extent_type;
typedef coord_linear_border<extent_type, normalized_type> 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 <typename texture_type, typename interpolate_type, typename normalized_type, typename fetch_type, typename texel_type>
struct linear<DIMENSION_1D, texture_type, interpolate_type, normalized_type, fetch_type, texel_type, true, false> : public filterBase<DIMENSION_1D, texture_type, interpolate_type, normalized_type, fetch_type, texel_type>
{
typedef filterBase<DIMENSION_1D, texture_type, interpolate_type, normalized_type, fetch_type, texel_type> base_type;
typedef typename base_type::size_type size_type;
typedef typename base_type::extent_type extent_type;
typedef coord_linear<extent_type, normalized_type> 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 <typename texture_type, typename interpolate_type, typename normalized_type, typename fetch_type, typename texel_type>
struct linear<DIMENSION_2D, texture_type, interpolate_type, normalized_type, fetch_type, texel_type, true, true> : public filterBase<DIMENSION_2D, texture_type, interpolate_type, normalized_type, fetch_type, texel_type>
{
typedef filterBase<DIMENSION_2D, texture_type, interpolate_type, normalized_type, fetch_type, texel_type> base_type;
typedef typename base_type::size_type size_type;
typedef typename base_type::extent_type extent_type;
typedef coord_linear_border<extent_type, normalized_type> 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 <typename texture_type, typename interpolate_type, typename normalized_type, typename fetch_type, typename texel_type>
struct linear<DIMENSION_2D, texture_type, interpolate_type, normalized_type, fetch_type, texel_type, true, false> : public filterBase<DIMENSION_2D, texture_type, interpolate_type, normalized_type, fetch_type, texel_type>
{
typedef filterBase<DIMENSION_2D, texture_type, interpolate_type, normalized_type, fetch_type, texel_type> base_type;
typedef typename base_type::size_type size_type;
typedef typename base_type::extent_type extent_type;
typedef coord_linear<extent_type, normalized_type> 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 <typename texture_type, typename interpolate_type, typename normalized_type, typename fetch_type, typename texel_type>
struct linear<DIMENSION_3D, texture_type, interpolate_type, normalized_type, fetch_type, texel_type, true, true> : public filterBase<DIMENSION_3D, texture_type, interpolate_type, normalized_type, fetch_type, texel_type>
{
typedef filterBase<DIMENSION_3D, texture_type, interpolate_type, normalized_type, fetch_type, texel_type> base_type;
typedef typename base_type::size_type size_type;
typedef typename base_type::extent_type extent_type;
typedef coord_linear_border<extent_type, normalized_type> 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 <typename texture_type, typename interpolate_type, typename normalized_type, typename fetch_type, typename texel_type>
struct linear<DIMENSION_3D, texture_type, interpolate_type, normalized_type, fetch_type, texel_type, true, false> : public filterBase<DIMENSION_3D, texture_type, interpolate_type, normalized_type, fetch_type, texel_type>
{
typedef filterBase<DIMENSION_3D, texture_type, interpolate_type, normalized_type, fetch_type, texel_type> base_type;
typedef typename base_type::size_type size_type;
typedef typename base_type::extent_type extent_type;
typedef coord_linear<extent_type, normalized_type> 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 <dimension Dimension, typename texture_type, typename interpolate_type, typename normalized_type, typename fetch_type, typename texel_type, bool is_float, bool support_border>
struct nearest_mipmap_nearest : public filterBase<Dimension, texture_type, interpolate_type, normalized_type, fetch_type, texel_type>
{
typedef filterBase<Dimension, texture_type, interpolate_type, normalized_type, fetch_type, texel_type> base_type;
typedef typename base_type::size_type size_type;
typedef typename base_type::extent_type extent_type;
typedef coord_linear_border<extent_type, normalized_type> 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<Dimension, texture_type, interpolate_type, normalized_type, fetch_type, texel_type, is_float, support_border>::call(Texture, Fetch, SampleCoordWrap, Layer, Face, glm::iround(Level), BorderColor);
}
};
template <dimension Dimension, typename texture_type, typename interpolate_type, typename normalized_type, typename fetch_type, typename texel_type, bool is_float, bool support_border>
struct nearest_mipmap_linear : public filterBase<Dimension, texture_type, interpolate_type, normalized_type, fetch_type, texel_type>
{
typedef filterBase<Dimension, texture_type, interpolate_type, normalized_type, fetch_type, texel_type> base_type;
typedef typename base_type::size_type size_type;
typedef typename base_type::extent_type extent_type;
typedef coord_linear_border<extent_type, normalized_type> 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<Dimension, texture_type, interpolate_type, normalized_type, fetch_type, texel_type, is_float, support_border>::call(Texture, Fetch, SampleCoordWrap, Layer, Face, static_cast<size_type>(floor(Level)), BorderColor);
texel_type const MaxTexel = nearest<Dimension, texture_type, interpolate_type, normalized_type, fetch_type, texel_type, is_float, support_border>::call(Texture, Fetch, SampleCoordWrap, Layer, Face, static_cast<size_type>(ceil(Level)), BorderColor);
return mix(MinTexel, MaxTexel, fract(Level));
}
};
template <dimension Dimension, typename texture_type, typename interpolate_type, typename normalized_type, typename fetch_type, typename texel_type, bool is_float, bool support_border>
struct linear_mipmap_nearest : public filterBase<Dimension, texture_type, interpolate_type, normalized_type, fetch_type, texel_type>
{
typedef filterBase<Dimension, texture_type, interpolate_type, normalized_type, fetch_type, texel_type> base_type;
typedef typename base_type::size_type size_type;
typedef typename base_type::extent_type extent_type;
typedef coord_linear_border<extent_type, normalized_type> 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<Dimension, texture_type, interpolate_type, normalized_type, fetch_type, texel_type, is_float, support_border>::call(Texture, Fetch, SampleCoordWrap, Layer, Face, glm::iround(Level), BorderColor);
}
};
template <dimension Dimension, typename texture_type, typename interpolate_type, typename normalized_type, typename fetch_type, typename texel_type, bool is_float, bool support_border>
struct linear_mipmap_linear : public filterBase<Dimension, texture_type, interpolate_type, normalized_type, fetch_type, texel_type>
{
typedef filterBase<Dimension, texture_type, interpolate_type, normalized_type, fetch_type, texel_type> base_type;
typedef typename base_type::size_type size_type;
typedef typename base_type::extent_type extent_type;
typedef coord_linear_border<extent_type, normalized_type> 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<size_type>(floor(Level));
size_type const CeilLevel = static_cast<size_type>(ceil(Level));
texel_type const MinTexel = linear<Dimension, texture_type, interpolate_type, normalized_type, fetch_type, texel_type, is_float, support_border>::call(Texture, Fetch, SampleCoordWrap, Layer, Face, FloorLevel, BorderColor);
texel_type const MaxTexel = linear<Dimension, texture_type, interpolate_type, normalized_type, fetch_type, texel_type, is_float, support_border>::call(Texture, Fetch, SampleCoordWrap, Layer, Face, CeilLevel, BorderColor);
return mix(MinTexel, MaxTexel, fract(Level));
}
};
template <typename filter_type, dimension Dimensions, typename texture_type, typename interpolate_type, typename normalized_type, typename fetch_type, typename texel_type, typename T>
inline filter_type get_filter(filter Mip, filter Min, bool Border)
{
static filter_type Table[][FILTER_COUNT][2] =
{
{
{
nearest_mipmap_nearest<Dimensions, texture_type, interpolate_type, normalized_type, fetch_type, texel_type, std::numeric_limits<T>::is_iec559, false>::call,
nearest_mipmap_nearest<Dimensions, texture_type, interpolate_type, normalized_type, fetch_type, texel_type, std::numeric_limits<T>::is_iec559, true>::call
},
{
linear_mipmap_nearest<Dimensions, texture_type, interpolate_type, normalized_type, fetch_type, texel_type, std::numeric_limits<T>::is_iec559, false>::call,
linear_mipmap_nearest<Dimensions, texture_type, interpolate_type, normalized_type, fetch_type, texel_type, std::numeric_limits<T>::is_iec559, true>::call
}
},
{
{
nearest_mipmap_linear<Dimensions, texture_type, interpolate_type, normalized_type, fetch_type, texel_type, std::numeric_limits<T>::is_iec559, false>::call,
nearest_mipmap_linear<Dimensions, texture_type, interpolate_type, normalized_type, fetch_type, texel_type, std::numeric_limits<T>::is_iec559, true>::call
},
{
linear_mipmap_linear<Dimensions, texture_type, interpolate_type, normalized_type, fetch_type, texel_type, std::numeric_limits<T>::is_iec559, false>::call,
linear_mipmap_linear<Dimensions, texture_type, interpolate_type, normalized_type, fetch_type, texel_type, std::numeric_limits<T>::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

View file

@ -1,17 +0,0 @@
#pragma once
#include <array>
#include "../texture2d.hpp"
#include "../texture2d_array.hpp"
#include "../texture_cube.hpp"
#include "../texture_cube_array.hpp"
namespace gli
{
template <typename texture>
texture flip(texture const & Texture);
}//namespace gli
#include "flip.inl"

View file

@ -1,338 +0,0 @@
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<glm::byte>() + OffsetDst,
ImageSrc.data<glm::byte>() + 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<dxt1_block*>(BlockSrc);
dxt1_block* Dst = reinterpret_cast<dxt1_block*>(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<dxt3_block*>(BlockSrc);
dxt3_block* Dst = reinterpret_cast<dxt3_block*>(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<dxt5_block*>(BlockSrc);
dxt5_block* Dst = reinterpret_cast<dxt5_block*>(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<uint8_t>() + i_block * block_size(Format), ImageSrc.data<uint8_t>() + 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<uint8_t>() + (MaxYBlock - i_row) * block_size(Format) * XBlocks + i_block * block_size(Format), ImageSrc.data<uint8_t>() + 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

View file

@ -1,376 +0,0 @@
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>(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

View file

@ -1,127 +0,0 @@
#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 texture1d generate_mipmaps(
texture1d const& Texture,
texture1d::size_type BaseLevel, texture1d::size_type MaxLevel,
filter Minification)
{
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>(texture1d const& Texture, filter Minification)
{
return generate_mipmaps(Texture, Texture.base_level(), Texture.max_level(), Minification);
}
template <>
inline texture1d_array generate_mipmaps<texture1d_array>(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>(texture2d const& Texture, filter Minification)
{
return generate_mipmaps(Texture, Texture.base_level(), Texture.max_level(), Minification);
}
template <>
inline texture2d_array generate_mipmaps<texture2d_array>(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>(texture3d const& Texture, filter Minification)
{
return generate_mipmaps(Texture, Texture.base_level(), Texture.max_level(), Minification);
}
template <>
inline texture_cube generate_mipmaps<texture_cube>(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>(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

View file

@ -1,366 +0,0 @@
#include <algorithm>
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<gli::format>(FormatIndex);
}
return static_cast<gli::format>(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

View file

@ -1,251 +0,0 @@
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<size_t>(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<size_t>(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<size_t>(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<extent2d::value_type>::max());
GLI_ASSERT(TexelCoord.y < Extent.y && TexelCoord.y >= 0 && TexelCoord.y < std::numeric_limits<extent2d::value_type>::max());
glm::u32vec2 const Input(TexelCoord);
return static_cast<size_t>(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<size_t>(glm::bitfieldInterleave(Input.x, Input.y, Input.z));
}
}//namespace detail
inline image::image()
: Format(static_cast<gli::format>(FORMAT_INVALID))
, BaseLevel(0)
, Data(nullptr)
, Size(0)
{}
inline image::image
(
format_type Format,
extent_type const& Extent
)
: Storage(std::make_shared<storage_linear>(Format, Extent, 1, 1, 1))
, Format(Format)
, BaseLevel(0)
, Data(Storage->data())
, Size(compute_size(0))
{}
inline image::image
(
std::shared_ptr<storage_linear> 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 <typename genType>
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 <typename genType>
inline genType* image::data()
{
GLI_ASSERT(!this->empty());
GLI_ASSERT(this->Storage->block_size() >= sizeof(genType));
return reinterpret_cast<genType *>(this->data());
}
template <typename genType>
inline genType const* image::data() const
{
GLI_ASSERT(!this->empty());
GLI_ASSERT(this->Storage->block_size() >= sizeof(genType));
return reinterpret_cast<genType const *>(this->data());
}
inline void image::clear()
{
GLI_ASSERT(!this->empty());
memset(this->data<glm::byte>(), 0, this->size<glm::byte>());
}
template <typename genType>
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<genType>(); ++TexelIndex)
*(this->data<genType>() + 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 <typename genType>
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<genType>() + detail::texel_linear_adressing(this->extent(), TexelCoord));
}
template <typename genType>
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<genType>() + detail::texel_linear_adressing(this->extent(), TexelCoord)) = Data;
}
}//namespace gli

View file

@ -1,24 +0,0 @@
#include <glm/gtc/integer.hpp>
#define GLM_ENABLE_EXPERIMENTAL
#include <glm/gtx/component_wise.hpp>
namespace gli
{
template <length_t L, typename T, precision P, template <length_t, typename, precision> class vecType>
inline T levels(vecType<L, T, P> const& Extent)
{
return glm::log2(compMax(Extent)) + static_cast<T>(1);
}
template <typename T>
inline T levels(T Extent)
{
return static_cast<T>(glm::log2(Extent) + static_cast<size_t>(1));
}
/*
inline int levels(int Extent)
{
return glm::log2(Extent) + static_cast<int>(1);
}
*/
}//namespace gli

View file

@ -1,55 +0,0 @@
#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<char> Data(static_cast<std::size_t>(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

View file

@ -1,324 +0,0 @@
#include "../dx.hpp"
#include "file.hpp"
#include <cstdio>
#include <cassert>
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<detail::dds_header const *>(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>(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<format>(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<format>(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<format>(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<texture::size_type>(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<char> Data(static_cast<std::size_t>(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

View file

@ -1,103 +0,0 @@
#include "file.hpp"
#include <cstdio>
#include <cassert>
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<detail::kmgHeader10 const *>(Data));
size_t Offset = sizeof(detail::kmgHeader10);
texture Texture(
static_cast<target>(Header.Target),
static_cast<format>(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_type>(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<char> Data(static_cast<std::size_t>(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

View file

@ -1,137 +0,0 @@
#include "../gl.hpp"
#include "file.hpp"
#include <cstdio>
#include <cassert>
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<detail::ktx_header10 const*>(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<gli::gl::internal_format>(Header.GLInternalFormat),
static_cast<gli::gl::external_format>(Header.GLFormat),
static_cast<gli::gl::type_format>(Header.GLType));
GLI_ASSERT(Format != static_cast<format>(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<texture::size_type>(Header.PixelHeight, 1),
std::max<texture::size_type>(Header.PixelDepth, 1)),
std::max<texture::size_type>(Header.NumberOfArrayElements, 1),
std::max<texture::size_type>(Header.NumberOfFaces, 1),
std::max<texture::size_type>(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<texture::size_type>(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<char> Data(static_cast<std::size_t>(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

View file

@ -1,72 +0,0 @@
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

View file

@ -1,116 +0,0 @@
#pragma once
#include "filter_compute.hpp"
namespace gli{
namespace detail
{
template <typename texture_type, typename sampler_value_type, typename fetch_func, typename write_func, typename normalized_type, typename texel_type>
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<sampler_value_type>::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<detail::DIMENSION_1D, texture_type, interpolate_type, normalized_type, fetch_func, texel_type>::filterFunc filter_func;
filter_func const Filter = detail::get_filter<filter_func, detail::DIMENSION_1D, texture_type, interpolate_type, normalized_type, fetch_func, texel_type, sampler_value_type>(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<typename normalized_type::value_type>(i)) * Scale);
texel_type const& Texel = Filter(Texture, Fetch, SamplePosition, Layer, Face, static_cast<sampler_value_type>(Level), texel_type(0));
Write(Texture, extent_type(i), Layer, Face, Level + 1, Texel);
}
}
}
template <typename texture_type, typename sampler_value_type, typename fetch_func, typename write_func, typename normalized_type, typename texel_type>
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<sampler_value_type>::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<detail::DIMENSION_2D, texture_type, interpolate_type, normalized_type, fetch_func, texel_type>::filterFunc filter_func;
filter_func const Filter = detail::get_filter<filter_func, detail::DIMENSION_2D, texture_type, interpolate_type, normalized_type, fetch_func, texel_type, sampler_value_type>(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<sampler_value_type>(Level), texel_type(0));
Write(Texture, extent_type(i, j), Layer, Face, Level + 1, Texel);
}
}
}
template <typename texture_type, typename sampler_value_type, typename fetch_func, typename write_func, typename normalized_type, typename texel_type>
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<sampler_value_type>::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<detail::DIMENSION_3D, texture_type, interpolate_type, normalized_type, fetch_func, texel_type>::filterFunc filter_func;
filter_func const Filter = detail::get_filter<filter_func, detail::DIMENSION_3D, texture_type, interpolate_type, normalized_type, fetch_func, texel_type, sampler_value_type>(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<sampler_value_type>(Level), texel_type(0));
Write(Texture, extent_type(i, j, k), Layer, Face, Level + 1, Texel);
}
}
}
}//namespace detail
}//namespace gli

View file

@ -1,533 +0,0 @@
#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 <typename val_type>
struct binary_func
{
typedef vec<4, val_type>(*type)(vec<4, val_type> const& A, vec<4, val_type> 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 <typename val_type>
struct compute_sampler_reduce_1d
{
typedef typename binary_func<val_type>::type func_type;
typedef texture1d::size_type size_type;
typedef texture1d::extent_type extent_type;
static vec<4, val_type> call(texture1d const& A, texture1d const& B, binary_func<val_type> TexelFunc, binary_func<val_type> ReduceFunc)
{
GLI_ASSERT(are_compatible(A, B));
sampler1d<val_type> const SamplerA(A, gli::WRAP_CLAMP_TO_EDGE), SamplerB(B, gli::WRAP_CLAMP_TO_EDGE);
extent_type TexelIndex(0);
vec<4, val_type> 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 <typename val_type>
struct compute_sampler_reduce_1d_array
{
typedef typename binary_func<val_type>::type func_type;
typedef texture1d_array::size_type size_type;
typedef texture1d_array::extent_type extent_type;
static vec<4, val_type> call(texture1d_array const& A, texture1d_array const& B, binary_func<val_type> TexelFunc, binary_func<val_type> ReduceFunc)
{
GLI_ASSERT(are_compatible(A, B));
sampler1d_array<val_type> const SamplerA(A, gli::WRAP_CLAMP_TO_EDGE), SamplerB(B, gli::WRAP_CLAMP_TO_EDGE);
extent_type TexelIndex(0);
vec<4, val_type> 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 <typename val_type>
struct compute_sampler_reduce_2d
{
typedef typename binary_func<val_type>::type func_type;
typedef texture2d::size_type size_type;
typedef texture2d::extent_type extent_type;
static vec<4, val_type> call(texture2d const& A, texture2d const& B, binary_func<val_type> TexelFunc, binary_func<val_type> ReduceFunc)
{
GLI_ASSERT(are_compatible(A, B));
sampler2d<val_type> const SamplerA(A, gli::WRAP_CLAMP_TO_EDGE), SamplerB(B, gli::WRAP_CLAMP_TO_EDGE);
extent_type TexelIndex(0);
vec<4, val_type> 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 <typename val_type>
struct compute_sampler_reduce_2d_array
{
typedef typename binary_func<val_type>::type func_type;
typedef texture2d_array::size_type size_type;
typedef texture2d_array::extent_type extent_type;
static vec<4, val_type> call(texture2d_array const& A, texture2d_array const& B, binary_func<val_type> TexelFunc, binary_func<val_type> ReduceFunc)
{
GLI_ASSERT(are_compatible(A, B));
sampler2d_array<val_type> const SamplerA(A, gli::WRAP_CLAMP_TO_EDGE), SamplerB(B, gli::WRAP_CLAMP_TO_EDGE);
extent_type TexelIndex(0);
vec<4, val_type> 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 <typename val_type>
struct compute_sampler_reduce_3d
{
typedef typename binary_func<val_type>::type func_type;
typedef texture3d::size_type size_type;
typedef texture3d::extent_type extent_type;
static vec<4, val_type> call(texture3d const& A, texture3d const& B, binary_func<val_type> TexelFunc, binary_func<val_type> ReduceFunc)
{
GLI_ASSERT(are_compatible(A, B));
sampler3d<val_type> const SamplerA(A, gli::WRAP_CLAMP_TO_EDGE), SamplerB(B, gli::WRAP_CLAMP_TO_EDGE);
extent_type TexelIndex(0);
vec<4, val_type> 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 <typename val_type>
struct compute_sampler_reduce_cube
{
typedef typename binary_func<val_type>::type func_type;
typedef texture_cube::size_type size_type;
typedef texture_cube::extent_type extent_type;
static vec<4, val_type> call(texture_cube const& A, texture_cube const& B, binary_func<val_type> TexelFunc, binary_func<val_type> ReduceFunc)
{
GLI_ASSERT(are_compatible(A, B));
sampler_cube<val_type> const SamplerA(A, gli::WRAP_CLAMP_TO_EDGE), SamplerB(B, gli::WRAP_CLAMP_TO_EDGE);
extent_type TexelIndex(0);
vec<4, val_type> 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 <typename val_type>
struct compute_sampler_reduce_cube_array
{
typedef typename binary_func<val_type>::type func_type;
typedef texture_cube_array::size_type size_type;
typedef texture_cube_array::extent_type extent_type;
static vec<4, val_type> call(texture_cube_array const& A, texture_cube_array const& B, binary_func<val_type> TexelFunc, binary_func<val_type> ReduceFunc)
{
GLI_ASSERT(are_compatible(A, B));
sampler_cube_array<val_type> const SamplerA(A, gli::WRAP_CLAMP_TO_EDGE), SamplerB(B, gli::WRAP_CLAMP_TO_EDGE);
extent_type TexelIndex(0);
vec<4, val_type> 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 <typename vec_type>
struct compute_reduce_1d
{
typedef typename reduce_func<vec_type>::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<vec_type>(TexelIndex, 0),
B.template load<vec_type>(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<vec_type>(TexelIndex, LevelIndex),
B.template load<vec_type>(TexelIndex, LevelIndex)));
}
}
return Result;
}
};
template <typename vec_type>
struct compute_reduce_1d_array
{
typedef typename reduce_func<vec_type>::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<vec_type>(TexelIndex, 0),
B.template load<vec_type>(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<vec_type>(TexelIndex, LayerIndex, LevelIndex),
B.template load<vec_type>(TexelIndex, LayerIndex, LevelIndex)));
}
}
return Result;
}
};
template <typename vec_type>
struct compute_reduce_2d
{
typedef typename reduce_func<vec_type>::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<vec_type>(TexelIndex, 0),
B.template load<vec_type>(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<vec_type>(TexelIndex, LevelIndex),
B.template load<vec_type>(TexelIndex, LevelIndex)));
}
}
return Result;
}
};
template <typename vec_type>
struct compute_reduce_2d_array
{
typedef typename reduce_func<vec_type>::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<vec_type>(TexelIndex, 0, 0),
B.template load<vec_type>(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<vec_type>(TexelIndex, LayerIndex, LevelIndex),
B.template load<vec_type>(TexelIndex, LayerIndex, LevelIndex)));
}
}
return Result;
}
};
template <typename vec_type>
struct compute_reduce_3d
{
typedef typename reduce_func<vec_type>::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<vec_type>(TexelIndex, 0),
B.template load<vec_type>(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<vec_type>(TexelIndex, LevelIndex),
B.template load<vec_type>(TexelIndex, LevelIndex)));
}
}
return Result;
}
};
template <typename vec_type>
struct compute_reduce_cube
{
typedef typename reduce_func<vec_type>::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<vec_type>(TexelIndex, 0, 0),
B.load<vec_type>(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<vec_type>(TexelIndex, FaceIndex, LevelIndex),
B.template load<vec_type>(TexelIndex, FaceIndex, LevelIndex)));
}
}
return Result;
}
};
template <typename vec_type>
struct compute_reduce_cube_array
{
typedef typename reduce_func<vec_type>::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<vec_type>(TexelIndex, 0, 0, 0),
B.load<vec_type>(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<vec_type>(TexelIndex, LayerIndex, FaceIndex, LevelIndex),
B.template load<vec_type>(TexelIndex, LayerIndex, FaceIndex, LevelIndex)));
}
}
return Result;
}
};
}//namepsace detail
template <typename vec_type>
inline vec_type reduce(texture1d const& In0, texture1d const& In1, typename reduce_func<vec_type>::type TexelFunc, typename reduce_func<vec_type>::type ReduceFunc)
{
return detail::compute_reduce_1d<vec_type>::call(In0, In1, TexelFunc, ReduceFunc);
}
template <typename vec_type>
inline vec_type reduce(texture1d_array const& In0, texture1d_array const& In1, typename reduce_func<vec_type>::type TexelFunc, typename reduce_func<vec_type>::type ReduceFunc)
{
return detail::compute_reduce_1d_array<vec_type>::call(In0, In1, TexelFunc, ReduceFunc);
}
template <typename vec_type>
inline vec_type reduce(texture2d const& In0, texture2d const& In1, typename reduce_func<vec_type>::type TexelFunc, typename reduce_func<vec_type>::type ReduceFunc)
{
return detail::compute_reduce_2d<vec_type>::call(In0, In1, TexelFunc, ReduceFunc);
}
template <typename vec_type>
inline vec_type reduce(texture2d_array const& In0, texture2d_array const& In1, typename reduce_func<vec_type>::type TexelFunc, typename reduce_func<vec_type>::type ReduceFunc)
{
return detail::compute_reduce_2d_array<vec_type>::call(In0, In1, TexelFunc, ReduceFunc);
}
template <typename vec_type>
inline vec_type reduce(texture3d const& In0, texture3d const& In1, typename reduce_func<vec_type>::type TexelFunc, typename reduce_func<vec_type>::type ReduceFunc)
{
return detail::compute_reduce_3d<vec_type>::call(In0, In1, TexelFunc, ReduceFunc);
}
template <typename vec_type>
inline vec_type reduce(texture_cube const& In0, texture_cube const& In1, typename reduce_func<vec_type>::type TexelFunc, typename reduce_func<vec_type>::type ReduceFunc)
{
return detail::compute_reduce_cube<vec_type>::call(In0, In1, TexelFunc, ReduceFunc);
}
template <typename vec_type>
inline vec_type reduce(texture_cube_array const& In0, texture_cube_array const& In1, typename reduce_func<vec_type>::type TexelFunc, typename reduce_func<vec_type>::type ReduceFunc)
{
return detail::compute_reduce_cube_array<vec_type>::call(In0, In1, TexelFunc, ReduceFunc);
}
}//namespace gli

View file

@ -1,35 +0,0 @@
#define GLM_ENABLE_EXPERIMENTAL
#include <glm/gtx/wrap.hpp>
namespace gli{
namespace detail
{
template <typename T>
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

View file

@ -1,82 +0,0 @@
#include "clear.hpp"
#include <glm/vector_relational.hpp>
namespace gli
{
template <typename T, precision P>
inline sampler1d<T, P>::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<texture_type, T, P>::call(this->Texture.format()))
, BorderColor(BorderColor)
, Filter(detail::get_filter<filter_type, detail::DIMENSION_1D, texture_type, interpolate_type, normalized_type, fetch_type, texel_type, T>(Mip, Min, is_border(Wrap)))
{
GLI_ASSERT(!Texture.empty());
GLI_ASSERT(!is_compressed(Texture.format()));
GLI_ASSERT((!std::numeric_limits<T>::is_iec559 && Mip == FILTER_NEAREST && Min == FILTER_NEAREST) || std::numeric_limits<T>::is_iec559);
}
template <typename T, precision P>
inline typename sampler1d<T, P>::texture_type const & sampler1d<T, P>::operator()() const
{
return this->Texture;
}
template <typename T, precision P>
inline typename sampler1d<T, P>::texel_type sampler1d<T, P>::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 <typename T, precision P>
inline void sampler1d<T, P>::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 <typename T, precision P>
inline void sampler1d<T, P>::clear(texel_type const & Color)
{
GLI_ASSERT(!this->Texture.empty());
GLI_ASSERT(this->Convert.Write);
detail::clear<texture_type, T, P>::call(this->Texture, this->Convert.Write, Color);
}
template <typename T, precision P>
inline typename sampler1d<T, P>::texel_type sampler1d<T, P>::texture_lod(normalized_type const & SampleCoord, level_type Level) const
{
GLI_ASSERT(!this->Texture.empty());
GLI_ASSERT(std::numeric_limits<T>::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 <typename T, precision P>
inline void sampler1d<T, P>::generate_mipmaps(filter Minification)
{
this->generate_mipmaps(this->Texture.base_level(), this->Texture.max_level(), Minification);
}
template <typename T, precision P>
inline void sampler1d<T, P>::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<texture_type, T, fetch_type, write_type, normalized_type, texel_type>(
this->Texture, this->Convert.Fetch, this->Convert.Write, 0, 0, 0, 0, BaseLevel, MaxLevel, Minification);
}
}//namespace gli

View file

@ -1,83 +0,0 @@
#include "clear.hpp"
#include <glm/vector_relational.hpp>
namespace gli
{
template <typename T, precision P>
inline sampler1d_array<T, P>::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<texture_type, T, P>::call(this->Texture.format()))
, BorderColor(BorderColor)
, Filter(detail::get_filter<filter_type, detail::DIMENSION_1D, texture_type, interpolate_type, normalized_type, fetch_type, texel_type, T>(Mip, Min, is_border(Wrap)))
{
GLI_ASSERT(!Texture.empty());
GLI_ASSERT(!is_compressed(Texture.format()));
GLI_ASSERT((!std::numeric_limits<T>::is_iec559 && Mip == FILTER_NEAREST && Min == FILTER_NEAREST) || std::numeric_limits<T>::is_iec559);
}
template <typename T, precision P>
inline typename sampler1d_array<T, P>::texture_type const & sampler1d_array<T, P>::operator()() const
{
return this->Texture;
}
template <typename T, precision P>
inline typename sampler1d_array<T, P>::texel_type sampler1d_array<T, P>::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 <typename T, precision P>
inline void sampler1d_array<T, P>::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 <typename T, precision P>
inline void sampler1d_array<T, P>::clear(texel_type const & Color)
{
GLI_ASSERT(!this->Texture.empty());
GLI_ASSERT(this->Convert.Write);
detail::clear<texture_type, T, P>::call(this->Texture, this->Convert.Write, Color);
}
template <typename T, precision P>
inline typename sampler1d_array<T, P>::texel_type sampler1d_array<T, P>::texture_lod(normalized_type const & SampleCoord, size_type Layer, level_type Level) const
{
GLI_ASSERT(!this->Texture.empty());
GLI_ASSERT(std::numeric_limits<T>::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 <typename T, precision P>
inline void sampler1d_array<T, P>::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 <typename T, precision P>
inline void sampler1d_array<T, P>::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<texture_type, T, fetch_type, write_type, normalized_type, texel_type>(
this->Texture, this->Convert.Fetch, this->Convert.Write, BaseLayer, MaxLayer, 0, 0, BaseLevel, MaxLevel, Minification);
}
}//namespace gli

View file

@ -1,82 +0,0 @@
#include "clear.hpp"
#include <glm/vector_relational.hpp>
namespace gli
{
template <typename T, precision P>
inline sampler2d<T, P>::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<texture_type, T, P>::call(this->Texture.format()))
, BorderColor(BorderColor)
, Filter(detail::get_filter<filter_type, detail::DIMENSION_2D, texture_type, interpolate_type, normalized_type, fetch_type, texel_type, T>(Mip, Min, is_border(Wrap)))
{
GLI_ASSERT(!Texture.empty());
GLI_ASSERT(!is_compressed(Texture.format()));
GLI_ASSERT((!std::numeric_limits<T>::is_iec559 && Mip == FILTER_NEAREST && Min == FILTER_NEAREST) || std::numeric_limits<T>::is_iec559);
}
template <typename T, precision P>
inline typename sampler2d<T, P>::texture_type const & sampler2d<T, P>::operator()() const
{
return this->Texture;
}
template <typename T, precision P>
inline typename sampler2d<T, P>::texel_type sampler2d<T, P>::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 <typename T, precision P>
inline void sampler2d<T, P>::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 <typename T, precision P>
inline void sampler2d<T, P>::clear(texel_type const & Color)
{
GLI_ASSERT(!this->Texture.empty());
GLI_ASSERT(this->Convert.Write);
detail::clear<texture_type, T, P>::call(this->Texture, this->Convert.Write, Color);
}
template <typename T, precision P>
inline typename sampler2d<T, P>::texel_type sampler2d<T, P>::texture_lod(normalized_type const & SampleCoord, level_type Level) const
{
GLI_ASSERT(!this->Texture.empty());
GLI_ASSERT(std::numeric_limits<T>::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 <typename T, precision P>
inline void sampler2d<T, P>::generate_mipmaps(filter Minification)
{
this->generate_mipmaps(this->Texture.base_level(), this->Texture.max_level(), Minification);
}
template <typename T, precision P>
inline void sampler2d<T, P>::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<texture_type, T, fetch_type, write_type, normalized_type, texel_type>(
this->Texture, this->Convert.Fetch, this->Convert.Write, 0, 0, 0, 0, BaseLevel, MaxLevel, Minification);
}
}//namespace gli

View file

@ -1,83 +0,0 @@
#include "clear.hpp"
#include <glm/vector_relational.hpp>
namespace gli
{
template <typename T, precision P>
inline sampler2d_array<T, P>::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<texture_type, T, P>::call(this->Texture.format()))
, BorderColor(BorderColor)
, Filter(detail::get_filter<filter_type, detail::DIMENSION_2D, texture_type, interpolate_type, normalized_type, fetch_type, texel_type, T>(Mip, Min, is_border(Wrap)))
{
GLI_ASSERT(!Texture.empty());
GLI_ASSERT(!is_compressed(Texture.format()));
GLI_ASSERT((!std::numeric_limits<T>::is_iec559 && Mip == FILTER_NEAREST && Min == FILTER_NEAREST) || std::numeric_limits<T>::is_iec559);
}
template <typename T, precision P>
inline typename sampler2d_array<T, P>::texture_type const & sampler2d_array<T, P>::operator()() const
{
return this->Texture;
}
template <typename T, precision P>
inline typename sampler2d_array<T, P>::texel_type sampler2d_array<T, P>::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 <typename T, precision P>
inline void sampler2d_array<T, P>::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 <typename T, precision P>
inline void sampler2d_array<T, P>::clear(texel_type const & Color)
{
GLI_ASSERT(!this->Texture.empty());
GLI_ASSERT(this->Convert.Write);
detail::clear<texture_type, T, P>::call(this->Texture, this->Convert.Write, Color);
}
template <typename T, precision P>
inline typename sampler2d_array<T, P>::texel_type sampler2d_array<T, P>::texture_lod(normalized_type const & SampleCoord, size_type Layer, level_type Level) const
{
GLI_ASSERT(!this->Texture.empty());
GLI_ASSERT(std::numeric_limits<T>::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 <typename T, precision P>
inline void sampler2d_array<T, P>::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 <typename T, precision P>
inline void sampler2d_array<T, P>::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<texture_type, T, fetch_type, write_type, normalized_type, texel_type>(
this->Texture, this->Convert.Fetch, this->Convert.Write, BaseLayer, MaxLayer, 0, 0, BaseLevel, MaxLevel, Minification);
}
}//namespace gli

View file

@ -1,82 +0,0 @@
#include "clear.hpp"
#include <glm/vector_relational.hpp>
namespace gli
{
template <typename T, precision P>
inline sampler3d<T, P>::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<texture_type, T, P>::call(this->Texture.format()))
, BorderColor(BorderColor)
, Filter(detail::get_filter<filter_type, detail::DIMENSION_3D, texture_type, interpolate_type, normalized_type, fetch_type, texel_type, T>(Mip, Min, is_border(Wrap)))
{
GLI_ASSERT(!Texture.empty());
GLI_ASSERT(!is_compressed(Texture.format()));
GLI_ASSERT((!std::numeric_limits<T>::is_iec559 && Mip == FILTER_NEAREST && Min == FILTER_NEAREST) || std::numeric_limits<T>::is_iec559);
}
template <typename T, precision P>
inline typename sampler3d<T, P>::texture_type const & sampler3d<T, P>::operator()() const
{
return this->Texture;
}
template <typename T, precision P>
inline typename sampler3d<T, P>::texel_type sampler3d<T, P>::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 <typename T, precision P>
inline void sampler3d<T, P>::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 <typename T, precision P>
inline void sampler3d<T, P>::clear(texel_type const & Color)
{
GLI_ASSERT(!this->Texture.empty());
GLI_ASSERT(this->Convert.Write);
detail::clear<texture_type, T, P>::call(this->Texture, this->Convert.Write, Color);
}
template <typename T, precision P>
GLI_FORCE_INLINE typename sampler3d<T, P>::texel_type sampler3d<T, P>::texture_lod(normalized_type const & SampleCoord, level_type Level) const
{
GLI_ASSERT(!this->Texture.empty());
GLI_ASSERT(std::numeric_limits<T>::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 <typename T, precision P>
inline void sampler3d<T, P>::generate_mipmaps(filter Minification)
{
this->generate_mipmaps(this->Texture.base_level(), this->Texture.max_level(), Minification);
}
template <typename T, precision P>
inline void sampler3d<T, P>::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<texture_type, T, fetch_type, write_type, normalized_type, texel_type>(
this->Texture, this->Convert.Fetch, this->Convert.Write, 0, 0, 0, 0, BaseLevel, MaxLevel, Minification);
}
}//namespace gli

View file

@ -1,84 +0,0 @@
#include "clear.hpp"
#include <glm/vector_relational.hpp>
namespace gli
{
template <typename T, precision P>
inline sampler_cube<T, P>::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<texture_cube, T, P>::call(this->Texture.format()))
, BorderColor(BorderColor)
, Filter(detail::get_filter<filter_type, detail::DIMENSION_2D, texture_type, interpolate_type, normalized_type, fetch_type, texel_type, T>(Mip, Min, is_border(Wrap)))
{
GLI_ASSERT(!Texture.empty());
GLI_ASSERT(!is_compressed(Texture.format()));
GLI_ASSERT((!std::numeric_limits<T>::is_iec559 && Mip == FILTER_NEAREST && Min == FILTER_NEAREST) || std::numeric_limits<T>::is_iec559);
}
template <typename T, precision P>
inline texture_cube const & sampler_cube<T, P>::operator()() const
{
return this->Texture;
}
template <typename T, precision P>
inline typename sampler_cube<T, P>::texel_type sampler_cube<T, P>::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 <typename T, precision P>
inline void sampler_cube<T, P>::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 <typename T, precision P>
inline void sampler_cube<T, P>::clear(texel_type const & Color)
{
GLI_ASSERT(!this->Texture.empty());
GLI_ASSERT(this->Convert.Write);
detail::clear<texture_type, T, P>::call(this->Texture, this->Convert.Write, Color);
}
template <typename T, precision P>
inline typename sampler_cube<T, P>::texel_type sampler_cube<T, P>::texture_lod(normalized_type const & SampleCoord, size_type Face, level_type Level) const
{
GLI_ASSERT(!this->Texture.empty());
GLI_ASSERT(std::numeric_limits<T>::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 <typename T, precision P>
inline void sampler_cube<T, P>::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 <typename T, precision P>
inline void sampler_cube<T, P>::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<texture_type, T, fetch_type, write_type, normalized_type, texel_type>(
this->Texture, this->Convert.Fetch, this->Convert.Write, 0, 0, BaseFace, MaxFace, BaseLevel, MaxLevel, Minification);
}
}//namespace gli

View file

@ -1,84 +0,0 @@
#include "clear.hpp"
#include <glm/vector_relational.hpp>
namespace gli
{
template <typename T, precision P>
inline sampler_cube_array<T, P>::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<texture_type, T, P>::call(this->Texture.format()))
, BorderColor(BorderColor)
, Filter(detail::get_filter<filter_type, detail::DIMENSION_2D, texture_type, interpolate_type, normalized_type, fetch_type, texel_type, T>(Mip, Min, is_border(Wrap)))
{
GLI_ASSERT(!Texture.empty());
GLI_ASSERT(!is_compressed(Texture.format()));
GLI_ASSERT((!std::numeric_limits<T>::is_iec559 && Mip == FILTER_NEAREST && Min == FILTER_NEAREST) || std::numeric_limits<T>::is_iec559);
}
template <typename T, precision P>
inline typename sampler_cube_array<T, P>::texture_type const & sampler_cube_array<T, P>::operator()() const
{
return this->Texture;
}
template <typename T, precision P>
inline typename sampler_cube_array<T, P>::texel_type sampler_cube_array<T, P>::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 <typename T, precision P>
inline void sampler_cube_array<T, P>::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 <typename T, precision P>
inline void sampler_cube_array<T, P>::clear(texel_type const & Color)
{
GLI_ASSERT(!this->Texture.empty());
GLI_ASSERT(this->Convert.Write);
detail::clear<texture_type, T, P>::call(this->Texture, this->Convert.Write, Color);
}
template <typename T, precision P>
inline typename sampler_cube_array<T, P>::texel_type sampler_cube_array<T, P>::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<T>::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 <typename T, precision P>
inline void sampler_cube_array<T, P>::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 <typename T, precision P>
inline void sampler_cube_array<T, P>::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<texture_type, T, fetch_type, write_type, normalized_type, texel_type>(
this->Texture, this->Convert.Fetch, this->Convert.Write, BaseLayer, MaxLayer, BaseFace, MaxFace, BaseLevel, MaxLevel, Minification);
}
}//namespace gli

View file

@ -1,22 +0,0 @@
#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

View file

@ -1,139 +0,0 @@
#include <cstdio>
#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<char>& 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<detail::dds_header*>(&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<std::uint32_t>(Texture.extent().x);
Header.Height = static_cast<std::uint32_t>(Texture.extent().y);
Header.Pitch = static_cast<std::uint32_t>((Desc.Flags & detail::CAP_COMPRESSED_BIT) ? Texture.size() / Texture.faces() : 32);
Header.Depth = static_cast<std::uint32_t>(Texture.extent().z > 1 ? Texture.extent().z : 0);
Header.MipMapLevels = static_cast<std::uint32_t>(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<std::uint32_t>(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<detail::dds_header10*>(&Memory[0] + Offset);
Offset += sizeof(detail::dds_header10);
Header10.ArraySize = static_cast<std::uint32_t>(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<char> 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

View file

@ -1,80 +0,0 @@
#include <cstdio>
#include <glm/gtc/round.hpp>
#include "../load_kmg.hpp"
#include "filter.hpp"
#include "file.hpp"
namespace gli
{
inline bool save_kmg(texture const & Texture, std::vector<char> & 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<detail::kmgHeader10*>(&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<std::uint32_t>(Texture.extent().x);
Header.PixelHeight = static_cast<std::uint32_t>(Texture.extent().y);
Header.PixelDepth = static_cast<std::uint32_t>(Texture.extent().z);
Header.Layers = static_cast<std::uint32_t>(Texture.layers());
Header.Levels = static_cast<std::uint32_t>(Texture.levels());
Header.Faces = static_cast<std::uint32_t>(Texture.faces());
Header.GenerateMipmaps = FILTER_NONE;
Header.BaseLevel = static_cast<std::uint32_t>(Texture.base_level());
Header.MaxLevel = static_cast<std::uint32_t>(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<char> 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

View file

@ -1,114 +0,0 @@
#include <cstdio>
#include <glm/gtc/round.hpp>
#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<texture::size_type>(4)));
TotalSize += PaddedSize;
}
}
return TotalSize;
}
}//namespace detail
inline bool save_ktx(texture const& Texture, std::vector<char>& 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<detail::ktx_header10*>(&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<std::uint32_t>(Texture.extent().x);
Header.PixelHeight = !is_target_1d(Target) ? static_cast<std::uint32_t>(Texture.extent().y) : 0;
Header.PixelDepth = Target == TARGET_3D ? static_cast<std::uint32_t>(Texture.extent().z) : 0;
Header.NumberOfArrayElements = is_target_array(Target) ? static_cast<std::uint32_t>(Texture.layers()) : 0;
Header.NumberOfFaces = is_target_cube(Target) ? static_cast<std::uint32_t>(Texture.faces()) : 1;
Header.NumberOfMipmapLevels = static_cast<std::uint32_t>(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<std::uint32_t*>(&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<texture::size_type>(4));
ImageSize += static_cast<std::uint32_t>(PaddedSize);
Offset += PaddedSize;
GLI_ASSERT(Offset <= Memory.size());
}
ImageSize = glm::ceilMultiple(ImageSize, static_cast<std::uint32_t>(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<char> 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

View file

@ -1,92 +0,0 @@
#pragma once
// STD
#include <vector>
#include <queue>
#include <string>
#include <cassert>
#include <cmath>
#include <cstring>
#include <memory>
#include "../type.hpp"
#include "../format.hpp"
// GLM
#include <glm/gtc/round.hpp>
#include <glm/gtx/component_wise.hpp>
#include <glm/gtx/integer.hpp>
#include <glm/gtx/bit.hpp>
#include <glm/gtx/raw_data.hpp>
#include <glm/gtx/wrap.hpp>
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_type> Data;
};
}//namespace gli
#include "storage_linear.inl"

View file

@ -1,170 +0,0 @@
#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<storage_linear::extent_type::value_type>(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<storage_linear::extent_type::value_type>(Level)), storage_linear::extent_type(1));
}
inline storage_linear::size_type storage_linear::size() const
{
GLI_ASSERT(!this->empty());
return static_cast<size_type>(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

View file

@ -1,98 +0,0 @@
#pragma once
// STD
#include <vector>
#include <queue>
#include <string>
#include <cassert>
#include <cmath>
#include <cstring>
#include <memory>
#include "../type.hpp"
#include "../format.hpp"
// GLM
#include <glm/gtc/round.hpp>
#include <glm/gtx/component_wise.hpp>
#include <glm/gtx/integer.hpp>
#include <glm/gtx/bit.hpp>
#include <glm/gtx/raw_data.hpp>
#include <glm/gtx/wrap.hpp>
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_type> Data;
};
}//namespace gli
#include "storage_linear.inl"

View file

@ -1,186 +0,0 @@
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<storage_linear::extent_type::value_type>(Level)), storage_linear::extent_type(1));
}
inline storage_linear::size_type storage_linear::size() const
{
GLI_ASSERT(!this->empty());
return static_cast<size_type>(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<size_t>(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<size_t>(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<storage_linear::size_type>(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

View file

@ -1,410 +0,0 @@
#include <cstring>
namespace gli
{
inline texture::texture()
: Storage(nullptr)
, Target(static_cast<gli::target>(TARGET_INVALID))
, Format(static_cast<gli::format>(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<storage_type>(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 <typename gen_type>
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 <typename gen_type>
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 <typename gen_type>
inline gen_type* texture::data()
{
GLI_ASSERT(block_size(this->format()) >= sizeof(gen_type));
return reinterpret_cast<gen_type*>(this->data());
}
template <typename gen_type>
inline gen_type const* texture::data() const
{
GLI_ASSERT(block_size(this->format()) >= sizeof(gen_type));
return reinterpret_cast<gen_type const*>(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 <typename gen_type>
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<gen_type*>(this->data(Layer, Face, Level));
}
template <typename gen_type>
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<gen_type const* const>(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 <typename gen_type>
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<gen_type>();
size_type const BlockCount = this->size<gen_type>();
for(size_type BlockIndex = 0; BlockIndex < BlockCount; ++BlockIndex)
*(Data + BlockIndex) = Texel;
}
template <typename gen_type>
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<gen_type>(Layer, Face, Level);
for(size_type BlockIndex = 0; BlockIndex < BlockCount; ++BlockIndex)
*(Data + BlockIndex) = BlockData;
}
template <typename gen_type>
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<gen_type* const>(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 <typename gen_type>
inline void texture::swizzle(gli::swizzles const& Swizzles)
{
for(size_type TexelIndex = 0, TexelCount = this->size<gen_type>(); TexelIndex < TexelCount; ++TexelIndex)
{
gen_type& TexelDst = *(this->data<gen_type>() + TexelIndex);
gen_type const TexelSrc = TexelDst;
for(typename gen_type::length_type Component = 0; Component < TexelDst.length(); ++Component)
{
GLI_ASSERT(static_cast<typename gen_type::length_type>(Swizzles[Component]) < TexelDst.length());
TexelDst[Component] = TexelSrc[Swizzles[Component]];
}
}
}
template <typename gen_type>
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<gen_type>(Level));
return *(this->data<gen_type>(Layer, Face, Level) + ImageOffset);
}
template <typename gen_type>
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<gen_type>(Level));
*(this->data<gen_type>(Layer, Face, Level) + ImageOffset) = Texel;
}
}//namespace gli

View file

@ -1,79 +0,0 @@
#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 <typename gen_type>
inline gen_type texture1d::load(extent_type const& TexelCoord, size_type Level) const
{
return this->texture::load<gen_type>(texture::extent_type(TexelCoord.x, 0, 0), 0, 0, Level);
}
template <typename gen_type>
inline void texture1d::store(extent_type const& TexelCoord, size_type Level, gen_type const& Texel)
{
this->texture::store<gen_type>(texture::extent_type(TexelCoord.x, 0, 0), 0, 0, Level, Texel);
}
}//namespace gli

View file

@ -1,81 +0,0 @@
#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 <typename gen_type>
inline gen_type texture1d_array::load(extent_type const& TexelCoord, size_type Layer, size_type Level) const
{
return this->texture::load<gen_type>(texture::extent_type(TexelCoord.x, 0, 0), Layer, 0, Level);
}
template <typename gen_type>
inline void texture1d_array::store(extent_type const& TexelCoord, size_type Layer, size_type Level, gen_type const& Texel)
{
this->texture::store<gen_type>(texture::extent_type(TexelCoord.x, 0, 0), Layer, 0, Level, Texel);
}
}//namespace gli

View file

@ -1,77 +0,0 @@
#include "../levels.hpp"
namespace gli
{
inline texture2d::texture2d()
{}
inline texture2d::texture2d(format_type Format, extent_type const& Extent, swizzles_type const& Swizzles)
: texture(TARGET_2D, Format, texture::extent_type(Extent, 1), 1, 1, gli::levels(Extent), Swizzles)
{}
inline texture2d::texture2d(format_type Format, extent_type const& Extent, size_type Levels, swizzles_type const& Swizzles)
: texture(TARGET_2D, Format, texture::extent_type(Extent, 1), 1, 1, Levels, Swizzles)
{}
inline texture2d::texture2d(texture const& Texture)
: texture(Texture, TARGET_2D, Texture.format())
{}
inline texture2d::texture2d
(
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_2D, Format,
BaseLayer, MaxLayer,
BaseFace, MaxFace,
BaseLevel, MaxLevel,
Swizzles)
{}
inline texture2d::texture2d
(
texture2d const& Texture,
size_type BaseLevel, size_type MaxLevel
)
: texture(
Texture, TARGET_2D, Texture.format(),
Texture.base_layer(), Texture.max_layer(),
Texture.base_face(), Texture.max_face(),
Texture.base_level() + BaseLevel, Texture.base_level() + MaxLevel)
{}
inline image texture2d::operator[](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 texture2d::extent_type texture2d::extent(size_type Level) const
{
return extent_type(this->texture::extent(Level));
}
template <typename gen_type>
inline gen_type texture2d::load(extent_type const& TexelCoord, size_type Level) const
{
return this->texture::load<gen_type>(texture::extent_type(TexelCoord, 0), 0, 0, Level);
}
template <typename gen_type>
inline void texture2d::store(extent_type const& TexelCoord, size_type Level, gen_type const& Texel)
{
this->texture::store<gen_type>(texture::extent_type(TexelCoord, 0), 0, 0, Level, Texel);
}
}//namespace gli

View file

@ -1,79 +0,0 @@
#include "../levels.hpp"
namespace gli
{
inline texture2d_array::texture2d_array()
{}
inline texture2d_array::texture2d_array(format_type Format, extent_type const& Extent, size_type Layers, swizzles_type const& Swizzles)
: texture(TARGET_2D_ARRAY, Format, texture::extent_type(Extent, 1), Layers, 1, gli::levels(Extent), Swizzles)
{}
inline texture2d_array::texture2d_array(format_type Format, extent_type const& Extent, size_type Layers, size_type Levels, swizzles_type const& Swizzles)
: texture(TARGET_2D_ARRAY, Format, texture::extent_type(Extent, 1), Layers, 1, Levels, Swizzles)
{}
inline texture2d_array::texture2d_array(texture const& Texture)
: texture(Texture, TARGET_2D_ARRAY, Texture.format())
{}
inline texture2d_array::texture2d_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_2D_ARRAY,
Format,
BaseLayer, MaxLayer,
BaseFace, MaxFace,
BaseLevel, MaxLevel,
Swizzles)
{}
inline texture2d_array::texture2d_array
(
texture2d_array const& Texture,
size_type BaseLayer, size_type MaxLayer,
size_type BaseLevel, size_type MaxLevel
)
: texture(
Texture, TARGET_2D_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 texture2d texture2d_array::operator[](size_type Layer) const
{
GLI_ASSERT(Layer < this->layers());
return texture2d(
*this, this->format(),
this->base_layer() + Layer, this->base_layer() + Layer,
this->base_face(), this->max_face(),
this->base_level(), this->max_level());
}
inline texture2d_array::extent_type texture2d_array::extent(size_type Level) const
{
return extent_type(this->texture::extent(Level));
}
template <typename gen_type>
inline gen_type texture2d_array::load(extent_type const& TexelCoord, size_type Layer, size_type Level) const
{
return this->texture::load<gen_type>(texture::extent_type(TexelCoord, 0), Layer, 0, Level);
}
template <typename gen_type>
inline void texture2d_array::store(extent_type const& TexelCoord, size_type Layer, size_type Level, gen_type const& Texel)
{
this->texture::store<gen_type>(texture::extent_type(TexelCoord, 0), Layer, 0, Level, Texel);
}
}//namespace gli

View file

@ -1,77 +0,0 @@
#include "../levels.hpp"
namespace gli
{
inline texture3d::texture3d()
{}
inline texture3d::texture3d(format_type Format, extent_type const& Extent, swizzles_type const& Swizzles)
: texture(TARGET_3D, Format, Extent, 1, 1, gli::levels(Extent), Swizzles)
{}
inline texture3d::texture3d(format_type Format, extent_type const& Extent, size_type Levels, swizzles_type const& Swizzles)
: texture(TARGET_3D, Format, Extent, 1, 1, Levels, Swizzles)
{}
inline texture3d::texture3d(texture const& Texture)
: texture(Texture, TARGET_3D, Texture.format())
{}
inline texture3d::texture3d
(
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_3D, Format,
BaseLayer, MaxLayer,
BaseFace, MaxFace,
BaseLevel, MaxLevel,
Swizzles)
{}
inline texture3d::texture3d
(
texture3d const& Texture,
size_type BaseLevel, size_type MaxLevel
)
: texture(
Texture, TARGET_3D, Texture.format(),
Texture.base_layer(), Texture.max_layer(),
Texture.base_face(), Texture.max_face(),
Texture.base_level() + BaseLevel, Texture.base_level() + MaxLevel)
{}
inline image texture3d::operator[](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 texture3d::extent_type texture3d::extent(size_type Level) const
{
return extent_type(this->texture::extent(Level));
}
template <typename gen_type>
inline gen_type texture3d::load(extent_type const& TexelCoord, size_type Level) const
{
return this->texture::load<gen_type>(texture::extent_type(TexelCoord), 0, 0, Level);
}
template <typename gen_type>
inline void texture3d::store(extent_type const& TexelCoord, size_type Level, gen_type const& Texel)
{
this->texture::store<gen_type>(texture::extent_type(TexelCoord), 0, 0, Level, Texel);
}
}//namespace gli

View file

@ -1,75 +0,0 @@
namespace gli
{
inline texture_cube::texture_cube()
{}
inline texture_cube::texture_cube(format_type Format, extent_type const& Extent, swizzles_type const& Swizzles)
: texture(TARGET_CUBE, Format, texture::extent_type(Extent, 1), 1, 6, gli::levels(Extent), Swizzles)
{}
inline texture_cube::texture_cube(format_type Format, extent_type const& Extent, size_type Levels, swizzles_type const& Swizzles)
: texture(TARGET_CUBE, Format, texture::extent_type(Extent, 1), 1, 6, Levels, Swizzles)
{}
inline texture_cube::texture_cube(texture const& Texture)
: texture(Texture, TARGET_CUBE, Texture.format())
{}
inline texture_cube::texture_cube
(
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_CUBE, Format,
BaseLayer, MaxLayer,
BaseFace, MaxFace,
BaseLevel, MaxLevel,
Swizzles)
{}
inline texture_cube::texture_cube
(
texture_cube const& Texture,
size_type BaseFace, size_type MaxFace,
size_type BaseLevel, size_type MaxLevel
)
: texture(
Texture, TARGET_CUBE, Texture.format(),
Texture.base_layer(), Texture.max_layer(),
Texture.base_face() + BaseFace, Texture.base_face() + MaxFace,
Texture.base_level() + BaseLevel, Texture.base_level() + MaxLevel)
{}
inline texture2d texture_cube::operator[](size_type Face) const
{
GLI_ASSERT(Face < this->faces());
return texture2d(
*this, this->format(),
this->base_layer(), this->max_layer(),
this->base_face() + Face, this->base_face() + Face,
this->base_level(), this->max_level());
}
inline texture_cube::extent_type texture_cube::extent(size_type Level) const
{
return extent_type(this->texture::extent(Level));
}
template <typename gen_type>
inline gen_type texture_cube::load(extent_type const& TexelCoord, size_type Face, size_type Level) const
{
return this->texture::load<gen_type>(texture::extent_type(TexelCoord, 0), 0, Face, Level);
}
template <typename gen_type>
inline void texture_cube::store(extent_type const& TexelCoord, size_type Face, size_type Level, gen_type const& Texel)
{
this->texture::store<gen_type>(texture::extent_type(TexelCoord, 0), 0, Face, Level, Texel);
}
}//namespace gli

View file

@ -1,77 +0,0 @@
namespace gli
{
inline texture_cube_array::texture_cube_array()
{}
inline texture_cube_array::texture_cube_array(format_type Format, extent_type const& Extent, size_type Layers, swizzles_type const& Swizzles)
: texture(TARGET_CUBE_ARRAY, Format, texture::extent_type(Extent, 1), Layers, 6, gli::levels(Extent), Swizzles)
{}
inline texture_cube_array::texture_cube_array(format_type Format, extent_type const& Extent, size_type Layers, size_type Levels, swizzles_type const& Swizzles)
: texture(TARGET_CUBE_ARRAY, Format, texture::extent_type(Extent, 1), Layers, 6, Levels, Swizzles)
{}
inline texture_cube_array::texture_cube_array(texture const& Texture)
: texture(Texture, gli::TARGET_CUBE_ARRAY, Texture.format())
{}
inline texture_cube_array::texture_cube_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_CUBE_ARRAY,
Format,
BaseLayer, MaxLayer,
BaseFace, MaxFace,
BaseLevel, MaxLevel,
Swizzles)
{}
inline texture_cube_array::texture_cube_array
(
texture_cube_array const& Texture,
size_type BaseLayer, size_type MaxLayer,
size_type BaseFace, size_type MaxFace,
size_type BaseLevel, size_type MaxLevel
)
: texture(
Texture, TARGET_CUBE_ARRAY, Texture.format(),
Texture.base_layer() + BaseLayer, Texture.base_layer() + MaxLayer,
Texture.base_face() + BaseFace, Texture.base_face() + MaxFace,
Texture.base_level() + BaseLevel, Texture.base_level() + MaxLevel)
{}
inline texture_cube texture_cube_array::operator[](size_type Layer) const
{
GLI_ASSERT(Layer < this->layers());
return texture_cube(
*this, this->format(),
this->base_layer() + Layer, this->base_layer() + Layer,
this->base_face(), this->max_face(),
this->base_level(), this->max_level());
}
inline texture_cube_array::extent_type texture_cube_array::extent(size_type Level) const
{
return extent_type(this->texture::extent(Level));
}
template <typename gen_type>
inline gen_type texture_cube_array::load(extent_type const& TexelCoord, size_type Layer, size_type Face, size_type Level) const
{
return this->texture::load<gen_type>(texture::extent_type(TexelCoord, 0), Layer, Face, Level);
}
template <typename gen_type>
inline void texture_cube_array::store(extent_type const& TexelCoord, size_type Layer, size_type Face, size_type Level, gen_type const& Texel)
{
this->texture::store<gen_type>(texture::extent_type(TexelCoord, 0), Layer, Face, Level, Texel);
}
}//namespace gli

View file

@ -1,257 +0,0 @@
namespace gli{
namespace detail
{
template <typename vec_type>
struct compute_transform_1d
{
typedef typename transform_func<vec_type>::type func_type;
typedef texture1d::size_type size_type;
typedef texture1d::extent_type extent_type;
static void call(texture1d& Output, texture1d const& A, texture1d const& B, func_type Func)
{
GLI_ASSERT(all(equal(A.extent(), B.extent())));
GLI_ASSERT(A.levels() == B.levels());
GLI_ASSERT(A.size() == B.size());
for(size_type LevelIndex = 0, LevelCount = A.levels(); LevelIndex < LevelCount; ++LevelIndex)
{
extent_type const TexelCount(A.extent(LevelIndex));
extent_type TexelIndex(0);
for(TexelIndex.x = 0; TexelIndex.x < TexelCount.x; ++TexelIndex.x)
{
Output.store<vec_type>(TexelIndex, LevelIndex, Func(
A.load<vec_type>(TexelIndex, LevelIndex),
B.load<vec_type>(TexelIndex, LevelIndex)));
}
}
}
};
template <typename vec_type>
struct compute_transform_1d_array
{
typedef typename transform_func<vec_type>::type func_type;
typedef texture1d_array::size_type size_type;
typedef texture1d_array::extent_type extent_type;
static void call(texture1d_array& Output, texture1d_array const& A, texture1d_array const& B, func_type Func)
{
GLI_ASSERT(all(equal(A.extent(), B.extent())));
GLI_ASSERT(A.layers() == B.layers());
GLI_ASSERT(A.levels() == B.levels());
GLI_ASSERT(A.size() == B.size());
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));
extent_type TexelIndex(0);
for(TexelIndex.x = 0; TexelIndex.x < TexelCount.x; ++TexelIndex.x)
{
Output.store<vec_type>(TexelIndex, LayerIndex, LevelIndex, Func(
A.load<vec_type>(TexelIndex, LayerIndex, LevelIndex),
B.load<vec_type>(TexelIndex, LayerIndex, LevelIndex)));
}
}
}
};
template <typename vec_type>
struct compute_transform_2d
{
typedef typename transform_func<vec_type>::type func_type;
typedef texture2d::size_type size_type;
typedef texture2d::extent_type extent_type;
static void call(texture2d& Output, texture2d const& A, texture2d const& B, func_type Func)
{
GLI_ASSERT(all(equal(A.extent(), B.extent())));
GLI_ASSERT(A.levels() == B.levels());
GLI_ASSERT(A.size() == B.size());
for(size_type LevelIndex = 0, LevelCount = A.levels(); LevelIndex < LevelCount; ++LevelIndex)
{
extent_type const TexelCount(A.extent(LevelIndex));
extent_type TexelIndex(0);
for(TexelIndex.y = 0; TexelIndex.y < TexelCount.y; ++TexelIndex.y)
for(TexelIndex.x = 0; TexelIndex.x < TexelCount.x; ++TexelIndex.x)
{
Output.store<vec_type>(TexelIndex, LevelIndex, Func(
A.load<vec_type>(TexelIndex, LevelIndex),
B.load<vec_type>(TexelIndex, LevelIndex)));
}
}
}
};
template <typename vec_type>
struct compute_transform_2d_array
{
typedef typename transform_func<vec_type>::type func_type;
typedef texture2d_array::size_type size_type;
typedef texture2d_array::extent_type extent_type;
static void call(texture2d_array& Output, texture2d_array const& A, texture2d_array const& B, func_type Func)
{
GLI_ASSERT(all(equal(A.extent(), B.extent())));
GLI_ASSERT(A.layers() == B.layers());
GLI_ASSERT(A.levels() == B.levels());
GLI_ASSERT(A.size() == B.size());
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));
extent_type TexelIndex(0);
for(TexelIndex.y = 0; TexelIndex.y < TexelCount.y; ++TexelIndex.y)
for(TexelIndex.x = 0; TexelIndex.x < TexelCount.x; ++TexelIndex.x)
{
Output.store<vec_type>(TexelIndex, LayerIndex, LevelIndex, Func(
A.load<vec_type>(TexelIndex, LayerIndex, LevelIndex),
B.load<vec_type>(TexelIndex, LayerIndex, LevelIndex)));
}
}
}
};
template <typename vec_type>
struct compute_transform_3d
{
typedef typename transform_func<vec_type>::type func_type;
typedef texture3d::size_type size_type;
typedef texture3d::extent_type extent_type;
static void call(texture3d& Output, texture3d const& A, texture3d const& B, func_type Func)
{
GLI_ASSERT(all(equal(A.extent(), B.extent())));
GLI_ASSERT(A.levels() == B.levels());
GLI_ASSERT(A.size() == B.size());
for(size_type LevelIndex = 0, LevelCount = A.levels(); LevelIndex < LevelCount; ++LevelIndex)
{
extent_type const TexelCount(A.extent(LevelIndex));
extent_type TexelIndex(0);
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)
{
Output.store<vec_type>(TexelIndex, LevelIndex, Func(
A.load<vec_type>(TexelIndex, LevelIndex),
B.load<vec_type>(TexelIndex, LevelIndex)));
}
}
}
};
template <typename vec_type>
struct compute_transform_cube
{
typedef typename transform_func<vec_type>::type func_type;
typedef texture_cube::size_type size_type;
typedef texture_cube::extent_type extent_type;
static void call(texture_cube& Output, texture_cube const& A, texture_cube const& B, func_type Func)
{
GLI_ASSERT(all(equal(A.extent(), B.extent())));
GLI_ASSERT(A.faces() == B.faces());
GLI_ASSERT(A.levels() == B.levels());
GLI_ASSERT(A.size() == B.size());
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));
extent_type TexelIndex(0);
for(TexelIndex.y = 0; TexelIndex.y < TexelCount.y; ++TexelIndex.y)
for(TexelIndex.x = 0; TexelIndex.x < TexelCount.x; ++TexelIndex.x)
{
Output.store<vec_type>(TexelIndex, FaceIndex, LevelIndex, Func(
A.load<vec_type>(TexelIndex, FaceIndex, LevelIndex),
B.load<vec_type>(TexelIndex, FaceIndex, LevelIndex)));
}
}
}
};
template <typename vec_type>
struct compute_transform_cube_array
{
typedef typename transform_func<vec_type>::type func_type;
typedef texture_cube_array::size_type size_type;
typedef texture_cube_array::extent_type extent_type;
static void call(texture_cube_array& Output, texture_cube_array const& A, texture_cube_array const& B, func_type Func)
{
GLI_ASSERT(all(equal(A.extent(), B.extent())));
GLI_ASSERT(A.layers() == B.layers());
GLI_ASSERT(A.levels() == B.levels());
GLI_ASSERT(A.size() == B.size());
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));
extent_type TexelIndex(0);
for(TexelIndex.y = 0; TexelIndex.y < TexelCount.y; ++TexelIndex.y)
for(TexelIndex.x = 0; TexelIndex.x < TexelCount.x; ++TexelIndex.x)
{
Output.store<vec_type>(TexelIndex, LayerIndex, FaceIndex, LevelIndex, Func(
A.load<vec_type>(TexelIndex, LayerIndex, FaceIndex, LevelIndex),
B.load<vec_type>(TexelIndex, LayerIndex, FaceIndex, LevelIndex)));
}
}
}
};
}//namepsace detail
template <typename vec_type>
inline void transform(texture1d& Out, texture1d const& In0, texture1d const& In1, typename transform_func<vec_type>::type Func)
{
detail::compute_transform_1d<vec_type>::call(Out, In0, In1, Func);
}
template <typename vec_type>
inline void transform(texture1d_array& Out, texture1d_array const& In0, texture1d_array const& In1, typename transform_func<vec_type>::type Func)
{
detail::compute_transform_1d_array<vec_type>::call(Out, In0, In1, Func);
}
template <typename vec_type>
inline void transform(texture2d& Out, texture2d const& In0, texture2d const& In1, typename transform_func<vec_type>::type Func)
{
detail::compute_transform_2d<vec_type>::call(Out, In0, In1, Func);
}
template <typename vec_type>
inline void transform(texture2d_array& Out, texture2d_array const& In0, texture2d_array const& In1, typename transform_func<vec_type>::type Func)
{
detail::compute_transform_2d_array<vec_type>::call(Out, In0, In1, Func);
}
template <typename vec_type>
inline void transform(texture3d& Out, texture3d const& In0, texture3d const& In1, typename transform_func<vec_type>::type Func)
{
detail::compute_transform_3d<vec_type>::call(Out, In0, In1, Func);
}
template <typename vec_type>
inline void transform(texture_cube& Out, texture_cube const& In0, texture_cube const& In1, typename transform_func<vec_type>::type Func)
{
detail::compute_transform_cube<vec_type>::call(Out, In0, In1, Func);
}
template <typename vec_type>
inline void transform(texture_cube_array& Out, texture_cube_array const& In0, texture_cube_array const& In1, typename transform_func<vec_type>::type Func)
{
detail::compute_transform_cube_array<vec_type>::call(Out, In0, In1, Func);
}
}//namespace gli

View file

@ -1,169 +0,0 @@
namespace gli
{
inline image view(image const& Image)
{
return Image;
}
inline texture view(texture const& Texture)
{
return Texture;
}
template <typename texType>
inline texture view(texType const& Texture)
{
return Texture;
}
inline texture view
(
texture const& Texture,
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(!Texture.empty());
GLI_ASSERT(BaseLevel >= 0 && BaseLevel < Texture.levels() && MaxLevel >= 0 && MaxLevel < Texture.levels() && BaseLevel <= MaxLevel);
GLI_ASSERT(BaseFace >= 0 && BaseFace < Texture.faces() && MaxFace >= 0 && MaxFace < Texture.faces() && BaseFace <= MaxFace);
GLI_ASSERT(BaseLayer >= 0 && BaseLayer < Texture.layers() && MaxLayer >= 0 && MaxLayer < Texture.layers() && BaseLayer <= MaxLayer);
return texture(
Texture, Texture.target(), Texture.format(),
Texture.base_layer() + BaseLayer, Texture.base_layer() + MaxLayer,
Texture.base_face() + BaseFace, Texture.base_face() + MaxFace,
Texture.base_level() + BaseLevel, Texture.base_level() + MaxLevel);
}
template <typename texType>
inline texture view(texType const& Texture, format Format)
{
GLI_ASSERT(!Texture.empty());
GLI_ASSERT(block_size(Texture.format()) == block_size(Format));
return texture(Texture, Texture.target(), Format);
}
inline texture view
(
texture1d const& Texture,
texture1d::size_type BaseLevel, texture1d::size_type MaxLevel
)
{
GLI_ASSERT(!Texture.empty());
GLI_ASSERT(BaseLevel >= 0 && BaseLevel < Texture.levels() && MaxLevel >= 0 && MaxLevel < Texture.levels() && BaseLevel <= MaxLevel);
return 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 texture view
(
texture1d_array const & Texture,
texture1d_array::size_type BaseLayer, texture1d_array::size_type MaxLayer,
texture1d_array::size_type BaseLevel, texture1d_array::size_type MaxLevel
)
{
GLI_ASSERT(!Texture.empty());
GLI_ASSERT(BaseLevel >= 0 && BaseLevel < Texture.levels() && MaxLevel >= 0 && MaxLevel < Texture.levels() && BaseLevel <= MaxLevel);
GLI_ASSERT(BaseLayer >= 0 && BaseLayer < Texture.layers() && MaxLayer >= 0 && MaxLayer < Texture.layers() && BaseLayer <= MaxLayer);
return 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 texture view
(
texture2d const & Texture,
texture2d::size_type BaseLevel, texture2d::size_type MaxLevel
)
{
GLI_ASSERT(!Texture.empty());
GLI_ASSERT(BaseLevel >= 0 && BaseLevel < Texture.levels() && MaxLevel >= 0 && MaxLevel < Texture.levels() && BaseLevel <= MaxLevel);
return texture(
Texture, TARGET_2D, Texture.format(),
Texture.base_layer(), Texture.max_layer(),
Texture.base_face(), Texture.max_face(),
Texture.base_level() + BaseLevel, Texture.base_level() + MaxLevel);
}
inline texture view
(
texture2d_array const & Texture,
texture2d_array::size_type BaseLayer, texture2d_array::size_type MaxLayer,
texture2d_array::size_type BaseLevel, texture2d_array::size_type MaxLevel
)
{
GLI_ASSERT(!Texture.empty());
GLI_ASSERT(BaseLevel >= 0 && BaseLevel < Texture.levels() && MaxLevel >= 0 && MaxLevel < Texture.levels() && BaseLevel <= MaxLevel);
GLI_ASSERT(BaseLayer >= 0 && BaseLayer < Texture.layers() && MaxLayer >= 0 && MaxLayer < Texture.layers() && BaseLayer <= MaxLayer);
return texture(
Texture, TARGET_2D_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 texture view
(
texture3d const & Texture,
texture3d::size_type BaseLevel, texture3d::size_type MaxLevel
)
{
GLI_ASSERT(!Texture.empty());
GLI_ASSERT(BaseLevel >= 0 && BaseLevel < Texture.levels() && MaxLevel >= 0 && MaxLevel < Texture.levels() && BaseLevel <= MaxLevel);
return texture(
Texture, TARGET_3D, Texture.format(),
Texture.base_layer(), Texture.max_layer(),
Texture.base_face(), Texture.max_face(),
Texture.base_level() + BaseLevel, Texture.base_level() + MaxLevel);
}
inline texture view
(
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(!Texture.empty());
GLI_ASSERT(BaseLevel >= 0 && BaseLevel < Texture.levels() && MaxLevel >= 0 && MaxLevel < Texture.levels() && BaseLevel <= MaxLevel);
GLI_ASSERT(BaseFace >= 0 && BaseFace < Texture.faces() && MaxFace >= 0 && MaxFace < Texture.faces() && BaseFace <= MaxFace);
return texture(
Texture, TARGET_CUBE, Texture.format(),
Texture.base_layer(), Texture.max_layer(),
Texture.base_face(), Texture.base_face() + MaxFace,
Texture.base_level() + BaseLevel, Texture.base_level() + MaxLevel);
}
inline texture view
(
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(!Texture.empty());
GLI_ASSERT(BaseLevel >= 0 && BaseLevel < Texture.levels() && MaxLevel >= 0 && MaxLevel < Texture.levels() && BaseLevel <= MaxLevel);
GLI_ASSERT(BaseFace >= 0 && BaseFace < Texture.faces() && MaxFace >= 0 && MaxFace < Texture.faces() && BaseFace <= MaxFace);
GLI_ASSERT(BaseLayer >= 0 && BaseLayer < Texture.layers() && MaxLayer >= 0 && MaxLayer < Texture.layers() && BaseLayer <= MaxLayer);
return texture(
Texture, TARGET_CUBE_ARRAY, Texture.format(),
Texture.base_layer() + BaseLayer, Texture.base_layer() + MaxLayer,
Texture.base_face() + BaseFace, Texture.base_face() + MaxFace,
Texture.base_level() + BaseLevel, Texture.base_level() + MaxLevel);
}
}//namespace gli

View file

@ -1,392 +0,0 @@
#pragma once
// Removed after upgrading to GLM 0.9.8
namespace gli{
namespace workaround{
namespace detail
{
union u3u3u2
{
struct
{
uint x : 3;
uint y : 3;
uint z : 2;
} data;
uint8 pack;
};
union u4u4
{
struct
{
uint x : 4;
uint y : 4;
} data;
uint8 pack;
};
union u4u4u4u4
{
struct
{
uint x : 4;
uint y : 4;
uint z : 4;
uint w : 4;
} data;
uint16 pack;
};
union u5u6u5
{
struct
{
uint x : 5;
uint y : 6;
uint z : 5;
} data;
uint16 pack;
};
union u5u5u5u1
{
struct
{
uint x : 5;
uint y : 5;
uint z : 5;
uint w : 1;
} data;
uint16 pack;
};
union u9u9u9e5
{
struct
{
uint x : 9;
uint y : 9;
uint z : 9;
uint w : 5;
} data;
uint32 pack;
};
template <typename T, typename floatType, precision P, template <typename, precision> class vecType, bool isInteger, bool signedType>
struct compute_compNormalize
{};
template <typename T, typename floatType, precision P, template <typename, precision> class vecType>
struct compute_compNormalize<T, floatType, P, vecType, true, true>
{
GLM_FUNC_QUALIFIER static vecType<floatType, P> call(vecType<T, P> const & v)
{
floatType const Min = static_cast<floatType>(std::numeric_limits<T>::min());
floatType const Max = static_cast<floatType>(std::numeric_limits<T>::max());
return (vecType<floatType, P>(v) - Min) / (Max - Min) * static_cast<floatType>(2) - static_cast<floatType>(1);
}
};
template <typename T, typename floatType, precision P, template <typename, precision> class vecType>
struct compute_compNormalize<T, floatType, P, vecType, true, false>
{
GLM_FUNC_QUALIFIER static vecType<floatType, P> call(vecType<T, P> const & v)
{
return vecType<floatType, P>(v) / static_cast<floatType>(std::numeric_limits<T>::max());
}
};
template <typename T, typename floatType, precision P, template <typename, precision> class vecType>
struct compute_compNormalize<T, floatType, P, vecType, false, true>
{
GLM_FUNC_QUALIFIER static vecType<floatType, P> call(vecType<T, P> const & v)
{
return v;
}
};
template <typename T, typename floatType, precision P, template <typename, precision> class vecType, bool isInteger, bool signedType>
struct compute_compScale
{};
template <typename T, typename floatType, precision P, template <typename, precision> class vecType>
struct compute_compScale<T, floatType, P, vecType, true, true>
{
GLM_FUNC_QUALIFIER static vecType<T, P> call(vecType<floatType, P> const & v)
{
floatType const Max = static_cast<floatType>(std::numeric_limits<T>::max()) + static_cast<floatType>(0.5);
vecType<floatType, P> const Scaled(v * Max);
vecType<T, P> const Result(Scaled - static_cast<floatType>(0.5));
return Result;
}
};
template <typename T, typename floatType, precision P, template <typename, precision> class vecType>
struct compute_compScale<T, floatType, P, vecType, true, false>
{
GLM_FUNC_QUALIFIER static vecType<T, P> call(vecType<floatType, P> const & v)
{
return vecType<T, P>(vecType<floatType, P>(v) * static_cast<floatType>(std::numeric_limits<T>::max()));
}
};
template <typename T, typename floatType, precision P, template <typename, precision> class vecType>
struct compute_compScale<T, floatType, P, vecType, false, true>
{
GLM_FUNC_QUALIFIER static vecType<T, P> call(vecType<floatType, P> const & v)
{
return v;
}
};
template <precision P, template <typename, precision> class vecType>
struct compute_half
{};
template <precision P>
struct compute_half<P, tvec1>
{
GLM_FUNC_QUALIFIER static tvec1<uint16, P> pack(tvec1<float, P> const & v)
{
int16 const Unpacked(glm::detail::toFloat16(v.x));
return tvec1<uint16, P>(reinterpret_cast<uint16 const &>(Unpacked));
}
GLM_FUNC_QUALIFIER static tvec1<float, P> unpack(tvec1<uint16, P> const & v)
{
return tvec1<float, P>(glm::detail::toFloat32(reinterpret_cast<int16 const &>(v.x)));
}
};
template <precision P>
struct compute_half<P, tvec2>
{
GLM_FUNC_QUALIFIER static tvec2<uint16, P> pack(tvec2<float, P> const & v)
{
tvec2<int16, P> const Unpacked(glm::detail::toFloat16(v.x), glm::detail::toFloat16(v.y));
return tvec2<uint16, P>(
reinterpret_cast<uint16 const &>(Unpacked.x),
reinterpret_cast<uint16 const &>(Unpacked.y));
}
GLM_FUNC_QUALIFIER static tvec2<float, P> unpack(tvec2<uint16, P> const & v)
{
return tvec2<float, P>(
glm::detail::toFloat32(reinterpret_cast<int16 const &>(v.x)),
glm::detail::toFloat32(reinterpret_cast<int16 const &>(v.y)));
}
};
template <precision P>
struct compute_half<P, tvec3>
{
GLM_FUNC_QUALIFIER static tvec3<uint16, P> pack(tvec3<float, P> const & v)
{
tvec3<int16, P> const Unpacked(glm::detail::toFloat16(v.x), glm::detail::toFloat16(v.y), glm::detail::toFloat16(v.z));
return tvec3<uint16, P>(
reinterpret_cast<uint16 const &>(Unpacked.x),
reinterpret_cast<uint16 const &>(Unpacked.y),
reinterpret_cast<uint16 const &>(Unpacked.z));
}
GLM_FUNC_QUALIFIER static tvec3<float, P> unpack(tvec3<uint16, P> const & v)
{
return tvec3<float, P>(
glm::detail::toFloat32(reinterpret_cast<int16 const &>(v.x)),
glm::detail::toFloat32(reinterpret_cast<int16 const &>(v.y)),
glm::detail::toFloat32(reinterpret_cast<int16 const &>(v.z)));
}
};
template <precision P>
struct compute_half<P, tvec4>
{
GLM_FUNC_QUALIFIER static vec<4, uint16, P> pack(vec<4, float, P> const & v)
{
vec<4, int16, P> const Unpacked(glm::detail::toFloat16(v.x), glm::detail::toFloat16(v.y), glm::detail::toFloat16(v.z), glm::detail::toFloat16(v.w));
return vec<4, uint16, P>(
reinterpret_cast<uint16 const &>(Unpacked.x),
reinterpret_cast<uint16 const &>(Unpacked.y),
reinterpret_cast<uint16 const &>(Unpacked.z),
reinterpret_cast<uint16 const &>(Unpacked.w));
}
GLM_FUNC_QUALIFIER static vec<4, float, P> unpack(vec<4, uint16, P> const & v)
{
return vec<4, float, P>(
glm::detail::toFloat32(reinterpret_cast<int16 const &>(v.x)),
glm::detail::toFloat32(reinterpret_cast<int16 const &>(v.y)),
glm::detail::toFloat32(reinterpret_cast<int16 const &>(v.z)),
glm::detail::toFloat32(reinterpret_cast<int16 const &>(v.w)));
}
};
}//namespace detail
template <typename floatType, typename T, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<floatType, P> compNormalize(vecType<T, P> const & v)
{
GLM_STATIC_ASSERT(std::numeric_limits<floatType>::is_iec559, "'compNormalize' accepts only floating-point types for 'floatType' template parameter");
return detail::compute_compNormalize<T, floatType, P, vecType, std::numeric_limits<T>::is_integer, std::numeric_limits<T>::is_signed>::call(v);
}
template <typename T, typename floatType, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<T, P> compScale(vecType<floatType, P> const & v)
{
GLM_STATIC_ASSERT(std::numeric_limits<floatType>::is_iec559, "'compScale' accepts only floating-point types for 'floatType' template parameter");
return detail::compute_compScale<T, floatType, P, vecType, std::numeric_limits<T>::is_integer, std::numeric_limits<T>::is_signed>::call(v);
}
template <typename uintType, typename floatType, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<uintType, P> packUnorm(vecType<floatType, P> const & v)
{
GLM_STATIC_ASSERT(std::numeric_limits<uintType>::is_integer, "uintType must be an integer type");
GLM_STATIC_ASSERT(std::numeric_limits<floatType>::is_iec559, "floatType must be a floating point type");
return vecType<uintType, P>(round(clamp(v, static_cast<floatType>(0), static_cast<floatType>(1)) * static_cast<floatType>(std::numeric_limits<uintType>::max())));
}
template <typename uintType, typename floatType, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<floatType, P> unpackUnorm(vecType<uintType, P> const & v)
{
GLM_STATIC_ASSERT(std::numeric_limits<uintType>::is_integer, "uintType must be an integer type");
GLM_STATIC_ASSERT(std::numeric_limits<floatType>::is_iec559, "floatType must be a floating point type");
return vecType<float, P>(v) * (static_cast<floatType>(1) / static_cast<floatType>(std::numeric_limits<uintType>::max()));
}
GLM_FUNC_QUALIFIER uint8 packUnorm2x3_1x2(vec3 const & v)
{
u32vec3 const Unpack(round(clamp(v, 0.0f, 1.0f) * vec3(7.f, 7.f, 3.f)));
detail::u3u3u2 Result;
Result.data.x = Unpack.x;
Result.data.y = Unpack.y;
Result.data.z = Unpack.z;
return Result.pack;
}
GLM_FUNC_QUALIFIER vec3 unpackUnorm2x3_1x2(uint8 v)
{
vec3 const ScaleFactor(1.f / 7.f, 1.f / 7.f, 1.f / 3.f);
detail::u3u3u2 Unpack;
Unpack.pack = v;
return vec3(Unpack.data.x, Unpack.data.y, Unpack.data.z) * ScaleFactor;
}
GLM_FUNC_QUALIFIER uint8 packUnorm2x4(vec2 const & v)
{
u32vec2 const Unpack(round(clamp(v, 0.0f, 1.0f) * 15.0f));
detail::u4u4 Result;
Result.data.x = Unpack.x;
Result.data.y = Unpack.y;
return Result.pack;
}
GLM_FUNC_QUALIFIER vec2 unpackUnorm2x4(uint8 v)
{
float const ScaleFactor(1.f / 15.f);
detail::u4u4 Unpack;
Unpack.pack = v;
return vec2(Unpack.data.x, Unpack.data.y) * ScaleFactor;
}
GLM_FUNC_QUALIFIER uint16 packUnorm4x4(vec4 const & v)
{
u32vec4 const Unpack(round(clamp(v, 0.0f, 1.0f) * 15.0f));
detail::u4u4u4u4 Result;
Result.data.x = Unpack.x;
Result.data.y = Unpack.y;
Result.data.z = Unpack.z;
Result.data.w = Unpack.w;
return Result.pack;
}
GLM_FUNC_QUALIFIER vec4 unpackUnorm4x4(uint16 v)
{
float const ScaleFactor(1.f / 15.f);
detail::u4u4u4u4 Unpack;
Unpack.pack = v;
return vec4(Unpack.data.x, Unpack.data.y, Unpack.data.z, Unpack.data.w) * ScaleFactor;
}
GLM_FUNC_QUALIFIER uint16 packUnorm3x5_1x1(vec4 const & v)
{
u32vec4 const Unpack(round(clamp(v, 0.0f, 1.0f) * vec4(15.f, 15.f, 15.f, 1.f)));
detail::u5u5u5u1 Result;
Result.data.x = Unpack.x;
Result.data.y = Unpack.y;
Result.data.z = Unpack.z;
Result.data.w = Unpack.w;
return Result.pack;
}
GLM_FUNC_QUALIFIER vec4 unpackUnorm3x5_1x1(uint16 v)
{
vec4 const ScaleFactor(1.f / 15.f, 1.f / 15.f, 1.f / 15.f, 1.f);
detail::u5u5u5u1 Unpack;
Unpack.pack = v;
return vec4(Unpack.data.x, Unpack.data.y, Unpack.data.z, Unpack.data.w) * ScaleFactor;
}
GLM_FUNC_QUALIFIER uint16 packUnorm1x5_1x6_1x5(vec3 const & v)
{
u32vec3 const Unpack(round(clamp(v, 0.0f, 1.0f) * vec3(15.f, 31.f, 15.f)));
detail::u5u6u5 Result;
Result.data.x = Unpack.x;
Result.data.y = Unpack.y;
Result.data.z = Unpack.z;
return Result.pack;
}
GLM_FUNC_QUALIFIER vec3 unpackUnorm1x5_1x6_1x5(uint16 v)
{
vec3 const ScaleFactor(1.f / 15.f, 1.f / 31.f, 1.f / 15.f);
detail::u5u6u5 Unpack;
Unpack.pack = v;
return vec3(Unpack.data.x, Unpack.data.y, Unpack.data.z) * ScaleFactor;
}
GLM_FUNC_QUALIFIER uint32 packF3x9_E1x5(vec3 const & v)
{
float const SharedExpMax = (pow(2.0f, 9.0f - 1.0f) / pow(2.0f, 9.0f)) * pow(2.0f, 31.f - 15.f);
vec3 const Color = clamp(v, 0.0f, SharedExpMax);
float const MaxColor = max(Color.x, max(Color.y, Color.z));
float const ExpSharedP = max(-15.f - 1.f, floor(log2(MaxColor))) + 1.0f + 15.f;
float const MaxShared = floor(MaxColor / pow(2.0f, (ExpSharedP - 16.f - 9.f)) + 0.5f);
float const ExpShared = MaxShared == pow(2.0f, 9.0f) ? ExpSharedP + 1.0f : ExpSharedP;
uvec3 const ColorComp(floor(Color / pow(2.f, (ExpShared - 15.f - 9.f)) + 0.5f));
detail::u9u9u9e5 Unpack;
Unpack.data.x = ColorComp.x;
Unpack.data.y = ColorComp.y;
Unpack.data.z = ColorComp.z;
Unpack.data.w = uint(ExpShared);
return Unpack.pack;
}
GLM_FUNC_QUALIFIER vec3 unpackF3x9_E1x5(uint32 v)
{
detail::u9u9u9e5 Unpack;
Unpack.pack = v;
return vec3(Unpack.data.x, Unpack.data.y, Unpack.data.z) * pow(2.0f, Unpack.data.w - 15.f - 9.f);
}
template <precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<uint16, P> packHalf(vecType<float, P> const & v)
{
return detail::compute_half<P, vecType>::pack(v);
}
template <precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER vecType<float, P> unpackHalf(vecType<uint16, P> const & v)
{
return detail::compute_half<P, vecType>::unpack(v);
}
}//namespace workaround
}//namespace gli

View file

@ -1,70 +0,0 @@
/// @brief Include to duplicate textures, images or a subset of either textures or an image. These operations will cause memory allocations.
/// @file gli/duplicate.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
{
/// Duplicate an image and create a new image with a new storage_linear allocation.
image duplicate(image const & Image);
/// Duplicate a texture and create a new texture with a new storage_linear allocation.
template <typename texType>
texture duplicate(texType const& Texture);
/// Duplicate a texture and create a new texture with a new storage_linear allocation but a different format.
/// The format must be a compatible format, a format which block size match the original format.
template <typename texType>
texture duplicate(texType const& Texture, format Format);
/// Duplicate a subset of a texture and create a new texture with a new storage_linear allocation.
texture duplicate(
texture1d const& Texture,
texture1d::size_type BaseLevel, texture1d::size_type MaxLevel);
/// Duplicate a subset of a texture and create a new texture with a new storage_linear allocation.
texture duplicate(
texture1d_array const& Texture,
texture1d_array::size_type BaseLayer, texture1d_array::size_type MaxLayer,
texture1d_array::size_type BaseLevel, texture1d_array::size_type MaxLevel);
/// Duplicate a subset of a texture and create a new texture with a new storage_linear allocation.
texture duplicate(
texture2d const& Texture,
texture2d::size_type BaseLevel, texture2d::size_type MaxLevel);
/// Duplicate a subset of a texture and create a new texture with a new storage_linear allocation.
texture duplicate(
texture2d_array const& Texture,
texture2d_array::size_type BaseLayer, texture2d_array::size_type MaxLayer,
texture2d_array::size_type BaseLevel, texture2d_array::size_type MaxLevel);
/// Duplicate a subset of a texture and create a new texture with a new storage_linear allocation.
texture duplicate(
texture3d const& Texture,
texture3d::size_type BaseLevel, texture3d::size_type MaxLevel);
/// Duplicate a subset of a texture and create a new texture with a new storage_linear allocation.
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);
/// Duplicate a subset of a texture and create a new texture with a new storage_linear allocation.
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);
}//namespace gli
#include "./core/duplicate.inl"

View file

@ -1,490 +0,0 @@
/// @brief Include to translate GLI enums to DirectX enums
/// @file gli/dx.hpp
#pragma once
#include "format.hpp"
#include "target.hpp"
#include <array>
namespace gli
{
/// Translation class to convert GLI enums into DirectX enums
class dx
{
public:
#define GLI_MAKEFOURCC(ch0, ch1, ch2, ch3) \
(std::uint32_t)( \
(((std::uint32_t)(std::uint8_t)(ch3) << 24) & 0xFF000000) | \
(((std::uint32_t)(std::uint8_t)(ch2) << 16) & 0x00FF0000) | \
(((std::uint32_t)(std::uint8_t)(ch1) << 8) & 0x0000FF00) | \
((std::uint32_t)(std::uint8_t)(ch0) & 0x000000FF) )
enum d3dfmt
{
D3DFMT_UNKNOWN = 0,
D3DFMT_R8G8B8 = 20,
D3DFMT_A8R8G8B8 = 21,
D3DFMT_X8R8G8B8 = 22,
D3DFMT_R5G6B5 = 23,
D3DFMT_X1R5G5B5 = 24,
D3DFMT_A1R5G5B5 = 25,
D3DFMT_A4R4G4B4 = 26,
D3DFMT_R3G3B2 = 27,
D3DFMT_A8 = 28,
D3DFMT_A8R3G3B2 = 29,
D3DFMT_X4R4G4B4 = 30,
D3DFMT_A2B10G10R10 = 31,
D3DFMT_A8B8G8R8 = 32,
D3DFMT_X8B8G8R8 = 33,
D3DFMT_G16R16 = 34,
D3DFMT_A2R10G10B10 = 35,
D3DFMT_A16B16G16R16 = 36,
D3DFMT_A8P8 = 40,
D3DFMT_P8 = 41,
D3DFMT_L8 = 50,
D3DFMT_A8L8 = 51,
D3DFMT_A4L4 = 52,
D3DFMT_V8U8 = 60,
D3DFMT_L6V5U5 = 61,
D3DFMT_X8L8V8U8 = 62,
D3DFMT_Q8W8V8U8 = 63,
D3DFMT_V16U16 = 64,
D3DFMT_A2W10V10U10 = 67,
D3DFMT_UYVY = GLI_MAKEFOURCC('U', 'Y', 'V', 'Y'),
D3DFMT_R8G8_B8G8 = GLI_MAKEFOURCC('R', 'G', 'B', 'G'),
D3DFMT_YUY2 = GLI_MAKEFOURCC('Y', 'U', 'Y', '2'),
D3DFMT_G8R8_G8B8 = GLI_MAKEFOURCC('G', 'R', 'G', 'B'),
D3DFMT_DXT1 = GLI_MAKEFOURCC('D', 'X', 'T', '1'),
D3DFMT_DXT2 = GLI_MAKEFOURCC('D', 'X', 'T', '2'),
D3DFMT_DXT3 = GLI_MAKEFOURCC('D', 'X', 'T', '3'),
D3DFMT_DXT4 = GLI_MAKEFOURCC('D', 'X', 'T', '4'),
D3DFMT_DXT5 = GLI_MAKEFOURCC('D', 'X', 'T', '5'),
D3DFMT_ATI1 = GLI_MAKEFOURCC('A', 'T', 'I', '1'),
D3DFMT_AT1N = GLI_MAKEFOURCC('A', 'T', '1', 'N'),
D3DFMT_ATI2 = GLI_MAKEFOURCC('A', 'T', 'I', '2'),
D3DFMT_AT2N = GLI_MAKEFOURCC('A', 'T', '2', 'N'),
D3DFMT_BC4U = GLI_MAKEFOURCC('B', 'C', '4', 'U'),
D3DFMT_BC4S = GLI_MAKEFOURCC('B', 'C', '4', 'S'),
D3DFMT_BC5U = GLI_MAKEFOURCC('B', 'C', '5', 'U'),
D3DFMT_BC5S = GLI_MAKEFOURCC('B', 'C', '5', 'S'),
D3DFMT_ETC = GLI_MAKEFOURCC('E', 'T', 'C', ' '),
D3DFMT_ETC1 = GLI_MAKEFOURCC('E', 'T', 'C', '1'),
D3DFMT_ATC = GLI_MAKEFOURCC('A', 'T', 'C', ' '),
D3DFMT_ATCA = GLI_MAKEFOURCC('A', 'T', 'C', 'A'),
D3DFMT_ATCI = GLI_MAKEFOURCC('A', 'T', 'C', 'I'),
D3DFMT_POWERVR_2BPP = GLI_MAKEFOURCC('P', 'T', 'C', '2'),
D3DFMT_POWERVR_4BPP = GLI_MAKEFOURCC('P', 'T', 'C', '4'),
D3DFMT_D16_LOCKABLE = 70,
D3DFMT_D32 = 71,
D3DFMT_D15S1 = 73,
D3DFMT_D24S8 = 75,
D3DFMT_D24X8 = 77,
D3DFMT_D24X4S4 = 79,
D3DFMT_D16 = 80,
D3DFMT_D32F_LOCKABLE = 82,
D3DFMT_D24FS8 = 83,
D3DFMT_L16 = 81,
D3DFMT_VERTEXDATA = 100,
D3DFMT_INDEX16 = 101,
D3DFMT_INDEX32 = 102,
D3DFMT_Q16W16V16U16 = 110,
D3DFMT_MULTI2_ARGB8 = GLI_MAKEFOURCC('M','E','T','1'),
D3DFMT_R16F = 111,
D3DFMT_G16R16F = 112,
D3DFMT_A16B16G16R16F = 113,
D3DFMT_R32F = 114,
D3DFMT_G32R32F = 115,
D3DFMT_A32B32G32R32F = 116,
D3DFMT_CxV8U8 = 117,
D3DFMT_DX10 = GLI_MAKEFOURCC('D', 'X', '1', '0'),
D3DFMT_GLI1 = GLI_MAKEFOURCC('G', 'L', 'I', '1'),
D3DFMT_FORCE_DWORD = 0x7fffffff
};
enum dxgi_format_dds
{
DXGI_FORMAT_UNKNOWN = 0,
DXGI_FORMAT_R32G32B32A32_TYPELESS = 1,
DXGI_FORMAT_R32G32B32A32_FLOAT = 2,
DXGI_FORMAT_R32G32B32A32_UINT = 3,
DXGI_FORMAT_R32G32B32A32_SINT = 4,
DXGI_FORMAT_R32G32B32_TYPELESS = 5,
DXGI_FORMAT_R32G32B32_FLOAT = 6,
DXGI_FORMAT_R32G32B32_UINT = 7,
DXGI_FORMAT_R32G32B32_SINT = 8,
DXGI_FORMAT_R16G16B16A16_TYPELESS = 9,
DXGI_FORMAT_R16G16B16A16_FLOAT = 10,
DXGI_FORMAT_R16G16B16A16_UNORM = 11,
DXGI_FORMAT_R16G16B16A16_UINT = 12,
DXGI_FORMAT_R16G16B16A16_SNORM = 13,
DXGI_FORMAT_R16G16B16A16_SINT = 14,
DXGI_FORMAT_R32G32_TYPELESS = 15,
DXGI_FORMAT_R32G32_FLOAT = 16,
DXGI_FORMAT_R32G32_UINT = 17,
DXGI_FORMAT_R32G32_SINT = 18,
DXGI_FORMAT_R32G8X24_TYPELESS = 19,
DXGI_FORMAT_D32_FLOAT_S8X24_UINT = 20,
DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS = 21,
DXGI_FORMAT_X32_TYPELESS_G8X24_UINT = 22,
DXGI_FORMAT_R10G10B10A2_TYPELESS = 23,
DXGI_FORMAT_R10G10B10A2_UNORM = 24,
DXGI_FORMAT_R10G10B10A2_UINT = 25,
DXGI_FORMAT_R11G11B10_FLOAT = 26,
DXGI_FORMAT_R8G8B8A8_TYPELESS = 27,
DXGI_FORMAT_R8G8B8A8_UNORM = 28,
DXGI_FORMAT_R8G8B8A8_UNORM_SRGB = 29,
DXGI_FORMAT_R8G8B8A8_UINT = 30,
DXGI_FORMAT_R8G8B8A8_SNORM = 31,
DXGI_FORMAT_R8G8B8A8_SINT = 32,
DXGI_FORMAT_R16G16_TYPELESS = 33,
DXGI_FORMAT_R16G16_FLOAT = 34,
DXGI_FORMAT_R16G16_UNORM = 35,
DXGI_FORMAT_R16G16_UINT = 36,
DXGI_FORMAT_R16G16_SNORM = 37,
DXGI_FORMAT_R16G16_SINT = 38,
DXGI_FORMAT_R32_TYPELESS = 39,
DXGI_FORMAT_D32_FLOAT = 40,
DXGI_FORMAT_R32_FLOAT = 41,
DXGI_FORMAT_R32_UINT = 42,
DXGI_FORMAT_R32_SINT = 43,
DXGI_FORMAT_R24G8_TYPELESS = 44,
DXGI_FORMAT_D24_UNORM_S8_UINT = 45,
DXGI_FORMAT_R24_UNORM_X8_TYPELESS = 46,
DXGI_FORMAT_X24_TYPELESS_G8_UINT = 47,
DXGI_FORMAT_R8G8_TYPELESS = 48,
DXGI_FORMAT_R8G8_UNORM = 49,
DXGI_FORMAT_R8G8_UINT = 50,
DXGI_FORMAT_R8G8_SNORM = 51,
DXGI_FORMAT_R8G8_SINT = 52,
DXGI_FORMAT_R16_TYPELESS = 53,
DXGI_FORMAT_R16_FLOAT = 54,
DXGI_FORMAT_D16_UNORM = 55,
DXGI_FORMAT_R16_UNORM = 56,
DXGI_FORMAT_R16_UINT = 57,
DXGI_FORMAT_R16_SNORM = 58,
DXGI_FORMAT_R16_SINT = 59,
DXGI_FORMAT_R8_TYPELESS = 60,
DXGI_FORMAT_R8_UNORM = 61,
DXGI_FORMAT_R8_UINT = 62,
DXGI_FORMAT_R8_SNORM = 63,
DXGI_FORMAT_R8_SINT = 64,
DXGI_FORMAT_A8_UNORM = 65,
DXGI_FORMAT_R1_UNORM = 66,
DXGI_FORMAT_R9G9B9E5_SHAREDEXP = 67,
DXGI_FORMAT_R8G8_B8G8_UNORM = 68,
DXGI_FORMAT_G8R8_G8B8_UNORM = 69,
DXGI_FORMAT_BC1_TYPELESS = 70,
DXGI_FORMAT_BC1_UNORM = 71,
DXGI_FORMAT_BC1_UNORM_SRGB = 72,
DXGI_FORMAT_BC2_TYPELESS = 73,
DXGI_FORMAT_BC2_UNORM = 74,
DXGI_FORMAT_BC2_UNORM_SRGB = 75,
DXGI_FORMAT_BC3_TYPELESS = 76,
DXGI_FORMAT_BC3_UNORM = 77,
DXGI_FORMAT_BC3_UNORM_SRGB = 78,
DXGI_FORMAT_BC4_TYPELESS = 79,
DXGI_FORMAT_BC4_UNORM = 80,
DXGI_FORMAT_BC4_SNORM = 81,
DXGI_FORMAT_BC5_TYPELESS = 82,
DXGI_FORMAT_BC5_UNORM = 83,
DXGI_FORMAT_BC5_SNORM = 84,
DXGI_FORMAT_B5G6R5_UNORM = 85,
DXGI_FORMAT_B5G5R5A1_UNORM = 86,
DXGI_FORMAT_B8G8R8A8_UNORM = 87,
DXGI_FORMAT_B8G8R8X8_UNORM = 88,
DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM = 89,
DXGI_FORMAT_B8G8R8A8_TYPELESS = 90,
DXGI_FORMAT_B8G8R8A8_UNORM_SRGB = 91,
DXGI_FORMAT_B8G8R8X8_TYPELESS = 92,
DXGI_FORMAT_B8G8R8X8_UNORM_SRGB = 93,
DXGI_FORMAT_BC6H_TYPELESS = 94,
DXGI_FORMAT_BC6H_UF16 = 95,
DXGI_FORMAT_BC6H_SF16 = 96,
DXGI_FORMAT_BC7_TYPELESS = 97,
DXGI_FORMAT_BC7_UNORM = 98,
DXGI_FORMAT_BC7_UNORM_SRGB = 99,
DXGI_FORMAT_AYUV = 100,
DXGI_FORMAT_Y410 = 101,
DXGI_FORMAT_Y416 = 102,
DXGI_FORMAT_NV12 = 103,
DXGI_FORMAT_P010 = 104,
DXGI_FORMAT_P016 = 105,
DXGI_FORMAT_420_OPAQUE = 106,
DXGI_FORMAT_YUY2 = 107,
DXGI_FORMAT_Y210 = 108,
DXGI_FORMAT_Y216 = 109,
DXGI_FORMAT_NV11 = 110,
DXGI_FORMAT_AI44 = 111,
DXGI_FORMAT_IA44 = 112,
DXGI_FORMAT_P8 = 113,
DXGI_FORMAT_A8P8 = 114,
DXGI_FORMAT_B4G4R4A4_UNORM = 115,
DXGI_FORMAT_P208 = 130,
DXGI_FORMAT_V208 = 131,
DXGI_FORMAT_V408 = 132,
DXGI_FORMAT_ASTC_4X4_TYPELESS = 133,
DXGI_FORMAT_ASTC_4X4_UNORM = 134,
DXGI_FORMAT_ASTC_4X4_UNORM_SRGB = 135,
DXGI_FORMAT_ASTC_5X4_TYPELESS = 137,
DXGI_FORMAT_ASTC_5X4_UNORM = 138,
DXGI_FORMAT_ASTC_5X4_UNORM_SRGB = 139,
DXGI_FORMAT_ASTC_5X5_TYPELESS = 141,
DXGI_FORMAT_ASTC_5X5_UNORM = 142,
DXGI_FORMAT_ASTC_5X5_UNORM_SRGB = 143,
DXGI_FORMAT_ASTC_6X5_TYPELESS = 145,
DXGI_FORMAT_ASTC_6X5_UNORM = 146,
DXGI_FORMAT_ASTC_6X5_UNORM_SRGB = 147,
DXGI_FORMAT_ASTC_6X6_TYPELESS = 149,
DXGI_FORMAT_ASTC_6X6_UNORM = 150,
DXGI_FORMAT_ASTC_6X6_UNORM_SRGB = 151,
DXGI_FORMAT_ASTC_8X5_TYPELESS = 153,
DXGI_FORMAT_ASTC_8X5_UNORM = 154,
DXGI_FORMAT_ASTC_8X5_UNORM_SRGB = 155,
DXGI_FORMAT_ASTC_8X6_TYPELESS = 157,
DXGI_FORMAT_ASTC_8X6_UNORM = 158,
DXGI_FORMAT_ASTC_8X6_UNORM_SRGB = 159,
DXGI_FORMAT_ASTC_8X8_TYPELESS = 161,
DXGI_FORMAT_ASTC_8X8_UNORM = 162,
DXGI_FORMAT_ASTC_8X8_UNORM_SRGB = 163,
DXGI_FORMAT_ASTC_10X5_TYPELESS = 165,
DXGI_FORMAT_ASTC_10X5_UNORM = 166,
DXGI_FORMAT_ASTC_10X5_UNORM_SRGB = 167,
DXGI_FORMAT_ASTC_10X6_TYPELESS = 169,
DXGI_FORMAT_ASTC_10X6_UNORM = 170,
DXGI_FORMAT_ASTC_10X6_UNORM_SRGB = 171,
DXGI_FORMAT_ASTC_10X8_TYPELESS = 173,
DXGI_FORMAT_ASTC_10X8_UNORM = 174,
DXGI_FORMAT_ASTC_10X8_UNORM_SRGB = 175,
DXGI_FORMAT_ASTC_10X10_TYPELESS = 177,
DXGI_FORMAT_ASTC_10X10_UNORM = 178,
DXGI_FORMAT_ASTC_10X10_UNORM_SRGB = 179,
DXGI_FORMAT_ASTC_12X10_TYPELESS = 181,
DXGI_FORMAT_ASTC_12X10_UNORM = 182,
DXGI_FORMAT_ASTC_12X10_UNORM_SRGB = 183,
DXGI_FORMAT_ASTC_12X12_TYPELESS = 185,
DXGI_FORMAT_ASTC_12X12_UNORM = 186,
DXGI_FORMAT_ASTC_12X12_UNORM_SRGB = 187,
DXGI_FORMAT_FORCE_UINT = 0xffffffffUL
};
enum dxgi_format_gli
{
DXGI_FORMAT_R64_UINT_GLI = 1,
DXGI_FORMAT_R64_SINT_GLI,
DXGI_FORMAT_R64_FLOAT_GLI,
DXGI_FORMAT_R64G64_UINT_GLI,
DXGI_FORMAT_R64G64_SINT_GLI,
DXGI_FORMAT_R64G64_FLOAT_GLI,
DXGI_FORMAT_R64G64B64_UINT_GLI,
DXGI_FORMAT_R64G64B64_SINT_GLI,
DXGI_FORMAT_R64G64B64_FLOAT_GLI,
DXGI_FORMAT_R64G64B64A64_UINT_GLI,
DXGI_FORMAT_R64G64B64A64_SINT_GLI,
DXGI_FORMAT_R64G64B64A64_FLOAT_GLI,
DXGI_FORMAT_RG4_UNORM_GLI,
DXGI_FORMAT_RGBA4_UNORM_GLI,
DXGI_FORMAT_R5G6B5_UNORM_GLI,
DXGI_FORMAT_R5G5B5A1_UNORM_GLI,
DXGI_FORMAT_A1B5G5R5_UNORM_GLI,
DXGI_FORMAT_R8_SRGB_GLI,
DXGI_FORMAT_R8_USCALED_GLI,
DXGI_FORMAT_R8_SSCALED_GLI,
DXGI_FORMAT_R8G8_SRGB_GLI,
DXGI_FORMAT_R8G8_USCALED_GLI,
DXGI_FORMAT_R8G8_SSCALED_GLI,
DXGI_FORMAT_R8G8B8_UNORM_GLI,
DXGI_FORMAT_R8G8B8_SNORM_GLI,
DXGI_FORMAT_R8G8B8_USCALED_GLI,
DXGI_FORMAT_R8G8B8_SSCALED_GLI,
DXGI_FORMAT_R8G8B8_UINT_GLI,
DXGI_FORMAT_R8G8B8_SINT_GLI,
DXGI_FORMAT_R8G8B8_SRGB_GLI,
DXGI_FORMAT_B8G8R8_UNORM_GLI,
DXGI_FORMAT_B8G8R8_SNORM_GLI,
DXGI_FORMAT_B8G8R8_USCALED_GLI,
DXGI_FORMAT_B8G8R8_SSCALED_GLI,
DXGI_FORMAT_B8G8R8_UINT_GLI,
DXGI_FORMAT_B8G8R8_SINT_GLI,
DXGI_FORMAT_B8G8R8_SRGB_GLI,
DXGI_FORMAT_R8G8B8A8_USCALED_GLI,
DXGI_FORMAT_R8G8B8A8_SSCALED_GLI,
DXGI_FORMAT_B8G8R8A8_SNORM_GLI,
DXGI_FORMAT_B8G8R8A8_USCALED_GLI,
DXGI_FORMAT_B8G8R8A8_SSCALED_GLI,
DXGI_FORMAT_B8G8R8A8_UINT_GLI,
DXGI_FORMAT_B8G8R8A8_SINT_GLI,
DXGI_FORMAT_R8G8B8A8_PACK_UNORM_GLI,
DXGI_FORMAT_R8G8B8A8_PACK_SNORM_GLI,
DXGI_FORMAT_R8G8B8A8_PACK_USCALED_GLI,
DXGI_FORMAT_R8G8B8A8_PACK_SSCALED_GLI,
DXGI_FORMAT_R8G8B8A8_PACK_UINT_GLI,
DXGI_FORMAT_R8G8B8A8_PACK_SINT_GLI,
DXGI_FORMAT_R8G8B8A8_PACK_SRGB_GLI,
DXGI_FORMAT_R10G10B10A2_SNORM_GLI,
DXGI_FORMAT_R10G10B10A2_USCALED_GLI,
DXGI_FORMAT_R10G10B10A2_SSCALED_GLI,
DXGI_FORMAT_R10G10B10A2_SINT_GLI,
DXGI_FORMAT_B10G10R10A2_UNORM_GLI,
DXGI_FORMAT_B10G10R10A2_SNORM_GLI,
DXGI_FORMAT_B10G10R10A2_USCALED_GLI,
DXGI_FORMAT_B10G10R10A2_SSCALED_GLI,
DXGI_FORMAT_B10G10R10A2_UINT_GLI,
DXGI_FORMAT_B10G10R10A2_SINT_GLI,
DXGI_FORMAT_R16_USCALED_GLI,
DXGI_FORMAT_R16_SSCALED_GLI,
DXGI_FORMAT_R16G16_USCALED_GLI,
DXGI_FORMAT_R16G16_SSCALED_GLI,
DXGI_FORMAT_R16G16B16_UNORM_GLI,
DXGI_FORMAT_R16G16B16_SNORM_GLI,
DXGI_FORMAT_R16G16B16_USCALED_GLI,
DXGI_FORMAT_R16G16B16_SSCALED_GLI,
DXGI_FORMAT_R16G16B16_UINT_GLI,
DXGI_FORMAT_R16G16B16_SINT_GLI,
DXGI_FORMAT_R16G16B16_FLOAT_GLI,
DXGI_FORMAT_R16G16B16A16_USCALED_GLI,
DXGI_FORMAT_R16G16B16A16_SSCALED_GLI,
DXGI_FORMAT_S8_UINT_GLI,
DXGI_FORMAT_D16_UNORM_S8_UINT_GLI,
DXGI_FORMAT_D24_UNORM_GLI,
DXGI_FORMAT_L8_UNORM_GLI,
DXGI_FORMAT_A8_UNORM_GLI,
DXGI_FORMAT_LA8_UNORM_GLI,
DXGI_FORMAT_L16_UNORM_GLI,
DXGI_FORMAT_A16_UNORM_GLI,
DXGI_FORMAT_LA16_UNORM_GLI,
DXGI_FORMAT_R3G3B2_UNORM_GLI,
DXGI_FORMAT_BC1_RGB_UNORM_GLI,
DXGI_FORMAT_BC1_RGB_SRGB_GLI,
DXGI_FORMAT_RGB_ETC2_UNORM_GLI,
DXGI_FORMAT_RGB_ETC2_SRGB_GLI,
DXGI_FORMAT_RGBA_ETC2_A1_UNORM_GLI,
DXGI_FORMAT_RGBA_ETC2_A1_SRGB_GLI,
DXGI_FORMAT_RGBA_ETC2_UNORM_GLI,
DXGI_FORMAT_RGBA_ETC2_SRGB_GLI,
DXGI_FORMAT_R11_EAC_UNORM_GLI,
DXGI_FORMAT_R11_EAC_SNORM_GLI,
DXGI_FORMAT_RG11_EAC_UNORM_GLI,
DXGI_FORMAT_RG11_EAC_SNORM_GLI,
DXGI_FORMAT_RGB_PVRTC1_8X8_UNORM_GLI,
DXGI_FORMAT_RGB_PVRTC1_8X8_SRGB_GLI,
DXGI_FORMAT_RGB_PVRTC1_16X8_UNORM_GLI,
DXGI_FORMAT_RGB_PVRTC1_16X8_SRGB_GLI,
DXGI_FORMAT_RGBA_PVRTC1_8X8_UNORM_GLI,
DXGI_FORMAT_RGBA_PVRTC1_8X8_SRGB_GLI,
DXGI_FORMAT_RGBA_PVRTC1_16X8_UNORM_GLI,
DXGI_FORMAT_RGBA_PVRTC1_16X8_SRGB_GLI,
DXGI_FORMAT_RGBA_PVRTC2_8X8_UNORM_GLI,
DXGI_FORMAT_RGBA_PVRTC2_8X8_SRGB_GLI,
DXGI_FORMAT_RGBA_PVRTC2_16X8_UNORM_GLI,
DXGI_FORMAT_RGBA_PVRTC2_16X8_SRGB_GLI,
DXGI_FORMAT_RGB_ETC_UNORM_GLI,
DXGI_FORMAT_RGB_ATC_UNORM_GLI,
DXGI_FORMAT_RGBA_ATCA_UNORM_GLI,
DXGI_FORMAT_RGBA_ATCI_UNORM_GLI,
};
union dxgiFormat
{
dxgiFormat()
: DDS(DXGI_FORMAT_UNKNOWN)
{}
dxgiFormat(dxgi_format_dds DDS)
: DDS(DDS)
{}
dxgiFormat(dxgi_format_gli GLI)
: GLI(GLI)
{}
dxgi_format_dds DDS;
dxgi_format_gli GLI;
};
enum ddpf
{
DDPF_ALPHAPIXELS = 0x1,
DDPF_ALPHA = 0x2,
DDPF_FOURCC = 0x4,
DDPF_RGB = 0x40,
DDPF_YUV = 0x200,
DDPF_LUMINANCE = 0x20000,
DDPF_LUMINANCE_ALPHA = DDPF_LUMINANCE | DDPF_ALPHA,
DDPF_RGBAPIXELS = DDPF_RGB | DDPF_ALPHAPIXELS,
DDPF_RGBA = DDPF_RGB | DDPF_ALPHA,
DDPF_LUMINANCE_ALPHAPIXELS = DDPF_LUMINANCE | DDPF_ALPHAPIXELS,
};
struct format
{
ddpf DDPixelFormat;
d3dfmt D3DFormat;
dxgiFormat DXGIFormat;
glm::u32vec4 Mask;
};
public:
dx();
/// Convert GLI formats into Direct3D formats
format const& translate(gli::format Format) const;
/// Convert a Direct3D 9 format into a GLI format
gli::format find(d3dfmt FourCC) const;
/// Convert a Direct3D 10 format into a GLI format
gli::format find(d3dfmt FourCC, dxgiFormat Format) const;
private:
std::array<format, FORMAT_COUNT> Translation;
};
/// Evaluate whether a target and format combinaison is only supported by the DDS container through GLI DDS extension.
bool is_dds_ext(target Target, format Format);
}//namespace gli
#include "./core/dx.inl"

View file

@ -1,340 +0,0 @@
/// @brief Include to use the format enum and query properties of formats.
/// @file gli/format.hpp
#pragma once
#include "type.hpp"
#include <cstdint>
namespace gli
{
/// Texture data format
enum format
{
FORMAT_UNDEFINED = 0,
FORMAT_RG4_UNORM_PACK8, FORMAT_FIRST = FORMAT_RG4_UNORM_PACK8,
FORMAT_RGBA4_UNORM_PACK16,
FORMAT_BGRA4_UNORM_PACK16,
FORMAT_R5G6B5_UNORM_PACK16,
FORMAT_B5G6R5_UNORM_PACK16,
FORMAT_RGB5A1_UNORM_PACK16,
FORMAT_BGR5A1_UNORM_PACK16,
FORMAT_A1RGB5_UNORM_PACK16,
FORMAT_R8_UNORM_PACK8,
FORMAT_R8_SNORM_PACK8,
FORMAT_R8_USCALED_PACK8,
FORMAT_R8_SSCALED_PACK8,
FORMAT_R8_UINT_PACK8,
FORMAT_R8_SINT_PACK8,
FORMAT_R8_SRGB_PACK8,
FORMAT_RG8_UNORM_PACK8,
FORMAT_RG8_SNORM_PACK8,
FORMAT_RG8_USCALED_PACK8,
FORMAT_RG8_SSCALED_PACK8,
FORMAT_RG8_UINT_PACK8,
FORMAT_RG8_SINT_PACK8,
FORMAT_RG8_SRGB_PACK8,
FORMAT_RGB8_UNORM_PACK8,
FORMAT_RGB8_SNORM_PACK8,
FORMAT_RGB8_USCALED_PACK8,
FORMAT_RGB8_SSCALED_PACK8,
FORMAT_RGB8_UINT_PACK8,
FORMAT_RGB8_SINT_PACK8,
FORMAT_RGB8_SRGB_PACK8,
FORMAT_BGR8_UNORM_PACK8,
FORMAT_BGR8_SNORM_PACK8,
FORMAT_BGR8_USCALED_PACK8,
FORMAT_BGR8_SSCALED_PACK8,
FORMAT_BGR8_UINT_PACK8,
FORMAT_BGR8_SINT_PACK8,
FORMAT_BGR8_SRGB_PACK8,
FORMAT_RGBA8_UNORM_PACK8,
FORMAT_RGBA8_SNORM_PACK8,
FORMAT_RGBA8_USCALED_PACK8,
FORMAT_RGBA8_SSCALED_PACK8,
FORMAT_RGBA8_UINT_PACK8,
FORMAT_RGBA8_SINT_PACK8,
FORMAT_RGBA8_SRGB_PACK8,
FORMAT_BGRA8_UNORM_PACK8,
FORMAT_BGRA8_SNORM_PACK8,
FORMAT_BGRA8_USCALED_PACK8,
FORMAT_BGRA8_SSCALED_PACK8,
FORMAT_BGRA8_UINT_PACK8,
FORMAT_BGRA8_SINT_PACK8,
FORMAT_BGRA8_SRGB_PACK8,
FORMAT_RGBA8_UNORM_PACK32,
FORMAT_RGBA8_SNORM_PACK32,
FORMAT_RGBA8_USCALED_PACK32,
FORMAT_RGBA8_SSCALED_PACK32,
FORMAT_RGBA8_UINT_PACK32,
FORMAT_RGBA8_SINT_PACK32,
FORMAT_RGBA8_SRGB_PACK32,
FORMAT_RGB10A2_UNORM_PACK32,
FORMAT_RGB10A2_SNORM_PACK32,
FORMAT_RGB10A2_USCALED_PACK32,
FORMAT_RGB10A2_SSCALED_PACK32,
FORMAT_RGB10A2_UINT_PACK32,
FORMAT_RGB10A2_SINT_PACK32,
FORMAT_BGR10A2_UNORM_PACK32,
FORMAT_BGR10A2_SNORM_PACK32,
FORMAT_BGR10A2_USCALED_PACK32,
FORMAT_BGR10A2_SSCALED_PACK32,
FORMAT_BGR10A2_UINT_PACK32,
FORMAT_BGR10A2_SINT_PACK32,
FORMAT_R16_UNORM_PACK16,
FORMAT_R16_SNORM_PACK16,
FORMAT_R16_USCALED_PACK16,
FORMAT_R16_SSCALED_PACK16,
FORMAT_R16_UINT_PACK16,
FORMAT_R16_SINT_PACK16,
FORMAT_R16_SFLOAT_PACK16,
FORMAT_RG16_UNORM_PACK16,
FORMAT_RG16_SNORM_PACK16,
FORMAT_RG16_USCALED_PACK16,
FORMAT_RG16_SSCALED_PACK16,
FORMAT_RG16_UINT_PACK16,
FORMAT_RG16_SINT_PACK16,
FORMAT_RG16_SFLOAT_PACK16,
FORMAT_RGB16_UNORM_PACK16,
FORMAT_RGB16_SNORM_PACK16,
FORMAT_RGB16_USCALED_PACK16,
FORMAT_RGB16_SSCALED_PACK16,
FORMAT_RGB16_UINT_PACK16,
FORMAT_RGB16_SINT_PACK16,
FORMAT_RGB16_SFLOAT_PACK16,
FORMAT_RGBA16_UNORM_PACK16,
FORMAT_RGBA16_SNORM_PACK16,
FORMAT_RGBA16_USCALED_PACK16,
FORMAT_RGBA16_SSCALED_PACK16,
FORMAT_RGBA16_UINT_PACK16,
FORMAT_RGBA16_SINT_PACK16,
FORMAT_RGBA16_SFLOAT_PACK16,
FORMAT_R32_UINT_PACK32,
FORMAT_R32_SINT_PACK32,
FORMAT_R32_SFLOAT_PACK32,
FORMAT_RG32_UINT_PACK32,
FORMAT_RG32_SINT_PACK32,
FORMAT_RG32_SFLOAT_PACK32,
FORMAT_RGB32_UINT_PACK32,
FORMAT_RGB32_SINT_PACK32,
FORMAT_RGB32_SFLOAT_PACK32,
FORMAT_RGBA32_UINT_PACK32,
FORMAT_RGBA32_SINT_PACK32,
FORMAT_RGBA32_SFLOAT_PACK32,
FORMAT_R64_UINT_PACK64,
FORMAT_R64_SINT_PACK64,
FORMAT_R64_SFLOAT_PACK64,
FORMAT_RG64_UINT_PACK64,
FORMAT_RG64_SINT_PACK64,
FORMAT_RG64_SFLOAT_PACK64,
FORMAT_RGB64_UINT_PACK64,
FORMAT_RGB64_SINT_PACK64,
FORMAT_RGB64_SFLOAT_PACK64,
FORMAT_RGBA64_UINT_PACK64,
FORMAT_RGBA64_SINT_PACK64,
FORMAT_RGBA64_SFLOAT_PACK64,
FORMAT_RG11B10_UFLOAT_PACK32,
FORMAT_RGB9E5_UFLOAT_PACK32,
FORMAT_D16_UNORM_PACK16,
FORMAT_D24_UNORM_PACK32,
FORMAT_D32_SFLOAT_PACK32,
FORMAT_S8_UINT_PACK8,
FORMAT_D16_UNORM_S8_UINT_PACK32,
FORMAT_D24_UNORM_S8_UINT_PACK32,
FORMAT_D32_SFLOAT_S8_UINT_PACK64,
FORMAT_RGB_DXT1_UNORM_BLOCK8,
FORMAT_RGB_DXT1_SRGB_BLOCK8,
FORMAT_RGBA_DXT1_UNORM_BLOCK8,
FORMAT_RGBA_DXT1_SRGB_BLOCK8,
FORMAT_RGBA_DXT3_UNORM_BLOCK16,
FORMAT_RGBA_DXT3_SRGB_BLOCK16,
FORMAT_RGBA_DXT5_UNORM_BLOCK16,
FORMAT_RGBA_DXT5_SRGB_BLOCK16,
FORMAT_R_ATI1N_UNORM_BLOCK8,
FORMAT_R_ATI1N_SNORM_BLOCK8,
FORMAT_RG_ATI2N_UNORM_BLOCK16,
FORMAT_RG_ATI2N_SNORM_BLOCK16,
FORMAT_RGB_BP_UFLOAT_BLOCK16,
FORMAT_RGB_BP_SFLOAT_BLOCK16,
FORMAT_RGBA_BP_UNORM_BLOCK16,
FORMAT_RGBA_BP_SRGB_BLOCK16,
FORMAT_RGB_ETC2_UNORM_BLOCK8,
FORMAT_RGB_ETC2_SRGB_BLOCK8,
FORMAT_RGBA_ETC2_UNORM_BLOCK8,
FORMAT_RGBA_ETC2_SRGB_BLOCK8,
FORMAT_RGBA_ETC2_UNORM_BLOCK16,
FORMAT_RGBA_ETC2_SRGB_BLOCK16,
FORMAT_R_EAC_UNORM_BLOCK8,
FORMAT_R_EAC_SNORM_BLOCK8,
FORMAT_RG_EAC_UNORM_BLOCK16,
FORMAT_RG_EAC_SNORM_BLOCK16,
FORMAT_RGBA_ASTC_4X4_UNORM_BLOCK16,
FORMAT_RGBA_ASTC_4X4_SRGB_BLOCK16,
FORMAT_RGBA_ASTC_5X4_UNORM_BLOCK16,
FORMAT_RGBA_ASTC_5X4_SRGB_BLOCK16,
FORMAT_RGBA_ASTC_5X5_UNORM_BLOCK16,
FORMAT_RGBA_ASTC_5X5_SRGB_BLOCK16,
FORMAT_RGBA_ASTC_6X5_UNORM_BLOCK16,
FORMAT_RGBA_ASTC_6X5_SRGB_BLOCK16,
FORMAT_RGBA_ASTC_6X6_UNORM_BLOCK16,
FORMAT_RGBA_ASTC_6X6_SRGB_BLOCK16,
FORMAT_RGBA_ASTC_8X5_UNORM_BLOCK16,
FORMAT_RGBA_ASTC_8X5_SRGB_BLOCK16,
FORMAT_RGBA_ASTC_8X6_UNORM_BLOCK16,
FORMAT_RGBA_ASTC_8X6_SRGB_BLOCK16,
FORMAT_RGBA_ASTC_8X8_UNORM_BLOCK16,
FORMAT_RGBA_ASTC_8X8_SRGB_BLOCK16,
FORMAT_RGBA_ASTC_10X5_UNORM_BLOCK16,
FORMAT_RGBA_ASTC_10X5_SRGB_BLOCK16,
FORMAT_RGBA_ASTC_10X6_UNORM_BLOCK16,
FORMAT_RGBA_ASTC_10X6_SRGB_BLOCK16,
FORMAT_RGBA_ASTC_10X8_UNORM_BLOCK16,
FORMAT_RGBA_ASTC_10X8_SRGB_BLOCK16,
FORMAT_RGBA_ASTC_10X10_UNORM_BLOCK16,
FORMAT_RGBA_ASTC_10X10_SRGB_BLOCK16,
FORMAT_RGBA_ASTC_12X10_UNORM_BLOCK16,
FORMAT_RGBA_ASTC_12X10_SRGB_BLOCK16,
FORMAT_RGBA_ASTC_12X12_UNORM_BLOCK16,
FORMAT_RGBA_ASTC_12X12_SRGB_BLOCK16,
FORMAT_RGB_PVRTC1_8X8_UNORM_BLOCK32,
FORMAT_RGB_PVRTC1_8X8_SRGB_BLOCK32,
FORMAT_RGB_PVRTC1_16X8_UNORM_BLOCK32,
FORMAT_RGB_PVRTC1_16X8_SRGB_BLOCK32,
FORMAT_RGBA_PVRTC1_8X8_UNORM_BLOCK32,
FORMAT_RGBA_PVRTC1_8X8_SRGB_BLOCK32,
FORMAT_RGBA_PVRTC1_16X8_UNORM_BLOCK32,
FORMAT_RGBA_PVRTC1_16X8_SRGB_BLOCK32,
FORMAT_RGBA_PVRTC2_4X4_UNORM_BLOCK8,
FORMAT_RGBA_PVRTC2_4X4_SRGB_BLOCK8,
FORMAT_RGBA_PVRTC2_8X4_UNORM_BLOCK8,
FORMAT_RGBA_PVRTC2_8X4_SRGB_BLOCK8,
FORMAT_RGB_ETC_UNORM_BLOCK8,
FORMAT_RGB_ATC_UNORM_BLOCK8,
FORMAT_RGBA_ATCA_UNORM_BLOCK16,
FORMAT_RGBA_ATCI_UNORM_BLOCK16,
FORMAT_L8_UNORM_PACK8,
FORMAT_A8_UNORM_PACK8,
FORMAT_LA8_UNORM_PACK8,
FORMAT_L16_UNORM_PACK16,
FORMAT_A16_UNORM_PACK16,
FORMAT_LA16_UNORM_PACK16,
FORMAT_BGR8_UNORM_PACK32,
FORMAT_BGR8_SRGB_PACK32,
FORMAT_RG3B2_UNORM_PACK8, FORMAT_LAST = FORMAT_RG3B2_UNORM_PACK8
};
/// Represent the source of a channel
enum swizzle
{
SWIZZLE_RED, SWIZZLE_FIRST = SWIZZLE_RED, SWIZZLE_CHANNEL_FIRST = SWIZZLE_RED,
SWIZZLE_GREEN,
SWIZZLE_BLUE,
SWIZZLE_ALPHA, SWIZZLE_CHANNEL_LAST = SWIZZLE_ALPHA,
SWIZZLE_ZERO,
SWIZZLE_ONE, SWIZZLE_LAST = SWIZZLE_ONE
};
/// Determine whether the Swizzle value represent a channel
inline bool is_channel(swizzle Swizzle)
{
return Swizzle >= SWIZZLE_CHANNEL_FIRST && Swizzle <= SWIZZLE_CHANNEL_LAST;
}
enum
{
FORMAT_INVALID = -1,
FORMAT_COUNT = FORMAT_LAST - FORMAT_FIRST + 1,
SWIZZLE_COUNT = SWIZZLE_LAST - SWIZZLE_FIRST + 1
};
/// Evaluate whether a format value is value or not
inline bool is_valid(format Format)
{
return Format >= FORMAT_FIRST && Format <= FORMAT_LAST;
}
typedef glm::vec<4, swizzle> swizzles;
/// Evaluate whether a format is compressed
bool is_compressed(format Format);
/// Evaluate whether a format is compressed with an S3TC algorithm.
bool is_s3tc_compressed(format Format);
/// Evaluate whether a format stores sRGB color space values
bool is_srgb(format Format);
/// Return the size in bytes of a block for a format.
size_t block_size(format Format);
/// Return the dimensions in texels of the block for a format
ivec3 block_extent(format Format);
/// Return the number of components of a format
size_t component_count(format Format);
/// Evaluate whether a format is unsigned
bool is_unsigned(format Format);
/// Evaluate whether a format is signed
bool is_signed(format Format);
/// Evaluate whether the format is an integer format
bool is_integer(format Format);
/// Evaluate whether the format is a signed integer format
bool is_signed_integer(format Format);
/// Evaluate whether the format is an unsigned integer format
bool is_unsigned_integer(format Format);
/// Evaluate whether the format is an float format
bool is_float(format Format);
/// Evaluate whether the format is normalized
bool is_normalized(format Format);
/// Evaluate whether the format is an unsigned normalized format
bool is_unorm(format Format);
/// Evaluate whether the format is a signed normalized format
bool is_snorm(format Format);
/// Evaluate whether the format is packed
bool is_packed(format Format);
}//namespace gli
#include "./core/format.inl"

View file

@ -1,69 +0,0 @@
/// @brief Include to generate mipmaps of textures.
/// @file gli/generate_mipmaps.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"
#include "sampler.hpp"
namespace gli
{
/// Allocate a texture and generate all the mipmaps of the texture using the Minification filter.
template <typename texture_type>
texture_type generate_mipmaps(texture_type const& Texture, filter Minification);
/// Allocate a texture and generate the mipmaps of the texture from the BaseLevel to the MaxLevel included using the Minification filter.
texture1d generate_mipmaps(
texture1d const& Texture,
texture1d::size_type BaseLevel, texture1d::size_type MaxLevel,
filter Minification);
/// Allocate a texture and generate the mipmaps of the texture from the BaseLayer to the MaxLayer and from the BaseLevel to the MaxLevel included levels using the Minification filter.
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);
/// Allocate a texture and generate the mipmaps of the texture from the BaseLevel to the MaxLevel included using the Minification filter.
texture2d generate_mipmaps(
texture2d const& Texture,
texture2d::size_type BaseLevel, texture2d::size_type MaxLevel,
filter Minification);
/// Allocate a texture and generate the mipmaps of the texture from the BaseLayer to the MaxLayer and from the BaseLevel to the MaxLevel included levels using the Minification filter.
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);
/// Allocate a texture and generate the mipmaps of the texture from the BaseLevel to the MaxLevel included using the Minification filter.
texture3d generate_mipmaps(
texture3d const& Texture,
texture3d::size_type BaseLevel, texture3d::size_type MaxLevel,
filter Minification);
/// Allocate a texture and generate the mipmaps of the texture from the BaseLayer to the MaxLayer, from the BaseFace to the MaxFace and from the BaseLevel to the MaxLevel included levels using the Minification filter.
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);
/// Allocate a texture and generate the mipmaps of the texture from the BaseLayer to the MaxLayer and from the BaseLevel to the MaxLevel included levels using the Minification filter.
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);
}//namespace gli
#include "./core/generate_mipmaps.inl"

View file

@ -1,373 +0,0 @@
/// @brief Include to translate GLI enums to OpenGL enums
/// @file gli/gl.hpp
#pragma once
#include "format.hpp"
#include "target.hpp"
#include <array>
namespace gli
{
/// Translation class to convert GLI enums into OpenGL values
class gl
{
public:
enum internal_format
{
INTERNAL_RGB_UNORM= 0x1907, //GL_RGB
INTERNAL_BGR_UNORM = 0x80E0, //GL_BGR
INTERNAL_RGBA_UNORM = 0x1908, //GL_RGBA
INTERNAL_BGRA_UNORM = 0x80E1, //GL_BGRA
INTERNAL_BGRA8_UNORM = 0x93A1, //GL_BGRA8_EXT
// unorm formats
INTERNAL_R8_UNORM = 0x8229, //GL_R8
INTERNAL_RG8_UNORM = 0x822B, //GL_RG8
INTERNAL_RGB8_UNORM = 0x8051, //GL_RGB8
INTERNAL_RGBA8_UNORM = 0x8058, //GL_RGBA8
INTERNAL_R16_UNORM = 0x822A, //GL_R16
INTERNAL_RG16_UNORM = 0x822C, //GL_RG16
INTERNAL_RGB16_UNORM = 0x8054, //GL_RGB16
INTERNAL_RGBA16_UNORM = 0x805B, //GL_RGBA16
INTERNAL_RGB10A2_UNORM = 0x8059, //GL_RGB10_A2
INTERNAL_RGB10A2_SNORM_EXT = 0xFFFC,
// snorm formats
INTERNAL_R8_SNORM = 0x8F94, //GL_R8_SNORM
INTERNAL_RG8_SNORM = 0x8F95, //GL_RG8_SNORM
INTERNAL_RGB8_SNORM = 0x8F96, //GL_RGB8_SNORM
INTERNAL_RGBA8_SNORM = 0x8F97, //GL_RGBA8_SNORM
INTERNAL_R16_SNORM = 0x8F98, //GL_R16_SNORM
INTERNAL_RG16_SNORM= 0x8F99, //GL_RG16_SNORM
INTERNAL_RGB16_SNORM= 0x8F9A, //GL_RGB16_SNORM
INTERNAL_RGBA16_SNORM = 0x8F9B, //GL_RGBA16_SNORM
// unsigned integer formats
INTERNAL_R8U = 0x8232, //GL_R8UI
INTERNAL_RG8U = 0x8238, //GL_RG8UI
INTERNAL_RGB8U = 0x8D7D, //GL_RGB8UI
INTERNAL_RGBA8U = 0x8D7C, //GL_RGBA8UI
INTERNAL_R16U = 0x8234, //GL_R16UI
INTERNAL_RG16U = 0x823A, //GL_RG16UI
INTERNAL_RGB16U = 0x8D77, //GL_RGB16UI
INTERNAL_RGBA16U = 0x8D76, //GL_RGBA16UI
INTERNAL_R32U = 0x8236, //GL_R32UI
INTERNAL_RG32U = 0x823C, //GL_RG32UI
INTERNAL_RGB32U = 0x8D71, //GL_RGB32UI
INTERNAL_RGBA32U = 0x8D70, //GL_RGBA32UI
INTERNAL_RGB10A2U = 0x906F, //GL_RGB10_A2UI
INTERNAL_RGB10A2I_EXT = 0xFFFB,
// signed integer formats
INTERNAL_R8I = 0x8231, //GL_R8I
INTERNAL_RG8I = 0x8237, //GL_RG8I
INTERNAL_RGB8I = 0x8D8F, //GL_RGB8I
INTERNAL_RGBA8I = 0x8D8E, //GL_RGBA8I
INTERNAL_R16I = 0x8233, //GL_R16I
INTERNAL_RG16I = 0x8239, //GL_RG16I
INTERNAL_RGB16I = 0x8D89, //GL_RGB16I
INTERNAL_RGBA16I = 0x8D88, //GL_RGBA16I
INTERNAL_R32I = 0x8235, //GL_R32I
INTERNAL_RG32I = 0x823B, //GL_RG32I
INTERNAL_RGB32I = 0x8D83, //GL_RGB32I
INTERNAL_RGBA32I = 0x8D82, //GL_RGBA32I
// Floating formats
INTERNAL_R16F = 0x822D, //GL_R16F
INTERNAL_RG16F = 0x822F, //GL_RG16F
INTERNAL_RGB16F = 0x881B, //GL_RGB16F
INTERNAL_RGBA16F = 0x881A, //GL_RGBA16F
INTERNAL_R32F = 0x822E, //GL_R32F
INTERNAL_RG32F = 0x8230, //GL_RG32F
INTERNAL_RGB32F = 0x8815, //GL_RGB32F
INTERNAL_RGBA32F = 0x8814, //GL_RGBA32F
INTERNAL_R64F_EXT = 0xFFFA, //GL_R64F
INTERNAL_RG64F_EXT = 0xFFF9, //GL_RG64F
INTERNAL_RGB64F_EXT = 0xFFF8, //GL_RGB64F
INTERNAL_RGBA64F_EXT = 0xFFF7, //GL_RGBA64F
// sRGB formats
INTERNAL_SR8 = 0x8FBD, //GL_SR8_EXT
INTERNAL_SRG8 = 0x8FBE, //GL_SRG8_EXT
INTERNAL_SRGB8 = 0x8C41, //GL_SRGB8
INTERNAL_SRGB8_ALPHA8 = 0x8C43, //GL_SRGB8_ALPHA8
// Packed formats
INTERNAL_RGB9E5 = 0x8C3D, //GL_RGB9_E5
INTERNAL_RG11B10F = 0x8C3A, //GL_R11F_G11F_B10F
INTERNAL_RG3B2 = 0x2A10, //GL_R3_G3_B2
INTERNAL_R5G6B5 = 0x8D62, //GL_RGB565
INTERNAL_RGB5A1 = 0x8057, //GL_RGB5_A1
INTERNAL_RGBA4 = 0x8056, //GL_RGBA4
INTERNAL_RG4_EXT = 0xFFFE,
// Luminance Alpha formats
INTERNAL_LA4 = 0x8043, //GL_LUMINANCE4_ALPHA4
INTERNAL_L8 = 0x8040, //GL_LUMINANCE8
INTERNAL_A8 = 0x803C, //GL_ALPHA8
INTERNAL_LA8 = 0x8045, //GL_LUMINANCE8_ALPHA8
INTERNAL_L16 = 0x8042, //GL_LUMINANCE16
INTERNAL_A16 = 0x803E, //GL_ALPHA16
INTERNAL_LA16 = 0x8048, //GL_LUMINANCE16_ALPHA16
// Depth formats
INTERNAL_D16 = 0x81A5, //GL_DEPTH_COMPONENT16
INTERNAL_D24 = 0x81A6, //GL_DEPTH_COMPONENT24
INTERNAL_D16S8_EXT = 0xFFF6,
INTERNAL_D24S8 = 0x88F0, //GL_DEPTH24_STENCIL8
INTERNAL_D32 = 0x81A7, //GL_DEPTH_COMPONENT32
INTERNAL_D32F = 0x8CAC, //GL_DEPTH_COMPONENT32F
INTERNAL_D32FS8X24 = 0x8CAD, //GL_DEPTH32F_STENCIL8
INTERNAL_S8_EXT = 0x8D48, //GL_STENCIL_INDEX8
// Compressed formats
INTERNAL_RGB_DXT1 = 0x83F0, //GL_COMPRESSED_RGB_S3TC_DXT1_EXT
INTERNAL_RGBA_DXT1 = 0x83F1, //GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
INTERNAL_RGBA_DXT3 = 0x83F2, //GL_COMPRESSED_RGBA_S3TC_DXT3_EXT
INTERNAL_RGBA_DXT5 = 0x83F3, //GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
INTERNAL_R_ATI1N_UNORM = 0x8DBB, //GL_COMPRESSED_RED_RGTC1
INTERNAL_R_ATI1N_SNORM = 0x8DBC, //GL_COMPRESSED_SIGNED_RED_RGTC1
INTERNAL_RG_ATI2N_UNORM = 0x8DBD, //GL_COMPRESSED_RG_RGTC2
INTERNAL_RG_ATI2N_SNORM = 0x8DBE, //GL_COMPRESSED_SIGNED_RG_RGTC2
INTERNAL_RGB_BP_UNSIGNED_FLOAT = 0x8E8F, //GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT
INTERNAL_RGB_BP_SIGNED_FLOAT = 0x8E8E, //GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT
INTERNAL_RGB_BP_UNORM = 0x8E8C, //GL_COMPRESSED_RGBA_BPTC_UNORM
INTERNAL_RGB_PVRTC_4BPPV1 = 0x8C00, //GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG
INTERNAL_RGB_PVRTC_2BPPV1 = 0x8C01, //GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG
INTERNAL_RGBA_PVRTC_4BPPV1 = 0x8C02, //GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG
INTERNAL_RGBA_PVRTC_2BPPV1 = 0x8C03, //GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG
INTERNAL_RGBA_PVRTC_4BPPV2 = 0x9137, //GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG
INTERNAL_RGBA_PVRTC_2BPPV2 = 0x9138, //GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG
INTERNAL_ATC_RGB = 0x8C92, //GL_ATC_RGB_AMD
INTERNAL_ATC_RGBA_EXPLICIT_ALPHA = 0x8C93, //GL_ATC_RGBA_EXPLICIT_ALPHA_AMD
INTERNAL_ATC_RGBA_INTERPOLATED_ALPHA = 0x87EE, //GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD
INTERNAL_RGB_ETC = 0x8D64, //GL_COMPRESSED_RGB8_ETC1
INTERNAL_RGB_ETC2 = 0x9274, //GL_COMPRESSED_RGB8_ETC2
INTERNAL_RGBA_PUNCHTHROUGH_ETC2 = 0x9276, //GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2
INTERNAL_RGBA_ETC2 = 0x9278, //GL_COMPRESSED_RGBA8_ETC2_EAC
INTERNAL_R11_EAC = 0x9270, //GL_COMPRESSED_R11_EAC
INTERNAL_SIGNED_R11_EAC = 0x9271, //GL_COMPRESSED_SIGNED_R11_EAC
INTERNAL_RG11_EAC = 0x9272, //GL_COMPRESSED_RG11_EAC
INTERNAL_SIGNED_RG11_EAC = 0x9273, //GL_COMPRESSED_SIGNED_RG11_EAC
INTERNAL_RGBA_ASTC_4x4 = 0x93B0, //GL_COMPRESSED_RGBA_ASTC_4x4_KHR
INTERNAL_RGBA_ASTC_5x4 = 0x93B1, //GL_COMPRESSED_RGBA_ASTC_5x4_KHR
INTERNAL_RGBA_ASTC_5x5 = 0x93B2, //GL_COMPRESSED_RGBA_ASTC_5x5_KHR
INTERNAL_RGBA_ASTC_6x5 = 0x93B3, //GL_COMPRESSED_RGBA_ASTC_6x5_KHR
INTERNAL_RGBA_ASTC_6x6 = 0x93B4, //GL_COMPRESSED_RGBA_ASTC_6x6_KHR
INTERNAL_RGBA_ASTC_8x5 = 0x93B5, //GL_COMPRESSED_RGBA_ASTC_8x5_KHR
INTERNAL_RGBA_ASTC_8x6 = 0x93B6, //GL_COMPRESSED_RGBA_ASTC_8x6_KHR
INTERNAL_RGBA_ASTC_8x8 = 0x93B7, //GL_COMPRESSED_RGBA_ASTC_8x8_KHR
INTERNAL_RGBA_ASTC_10x5 = 0x93B8, //GL_COMPRESSED_RGBA_ASTC_10x5_KHR
INTERNAL_RGBA_ASTC_10x6 = 0x93B9, //GL_COMPRESSED_RGBA_ASTC_10x6_KHR
INTERNAL_RGBA_ASTC_10x8 = 0x93BA, //GL_COMPRESSED_RGBA_ASTC_10x8_KHR
INTERNAL_RGBA_ASTC_10x10 = 0x93BB, //GL_COMPRESSED_RGBA_ASTC_10x10_KHR
INTERNAL_RGBA_ASTC_12x10 = 0x93BC, //GL_COMPRESSED_RGBA_ASTC_12x10_KHR
INTERNAL_RGBA_ASTC_12x12 = 0x93BD, //GL_COMPRESSED_RGBA_ASTC_12x12_KHR
// sRGB formats
INTERNAL_SRGB_DXT1 = 0x8C4C, //GL_COMPRESSED_SRGB_S3TC_DXT1_EXT
INTERNAL_SRGB_ALPHA_DXT1 = 0x8C4D, //GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT
INTERNAL_SRGB_ALPHA_DXT3 = 0x8C4E, //GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT
INTERNAL_SRGB_ALPHA_DXT5 = 0x8C4F, //GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT
INTERNAL_SRGB_BP_UNORM = 0x8E8D, //GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM
INTERNAL_SRGB_PVRTC_2BPPV1 = 0x8A54, //GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT
INTERNAL_SRGB_PVRTC_4BPPV1 = 0x8A55, //GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT
INTERNAL_SRGB_ALPHA_PVRTC_2BPPV1 = 0x8A56, //GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT
INTERNAL_SRGB_ALPHA_PVRTC_4BPPV1 = 0x8A57, //GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT
INTERNAL_SRGB_ALPHA_PVRTC_2BPPV2 = 0x93F0, //COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV2_IMG
INTERNAL_SRGB_ALPHA_PVRTC_4BPPV2 = 0x93F1, //GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV2_IMG
INTERNAL_SRGB8_ETC2 = 0x9275, //GL_COMPRESSED_SRGB8_ETC2
INTERNAL_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 0x9277, //GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2
INTERNAL_SRGB8_ALPHA8_ETC2_EAC = 0x9279, //GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC
INTERNAL_SRGB8_ALPHA8_ASTC_4x4 = 0x93D0, //GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR
INTERNAL_SRGB8_ALPHA8_ASTC_5x4 = 0x93D1, //GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR
INTERNAL_SRGB8_ALPHA8_ASTC_5x5 = 0x93D2, //GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR
INTERNAL_SRGB8_ALPHA8_ASTC_6x5 = 0x93D3, //GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR
INTERNAL_SRGB8_ALPHA8_ASTC_6x6 = 0x93D4, //GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR
INTERNAL_SRGB8_ALPHA8_ASTC_8x5 = 0x93D5, //GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR
INTERNAL_SRGB8_ALPHA8_ASTC_8x6 = 0x93D6, //GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR
INTERNAL_SRGB8_ALPHA8_ASTC_8x8 = 0x93D7, //GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR
INTERNAL_SRGB8_ALPHA8_ASTC_10x5 = 0x93D8, //GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR
INTERNAL_SRGB8_ALPHA8_ASTC_10x6 = 0x93D9, //GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR
INTERNAL_SRGB8_ALPHA8_ASTC_10x8 = 0x93DA, //GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR
INTERNAL_SRGB8_ALPHA8_ASTC_10x10 = 0x93DB, //GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR
INTERNAL_SRGB8_ALPHA8_ASTC_12x10 = 0x93DC, //GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR
INTERNAL_SRGB8_ALPHA8_ASTC_12x12 = 0x93DD, //GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR
INTERNAL_ALPHA8 = 0x803C,
INTERNAL_ALPHA16 = 0x803E,
INTERNAL_LUMINANCE8 = 0x8040,
INTERNAL_LUMINANCE16 = 0x8042,
INTERNAL_LUMINANCE8_ALPHA8 = 0x8045,
INTERNAL_LUMINANCE16_ALPHA16 = 0x8048,
INTERNAL_R8_USCALED_GTC = 0xF000,
INTERNAL_R8_SSCALED_GTC,
INTERNAL_RG8_USCALED_GTC,
INTERNAL_RG8_SSCALED_GTC,
INTERNAL_RGB8_USCALED_GTC,
INTERNAL_RGB8_SSCALED_GTC,
INTERNAL_RGBA8_USCALED_GTC,
INTERNAL_RGBA8_SSCALED_GTC,
INTERNAL_RGB10A2_USCALED_GTC,
INTERNAL_RGB10A2_SSCALED_GTC,
INTERNAL_R16_USCALED_GTC,
INTERNAL_R16_SSCALED_GTC,
INTERNAL_RG16_USCALED_GTC,
INTERNAL_RG16_SSCALED_GTC,
INTERNAL_RGB16_USCALED_GTC,
INTERNAL_RGB16_SSCALED_GTC,
INTERNAL_RGBA16_USCALED_GTC,
INTERNAL_RGBA16_SSCALED_GTC,
};
enum external_format
{
EXTERNAL_NONE = 0, //GL_NONE
EXTERNAL_RED = 0x1903, //GL_RED
EXTERNAL_RG = 0x8227, //GL_RG
EXTERNAL_RGB= 0x1907, //GL_RGB
EXTERNAL_BGR = 0x80E0, //GL_BGR
EXTERNAL_RGBA = 0x1908, //GL_RGBA
EXTERNAL_BGRA = 0x80E1, //GL_BGRA
EXTERNAL_RED_INTEGER = 0x8D94, //GL_RED_INTEGER
EXTERNAL_RG_INTEGER = 0x8228, //GL_RG_INTEGER
EXTERNAL_RGB_INTEGER = 0x8D98, //GL_RGB_INTEGER
EXTERNAL_BGR_INTEGER = 0x8D9A, //GL_BGR_INTEGER
EXTERNAL_RGBA_INTEGER = 0x8D99, //GL_RGBA_INTEGER
EXTERNAL_BGRA_INTEGER = 0x8D9B, //GL_BGRA_INTEGER
EXTERNAL_DEPTH = 0x1902, //GL_DEPTH_COMPONENT
EXTERNAL_DEPTH_STENCIL = 0x84F9, //GL_DEPTH_STENCIL
EXTERNAL_STENCIL = 0x1901, //GL_STENCIL_INDEX
EXTERNAL_LUMINANCE = 0x1909, //GL_LUMINANCE
EXTERNAL_ALPHA = 0x1906, //GL_ALPHA
EXTERNAL_LUMINANCE_ALPHA = 0x190A, //GL_LUMINANCE_ALPHA
EXTERNAL_SRGB_EXT = 0x8C40, //SRGB_EXT
EXTERNAL_SRGB_ALPHA_EXT = 0x8C42 //SRGB_ALPHA_EXT
};
enum type_format
{
TYPE_NONE = 0, //GL_NONE
TYPE_I8 = 0x1400, //GL_BYTE
TYPE_U8 = 0x1401, //GL_UNSIGNED_BYTE
TYPE_I16 = 0x1402, //GL_SHORT
TYPE_U16 = 0x1403, //GL_UNSIGNED_SHORT
TYPE_I32 = 0x1404, //GL_INT
TYPE_U32 = 0x1405, //GL_UNSIGNED_INT
TYPE_I64 = 0x140E, //GL_INT64_ARB
TYPE_U64 = 0x140F, //GL_UNSIGNED_INT64_ARB
TYPE_F16 = 0x140B, //GL_HALF_FLOAT
TYPE_F16_OES = 0x8D61, //GL_HALF_FLOAT_OES
TYPE_F32 = 0x1406, //GL_FLOAT
TYPE_F64 = 0x140A, //GL_DOUBLE
TYPE_UINT32_RGB9_E5_REV = 0x8C3E, //GL_UNSIGNED_INT_5_9_9_9_REV
TYPE_UINT32_RG11B10F_REV = 0x8C3B, //GL_UNSIGNED_INT_10F_11F_11F_REV
TYPE_UINT8_RG3B2 = 0x8032, //GL_UNSIGNED_BYTE_3_3_2
TYPE_UINT8_RG3B2_REV = 0x8362, //GL_UNSIGNED_BYTE_2_3_3_REV
TYPE_UINT16_RGB5A1 = 0x8034, //GL_UNSIGNED_SHORT_5_5_5_1
TYPE_UINT16_RGB5A1_REV = 0x8366, //GL_UNSIGNED_SHORT_1_5_5_5_REV
TYPE_UINT16_R5G6B5 = 0x8363, //GL_UNSIGNED_SHORT_5_6_5
TYPE_UINT16_R5G6B5_REV = 0x8364, //GL_UNSIGNED_SHORT_5_6_5_REV
TYPE_UINT16_RGBA4 = 0x8033, //GL_UNSIGNED_SHORT_4_4_4_4
TYPE_UINT16_RGBA4_REV = 0x8365, //GL_UNSIGNED_SHORT_4_4_4_4_REV
TYPE_UINT32_RGBA8 = 0x8035, //GL_UNSIGNED_SHORT_8_8_8_8
TYPE_UINT32_RGBA8_REV = 0x8367, //GL_UNSIGNED_SHORT_8_8_8_8_REV
TYPE_UINT32_RGB10A2 = 0x8036, //GL_UNSIGNED_INT_10_10_10_2
TYPE_UINT32_RGB10A2_REV = 0x8368, //GL_UNSIGNED_INT_2_10_10_10_REV
TYPE_UINT8_RG4_REV_GTC = 0xFFFD,
TYPE_UINT16_A1RGB5_GTC = 0xFFFC
};
enum target
{
TARGET_1D = 0x0DE0,
TARGET_1D_ARRAY = 0x8C18,
TARGET_2D = 0x0DE1,
TARGET_2D_ARRAY = 0x8C1A,
TARGET_3D = 0x806F,
TARGET_RECT = 0x84F5,
TARGET_RECT_ARRAY = 0x84F5, // Not supported by OpenGL
TARGET_CUBE = 0x8513,
TARGET_CUBE_ARRAY = 0x9009
};
enum swizzle
{
SWIZZLE_RED = 0x1903, //GL_RED
SWIZZLE_GREEN = 0x1904, //GL_GREEN
SWIZZLE_BLUE = 0x1905, //GL_BLUE
SWIZZLE_ALPHA = 0x1906, //GL_ALPHA
SWIZZLE_ZERO = 0x0000, //GL_ZERO
SWIZZLE_ONE = 0x0001, //GL_ONE
};
enum profile
{
PROFILE_ES20,
PROFILE_ES30,
PROFILE_GL32,
PROFILE_GL33,
PROFILE_KTX
};
typedef glm::vec<4, int> swizzles;
struct format
{
internal_format Internal;
external_format External;
type_format Type;
swizzles Swizzles;
};
gl(profile Profile);
/// Convert GLI targets into OpenGL texture targets
target const& translate(gli::target Target) const;
/// Convert GLI formats into OpenGL texture formats
format translate(gli::format Format, gli::swizzles const& Swizzle) const;
/// Convert an OpenGL format into a GLI format
gli::format find(internal_format InternalFormat, external_format ExternalFormat, type_format Type);
private:
struct format_desc
{
internal_format Internal;
external_format External;
type_format Type;
unsigned int Properties;
};
bool has_swizzle(profile Profile) const
{
return Profile == PROFILE_ES30 || Profile == PROFILE_GL33;
}
gl::swizzles compute_swizzle(format_desc const& FormatDesc, gli::swizzles const& Swizzle) const;
std::array<format_desc, FORMAT_COUNT> FormatDesc;
profile Profile;
};
}//namespace gli
#include "./core/gl.inl"

View file

@ -1,75 +0,0 @@
/// @brief Include to include everything in GLI which is not recommendated due to compilation time cost.
/// @file gli/gli.hpp
/// @mainpage OpenGL Image (GLI)
///
/// [OpenGL Image](http://gli.g-truc.net/) (*GLI*) is a header only C++ image library for graphics software.
/// (*GLI*) provides classes and functions to load image files ([KTX](https://www.khronos.org/opengles/sdk/tools/KTX/) and [DDS](https://msdn.microsoft.com/en-us/library/windows/desktop/bb943990%28v=vs.85%29.aspx)),
/// facilitate graphics APIs texture creation, compare textures, access texture texels, sample textures, convert textures, generate mipmaps, etc.
///
/// This library works perfectly with [OpenGL](https://www.opengl.org) or [Vulkan](https://www.khronos.org/vulkan) but it also ensures interoperability with other third party libraries and SDK.
/// It is a good candidate for software rendering (raytracing / rasterisation), image processing, image based software testing or any development context that requires a simple and convenient image library.
///
/// *GLI* is written in C++11. It is a platform independent library with no dependence and it supports the following compilers:
/// - [Apple Clang 4.0](https://developer.apple.com/library/mac/documentation/CompilerTools/Conceptual/LLVMCompilerOverview/index.html) and higher
/// - [GCC](http://gcc.gnu.org/) 4.6 and higher
/// - [Intel C++ Composer](https://software.intel.com/en-us/intel-compilers) XE 2013 and higher
/// - [LLVM](http://llvm.org/) 3.2 and higher
/// - [Visual C++](http://www.visualstudio.com/) 2010 and higher
/// - Any conform C++11 compiler
///
/// For more information about *GLI*, please have a look at the [API reference documentation](http://gli.g-truc.net/0.8.0/api/index.html).
/// The source code and the documentation are licensed under the [Happy Bunny License (Modified MIT) or the MIT License](copying.md).
///
/// Thanks for contributing to the project by [submitting issues](https://github.com/g-truc/gli/issues) for bug reports and feature requests. Any feedback is welcome at [gli@g-truc.net](mailto://gli@g-truc.net).
#pragma once
#define GLI_VERSION 82
#define GLI_VERSION_MAJOR 0
#define GLI_VERSION_MINOR 8
#define GLI_VERSION_PATCH 2
#define GLI_VERSION_REVISION 1
/// Namespace where all the classes and functions provided by GLI are exposed
namespace gli
{
}//namespace gli
#include "format.hpp"
#include "target.hpp"
#include "levels.hpp"
#include "image.hpp"
#include "texture.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 "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"
#include "duplicate.hpp"
#include "convert.hpp"
#include "view.hpp"
#include "comparison.hpp"
#include "reduce.hpp"
#include "transform.hpp"
#include "load.hpp"
#include "save.hpp"
#include "gl.hpp"
#include "dx.hpp"
#include "./core/flip.hpp"

View file

@ -1,111 +0,0 @@
/// @brief Include to use images, a representation of a single texture level.
/// @file gli/image.hpp
#pragma once
#include "./core/storage_linear.hpp"
namespace gli
{
/// Image, representation for a single texture level
class image
{
private:
friend class texture1d;
friend class texture2d;
friend class texture3d;
public:
typedef size_t size_type;
typedef gli::format format_type;
typedef storage_linear::extent_type extent_type;
typedef storage_linear::data_type data_type;
/// Create an empty image instance
image();
/// Create an image object and allocate an image storoge for it.
explicit image(format_type Format, extent_type const& Extent);
/// Create an image object by sharing an existing image storage_linear from another image instance.
/// This image object is effectively an image view where format can be reinterpreted
/// with a different compatible image format.
/// For formats to be compatible, the block size of source and destination must match.
explicit image(image const& Image, format_type Format);
/// Return whether the image instance is empty, no storage_linear or description have been assigned to the instance.
bool empty() const;
/// Return the image instance format.
format_type format() const;
/// Return the dimensions of an image instance: width, height and depth.
extent_type extent() const;
/// Return the memory size of an image instance storage_linear in bytes.
size_type size() const;
/// Return the number of blocks contained in an image instance storage_linear.
/// genType size must match the block size conresponding to the image format.
template <typename genType>
size_type size() const;
/// Return a pointer to the beginning of the image instance data.
void* data();
/// Return a pointer to the beginning of the image instance data.
void const* data() const;
/// Return a pointer of type genType which size must match the image format block size.
template <typename genType>
genType* data();
/// Return a pointer of type genType which size must match the image format block size.
template <typename genType>
genType const* data() const;
/// Clear the entire image storage_linear with zeros
void clear();
/// Clear the entire image storage_linear with Texel which type must match the image storage_linear format block size
/// If the type of genType doesn't match the type of the image format, no conversion is performed and the data will be reinterpreted as if is was of the image format.
template <typename genType>
void clear(genType const& Texel);
/// Load the texel located at TexelCoord coordinates.
/// It's an error to call this function if the format is compressed.
/// It's an error if TexelCoord values aren't between [0, dimensions].
template <typename genType>
genType load(extent_type const& TexelCoord);
/// Store the texel located at TexelCoord coordinates.
/// It's an error to call this function if the format is compressed.
/// It's an error if TexelCoord values aren't between [0, dimensions].
template <typename genType>
void store(extent_type const& TexelCoord, genType const& Data);
private:
/// Create an image object by sharing an existing image storage_linear from another image instance.
/// This image object is effectively an image view where the layer, the face and the level allows identifying
/// a specific subset of the image storage_linear source.
/// This image object is effectively a image view where the format can be reinterpreted
/// with a different compatible image format.
explicit image(
std::shared_ptr<storage_linear> Storage,
format_type Format,
size_type BaseLayer,
size_type BaseFace,
size_type BaseLevel);
std::shared_ptr<storage_linear> Storage;
format_type const Format;
size_type const BaseLevel;
data_type* Data;
size_type const Size;
data_type* compute_data(size_type BaseLayer, size_type BaseFace, size_type BaseLevel);
size_type compute_size(size_type Level) const;
};
}//namespace gli
#include "./core/image.inl"

View file

@ -1,48 +0,0 @@
/// @brief Include to compute the number of mipmaps levels necessary to create a mipmap complete texture.
/// @file gli/levels.hpp
#pragma once
#include "type.hpp"
namespace gli
{
/// Compute the number of mipmaps levels necessary to create a mipmap complete texture
///
/// @param Extent Extent of the texture base level mipmap
/// @tparam vecType Vector type used to express the dimensions of a texture of any kind.
/// @code
/// #include <gli/texture2d.hpp>
/// #include <gli/levels.hpp>
/// ...
/// gli::texture2d::extent_type Extent(32, 10);
/// gli::texture2d Texture(gli::levels(Extent));
/// @endcode
template <typename T, precision P, template <typename, precision> class vecType>
T levels(vecType<T, P> const& Extent);
/*
/// Compute the number of mipmaps levels necessary to create a mipmap complete texture
///
/// @param Extent Extent of the texture base level mipmap
/// @code
/// #include <gli/texture2d.hpp>
/// #include <gli/levels.hpp>
/// ...
/// gli::texture2d Texture(32);
/// @endcode
size_t levels(size_t Extent);
/// Compute the number of mipmaps levels necessary to create a mipmap complete texture
///
/// @param Extent Extent of the texture base level mipmap
/// @code
/// #include <gli/texture2d.hpp>
/// #include <gli/levels.hpp>
/// ...
/// gli::texture2d Texture(32);
/// @endcode
int levels(int Extent);
*/
}//namespace gli
#include "./core/levels.inl"

View file

@ -1,27 +0,0 @@
/// @brief Include to load DDS, KTX or KMG textures from files or memory.
/// @file gli/load.hpp
#pragma once
#include "texture.hpp"
namespace gli
{
/// Loads a texture storage_linear from file. Returns an empty storage_linear in case of failure.
///
/// @param Path Path of the file to open including filaname and filename extension
texture load(char const* Path);
/// Loads a texture storage_linear from file. Returns an empty storage_linear in case of failure.
///
/// @param Path Path of the file to open including filaname and filename extension
texture load(std::string const& Path);
/// Loads a texture storage_linear from memory. Returns an empty storage_linear in case of failure.
///
/// @param Data Data of a texture
/// @param Size Size of the data
texture load(char const* Data, std::size_t Size);
}//namespace gli
#include "./core/load.inl"

View file

@ -1,27 +0,0 @@
/// @brief Include to load DDS textures from files or memory.
/// @file gli/load_dds.hpp
#pragma once
#include "texture.hpp"
namespace gli
{
/// Loads a texture storage_linear from DDS file. Returns an empty storage_linear in case of failure.
///
/// @param Path Path of the file to open including filaname and filename extension
texture load_dds(char const* Path);
/// Loads a texture storage_linear from DDS file. Returns an empty storage_linear in case of failure.
///
/// @param Path Path of the file to open including filaname and filename extension
texture load_dds(std::string const& Path);
/// Loads a texture storage_linear from DDS memory. Returns an empty storage_linear in case of failure.
///
/// @param Data Pointer to the beginning of the texture container data to read
/// @param Size Size of texture container Data to read
texture load_dds(char const* Data, std::size_t Size);
}//namespace gli
#include "./core/load_dds.inl"

View file

@ -1,27 +0,0 @@
/// @brief Include to load KMG textures from files or memory.
/// @file gli/load_kmg.hpp
#pragma once
#include "texture.hpp"
namespace gli
{
/// Loads a texture storage_linear from KMG (Khronos Image) file. Returns an empty storage_linear in case of failure.
///
/// @param Path Path of the file to open including filaname and filename extension
texture load_kmg(char const* Path);
/// Loads a texture storage_linear from KMG (Khronos Image) file. Returns an empty storage_linear in case of failure.
///
/// @param Path Path of the file to open including filaname and filename extension
texture load_kmg(std::string const& Path);
/// Loads a texture storage_linear from KMG (Khronos Image) memory. Returns an empty storage_linear in case of failure.
///
/// @param Data Pointer to the beginning of the texture container data to read
/// @param Size Size of texture container Data to read
texture load_kmg(char const* Data, std::size_t Size);
}//namespace gli
#include "./core/load_kmg.inl"

View file

@ -1,27 +0,0 @@
/// @brief Include to load KTX textures from files or memory.
/// @file gli/load_ktx.hpp
#pragma once
#include "texture.hpp"
namespace gli
{
/// Loads a texture storage_linear from KTX file. Returns an empty storage_linear in case of failure.
///
/// @param Path Path of the file to open including filaname and filename extension
texture load_ktx(char const* Path);
/// Loads a texture storage_linear from KTX file. Returns an empty storage_linear in case of failure.
///
/// @param Path Path of the file to open including filaname and filename extension
texture load_ktx(std::string const& Path);
/// Loads a texture storage_linear from KTX memory. Returns an empty storage_linear in case of failure.
///
/// @param Data Pointer to the beginning of the texture container data to read
/// @param Size Size of texture container Data to read
texture load_ktx(char const* Data, std::size_t Size);
}//namespace gli
#include "./core/load_ktx.inl"

View file

@ -1,51 +0,0 @@
/// @brief Helper functions to create generic texture
/// @file gli/make_texture.hpp
#pragma once
namespace gli
{
// Helper function to create a 1d texture with a specific number of levels
gli::texture make_texture1d(format Format, extent1d const& Extent, size_t Levels);
// Helper function to create a 1d texture with a complete mipmap chain
gli::texture make_texture1d(format Format, extent1d const& Extent);
// Helper function to create a 1d array texture with a specific number of levels
gli::texture make_texture1d_array(format Format, extent1d const& Extent, size_t Layers, size_t Levels);
// Helper function to create a 1d array texture with a complete mipmap chain
gli::texture make_texture1d_array(format Format, extent1d const& Extent, size_t Layers);
// Helper function to create a 2d texture with a specific number of levels
gli::texture make_texture2d(format Format, extent2d const& Extent, size_t Levels);
// Helper function to create a 2d texture with a complete mipmap chain
gli::texture make_texture2d(format Format, extent2d const& Extent);
// Helper function to create a 2d array texture with a specific number of levels
gli::texture make_texture2d_array(format Format, extent2d const& Extent, size_t Layer, size_t Levels);
// Helper function to create a 2d array texture with a complete mipmap chain
gli::texture make_texture2d_array(format Format, extent2d const& Extent, size_t Layer);
// Helper function to create a 3d texture with a specific number of levels
gli::texture make_texture3d(format Format, extent3d const& Extent, size_t Levels);
// Helper function to create a 3d texture with a complete mipmap chain
gli::texture make_texture3d(format Format, extent3d const& Extent);
// Helper function to create a cube texture with a specific number of levels
gli::texture make_texture_cube(format Format, extent2d const& Extent, size_t Levels);
// Helper function to create a cube texture with a complete mipmap chain
gli::texture make_texture_cube(format Format, extent2d const& Extent);
// Helper function to create a cube array texture with a specific number of levels
gli::texture make_texture_cube_array(format Format, extent2d const& Extent, size_t Layer, size_t Levels);
// Helper function to create a cube array texture with a complete mipmap chain
gli::texture make_texture_cube_array(format Format, extent2d const& Extent, size_t Layer);
}//namespace gli
#include "./core/make_texture.inl"

View file

@ -1,95 +0,0 @@
/// @brief Include to perform reduction operations.
/// @file gli/reduce.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
{
template <typename vec_type>
struct reduce_func
{
typedef vec_type(*type)(vec_type const & A, vec_type const & B);
};
/// Compute per-texel operations using a user defined function.
///
/// @param In0 First input texture.
/// @param In1 Second input texture.
/// @param TexelFunc Pointer to a binary function for per texel operation.
/// @param ReduceFunc Pointer to a binary function to reduce texels.
template <typename vec_type>
vec_type reduce(texture1d const & In0, texture1d const & In1, typename reduce_func<vec_type>::type TexelFunc, typename reduce_func<vec_type>::type ReduceFunc);
/// Compute per-texel operations using a user defined function.
///
/// @param In0 First input texture.
/// @param In1 Second input texture.
/// @param TexelFunc Pointer to a binary function for per texel operation.
/// @param ReduceFunc Pointer to a binary function to reduce texels.
template <typename vec_type>
vec_type reduce(texture1d_array const & In0, texture1d_array const & In1, typename reduce_func<vec_type>::type TexelFunc, typename reduce_func<vec_type>::type ReduceFunc);
/// Compute per-texel operations using a user defined function.
///
/// @param In0 First input texture.
/// @param In1 Second input texture.
/// @param TexelFunc Pointer to a binary function for per texel operation.
/// @param ReduceFunc Pointer to a binary function to reduce texels.
template <typename vec_type>
vec_type reduce(texture2d const & In0, texture2d const & In1, typename reduce_func<vec_type>::type TexelFunc, typename reduce_func<vec_type>::type ReduceFunc);
/// Compute per-texel operations using a user defined function.
///
/// @param In0 First input texture.
/// @param In1 Second input texture.
/// @param TexelFunc Pointer to a binary function for per texel operation.
/// @param ReduceFunc Pointer to a binary function to reduce texels.
template <typename vec_type>
vec_type reduce(texture2d_array const & In0, texture2d_array const & In1, typename reduce_func<vec_type>::type TexelFunc, typename reduce_func<vec_type>::type ReduceFunc);
/// Compute per-texel operations using a user defined function.
///
/// @param In0 First input texture.
/// @param In1 Second input texture.
/// @param TexelFunc Pointer to a binary function for per texel operation.
/// @param ReduceFunc Pointer to a binary function to reduce texels.
template <typename vec_type>
vec_type reduce(texture3d const & In0, texture3d const & In1, typename reduce_func<vec_type>::type TexelFunc, typename reduce_func<vec_type>::type ReduceFunc);
/// Compute per-texel operations using a user defined function.
///
/// @param In0 First input texture.
/// @param In1 Second input texture.
/// @param TexelFunc Pointer to a binary function for per texel operation.
/// @param ReduceFunc Pointer to a binary function to reduce texels.
template <typename vec_type>
vec_type reduce(texture_cube const & In0, texture_cube const & In1, typename reduce_func<vec_type>::type TexelFunc, typename reduce_func<vec_type>::type ReduceFunc);
/// Compute per-texel operations using a user defined function.
///
/// @param In0 First input texture.
/// @param In1 Second input texture.
/// @param TexelFunc Pointer to a binary function for per texel operation.
/// @param ReduceFunc Pointer to a binary function to reduce texels.
template <typename vec_type>
vec_type reduce(texture_cube_array const & In0, texture_cube_array const & In1, typename reduce_func<vec_type>::type TexelFunc, typename reduce_func<vec_type>::type ReduceFunc);
/// Compute per-texel operations using a user defined function.
///
/// @param In0 First input texture.
/// @param In1 Second input texture.
/// @param TexelFunc Pointer to a binary function for per texel operation.
/// @param ReduceFunc Pointer to a binary function to reduce texels.
template <typename texture_type, typename vec_type>
vec_type reduce(texture_type const & In0, texture_type const & In1, typename reduce_func<vec_type>::type TexelFunc, typename reduce_func<vec_type>::type ReduceFunc);
}//namespace gli
#include "./core/reduce.inl"

View file

@ -1,49 +0,0 @@
/// @brief Include to use wrap modes and the sampler base class.
/// @file gli/sampler.hpp
#pragma once
#include "core/filter.hpp"
namespace gli
{
/// Texture coordinate wrapping mode
enum wrap
{
WRAP_CLAMP_TO_EDGE, WRAP_FIRST = WRAP_CLAMP_TO_EDGE,
WRAP_CLAMP_TO_BORDER,
WRAP_REPEAT,
WRAP_MIRROR_REPEAT,
WRAP_MIRROR_CLAMP_TO_EDGE,
WRAP_MIRROR_CLAMP_TO_BORDER, WRAP_LAST = WRAP_MIRROR_CLAMP_TO_BORDER
};
enum
{
WRAP_COUNT = WRAP_LAST - WRAP_FIRST + 1
};
/// Evaluate whether the texture coordinate wrapping mode relies on border color
inline bool is_border(wrap Wrap)
{
return Wrap == WRAP_CLAMP_TO_BORDER || Wrap == WRAP_MIRROR_CLAMP_TO_BORDER;
}
/// Genetic sampler class.
class sampler
{
public:
sampler(wrap Wrap, filter Mip, filter Min);
protected:
typedef float(*wrap_type)(float const & SamplerCoord);
wrap_type get_func(wrap WrapMode) const;
wrap_type Wrap;
filter Mip;
filter Min;
};
}//namespace gli
#include "./core/sampler.inl"

View file

@ -1,71 +0,0 @@
/// @brief Include to sample 1d textures.
/// @file gli/sampler1d.hpp
#pragma once
#include "sampler.hpp"
#include "texture1d.hpp"
#include "core/mipmaps_compute.hpp"
#include "core/convert_func.hpp"
namespace gli
{
/// 1d texture sampler
/// @tparam T Sampler can fetch, write and interpret any texture format but will expose and process the data through type T conversions.
/// @tparam P Precision in term of ULPs
template <typename T, precision P = defaultp>
class sampler1d : public sampler
{
private:
typedef typename detail::interpolate<T>::type interpolate_type;
public:
typedef texture1d texture_type;
typedef typename texture_type::size_type size_type;
typedef typename texture_type::extent_type extent_type;
typedef interpolate_type level_type;
typedef vec<1, interpolate_type, P> normalized_type;
typedef vec<4, T, P> texel_type;
sampler1d(texture_type const& Texture, wrap Wrap, filter Mip = FILTER_NEAREST, filter Min = FILTER_NEAREST, texel_type const& BorderColor = texel_type(0, 0, 0, 1));
/// Access the sampler texture object
texture_type const& operator()() const;
/// Fetch a texel from the sampler texture
texel_type texel_fetch(extent_type const& TexelCoord, size_type const& Level) const;
/// Write a texel in the sampler texture
void texel_write(extent_type const& TexelCoord, size_type const& Level, texel_type const& Texel);
/// Clear the sampler texture with a uniform texel
void clear(texel_type const& Texel);
/// Sample the sampler texture at a specific level
texel_type texture_lod(normalized_type const& SampleCoord, level_type Level) const;
/// Generate all the mipmaps of the sampler texture from the texture base level
void generate_mipmaps(filter Minification);
/// Generate the mipmaps of the sampler texture from the texture base level to the texture max level included
void generate_mipmaps(size_type BaseLevel, size_type MaxLevel, filter Minification);
private:
typedef typename detail::convert<texture_type, T, P>::func convert_type;
typedef typename detail::convert<texture_type, T, P>::fetchFunc fetch_type;
typedef typename detail::convert<texture_type, T, P>::writeFunc write_type;
typedef typename detail::filterBase<detail::DIMENSION_1D, texture_type, interpolate_type, normalized_type, fetch_type, texel_type>::filterFunc filter_type;
texture_type Texture;
convert_type Convert;
texel_type BorderColor;
filter_type Filter;
};
typedef sampler1d<float> fsampler1D;
typedef sampler1d<double> dsampler1D;
typedef sampler1d<unsigned int> usampler1D;
typedef sampler1d<int> isampler1D;
}//namespace gli
#include "./core/sampler1d.inl"

View file

@ -1,72 +0,0 @@
/// @brief Include to sample 1d array textures.
/// @file gli/sampler1d_array.hpp
#pragma once
#include "sampler.hpp"
#include "texture1d_array.hpp"
#include "core/mipmaps_compute.hpp"
#include "core/convert_func.hpp"
namespace gli
{
/// 1d array texture sampler
/// @tparam T Sampler can fetch, write and interpret any texture format but will expose and process the data through type T conversions.
/// @tparam P Precision in term of ULPs
template <typename T, precision P = defaultp>
class sampler1d_array : public sampler
{
private:
typedef typename detail::interpolate<T>::type interpolate_type;
public:
typedef texture1d_array texture_type;
typedef typename texture_type::size_type size_type;
typedef typename texture_type::extent_type extent_type;
typedef interpolate_type level_type;
typedef vec<1, interpolate_type, P> normalized_type;
typedef vec<4, T, P> texel_type;
sampler1d_array(texture_type const& Texture, wrap Wrap, filter Mip = FILTER_NEAREST, filter Min = FILTER_NEAREST, texel_type const& BorderColor = texel_type(0, 0, 0, 1));
/// Access the sampler texture object
texture_type const& operator()() const;
/// Fetch a texel from the sampler texture
texel_type texel_fetch(extent_type const& TexelCoord, size_type layer, size_type Level) const;
/// Write a texel in the sampler texture
void texel_write(extent_type const& TexelCoord, size_type layer, size_type Level, texel_type const & Texel);
/// Clear the sampler texture with a uniform texel
void clear(texel_type const& Texel);
/// Sample the sampler texture at a specific level
texel_type texture_lod(normalized_type const& SampleCoord, size_type layer, level_type Level) const;
/// Generate all the mipmaps of the sampler texture from the texture base level
void generate_mipmaps(filter Minification);
/// Generate the mipmaps of the sampler texture from the texture base level to the texture max level included
void generate_mipmaps(size_type BaseLayer, size_type MaxLayer, size_type BaseLevel, size_type MaxLevel, filter Minification);
private:
typedef typename detail::convert<texture_type, T, P>::func convert_type;
typedef typename detail::convert<texture_type, T, P>::fetchFunc fetch_type;
typedef typename detail::convert<texture_type, T, P>::writeFunc write_type;
typedef typename detail::filterBase<detail::DIMENSION_1D, texture_type, interpolate_type, normalized_type, fetch_type, texel_type>::filterFunc filter_type;
texture_type Texture;
convert_type Convert;
texel_type BorderColor;
filter_type Filter;
};
typedef sampler1d_array<float> fsampler1DArray;
typedef sampler1d_array<double> dsampler1DArray;
typedef sampler1d_array<unsigned int> usampler1DArray;
typedef sampler1d_array<int> isampler1DArray;
}//namespace gli
#include "./core/sampler1d_array.inl"

View file

@ -1,72 +0,0 @@
/// @brief Include to sample 2d textures.
/// @file gli/sampler2d.hpp
#pragma once
#include "sampler.hpp"
#include "texture2d.hpp"
#include "core/mipmaps_compute.hpp"
#include "core/convert_func.hpp"
namespace gli
{
/// 2d texture sampler
/// @tparam T Sampler can fetch, write and interpret any texture format but will expose and process the data through type T conversions.
/// @tparam P Precision in term of ULPs
template <typename T, precision P = defaultp>
class sampler2d : public sampler
{
private:
typedef typename detail::interpolate<T>::type interpolate_type;
public:
typedef texture2d texture_type;
typedef typename texture_type::size_type size_type;
typedef typename texture_type::extent_type extent_type;
typedef interpolate_type level_type;
typedef vec<2, interpolate_type, P> normalized_type;
typedef vec<4, T, P> texel_type;
sampler2d(texture_type const& Texture, wrap Wrap, filter Mip = FILTER_NEAREST, filter Min = FILTER_NEAREST, texel_type const& BorderColor = texel_type(0, 0, 0, 1));
/// Access the sampler texture object
texture_type const& operator()() const;
/// Fetch a texel from the sampler texture
texel_type texel_fetch(extent_type const& TexelCoord, size_type const& Level) const;
/// Write a texel in the sampler texture
void texel_write(extent_type const& TexelCoord, size_type const& Level, texel_type const& Texel);
/// Clear the sampler texture with a uniform texel
void clear(texel_type const& Texel);
/// Sample the sampler texture at a specific level
texel_type texture_lod(normalized_type const& SampleCoord, level_type Level) const;
/// Generate all the mipmaps of the sampler texture from the texture base level
void generate_mipmaps(filter Minification);
/// Generate the mipmaps of the sampler texture from the texture base level to the texture max level included
void generate_mipmaps(size_type BaseLevel, size_type MaxLevel, filter Minification);
private:
typedef typename detail::convert<texture_type, T, P>::func convert_type;
typedef typename detail::convert<texture_type, T, P>::fetchFunc fetch_type;
typedef typename detail::convert<texture_type, T, P>::writeFunc write_type;
typedef typename detail::filterBase<detail::DIMENSION_2D, texture_type, interpolate_type, normalized_type, fetch_type, texel_type>::filterFunc filter_type;
texture_type Texture;
convert_type Convert;
texel_type BorderColor;
filter_type Filter;
};
typedef sampler2d<float> fsampler2D;
typedef sampler2d<double> dsampler2D;
typedef sampler2d<unsigned int> usampler2D;
typedef sampler2d<int> isampler2D;
}//namespace gli
#include "./core/sampler2d.inl"

View file

@ -1,72 +0,0 @@
/// @brief Include to sample 2d array textures.
/// @file gli/sampler2d_array.hpp
#pragma once
#include "sampler.hpp"
#include "texture2d_array.hpp"
#include "core/mipmaps_compute.hpp"
#include "core/convert_func.hpp"
namespace gli
{
/// 2d array texture sampler
/// @tparam T Sampler can fetch, write and interpret any texture format but will expose and process the data through type T conversions.
/// @tparam P Precision in term of ULPs
template <typename T, precision P = defaultp>
class sampler2d_array : public sampler
{
private:
typedef typename detail::interpolate<T>::type interpolate_type;
public:
typedef texture2d_array texture_type;
typedef typename texture_type::size_type size_type;
typedef typename texture_type::extent_type extent_type;
typedef interpolate_type level_type;
typedef vec<2, interpolate_type, P> normalized_type;
typedef vec<4, T, P> texel_type;
sampler2d_array(texture_type const& Texture, wrap Wrap, filter Mip = FILTER_NEAREST, filter Min = FILTER_NEAREST, texel_type const& BorderColor = texel_type(0, 0, 0, 1));
/// Access the sampler texture object
texture_type const& operator()() const;
/// Fetch a texel from the sampler texture
texel_type texel_fetch(extent_type const& TexelCoord, size_type layer, size_type Level) const;
/// Write a texel in the sampler texture
void texel_write(extent_type const& TexelCoord, size_type layer, size_type Level, texel_type const& Texel);
/// Clear the sampler texture with a uniform texel
void clear(texel_type const& Texel);
/// Sample the sampler texture at a specific level
texel_type texture_lod(normalized_type const& SampleCoord, size_type layer, level_type Level) const;
/// Generate all the mipmaps of the sampler texture from the texture base level
void generate_mipmaps(filter Minification);
/// Generate the mipmaps of the sampler texture from the texture base level to the texture max level included
void generate_mipmaps(size_type BaseLayer, size_type MaxLayer, size_type BaseLevel, size_type MaxLevel, filter Minification);
private:
typedef typename detail::convert<texture_type, T, P>::func convert_type;
typedef typename detail::convert<texture_type, T, P>::fetchFunc fetch_type;
typedef typename detail::convert<texture_type, T, P>::writeFunc write_type;
typedef typename detail::filterBase<detail::DIMENSION_2D, texture_type, interpolate_type, normalized_type, fetch_type, texel_type>::filterFunc filter_type;
texture_type Texture;
convert_type Convert;
texel_type BorderColor;
filter_type Filter;
};
typedef sampler2d_array<float> fsampler2DArray;
typedef sampler2d_array<double> dsampler2DArray;
typedef sampler2d_array<unsigned int> usampler2DArray;
typedef sampler2d_array<int> isampler2DArray;
}//namespace gli
#include "./core/sampler2d_array.inl"

View file

@ -1,71 +0,0 @@
/// @brief Include to sample 3d textures.
/// @file gli/sampler3d.hpp
#pragma once
#include "sampler.hpp"
#include "texture3d.hpp"
#include "core/mipmaps_compute.hpp"
#include "core/convert_func.hpp"
namespace gli
{
/// 3d texture sampler
/// @tparam T Sampler can fetch, write and interpret any texture format but will expose and process the data through type T conversions.
/// @tparam P Precision in term of ULPs
template <typename T, precision P = defaultp>
class sampler3d : public sampler
{
private:
typedef typename detail::interpolate<T>::type interpolate_type;
public:
typedef texture3d texture_type;
typedef typename texture_type::size_type size_type;
typedef typename texture_type::extent_type extent_type;
typedef interpolate_type level_type;
typedef vec<3, interpolate_type, P> normalized_type;
typedef vec<4, T, P> texel_type;
sampler3d(texture_type const& Texture, wrap Wrap, filter Mip = FILTER_NEAREST, filter Min = FILTER_NEAREST, texel_type const& BorderColor = texel_type(0, 0, 0, 1));
/// Access the sampler texture object
texture_type const& operator()() const;
/// Fetch a texel from the sampler texture
texel_type texel_fetch(extent_type const& TexelCoord, size_type const& Level) const;
/// Write a texel in the sampler texture
void texel_write(extent_type const& TexelCoord, size_type const & Level, texel_type const& Texel);
/// Clear the sampler texture with a uniform texel
void clear(texel_type const& Texel);
/// Sample the sampler texture at a specific level
texel_type texture_lod(normalized_type const& SampleCoord, level_type Level) const;
/// Generate all the mipmaps of the sampler texture from the texture base level
void generate_mipmaps(filter Minification);
/// Generate the mipmaps of the sampler texture from the texture base level to the texture max level included
void generate_mipmaps(size_type BaseLevel, size_type MaxLevel, filter Minification);
private:
typedef typename detail::convert<texture_type, T, P>::func convert_type;
typedef typename detail::convert<texture_type, T, P>::fetchFunc fetch_type;
typedef typename detail::convert<texture_type, T, P>::writeFunc write_type;
typedef typename detail::filterBase<detail::DIMENSION_3D, texture_type, interpolate_type, normalized_type, fetch_type, texel_type>::filterFunc filter_type;
texture_type Texture;
convert_type Convert;
texel_type BorderColor;
filter_type Filter;
};
typedef sampler3d<float> fsampler3D;
typedef sampler3d<double> dsampler3D;
typedef sampler3d<unsigned int> usampler3D;
typedef sampler3d<int> isampler3D;
}//namespace gli
#include "./core/sampler3d.inl"

View file

@ -1,72 +0,0 @@
/// @brief Include to sample cube map textures.
/// @file gli/sampler_cube.hpp
#pragma once
#include "sampler.hpp"
#include "texture_cube.hpp"
#include "core/mipmaps_compute.hpp"
#include "core/convert_func.hpp"
namespace gli
{
/// Cube map texture sampler
/// @tparam T Sampler can fetch, write and interpret any texture format but will expose and process the data through type T conversions.
/// @tparam P Precision in term of ULPs
template <typename T, precision P = defaultp>
class sampler_cube : public sampler
{
private:
typedef typename detail::interpolate<T>::type interpolate_type;
public:
typedef texture_cube texture_type;
typedef typename texture_type::size_type size_type;
typedef typename texture_type::extent_type extent_type;
typedef interpolate_type level_type;
typedef vec<2, interpolate_type, P> normalized_type;
typedef vec<4, T, P> texel_type;
sampler_cube(texture_type const& Texture, wrap Wrap, filter Mip = FILTER_NEAREST, filter Min = FILTER_NEAREST, texel_type const& BorderColor = texel_type(0, 0, 0, 1));
/// Access the sampler texture object
texture_type const& operator()() const;
/// Fetch a texel from the sampler texture
texel_type texel_fetch(extent_type const& TexelCoord, size_type Face, size_type Level) const;
/// Write a texel in the sampler texture
void texel_write(extent_type const& TexelCoord, size_type Face, size_type Level, texel_type const& Texel);
/// Clear the sampler texture with a uniform texel
void clear(texel_type const& Texel);
/// Sample the sampler texture at a specific level
texel_type texture_lod(normalized_type const& SampleCoord, size_type Face, level_type Level) const;
/// Generate all the mipmaps of the sampler texture from the texture base level
void generate_mipmaps(filter Minification);
/// Generate the mipmaps of the sampler texture from the texture base level to the texture max level included
void generate_mipmaps(size_type BaseFace, size_type MaxFace, size_type BaseLevel, size_type MaxLevel, filter Minification);
private:
typedef typename detail::convert<texture_type, T, P>::func convert_type;
typedef typename detail::convert<texture_type, T, P>::fetchFunc fetch_type;
typedef typename detail::convert<texture_type, T, P>::writeFunc write_type;
typedef typename detail::filterBase<detail::DIMENSION_2D, texture_type, interpolate_type, normalized_type, fetch_type, texel_type>::filterFunc filter_type;
texture_type Texture;
convert_type Convert;
texel_type BorderColor;
filter_type Filter;
};
typedef sampler_cube<float> fsamplerCube;
typedef sampler_cube<double> dsamplerCube;
typedef sampler_cube<unsigned int> usamplerCube;
typedef sampler_cube<int> isamplerCube;
}//namespace gli
#include "./core/sampler_cube.inl"

View file

@ -1,72 +0,0 @@
/// @brief Include to sample cube map array textures.
/// @file gli/sampler_cube_array.hpp
#pragma once
#include "sampler.hpp"
#include "texture_cube_array.hpp"
#include "core/mipmaps_compute.hpp"
#include "core/convert_func.hpp"
namespace gli
{
/// Cube map array texture sampler
/// @tparam T Sampler can fetch, write and interpret any texture format but will expose and process the data through type T conversions.
/// @tparam P Precision in term of ULPs
template <typename T, precision P = defaultp>
class sampler_cube_array : public sampler
{
private:
typedef typename detail::interpolate<T>::type interpolate_type;
public:
typedef texture_cube_array texture_type;
typedef typename texture_type::size_type size_type;
typedef typename texture_type::extent_type extent_type;
typedef interpolate_type level_type;
typedef vec<2, interpolate_type, P> normalized_type;
typedef vec<4, T, P> texel_type;
sampler_cube_array(texture_type const& Texture, wrap Wrap, filter Mip = FILTER_NEAREST, filter Min = FILTER_NEAREST, texel_type const& BorderColor = texel_type(0, 0, 0, 1));
/// Access the sampler texture object
texture_type const& operator()() const;
/// Fetch a texel from the sampler texture
texel_type texel_fetch(extent_type const& TexelCoord, size_type layer, size_type Face, size_type Level) const;
/// Write a texel in the sampler texture
void texel_write(extent_type const& TexelCoord, size_type layer, size_type Face, size_type Level, texel_type const& Texel);
/// Clear the sampler texture with a uniform texel
void clear(texel_type const& Texel);
/// Sample the sampler texture at a specific level
texel_type texture_lod(normalized_type const& SampleCoord, size_type layer, size_type Face, level_type Level) const;
/// Generate all the mipmaps of the sampler texture from the texture base level
void generate_mipmaps(filter Minification);
/// Generate the mipmaps of the sampler texture from the texture base level to the texture max level included
void generate_mipmaps(size_type BaseLayer, size_type MaxLayer, size_type BaseFace, size_type MaxFace, size_type BaseLevel, size_type MaxLevel, filter Minification);
private:
typedef typename detail::convert<texture_type, T, P>::func convert_type;
typedef typename detail::convert<texture_type, T, P>::fetchFunc fetch_type;
typedef typename detail::convert<texture_type, T, P>::writeFunc write_type;
typedef typename detail::filterBase<detail::DIMENSION_2D, texture_type, interpolate_type, normalized_type, fetch_type, texel_type>::filterFunc filter_type;
texture_type Texture;
convert_type Convert;
texel_type BorderColor;
filter_type Filter;
};
typedef sampler_cube_array<float> fsamplerCubeArray;
typedef sampler_cube_array<double> dsamplerCubeArray;
typedef sampler_cube_array<unsigned int> usamplerCubeArray;
typedef sampler_cube_array<int> isamplerCubeArray;
}//namespace gli
#include "./core/sampler_cube_array.inl"

View file

@ -1,28 +0,0 @@
/// @brief Include to save DDS, KTX or KMG textures to files or memory.
/// @file gli/save.hpp
#pragma once
#include "save_dds.hpp"
#include "save_ktx.hpp"
namespace gli
{
/// Save a texture storage_linear to file.
///
/// @param Texture Source texture to save
/// @param Path Path for where to save the file. It must include the filaname and filename extension.
/// The function use the filename extension included in the path to figure out the file container to use.
/// @return Returns false if the function fails to save the file.
bool save(texture const & Texture, char const * Path);
/// Save a texture storage_linear to file.
///
/// @param Texture Source texture to save
/// @param Path Path for where to save the file. It must include the filaname and filename extension.
/// The function use the filename extension included in the path to figure out the file container to use.
/// @return Returns false if the function fails to save the file.
bool save(texture const & Texture, std::string const & Path);
}//namespace gli
#include "./core/save.inl"

View file

@ -1,34 +0,0 @@
/// @brief Include to save DDS textures to files or memory.
/// @file gli/save_dds.hpp
#pragma once
#include "texture.hpp"
namespace gli
{
/// Save a texture storage_linear to a DDS file.
///
/// @param Texture Source texture to save
/// @param Path Path for where to save the file. It must include the filaname and filename extension.
/// This function ignores the filename extension in the path and save to DDS anyway but keep the requested filename extension.
/// @return Returns false if the function fails to save the file.
bool save_dds(texture const & Texture, char const* Path);
/// Save a texture storage_linear to a DDS file.
///
/// @param Texture Source texture to save
/// @param Path Path for where to save the file. It must include the filaname and filename extension.
/// This function ignores the filename extension in the path and save to DDS anyway but keep the requested filename extension.
/// @return Returns false if the function fails to save the file.
bool save_dds(texture const & Texture, std::string const & Path);
/// Save a texture storage_linear to a DDS file.
///
/// @param Texture Source texture to save
/// @param Memory Storage for the DDS container. The function resizes the containers to fit the necessary storage_linear.
/// @return Returns false if the function fails to save the file.
bool save_dds(texture const & Texture, std::vector<char> & Memory);
}//namespace gli
#include "./core/save_dds.inl"

View file

@ -1,34 +0,0 @@
/// @brief Include to save KMG textures to files or memory.
/// @file gli/save_kmg.hpp
#pragma once
#include "texture.hpp"
namespace gli
{
/// Save a texture storage_linear to a KMG (Khronos Image) file.
///
/// @param Texture Source texture to save
/// @param Path Path for where to save the file. It must include the filaname and filename extension.
/// This function ignores the filename extension in the path and save to KMG anyway but keep the requested filename extension.
/// @return Returns false if the function fails to save the file.
bool save_kmg(texture const & Texture, char const * Path);
/// Save a texture storage_linear to a KMG (Khronos Image) file.
///
/// @param Texture Source texture to save
/// @param Path Path for where to save the file. It must include the filaname and filename extension.
/// This function ignores the filename extension in the path and save to KMG anyway but keep the requested filename extension.
/// @return Returns false if the function fails to save the file.
bool save_kmg(texture const & Texture, std::string const & Path);
/// Save a texture storage_linear to a KMG (Khronos Image) file.
///
/// @param Texture Source texture to save
/// @param Memory Storage for the KMG container. The function resizes the containers to fit the necessary storage_linear.
/// @return Returns false if the function fails to save the file.
bool save_kmg(texture const & Texture, std::vector<char> & Memory);
}//namespace gli
#include "./core/save_kmg.inl"

View file

@ -1,34 +0,0 @@
/// @brief Include to save KTX textures to files or memory.
/// @file gli/save_ktx.hpp
#pragma once
#include "texture.hpp"
namespace gli
{
/// Save a texture storage_linear to a KTX file.
///
/// @param Texture Source texture to save
/// @param Path Path for where to save the file. It must include the filaname and filename extension.
/// This function ignores the filename extension in the path and save to KTX anyway but keep the requested filename extension.
/// @return Returns false if the function fails to save the file.
bool save_ktx(texture const & Texture, char const * Path);
/// Save a texture storage_linear to a KTX file.
///
/// @param Texture Source texture to save
/// @param Path Path for where to save the file. It must include the filaname and filename extension.
/// This function ignores the filename extension in the path and save to KTX anyway but keep the requested filename extension.
/// @return Returns false if the function fails to save the file.
bool save_ktx(texture const & Texture, std::string const & Path);
/// Save a texture storage_linear to a KTX file.
///
/// @param Texture Source texture to save
/// @param Memory Storage for the KTX container. The function resizes the containers to fit the necessary storage_linear.
/// @return Returns false if the function fails to save the file.
bool save_ktx(texture const & Texture, std::vector<char> & Memory);
}//namespace gli
#include "./core/save_ktx.inl"

View file

@ -1,51 +0,0 @@
/// @brief Include to use the target enum and query properties of targets.
/// @file gli/target.hpp
#pragma once
namespace gli
{
/// Texture target: type/shape of the texture storage_linear
enum target
{
TARGET_1D = 0, TARGET_FIRST = TARGET_1D,
TARGET_1D_ARRAY,
TARGET_2D,
TARGET_2D_ARRAY,
TARGET_3D,
TARGET_RECT,
TARGET_RECT_ARRAY,
TARGET_CUBE,
TARGET_CUBE_ARRAY, TARGET_LAST = TARGET_CUBE_ARRAY
};
enum
{
TARGET_COUNT = TARGET_LAST - TARGET_FIRST + 1,
TARGET_INVALID = -1
};
/// Check whether a target is a 1D target
inline bool is_target_1d(target Target)
{
return Target == TARGET_1D || Target == TARGET_1D_ARRAY;
}
/// Check whether a target is an array target
inline bool is_target_array(target Target)
{
return Target == TARGET_1D_ARRAY || Target == TARGET_2D_ARRAY || Target == TARGET_CUBE_ARRAY;
}
/// Check whether a target is a cube map target
inline bool is_target_cube(target Target)
{
return Target == TARGET_CUBE || Target == TARGET_CUBE_ARRAY;
}
/// Check whether a target is a rectangle target
inline bool is_target_rect(target Target)
{
return Target == TARGET_RECT || Target == TARGET_RECT_ARRAY;
}
}//namespace gli

View file

@ -1,297 +0,0 @@
/// @brief Include to use generic textures which can represent any texture target but they don't have target specific built-in caches making accesses slower.
/// @file gli/texture.hpp
#pragma once
#include "image.hpp"
#include "target.hpp"
#include "levels.hpp"
#include <array>
namespace gli
{
/// Genetic texture class. It can support any target.
class texture
{
public:
typedef size_t size_type;
typedef gli::target target_type;
typedef gli::format format_type;
typedef gli::swizzles swizzles_type;
typedef storage_linear storage_type;
typedef storage_type::data_type data_type;
typedef storage_type::extent_type extent_type;
/// Create an empty texture instance
texture();
/// Create a texture object and allocate a texture storage for it
/// @param Target Type/Shape of the texture storage_linear
/// @param Format Texel format
/// @param Extent Size of the texture: width, height and depth.
/// @param Layers Number of one-dimensional or two-dimensional images of identical size and format
/// @param Faces 6 for cube map textures otherwise 1.
/// @param Levels Number of images in the texture mipmap chain.
/// @param Swizzles A mechanism to swizzle the components of a texture before they are applied according to the texture environment.
texture(
target_type Target,
format_type Format,
extent_type const& Extent,
size_type Layers,
size_type Faces,
size_type Levels,
swizzles_type const& Swizzles = swizzles_type(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA));
/// Create a texture object by sharing an existing texture storage_type from another texture instance.
/// This texture object is effectively a texture view where the layer, the face and the level allows identifying
/// a specific subset of the texture storage_linear source.
/// This texture object is effectively a texture view where the target and format can be reinterpreted
/// with a different compatible texture target and texture format.
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 = swizzles_type(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA));
/// Create a texture object by sharing an existing texture storage_type from another texture instance.
/// This texture object is effectively a texture view where the target and format can be reinterpreted
/// with a different compatible texture target and texture format.
texture(
texture const& Texture,
target_type Target,
format_type Format,
swizzles_type const& Swizzles = swizzles_type(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA));
virtual ~texture(){}
/// Return whether the texture instance is empty, no storage_type or description have been assigned to the instance.
bool empty() const;
/// Return the target of a texture instance.
target_type target() const{return this->Target;}
/// Return the texture instance format
format_type format() const;
swizzles_type swizzles() const;
/// Return the base layer of the texture instance, effectively a memory offset in the actual texture storage_type to identify where to start reading the layers.
size_type base_layer() const;
/// Return the max layer of the texture instance, effectively a memory offset to the beginning of the last layer in the actual texture storage_type that the texture instance can access.
size_type max_layer() const;
/// Return max_layer() - base_layer() + 1
size_type layers() const;
/// Return the base face of the texture instance, effectively a memory offset in the actual texture storage_type to identify where to start reading the faces.
size_type base_face() const;
/// Return the max face of the texture instance, effectively a memory offset to the beginning of the last face in the actual texture storage_type that the texture instance can access.
size_type max_face() const;
/// Return max_face() - base_face() + 1
size_type faces() const;
/// Return the base level of the texture instance, effectively a memory offset in the actual texture storage_type to identify where to start reading the levels.
size_type base_level() const;
/// Return the max level of the texture instance, effectively a memory offset to the beginning of the last level in the actual texture storage_type that the texture instance can access.
size_type max_level() const;
/// Return max_level() - base_level() + 1.
size_type levels() const;
/// Return the size of a texture instance: width, height and depth.
extent_type extent(size_type Level = 0) const;
/// Return the memory size of a texture instance storage_type in bytes.
size_type size() const;
/// Return the number of blocks contained in a texture instance storage_type.
/// genType size must match the block size conresponding to the texture format.
template <typename genType>
size_type size() const;
/// Return the memory size of a specific level identified by Level.
size_type size(size_type Level) const;
/// Return the memory size of a specific level identified by Level.
/// genType size must match the block size conresponding to the texture format.
template <typename gen_type>
size_type size(size_type Level) const;
/// Return a pointer to the beginning of the texture instance data.
void* data();
/// Return a pointer of type genType which size must match the texture format block size
template <typename gen_type>
gen_type* data();
/// Return a pointer to the beginning of the texture instance data.
void const* data() const;
/// Return a pointer of type genType which size must match the texture format block size
template <typename gen_type>
gen_type const* data() const;
/// Return a pointer to the beginning of the texture instance data.
void* data(size_type Layer, size_type Face, size_type Level);
/// Return a pointer to the beginning of the texture instance data.
void const* const data(size_type Layer, size_type Face, size_type Level) const;
/// Return a pointer of type genType which size must match the texture format block size
template <typename gen_type>
gen_type* data(size_type Layer, size_type Face, size_type Level);
/// Return a pointer of type genType which size must match the texture format block size
template <typename gen_type>
gen_type const* const data(size_type Layer, size_type Face, size_type Level) const;
/// Clear the entire texture storage_linear with zeros
void clear();
/// Clear the entire texture storage_linear with Texel which type must match the texture storage_linear format block size
/// If the type of gen_type doesn't match the type of the texture format, no conversion is performed and the data will be reinterpreted as if is was of the texture format.
template <typename gen_type>
void clear(gen_type const& Texel);
/// Clear a specific image of a texture.
template <typename gen_type>
void clear(size_type Layer, size_type Face, size_type Level, gen_type const& BlockData);
/// Clear a subset of a specific image of a texture.
template <typename gen_type>
void clear(size_type Layer, size_type Face, size_type Level, extent_type const& TexelOffset, extent_type const& TexelExtent, gen_type const& BlockData);
/// Copy a specific image of a texture
void copy(
texture const& TextureSrc,
size_t LayerSrc, size_t FaceSrc, size_t LevelSrc,
size_t LayerDst, size_t FaceDst, size_t LevelDst);
/// Copy a subset of a specific image of a texture
void copy(
texture const& TextureSrc,
size_t LayerSrc, size_t FaceSrc, size_t LevelSrc, extent_type const& OffsetSrc,
size_t LayerDst, size_t FaceDst, size_t LevelDst, extent_type const& OffsetDst,
extent_type const& Extent);
/// Reorder the component in texture memory.
template <typename gen_type>
void swizzle(gli::swizzles const& Swizzles);
/// Fetch a texel from a texture. The texture format must be uncompressed.
template <typename gen_type>
gen_type load(extent_type const & TexelCoord, size_type Layer, size_type Face, size_type Level) const;
/// Write a texel to a texture. The texture format must be uncompressed.
template <typename gen_type>
void store(extent_type const& TexelCoord, size_type Layer, size_type Face, size_type Level, gen_type const& Texel);
protected:
std::shared_ptr<storage_type> Storage;
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 Swizzles;
// Pre compute at texture instance creation some information for faster access to texels
struct cache
{
public:
enum ctor
{
DEFAULT
};
explicit cache(ctor)
{}
cache
(
storage_type& Storage,
format_type Format,
size_type BaseLayer, size_type Layers,
size_type BaseFace, size_type MaxFace,
size_type BaseLevel, size_type MaxLevel
)
: Faces(MaxFace - BaseFace + 1)
, Levels(MaxLevel - BaseLevel + 1)
{
GLI_ASSERT(static_cast<size_t>(gli::levels(Storage.extent(0))) < this->ImageMemorySize.size());
this->BaseAddresses.resize(Layers * this->Faces * this->Levels);
for(size_type Layer = 0; Layer < Layers; ++Layer)
for(size_type Face = 0; Face < this->Faces; ++Face)
for(size_type Level = 0; Level < this->Levels; ++Level)
{
size_type const Index = index_cache(Layer, Face, Level);
this->BaseAddresses[Index] = Storage.data() + Storage.base_offset(
BaseLayer + Layer, BaseFace + Face, BaseLevel + Level);
}
for(size_type Level = 0; Level < this->Levels; ++Level)
{
extent_type const& SrcExtent = Storage.extent(BaseLevel + Level);
extent_type const& DstExtent = SrcExtent * block_extent(Format) / Storage.block_extent();
this->ImageExtent[Level] = glm::max(DstExtent, extent_type(1));
this->ImageMemorySize[Level] = Storage.level_size(BaseLevel + Level);
}
this->GlobalMemorySize = Storage.layer_size(BaseFace, MaxFace, BaseLevel, MaxLevel) * Layers;
}
// Base addresses of each images of a texture.
data_type* get_base_address(size_type Layer, size_type Face, size_type Level) const
{
return this->BaseAddresses[index_cache(Layer, Face, Level)];
}
// In texels
extent_type get_extent(size_type Level) const
{
return this->ImageExtent[Level];
};
// In bytes
size_type get_memory_size(size_type Level) const
{
return this->ImageMemorySize[Level];
};
// In bytes
size_type get_memory_size() const
{
return this->GlobalMemorySize;
};
private:
size_type index_cache(size_type Layer, size_type Face, size_type Level) const
{
return ((Layer * this->Faces) + Face) * this->Levels + Level;
}
size_type Faces;
size_type Levels;
std::vector<data_type*> BaseAddresses;
std::array<extent_type, 16> ImageExtent;
std::array<size_type, 16> ImageMemorySize;
size_type GlobalMemorySize;
} Cache;
};
}//namespace gli
#include "./core/texture.inl"

View file

@ -1,67 +0,0 @@
/// @brief Include to use 1d textures.
/// @file gli/texture1d.hpp
#pragma once
#include "texture.hpp"
#include "image.hpp"
namespace gli
{
/// 1d texture
class texture1d : public texture
{
public:
typedef extent1d extent_type;
/// Create an empty texture 1D
texture1d();
/// Create a texture1d and allocate a new storage_linear
texture1d(
format_type Format,
extent_type const& Extent,
size_type Levels,
swizzles_type const& Swizzles = swizzles_type(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA));
/// Create a texture1d and allocate a new storage_linear with a complete mipmap chain
texture1d(
format_type Format,
extent_type const& Extent,
swizzles_type const& Swizzles = swizzles_type(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA));
/// Create a texture1d view with an existing storage_linear
explicit texture1d(
texture const& Texture);
/// Create a texture1d view with an existing storage_linear
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 = swizzles_type(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA));
/// Create a texture1d view, reference a subset of an existing texture1d instance
texture1d(
texture1d const& Texture,
size_type BaseLevel, size_type MaxLevel);
/// Create a view of the image identified by Level in the mipmap chain of the texture
image operator[](size_type Level) const;
/// Return the width of a texture instance
extent_type extent(size_type Level = 0) const;
/// Fetch a texel from a texture. The texture format must be uncompressed.
template <typename gen_type>
gen_type load(extent_type const& TexelCoord, size_type Level) const;
/// Write a texel to a texture. The texture format must be uncompressed.
template <typename gen_type>
void store(extent_type const& TexelCoord, size_type Level, gen_type const& Texel);
};
}//namespace gli
#include "./core/texture1d.inl"

View file

@ -1,70 +0,0 @@
/// @brief Include to use 1d array textures.
/// @file gli/texture1d_array.hpp
#pragma once
#include "texture1d.hpp"
namespace gli
{
/// 1d array texture
class texture1d_array : public texture
{
public:
typedef extent1d extent_type;
public:
/// Create an empty texture 1D array
texture1d_array();
/// Create a texture1d_array and allocate a new storage_linear
texture1d_array(
format_type Format,
extent_type const& Extent,
size_type Layers,
size_type Levels,
swizzles_type const& Swizzles = swizzles_type(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA));
/// Create a texture1d_array and allocate a new storage_linear with a complete mipmap chain
texture1d_array(
format_type Format,
extent_type const& Extent,
size_type Layers,
swizzles_type const& Swizzles = swizzles_type(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA));
/// Create a texture1d_array view with an existing storage_linear
explicit texture1d_array(
texture const& Texture);
/// Create a texture1d_array view with an existing storage_linear
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 = swizzles_type(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA));
/// Create a texture view, reference a subset of an exiting storage_linear
texture1d_array(
texture1d_array const& Texture,
size_type BaseLayer, size_type MaxLayer,
size_type BaseLevel, size_type MaxLevel);
/// Create a view of the texture identified by Layer in the texture array
texture1d operator[](size_type Layer) const;
/// Return the width of a texture instance
extent_type extent(size_type Level = 0) const;
/// Fetch a texel from a texture. The texture format must be uncompressed.
template <typename gen_type>
gen_type load(extent_type const& TexelCoord, size_type Layer, size_type Level) const;
/// Write a texel to a texture. The texture format must be uncompressed.
template <typename gen_type>
void store(extent_type const& TexelCoord, size_type Layer, size_type Level, gen_type const& Texel);
};
}//namespace gli
#include "./core/texture1d_array.inl"

View file

@ -1,67 +0,0 @@
/// @brief Include to use 2d textures.
/// @file gli/texture2d.hpp
#pragma once
#include "texture.hpp"
#include "image.hpp"
namespace gli
{
/// 2d texture
class texture2d : public texture
{
public:
typedef extent2d extent_type;
/// Create an empty texture 2D.
texture2d();
/// Create a texture2d and allocate a new storage_linear.
texture2d(
format_type Format,
extent_type const& Extent,
size_type Levels,
swizzles_type const& Swizzles = swizzles_type(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA));
/// Create a texture2d and allocate a new storage_linear with a complete mipmap chain.
texture2d(
format_type Format,
extent_type const& Extent,
swizzles_type const& Swizzles = swizzles_type(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA));
/// Create a texture2d view with an existing storage_linear.
explicit texture2d(
texture const& Texture);
/// Create a texture2d view with an existing storage_linear.
texture2d(
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 = swizzles_type(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA));
/// Create a texture2d view, reference a subset of an existing texture2d instance.
texture2d(
texture2d const& Texture,
size_type BaseLevel, size_type MaxLevel);
/// Create a view of the image identified by Level in the mipmap chain of the texture.
image operator[](size_type Level) const;
/// Return the dimensions of a texture instance: width and height.
extent_type extent(size_type Level = 0) const;
/// Fetch a texel from a texture. The texture format must be uncompressed.
template <typename gen_type>
gen_type load(extent_type const& TexelCoord, size_type Level) const;
/// Write a texel to a texture. The texture format must be uncompressed.
template <typename gen_type>
void store(extent_type const& TexelCoord, size_type Level, gen_type const& Texel);
};
}//namespace gli
#include "./core/texture2d.inl"

View file

@ -1,70 +0,0 @@
/// @brief Include to use 2d array textures.
/// @file gli/texture2d_array.hpp
#pragma once
#include "texture2d.hpp"
namespace gli
{
/// 2d array texture
class texture2d_array : public texture
{
public:
typedef extent2d extent_type;
public:
/// Create an empty texture 2D array
texture2d_array();
/// Create a texture2d_array and allocate a new storage_linear
texture2d_array(
format_type Format,
extent_type const& Extent,
size_type Layers,
size_type Levels,
swizzles_type const& Swizzles = swizzles_type(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA));
/// Create a texture2d_array and allocate a new storage_linear with a complete mipmap chain
texture2d_array(
format_type Format,
extent_type const& Extent,
size_type Layers,
swizzles_type const& Swizzles = swizzles_type(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA));
/// Create a texture2d_array view with an existing storage_linear
explicit texture2d_array(
texture const& Texture);
/// Create a texture2d_array view with an existing storage_linear
texture2d_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 = swizzles_type(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA));
/// Create a texture view, reference a subset of an exiting texture2d_array instance
texture2d_array(
texture2d_array const& Texture,
size_type BaseLayer, size_type MaxLayer,
size_type BaseLevel, size_type MaxLevel);
/// Create a view of the texture identified by Layer in the texture array
texture2d operator[](size_type Layer) const;
/// Return the dimensions of a texture instance: width and height
extent_type extent(size_type Level = 0) const;
/// Fetch a texel from a texture. The texture format must be uncompressed.
template <typename gen_type>
gen_type load(extent_type const& TexelCoord, size_type Layer, size_type Level) const;
/// Write a texel to a texture. The texture format must be uncompressed.
template <typename gen_type>
void store(extent_type const& TexelCoord, size_type Layer, size_type Level, gen_type const& Texel);
};
}//namespace gli
#include "./core/texture2d_array.inl"

View file

@ -1,68 +0,0 @@
/// @brief Include to use 3d textures.
/// @file gli/texture3d.hpp
#pragma once
#include "texture.hpp"
#include "image.hpp"
namespace gli
{
/// 3d texture
class texture3d : public texture
{
public:
typedef extent3d extent_type;
public:
/// Create an empty texture 3D
texture3d();
/// Create a texture3d and allocate a new storage_linear
texture3d(
format_type Format,
extent_type const& Extent,
size_type Levels,
swizzles_type const& Swizzles = swizzles_type(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA));
/// Create a texture3d and allocate a new storage_linear with a complete mipmap chain
texture3d(
format_type Format,
extent_type const& Extent,
swizzles_type const& Swizzles = swizzles_type(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA));
/// Create a texture3d view with an existing storage_linear
explicit texture3d(
texture const & Texture);
/// Create a texture3d view with an existing storage_linear
texture3d(
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 = swizzles_type(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA));
/// Create a texture3d view, reference a subset of an existing texture3d instance
texture3d(
texture3d const & Texture,
size_type BaseLevel, size_type MaxLevel);
/// Create a view of the image identified by Level in the mipmap chain of the texture
image operator[](size_type Level) const;
/// Return the dimensions of a texture instance: width, height and depth
extent_type extent(size_type Level = 0) const;
/// Fetch a texel from a texture. The texture format must be uncompressed.
template <typename gen_type>
gen_type load(extent_type const& TexelCoord, size_type Level) const;
/// Write a texel to a texture. The texture format must be uncompressed.
template <typename gen_type>
void store(extent_type const& TexelCoord, size_type Level, gen_type const& Texel);
};
}//namespace gli
#include "./core/texture3d.inl"

View file

@ -1,68 +0,0 @@
/// @brief Include to use cube map textures.
/// @file gli/texture_cube.hpp
#pragma once
#include "texture2d.hpp"
namespace gli
{
/// Cube map texture
class texture_cube : public texture
{
public:
typedef extent2d extent_type;
public:
/// Create an empty texture cube
texture_cube();
/// Create a texture_cube and allocate a new storage_linear
texture_cube(
format_type Format,
extent_type const & Extent,
size_type Levels,
swizzles_type const& Swizzles = swizzles_type(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA));
/// Create a texture_cube and allocate a new storage_linear with a complete mipmap chain
texture_cube(
format_type Format,
extent_type const & Extent,
swizzles_type const& Swizzles = swizzles_type(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA));
/// Create a texture_cube view with an existing storage_linear
explicit texture_cube(
texture const& Texture);
/// Create a texture_cube view with an existing storage_linear
texture_cube(
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 = swizzles_type(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA));
/// Create a texture_cube view, reference a subset of an existing texture_cube instance
texture_cube(
texture_cube const& Texture,
size_type BaseFace, size_type MaxFace,
size_type BaseLevel, size_type MaxLevel);
/// Create a view of the texture identified by Face in the texture cube
texture2d operator[](size_type Face) const;
/// Return the dimensions of a texture instance: width and height where both should be equal.
extent_type extent(size_type Level = 0) const;
/// Fetch a texel from a texture. The texture format must be uncompressed.
template <typename gen_type>
gen_type load(extent_type const& TexelCoord, size_type Face, size_type Level) const;
/// Write a texel to a texture. The texture format must be uncompressed.
template <typename gen_type>
void store(extent_type const& TexelCoord, size_type Face, size_type Level, gen_type const& Texel);
};
}//namespace gli
#include "./core/texture_cube.inl"

View file

@ -1,72 +0,0 @@
/// @brief Include to use cube map array textures.
/// @file gli/texture_cube_array.hpp
#pragma once
#include "texture_cube.hpp"
namespace gli
{
/// Cube map array texture
class texture_cube_array : public texture
{
public:
typedef extent2d extent_type;
public:
/// Create an empty texture cube array
texture_cube_array();
/// Create a texture_cube_array and allocate a new storage_linear
texture_cube_array(
format_type Format,
extent_type const& Extent,
size_type Layers,
size_type Levels,
swizzles_type const& Swizzles = swizzles_type(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA));
/// Create a texture_cube_array and allocate a new storage_linear with a complete mipmap chain
texture_cube_array(
format_type Format,
extent_type const& Extent,
size_type Layers,
swizzles_type const& Swizzles = swizzles_type(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA));
/// Create a texture_cube_array view with an existing storage_linear
explicit texture_cube_array(
texture const& Texture);
/// Reference a subset of an exiting storage_linear constructor
texture_cube_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 = swizzles_type(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA));
/// Create a texture view, reference a subset of an exiting texture_cube_array instance
texture_cube_array(
texture_cube_array const& Texture,
size_type BaseLayer, size_type MaxLayer,
size_type BaseFace, size_type MaxFace,
size_type BaseLevel, size_type MaxLevel);
/// Create a view of the texture identified by Layer in the texture array
texture_cube operator[](size_type Layer) const;
/// Return the dimensions of a texture instance: width and height where both should be equal.
extent_type extent(size_type Level = 0) const;
/// Fetch a texel from a texture. The texture format must be uncompressed.
template <typename gen_type>
gen_type load(extent_type const & TexelCoord, size_type Layer, size_type Face, size_type Level) const;
/// Write a texel to a texture. The texture format must be uncompressed.
template <typename gen_type>
void store(extent_type const& TexelCoord, size_type Layer, size_type Face, size_type Level, gen_type const& Texel);
};
}//namespace gli
#include "./core/texture_cube_array.inl"

View file

@ -1,87 +0,0 @@
/// @brief Include to perform arithmetic per texel between two textures.
/// @file gli/transform.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
{
template <typename vec_type>
struct transform_func
{
typedef vec_type(*type)(vec_type const & A, vec_type const & B);
};
/// Compute per-texel operations using a user defined function.
///
/// @param Out Output texture.
/// @param In0 First input texture.
/// @param In1 Second input texture.
/// @param TexelFunc Pointer to a binary function.
template <typename vec_type>
void transform(texture1d & Out, texture1d const & In0, texture1d const & In1, typename transform_func<vec_type>::type TexelFunc);
/// Compute per-texel operations using a user defined function.
///
/// @param Out Output texture.
/// @param In0 First input texture.
/// @param In1 Second input texture.
/// @param TexelFunc Pointer to a binary function.
template <typename vec_type>
void transform(texture1d_array & Out, texture1d_array const & In0, texture1d_array const & In1, typename transform_func<vec_type>::type TexelFunc);
/// Compute per-texel operations using a user defined function.
///
/// @param Out Output texture.
/// @param In0 First input texture.
/// @param In1 Second input texture.
/// @param TexelFunc Pointer to a binary function.
template <typename vec_type>
void transform(texture2d & Out, texture2d const & In0, texture2d const & In1, typename transform_func<vec_type>::type TexelFunc);
/// Compute per-texel operations using a user defined function.
///
/// @param Out Output texture.
/// @param In0 First input texture.
/// @param In1 Second input texture.
/// @param TexelFunc Pointer to a binary function.
template <typename vec_type>
void transform(texture2d_array & Out, texture2d_array const & In0, texture2d_array const & In1, typename transform_func<vec_type>::type TexelFunc);
/// Compute per-texel operations using a user defined function.
///
/// @param Out Output texture.
/// @param In0 First input texture.
/// @param In1 Second input texture.
/// @param TexelFunc Pointer to a binary function.
template <typename vec_type>
void transform(texture3d & Out, texture3d const & In0, texture3d const & In1, typename transform_func<vec_type>::type TexelFunc);
/// Compute per-texel operations using a user defined function.
///
/// @param Out Output texture.
/// @param In0 First input texture.
/// @param In1 Second input texture.
/// @param TexelFunc Pointer to a binary function.
template <typename vec_type>
void transform(texture_cube & Out, texture_cube const & In0, texture_cube const & In1, typename transform_func<vec_type>::type TexelFunc);
/// Compute per-texel operations using a user defined function.
///
/// @param Out Output texture.
/// @param In0 First input texture.
/// @param In1 Second input texture.
/// @param TexelFunc Pointer to a binary function.
template <typename vec_type>
void transform(texture_cube_array & Out, texture_cube_array const & In0, texture_cube_array const & In1, typename transform_func<vec_type>::type TexelFunc);
}//namespace gli
#include "./core/transform.inl"

View file

@ -1,65 +0,0 @@
/// @brief Include to use basic GLI types.
/// @file gli/type.hpp
#pragma once
// STD
#include <cstddef>
// GLM
#define GLM_FORCE_EXPLICIT_CTOR
#include <glm/glm.hpp>
#include <glm/gtc/vec1.hpp>
#define GLM_ENABLE_EXPERIMENTAL
#if GLM_COMPILER & GLM_COMPILER_VC
# define GLI_FORCE_INLINE __forceinline
#elif GLM_COMPILER & (GLM_COMPILER_GCC | GLM_COMPILER_APPLE_CLANG | GLM_COMPILER_LLVM)
# define GLI_FORCE_INLINE inline __attribute__((__always_inline__))
#else
# define GLI_FORCE_INLINE inline
#endif//GLM_COMPILER
#define GLI_DISABLE_ASSERT 0
#if defined(NDEBUG) || GLI_DISABLE_ASSERT
# define GLI_ASSERT(test)
#else
# define GLI_ASSERT(test) assert((test))
#endif
namespace gli
{
using namespace glm;
using std::size_t;
typedef ivec1 extent1d;
typedef ivec2 extent2d;
typedef ivec3 extent3d;
typedef ivec4 extent4d;
template <typename T, precision P>
inline vec<4, T, P> make_vec4(vec<1, T, P> const & v)
{
return vec<4, T, P>(v.x, static_cast<T>(0), static_cast<T>(0), static_cast<T>(1));
}
template <typename T, precision P>
inline vec<4, T, P> make_vec4(vec<2, T, P> const & v)
{
return vec<4, T, P>(v.x, v.y, static_cast<T>(0), static_cast<T>(1));
}
template <typename T, precision P>
inline vec<4, T, P> make_vec4(vec<3, T, P> const & v)
{
return vec<4, T, P>(v.x, v.y, v.z, static_cast<T>(1));
}
template <typename T, precision P>
inline vec<4, T, P> make_vec4(vec<4, T, P> const & v)
{
return v;
}
}//namespace gli

View file

@ -1,81 +0,0 @@
/// @brief Include create views of textures, either to isolate a subset or to reinterpret data without memory copy.
/// @file gli/view.hpp
#pragma once
#include "image.hpp"
#include "texture.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
{
/// Create an image view of an existing image, sharing the same memory storage_linear.
image view(image const & Image);
/// Create a texture view of an existing texture, sharing the same memory storage_linear.
texture view(texture const & Texture);
/// Create a texture view of an existing texture, sharing the same memory storage_linear but giving access only to a subset of layers, levels and faces.
texture view(
texture const & Texture,
texture::size_type BaseLayer, texture::size_type MaxLayer,
texture::size_type BaseFace, texture::size_type MaxFace,
texture::size_type BaseLevel, texture::size_type MaxLevel);
/// Create a texture view of an existing texture, sharing the same memory storage_linear.
template <typename texType>
texture view(texType const & Texture);
/// Create a texture view of an existing texture, sharing the same memory storage_linear but a different format.
/// The format must be a compatible format, a format which block size match the original format.
template <typename texType>
texture view(texType const & Texture, format Format);
/// Create a texture view of an existing texture, sharing the same memory storage_linear but giving access only to a subset of levels.
texture view(
texture1d const & Texture,
texture1d::size_type BaseLevel, texture1d::size_type MaxLevel);
/// Create a texture view of an existing texture, sharing the same memory storage_linear but giving access only to a subset of levels and layers.
texture view(
texture1d_array const & Texture,
texture1d_array::size_type BaseLayer, texture1d_array::size_type MaxLayer,
texture1d_array::size_type BaseLevel, texture1d_array::size_type MaxLevel);
/// Create a texture view of an existing texture, sharing the same memory storage_linear but giving access only to a subset of levels.
texture view(
texture2d const & Texture,
texture2d::size_type BaseLevel, texture2d::size_type MaxLevel);
/// Create a texture view of an existing texture, sharing the same memory storage_linear but giving access only to a subset of levels and layers.
texture view(
texture2d_array const & Texture,
texture2d_array::size_type BaseLayer, texture2d_array::size_type MaxLayer,
texture2d_array::size_type BaseLevel, texture2d_array::size_type MaxLevel);
/// Create a texture view of an existing texture, sharing the same memory storage_linear but giving access only to a subset of levels.
texture view(
texture3d const & Texture,
texture3d::size_type BaseLevel, texture3d::size_type MaxLevel);
/// Create a texture view of an existing texture, sharing the same memory storage_linear but giving access only to a subset of levels and faces.
texture view(
texture_cube const & Texture,
texture_cube::size_type BaseFace, texture_cube::size_type MaxFace,
texture_cube::size_type BaseLevel, texture_cube::size_type MaxLevel);
/// Create a texture view of an existing texture, sharing the same memory storage_linear but giving access only to a subset of layers, levels and faces.
texture view(
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);
}//namespace gli
#include "./core/view.inl"