mirror of https://github.com/mosra/magnum.git
Browse Source
Because I don't yet have any source file that's assert-independent, the MagnumVkObjects library is commented out, as it is completely empty right now.pull/297/head
12 changed files with 1149 additions and 82 deletions
@ -0,0 +1,192 @@
|
||||
/*
|
||||
This file is part of Magnum. |
||||
|
||||
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 |
||||
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 "Enums.h" |
||||
|
||||
#include <Corrade/Containers/ArrayView.h> |
||||
|
||||
#include "Magnum/Mesh.h" |
||||
#include "Magnum/PixelFormat.h" |
||||
#include "Magnum/Sampler.h" |
||||
|
||||
namespace Magnum { namespace Vk { |
||||
|
||||
namespace { |
||||
|
||||
constexpr VkPrimitiveTopology PrimitiveTopologyMapping[]{ |
||||
VK_PRIMITIVE_TOPOLOGY_POINT_LIST, |
||||
VK_PRIMITIVE_TOPOLOGY_LINE_LIST, |
||||
VkPrimitiveTopology(~UnsignedInt{}), |
||||
VK_PRIMITIVE_TOPOLOGY_LINE_STRIP, |
||||
VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, |
||||
VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP, |
||||
VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN |
||||
}; |
||||
|
||||
constexpr VkIndexType IndexTypeMapping[]{ |
||||
VkIndexType(~UnsignedInt{}), |
||||
VK_INDEX_TYPE_UINT16, |
||||
VK_INDEX_TYPE_UINT32 |
||||
}; |
||||
|
||||
#ifndef DOXYGEN_GENERATING_OUTPUT /* It gets *really* confused */ |
||||
constexpr VkFormat FormatMapping[] { |
||||
#define _c(input, format) VK_FORMAT_ ## format, |
||||
#define _s(input) VkFormat(~UnsignedInt{}), |
||||
#include "Magnum/Vk/Implementation/formatMapping.hpp" |
||||
#undef _s |
||||
#undef _c |
||||
}; |
||||
|
||||
constexpr VkFormat CompressedFormatMapping[] { |
||||
#define _c(input, format) VK_FORMAT_ ## format, |
||||
#define _s(input) VkFormat(~UnsignedInt{}), |
||||
#include "Magnum/Vk/Implementation/compressedFormatMapping.hpp" |
||||
#undef _s |
||||
#undef _c |
||||
}; |
||||
#endif |
||||
|
||||
constexpr VkFilter FilterMapping[]{ |
||||
VK_FILTER_NEAREST, |
||||
VK_FILTER_LINEAR |
||||
}; |
||||
|
||||
constexpr VkSamplerMipmapMode SamplerMipmapModeMapping[]{ |
||||
VK_SAMPLER_MIPMAP_MODE_NEAREST, /* See vkSamplerMipmapMode() for details */ |
||||
VK_SAMPLER_MIPMAP_MODE_NEAREST, |
||||
VK_SAMPLER_MIPMAP_MODE_LINEAR |
||||
}; |
||||
|
||||
constexpr VkSamplerAddressMode SamplerAddressModeMapping[]{ |
||||
VK_SAMPLER_ADDRESS_MODE_REPEAT, |
||||
VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT, |
||||
VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, |
||||
VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, |
||||
VkSamplerAddressMode(~UnsignedInt{}), |
||||
}; |
||||
|
||||
} |
||||
|
||||
bool hasVkPrimitiveTopology(const Magnum::MeshPrimitive primitive) { |
||||
CORRADE_ASSERT(UnsignedInt(primitive) < Containers::arraySize(PrimitiveTopologyMapping), |
||||
"Vk::hasVkPrimitiveTopology(): invalid primitive" << primitive, {}); |
||||
return UnsignedInt(PrimitiveTopologyMapping[UnsignedInt(primitive)]) != ~UnsignedInt{}; |
||||
} |
||||
|
||||
VkPrimitiveTopology vkPrimitiveTopology(const Magnum::MeshPrimitive primitive) { |
||||
CORRADE_ASSERT(UnsignedInt(primitive) < Containers::arraySize(PrimitiveTopologyMapping), |
||||
"Vk::vkPrimitiveTopology(): invalid primitive" << primitive, {}); |
||||
const VkPrimitiveTopology out = PrimitiveTopologyMapping[UnsignedInt(primitive)]; |
||||
CORRADE_ASSERT(out != VkPrimitiveTopology(~UnsignedInt{}), |
||||
"Vk::vkPrimitiveTopology(): unsupported primitive" << primitive, {}); |
||||
return out; |
||||
} |
||||
|
||||
bool hasVkIndexType(const Magnum::MeshIndexType type) { |
||||
CORRADE_ASSERT(UnsignedInt(type) < Containers::arraySize(IndexTypeMapping), |
||||
"Vk::hasVkIndexType(): invalid type" << type, {}); |
||||
return UnsignedInt(IndexTypeMapping[UnsignedInt(type)]) != ~UnsignedInt{}; |
||||
} |
||||
|
||||
VkIndexType vkIndexType(const Magnum::MeshIndexType type) { |
||||
CORRADE_ASSERT(UnsignedInt(type) < Containers::arraySize(IndexTypeMapping), |
||||
"Vk::vkIndexType(): invalid type" << type, {}); |
||||
const VkIndexType out = IndexTypeMapping[UnsignedInt(type)]; |
||||
CORRADE_ASSERT(out != VkIndexType(~UnsignedInt{}), |
||||
"Vk::vkIndexType(): unsupported type" << type, {}); |
||||
return out; |
||||
} |
||||
|
||||
bool hasVkFormat(const Magnum::PixelFormat format) { |
||||
if(isPixelFormatImplementationSpecific(format)) |
||||
return true; |
||||
|
||||
CORRADE_ASSERT(UnsignedInt(format) < Containers::arraySize(FormatMapping), |
||||
"Vk::hasVkFormat(): invalid format" << format, {}); |
||||
return UnsignedInt(FormatMapping[UnsignedInt(format)]); |
||||
} |
||||
|
||||
bool hasVkFormat(const Magnum::CompressedPixelFormat format) { |
||||
if(isCompressedPixelFormatImplementationSpecific(format)) |
||||
return true; |
||||
|
||||
CORRADE_ASSERT(UnsignedInt(format) < Containers::arraySize(CompressedFormatMapping), |
||||
"Vk::hasVkFormat(): invalid format" << format, {}); |
||||
return UnsignedInt(CompressedFormatMapping[UnsignedInt(format)]); |
||||
} |
||||
|
||||
VkFormat vkFormat(const Magnum::PixelFormat format) { |
||||
if(isPixelFormatImplementationSpecific(format)) |
||||
return pixelFormatUnwrap<VkFormat>(format); |
||||
|
||||
CORRADE_ASSERT(UnsignedInt(format) < Containers::arraySize(FormatMapping), |
||||
"Vk::vkFormat(): invalid format" << format, {}); |
||||
const VkFormat out = FormatMapping[UnsignedInt(format)]; |
||||
CORRADE_ASSERT(UnsignedInt(out), |
||||
"Vk::vkFormat(): unsupported format" << format, {}); |
||||
return out; |
||||
} |
||||
|
||||
VkFormat vkFormat(const Magnum::CompressedPixelFormat format) { |
||||
if(isCompressedPixelFormatImplementationSpecific(format)) |
||||
return compressedPixelFormatUnwrap<VkFormat>(format); |
||||
|
||||
CORRADE_ASSERT(UnsignedInt(format) < Containers::arraySize(CompressedFormatMapping), |
||||
"Vk::vkFormat(): invalid format" << format, {}); |
||||
const VkFormat out = CompressedFormatMapping[UnsignedInt(format)]; |
||||
CORRADE_ASSERT(UnsignedInt(out), |
||||
"Vk::vkFormat(): unsupported format" << format, {}); |
||||
return out; |
||||
} |
||||
|
||||
VkFilter vkFilter(const Magnum::SamplerFilter filter) { |
||||
CORRADE_ASSERT(UnsignedInt(filter) < Containers::arraySize(FilterMapping), |
||||
"Vk::vkFilter(): invalid filter" << filter, {}); |
||||
return FilterMapping[UnsignedInt(filter)]; |
||||
} |
||||
|
||||
VkSamplerMipmapMode vkSamplerMipmapMode(const Magnum::SamplerMipmap mipmap) { |
||||
CORRADE_ASSERT(UnsignedInt(mipmap) < Containers::arraySize(SamplerMipmapModeMapping), |
||||
"Vk::vkSamplerMipmapMode(): invalid mode" << mipmap, {}); |
||||
return SamplerMipmapModeMapping[UnsignedInt(mipmap)]; |
||||
} |
||||
|
||||
bool hasVkSamplerAddressMode(const Magnum::SamplerWrapping wrapping) { |
||||
CORRADE_ASSERT(UnsignedInt(wrapping) < Containers::arraySize(SamplerAddressModeMapping), |
||||
"Vk::hasVkSamplerAddressMode(): invalid wrapping" << wrapping, {}); |
||||
return UnsignedInt(SamplerAddressModeMapping[UnsignedInt(wrapping)]) != ~UnsignedInt{}; |
||||
} |
||||
|
||||
VkSamplerAddressMode vkSamplerAddressMode(const Magnum::SamplerWrapping wrapping) { |
||||
CORRADE_ASSERT(UnsignedInt(wrapping) < Containers::arraySize(SamplerAddressModeMapping), |
||||
"Vk::vkSamplerAddressMode(): invalid wrapping" << wrapping, {}); |
||||
const VkSamplerAddressMode out = SamplerAddressModeMapping[UnsignedInt(wrapping)]; |
||||
CORRADE_ASSERT(out != VkSamplerAddressMode(~UnsignedInt{}), |
||||
"Vk::vkSamplerAddressMode(): unsupported wrapping" << wrapping, {}); |
||||
return out; |
||||
} |
||||
|
||||
}} |
||||
@ -0,0 +1,195 @@
|
||||
#ifndef Magnum_GL_Enums_h |
||||
#define Magnum_GL_Enums_h |
||||
/*
|
||||
This file is part of Magnum. |
||||
|
||||
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 |
||||
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. |
||||
*/ |
||||
|
||||
/** @file
|
||||
* @brief Function @ref Magnum::Vk::hasVkPrimitiveTopology(), @ref Magnum::Vk::vkPrimitiveTopology(), @ref Magnum::Vk::hasVkIndexType(), @ref Magnum::Vk::vkIndexType(), @ref Magnum::Vk::hasVkFormat(), @ref Magnum::Vk::vkFormat(), @ref Magnum::Vk::vkFilter(), @ref Magnum::Vk::vkSamplerMipmapMode(), @ref Magnum::Vk::hasVkSamplerAddressMode(), @ref Magnum::Vk::vkSamplerAddressMode() |
||||
*/ |
||||
|
||||
#include "Magnum/Array.h" |
||||
#include "Magnum/Vk/Vulkan.h" |
||||
#include "Magnum/Vk/visibility.h" |
||||
|
||||
namespace Magnum { namespace Vk { |
||||
|
||||
/**
|
||||
@brief Check availability of a generic mesh primitive |
||||
|
||||
In particular, Vulkan doesn't support the @ref MeshPrimitive::LineLoop |
||||
primitive. Returns @cpp false @ce if Vulkan doesn't support such primitive, |
||||
@cpp true @ce otherwise. The @p primitive value is expected to be valid. |
||||
@see @ref vkPrimitiveTopology() |
||||
*/ |
||||
MAGNUM_VK_EXPORT bool hasVkPrimitiveTopology(Magnum::MeshPrimitive primitive); |
||||
|
||||
/**
|
||||
@brief Convert generic mesh primitive to Vulkan primitive topology |
||||
|
||||
Not all generic mesh primitives are available in Vulkan and this function |
||||
expects that given primitive is available. Use @ref hasVkPrimitiveTopology() to |
||||
query availability of given primitive. |
||||
@see @ref vkIndexType() |
||||
*/ |
||||
MAGNUM_VK_EXPORT VkPrimitiveTopology vkPrimitiveTopology(Magnum::MeshPrimitive primitive); |
||||
|
||||
/**
|
||||
@brief Check availability of a generic index type |
||||
|
||||
In particular, Vulkan doesn't support the @ref MeshIndexType::UnsignedByte |
||||
type. Returns @cpp false @ce if Vulkan doesn't support such type, @cpp true @ce |
||||
otherwise. The @p type value is expected to be valid. |
||||
@see @ref vkIndexType() |
||||
*/ |
||||
MAGNUM_VK_EXPORT bool hasVkIndexType(Magnum::MeshIndexType type); |
||||
|
||||
/**
|
||||
@brief Convert generic mesh index type to Vulkan mesh index type |
||||
|
||||
Not all generic index types are available in Vulkan and this function expects |
||||
that given type is available. Use @ref hasVkIndexType() to query availability |
||||
of given index type. |
||||
@see @ref vkPrimitiveTopology() |
||||
*/ |
||||
MAGNUM_VK_EXPORT VkIndexType vkIndexType(Magnum::MeshIndexType type); |
||||
|
||||
/**
|
||||
@brief Check availability of a generic pixel format |
||||
|
||||
Some Vulkan targets don't support all generic formats. Returns @cpp false @ce |
||||
if current target can't support such format, @cpp true @ce otherwise. Moreover, |
||||
returns @cpp true @ce also for all formats that are |
||||
@ref isPixelFormatImplementationSpecific(). The @p format value is expected to |
||||
be valid. |
||||
|
||||
@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 vkFormat() |
||||
*/ |
||||
MAGNUM_VK_EXPORT bool hasVkFormat(Magnum::PixelFormat format); |
||||
|
||||
/**
|
||||
@brief Check availability of a generic compressed pixel format |
||||
|
||||
Some Vulkan targets don't support all generic formats. Returns @cpp false @ce |
||||
if current target can't support such format, @cpp true @ce otherwise. Moreover, |
||||
returns @cpp true @ce also for all formats that are |
||||
@ref isCompressedPixelFormatImplementationSpecific(). The @p format value is |
||||
expected to be valid. |
||||
|
||||
@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 vkFormat() |
||||
*/ |
||||
MAGNUM_VK_EXPORT bool hasVkFormat(Magnum::CompressedPixelFormat format); |
||||
|
||||
/**
|
||||
@brief Convert a generic pixel format to Vulkan format |
||||
|
||||
In case @ref isPixelFormatImplementationSpecific() returns @cpp false @ce for |
||||
@p format, maps it to a corresponding Vulkan format. In case |
||||
@ref isPixelFormatImplementationSpecific() returns @cpp true @ce, assumes |
||||
@p format stores Vulkan-specific format and returns @ref pixelFormatUnwrap() |
||||
cast to @type_vk{Format}. |
||||
|
||||
Not all generic pixel formats may be available on all targets and this function |
||||
expects that given format is available on the target. Use @ref hasVkFormat() to |
||||
query availability of given format. |
||||
*/ |
||||
MAGNUM_VK_EXPORT VkFormat vkFormat(Magnum::PixelFormat format); |
||||
|
||||
/**
|
||||
@brief Convert a generic pixel format to Vulkan format |
||||
|
||||
In case @ref isCompressedPixelFormatImplementationSpecific() returns |
||||
@cpp false @ce for @p format, maps it to a corresponding Vulkan format. In case |
||||
@ref isCompressedPixelFormatImplementationSpecific() returns @cpp true @ce, |
||||
assumes @p format stores Vulkan-specific format and returns |
||||
@ref compressedPixelFormatUnwrap() cast to @type_vk{Format}. |
||||
|
||||
Not all generic pixel formats may be available on all targets and this function |
||||
expects that given format is available on the target. Use @ref hasVkFormat() to |
||||
query availability of given format. |
||||
*/ |
||||
MAGNUM_VK_EXPORT VkFormat vkFormat(Magnum::CompressedPixelFormat format); |
||||
|
||||
/**
|
||||
@brief Convert generic sampler filter to Vulkan filter |
||||
|
||||
@see @ref vkSamplerMipmapMode(), @ref vkSamplerAddressMode() |
||||
*/ |
||||
MAGNUM_VK_EXPORT VkFilter vkFilter(Magnum::SamplerFilter filter); |
||||
|
||||
/**
|
||||
@brief Convert generic sampler mipomap mode to Vulkan sampler mipmap mode |
||||
|
||||
Vulkan doesn't support the @ref SamplerMipmap::Base value directly, instead |
||||
@def_vk{SAMPLER_MIPMAP_MODE_NEAREST,SamplerMipmapMode} is used and you have to |
||||
configure the sampler to use just a single mipmap level. |
||||
@see @ref vkFilter(), @ref vkSamplerAddressMode() |
||||
*/ |
||||
MAGNUM_VK_EXPORT VkSamplerMipmapMode vkSamplerMipmapMode(Magnum::SamplerMipmap mipmap); |
||||
|
||||
/**
|
||||
@brief Check availability of a generic sampler wrapping mode |
||||
|
||||
Some Vulkan targets don't support all generic sampler wrapping modes (for |
||||
example the @ref SamplerWrapping::MirrorClampToEdge). Returns @cpp false @ce if |
||||
current target can't support such format, @cpp true @ce otherwise. The |
||||
@p wrapping value is expected to be valid. |
||||
|
||||
@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 vkSamplerAddressMode(), @ref vkFilter(), @ref vkSamplerMipmapMode() |
||||
*/ |
||||
MAGNUM_VK_EXPORT bool hasVkSamplerAddressMode(Magnum::SamplerWrapping wrapping); |
||||
|
||||
/**
|
||||
@brief Convert generic sampler filter mode to Vulkan sampler address mode |
||||
|
||||
Not all generic sampler wrapping modes may be available on all targets and this |
||||
function expects that given format is available on the target. Use |
||||
@ref hasVkSamplerAddressMode() to query availability of given mode. |
||||
@see @ref vkFilter(), @ref vkSamplerAddressMode() |
||||
*/ |
||||
MAGNUM_VK_EXPORT VkSamplerAddressMode vkSamplerAddressMode(Magnum::SamplerWrapping wrapping); |
||||
|
||||
/** @overload */ |
||||
template<UnsignedInt dimensions> Array<dimensions, VkSamplerAddressMode> vkSamplerAddressMode(const Array<dimensions, Magnum::SamplerWrapping>& wrapping) { |
||||
Array<dimensions, VkSamplerAddressMode> out; /** @todo NoInit */ |
||||
for(std::size_t i = 0; i != dimensions; ++i) |
||||
out[i] = vkSamplerAddressMode(wrapping[i]); |
||||
return out; |
||||
} |
||||
|
||||
}} |
||||
|
||||
#endif |
||||
@ -0,0 +1,32 @@
|
||||
/*
|
||||
This file is part of Magnum. |
||||
|
||||
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 |
||||
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. |
||||
*/ |
||||
|
||||
/* See Magnum/Vk/Enums.cpp and Magnum/Vk/Test/EnumsTest.cpp */ |
||||
#ifdef _c |
||||
_c(Bc1RGBUnorm, BC1_RGB_UNORM_BLOCK) |
||||
_c(Bc1RGBAUnorm, BC1_RGBA_UNORM_BLOCK) |
||||
_c(Bc2RGBAUnorm, BC2_UNORM_BLOCK) |
||||
_c(Bc3RGBAUnorm, BC3_UNORM_BLOCK) |
||||
#endif |
||||
@ -0,0 +1,76 @@
|
||||
/*
|
||||
This file is part of Magnum. |
||||
|
||||
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 |
||||
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. |
||||
*/ |
||||
|
||||
/* See Magnum/Vk/Enums.cpp and Magnum/Vk/Test/EnumsTest.cpp */ |
||||
#ifdef _c |
||||
_c(R8Unorm, R8_UNORM) |
||||
_c(RG8Unorm, R8G8_UNORM) |
||||
_c(RGB8Unorm, R8G8B8_UNORM) |
||||
_c(RGBA8Unorm, R8G8B8A8_UNORM) |
||||
_c(R8Snorm, R8_SNORM) |
||||
_c(RG8Snorm, R8G8_SNORM) |
||||
_c(RGB8Snorm, R8G8B8_SNORM) |
||||
_c(RGBA8Snorm, R8G8B8A8_SNORM) |
||||
_c(R8UI, R8_UINT) |
||||
_c(RG8UI, R8G8_UINT) |
||||
_c(RGB8UI, R8G8B8_UINT) |
||||
_c(RGBA8UI, R8G8B8A8_UINT) |
||||
_c(R8I, R8_SINT) |
||||
_c(RG8I, R8G8_SINT) |
||||
_c(RGB8I, R8G8B8_SINT) |
||||
_c(RGBA8I, R8G8B8A8_SINT) |
||||
_c(R16Unorm, R16_UNORM) |
||||
_c(RG16Unorm, R16G16_UNORM) |
||||
_c(RGB16Unorm, R16G16B16_UNORM) |
||||
_c(RGBA16Unorm, R16G16B16A16_UNORM) |
||||
_c(R16Snorm, R16_SNORM) |
||||
_c(RG16Snorm, R16G16_SNORM) |
||||
_c(RGB16Snorm, R16G16B16_SNORM) |
||||
_c(RGBA16Snorm, R16G16B16A16_SNORM) |
||||
_c(R16UI, R16_UINT) |
||||
_c(RG16UI, R16G16_UINT) |
||||
_c(RGB16UI, R16G16B16_UINT) |
||||
_c(RGBA16UI, R16G16B16A16_UINT) |
||||
_c(R16I, R16_SINT) |
||||
_c(RG16I, R16G16_SINT) |
||||
_c(RGB16I, R16G16B16_SINT) |
||||
_c(RGBA16I, R16G16B16A16_SINT) |
||||
_c(R32UI, R32_UINT) |
||||
_c(RG32UI, R32G32_UINT) |
||||
_c(RGB32UI, R32G32B32_UINT) |
||||
_c(RGBA32UI, R32G32B32A32_UINT) |
||||
_c(R32I, R32_SINT) |
||||
_c(RG32I, R32G32_SINT) |
||||
_c(RGB32I, R32G32B32_SINT) |
||||
_c(RGBA32I, R32G32B32A32_SINT) |
||||
_c(R16F, R16_SFLOAT) |
||||
_c(RG16F, R16G16_SFLOAT) |
||||
_c(RGB16F, R16G16B16_SFLOAT) |
||||
_c(RGBA16F, R16G16B16A16_SFLOAT) |
||||
_c(R32F, R32_SFLOAT) |
||||
_c(RG32F, R32G32_SFLOAT) |
||||
_c(RGB32F, R32G32B32_SFLOAT) |
||||
_c(RGBA32F, R32G32B32A32_SFLOAT) |
||||
#endif |
||||
@ -0,0 +1,406 @@
|
||||
/*
|
||||
This file is part of Magnum. |
||||
|
||||
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 |
||||
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 "Magnum/configure.h" |
||||
|
||||
#if defined(MAGNUM_BUILD_DEPRECATED) && defined(MAGNUM_TARGET_GL) |
||||
/* So we don't need to care about the deprecated (Compressed)PixelFormat values */ |
||||
#undef MAGNUM_TARGET_GL |
||||
#endif |
||||
|
||||
#include "Magnum/Mesh.h" |
||||
#include "Magnum/PixelFormat.h" |
||||
#include "Magnum/Sampler.h" |
||||
#include "Magnum/Vk/Enums.h" |
||||
|
||||
namespace Magnum { namespace Vk { namespace Test { |
||||
|
||||
/* Tests MeshView as well */ |
||||
|
||||
struct EnumsTest: TestSuite::Tester { |
||||
explicit EnumsTest(); |
||||
|
||||
void mapVkPrimitiveTopology(); |
||||
void mapVkPrimitiveTopologyUnsupported(); |
||||
void mapVkPrimitiveTopologyInvalid(); |
||||
|
||||
void mapVkIndexType(); |
||||
void mapVkIndexTypeUnsupported(); |
||||
void mapVkIndexTypeInvalid(); |
||||
|
||||
void mapVkFormat(); |
||||
void mapVkFormatImplementationSpecific(); |
||||
void mapVkFormatUnsupported(); |
||||
void mapVkFormatInvalid(); |
||||
|
||||
void mapVkFormatCompressed(); |
||||
void mapVkFormatCompressedImplementationSpecific(); |
||||
void mapVkFormatCompressedUnsupported(); |
||||
void mapVkFormatCompressedInvalid(); |
||||
|
||||
void mapVkFilter(); |
||||
void mapVkFilterInvalid(); |
||||
|
||||
void mapVkSamplerMipmapMode(); |
||||
void mapVkSamplerMipmapModeInvalid(); |
||||
|
||||
void mapVkSamplerAddressMode(); |
||||
void mapVkSamplerAddressModeArray(); |
||||
void mapVkSamplerAddressModeUnsupported(); |
||||
void mapVkSamplerAddressModeInvalid(); |
||||
}; |
||||
|
||||
EnumsTest::EnumsTest() { |
||||
addTests({&EnumsTest::mapVkPrimitiveTopology, |
||||
&EnumsTest::mapVkPrimitiveTopologyUnsupported, |
||||
&EnumsTest::mapVkPrimitiveTopologyInvalid, |
||||
|
||||
&EnumsTest::mapVkIndexType, |
||||
&EnumsTest::mapVkIndexTypeUnsupported, |
||||
&EnumsTest::mapVkIndexTypeInvalid, |
||||
|
||||
&EnumsTest::mapVkFormat, |
||||
&EnumsTest::mapVkFormatImplementationSpecific, |
||||
&EnumsTest::mapVkFormatUnsupported, |
||||
&EnumsTest::mapVkFormatInvalid, |
||||
|
||||
&EnumsTest::mapVkFormatCompressed, |
||||
&EnumsTest::mapVkFormatCompressedImplementationSpecific, |
||||
&EnumsTest::mapVkFormatCompressedUnsupported, |
||||
&EnumsTest::mapVkFormatCompressedInvalid, |
||||
|
||||
&EnumsTest::mapVkFilter, |
||||
&EnumsTest::mapVkFilterInvalid, |
||||
|
||||
&EnumsTest::mapVkSamplerMipmapMode, |
||||
&EnumsTest::mapVkSamplerMipmapModeInvalid, |
||||
|
||||
&EnumsTest::mapVkSamplerAddressMode, |
||||
&EnumsTest::mapVkSamplerAddressModeArray, |
||||
&EnumsTest::mapVkSamplerAddressModeUnsupported, |
||||
&EnumsTest::mapVkSamplerAddressModeInvalid}); |
||||
} |
||||
|
||||
void EnumsTest::mapVkPrimitiveTopology() { |
||||
CORRADE_VERIFY(hasVkPrimitiveTopology(Magnum::MeshPrimitive::Points)); |
||||
CORRADE_COMPARE(vkPrimitiveTopology(Magnum::MeshPrimitive::Points), VK_PRIMITIVE_TOPOLOGY_POINT_LIST); |
||||
|
||||
CORRADE_VERIFY(hasVkPrimitiveTopology(Magnum::MeshPrimitive::Lines)); |
||||
CORRADE_COMPARE(vkPrimitiveTopology(Magnum::MeshPrimitive::Lines), VK_PRIMITIVE_TOPOLOGY_LINE_LIST); |
||||
|
||||
CORRADE_VERIFY(hasVkPrimitiveTopology(Magnum::MeshPrimitive::LineStrip)); |
||||
CORRADE_COMPARE(vkPrimitiveTopology(Magnum::MeshPrimitive::LineStrip), VK_PRIMITIVE_TOPOLOGY_LINE_STRIP); |
||||
|
||||
CORRADE_VERIFY(hasVkPrimitiveTopology(Magnum::MeshPrimitive::Triangles)); |
||||
CORRADE_COMPARE(vkPrimitiveTopology(Magnum::MeshPrimitive::Triangles), VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST); |
||||
|
||||
CORRADE_VERIFY(hasVkPrimitiveTopology(Magnum::MeshPrimitive::TriangleStrip)); |
||||
CORRADE_COMPARE(vkPrimitiveTopology(Magnum::MeshPrimitive::TriangleStrip), VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP); |
||||
|
||||
CORRADE_VERIFY(hasVkPrimitiveTopology(Magnum::MeshPrimitive::TriangleFan)); |
||||
CORRADE_COMPARE(vkPrimitiveTopology(Magnum::MeshPrimitive::TriangleFan), VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN); |
||||
} |
||||
|
||||
void EnumsTest::mapVkPrimitiveTopologyUnsupported() { |
||||
CORRADE_VERIFY(!hasVkPrimitiveTopology(Magnum::MeshPrimitive::LineLoop)); |
||||
|
||||
std::ostringstream out; |
||||
{ |
||||
Error redirectError{&out}; |
||||
vkPrimitiveTopology(Magnum::MeshPrimitive::LineLoop); |
||||
} |
||||
CORRADE_COMPARE(out.str(), |
||||
"Vk::vkPrimitiveTopology(): unsupported primitive MeshPrimitive::LineLoop\n"); |
||||
} |
||||
|
||||
void EnumsTest::mapVkPrimitiveTopologyInvalid() { |
||||
std::ostringstream out; |
||||
Error redirectError{&out}; |
||||
|
||||
hasVkPrimitiveTopology(Magnum::MeshPrimitive(0x123)); |
||||
vkPrimitiveTopology(Magnum::MeshPrimitive(0x123)); |
||||
CORRADE_COMPARE(out.str(), |
||||
"Vk::hasVkPrimitiveTopology(): invalid primitive MeshPrimitive(0x123)\n" |
||||
"Vk::vkPrimitiveTopology(): invalid primitive MeshPrimitive(0x123)\n"); |
||||
} |
||||
|
||||
void EnumsTest::mapVkIndexType() { |
||||
CORRADE_VERIFY(hasVkIndexType(Magnum::MeshIndexType::UnsignedShort)); |
||||
CORRADE_COMPARE(vkIndexType(Magnum::MeshIndexType::UnsignedShort), VK_INDEX_TYPE_UINT16); |
||||
|
||||
CORRADE_VERIFY(hasVkIndexType(Magnum::MeshIndexType::UnsignedInt)); |
||||
CORRADE_COMPARE(vkIndexType(Magnum::MeshIndexType::UnsignedInt), VK_INDEX_TYPE_UINT32); |
||||
} |
||||
|
||||
void EnumsTest::mapVkIndexTypeUnsupported() { |
||||
CORRADE_VERIFY(!hasVkIndexType(Magnum::MeshIndexType::UnsignedByte)); |
||||
std::ostringstream out; |
||||
{ |
||||
Error redirectError{&out}; |
||||
vkIndexType(Magnum::MeshIndexType::UnsignedByte); |
||||
} |
||||
CORRADE_COMPARE(out.str(), |
||||
"Vk::vkIndexType(): unsupported type MeshIndexType::UnsignedByte\n"); |
||||
} |
||||
|
||||
void EnumsTest::mapVkIndexTypeInvalid() { |
||||
std::ostringstream out; |
||||
Error redirectError{&out}; |
||||
|
||||
hasVkIndexType(Magnum::MeshIndexType(0x123)); |
||||
vkIndexType(Magnum::MeshIndexType(0x123)); |
||||
CORRADE_COMPARE(out.str(), |
||||
"Vk::hasVkIndexType(): invalid type MeshIndexType(0x123)\n" |
||||
"Vk::vkIndexType(): invalid type MeshIndexType(0x123)\n"); |
||||
} |
||||
|
||||
void EnumsTest::mapVkFormat() { |
||||
/* Touchstone verification */ |
||||
CORRADE_VERIFY(hasVkFormat(Magnum::PixelFormat::RGBA8Unorm)); |
||||
CORRADE_COMPARE(vkFormat(Magnum::PixelFormat::RGBA8Unorm), VK_FORMAT_R8G8B8A8_UNORM); |
||||
|
||||
/* 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 = 0; |
||||
for(UnsignedInt i = 0; i <= 0xffff; ++i) { |
||||
const auto format = Magnum::PixelFormat(i); |
||||
/* Each case verifies:
|
||||
- that the cases are ordered by number (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 */ |
||||
switch(format) { |
||||
#define _c(format, expectedFormat) \ |
||||
case Magnum::PixelFormat::format: \
|
||||
CORRADE_COMPARE(nextHandled, i); \
|
||||
CORRADE_COMPARE(firstUnhandled, 0xffff); \
|
||||
CORRADE_VERIFY(hasVkFormat(Magnum::PixelFormat::format)); \
|
||||
CORRADE_COMPARE(vkFormat(Magnum::PixelFormat::format), VK_FORMAT_ ## expectedFormat); \
|
||||
++nextHandled; \
|
||||
continue; |
||||
#define _s(format) \ |
||||
case Magnum::PixelFormat::format: \
|
||||
CORRADE_COMPARE(nextHandled, i); \
|
||||
CORRADE_COMPARE(firstUnhandled, 0xffff); \
|
||||
CORRADE_VERIFY(!hasVkFormat(Magnum::PixelFormat::format)); \
|
||||
vkFormat(Magnum::PixelFormat::format); \
|
||||
++nextHandled; \
|
||||
continue; |
||||
#include "Magnum/Vk/Implementation/formatMapping.hpp" |
||||
#undef _s |
||||
#undef _c |
||||
} |
||||
|
||||
/* 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 EnumsTest::mapVkFormatImplementationSpecific() { |
||||
CORRADE_VERIFY(hasVkFormat(Magnum::pixelFormatWrap(VK_FORMAT_A8B8G8R8_SINT_PACK32))); |
||||
CORRADE_COMPARE(vkFormat(Magnum::pixelFormatWrap(VK_FORMAT_A8B8G8R8_SINT_PACK32)), |
||||
VK_FORMAT_A8B8G8R8_SINT_PACK32); |
||||
} |
||||
|
||||
void EnumsTest::mapVkFormatUnsupported() { |
||||
#if 1 |
||||
CORRADE_SKIP("All pixel formats are supported."); |
||||
#else |
||||
std::ostringstream out; |
||||
Error redirectError{&out}; |
||||
|
||||
vkFormat(Magnum::PixelFormat::RGB16UI); |
||||
CORRADE_COMPARE(out.str(), "Vk::vkFormat(): unsupported format PixelFormat::RGB16UI\n"); |
||||
#endif |
||||
} |
||||
|
||||
void EnumsTest::mapVkFormatInvalid() { |
||||
std::ostringstream out; |
||||
Error redirectError{&out}; |
||||
|
||||
hasVkFormat(Magnum::PixelFormat(0x123)); |
||||
vkFormat(Magnum::PixelFormat(0x123)); |
||||
CORRADE_COMPARE(out.str(), |
||||
"Vk::hasVkFormat(): invalid format PixelFormat(0x123)\n" |
||||
"Vk::vkFormat(): invalid format PixelFormat(0x123)\n"); |
||||
} |
||||
|
||||
void EnumsTest::mapVkFormatCompressed() { |
||||
/* Touchstone verification */ |
||||
CORRADE_VERIFY(hasVkFormat(Magnum::CompressedPixelFormat::Bc1RGBAUnorm)); |
||||
CORRADE_COMPARE(vkFormat(Magnum::CompressedPixelFormat::Bc1RGBAUnorm), VK_FORMAT_BC1_RGBA_UNORM_BLOCK); |
||||
|
||||
/* 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 = 0; |
||||
for(UnsignedInt i = 0; i <= 0xffff; ++i) { |
||||
const auto format = Magnum::CompressedPixelFormat(i); |
||||
/* Each case verifies:
|
||||
- that the cases are ordered by number (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 */ |
||||
switch(format) { |
||||
#define _c(format, expectedFormat) \ |
||||
case Magnum::CompressedPixelFormat::format: \
|
||||
CORRADE_COMPARE(nextHandled, i); \
|
||||
CORRADE_COMPARE(firstUnhandled, 0xffff); \
|
||||
CORRADE_VERIFY(hasVkFormat(Magnum::CompressedPixelFormat::format)); \
|
||||
CORRADE_COMPARE(vkFormat(Magnum::CompressedPixelFormat::format), VK_FORMAT_ ## expectedFormat); \
|
||||
++nextHandled; \
|
||||
continue; |
||||
#define _s(format) \ |
||||
case Magnum::CompressedPixelFormat::format: \
|
||||
CORRADE_COMPARE(nextHandled, i); \
|
||||
CORRADE_COMPARE(firstUnhandled, 0xffff); \
|
||||
CORRADE_VERIFY(!hasVkFormat(Magnum::CompressedPixelFormat::format)); \
|
||||
vkFormat(Magnum::CompressedPixelFormat::format); \
|
||||
++nextHandled; \
|
||||
continue; |
||||
#include "Magnum/Vk/Implementation/compressedFormatMapping.hpp" |
||||
#undef _s |
||||
#undef _c |
||||
} |
||||
|
||||
/* 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 EnumsTest::mapVkFormatCompressedImplementationSpecific() { |
||||
CORRADE_VERIFY(hasVkFormat(Magnum::compressedPixelFormatWrap(VK_FORMAT_ASTC_10x6_UNORM_BLOCK))); |
||||
CORRADE_COMPARE(vkFormat(Magnum::compressedPixelFormatWrap(VK_FORMAT_ASTC_10x6_UNORM_BLOCK)), |
||||
VK_FORMAT_ASTC_10x6_UNORM_BLOCK); |
||||
} |
||||
|
||||
void EnumsTest::mapVkFormatCompressedUnsupported() { |
||||
#if 1 |
||||
CORRADE_SKIP("All compressed pixel formats are currently supported."); |
||||
#else |
||||
CORRADE_VERIFY(!hasVkFormat(Magnum::CompressedPixelFormat::Bc1RGBAUnorm)); |
||||
|
||||
std::ostringstream out; |
||||
Error redirectError{&out}; |
||||
vkFormat(Magnum::CompressedPixelFormat::Bc1RGBAUnorm); |
||||
CORRADE_COMPARE(out.str(), "Vk::vkFormat(): unsupported format CompressedPixelFormat::Bc1RGBAUnorm\n"); |
||||
#endif |
||||
} |
||||
|
||||
void EnumsTest::mapVkFormatCompressedInvalid() { |
||||
std::ostringstream out; |
||||
Error redirectError{&out}; |
||||
|
||||
hasVkFormat(Magnum::CompressedPixelFormat(0x123)); |
||||
vkFormat(Magnum::CompressedPixelFormat(0x123)); |
||||
CORRADE_COMPARE(out.str(), |
||||
"Vk::hasVkFormat(): invalid format CompressedPixelFormat(0x123)\n" |
||||
"Vk::vkFormat(): invalid format CompressedPixelFormat(0x123)\n"); |
||||
} |
||||
|
||||
void EnumsTest::mapVkFilter() { |
||||
CORRADE_COMPARE(vkFilter(SamplerFilter::Nearest), VK_FILTER_NEAREST); |
||||
CORRADE_COMPARE(vkFilter(SamplerFilter::Linear), VK_FILTER_LINEAR); |
||||
} |
||||
|
||||
void EnumsTest::mapVkFilterInvalid() { |
||||
std::ostringstream out; |
||||
Error redirectError{&out}; |
||||
|
||||
vkFilter(Magnum::SamplerFilter(0x123)); |
||||
CORRADE_COMPARE(out.str(), |
||||
"Vk::vkFilter(): invalid filter SamplerFilter(0x123)\n"); |
||||
} |
||||
|
||||
void EnumsTest::mapVkSamplerMipmapMode() { |
||||
CORRADE_COMPARE(vkSamplerMipmapMode(SamplerMipmap::Base), VK_SAMPLER_MIPMAP_MODE_NEAREST); /* deliberate */ |
||||
CORRADE_COMPARE(vkSamplerMipmapMode(SamplerMipmap::Nearest), VK_SAMPLER_MIPMAP_MODE_NEAREST); |
||||
CORRADE_COMPARE(vkSamplerMipmapMode(SamplerMipmap::Linear), VK_SAMPLER_MIPMAP_MODE_LINEAR); |
||||
} |
||||
|
||||
void EnumsTest::mapVkSamplerMipmapModeInvalid() { |
||||
std::ostringstream out; |
||||
Error redirectError{&out}; |
||||
|
||||
vkSamplerMipmapMode(Magnum::SamplerMipmap(0x123)); |
||||
CORRADE_COMPARE(out.str(), |
||||
"Vk::vkSamplerMipmapMode(): invalid mode SamplerMipmap(0x123)\n"); |
||||
} |
||||
|
||||
void EnumsTest::mapVkSamplerAddressMode() { |
||||
CORRADE_VERIFY(hasVkSamplerAddressMode(SamplerWrapping::Repeat)); |
||||
CORRADE_COMPARE(vkSamplerAddressMode(SamplerWrapping::Repeat), VK_SAMPLER_ADDRESS_MODE_REPEAT); |
||||
|
||||
CORRADE_VERIFY(hasVkSamplerAddressMode(SamplerWrapping::MirroredRepeat)); |
||||
CORRADE_COMPARE(vkSamplerAddressMode(SamplerWrapping::MirroredRepeat), VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT); |
||||
|
||||
CORRADE_VERIFY(hasVkSamplerAddressMode(SamplerWrapping::ClampToEdge)); |
||||
CORRADE_COMPARE(vkSamplerAddressMode(SamplerWrapping::ClampToEdge), VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE); |
||||
|
||||
CORRADE_VERIFY(hasVkSamplerAddressMode(SamplerWrapping::ClampToBorder)); |
||||
CORRADE_COMPARE(vkSamplerAddressMode(SamplerWrapping::ClampToBorder), VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER); |
||||
} |
||||
|
||||
void EnumsTest::mapVkSamplerAddressModeArray() { |
||||
CORRADE_COMPARE(vkSamplerAddressMode<2>({SamplerWrapping::Repeat, SamplerWrapping::ClampToBorder}), (Array2D<VkSamplerAddressMode>{VK_SAMPLER_ADDRESS_MODE_REPEAT, VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER})); |
||||
} |
||||
|
||||
void EnumsTest::mapVkSamplerAddressModeUnsupported() { |
||||
CORRADE_VERIFY(!hasVkSamplerAddressMode(Magnum::SamplerWrapping::MirrorClampToEdge)); |
||||
std::ostringstream out; |
||||
{ |
||||
Error redirectError{&out}; |
||||
vkSamplerAddressMode(Magnum::SamplerWrapping::MirrorClampToEdge); |
||||
} |
||||
CORRADE_COMPARE(out.str(), |
||||
"Vk::vkSamplerAddressMode(): unsupported wrapping SamplerWrapping::MirrorClampToEdge\n"); |
||||
} |
||||
|
||||
void EnumsTest::mapVkSamplerAddressModeInvalid() { |
||||
std::ostringstream out; |
||||
Error redirectError{&out}; |
||||
|
||||
vkSamplerAddressMode(Magnum::SamplerWrapping(0x123)); |
||||
CORRADE_COMPARE(out.str(), |
||||
"Vk::vkSamplerAddressMode(): invalid wrapping SamplerWrapping(0x123)\n"); |
||||
} |
||||
|
||||
}}} |
||||
|
||||
CORRADE_TEST_MAIN(Magnum::Vk::Test::EnumsTest) |
||||
Loading…
Reference in new issue