API Documentation
Loading...
Searching...
No Matches
VulkanDevice.h
Go to the documentation of this file.
1#pragma once
4struct VkDeviceCreateInfo;
5namespace NDEVR
6{
8 {
9 public:
10 VulkanDevice(VkPhysicalDevice physical_device, const DynamicPointer<VulkanInstance>& instance);
13 virtual ~VulkanDevice(){};
16 UUID id() const override { return m_id; };
17
18 void init() override;
19 void cleanup();
20 bool isInitialized() const override { return m_is_init; }
21 bool isValid() const override;
22 void destroyImageView(VkImageView image_view);
28 void endSingleTimeCommands(VkCommandBuffer commandBuffer, bool wait_for_completion, uint04 id = Constant<uint04>::Invalid) const;
30 void checkoutID(uint04 id) const;
32 uint04 maxSupportedSamples() const override;
33 virtual uint04 getThreadedID() const;
34 bool isSoftwareRendered() const;
35 virtual bool canServiceCaptureRequests() const final override;
36 #ifdef ANDROID
37 virtual bool supportsMultiThreading() const override { return false; }
38 #else
39 virtual bool supportsMultiThreading() const override { return true; }
40 #endif
43 const VkPhysicalDeviceProperties& physicalProperties() const;
44 const VkPhysicalDeviceFeatures& physicalFeatures() const;
45 const VkPhysicalDeviceFeatures& enabledFeatures() const;
46 const void* initLockPtr() const override;//To initialize, must hold write lock, to use must hold read lock
47 VkPresentModeKHR chooseSwapPresentMode(const Buffer<VkPresentModeKHR>& availablePresentModes);
48 void addSurface(VkSurfaceKHR surface);
49 void removeSurface(VkSurfaceKHR surface);
50
51 VkFormat findDepthFormat() const;
53 VkInstance vkInstance() const { lib_assert(!m_instance.isNull(), "Instance not yet created, but access is attempted"); return m_instance->vkInstance(); }
54 VkDevice device() const { return m_device; }
55 const VkPhysicalDevice& physicalDevice() const { return m_physical_device; }
56
58 ProgressInfo* log() { return m_log; }
59 bool supportsTriangleFan() const {return m_instance->supportsTriangleFan();}
60 uint04 findMemoryType(uint04 typeFilter, uint04 properties) const;
61 protected:
64 bool checkDeviceExtensionSupport(VkPhysicalDevice device);
65 void createCommandPool(uint04 thread) const;
66 virtual VkResult createLogicalDevice(const VkDeviceCreateInfo& create_info);
68 protected:
71 VkDevice m_device;//Virtual device for rendering
72 VkPhysicalDevice m_physical_device;//Best device for rendering
78 mutable VkPhysicalDeviceProperties* m_physical_properties;
79 mutable VkPhysicalDeviceFeatures* m_physical_features;
80 mutable VkPhysicalDeviceFeatures* m_enabled_features;
84
85 mutable Dictionary<uint04, VkCommandPool> m_command_pools;//A command pool for each thread
86
93
95 };
96}
#define lib_assert(expression, message)
Asserts some logic in the code. Disabled in non debug mode by default. Can be re-enabled in release u...
Definition LibAssert.h:68
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:59
A hash-based key-value store, useful for quick associative lookups.
Definition Dictionary.h:59
Provides a modifiable pointer that has shared ownership of a dynamically allocated object.
Definition Pointer.hpp:319
Definition GraphicsDevice.h:8
A light-weight base class for Log that allows processes to update, without the need for.
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:62
Definition VulkanDevice.h:8
void returnID(uint04 id=Constant< uint04 >::Invalid) const
VkQueue presentQueue(uint04 id=Constant< uint04 >::Invalid) const
VkDevice device() const
Definition VulkanDevice.h:54
uint04 m_graphics_family_index
Definition VulkanDevice.h:81
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:53
Dictionary< uint04, VkCommandPool > m_command_pools
Definition VulkanDevice.h:85
const void * initLockPtr() const override
Buffer< VkQueueFamilyProperties, uint04, ObjectAllocator< true > > m_queue_families
Definition VulkanDevice.h:77
void createCommandPool(uint04 thread) const
Buffer< String > m_device_extensions
Definition VulkanDevice.h:73
VkDevice m_device
Definition VulkanDevice.h:71
bool isInitialized() const override
Definition VulkanDevice.h:20
virtual VkResult createLogicalDevice(const VkDeviceCreateInfo &create_info)
DynamicPointer< VulkanInstance > m_instance
Definition VulkanDevice.h:70
void setLog(ProgressInfo *log)
VulkanDevice(VulkanDevice &&instance) noexcept
UUID m_id
Definition VulkanDevice.h:76
Dictionary< uint04, uint04 > m_thread_checkouts
Definition VulkanDevice.h:91
Dictionary< uint04, uint04 > m_graphics_queue_index
Definition VulkanDevice.h:89
static DynamicPointer< VulkanDevice > & DefaultVulkanDevice()
uint04 m_present_family_index
Definition VulkanDevice.h:82
ProgressInfo * log()
Definition VulkanDevice.h:58
VkPhysicalDeviceFeatures * m_enabled_features
Definition VulkanDevice.h:80
const VkPhysicalDeviceFeatures & enabledFeatures() const
bool supportsTriangleFan() const
Definition VulkanDevice.h:59
bool isSoftwareRendered() const
virtual ~VulkanDevice()
Definition VulkanDevice.h:13
Dictionary< uint04, VkQueue > m_present_queue
Definition VulkanDevice.h:87
uint04 maxSupportedSamples() const override
const VkPhysicalDevice & physicalDevice() const
Definition VulkanDevice.h:55
virtual uint04 getThreadedID() const
bool m_is_init
Definition VulkanDevice.h:94
bool m_is_software_rendered
Definition VulkanDevice.h:92
Buffer< String > m_device_layers
Definition VulkanDevice.h:74
VkPhysicalDevice m_physical_device
Definition VulkanDevice.h:72
Buffer< VkSurfaceKHR > m_surfaces
Definition VulkanDevice.h:75
VkPhysicalDeviceProperties * m_physical_properties
Definition VulkanDevice.h:78
void checkoutID(uint04 id) const
void addSurface(VkSurfaceKHR surface)
ProgressInfo * m_log
Definition VulkanDevice.h:69
VulkanDevice(const DynamicPointer< VulkanInstance > &instance)
void destroyImageView(VkImageView image_view)
VkPhysicalDeviceFeatures * m_physical_features
Definition VulkanDevice.h:79
Dictionary< uint04, VkQueue > m_graphics_queue
Definition VulkanDevice.h:88
Buffer< uint04 > m_checkouts
Definition VulkanDevice.h:90
VkPresentModeKHR chooseSwapPresentMode(const Buffer< VkPresentModeKHR > &availablePresentModes)
VkCommandBuffer beginSingleTimeCommands(uint04 id=Constant< uint04 >::Invalid) const
UUID id() const override
Definition VulkanDevice.h:16
virtual bool supportsMultiThreading() const override
Definition VulkanDevice.h:39
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:83
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:94
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved.
Definition BaseValues.hpp:230