Add various normalized & floating-point image formats

This commit is contained in:
Nikita Lisitsa 2020-10-24 14:33:28 +03:00
parent ef3fa4b091
commit 13595864fd

View file

@ -17,6 +17,14 @@ namespace psemek::gfx
std::uint8_t stencil;
};
struct float16
{
std::uint16_t value;
};
struct uint10;
struct uint12;
template <typename Pixel>
struct pixel_traits;
@ -53,35 +61,59 @@ namespace psemek::gfx
};
template <>
struct pixel_traits<std::int8_t>
struct pixel_traits<std::uint16_t>
{
static constexpr GLenum internal_format = gl::R8;
static constexpr GLenum internal_format = gl::R16;
static constexpr GLenum format = gl::RED;
static constexpr GLenum type = gl::BYTE;
static constexpr GLenum type = gl::UNSIGNED_BYTE;
};
template <>
struct pixel_traits<geom::vector<std::int8_t, 2>>
struct pixel_traits<geom::vector<std::uint16_t, 2>>
{
static constexpr GLenum internal_format = gl::RG8;
static constexpr GLenum internal_format = gl::RG16;
static constexpr GLenum format = gl::RG;
static constexpr GLenum type = gl::BYTE;
static constexpr GLenum type = gl::UNSIGNED_BYTE;
};
template <>
struct pixel_traits<geom::vector<std::int8_t, 3>>
struct pixel_traits<geom::vector<std::uint16_t, 3>>
{
static constexpr GLenum internal_format = gl::RGB8;
static constexpr GLenum internal_format = gl::RGB16;
static constexpr GLenum format = gl::RGB;
static constexpr GLenum type = gl::BYTE;
static constexpr GLenum type = gl::UNSIGNED_BYTE;
};
template <>
struct pixel_traits<geom::vector<std::int8_t, 4>>
struct pixel_traits<geom::vector<std::uint16_t, 4>>
{
static constexpr GLenum internal_format = gl::RGBA8;
static constexpr GLenum internal_format = gl::RGBA16;
static constexpr GLenum format = gl::RGBA;
static constexpr GLenum type = gl::BYTE;
static constexpr GLenum type = gl::UNSIGNED_BYTE;
};
template <>
struct pixel_traits<geom::vector<uint10, 3>>
{
static constexpr GLenum internal_format = gl::RGB10;
static constexpr GLenum format = gl::RGB;
static constexpr GLenum type = gl::UNSIGNED_BYTE;
};
template <>
struct pixel_traits<geom::vector<uint12, 3>>
{
static constexpr GLenum internal_format = gl::RGB12;
static constexpr GLenum format = gl::RGB;
static constexpr GLenum type = gl::UNSIGNED_BYTE;
};
template <>
struct pixel_traits<geom::vector<uint12, 4>>
{
static constexpr GLenum internal_format = gl::RGBA12;
static constexpr GLenum format = gl::RGBA;
static constexpr GLenum type = gl::UNSIGNED_BYTE;
};
template <>
@ -92,6 +124,62 @@ namespace psemek::gfx
static constexpr GLenum type = gl::FLOAT;
};
template <>
struct pixel_traits<geom::vector<float, 2>>
{
static constexpr GLenum internal_format = gl::RG32F;
static constexpr GLenum format = gl::RG;
static constexpr GLenum type = gl::FLOAT;
};
template <>
struct pixel_traits<geom::vector<float, 3>>
{
static constexpr GLenum internal_format = gl::RGB32F;
static constexpr GLenum format = gl::RGB;
static constexpr GLenum type = gl::FLOAT;
};
template <>
struct pixel_traits<geom::vector<float, 4>>
{
static constexpr GLenum internal_format = gl::RGBA32F;
static constexpr GLenum format = gl::RGBA;
static constexpr GLenum type = gl::FLOAT;
};
template <>
struct pixel_traits<float16>
{
static constexpr GLenum internal_format = gl::R16F;
static constexpr GLenum format = gl::RED;
static constexpr GLenum type = gl::FLOAT;
};
template <>
struct pixel_traits<geom::vector<float16, 2>>
{
static constexpr GLenum internal_format = gl::RG16F;
static constexpr GLenum format = gl::RG;
static constexpr GLenum type = gl::FLOAT;
};
template <>
struct pixel_traits<geom::vector<float16, 3>>
{
static constexpr GLenum internal_format = gl::RGB16F;
static constexpr GLenum format = gl::RGB;
static constexpr GLenum type = gl::FLOAT;
};
template <>
struct pixel_traits<geom::vector<float16, 4>>
{
static constexpr GLenum internal_format = gl::RGBA16F;
static constexpr GLenum format = gl::RGBA;
static constexpr GLenum type = gl::FLOAT;
};
template <>
struct pixel_traits<depth24_pixel>
{