mirror of https://github.com/mosra/magnum.git
9 changed files with 519 additions and 3 deletions
@ -0,0 +1,83 @@ |
|||||||
|
/*
|
||||||
|
This file is part of Magnum. |
||||||
|
|
||||||
|
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, |
||||||
|
2020, 2021 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 "PipelineLayout.h" |
||||||
|
#include "PipelineLayoutCreateInfo.h" |
||||||
|
|
||||||
|
#include "Magnum/Vk/Assert.h" |
||||||
|
#include "Magnum/Vk/Device.h" |
||||||
|
#include "Magnum/Vk/Result.h" |
||||||
|
|
||||||
|
namespace Magnum { namespace Vk { |
||||||
|
|
||||||
|
PipelineLayoutCreateInfo::PipelineLayoutCreateInfo(): _info{} { |
||||||
|
_info.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
||||||
|
} |
||||||
|
|
||||||
|
PipelineLayoutCreateInfo::PipelineLayoutCreateInfo(NoInitT) noexcept {} |
||||||
|
|
||||||
|
PipelineLayoutCreateInfo::PipelineLayoutCreateInfo(const VkPipelineLayoutCreateInfo& info): |
||||||
|
/* Can't use {} with GCC 4.8 here because it tries to initialize the first
|
||||||
|
member instead of doing a copy */ |
||||||
|
_info(info) {} |
||||||
|
|
||||||
|
PipelineLayout PipelineLayout::wrap(Device& device, const VkPipelineLayout handle, const HandleFlags flags) { |
||||||
|
PipelineLayout out{NoCreate}; |
||||||
|
out._device = &device; |
||||||
|
out._handle = handle; |
||||||
|
out._flags = flags; |
||||||
|
return out; |
||||||
|
} |
||||||
|
|
||||||
|
PipelineLayout::PipelineLayout(Device& device, const PipelineLayoutCreateInfo& info): _device{&device}, _flags{HandleFlag::DestroyOnDestruction} { |
||||||
|
MAGNUM_VK_INTERNAL_ASSERT_SUCCESS(device->CreatePipelineLayout(device, info, nullptr, &_handle)); |
||||||
|
} |
||||||
|
|
||||||
|
PipelineLayout::PipelineLayout(NoCreateT): _device{}, _handle{} {} |
||||||
|
|
||||||
|
PipelineLayout::PipelineLayout(PipelineLayout&& other) noexcept: _device{other._device}, _handle{other._handle}, _flags{other._flags} { |
||||||
|
other._handle = {}; |
||||||
|
} |
||||||
|
|
||||||
|
PipelineLayout::~PipelineLayout() { |
||||||
|
if(_handle && (_flags & HandleFlag::DestroyOnDestruction)) |
||||||
|
(**_device).DestroyPipelineLayout(*_device, _handle, nullptr); |
||||||
|
} |
||||||
|
|
||||||
|
PipelineLayout& PipelineLayout::operator=(PipelineLayout&& other) noexcept { |
||||||
|
using std::swap; |
||||||
|
swap(other._device, _device); |
||||||
|
swap(other._handle, _handle); |
||||||
|
swap(other._flags, _flags); |
||||||
|
return *this; |
||||||
|
} |
||||||
|
|
||||||
|
VkPipelineLayout PipelineLayout::release() { |
||||||
|
const VkPipelineLayout handle = _handle; |
||||||
|
_handle = {}; |
||||||
|
return handle; |
||||||
|
} |
||||||
|
|
||||||
|
}} |
||||||
@ -0,0 +1,134 @@ |
|||||||
|
#ifndef Magnum_Vk_PipelineLayout_h |
||||||
|
#define Magnum_Vk_PipelineLayout_h |
||||||
|
/*
|
||||||
|
This file is part of Magnum. |
||||||
|
|
||||||
|
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, |
||||||
|
2020, 2021 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 Class @ref Magnum::Vk::PipelineLayout |
||||||
|
* @m_since_latest |
||||||
|
*/ |
||||||
|
|
||||||
|
#include "Magnum/Magnum.h" |
||||||
|
#include "Magnum/Tags.h" |
||||||
|
#include "Magnum/Vk/Handle.h" |
||||||
|
#include "Magnum/Vk/Vk.h" |
||||||
|
#include "Magnum/Vk/Vulkan.h" |
||||||
|
#include "Magnum/Vk/visibility.h" |
||||||
|
|
||||||
|
namespace Magnum { namespace Vk { |
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Pipeline layout |
||||||
|
@m_since_latest |
||||||
|
|
||||||
|
Wraps a @type_vk_keyword{PipelineLayout}. |
||||||
|
*/ |
||||||
|
class MAGNUM_VK_EXPORT PipelineLayout { |
||||||
|
public: |
||||||
|
/**
|
||||||
|
* @brief Wrap existing Vulkan handle |
||||||
|
* @param device Vulkan device the pipeline layout is |
||||||
|
* created on |
||||||
|
* @param handle The @type_vk{PipelineLayout} handle |
||||||
|
* @param flags Handle flags |
||||||
|
* |
||||||
|
* The @p handle is expected to be originating from @p device. Unlike |
||||||
|
* a pipeline layout created using a constructor, the Vulkan pipeline |
||||||
|
* layout is by default not deleted on destruction, use @p flags for |
||||||
|
* different behavior. |
||||||
|
* @see @ref release() |
||||||
|
*/ |
||||||
|
static PipelineLayout wrap(Device& device, VkPipelineLayout handle, HandleFlags flags = {}); |
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Constructor |
||||||
|
* @param device Vulkan device to create the pipeline layout on |
||||||
|
* @param info Pipeline layout creation info |
||||||
|
* |
||||||
|
* @see @fn_vk_keyword{CreatePipelineLayout} |
||||||
|
*/ |
||||||
|
explicit PipelineLayout(Device& device, const PipelineLayoutCreateInfo& info); |
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Construct without creating the pipeline layout |
||||||
|
* |
||||||
|
* The constructed instance is equivalent to moved-from state. Useful |
||||||
|
* in cases where you will overwrite the instance later anyway. Move |
||||||
|
* another object over it to make it useful. |
||||||
|
*/ |
||||||
|
explicit PipelineLayout(NoCreateT); |
||||||
|
|
||||||
|
/** @brief Copying is not allowed */ |
||||||
|
PipelineLayout(const PipelineLayout&) = delete; |
||||||
|
|
||||||
|
/** @brief Move constructor */ |
||||||
|
PipelineLayout(PipelineLayout&& other) noexcept; |
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Destructor |
||||||
|
* |
||||||
|
* Destroys associated @type_vk{PipelineLayout} handle, unless the |
||||||
|
* instance was created using @ref wrap() without |
||||||
|
* @ref HandleFlag::DestroyOnDestruction specified. |
||||||
|
* @see @fn_vk_keyword{DestroyPipelineLayout}, @ref release() |
||||||
|
*/ |
||||||
|
~PipelineLayout(); |
||||||
|
|
||||||
|
/** @brief Copying is not allowed */ |
||||||
|
PipelineLayout& operator=(const PipelineLayout&) = delete; |
||||||
|
|
||||||
|
/** @brief Move assignment */ |
||||||
|
PipelineLayout& operator=(PipelineLayout&& other) noexcept; |
||||||
|
|
||||||
|
/** @brief Underlying @type_vk{PipelineLayout} handle */ |
||||||
|
VkPipelineLayout handle() { return _handle; } |
||||||
|
/** @overload */ |
||||||
|
operator VkPipelineLayout() { return _handle; } |
||||||
|
|
||||||
|
/** @brief Handle flags */ |
||||||
|
HandleFlags handleFlags() const { return _flags; } |
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Release the underlying Vulkan pipeline layout |
||||||
|
* |
||||||
|
* Releases ownership of the Vulkan pipeline layout and returns its |
||||||
|
* handle so @fn_vk{DestroyPipelineLayout} is not called on |
||||||
|
* destruction. The internal state is then equivalent to moved-from |
||||||
|
* state. |
||||||
|
* @see @ref wrap() |
||||||
|
*/ |
||||||
|
VkPipelineLayout release(); |
||||||
|
|
||||||
|
private: |
||||||
|
/* Can't be a reference because of the NoCreate constructor */ |
||||||
|
Device* _device; |
||||||
|
|
||||||
|
VkPipelineLayout _handle; |
||||||
|
HandleFlags _flags; |
||||||
|
}; |
||||||
|
|
||||||
|
}} |
||||||
|
|
||||||
|
#endif |
||||||
@ -0,0 +1,96 @@ |
|||||||
|
#ifndef Magnum_Vk_PipelineLayoutCreateInfo_h |
||||||
|
#define Magnum_Vk_PipelineLayoutCreateInfo_h |
||||||
|
/*
|
||||||
|
This file is part of Magnum. |
||||||
|
|
||||||
|
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, |
||||||
|
2020, 2021 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 Class @ref Magnum::Vk::PipelineLayoutCreateInfo |
||||||
|
* @m_since_latest |
||||||
|
*/ |
||||||
|
|
||||||
|
#include "Magnum/Tags.h" |
||||||
|
#include "Magnum/Vk/Vk.h" |
||||||
|
#include "Magnum/Vk/Vulkan.h" |
||||||
|
#include "Magnum/Vk/visibility.h" |
||||||
|
|
||||||
|
namespace Magnum { namespace Vk { |
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Pipeline layout creation info |
||||||
|
@m_since_latest |
||||||
|
|
||||||
|
Wraps a @type_vk_keyword{PipelineLayoutCreateInfo}. |
||||||
|
*/ |
||||||
|
class MAGNUM_VK_EXPORT PipelineLayoutCreateInfo { |
||||||
|
public: |
||||||
|
/**
|
||||||
|
* @brief Constructor |
||||||
|
* |
||||||
|
* The following @type_vk{PipelineLayoutCreateInfo} fields are |
||||||
|
* pre-filled in addition to `sType`, everything else is zero-filled: |
||||||
|
* |
||||||
|
* - <em>(none)</em> |
||||||
|
*/ |
||||||
|
explicit PipelineLayoutCreateInfo(); |
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Construct without initializing the contents |
||||||
|
* |
||||||
|
* Note that not even the `sType` field is set --- the structure has to |
||||||
|
* be fully initialized afterwards in order to be usable. |
||||||
|
*/ |
||||||
|
explicit PipelineLayoutCreateInfo(NoInitT) noexcept; |
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Construct from existing data |
||||||
|
* |
||||||
|
* Copies the existing values verbatim, pointers are kept unchanged |
||||||
|
* without taking over the ownership. Modifying the newly created |
||||||
|
* instance will not modify the original data nor the pointed-to data. |
||||||
|
*/ |
||||||
|
explicit PipelineLayoutCreateInfo(const VkPipelineLayoutCreateInfo& info); |
||||||
|
|
||||||
|
/** @brief Underlying @type_vk{PipelineLayoutCreateInfo} structure */ |
||||||
|
VkPipelineLayoutCreateInfo& operator*() { return _info; } |
||||||
|
/** @overload */ |
||||||
|
const VkPipelineLayoutCreateInfo& operator*() const { return _info; } |
||||||
|
/** @overload */ |
||||||
|
VkPipelineLayoutCreateInfo* operator->() { return &_info; } |
||||||
|
/** @overload */ |
||||||
|
const VkPipelineLayoutCreateInfo* operator->() const { return &_info; } |
||||||
|
/** @overload */ |
||||||
|
operator const VkPipelineLayoutCreateInfo*() const { return &_info; } |
||||||
|
|
||||||
|
private: |
||||||
|
VkPipelineLayoutCreateInfo _info; |
||||||
|
}; |
||||||
|
|
||||||
|
}} |
||||||
|
|
||||||
|
/* Make the definition complete -- it doesn't make sense to have a CreateInfo
|
||||||
|
without the corresponding object anyway. */ |
||||||
|
#include "Magnum/Vk/PipelineLayout.h" |
||||||
|
|
||||||
|
#endif |
||||||
@ -0,0 +1,96 @@ |
|||||||
|
/*
|
||||||
|
This file is part of Magnum. |
||||||
|
|
||||||
|
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, |
||||||
|
2020, 2021 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 <new> |
||||||
|
#include <Corrade/TestSuite/Tester.h> |
||||||
|
|
||||||
|
#include "Magnum/Vk/PipelineLayoutCreateInfo.h" |
||||||
|
|
||||||
|
namespace Magnum { namespace Vk { namespace Test { namespace { |
||||||
|
|
||||||
|
struct PipelineLayoutTest: TestSuite::Tester { |
||||||
|
explicit PipelineLayoutTest(); |
||||||
|
|
||||||
|
void createInfoConstruct(); |
||||||
|
void createInfoConstructNoInit(); |
||||||
|
void createInfoConstructFromVk(); |
||||||
|
|
||||||
|
void constructNoCreate(); |
||||||
|
void constructCopy(); |
||||||
|
}; |
||||||
|
|
||||||
|
PipelineLayoutTest::PipelineLayoutTest() { |
||||||
|
addTests({&PipelineLayoutTest::createInfoConstruct, |
||||||
|
&PipelineLayoutTest::createInfoConstructNoInit, |
||||||
|
&PipelineLayoutTest::createInfoConstructFromVk, |
||||||
|
|
||||||
|
&PipelineLayoutTest::constructNoCreate, |
||||||
|
&PipelineLayoutTest::constructCopy}); |
||||||
|
} |
||||||
|
|
||||||
|
void PipelineLayoutTest::createInfoConstruct() { |
||||||
|
PipelineLayoutCreateInfo info; |
||||||
|
/** @todo expand once there's actually something */ |
||||||
|
CORRADE_COMPARE(info->flags, 0); |
||||||
|
} |
||||||
|
|
||||||
|
void PipelineLayoutTest::createInfoConstructNoInit() { |
||||||
|
PipelineLayoutCreateInfo info{NoInit}; |
||||||
|
info->sType = VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2; |
||||||
|
new(&info) PipelineLayoutCreateInfo{NoInit}; |
||||||
|
CORRADE_COMPARE(info->sType, VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2); |
||||||
|
|
||||||
|
CORRADE_VERIFY((std::is_nothrow_constructible<PipelineLayoutCreateInfo, NoInitT>::value)); |
||||||
|
|
||||||
|
/* Implicit construction is not allowed */ |
||||||
|
CORRADE_VERIFY(!(std::is_convertible<NoInitT, PipelineLayoutCreateInfo>::value)); |
||||||
|
} |
||||||
|
|
||||||
|
void PipelineLayoutTest::createInfoConstructFromVk() { |
||||||
|
VkPipelineLayoutCreateInfo vkInfo; |
||||||
|
vkInfo.sType = VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2; |
||||||
|
|
||||||
|
PipelineLayoutCreateInfo info{vkInfo}; |
||||||
|
CORRADE_COMPARE(info->sType, VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2); |
||||||
|
} |
||||||
|
|
||||||
|
void PipelineLayoutTest::constructNoCreate() { |
||||||
|
{ |
||||||
|
PipelineLayout layout{NoCreate}; |
||||||
|
CORRADE_VERIFY(!layout.handle()); |
||||||
|
} |
||||||
|
|
||||||
|
/* Implicit construction is not allowed */ |
||||||
|
CORRADE_VERIFY(!(std::is_convertible<NoCreateT, PipelineLayout>::value)); |
||||||
|
} |
||||||
|
|
||||||
|
void PipelineLayoutTest::constructCopy() { |
||||||
|
CORRADE_VERIFY(!std::is_copy_constructible<PipelineLayout>{}); |
||||||
|
CORRADE_VERIFY(!std::is_copy_assignable<PipelineLayout>{}); |
||||||
|
} |
||||||
|
|
||||||
|
}}}} |
||||||
|
|
||||||
|
CORRADE_TEST_MAIN(Magnum::Vk::Test::PipelineLayoutTest) |
||||||
@ -0,0 +1,98 @@ |
|||||||
|
/*
|
||||||
|
This file is part of Magnum. |
||||||
|
|
||||||
|
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, |
||||||
|
2020, 2021 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 <Corrade/Containers/Reference.h> |
||||||
|
|
||||||
|
#include "Magnum/Vk/PipelineLayoutCreateInfo.h" |
||||||
|
#include "Magnum/Vk/Result.h" |
||||||
|
#include "Magnum/Vk/VulkanTester.h" |
||||||
|
|
||||||
|
namespace Magnum { namespace Vk { namespace Test { namespace { |
||||||
|
|
||||||
|
struct PipelineLayoutVkTest: VulkanTester { |
||||||
|
explicit PipelineLayoutVkTest(); |
||||||
|
|
||||||
|
void construct(); |
||||||
|
void constructMove(); |
||||||
|
|
||||||
|
void wrap(); |
||||||
|
}; |
||||||
|
|
||||||
|
PipelineLayoutVkTest::PipelineLayoutVkTest() { |
||||||
|
addTests({&PipelineLayoutVkTest::construct, |
||||||
|
&PipelineLayoutVkTest::constructMove, |
||||||
|
|
||||||
|
&PipelineLayoutVkTest::wrap}); |
||||||
|
} |
||||||
|
|
||||||
|
void PipelineLayoutVkTest::construct() { |
||||||
|
{ |
||||||
|
PipelineLayout layout{device(), PipelineLayoutCreateInfo{}}; |
||||||
|
CORRADE_VERIFY(layout.handle()); |
||||||
|
CORRADE_COMPARE(layout.handleFlags(), HandleFlag::DestroyOnDestruction); |
||||||
|
} |
||||||
|
|
||||||
|
/* Shouldn't crash or anything */ |
||||||
|
CORRADE_VERIFY(true); |
||||||
|
} |
||||||
|
|
||||||
|
void PipelineLayoutVkTest::constructMove() { |
||||||
|
PipelineLayout a{device(), PipelineLayoutCreateInfo{}}; |
||||||
|
VkPipelineLayout handle = a.handle(); |
||||||
|
|
||||||
|
PipelineLayout b = std::move(a); |
||||||
|
CORRADE_VERIFY(!a.handle()); |
||||||
|
CORRADE_COMPARE(b.handle(), handle); |
||||||
|
CORRADE_COMPARE(b.handleFlags(), HandleFlag::DestroyOnDestruction); |
||||||
|
|
||||||
|
PipelineLayout c{NoCreate}; |
||||||
|
c = std::move(b); |
||||||
|
CORRADE_VERIFY(!b.handle()); |
||||||
|
CORRADE_COMPARE(b.handleFlags(), HandleFlags{}); |
||||||
|
CORRADE_COMPARE(c.handle(), handle); |
||||||
|
CORRADE_COMPARE(c.handleFlags(), HandleFlag::DestroyOnDestruction); |
||||||
|
|
||||||
|
CORRADE_VERIFY(std::is_nothrow_move_constructible<PipelineLayout>::value); |
||||||
|
CORRADE_VERIFY(std::is_nothrow_move_assignable<PipelineLayout>::value); |
||||||
|
} |
||||||
|
|
||||||
|
void PipelineLayoutVkTest::wrap() { |
||||||
|
VkPipelineLayout layout{}; |
||||||
|
CORRADE_COMPARE(Result(device()->CreatePipelineLayout(device(), |
||||||
|
PipelineLayoutCreateInfo{}, |
||||||
|
nullptr, &layout)), Result::Success); |
||||||
|
|
||||||
|
auto wrapped = PipelineLayout::wrap(device(), layout, HandleFlag::DestroyOnDestruction); |
||||||
|
CORRADE_COMPARE(wrapped.handle(), layout); |
||||||
|
|
||||||
|
/* Release the handle again, destroy by hand */ |
||||||
|
CORRADE_COMPARE(wrapped.release(), layout); |
||||||
|
CORRADE_VERIFY(!wrapped.handle()); |
||||||
|
device()->DestroyPipelineLayout(device(), layout, nullptr); |
||||||
|
} |
||||||
|
|
||||||
|
}}}} |
||||||
|
|
||||||
|
CORRADE_TEST_MAIN(Magnum::Vk::Test::PipelineLayoutVkTest) |
||||||
Loading…
Reference in new issue