Browse Source

Added ETC2 and EAC compressed pixel formats to the generic enum.

pull/370/head
Vladimír Vondruš 7 years ago
parent
commit
7d9ceb8832
  1. 3
      doc/changelog.dox
  2. 23
      src/Magnum/GL/Implementation/compressedPixelFormatMapping.hpp
  3. 10
      src/Magnum/GL/Test/PixelFormatTest.cpp
  4. 10
      src/Magnum/PixelFormat.cpp
  5. 102
      src/Magnum/PixelFormat.h
  6. 10
      src/Magnum/Vk/Implementation/compressedFormatMapping.hpp

3
doc/changelog.dox

@ -50,6 +50,9 @@ See also:
- New @ref BasicMutableImageView "MutableImageView*D" and
@ref BasicMutableCompressedImageView "MutableCompressedImageView*D" types
for mutable views onto image data
- Added ETC2 and EAC formats to @ref CompressedPixelFormat as well as their
conversion to corresponding GL/Vulkan in @ref GL::compressedPixelFormat()
and @ref Vk::vkFormat(Magnum::CompressedPixelFormat)
@subsubsection changelog-latest-new-audio Audio library

23
src/Magnum/GL/Implementation/compressedPixelFormatMapping.hpp

@ -29,4 +29,27 @@ _c(Bc1RGBUnorm, RGBS3tcDxt1)
_c(Bc1RGBAUnorm, RGBAS3tcDxt1)
_c(Bc2RGBAUnorm, RGBAS3tcDxt3)
_c(Bc3RGBAUnorm, RGBAS3tcDxt5)
#ifndef MAGNUM_TARGET_GLES2
_c(EacR11Unorm, R11Eac)
_c(EacR11Snorm, SignedR11Eac)
_c(EacRG11Unorm, RG11Eac)
_c(EacRG11Snorm, SignedRG11Eac)
_c(Etc2RGB8Unorm, RGB8Etc2)
_c(Etc2RGB8Srgb, SRGB8Etc2)
_c(Etc2RGB8A1Unorm, RGB8PunchthroughAlpha1Etc2)
_c(Etc2RGB8A1Srgb, SRGB8PunchthroughAlpha1Etc2)
_c(Etc2RGBA8Unorm, RGBA8Etc2Eac)
_c(Etc2RGBA8Srgb, SRGB8Alpha8Etc2Eac)
#else
_s(EacR11Unorm)
_s(EacR11Snorm)
_s(EacRG11Unorm)
_s(EacRG11Snorm)
_s(Etc2RGB8Unorm)
_s(Etc2RGB8Srgb)
_s(Etc2RGB8A1Unorm)
_s(Etc2RGB8A1Srgb)
_s(Etc2RGBA8Unorm)
_s(Etc2RGBA8Srgb)
#endif
#endif

10
src/Magnum/GL/Test/PixelFormatTest.cpp

@ -271,15 +271,15 @@ void PixelFormatTest::mapCompressedFormatImplementationSpecific() {
CompressedPixelFormat::RGBAS3tcDxt1);
}
void PixelFormatTest::mapCompressedFormatUnsupported() {
#if 1
CORRADE_SKIP("All compressed pixel formats are currently supported everywhere.");
#ifndef MAGNUM_TARGET_GLES2
CORRADE_SKIP("All pixel formats are supported on ES3+.");
#else
CORRADE_VERIFY(!hasCompressedPixelFormat(Magnum::CompressedPixelFormat::Bc1RGBAUnorm));
CORRADE_VERIFY(!hasCompressedPixelFormat(Magnum::CompressedPixelFormat::Etc2RGB8Unorm));
std::ostringstream out;
Error redirectError{&out};
compressedPixelFormat(Magnum::CompressedPixelFormat::Bc1RGBAUnorm);
CORRADE_COMPARE(out.str(), "GL::compressedPixelFormat(): format CompressedPixelFormat::Bc1RGBAUnorm is not supported on this target\n");
compressedPixelFormat(Magnum::CompressedPixelFormat::Etc2RGB8Unorm);
CORRADE_COMPARE(out.str(), "GL::compressedPixelFormat(): format CompressedPixelFormat::Etc2RGB8Unorm is not supported on this target\n");
#endif
}

