API Documentation
Loading...
Searching...
No Matches
VulkanDevice.h
Go to the documentation of this file.
1#pragma once
4struct VkDeviceCreateInfo;
5namespace NDEVR
6{
7 /**--------------------------------------------------------------------------------------------------
8 \brief A GraphicsDevice for managing Vulkan limitations and actions. See:
9 https://docs.vulkan.org/spec/latest/chapters/devsandqueues.html
10 **/
12 {
13 public:
17 virtual ~VulkanDevice(){};
20 UUID id() const override { return m_id; };
21
22 void init() override;
23 void cleanup();
24 bool isInitialized() const override { return m_is_init; }
25 bool isValid() const override;
26 void destroyImageView(VkImageView image_view);
32 void endSingleTimeCommands(VkCommandBuffer commandBuffer, bool wait_for_completion, uint04 id = Constant<uint04>::Invalid) const;
34 void checkoutID(uint04 id) const;
36 uint04 maxSupportedSamples() const override;
37 virtual uint04 getThreadedID() const;
38 bool isSoftwareRendered() const;
39 virtual bool canServiceCaptureRequests() const final override;
40 #ifdef ANDROID
41 virtual bool supportsMultiThreading() const override { return false; }
42 #else
43 virtual bool supportsMultiThreading() const override { return true; }
44 #endif
47 const VkPhysicalDeviceProperties& physicalProperties() const;
48 const VkPhysicalDeviceFeatures& physicalFeatures() const;
49 const VkPhysicalDeviceFeatures& enabledFeatures() const;
50 const void* initLockPtr() const override;//To initialize, must hold write lock, to use must hold read lock
51 VkPresentModeKHR chooseSwapPresentMode(const Buffer<VkPresentModeKHR>& availablePresentModes);
52 void addSurface(VkSurfaceKHR surface);
54
55 VkFormat findDepthFormat() const;
57 VkInstance vkInstance() const { lib_assert(!m_instance.isNull(), "Instance not yet created, but access is attempted"); return m_instance->vkInstance(); }
58 VkDevice device() const { return m_device; }
60
62 ProgressInfo* log() { return m_log; }
63 bool supportsTriangleFan() const {return m_instance->supportsTriangleFan();}
64 uint04 findMemoryType(uint04 typeFilter, uint04 properties) const;
65 protected:
69 void createCommandPool(uint04 thread) const;
70 virtual VkResult createLogicalDevice(const VkDeviceCreateInfo& create_info);
72 protected:
75 VkDevice m_device;//Virtual device for rendering
76 VkPhysicalDevice m_physical_device;//Best device for rendering
82 mutable VkPhysicalDeviceProperties* m_physical_properties;
83 mutable VkPhysicalDeviceFeatures* m_physical_features;
84 mutable VkPhysicalDeviceFeatures* m_enabled_features;
88
89 mutable Dictionary<uint04, VkCommandPool> m_command_pools;//A command pool for each thread
90
97
99 };
100}
uint64_t VkImageView
Definition ImageResources.h:41
#define lib_assert(expression, message)
Definition LibAssert.h:61
uint64_t VkSurfaceKHR
Definition VulkanInstance.h:62
uint64_t VkCommandPool
Definition VulkanInstance.h:63
struct VkPhysicalDevice_T * VkPhysicalDevice
Definition VulkanInstance.h:55
struct VkQueue_T * VkQueue
Definition VulkanInstance.h:57
struct VkInstance_T * VkInstance
Definition VulkanInstance.h:54
struct VkDevice_T * VkDevice
Definition VulkanInstance.h:56
struct VkCommandBuffer_T * VkCommandBuffer
Definition VulkanInstance.h:58
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:56
A hash-based key-value store, useful for quick associative lookups. Key features include:
Definition Dictionary.h:61
Provides a modifiable pointer that has shared ownership of a dynamically allocated object.
Definition Pointer.hpp:320
A physical or virtual device used with the NDEVR Rendering Engine. A device contains System specific ...
Definition GraphicsDevice.h:12
A light-weight base class for Log that allows processes to update, without the need for additional in...
Definition ProgressInfo.hpp:48
Represents a timestamp with utilities for manipulation and conversion.
Definition Time.h:54
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
Definition UUID.h:60
A GraphicsDevice for managing Vulkan limitations and actions. See: https://docs.vulkan....
Definition VulkanDevice.h:12
void returnID(uint04 id=Constant< uint04 >::Invalid) const
VkQueue presentQueue(uint04 id=Constant< uint04 >::Invalid) const
VkDevice device() const
Definition VulkanDevice.h:58
uint04 m_graphics_family_index
Definition VulkanDevice.h:85
VkCommandPool getCommandPool(uint04 id=Constant< uint04 >::Invalid) const
const VkPhysicalDeviceFeatures & physicalFeatures() const
bool checkDeviceExtensionSupport(VkPhysicalDevice device)
VulkanDevice(VkPhysicalDevice physical_device, const DynamicPointer< VulkanInstance > &instance)
VkInstance vkInstance() const
Definition VulkanDevice.h:57
Dictionary< uint04, VkCommandPool > m_command_pools
Definition VulkanDevice.h:89
const void * initLockPtr() const override
Buffer< VkQueueFamilyProperties, uint04, ObjectAllocator< true > > m_queue_families
Definition VulkanDevice.h:81
void createCommandPool(uint04 thread) const
Buffer< String > m_device_extensions
Definition VulkanDevice.h:77
VkDevice m_device
Definition VulkanDevice.h:75
bool isInitialized() const override
Definition VulkanDevice.h:24
virtual VkResult createLogicalDevice(const VkDeviceCreateInfo &create_info)
DynamicPointer< VulkanInstance > m_instance
Definition VulkanDevice.h:74
void setLog(ProgressInfo *log)
VulkanDevice(VulkanDevice &&instance) noexcept
UUID m_id
Definition VulkanDevice.h:80
Dictionary< uint04, uint04 > m_thread_checkouts
Definition VulkanDevice.h:95
Dictionary< uint04, uint04 > m_graphics_queue_index
Definition VulkanDevice.h:93
static DynamicPointer< VulkanDevice > & DefaultVulkanDevice()
uint04 m_present_family_index
Definition VulkanDevice.h:86
ProgressInfo * log()
Definition VulkanDevice.h:62
VkPhysicalDeviceFeatures * m_enabled_features
Definition VulkanDevice.h:84
const VkPhysicalDeviceFeatures & enabledFeatures() const
bool supportsTriangleFan() const
Definition VulkanDevice.h:63
bool isSoftwareRendered() const
virtual ~VulkanDevice()
Definition VulkanDevice.h:17
Dictionary< uint04, VkQueue > m_present_queue
Definition VulkanDevice.h:91
uint04 maxSupportedSamples() const override
const VkPhysicalDevice & physicalDevice() const
Definition VulkanDevice.h:59
virtual uint04 getThreadedID() const
bool m_is_init
Definition VulkanDevice.h:98
bool m_is_software_rendered
Definition VulkanDevice.h:96
Buffer< String > m_device_layers
Definition VulkanDevice.h:78
VkPhysicalDevice m_physical_device
Definition VulkanDevice.h:76
Buffer< VkSurfaceKHR > m_surfaces
Definition VulkanDevice.h:79
VkPhysicalDeviceProperties * m_physical_properties
Definition VulkanDevice.h:82
void checkoutID(uint04 id) const
void addSurface(VkSurfaceKHR surface)
ProgressInfo * m_log
Definition VulkanDevice.h:73
VulkanDevice(const DynamicPointer< VulkanInstance > &instance)
void destroyImageView(VkImageView image_view)
VkPhysicalDeviceFeatures * m_physical_features
Definition VulkanDevice.h:83
Dictionary< uint04, VkQueue > m_graphics_queue
Definition VulkanDevice.h:92
Buffer< uint04 > m_checkouts
Definition VulkanDevice.h:94
VkPresentModeKHR chooseSwapPresentMode(const Buffer< VkPresentModeKHR > &availablePresentModes)
VkCommandBuffer beginSingleTimeCommands(uint04 id=Constant< uint04 >::Invalid) const
UUID id() const override
Definition VulkanDevice.h:20
virtual bool supportsMultiThreading() const override
Definition VulkanDevice.h:43
void removeSurface(VkSurfaceKHR surface)
void endSingleTimeCommands(VkCommandBuffer commandBuffer, bool wait_for_completion, uint04 id=Constant< uint04 >::Invalid) const
uint04 checkoutID() const
uint04 findMemoryType(uint04 typeFilter, uint04 properties) const
void init() override
Time m_creation_time
Definition VulkanDevice.h:87
const VkPhysicalDeviceProperties & physicalProperties() const
DynamicPointer< VulkanInstance > instance() const
virtual void autoChoosePhysicalDevice()
virtual bool canServiceCaptureRequests() const final override
virtual void waitForGraphicsQueue(uint04 id=Constant< uint04 >::Invalid) const
bool isValid() const override
VkFormat findDepthFormat() const
VkQueue graphicsQueue(uint04 id=Constant< uint04 >::Invalid) const
void destroyCommandPool(uint04 id)
Definition ACIColor.h:37
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:96
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved 'invali...
Definition BaseValues.hpp:233