mirror of https://github.com/mosra/magnum.git
Browse Source
Similar to PixelFormat, to filter out values that make no sense as a vertex format (such as sRGB) and add others (such as doubles). And documenting which are guaranteed to be supported and which not. The hasVkFormat(Magnum::VertexFormat) and vkFormat(Magnum::VertexFormat) were also deprecated in favor of the new hasVertexFormat() / vertexFormat() APIs.pull/494/head
12 changed files with 872 additions and 354 deletions
@ -0,0 +1,172 @@
|
||||
/*
|
||||
This file is part of Magnum. |
||||
|
||||
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, |
||||
2020 Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a |
||||
copy of this software and associated documentation files (the "Software"), |
||||
to deal in the Software without restriction, including without limitation |
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense, |
||||
and/or sell copies of the Software, and to permit persons to whom the |
||||
Software is furnished to do so, subject to the following conditions: |
||||
|
||||
The above copyright notice and this permission notice shall be included |
||||
in all copies or substantial portions of the Software. |
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
||||
DEALINGS IN THE SOFTWARE. |
||||
*/ |
||||
|
||||
#include <sstream> |
||||
#include <Corrade/TestSuite/Tester.h> |
||||
#include <Corrade/Utility/DebugStl.h> |
||||
|
||||
#include "Magnum/VertexFormat.h" |
||||
#include "Magnum/Vk/VertexFormat.h" |
||||
|
||||
namespace Magnum { namespace Vk { namespace Test { namespace { |
||||
|
||||
struct VertexFormatTest: TestSuite::Tester { |
||||
explicit VertexFormatTest(); |
||||
|
||||
void map(); |
||||
void mapImplementationSpecific(); |
||||
void mapUnsupported(); |
||||
void mapInvalid(); |
||||
|
||||
void debug(); |
||||
}; |
||||
|
||||
VertexFormatTest::VertexFormatTest() { |
||||
addTests({&VertexFormatTest::map, |
||||
&VertexFormatTest::mapImplementationSpecific, |
||||
&VertexFormatTest::mapUnsupported, |
||||
&VertexFormatTest::mapInvalid, |
||||
|
||||
&VertexFormatTest::debug}); |
||||
} |
||||
|
||||
void VertexFormatTest::map() { |
||||
/* Touchstone verification */ |
||||
CORRADE_VERIFY(hasVertexFormat(Magnum::VertexFormat::Vector3us)); |
||||
CORRADE_COMPARE(vertexFormat(Magnum::VertexFormat::Vector3us), VertexFormat::Vector3us); |
||||
CORRADE_COMPARE(vertexFormat(Magnum::VertexFormat::Matrix2x3bNormalizedAligned), VertexFormat::Vector3bNormalized); |
||||
|
||||
/* This goes through the first 16 bits, which should be enough. Going
|
||||
through 32 bits takes 8 seconds, too much. */ |
||||
UnsignedInt firstUnhandled = 0xffff; |
||||
UnsignedInt nextHandled = 1; /* 0 is an invalid format */ |
||||
for(UnsignedInt i = 1; i <= 0xffff; ++i) { |
||||
const auto format = Magnum::VertexFormat(i); |
||||
/* Each case verifies:
|
||||
- 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 generic format maps to a particular format |
||||
- that the debug output matches what was converted |
||||
*/ |
||||
#ifdef __GNUC__ |
||||
#pragma GCC diagnostic push |
||||
#pragma GCC diagnostic error "-Wswitch" |
||||
#endif |
||||
switch(format) { |
||||
#define _c(input, output) \ |
||||
case Magnum::VertexFormat::input: \
|
||||
CORRADE_COMPARE(nextHandled, i); \
|
||||
CORRADE_COMPARE(firstUnhandled, 0xffff); \
|
||||
CORRADE_VERIFY(hasVertexFormat(Magnum::VertexFormat::input)); \
|
||||
CORRADE_COMPARE(vertexFormat(Magnum::VertexFormat::input), VertexFormat::output); \
|
||||
{ \
|
||||
std::ostringstream out; \
|
||||
Debug{&out} << vertexFormat(Magnum::VertexFormat::input); \
|
||||
CORRADE_COMPARE(out.str(), "Vk::VertexFormat::" #output "\n"); \
|
||||
} \
|
||||
++nextHandled; \
|
||||
continue; |
||||
#define _s(format) \ |
||||
case Magnum::VertexFormat::format: { \
|
||||
CORRADE_COMPARE(nextHandled, i); \
|
||||
CORRADE_COMPARE(firstUnhandled, 0xffff); \
|
||||
CORRADE_VERIFY(!hasVertexFormat(Magnum::VertexFormat::format)); \
|
||||
std::ostringstream out; \
|
||||
{ /* Redirected otherwise graceful assert would abort */ \
|
||||
Error redirectError{&out}; \
|
||||
vertexFormat(Magnum::VertexFormat::format); \
|
||||
} \
|
||||
Debug{Debug::Flag::NoNewlineAtTheEnd} << out.str(); \
|
||||
++nextHandled; \
|
||||
continue; \
|
||||
} |
||||
#include "Magnum/Vk/Implementation/vertexFormatMapping.hpp" |
||||
#undef _s |
||||
#undef _c |
||||
} |
||||
#ifdef __GNUC__ |
||||
#pragma GCC diagnostic pop |
||||
#endif |
||||
|
||||
/* Not handled by any value, remember -- we might either be at the end
|
||||
of the enum range (which is okay) or some value might be unhandled |
||||
here */ |
||||
firstUnhandled = i; |
||||
} |
||||
|
||||
CORRADE_COMPARE(firstUnhandled, 0xffff); |
||||
} |
||||
|
||||
void VertexFormatTest::mapImplementationSpecific() { |
||||
CORRADE_VERIFY(hasVertexFormat(Magnum::vertexFormatWrap(VK_FORMAT_A8B8G8R8_SINT_PACK32))); |
||||
CORRADE_COMPARE(vertexFormat(Magnum::vertexFormatWrap(VK_FORMAT_A8B8G8R8_SINT_PACK32)), |
||||
VertexFormat(VK_FORMAT_A8B8G8R8_SINT_PACK32)); |
||||
} |
||||
|
||||
void VertexFormatTest::mapUnsupported() { |
||||
#ifdef CORRADE_NO_ASSERT |
||||
CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); |
||||
#endif |
||||
|
||||
#if 1 |
||||
CORRADE_SKIP("All vertex formats are supported."); |
||||
#else |
||||
std::ostringstream out; |
||||
Error redirectError{&out}; |
||||
|
||||
vertexFormat(Magnum::VertexFormat::Vector3d); |
||||
CORRADE_COMPARE(out.str(), "Vk::vertexFormat(): unsupported format VertexFormat::Vector3d\n"); |
||||
#endif |
||||
} |
||||
|
||||
void VertexFormatTest::mapInvalid() { |
||||
#ifdef CORRADE_NO_ASSERT |
||||
CORRADE_SKIP("CORRADE_NO_ASSERT defined, can't test assertions"); |
||||
#endif |
||||
|
||||
std::ostringstream out; |
||||
Error redirectError{&out}; |
||||
|
||||
hasVertexFormat(Magnum::VertexFormat{}); |
||||
hasVertexFormat(Magnum::VertexFormat(0x123)); |
||||
vertexFormat(Magnum::VertexFormat{}); |
||||
vertexFormat(Magnum::VertexFormat(0x123)); |
||||
CORRADE_COMPARE(out.str(), |
||||
"Vk::hasVertexFormat(): invalid format VertexFormat(0x0)\n" |
||||
"Vk::hasVertexFormat(): invalid format VertexFormat(0x123)\n" |
||||
"Vk::vertexFormat(): invalid format VertexFormat(0x0)\n" |
||||
"Vk::vertexFormat(): invalid format VertexFormat(0x123)\n"); |
||||
} |
||||
|
||||
void VertexFormatTest::debug() { |
||||
std::ostringstream out; |
||||
Debug{&out} << VertexFormat::Vector2usNormalized << VertexFormat(-10007655); |
||||
CORRADE_COMPARE(out.str(), "Vk::VertexFormat::Vector2usNormalized Vk::VertexFormat(-10007655)\n"); |
||||
} |
||||
|
||||
}}}} |
||||
|
||||
CORRADE_TEST_MAIN(Magnum::Vk::Test::VertexFormatTest) |
||||
@ -0,0 +1,137 @@
|
||||
/*
|
||||
This file is part of Magnum. |
||||
|
||||
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, |
||||
2020 Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a |
||||
copy of this software and associated documentation files (the "Software"), |
||||
to deal in the Software without restriction, including without limitation |
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense, |
||||
and/or sell copies of the Software, and to permit persons to whom the |
||||
Software is furnished to do so, subject to the following conditions: |
||||
|
||||
The above copyright notice and this permission notice shall be included |
||||
in all copies or substantial portions of the Software. |
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
||||
DEALINGS IN THE SOFTWARE. |
||||
*/ |
||||
|
||||
#include "VertexFormat.h" |
||||
|
||||
#include <Corrade/Containers/ArrayView.h> |
||||
#include <Corrade/Utility/Debug.h> |
||||
|
||||
#include "Magnum/VertexFormat.h" |
||||
|
||||
namespace Magnum { namespace Vk { |
||||
|
||||
namespace { |
||||
|
||||
#ifndef DOXYGEN_GENERATING_OUTPUT /* It gets *really* confused */ |
||||
constexpr VertexFormat VertexFormatMapping[] { |
||||
/* GCC 4.8 doesn't like just a {} for default enum values */ |
||||
#define _c(input, output) VertexFormat::output, |
||||
#define _s(input) VertexFormat{}, |
||||
#include "Magnum/Vk/Implementation/vertexFormatMapping.hpp" |
||||
#undef _s |
||||
#undef _c |
||||
}; |
||||
#endif |
||||
|
||||
} |
||||
|
||||
Debug& operator<<(Debug& debug, const VertexFormat value) { |
||||
debug << "Vk::VertexFormat" << Debug::nospace; |
||||
|
||||
switch(value) { |
||||
/* LCOV_EXCL_START */ |
||||
#define _c(value) case Vk::VertexFormat::value: return debug << "::" << Debug::nospace << #value; |
||||
_c(Float) |
||||
_c(Half) |
||||
_c(Double) |
||||
_c(UnsignedByte) |
||||
_c(UnsignedByteNormalized) |
||||
_c(Byte) |
||||
_c(ByteNormalized) |
||||
_c(UnsignedShort) |
||||
_c(UnsignedShortNormalized) |
||||
_c(Short) |
||||
_c(ShortNormalized) |
||||
_c(UnsignedInt) |
||||
_c(Int) |
||||
_c(Vector2) |
||||
_c(Vector2h) |
||||
_c(Vector2d) |
||||
_c(Vector2ub) |
||||
_c(Vector2ubNormalized) |
||||
_c(Vector2b) |
||||
_c(Vector2bNormalized) |
||||
_c(Vector2us) |
||||
_c(Vector2usNormalized) |
||||
_c(Vector2s) |
||||
_c(Vector2sNormalized) |
||||
_c(Vector2ui) |
||||
_c(Vector2i) |
||||
_c(Vector3) |
||||
_c(Vector3h) |
||||
_c(Vector3d) |
||||
_c(Vector3ub) |
||||
_c(Vector3ubNormalized) |
||||
_c(Vector3b) |
||||
_c(Vector3bNormalized) |
||||
_c(Vector3us) |
||||
_c(Vector3usNormalized) |
||||
_c(Vector3s) |
||||
_c(Vector3sNormalized) |
||||
_c(Vector3ui) |
||||
_c(Vector3i) |
||||
_c(Vector4) |
||||
_c(Vector4h) |
||||
_c(Vector4d) |
||||
_c(Vector4ub) |
||||
_c(Vector4ubNormalized) |
||||
_c(Vector4b) |
||||
_c(Vector4bNormalized) |
||||
_c(Vector4us) |
||||
_c(Vector4usNormalized) |
||||
_c(Vector4s) |
||||
_c(Vector4sNormalized) |
||||
_c(Vector4ui) |
||||
_c(Vector4i) |
||||
#undef _c |
||||
/* LCOV_EXCL_STOP */ |
||||
} |
||||
|
||||
/* Vulkan docs have the values in decimal, so not converting to hex */ |
||||
return debug << "(" << Debug::nospace << Int(value) << Debug::nospace << ")"; |
||||
} |
||||
|
||||
bool hasVertexFormat(const Magnum::VertexFormat format) { |
||||
if(isVertexFormatImplementationSpecific(format)) |
||||
return true; |
||||
|
||||
CORRADE_ASSERT(UnsignedInt(format) - 1 < Containers::arraySize(VertexFormatMapping), |
||||
"Vk::hasVertexFormat(): invalid format" << format, {}); |
||||
return UnsignedInt(VertexFormatMapping[UnsignedInt(format) - 1]); |
||||
} |
||||
|
||||
VertexFormat vertexFormat(const Magnum::VertexFormat format) { |
||||
if(isVertexFormatImplementationSpecific(format)) |
||||
return vertexFormatUnwrap<VertexFormat>(format); |
||||
|
||||
CORRADE_ASSERT(UnsignedInt(format) - 1 < Containers::arraySize(VertexFormatMapping), |
||||
"Vk::vertexFormat(): invalid format" << format, {}); |
||||
const VertexFormat out = VertexFormatMapping[UnsignedInt(format) - 1]; |
||||
CORRADE_ASSERT(UnsignedInt(out), |
||||
"Vk::vertexFormat(): unsupported format" << format, {}); |
||||
return out; |
||||
} |
||||
|
||||
}} |
||||
@ -0,0 +1,371 @@
|
||||
#ifndef Magnum_Vk_VertexFormat_h |
||||
#define Magnum_Vk_VertexFormat_h |
||||
/*
|
||||
This file is part of Magnum. |
||||
|
||||
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, |
||||
2020 Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a |
||||
copy of this software and associated documentation files (the "Software"), |
||||
to deal in the Software without restriction, including without limitation |
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense, |
||||
and/or sell copies of the Software, and to permit persons to whom the |
||||
Software is furnished to do so, subject to the following conditions: |
||||
|
||||
The above copyright notice and this permission notice shall be included |
||||
in all copies or substantial portions of the Software. |
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
||||
DEALINGS IN THE SOFTWARE. |
||||
*/ |
||||
|
||||
#include "Magnum/Magnum.h" |
||||
#include "Magnum/Vk/Vulkan.h" |
||||
#include "Magnum/Vk/visibility.h" |
||||
|
||||
/** @file
|
||||
* @brief Enum @ref Magnum::Vk::VertexFormat, function @ref Magnum::Vk::hasVertexFormat(), @ref Magnum::Vk::vertexFormat() |
||||
* @m_since_latest |
||||
*/ |
||||
|
||||
namespace Magnum { namespace Vk { |
||||
|
||||
/**
|
||||
@brief Vertex format |
||||
@m_since_latest |
||||
|
||||
Wraps a subset of @type_vk_keyword{Format} that's usable as a vertex format. |
||||
Unless said otherwise (mostly in case of 8- and 16-bit three-component |
||||
formats and doubles), all formats are guaranteed to be supported by the spec. |
||||
|
||||
@m_enum_values_as_keywords |
||||
|
||||
@see @ref Magnum::VertexFormat, @ref hasVertexFormat(), @ref vertexFormat() |
||||
*/ |
||||
enum class VertexFormat: Int { |
||||
/** @ref Magnum::Float "Float" */ |
||||
Float = VK_FORMAT_R32_SFLOAT, |
||||
|
||||
/** @ref Magnum::Half "Half" */ |
||||
Half = VK_FORMAT_R16_SFLOAT, |
||||
|
||||
/**
|
||||
* @ref Magnum::Double "Double". |
||||
* |
||||
* Compared to @ref VertexFormat::Float, this format is not guaranteed to |
||||
* be supported. |
||||
*/ |
||||
Double = VK_FORMAT_R64_SFLOAT, |
||||
|
||||
/** @ref Magnum::UnsignedByte "UnsignedByte" */ |
||||
UnsignedByte = VK_FORMAT_R8_UINT, |
||||
|
||||
/**
|
||||
* @ref Magnum::UnsignedByte "UnsignedByte", with range @f$ [0, 255] @f$ |
||||
* interpreted as @f$ [0.0, 1.0] @f$. |
||||
*/ |
||||
UnsignedByteNormalized = VK_FORMAT_R8_UNORM, |
||||
|
||||
/** @ref Magnum::Byte "Byte" */ |
||||
Byte = VK_FORMAT_R8_SINT, |
||||
|
||||
/**
|
||||
* @ref Magnum::Byte "Byte", with range @f$ [-127, 127] @f$ interpreted as |
||||
* @f$ [-1.0, 1.0] @f$. |
||||
*/ |
||||
ByteNormalized = VK_FORMAT_R8_SNORM, |
||||
|
||||
/** @ref Magnum::UnsignedShort "UnsignedShort" */ |
||||
UnsignedShort = VK_FORMAT_R16_UINT, |
||||
|
||||
/**
|
||||
* @ref Magnum::UnsignedShort "UnsignedShort", with range |
||||
* @f$ [0, 65535] @f$ interpreted as @f$ [0.0, 1.0] @f$. |
||||
*/ |
||||
UnsignedShortNormalized = VK_FORMAT_R16_UNORM, |
||||
|
||||
/** @ref Magnum::Short "Short" */ |
||||
Short = VK_FORMAT_R16_SINT, |
||||
|
||||
/**
|
||||
* @ref Magnum::Short "Short", with range @f$ [-32767, 32767] @f$ |
||||
* interpreted as @f$ [-1.0, 1.0] @f$. |
||||
*/ |
||||
ShortNormalized = VK_FORMAT_R16_SNORM, |
||||
|
||||
/** @ref Magnum::UnsignedInt "UnsignedInt" */ |
||||
UnsignedInt = VK_FORMAT_R32_UINT, |
||||
|
||||
/** @ref Magnum::Int "Int" */ |
||||
Int = VK_FORMAT_R32_SINT, |
||||
|
||||
/** @ref Magnum::Vector2 "Vector2" */ |
||||
Vector2 = VK_FORMAT_R32G32_SFLOAT, |
||||
|
||||
/** @ref Magnum::Vector2h "Vector2h" */ |
||||
Vector2h = VK_FORMAT_R16G16_SFLOAT, |
||||
|
||||
/**
|
||||
* @ref Magnum::Vector2d "Vector2d". |
||||
* |
||||
* Compared to @ref VertexFormat::Vector2, this format is not guaranteed to |
||||
* be supported. |
||||
*/ |
||||
Vector2d = VK_FORMAT_R64G64_SFLOAT, |
||||
|
||||
/** @ref Magnum::Vector2ub "Vector2ub" */ |
||||
Vector2ub = VK_FORMAT_R8G8_UINT, |
||||
|
||||
/**
|
||||
* @ref Magnum::Vector2ub "Vector2ub", with range @f$ [0, 255] @f$ |
||||
* interpreted as @f$ [0.0, 1.0] @f$. |
||||
*/ |
||||
Vector2ubNormalized = VK_FORMAT_R8G8_UNORM, |
||||
|
||||
/** @ref Magnum::Vector2b "Vector2b" */ |
||||
Vector2b = VK_FORMAT_R8G8_SINT, |
||||
|
||||
/**
|
||||
* @ref Magnum::Vector2b "Vector2b", with range @f$ [-127, 127] @f$ |
||||
* interpreted as @f$ [-1.0, 1.0] @f$. |
||||
*/ |
||||
Vector2bNormalized = VK_FORMAT_R8G8_SNORM, |
||||
|
||||
/** @ref Magnum::Vector2us "Vector2us" */ |
||||
Vector2us = VK_FORMAT_R16G16_UINT, |
||||
|
||||
/**
|
||||
* @ref Magnum::Vector2us "Vector2us", with range @f$ [0, 65535] @f$ |
||||
* interpreted as @f$ [0.0, 1.0] @f$. |
||||
*/ |
||||
Vector2usNormalized = VK_FORMAT_R16G16_UNORM, |
||||
|
||||
/** @ref Magnum::Vector2s "Vector2s" */ |
||||
Vector2s = VK_FORMAT_R16G16_SINT, |
||||
|
||||
/**
|
||||
* @ref Magnum::Vector2s "Vector2s", with range @f$ [-32767, 32767] @f$ |
||||
* interpreted as @f$ [-1.0, 1.0] @f$. |
||||
*/ |
||||
Vector2sNormalized = VK_FORMAT_R16G16_SNORM, |
||||
|
||||
/** @ref Magnum::Vector2ui "Vector2ui" */ |
||||
Vector2ui = VK_FORMAT_R32G32_UINT, |
||||
|
||||
/** @ref Magnum::Vector2i "Vector2i" */ |
||||
Vector2i = VK_FORMAT_R32G32_SINT, |
||||
|
||||
/** @ref Magnum::Vector3 "Vector3" or @ref Magnum::Color3 "Color3" */ |
||||
Vector3 = VK_FORMAT_R32G32B32_SFLOAT, |
||||
|
||||
/**
|
||||
* @ref Magnum::Vector3h "Vector3h" or @ref Magnum::Color3h "Color3h". |
||||
* |
||||
* Compared to @ref VertexFormat::Vector3 or @ref VertexFormat::Vector2h / |
||||
* @ref VertexFormat::Vector4h, this format is not guaranteed to be |
||||
* supported. |
||||
*/ |
||||
Vector3h = VK_FORMAT_R16G16B16_SFLOAT, |
||||
|
||||
/**
|
||||
* @ref Magnum::Vector3d "Vector3d". |
||||
* |
||||
* Compared to @ref VertexFormat::Vector3, this format is not guaranteed to |
||||
* be supported. |
||||
*/ |
||||
Vector3d = VK_FORMAT_R64G64B64_SFLOAT, |
||||
|
||||
/**
|
||||
* @ref Magnum::Vector3ub "Vector3ub". |
||||
* |
||||
* Compared to @ref VertexFormat::Vector3ui or @ref VertexFormat::Vector2ub |
||||
* / @ref VertexFormat::Vector4ub, this format is not guaranteed to be |
||||
* supported. |
||||
*/ |
||||
Vector3ub = VK_FORMAT_R8G8B8_UINT, |
||||
|
||||
/**
|
||||
* @ref Magnum::Vector3ub "Vector3ub" or @ref Magnum::Color3ub "Color3ub", |
||||
* with range @f$ [0, 255] @f$ interpreted as @f$ [0.0, 1.0] @f$. |
||||
* |
||||
* Compared to @ref VertexFormat::Vector3 or |
||||
* @ref VertexFormat..Vector2ubNormalized / |
||||
* @ref VertexFormat::Vector4ubNormalized, this format is not guaranteed to |
||||
* be supported. |
||||
*/ |
||||
Vector3ubNormalized = VK_FORMAT_R8G8B8_UNORM, |
||||
|
||||
/**
|
||||
* @ref Magnum::Vector3b "Vector3b". |
||||
* |
||||
* Compared to @ref VertexFormat::Vector3i or @ref VertexFormat::Vector2b / |
||||
* @ref VertexFormat::Vector4b, this format is not guaranteed to be |
||||
* supported. |
||||
*/ |
||||
Vector3b = VK_FORMAT_R8G8B8_SINT, |
||||
|
||||
/**
|
||||
* @ref Magnum::Vector3b "Vector3b", with range @f$ [-127, 127] @f$ |
||||
* )interpreted as @f$ [-1.0, 1.0] @f$. |
||||
* |
||||
* Compared to @ref VertexFormat::Vector3 or |
||||
* @ref VertexFormat::Vector2bNormalized / |
||||
* @ref VertexFormat::Vector4bNormalized, this format is not guaranteed to |
||||
* be supported. |
||||
*/ |
||||
Vector3bNormalized = VK_FORMAT_R8G8B8_SNORM, |
||||
|
||||
/**
|
||||
* @ref Magnum::Vector3us "Vector3us". |
||||
* |
||||
* Compared to @ref VertexFormat::Vector3ui or @ref VertexFormat::Vector2us |
||||
* / @ref VertexFormat::Vector4us, this format is not guaranteed to be |
||||
* supported. |
||||
*/ |
||||
Vector3us = VK_FORMAT_R16G16B16_UINT, |
||||
|
||||
/**
|
||||
* @ref Magnum::Vector3us "Vector3us" or @ref Magnum::Color3us "Color3us", |
||||
* with range @f$ [0, 65535] @f$ interpreted as @f$ [0.0, 1.0] @f$. |
||||
* |
||||
* Compared to @ref VertexFormat::Vector3 or |
||||
* @ref VertexFormat::Vector3usNormalized / |
||||
* @ref VertexFormat::Vector4usNormalized, this format is not guaranteed to |
||||
* be supported. |
||||
*/ |
||||
Vector3usNormalized = VK_FORMAT_R16G16B16_UNORM, |
||||
|
||||
/**
|
||||
* @ref Magnum::Vector3s "Vector3s". |
||||
* |
||||
* Compared to @ref VertexFormat::Vector3i or @ref VertexFormat::Vector2b / |
||||
* @ref VertexFormat::Vector4b, this format is not guaranteed to be |
||||
* supported. |
||||
*/ |
||||
Vector3s = VK_FORMAT_R16G16B16_SINT, |
||||
|
||||
/**
|
||||
* @ref Magnum::Vector3s "Vector3s", with range @f$ [-32767, 32767] @f$ |
||||
* interpreted as @f$ [-1.0, 1.0] @f$. |
||||
* |
||||
* Compared to @ref VertexFormat::Vector3 or |
||||
* @ref VertexFormat::Vector3sNormalized / |
||||
* @ref VertexFormat::Vector4sNormalized, this format is not guaranteed to |
||||
* be supported. |
||||
*/ |
||||
Vector3sNormalized = VK_FORMAT_R16G16B16_SNORM, |
||||
|
||||
/** @ref Magnum::Vector3ui "Vector3ui" */ |
||||
Vector3ui = VK_FORMAT_R32G32B32_UINT, |
||||
|
||||
/** @ref Magnum::Vector3i "Vector3i" */ |
||||
Vector3i = VK_FORMAT_R32G32B32_SINT, |
||||
|
||||
/** @ref Magnum::Vector4 "Vector4" or @ref Magnum::Color4 "Color4" */ |
||||
Vector4 = VK_FORMAT_R32G32B32A32_SFLOAT, |
||||
|
||||
/** @ref Magnum::Vector4h "Vector4h" or @ref Magnum::Color4h "Color4h" */ |
||||
Vector4h = VK_FORMAT_R16G16B16A16_SFLOAT, |
||||
|
||||
/**
|
||||
* @ref Magnum::Vector4d "Vector4d". |
||||
* |
||||
* Compared to @ref VertexFormat::Vector4, this format is not guaranteed to |
||||
* be supported. |
||||
*/ |
||||
Vector4d = VK_FORMAT_R64G64B64A64_SFLOAT, |
||||
|
||||
/** @ref Magnum::Vector4ub "Vector4ub" */ |
||||
Vector4ub = VK_FORMAT_R8G8B8A8_UINT, |
||||
|
||||
/**
|
||||
* @ref Magnum::Vector4ub "Vector4ub" or @ref Magnum::Color4ub "Color4ub", |
||||
* with range @f$ [0, 255] @f$ interpreted as @f$ [0.0, 1.0] @f$. |
||||
*/ |
||||
Vector4ubNormalized = VK_FORMAT_R8G8B8A8_UNORM, |
||||
|
||||
/** @ref Magnum::Vector4b "Vector4b" */ |
||||
Vector4b = VK_FORMAT_R8G8B8A8_SINT, |
||||
|
||||
/**
|
||||
* @ref Magnum::Vector4b "Vector4b", with range @f$ [-127, 127] @f$ |
||||
* interpreted as @f$ [-1.0, 1.0] @f$. |
||||
*/ |
||||
Vector4bNormalized = VK_FORMAT_R8G8B8A8_SNORM, |
||||
|
||||
/** @ref Magnum::Vector4us "Vector4us" */ |
||||
Vector4us = VK_FORMAT_R16G16B16A16_UINT, |
||||
|
||||
/**
|
||||
* @ref Magnum::Vector4us "Vector4us" or @ref Magnum::Color4us "Color4us", |
||||
* with range @f$ [0, 65535] @f$ interpreted as @f$ [0.0, 1.0] @f$. |
||||
*/ |
||||
Vector4usNormalized = VK_FORMAT_R16G16B16A16_UNORM, |
||||
|
||||
/** @ref Magnum::Vector4s "Vector4s" */ |
||||
Vector4s = VK_FORMAT_R16G16B16A16_SINT, |
||||
|
||||
/**
|
||||
* @ref Magnum::Vector4s "Vector4s", with range @f$ [-32767, 32767] @f$ |
||||
* interpreted as @f$ [-1.0, 1.0] @f$. |
||||
*/ |
||||
Vector4sNormalized = VK_FORMAT_R16G16B16A16_SNORM, |
||||
|
||||
/** @ref Magnum::Vector4ui "Vector4ui" */ |
||||
Vector4ui = VK_FORMAT_R32G32B32A32_UINT, |
||||
|
||||
/** @ref Magnum::Vector4i "Vector4i" */ |
||||
Vector4i = VK_FORMAT_R32G32B32A32_SINT, |
||||
}; |
||||
|
||||
/**
|
||||
@debugoperatorenum{VertexFormat} |
||||
@m_since_latest |
||||
*/ |
||||
MAGNUM_VK_EXPORT Debug& operator<<(Debug& debug, VertexFormat value); |
||||
|
||||
/**
|
||||
@brief Check availability of a generic vertex format |
||||
@m_since_latest |
||||
|
||||
Returns @cpp false @ce if Vulkan doesn't support such format, @cpp true @ce |
||||
otherwise. Moreover, returns @cpp true @ce also for all formats that are |
||||
@ref isVertexFormatImplementationSpecific(). The @p format value is expected |
||||
to be valid. Note that for matrix formats the function only returns a |
||||
corresponding vector type, and the user is expected to bind the remaining |
||||
vectors to consecutive attribute locations based on what |
||||
@ref vertexFormatVectorCount() and @ref vertexFormatVectorStride() return. |
||||
|
||||
@note Support of some formats depends on presence of a particular Vulkan |
||||
extension. Such check is outside of the scope of this function and you are |
||||
expected to verify extension availability before using such format. |
||||
|
||||
@see @ref vertexFormat() |
||||
*/ |
||||
MAGNUM_VK_EXPORT bool hasVertexFormat(Magnum::VertexFormat format); |
||||
|
||||
/**
|
||||
@brief Convert a generic vertex format to Vulkan vertex format |
||||
@m_since_latest |
||||
|
||||
In case @ref isVertexFormatImplementationSpecific() returns @cpp false @ce for |
||||
@p format, maps it to a corresponding Vulkan format. In case |
||||
@ref isVertexFormatImplementationSpecific() returns @cpp true @ce, assumes |
||||
@p format stores a Vulkan-specific format and returns @ref vertexFormatUnwrap() |
||||
cast to @ref VertexFormat. |
||||
|
||||
Not all generic vertex formats have a Vulkan equivalent and this function |
||||
expects that given format is available. Use @ref hasVertexFormat() to query |
||||
availability of given format. |
||||
*/ |
||||
MAGNUM_VK_EXPORT VertexFormat vertexFormat(Magnum::VertexFormat format); |
||||
|
||||
}} |
||||
|
||||
#endif |
||||
Loading…
Reference in new issue