Browse Source

Vk: and thus VulkanTester doesn't need a DeviceProperties instance.

pull/234/head
Vladimír Vondruš 6 years ago
parent
commit
c402c97307
  1. 8
      src/Magnum/Vk/Test/CommandBufferVkTest.cpp
  2. 10
      src/Magnum/Vk/Test/CommandPoolVkTest.cpp
  3. 6
      src/Magnum/Vk/Test/ImageVkTest.cpp
  4. 6
      src/Magnum/Vk/Test/MemoryVkTest.cpp
  5. 9
      src/Magnum/Vk/VulkanTester.cpp
  6. 27
      src/Magnum/Vk/VulkanTester.h

8
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();

10
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());

6
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);

6
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);

9
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} {}
}}

27
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> _deviceProperties;
Queue _queue;
};

Loading…
Cancel
Save