Contains convenient function to design a device based on the requirements for the physical device it is based around
NOTE: To get the appropriate index into the basalt::Device queue list, track the order of request_queue(s) calls in the designer
This commit is contained in:
55
include/vulkan/basalt_device.h
Normal file
55
include/vulkan/basalt_device.h
Normal file
@@ -0,0 +1,55 @@
|
||||
#pragma once
|
||||
#include "basalt_physical_device.h"
|
||||
#include "basalt_queue.h"
|
||||
|
||||
namespace basalt
|
||||
{
|
||||
class Device
|
||||
{
|
||||
public:
|
||||
Device(const Device& src);
|
||||
Device& operator =(const Device& src);
|
||||
Device(Device&& other) noexcept;
|
||||
Device& operator =(Device&& other) noexcept;
|
||||
|
||||
Device(basalt::Context& ctx, basalt::PhysicalDevice& physical, VkDevice logical);
|
||||
~Device();
|
||||
|
||||
operator VkPhysicalDevice();
|
||||
operator VkDevice();
|
||||
|
||||
basalt::darray<basalt::Queue> queues;
|
||||
VkDevice logical = VK_NULL_HANDLE;
|
||||
basalt::Context* ctx;
|
||||
basalt::PhysicalDevice* phys;
|
||||
bool should_free = true;
|
||||
};
|
||||
class DeviceDesigner
|
||||
{
|
||||
public:
|
||||
DeviceDesigner(basalt::Context& ctx, basalt::PhysicalDevice& phy);
|
||||
|
||||
DeviceDesigner& request_features(VkPhysicalDeviceFeatures features);
|
||||
|
||||
DeviceDesigner& request_extensions(const basalt::darray<const char*>& extensions);
|
||||
DeviceDesigner& request_extensions(const char** extensions, const u32 num_extensions);
|
||||
DeviceDesigner& request_extension(const char* extension);
|
||||
|
||||
DeviceDesigner& request_layers(const basalt::darray<const char*>& layers);
|
||||
DeviceDesigner& request_layers(const char** layers, const u32 num_layers);
|
||||
DeviceDesigner& request_layer(const char* layer);
|
||||
|
||||
DeviceDesigner& request_queue(u32 family_index, const float priority=1.0f, VkDeviceQueueCreateFlags flags=0);
|
||||
DeviceDesigner& request_queues(u32 family_index, const basalt::darray<float>& queue_priorities, VkDeviceQueueCreateFlags flags=0);
|
||||
|
||||
basalt::Device design(void);
|
||||
|
||||
VkPhysicalDeviceFeatures req_features;
|
||||
basalt::darray<VkDeviceQueueCreateInfo> req_queues;
|
||||
basalt::darray<const char*> req_extensions;
|
||||
basalt::darray<const char*> req_layers;
|
||||
basalt::darray<float> queue_priorities;
|
||||
basalt::Context& ctx;
|
||||
basalt::PhysicalDevice& phys;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user