From c402c973078221151751a17de4e9d101087bebfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 14 Nov 2020 20:16:46 +0100 Subject: [PATCH] Vk: and thus VulkanTester doesn't need a DeviceProperties instance. --- src/Magnum/Vk/Test/CommandBufferVkTest.cpp | 8 +++---- src/Magnum/Vk/Test/CommandPoolVkTest.cpp | 10 ++++---- src/Magnum/Vk/Test/ImageVkTest.cpp | 6 ++--- src/Magnum/Vk/Test/MemoryVkTest.cpp | 6 ++--- src/Magnum/Vk/VulkanTester.cpp | 9 ++++---- src/Magnum/Vk/VulkanTester.h | 27 ++++++---------------- 6 files changed, 27 insertions(+), 39 deletions(-) diff --git a/src/Magnum/Vk/Test/CommandBufferVkTest.cpp b/src/Magnum/Vk/Test/CommandBufferVkTest.cpp index 623f950a9..024461c26 100644 --- a/src/Magnum/Vk/Test/CommandBufferVkTest.cpp +++ b/src/Magnum/Vk/Test/CommandBufferVkTest.cpp @@ -52,7 +52,7 @@ CommandBufferVkTest::CommandBufferVkTest() { void CommandBufferVkTest::construct() { CommandPool pool{device(), CommandPoolCreateInfo{ - deviceProperties().pickQueueFamily(QueueFlag::Graphics)}}; + device().properties().pickQueueFamily(QueueFlag::Graphics)}}; { CommandBuffer buffer = pool.allocate(); @@ -66,7 +66,7 @@ void CommandBufferVkTest::construct() { void CommandBufferVkTest::constructMove() { CommandPool pool{device(), CommandPoolCreateInfo{ - deviceProperties().pickQueueFamily(QueueFlag::Graphics)}}; + device().properties().pickQueueFamily(QueueFlag::Graphics)}}; CommandBuffer a = pool.allocate(); VkCommandBuffer handle = a.handle(); @@ -89,7 +89,7 @@ void CommandBufferVkTest::constructMove() { void CommandBufferVkTest::wrap() { CommandPool pool{device(), CommandPoolCreateInfo{ - deviceProperties().pickQueueFamily(QueueFlag::Graphics)}}; + device().properties().pickQueueFamily(QueueFlag::Graphics)}}; VkCommandBuffer buffer{}; VkCommandBufferAllocateInfo info{}; @@ -111,7 +111,7 @@ void CommandBufferVkTest::wrap() { void CommandBufferVkTest::reset() { CommandPool pool{device(), CommandPoolCreateInfo{ - deviceProperties().pickQueueFamily(QueueFlag::Graphics), + device().properties().pickQueueFamily(QueueFlag::Graphics), CommandPoolCreateInfo::Flag::ResetCommandBuffer}}; CommandBuffer a = pool.allocate(); diff --git a/src/Magnum/Vk/Test/CommandPoolVkTest.cpp b/src/Magnum/Vk/Test/CommandPoolVkTest.cpp index be8c36eaf..a4fd4ea99 100644 --- a/src/Magnum/Vk/Test/CommandPoolVkTest.cpp +++ b/src/Magnum/Vk/Test/CommandPoolVkTest.cpp @@ -55,7 +55,7 @@ CommandPoolVkTest::CommandPoolVkTest() { void CommandPoolVkTest::construct() { { CommandPool pool{device(), CommandPoolCreateInfo{ - deviceProperties().pickQueueFamily(QueueFlag::Graphics), + device().properties().pickQueueFamily(QueueFlag::Graphics), CommandPoolCreateInfo::Flag::ResetCommandBuffer}}; CORRADE_VERIFY(pool.handle()); CORRADE_COMPARE(pool.handleFlags(), HandleFlag::DestroyOnDestruction); @@ -67,7 +67,7 @@ void CommandPoolVkTest::construct() { void CommandPoolVkTest::constructMove() { CommandPool a{device(), CommandPoolCreateInfo{ - deviceProperties().pickQueueFamily(QueueFlag::Graphics), + device().properties().pickQueueFamily(QueueFlag::Graphics), CommandPoolCreateInfo::Flag::Transient}}; VkCommandPool handle = a.handle(); @@ -91,7 +91,7 @@ void CommandPoolVkTest::wrap() { VkCommandPool pool{}; CORRADE_COMPARE(Result(device()->CreateCommandPool(device(), CommandPoolCreateInfo{ - deviceProperties().pickQueueFamily(QueueFlag::Graphics)}, + device().properties().pickQueueFamily(QueueFlag::Graphics)}, nullptr, &pool)), Result::Success); CORRADE_VERIFY(pool); @@ -106,7 +106,7 @@ void CommandPoolVkTest::wrap() { void CommandPoolVkTest::reset() { CommandPool pool{device(), CommandPoolCreateInfo{ - deviceProperties().pickQueueFamily(QueueFlag::Graphics)}}; + device().properties().pickQueueFamily(QueueFlag::Graphics)}}; pool.reset(CommandPoolResetFlag::ReleaseResources); @@ -116,7 +116,7 @@ void CommandPoolVkTest::reset() { void CommandPoolVkTest::allocate() { CommandPool pool{device(), CommandPoolCreateInfo{ - deviceProperties().pickQueueFamily(QueueFlag::Graphics)}}; + device().properties().pickQueueFamily(QueueFlag::Graphics)}}; CommandBuffer a = pool.allocate(CommandBufferLevel::Secondary); CORRADE_VERIFY(a.handle()); diff --git a/src/Magnum/Vk/Test/ImageVkTest.cpp b/src/Magnum/Vk/Test/ImageVkTest.cpp index c92c8b92f..db840a707 100644 --- a/src/Magnum/Vk/Test/ImageVkTest.cpp +++ b/src/Magnum/Vk/Test/ImageVkTest.cpp @@ -164,7 +164,7 @@ void ImageVkTest::constructMove() { /* Verify that also the dedicated memory gets moved */ MemoryRequirements requirements = a.memoryRequirements(); a.bindDedicatedMemory(Vk::Memory{device(), Vk::MemoryAllocateInfo{requirements.size(), - deviceProperties().pickMemory(Vk::MemoryFlag::DeviceLocal, requirements.memories())}}); + device().properties().pickMemory(Vk::MemoryFlag::DeviceLocal, requirements.memories())}}); VkDeviceMemory memoryHandle = a.dedicatedMemory().handle(); Image b = std::move(a); @@ -230,7 +230,7 @@ void ImageVkTest::bindMemory() { Vk::Memory memory{device(), Vk::MemoryAllocateInfo{ requirements.size() + offset, - deviceProperties().pickMemory(Vk::MemoryFlag::DeviceLocal, requirements.memories())}}; + device().properties().pickMemory(Vk::MemoryFlag::DeviceLocal, requirements.memories())}}; image.bindMemory(memory, offset); CORRADE_VERIFY(!image.hasDedicatedMemory()); @@ -245,7 +245,7 @@ void ImageVkTest::bindDedicatedMemory() { Vk::Memory memory{device(), Vk::MemoryAllocateInfo{ requirements.size(), - deviceProperties().pickMemory(Vk::MemoryFlag::DeviceLocal, requirements.memories())}}; + device().properties().pickMemory(Vk::MemoryFlag::DeviceLocal, requirements.memories())}}; VkDeviceMemory handle = memory.handle(); CORRADE_VERIFY(handle); diff --git a/src/Magnum/Vk/Test/MemoryVkTest.cpp b/src/Magnum/Vk/Test/MemoryVkTest.cpp index 16ac06f12..12e554873 100644 --- a/src/Magnum/Vk/Test/MemoryVkTest.cpp +++ b/src/Magnum/Vk/Test/MemoryVkTest.cpp @@ -48,13 +48,13 @@ MemoryVkTest::MemoryVkTest() { } void MemoryVkTest::construct() { - Memory memory{device(), MemoryAllocateInfo{1024*1024, deviceProperties().pickMemory(MemoryFlag::DeviceLocal)}}; + Memory memory{device(), MemoryAllocateInfo{1024*1024, device().properties().pickMemory(MemoryFlag::DeviceLocal)}}; CORRADE_VERIFY(memory.handle()); CORRADE_COMPARE(memory.handleFlags(), HandleFlag::DestroyOnDestruction); } void MemoryVkTest::constructMove() { - Memory a{device(), MemoryAllocateInfo{1024*1024, deviceProperties().pickMemory(MemoryFlag::DeviceLocal)}}; + Memory a{device(), MemoryAllocateInfo{1024*1024, device().properties().pickMemory(MemoryFlag::DeviceLocal)}}; VkDeviceMemory handle = a.handle(); Memory b = std::move(a); @@ -76,7 +76,7 @@ void MemoryVkTest::constructMove() { void MemoryVkTest::wrap() { VkDeviceMemory memory{}; CORRADE_COMPARE(Result(device()->AllocateMemory(device(), - MemoryAllocateInfo{1024*1024, deviceProperties().pickMemory(MemoryFlag::DeviceLocal)}, + MemoryAllocateInfo{1024*1024, device().properties().pickMemory(MemoryFlag::DeviceLocal)}, nullptr, &memory)), Result::Success); CORRADE_VERIFY(memory); diff --git a/src/Magnum/Vk/VulkanTester.cpp b/src/Magnum/Vk/VulkanTester.cpp index b1e5eb078..dc28df383 100644 --- a/src/Magnum/Vk/VulkanTester.cpp +++ b/src/Magnum/Vk/VulkanTester.cpp @@ -33,9 +33,10 @@ namespace Magnum { namespace Vk { VulkanTester::VulkanTester(): VulkanTester{NoCreate} { - *_deviceProperties = pickDevice(_instance); - _device = Vk::Device{_instance, Vk::DeviceCreateInfo{*_deviceProperties} - .addQueues(_deviceProperties->pickQueueFamily(Vk::QueueFlag::Graphics), {0.0f}, {_queue}) + DeviceProperties deviceProperties = pickDevice(_instance); + UnsignedInt graphicsQueue = deviceProperties.pickQueueFamily(Vk::QueueFlag::Graphics); + _device = Vk::Device{_instance, Vk::DeviceCreateInfo{std::move(deviceProperties)} + .addQueues(graphicsQueue, {0.0f}, {_queue}) }; } @@ -45,6 +46,6 @@ VulkanTester::VulkanTester(NoCreateT): VulkanTester{NoCreate, NoCreate} { }; } -VulkanTester::VulkanTester(NoCreateT, NoCreateT): TestSuite::Tester{TestSuite::Tester::TesterConfiguration{}.setSkippedArgumentPrefixes({"magnum"})}, _instance{NoCreate}, _device{NoCreate}, _deviceProperties{Containers::InPlaceInit, NoCreate}, _queue{NoCreate} {} +VulkanTester::VulkanTester(NoCreateT, NoCreateT): TestSuite::Tester{TestSuite::Tester::TesterConfiguration{}.setSkippedArgumentPrefixes({"magnum"})}, _instance{NoCreate}, _device{NoCreate}, _queue{NoCreate} {} }} diff --git a/src/Magnum/Vk/VulkanTester.h b/src/Magnum/Vk/VulkanTester.h index 104ae9864..7fc37cb23 100644 --- a/src/Magnum/Vk/VulkanTester.h +++ b/src/Magnum/Vk/VulkanTester.h @@ -77,8 +77,7 @@ See @ref building, @ref cmake and @ref testsuite for more information. The class implicitly creates a Vulkan @ref Instance and @ref Device with default layers and extensions and one graphics queue. These are then available -through @ref instance(), @ref device(), @ref deviceProperties() and -@ref queue() getters. +through @ref instance(), @ref device() and @ref queue() getters. If you want to create a custom device, use the @ref VulkanTester(NoCreateT) constructor. You can then move the device and queue instances to the getters to @@ -93,8 +92,7 @@ class VulkanTester: public TestSuite::Tester { * * Creates an instance using implicit settings, picks a default device * and creates a graphics queue on that device. These are then exposed - * through @ref instance(), @ref device(), @ref deviceProperties() and - * @ref queue() getters. + * through @ref instance(), @ref device() and @ref queue() getters. */ explicit VulkanTester(); @@ -102,8 +100,8 @@ class VulkanTester: public TestSuite::Tester { * @brief Construct without creating a device * * Use the @ref instance() to pick and create a device. You can then - * move it to @ref device(), @ref deviceProperties() and @ref queue() - * to have them accessible through common interfaces again. + * move it to @ref device() and @ref queue() to have them accessible + * through common interfaces again. */ explicit VulkanTester(NoCreateT); @@ -111,8 +109,8 @@ class VulkanTester: public TestSuite::Tester { * @brief Construct without creating an instance or device * * Leaves the initialization completely on the user. You can move the - * instances to @ref instance(), @ref device(), @ref deviceProperties() - * and @ref queue() to have them accessible through common interfaces. + * instances to @ref instance(), @ref device() and @ref queue() to have + * them accessible through common interfaces. */ explicit VulkanTester(NoCreateT, NoCreateT); @@ -136,22 +134,12 @@ class VulkanTester: public TestSuite::Tester { */ Device& device() { return _device; } - /** - * @brief Vulkan device properties - * - * In case the class was constructed using @ref VulkanTester(NoCreateT) - * or @ref VulkanTester(NoCreateT, NoCreateT), this instance is - * initially not created. Move a created instance onto it to make it - * useful. - */ - DeviceProperties& deviceProperties() { return *_deviceProperties; } - /** * @brief Vulkan queue * * In case the calss was constructed using @ref VulkanTester(), the * queue corresponds to @ref DeviceProperties::pickQueueFamily() with - * @ref QueueFlag::Graphics called on @ref deviceProperties(). + * @ref QueueFlag::Graphics called on @ref Device::properties(). * * In case the class was constructed using @ref VulkanTester(NoCreateT) * or @ref VulkanTester(NoCreateT, NoCreateT), this instance is @@ -163,7 +151,6 @@ class VulkanTester: public TestSuite::Tester { private: Instance _instance; Device _device; - Containers::Pointer _deviceProperties; Queue _queue; };