Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
vkDevice.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2018 DIVIDE-Studio
3 Copyright (c) 2009 Ionut Cava
4
5 This file is part of DIVIDE Framework.
6
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software
9 and associated documentation files (the "Software"), to deal in the Software
10 without restriction,
11 including without limitation the rights to use, copy, modify, merge, publish,
12 distribute, sublicense,
13 and/or sell copies of the Software, and to permit persons to whom the
14 Software is furnished to do so,
15 subject to the following conditions:
16
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
19
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 IMPLIED,
22 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
23 PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25 DAMAGES OR OTHER LIABILITY,
26 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
27 IN CONNECTION WITH THE SOFTWARE
28 OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
30 */
31
32#pragma once
33#ifndef DVD_VK_DEVICE_H_
34#define DVD_VK_DEVICE_H_
35
36#include "vkResources.h"
37
38namespace Divide {
39
41{
42 public:
43 VKDevice( vkb::Instance& instance, VkSurfaceKHR targetSurface);
44 ~VKDevice();
45
46 [[nodiscard]] VkDevice getVKDevice() const noexcept;
47 [[nodiscard]] VkPhysicalDevice getVKPhysicalDevice() const noexcept;
48
49 [[nodiscard]] const vkb::Device& getDevice() const noexcept;
50 [[nodiscard]] const vkb::PhysicalDevice& getPhysicalDevice() const noexcept;
51
52 [[nodiscard]] VkCommandPool createCommandPool(uint32_t queueFamilyIndex, VkCommandPoolCreateFlags createFlags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT) const;
53 void submitToQueue(QueueType queue, const VkSubmitInfo& submitInfo, VkFence& fence) const;
54 [[nodiscard]] VkResult queuePresent(QueueType queue, const VkPresentInfoKHR& presentInfo) const;
55
56 [[nodiscard]] U32 getPresentQueueIndex() const noexcept;
57 [[nodiscard]] VKQueue getQueue( QueueType type ) const noexcept;
58
59 PROPERTY_R_IW(bool, supportsDynamicExtension3, false);
60 PROPERTY_R_IW(bool, supportsPushDescriptors, false);
61 PROPERTY_R_IW(bool, supportsDescriptorBuffers, false);
62
63 private:
64 [[nodiscard]] VKQueue getQueueInternal( QueueType type, bool dedicated) const noexcept;
65
66 private:
67 vkb::Device _device{}; // Vulkan device for commands
68 vkb::PhysicalDevice _physicalDevice{}; // GPU chosen as the default device
70
72 mutable std::array<Mutex, to_base( QueueType::COUNT )> _queueLocks;
73};
74
76
77}; //namespace Divide
78
79#endif //DVD_VK_DEVICE_H_
#define FWD_DECLARE_MANAGED_CLASS(T)
U32 _presentQueueIndex
Definition: vkDevice.h:69
const vkb::PhysicalDevice & getPhysicalDevice() const noexcept
Definition: vkDevice.cpp:218
VkCommandPool createCommandPool(uint32_t queueFamilyIndex, VkCommandPoolCreateFlags createFlags=VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT) const
Definition: vkDevice.cpp:223
PROPERTY_R_IW(bool, supportsDescriptorBuffers, false)
std::array< Mutex, to_base(QueueType::COUNT)> _queueLocks
Definition: vkDevice.h:72
PROPERTY_R_IW(bool, supportsDynamicExtension3, false)
U32 getPresentQueueIndex() const noexcept
Definition: vkDevice.cpp:147
std::array< VKQueue, to_base(QueueType::COUNT) > _queues
Definition: vkDevice.h:71
void submitToQueue(QueueType queue, const VkSubmitInfo &submitInfo, VkFence &fence) const
Definition: vkDevice.cpp:235
VkPhysicalDevice getVKPhysicalDevice() const noexcept
Definition: vkDevice.cpp:208
PROPERTY_R_IW(bool, supportsPushDescriptors, false)
VKQueue getQueue(QueueType type) const noexcept
Definition: vkDevice.cpp:152
const vkb::Device & getDevice() const noexcept
Definition: vkDevice.cpp:213
VKQueue getQueueInternal(QueueType type, bool dedicated) const noexcept
Definition: vkDevice.cpp:157
vkb::PhysicalDevice _physicalDevice
Definition: vkDevice.h:68
vkb::Device _device
Definition: vkDevice.h:67
VkResult queuePresent(QueueType queue, const VkPresentInfoKHR &presentInfo) const
Definition: vkDevice.cpp:245
VkDevice getVKDevice() const noexcept
Definition: vkDevice.cpp:203
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
std::mutex Mutex
Definition: SharedMutex.h:40
constexpr U32 INVALID_VK_QUEUE_INDEX
Definition: vkResources.h:82
uint32_t U32
constexpr auto to_base(const Type value) -> Type