10
src/Magnum/PixelFormat.cpp

@ -174,6 +174,16 @@ Debug& operator<<(Debug& debug, const CompressedPixelFormat value) {
_c(Bc1RGBAUnorm)
_c(Bc2RGBAUnorm)
_c(Bc3RGBAUnorm)
_c(EacR11Unorm)
_c(EacR11Snorm)
_c(EacRG11Unorm)
_c(EacRG11Snorm)
_c(Etc2RGB8Unorm)
_c(Etc2RGB8Srgb)
_c(Etc2RGB8A1Unorm)
_c(Etc2RGB8A1Srgb)
_c(Etc2RGBA8Unorm)
_c(Etc2RGBA8Srgb)
#undef _c
/* LCOV_EXCL_STOP */
}

102
src/Magnum/PixelFormat.h

@ -608,7 +608,107 @@ enum class CompressedPixelFormat: UnsignedInt {
* @ref GL::TextureFormat::CompressedRGBAS3tcDxt5 /
* @def_vk_keyword{FORMAT_BC3_UNORM_BLOCK,Format}.
*/
Bc3RGBAUnorm
Bc3RGBAUnorm,
/**
* [EAC](https://en.wikipedia.org/wiki/Ericsson_Texture_Compression#ETC2_and_EAC)
* compressed red component, normalized unsigned 11-bit.
*
* Corresponds to @ref GL::CompressedPixelFormat::R11Eac,
* @ref GL::TextureFormat::CompressedR11Eac /
* @def_vk_keyword{FORMAT_EAC_R11_UNORM_BLOCK,Format}.
*/
EacR11Unorm,
/**
* [EAC](https://en.wikipedia.org/wiki/Ericsson_Texture_Compression#ETC2_and_EAC)
* compressed red component, normalized signed 11-bit.
*
* Corresponds to @ref GL::CompressedPixelFormat::SignedR11Eac,
* @ref GL::TextureFormat::CompressedSignedR11Eac /
* @def_vk_keyword{FORMAT_EAC_R11_SNORM_BLOCK,Format}.
*/
EacR11Snorm,
/**
* [EAC](https://en.wikipedia.org/wiki/Ericsson_Texture_Compression#ETC2_and_EAC)
* compressed red and green component, normalized unsigned 11-bit.
*
* Corresponds to @ref GL::CompressedPixelFormat::RG11Eac,
* @ref GL::TextureFormat::CompressedRG11Eac /
* @def_vk_keyword{FORMAT_EAC_R11G11_UNORM_BLOCK,Format}.
*/
EacRG11Unorm,
/**
* [EAC](https://en.wikipedia.org/wiki/Ericsson_Texture_Compression#ETC2_and_EAC)
* compressed red and green component, normalized signed 11-bit.
*
* Corresponds to @ref GL::CompressedPixelFormat::SignedRG11Eac,
* @ref GL::TextureFormat::CompressedSignedRG11Eac /
* @def_vk_keyword{FORMAT_EAC_R11G11_SNORM_BLOCK,Format}.
*/
EacRG11Snorm,
/**
* [ETC2](https://en.wikipedia.org/wiki/Ericsson_Texture_Compression#ETC2_and_EAC)
* compressed RGB, normalized unsigned byte.
*
* Corresponds to @ref GL::CompressedPixelFormat::RGB8Etc2,
* @ref GL::TextureFormat::CompressedRGB8Etc2 /
* @def_vk_keyword{FORMAT_ETC2_R8G8B8_UNORM_BLOCK,Format}.
*/
Etc2RGB8Unorm,
/**
* [ETC2](https://en.wikipedia.org/wiki/Ericsson_Texture_Compression#ETC2_and_EAC)
* compressed sRGB, normalized unsigned byte.
*
* Corresponds to @ref GL::CompressedPixelFormat::SRGB8Etc2,
* @ref GL::TextureFormat::CompressedSRGB8Etc2 /
* @def_vk_keyword{FORMAT_ETC2_R8G8B8_SRGB_BLOCK,Format}.
*/
Etc2RGB8Srgb,
/**
* [ETC2](https://en.wikipedia.org/wiki/Ericsson_Texture_Compression#ETC2_and_EAC)
* compressed RGB, normalized unsigned byte + a single-bit alpha.
*
* Corresponds to @ref GL::CompressedPixelFormat::RGB8PunchthroughAlpha1Etc2,
* @ref GL::TextureFormat::CompressedRGB8PunchthroughAlpha1Etc2 /
* @def_vk_keyword{FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK,Format}.
*/
Etc2RGB8A1Unorm,
/**
* [ETC2](https://en.wikipedia.org/wiki/Ericsson_Texture_Compression#ETC2_and_EAC)
* compressed sRGB, normalized unsigned byte + a single-bit alpha.
*
* Corresponds to @ref GL::CompressedPixelFormat::SRGB8PunchthroughAlpha1Etc2,
* @ref GL::TextureFormat::CompressedSRGB8PunchthroughAlpha1Etc2 /
* @def_vk_keyword{FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK,Format}.
*/
Etc2RGB8A1Srgb,
/**
* [ETC2](https://en.wikipedia.org/wiki/Ericsson_Texture_Compression#ETC2_and_EAC)
* compressed RGBA, normalized unsigned byte (EAC).
*
* Corresponds to @ref GL::CompressedPixelFormat::RGBA8Etc2Eac,
* @ref GL::TextureFormat::CompressedRGBA8Etc2Eac /
* @def_vk_keyword{FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK,Format}.
*/
Etc2RGBA8Unorm,
/**
* [ETC2](https://en.wikipedia.org/wiki/Ericsson_Texture_Compression#ETC2_and_EAC)
* compressed sRGB + linear alpha, normalized unsigned byte (EAC).
*
* Corresponds to @ref GL::CompressedPixelFormat::SRGB8Alpha8Etc2Eac,
* @ref GL::TextureFormat::CompressedSRGB8Alpha8Etc2Eac /
* @def_vk_keyword{FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK,Format}.
*/
Etc2RGBA8Srgb
};
/** @debugoperatorenum{CompressedPixelFormat} */

