Browse Source

Vk: de-inline Queue members and test them.

For consistency with other classes and to prepare for future extension.
Interesting that I didn't even create a test file for this class yet.
pull/494/head
Vladimír Vondruš 5 years ago
parent
commit
84bdb8076d
  1. 1
      src/Magnum/Vk/CMakeLists.txt
  2. 42
      src/Magnum/Vk/Queue.cpp
  3. 9
      src/Magnum/Vk/Queue.h
  4. 2
      src/Magnum/Vk/Test/CMakeLists.txt
  5. 70
      src/Magnum/Vk/Test/QueueTest.cpp

1
src/Magnum/Vk/CMakeLists.txt

@ -34,6 +34,7 @@ set(MagnumVk_SRCS
Framebuffer.cpp Framebuffer.cpp
Handle.cpp Handle.cpp
Instance.cpp Instance.cpp
Queue.cpp
Result.cpp Result.cpp
Shader.cpp Shader.cpp
Version.cpp Version.cpp

42
src/Magnum/Vk/Queue.cpp

@ -0,0 +1,42 @@
/*
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 "Queue.h"
#include <Corrade/Containers/Array.h>
#include <Corrade/Utility/Algorithms.h>
namespace Magnum { namespace Vk {
Queue Queue::wrap(Device& device, VkQueue handle) {
Queue out{NoCreate};
out._device = &device;
out._handle = handle;
return out;
}
Queue::Queue(NoCreateT): _device{}, _handle{} {}
}}

9
src/Magnum/Vk/Queue.h

@ -57,12 +57,7 @@ class MAGNUM_VK_EXPORT Queue {
* be destroyed at the end, so there's no equivalent of e.g. * be destroyed at the end, so there's no equivalent of e.g.
* @ref Device::release() or @ref Device::handleFlags(). * @ref Device::release() or @ref Device::handleFlags().
*/ */
static Queue wrap(Device& device, VkQueue handle) { static Queue wrap(Device& device, VkQueue handle);
Queue out{NoCreate};
out._device = &device;
out._handle = handle;
return out;
}
/** /**
* @brief Construct without creating the instance * @brief Construct without creating the instance
@ -70,7 +65,7 @@ class MAGNUM_VK_EXPORT Queue {
* This is the expected way to create a queue that's later populated * This is the expected way to create a queue that's later populated
* on @ref Device creation through @ref DeviceCreateInfo::addQueues(). * on @ref Device creation through @ref DeviceCreateInfo::addQueues().
*/ */
explicit Queue(NoCreateT): _device{}, _handle{} {} explicit Queue(NoCreateT);
/** @brief Underlying @type_vk{Queue} handle */ /** @brief Underlying @type_vk{Queue} handle */
VkQueue handle() { return _handle; } VkQueue handle() { return _handle; }

2
src/Magnum/Vk/Test/CMakeLists.txt

@ -42,6 +42,7 @@ corrade_add_test(VkInstanceTest InstanceTest.cpp LIBRARIES MagnumVk)
corrade_add_test(VkIntegrationTest IntegrationTest.cpp LIBRARIES MagnumVk) corrade_add_test(VkIntegrationTest IntegrationTest.cpp LIBRARIES MagnumVk)
corrade_add_test(VkLayerPropertiesTest LayerPropertiesTest.cpp LIBRARIES MagnumVk) corrade_add_test(VkLayerPropertiesTest LayerPropertiesTest.cpp LIBRARIES MagnumVk)
corrade_add_test(VkMemoryTest MemoryTest.cpp LIBRARIES MagnumVkTestLib) corrade_add_test(VkMemoryTest MemoryTest.cpp LIBRARIES MagnumVkTestLib)
corrade_add_test(VkQueueTest QueueTest.cpp LIBRARIES MagnumVk)
corrade_add_test(VkResultTest ResultTest.cpp LIBRARIES MagnumVk) corrade_add_test(VkResultTest ResultTest.cpp LIBRARIES MagnumVk)
corrade_add_test(VkRenderPassTest RenderPassTest.cpp LIBRARIES MagnumVkTestLib) corrade_add_test(VkRenderPassTest RenderPassTest.cpp LIBRARIES MagnumVkTestLib)
corrade_add_test(VkShaderTest ShaderTest.cpp LIBRARIES MagnumVk) corrade_add_test(VkShaderTest ShaderTest.cpp LIBRARIES MagnumVk)
@ -133,6 +134,7 @@ set_target_properties(
VkIntegrationTest VkIntegrationTest
VkLayerPropertiesTest VkLayerPropertiesTest
VkMemoryTest VkMemoryTest
VkQueueTest
VkResultTest VkResultTest
VkRenderPassTest VkRenderPassTest
VkShaderTest VkShaderTest

70
src/Magnum/Vk/Test/QueueTest.cpp

@ -0,0 +1,70 @@
/*
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 <Corrade/TestSuite/Tester.h>
#include "Magnum/Vk/Device.h"
#include "Magnum/Vk/Queue.h"
namespace Magnum { namespace Vk { namespace Test { namespace {
struct QueueTest: TestSuite::Tester {
explicit QueueTest();
void constructNoCreate();
void wrap();
};
QueueTest::QueueTest() {
addTests({&QueueTest::constructNoCreate,
&QueueTest::wrap});
}
void QueueTest::constructNoCreate() {
{
Queue queue{NoCreate};
CORRADE_VERIFY(!queue.handle());
}
/* Implicit construction is not allowed */
CORRADE_VERIFY(!(std::is_convertible<NoCreateT, Queue>::value));
}
void QueueTest::wrap() {
/* Queues are not getting destroyed in any way, so it's enough to do it in
a non-Vulkan-enabled test */
Device device{NoCreate};
auto vkQueue = reinterpret_cast<VkQueue>(0xbadcafe);
Queue queue = Queue::wrap(device, vkQueue);
CORRADE_COMPARE(queue.handle(), vkQueue);
}
}}}}
CORRADE_TEST_MAIN(Magnum::Vk::Test::QueueTest)
Loading…
Cancel
Save