2#include "../../VulkanGraphics/Headers/VulkanInstance.h"
3#include <NDEVR/GraphicsDevice.h>
4struct VkDeviceCreateInfo;
38 void destroyImageView(VkImageView image_view);
39 VkCommandPool getCommandPool(
uint04 id = Constant<uint04>::Invalid)
const;
40 void destroyCommandPool(
uint04 id);
41 VkQueue graphicsQueue(
uint04 id = Constant<uint04>::Invalid)
const;
42 VkQueue presentQueue(
void* window)
const;
43 VkCommandBuffer beginSingleTimeCommands(
uint04 id = Constant<uint04>::Invalid)
const;
44 void endSingleTimeCommands(VkCommandBuffer commandBuffer,
bool wait_for_completion,
uint04 id = Constant<uint04>::Invalid)
const;
46 void checkoutID(
uint04 id)
const;
47 void returnID(
uint04 id = Constant<uint04>::Invalid)
const;
49 virtual uint04 getThreadedID()
const;
50 bool isSoftwareRendered()
const;
56 virtual void waitForGraphicsQueue(
uint04 id = Constant<uint04>::Invalid)
const;
57 void logPhysicalDevice();
58 const VkPhysicalDeviceProperties& physicalProperties()
const;
59 const VkPhysicalDeviceFeatures& physicalFeatures()
const;
60 const VkPhysicalDeviceFeatures& enabledFeatures()
const;
63 void addSurface(VkSurfaceKHR surface);
64 void removeSurface(VkSurfaceKHR surface);
66 VkFormat findDepthFormat()
const;
68 VkInstance vkInstance()
const { lib_assert(!
m_instance.isNull(),
"Instance not yet created, but access is attempted");
return m_instance->vkInstance(); }
69 VkDevice device()
const {
return m_device; }
71 VulkanStagingRing* stagingRing()
const;
72 void setLog(LogPtr log);
74 LogPtr log() {
return m_log; }
75 bool supportsTriangleFan()
const {
return m_instance->supportsTriangleFan();}
78 void setQueueFamilies();
79 void setupLogicalDevice();
80 bool checkDeviceExtensionSupport(VkPhysicalDevice device);
81 void createCommandPool(
uint04 thread)
const;
82 virtual VkResult createLogicalDevice(
const VkDeviceCreateInfo& create_info);
83 virtual void autoChoosePhysicalDevice();
The equivelent of std::vector but with a bit more control.
A hash-based key-value store, useful for quick associative lookups.
Provides a modifiable pointer that has shared ownership of a dynamically allocated object.
GraphicsDevice()
Default constructor.
A light-weight wrapper that will be a no-op if there is not a valid log reference,...
Represents a timestamp with utilities for manipulation and conversion.
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
void setDeviceLost()
Handles a device-lost event by cleaning up resources.
VkDevice m_device
The logical Vulkan device handle.
VulkanDevice(VkPhysicalDevice physical_device, const DynamicPointer< VulkanInstance > &instance)
Constructs a Vulkan device for a specific physical device.
VkPhysicalDevice m_physical_device
The physical device handle.
UUID id() const override
Returns the unique identifier for this device.
static DynamicPointer< VulkanDevice > & DefaultVulkanDevice()
Returns a reference to the global default Vulkan device.
DynamicPointer< VulkanInstance > m_instance
The Vulkan instance this device belongs to.
LogPtr m_log
Log for device messages.
Dictionary< uint04, uint04 > m_thread_checkouts
Thread-to-checkout-ID mapping.
VulkanStagingRing * m_staging_ring
Staging ring for CPU-to-GPU transfers.
Dictionary< uint04, VkQueue > m_graphics_queue
Graphics queues keyed by checkout ID.
Dictionary< uint04, uint04 > m_graphics_queue_index
Queue family indices keyed by checkout ID.
Dictionary< void *, VkQueue > m_present_queue
Present queues keyed by window handle.
bool m_is_init
Whether the device has been initialized.
Buffer< VkQueueFamilyProperties > m_queue_families
Available queue families on the physical device.
Buffer< String > m_device_layers
Enabled device layers.
uint04 m_graphics_family_index
The queue family index for graphics operations.
uint04 maxSupportedSamples() const override
Returns the maximum number of multisample samples supported.
Time m_creation_time
The time this device was created.
Buffer< VkSurfaceKHR > m_surfaces
Surfaces registered with this device.
virtual bool supportsMultiThreading() const override
Checks whether the device supports multi-threaded rendering.
Dictionary< uint04, VkCommandPool > m_command_pools
Command pools keyed by thread ID.
bool isValid() const override
Checks whether this device is valid and usable.
VkPhysicalDeviceFeatures * m_physical_features
Cached physical device features.
uint04 m_present_family_index
The queue family index for presentation.
UUID m_id
Unique identifier for this device.
void init() override
Initializes the graphics device.
bool m_is_software_rendered
Whether this is a software-rendered device.
bool isInitialized() const override
Checks whether the device has been initialized.
VulkanDevice(const DynamicPointer< VulkanInstance > &instance)
Constructs a Vulkan device that will auto-choose the best physical device.
VkPhysicalDeviceProperties * m_physical_properties
Cached physical device properties.
const void * initLockPtr() const override
Returns a pointer used for synchronizing device initialization.
virtual ~VulkanDevice()
Destructor.
VkPhysicalDeviceFeatures * m_enabled_features
Features enabled on the logical device.
Buffer< uint04 > m_checkouts
Available checkout IDs.
VulkanDevice(VulkanDevice &&instance) noexcept
Move constructor.
Buffer< String > m_device_extensions
Enabled device extensions.
A ring buffer for staging GPU uploads.
The primary namespace for the NDEVR SDK.
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...