10
src/Magnum/Vk/Implementation/compressedFormatMapping.hpp

@ -29,4 +29,14 @@ _c(Bc1RGBUnorm, BC1_RGB_UNORM_BLOCK)
_c(Bc1RGBAUnorm, BC1_RGBA_UNORM_BLOCK)
_c(Bc2RGBAUnorm, BC2_UNORM_BLOCK)
_c(Bc3RGBAUnorm, BC3_UNORM_BLOCK)
_c(EacR11Unorm, EAC_R11_UNORM_BLOCK)
_c(EacR11Snorm, EAC_R11_SNORM_BLOCK)
_c(EacRG11Unorm, EAC_R11G11_UNORM_BLOCK)
_c(EacRG11Snorm, EAC_R11G11_SNORM_BLOCK)
_c(Etc2RGB8Unorm, ETC2_R8G8B8_UNORM_BLOCK)
_c(Etc2RGB8Srgb, ETC2_R8G8B8_SRGB_BLOCK)
_c(Etc2RGB8A1Unorm, ETC2_R8G8B8A1_UNORM_BLOCK)
_c(Etc2RGB8A1Srgb, ETC2_R8G8B8A1_SRGB_BLOCK)
_c(Etc2RGBA8Unorm, ETC2_R8G8B8A8_UNORM_BLOCK)
_c(Etc2RGBA8Srgb, ETC2_R8G8B8A8_SRGB_BLOCK)
#endif

Loading…
Cancel
Save