mirror of
https://github.com/g-truc/glm.git
synced 2024-11-26 18:24:35 +00:00
Updated GLI version used in GLM tests
This commit is contained in:
parent
3440139d3a
commit
7e4007d427
9
test/external/gli/CMakeLists.txt
vendored
9
test/external/gli/CMakeLists.txt
vendored
@ -1,8 +1,11 @@
|
||||
set(NAME gli)
|
||||
set(NAME gli_dummy)
|
||||
|
||||
file(GLOB ROOT_SOURCE *.cpp)
|
||||
file(GLOB ROOT_INLINE *.inl)
|
||||
file(GLOB ROOT_HEADER *.hpp)
|
||||
file(GLOB ROOT_TEXT ../*.txt)
|
||||
file(GLOB ROOT_MD ../*.md)
|
||||
file(GLOB ROOT_KMG ../doc/spec/*.html)
|
||||
|
||||
file(GLOB_RECURSE CORE_SOURCE ./core/*.cpp)
|
||||
file(GLOB_RECURSE CORE_INLINE ./core/*.inl)
|
||||
@ -12,6 +15,8 @@ file(GLOB_RECURSE GTX_SOURCE ./gtx/*.cpp)
|
||||
file(GLOB_RECURSE GTX_INLINE ./gtx/*.inl)
|
||||
file(GLOB_RECURSE GTX_HEADER ./gtx/*.hpp)
|
||||
|
||||
source_group("KMG Spec" FILES ${ROOT_KMG})
|
||||
source_group("Text Files" FILES ${ROOT_TEXT} ${ROOT_MD})
|
||||
source_group("Core Files" FILES ${CORE_SOURCE})
|
||||
source_group("Core Files" FILES ${CORE_INLINE})
|
||||
source_group("Core Files" FILES ${CORE_HEADER})
|
||||
@ -21,7 +26,7 @@ source_group("GTX Files" FILES ${GTX_HEADER})
|
||||
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
|
||||
|
||||
add_executable(${NAME}
|
||||
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})
|
||||
|
47
test/external/gli/clear.hpp
vendored
Normal file
47
test/external/gli/clear.hpp
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
/// @brief Include to copy textures or a subset of either textures. These operations are performed without memory allocations.
|
||||
/// @file gli/clear.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace gli
|
||||
{
|
||||
/// Clear a complete texture
|
||||
template <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"
|
||||
|
30
test/external/gli/comparison.hpp
vendored
Normal file
30
test/external/gli/comparison.hpp
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
/// @brief Include to use operators to compare whether two textures or images are equal
|
||||
/// @file gli/comparison.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "image.hpp"
|
||||
#include "texture1d.hpp"
|
||||
#include "texture1d_array.hpp"
|
||||
#include "texture2d.hpp"
|
||||
#include "texture2d_array.hpp"
|
||||
#include "texture3d.hpp"
|
||||
#include "texture_cube.hpp"
|
||||
#include "texture_cube_array.hpp"
|
||||
|
||||
namespace gli
|
||||
{
|
||||
/// Compare two images. Two images are equal when the date is the same.
|
||||
bool operator==(image const& ImageA, image const& ImageB);
|
||||
|
||||
/// Compare two images. Two images are equal when the date is the same.
|
||||
bool operator!=(image const& ImageA, image const& ImageB);
|
||||
|
||||
/// Compare two textures. Two textures are the same when the data, the format and the targets are the same.
|
||||
bool operator==(texture const& A, texture const& B);
|
||||
|
||||
/// Compare two textures. Two textures are the same when the data, the format and the targets are the same.
|
||||
bool operator!=(texture const& A, texture const& B);
|
||||
}//namespace gli
|
||||
|
||||
#include "./core/comparison.inl"
|
25
test/external/gli/convert.hpp
vendored
Normal file
25
test/external/gli/convert.hpp
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
/// @brief Include to copy textures, images or a subset of either textures or an images. These operations will cause memory allocations.
|
||||
/// @file gli/convert.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "texture1d.hpp"
|
||||
#include "texture1d_array.hpp"
|
||||
#include "texture2d.hpp"
|
||||
#include "texture2d_array.hpp"
|
||||
#include "texture3d.hpp"
|
||||
#include "texture_cube.hpp"
|
||||
#include "texture_cube_array.hpp"
|
||||
|
||||
namespace gli
|
||||
{
|
||||
/// Convert texture data to a new format
|
||||
///
|
||||
/// @param Texture Source texture, the format must be uncompressed.
|
||||
/// @param Format Destination Texture format, it must be uncompressed.
|
||||
template <typename texture_type>
|
||||
texture_type convert(texture_type const& Texture, format Format);
|
||||
|
||||
}//namespace gli
|
||||
|
||||
#include "./core/convert.inl"
|
62
test/external/gli/copy.hpp
vendored
Normal file
62
test/external/gli/copy.hpp
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
/// @brief Include to copy textures or a subset of either textures. These operations are performed without memory allocations.
|
||||
/// @file gli/copy.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "type.hpp"
|
||||
|
||||
namespace gli
|
||||
{
|
||||
/// Copy a specific image of a texture
|
||||
template <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"
|
25
test/external/gli/core/clear.hpp
vendored
Normal file
25
test/external/gli/core/clear.hpp
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
#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, tvec4<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
|
71
test/external/gli/core/clear.inl
vendored
Normal file
71
test/external/gli/core/clear.inl
vendored
Normal file
@ -0,0 +1,71 @@
|
||||
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
|
100
test/external/gli/core/comparison.inl
vendored
Normal file
100
test/external/gli/core/comparison.inl
vendored
Normal file
@ -0,0 +1,100 @@
|
||||
#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
|
45
test/external/gli/core/convert.inl
vendored
Normal file
45
test/external/gli/core/convert.inl
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
#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
|
||||
|
767
test/external/gli/core/convert_func.hpp
vendored
Normal file
767
test/external/gli/core/convert_func.hpp
vendored
Normal file
@ -0,0 +1,767 @@
|
||||
#pragma once
|
||||
|
||||
#include "../type.hpp"
|
||||
#include "../texture1d.hpp"
|
||||
#include "../texture1d_array.hpp"
|
||||
#include "../texture2d.hpp"
|
||||
#include "../texture2d_array.hpp"
|
||||
#include "../texture3d.hpp"
|
||||
#include "../texture_cube.hpp"
|
||||
#include "../texture_cube_array.hpp"
|
||||
#include <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, typename T, precision P, template <typename, precision> class vecType, convertMode mode = CONVERT_MODE_CAST, bool isSamplerFloat = false>
|
||||
struct convertFunc
|
||||
{
|
||||
typedef accessFunc<textureType, vecType<T, P> > access;
|
||||
|
||||
static tvec4<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>(vecType<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, tvec4<retType, P> const & Texel)
|
||||
{
|
||||
access::store(Texture, TexelCoord, Layer, Face, Level, vecType<T, P>(Texel));
|
||||
}
|
||||
};
|
||||
|
||||
template <typename textureType, typename retType, typename T, precision P, template <typename, precision> class vecType, bool isSamplerFloat>
|
||||
struct convertFunc<textureType, retType, T, P, vecType, CONVERT_MODE_DEFAULT, isSamplerFloat>
|
||||
{
|
||||
static tvec4<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 tvec4<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, tvec4<retType, P> const & Texel)
|
||||
{}
|
||||
};
|
||||
|
||||
template <typename textureType, typename retType, typename T, precision P, template <typename, precision> class vecType>
|
||||
struct convertFunc<textureType, retType, T, P, vecType, CONVERT_MODE_NORM, true>
|
||||
{
|
||||
typedef accessFunc<textureType, vecType<T, P> > access;
|
||||
|
||||
static tvec4<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, tvec4<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>(vecType<retType, P>(Texel)));
|
||||
}
|
||||
};
|
||||
|
||||
template <typename textureType, typename retType, typename T, precision P, template <typename, precision> class vecType>
|
||||
struct convertFunc<textureType, retType, T, P, vecType, CONVERT_MODE_SRGB, true>
|
||||
{
|
||||
typedef accessFunc<textureType, vecType<T, P> > access;
|
||||
|
||||
static tvec4<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, tvec4<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(vecType<retType, P>(Texel))));
|
||||
}
|
||||
};
|
||||
|
||||
template <typename textureType, typename retType, typename T, precision P, template <typename, precision> class vecType>
|
||||
struct convertFunc<textureType, retType, T, P, vecType, CONVERT_MODE_RGB9E5, true>
|
||||
{
|
||||
typedef accessFunc<textureType, uint32> access;
|
||||
|
||||
static tvec4<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 tvec4<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, tvec4<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(tvec3<float, P>(Texel)));
|
||||
}
|
||||
};
|
||||
|
||||
template <typename textureType, typename retType, typename T, precision P, template <typename, precision> class vecType>
|
||||
struct convertFunc<textureType, retType, T, P, vecType, CONVERT_MODE_RG11B10F, true>
|
||||
{
|
||||
typedef accessFunc<textureType, uint32> access;
|
||||
|
||||
static tvec4<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 tvec4<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, tvec4<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(tvec3<float, P>(Texel)));
|
||||
}
|
||||
};
|
||||
|
||||
template <typename textureType, typename retType, typename T, precision P, template <typename, precision> class vecType>
|
||||
struct convertFunc<textureType, retType, T, P, vecType, CONVERT_MODE_HALF, true>
|
||||
{
|
||||
typedef accessFunc<textureType, vecType<uint16, P> > access;
|
||||
|
||||
static tvec4<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>(vecType<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, tvec4<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(vecType<float, P>(Texel)));
|
||||
}
|
||||
};
|
||||
|
||||
template <typename textureType, typename retType, typename T, precision P, template <typename, precision> class vecType>
|
||||
struct convertFunc<textureType, retType, T, P, vecType, CONVERT_MODE_44UNORM, true>
|
||||
{
|
||||
typedef accessFunc<textureType, uint8> access;
|
||||
|
||||
static tvec4<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 tvec4<retType, P>(tvec2<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, tvec4<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(tvec2<float, P>(Texel)));
|
||||
}
|
||||
};
|
||||
|
||||
template <typename textureType, typename retType, typename T, precision P, template <typename, precision> class vecType>
|
||||
struct convertFunc<textureType, retType, T, P, vecType, CONVERT_MODE_4444UNORM, true>
|
||||
{
|
||||
typedef accessFunc<textureType, uint16> access;
|
||||
|
||||
static tvec4<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 tvec4<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, tvec4<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(tvec4<float, P>(Texel)));
|
||||
}
|
||||
};
|
||||
|
||||
template <typename textureType, typename retType, typename T, precision P, template <typename, precision> class vecType>
|
||||
struct convertFunc<textureType, retType, T, P, vecType, CONVERT_MODE_565UNORM, true>
|
||||
{
|
||||
typedef accessFunc<textureType, uint16> access;
|
||||
|
||||
static tvec4<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 tvec4<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, tvec4<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(tvec3<float, P>(Texel)));
|
||||
}
|
||||
};
|
||||
|
||||
template <typename textureType, typename retType, typename T, precision P, template <typename, precision> class vecType>
|
||||
struct convertFunc<textureType, retType, T, P, vecType, CONVERT_MODE_5551UNORM, true>
|
||||
{
|
||||
typedef accessFunc<textureType, uint16> access;
|
||||
|
||||
static tvec4<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 tvec4<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, tvec4<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(tvec4<float, P>(Texel)));
|
||||
}
|
||||
};
|
||||
|
||||
template <typename textureType, typename retType, typename T, precision P, template <typename, precision> class vecType>
|
||||
struct convertFunc<textureType, retType, T, P, vecType, CONVERT_MODE_332UNORM, true>
|
||||
{
|
||||
typedef accessFunc<textureType, uint8> access;
|
||||
|
||||
static tvec4<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 tvec4<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, tvec4<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(tvec3<float, P>(Texel)));
|
||||
}
|
||||
};
|
||||
|
||||
template <typename textureType, typename retType, typename T, precision P, template <typename, precision> class vecType>
|
||||
struct convertFunc<textureType, retType, T, P, vecType, CONVERT_MODE_RGB10A2UNORM, true>
|
||||
{
|
||||
typedef accessFunc<textureType, uint32> access;
|
||||
|
||||
static tvec4<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 tvec4<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, tvec4<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(tvec4<float, P>(Texel)));
|
||||
}
|
||||
};
|
||||
|
||||
template <typename textureType, typename retType, typename T, precision P, template <typename, precision> class vecType>
|
||||
struct convertFunc<textureType, retType, T, P, vecType, CONVERT_MODE_RGB10A2SNORM, true>
|
||||
{
|
||||
typedef accessFunc<textureType, uint32> access;
|
||||
|
||||
static tvec4<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 tvec4<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, tvec4<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, typename T, precision P, template <typename, precision> class vecType>
|
||||
struct convertFunc<textureType, retType, T, P, vecType, CONVERT_MODE_RGB10A2USCALE, true>
|
||||
{
|
||||
typedef accessFunc<textureType, uint32> access;
|
||||
|
||||
static tvec4<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 tvec4<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, tvec4<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, typename T, precision P, template <typename, precision> class vecType>
|
||||
struct convertFunc<textureType, retType, T, P, vecType, CONVERT_MODE_RGB10A2SSCALE, true>
|
||||
{
|
||||
typedef accessFunc<textureType, uint32> access;
|
||||
|
||||
static tvec4<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 tvec4<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, tvec4<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, typename T, precision P, template <typename, precision> class vecType>
|
||||
struct convertFunc<textureType, retType, T, P, vecType, CONVERT_MODE_RGB10A2UINT, false>
|
||||
{
|
||||
typedef accessFunc<textureType, uint32> access;
|
||||
|
||||
static tvec4<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 tvec4<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, tvec4<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, typename T, precision P, template <typename, precision> class vecType>
|
||||
struct convertFunc<textureType, retType, T, P, vecType, CONVERT_MODE_RGB10A2SINT, false>
|
||||
{
|
||||
typedef accessFunc<textureType, uint32> access;
|
||||
|
||||
static tvec4<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 tvec4<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, tvec4<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 glm::tvec4<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, glm::tvec4<samplerValType, P> const & Texel);
|
||||
|
||||
template <typename T, template <typename, precision> class vecType, convertMode mode>
|
||||
struct conv
|
||||
{
|
||||
static tvec4<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, T, P, vecType, 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, tvec4<samplerValType, P> const & Texel)
|
||||
{
|
||||
convertFunc<textureType, samplerValType, T, P, vecType, 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<u8, tvec2, CONVERT_MODE_44UNORM>::fetch, conv<u8, tvec2, CONVERT_MODE_44UNORM>::write}, // FORMAT_RG4_UNORM
|
||||
{conv<u8, tvec4, CONVERT_MODE_4444UNORM>::fetch, conv<u8, tvec4, CONVERT_MODE_4444UNORM>::write}, // FORMAT_RGBA4_UNORM
|
||||
{conv<u8, tvec4, CONVERT_MODE_4444UNORM>::fetch, conv<u8, tvec4, CONVERT_MODE_4444UNORM>::write}, // FORMAT_BGRA4_UNORM
|
||||
{conv<u8, tvec3, CONVERT_MODE_565UNORM>::fetch, conv<u8, tvec3, CONVERT_MODE_565UNORM>::write}, // FORMAT_R5G6B5_UNORM
|
||||
{conv<u8, tvec3, CONVERT_MODE_565UNORM>::fetch, conv<u8, tvec3, CONVERT_MODE_565UNORM>::write}, // FORMAT_B5G6R5_UNORM
|
||||
{conv<u8, tvec4, CONVERT_MODE_5551UNORM>::fetch, conv<u8, tvec4, CONVERT_MODE_5551UNORM>::write}, // FORMAT_RGB5A1_UNORM
|
||||
{conv<u8, tvec4, CONVERT_MODE_5551UNORM>::fetch, conv<u8, tvec4, CONVERT_MODE_5551UNORM>::write}, // FORMAT_BGR5A1_UNORM
|
||||
{conv<u8, tvec4, CONVERT_MODE_5551UNORM>::fetch, conv<u8, tvec4, CONVERT_MODE_5551UNORM>::write}, // FORMAT_A1RGB5_UNORM
|
||||
|
||||
{conv<u8, tvec1, CONVERT_MODE_NORM>::fetch, conv<u8, tvec1, CONVERT_MODE_NORM>::write}, // FORMAT_R8_UNORM
|
||||
{conv<i8, tvec1, CONVERT_MODE_NORM>::fetch, conv<i8, tvec1, CONVERT_MODE_NORM>::write}, // FORMAT_R8_SNORM
|
||||
{conv<u8, tvec1, CONVERT_MODE_CAST>::fetch, conv<u8, tvec1, CONVERT_MODE_CAST>::write}, // FORMAT_R8_USCALED
|
||||
{conv<i8, tvec1, CONVERT_MODE_CAST>::fetch, conv<i8, tvec1, CONVERT_MODE_CAST>::write}, // FORMAT_R8_SSCALED
|
||||
{conv<u8, tvec1, CONVERT_MODE_CAST>::fetch, conv<u8, tvec1, CONVERT_MODE_CAST>::write}, // FORMAT_R8_UINT
|
||||
{conv<i8, tvec1, CONVERT_MODE_CAST>::fetch, conv<i8, tvec1, CONVERT_MODE_CAST>::write}, // FORMAT_R8_SINT
|
||||
{conv<u8, tvec1, CONVERT_MODE_SRGB>::fetch, conv<u8, tvec1, CONVERT_MODE_SRGB>::write}, // FORMAT_R8_SRGB
|
||||
|
||||
{conv<u8, tvec2, CONVERT_MODE_NORM>::fetch, conv<u8, tvec2, CONVERT_MODE_NORM>::write}, // FORMAT_RG8_UNORM
|
||||
{conv<i8, tvec2, CONVERT_MODE_NORM>::fetch, conv<i8, tvec2, CONVERT_MODE_NORM>::write}, // FORMAT_RG8_SNORM
|
||||
{conv<u8, tvec2, CONVERT_MODE_CAST>::fetch, conv<u8, tvec2, CONVERT_MODE_CAST>::write}, // FORMAT_RG8_USCALED
|
||||
{conv<i8, tvec2, CONVERT_MODE_CAST>::fetch, conv<i8, tvec2, CONVERT_MODE_CAST>::write}, // FORMAT_RG8_SSCALED
|
||||
{conv<u8, tvec2, CONVERT_MODE_CAST>::fetch, conv<u8, tvec2, CONVERT_MODE_CAST>::write}, // FORMAT_RG8_UINT
|
||||
{conv<i8, tvec2, CONVERT_MODE_CAST>::fetch, conv<i8, tvec2, CONVERT_MODE_CAST>::write}, // FORMAT_RG8_SINT
|
||||
{conv<u8, tvec2, CONVERT_MODE_SRGB>::fetch, conv<u8, tvec2, CONVERT_MODE_SRGB>::write}, // FORMAT_RG8_SRGB
|
||||
|
||||
{conv<u8, tvec3, CONVERT_MODE_NORM>::fetch, conv<u8, tvec3, CONVERT_MODE_NORM>::write}, // FORMAT_RGB8_UNORM
|
||||
{conv<i8, tvec3, CONVERT_MODE_NORM>::fetch, conv<i8, tvec3, CONVERT_MODE_NORM>::write}, // FORMAT_RGB8_SNORM
|
||||
{conv<u8, tvec3, CONVERT_MODE_CAST>::fetch, conv<u8, tvec3, CONVERT_MODE_CAST>::write}, // FORMAT_RGB8_USCALED
|
||||
{conv<i8, tvec3, CONVERT_MODE_CAST>::fetch, conv<i8, tvec3, CONVERT_MODE_CAST>::write}, // FORMAT_RGB8_SSCALED
|
||||
{conv<u8, tvec3, CONVERT_MODE_CAST>::fetch, conv<u8, tvec3, CONVERT_MODE_CAST>::write}, // FORMAT_RGB8_UINT
|
||||
{conv<i8, tvec3, CONVERT_MODE_CAST>::fetch, conv<i8, tvec3, CONVERT_MODE_CAST>::write}, // FORMAT_RGB8_SINT
|
||||
{conv<u8, tvec3, CONVERT_MODE_SRGB>::fetch, conv<u8, tvec3, CONVERT_MODE_SRGB>::write}, // FORMAT_RGB8_SRGB
|
||||
|
||||
{conv<u8, tvec3, CONVERT_MODE_NORM>::fetch, conv<u8, tvec3, CONVERT_MODE_NORM>::write}, // FORMAT_BGR8_UNORM
|
||||
{conv<i8, tvec3, CONVERT_MODE_NORM>::fetch, conv<i8, tvec3, CONVERT_MODE_NORM>::write}, // FORMAT_BGR8_SNORM
|
||||
{conv<u8, tvec3, CONVERT_MODE_CAST>::fetch, conv<u8, tvec3, CONVERT_MODE_CAST>::write}, // FORMAT_BGR8_USCALED
|
||||
{conv<i8, tvec3, CONVERT_MODE_CAST>::fetch, conv<i8, tvec3, CONVERT_MODE_CAST>::write}, // FORMAT_BGR8_SSCALED
|
||||
{conv<u32, tvec3, CONVERT_MODE_CAST>::fetch, conv<u32, tvec3, CONVERT_MODE_CAST>::write}, // FORMAT_BGR8_UINT
|
||||
{conv<i32, tvec3, CONVERT_MODE_CAST>::fetch, conv<i32, tvec3, CONVERT_MODE_CAST>::write}, // FORMAT_BGR8_SINT
|
||||
{conv<u8, tvec3, CONVERT_MODE_SRGB>::fetch, conv<u8, tvec3, CONVERT_MODE_SRGB>::write}, // FORMAT_BGR8_SRGB
|
||||
|
||||
{conv<u8, tvec4, CONVERT_MODE_NORM>::fetch, conv<u8, tvec4, CONVERT_MODE_NORM>::write}, // FORMAT_RGBA8_UNORM
|
||||
{conv<i8, tvec4, CONVERT_MODE_NORM>::fetch, conv<i8, tvec4, CONVERT_MODE_NORM>::write}, // FORMAT_RGBA8_SNORM
|
||||
{conv<u8, tvec4, CONVERT_MODE_CAST>::fetch, conv<u8, tvec4, CONVERT_MODE_CAST>::write}, // FORMAT_RGBA8_USCALED
|
||||
{conv<i8, tvec4, CONVERT_MODE_CAST>::fetch, conv<i8, tvec4, CONVERT_MODE_CAST>::write}, // FORMAT_RGBA8_SSCALED
|
||||
{conv<u8, tvec4, CONVERT_MODE_CAST>::fetch, conv<u8, tvec4, CONVERT_MODE_CAST>::write}, // FORMAT_RGBA8_UINT
|
||||
{conv<i8, tvec4, CONVERT_MODE_CAST>::fetch, conv<i8, tvec4, CONVERT_MODE_CAST>::write}, // FORMAT_RGBA8_SINT
|
||||
{conv<u8, tvec4, CONVERT_MODE_SRGB>::fetch, conv<u8, tvec4, CONVERT_MODE_SRGB>::write}, // FORMAT_RGBA8_SRGB
|
||||
|
||||
{conv<u8, tvec4, CONVERT_MODE_NORM>::fetch, conv<u8, tvec4, CONVERT_MODE_NORM>::write}, // FORMAT_BGRA8_UNORM
|
||||
{conv<i8, tvec4, CONVERT_MODE_NORM>::fetch, conv<i8, tvec4, CONVERT_MODE_NORM>::write}, // FORMAT_BGRA8_SNORM
|
||||
{conv<u8, tvec4, CONVERT_MODE_CAST>::fetch, conv<u8, tvec4, CONVERT_MODE_CAST>::write}, // FORMAT_BGRA8_USCALED
|
||||
{conv<i8, tvec4, CONVERT_MODE_CAST>::fetch, conv<i8, tvec4, CONVERT_MODE_CAST>::write}, // FORMAT_BGRA8_SSCALED
|
||||
{conv<u8, tvec4, CONVERT_MODE_CAST>::fetch, conv<u8, tvec4, CONVERT_MODE_CAST>::write}, // FORMAT_BGRA8_UINT
|
||||
{conv<i8, tvec4, CONVERT_MODE_CAST>::fetch, conv<i8, tvec4, CONVERT_MODE_CAST>::write}, // FORMAT_BGRA8_SINT
|
||||
{conv<u8, tvec4, CONVERT_MODE_SRGB>::fetch, conv<u8, tvec4, CONVERT_MODE_SRGB>::write}, // FORMAT_BGRA8_SRGB
|
||||
|
||||
{conv<u8, tvec4, CONVERT_MODE_NORM>::fetch, conv<u8, tvec4, CONVERT_MODE_NORM>::write}, // FORMAT_ABGR8_UNORM
|
||||
{conv<i8, tvec4, CONVERT_MODE_NORM>::fetch, conv<i8, tvec4, CONVERT_MODE_NORM>::write}, // FORMAT_ABGR8_SNORM
|
||||
{conv<u8, tvec4, CONVERT_MODE_CAST>::fetch, conv<u8, tvec4, CONVERT_MODE_CAST>::write}, // FORMAT_ABGR8_USCALED
|
||||
{conv<i8, tvec4, CONVERT_MODE_CAST>::fetch, conv<i8, tvec4, CONVERT_MODE_CAST>::write}, // FORMAT_ABGR8_SSCALED
|
||||
{conv<u8, tvec4, CONVERT_MODE_CAST>::fetch, conv<u8, tvec4, CONVERT_MODE_CAST>::write}, // FORMAT_ABGR8_UINT
|
||||
{conv<i8, tvec4, CONVERT_MODE_CAST>::fetch, conv<i8, tvec4, CONVERT_MODE_CAST>::write}, // FORMAT_ABGR8_SINT
|
||||
{conv<u8, tvec4, CONVERT_MODE_SRGB>::fetch, conv<u8, tvec4, CONVERT_MODE_SRGB>::write}, // FORMAT_ABGR8_SRGB
|
||||
|
||||
{conv<u8, tvec4, CONVERT_MODE_RGB10A2UNORM>::fetch, conv<u8, tvec4, CONVERT_MODE_RGB10A2UNORM>::write}, // FORMAT_RGB10A2_UNORM
|
||||
{conv<i8, tvec4, CONVERT_MODE_RGB10A2SNORM>::fetch, conv<i8, tvec4, CONVERT_MODE_RGB10A2SNORM>::write}, // FORMAT_RGB10A2_SNORM
|
||||
{conv<u8, tvec4, CONVERT_MODE_RGB10A2USCALE>::fetch, conv<u8, tvec4, CONVERT_MODE_RGB10A2USCALE>::write}, // FORMAT_RGB10A2_USCALED
|
||||
{conv<i8, tvec4, CONVERT_MODE_RGB10A2SSCALE>::fetch, conv<i8, tvec4, CONVERT_MODE_RGB10A2SSCALE>::write}, // FORMAT_RGB10A2_SSCALED
|
||||
{conv<u8, tvec4, CONVERT_MODE_RGB10A2UINT>::fetch, conv<u8, tvec4, CONVERT_MODE_RGB10A2UINT>::write}, // FORMAT_RGB10A2_UINT
|
||||
{conv<i8, tvec4, CONVERT_MODE_RGB10A2SINT>::fetch, conv<i8, tvec4, CONVERT_MODE_RGB10A2SINT>::write}, // FORMAT_RGB10A2_SINT
|
||||
|
||||
{conv<u8, tvec4, CONVERT_MODE_RGB10A2UNORM>::fetch, conv<u8, tvec4, CONVERT_MODE_RGB10A2UNORM>::write}, // FORMAT_BGR10A2_UNORM
|
||||
{conv<i8, tvec4, CONVERT_MODE_RGB10A2SNORM>::fetch, conv<i8, tvec4, CONVERT_MODE_RGB10A2SNORM>::write}, // FORMAT_BGR10A2_SNORM
|
||||
{conv<u8, tvec4, CONVERT_MODE_RGB10A2USCALE>::fetch, conv<u8, tvec4, CONVERT_MODE_RGB10A2USCALE>::write}, // FORMAT_BGR10A2_USCALED
|
||||
{conv<i8, tvec4, CONVERT_MODE_RGB10A2SSCALE>::fetch, conv<i8, tvec4, CONVERT_MODE_RGB10A2SSCALE>::write}, // FORMAT_BGR10A2_SSCALED
|
||||
{conv<u8, tvec4, CONVERT_MODE_RGB10A2UINT>::fetch, conv<u8, tvec4, CONVERT_MODE_RGB10A2UINT>::write}, // FORMAT_BGR10A2_UINT
|
||||
{conv<i8, tvec4, CONVERT_MODE_RGB10A2SINT>::fetch, conv<i8, tvec4, CONVERT_MODE_RGB10A2SINT>::write}, // FORMAT_BGR10A2_SINT
|
||||
|
||||
{conv<u16, tvec1, CONVERT_MODE_NORM>::fetch, conv<u16, tvec1, CONVERT_MODE_NORM>::write}, // FORMAT_R16_UNORM_PACK16
|
||||
{conv<i16, tvec1, CONVERT_MODE_NORM>::fetch, conv<i16, tvec1, CONVERT_MODE_NORM>::write}, // FORMAT_R16_SNORM_PACK16
|
||||
{conv<u16, tvec1, CONVERT_MODE_CAST>::fetch, conv<u16, tvec1, CONVERT_MODE_CAST>::write}, // FORMAT_R16_USCALED_PACK16
|
||||
{conv<i16, tvec1, CONVERT_MODE_CAST>::fetch, conv<i16, tvec1, CONVERT_MODE_CAST>::write}, // FORMAT_R16_SSCALED_PACK16
|
||||
{conv<u16, tvec1, CONVERT_MODE_CAST>::fetch, conv<u16, tvec1, CONVERT_MODE_CAST>::write}, // FORMAT_R16_UINT_PACK16
|
||||
{conv<i16, tvec1, CONVERT_MODE_CAST>::fetch, conv<i16, tvec1, CONVERT_MODE_CAST>::write}, // FORMAT_R16_SINT_PACK16
|
||||
{conv<u16, tvec1, CONVERT_MODE_HALF>::fetch, conv<u16, tvec1, CONVERT_MODE_HALF>::write}, // FORMAT_R16_SFLOAT_PACK16
|
||||
|
||||
{conv<u16, tvec2, CONVERT_MODE_NORM>::fetch, conv<u16, tvec2, CONVERT_MODE_NORM>::write}, // FORMAT_RG16_UNORM_PACK16
|
||||
{conv<i16, tvec2, CONVERT_MODE_NORM>::fetch, conv<i16, tvec2, CONVERT_MODE_NORM>::write}, // FORMAT_RG16_SNORM_PACK16
|
||||
{conv<u16, tvec2, CONVERT_MODE_CAST>::fetch, conv<u16, tvec2, CONVERT_MODE_CAST>::write}, // FORMAT_RG16_USCALED_PACK16
|
||||
{conv<i16, tvec2, CONVERT_MODE_CAST>::fetch, conv<i16, tvec2, CONVERT_MODE_CAST>::write}, // FORMAT_RG16_SSCALED_PACK16
|
||||
{conv<u16, tvec2, CONVERT_MODE_CAST>::fetch, conv<u16, tvec2, CONVERT_MODE_CAST>::write}, // FORMAT_RG16_UINT_PACK16
|
||||
{conv<i16, tvec2, CONVERT_MODE_CAST>::fetch, conv<i16, tvec2, CONVERT_MODE_CAST>::write}, // FORMAT_RG16_SINT_PACK16
|
||||
{conv<u16, tvec2, CONVERT_MODE_HALF>::fetch, conv<u16, tvec2, CONVERT_MODE_HALF>::write}, // FORMAT_RG16_SFLOAT_PACK16
|
||||
|
||||
{conv<u16, tvec3, CONVERT_MODE_NORM>::fetch, conv<u16, tvec3, CONVERT_MODE_NORM>::write}, // FORMAT_RGB16_UNORM_PACK16
|
||||
{conv<i16, tvec3, CONVERT_MODE_NORM>::fetch, conv<i16, tvec3, CONVERT_MODE_NORM>::write}, // FORMAT_RGB16_SNORM_PACK16
|
||||
{conv<u16, tvec3, CONVERT_MODE_CAST>::fetch, conv<u16, tvec3, CONVERT_MODE_CAST>::write}, // FORMAT_RGB16_USCALED_PACK16
|
||||
{conv<i16, tvec3, CONVERT_MODE_CAST>::fetch, conv<i16, tvec3, CONVERT_MODE_CAST>::write}, // FORMAT_RGB16_SSCALED_PACK16
|
||||
{conv<u16, tvec3, CONVERT_MODE_CAST>::fetch, conv<u16, tvec3, CONVERT_MODE_CAST>::write}, // FORMAT_RGB16_UINT_PACK16
|
||||
{conv<i16, tvec3, CONVERT_MODE_CAST>::fetch, conv<i16, tvec3, CONVERT_MODE_CAST>::write}, // FORMAT_RGB16_SINT_PACK16
|
||||
{conv<u16, tvec3, CONVERT_MODE_HALF>::fetch, conv<u16, tvec3, CONVERT_MODE_HALF>::write}, // FORMAT_RGB16_SFLOAT_PACK16
|
||||
|
||||
{conv<u16, tvec4, CONVERT_MODE_NORM>::fetch, conv<u16, tvec4, CONVERT_MODE_NORM>::write}, // FORMAT_RGBA16_UNORM_PACK16
|
||||
{conv<i16, tvec4, CONVERT_MODE_NORM>::fetch, conv<i16, tvec4, CONVERT_MODE_NORM>::write}, // FORMAT_RGBA16_SNORM_PACK16
|
||||
{conv<u16, tvec4, CONVERT_MODE_CAST>::fetch, conv<u16, tvec4, CONVERT_MODE_CAST>::write}, // FORMAT_RGBA16_USCALED_PACK16
|
||||
{conv<i16, tvec4, CONVERT_MODE_CAST>::fetch, conv<i16, tvec4, CONVERT_MODE_CAST>::write}, // FORMAT_RGBA16_SSCALED_PACK16
|
||||
{conv<u16, tvec4, CONVERT_MODE_CAST>::fetch, conv<u16, tvec4, CONVERT_MODE_CAST>::write}, // FORMAT_RGBA16_UINT_PACK16
|
||||
{conv<i16, tvec4, CONVERT_MODE_CAST>::fetch, conv<i16, tvec4, CONVERT_MODE_CAST>::write}, // FORMAT_RGBA16_SINT_PACK16
|
||||
{conv<u16, tvec4, CONVERT_MODE_HALF>::fetch, conv<u16, tvec4, CONVERT_MODE_HALF>::write}, // FORMAT_RGBA16_SFLOAT_PACK16
|
||||
|
||||
{conv<u32, tvec1, CONVERT_MODE_CAST>::fetch, conv<u32, tvec1, CONVERT_MODE_CAST>::write}, // FORMAT_R32_UINT_PACK32
|
||||
{conv<i32, tvec1, CONVERT_MODE_CAST>::fetch, conv<i32, tvec1, CONVERT_MODE_CAST>::write}, // FORMAT_R32_SINT_PACK32
|
||||
{conv<f32, tvec1, CONVERT_MODE_CAST>::fetch, conv<f32, tvec1, CONVERT_MODE_CAST>::write}, // FORMAT_R32_SFLOAT_PACK32
|
||||
|
||||
{conv<u32, tvec2, CONVERT_MODE_CAST>::fetch, conv<u32, tvec2, CONVERT_MODE_CAST>::write}, // FORMAT_RG32_UINT_PACK32
|
||||
{conv<i32, tvec2, CONVERT_MODE_CAST>::fetch, conv<i32, tvec2, CONVERT_MODE_CAST>::write}, // FORMAT_RG32_SINT_PACK32
|
||||
{conv<f32, tvec2, CONVERT_MODE_CAST>::fetch, conv<f32, tvec2, CONVERT_MODE_CAST>::write}, // FORMAT_RG32_SFLOAT_PACK32
|
||||
|
||||
{conv<u32, tvec3, CONVERT_MODE_CAST>::fetch, conv<u32, tvec3, CONVERT_MODE_CAST>::write}, // FORMAT_RGB32_UINT_PACK32
|
||||
{conv<i32, tvec3, CONVERT_MODE_CAST>::fetch, conv<i32, tvec3, CONVERT_MODE_CAST>::write}, // FORMAT_RGB32_SINT_PACK32
|
||||
{conv<f32, tvec3, CONVERT_MODE_CAST>::fetch, conv<f32, tvec3, CONVERT_MODE_CAST>::write}, // FORMAT_RGB32_SFLOAT_PACK32
|
||||
|
||||
{conv<u32, tvec4, CONVERT_MODE_CAST>::fetch, conv<u32, tvec4, CONVERT_MODE_CAST>::write}, // FORMAT_RGBA32_UINT_PACK32
|
||||
{conv<i32, tvec4, CONVERT_MODE_CAST>::fetch, conv<i32, tvec4, CONVERT_MODE_CAST>::write}, // FORMAT_RGBA32_SINT_PACK32
|
||||
{conv<f32, tvec4, CONVERT_MODE_CAST>::fetch, conv<f32, tvec4, CONVERT_MODE_CAST>::write}, // FORMAT_RGBA32_SFLOAT_PACK32
|
||||
|
||||
{conv<u64, tvec1, CONVERT_MODE_CAST>::fetch, conv<u64, tvec1, CONVERT_MODE_CAST>::write}, // FORMAT_R64_UINT_PACK64
|
||||
{conv<i64, tvec1, CONVERT_MODE_CAST>::fetch, conv<i64, tvec1, CONVERT_MODE_CAST>::write}, // FORMAT_R64_SINT_PACK64
|
||||
{conv<f64, tvec1, CONVERT_MODE_CAST>::fetch, conv<f64, tvec1, CONVERT_MODE_CAST>::write}, // FORMAT_R64_SFLOAT_PACK64
|
||||
|
||||
{conv<u64, tvec2, CONVERT_MODE_CAST>::fetch, conv<u64, tvec2, CONVERT_MODE_CAST>::write}, // FORMAT_RG64_UINT_PACK64
|
||||
{conv<i64, tvec2, CONVERT_MODE_CAST>::fetch, conv<i64, tvec2, CONVERT_MODE_CAST>::write}, // FORMAT_RG64_SINT_PACK64
|
||||
{conv<f64, tvec2, CONVERT_MODE_CAST>::fetch, conv<f64, tvec2, CONVERT_MODE_CAST>::write}, // FORMAT_RG64_SFLOAT_PACK64
|
||||
|
||||
{conv<u64, tvec3, CONVERT_MODE_CAST>::fetch, conv<u64, tvec3, CONVERT_MODE_CAST>::write}, // FORMAT_RGB64_UINT_PACK64
|
||||
{conv<i64, tvec3, CONVERT_MODE_CAST>::fetch, conv<i64, tvec3, CONVERT_MODE_CAST>::write}, // FORMAT_RGB64_SINT_PACK64
|
||||
{conv<f64, tvec3, CONVERT_MODE_CAST>::fetch, conv<f64, tvec3, CONVERT_MODE_CAST>::write}, // FORMAT_RGB64_SFLOAT_PACK64
|
||||
|
||||
{conv<u64, tvec4, CONVERT_MODE_CAST>::fetch, conv<u64, tvec4, CONVERT_MODE_CAST>::write}, // FORMAT_RGBA64_UINT_PACK64
|
||||
{conv<i64, tvec4, CONVERT_MODE_CAST>::fetch, conv<i64, tvec4, CONVERT_MODE_CAST>::write}, // FORMAT_RGBA64_SINT_PACK64
|
||||
{conv<f64, tvec4, CONVERT_MODE_CAST>::fetch, conv<f64, tvec4, CONVERT_MODE_CAST>::write}, // FORMAT_RGBA64_SFLOAT_PACK64
|
||||
|
||||
{conv<u32, tvec1, CONVERT_MODE_RG11B10F>::fetch, conv<u32, tvec1, CONVERT_MODE_RG11B10F>::write}, // FORMAT_RG11B10_UFLOAT
|
||||
{conv<u32, tvec1, CONVERT_MODE_RGB9E5>::fetch, conv<u32, tvec1, CONVERT_MODE_RGB9E5>::write}, // FORMAT_RGB9E5_UFLOAT
|
||||
|
||||
{conv<u16, tvec1, CONVERT_MODE_DEFAULT>::fetch, conv<u16, tvec1, CONVERT_MODE_DEFAULT>::write}, // FORMAT_D16_UNORM_PACK16
|
||||
{conv<u32, tvec1, CONVERT_MODE_DEFAULT>::fetch, conv<u32, tvec1, CONVERT_MODE_DEFAULT>::write}, // FORMAT_D24_UNORM
|
||||
{conv<float, tvec1, CONVERT_MODE_DEFAULT>::fetch, conv<float, tvec1, CONVERT_MODE_DEFAULT>::write}, // FORMAT_D32_SFLOAT_PACK32
|
||||
{conv<u8, tvec1, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec1, CONVERT_MODE_DEFAULT>::write}, // FORMAT_S8_UINT_PACK8
|
||||
{conv<u16, tvec2, CONVERT_MODE_DEFAULT>::fetch, conv<u16, tvec2, CONVERT_MODE_DEFAULT>::write}, // FORMAT_D16_UNORM_S8_UINT_PACK32
|
||||
{conv<u32, tvec2, CONVERT_MODE_DEFAULT>::fetch, conv<u32, tvec2, CONVERT_MODE_DEFAULT>::write}, // FORMAT_D24_UNORM_S8_UINT_PACK32
|
||||
{conv<u32, tvec2, CONVERT_MODE_DEFAULT>::fetch, conv<u32, tvec2, CONVERT_MODE_DEFAULT>::write}, // FORMAT_D32_SFLOAT_S8_UINT_PACK64
|
||||
|
||||
{conv<u8, tvec3, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec3, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGB_DXT1_UNORM_BLOCK8
|
||||
{conv<u8, tvec3, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec3, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGB_DXT1_SRGB_BLOCK8
|
||||
{conv<u8, tvec4, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec4, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGBA_DXT1_UNORM_BLOCK8
|
||||
{conv<u8, tvec4, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec4, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGBA_DXT1_SRGB_BLOCK8
|
||||
{conv<u8, tvec4, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec4, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGBA_DXT3_UNORM_BLOCK16
|
||||
{conv<u8, tvec4, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec4, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGBA_DXT3_SRGB_BLOCK16
|
||||
{conv<u8, tvec4, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec4, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGBA_DXT5_UNORM_BLOCK16
|
||||
{conv<u8, tvec4, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec4, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGBA_DXT5_SRGB_BLOCK16
|
||||
{conv<u8, tvec1, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec1, CONVERT_MODE_DEFAULT>::write}, // FORMAT_R_ATI1N_UNORM_BLOCK8
|
||||
{conv<u8, tvec1, CONVERT_MODE_DEFAULT>::fetch, conv<i8, tvec1, CONVERT_MODE_DEFAULT>::write}, // FORMAT_R_ATI1N_SNORM_BLOCK8
|
||||
{conv<u8, tvec2, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec2, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RG_ATI2N_UNORM_BLOCK16
|
||||
{conv<u8, tvec2, CONVERT_MODE_DEFAULT>::fetch, conv<i8, tvec2, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RG_ATI2N_SNORM_BLOCK16
|
||||
{conv<float, tvec3, CONVERT_MODE_DEFAULT>::fetch, conv<float, tvec3, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGB_BP_UFLOAT_BLOCK16
|
||||
{conv<float, tvec3, CONVERT_MODE_DEFAULT>::fetch, conv<float, tvec3, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGB_BP_SFLOAT_BLOCK16
|
||||
{conv<u8, tvec4, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec4, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGBA_BP_UNORM_BLOCK16
|
||||
{conv<u8, tvec4, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec4, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGBA_BP_SRGB_BLOCK16
|
||||
|
||||
{conv<u8, tvec3, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec3, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGB_ETC2_UNORM_BLOCK8
|
||||
{conv<u8, tvec3, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec3, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGB_ETC2_SRGB_BLOCK8
|
||||
{conv<u8, tvec4, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec4, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGBA_ETC2_A1_UNORM_BLOCK8
|
||||
{conv<u8, tvec4, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec4, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGBA_ETC2_A1_SRGB_BLOCK8
|
||||
{conv<u8, tvec4, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec4, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGBA_ETC2_UNORM_BLOCK16
|
||||
{conv<u8, tvec4, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec4, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGBA_ETC2_SRGB_BLOCK16
|
||||
{conv<u8, tvec1, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec1, CONVERT_MODE_DEFAULT>::write}, // FORMAT_R_EAC_UNORM_BLOCK8
|
||||
{conv<u8, tvec1, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec1, CONVERT_MODE_DEFAULT>::write}, // FORMAT_R_EAC_SNORM_BLOCK8
|
||||
{conv<u8, tvec2, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec2, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RG_EAC_UNORM_BLOCK16
|
||||
{conv<u8, tvec2, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec2, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RG_EAC_SNORM_BLOCK16
|
||||
|
||||
{conv<u8, tvec4, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec4, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_4x4_UNORM
|
||||
{conv<u8, tvec4, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec4, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_4x4_SRGB
|
||||
{conv<u8, tvec4, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec4, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_5x4_UNORM
|
||||
{conv<u8, tvec4, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec4, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_5x4_SRGB
|
||||
{conv<u8, tvec4, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec4, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_5x5_UNORM
|
||||
{conv<u8, tvec4, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec4, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_5x5_SRGB
|
||||
{conv<u8, tvec4, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec4, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_6x5_UNORM
|
||||
{conv<u8, tvec4, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec4, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_6x5_SRGB
|
||||
{conv<u8, tvec4, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec4, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_6x6_UNORM
|
||||
{conv<u8, tvec4, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec4, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_6x6_SRGB
|
||||
{conv<u8, tvec4, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec4, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_8x5_UNORM
|
||||
{conv<u8, tvec4, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec4, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_8x5_SRGB
|
||||
{conv<u8, tvec4, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec4, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_8x6_UNORM
|
||||
{conv<u8, tvec4, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec4, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_8x6_SRGB
|
||||
{conv<u8, tvec4, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec4, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_8x8_UNORM
|
||||
{conv<u8, tvec4, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec4, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_8x8_SRGB
|
||||
{conv<u8, tvec4, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec4, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_10x5_UNORM
|
||||
{conv<u8, tvec4, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec4, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_10x5_SRGB
|
||||
{conv<u8, tvec4, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec4, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_10x6_UNORM
|
||||
{conv<u8, tvec4, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec4, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_10x6_SRGB
|
||||
{conv<u8, tvec4, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec4, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_10x8_UNORM
|
||||
{conv<u8, tvec4, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec4, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_10x8_SRGB
|
||||
{conv<u8, tvec4, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec4, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_10x10_UNORM
|
||||
{conv<u8, tvec4, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec4, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_10x10_SRGB
|
||||
{conv<u8, tvec4, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec4, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_12x10_UNORM
|
||||
{conv<u8, tvec4, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec4, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_12x10_SRGB
|
||||
{conv<u8, tvec4, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec4, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_12x12_UNORM
|
||||
{conv<u8, tvec4, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec4, CONVERT_MODE_DEFAULT>::write}, // FORMAT_ASTC_12x12_SRGB
|
||||
|
||||
{conv<u8, tvec3, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec3, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGB_PVRTC1_8X8_UNORM_BLOCK32
|
||||
{conv<u8, tvec3, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec3, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGB_PVRTC1_8X8_SRGB_BLOCK32
|
||||
{conv<u8, tvec3, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec3, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGB_PVRTC1_16X8_UNORM_BLOCK32
|
||||
{conv<u8, tvec3, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec3, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGB_PVRTC1_16X8_SRGB_BLOCK32
|
||||
{conv<u8, tvec4, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec4, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGBA_PVRTC1_8X8_UNORM_BLOCK32
|
||||
{conv<u8, tvec4, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec4, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGBA_PVRTC1_8X8_SRGB_BLOCK32
|
||||
{conv<u8, tvec4, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec4, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGBA_PVRTC1_16X8_UNORM_BLOCK32
|
||||
{conv<u8, tvec4, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec4, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGBA_PVRTC1_16X8_SRGB_BLOCK32
|
||||
{conv<u8, tvec4, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec4, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGBA_PVRTC2_4X4_UNORM_BLOCK8
|
||||
{conv<u8, tvec4, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec4, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGBA_PVRTC2_4X4_SRGB_BLOCK8
|
||||
{conv<u8, tvec4, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec4, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGBA_PVRTC2_8X4_UNORM_BLOCK8
|
||||
{conv<u8, tvec4, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec4, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGBA_PVRTC2_8X4_SRGB_BLOCK8
|
||||
|
||||
{conv<u8, tvec3, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec3, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGB_ETC_UNORM_BLOCK8
|
||||
{conv<u8, tvec3, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec3, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGB_ATC_UNORM_BLOCK8
|
||||
{conv<u8, tvec4, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec4, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGBA_ATCA_UNORM_BLOCK16
|
||||
{conv<u8, tvec4, CONVERT_MODE_DEFAULT>::fetch, conv<u8, tvec4, CONVERT_MODE_DEFAULT>::write}, // FORMAT_RGBA_ATCI_UNORM_BLOCK16
|
||||
|
||||
{conv<u8, tvec1, CONVERT_MODE_NORM>::fetch, conv<u8, tvec1, CONVERT_MODE_NORM>::write}, // FORMAT_L8_UNORM_PACK8
|
||||
{conv<u8, tvec1, CONVERT_MODE_NORM>::fetch, conv<u8, tvec1, CONVERT_MODE_NORM>::write}, // FORMAT_A8_UNORM_PACK8
|
||||
{conv<u8, tvec2, CONVERT_MODE_NORM>::fetch, conv<u8, tvec2, CONVERT_MODE_NORM>::write}, // FORMAT_LA8_UNORM_PACK8
|
||||
{conv<u16, tvec1, CONVERT_MODE_NORM>::fetch, conv<u16, tvec1, CONVERT_MODE_NORM>::write}, // FORMAT_L16_UNORM_PACK16
|
||||
{conv<u16, tvec1, CONVERT_MODE_NORM>::fetch, conv<u16, tvec1, CONVERT_MODE_NORM>::write}, // FORMAT_A16_UNORM_PACK16
|
||||
{conv<u16, tvec2, CONVERT_MODE_NORM>::fetch, conv<u16, tvec2, CONVERT_MODE_NORM>::write}, // FORMAT_LA16_UNORM_PACK16
|
||||
|
||||
{conv<u8, tvec4, CONVERT_MODE_NORM>::fetch, conv<u8, tvec4, CONVERT_MODE_NORM>::write}, // FORMAT_BGRX8_UNORM
|
||||
{conv<u8, tvec4, CONVERT_MODE_SRGB>::fetch, conv<u8, tvec4, CONVERT_MODE_SRGB>::write}, // FORMAT_BGRX8_SRGB
|
||||
|
||||
{conv<u8, tvec3, CONVERT_MODE_332UNORM>::fetch, conv<u8, tvec3, 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
|
87
test/external/gli/core/coord.hpp
vendored
Normal file
87
test/external/gli/core/coord.hpp
vendored
Normal file
@ -0,0 +1,87 @@
|
||||
#pragma once
|
||||
|
||||
#include "../type.hpp"
|
||||
|
||||
namespace gli{
|
||||
namespace detail
|
||||
{
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
inline vecType<bool, P> in_interval(vecType<T, P> const& Value, vecType<T, P> const& Min, vecType<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
|
112
test/external/gli/core/copy.inl
vendored
Normal file
112
test/external/gli/core/copy.inl
vendored
Normal file
@ -0,0 +1,112 @@
|
||||
#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
|
267
test/external/gli/core/duplicate.inl
vendored
Normal file
267
test/external/gli/core/duplicate.inl
vendored
Normal file
@ -0,0 +1,267 @@
|
||||
namespace gli{
|
||||
namespace detail
|
||||
{
|
||||
inline void duplicate_images
|
||||
(
|
||||
texture const & Src, texture & Dst,
|
||||
texture::size_type BaseLayer, texture::size_type MaxLayer,
|
||||
texture::size_type BaseFace, texture::size_type MaxFace,
|
||||
texture::size_type BaseLevel, texture::size_type MaxLevel
|
||||
)
|
||||
{
|
||||
GLI_ASSERT(BaseLayer >= 0 && BaseLayer <= MaxLayer && MaxLayer < Src.layers());
|
||||
GLI_ASSERT(BaseFace >= 0 && BaseFace <= MaxFace && MaxFace < Src.faces());
|
||||
GLI_ASSERT(BaseLevel >= 0 && BaseLevel <= MaxLevel && MaxLevel < Src.levels());
|
||||
|
||||
texture::size_type LevelsSize = 0;
|
||||
for(texture::size_type LevelIndex = 0; LevelIndex < MaxLevel - BaseLevel + 1; ++LevelIndex)
|
||||
{
|
||||
GLI_ASSERT(Dst.size(LevelIndex) == Src.size(LevelIndex));
|
||||
LevelsSize += Dst.size(LevelIndex);
|
||||
}
|
||||
|
||||
for(texture::size_type LayerIndex = 0, LayerCount = MaxLayer - BaseLayer + 1; LayerIndex < LayerCount; ++LayerIndex)
|
||||
for(texture::size_type FaceIndex = 0, FaceCount = MaxFace - BaseFace + 1; FaceIndex < FaceCount; ++FaceIndex)
|
||||
{
|
||||
memcpy(Dst.data(LayerIndex, FaceIndex, BaseLevel), Src.data(BaseLayer + LayerIndex, BaseFace + FaceIndex, BaseLevel), LevelsSize);
|
||||
}
|
||||
}
|
||||
}//namespace detail
|
||||
|
||||
inline image duplicate(image const & Image)
|
||||
{
|
||||
image Result(Image.format(), Image.extent());
|
||||
|
||||
memcpy(Result.data(), Image.data(), Image.size());
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <>
|
||||
inline texture duplicate(texture const & Texture)
|
||||
{
|
||||
texture Duplicate(
|
||||
Texture.target(),
|
||||
Texture.format(),
|
||||
Texture.extent(),
|
||||
Texture.layers(),
|
||||
Texture.faces(),
|
||||
Texture.levels());
|
||||
|
||||
detail::duplicate_images(
|
||||
Texture, Duplicate,
|
||||
0, Texture.layers() - 1,
|
||||
0, Texture.faces() - 1,
|
||||
0, Texture.levels() - 1);
|
||||
|
||||
return Duplicate;
|
||||
}
|
||||
|
||||
template <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
|
311
test/external/gli/core/dx.inl
vendored
Normal file
311
test/external/gli/core/dx.inl
vendored
Normal file
@ -0,0 +1,311 @@
|
||||
#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
|
15
test/external/gli/core/file.hpp
vendored
Normal file
15
test/external/gli/core/file.hpp
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
/// @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"
|
19
test/external/gli/core/file.inl
vendored
Normal file
19
test/external/gli/core/file.inl
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
#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
|
23
test/external/gli/core/filter.hpp
vendored
Normal file
23
test/external/gli/core/filter.hpp
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
/// @brief Include to use filter enum, to select filtering methods.
|
||||
/// @file gli/core/filter.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace gli
|
||||
{
|
||||
/// Texture filtring modes
|
||||
enum filter
|
||||
{
|
||||
FILTER_NONE = 0,
|
||||
FILTER_NEAREST, FILTER_FIRST = FILTER_NEAREST,
|
||||
FILTER_LINEAR, FILTER_LAST = FILTER_LINEAR
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
FILTER_COUNT = FILTER_LAST - FILTER_FIRST + 1,
|
||||
FILTER_INVALID = -1
|
||||
};
|
||||
}//namespace gli
|
||||
|
||||
#include "filter.inl"
|
8
test/external/gli/core/filter.inl
vendored
Normal file
8
test/external/gli/core/filter.inl
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
namespace gli{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
}//namespace detail
|
||||
}//namespace gli
|
390
test/external/gli/core/filter_compute.hpp
vendored
Normal file
390
test/external/gli/core/filter_compute.hpp
vendored
Normal file
@ -0,0 +1,390 @@
|
||||
#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
|
||||
|
17
test/external/gli/core/flip.hpp
vendored
Normal file
17
test/external/gli/core/flip.hpp
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
#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"
|
338
test/external/gli/core/flip.inl
vendored
Normal file
338
test/external/gli/core/flip.inl
vendored
Normal file
@ -0,0 +1,338 @@
|
||||
namespace gli{
|
||||
namespace detail
|
||||
{
|
||||
inline void flip(image ImageDst, image ImageSrc, size_t BlockSize)
|
||||
{
|
||||
size_t const LineSize = BlockSize * ImageDst.extent().x;
|
||||
|
||||
for(int y = 0; y < ImageDst.extent().y; ++y)
|
||||
{
|
||||
size_t OffsetDst = LineSize * y;
|
||||
size_t OffsetSrc = ImageSrc.size() - (LineSize * (y + 1));
|
||||
|
||||
memcpy(
|
||||
ImageDst.data<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
|
376
test/external/gli/core/format.inl
vendored
Normal file
376
test/external/gli/core/format.inl
vendored
Normal file
@ -0,0 +1,376 @@
|
||||
namespace gli{
|
||||
namespace detail
|
||||
{
|
||||
enum
|
||||
{
|
||||
CAP_COMPRESSED_BIT = (1 << 0),
|
||||
CAP_COLORSPACE_SRGB_BIT = (1 << 1),
|
||||
CAP_NORMALIZED_BIT = (1 << 2),
|
||||
CAP_SCALED_BIT = (1 << 3),
|
||||
CAP_UNSIGNED_BIT = (1 << 4),
|
||||
CAP_SIGNED_BIT = (1 << 5),
|
||||
CAP_INTEGER_BIT = (1 << 6),
|
||||
CAP_FLOAT_BIT = (1 << 7),
|
||||
CAP_DEPTH_BIT = (1 << 8),
|
||||
CAP_STENCIL_BIT = (1 << 9),
|
||||
CAP_SWIZZLE_BIT = (1 << 10),
|
||||
CAP_LUMINANCE_ALPHA_BIT = (1 << 11),
|
||||
CAP_PACKED8_BIT = (1 << 12),
|
||||
CAP_PACKED16_BIT = (1 << 13),
|
||||
CAP_PACKED32_BIT = (1 << 14),
|
||||
CAP_DDS_GLI_EXT_BIT = (1 << 15)
|
||||
};
|
||||
|
||||
struct formatInfo
|
||||
{
|
||||
std::uint8_t BlockSize;
|
||||
glm::u8vec3 BlockExtent;
|
||||
std::uint8_t Component;
|
||||
swizzles Swizzles;
|
||||
std::uint16_t Flags;
|
||||
};
|
||||
|
||||
inline formatInfo const & get_format_info(format Format)
|
||||
{
|
||||
GLI_ASSERT(Format >= FORMAT_FIRST && Format <= FORMAT_LAST);
|
||||
|
||||
static formatInfo const Table[] =
|
||||
{
|
||||
{ 1, glm::u8vec3(1, 1, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_PACKED8_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_R4G4_UNORM,
|
||||
{ 2, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_PACKED16_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA4_UNORM,
|
||||
{ 2, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ALPHA), CAP_PACKED16_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_BGRA4_UNORM,
|
||||
{ 2, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_PACKED16_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_R5G6B5_UNORM,
|
||||
{ 2, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ONE), CAP_PACKED16_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_B5G6R5_UNORM,
|
||||
{ 2, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_PACKED16_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB5A1_UNORM,
|
||||
{ 2, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ALPHA), CAP_PACKED16_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_BGR5A1_UNORM,
|
||||
{ 2, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_ALPHA, SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE), CAP_PACKED16_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_A1RGB5_UNORM,
|
||||
|
||||
{ 1, glm::u8vec3(1, 1, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_R8_UNORM,
|
||||
{ 1, glm::u8vec3(1, 1, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_NORMALIZED_BIT | CAP_SIGNED_BIT}, //FORMAT_R8_SNORM,
|
||||
{ 1, glm::u8vec3(1, 1, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_SCALED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_R8_USCALED,
|
||||
{ 1, glm::u8vec3(1, 1, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_SCALED_BIT | CAP_SIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_R8_SSCALED,
|
||||
{ 1, glm::u8vec3(1, 1, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_INTEGER_BIT | CAP_UNSIGNED_BIT}, //FORMAT_R8_UINT,
|
||||
{ 1, glm::u8vec3(1, 1, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_INTEGER_BIT | CAP_SIGNED_BIT}, //FORMAT_R8_SINT,
|
||||
{ 1, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_R8_SRGB,
|
||||
|
||||
{ 2, glm::u8vec3(1, 1, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RG8_UNORM,
|
||||
{ 2, glm::u8vec3(1, 1, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_NORMALIZED_BIT | CAP_SIGNED_BIT}, //FORMAT_RG8_SNORM,
|
||||
{ 2, glm::u8vec3(1, 1, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_SCALED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RG8_USCALED,
|
||||
{ 2, glm::u8vec3(1, 1, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_SCALED_BIT | CAP_SIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RG8_SSCALED,
|
||||
{ 2, glm::u8vec3(1, 1, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_INTEGER_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RG8_UINT,
|
||||
{ 2, glm::u8vec3(1, 1, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_INTEGER_BIT | CAP_SIGNED_BIT}, //FORMAT_RG8_SINT,
|
||||
{ 2, glm::u8vec3(1, 1, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_NORMALIZED_BIT | CAP_SIGNED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RG8_SRGB,
|
||||
|
||||
{ 3, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB8_UNORM,
|
||||
{ 3, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_NORMALIZED_BIT | CAP_SIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB8_SNORM,
|
||||
{ 3, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_SCALED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB8_USCALED,
|
||||
{ 3, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_SCALED_BIT | CAP_SIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB8_SSCALED,
|
||||
{ 3, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_INTEGER_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB8_UINT,
|
||||
{ 3, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_INTEGER_BIT | CAP_SIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB8_SINT,
|
||||
{ 3, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB8_SRGB,
|
||||
|
||||
{ 3, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ONE), CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_SWIZZLE_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_BGR8_UNORM,
|
||||
{ 3, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ONE), CAP_NORMALIZED_BIT | CAP_SIGNED_BIT | CAP_SWIZZLE_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_BGR8_SNORM,
|
||||
{ 3, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ONE), CAP_SCALED_BIT | CAP_UNSIGNED_BIT | CAP_SWIZZLE_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_BGR8_USCALED,
|
||||
{ 3, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ONE), CAP_SCALED_BIT | CAP_SIGNED_BIT | CAP_SWIZZLE_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_BGR8_SSCALED,
|
||||
{ 3, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ONE), CAP_INTEGER_BIT | CAP_UNSIGNED_BIT | CAP_SWIZZLE_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_BGR8_UINT,
|
||||
{ 3, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ONE), CAP_INTEGER_BIT | CAP_SIGNED_BIT | CAP_SWIZZLE_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_BGR8_SINT,
|
||||
{ 3, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ONE), CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_SWIZZLE_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_BGR8_SRGB,
|
||||
|
||||
{ 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA8_UNORM,
|
||||
{ 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_NORMALIZED_BIT | CAP_SIGNED_BIT}, //FORMAT_RGBA8_SNORM,
|
||||
{ 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_SCALED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA8_USCALED,
|
||||
{ 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_SCALED_BIT | CAP_SIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA8_SSCALED,
|
||||
{ 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_INTEGER_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA8_UINT,
|
||||
{ 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_INTEGER_BIT | CAP_SIGNED_BIT}, //FORMAT_RGBA8_SINT,
|
||||
{ 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_COLORSPACE_SRGB_BIT}, //FORMAT_RGBA8_SRGB,
|
||||
|
||||
{ 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ALPHA), CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_SWIZZLE_BIT}, //FORMAT_BGRA8_UNORM,
|
||||
{ 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ALPHA), CAP_NORMALIZED_BIT | CAP_SIGNED_BIT | CAP_SWIZZLE_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_BGRA8_SNORM,
|
||||
{ 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ALPHA), CAP_SCALED_BIT | CAP_UNSIGNED_BIT | CAP_SWIZZLE_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_BGRA8_USCALED,
|
||||
{ 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ALPHA), CAP_SCALED_BIT | CAP_SIGNED_BIT | CAP_SWIZZLE_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_BGRA8_SSCALED,
|
||||
{ 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ALPHA), CAP_INTEGER_BIT | CAP_UNSIGNED_BIT | CAP_SWIZZLE_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_BGRA8_UINT,
|
||||
{ 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ALPHA), CAP_INTEGER_BIT | CAP_SIGNED_BIT | CAP_SWIZZLE_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_BGRA8_SINT,
|
||||
{ 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ALPHA), CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_SWIZZLE_BIT}, //FORMAT_BGRA8_SRGB,
|
||||
|
||||
{ 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ALPHA), CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_SWIZZLE_BIT | CAP_PACKED32_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA8_UNORM_PACK32,
|
||||
{ 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ALPHA), CAP_NORMALIZED_BIT | CAP_SIGNED_BIT | CAP_SWIZZLE_BIT | CAP_PACKED32_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA8_SNORM_PACK32,
|
||||
{ 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ALPHA), CAP_SCALED_BIT | CAP_UNSIGNED_BIT | CAP_SWIZZLE_BIT | CAP_PACKED32_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA8_USCALED_PACK32,
|
||||
{ 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ALPHA), CAP_SCALED_BIT | CAP_SIGNED_BIT | CAP_SWIZZLE_BIT | CAP_PACKED32_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA8_SSCALED_PACK32,
|
||||
{ 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ALPHA), CAP_INTEGER_BIT | CAP_UNSIGNED_BIT | CAP_SWIZZLE_BIT | CAP_PACKED32_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA8_UINT_PACK32,
|
||||
{ 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ALPHA), CAP_INTEGER_BIT | CAP_SIGNED_BIT | CAP_SWIZZLE_BIT | CAP_PACKED32_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA8_SINT_PACK32,
|
||||
{ 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ALPHA), CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_SWIZZLE_BIT | CAP_PACKED32_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA8_SRGB_PACK32,
|
||||
|
||||
{ 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_PACKED32_BIT}, //FORMAT_RGB10A2_UNORM,
|
||||
{ 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_NORMALIZED_BIT | CAP_SIGNED_BIT | CAP_PACKED32_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB10A2_SNORM,
|
||||
{ 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_SCALED_BIT | CAP_UNSIGNED_BIT | CAP_PACKED32_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB10A2_USCALE,
|
||||
{ 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_SCALED_BIT | CAP_SIGNED_BIT | CAP_PACKED32_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB10A2_SSCALE,
|
||||
{ 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_INTEGER_BIT | CAP_UNSIGNED_BIT | CAP_PACKED32_BIT}, //FORMAT_RGB10A2_UINT,
|
||||
{ 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_INTEGER_BIT | CAP_SIGNED_BIT | CAP_PACKED32_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB10A2_SINT,
|
||||
|
||||
{ 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ALPHA), CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_PACKED32_BIT | CAP_SWIZZLE_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_BGR10A2_UNORM,
|
||||
{ 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ALPHA), CAP_NORMALIZED_BIT | CAP_SIGNED_BIT | CAP_PACKED32_BIT | CAP_SWIZZLE_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_BGR10A2_SNORM,
|
||||
{ 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ALPHA), CAP_SCALED_BIT | CAP_UNSIGNED_BIT | CAP_PACKED32_BIT | CAP_SWIZZLE_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_BGR10A2_USCALE,
|
||||
{ 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ALPHA), CAP_SCALED_BIT | CAP_SIGNED_BIT | CAP_PACKED32_BIT | CAP_SWIZZLE_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_BGR10A2_SSCALE,
|
||||
{ 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ALPHA), CAP_INTEGER_BIT | CAP_UNSIGNED_BIT | CAP_PACKED32_BIT | CAP_SWIZZLE_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_BGR10A2_UINT,
|
||||
{ 4, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ALPHA), CAP_INTEGER_BIT | CAP_SIGNED_BIT | CAP_PACKED32_BIT | CAP_SWIZZLE_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_BGR10A2_SINT,
|
||||
|
||||
{ 2, glm::u8vec3(1, 1, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_R16_UNORM_PACK16,
|
||||
{ 2, glm::u8vec3(1, 1, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_NORMALIZED_BIT | CAP_SIGNED_BIT}, //FORMAT_R16_SNORM_PACK16,
|
||||
{ 2, glm::u8vec3(1, 1, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_SCALED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_R16_USCALE,
|
||||
{ 2, glm::u8vec3(1, 1, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_SCALED_BIT | CAP_SIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_R16_SSCALE,
|
||||
{ 2, glm::u8vec3(1, 1, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_INTEGER_BIT | CAP_UNSIGNED_BIT}, //FORMAT_R16_UINT_PACK16,
|
||||
{ 2, glm::u8vec3(1, 1, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_INTEGER_BIT | CAP_SIGNED_BIT}, //FORMAT_R16_SINT_PACK16,
|
||||
{ 2, glm::u8vec3(1, 1, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_FLOAT_BIT | CAP_SIGNED_BIT}, //FORMAT_R16_SFLOAT_PACK16,
|
||||
|
||||
{ 4, glm::u8vec3(1, 1, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RG16_UNORM_PACK16,
|
||||
{ 4, glm::u8vec3(1, 1, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_NORMALIZED_BIT | CAP_SIGNED_BIT}, //FORMAT_RG16_SNORM_PACK16,
|
||||
{ 4, glm::u8vec3(1, 1, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_SCALED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RG16_USCALE,
|
||||
{ 4, glm::u8vec3(1, 1, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_SCALED_BIT | CAP_SIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RG16_SSCALE,
|
||||
{ 4, glm::u8vec3(1, 1, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_INTEGER_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RG16_UINT_PACK16,
|
||||
{ 4, glm::u8vec3(1, 1, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_INTEGER_BIT | CAP_SIGNED_BIT}, //FORMAT_RG16_SINT_PACK16,
|
||||
{ 4, glm::u8vec3(1, 1, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_FLOAT_BIT | CAP_SIGNED_BIT}, //FORMAT_RG16_SFLOAT_PACK16,
|
||||
|
||||
{ 6, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB16_UNORM_PACK16,
|
||||
{ 6, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_NORMALIZED_BIT | CAP_SIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB16_SNORM_PACK16,
|
||||
{ 6, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_SCALED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB16_USCALE,
|
||||
{ 6, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_SCALED_BIT | CAP_SIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB16_SSCALE,
|
||||
{ 6, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_INTEGER_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB16_UINT_PACK16,
|
||||
{ 6, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_INTEGER_BIT | CAP_SIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB16_SINT_PACK16,
|
||||
{ 6, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_FLOAT_BIT | CAP_SIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB16_SFLOAT_PACK16,
|
||||
|
||||
{ 8, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA16_UNORM_PACK16,
|
||||
{ 8, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_NORMALIZED_BIT | CAP_SIGNED_BIT}, //FORMAT_RGBA16_SNORM_PACK16,
|
||||
{ 8, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_SCALED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA16_USCALE,
|
||||
{ 8, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_SCALED_BIT | CAP_SIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA16_SSCALE,
|
||||
{ 8, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_INTEGER_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA16_UINT_PACK16,
|
||||
{ 8, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_INTEGER_BIT | CAP_SIGNED_BIT}, //FORMAT_RGBA16_SINT_PACK16,
|
||||
{ 8, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_FLOAT_BIT | CAP_SIGNED_BIT}, //FORMAT_RGBA16_SFLOAT_PACK16,
|
||||
|
||||
{ 4, glm::u8vec3(1, 1, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_INTEGER_BIT | CAP_UNSIGNED_BIT}, //FORMAT_R32_UINT_PACK32,
|
||||
{ 4, glm::u8vec3(1, 1, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_INTEGER_BIT | CAP_SIGNED_BIT}, //FORMAT_R32_SINT_PACK32,
|
||||
{ 4, glm::u8vec3(1, 1, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_FLOAT_BIT | CAP_SIGNED_BIT}, //FORMAT_R32_SFLOAT_PACK32,
|
||||
|
||||
{ 8, glm::u8vec3(1, 1, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_INTEGER_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RG32_UINT_PACK32,
|
||||
{ 8, glm::u8vec3(1, 1, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_INTEGER_BIT | CAP_SIGNED_BIT}, //FORMAT_RG32_SINT_PACK32,
|
||||
{ 8, glm::u8vec3(1, 1, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_FLOAT_BIT | CAP_SIGNED_BIT}, //FORMAT_RG32_SFLOAT_PACK32,
|
||||
|
||||
{ 12, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_INTEGER_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGB32_UINT_PACK32,
|
||||
{ 12, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_INTEGER_BIT | CAP_SIGNED_BIT}, //FORMAT_RGB32_SINT_PACK32,
|
||||
{ 12, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_FLOAT_BIT | CAP_SIGNED_BIT}, //FORMAT_RGB32_SFLOAT_PACK32,
|
||||
|
||||
{ 16, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_INTEGER_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA32_UINT_PACK32,
|
||||
{ 16, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_INTEGER_BIT | CAP_SIGNED_BIT}, //FORMAT_RGBA32_SINT_PACK32,
|
||||
{ 16, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_FLOAT_BIT | CAP_SIGNED_BIT}, //FORMAT_RGBA32_SFLOAT_PACK32,
|
||||
|
||||
{ 8, glm::u8vec3(1, 1, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_INTEGER_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_R64_UINT_PACK64,
|
||||
{ 8, glm::u8vec3(1, 1, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_INTEGER_BIT | CAP_SIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_R64_SINT_PACK64,
|
||||
{ 8, glm::u8vec3(1, 1, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_FLOAT_BIT | CAP_SIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_R64_SFLOAT_PACK64,
|
||||
|
||||
{ 16, glm::u8vec3(1, 1, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_INTEGER_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RG64_UINT_PACK64,
|
||||
{ 16, glm::u8vec3(1, 1, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_INTEGER_BIT | CAP_SIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RG64_SINT_PACK64,
|
||||
{ 16, glm::u8vec3(1, 1, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_FLOAT_BIT | CAP_SIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RG64_SFLOAT_PACK64,
|
||||
|
||||
{ 24, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_INTEGER_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB64_UINT_PACK64,
|
||||
{ 24, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_INTEGER_BIT | CAP_SIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB64_SINT_PACK64,
|
||||
{ 24, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_FLOAT_BIT | CAP_SIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB64_SFLOAT_PACK64,
|
||||
|
||||
{ 32, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_INTEGER_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA64_UINT_PACK64,
|
||||
{ 32, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_INTEGER_BIT | CAP_SIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA64_SINT_PACK64,
|
||||
{ 32, glm::u8vec3(1, 1, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_FLOAT_BIT | CAP_SIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA64_SFLOAT_PACK64,
|
||||
|
||||
{ 4, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_PACKED32_BIT | CAP_FLOAT_BIT | CAP_SIGNED_BIT}, //FORMAT_RG11B10_UFLOAT_PACK32,
|
||||
{ 4, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_PACKED32_BIT | CAP_FLOAT_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGB9E5_UFLOAT_PACK32,
|
||||
|
||||
{ 2, glm::u8vec3(1, 1, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_DEPTH_BIT | CAP_INTEGER_BIT}, //FORMAT_D16_UNORM_PACK16,
|
||||
{ 4, glm::u8vec3(1, 1, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_DEPTH_BIT | CAP_INTEGER_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_D24_UNORM_PACK32,
|
||||
{ 4, glm::u8vec3(1, 1, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_DEPTH_BIT | CAP_FLOAT_BIT}, //FORMAT_D32_UFLOAT_PACK32,
|
||||
{ 1, glm::u8vec3(1, 1, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_DEPTH_BIT | CAP_STENCIL_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_S8_UNORM_PACK8,
|
||||
{ 3, glm::u8vec3(1, 1, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_DEPTH_BIT | CAP_INTEGER_BIT | CAP_STENCIL_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_D16_UNORM_S8_UINT_PACK32,
|
||||
{ 4, glm::u8vec3(1, 1, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_DEPTH_BIT | CAP_INTEGER_BIT | CAP_STENCIL_BIT}, //FORMAT_D24_UNORM_S8_UINT_PACK32,
|
||||
{ 5, glm::u8vec3(1, 1, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_DEPTH_BIT | CAP_FLOAT_BIT | CAP_STENCIL_BIT}, //FORMAT_D32_SFLOAT_S8_UINT_PACK64,
|
||||
|
||||
{ 8, glm::u8vec3(4, 4, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB_DXT1_UNORM_BLOCK8,
|
||||
{ 8, glm::u8vec3(4, 4, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB_DXT1_SRGB_BLOCK8,
|
||||
{ 8, glm::u8vec3(4, 4, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_DXT1_UNORM_BLOCK8,
|
||||
{ 8, glm::u8vec3(4, 4, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_DXT1_SRGB_BLOCK8,
|
||||
{ 16, glm::u8vec3(4, 4, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_DXT3_UNORM_BLOCK16,
|
||||
{ 16, glm::u8vec3(4, 4, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_DXT3_SRGB_BLOCK16,
|
||||
{ 16, glm::u8vec3(4, 4, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_DXT5_UNORM_BLOCK16,
|
||||
{ 16, glm::u8vec3(4, 4, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_DXT5_SRGB_BLOCK16,
|
||||
{ 8, glm::u8vec3(4, 4, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_R_ATI1N_UNORM_BLOCK8,
|
||||
{ 8, glm::u8vec3(4, 4, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_SIGNED_BIT}, //FORMAT_R_ATI1N_SNORM_BLOCK8,
|
||||
{ 16, glm::u8vec3(4, 4, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RG_ATI2N_UNORM_BLOCK16,
|
||||
{ 16, glm::u8vec3(4, 4, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_SIGNED_BIT}, //FORMAT_RG_ATI2N_SNORM_BLOCK16,
|
||||
{ 16, glm::u8vec3(4, 4, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_COMPRESSED_BIT | CAP_FLOAT_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGB_BP_UFLOAT_BLOCK16,
|
||||
{ 16, glm::u8vec3(4, 4, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_COMPRESSED_BIT | CAP_FLOAT_BIT | CAP_SIGNED_BIT}, //FORMAT_RGB_BP_SFLOAT_BLOCK16,
|
||||
{ 16, glm::u8vec3(4, 4, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_BP_UNORM_BLOCK16,
|
||||
{ 16, glm::u8vec3(4, 4, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_BP_SRGB_BLOCK16,
|
||||
|
||||
{ 8, glm::u8vec3(4, 4, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB_ETC2_UNORM_BLOCK8,
|
||||
{ 8, glm::u8vec3(4, 4, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB_ETC2_SRGB_BLOCK8,
|
||||
{ 8, glm::u8vec3(4, 4, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA_ETC2_UNORM_BLOCK8,
|
||||
{ 8, glm::u8vec3(4, 4, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA_ETC2_SRGB_BLOCK8,
|
||||
{ 16, glm::u8vec3(4, 4, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA_ETC2_UNORM_BLOCK16,
|
||||
{ 16, glm::u8vec3(4, 4, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA_ETC2_SRGB_BLOCK16,
|
||||
{ 8, glm::u8vec3(4, 4, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_R_EAC_UNORM_BLOCK8,
|
||||
{ 8, glm::u8vec3(4, 4, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_SIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_R_EAC_SNORM_BLOCK8,
|
||||
{ 16, glm::u8vec3(4, 4, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RG_EAC_UNORM_BLOCK16,
|
||||
{ 16, glm::u8vec3(4, 4, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_SIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RG_EAC_SNORM_BLOCK16,
|
||||
|
||||
{ 16, glm::u8vec3(4, 4, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_4X4_UNORM_BLOCK16,
|
||||
{ 16, glm::u8vec3(4, 4, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_4X4_SRGB_BLOCK16,
|
||||
{ 16, glm::u8vec3(5, 4, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_5X4_UNORM_BLOCK16,
|
||||
{ 16, glm::u8vec3(5, 4, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_5X4_SRGB_BLOCK16,
|
||||
{ 16, glm::u8vec3(5, 5, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_5X5_UNORM_BLOCK16,
|
||||
{ 16, glm::u8vec3(5, 5, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_5X5_SRGB_BLOCK16,
|
||||
{ 16, glm::u8vec3(6, 5, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_6X5_UNORM_BLOCK16,
|
||||
{ 16, glm::u8vec3(6, 5, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_6X5_SRGB_BLOCK16,
|
||||
{ 16, glm::u8vec3(6, 6, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_6X6_UNORM_BLOCK16,
|
||||
{ 16, glm::u8vec3(6, 6, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_6X6_SRGB_BLOCK16,
|
||||
{ 16, glm::u8vec3(8, 5, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_8X5_UNORM_BLOCK16,
|
||||
{ 16, glm::u8vec3(8, 5, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_8X5_SRGB_BLOCK16,
|
||||
{ 16, glm::u8vec3(8, 6, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_8X6_UNORM_BLOCK16,
|
||||
{ 16, glm::u8vec3(8, 6, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_8X6_SRGB_BLOCK16,
|
||||
{ 16, glm::u8vec3(8, 8, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_8X8_UNORM_BLOCK16,
|
||||
{ 16, glm::u8vec3(8, 8, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_8X8_SRGB_BLOCK16,
|
||||
{ 16, glm::u8vec3(10, 5, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_10X5_UNORM_BLOCK16,
|
||||
{ 16, glm::u8vec3(10, 5, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_10X5_SRGB_BLOCK16,
|
||||
{ 16, glm::u8vec3(10, 6, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_10X6_UNORM_BLOCK16,
|
||||
{ 16, glm::u8vec3(10, 6, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_10X6_SRGB_BLOCK16,
|
||||
{ 16, glm::u8vec3(10, 8, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_10X8_UNORM_BLOCK16,
|
||||
{ 16, glm::u8vec3(10, 8, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_10X8_SRGB_BLOCK16,
|
||||
{ 16, glm::u8vec3(10, 10, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_10X10_UNORM_BLOCK16,
|
||||
{ 16, glm::u8vec3(10, 10, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_10X10_SRGB_BLOCK16,
|
||||
{ 16, glm::u8vec3(12, 10, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_12X10_UNORM_BLOCK16,
|
||||
{ 16, glm::u8vec3(12, 10, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_12X10_SRGB_BLOCK16,
|
||||
{ 16, glm::u8vec3(12, 12, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_12X12_UNORM_BLOCK16,
|
||||
{ 16, glm::u8vec3(12, 12, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT}, //FORMAT_RGBA_ASTC_12X12_SRGB_BLOCK16,
|
||||
|
||||
{ 32, glm::u8vec3(8, 8, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB_PVRTC1_8X8_UNORM_BLOCK32,
|
||||
{ 32, glm::u8vec3(8, 8, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB_PVRTC1_8X8_SRGB_BLOCK32,
|
||||
{ 32, glm::u8vec3(16, 8, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB_PVRTC1_16X8_UNORM_BLOCK32,
|
||||
{ 32, glm::u8vec3(16, 8, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB_PVRTC1_16X8_SRGB_BLOCK32,
|
||||
{ 32, glm::u8vec3(8, 8, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA_PVRTC1_8X8_UNORM_BLOCK32,
|
||||
{ 32, glm::u8vec3(8, 8, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA_PVRTC1_8X8_SRGB_BLOCK32,
|
||||
{ 32, glm::u8vec3(16, 8, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA_PVRTC1_16X8_UNORM_BLOCK32,
|
||||
{ 32, glm::u8vec3(16, 8, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA_PVRTC1_16X8_SRGB_BLOCK32,
|
||||
{ 8, glm::u8vec3(4, 4, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA_PVRTC2_4X4_UNORM_BLOCK8,
|
||||
{ 8, glm::u8vec3(4, 4, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA_PVRTC2_4X4_SRGB_BLOCK8,
|
||||
{ 8, glm::u8vec3(8, 4, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA_PVRTC2_8X4_UNORM_BLOCK8,
|
||||
{ 8, glm::u8vec3(8, 4, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_COLORSPACE_SRGB_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA_PVRTC2_8X4_SRGB_BLOCK8,
|
||||
|
||||
{ 8, glm::u8vec3(4, 4, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB_ETC_UNORM_BLOCK8,
|
||||
{ 8, glm::u8vec3(4, 4, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGB_ATC_UNORM_BLOCK8,
|
||||
{ 16, glm::u8vec3(4, 4, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA_ATCA_UNORM_BLOCK16,
|
||||
{ 16, glm::u8vec3(4, 4, 1), 4, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ALPHA), CAP_COMPRESSED_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RGBA_ATCI_UNORM_BLOCK16,
|
||||
|
||||
{ 1, glm::u8vec3(1, 1, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_RED, SWIZZLE_RED, SWIZZLE_ONE), CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_LUMINANCE_ALPHA_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_L8_UNORM_PACK8,
|
||||
{ 1, glm::u8vec3(1, 1, 1), 1, swizzles(SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_RED), CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_LUMINANCE_ALPHA_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_A8_UNORM_PACK8,
|
||||
{ 2, glm::u8vec3(1, 1, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_RED, SWIZZLE_RED, SWIZZLE_GREEN), CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_LUMINANCE_ALPHA_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_LA8_UNORM_PACK8,
|
||||
{ 2, glm::u8vec3(1, 1, 1), 1, swizzles(SWIZZLE_RED, SWIZZLE_RED, SWIZZLE_RED, SWIZZLE_ONE), CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_LUMINANCE_ALPHA_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_L16_UNORM_PACK16,
|
||||
{ 2, glm::u8vec3(1, 1, 1), 1, swizzles(SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_RED), CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_LUMINANCE_ALPHA_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_A16_UNORM_PACK16,
|
||||
{ 4, glm::u8vec3(1, 1, 1), 2, swizzles(SWIZZLE_RED, SWIZZLE_RED, SWIZZLE_RED, SWIZZLE_GREEN), CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_LUMINANCE_ALPHA_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_LA16_UNORM_PACK16,
|
||||
|
||||
{ 4, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ONE), CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_SWIZZLE_BIT}, //FORMAT_BGR8_UNORM_PACK32,
|
||||
{ 4, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_BLUE, SWIZZLE_GREEN, SWIZZLE_RED, SWIZZLE_ONE), CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_SWIZZLE_BIT | CAP_COLORSPACE_SRGB_BIT}, //FORMAT_BGR8_SRGB_PACK32,
|
||||
|
||||
{ 1, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_PACKED8_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RG3B2_UNORM_PACK8,
|
||||
};
|
||||
|
||||
GLM_STATIC_ASSERT(sizeof(Table) / sizeof(Table[0]) == FORMAT_COUNT, "GLI error: format descriptor list doesn't match number of supported formats");
|
||||
GLI_ASSERT(Format != static_cast<format>(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
|
25
test/external/gli/core/generate_mipmaps.hpp
vendored
25
test/external/gli/core/generate_mipmaps.hpp
vendored
@ -1,25 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2010-09-27
|
||||
// Updated : 2010-09-27
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/core/generate_mipmaps.hpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLI_GENERATE_MIPMAPS_INCLUDED
|
||||
#define GLI_GENERATE_MIPMAPS_INCLUDED
|
||||
|
||||
#include "texture2d.hpp"
|
||||
|
||||
namespace gli
|
||||
{
|
||||
texture2D generateMipmaps(
|
||||
texture2D const & Texture,
|
||||
texture2D::level_type const & BaseLevel);
|
||||
|
||||
}//namespace gli
|
||||
|
||||
#include "generate_mipmaps.inl"
|
||||
|
||||
#endif//GLI_GENERATE_MIPMAPS_INCLUDED
|
176
test/external/gli/core/generate_mipmaps.inl
vendored
176
test/external/gli/core/generate_mipmaps.inl
vendored
@ -1,69 +1,127 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2010-09-27
|
||||
// Updated : 2010-09-27
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/core/generate_mipmaps.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#include "../sampler1d.hpp"
|
||||
#include "../sampler1d_array.hpp"
|
||||
#include "../sampler2d.hpp"
|
||||
#include "../sampler2d_array.hpp"
|
||||
#include "../sampler3d.hpp"
|
||||
#include "../sampler_cube.hpp"
|
||||
#include "../sampler_cube_array.hpp"
|
||||
|
||||
namespace gli
|
||||
{
|
||||
/*
|
||||
inline texture2D generateMipmaps
|
||||
(
|
||||
texture2D const & Image,
|
||||
texture2D::level_type const & BaseLevel
|
||||
)
|
||||
inline texture1d generate_mipmaps(
|
||||
texture1d const& Texture,
|
||||
texture1d::size_type BaseLevel, texture1d::size_type MaxLevel,
|
||||
filter Minification)
|
||||
{
|
||||
assert(BaseLevel < Image.levels());
|
||||
texture2D::format_type Format = Image[BaseLevel].format();
|
||||
|
||||
assert(Format == R8U || Format == RG8U || Format == RGB8U || Format == RGBA8U);
|
||||
texture2D::level_type Levels = std::size_t(glm::log2(float(glm::compMax(Image[0].dimensions())))) + 1;
|
||||
|
||||
texture2D Result(Levels);
|
||||
for(texture2D::level_type Level = 0; Level <= BaseLevel; ++Level)
|
||||
Result[Level] = detail::duplicate(Image[Level]);
|
||||
|
||||
for(texture2D::level_type Level = BaseLevel; Level < Levels - 1; ++Level)
|
||||
{
|
||||
std::size_t BaseWidth = Result[Level + 0].dimensions().x;
|
||||
texture2D::value_type * DataSrc = Result[Level + 0].data();
|
||||
|
||||
texture2D::dimensions_type LevelDimensions = Result[Level + 0].dimensions() >> texture2D::dimensions_type(1);
|
||||
LevelDimensions = glm::max(LevelDimensions, texture2D::dimensions_type(1));
|
||||
texture2D::size_type Components = Result[Level + 0].components();
|
||||
|
||||
texture2D::data_type DataDst(glm::compMul(LevelDimensions) * Components);
|
||||
|
||||
for(std::size_t j = 0; j < LevelDimensions.y; ++j)
|
||||
for(std::size_t i = 0; i < LevelDimensions.x; ++i)
|
||||
for(std::size_t c = 0; c < Components; ++c)
|
||||
{
|
||||
std::size_t x = (i << 1);
|
||||
std::size_t y = (j << 1);
|
||||
|
||||
std::size_t Index00 = ((x + 0) + (y + 0) * BaseWidth) * Components + c;
|
||||
std::size_t Index01 = ((x + 0) + (y + 1) * BaseWidth) * Components + c;
|
||||
std::size_t Index11 = ((x + 1) + (y + 1) * BaseWidth) * Components + c;
|
||||
std::size_t Index10 = ((x + 1) + (y + 0) * BaseWidth) * Components + c;
|
||||
|
||||
glm::u32 Data00 = reinterpret_cast<texture2D::value_type*>(DataSrc)[Index00];
|
||||
glm::u32 Data01 = reinterpret_cast<texture2D::value_type*>(DataSrc)[Index01];
|
||||
glm::u32 Data11 = reinterpret_cast<texture2D::value_type*>(DataSrc)[Index11];
|
||||
glm::u32 Data10 = reinterpret_cast<texture2D::value_type*>(DataSrc)[Index10];
|
||||
|
||||
texture2D::value_type Result = (Data00 + Data01 + Data11 + Data10) >> 2;
|
||||
texture2D::value_type * Data = reinterpret_cast<texture2D::value_type*>(DataDst.data());
|
||||
|
||||
*(Data + ((i + j * LevelDimensions.x) * Components + c)) = Result;
|
||||
fsampler1D Sampler(Texture, WRAP_CLAMP_TO_EDGE);
|
||||
Sampler.generate_mipmaps(BaseLevel, MaxLevel, Minification);
|
||||
return Sampler();
|
||||
}
|
||||
|
||||
Result[Level + 1] = image2D(LevelDimensions, Format, DataDst);
|
||||
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();
|
||||
}
|
||||
|
||||
return Result;
|
||||
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
|
||||
|
366
test/external/gli/core/gl.inl
vendored
Normal file
366
test/external/gli/core/gl.inl
vendored
Normal file
@ -0,0 +1,366 @@
|
||||
#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
|
251
test/external/gli/core/image.inl
vendored
Normal file
251
test/external/gli/core/image.inl
vendored
Normal file
@ -0,0 +1,251 @@
|
||||
namespace gli{
|
||||
namespace detail
|
||||
{
|
||||
inline size_t texel_linear_aAdressing
|
||||
(
|
||||
extent1d const& Extent,
|
||||
extent1d const& TexelCoord
|
||||
)
|
||||
{
|
||||
GLI_ASSERT(glm::all(glm::lessThan(TexelCoord, Extent)));
|
||||
|
||||
return static_cast<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
|
169
test/external/gli/core/image2d.hpp
vendored
169
test/external/gli/core/image2d.hpp
vendored
@ -1,169 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2011-04-05
|
||||
// Updated : 2011-04-05
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/core/image2d.hpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLI_CORE_IMAGE2D_INCLUDED
|
||||
#define GLI_CORE_IMAGE2D_INCLUDED
|
||||
|
||||
// STD
|
||||
#include <vector>
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
|
||||
// GLM
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtx/number_precision.hpp>
|
||||
#include <glm/gtx/raw_data.hpp>
|
||||
#include <glm/gtx/gradient_paint.hpp>
|
||||
#include <glm/gtx/component_wise.hpp>
|
||||
|
||||
namespace gli
|
||||
{
|
||||
enum format
|
||||
{
|
||||
FORMAT_NULL,
|
||||
|
||||
// Unsigned integer formats
|
||||
R8U,
|
||||
RG8U,
|
||||
RGB8U,
|
||||
RGBA8U,
|
||||
|
||||
R16U,
|
||||
RG16U,
|
||||
RGB16U,
|
||||
RGBA16U,
|
||||
|
||||
R32U,
|
||||
RG32U,
|
||||
RGB32U,
|
||||
RGBA32U,
|
||||
|
||||
// Signed integer formats
|
||||
R8I,
|
||||
RG8I,
|
||||
RGB8I,
|
||||
RGBA8I,
|
||||
|
||||
R16I,
|
||||
RG16I,
|
||||
RGB16I,
|
||||
RGBA16I,
|
||||
|
||||
R32I,
|
||||
RG32I,
|
||||
RGB32I,
|
||||
RGBA32I,
|
||||
|
||||
// Floating formats
|
||||
R16F,
|
||||
RG16F,
|
||||
RGB16F,
|
||||
RGBA16F,
|
||||
|
||||
R32F,
|
||||
RG32F,
|
||||
RGB32F,
|
||||
RGBA32F,
|
||||
|
||||
// Packed formats
|
||||
RGBE8,
|
||||
RGB9E5,
|
||||
RG11B10F,
|
||||
R5G6B5,
|
||||
RGBA4,
|
||||
RGB10A2,
|
||||
|
||||
// Depth formats
|
||||
D16,
|
||||
D24X8,
|
||||
D24S8,
|
||||
D32F,
|
||||
D32FS8X24,
|
||||
|
||||
// Compressed formats
|
||||
DXT1,
|
||||
DXT3,
|
||||
DXT5,
|
||||
ATI1N_UNORM,
|
||||
ATI1N_SNORM,
|
||||
ATI2N_UNORM,
|
||||
ATI2N_SNORM,
|
||||
BP_UF16,
|
||||
BP_SF16,
|
||||
BP,
|
||||
|
||||
FORMAT_MAX
|
||||
};
|
||||
|
||||
enum size_type
|
||||
{
|
||||
LINEAR_SIZE,
|
||||
BLOCK_SIZE,
|
||||
BIT_PER_PIXEL,
|
||||
COMPONENT
|
||||
};
|
||||
|
||||
class image2D
|
||||
{
|
||||
public:
|
||||
typedef glm::uvec2 dimensions_type;
|
||||
typedef glm::vec2 texcoord_type;
|
||||
typedef glm::uint32 size_type;
|
||||
typedef glm::byte value_type;
|
||||
typedef gli::format format_type;
|
||||
typedef std::vector<value_type> data_type;
|
||||
|
||||
public:
|
||||
image2D();
|
||||
image2D(
|
||||
image2D const & Image);
|
||||
|
||||
explicit image2D(
|
||||
dimensions_type const & Dimensions,
|
||||
format_type const & Format);
|
||||
|
||||
template <typename genType>
|
||||
explicit image2D(
|
||||
dimensions_type const & Dimensions,
|
||||
format_type const & Format,
|
||||
genType const & Value);
|
||||
|
||||
explicit image2D(
|
||||
dimensions_type const & Dimensions,
|
||||
format_type const & Format,
|
||||
std::vector<value_type> const & Data);
|
||||
|
||||
~image2D();
|
||||
|
||||
template <typename genType>
|
||||
void setPixel(
|
||||
dimensions_type const & TexelCoord,
|
||||
genType const & TexelData);
|
||||
|
||||
size_type value_size() const;
|
||||
size_type capacity() const;
|
||||
dimensions_type dimensions() const;
|
||||
size_type components() const;
|
||||
format_type format() const;
|
||||
|
||||
value_type * data();
|
||||
value_type const * const data() const;
|
||||
|
||||
private:
|
||||
data_type Data;
|
||||
dimensions_type Dimensions;
|
||||
format_type Format;
|
||||
};
|
||||
|
||||
}//namespace gli
|
||||
|
||||
#include "image2d.inl"
|
||||
|
||||
#endif//GLI_CORE_IMAGE2D_INCLUDED
|
229
test/external/gli/core/image2d.inl
vendored
229
test/external/gli/core/image2d.inl
vendored
@ -1,229 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2011-04-05
|
||||
// Updated : 2011-04-05
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/core/image2d.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace gli
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
struct format_desc
|
||||
{
|
||||
image2D::size_type BlockSize;
|
||||
image2D::size_type BBP;
|
||||
image2D::size_type Component;
|
||||
};
|
||||
|
||||
inline format_desc getFormatInfo(format const & Format)
|
||||
{
|
||||
format_desc Desc[FORMAT_MAX] =
|
||||
{
|
||||
{ 0, 0, 0}, //FORMAT_NULL
|
||||
|
||||
// Unsigned integer formats
|
||||
{ 1, 8, 1}, //R8U,
|
||||
{ 2, 16, 2}, //RG8U,
|
||||
{ 3, 24, 3}, //RGB8U,
|
||||
{ 4, 32, 4}, //RGBA8U,
|
||||
|
||||
{ 2, 16, 1}, //R16U,
|
||||
{ 4, 32, 2}, //RG16U,
|
||||
{ 6, 48, 3}, //RGB16U,
|
||||
{ 8, 64, 4}, //RGBA16U,
|
||||
|
||||
{ 4, 32, 1}, //R32U,
|
||||
{ 8, 64, 2}, //RG32U,
|
||||
{ 12, 96, 3}, //RGB32U,
|
||||
{ 16, 128, 4}, //RGBA32U,
|
||||
|
||||
//// Signed integer formats
|
||||
{ 4, 32, 1}, //R8I,
|
||||
{ 8, 64, 2}, //RG8I,
|
||||
{ 12, 96, 3}, //RGB8I,
|
||||
{ 16, 128, 4}, //RGBA8I,
|
||||
|
||||
{ 2, 16, 1}, //R16I,
|
||||
{ 4, 32, 2}, //RG16I,
|
||||
{ 6, 48, 3}, //RGB16I,
|
||||
{ 8, 64, 4}, //RGBA16I,
|
||||
|
||||
{ 4, 32, 1}, //R32I,
|
||||
{ 8, 64, 2}, //RG32I,
|
||||
{ 12, 96, 3}, //RGB32I,
|
||||
{ 16, 128, 4}, //RGBA32I,
|
||||
|
||||
//// Floating formats
|
||||
{ 2, 16, 1}, //R16F,
|
||||
{ 4, 32, 2}, //RG16F,
|
||||
{ 6, 48, 3}, //RGB16F,
|
||||
{ 8, 64, 4}, //RGBA16F,
|
||||
|
||||
{ 4, 32, 1}, //R32F,
|
||||
{ 8, 64, 2}, //RG32F,
|
||||
{ 12, 96, 3}, //RGB32F,
|
||||
{ 16, 128, 4}, //RGBA32F,
|
||||
|
||||
//// Packed formats
|
||||
{ 4, 32, 3}, //RGBE8,
|
||||
{ 4, 32, 3}, //RGB9E5,
|
||||
{ 4, 32, 3}, //RG11B10F,
|
||||
{ 2, 16, 3}, //R5G6B5,
|
||||
{ 2, 16, 4}, //RGBA4,
|
||||
{ 4, 32, 3}, //RGB10A2,
|
||||
|
||||
//// Depth formats
|
||||
{ 2, 16, 1}, //D16,
|
||||
{ 4, 32, 1}, //D24X8,
|
||||
{ 4, 32, 2}, //D24S8,
|
||||
{ 4, 32, 1}, //D32F,
|
||||
{ 8, 64, 2}, //D32FS8X24,
|
||||
|
||||
//// Compressed formats
|
||||
{ 8, 4, 4}, //DXT1,
|
||||
{ 16, 8, 4}, //DXT3,
|
||||
{ 16, 8, 4}, //DXT5,
|
||||
{ 8, 4, 1}, //ATI1N_UNORM,
|
||||
{ 8, 4, 1}, //ATI1N_SNORM,
|
||||
{ 16, 8, 2}, //ATI2N_UNORM,
|
||||
{ 16, 8, 2}, //ATI2N_SNORM,
|
||||
{ 16, 8, 3}, //BP_UF16,
|
||||
{ 16, 8, 3}, //BP_SF16,
|
||||
{ 16, 8, 4}, //BP,
|
||||
};
|
||||
|
||||
return Desc[Format];
|
||||
}
|
||||
|
||||
inline image2D::size_type sizeBlock
|
||||
(
|
||||
format const & Format
|
||||
)
|
||||
{
|
||||
return getFormatInfo(Format).BlockSize;
|
||||
}
|
||||
|
||||
inline image2D::size_type sizeBitPerPixel
|
||||
(
|
||||
format const & Format
|
||||
)
|
||||
{
|
||||
return getFormatInfo(Format).BBP;
|
||||
}
|
||||
|
||||
inline image2D::size_type sizeComponent
|
||||
(
|
||||
format const & Format
|
||||
)
|
||||
{
|
||||
return getFormatInfo(Format).Component;
|
||||
}
|
||||
|
||||
inline image2D::size_type sizeLinear
|
||||
(
|
||||
image2D const & Image
|
||||
)
|
||||
{
|
||||
image2D::dimensions_type Dimension = Image.dimensions();
|
||||
Dimension = glm::max(Dimension, image2D::dimensions_type(1));
|
||||
|
||||
image2D::size_type BlockSize = sizeBlock(Image.format());
|
||||
image2D::size_type BPP = sizeBitPerPixel(Image.format());
|
||||
image2D::size_type BlockCount = 0;
|
||||
if((BlockSize << 3) == BPP)
|
||||
BlockCount = Dimension.x * Dimension.y;
|
||||
else
|
||||
BlockCount = ((Dimension.x + 3) >> 2) * ((Dimension.y + 3) >> 2);
|
||||
|
||||
return BlockCount * BlockSize;
|
||||
}
|
||||
}//namespace detail
|
||||
|
||||
inline image2D::image2D() :
|
||||
Data(0),
|
||||
Dimensions(0),
|
||||
Format(FORMAT_NULL)
|
||||
{}
|
||||
|
||||
inline image2D::image2D
|
||||
(
|
||||
image2D const & Image
|
||||
) :
|
||||
Data(Image.Data),
|
||||
Dimensions(Image.Dimensions),
|
||||
Format(Image.Format)
|
||||
{}
|
||||
|
||||
inline image2D::image2D
|
||||
(
|
||||
dimensions_type const & Dimensions,
|
||||
format_type const & Format
|
||||
) :
|
||||
Data((glm::compMul(Dimensions) * detail::sizeBitPerPixel(Format)) >> 3),
|
||||
Dimensions(Dimensions),
|
||||
Format(Format)
|
||||
{}
|
||||
|
||||
inline image2D::image2D
|
||||
(
|
||||
dimensions_type const & Dimensions,
|
||||
format_type const & Format,
|
||||
std::vector<value_type> const & Data
|
||||
) :
|
||||
Data(Data),
|
||||
Dimensions(Dimensions),
|
||||
Format(Format)
|
||||
{}
|
||||
|
||||
inline image2D::~image2D()
|
||||
{}
|
||||
|
||||
template <typename genType>
|
||||
inline void image2D::setPixel
|
||||
(
|
||||
dimensions_type const & TexelCoord,
|
||||
genType const & TexelData
|
||||
)
|
||||
{
|
||||
size_type Index = this->dimensions().x * sizeof(genType) * TexelCoord.y + sizeof(genType) * TexelCoord.x;
|
||||
memcpy(this->data() + Index, &TexelData[0], sizeof(genType));
|
||||
}
|
||||
|
||||
inline image2D::size_type image2D::value_size() const
|
||||
{
|
||||
return detail::sizeBitPerPixel(this->format());
|
||||
}
|
||||
|
||||
inline image2D::size_type image2D::capacity() const
|
||||
{
|
||||
return detail::sizeLinear(*this);
|
||||
}
|
||||
|
||||
inline image2D::dimensions_type image2D::dimensions() const
|
||||
{
|
||||
return this->Dimensions;
|
||||
}
|
||||
|
||||
inline image2D::size_type image2D::components() const
|
||||
{
|
||||
return detail::sizeComponent(this->format());
|
||||
}
|
||||
|
||||
inline image2D::format_type image2D::format() const
|
||||
{
|
||||
return this->Format;
|
||||
}
|
||||
|
||||
inline image2D::value_type * image2D::data()
|
||||
{
|
||||
return &this->Data[0];
|
||||
}
|
||||
|
||||
inline image2D::value_type const * const image2D::data() const
|
||||
{
|
||||
return &this->Data[0];
|
||||
}
|
||||
}//namespace gli
|
23
test/external/gli/core/levels.inl
vendored
Normal file
23
test/external/gli/core/levels.inl
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
#include <glm/gtc/integer.hpp>
|
||||
#include <glm/gtx/component_wise.hpp>
|
||||
|
||||
namespace gli
|
||||
{
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
inline T levels(vecType<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
|
55
test/external/gli/core/load.inl
vendored
Normal file
55
test/external/gli/core/load.inl
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
#include "../load_dds.hpp"
|
||||
#include "../load_kmg.hpp"
|
||||
#include "../load_ktx.hpp"
|
||||
#include "file.hpp"
|
||||
|
||||
namespace gli
|
||||
{
|
||||
/// Load a texture (DDS, KTX or KMG) from memory
|
||||
inline texture load(char const * Data, std::size_t Size)
|
||||
{
|
||||
{
|
||||
texture Texture = load_dds(Data, Size);
|
||||
if(!Texture.empty())
|
||||
return Texture;
|
||||
}
|
||||
{
|
||||
texture Texture = load_kmg(Data, Size);
|
||||
if(!Texture.empty())
|
||||
return Texture;
|
||||
}
|
||||
{
|
||||
texture Texture = load_ktx(Data, Size);
|
||||
if(!Texture.empty())
|
||||
return Texture;
|
||||
}
|
||||
|
||||
return texture();
|
||||
}
|
||||
|
||||
/// Load a texture (DDS, KTX or KMG) from file
|
||||
inline texture load(char const * Filename)
|
||||
{
|
||||
FILE* File = detail::open_file(Filename, "rb");
|
||||
if(!File)
|
||||
return texture();
|
||||
|
||||
long Beg = std::ftell(File);
|
||||
std::fseek(File, 0, SEEK_END);
|
||||
long End = std::ftell(File);
|
||||
std::fseek(File, 0, SEEK_SET);
|
||||
|
||||
std::vector<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
|
324
test/external/gli/core/load_dds.inl
vendored
Normal file
324
test/external/gli/core/load_dds.inl
vendored
Normal file
@ -0,0 +1,324 @@
|
||||
#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
|
103
test/external/gli/core/load_kmg.inl
vendored
Normal file
103
test/external/gli/core/load_kmg.inl
vendored
Normal file
@ -0,0 +1,103 @@
|
||||
#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
|
137
test/external/gli/core/load_ktx.inl
vendored
Normal file
137
test/external/gli/core/load_ktx.inl
vendored
Normal file
@ -0,0 +1,137 @@
|
||||
#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
|
72
test/external/gli/core/make_texture.inl
vendored
Normal file
72
test/external/gli/core/make_texture.inl
vendored
Normal file
@ -0,0 +1,72 @@
|
||||
namespace gli
|
||||
{
|
||||
inline gli::texture make_texture1d(format Format, extent1d const& Extent, size_t Levels)
|
||||
{
|
||||
return gli::texture(TARGET_1D, Format, texture::extent_type(Extent.x, 1, 1), 1, 1, Levels);
|
||||
}
|
||||
|
||||
inline gli::texture make_texture1d(format Format, extent1d const& Extent)
|
||||
{
|
||||
return gli::texture(TARGET_1D, Format, texture::extent_type(Extent.x, 1, 1), 1, 1, gli::levels(texture::extent_type(Extent.x, 1, 1)));
|
||||
}
|
||||
|
||||
inline gli::texture make_texture1d_array(format Format, extent1d const& Extent, size_t Layers, size_t Levels)
|
||||
{
|
||||
return gli::texture(TARGET_1D_ARRAY, Format, texture::extent_type(Extent.x, 1, 1), Layers, 1, Levels);
|
||||
}
|
||||
|
||||
inline gli::texture make_texture1d_array(format Format, extent1d const& Extent, size_t Layers)
|
||||
{
|
||||
return gli::texture(TARGET_1D_ARRAY, Format, texture::extent_type(Extent.x, 1, 1), Layers, 1, gli::levels(texture::extent_type(Extent.x, 1, 1)));
|
||||
}
|
||||
|
||||
inline gli::texture make_texture2d(format Format, extent2d const& Extent, size_t Levels)
|
||||
{
|
||||
return gli::texture(TARGET_2D, Format, texture::extent_type(Extent, 1), 1, 1, Levels);
|
||||
}
|
||||
|
||||
inline gli::texture make_texture2d(format Format, extent2d const& Extent)
|
||||
{
|
||||
return gli::texture(TARGET_2D, Format, texture::extent_type(Extent, 1), 1, 1, gli::levels(texture::extent_type(Extent, 1)));
|
||||
}
|
||||
|
||||
inline gli::texture make_texture2d_array(format Format, extent2d const& Extent, size_t Layer, size_t Levels)
|
||||
{
|
||||
return gli::texture(TARGET_2D_ARRAY, Format, texture::extent_type(Extent, 1), Layer, 1, Levels);
|
||||
}
|
||||
|
||||
inline gli::texture make_texture2d_array(format Format, extent2d const& Extent, size_t Layer)
|
||||
{
|
||||
return gli::texture(TARGET_2D_ARRAY, Format, texture::extent_type(Extent, 1), Layer, 1, gli::levels(texture::extent_type(Extent, 1)));
|
||||
}
|
||||
|
||||
inline gli::texture make_texture3d(format Format, extent3d const& Extent, size_t Levels)
|
||||
{
|
||||
return gli::texture(TARGET_3D, Format, texture::extent_type(Extent), 1, 1, Levels);
|
||||
}
|
||||
|
||||
inline gli::texture make_texture3d(format Format, extent3d const& Extent)
|
||||
{
|
||||
return gli::texture(TARGET_3D, Format, texture::extent_type(Extent), 1, 1, gli::levels(texture::extent_type(Extent)));
|
||||
}
|
||||
|
||||
inline gli::texture make_texture_cube(format Format, extent2d const& Extent, size_t Levels)
|
||||
{
|
||||
return gli::texture(TARGET_CUBE, Format, texture::extent_type(Extent, 1), 1, 6, Levels);
|
||||
}
|
||||
|
||||
inline gli::texture make_texture_cube(format Format, extent2d const& Extent)
|
||||
{
|
||||
return gli::texture(TARGET_CUBE, Format, texture::extent_type(Extent, 1), 1, 6, gli::levels(texture::extent_type(Extent, 1)));
|
||||
}
|
||||
|
||||
inline gli::texture make_texture_cube_array(format Format, extent2d const& Extent, size_t Layer, size_t Levels)
|
||||
{
|
||||
return gli::texture(TARGET_CUBE_ARRAY, Format, texture::extent_type(Extent, 1), Layer, 6, Levels);
|
||||
}
|
||||
|
||||
inline gli::texture make_texture_cube_array(format Format, extent2d const& Extent, size_t Layer)
|
||||
{
|
||||
return gli::texture(TARGET_CUBE_ARRAY, Format, texture::extent_type(Extent, 1), Layer, 6, gli::levels(texture::extent_type(Extent, 1)));
|
||||
}
|
||||
}//namespace gli
|
116
test/external/gli/core/mipmaps_compute.hpp
vendored
Normal file
116
test/external/gli/core/mipmaps_compute.hpp
vendored
Normal file
@ -0,0 +1,116 @@
|
||||
#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
|
82
test/external/gli/core/operation.hpp
vendored
82
test/external/gli/core/operation.hpp
vendored
@ -1,82 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2008-12-19
|
||||
// Updated : 2010-01-09
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/operation.hpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLI_OPERATION_INCLUDED
|
||||
#define GLI_OPERATION_INCLUDED
|
||||
|
||||
#include "texture2d.hpp"
|
||||
|
||||
namespace gli
|
||||
{
|
||||
texture2D duplicate(texture2D const & Texture);
|
||||
texture2D flip(texture2D const & Texture);
|
||||
texture2D mirror(texture2D const & Texture);
|
||||
texture2D swizzle(
|
||||
texture2D const & Texture,
|
||||
glm::uvec4 const & Channel);
|
||||
texture2D crop(
|
||||
texture2D const & Texture,
|
||||
texture2D::dimensions_type const & Position,
|
||||
texture2D::dimensions_type const & Size);
|
||||
|
||||
image2D crop(
|
||||
image2D const & Image,
|
||||
texture2D::dimensions_type const & Position,
|
||||
texture2D::dimensions_type const & Size);
|
||||
|
||||
image2D copy(
|
||||
image2D const & SrcImage,
|
||||
image2D::dimensions_type const & SrcPosition,
|
||||
image2D::dimensions_type const & SrcSize,
|
||||
image2D & DstImage,
|
||||
image2D::dimensions_type const & DstPosition);
|
||||
|
||||
//image operator+(image const & MipmapA, image const & MipmapB);
|
||||
//image operator-(image const & MipmapA, image const & MipmapB);
|
||||
//image operator*(image const & MipmapA, image const & MipmapB);
|
||||
//image operator/(image const & MipmapA, image const & MipmapB);
|
||||
|
||||
//namespace wip
|
||||
//{
|
||||
// template <typename GENTYPE, template <typename> class SURFACE>
|
||||
// GENTYPE fetch(SURFACE<GENTYPE> const & Image)
|
||||
// {
|
||||
// return GENTYPE();
|
||||
// }
|
||||
|
||||
// template
|
||||
// <
|
||||
// typename GENTYPE,
|
||||
// template
|
||||
// <
|
||||
// typename
|
||||
// >
|
||||
// class SURFACE,
|
||||
// template
|
||||
// <
|
||||
// typename,
|
||||
// template
|
||||
// <
|
||||
// typename
|
||||
// >
|
||||
// class
|
||||
// >
|
||||
// class IMAGE
|
||||
// >
|
||||
// GENTYPE fetch(IMAGE<GENTYPE, SURFACE> const & Image)
|
||||
// {
|
||||
// return GENTYPE();
|
||||
// }
|
||||
//}//namespace wip
|
||||
|
||||
}//namespace gli
|
||||
|
||||
#include "operation.inl"
|
||||
|
||||
#endif//GLI_OPERATION_INCLUDED
|
233
test/external/gli/core/operation.inl
vendored
233
test/external/gli/core/operation.inl
vendored
@ -1,233 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2008-12-19
|
||||
// Updated : 2010-09-08
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/core/operation.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cstring>
|
||||
|
||||
namespace gli
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
inline image2D duplicate(image2D const & Mipmap2D)
|
||||
{
|
||||
image2D Result(Mipmap2D.dimensions(), Mipmap2D.format());
|
||||
memcpy(Result.data(), Mipmap2D.data(), Mipmap2D.capacity());
|
||||
return Result;
|
||||
}
|
||||
|
||||
inline image2D flip(image2D const & Mipmap2D)
|
||||
{
|
||||
image2D Result(Mipmap2D.dimensions(), Mipmap2D.format());
|
||||
|
||||
std::size_t ValueSize = Result.value_size();
|
||||
glm::byte * DstPtr = Result.data();
|
||||
glm::byte const * const SrcPtr = Mipmap2D.data();
|
||||
|
||||
for(std::size_t j = 0; j < Result.dimensions().y; ++j)
|
||||
for(std::size_t i = 0; i < Result.dimensions().x; ++i)
|
||||
{
|
||||
std::size_t DstIndex = (i + j * Result.dimensions().y) * ValueSize;
|
||||
std::size_t SrcIndex = (i + (Result.dimensions().y - j) * Result.dimensions().x) * ValueSize;
|
||||
memcpy(DstPtr + DstIndex, SrcPtr + SrcIndex, ValueSize);
|
||||
}
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
inline image2D mirror(image2D const & Mipmap2D)
|
||||
{
|
||||
image2D Result(Mipmap2D.dimensions(), Mipmap2D.format());
|
||||
|
||||
std::size_t ValueSize = Mipmap2D.value_size();
|
||||
glm::byte * DstPtr = Result.data();
|
||||
glm::byte const * const SrcPtr = Mipmap2D.data();
|
||||
|
||||
for(std::size_t j = 0; j < Result.dimensions().y; ++j)
|
||||
for(std::size_t i = 0; i < Result.dimensions().x; ++i)
|
||||
{
|
||||
std::size_t DstIndex = (i + j * Result.dimensions().x) * ValueSize;
|
||||
std::size_t SrcIndex = ((Result.dimensions().x - i) + j * Result.dimensions().x) * ValueSize;
|
||||
memcpy(DstPtr + DstIndex, SrcPtr + SrcIndex, ValueSize);
|
||||
}
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
inline image2D swizzle
|
||||
(
|
||||
image2D const & Mipmap,
|
||||
glm::uvec4 const & Channel
|
||||
)
|
||||
{
|
||||
image2D Result = detail::duplicate(Mipmap);
|
||||
|
||||
glm::byte * DataDst = Result.data();
|
||||
glm::byte const * const DataSrc = Mipmap.data();
|
||||
|
||||
gli::texture2D::size_type CompSize = Mipmap.value_size() / Mipmap.components();
|
||||
gli::texture2D::size_type TexelCount = Mipmap.capacity() / Mipmap.value_size();
|
||||
|
||||
for(gli::texture2D::size_type t = 0; t < TexelCount; ++t)
|
||||
for(gli::texture2D::size_type c = 0; c < Mipmap.components(); ++c)
|
||||
{
|
||||
gli::texture2D::size_type IndexSrc = t * Mipmap.components() + Channel[static_cast<int>(c)];
|
||||
gli::texture2D::size_type IndexDst = t * Mipmap.components() + c;
|
||||
|
||||
memcpy(DataDst + IndexDst, DataSrc + IndexSrc, CompSize);
|
||||
}
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
inline image2D crop
|
||||
(
|
||||
image2D const & Image,
|
||||
image2D::dimensions_type const & Position,
|
||||
image2D::dimensions_type const & Size
|
||||
)
|
||||
{
|
||||
assert((Position.x + Size.x) <= Image.dimensions().x && (Position.y + Size.y) <= Image.dimensions().y);
|
||||
|
||||
image2D Result(Size, Image.format());
|
||||
|
||||
glm::byte* DstData = Result.data();
|
||||
glm::byte const * const SrcData = Image.data();
|
||||
|
||||
for(std::size_t j = 0; j < Size.y; ++j)
|
||||
{
|
||||
std::size_t DstIndex = 0 + (0 + j) * Size.x * Image.value_size();
|
||||
std::size_t SrcIndex = Position.x * Image.value_size() + (Position.y + j) * Image.dimensions().x * Image.value_size();
|
||||
memcpy(DstData + DstIndex, SrcData + SrcIndex, Image.value_size() * Size.x);
|
||||
}
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
inline image2D copy
|
||||
(
|
||||
image2D const & SrcMipmap,
|
||||
image2D::dimensions_type const & SrcPosition,
|
||||
image2D::dimensions_type const & SrcSize,
|
||||
image2D & DstMipmap,
|
||||
image2D::dimensions_type const & DstPosition
|
||||
)
|
||||
{
|
||||
assert((SrcPosition.x + SrcSize.x) <= SrcMipmap.dimensions().x && (SrcPosition.y + SrcSize.y) <= SrcMipmap.dimensions().y);
|
||||
assert(SrcMipmap.format() == DstMipmap.format());
|
||||
|
||||
glm::byte * DstData = DstMipmap.data();
|
||||
glm::byte const * const SrcData = SrcMipmap.data();
|
||||
|
||||
std::size_t SizeX = glm::min(std::size_t(SrcSize.x + SrcPosition.x), std::size_t(DstMipmap.dimensions().x + DstPosition.x));
|
||||
std::size_t SizeY = glm::min(std::size_t(SrcSize.y + SrcPosition.y), std::size_t(DstMipmap.dimensions().y + DstPosition.y));
|
||||
|
||||
for(std::size_t j = 0; j < SizeY; ++j)
|
||||
{
|
||||
std::size_t DstIndex = DstPosition.x * DstMipmap.value_size() + (DstPosition.y + j) * DstMipmap.dimensions().x * DstMipmap.value_size();
|
||||
std::size_t SrcIndex = SrcPosition.x * SrcMipmap.value_size() + (SrcPosition.y + j) * SrcMipmap.dimensions().x * SrcMipmap.value_size();
|
||||
memcpy(DstData + DstIndex, SrcData + SrcIndex, SrcMipmap.value_size() * SizeX);
|
||||
}
|
||||
|
||||
return DstMipmap;
|
||||
}
|
||||
|
||||
}//namespace detail
|
||||
|
||||
inline texture2D duplicate(texture2D const & Texture2D)
|
||||
{
|
||||
texture2D Result(Texture2D.levels());
|
||||
for(texture2D::level_type Level = 0; Level < Texture2D.levels(); ++Level)
|
||||
Result[Level] = detail::duplicate(Texture2D[Level]);
|
||||
return Result;
|
||||
}
|
||||
|
||||
inline texture2D flip(texture2D const & Texture2D)
|
||||
{
|
||||
texture2D Result(Texture2D.levels());
|
||||
for(texture2D::level_type Level = 0; Level < Texture2D.levels(); ++Level)
|
||||
Result[Level] = detail::flip(Texture2D[Level]);
|
||||
return Result;
|
||||
}
|
||||
|
||||
inline texture2D mirror(texture2D const & Texture2D)
|
||||
{
|
||||
texture2D Result(Texture2D.levels());
|
||||
for(texture2D::level_type Level = 0; Level < Texture2D.levels(); ++Level)
|
||||
Result[Level] = detail::mirror(Texture2D[Level]);
|
||||
return Result;
|
||||
}
|
||||
|
||||
inline texture2D crop
|
||||
(
|
||||
texture2D const & Texture2D,
|
||||
texture2D::dimensions_type const & Position,
|
||||
texture2D::dimensions_type const & Size
|
||||
)
|
||||
{
|
||||
texture2D Result(Texture2D.levels());
|
||||
for(texture2D::level_type Level = 0; Level < Texture2D.levels(); ++Level)
|
||||
Result[Level] = detail::crop(
|
||||
Texture2D[Level],
|
||||
Position >> texture2D::dimensions_type(Level),
|
||||
Size >> texture2D::dimensions_type(Level));
|
||||
return Result;
|
||||
}
|
||||
|
||||
inline texture2D swizzle
|
||||
(
|
||||
texture2D const & Texture2D,
|
||||
glm::uvec4 const & Channel
|
||||
)
|
||||
{
|
||||
texture2D Result(Texture2D.levels());
|
||||
for(texture2D::level_type Level = 0; Level < Texture2D.levels(); ++Level)
|
||||
Result[Level] = detail::swizzle(Texture2D[Level], Channel);
|
||||
return Result;
|
||||
}
|
||||
|
||||
inline texture2D copy
|
||||
(
|
||||
texture2D const & SrcImage,
|
||||
texture2D::level_type const & SrcLevel,
|
||||
texture2D::dimensions_type const & SrcPosition,
|
||||
texture2D::dimensions_type const & SrcDimensions,
|
||||
texture2D & DstMipmap,
|
||||
texture2D::level_type const & DstLevel,
|
||||
texture2D::dimensions_type const & DstDimensions
|
||||
)
|
||||
{
|
||||
detail::copy(
|
||||
SrcImage[SrcLevel],
|
||||
SrcPosition,
|
||||
SrcDimensions,
|
||||
DstMipmap[DstLevel],
|
||||
DstDimensions);
|
||||
return DstMipmap;
|
||||
}
|
||||
|
||||
//inline image operator+(image const & MipmapA, image const & MipmapB)
|
||||
//{
|
||||
//
|
||||
//}
|
||||
|
||||
//inline image operator-(image const & MipmapA, image const & MipmapB)
|
||||
//{
|
||||
//
|
||||
//}
|
||||
|
||||
//inline image operator*(image const & MipmapA, image const & MipmapB)
|
||||
//{
|
||||
//
|
||||
//}
|
||||
|
||||
//inline image operator/(image const & MipmapA, image const & MipmapB)
|
||||
//{
|
||||
//
|
||||
//}
|
||||
|
||||
}//namespace gli
|
28
test/external/gli/core/operator.hpp
vendored
28
test/external/gli/core/operator.hpp
vendored
@ -1,28 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2010-01-19
|
||||
// Updated : 2010-01-19
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/core/operator.hpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLI_OPERATOR_INCLUDED
|
||||
#define GLI_OPERATOR_INCLUDED
|
||||
|
||||
#include "texture2d.hpp"
|
||||
|
||||
namespace gli{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
}//namespace detail
|
||||
|
||||
texture2D operator+(texture2D const & TextureA, texture2D const & TextureB);
|
||||
texture2D operator-(texture2D const & TextureA, texture2D const & TextureB);
|
||||
|
||||
}//namespace gli
|
||||
|
||||
#include "operator.inl"
|
||||
|
||||
#endif//GLI_OPERATOR_INCLUDED
|
210
test/external/gli/core/operator.inl
vendored
210
test/external/gli/core/operator.inl
vendored
@ -1,210 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2010-01-19
|
||||
// Updated : 2010-01-19
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/core/operator.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace gli
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
template <typename T>
|
||||
void element
|
||||
(
|
||||
T & DataDst,
|
||||
T const & DataSrcA,
|
||||
T const & DataSrcB,
|
||||
std::binary_function<T, T, T> const & Func
|
||||
)
|
||||
{
|
||||
*DataDst = Func(DataSrcA, DataSrcB);
|
||||
}
|
||||
|
||||
void op
|
||||
(
|
||||
texture2D::value_type * DataDst,
|
||||
texture2D::value_type const * const DataSrcA,
|
||||
texture2D::value_type const * const DataSrcB,
|
||||
format Format
|
||||
)
|
||||
{
|
||||
std::plus<>()
|
||||
switch(Format)
|
||||
{
|
||||
case R8U:
|
||||
*((glm::u8*)DataDst) = *((glm::u8*)DataSrcA) + *((glm::u8*)DataSrcB);
|
||||
break;
|
||||
case RG8U:
|
||||
*((glm::u8vec2*)DataDst) = *((glm::u8vec2*)DataSrcA) + *((glm::u8vec2*)DataSrcB);
|
||||
break;
|
||||
case RGB8U:
|
||||
*((glm::u8vec3*)DataDst) = *((glm::u8vec3*)DataSrcA) + *((glm::u8vec3*)DataSrcB);
|
||||
break;
|
||||
case RGBA8U:
|
||||
*((glm::u8vec4*)DataDst) = *((glm::u8vec4*)DataSrcA) + *((glm::u8vec4*)DataSrcB);
|
||||
break;
|
||||
|
||||
case R16U:
|
||||
*((glm::u16*)DataDst) = *((glm::u16*)DataSrcA) + *((glm::u16*)DataSrcB);
|
||||
break;
|
||||
case RG16U:
|
||||
*((glm::u16vec2*)DataDst) = *((glm::u16vec2*)DataSrcA) + *((glm::u16vec2*)DataSrcB);
|
||||
break;
|
||||
case RGB16U:
|
||||
*((glm::u16vec3*)DataDst) = *((glm::u16vec3*)DataSrcA) + *((glm::u16vec3*)DataSrcB);
|
||||
break;
|
||||
case RGBA16U:
|
||||
*((glm::u16vec4*)DataDst) = *((glm::u16vec4*)DataSrcA) + *((glm::u16vec4*)DataSrcB);
|
||||
break;
|
||||
|
||||
case R32U:
|
||||
*((glm::u32*)DataDst) = *((glm::u32*)DataSrcA) + *((glm::u32*)DataSrcB);
|
||||
break;
|
||||
case RG32U:
|
||||
*((glm::u32vec2*)DataDst) = *((glm::u32vec2*)DataSrcA) + *((glm::u32vec2*)DataSrcB);
|
||||
break;
|
||||
case RGB32U:
|
||||
*((glm::u32vec3*)DataDst) = *((glm::u32vec3*)DataSrcA) + *((glm::u32vec3*)DataSrcB);
|
||||
break;
|
||||
case RGBA32U:
|
||||
*((glm::u32vec4*)DataDst) = *((glm::u32vec4*)DataSrcA) + *((glm::u32vec4*)DataSrcB);
|
||||
break;
|
||||
|
||||
case R8I:
|
||||
*((glm::i8*)DataDst) = *((glm::i8*)DataSrcA) + *((glm::i8*)DataSrcB);
|
||||
break;
|
||||
case RG8I:
|
||||
*((glm::i8vec2*)DataDst) = *((glm::i8vec2*)DataSrcA) + *((glm::i8vec2*)DataSrcB);
|
||||
break;
|
||||
case RGB8I:
|
||||
*((glm::i8vec3*)DataDst) = *((glm::i8vec3*)DataSrcA) + *((glm::i8vec3*)DataSrcB);
|
||||
break;
|
||||
case RGBA8I:
|
||||
*((glm::i8vec4*)DataDst) = *((glm::i8vec4*)DataSrcA) + *((glm::i8vec4*)DataSrcB);
|
||||
break;
|
||||
|
||||
case R16I:
|
||||
*((glm::i16*)DataDst) = *((glm::i16*)DataSrcA) + *((glm::i16*)DataSrcB);
|
||||
break;
|
||||
case RG16I:
|
||||
*((glm::i16vec2*)DataDst) = *((glm::i16vec2*)DataSrcA) + *((glm::i16vec2*)DataSrcB);
|
||||
break;
|
||||
case RGB16I:
|
||||
*((glm::i16vec3*)DataDst) = *((glm::i16vec3*)DataSrcA) + *((glm::i16vec3*)DataSrcB);
|
||||
break;
|
||||
case RGBA16I:
|
||||
*((glm::i16vec4*)DataDst) = *((glm::i16vec4*)DataSrcA) + *((glm::i16vec4*)DataSrcB);
|
||||
break;
|
||||
|
||||
case R32I:
|
||||
*((glm::i32*)DataDst) = *((glm::i32*)DataSrcA) + *((glm::i32*)DataSrcB);
|
||||
break;
|
||||
case RG32I:
|
||||
*((glm::i32vec2*)DataDst) = *((glm::i32vec2*)DataSrcA) + *((glm::i32vec2*)DataSrcB);
|
||||
break;
|
||||
case RGB32I:
|
||||
*((glm::i32vec3*)DataDst) = *((glm::i32vec3*)DataSrcA) + *((glm::i32vec3*)DataSrcB);
|
||||
break;
|
||||
case RGBA32I:
|
||||
*((glm::i32vec4*)DataDst) = *((glm::i32vec4*)DataSrcA) + *((glm::i32vec4*)DataSrcB);
|
||||
break;
|
||||
|
||||
case R16F:
|
||||
*((glm::f16*)DataDst) = *((glm::f16*)DataSrcA) + *((glm::f16*)DataSrcB);
|
||||
break;
|
||||
case RG16F:
|
||||
*((glm::f16vec2*)DataDst) = *((glm::f16vec2*)DataSrcA) + *((glm::f16vec2*)DataSrcB);
|
||||
break;
|
||||
case RGB16F:
|
||||
*((glm::f16vec3*)DataDst) = *((glm::f16vec3*)DataSrcA) + *((glm::f16vec3*)DataSrcB);
|
||||
break;
|
||||
case RGBA16F:
|
||||
*((glm::f16vec4*)DataDst) = *((glm::f16vec4*)DataSrcA) + *((glm::f16vec4*)DataSrcB);
|
||||
break;
|
||||
|
||||
case R32F:
|
||||
*((glm::f32*)DataDst) = *((glm::f32*)DataSrcA) + *((glm::f32*)DataSrcB);
|
||||
break;
|
||||
case RG32F:
|
||||
*((glm::f32vec2*)DataDst) = *((glm::f32vec2*)DataSrcA) + *((glm::f32vec2*)DataSrcB);
|
||||
break;
|
||||
case RGB32F:
|
||||
*((glm::f32vec3*)DataDst) = *((glm::f32vec3*)DataSrcA) + *((glm::f32vec3*)DataSrcB);
|
||||
break;
|
||||
case RGBA32F:
|
||||
*((glm::f32vec4*)DataDst) = *((glm::f32vec4*)DataSrcA) + *((glm::f32vec4*)DataSrcB);
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
|
||||
void add
|
||||
(
|
||||
texture2D::image & Result,
|
||||
texture2D::image const & ImageA,
|
||||
texture2D::image const & ImageB,
|
||||
)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}//namespace detail
|
||||
|
||||
texture2D operator+
|
||||
(
|
||||
texture2D const & ImageA,
|
||||
texture2D const & ImageB
|
||||
)
|
||||
{
|
||||
assert(ImageA.levels() == ImageB.levels());
|
||||
texture2D Result[ImageA.levels()];
|
||||
|
||||
for(texture2D::level_type Level = 0; Level < Result.levels(); ++Level)
|
||||
{
|
||||
assert(ImageA.capacity() == ImageB.capacity());
|
||||
assert(ImageA.format() == ImageB.format());
|
||||
|
||||
Result[Level] = texture2D::image(ImageA[Level].dimensions(), ImageA[Level].format());
|
||||
|
||||
add(Result[Level], ImageA[Level], ImageB[Level]);
|
||||
|
||||
texture2D::size_type ValueSize = Result.value_size();
|
||||
texture2D::size_type TexelCount = this->capacity() / ValueSize;
|
||||
for(texture2D::size_type Texel = 0; Texel < TexelCount; ++Texel)
|
||||
{
|
||||
texture2D::value_type * DataDst = Result[Level].data() + Texel * ValueSize;
|
||||
texture2D::value_type const * const DataSrcA = ImageA[Level].data() + Texel * ValueSize;
|
||||
texture2D::value_type const * const DataSrcB = ImageB[Level].data() + Texel * ValueSize;
|
||||
|
||||
detail::op(DataDst, DataSrcA, DataSrcB, Result.format(), std::plus);
|
||||
}
|
||||
}
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
texture2D operator-
|
||||
(
|
||||
texture2D const & ImageA,
|
||||
texture2D const & ImageB
|
||||
)
|
||||
{
|
||||
assert(ImageA.levels() == ImageB.levels());
|
||||
texture2D Result[ImageA.levels()];
|
||||
|
||||
|
||||
for(texture2D::level_type Level = 0; Level < ImageA.levels(); ++Level)
|
||||
{
|
||||
assert(ImageA.capacity() == ImageB.capacity());
|
||||
|
||||
|
||||
}
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
}//namespace gli
|
533
test/external/gli/core/reduce.inl
vendored
Normal file
533
test/external/gli/core/reduce.inl
vendored
Normal file
@ -0,0 +1,533 @@
|
||||
#include "../sampler1d.hpp"
|
||||
#include "../sampler1d_array.hpp"
|
||||
#include "../sampler2d.hpp"
|
||||
#include "../sampler2d_array.hpp"
|
||||
#include "../sampler3d.hpp"
|
||||
#include "../sampler_cube.hpp"
|
||||
#include "../sampler_cube_array.hpp"
|
||||
|
||||
namespace gli
|
||||
{
|
||||
template <typename val_type>
|
||||
struct binary_func
|
||||
{
|
||||
typedef tvec4<val_type>(*type)(tvec4<val_type> const& A, tvec4<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 tvec4<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);
|
||||
tvec4<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 tvec4<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);
|
||||
tvec4<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 tvec4<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);
|
||||
tvec4<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 tvec4<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);
|
||||
tvec4<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 tvec4<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);
|
||||
tvec4<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 tvec4<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);
|
||||
tvec4<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 tvec4<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);
|
||||
tvec4<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
|
||||
|
34
test/external/gli/core/sampler.inl
vendored
Normal file
34
test/external/gli/core/sampler.inl
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
#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
|
82
test/external/gli/core/sampler1d.inl
vendored
Normal file
82
test/external/gli/core/sampler1d.inl
vendored
Normal file
@ -0,0 +1,82 @@
|
||||
#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
|
||||
|
83
test/external/gli/core/sampler1d_array.inl
vendored
Normal file
83
test/external/gli/core/sampler1d_array.inl
vendored
Normal file
@ -0,0 +1,83 @@
|
||||
#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
|
||||
|
82
test/external/gli/core/sampler2d.inl
vendored
Normal file
82
test/external/gli/core/sampler2d.inl
vendored
Normal file
@ -0,0 +1,82 @@
|
||||
#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
|
||||
|
83
test/external/gli/core/sampler2d_array.inl
vendored
Normal file
83
test/external/gli/core/sampler2d_array.inl
vendored
Normal file
@ -0,0 +1,83 @@
|
||||
#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
|
||||
|
82
test/external/gli/core/sampler3d.inl
vendored
Normal file
82
test/external/gli/core/sampler3d.inl
vendored
Normal file
@ -0,0 +1,82 @@
|
||||
#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
|
||||
|
84
test/external/gli/core/sampler_cube.inl
vendored
Normal file
84
test/external/gli/core/sampler_cube.inl
vendored
Normal file
@ -0,0 +1,84 @@
|
||||
#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
|
||||
|
84
test/external/gli/core/sampler_cube_array.inl
vendored
Normal file
84
test/external/gli/core/sampler_cube_array.inl
vendored
Normal file
@ -0,0 +1,84 @@
|
||||
#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
|
||||
|
22
test/external/gli/core/save.inl
vendored
Normal file
22
test/external/gli/core/save.inl
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
#include "../save_dds.hpp"
|
||||
#include "../save_kmg.hpp"
|
||||
#include "../save_ktx.hpp"
|
||||
|
||||
namespace gli
|
||||
{
|
||||
inline bool save(texture const & Texture, char const * Path)
|
||||
{
|
||||
return save(Texture, std::string(Path));
|
||||
}
|
||||
|
||||
inline bool save(texture const & Texture, std::string const & Path)
|
||||
{
|
||||
if(Path.rfind(".dds") != std::string::npos)
|
||||
return save_dds(Texture, Path);
|
||||
if(Path.rfind(".kmg") != std::string::npos)
|
||||
return save_kmg(Texture, Path);
|
||||
if(Path.rfind(".ktx") != std::string::npos)
|
||||
return save_ktx(Texture, Path);
|
||||
return false;
|
||||
}
|
||||
}//namespace gli
|
139
test/external/gli/core/save_dds.inl
vendored
Normal file
139
test/external/gli/core/save_dds.inl
vendored
Normal file
@ -0,0 +1,139 @@
|
||||
#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
|
80
test/external/gli/core/save_kmg.inl
vendored
Normal file
80
test/external/gli/core/save_kmg.inl
vendored
Normal file
@ -0,0 +1,80 @@
|
||||
#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
|
114
test/external/gli/core/save_ktx.inl
vendored
Normal file
114
test/external/gli/core/save_ktx.inl
vendored
Normal file
@ -0,0 +1,114 @@
|
||||
#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
|
48
test/external/gli/core/shared_array.hpp
vendored
48
test/external/gli/core/shared_array.hpp
vendored
@ -1,48 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2008-12-19
|
||||
// Updated : 2005-06-13
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/shared_array.hpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLI_SHARED_ARRAY_INCLUDED
|
||||
#define GLI_SHARED_ARRAY_INCLUDED
|
||||
|
||||
namespace gli
|
||||
{
|
||||
template <typename T>
|
||||
class shared_array
|
||||
{
|
||||
public:
|
||||
|
||||
shared_array();
|
||||
shared_array(shared_array const & SharedArray);
|
||||
shared_array(T * Pointer);
|
||||
virtual ~shared_array();
|
||||
|
||||
void reset();
|
||||
void reset(T * Pointer);
|
||||
|
||||
T & operator*();
|
||||
T * operator->();
|
||||
T const & operator*() const;
|
||||
T const * const operator->() const;
|
||||
|
||||
T * get();
|
||||
T const * const get() const;
|
||||
|
||||
shared_array & operator=(shared_array const & SharedArray);
|
||||
bool operator==(shared_array const & SharedArray) const;
|
||||
bool operator!=(shared_array const & SharedArray) const;
|
||||
|
||||
private:
|
||||
int * Counter;
|
||||
T * Pointer;
|
||||
};
|
||||
}//namespace gli
|
||||
|
||||
#include "shared_array.inl"
|
||||
|
||||
#endif //GLI_SHARED_ARRAY_INCLUDED
|
151
test/external/gli/core/shared_array.inl
vendored
151
test/external/gli/core/shared_array.inl
vendored
@ -1,151 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2008-12-19
|
||||
// Updated : 2005-06-13
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/shared_array.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace gli
|
||||
{
|
||||
template <typename T>
|
||||
shared_array<T>::shared_array() :
|
||||
Counter(0),
|
||||
Pointer(0)
|
||||
{}
|
||||
|
||||
template <typename T>
|
||||
shared_array<T>::shared_array
|
||||
(
|
||||
shared_array<T> const & SharedArray
|
||||
)
|
||||
{
|
||||
this->Counter = SharedArray.Counter;
|
||||
this->Pointer = SharedArray.Pointer;
|
||||
(*this->Counter)++;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
shared_array<T>::shared_array
|
||||
(
|
||||
T * Pointer
|
||||
)
|
||||
{
|
||||
this->reset(Pointer);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
shared_array<T>::~shared_array()
|
||||
{
|
||||
this->reset();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void shared_array<T>::reset()
|
||||
{
|
||||
if(this->Pointer)
|
||||
{
|
||||
(*this->Counter)--;
|
||||
if(*this->Counter <= 0)
|
||||
{
|
||||
delete this->Counter;
|
||||
this->Counter = 0;
|
||||
delete[] this->Pointer;
|
||||
this->Pointer = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void shared_array<T>::reset(T * Pointer)
|
||||
{
|
||||
this->Counter = new int;
|
||||
this->Pointer = Pointer;
|
||||
*this->Counter = 1;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
shared_array<T>& shared_array<T>::operator=
|
||||
(
|
||||
shared_array<T> const & SharedArray
|
||||
)
|
||||
{
|
||||
this->reset();
|
||||
|
||||
this->Counter = SharedArray.Counter;
|
||||
this->Pointer = SharedArray.Pointer;
|
||||
(*this->Counter)++;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//template <typename T>
|
||||
//shared_array<T> & shared_array<T>::operator=(T * Pointer)
|
||||
//{
|
||||
// if(this->Pointer)
|
||||
// {
|
||||
// (*this->Counter)--;
|
||||
// if(*this->Counter <= 0)
|
||||
// {
|
||||
// delete this->Counter;
|
||||
// delete[] this->Pointer;
|
||||
// }
|
||||
// }
|
||||
|
||||
// this->Counter = new int;
|
||||
// this->Pointer = this->Pointer;
|
||||
// (*this->Counter) = 1;
|
||||
|
||||
// return *this;
|
||||
//}
|
||||
|
||||
template <typename T>
|
||||
bool shared_array<T>::operator==(shared_array<T> const & SharedArray) const
|
||||
{
|
||||
return this->Pointer == SharedArray.Pointer;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool shared_array<T>::operator!=(shared_array<T> const & SharedArray) const
|
||||
{
|
||||
return this->Pointer != SharedArray.Pointer;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T & shared_array<T>::operator*()
|
||||
{
|
||||
return *this->Pointer;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T * shared_array<T>::operator->()
|
||||
{
|
||||
return this->Pointer;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T const & shared_array<T>::operator*() const
|
||||
{
|
||||
return * this->Pointer;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T const * const shared_array<T>::operator->() const
|
||||
{
|
||||
return this->Pointer;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T * shared_array<T>::get()
|
||||
{
|
||||
return this->Pointer;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T const * const shared_array<T>::get() const
|
||||
{
|
||||
return this->Pointer;
|
||||
}
|
||||
|
||||
}//namespace gli
|
41
test/external/gli/core/shared_ptr.hpp
vendored
41
test/external/gli/core/shared_ptr.hpp
vendored
@ -1,41 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2008-12-19
|
||||
// Updated : 2005-06-13
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/fetch.hpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLI_SHARED_PTR_INCLUDED
|
||||
#define GLI_SHARED_PTR_INCLUDED
|
||||
|
||||
namespace gli
|
||||
{
|
||||
template <typename T>
|
||||
class shared_ptr
|
||||
{
|
||||
public:
|
||||
shared_ptr();
|
||||
shared_ptr(shared_ptr const & SmartPtr);
|
||||
shared_ptr(T* pPointer);
|
||||
~shared_ptr();
|
||||
|
||||
T& operator*();
|
||||
T* operator->();
|
||||
const T& operator*() const;
|
||||
const T* operator->() const;
|
||||
shared_ptr& operator=(shared_ptr const & SmartPtr);
|
||||
shared_ptr& operator=(T* pPointer);
|
||||
bool operator==(shared_ptr const & SmartPtr) const;
|
||||
bool operator!=(shared_ptr const & SmartPtr) const;
|
||||
|
||||
private:
|
||||
int* m_pReference;
|
||||
T* m_pPointer;
|
||||
};
|
||||
}//namespace gli
|
||||
|
||||
#include "shared_ptr.inl"
|
||||
|
||||
#endif //GLI_SHARED_PTR_INCLUDED
|
125
test/external/gli/core/shared_ptr.inl
vendored
125
test/external/gli/core/shared_ptr.inl
vendored
@ -1,125 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Interstate Gangs : smart_ptr.inl
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// This file is under GPL licence
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// CHANGELOG
|
||||
// Groove - 13/06/2005 :
|
||||
// - Create file
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace gli
|
||||
{
|
||||
template <typename T>
|
||||
util::CSmartPtr<T>::CSmartPtr()
|
||||
{
|
||||
m_pPointer = 0;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
util::CSmartPtr<T>::CSmartPtr(const util::CSmartPtr<T> & SmartPtr)
|
||||
{
|
||||
m_pReference = SmartPtr.m_pReference;
|
||||
m_pPointer = SmartPtr.m_pPointer;
|
||||
(*m_pReference)++;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
util::CSmartPtr<T>::CSmartPtr(T* pPointer)
|
||||
{
|
||||
m_pReference = new int;
|
||||
m_pPointer = pPointer;
|
||||
(*m_pReference) = 1;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
util::CSmartPtr<T>::~CSmartPtr()
|
||||
{
|
||||
if(!m_pPointer)
|
||||
return;
|
||||
|
||||
(*m_pReference)--;
|
||||
if(*m_pReference <= 0)
|
||||
{
|
||||
delete m_pReference;
|
||||
delete m_pPointer;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
util::CSmartPtr<T>& util::CSmartPtr<T>::operator=(const util::CSmartPtr<T> & SmartPtr)
|
||||
{
|
||||
if(m_pPointer)
|
||||
{
|
||||
(*m_pReference)--;
|
||||
if(*m_pReference <= 0)
|
||||
{
|
||||
delete m_pReference;
|
||||
delete m_pPointer;
|
||||
}
|
||||
}
|
||||
|
||||
m_pReference = SmartPtr.m_pReference;
|
||||
m_pPointer = SmartPtr.m_pPointer;
|
||||
(*m_pReference)++;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
util::CSmartPtr<T>& util::CSmartPtr<T>::operator=(T* pPointer)
|
||||
{
|
||||
if(m_pPointer)
|
||||
{
|
||||
(*m_pReference)--;
|
||||
if(*m_pReference <= 0)
|
||||
{
|
||||
delete m_pReference;
|
||||
delete m_pPointer;
|
||||
}
|
||||
}
|
||||
|
||||
m_pReference = new int;
|
||||
m_pPointer = pPointer;
|
||||
(*m_pReference) = 1;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool util::CSmartPtr<T>::operator==(const util::CSmartPtr<T> & SmartPtr) const
|
||||
{
|
||||
return m_pPointer == SmartPtr.m_pPointer;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool util::CSmartPtr<T>::operator!=(const util::CSmartPtr<T> & SmartPtr) const
|
||||
{
|
||||
return m_pPointer != SmartPtr.m_pPointer;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T& util::CSmartPtr<T>::operator*()
|
||||
{
|
||||
return *m_pPointer;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T* util::CSmartPtr<T>::operator->()
|
||||
{
|
||||
return m_pPointer;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
const T& util::CSmartPtr<T>::operator*() const
|
||||
{
|
||||
return *m_pPointer;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
const T* util::CSmartPtr<T>::operator->() const
|
||||
{
|
||||
return m_pPointer;
|
||||
}
|
||||
|
||||
}//namespace gli
|
31
test/external/gli/core/size.hpp
vendored
31
test/external/gli/core/size.hpp
vendored
@ -1,31 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2010-09-08
|
||||
// Updated : 2010-09-08
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/core/size.hpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLI_CORE_SIZE_INCLUDED
|
||||
#define GLI_CORE_SIZE_INCLUDED
|
||||
|
||||
#include "texture2d.hpp"
|
||||
|
||||
namespace gli
|
||||
{
|
||||
//template <size_type sizeType>
|
||||
image2D::size_type size(
|
||||
image2D const & Image,
|
||||
image2D::size_type const & SizeType);
|
||||
|
||||
//template <size_type sizeType>
|
||||
texture2D::size_type size(
|
||||
texture2D const & Texture,
|
||||
texture2D::size_type const & SizeType);
|
||||
|
||||
}//namespace gli
|
||||
|
||||
#include "size.inl"
|
||||
|
||||
#endif//GLI_CORE_SIZE_INCLUDED
|
47
test/external/gli/core/size.inl
vendored
47
test/external/gli/core/size.inl
vendored
@ -1,47 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2008-12-19
|
||||
// Updated : 2010-09-08
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/core/size.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace gli
|
||||
{
|
||||
inline image2D::size_type size
|
||||
(
|
||||
image2D const & Image,
|
||||
image2D::size_type const & SizeType
|
||||
)
|
||||
{
|
||||
switch(SizeType)
|
||||
{
|
||||
case LINEAR_SIZE:
|
||||
return detail::sizeLinear(Image);
|
||||
case BLOCK_SIZE:
|
||||
return detail::sizeBlock(Image.format());
|
||||
case BIT_PER_PIXEL:
|
||||
return detail::sizeBitPerPixel(Image.format());
|
||||
case COMPONENT:
|
||||
return detail::sizeComponent(Image.format());
|
||||
default:
|
||||
assert(0);
|
||||
return 0;
|
||||
};
|
||||
}
|
||||
|
||||
inline texture2D::size_type size
|
||||
(
|
||||
texture2D const & Texture,
|
||||
texture2D::size_type const & SizeType
|
||||
)
|
||||
{
|
||||
texture2D::size_type Size = 0;
|
||||
for(texture2D::level_type Level = 0; Level < Texture.levels(); ++Level)
|
||||
Size += size(Texture[Level], SizeType);
|
||||
|
||||
return Size;
|
||||
}
|
||||
|
||||
}//namespace
|
92
test/external/gli/core/storage.hpp
vendored
Normal file
92
test/external/gli/core/storage.hpp
vendored
Normal file
@ -0,0 +1,92 @@
|
||||
#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"
|
170
test/external/gli/core/storage.inl
vendored
Normal file
170
test/external/gli/core/storage.inl
vendored
Normal file
@ -0,0 +1,170 @@
|
||||
#include "../index.hpp"
|
||||
|
||||
namespace gli
|
||||
{
|
||||
inline storage_linear::storage_linear()
|
||||
: Layers(0)
|
||||
, Faces(0)
|
||||
, Levels(0)
|
||||
, BlockSize(0)
|
||||
, BlockCount(0)
|
||||
, BlockExtent(0)
|
||||
, Extent(0)
|
||||
{}
|
||||
|
||||
inline storage_linear::storage_linear(format_type Format, extent_type const & Extent, size_type Layers, size_type Faces, size_type Levels)
|
||||
: Layers(Layers)
|
||||
, Faces(Faces)
|
||||
, Levels(Levels)
|
||||
, BlockSize(gli::block_size(Format))
|
||||
, BlockCount(glm::max(Extent / gli::block_extent(Format), extent_type(1)))
|
||||
, BlockExtent(gli::block_extent(Format))
|
||||
, Extent(Extent)
|
||||
{
|
||||
GLI_ASSERT(Layers > 0);
|
||||
GLI_ASSERT(Faces > 0);
|
||||
GLI_ASSERT(Levels > 0);
|
||||
GLI_ASSERT(glm::all(glm::greaterThan(Extent, extent_type(0))));
|
||||
|
||||
this->Data.resize(this->layer_size(0, Faces - 1, 0, Levels - 1) * Layers, 0);
|
||||
}
|
||||
|
||||
inline bool storage_linear::empty() const
|
||||
{
|
||||
return this->Data.empty();
|
||||
}
|
||||
|
||||
inline storage_linear::size_type storage_linear::layers() const
|
||||
{
|
||||
return this->Layers;
|
||||
}
|
||||
|
||||
inline storage_linear::size_type storage_linear::faces() const
|
||||
{
|
||||
return this->Faces;
|
||||
}
|
||||
|
||||
inline storage_linear::size_type storage_linear::levels() const
|
||||
{
|
||||
return this->Levels;
|
||||
}
|
||||
|
||||
inline storage_linear::size_type storage_linear::block_size() const
|
||||
{
|
||||
return this->BlockSize;
|
||||
}
|
||||
|
||||
inline storage_linear::extent_type storage_linear::block_extent() const
|
||||
{
|
||||
return this->BlockExtent;
|
||||
}
|
||||
|
||||
inline storage_linear::extent_type storage_linear::block_count(size_type Level) const
|
||||
{
|
||||
GLI_ASSERT(Level >= 0 && Level < this->Levels);
|
||||
|
||||
return glm::max(this->BlockCount >> storage_linear::extent_type(static_cast<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
|
98
test/external/gli/core/storage_linear.hpp
vendored
Normal file
98
test/external/gli/core/storage_linear.hpp
vendored
Normal file
@ -0,0 +1,98 @@
|
||||
#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"
|
186
test/external/gli/core/storage_linear.inl
vendored
Normal file
186
test/external/gli/core/storage_linear.inl
vendored
Normal file
@ -0,0 +1,186 @@
|
||||
namespace gli
|
||||
{
|
||||
inline storage_linear::storage_linear()
|
||||
: Layers(0)
|
||||
, Faces(0)
|
||||
, Levels(0)
|
||||
, BlockSize(0)
|
||||
, BlockCount(0)
|
||||
, BlockExtent(0)
|
||||
, Extent(0)
|
||||
{}
|
||||
|
||||
inline storage_linear::storage_linear(format_type Format, extent_type const& Extent, size_type Layers, size_type Faces, size_type Levels)
|
||||
: Layers(Layers)
|
||||
, Faces(Faces)
|
||||
, Levels(Levels)
|
||||
, BlockSize(gli::block_size(Format))
|
||||
, BlockCount(glm::ceilMultiple(Extent, gli::block_extent(Format)) / gli::block_extent(Format))
|
||||
, BlockExtent(gli::block_extent(Format))
|
||||
, Extent(Extent)
|
||||
{
|
||||
GLI_ASSERT(Layers > 0);
|
||||
GLI_ASSERT(Faces > 0);
|
||||
GLI_ASSERT(Levels > 0);
|
||||
GLI_ASSERT(glm::all(glm::greaterThan(Extent, extent_type(0))));
|
||||
|
||||
this->Data.resize(this->layer_size(0, Faces - 1, 0, Levels - 1) * Layers, 0);
|
||||
}
|
||||
|
||||
inline bool storage_linear::empty() const
|
||||
{
|
||||
return this->Data.empty();
|
||||
}
|
||||
|
||||
inline storage_linear::size_type storage_linear::layers() const
|
||||
{
|
||||
return this->Layers;
|
||||
}
|
||||
|
||||
inline storage_linear::size_type storage_linear::faces() const
|
||||
{
|
||||
return this->Faces;
|
||||
}
|
||||
|
||||
inline storage_linear::size_type storage_linear::levels() const
|
||||
{
|
||||
return this->Levels;
|
||||
}
|
||||
|
||||
inline storage_linear::size_type storage_linear::block_size() const
|
||||
{
|
||||
return this->BlockSize;
|
||||
}
|
||||
|
||||
inline storage_linear::extent_type storage_linear::block_extent() const
|
||||
{
|
||||
return this->BlockExtent;
|
||||
}
|
||||
|
||||
inline storage_linear::extent_type storage_linear::block_count(size_type Level) const
|
||||
{
|
||||
GLI_ASSERT(Level >= 0 && Level < this->Levels);
|
||||
|
||||
return glm::ceilMultiple(this->extent(Level), BlockExtent) / BlockExtent;
|
||||
}
|
||||
|
||||
inline storage_linear::extent_type storage_linear::extent(size_type Level) const
|
||||
{
|
||||
GLI_ASSERT(Level >= 0 && Level < this->Levels);
|
||||
|
||||
return glm::max(this->Extent >> storage_linear::extent_type(static_cast<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
|
410
test/external/gli/core/texture.inl
vendored
Normal file
410
test/external/gli/core/texture.inl
vendored
Normal file
@ -0,0 +1,410 @@
|
||||
#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
|
||||
|
79
test/external/gli/core/texture1d.inl
vendored
Normal file
79
test/external/gli/core/texture1d.inl
vendored
Normal file
@ -0,0 +1,79 @@
|
||||
#include "../levels.hpp"
|
||||
|
||||
namespace gli
|
||||
{
|
||||
inline texture1d::texture1d()
|
||||
{}
|
||||
|
||||
inline texture1d::texture1d(format_type Format, extent_type const& Extent, swizzles_type const& Swizzles)
|
||||
: texture(TARGET_1D, Format, texture::extent_type(Extent.x, 1, 1), 1, 1, gli::levels(Extent), Swizzles)
|
||||
{}
|
||||
|
||||
inline texture1d::texture1d(format_type Format, extent_type const& Extent, size_type Levels, swizzles_type const& Swizzles)
|
||||
: texture(TARGET_1D, Format, texture::extent_type(Extent.x, 1, 1), 1, 1, Levels, Swizzles)
|
||||
{}
|
||||
|
||||
inline texture1d::texture1d(texture const& Texture)
|
||||
: texture(Texture, TARGET_1D, Texture.format())
|
||||
{}
|
||||
|
||||
inline texture1d::texture1d
|
||||
(
|
||||
texture const& Texture,
|
||||
format_type Format,
|
||||
size_type BaseLayer, size_type MaxLayer,
|
||||
size_type BaseFace, size_type MaxFace,
|
||||
size_type BaseLevel, size_type MaxLevel,
|
||||
swizzles_type const& Swizzles
|
||||
)
|
||||
: texture(
|
||||
Texture, TARGET_1D,
|
||||
Format,
|
||||
BaseLayer, MaxLayer,
|
||||
BaseFace, MaxFace,
|
||||
BaseLevel, MaxLevel,
|
||||
Swizzles)
|
||||
{}
|
||||
|
||||
inline texture1d::texture1d
|
||||
(
|
||||
texture1d const& Texture,
|
||||
size_type BaseLevel, size_type MaxLevel
|
||||
)
|
||||
: texture(
|
||||
Texture, TARGET_1D,
|
||||
Texture.format(),
|
||||
Texture.base_layer(), Texture.max_layer(),
|
||||
Texture.base_face(), Texture.max_face(),
|
||||
Texture.base_level() + BaseLevel, Texture.base_level() + MaxLevel)
|
||||
{}
|
||||
|
||||
inline image texture1d::operator[](texture1d::size_type Level) const
|
||||
{
|
||||
GLI_ASSERT(Level < this->levels());
|
||||
|
||||
return image(
|
||||
this->Storage,
|
||||
this->format(),
|
||||
this->base_layer(),
|
||||
this->base_face(),
|
||||
this->base_level() + Level);
|
||||
}
|
||||
|
||||
inline texture1d::extent_type texture1d::extent(size_type Level) const
|
||||
{
|
||||
return extent_type(this->texture::extent(Level));
|
||||
}
|
||||
|
||||
template <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
|
81
test/external/gli/core/texture1d_array.inl
vendored
Normal file
81
test/external/gli/core/texture1d_array.inl
vendored
Normal file
@ -0,0 +1,81 @@
|
||||
#include "../levels.hpp"
|
||||
|
||||
namespace gli
|
||||
{
|
||||
inline texture1d_array::texture1d_array()
|
||||
{}
|
||||
|
||||
inline texture1d_array::texture1d_array(format_type Format, extent_type const& Extent, size_type Layers, swizzles_type const& Swizzles)
|
||||
: texture(TARGET_1D_ARRAY, Format, texture::extent_type(Extent.x, 1, 1), Layers, 1, gli::levels(Extent), Swizzles)
|
||||
{}
|
||||
|
||||
inline texture1d_array::texture1d_array(format_type Format, extent_type const& Extent, size_type Layers, size_type Levels, swizzles_type const& Swizzles)
|
||||
: texture(TARGET_1D_ARRAY, Format, texture::extent_type(Extent.x, 1, 1), Layers, 1, Levels, Swizzles)
|
||||
{}
|
||||
|
||||
inline texture1d_array::texture1d_array(texture const& Texture)
|
||||
: texture(Texture, TARGET_1D_ARRAY, Texture.format())
|
||||
{}
|
||||
|
||||
inline texture1d_array::texture1d_array
|
||||
(
|
||||
texture const& Texture,
|
||||
format_type Format,
|
||||
size_type BaseLayer, size_type MaxLayer,
|
||||
size_type BaseFace, size_type MaxFace,
|
||||
size_type BaseLevel, size_type MaxLevel,
|
||||
swizzles_type const& Swizzles
|
||||
)
|
||||
: texture(
|
||||
Texture, TARGET_1D_ARRAY, Format,
|
||||
BaseLayer, MaxLayer,
|
||||
BaseFace, MaxFace,
|
||||
BaseLevel, MaxLevel,
|
||||
Swizzles)
|
||||
{}
|
||||
|
||||
inline texture1d_array::texture1d_array
|
||||
(
|
||||
texture1d_array const& Texture,
|
||||
size_type BaseLayer, size_type MaxLayer,
|
||||
size_type BaseLevel, size_type MaxLevel
|
||||
)
|
||||
: texture(
|
||||
Texture, TARGET_1D_ARRAY,
|
||||
Texture.format(),
|
||||
Texture.base_layer() + BaseLayer, Texture.base_layer() + MaxLayer,
|
||||
Texture.base_face(), Texture.max_face(),
|
||||
Texture.base_level() + BaseLevel, Texture.base_level() + MaxLevel)
|
||||
{}
|
||||
|
||||
inline texture1d texture1d_array::operator[](size_type Layer) const
|
||||
{
|
||||
GLI_ASSERT(!this->empty());
|
||||
GLI_ASSERT(Layer < this->layers());
|
||||
|
||||
return texture1d(
|
||||
*this, this->format(),
|
||||
this->base_layer() + Layer, this->base_layer() + Layer,
|
||||
this->base_face(), this->max_face(),
|
||||
this->base_level(), this->max_level());
|
||||
}
|
||||
|
||||
inline texture1d_array::extent_type texture1d_array::extent(size_type Level) const
|
||||
{
|
||||
return extent_type(this->texture::extent(Level));
|
||||
}
|
||||
|
||||
template <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
|
||||
|
||||
|
122
test/external/gli/core/texture2d.hpp
vendored
122
test/external/gli/core/texture2d.hpp
vendored
@ -1,122 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2010-01-09
|
||||
// Updated : 2010-01-09
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/core/texture2d.hpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLI_CORE_TEXTURE2D_INCLUDED
|
||||
#define GLI_CORE_TEXTURE2D_INCLUDED
|
||||
|
||||
#include "image2d.hpp"
|
||||
|
||||
namespace gli
|
||||
{
|
||||
enum comp
|
||||
{
|
||||
X = 0,
|
||||
R = 0,
|
||||
S = 0,
|
||||
Y = 1,
|
||||
G = 1,
|
||||
T = 1,
|
||||
Z = 2,
|
||||
B = 2,
|
||||
P = 2,
|
||||
W = 3,
|
||||
A = 3,
|
||||
Q = 3
|
||||
};
|
||||
|
||||
//template <template <typename> class mem>
|
||||
class texture2D
|
||||
{
|
||||
public:
|
||||
typedef image2D::dimensions_type dimensions_type;
|
||||
typedef image2D::texcoord_type texcoord_type;
|
||||
typedef image2D::size_type size_type;
|
||||
typedef image2D::value_type value_type;
|
||||
typedef image2D::format_type format_type;
|
||||
typedef image2D::data_type data_type;
|
||||
typedef std::size_t level_type;
|
||||
|
||||
public:
|
||||
texture2D();
|
||||
|
||||
explicit texture2D(level_type const & Levels);
|
||||
//texture2D(image const & Mipmap, bool GenerateMipmaps = false);
|
||||
|
||||
~texture2D();
|
||||
|
||||
image2D & operator[] (
|
||||
level_type const & Level);
|
||||
image2D const & operator[] (
|
||||
level_type const & Level) const;
|
||||
|
||||
bool empty() const;
|
||||
format_type format() const;
|
||||
level_type levels() const;
|
||||
void resize(level_type const & Levels);
|
||||
|
||||
template <typename genType>
|
||||
void swizzle(gli::comp X, gli::comp Y, gli::comp Z, gli::comp W);
|
||||
|
||||
private:
|
||||
std::vector<image2D> Images;
|
||||
};
|
||||
|
||||
//namespace wip
|
||||
//{
|
||||
// // plain
|
||||
// template <typename genType>
|
||||
// class plain
|
||||
// {
|
||||
// public:
|
||||
//
|
||||
// private:
|
||||
// boost::shared_array<genType> Data;
|
||||
// };
|
||||
//
|
||||
// // texture2D
|
||||
// template
|
||||
// <
|
||||
// typename genType,
|
||||
// template <typename> class surface = plain
|
||||
// >
|
||||
// class texture2D
|
||||
// {
|
||||
// public:
|
||||
// typedef genType value_type;
|
||||
//
|
||||
// private:
|
||||
// class image_impl
|
||||
// {
|
||||
// public:
|
||||
// template <typename coordType>
|
||||
// value_type const & operator() (coordType const & Coord) const;
|
||||
//
|
||||
// private:
|
||||
// surface<value_type> Surface;
|
||||
// };
|
||||
//
|
||||
// public:
|
||||
// typedef image_impl image;
|
||||
// typedef std::vector<image> mipmaps;
|
||||
// typedef typename mipmaps::size_type level_type;
|
||||
//
|
||||
// level_type levels() const;
|
||||
// image & operator[] (level_type Level);
|
||||
// image const & operator[] (level_type Level) const;
|
||||
//
|
||||
// private:
|
||||
// mipmaps Mipmaps;
|
||||
// };
|
||||
//
|
||||
//}//namespace wip
|
||||
}//namespace gli
|
||||
|
||||
#include "texture2d.inl"
|
||||
|
||||
#endif//GLI_CORE_TEXTURE2D_INCLUDED
|
335
test/external/gli/core/texture2d.inl
vendored
335
test/external/gli/core/texture2d.inl
vendored
@ -1,304 +1,77 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2010-09-27
|
||||
// Updated : 2010-09-27
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/core/texture2D.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#include "../levels.hpp"
|
||||
|
||||
namespace gli
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
inline texture2D::size_type sizeLinear
|
||||
(
|
||||
texture2D const & Texture
|
||||
)
|
||||
{
|
||||
texture2D::size_type Result = 0;
|
||||
for(texture2D::level_type Level = 0; Level < Texture.levels(); ++Level)
|
||||
Result += sizeLinear(Texture[Level]);
|
||||
return Result;
|
||||
}
|
||||
}//namespace detail
|
||||
|
||||
inline texture2D::texture2D()
|
||||
inline texture2d::texture2d()
|
||||
{}
|
||||
|
||||
inline texture2D::texture2D
|
||||
(
|
||||
level_type const & Levels
|
||||
)
|
||||
{
|
||||
this->Images.resize(Levels);
|
||||
}
|
||||
|
||||
//inline texture2D::texture2D
|
||||
//(
|
||||
// image const & Mipmap,
|
||||
// bool GenerateMipmaps // ToDo
|
||||
//)
|
||||
//{
|
||||
// //std::size_t Levels = !GenerateMipmaps ? 1 : std::size_t(glm::log2(float(glm::max(Mipmap.width(), Mipmap.height()))));
|
||||
// texture2D::level_type Levels = !GenerateMipmaps ? 1 : std::size_t(glm::log2(float(glm::compMax(Mipmap.dimensions()))));
|
||||
// this->Mipmaps.resize(Levels);
|
||||
// this->Mipmaps[0] = Mipmap;
|
||||
|
||||
// if(GenerateMipmaps)
|
||||
// this->generateMipmaps(0);
|
||||
//}
|
||||
|
||||
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 image2D & texture2D::operator[] (level_type const & Level)
|
||||
{
|
||||
return this->Images[Level];
|
||||
}
|
||||
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 image2D const & texture2D::operator[] (level_type const & Level) const
|
||||
{
|
||||
return this->Images[Level];
|
||||
}
|
||||
inline texture2d::texture2d(texture const& Texture)
|
||||
: texture(Texture, TARGET_2D, Texture.format())
|
||||
{}
|
||||
|
||||
inline bool texture2D::empty() const
|
||||
{
|
||||
return this->Images.size() == 0;
|
||||
}
|
||||
|
||||
inline texture2D::format_type texture2D::format() const
|
||||
{
|
||||
return this->Images.empty() ? FORMAT_NULL : this->Images[0].format();
|
||||
}
|
||||
|
||||
inline texture2D::level_type texture2D::levels() const
|
||||
{
|
||||
return this->Images.size();
|
||||
}
|
||||
|
||||
inline void texture2D::resize
|
||||
inline texture2d::texture2d
|
||||
(
|
||||
texture2D::level_type const & Levels
|
||||
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
|
||||
)
|
||||
{
|
||||
this->Images.resize(Levels);
|
||||
}
|
||||
: texture(
|
||||
Texture, TARGET_2D, Format,
|
||||
BaseLayer, MaxLayer,
|
||||
BaseFace, MaxFace,
|
||||
BaseLevel, MaxLevel,
|
||||
Swizzles)
|
||||
{}
|
||||
|
||||
template <typename genType>
|
||||
inline void texture2D::swizzle(gli::comp X, gli::comp Y, gli::comp Z, gli::comp W)
|
||||
{
|
||||
for(texture2D::level_type Level = 0; Level < this->levels(); ++Level)
|
||||
{
|
||||
genType * Data = reinterpret_cast<genType*>(this->Images[Level].data());
|
||||
texture2D::size_type Components = this->Images[Level].components();
|
||||
//gli::detail::getComponents(this->Images[Level].format());
|
||||
texture2D::size_type Size = (glm::compMul(this->Images[Level].dimensions()) * Components) / sizeof(genType);
|
||||
|
||||
for(texture2D::size_type i = 0; i < Size; ++i)
|
||||
{
|
||||
genType Copy = Data[i];
|
||||
if(Components > 0)
|
||||
Data[i][0] = Copy[X];
|
||||
if(Components > 1)
|
||||
Data[i][1] = Copy[Y];
|
||||
if(Components > 2)
|
||||
Data[i][2] = Copy[Z];
|
||||
if(Components > 3)
|
||||
Data[i][3] = Copy[W];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
template <typename T>
|
||||
inline T texture<T>::texture(float x, float y) const
|
||||
{
|
||||
size_type x_below = size_type(std::floor(x * (_width - 1)));
|
||||
size_type x_above = size_type(std::ceil(x * (_width - 1)));
|
||||
size_type y_below = size_type(std::floor(y * (_height - 1)));
|
||||
size_type y_above = size_type(std::ceil(y * (_height - 1)));
|
||||
|
||||
float x_step = 1.0f / float(_width);
|
||||
float y_step = 1.0f / float(_height);
|
||||
|
||||
float x_below_normalized = float(x_below) / float(_width - 1);
|
||||
float x_above_normalized = float(x_above) / float(_width - 1);
|
||||
float y_below_normalized = float(y_below) / float(_height - 1);
|
||||
float y_above_normalized = float(y_above) / float(_height - 1);
|
||||
|
||||
T value1 = _data[x_below + y_below * _width];
|
||||
T value2 = _data[x_above + y_below * _width];
|
||||
T value3 = _data[x_above + y_above * _width];
|
||||
T value4 = _data[x_below + y_above * _width];
|
||||
|
||||
T valueA = glm::mix(value1, value2, x - x_below_normalized);
|
||||
T valueB = glm::mix(value4, value3, x - x_below_normalized);
|
||||
T valueC = glm::mix(valueA, valueB, y - y_below_normalized);
|
||||
return valueC;
|
||||
}
|
||||
*/
|
||||
/*
|
||||
template <typename T>
|
||||
inline T texture(const texture2D<T>& Image2D, const glm::vec2& TexCoord)
|
||||
{
|
||||
texture2D<T>::size_type s_below = texture2D<T>::size_type(std::floor(TexCoord.s * (Image2D.width() - 1)));
|
||||
texture2D<T>::size_type s_above = texture2D<T>::size_type(std::ceil(TexCoord.s * (Image2D.width() - 1)));
|
||||
texture2D<T>::size_type t_below = texture2D<T>::size_type(std::floor(TexCoord.t * (Image2D.height() - 1)));
|
||||
texture2D<T>::size_type t_above = texture2D<T>::size_type(std::ceil(TexCoord.t * (Image2D.height() - 1)));
|
||||
|
||||
glm::vec2::value_type s_step = 1.0f / glm::vec2::value_type(Image2D.width());
|
||||
glm::vec2::value_type t_step = 1.0f / glm::vec2::value_type(Image2D.height());
|
||||
|
||||
glm::vec2::value_type s_below_normalized = glm::vec2::value_type(s_below) / glm::vec2::value_type(Image2D.width() - 1);
|
||||
glm::vec2::value_type s_above_normalized = glm::vec2::value_type(s_above) / glm::vec2::value_type(Image2D.width() - 1);
|
||||
glm::vec2::value_type t_below_normalized = glm::vec2::value_type(t_below) / glm::vec2::value_type(Image2D.height() - 1);
|
||||
glm::vec2::value_type t_above_normalized = glm::vec2::value_type(t_above) / glm::vec2::value_type(Image2D.height() - 1);
|
||||
|
||||
T value1 = Image2D[s_below + t_below * Image2D.width()];
|
||||
T value2 = Image2D[s_above + t_below * Image2D.width()];
|
||||
T value3 = Image2D[s_above + t_above * Image2D.width()];
|
||||
T value4 = Image2D[s_below + t_above * Image2D.width()];
|
||||
|
||||
T valueA = glm::mix(value1, value2, TexCoord.s - s_below_normalized);
|
||||
T valueB = glm::mix(value4, value3, TexCoord.s - s_below_normalized);
|
||||
T valueC = glm::mix(valueA, valueB, TexCoord.t - t_below_normalized);
|
||||
return valueC;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline T textureNearest(const texture2D<T>& Image2D, const glm::vec2& TexCoord)
|
||||
{
|
||||
texture2D<T>::size_type s = texture2D<T>::size_type(glm::roundGTX(TexCoord.s * (Image2D.width() - 1)));
|
||||
texture2D<T>::size_type t = texture2D<T>::size_type(std::roundGTX(TexCoord.t * (Image2D.height() - 1)));
|
||||
|
||||
return Image2D[s + t * Image2D.width()];
|
||||
}
|
||||
*/
|
||||
|
||||
namespace wip
|
||||
{
|
||||
////////////////
|
||||
// image
|
||||
/*
|
||||
//
|
||||
template
|
||||
<
|
||||
typename coordType
|
||||
>
|
||||
template
|
||||
<
|
||||
typename genType,
|
||||
template <typename> class surface
|
||||
>
|
||||
typename texture2D<genType, surface>::value_type &
|
||||
texture2D<genType, surface>::image_impl<coordType>::operator()
|
||||
inline texture2d::texture2d
|
||||
(
|
||||
coordType const & Coord
|
||||
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);
|
||||
}
|
||||
*/
|
||||
/*
|
||||
//
|
||||
template
|
||||
<
|
||||
typename coordType
|
||||
>
|
||||
template
|
||||
<
|
||||
typename genType,
|
||||
template <typename> class surface
|
||||
>
|
||||
typename texture2D<genType, surface>::value_type const &
|
||||
texture2D<genType, surface>::image_impl::operator()
|
||||
(
|
||||
coordType const & Coord
|
||||
) const
|
||||
|
||||
inline texture2d::extent_type texture2d::extent(size_type Level) const
|
||||
{
|
||||
return value_type(0);
|
||||
return extent_type(this->texture::extent(Level));
|
||||
}
|
||||
*/
|
||||
/*
|
||||
//
|
||||
template
|
||||
<
|
||||
typename coordType
|
||||
>
|
||||
template
|
||||
<
|
||||
typename genType,
|
||||
template <typename> class surface
|
||||
>
|
||||
void texture2D<genType, surface>::image_impl::operator()
|
||||
(
|
||||
coordType const & Coord
|
||||
) const
|
||||
|
||||
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 genType,
|
||||
// template <typename> class surface
|
||||
//>
|
||||
//template
|
||||
//<
|
||||
// typename coordType
|
||||
//>
|
||||
//typename texture2D<genType, surface>::value_type const &
|
||||
//texture2D<genType, surface>::image_impl::operator()
|
||||
//(
|
||||
// coordType const & Coord
|
||||
//) const
|
||||
//{
|
||||
// return value_type(0);
|
||||
//}
|
||||
|
||||
//////////////////
|
||||
//// texture2D
|
||||
|
||||
////
|
||||
//template
|
||||
//<
|
||||
// typename genType,
|
||||
// template <typename> class surface
|
||||
//>
|
||||
//typename texture2D<genType, surface>::level_type texture2D<genType, surface>::levels() const
|
||||
//{
|
||||
// return this->Mipmaps.size();
|
||||
//}
|
||||
|
||||
////
|
||||
//template
|
||||
//<
|
||||
// typename genType,
|
||||
// template <typename> class surface
|
||||
//>
|
||||
//typename texture2D<genType, surface>::image & texture2D<genType, surface>::operator[]
|
||||
//(
|
||||
// typename texture2D<genType, surface>::level_type Level
|
||||
//)
|
||||
//{
|
||||
// return this->Mipmaps[Level];
|
||||
//}
|
||||
|
||||
////
|
||||
//template
|
||||
//<
|
||||
// typename genType,
|
||||
// template <typename> class surface
|
||||
//>
|
||||
//typename texture2D<genType, surface>::image const & texture2D<genType, surface>::operator[]
|
||||
//(
|
||||
// typename texture2D<genType, surface>::level_type Level
|
||||
//) const
|
||||
//{
|
||||
// return this->Mipmaps[Level];
|
||||
//}
|
||||
|
||||
}//namespace wip
|
||||
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
|
||||
|
59
test/external/gli/core/texture2d_array.hpp
vendored
59
test/external/gli/core/texture2d_array.hpp
vendored
@ -1,59 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2011-04-06
|
||||
// Updated : 2011-04-06
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/core/texture2d_array.hpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLI_CORE_TEXTURE2D_ARRAY_INCLUDED
|
||||
#define GLI_CORE_TEXTURE2D_ARRAY_INCLUDED
|
||||
|
||||
#include "texture2d.hpp"
|
||||
|
||||
namespace gli
|
||||
{
|
||||
class texture2DArray
|
||||
{
|
||||
public:
|
||||
typedef texture2D::dimensions_type dimensions_type;
|
||||
typedef texture2D::texcoord_type texcoord_type;
|
||||
typedef texture2D::size_type size_type;
|
||||
typedef texture2D::value_type value_type;
|
||||
typedef texture2D::format_type format_type;
|
||||
typedef texture2D::data_type data_type;
|
||||
typedef texture2D::level_type level_type;
|
||||
typedef std::vector<texture2D>::size_type layer_type;
|
||||
|
||||
public:
|
||||
texture2DArray();
|
||||
|
||||
explicit texture2DArray(
|
||||
layer_type const & Layers,
|
||||
level_type const & Levels);
|
||||
|
||||
~texture2DArray();
|
||||
|
||||
texture2D & operator[] (
|
||||
layer_type const & Layer);
|
||||
texture2D const & operator[] (
|
||||
layer_type const & Layer) const;
|
||||
|
||||
bool empty() const;
|
||||
format_type format() const;
|
||||
layer_type layers() const;
|
||||
level_type levels() const;
|
||||
void resize(
|
||||
layer_type const & Layers,
|
||||
level_type const & Levels);
|
||||
|
||||
private:
|
||||
std::vector<texture2D> Arrays;
|
||||
};
|
||||
|
||||
}//namespace gli
|
||||
|
||||
#include "texture2d_array.inl"
|
||||
|
||||
#endif//GLI_CORE_TEXTURE2D_ARRAY_INCLUDED
|
125
test/external/gli/core/texture2d_array.inl
vendored
125
test/external/gli/core/texture2d_array.inl
vendored
@ -1,78 +1,79 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2011-04-06
|
||||
// Updated : 2011-04-06
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/core/texture_cube.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#include "../levels.hpp"
|
||||
|
||||
namespace gli
|
||||
{
|
||||
inline texture2DArray::texture2DArray()
|
||||
inline texture2d_array::texture2d_array()
|
||||
{}
|
||||
|
||||
inline texture2DArray::texture2DArray
|
||||
(
|
||||
texture2DArray::layer_type const & Layers,
|
||||
texture2DArray::level_type const & Levels
|
||||
)
|
||||
{
|
||||
this->Arrays.resize(Layers);
|
||||
for(texture2DArray::size_type i = 0; i < this->Arrays.size(); ++i)
|
||||
this->Arrays[i].resize(Levels);
|
||||
}
|
||||
|
||||
inline texture2DArray::~texture2DArray()
|
||||
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 & texture2DArray::operator[]
|
||||
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
|
||||
(
|
||||
layer_type const & Layer
|
||||
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
|
||||
)
|
||||
{
|
||||
return this->Arrays[Layer];
|
||||
}
|
||||
: texture(
|
||||
Texture, TARGET_2D_ARRAY,
|
||||
Format,
|
||||
BaseLayer, MaxLayer,
|
||||
BaseFace, MaxFace,
|
||||
BaseLevel, MaxLevel,
|
||||
Swizzles)
|
||||
{}
|
||||
|
||||
inline texture2D const & texture2DArray::operator[]
|
||||
inline texture2d_array::texture2d_array
|
||||
(
|
||||
layer_type const & Layer
|
||||
) const
|
||||
{
|
||||
return this->Arrays[Layer];
|
||||
}
|
||||
|
||||
inline bool texture2DArray::empty() const
|
||||
{
|
||||
return this->Arrays.empty();
|
||||
}
|
||||
|
||||
inline texture2DArray::format_type texture2DArray::format() const
|
||||
{
|
||||
return this->Arrays.empty() ? FORMAT_NULL : this->Arrays[0].format();
|
||||
}
|
||||
|
||||
inline texture2DArray::layer_type texture2DArray::layers() const
|
||||
{
|
||||
return this->Arrays.size();
|
||||
}
|
||||
|
||||
inline texture2DArray::level_type texture2DArray::levels() const
|
||||
{
|
||||
if(this->empty())
|
||||
return 0;
|
||||
return this->Arrays[0].levels();
|
||||
}
|
||||
|
||||
inline void texture2DArray::resize
|
||||
(
|
||||
texture2DArray::layer_type const & Layers,
|
||||
texture2DArray::level_type const & Levels
|
||||
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
|
||||
{
|
||||
this->Arrays.resize(Layers);
|
||||
for(texture2DArray::layer_type i = 0; i < this->Arrays.size(); ++i)
|
||||
this->Arrays[i].resize(Levels);
|
||||
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
|
||||
|
77
test/external/gli/core/texture3d.inl
vendored
Normal file
77
test/external/gli/core/texture3d.inl
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
#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
|
65
test/external/gli/core/texture_cube.hpp
vendored
65
test/external/gli/core/texture_cube.hpp
vendored
@ -1,65 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2011-04-06
|
||||
// Updated : 2011-04-06
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/core/texture_cube.hpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLI_CORE_TEXTURE_CUBE_INCLUDED
|
||||
#define GLI_CORE_TEXTURE_CUBE_INCLUDED
|
||||
|
||||
#include "texture2d.hpp"
|
||||
|
||||
namespace gli
|
||||
{
|
||||
enum face
|
||||
{
|
||||
POSITIVE_X,
|
||||
NEGATIVE_X,
|
||||
POSITIVE_Y,
|
||||
NEGATIVE_Y,
|
||||
POSITIVE_Z,
|
||||
NEGATIVE_Z,
|
||||
FACE_MAX
|
||||
};
|
||||
|
||||
class textureCube
|
||||
{
|
||||
public:
|
||||
typedef texture2D::dimensions_type dimensions_type;
|
||||
typedef texture2D::texcoord_type texcoord_type;
|
||||
typedef texture2D::size_type size_type;
|
||||
typedef texture2D::value_type value_type;
|
||||
typedef texture2D::format_type format_type;
|
||||
typedef texture2D::data_type data_type;
|
||||
typedef texture2D::level_type level_type;
|
||||
typedef face face_type;
|
||||
|
||||
public:
|
||||
textureCube();
|
||||
|
||||
explicit textureCube(level_type const & Levels);
|
||||
|
||||
~textureCube();
|
||||
|
||||
texture2D & operator[] (
|
||||
face_type const & Face);
|
||||
texture2D const & operator[] (
|
||||
face_type const & Face) const;
|
||||
|
||||
bool empty() const;
|
||||
format_type format() const;
|
||||
level_type levels() const;
|
||||
void resize(level_type const & Levels);
|
||||
|
||||
private:
|
||||
std::vector<texture2D> Faces;
|
||||
};
|
||||
|
||||
}//namespace gli
|
||||
|
||||
#include "texture_cube.inl"
|
||||
|
||||
#endif//GLI_CORE_TEXTURE_CUBE_INCLUDED
|
115
test/external/gli/core/texture_cube.inl
vendored
115
test/external/gli/core/texture_cube.inl
vendored
@ -1,70 +1,75 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2011-04-06
|
||||
// Updated : 2011-04-06
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/core/texture_cube.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace gli
|
||||
{
|
||||
inline textureCube::textureCube()
|
||||
inline texture_cube::texture_cube()
|
||||
{}
|
||||
|
||||
inline textureCube::textureCube
|
||||
(
|
||||
level_type const & Levels
|
||||
)
|
||||
{
|
||||
this->Faces.resize(FACE_MAX);
|
||||
for(textureCube::size_type i = 0; i < FACE_MAX; ++i)
|
||||
this->Faces[i].resize(Levels);
|
||||
}
|
||||
|
||||
inline textureCube::~textureCube()
|
||||
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 texture2D & textureCube::operator[]
|
||||
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
|
||||
(
|
||||
face_type const & Face
|
||||
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
|
||||
)
|
||||
{
|
||||
return this->Faces[Face];
|
||||
}
|
||||
: texture(
|
||||
Texture, TARGET_CUBE, Format,
|
||||
BaseLayer, MaxLayer,
|
||||
BaseFace, MaxFace,
|
||||
BaseLevel, MaxLevel,
|
||||
Swizzles)
|
||||
{}
|
||||
|
||||
inline texture2D const & textureCube::operator[]
|
||||
inline texture_cube::texture_cube
|
||||
(
|
||||
face_type const & Face
|
||||
) const
|
||||
{
|
||||
return this->Faces[Face];
|
||||
}
|
||||
|
||||
inline bool textureCube::empty() const
|
||||
{
|
||||
return this->Faces.size() == 0;
|
||||
}
|
||||
|
||||
inline textureCube::format_type textureCube::format() const
|
||||
{
|
||||
return this->Faces.empty() ? FORMAT_NULL : this->Faces[0].format();
|
||||
}
|
||||
|
||||
inline textureCube::level_type textureCube::levels() const
|
||||
{
|
||||
if(this->empty())
|
||||
return 0;
|
||||
return this->Faces[POSITIVE_X].levels();
|
||||
}
|
||||
|
||||
inline void textureCube::resize
|
||||
(
|
||||
level_type const & Levels
|
||||
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
|
||||
{
|
||||
for(textureCube::size_type i = 0; i < FACE_MAX; ++i)
|
||||
this->Faces[i].resize(Levels);
|
||||
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
|
||||
|
59
test/external/gli/core/texture_cube_array.hpp
vendored
59
test/external/gli/core/texture_cube_array.hpp
vendored
@ -1,59 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2011-04-06
|
||||
// Updated : 2011-04-06
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/core/texture_cube_array.hpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLI_CORE_TEXTURE_CUBE_ARRAY_INCLUDED
|
||||
#define GLI_CORE_TEXTURE_CUBE_ARRAY_INCLUDED
|
||||
|
||||
#include "texture_cube.hpp"
|
||||
|
||||
namespace gli
|
||||
{
|
||||
class textureCubeArray
|
||||
{
|
||||
public:
|
||||
typedef textureCube::dimensions_type dimensions_type;
|
||||
typedef textureCube::texcoord_type texcoord_type;
|
||||
typedef textureCube::size_type size_type;
|
||||
typedef textureCube::value_type value_type;
|
||||
typedef textureCube::format_type format_type;
|
||||
typedef std::vector<textureCube> data_type;
|
||||
typedef textureCube::level_type level_type;
|
||||
typedef data_type::size_type layer_type;
|
||||
|
||||
public:
|
||||
textureCubeArray();
|
||||
|
||||
explicit textureCubeArray(
|
||||
layer_type const & Layers,
|
||||
level_type const & Levels);
|
||||
|
||||
~textureCubeArray();
|
||||
|
||||
textureCube & operator[] (
|
||||
layer_type const & Layer);
|
||||
textureCube const & operator[] (
|
||||
layer_type const & Layer) const;
|
||||
|
||||
bool empty() const;
|
||||
format_type format() const;
|
||||
layer_type layers() const;
|
||||
level_type levels() const;
|
||||
void resize(
|
||||
layer_type const & Layers,
|
||||
level_type const & Levels);
|
||||
|
||||
private:
|
||||
data_type Arrays;
|
||||
};
|
||||
|
||||
}//namespace gli
|
||||
|
||||
#include "texture_cube_array.inl"
|
||||
|
||||
#endif//GLI_CORE_TEXTURE_CUBE_ARRAY_INCLUDED
|
119
test/external/gli/core/texture_cube_array.inl
vendored
119
test/external/gli/core/texture_cube_array.inl
vendored
@ -1,72 +1,77 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2011-04-06
|
||||
// Updated : 2011-04-06
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/core/texture_cube_array.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace gli
|
||||
{
|
||||
inline textureCubeArray::textureCubeArray()
|
||||
inline texture_cube_array::texture_cube_array()
|
||||
{}
|
||||
|
||||
inline textureCubeArray::textureCubeArray
|
||||
(
|
||||
layer_type const & Layers,
|
||||
level_type const & Levels
|
||||
)
|
||||
{
|
||||
this->Arrays.resize(Layers);
|
||||
for(textureCubeArray::size_type i = 0; i < this->Arrays.size(); ++i)
|
||||
this->Arrays[i].resize(Levels);
|
||||
}
|
||||
|
||||
inline textureCubeArray::~textureCubeArray()
|
||||
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 textureCube & textureCubeArray::operator[]
|
||||
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
|
||||
(
|
||||
layer_type const & Layer
|
||||
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
|
||||
)
|
||||
{
|
||||
return this->Arrays[Layer];
|
||||
}
|
||||
: texture(
|
||||
Texture, TARGET_CUBE_ARRAY,
|
||||
Format,
|
||||
BaseLayer, MaxLayer,
|
||||
BaseFace, MaxFace,
|
||||
BaseLevel, MaxLevel,
|
||||
Swizzles)
|
||||
{}
|
||||
|
||||
inline textureCube const & textureCubeArray::operator[]
|
||||
inline texture_cube_array::texture_cube_array
|
||||
(
|
||||
layer_type const & Layer
|
||||
) const
|
||||
{
|
||||
return this->Arrays[Layer];
|
||||
}
|
||||
|
||||
inline bool textureCubeArray::empty() const
|
||||
{
|
||||
return this->Arrays.empty();
|
||||
}
|
||||
|
||||
inline textureCubeArray::format_type textureCubeArray::format() const
|
||||
{
|
||||
return this->Arrays.empty() ? FORMAT_NULL : this->Arrays[0].format();
|
||||
}
|
||||
|
||||
inline textureCubeArray::level_type textureCubeArray::levels() const
|
||||
{
|
||||
if(this->empty())
|
||||
return 0;
|
||||
return this->Arrays[0].levels();
|
||||
}
|
||||
|
||||
inline void textureCubeArray::resize
|
||||
(
|
||||
layer_type const & Layers,
|
||||
level_type const & Levels
|
||||
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
|
||||
{
|
||||
for(textureCubeArray::size_type i = 0; i < this->Arrays.size(); ++i)
|
||||
this->Arrays[i].resize(Levels);
|
||||
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
|
||||
|
257
test/external/gli/core/transform.inl
vendored
Normal file
257
test/external/gli/core/transform.inl
vendored
Normal file
@ -0,0 +1,257 @@
|
||||
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
|
169
test/external/gli/core/view.inl
vendored
Normal file
169
test/external/gli/core/view.inl
vendored
Normal file
@ -0,0 +1,169 @@
|
||||
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
|
392
test/external/gli/core/workaround.hpp
vendored
Normal file
392
test/external/gli/core/workaround.hpp
vendored
Normal file
@ -0,0 +1,392 @@
|
||||
#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 tvec4<uint16, P> pack(tvec4<float, P> const & v)
|
||||
{
|
||||
tvec4<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 tvec4<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 tvec4<float, P> unpack(tvec4<uint16, P> const & v)
|
||||
{
|
||||
return tvec4<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
|
||||
|
70
test/external/gli/duplicate.hpp
vendored
Normal file
70
test/external/gli/duplicate.hpp
vendored
Normal file
@ -0,0 +1,70 @@
|
||||
/// @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"
|
490
test/external/gli/dx.hpp
vendored
Normal file
490
test/external/gli/dx.hpp
vendored
Normal file
@ -0,0 +1,490 @@
|
||||
/// @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"
|
340
test/external/gli/format.hpp
vendored
Normal file
340
test/external/gli/format.hpp
vendored
Normal file
@ -0,0 +1,340 @@
|
||||
/// @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::tvec4<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"
|
69
test/external/gli/generate_mipmaps.hpp
vendored
Normal file
69
test/external/gli/generate_mipmaps.hpp
vendored
Normal file
@ -0,0 +1,69 @@
|
||||
/// @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"
|
373
test/external/gli/gl.hpp
vendored
Normal file
373
test/external/gli/gl.hpp
vendored
Normal file
@ -0,0 +1,373 @@
|
||||
/// @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::tvec4<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"
|
95
test/external/gli/gli.hpp
vendored
95
test/external/gli/gli.hpp
vendored
@ -1,31 +1,74 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2008-12-19
|
||||
// Updated : 2010-09-29
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/gli.hpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @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).
|
||||
|
||||
/*! \mainpage OpenGL Image
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#ifndef GLI_GLI_INCLUDED
|
||||
#define GLI_GLI_INCLUDED
|
||||
|
||||
#define GLI_VERSION 31
|
||||
#define GLI_VERSION 82
|
||||
#define GLI_VERSION_MAJOR 0
|
||||
#define GLI_VERSION_MINOR 3
|
||||
#define GLI_VERSION_PATCH 1
|
||||
#define GLI_VERSION_REVISION 0
|
||||
#define GLI_VERSION_MINOR 8
|
||||
#define GLI_VERSION_PATCH 2
|
||||
#define GLI_VERSION_REVISION 1
|
||||
|
||||
#include "./core/texture2d.hpp"
|
||||
#include "./core/texture2d_array.hpp"
|
||||
#include "./core/texture_cube.hpp"
|
||||
#include "./core/texture_cube_array.hpp"
|
||||
#include "./core/size.hpp"
|
||||
#include "./core/operation.hpp"
|
||||
#include "./core/generate_mipmaps.hpp"
|
||||
/// Namespace where all the classes and functions provided by GLI are exposed
|
||||
namespace gli
|
||||
{
|
||||
|
||||
#endif//GLI_GLI_INCLUDED
|
||||
}//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 "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"
|
||||
|
27
test/external/gli/gtx/compression.hpp
vendored
27
test/external/gli/gtx/compression.hpp
vendored
@ -1,27 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2008-12-19
|
||||
// Updated : 2010-01-09
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/gtx/compression.hpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLI_GTX_COMPRESSION_INCLUDED
|
||||
#define GLI_GTX_COMPRESSION_INCLUDED
|
||||
|
||||
namespace gli{
|
||||
namespace gtx{
|
||||
namespace compression
|
||||
{
|
||||
|
||||
|
||||
}//namespace compression
|
||||
}//namespace gtx
|
||||
}//namespace gli
|
||||
|
||||
namespace gli{using namespace gtx::compression;}
|
||||
|
||||
#include "compression.inl"
|
||||
|
||||
#endif//GLI_GTX_COMPRESSION_INCLUDED
|
8
test/external/gli/gtx/compression.inl
vendored
8
test/external/gli/gtx/compression.inl
vendored
@ -1,8 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2008-12-19
|
||||
// Updated : 2010-01-09
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/gtx/compression.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
46
test/external/gli/gtx/fetch.hpp
vendored
46
test/external/gli/gtx/fetch.hpp
vendored
@ -1,46 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2008-12-19
|
||||
// Updated : 2010-09-27
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/gtx/fetch.hpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLI_GTX_FETCH_INCLUDED
|
||||
#define GLI_GTX_FETCH_INCLUDED
|
||||
|
||||
#include "../gli.hpp"
|
||||
|
||||
namespace gli{
|
||||
namespace gtx{
|
||||
namespace fetch
|
||||
{
|
||||
template <typename genType>
|
||||
genType texelFetch(
|
||||
texture2D const & Texture,
|
||||
texture2D::dimensions_type const & Texcoord,
|
||||
texture2D::level_type const & Level);
|
||||
|
||||
template <typename genType>
|
||||
genType textureLod(
|
||||
texture2D const & Texture,
|
||||
texture2D::texcoord_type const & Texcoord,
|
||||
texture2D::level_type const & Level);
|
||||
|
||||
template <typename genType>
|
||||
void texelWrite(
|
||||
texture2D & Texture,
|
||||
texture2D::dimensions_type const & Texcoord,
|
||||
texture2D::level_type const & Level,
|
||||
genType const & Color);
|
||||
|
||||
}//namespace fetch
|
||||
}//namespace gtx
|
||||
}//namespace gli
|
||||
|
||||
namespace gli{using namespace gtx::fetch;}
|
||||
|
||||
#include "fetch.inl"
|
||||
|
||||
#endif//GLI_GTX_FETCH_INCLUDED
|
91
test/external/gli/gtx/fetch.inl
vendored
91
test/external/gli/gtx/fetch.inl
vendored
@ -1,91 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2008-12-19
|
||||
// Updated : 2010-09-27
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/gtx/fetch.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace gli{
|
||||
namespace gtx{
|
||||
namespace fetch
|
||||
{
|
||||
template <typename genType>
|
||||
inline genType texelFetch
|
||||
(
|
||||
texture2D const & Image,
|
||||
texture2D::dimensions_type const & TexCoord,
|
||||
texture2D::level_type const & Level
|
||||
)
|
||||
{
|
||||
assert(Image[Level].format() == R8U || Image[Level].format() == RG8U || Image[Level].format() == RGB8U || Image[Level].format() == RGBA8U);
|
||||
|
||||
texture2D::dimensions_type Dimensions = Image[Level].dimensions();
|
||||
texture2D::value_type const * const Data = Image[Level].data();
|
||||
|
||||
return reinterpret_cast<genType const * const>(Data)[TexCoord.x + TexCoord.y * Dimensions.x];
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
inline genType textureLod
|
||||
(
|
||||
texture2D const & Image,
|
||||
texture2D::texcoord_type const & TexCoord,
|
||||
texture2D::level_type const & Level
|
||||
)
|
||||
{
|
||||
assert(Image[Level].format() == R8U || Image[Level].format() == RG8U || Image[Level].format() == RGB8U || Image[Level].format() == RGBA8U);
|
||||
|
||||
texture2D::dimensions_type Dimensions = Image[Level].dimensions();
|
||||
texture2D::value_type const * const Data = Image[Level].data();
|
||||
|
||||
std::size_t s_below = std::size_t(glm::floor(TexCoord.s * float(Dimensions.x - 1)));
|
||||
std::size_t s_above = std::size_t(glm::ceil( TexCoord.s * float(Dimensions.x - 1)));
|
||||
std::size_t t_below = std::size_t(glm::floor(TexCoord.t * float(Dimensions.y - 1)));
|
||||
std::size_t t_above = std::size_t(glm::ceil( TexCoord.t * float(Dimensions.y - 1)));
|
||||
|
||||
float s_step = 1.0f / float(Dimensions.x);
|
||||
float t_step = 1.0f / float(Dimensions.y);
|
||||
|
||||
float s_below_normalized = s_below / float(Dimensions.x);
|
||||
float s_above_normalized = s_above / float(Dimensions.x);
|
||||
float t_below_normalized = t_below / float(Dimensions.y);
|
||||
float t_above_normalized = t_above / float(Dimensions.y);
|
||||
|
||||
genType Value1 = reinterpret_cast<genType const * const>(Data)[s_below + t_below * Dimensions.x];
|
||||
genType Value2 = reinterpret_cast<genType const * const>(Data)[s_above + t_below * Dimensions.x];
|
||||
genType Value3 = reinterpret_cast<genType const * const>(Data)[s_above + t_above * Dimensions.x];
|
||||
genType Value4 = reinterpret_cast<genType const * const>(Data)[s_below + t_above * Dimensions.x];
|
||||
|
||||
float BlendA = float(TexCoord.s - s_below_normalized) * float(Dimensions.x - 1);
|
||||
float BlendB = float(TexCoord.s - s_below_normalized) * float(Dimensions.x - 1);
|
||||
float BlendC = float(TexCoord.t - t_below_normalized) * float(Dimensions.y - 1);
|
||||
|
||||
genType ValueA(glm::mix(Value1, Value2, BlendA));
|
||||
genType ValueB(glm::mix(Value4, Value3, BlendB));
|
||||
|
||||
return genType(glm::mix(ValueA, ValueB, BlendC));
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
void texelWrite
|
||||
(
|
||||
texture2D & Image,
|
||||
texture2D::dimensions_type const & Texcoord,
|
||||
texture2D::level_type const & Level,
|
||||
genType const & Color
|
||||
)
|
||||
{
|
||||
genType * Data = (genType*)Image[Level].data();
|
||||
std::size_t Index = Texcoord.x + Texcoord.y * Image[Level].dimensions().x;
|
||||
|
||||
std::size_t Capacity = Image[Level].capacity();
|
||||
assert(Index < Capacity);
|
||||
|
||||
*(Data + Index) = Color;
|
||||
}
|
||||
|
||||
}//namespace fetch
|
||||
}//namespace gtx
|
||||
}//namespace gli
|
33
test/external/gli/gtx/gl_texture2d.hpp
vendored
33
test/external/gli/gtx/gl_texture2d.hpp
vendored
@ -1,33 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2010-09-27
|
||||
// Updated : 2010-10-01
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/gtx/gl_texture2d.hpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLI_GTX_GL_TEXTURE2D_INCLUDED
|
||||
#define GLI_GTX_GL_TEXTURE2D_INCLUDED
|
||||
|
||||
#include "../gli.hpp"
|
||||
#include "../gtx/loader.hpp"
|
||||
|
||||
#ifndef GL_VERSION_1_1
|
||||
#error "ERROR: OpenGL must be included before GLI_GTX_gl_texture2d"
|
||||
#endif//GL_VERSION_1_1
|
||||
|
||||
namespace gli{
|
||||
namespace gtx{
|
||||
namespace gl_texture2d
|
||||
{
|
||||
GLuint createTexture2D(std::string const & Filename);
|
||||
}//namespace gl_texture2d
|
||||
}//namespace gtx
|
||||
}//namespace gli
|
||||
|
||||
namespace gli{using namespace gtx::gl_texture2d;}
|
||||
|
||||
#include "gl_texture2d.inl"
|
||||
|
||||
#endif//GLI_GTX_GL_TEXTURE2D_INCLUDED
|
210
test/external/gli/gtx/gl_texture2d.inl
vendored
210
test/external/gli/gtx/gl_texture2d.inl
vendored
@ -1,210 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2010-09-27
|
||||
// Updated : 2010-10-01
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/gtx/gl_texture2d.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace gli{
|
||||
namespace gtx{
|
||||
namespace gl_texture2d{
|
||||
namespace detail
|
||||
{
|
||||
//GL_COMPRESSED_RED, GL_COMPRESSED_RG, GL_COMPRESSED_RGB, GL_COMPRESSED_RGBA, GL_COMPRESSED_SRGB, GL_COMPRESSED_SRGB_ALPHA,
|
||||
//GL_SRGB, GL_SRGB8, GL_SRGB_ALPHA, or GL_SRGB8_ALPHA8
|
||||
struct texture_desc
|
||||
{
|
||||
GLint InternalFormat;
|
||||
GLint InternalFormatCompressed;
|
||||
GLint InternalFormatSRGB;
|
||||
GLint InternalFormatCompressedSRGB;
|
||||
GLenum ExternalFormat;
|
||||
GLenum ExternalFormatRev;
|
||||
GLenum Type;
|
||||
};
|
||||
|
||||
//GL_RED, GL_RG, GL_RGB, GL_BGR, GL_RGBA, and GL_BGRA.
|
||||
//GL_UNSIGNED_BYTE, GL_BYTE, GL_UNSIGNED_SHORT, GL_SHORT, GL_UNSIGNED_INT,
|
||||
//GL_INT, GL_FLOAT, GL_UNSIGNED_BYTE_3_3_2, GL_UNSIGNED_BYTE_2_3_3_REV,
|
||||
//GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_SHORT_5_6_5_REV, GL_UNSIGNED_SHORT_4_4_4_4,
|
||||
//GL_UNSIGNED_SHORT_4_4_4_4_REV, GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_SHORT_1_5_5_5_REV,
|
||||
//GL_UNSIGNED_INT_8_8_8_8, GL_UNSIGNED_INT_8_8_8_8_REV, GL_UNSIGNED_INT_10_10_10_2,
|
||||
//GL_UNSIGNED_INT_2_10_10_10_REV
|
||||
|
||||
# ifndef GL_COMPRESSED_RGBA_BPTC_UNORM_ARB
|
||||
# define GL_COMPRESSED_RGBA_BPTC_UNORM_ARB 0x8E8C
|
||||
# endif
|
||||
|
||||
# ifndef GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB
|
||||
# define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB 0x8E8D
|
||||
# endif
|
||||
|
||||
# ifndef GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB
|
||||
# define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB 0x8E8E
|
||||
# endif
|
||||
|
||||
# ifndef GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB
|
||||
# define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB 0x8E8F
|
||||
# endif
|
||||
|
||||
inline texture_desc gli2ogl_cast(format const & Format)
|
||||
{
|
||||
texture_desc Cast[] =
|
||||
{
|
||||
{GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE},
|
||||
|
||||
//// Normalized
|
||||
//{GL_RED, GL_COMPRESSED_RED, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_UNSIGNED_BYTE},
|
||||
//{GL_RG, GL_COMPRESSED_RG, GL_RG, GL_COMPRESSED_RG, GL_RG, GL_RG, GL_UNSIGNED_BYTE},
|
||||
//{GL_RGB, GL_COMPRESSED_RGB, GL_SRGB8, GL_COMPRESSED_SRGB, GL_RGB, GL_BGR, GL_UNSIGNED_BYTE},
|
||||
//{GL_RGBA, GL_COMPRESSED_RGBA, GL_SRGB8_ALPHA8, GL_COMPRESSED_SRGB_ALPHA, GL_RGBA, GL_BGRA, GL_UNSIGNED_BYTE},
|
||||
|
||||
//{GL_RED, GL_COMPRESSED_RED, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_UNSIGNED_SHORT},
|
||||
//{GL_RG, GL_COMPRESSED_RG, GL_RG, GL_COMPRESSED_RG, GL_RG, GL_RG, GL_UNSIGNED_SHORT},
|
||||
//{GL_RGB, GL_COMPRESSED_RGB, GL_SRGB8, GL_COMPRESSED_SRGB, GL_RGB, GL_BGR, GL_UNSIGNED_SHORT},
|
||||
//{GL_RGBA, GL_COMPRESSED_RGBA, GL_SRGB8_ALPHA8, GL_COMPRESSED_SRGB_ALPHA, GL_RGBA, GL_BGRA, GL_UNSIGNED_SHORT},
|
||||
|
||||
//{GL_RED, GL_COMPRESSED_RED, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_UNSIGNED_INT},
|
||||
//{GL_RG, GL_COMPRESSED_RG, GL_RG, GL_COMPRESSED_RG, GL_RG, GL_RG, GL_UNSIGNED_INT},
|
||||
//{GL_RGB, GL_COMPRESSED_RGB, GL_SRGB8, GL_COMPRESSED_SRGB, GL_RGB, GL_BGR, GL_UNSIGNED_INT},
|
||||
//{GL_RGBA, GL_COMPRESSED_RGBA, GL_SRGB8_ALPHA8, GL_COMPRESSED_SRGB_ALPHA, GL_RGBA, GL_BGRA, GL_UNSIGNED_INT},
|
||||
|
||||
// Unsigned
|
||||
{GL_RED, GL_COMPRESSED_RED, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_UNSIGNED_BYTE},
|
||||
{GL_RG, GL_COMPRESSED_RG, GL_RG, GL_COMPRESSED_RG, GL_RG, GL_RG, GL_UNSIGNED_BYTE},
|
||||
{GL_RGB, GL_COMPRESSED_RGB, GL_SRGB8, GL_COMPRESSED_SRGB, GL_RGB, GL_BGR, GL_UNSIGNED_BYTE},
|
||||
{GL_RGBA, GL_COMPRESSED_RGBA, GL_SRGB8_ALPHA8, GL_COMPRESSED_SRGB_ALPHA, GL_RGBA, GL_BGRA, GL_UNSIGNED_BYTE},
|
||||
|
||||
{GL_RED, GL_COMPRESSED_RED, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_UNSIGNED_SHORT},
|
||||
{GL_RG, GL_COMPRESSED_RG, GL_RG, GL_COMPRESSED_RG, GL_RG, GL_RG, GL_UNSIGNED_SHORT},
|
||||
{GL_RGB, GL_COMPRESSED_RGB, GL_SRGB8, GL_COMPRESSED_SRGB, GL_RGB, GL_BGR, GL_UNSIGNED_SHORT},
|
||||
{GL_RGBA, GL_COMPRESSED_RGBA, GL_SRGB8_ALPHA8, GL_COMPRESSED_SRGB_ALPHA, GL_RGBA, GL_BGRA, GL_UNSIGNED_SHORT},
|
||||
|
||||
{GL_RED, GL_COMPRESSED_RED, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_UNSIGNED_INT},
|
||||
{GL_RG, GL_COMPRESSED_RG, GL_RG, GL_COMPRESSED_RG, GL_RG, GL_RG, GL_UNSIGNED_INT},
|
||||
{GL_RGB, GL_COMPRESSED_RGB, GL_SRGB8, GL_COMPRESSED_SRGB, GL_RGB, GL_BGR, GL_UNSIGNED_INT},
|
||||
{GL_RGBA, GL_COMPRESSED_RGBA, GL_SRGB8_ALPHA8, GL_COMPRESSED_SRGB_ALPHA, GL_RGBA, GL_BGRA, GL_UNSIGNED_INT},
|
||||
|
||||
// Signed
|
||||
{GL_RED, GL_COMPRESSED_RED, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_BYTE},
|
||||
{GL_RG, GL_COMPRESSED_RG, GL_RG, GL_COMPRESSED_RG, GL_RG, GL_RG, GL_BYTE},
|
||||
{GL_RGB, GL_COMPRESSED_RGB, GL_SRGB8, GL_COMPRESSED_SRGB, GL_RGB, GL_BGR, GL_BYTE},
|
||||
{GL_RGBA, GL_COMPRESSED_RGBA, GL_SRGB8_ALPHA8, GL_COMPRESSED_SRGB_ALPHA, GL_RGBA, GL_BGRA, GL_BYTE},
|
||||
|
||||
{GL_RED, GL_COMPRESSED_RED, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_SHORT},
|
||||
{GL_RG, GL_COMPRESSED_RG, GL_RG, GL_COMPRESSED_RG, GL_RG, GL_RG, GL_SHORT},
|
||||
{GL_RGB, GL_COMPRESSED_RGB, GL_SRGB8, GL_COMPRESSED_SRGB, GL_RGB, GL_BGR, GL_SHORT},
|
||||
{GL_RGBA, GL_COMPRESSED_RGBA, GL_SRGB8_ALPHA8, GL_COMPRESSED_SRGB_ALPHA, GL_RGBA, GL_BGRA, GL_SHORT},
|
||||
|
||||
{GL_RED, GL_COMPRESSED_RED, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_INT},
|
||||
{GL_RG, GL_COMPRESSED_RG, GL_RG, GL_COMPRESSED_RG, GL_RG, GL_RG, GL_INT},
|
||||
{GL_RGB, GL_COMPRESSED_RGB, GL_SRGB8, GL_COMPRESSED_SRGB, GL_RGB, GL_BGR, GL_INT},
|
||||
{GL_RGBA, GL_COMPRESSED_RGBA, GL_SRGB8_ALPHA8, GL_COMPRESSED_SRGB_ALPHA, GL_RGBA, GL_BGRA, GL_INT},
|
||||
|
||||
// Float
|
||||
{GL_RED, GL_COMPRESSED_RED, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_HALF_FLOAT},
|
||||
{GL_RG, GL_COMPRESSED_RG, GL_RG, GL_COMPRESSED_RG, GL_RG, GL_RG, GL_HALF_FLOAT},
|
||||
{GL_RGB, GL_COMPRESSED_RGB, GL_SRGB8, GL_COMPRESSED_SRGB, GL_RGB, GL_BGR, GL_HALF_FLOAT},
|
||||
{GL_RGBA, GL_COMPRESSED_RGBA, GL_SRGB8_ALPHA8, GL_COMPRESSED_SRGB_ALPHA, GL_RGBA, GL_BGRA, GL_HALF_FLOAT},
|
||||
|
||||
{GL_RED, GL_COMPRESSED_RED, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_FLOAT},
|
||||
{GL_RG, GL_COMPRESSED_RG, GL_RG, GL_COMPRESSED_RG, GL_RG, GL_RG, GL_FLOAT},
|
||||
{GL_RGB, GL_COMPRESSED_RGB, GL_SRGB8, GL_COMPRESSED_SRGB, GL_RGB, GL_BGR, GL_FLOAT},
|
||||
{GL_RGBA, GL_COMPRESSED_RGBA, GL_SRGB8_ALPHA8, GL_COMPRESSED_SRGB_ALPHA, GL_RGBA, GL_BGRA, GL_FLOAT},
|
||||
|
||||
// Packed
|
||||
{GL_RED, GL_COMPRESSED_RED, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_HALF_FLOAT},
|
||||
{GL_RGB9_E5, GL_RGB9_E5, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_HALF_FLOAT},
|
||||
{GL_R11F_G11F_B10F, GL_R11F_G11F_B10F, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_HALF_FLOAT},
|
||||
{GL_RED, GL_COMPRESSED_RED, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_HALF_FLOAT},
|
||||
{GL_RGBA4, GL_RGBA4, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_HALF_FLOAT},
|
||||
{GL_RGB10_A2, GL_RGB10_A2, GL_RED, GL_COMPRESSED_RED, GL_RED, GL_RED, GL_HALF_FLOAT},
|
||||
|
||||
// Depth
|
||||
{GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT},
|
||||
{GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT},
|
||||
{GL_DEPTH24_STENCIL8, GL_DEPTH24_STENCIL8, GL_DEPTH24_STENCIL8, GL_DEPTH24_STENCIL8, GL_DEPTH_COMPONENT, GL_DEPTH_STENCIL, GL_UNSIGNED_INT},
|
||||
{GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_FLOAT},
|
||||
{GL_DEPTH32F_STENCIL8, GL_DEPTH32F_STENCIL8, GL_DEPTH32F_STENCIL8, GL_DEPTH32F_STENCIL8, GL_DEPTH_COMPONENT, GL_DEPTH_STENCIL, GL_UNSIGNED_INT},
|
||||
|
||||
// Compressed formats
|
||||
{GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_NONE, GL_NONE, GL_NONE},
|
||||
{GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_NONE, GL_NONE, GL_NONE},
|
||||
{GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_NONE, GL_NONE, GL_NONE},
|
||||
{GL_COMPRESSED_RED_RGTC1, GL_COMPRESSED_RED_RGTC1, GL_COMPRESSED_RED_RGTC1, GL_COMPRESSED_RED_RGTC1, GL_NONE, GL_NONE, GL_NONE},
|
||||
{GL_COMPRESSED_SIGNED_RED_RGTC1, GL_COMPRESSED_SIGNED_RED_RGTC1, GL_COMPRESSED_SIGNED_RED_RGTC1, GL_COMPRESSED_SIGNED_RED_RGTC1, GL_NONE, GL_NONE, GL_NONE},
|
||||
{GL_COMPRESSED_RG_RGTC2, GL_COMPRESSED_RG_RGTC2, GL_COMPRESSED_RG_RGTC2, GL_COMPRESSED_RG_RGTC2, GL_NONE, GL_NONE, GL_NONE},
|
||||
{GL_COMPRESSED_SIGNED_RG_RGTC2, GL_COMPRESSED_SIGNED_RG_RGTC2, GL_COMPRESSED_SIGNED_RG_RGTC2, GL_COMPRESSED_SIGNED_RG_RGTC2, GL_NONE, GL_NONE, GL_NONE},
|
||||
{GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB, GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB, GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB, GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB, GL_NONE, GL_NONE, GL_NONE},
|
||||
{GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB, GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB, GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB, GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB, GL_NONE, GL_NONE, GL_NONE},
|
||||
{GL_COMPRESSED_RGBA_BPTC_UNORM_ARB, GL_COMPRESSED_RGBA_BPTC_UNORM_ARB, GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB, GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB, GL_NONE, GL_NONE, GL_NONE},
|
||||
};
|
||||
|
||||
return Cast[Format];
|
||||
}
|
||||
|
||||
}//namespace detail
|
||||
|
||||
inline GLuint createTexture2D(std::string const & Filename)
|
||||
{
|
||||
gli::texture2D Texture = gli::load(Filename);
|
||||
if(Texture.empty())
|
||||
return 0;
|
||||
|
||||
detail::texture_desc TextureDesc = detail::gli2ogl_cast(Texture.format());
|
||||
|
||||
GLint Alignment = 0;
|
||||
glGetIntegerv(GL_UNPACK_ALIGNMENT, &Alignment);
|
||||
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
|
||||
GLuint Name = 0;
|
||||
glGenTextures(1, &Name);
|
||||
glBindTexture(GL_TEXTURE_2D, Name);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, Texture.levels() > 1 ? GL_NEAREST_MIPMAP_NEAREST : GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
||||
if(size(Texture, BIT_PER_PIXEL) == size(Texture, BLOCK_SIZE) << 3)
|
||||
{
|
||||
for(gli::texture2D::level_type Level = 0; Level < Texture.levels(); ++Level)
|
||||
{
|
||||
glTexImage2D(
|
||||
GL_TEXTURE_2D,
|
||||
GLint(Level),
|
||||
TextureDesc.InternalFormat,
|
||||
GLsizei(Texture[Level].dimensions().x),
|
||||
GLsizei(Texture[Level].dimensions().y),
|
||||
0,
|
||||
TextureDesc.ExternalFormatRev,
|
||||
TextureDesc.Type,
|
||||
Texture[Level].data());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(gli::texture2D::level_type Level = 0; Level < Texture.levels(); ++Level)
|
||||
{
|
||||
glCompressedTexImage2D(
|
||||
GL_TEXTURE_2D,
|
||||
GLint(Level),
|
||||
TextureDesc.InternalFormat,
|
||||
GLsizei(Texture[Level].dimensions().x),
|
||||
GLsizei(Texture[Level].dimensions().y),
|
||||
0,
|
||||
GLsizei(Texture[Level].capacity()),
|
||||
Texture[Level].data());
|
||||
}
|
||||
}
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, Alignment);
|
||||
|
||||
return Name;
|
||||
}
|
||||
|
||||
}//namespace gl_texture_2d
|
||||
}//namespace gtx
|
||||
}//namespace gli
|
38
test/external/gli/gtx/gradient.hpp
vendored
38
test/external/gli/gtx/gradient.hpp
vendored
@ -1,38 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2008-12-19
|
||||
// Updated : 2010-01-09
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/gtx/gradient.hpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLI_GTX_GRADIENT_INCLUDED
|
||||
#define GLI_GTX_GRADIENT_INCLUDED
|
||||
|
||||
#include "../gli.hpp"
|
||||
|
||||
namespace gli{
|
||||
namespace gtx{
|
||||
namespace gradient
|
||||
{
|
||||
texture2D radial(
|
||||
texture2D::dimensions_type const & Size,
|
||||
texture2D::texcoord_type const & Center,
|
||||
float const & Radius,
|
||||
texture2D::texcoord_type const & Focal);
|
||||
|
||||
texture2D linear(
|
||||
texture2D::dimensions_type const & Size,
|
||||
texture2D::texcoord_type const & Point0,
|
||||
texture2D::texcoord_type const & Point1);
|
||||
|
||||
}//namespace gradient
|
||||
}//namespace gtx
|
||||
}//namespace gli
|
||||
|
||||
namespace gli{using namespace gtx::gradient;}
|
||||
|
||||
#include "gradient.inl"
|
||||
|
||||
#endif//GLI_GTX_GRADIENT_INCLUDED
|
74
test/external/gli/gtx/gradient.inl
vendored
74
test/external/gli/gtx/gradient.inl
vendored
@ -1,74 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2008-12-19
|
||||
// Updated : 2010-01-09
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/gtx/gradient.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace gli{
|
||||
namespace gtx{
|
||||
namespace gradient
|
||||
{
|
||||
inline texture2D radial
|
||||
(
|
||||
texture2D::dimensions_type const & Size,
|
||||
texture2D::texcoord_type const & Center,
|
||||
float const & Radius,
|
||||
texture2D::texcoord_type const & Focal
|
||||
)
|
||||
{
|
||||
image2D Result(texture2D::dimensions_type(Size), gli::RGB8U);
|
||||
glm::u8vec3 * DstData = (glm::u8vec3 *)Result.data();
|
||||
|
||||
for(std::size_t y = 0; y < Result.dimensions().y; ++y)
|
||||
for(std::size_t x = 0; x < Result.dimensions().x; ++x)
|
||||
{
|
||||
float Value = glm::radialGradient(
|
||||
Center * glm::vec2(Size),
|
||||
Radius,
|
||||
Focal * glm::vec2(Size),
|
||||
glm::vec2(x, y));
|
||||
|
||||
std::size_t Index = x + y * Result.dimensions().x;
|
||||
|
||||
*(DstData + Index) = glm::u8vec3(glm::u8(glm::clamp(Value * 255.f, 0.f, 255.f)));
|
||||
}
|
||||
|
||||
gli::texture2D Image(1);
|
||||
Image[0] = Result;
|
||||
return Image;
|
||||
}
|
||||
|
||||
inline texture2D linear
|
||||
(
|
||||
texture2D::dimensions_type const & Size,
|
||||
texture2D::texcoord_type const & Point0,
|
||||
texture2D::texcoord_type const & Point1
|
||||
)
|
||||
{
|
||||
image2D Result(texture2D::dimensions_type(Size), gli::RGB8U);
|
||||
glm::u8vec3 * DstData = (glm::u8vec3 *)Result.data();
|
||||
|
||||
for(std::size_t y = 0; y < Result.dimensions().y; ++y)
|
||||
for(std::size_t x = 0; x < Result.dimensions().x; ++x)
|
||||
{
|
||||
float Value = glm::linearGradient(
|
||||
Point0 * glm::vec2(Size),
|
||||
Point1 * glm::vec2(Size),
|
||||
texture2D::texcoord_type(x, y));
|
||||
|
||||
std::size_t Index = x + y * Result.dimensions().x;
|
||||
|
||||
*(DstData + Index) = glm::u8vec3(glm::u8(glm::clamp(Value * 255.f, 0.f, 255.f)));
|
||||
}
|
||||
|
||||
gli::texture2D Image(1);
|
||||
Image[0] = Result;
|
||||
return Image;
|
||||
}
|
||||
|
||||
}//namespace gradient
|
||||
}//namespace gtx
|
||||
}//namespace gli
|
37
test/external/gli/gtx/loader.hpp
vendored
37
test/external/gli/gtx/loader.hpp
vendored
@ -1,37 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2010-09-08
|
||||
// Updated : 2010-09-27
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/gtx/loader.hpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLI_GTX_LOADER_INCLUDED
|
||||
#define GLI_GTX_LOADER_INCLUDED
|
||||
|
||||
#include "../gli.hpp"
|
||||
#include "../gtx/loader_dds9.hpp"
|
||||
#include "../gtx/loader_dds10.hpp"
|
||||
#include "../gtx/loader_tga.hpp"
|
||||
|
||||
namespace gli{
|
||||
namespace gtx{
|
||||
namespace loader
|
||||
{
|
||||
inline texture2D load(
|
||||
std::string const & Filename);
|
||||
|
||||
inline void save(
|
||||
texture2D const & Image,
|
||||
std::string const & Filename);
|
||||
|
||||
}//namespace loader
|
||||
}//namespace gtx
|
||||
}//namespace gli
|
||||
|
||||
namespace gli{using namespace gtx::loader;}
|
||||
|
||||
#include "loader.inl"
|
||||
|
||||
#endif//GLI_GTX_LOADER_INCLUDED
|
46
test/external/gli/gtx/loader.inl
vendored
46
test/external/gli/gtx/loader.inl
vendored
@ -1,46 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2010-09-08
|
||||
// Updated : 2010-09-27
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/gtx/loader.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace gli{
|
||||
namespace gtx{
|
||||
namespace loader
|
||||
{
|
||||
inline texture2D load
|
||||
(
|
||||
std::string const & Filename
|
||||
)
|
||||
{
|
||||
if(Filename.find(".dds") != std::string::npos)
|
||||
return loadDDS10(Filename);
|
||||
else if(Filename.find(".tga") != std::string::npos)
|
||||
return loadTGA(Filename);
|
||||
else
|
||||
{
|
||||
assert(0); // File format not supported
|
||||
return texture2D();
|
||||
}
|
||||
}
|
||||
|
||||
inline void save
|
||||
(
|
||||
texture2D const & Image,
|
||||
std::string const & Filename
|
||||
)
|
||||
{
|
||||
if(Filename.find(".dds") != std::string::npos)
|
||||
saveDDS10(Image, Filename);
|
||||
else if(Filename.find(".tga") != std::string::npos)
|
||||
saveTGA(Image, Filename);
|
||||
else
|
||||
assert(0); // File format not supported
|
||||
}
|
||||
|
||||
}//namespace loader
|
||||
}//namespace gtx
|
||||
}//namespace gli
|
35
test/external/gli/gtx/loader_dds10.hpp
vendored
35
test/external/gli/gtx/loader_dds10.hpp
vendored
@ -1,35 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2010-09-26
|
||||
// Updated : 2010-09-27
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/gtx/loader_dds10.hpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLI_GTX_LOADER_DDS10_INCLUDED
|
||||
#define GLI_GTX_LOADER_DDS10_INCLUDED
|
||||
|
||||
#include "../gli.hpp"
|
||||
#include <fstream>
|
||||
|
||||
namespace gli{
|
||||
namespace gtx{
|
||||
namespace loader_dds10
|
||||
{
|
||||
texture2D loadDDS10(
|
||||
std::string const & Filename);
|
||||
|
||||
void saveDDS10(
|
||||
texture2D const & Image,
|
||||
std::string const & Filename);
|
||||
|
||||
}//namespace loader_dds10
|
||||
}//namespace gtx
|
||||
}//namespace gli
|
||||
|
||||
namespace gli{using namespace gtx::loader_dds10;}
|
||||
|
||||
#include "loader_dds10.inl"
|
||||
|
||||
#endif//GLI_GTX_LOADER_DDS10_INCLUDED
|
595
test/external/gli/gtx/loader_dds10.inl
vendored
595
test/external/gli/gtx/loader_dds10.inl
vendored
@ -1,595 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2010-09-26
|
||||
// Updated : 2010-09-27
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/gtx/loader_dds10.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace gli{
|
||||
namespace gtx{
|
||||
namespace loader_dds10{
|
||||
namespace detail
|
||||
{
|
||||
// DDS Documentation
|
||||
/*
|
||||
http://msdn.microsoft.com/en-us/library/bb943991(VS.85).aspx#File_Layout1
|
||||
http://msdn.microsoft.com/en-us/library/bb943992.aspx
|
||||
*/
|
||||
|
||||
#define GLI_MAKEFOURCC(ch0, ch1, ch2, ch3) \
|
||||
(glm::uint32)( \
|
||||
(((glm::uint32)(glm::uint8)(ch3) << 24) & 0xFF000000) | \
|
||||
(((glm::uint32)(glm::uint8)(ch2) << 16) & 0x00FF0000) | \
|
||||
(((glm::uint32)(glm::uint8)(ch1) << 8) & 0x0000FF00) | \
|
||||
((glm::uint32)(glm::uint8)(ch0) & 0x000000FF) )
|
||||
|
||||
enum DXGI_FORMAT
|
||||
{
|
||||
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_FORCE_UINT = 0xffffffffUL
|
||||
};
|
||||
|
||||
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 = 0x1L,
|
||||
D3D10_RESOURCE_MISC_SHARED = 0x2L,
|
||||
D3D10_RESOURCE_MISC_TEXTURECUBE = 0x4L,
|
||||
D3D10_RESOURCE_MISC_SHARED_KEYEDMUTEX = 0x10L,
|
||||
D3D10_RESOURCE_MISC_GDI_COMPATIBLE = 0x20L
|
||||
};
|
||||
|
||||
enum dds_format
|
||||
{
|
||||
GLI_D3DFMT_R8G8B8 = 20,
|
||||
GLI_D3DFMT_A8R8G8B8 = 21,
|
||||
GLI_D3DFMT_X8R8G8B8 = 22,
|
||||
GLI_D3DFMT_A8 = 28,
|
||||
GLI_D3DFMT_A2B10G10R10 = 31,
|
||||
GLI_D3DFMT_A8B8G8R8 = 32,
|
||||
GLI_D3DFMT_X8B8G8R8 = 33,
|
||||
GLI_D3DFMT_G16R16 = 34,
|
||||
GLI_D3DFMT_A2R10G10B10 = 35,
|
||||
GLI_D3DFMT_A16B16G16R16 = 36,
|
||||
|
||||
GLI_D3DFMT_L8 = 50,
|
||||
GLI_D3DFMT_A8L8 = 51,
|
||||
|
||||
GLI_D3DFMT_DXT1 = GLI_MAKEFOURCC('D', 'X', 'T', '1'),
|
||||
GLI_D3DFMT_DXT2 = GLI_MAKEFOURCC('D', 'X', 'T', '2'),
|
||||
GLI_D3DFMT_DXT3 = GLI_MAKEFOURCC('D', 'X', 'T', '3'),
|
||||
GLI_D3DFMT_DXT4 = GLI_MAKEFOURCC('D', 'X', 'T', '4'),
|
||||
GLI_D3DFMT_DXT5 = GLI_MAKEFOURCC('D', 'X', 'T', '5'),
|
||||
GLI_D3DFMT_DX10 = GLI_MAKEFOURCC('D', 'X', '1', '0'),
|
||||
|
||||
GLI_D3DFMT_D32 = 71,
|
||||
GLI_D3DFMT_D24S8 = 75,
|
||||
GLI_D3DFMT_D24X8 = 77,
|
||||
GLI_D3DFMT_D16 = 80,
|
||||
GLI_D3DFMT_L16 = 81,
|
||||
GLI_D3DFMT_D32F_LOCKABLE = 82,
|
||||
GLI_D3DFMT_D24FS8 = 83,
|
||||
|
||||
GLI_D3DFMT_R16F = 111,
|
||||
GLI_D3DFMT_G16R16F = 112,
|
||||
GLI_D3DFMT_A16B16G16R16F = 113,
|
||||
|
||||
GLI_D3DFMT_R32F = 114,
|
||||
GLI_D3DFMT_G32R32F = 115,
|
||||
GLI_D3DFMT_A32B32G32R32F = 116
|
||||
};
|
||||
|
||||
struct ddsHeader10
|
||||
{
|
||||
DXGI_FORMAT dxgiFormat;
|
||||
D3D10_RESOURCE_DIMENSION resourceDimension;
|
||||
glm::uint32 miscFlag; // D3D10_RESOURCE_MISC_GENERATE_MIPS
|
||||
glm::uint32 arraySize;
|
||||
glm::uint32 reserved;
|
||||
};
|
||||
|
||||
|
||||
inline gli::format format_fourcc2gli_cast(glm::uint32 const & FourCC)
|
||||
{
|
||||
switch(FourCC)
|
||||
{
|
||||
case loader_dds9::detail::GLI_FOURCC_DXT1:
|
||||
return DXT1;
|
||||
case loader_dds9::detail::GLI_FOURCC_DXT2:
|
||||
case loader_dds9::detail::GLI_FOURCC_DXT3:
|
||||
return DXT3;
|
||||
case loader_dds9::detail::GLI_FOURCC_DXT4:
|
||||
case loader_dds9::detail::GLI_FOURCC_DXT5:
|
||||
return DXT5;
|
||||
case loader_dds9::detail::GLI_FOURCC_R16F:
|
||||
return R16F;
|
||||
case loader_dds9::detail::GLI_FOURCC_G16R16F:
|
||||
return RG16F;
|
||||
case loader_dds9::detail::GLI_FOURCC_A16B16G16R16F:
|
||||
return RGBA16F;
|
||||
case loader_dds9::detail::GLI_FOURCC_R32F:
|
||||
return R32F;
|
||||
case loader_dds9::detail::GLI_FOURCC_G32R32F:
|
||||
return RG32F;
|
||||
case loader_dds9::detail::GLI_FOURCC_A32B32G32R32F:
|
||||
return RGBA32F;
|
||||
|
||||
case loader_dds9::detail::GLI_D3DFMT_R8G8B8:
|
||||
return RGB8U;
|
||||
case loader_dds9::detail::GLI_D3DFMT_A8R8G8B8:
|
||||
case loader_dds9::detail::GLI_D3DFMT_X8R8G8B8:
|
||||
case loader_dds9::detail::GLI_D3DFMT_A8B8G8R8:
|
||||
case loader_dds9::detail::GLI_D3DFMT_X8B8G8R8:
|
||||
return RGBA8U;
|
||||
case loader_dds9::detail::GLI_D3DFMT_R5G6B5:
|
||||
return R5G6B5;
|
||||
case loader_dds9::detail::GLI_D3DFMT_A4R4G4B4:
|
||||
case loader_dds9::detail::GLI_D3DFMT_X4R4G4B4:
|
||||
return RGBA4;
|
||||
case loader_dds9::detail::GLI_D3DFMT_G16R16:
|
||||
return RG16U;
|
||||
case loader_dds9::detail::GLI_D3DFMT_A16B16G16R16:
|
||||
return RGBA16U;
|
||||
case loader_dds9::detail::GLI_D3DFMT_A2R10G10B10:
|
||||
case loader_dds9::detail::GLI_D3DFMT_A2B10G10R10:
|
||||
return RGB10A2;
|
||||
default:
|
||||
assert(0);
|
||||
return FORMAT_NULL;
|
||||
}
|
||||
}
|
||||
|
||||
inline DXGI_FORMAT format_gli2dds_cast(gli::format const & Format)
|
||||
{
|
||||
DXGI_FORMAT Cast[] =
|
||||
{
|
||||
DXGI_FORMAT_UNKNOWN, //FORMAT_NULL,
|
||||
|
||||
// Unsigned integer formats
|
||||
DXGI_FORMAT_R8_UINT, //R8U,
|
||||
DXGI_FORMAT_R8G8_UINT, //RG8U,
|
||||
DXGI_FORMAT_UNKNOWN, //RGB8U,
|
||||
DXGI_FORMAT_R8G8B8A8_UINT, //RGBA8U,
|
||||
|
||||
DXGI_FORMAT_R16_UINT, //R16U,
|
||||
DXGI_FORMAT_R16G16_UINT, //RG16U,
|
||||
DXGI_FORMAT_UNKNOWN, //RGB16U,
|
||||
DXGI_FORMAT_R16G16B16A16_UINT, //RGBA16U,
|
||||
|
||||
DXGI_FORMAT_R32_UINT, //R32U,
|
||||
DXGI_FORMAT_R32G32_UINT, //RG32U,
|
||||
DXGI_FORMAT_R32G32B32_UINT, //RGB32U,
|
||||
DXGI_FORMAT_R32G32B32A32_UINT, //RGBA32U,
|
||||
|
||||
// Signed integer formats
|
||||
DXGI_FORMAT_R8_SINT, //R8I,
|
||||
DXGI_FORMAT_R8G8_SINT, //RG8I,
|
||||
DXGI_FORMAT_UNKNOWN, //RGB8I,
|
||||
DXGI_FORMAT_R8G8B8A8_SINT, //RGBA8I,
|
||||
|
||||
DXGI_FORMAT_R16_SINT, //R16I,
|
||||
DXGI_FORMAT_R16G16_SINT, //RG16I,
|
||||
DXGI_FORMAT_UNKNOWN, //RGB16I,
|
||||
DXGI_FORMAT_R16G16B16A16_SINT, //RGBA16I,
|
||||
|
||||
DXGI_FORMAT_R32_SINT, //R32I,
|
||||
DXGI_FORMAT_R32G32_SINT, //RG32I,
|
||||
DXGI_FORMAT_R32G32B32_SINT, //RGB32I,
|
||||
DXGI_FORMAT_R32G32B32A32_SINT, //RGBA32I,
|
||||
|
||||
// Floating formats
|
||||
DXGI_FORMAT_R16_FLOAT, //R16F,
|
||||
DXGI_FORMAT_R16G16_FLOAT, //RG16F,
|
||||
DXGI_FORMAT_UNKNOWN, //RGB16F,
|
||||
DXGI_FORMAT_R16G16B16A16_FLOAT, //RGBA16F,
|
||||
|
||||
DXGI_FORMAT_R32_FLOAT, //R32F,
|
||||
DXGI_FORMAT_R32G32_FLOAT, //RG32F,
|
||||
DXGI_FORMAT_R32G32B32_FLOAT, //RGB32F,
|
||||
DXGI_FORMAT_R32G32B32A32_FLOAT, //RGBA32F,
|
||||
|
||||
// Packed formats
|
||||
DXGI_FORMAT_UNKNOWN, //RGBE8,
|
||||
DXGI_FORMAT_R9G9B9E5_SHAREDEXP, //RGB9E5,
|
||||
DXGI_FORMAT_R11G11B10_FLOAT,
|
||||
DXGI_FORMAT_B5G6R5_UNORM, //R5G6B5,
|
||||
DXGI_FORMAT_UNKNOWN, //RGBA4,
|
||||
DXGI_FORMAT_R10G10B10A2_TYPELESS, //RGB10A2,
|
||||
|
||||
// Depth formats
|
||||
DXGI_FORMAT_D16_UNORM, //D16,
|
||||
DXGI_FORMAT_D24_UNORM_S8_UINT, //D24X8,
|
||||
DXGI_FORMAT_D24_UNORM_S8_UINT, //D24S8,
|
||||
DXGI_FORMAT_D32_FLOAT, //D32F,
|
||||
DXGI_FORMAT_D32_FLOAT_S8X24_UINT, //D32FS8X24,
|
||||
|
||||
// Compressed formats
|
||||
DXGI_FORMAT_BC1_UNORM, //DXT1,
|
||||
DXGI_FORMAT_BC2_UNORM, //DXT3,
|
||||
DXGI_FORMAT_BC3_UNORM, //DXT5,
|
||||
DXGI_FORMAT_BC4_UNORM, //ATI1N_UNORM,
|
||||
DXGI_FORMAT_BC4_SNORM, //ATI1N_SNORM,
|
||||
DXGI_FORMAT_BC5_UNORM, //ATI2N_UNORM,
|
||||
DXGI_FORMAT_BC5_SNORM, //ATI2N_SNORM,
|
||||
DXGI_FORMAT_BC6H_UF16, //BP_FLOAT,
|
||||
DXGI_FORMAT_BC6H_SF16, //BP_FLOAT,
|
||||
DXGI_FORMAT_BC7_UNORM //BP,
|
||||
};
|
||||
|
||||
return Cast[Format];
|
||||
}
|
||||
|
||||
inline gli::format format_dds2gli_cast(DXGI_FORMAT const & Format)
|
||||
{
|
||||
gli::format Cast[] =
|
||||
{
|
||||
gli::FORMAT_NULL, //DXGI_FORMAT_UNKNOWN = 0,
|
||||
gli::RGBA32U, //DXGI_FORMAT_R32G32B32A32_TYPELESS = 1,
|
||||
gli::RGBA32F, //DXGI_FORMAT_R32G32B32A32_FLOAT = 2,
|
||||
gli::RGBA32U, //DXGI_FORMAT_R32G32B32A32_UINT = 3,
|
||||
gli::RGBA32I, //DXGI_FORMAT_R32G32B32A32_SINT = 4,
|
||||
gli::RGB32U, //DXGI_FORMAT_R32G32B32_TYPELESS = 5,
|
||||
gli::RGB32F, //DXGI_FORMAT_R32G32B32_FLOAT = 6,
|
||||
gli::RGB32U, //DXGI_FORMAT_R32G32B32_UINT = 7,
|
||||
gli::RGB32I, //DXGI_FORMAT_R32G32B32_SINT = 8,
|
||||
gli::RGBA16U, //DXGI_FORMAT_R16G16B16A16_TYPELESS = 9,
|
||||
gli::RGBA16F, //DXGI_FORMAT_R16G16B16A16_FLOAT = 10,
|
||||
gli::RGBA16U, //DXGI_FORMAT_R16G16B16A16_UNORM = 11,
|
||||
gli::RGBA16I, //DXGI_FORMAT_R16G16B16A16_UINT = 12,
|
||||
gli::RGBA16I, //DXGI_FORMAT_R16G16B16A16_SNORM = 13,
|
||||
gli::RGBA16I, //DXGI_FORMAT_R16G16B16A16_SINT = 14,
|
||||
gli::RG32U, //DXGI_FORMAT_R32G32_TYPELESS = 15,
|
||||
gli::RG32F, //DXGI_FORMAT_R32G32_FLOAT = 16,
|
||||
gli::RG32U, //DXGI_FORMAT_R32G32_UINT = 17,
|
||||
gli::RG32I, //DXGI_FORMAT_R32G32_SINT = 18,
|
||||
gli::FORMAT_NULL, //DXGI_FORMAT_R32G8X24_TYPELESS = 19,
|
||||
gli::D32FS8X24, //DXGI_FORMAT_D32_FLOAT_S8X24_UINT = 20,
|
||||
gli::FORMAT_NULL, //DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS = 21,
|
||||
gli::FORMAT_NULL, //DXGI_FORMAT_X32_TYPELESS_G8X24_UINT = 22,
|
||||
gli::RGB10A2, //DXGI_FORMAT_R10G10B10A2_TYPELESS = 23,
|
||||
gli::RGB10A2, //DXGI_FORMAT_R10G10B10A2_UNORM = 24,
|
||||
gli::RGB10A2, //DXGI_FORMAT_R10G10B10A2_UINT = 25,
|
||||
gli::RG11B10F, //DXGI_FORMAT_R11G11B10_FLOAT = 26,
|
||||
gli::RGBA8U, //DXGI_FORMAT_R8G8B8A8_TYPELESS = 27,
|
||||
gli::RGBA8U, //DXGI_FORMAT_R8G8B8A8_UNORM = 28,
|
||||
gli::RGBA8U, //DXGI_FORMAT_R8G8B8A8_UNORM_SRGB = 29,
|
||||
gli::RGBA8U, //DXGI_FORMAT_R8G8B8A8_UINT = 30,
|
||||
gli::RGBA8I, //DXGI_FORMAT_R8G8B8A8_SNORM = 31,
|
||||
gli::RGBA8I, //DXGI_FORMAT_R8G8B8A8_SINT = 32,
|
||||
gli::RG16U, //DXGI_FORMAT_R16G16_TYPELESS = 33,
|
||||
gli::RG16F, //DXGI_FORMAT_R16G16_FLOAT = 34,
|
||||
gli::RG16U, //DXGI_FORMAT_R16G16_UNORM = 35,
|
||||
gli::RG16U, //DXGI_FORMAT_R16G16_UINT = 36,
|
||||
gli::RG16I, //DXGI_FORMAT_R16G16_SNORM = 37,
|
||||
gli::RG16I, //DXGI_FORMAT_R16G16_SINT = 38,
|
||||
gli::R32F, //DXGI_FORMAT_R32_TYPELESS = 39,
|
||||
gli::D32F, //DXGI_FORMAT_D32_FLOAT = 40,
|
||||
gli::R32F, //DXGI_FORMAT_R32_FLOAT = 41,
|
||||
gli::R32U, //DXGI_FORMAT_R32_UINT = 42,
|
||||
gli::R32I, //DXGI_FORMAT_R32_SINT = 43,
|
||||
gli::FORMAT_NULL, //DXGI_FORMAT_R24G8_TYPELESS = 44,
|
||||
gli::FORMAT_NULL, //DXGI_FORMAT_D24_UNORM_S8_UINT = 45,
|
||||
gli::FORMAT_NULL, //DXGI_FORMAT_R24_UNORM_X8_TYPELESS = 46,
|
||||
gli::FORMAT_NULL, //DXGI_FORMAT_X24_TYPELESS_G8_UINT = 47,
|
||||
gli::RG8U, //DXGI_FORMAT_R8G8_TYPELESS = 48,
|
||||
gli::RG8U, //DXGI_FORMAT_R8G8_UNORM = 49,
|
||||
gli::RG8U, //DXGI_FORMAT_R8G8_UINT = 50,
|
||||
gli::RG8I, //DXGI_FORMAT_R8G8_SNORM = 51,
|
||||
gli::RG8I, //DXGI_FORMAT_R8G8_SINT = 52,
|
||||
gli::R16U, //DXGI_FORMAT_R16_TYPELESS = 53,
|
||||
gli::R16F, //DXGI_FORMAT_R16_FLOAT = 54,
|
||||
gli::D16, //DXGI_FORMAT_D16_UNORM = 55,
|
||||
gli::R16U, //DXGI_FORMAT_R16_UNORM = 56,
|
||||
gli::R16U, //DXGI_FORMAT_R16_UINT = 57,
|
||||
gli::R16I, //DXGI_FORMAT_R16_SNORM = 58,
|
||||
gli::R16I, //DXGI_FORMAT_R16_SINT = 59,
|
||||
gli::R8U, //DXGI_FORMAT_R8_TYPELESS = 60,
|
||||
gli::R8U, //DXGI_FORMAT_R8_UNORM = 61,
|
||||
gli::R8U, //DXGI_FORMAT_R8_UINT = 62,
|
||||
gli::R8I, //DXGI_FORMAT_R8_SNORM = 63,
|
||||
gli::R8I, //DXGI_FORMAT_R8_SINT = 64,
|
||||
gli::R8U, //DXGI_FORMAT_A8_UNORM = 65,
|
||||
gli::FORMAT_NULL, //DXGI_FORMAT_R1_UNORM = 66,
|
||||
gli::RGB9E5, //DXGI_FORMAT_R9G9B9E5_SHAREDEXP = 67,
|
||||
gli::FORMAT_NULL, //DXGI_FORMAT_R8G8_B8G8_UNORM = 68,
|
||||
gli::FORMAT_NULL, //DXGI_FORMAT_G8R8_G8B8_UNORM = 69,
|
||||
gli::DXT1, //DXGI_FORMAT_BC1_TYPELESS = 70,
|
||||
gli::DXT1, //DXGI_FORMAT_BC1_UNORM = 71,
|
||||
gli::DXT1, //DXGI_FORMAT_BC1_UNORM_SRGB = 72,
|
||||
gli::DXT3, //DXGI_FORMAT_BC2_TYPELESS = 73,
|
||||
gli::DXT3, //DXGI_FORMAT_BC2_UNORM = 74,
|
||||
gli::DXT3, //DXGI_FORMAT_BC2_UNORM_SRGB = 75,
|
||||
gli::DXT5, //DXGI_FORMAT_BC3_TYPELESS = 76,
|
||||
gli::DXT5, //DXGI_FORMAT_BC3_UNORM = 77,
|
||||
gli::DXT5, //DXGI_FORMAT_BC3_UNORM_SRGB = 78,
|
||||
gli::ATI1N_UNORM, //DXGI_FORMAT_BC4_TYPELESS = 79,
|
||||
gli::ATI1N_UNORM, //DXGI_FORMAT_BC4_UNORM = 80,
|
||||
gli::ATI1N_SNORM, //DXGI_FORMAT_BC4_SNORM = 81,
|
||||
gli::ATI2N_UNORM, //DXGI_FORMAT_BC5_TYPELESS = 82,
|
||||
gli::ATI2N_UNORM, //DXGI_FORMAT_BC5_UNORM = 83,
|
||||
gli::ATI2N_SNORM, //DXGI_FORMAT_BC5_SNORM = 84,
|
||||
gli::FORMAT_NULL, //DXGI_FORMAT_B5G6R5_UNORM = 85,
|
||||
gli::FORMAT_NULL, //DXGI_FORMAT_B5G5R5A1_UNORM = 86,
|
||||
gli::RGBA8U, //DXGI_FORMAT_B8G8R8A8_UNORM = 87,
|
||||
gli::RGBA8U, //DXGI_FORMAT_B8G8R8X8_UNORM = 88,
|
||||
gli::FORMAT_NULL, //DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM = 89,
|
||||
gli::RGBA8U, //DXGI_FORMAT_B8G8R8A8_TYPELESS = 90,
|
||||
gli::RGBA8U, //DXGI_FORMAT_B8G8R8A8_UNORM_SRGB = 91,
|
||||
gli::RGBA8U, //DXGI_FORMAT_B8G8R8X8_TYPELESS = 92,
|
||||
gli::RGBA8U, //DXGI_FORMAT_B8G8R8X8_UNORM_SRGB = 93,
|
||||
gli::BP_UF16, //DXGI_FORMAT_BC6H_TYPELESS = 94,
|
||||
gli::BP_UF16, //DXGI_FORMAT_BC6H_UF16 = 95,
|
||||
gli::BP_SF16, //DXGI_FORMAT_BC6H_SF16 = 96,
|
||||
gli::BP, //DXGI_FORMAT_BC7_TYPELESS = 97,
|
||||
gli::BP, //DXGI_FORMAT_BC7_UNORM = 98,
|
||||
gli::BP, //DXGI_FORMAT_BC7_UNORM_SRGB = 99,
|
||||
gli::R32U //DXGI_FORMAT_FORCE_UINT = 0xffffffffUL
|
||||
};
|
||||
|
||||
return Cast[Format];
|
||||
}
|
||||
|
||||
}//namespace detail
|
||||
|
||||
inline texture2D loadDDS10
|
||||
(
|
||||
std::string const & Filename
|
||||
)
|
||||
{
|
||||
std::ifstream FileIn(Filename.c_str(), std::ios::in | std::ios::binary);
|
||||
if(FileIn.fail())
|
||||
return texture2D();
|
||||
|
||||
loader_dds9::detail::ddsHeader HeaderDesc;
|
||||
detail::ddsHeader10 HeaderDesc10;
|
||||
char Magic[4];
|
||||
|
||||
//* Read magic number and check if valid .dds file
|
||||
FileIn.read((char*)&Magic, sizeof(Magic));
|
||||
|
||||
assert(strncmp(Magic, "DDS ", 4) == 0);
|
||||
|
||||
// Get the surface descriptor
|
||||
FileIn.read((char*)&HeaderDesc, sizeof(HeaderDesc));
|
||||
if(HeaderDesc.format.flags & loader_dds9::detail::GLI_DDPF_FOURCC && HeaderDesc.format.fourCC == loader_dds9::detail::GLI_FOURCC_DX10)
|
||||
FileIn.read((char*)&HeaderDesc10, sizeof(HeaderDesc10));
|
||||
|
||||
loader_dds9::detail::DDLoader Loader;
|
||||
if(HeaderDesc.format.fourCC == loader_dds9::detail::GLI_FOURCC_DX10)
|
||||
Loader.Format = detail::format_dds2gli_cast(HeaderDesc10.dxgiFormat);
|
||||
else if(HeaderDesc.format.flags & loader_dds9::detail::GLI_DDPF_FOURCC)
|
||||
Loader.Format = detail::format_fourcc2gli_cast(HeaderDesc.format.fourCC);
|
||||
else
|
||||
{
|
||||
switch(HeaderDesc.format.bpp)
|
||||
{
|
||||
case 8:
|
||||
Loader.Format = R8U;
|
||||
break;
|
||||
case 16:
|
||||
Loader.Format = RG8U;
|
||||
break;
|
||||
case 24:
|
||||
Loader.Format = RGB8U;
|
||||
break;
|
||||
case 32:
|
||||
Loader.Format = RGBA8U;
|
||||
break;
|
||||
}
|
||||
}
|
||||
Loader.BlockSize = size(image2D(texture2D::dimensions_type(0), Loader.Format), BLOCK_SIZE);
|
||||
Loader.BPP = size(image2D(image2D::dimensions_type(0), Loader.Format), BIT_PER_PIXEL);
|
||||
|
||||
std::size_t Width = HeaderDesc.width;
|
||||
std::size_t Height = HeaderDesc.height;
|
||||
|
||||
gli::format Format = Loader.Format;
|
||||
|
||||
std::streamoff Curr = FileIn.tellg();
|
||||
FileIn.seekg(0, std::ios_base::end);
|
||||
std::streamoff End = FileIn.tellg();
|
||||
FileIn.seekg(Curr, std::ios_base::beg);
|
||||
|
||||
std::vector<glm::byte> Data(std::size_t(End - Curr), 0);
|
||||
std::size_t Offset = 0;
|
||||
|
||||
FileIn.read((char*)&Data[0], std::streamsize(Data.size()));
|
||||
|
||||
//texture2D Image(glm::min(MipMapCount, Levels));//SurfaceDesc.mipMapLevels);
|
||||
std::size_t MipMapCount = (HeaderDesc.flags & loader_dds9::detail::GLI_DDSD_MIPMAPCOUNT) ? HeaderDesc.mipMapLevels : 1;
|
||||
//if(Loader.Format == DXT1 || Loader.Format == DXT3 || Loader.Format == DXT5)
|
||||
// MipMapCount -= 2;
|
||||
texture2D Image(MipMapCount);
|
||||
for(std::size_t Level = 0; Level < Image.levels() && (Width || Height); ++Level)
|
||||
{
|
||||
Width = glm::max(std::size_t(Width), std::size_t(1));
|
||||
Height = glm::max(std::size_t(Height), std::size_t(1));
|
||||
|
||||
std::size_t MipmapSize = 0;
|
||||
if((Loader.BlockSize << 3) > Loader.BPP)
|
||||
MipmapSize = ((Width + 3) >> 2) * ((Height + 3) >> 2) * Loader.BlockSize;
|
||||
else
|
||||
MipmapSize = Width * Height * Loader.BlockSize;
|
||||
std::vector<glm::byte> MipmapData(MipmapSize, 0);
|
||||
|
||||
memcpy(&MipmapData[0], &Data[0] + Offset, MipmapSize);
|
||||
|
||||
image2D::dimensions_type Dimensions(Width, Height);
|
||||
Image[Level] = image2D(Dimensions, Format, MipmapData);
|
||||
|
||||
Offset += MipmapSize;
|
||||
Width >>= 1;
|
||||
Height >>= 1;
|
||||
}
|
||||
|
||||
return Image;
|
||||
}
|
||||
|
||||
inline void saveDDS10
|
||||
(
|
||||
gli::texture2D const & Image,
|
||||
std::string const & Filename
|
||||
)
|
||||
{
|
||||
std::ofstream FileOut(Filename.c_str(), std::ios::out | std::ios::binary);
|
||||
if (!FileOut)
|
||||
return;
|
||||
|
||||
char const * Magic = "DDS ";
|
||||
FileOut.write((char*)Magic, sizeof(char) * 4);
|
||||
|
||||
glm::uint32 Caps = loader_dds9::detail::GLI_DDSD_CAPS | loader_dds9::detail::GLI_DDSD_HEIGHT | loader_dds9::detail::GLI_DDSD_WIDTH | loader_dds9::detail::GLI_DDSD_PIXELFORMAT;
|
||||
|
||||
loader_dds9::detail::ddsHeader HeaderDesc;
|
||||
HeaderDesc.size = sizeof(loader_dds9::detail::ddsHeader);
|
||||
HeaderDesc.flags = Caps | (loader_dds9::detail::isCompressed(Image) ? loader_dds9::detail::GLI_DDSD_LINEARSIZE : loader_dds9::detail::GLI_DDSD_PITCH) | (Image.levels() > 1 ? loader_dds9::detail::GLI_DDSD_MIPMAPCOUNT : 0); //659463;
|
||||
HeaderDesc.width = Image[0].dimensions().x;
|
||||
HeaderDesc.height = Image[0].dimensions().y;
|
||||
HeaderDesc.pitch = loader_dds9::detail::isCompressed(Image) ? size(Image, LINEAR_SIZE) : 32;
|
||||
HeaderDesc.depth = 0;
|
||||
HeaderDesc.mipMapLevels = glm::uint32(Image.levels());
|
||||
HeaderDesc.format.size = sizeof(loader_dds9::detail::ddsPixelFormat);
|
||||
HeaderDesc.format.flags = loader_dds9::detail::GLI_DDPF_FOURCC;
|
||||
HeaderDesc.format.fourCC = loader_dds9::detail::GLI_FOURCC_DX10;
|
||||
HeaderDesc.format.bpp = size(Image, BIT_PER_PIXEL);
|
||||
HeaderDesc.format.redMask = 0;
|
||||
HeaderDesc.format.greenMask = 0;
|
||||
HeaderDesc.format.blueMask = 0;
|
||||
HeaderDesc.format.alphaMask = 0;
|
||||
HeaderDesc.surfaceFlags = loader_dds9::detail::GLI_DDSCAPS_TEXTURE | (Image.levels() > 1 ? loader_dds9::detail::GLI_DDSCAPS_MIPMAP : 0);
|
||||
HeaderDesc.cubemapFlags = 0;
|
||||
FileOut.write((char*)&HeaderDesc, sizeof(HeaderDesc));
|
||||
|
||||
detail::ddsHeader10 HeaderDesc10;
|
||||
HeaderDesc10.arraySize = 1;
|
||||
HeaderDesc10.resourceDimension = detail::D3D10_RESOURCE_DIMENSION_TEXTURE2D;
|
||||
HeaderDesc10.miscFlag = 0;//Image.levels() > 0 ? detail::D3D10_RESOURCE_MISC_GENERATE_MIPS : 0;
|
||||
HeaderDesc10.dxgiFormat = detail::format_gli2dds_cast(Image.format());
|
||||
HeaderDesc10.reserved = 0;
|
||||
|
||||
FileOut.write((char*)&HeaderDesc10, sizeof(HeaderDesc10));
|
||||
|
||||
for(gli::texture2D::level_type Level = 0; Level < Image.levels(); ++Level)
|
||||
{
|
||||
gli::texture2D::size_type ImageSize = size(Image[Level], gli::LINEAR_SIZE);
|
||||
FileOut.write((char*)(Image[Level].data()), ImageSize);
|
||||
}
|
||||
|
||||
if(FileOut.fail() || FileOut.bad())
|
||||
return;
|
||||
|
||||
FileOut.close ();
|
||||
}
|
||||
|
||||
}//namespace loader_dds10
|
||||
}//namespace gtx
|
||||
}//namespace gli
|
39
test/external/gli/gtx/loader_dds9.hpp
vendored
39
test/external/gli/gtx/loader_dds9.hpp
vendored
@ -1,39 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2010-09-08
|
||||
// Updated : 2010-09-27
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/gtx/loader_dds9.hpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLI_GTX_LOADER_DDS9_INCLUDED
|
||||
#define GLI_GTX_LOADER_DDS9_INCLUDED
|
||||
|
||||
#include "../gli.hpp"
|
||||
#include <fstream>
|
||||
|
||||
namespace gli{
|
||||
namespace gtx{
|
||||
namespace loader_dds9
|
||||
{
|
||||
texture2D loadDDS9(
|
||||
std::string const & Filename);
|
||||
|
||||
void saveDDS9(
|
||||
texture2D const & Texture,
|
||||
std::string const & Filename);
|
||||
|
||||
void saveTextureCubeDDS9(
|
||||
textureCube const & Texture,
|
||||
std::string const & Filename);
|
||||
|
||||
}//namespace loader_dds9
|
||||
}//namespace gtx
|
||||
}//namespace gli
|
||||
|
||||
namespace gli{using namespace gtx::loader_dds9;}
|
||||
|
||||
#include "loader_dds9.inl"
|
||||
|
||||
#endif//GLI_GTX_LOADER_DDS9_INCLUDED
|
790
test/external/gli/gtx/loader_dds9.inl
vendored
790
test/external/gli/gtx/loader_dds9.inl
vendored
@ -1,790 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2010-09-08
|
||||
// Updated : 2010-09-27
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/gtx/loader_dds9.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace gli{
|
||||
namespace gtx{
|
||||
namespace loader_dds9{
|
||||
namespace detail
|
||||
{
|
||||
// DDS Documentation
|
||||
/*
|
||||
http://msdn.microsoft.com/en-us/library/bb943991(VS.85).aspx#File_Layout1
|
||||
http://msdn.microsoft.com/en-us/library/bb943992.aspx
|
||||
*/
|
||||
|
||||
#define GLI_MAKEFOURCC(ch0, ch1, ch2, ch3) \
|
||||
(glm::uint32)( \
|
||||
(((glm::uint32)(glm::uint8)(ch3) << 24) & 0xFF000000) | \
|
||||
(((glm::uint32)(glm::uint8)(ch2) << 16) & 0x00FF0000) | \
|
||||
(((glm::uint32)(glm::uint8)(ch1) << 8) & 0x0000FF00) | \
|
||||
((glm::uint32)(glm::uint8)(ch0) & 0x000000FF) )
|
||||
|
||||
//enum dds_format
|
||||
//{
|
||||
// GLI_D3DFMT_R8G8B8 = 20,
|
||||
// GLI_D3DFMT_A8R8G8B8 = 21,
|
||||
// GLI_D3DFMT_X8R8G8B8 = 22,
|
||||
// GLI_D3DFMT_A8 = 28,
|
||||
// GLI_D3DFMT_A2B10G10R10 = 31,
|
||||
// GLI_D3DFMT_A8B8G8R8 = 32,
|
||||
// GLI_D3DFMT_X8B8G8R8 = 33,
|
||||
// GLI_D3DFMT_G16R16 = 34,
|
||||
// GLI_D3DFMT_A2R10G10B10 = 35,
|
||||
// GLI_D3DFMT_A16B16G16R16 = 36,
|
||||
|
||||
// GLI_D3DFMT_L8 = 50,
|
||||
// GLI_D3DFMT_A8L8 = 51,
|
||||
|
||||
// GLI_D3DFMT_DXT1 = GLI_MAKEFOURCC('D', 'X', 'T', '1'),
|
||||
// GLI_D3DFMT_DXT2 = GLI_MAKEFOURCC('D', 'X', 'T', '2'),
|
||||
// GLI_D3DFMT_DXT3 = GLI_MAKEFOURCC('D', 'X', 'T', '3'),
|
||||
// GLI_D3DFMT_DXT4 = GLI_MAKEFOURCC('D', 'X', 'T', '4'),
|
||||
// GLI_D3DFMT_DXT5 = GLI_MAKEFOURCC('D', 'X', 'T', '5'),
|
||||
// GLI_D3DFMT_DX10 = GLI_MAKEFOURCC('D', 'X', '1', '0'),
|
||||
|
||||
// GLI_D3DFMT_D32 = 71,
|
||||
// GLI_D3DFMT_D24S8 = 75,
|
||||
// GLI_D3DFMT_D24X8 = 77,
|
||||
// GLI_D3DFMT_D16 = 80,
|
||||
// GLI_D3DFMT_L16 = 81,
|
||||
// GLI_D3DFMT_D32F_LOCKABLE = 82,
|
||||
// GLI_D3DFMT_D24FS8 = 83,
|
||||
|
||||
// GLI_D3DFMT_R16F = 111,
|
||||
// GLI_D3DFMT_G16R16F = 112,
|
||||
// GLI_D3DFMT_A16B16G16R16F = 113,
|
||||
|
||||
// GLI_D3DFMT_R32F = 114,
|
||||
// GLI_D3DFMT_G32R32F = 115,
|
||||
// GLI_D3DFMT_A32B32G32R32F = 116
|
||||
//};
|
||||
|
||||
enum ddsCubemapflag
|
||||
{
|
||||
GLI_DDSCAPS2_CUBEMAP = 0x00000200,
|
||||
GLI_DDSCAPS2_CUBEMAP_POSITIVEX = 0x00000400,
|
||||
GLI_DDSCAPS2_CUBEMAP_NEGATIVEX = 0x00000800,
|
||||
GLI_DDSCAPS2_CUBEMAP_POSITIVEY = 0x00001000,
|
||||
GLI_DDSCAPS2_CUBEMAP_NEGATIVEY = 0x00002000,
|
||||
GLI_DDSCAPS2_CUBEMAP_POSITIVEZ = 0x00004000,
|
||||
GLI_DDSCAPS2_CUBEMAP_NEGATIVEZ = 0x00008000,
|
||||
GLI_DDSCAPS2_VOLUME = 0x00200000
|
||||
};
|
||||
|
||||
enum ddsSurfaceflag
|
||||
{
|
||||
GLI_DDSCAPS_COMPLEX = 0x00000008,
|
||||
GLI_DDSCAPS_MIPMAP = 0x00400000,
|
||||
GLI_DDSCAPS_TEXTURE = 0x00001000
|
||||
};
|
||||
|
||||
struct ddsPixelFormat
|
||||
{
|
||||
glm::uint32 size; // 32
|
||||
glm::uint32 flags;
|
||||
glm::uint32 fourCC;
|
||||
glm::uint32 bpp;
|
||||
glm::uint32 redMask;
|
||||
glm::uint32 greenMask;
|
||||
glm::uint32 blueMask;
|
||||
glm::uint32 alphaMask;
|
||||
};
|
||||
|
||||
struct ddsHeader
|
||||
{
|
||||
glm::uint32 size;
|
||||
glm::uint32 flags;
|
||||
glm::uint32 height;
|
||||
glm::uint32 width;
|
||||
glm::uint32 pitch;
|
||||
glm::uint32 depth;
|
||||
glm::uint32 mipMapLevels;
|
||||
glm::uint32 reserved1[11];
|
||||
ddsPixelFormat format;
|
||||
glm::uint32 surfaceFlags;
|
||||
glm::uint32 cubemapFlags;
|
||||
glm::uint32 reserved2[3];
|
||||
};
|
||||
|
||||
glm::uint32 const GLI_D3DFMT_R8G8B8 = 20;
|
||||
glm::uint32 const GLI_D3DFMT_A8R8G8B8 = 21;
|
||||
glm::uint32 const GLI_D3DFMT_X8R8G8B8 = 22;
|
||||
glm::uint32 const GLI_D3DFMT_R5G6B5 = 23;
|
||||
glm::uint32 const GLI_D3DFMT_X1R5G5B5 = 24;
|
||||
glm::uint32 const GLI_D3DFMT_A1R5G5B5 = 25;
|
||||
glm::uint32 const GLI_D3DFMT_A4R4G4B4 = 26;
|
||||
glm::uint32 const GLI_D3DFMT_X4R4G4B4 = 30;
|
||||
glm::uint32 const GLI_D3DFMT_A2B10G10R10 = 31;
|
||||
glm::uint32 const GLI_D3DFMT_A8B8G8R8 = 32;
|
||||
glm::uint32 const GLI_D3DFMT_X8B8G8R8 = 33;
|
||||
glm::uint32 const GLI_D3DFMT_G16R16 = 34;
|
||||
glm::uint32 const GLI_D3DFMT_A2R10G10B10 = 35;
|
||||
glm::uint32 const GLI_D3DFMT_A16B16G16R16 = 36;
|
||||
|
||||
|
||||
glm::uint32 const GLI_FOURCC_DXT1 = GLI_MAKEFOURCC('D', 'X', 'T', '1');
|
||||
glm::uint32 const GLI_FOURCC_DXT2 = GLI_MAKEFOURCC('D', 'X', 'T', '2');
|
||||
glm::uint32 const GLI_FOURCC_DXT3 = GLI_MAKEFOURCC('D', 'X', 'T', '3');
|
||||
glm::uint32 const GLI_FOURCC_DXT4 = GLI_MAKEFOURCC('D', 'X', 'T', '4');
|
||||
glm::uint32 const GLI_FOURCC_DXT5 = GLI_MAKEFOURCC('D', 'X', 'T', '5');
|
||||
glm::uint32 const GLI_FOURCC_ATI1 = GLI_MAKEFOURCC('A', 'T', 'I', '1'); // ATI1
|
||||
glm::uint32 const GLI_FOURCC_ATI2 = GLI_MAKEFOURCC('A', 'T', 'I', '2'); // ATI2 (AKA 3Dc)
|
||||
glm::uint32 const GLI_FOURCC_DX10 = GLI_MAKEFOURCC('D', 'X', '1', '0');
|
||||
glm::uint32 const GLI_FOURCC_BC4U = GLI_MAKEFOURCC('B', 'C', '4', 'U');
|
||||
glm::uint32 const GLI_FOURCC_BC4S = GLI_MAKEFOURCC('B', 'C', '4', 'S');
|
||||
glm::uint32 const GLI_FOURCC_BC5U = GLI_MAKEFOURCC('B', 'C', '5', 'U');
|
||||
glm::uint32 const GLI_FOURCC_BC5S = GLI_MAKEFOURCC('B', 'C', '5', 'S');
|
||||
glm::uint32 const GLI_FOURCC_BC6H = GLI_MAKEFOURCC('B', 'C', '6', 'H');
|
||||
glm::uint32 const GLI_FOURCC_BC7 = GLI_MAKEFOURCC('B', 'C', '7', 'U');
|
||||
|
||||
glm::uint32 const GLI_FOURCC_R16F = 0x0000006f; // 16-bit float Red
|
||||
glm::uint32 const GLI_FOURCC_G16R16F = 0x00000070; // 16-bit float Red/Green
|
||||
glm::uint32 const GLI_FOURCC_A16B16G16R16F = 0x00000071; // 16-bit float RGBA
|
||||
glm::uint32 const GLI_FOURCC_R32F = 0x00000072; // 32-bit float Red
|
||||
glm::uint32 const GLI_FOURCC_G32R32F = 0x00000073; // 32-bit float Red/Green
|
||||
glm::uint32 const GLI_FOURCC_A32B32G32R32F = 0x00000074; // 32-bit float RGBA
|
||||
|
||||
glm::uint32 const GLI_DDPF_ALPHAPIXELS = 0x00000001; // The surface has alpha channel information in the pixel format.
|
||||
glm::uint32 const GLI_DDPF_ALPHA = 0x00000002; // The pixel format contains alpha only information
|
||||
glm::uint32 const GLI_DDPF_FOURCC = 0x00000004; // The FourCC code is valid.
|
||||
glm::uint32 const GLI_DDPF_RGB = 0x00000040; // The RGB data in the pixel format structure is valid.
|
||||
//glm::uint32 const GLI_DDPF_COMPRESSED = 0x00000080; // The surface will accept pixel data in the format specified and compress it during the write.
|
||||
//glm::uint32 const GLI_DDPF_RGBTOYUV = 0x00000100; // The surface will accept RGB data and translate it during the write to YUV data.
|
||||
glm::uint32 const GLI_DDPF_YUV = 0x00000200; // Pixel format is YUV - YUV data in pixel format struct is valid.
|
||||
//glm::uint32 const GLI_DDPF_ZBUFFER = 0x00000400; // Pixel format is a z buffer only surface
|
||||
//glm::uint32 const GLI_DDPF_ZPIXELS = 0x00002000; // The surface contains Z information in the pixels
|
||||
//glm::uint32 const GLI_DDPF_STENCILBUFFER = 0x00004000; // The surface contains stencil information along with Z
|
||||
//glm::uint32 const GLI_DDPF_ALPHAPREMULT = 0x00008000; // Premultiplied alpha format -- the color components have been premultiplied by the alpha component.
|
||||
glm::uint32 const GLI_DDPF_LUMINANCE = 0x00020000; // Luminance data in the pixel format is valid.
|
||||
//glm::uint32 const GLI_DDPF_BUMPLUMINANCE = 0x00040000; // Use this flag for luminance-only or luminance+alpha surfaces, the bit depth is then ddpf.dwLuminanceBitCount.
|
||||
//glm::uint32 const GLI_DDPF_BUMPDUDV = 0x00080000; // Bump map dUdV data in the pixel format is valid.
|
||||
|
||||
glm::uint32 const GLI_DDSD_CAPS = 0x00000001;
|
||||
glm::uint32 const GLI_DDSD_HEIGHT = 0x00000002;
|
||||
glm::uint32 const GLI_DDSD_WIDTH = 0x00000004;
|
||||
glm::uint32 const GLI_DDSD_PITCH = 0x00000008;
|
||||
glm::uint32 const GLI_DDSD_PIXELFORMAT = 0x00001000;
|
||||
glm::uint32 const GLI_DDSD_MIPMAPCOUNT = 0x00020000;
|
||||
glm::uint32 const GLI_DDSD_LINEARSIZE = 0x00080000;
|
||||
glm::uint32 const GLI_DDSD_DEPTH = 0x00800000;
|
||||
|
||||
struct DDLoader
|
||||
{
|
||||
glm::uint32 BlockSize;
|
||||
glm::uint32 BPP;
|
||||
gli::format Format;
|
||||
};
|
||||
|
||||
enum format_type
|
||||
{
|
||||
FORMAT_TYPE_NULL,
|
||||
FORMAT_RGBA,
|
||||
FORMAT_FOURCC
|
||||
};
|
||||
|
||||
inline glm::uint32 getFormatFourCC(gli::texture2D const & Image)
|
||||
{
|
||||
switch(Image.format())
|
||||
{
|
||||
default:
|
||||
return 0;
|
||||
case DXT1:
|
||||
return GLI_FOURCC_DXT1;
|
||||
case DXT3:
|
||||
return GLI_FOURCC_DXT3;
|
||||
case DXT5:
|
||||
return GLI_FOURCC_DXT5;
|
||||
case ATI1N_UNORM:
|
||||
case ATI1N_SNORM:
|
||||
case ATI2N_UNORM:
|
||||
case ATI2N_SNORM:
|
||||
case BP_UF16:
|
||||
case BP_SF16:
|
||||
case BP:
|
||||
return GLI_FOURCC_DX10;
|
||||
case R16F:
|
||||
return GLI_FOURCC_R16F;
|
||||
case RG16F:
|
||||
return GLI_FOURCC_G16R16F;
|
||||
case RGBA16F:
|
||||
return GLI_FOURCC_A16B16G16R16F;
|
||||
case R32F:
|
||||
return GLI_FOURCC_R32F;
|
||||
case RG32F:
|
||||
return GLI_FOURCC_G32R32F;
|
||||
case RGBA32F:
|
||||
return GLI_FOURCC_A32B32G32R32F;
|
||||
}
|
||||
}
|
||||
|
||||
inline glm::uint32 getFormatBlockSize(gli::texture2D const & Image)
|
||||
{
|
||||
switch(Image.format())
|
||||
{
|
||||
default:
|
||||
return 0;
|
||||
case DXT1:
|
||||
return 8;
|
||||
case DXT3:
|
||||
return 16;
|
||||
case DXT5:
|
||||
return 16;
|
||||
case ATI1N_UNORM:
|
||||
case ATI1N_SNORM:
|
||||
return 16;
|
||||
case ATI2N_UNORM:
|
||||
case ATI2N_SNORM:
|
||||
return 32;
|
||||
case BP_UF16:
|
||||
case BP_SF16:
|
||||
return 32;
|
||||
case BP:
|
||||
return 32;
|
||||
case R16F:
|
||||
return 2;
|
||||
case RG16F:
|
||||
return 4;
|
||||
case RGBA16F:
|
||||
return 8;
|
||||
case R32F:
|
||||
return 4;
|
||||
case RG32F:
|
||||
return 8;
|
||||
case RGBA32F:
|
||||
return 16;
|
||||
}
|
||||
}
|
||||
|
||||
inline glm::uint32 getFormatFlags(gli::texture2D const & Image)
|
||||
{
|
||||
glm::uint32 Result = 0;
|
||||
|
||||
switch(Image.format())
|
||||
{
|
||||
default:
|
||||
break;
|
||||
case R8U:
|
||||
case RG8U:
|
||||
case RGB8U:
|
||||
case RGBA8U:
|
||||
case R16U:
|
||||
case RG16U:
|
||||
case RGB16U:
|
||||
case RGBA16U:
|
||||
case R32U:
|
||||
case RG32U:
|
||||
case RGB32U:
|
||||
case RGBA32U:
|
||||
case R8I:
|
||||
case RG8I:
|
||||
case RGB8I:
|
||||
case RGBA8I:
|
||||
case R16I:
|
||||
case RG16I:
|
||||
case RGB16I:
|
||||
case RGBA16I:
|
||||
case R32I:
|
||||
case RG32I:
|
||||
case RGB32I:
|
||||
case RGBA32I:
|
||||
Result |= GLI_DDPF_RGB;
|
||||
break;
|
||||
case R16F:
|
||||
case RG16F:
|
||||
case RGB16F:
|
||||
case RGBA16F:
|
||||
case R32F:
|
||||
case RG32F:
|
||||
case RGB32F:
|
||||
case RGBA32F:
|
||||
case RGBE8:
|
||||
case RGB9E5:
|
||||
case RG11B10F:
|
||||
case R5G6B5:
|
||||
case RGBA4:
|
||||
case RGB10A2:
|
||||
case D16:
|
||||
case D24X8:
|
||||
case D24S8:
|
||||
case D32F:
|
||||
case D32FS8X24:
|
||||
case DXT1:
|
||||
case DXT3:
|
||||
case DXT5:
|
||||
case ATI1N_UNORM:
|
||||
case ATI1N_SNORM:
|
||||
case ATI2N_UNORM:
|
||||
case ATI2N_SNORM:
|
||||
case BP_UF16:
|
||||
case BP_SF16:
|
||||
case BP:
|
||||
Result |= GLI_DDPF_FOURCC;
|
||||
break;
|
||||
};
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
inline glm::uint32 getFormatBPP(gli::texture2D const & Image)
|
||||
{
|
||||
switch(Image.format())
|
||||
{
|
||||
default:
|
||||
return 0;
|
||||
case R8U:
|
||||
case R8I:
|
||||
return 8;
|
||||
case RG8U:
|
||||
case RG8I:
|
||||
return 16;
|
||||
case RGB8U:
|
||||
case RGB8I:
|
||||
return 24;
|
||||
case RGBA8U:
|
||||
case RGBA8I:
|
||||
return 32;
|
||||
case DXT1:
|
||||
return 4;
|
||||
case DXT3:
|
||||
return 8;
|
||||
case DXT5:
|
||||
return 8;
|
||||
case ATI1N_UNORM:
|
||||
case ATI1N_SNORM:
|
||||
return 4;
|
||||
case ATI2N_UNORM:
|
||||
case ATI2N_SNORM:
|
||||
return 8;
|
||||
case BP_UF16:
|
||||
case BP_SF16:
|
||||
return 8;
|
||||
case BP:
|
||||
return 8;
|
||||
}
|
||||
}
|
||||
|
||||
inline bool isCompressed(gli::texture2D const & Image)
|
||||
{
|
||||
switch(Image.format())
|
||||
{
|
||||
default:
|
||||
return false;
|
||||
case DXT1:
|
||||
case DXT3:
|
||||
case DXT5:
|
||||
case ATI1N_UNORM:
|
||||
case ATI1N_SNORM:
|
||||
case ATI2N_UNORM:
|
||||
case ATI2N_SNORM:
|
||||
case BP_UF16:
|
||||
case BP_SF16:
|
||||
case BP:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}//namespace detail
|
||||
|
||||
inline texture2D loadDDS9
|
||||
(
|
||||
std::string const & Filename
|
||||
)
|
||||
{
|
||||
std::ifstream FileIn(Filename.c_str(), std::ios::in | std::ios::binary);
|
||||
if(FileIn.fail())
|
||||
return texture2D();
|
||||
|
||||
detail::ddsHeader SurfaceDesc;
|
||||
char Magic[4];
|
||||
|
||||
//* Read magic number and check if valid .dds file
|
||||
FileIn.read((char*)&Magic, sizeof(Magic));
|
||||
|
||||
assert(strncmp(Magic, "DDS ", 4) == 0);
|
||||
|
||||
// Get the surface descriptor
|
||||
FileIn.read((char*)&SurfaceDesc, sizeof(SurfaceDesc));
|
||||
|
||||
std::size_t Width = SurfaceDesc.width;
|
||||
std::size_t Height = SurfaceDesc.height;
|
||||
|
||||
//std::size_t Levels = glm::max(glm::highestBit(Width), glm::highestBit(Height));
|
||||
|
||||
detail::DDLoader Loader;
|
||||
if(SurfaceDesc.format.flags & detail::GLI_DDPF_FOURCC)
|
||||
{
|
||||
switch(SurfaceDesc.format.fourCC)
|
||||
{
|
||||
case detail::GLI_FOURCC_DX10:
|
||||
assert(0);
|
||||
break;
|
||||
case detail::GLI_FOURCC_DXT1:
|
||||
Loader.BlockSize = 8;
|
||||
Loader.Format = DXT1;
|
||||
break;
|
||||
case detail::GLI_FOURCC_DXT3:
|
||||
Loader.BlockSize = 16;
|
||||
Loader.Format = DXT3;
|
||||
break;
|
||||
case detail::GLI_FOURCC_DXT5:
|
||||
Loader.BlockSize = 16;
|
||||
Loader.Format = DXT5;
|
||||
break;
|
||||
case detail::GLI_FOURCC_R16F:
|
||||
Loader.BlockSize = 2;
|
||||
Loader.Format = R16F;
|
||||
break;
|
||||
case detail::GLI_FOURCC_G16R16F:
|
||||
Loader.BlockSize = 4;
|
||||
Loader.Format = RG16F;
|
||||
break;
|
||||
case detail::GLI_FOURCC_A16B16G16R16F:
|
||||
Loader.BlockSize = 8;
|
||||
Loader.Format = RGBA16F;
|
||||
break;
|
||||
case detail::GLI_FOURCC_R32F:
|
||||
Loader.BlockSize = 4;
|
||||
Loader.Format = R32F;
|
||||
break;
|
||||
case detail::GLI_FOURCC_G32R32F:
|
||||
Loader.BlockSize = 8;
|
||||
Loader.Format = RG32F;
|
||||
break;
|
||||
case detail::GLI_FOURCC_A32B32G32R32F:
|
||||
Loader.BlockSize = 16;
|
||||
Loader.Format = RGBA32F;
|
||||
break;
|
||||
|
||||
default:
|
||||
assert(0);
|
||||
return texture2D();
|
||||
}
|
||||
}
|
||||
else if(SurfaceDesc.format.flags & detail::GLI_DDPF_RGB)
|
||||
{
|
||||
switch(SurfaceDesc.format.bpp)
|
||||
{
|
||||
case 8:
|
||||
Loader.BlockSize = 2;
|
||||
Loader.Format = R8U;
|
||||
break;
|
||||
case 16:
|
||||
Loader.BlockSize = 2;
|
||||
Loader.Format = RG8U;
|
||||
break;
|
||||
case 24:
|
||||
Loader.BlockSize = 3;
|
||||
Loader.Format = RGB8U;
|
||||
break;
|
||||
case 32:
|
||||
Loader.BlockSize = 4;
|
||||
Loader.Format = RGBA8U;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
gli::format Format = Loader.Format;
|
||||
|
||||
std::streamoff Curr = FileIn.tellg();
|
||||
FileIn.seekg(0, std::ios_base::end);
|
||||
std::streamoff End = FileIn.tellg();
|
||||
FileIn.seekg(Curr, std::ios_base::beg);
|
||||
|
||||
std::vector<glm::byte> Data(std::size_t(End - Curr), 0);
|
||||
std::size_t Offset = 0;
|
||||
|
||||
FileIn.read((char*)&Data[0], std::streamsize(Data.size()));
|
||||
|
||||
//image Image(glm::min(MipMapCount, Levels));//SurfaceDesc.mipMapLevels);
|
||||
std::size_t MipMapCount = (SurfaceDesc.flags & detail::GLI_DDSD_MIPMAPCOUNT) ? SurfaceDesc.mipMapLevels : 1;
|
||||
//if(Loader.Format == DXT1 || Loader.Format == DXT3 || Loader.Format == DXT5)
|
||||
// MipMapCount -= 2;
|
||||
texture2D Image(MipMapCount);
|
||||
for(std::size_t Level = 0; Level < Image.levels() && (Width || Height); ++Level)
|
||||
{
|
||||
Width = glm::max(std::size_t(Width), std::size_t(1));
|
||||
Height = glm::max(std::size_t(Height), std::size_t(1));
|
||||
|
||||
std::size_t MipmapSize = 0;
|
||||
if(Loader.Format == DXT1 || Loader.Format == DXT3 || Loader.Format == DXT5)
|
||||
MipmapSize = ((Width + 3) >> 2) * ((Height + 3) >> 2) * Loader.BlockSize;
|
||||
else
|
||||
MipmapSize = Width * Height * Loader.BlockSize;
|
||||
std::vector<glm::byte> MipmapData(MipmapSize, 0);
|
||||
|
||||
memcpy(&MipmapData[0], &Data[0] + Offset, MipmapSize);
|
||||
|
||||
image2D::dimensions_type Dimensions(Width, Height);
|
||||
Image[Level] = image2D(Dimensions, Format, MipmapData);
|
||||
|
||||
Offset += MipmapSize;
|
||||
Width >>= 1;
|
||||
Height >>= 1;
|
||||
}
|
||||
|
||||
return Image;
|
||||
}
|
||||
|
||||
inline textureCube loadTextureCubeDDS9
|
||||
(
|
||||
std::string const & Filename
|
||||
)
|
||||
{
|
||||
std::ifstream FileIn(Filename.c_str(), std::ios::in | std::ios::binary);
|
||||
if(FileIn.fail())
|
||||
return textureCube();
|
||||
|
||||
detail::ddsHeader SurfaceDesc;
|
||||
char Magic[4];
|
||||
|
||||
//* Read magic number and check if valid .dds file
|
||||
FileIn.read((char*)&Magic, sizeof(Magic));
|
||||
|
||||
assert(strncmp(Magic, "DDS ", 4) == 0);
|
||||
|
||||
// Get the surface descriptor
|
||||
FileIn.read((char*)&SurfaceDesc, sizeof(SurfaceDesc));
|
||||
|
||||
std::size_t Width = SurfaceDesc.width;
|
||||
std::size_t Height = SurfaceDesc.height;
|
||||
|
||||
//std::size_t Levels = glm::max(glm::highestBit(Width), glm::highestBit(Height));
|
||||
|
||||
detail::DDLoader Loader;
|
||||
if(SurfaceDesc.format.flags & detail::GLI_DDPF_FOURCC)
|
||||
{
|
||||
switch(SurfaceDesc.format.fourCC)
|
||||
{
|
||||
case detail::GLI_FOURCC_DX10:
|
||||
assert(0);
|
||||
break;
|
||||
case detail::GLI_FOURCC_DXT1:
|
||||
Loader.BlockSize = 8;
|
||||
Loader.Format = DXT1;
|
||||
break;
|
||||
case detail::GLI_FOURCC_DXT3:
|
||||
Loader.BlockSize = 16;
|
||||
Loader.Format = DXT3;
|
||||
break;
|
||||
case detail::GLI_FOURCC_DXT5:
|
||||
Loader.BlockSize = 16;
|
||||
Loader.Format = DXT5;
|
||||
break;
|
||||
case detail::GLI_FOURCC_R16F:
|
||||
Loader.BlockSize = 2;
|
||||
Loader.Format = R16F;
|
||||
break;
|
||||
case detail::GLI_FOURCC_G16R16F:
|
||||
Loader.BlockSize = 4;
|
||||
Loader.Format = RG16F;
|
||||
break;
|
||||
case detail::GLI_FOURCC_A16B16G16R16F:
|
||||
Loader.BlockSize = 8;
|
||||
Loader.Format = RGBA16F;
|
||||
break;
|
||||
case detail::GLI_FOURCC_R32F:
|
||||
Loader.BlockSize = 4;
|
||||
Loader.Format = R32F;
|
||||
break;
|
||||
case detail::GLI_FOURCC_G32R32F:
|
||||
Loader.BlockSize = 8;
|
||||
Loader.Format = RG32F;
|
||||
break;
|
||||
case detail::GLI_FOURCC_A32B32G32R32F:
|
||||
Loader.BlockSize = 16;
|
||||
Loader.Format = RGBA32F;
|
||||
break;
|
||||
|
||||
default:
|
||||
assert(0);
|
||||
return textureCube();
|
||||
}
|
||||
}
|
||||
else if(SurfaceDesc.format.flags & detail::GLI_DDPF_RGB)
|
||||
{
|
||||
switch(SurfaceDesc.format.bpp)
|
||||
{
|
||||
case 8:
|
||||
Loader.BlockSize = 2;
|
||||
Loader.Format = R8U;
|
||||
break;
|
||||
case 16:
|
||||
Loader.BlockSize = 2;
|
||||
Loader.Format = RG8U;
|
||||
break;
|
||||
case 24:
|
||||
Loader.BlockSize = 3;
|
||||
Loader.Format = RGB8U;
|
||||
break;
|
||||
case 32:
|
||||
Loader.BlockSize = 4;
|
||||
Loader.Format = RGBA8U;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
gli::format Format = Loader.Format;
|
||||
|
||||
std::streamoff Curr = FileIn.tellg();
|
||||
FileIn.seekg(0, std::ios_base::end);
|
||||
std::streamoff End = FileIn.tellg();
|
||||
FileIn.seekg(Curr, std::ios_base::beg);
|
||||
|
||||
std::vector<glm::byte> Data(std::size_t(End - Curr), 0);
|
||||
std::size_t Offset = 0;
|
||||
|
||||
FileIn.read((char*)&Data[0], std::streamsize(Data.size()));
|
||||
|
||||
//image Image(glm::min(MipMapCount, Levels));//SurfaceDesc.mipMapLevels);
|
||||
std::size_t MipMapCount = (SurfaceDesc.flags & detail::GLI_DDSD_MIPMAPCOUNT) ? SurfaceDesc.mipMapLevels : 1;
|
||||
//if(Loader.Format == DXT1 || Loader.Format == DXT3 || Loader.Format == DXT5)
|
||||
// MipMapCount -= 2;
|
||||
textureCube Texture(MipMapCount);
|
||||
|
||||
for(textureCube::size_type Face = 0; Face < FACE_MAX; ++Face)
|
||||
{
|
||||
Width = SurfaceDesc.width;
|
||||
Height = SurfaceDesc.height;
|
||||
|
||||
for(textureCube::size_type Level = 0; Level < Texture.levels() && (Width || Height); ++Level)
|
||||
{
|
||||
Width = glm::max(std::size_t(Width), std::size_t(1));
|
||||
Height = glm::max(std::size_t(Height), std::size_t(1));
|
||||
|
||||
std::size_t MipmapSize = 0;
|
||||
if(Loader.Format == DXT1 || Loader.Format == DXT3 || Loader.Format == DXT5)
|
||||
MipmapSize = ((Width + 3) >> 2) * ((Height + 3) >> 2) * Loader.BlockSize;
|
||||
else
|
||||
MipmapSize = Width * Height * Loader.BlockSize;
|
||||
std::vector<glm::byte> MipmapData(MipmapSize, 0);
|
||||
|
||||
memcpy(&MipmapData[0], &Data[0] + Offset, MipmapSize);
|
||||
|
||||
textureCube::dimensions_type Dimensions(Width, Height);
|
||||
Texture[textureCube::face_type(Face)][Level] = image2D(Dimensions, Format, MipmapData);
|
||||
|
||||
Offset += MipmapSize;
|
||||
Width >>= 1;
|
||||
Height >>= 1;
|
||||
}
|
||||
}
|
||||
|
||||
return Texture;
|
||||
}
|
||||
|
||||
inline void saveDDS9
|
||||
(
|
||||
texture2D const & Texture,
|
||||
std::string const & Filename
|
||||
)
|
||||
{
|
||||
std::ofstream FileOut(Filename.c_str(), std::ios::out | std::ios::binary);
|
||||
if (!FileOut)
|
||||
return;
|
||||
|
||||
char const * Magic = "DDS ";
|
||||
FileOut.write((char*)Magic, sizeof(char) * 4);
|
||||
|
||||
glm::uint32 Caps = detail::GLI_DDSD_CAPS | detail::GLI_DDSD_HEIGHT | detail::GLI_DDSD_WIDTH | detail::GLI_DDSD_PIXELFORMAT;
|
||||
|
||||
detail::ddsHeader SurfaceDesc;
|
||||
SurfaceDesc.size = sizeof(detail::ddsHeader);
|
||||
SurfaceDesc.flags = Caps | (detail::isCompressed(Texture) ? detail::GLI_DDSD_LINEARSIZE : detail::GLI_DDSD_PITCH) | (Texture.levels() > 1 ? detail::GLI_DDSD_MIPMAPCOUNT : 0); //659463;
|
||||
SurfaceDesc.width = Texture[0].dimensions().x;
|
||||
SurfaceDesc.height = Texture[0].dimensions().y;
|
||||
SurfaceDesc.pitch = loader_dds9::detail::isCompressed(Texture) ? size(Texture, LINEAR_SIZE) : 32;
|
||||
SurfaceDesc.depth = 0;
|
||||
SurfaceDesc.mipMapLevels = glm::uint32(Texture.levels());
|
||||
SurfaceDesc.format.size = sizeof(detail::ddsPixelFormat);
|
||||
SurfaceDesc.format.flags = detail::getFormatFlags(Texture);
|
||||
SurfaceDesc.format.fourCC = detail::getFormatFourCC(Texture);
|
||||
SurfaceDesc.format.bpp = detail::getFormatBPP(Texture);
|
||||
SurfaceDesc.format.redMask = 0;
|
||||
SurfaceDesc.format.greenMask = 0;
|
||||
SurfaceDesc.format.blueMask = 0;
|
||||
SurfaceDesc.format.alphaMask = 0;
|
||||
SurfaceDesc.surfaceFlags = detail::GLI_DDSCAPS_TEXTURE | (Texture.levels() > 1 ? detail::GLI_DDSCAPS_MIPMAP : 0);
|
||||
SurfaceDesc.cubemapFlags = 0;
|
||||
|
||||
FileOut.write((char*)&SurfaceDesc, sizeof(SurfaceDesc));
|
||||
|
||||
for(texture2D::level_type Level = 0; Level < Texture.levels(); ++Level)
|
||||
{
|
||||
texture2D::size_type ImageSize = size(Texture[Level], gli::LINEAR_SIZE);
|
||||
FileOut.write((char*)(Texture[Level].data()), ImageSize);
|
||||
}
|
||||
|
||||
if(FileOut.fail() || FileOut.bad())
|
||||
return;
|
||||
|
||||
FileOut.close ();
|
||||
}
|
||||
|
||||
inline void saveTextureCubeDDS9
|
||||
(
|
||||
textureCube const & Texture,
|
||||
std::string const & Filename
|
||||
)
|
||||
{
|
||||
std::ofstream FileOut(Filename.c_str(), std::ios::out | std::ios::binary);
|
||||
if (!FileOut || Texture.empty())
|
||||
return;
|
||||
|
||||
char const * Magic = "DDS ";
|
||||
FileOut.write((char*)Magic, sizeof(char) * 4);
|
||||
|
||||
glm::uint32 Caps = detail::GLI_DDSD_CAPS | detail::GLI_DDSD_HEIGHT | detail::GLI_DDSD_WIDTH | detail::GLI_DDSD_PIXELFORMAT | detail::GLI_DDSCAPS_COMPLEX;
|
||||
|
||||
detail::ddsHeader SurfaceDesc;
|
||||
SurfaceDesc.size = sizeof(detail::ddsHeader);
|
||||
SurfaceDesc.flags = Caps | (detail::isCompressed(Texture[POSITIVE_X]) ? detail::GLI_DDSD_LINEARSIZE : detail::GLI_DDSD_PITCH) | (Texture.levels() > 1 ? detail::GLI_DDSD_MIPMAPCOUNT : 0); //659463;
|
||||
SurfaceDesc.width = Texture[POSITIVE_X][0].dimensions().x;
|
||||
SurfaceDesc.height = Texture[POSITIVE_X][0].dimensions().y;
|
||||
SurfaceDesc.pitch = loader_dds9::detail::isCompressed(Texture[POSITIVE_X]) ? size(Texture[POSITIVE_X], LINEAR_SIZE) : 32;
|
||||
SurfaceDesc.depth = 0;
|
||||
SurfaceDesc.mipMapLevels = glm::uint32(Texture.levels());
|
||||
SurfaceDesc.format.size = sizeof(detail::ddsPixelFormat);
|
||||
SurfaceDesc.format.flags = detail::getFormatFlags(Texture[POSITIVE_X]);
|
||||
SurfaceDesc.format.fourCC = detail::getFormatFourCC(Texture[POSITIVE_X]);
|
||||
SurfaceDesc.format.bpp = detail::getFormatBPP(Texture[POSITIVE_X]);
|
||||
SurfaceDesc.format.redMask = 0;
|
||||
SurfaceDesc.format.greenMask = 0;
|
||||
SurfaceDesc.format.blueMask = 0;
|
||||
SurfaceDesc.format.alphaMask = 0;
|
||||
SurfaceDesc.surfaceFlags = detail::GLI_DDSCAPS_TEXTURE | (Texture.levels() > 1 ? detail::GLI_DDSCAPS_MIPMAP : 0);
|
||||
SurfaceDesc.cubemapFlags =
|
||||
detail::GLI_DDSCAPS2_CUBEMAP | detail::GLI_DDSCAPS2_CUBEMAP_POSITIVEX | detail::GLI_DDSCAPS2_CUBEMAP_NEGATIVEX | detail::GLI_DDSCAPS2_CUBEMAP_POSITIVEY | detail::GLI_DDSCAPS2_CUBEMAP_NEGATIVEY | detail::GLI_DDSCAPS2_CUBEMAP_POSITIVEZ | detail::GLI_DDSCAPS2_CUBEMAP_NEGATIVEZ;
|
||||
|
||||
FileOut.write((char*)&SurfaceDesc, sizeof(SurfaceDesc));
|
||||
|
||||
for(textureCube::size_type Face = 0; Face < FACE_MAX; ++Face)
|
||||
for(texture2D::level_type Level = 0; Level < Texture.levels(); ++Level)
|
||||
{
|
||||
texture2D::size_type ImageSize = size(Texture[textureCube::face_type(Face)][Level], gli::LINEAR_SIZE);
|
||||
FileOut.write((char*)(Texture[textureCube::face_type(Face)][Level].data()), ImageSize);
|
||||
}
|
||||
|
||||
if(FileOut.fail() || FileOut.bad())
|
||||
return;
|
||||
|
||||
FileOut.close ();
|
||||
}
|
||||
|
||||
}//namespace loader_dds9
|
||||
}//namespace gtx
|
||||
}//namespace gli
|
36
test/external/gli/gtx/loader_tga.hpp
vendored
36
test/external/gli/gtx/loader_tga.hpp
vendored
@ -1,36 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2010-09-08
|
||||
// Updated : 2010-09-27
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/gtx/loader_tga.hpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLI_GTX_LOADER_TGA_INCLUDED
|
||||
#define GLI_GTX_LOADER_TGA_INCLUDED
|
||||
|
||||
#include "../gli.hpp"
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
|
||||
namespace gli{
|
||||
namespace gtx{
|
||||
namespace loader_tga
|
||||
{
|
||||
texture2D loadTGA(
|
||||
std::string const & Filename);
|
||||
|
||||
void saveTGA(
|
||||
texture2D const & Image,
|
||||
std::string const & Filename);
|
||||
|
||||
}//namespace loader_tga
|
||||
}//namespace gtx
|
||||
}//namespace gli
|
||||
|
||||
namespace gli{using namespace gtx::loader_tga;}
|
||||
|
||||
#include "loader_tga.inl"
|
||||
|
||||
#endif//GLI_GTX_LOADER_TGA_INCLUDED
|
159
test/external/gli/gtx/loader_tga.inl
vendored
159
test/external/gli/gtx/loader_tga.inl
vendored
@ -1,159 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2010-09-08
|
||||
// Updated : 2010-09-27
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/gtx/loader_tga.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace gli{
|
||||
namespace gtx{
|
||||
namespace loader_tga
|
||||
{
|
||||
inline texture2D loadTGA
|
||||
(
|
||||
std::string const & Filename
|
||||
)
|
||||
{
|
||||
std::ifstream FileIn(Filename.c_str(), std::ios::in | std::ios::binary);
|
||||
if(!FileIn)
|
||||
return texture2D();
|
||||
|
||||
unsigned char IdentificationFieldSize;
|
||||
unsigned char ColorMapType;
|
||||
unsigned char ImageType;
|
||||
unsigned short ColorMapOrigin;
|
||||
unsigned short ColorMapLength;
|
||||
unsigned char ColorMapEntrySize;
|
||||
unsigned short OriginX;
|
||||
unsigned short OriginY;
|
||||
unsigned short Width;
|
||||
unsigned short Height;
|
||||
unsigned char TexelSize;
|
||||
unsigned char Descriptor;
|
||||
|
||||
FileIn.read((char*)&IdentificationFieldSize, sizeof(IdentificationFieldSize));
|
||||
FileIn.read((char*)&ColorMapType, sizeof(ColorMapType));
|
||||
FileIn.read((char*)&ImageType, sizeof(ImageType));
|
||||
FileIn.read((char*)&ColorMapOrigin, sizeof(ColorMapOrigin));
|
||||
FileIn.read((char*)&ColorMapLength, sizeof(ColorMapLength));
|
||||
FileIn.read((char*)&ColorMapEntrySize, sizeof(ColorMapEntrySize));
|
||||
FileIn.read((char*)&OriginX, sizeof(OriginX));
|
||||
FileIn.read((char*)&OriginY, sizeof(OriginY));
|
||||
FileIn.read((char*)&Width, sizeof(Width));
|
||||
FileIn.read((char*)&Height, sizeof(Height));
|
||||
FileIn.read((char*)&TexelSize, sizeof(TexelSize));
|
||||
FileIn.read((char*)&Descriptor, sizeof(Descriptor));
|
||||
|
||||
gli::format Format = gli::FORMAT_NULL;
|
||||
if(TexelSize == 24)
|
||||
Format = gli::RGB8U;
|
||||
else if(TexelSize == 32)
|
||||
Format = gli::RGBA8U;
|
||||
else
|
||||
assert(0);
|
||||
|
||||
image2D Mipmap(texture2D::dimensions_type(Width, Height), Format);
|
||||
|
||||
if (FileIn.fail() || FileIn.bad())
|
||||
{
|
||||
assert(0);
|
||||
return texture2D();
|
||||
}
|
||||
|
||||
switch(ImageType)
|
||||
{
|
||||
default:
|
||||
assert(0);
|
||||
return texture2D();
|
||||
|
||||
case 2:
|
||||
FileIn.seekg(18 + ColorMapLength, std::ios::beg);
|
||||
|
||||
char* IdentificationField = new char[IdentificationFieldSize + 1];
|
||||
FileIn.read(IdentificationField, IdentificationFieldSize);
|
||||
IdentificationField[IdentificationFieldSize] = '\0';
|
||||
delete[] IdentificationField;
|
||||
|
||||
std::size_t DataSize = Width * Height * (TexelSize >> 3);
|
||||
FileIn.read((char*)Mipmap.data(), std::streamsize(DataSize));
|
||||
|
||||
if(FileIn.fail() || FileIn.bad())
|
||||
return texture2D();
|
||||
break;
|
||||
}
|
||||
|
||||
FileIn.close();
|
||||
|
||||
texture2D Image(1);
|
||||
Image[0] = Mipmap;
|
||||
|
||||
// TGA images are saved in BGR or BGRA format.
|
||||
if(TexelSize == 24)
|
||||
Image.swizzle<glm::u8vec3>(gli::B, gli::G, gli::R, gli::A);
|
||||
if(TexelSize == 32)
|
||||
Image.swizzle<glm::u8vec4>(gli::B, gli::G, gli::R, gli::A);
|
||||
|
||||
return Image;
|
||||
}
|
||||
|
||||
inline void saveTGA
|
||||
(
|
||||
gli::texture2D const & ImageIn,
|
||||
std::string const & Filename
|
||||
)
|
||||
{
|
||||
std::ofstream FileOut(Filename.c_str(), std::ios::out | std::ios::binary);
|
||||
if (!FileOut)
|
||||
return;
|
||||
|
||||
gli::texture2D Image = duplicate(ImageIn);
|
||||
|
||||
unsigned char IdentificationFieldSize = 1;
|
||||
unsigned char ColorMapType = 0;
|
||||
unsigned char ImageType = 2;
|
||||
unsigned short ColorMapOrigin = 0;
|
||||
unsigned short ColorMapLength = 0;
|
||||
unsigned char ColorMapEntrySize = 0;
|
||||
unsigned short OriginX = 0;
|
||||
unsigned short OriginY = 0;
|
||||
unsigned short Width = Image[0].dimensions().x;
|
||||
unsigned short Height = Image[0].dimensions().y;
|
||||
unsigned char TexelSize = (unsigned char)(Image[0].value_size());
|
||||
unsigned char Descriptor = 0;
|
||||
|
||||
if(TexelSize == 24)
|
||||
Image.swizzle<glm::u8vec3>(gli::B, gli::G, gli::R, gli::A);
|
||||
if(TexelSize == 32)
|
||||
Image.swizzle<glm::u8vec4>(gli::B, gli::G, gli::R, gli::A);
|
||||
|
||||
FileOut.write((char*)&IdentificationFieldSize, sizeof(IdentificationFieldSize));
|
||||
FileOut.write((char*)&ColorMapType, sizeof(ColorMapType));
|
||||
FileOut.write((char*)&ImageType, sizeof(ImageType));
|
||||
FileOut.write((char*)&ColorMapOrigin, sizeof(ColorMapOrigin));
|
||||
FileOut.write((char*)&ColorMapLength, sizeof(ColorMapLength));
|
||||
FileOut.write((char*)&ColorMapEntrySize, sizeof(ColorMapEntrySize));
|
||||
FileOut.write((char*)&OriginX, sizeof(OriginX));
|
||||
FileOut.write((char*)&OriginY, sizeof(OriginY));
|
||||
FileOut.write((char*)&Width, sizeof(Width));
|
||||
FileOut.write((char*)&Height, sizeof(Height));
|
||||
FileOut.write((char*)&TexelSize, sizeof(TexelSize));
|
||||
FileOut.write((char*)&Descriptor, sizeof(Descriptor));
|
||||
|
||||
if (FileOut.fail () || FileOut.bad ())
|
||||
return;
|
||||
|
||||
FileOut.seekp(18 + ColorMapLength, std::ios::beg);
|
||||
char* IdentificationField = new char[IdentificationFieldSize + 1];
|
||||
FileOut.write(IdentificationField, std::streamsize(IdentificationFieldSize));
|
||||
delete[] IdentificationField;
|
||||
FileOut.write((char*)Image[0].data(), std::streamsize(Image[0].capacity()));
|
||||
if(FileOut.fail() || FileOut.bad())
|
||||
return;
|
||||
|
||||
FileOut.close ();
|
||||
}
|
||||
}//namespace loader_tga
|
||||
}//namespace gtx
|
||||
}//namespace gli
|
27
test/external/gli/gtx/wavelet.hpp
vendored
27
test/external/gli/gtx/wavelet.hpp
vendored
@ -1,27 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Image Copyright (c) 2008 - 2011 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2010-01-09
|
||||
// Updated : 2010-01-09
|
||||
// Licence : This source is under MIT License
|
||||
// File : gli/gtx/wavelet.hpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef GLI_GTX_WAVELET_INCLUDED
|
||||
#define GLI_GTX_WAVELET_INCLUDED
|
||||
|
||||
namespace gli{
|
||||
namespace gtx{
|
||||
namespace wavelet
|
||||
{
|
||||
|
||||
|
||||
}//namespace wavelet
|
||||
}//namespace gtx
|
||||
}//namespace gli
|
||||
|
||||
namespace gli{using namespace gtx::wavelet;}
|
||||
|
||||
#include "wavelet.inl"
|
||||
|
||||
#endif//GLI_GTX_WAVELET_INCLUDED
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user