Browse Source

Make MeshPrimitive and MeshIndexType enums only 8bit.

Otherwise they take up too much space.
pull/371/head
Vladimír Vondruš 7 years ago
parent
commit
d46061b285
  1. 8
      src/Magnum/GL/Test/MeshTest.cpp
  2. 4
      src/Magnum/Magnum.h
  3. 4
      src/Magnum/Mesh.h
  4. 12
      src/Magnum/Test/MeshTest.cpp
  5. 16
      src/Magnum/Vk/Test/EnumsTest.cpp

8
src/Magnum/GL/Test/MeshTest.cpp

@ -182,10 +182,10 @@ void MeshTest::mapPrimitiveInvalid() {
Error redirectError{&out}; Error redirectError{&out};
meshPrimitive(Magnum::MeshPrimitive{}); meshPrimitive(Magnum::MeshPrimitive{});
meshPrimitive(Magnum::MeshPrimitive(0x123)); meshPrimitive(Magnum::MeshPrimitive(0x12));
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out.str(),
"GL::meshPrimitive(): invalid primitive MeshPrimitive(0x0)\n" "GL::meshPrimitive(): invalid primitive MeshPrimitive(0x0)\n"
"GL::meshPrimitive(): invalid primitive MeshPrimitive(0x123)\n"); "GL::meshPrimitive(): invalid primitive MeshPrimitive(0x12)\n");
} }
void MeshTest::mapIndexType() { void MeshTest::mapIndexType() {
@ -221,10 +221,10 @@ void MeshTest::mapIndexTypeInvalid() {
Error redirectError{&out}; Error redirectError{&out};
meshIndexType(Magnum::MeshIndexType(0x0)); meshIndexType(Magnum::MeshIndexType(0x0));
meshIndexType(Magnum::MeshIndexType(0x123)); meshIndexType(Magnum::MeshIndexType(0x12));
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out.str(),
"GL::meshIndexType(): invalid type MeshIndexType(0x0)\n" "GL::meshIndexType(): invalid type MeshIndexType(0x0)\n"
"GL::meshIndexType(): invalid type MeshIndexType(0x123)\n"); "GL::meshIndexType(): invalid type MeshIndexType(0x12)\n");
} }
void MeshTest::debugPrimitive() { void MeshTest::debugPrimitive() {

4
src/Magnum/Magnum.h

@ -860,8 +860,8 @@ typedef BasicMutableCompressedImageView<1> MutableCompressedImageView1D;
typedef BasicMutableCompressedImageView<2> MutableCompressedImageView2D; typedef BasicMutableCompressedImageView<2> MutableCompressedImageView2D;
typedef BasicMutableCompressedImageView<3> MutableCompressedImageView3D; typedef BasicMutableCompressedImageView<3> MutableCompressedImageView3D;
enum class MeshPrimitive: UnsignedInt; enum class MeshPrimitive: UnsignedByte;
enum class MeshIndexType: UnsignedInt; enum class MeshIndexType: UnsignedByte;
enum class VertexFormat: UnsignedInt; enum class VertexFormat: UnsignedInt;
enum class PixelFormat: UnsignedInt; enum class PixelFormat: UnsignedInt;

4
src/Magnum/Mesh.h

@ -52,7 +52,7 @@ For D3D, corresponds to @m_class{m-doc-external} [D3D_PRIMITIVE_TOPOLOGY](https:
for Metal, corresponds to @m_class{m-doc-external} [MTLPrimitiveType](https://developer.apple.com/documentation/metal/mtlprimitivetype?language=objc). for Metal, corresponds to @m_class{m-doc-external} [MTLPrimitiveType](https://developer.apple.com/documentation/metal/mtlprimitivetype?language=objc).
See documentation of each value for more information about the mapping. See documentation of each value for more information about the mapping.
*/ */
enum class MeshPrimitive: UnsignedInt { enum class MeshPrimitive: UnsignedByte {
/* Zero reserved for an invalid type (but not being a named value) */ /* Zero reserved for an invalid type (but not being a named value) */
/** /**
@ -148,7 +148,7 @@ for more information about the mapping. Note that not every type is available
there, use @ref Vk::hasVkIndexType() to check for its presence. there, use @ref Vk::hasVkIndexType() to check for its presence.
@see @ref meshIndexTypeSize() @see @ref meshIndexTypeSize()
*/ */
enum class MeshIndexType: UnsignedInt { enum class MeshIndexType: UnsignedByte {
/* Zero reserved for an invalid type (but not being a named value) */ /* Zero reserved for an invalid type (but not being a named value) */
/** /**

12
src/Magnum/Test/MeshTest.cpp

@ -150,23 +150,23 @@ void MeshTest::indexTypeSizeInvalid() {
Error redirectError{&out}; Error redirectError{&out};
meshIndexTypeSize(MeshIndexType{}); meshIndexTypeSize(MeshIndexType{});
meshIndexTypeSize(MeshIndexType(0xdead)); meshIndexTypeSize(MeshIndexType(0xfe));
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out.str(),
"meshIndexTypeSize(): invalid type MeshIndexType(0x0)\n" "meshIndexTypeSize(): invalid type MeshIndexType(0x0)\n"
"meshIndexTypeSize(): invalid type MeshIndexType(0xdead)\n"); "meshIndexTypeSize(): invalid type MeshIndexType(0xfe)\n");
} }
void MeshTest::debugPrimitive() { void MeshTest::debugPrimitive() {
std::ostringstream o; std::ostringstream o;
Debug(&o) << MeshPrimitive::TriangleFan << MeshPrimitive(0xdead); Debug(&o) << MeshPrimitive::TriangleFan << MeshPrimitive(0xfe);
CORRADE_COMPARE(o.str(), "MeshPrimitive::TriangleFan MeshPrimitive(0xdead)\n"); CORRADE_COMPARE(o.str(), "MeshPrimitive::TriangleFan MeshPrimitive(0xfe)\n");
} }
void MeshTest::debugIndexType() { void MeshTest::debugIndexType() {
std::ostringstream o; std::ostringstream o;
Debug(&o) << MeshIndexType::UnsignedShort << MeshIndexType(0xdead); Debug(&o) << MeshIndexType::UnsignedShort << MeshIndexType(0xfe);
CORRADE_COMPARE(o.str(), "MeshIndexType::UnsignedShort MeshIndexType(0xdead)\n"); CORRADE_COMPARE(o.str(), "MeshIndexType::UnsignedShort MeshIndexType(0xfe)\n");
} }
void MeshTest::configurationPrimitive() { void MeshTest::configurationPrimitive() {

16
src/Magnum/Vk/Test/EnumsTest.cpp

@ -158,14 +158,14 @@ void EnumsTest::mapVkPrimitiveTopologyInvalid() {
Error redirectError{&out}; Error redirectError{&out};
hasVkPrimitiveTopology(Magnum::MeshPrimitive{}); hasVkPrimitiveTopology(Magnum::MeshPrimitive{});
hasVkPrimitiveTopology(Magnum::MeshPrimitive(0x123)); hasVkPrimitiveTopology(Magnum::MeshPrimitive(0x12));
vkPrimitiveTopology(Magnum::MeshPrimitive{}); vkPrimitiveTopology(Magnum::MeshPrimitive{});
vkPrimitiveTopology(Magnum::MeshPrimitive(0x123)); vkPrimitiveTopology(Magnum::MeshPrimitive(0x12));
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out.str(),
"Vk::hasVkPrimitiveTopology(): invalid primitive MeshPrimitive(0x0)\n" "Vk::hasVkPrimitiveTopology(): invalid primitive MeshPrimitive(0x0)\n"
"Vk::hasVkPrimitiveTopology(): invalid primitive MeshPrimitive(0x123)\n" "Vk::hasVkPrimitiveTopology(): invalid primitive MeshPrimitive(0x12)\n"
"Vk::vkPrimitiveTopology(): invalid primitive MeshPrimitive(0x0)\n" "Vk::vkPrimitiveTopology(): invalid primitive MeshPrimitive(0x0)\n"
"Vk::vkPrimitiveTopology(): invalid primitive MeshPrimitive(0x123)\n"); "Vk::vkPrimitiveTopology(): invalid primitive MeshPrimitive(0x12)\n");
} }
void EnumsTest::mapVkIndexType() { void EnumsTest::mapVkIndexType() {
@ -218,14 +218,14 @@ void EnumsTest::mapVkIndexTypeInvalid() {
Error redirectError{&out}; Error redirectError{&out};
hasVkIndexType(Magnum::MeshIndexType(0x0)); hasVkIndexType(Magnum::MeshIndexType(0x0));
hasVkIndexType(Magnum::MeshIndexType(0x123)); hasVkIndexType(Magnum::MeshIndexType(0x12));
vkIndexType(Magnum::MeshIndexType(0x0)); vkIndexType(Magnum::MeshIndexType(0x0));
vkIndexType(Magnum::MeshIndexType(0x123)); vkIndexType(Magnum::MeshIndexType(0x12));
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out.str(),
"Vk::hasVkIndexType(): invalid type MeshIndexType(0x0)\n" "Vk::hasVkIndexType(): invalid type MeshIndexType(0x0)\n"
"Vk::hasVkIndexType(): invalid type MeshIndexType(0x123)\n" "Vk::hasVkIndexType(): invalid type MeshIndexType(0x12)\n"
"Vk::vkIndexType(): invalid type MeshIndexType(0x0)\n" "Vk::vkIndexType(): invalid type MeshIndexType(0x0)\n"
"Vk::vkIndexType(): invalid type MeshIndexType(0x123)\n"); "Vk::vkIndexType(): invalid type MeshIndexType(0x12)\n");
} }
void EnumsTest::mapVkFormatPixelFormat() { void EnumsTest::mapVkFormatPixelFormat() {

Loading…
Cancel
Save