Browse Source

GL: add compressedPixelFormatBlock*Size() utils.

Those will be needed by the new CompressedImage* constructors that query
and save the format-specific block properties.
pull/651/merge
Vladimír Vondruš 1 year ago
parent
commit
cc77fec9fa
  1. 4
      doc/changelog.dox
  2. 255
      src/Magnum/GL/PixelFormat.cpp
  3. 32
      src/Magnum/GL/PixelFormat.h
  4. 67
      src/Magnum/GL/Test/PixelFormatTest.cpp
  5. 12
      src/Magnum/PixelFormat.h

4
doc/changelog.dox

@ -219,6 +219,10 @@ See also:
@ref GL::Renderer::setDepthRange() if the extension is available. See also
[mosra/magnum#543](https://github.com/mosra/magnum/issues/543) and
[mosra/magnum#558](https://github.com/mosra/magnum/issues/558).
- Added @ref GL::compressedPixelFormatBlockSize() and
@ref GL::compressedPixelFormatBlockDataSize() utilities as OpenGL-specific
counterparts to the generic @ref compressedPixelFormatBlockSize() /
@ref compressedPixelFormatBlockDataSize() queries
- A new @cpp "nv-egl-crashy-query-device-attrib" @ce workaround for a crash
happening during EGL initialization in recent NVidia drivers. See
@ref opengl-workarounds and [mosra/magnum#491](https://github.com/mosra/magnum/pull/491)

255
src/Magnum/GL/PixelFormat.cpp

@ -32,6 +32,7 @@
#include <Corrade/Utility/Debug.h>
#include "Magnum/PixelFormat.h"
#include "Magnum/Math/Vector3.h"
#include "Magnum/GL/TextureFormat.h"
namespace Magnum { namespace GL {
@ -521,6 +522,260 @@ CompressedPixelFormat compressedPixelFormat(const Magnum::CompressedPixelFormat
return out;
}
Vector3i compressedPixelFormatBlockSize(const CompressedPixelFormat format) {
switch(format) {
#if !defined(MAGNUM_TARGET_GLES2) || defined(MAGNUM_TARGET_WEBGL)
case CompressedPixelFormat::RedRgtc1:
case CompressedPixelFormat::RGRgtc2:
case CompressedPixelFormat::SignedRedRgtc1:
case CompressedPixelFormat::SignedRGRgtc2:
case CompressedPixelFormat::RGBBptcUnsignedFloat:
case CompressedPixelFormat::RGBBptcSignedFloat:
case CompressedPixelFormat::RGBABptcUnorm:
case CompressedPixelFormat::SRGBAlphaBptcUnorm:
#endif
case CompressedPixelFormat::RGB8Etc2:
case CompressedPixelFormat::SRGB8Etc2:
case CompressedPixelFormat::RGB8PunchthroughAlpha1Etc2:
case CompressedPixelFormat::SRGB8PunchthroughAlpha1Etc2:
case CompressedPixelFormat::RGBA8Etc2Eac:
case CompressedPixelFormat::SRGB8Alpha8Etc2Eac:
case CompressedPixelFormat::R11Eac:
case CompressedPixelFormat::SignedR11Eac:
case CompressedPixelFormat::RG11Eac:
case CompressedPixelFormat::SignedRG11Eac:
case CompressedPixelFormat::RGBS3tcDxt1:
case CompressedPixelFormat::SRGBS3tcDxt1:
case CompressedPixelFormat::RGBAS3tcDxt1:
case CompressedPixelFormat::SRGBAlphaS3tcDxt1:
case CompressedPixelFormat::RGBAS3tcDxt3:
case CompressedPixelFormat::SRGBAlphaS3tcDxt3:
case CompressedPixelFormat::RGBAS3tcDxt5:
case CompressedPixelFormat::SRGBAlphaS3tcDxt5:
#ifdef MAGNUM_TARGET_GLES
case CompressedPixelFormat::RGBPvrtc4bppV1:
#ifndef MAGNUM_TARGET_WEBGL
case CompressedPixelFormat::SRGBPvrtc4bppV1:
#endif
case CompressedPixelFormat::RGBAPvrtc4bppV1:
#ifndef MAGNUM_TARGET_WEBGL
case CompressedPixelFormat::SRGBAlphaPvrtc4bppV1:
#endif
#endif
case CompressedPixelFormat::RGBAAstc4x4:
case CompressedPixelFormat::SRGB8Alpha8Astc4x4:
return {4, 4, 1};
case CompressedPixelFormat::RGBAAstc5x4:
case CompressedPixelFormat::SRGB8Alpha8Astc5x4:
return {5, 4, 1};
case CompressedPixelFormat::RGBAAstc5x5:
case CompressedPixelFormat::SRGB8Alpha8Astc5x5:
return {5, 5, 1};
case CompressedPixelFormat::RGBAAstc6x5:
case CompressedPixelFormat::SRGB8Alpha8Astc6x5:
return {6, 5, 1};
case CompressedPixelFormat::RGBAAstc6x6:
case CompressedPixelFormat::SRGB8Alpha8Astc6x6:
return {6, 6, 1};
case CompressedPixelFormat::RGBAAstc8x5:
case CompressedPixelFormat::SRGB8Alpha8Astc8x5:
return {8, 5, 1};
case CompressedPixelFormat::RGBAAstc8x6:
case CompressedPixelFormat::SRGB8Alpha8Astc8x6:
return {8, 6, 1};
case CompressedPixelFormat::RGBAAstc8x8:
case CompressedPixelFormat::SRGB8Alpha8Astc8x8:
return {8, 8, 1};
case CompressedPixelFormat::RGBAAstc10x5:
case CompressedPixelFormat::SRGB8Alpha8Astc10x5:
return {10, 5, 1};
case CompressedPixelFormat::RGBAAstc10x6:
case CompressedPixelFormat::SRGB8Alpha8Astc10x6:
return {10, 6, 1};
case CompressedPixelFormat::RGBAAstc10x8:
case CompressedPixelFormat::SRGB8Alpha8Astc10x8:
return {10, 8, 1};
case CompressedPixelFormat::RGBAAstc10x10:
case CompressedPixelFormat::SRGB8Alpha8Astc10x10:
return {10, 10, 1};
case CompressedPixelFormat::RGBAAstc12x10:
case CompressedPixelFormat::SRGB8Alpha8Astc12x10:
return {12, 10, 1};
case CompressedPixelFormat::RGBAAstc12x12:
case CompressedPixelFormat::SRGB8Alpha8Astc12x12:
return {12, 12, 1};
#ifdef MAGNUM_TARGET_GLES
case CompressedPixelFormat::RGBPvrtc2bppV1:
#ifndef MAGNUM_TARGET_WEBGL
case CompressedPixelFormat::SRGBPvrtc2bppV1:
#endif
case CompressedPixelFormat::RGBAPvrtc2bppV1:
#ifndef MAGNUM_TARGET_WEBGL
case CompressedPixelFormat::SRGBAlphaPvrtc2bppV1:
#endif
return {8, 4, 1};
#endif
#if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
case CompressedPixelFormat::RGBAAstc3x3x3:
case CompressedPixelFormat::SRGB8Alpha8Astc3x3x3:
return {3, 3, 3};
case CompressedPixelFormat::RGBAAstc4x3x3:
case CompressedPixelFormat::SRGB8Alpha8Astc4x3x3:
return {4, 3, 3};
case CompressedPixelFormat::RGBAAstc4x4x3:
case CompressedPixelFormat::SRGB8Alpha8Astc4x4x3:
return {4, 4, 3};
case CompressedPixelFormat::RGBAAstc4x4x4:
case CompressedPixelFormat::SRGB8Alpha8Astc4x4x4:
return {4, 4, 4};
case CompressedPixelFormat::RGBAAstc5x4x4:
case CompressedPixelFormat::SRGB8Alpha8Astc5x4x4:
return {5, 4, 4};
case CompressedPixelFormat::RGBAAstc5x5x4:
case CompressedPixelFormat::SRGB8Alpha8Astc5x5x4:
return {5, 5, 4};
case CompressedPixelFormat::RGBAAstc5x5x5:
case CompressedPixelFormat::SRGB8Alpha8Astc5x5x5:
return {5, 5, 5};
case CompressedPixelFormat::RGBAAstc6x5x5:
case CompressedPixelFormat::SRGB8Alpha8Astc6x5x5:
return {6, 5, 5};
case CompressedPixelFormat::RGBAAstc6x6x5:
case CompressedPixelFormat::SRGB8Alpha8Astc6x6x5:
return {6, 6, 5};
case CompressedPixelFormat::RGBAAstc6x6x6:
case CompressedPixelFormat::SRGB8Alpha8Astc6x6x6:
return {6, 6, 6};
#endif
#ifndef MAGNUM_TARGET_GLES
case CompressedPixelFormat::Red:
case CompressedPixelFormat::RG:
case CompressedPixelFormat::RGB:
case CompressedPixelFormat::RGBA:
CORRADE_ASSERT_UNREACHABLE("GL::compressedPixelFormatBlockSize(): cannot determine block size of generic" << format, {});
#endif
}
CORRADE_ASSERT_UNREACHABLE("GL::compressedPixelFormatBlockSize(): unknown format" << format, {});
}
UnsignedInt compressedPixelFormatBlockDataSize(const CompressedPixelFormat format) {
switch(format) {
/* Values from Magnum/Implementation/compressedPixelFormatMapping.hpp,
names matched w/ GL/Implementation/compressedPixelFormatMapping.hpp.
Using the bit sizes to avoid accidental errors. */
#if !defined(MAGNUM_TARGET_GLES2) || defined(MAGNUM_TARGET_WEBGL)
case CompressedPixelFormat::RedRgtc1:
case CompressedPixelFormat::SignedRedRgtc1:
#endif
case CompressedPixelFormat::RGB8Etc2:
case CompressedPixelFormat::SRGB8Etc2:
case CompressedPixelFormat::R11Eac:
case CompressedPixelFormat::SignedR11Eac:
case CompressedPixelFormat::RGB8PunchthroughAlpha1Etc2:
case CompressedPixelFormat::SRGB8PunchthroughAlpha1Etc2:
case CompressedPixelFormat::RGBS3tcDxt1:
case CompressedPixelFormat::SRGBS3tcDxt1:
case CompressedPixelFormat::RGBAS3tcDxt1:
case CompressedPixelFormat::SRGBAlphaS3tcDxt1:
#ifdef MAGNUM_TARGET_GLES
case CompressedPixelFormat::RGBPvrtc2bppV1:
#ifndef MAGNUM_TARGET_WEBGL
case CompressedPixelFormat::SRGBPvrtc2bppV1:
#endif
case CompressedPixelFormat::RGBAPvrtc2bppV1:
#ifndef MAGNUM_TARGET_WEBGL
case CompressedPixelFormat::SRGBAlphaPvrtc2bppV1:
#endif
case CompressedPixelFormat::RGBPvrtc4bppV1:
#ifndef MAGNUM_TARGET_WEBGL
case CompressedPixelFormat::SRGBPvrtc4bppV1:
#endif
case CompressedPixelFormat::RGBAPvrtc4bppV1:
#ifndef MAGNUM_TARGET_WEBGL
case CompressedPixelFormat::SRGBAlphaPvrtc4bppV1:
#endif
#endif
return 64/8;
#if !defined(MAGNUM_TARGET_GLES2) || defined(MAGNUM_TARGET_WEBGL)
case CompressedPixelFormat::RGRgtc2:
case CompressedPixelFormat::SignedRGRgtc2:
case CompressedPixelFormat::RGBBptcUnsignedFloat:
case CompressedPixelFormat::RGBBptcSignedFloat:
case CompressedPixelFormat::RGBABptcUnorm:
case CompressedPixelFormat::SRGBAlphaBptcUnorm:
#endif
case CompressedPixelFormat::RG11Eac:
case CompressedPixelFormat::SignedRG11Eac:
case CompressedPixelFormat::RGBA8Etc2Eac:
case CompressedPixelFormat::SRGB8Alpha8Etc2Eac:
case CompressedPixelFormat::RGBAS3tcDxt3:
case CompressedPixelFormat::SRGBAlphaS3tcDxt3:
case CompressedPixelFormat::RGBAS3tcDxt5:
case CompressedPixelFormat::SRGBAlphaS3tcDxt5:
case CompressedPixelFormat::RGBAAstc4x4:
case CompressedPixelFormat::SRGB8Alpha8Astc4x4:
case CompressedPixelFormat::RGBAAstc5x4:
case CompressedPixelFormat::SRGB8Alpha8Astc5x4:
case CompressedPixelFormat::RGBAAstc5x5:
case CompressedPixelFormat::SRGB8Alpha8Astc5x5:
case CompressedPixelFormat::RGBAAstc6x5:
case CompressedPixelFormat::SRGB8Alpha8Astc6x5:
case CompressedPixelFormat::RGBAAstc6x6:
case CompressedPixelFormat::SRGB8Alpha8Astc6x6:
case CompressedPixelFormat::RGBAAstc8x5:
case CompressedPixelFormat::SRGB8Alpha8Astc8x5:
case CompressedPixelFormat::RGBAAstc8x6:
case CompressedPixelFormat::SRGB8Alpha8Astc8x6:
case CompressedPixelFormat::RGBAAstc8x8:
case CompressedPixelFormat::SRGB8Alpha8Astc8x8:
case CompressedPixelFormat::RGBAAstc10x5:
case CompressedPixelFormat::SRGB8Alpha8Astc10x5:
case CompressedPixelFormat::RGBAAstc10x6:
case CompressedPixelFormat::SRGB8Alpha8Astc10x6:
case CompressedPixelFormat::RGBAAstc10x8:
case CompressedPixelFormat::SRGB8Alpha8Astc10x8:
case CompressedPixelFormat::RGBAAstc10x10:
case CompressedPixelFormat::SRGB8Alpha8Astc10x10:
case CompressedPixelFormat::RGBAAstc12x10:
case CompressedPixelFormat::SRGB8Alpha8Astc12x10:
case CompressedPixelFormat::RGBAAstc12x12:
case CompressedPixelFormat::SRGB8Alpha8Astc12x12:
#if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
case CompressedPixelFormat::RGBAAstc3x3x3:
case CompressedPixelFormat::SRGB8Alpha8Astc3x3x3:
case CompressedPixelFormat::RGBAAstc4x3x3:
case CompressedPixelFormat::SRGB8Alpha8Astc4x3x3:
case CompressedPixelFormat::RGBAAstc4x4x3:
case CompressedPixelFormat::SRGB8Alpha8Astc4x4x3:
case CompressedPixelFormat::RGBAAstc4x4x4:
case CompressedPixelFormat::SRGB8Alpha8Astc4x4x4:
case CompressedPixelFormat::RGBAAstc5x4x4:
case CompressedPixelFormat::SRGB8Alpha8Astc5x4x4:
case CompressedPixelFormat::RGBAAstc5x5x4:
case CompressedPixelFormat::SRGB8Alpha8Astc5x5x4:
case CompressedPixelFormat::RGBAAstc5x5x5:
case CompressedPixelFormat::SRGB8Alpha8Astc5x5x5:
case CompressedPixelFormat::RGBAAstc6x5x5:
case CompressedPixelFormat::SRGB8Alpha8Astc6x5x5:
case CompressedPixelFormat::RGBAAstc6x6x5:
case CompressedPixelFormat::SRGB8Alpha8Astc6x6x5:
case CompressedPixelFormat::RGBAAstc6x6x6:
case CompressedPixelFormat::SRGB8Alpha8Astc6x6x6:
#endif
return 128/8;
#ifndef MAGNUM_TARGET_GLES
case CompressedPixelFormat::Red:
case CompressedPixelFormat::RG:
case CompressedPixelFormat::RGB:
case CompressedPixelFormat::RGBA:
CORRADE_ASSERT_UNREACHABLE("GL::compressedPixelFormatBlockDataSize(): cannot determine block size of generic" << format, {});
#endif
}
CORRADE_ASSERT_UNREACHABLE("GL::compressedPixelFormatBlockDataSize(): unknown format" << format, {});
}
TextureFormat textureFormat(const Magnum::CompressedPixelFormat format) {
if(isCompressedPixelFormatImplementationSpecific(format))
return compressedPixelFormatUnwrap<GL::TextureFormat>(format);

32
src/Magnum/GL/PixelFormat.h

@ -702,7 +702,9 @@ MAGNUM_GL_EXPORT PixelType pixelType(Magnum::PixelFormat format, UnsignedInt ext
/**
@brief Size of a pixel for given format/type combination in bytes
@see @ref Magnum::pixelFormatSize(), @ref PixelStorage::dataProperties()
@see @ref Magnum::pixelFormatSize(), @ref compressedPixelFormatBlockSize(),
@ref compressedPixelFormatBlockDataSize(),
@ref PixelStorage::dataProperties()
*/
MAGNUM_GL_EXPORT UnsignedInt pixelFormatSize(PixelFormat format, PixelType type);
@ -2157,6 +2159,34 @@ The mapping operation is done with an @f$ \mathcal{O}(1) @f$ complexity.
*/
MAGNUM_GL_EXPORT CompressedPixelFormat compressedPixelFormat(Magnum::CompressedPixelFormat format);
/**
@brief Block size of given compressed pixel format, in pixels
@m_since_latest
Expects that @p format is not one of the generic
@ref CompressedPixelFormat::Red, @relativeref{CompressedPixelFormat,RG},
@relativeref{CompressedPixelFormat,RGB} or
@relativeref{CompressedPixelFormat,RGBA} formats for which properties are
unspecified. For 2D formats the Z dimension is always 1.
@see @ref compressedPixelFormatBlockDataSize(),
@ref Magnum::compressedPixelFormatBlockSize(), @ref pixelFormatSize()
*/
MAGNUM_GL_EXPORT Vector3i compressedPixelFormatBlockSize(CompressedPixelFormat format);
/**
@brief Block size of given compressed pixel format, in bytes
@m_since_latest
Expects that @p format is not one of the generic
@ref CompressedPixelFormat::Red, @relativeref{CompressedPixelFormat,RG},
@relativeref{CompressedPixelFormat,RGB} or
@relativeref{CompressedPixelFormat,RGBA} formats for which properties are
unspecified.
@see @ref compressedPixelFormatBlockSize(),
@ref Magnum::compressedPixelFormatBlockDataSize(), @ref pixelFormatSize()
*/
MAGNUM_GL_EXPORT UnsignedInt compressedPixelFormatBlockDataSize(CompressedPixelFormat format);
/**
@brief Convert OpenGL compressed pixel format to a generic compressed pixel format
@m_since_latest

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

@ -30,6 +30,7 @@
#include <Corrade/TestSuite/Compare/String.h>
#include "Magnum/PixelFormat.h"
#include "Magnum/Math/Vector3.h"
#include "Magnum/GL/PixelFormat.h"
#include "Magnum/GL/TextureFormat.h"
@ -66,6 +67,12 @@ struct PixelFormatTest: TestSuite::Tester {
void mapCompressedTextureFormatInvalid();
void mapGenericCompressedFormatUnsupported();
void sizeCompressed();
#ifndef MAGNUM_TARGET_GLES
void sizeCompressedGeneric();
#endif
void sizeCompressedInvalid();
void debugPixelFormat();
void debugPixelType();
void debugCompressedPixelFormat();
@ -98,6 +105,12 @@ PixelFormatTest::PixelFormatTest() {
&PixelFormatTest::mapCompressedTextureFormatInvalid,
&PixelFormatTest::mapGenericCompressedFormatUnsupported,
&PixelFormatTest::sizeCompressed,
#ifndef MAGNUM_TARGET_GLES
&PixelFormatTest::sizeCompressedGeneric,
#endif
&PixelFormatTest::sizeCompressedInvalid,
&PixelFormatTest::debugPixelFormat,
&PixelFormatTest::debugPixelType,
&PixelFormatTest::debugCompressedPixelFormat,
@ -486,8 +499,14 @@ void PixelFormatTest::mapCompressedFormatTextureFormat() {
- that the entries are ordered by number by comparing a function to
expected result (so insertion here is done in proper place)
- that there was no gap (unhandled value inside the range)
- that a particular pixel format maps to a particular GL format
- that a particular pixel type maps to a particular GL type */
- that a particular pixel format maps to a particular GL format and
back
- that a particular pixel format maps to a particular GL type and
back
- that a particular pixel format maps to a particular GL texture
format and back
- that the pixel format block size matches block size of the generic
format */
#ifdef CORRADE_TARGET_GCC
#pragma GCC diagnostic push
#pragma GCC diagnostic error "-Wswitch"
@ -503,6 +522,8 @@ void PixelFormatTest::mapCompressedFormatTextureFormat() {
CORRADE_COMPARE(compressedPixelFormat(Magnum::CompressedPixelFormat::format), Magnum::GL::CompressedPixelFormat::expectedFormat); \
CORRADE_COMPARE(textureFormat(Magnum::CompressedPixelFormat::format), Magnum::GL::TextureFormat::Compressed ## expectedFormat); \
CORRADE_COMPARE(genericCompressedPixelFormat(Magnum::GL::TextureFormat::Compressed ## expectedFormat), Magnum::CompressedPixelFormat::format); \
CORRADE_COMPARE(compressedPixelFormatBlockSize(Magnum::GL::CompressedPixelFormat::expectedFormat), compressedPixelFormatBlockSize(Magnum::CompressedPixelFormat::format)); \
CORRADE_COMPARE(compressedPixelFormatBlockDataSize(Magnum::GL::CompressedPixelFormat::expectedFormat), compressedPixelFormatBlockDataSize(Magnum::CompressedPixelFormat::format)); \
++nextHandled; \
continue;
/* For duplicate mappings compared to _c() it only checks the
@ -516,6 +537,8 @@ void PixelFormatTest::mapCompressedFormatTextureFormat() {
CORRADE_VERIFY(hasTextureFormat(Magnum::CompressedPixelFormat::format)); \
CORRADE_COMPARE(compressedPixelFormat(Magnum::CompressedPixelFormat::format), Magnum::GL::CompressedPixelFormat::expectedFormat); \
CORRADE_COMPARE(textureFormat(Magnum::CompressedPixelFormat::format), Magnum::GL::TextureFormat::Compressed ## expectedFormat); \
CORRADE_COMPARE(compressedPixelFormatBlockSize(Magnum::GL::CompressedPixelFormat::expectedFormat), compressedPixelFormatBlockSize(Magnum::CompressedPixelFormat::format)); \
CORRADE_COMPARE(compressedPixelFormatBlockDataSize(Magnum::GL::CompressedPixelFormat::expectedFormat), compressedPixelFormatBlockDataSize(Magnum::CompressedPixelFormat::format)); \
++nextHandled; \
continue;
#define _s(format) \
@ -653,6 +676,46 @@ void PixelFormatTest::mapGenericCompressedFormatUnsupported() {
CORRADE_COMPARE(genericCompressedPixelFormat(TextureFormat::RGB), Containers::NullOpt);
}
void PixelFormatTest::sizeCompressed() {
/* Just basic sanity verification. Formats that have a matching generic
format are checked against the generic compressedPixelFormatBlock*Size()
in mapCompressedFormatTextureFormat() above. */
CORRADE_COMPARE(compressedPixelFormatBlockSize(CompressedPixelFormat::SRGBAlphaS3tcDxt1), (Vector3i{4, 4, 1}));
CORRADE_COMPARE(compressedPixelFormatBlockDataSize(CompressedPixelFormat::SRGBAlphaS3tcDxt1), 8);
CORRADE_COMPARE(compressedPixelFormatBlockSize(CompressedPixelFormat::SRGB8Alpha8Astc10x5), (Vector3i{10, 5, 1}));
CORRADE_COMPARE(compressedPixelFormatBlockDataSize(CompressedPixelFormat::SRGB8Alpha8Astc10x5), 16);
}
#ifndef MAGNUM_TARGET_GLES
void PixelFormatTest::sizeCompressedGeneric() {
CORRADE_SKIP_IF_NO_ASSERT();
Containers::String out;
Error redirectError{&out};
compressedPixelFormatBlockSize(CompressedPixelFormat::RG);
compressedPixelFormatBlockDataSize(CompressedPixelFormat::RG);
CORRADE_COMPARE_AS(out,
"GL::compressedPixelFormatBlockSize(): cannot determine block size of generic GL::CompressedPixelFormat::RG\n"
"GL::compressedPixelFormatBlockDataSize(): cannot determine block size of generic GL::CompressedPixelFormat::RG\n",
TestSuite::Compare::String);
}
#endif
void PixelFormatTest::sizeCompressedInvalid() {
CORRADE_SKIP_IF_NO_ASSERT();
Containers::String out;
Error redirectError{&out};
compressedPixelFormatBlockSize(CompressedPixelFormat(0xdeadbeef));
compressedPixelFormatBlockDataSize(CompressedPixelFormat(0xdeadbeef));
CORRADE_COMPARE_AS(out,
"GL::compressedPixelFormatBlockSize(): unknown format GL::CompressedPixelFormat(0xdeadbeef)\n"
"GL::compressedPixelFormatBlockDataSize(): unknown format GL::CompressedPixelFormat(0xdeadbeef)\n",
TestSuite::Compare::String);
}
void PixelFormatTest::debugPixelFormat() {
Containers::String out;

12
src/Magnum/PixelFormat.h

@ -793,7 +793,8 @@ enum class PixelFormat: UnsignedInt {
Expects that the pixel format is *not* implementation-specific.
@see @ref isPixelFormatImplementationSpecific(), @ref GL::pixelFormatSize(),
@ref vertexFormatSize()
@ref compressedPixelFormatBlockSize(),
@ref compressedPixelFormatBlockDataSize(), @ref vertexFormatSize()
*/
MAGNUM_EXPORT UnsignedInt pixelFormatSize(PixelFormat format);
@ -2538,12 +2539,13 @@ enum class CompressedPixelFormat: UnsignedInt {
};
/**
@brief Block size of given compressed pixel format
@brief Block size of given compressed pixel format, in pixels
@m_since_latest
For 2D formats the Z dimension is always 1. Expects that the pixel format is
* *not* implementation-specific.
@see @ref compressedPixelFormatBlockDataSize(),
@ref GL::compressedPixelFormatBlockSize(), @ref pixelFormatSize(),
@ref isCompressedPixelFormatImplementationSpecific()
*/
MAGNUM_EXPORT Vector3i compressedPixelFormatBlockSize(CompressedPixelFormat format);
@ -2558,12 +2560,12 @@ MAGNUM_EXPORT CORRADE_DEPRECATED("use compressedPixelFormatBlockSize() instead")
#endif
/**
@brief Block data size of given compressed pixel format
@brief Block size of given compressed pixel format, in bytes
@m_since_latest
Byte size of each compressed block. Expects that the pixel format is *not*
implementation-specific.
Expects that the pixel format is *not* implementation-specific.
@see @ref compressedPixelFormatBlockSize(),
@ref GL::compressedPixelFormatBlockDataSize(), @ref pixelFormatSize(),
@ref isCompressedPixelFormatImplementationSpecific()
*/
MAGNUM_EXPORT UnsignedInt compressedPixelFormatBlockDataSize(CompressedPixelFormat format);

Loading…
Cancel
Save