mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-09 01:20:32 +01:00
feat(vulkan): gfxrenderer picks the opengl 4.6 or the vulkan 1.4 renderer (B1-B3)
This commit is contained in:
91
rendering/vulkan14/vulkan14device.h
Normal file
91
rendering/vulkan14/vulkan14device.h
Normal file
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
This Source Code Form is subject to the
|
||||
terms of the Mozilla Public License, v.
|
||||
2.0. If a copy of the MPL was not
|
||||
distributed with this file, You can
|
||||
obtain one at
|
||||
http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
// the gpu the renderer runs on, and the VkDevice with its queues.
|
||||
//
|
||||
// the gpu is the one named by gfx.vulkan.device (its index in the list of the log, or a part of its name), or else the best
|
||||
// usable one: discrete before integrated, then the one with more memory. a gpu missing something the renderer needs is
|
||||
// turned down with the name of what it lacks
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "rendering/vulkan14/vulkan14common.h"
|
||||
#include "rendering/vulkan14/vulkan14capabilities.h"
|
||||
|
||||
namespace vk14
|
||||
{
|
||||
|
||||
class instance;
|
||||
|
||||
struct queue_families
|
||||
{
|
||||
static constexpr std::uint32_t invalid{VK_QUEUE_FAMILY_IGNORED};
|
||||
|
||||
// graphics and presentation, from one family (every desktop driver has one)
|
||||
std::uint32_t graphics{invalid};
|
||||
// asynchronous compute and transfers; the graphics family where there's no family of their own
|
||||
std::uint32_t compute{invalid};
|
||||
std::uint32_t transfer{invalid};
|
||||
bool dedicated_compute{false};
|
||||
bool dedicated_transfer{false};
|
||||
};
|
||||
|
||||
class device
|
||||
{
|
||||
public:
|
||||
device() = default;
|
||||
device(device const &) = delete;
|
||||
device &operator=(device const &) = delete;
|
||||
~device();
|
||||
|
||||
// picks the gpu. Surface: the window to show images in, null before there's one (the presentation is then asked of
|
||||
// glfw). Verbose: every gpu and why it can't be used goes to the log. false: no usable gpu, Reason tells why
|
||||
bool select(VkInstance Instance, VkSurfaceKHR Surface, std::string const &Wanted, bool const Verbose, std::string &Reason);
|
||||
// makes the VkDevice of the gpu picked by select()
|
||||
bool create(instance const &Instance, std::string &Reason);
|
||||
void destroy();
|
||||
|
||||
VkPhysicalDevice physical() const
|
||||
{
|
||||
return m_physical;
|
||||
}
|
||||
VkDevice handle() const
|
||||
{
|
||||
return m_device;
|
||||
}
|
||||
capabilities const &caps() const
|
||||
{
|
||||
return m_capabilities;
|
||||
}
|
||||
queue_families const &families() const
|
||||
{
|
||||
return m_families;
|
||||
}
|
||||
VkQueue graphics_queue() const
|
||||
{
|
||||
return m_graphics_queue;
|
||||
}
|
||||
|
||||
private:
|
||||
static queue_families find_queue_families(VkInstance Instance, VkPhysicalDevice Physical, VkSurfaceKHR Surface, std::uint32_t &TimestampBits);
|
||||
static std::uint64_t score(capabilities const &Caps);
|
||||
|
||||
VkPhysicalDevice m_physical{VK_NULL_HANDLE};
|
||||
VkDevice m_device{VK_NULL_HANDLE};
|
||||
capabilities m_capabilities;
|
||||
queue_families m_families;
|
||||
feature_chain m_queried;
|
||||
bool m_portability_subset{false};
|
||||
|
||||
VkQueue m_graphics_queue{VK_NULL_HANDLE};
|
||||
VkQueue m_compute_queue{VK_NULL_HANDLE};
|
||||
VkQueue m_transfer_queue{VK_NULL_HANDLE};
|
||||
};
|
||||
|
||||
} // namespace vk14
|
||||
Reference in New Issue
Block a user