Skip to content
Snippets Groups Projects
Commit f8416c3b authored by n0F4x's avatar n0F4x
Browse files

Add queue priorities

parent 57c6960e
No related branches found
No related tags found
No related merge requests found
...@@ -130,7 +130,7 @@ Minden a gépen jelen levő Vulkan-képes processzort egy `vk::PhysicalDevice`-a ...@@ -130,7 +130,7 @@ Minden a gépen jelen levő Vulkan-képes processzort egy `vk::PhysicalDevice`-a
throw std::runtime_error{ "No Vulkan physical device is available." }; throw std::runtime_error{ "No Vulkan physical device is available." };
} }
auto ranked_devices_view{ const auto ranked_devices_view{
physical_devices | std::views::transform([](vk::PhysicalDevice physical_device) { physical_devices | std::views::transform([](vk::PhysicalDevice physical_device) {
switch (physical_device.getProperties().deviceType) { switch (physical_device.getProperties().deviceType) {
case vk::PhysicalDeviceType::eDiscreteGpu: case vk::PhysicalDeviceType::eDiscreteGpu:
...@@ -202,12 +202,15 @@ Adott minden, hogy a *Device*-t is létrehozzuk. ...@@ -202,12 +202,15 @@ Adott minden, hogy a *Device*-t is létrehozzuk.
static auto create_device(const vk::PhysicalDevice t_physical_device) static auto create_device(const vk::PhysicalDevice t_physical_device)
-> vk::UniqueDevice -> vk::UniqueDevice
{ {
constexpr static std::array queue_priorities{ 1.f };
const vk::DeviceQueueCreateInfo queue_create_info{ const vk::DeviceQueueCreateInfo queue_create_info{
.queueFamilyIndex = find_graphics_queue_family(t_physical_device), .queueFamilyIndex = find_graphics_queue_family(t_physical_device),
.queueCount = 1, .queueCount = 1,
.pQueuePriorities = queue_priorities.data(),
}; };
vk::DeviceCreateInfo device_create_info{ const vk::DeviceCreateInfo device_create_info{
.queueCreateInfoCount = 1, .queueCreateInfoCount = 1,
.pQueueCreateInfos = &queue_create_info, .pQueueCreateInfos = &queue_create_info,
}; };
...@@ -216,6 +219,33 @@ Adott minden, hogy a *Device*-t is létrehozzuk. ...@@ -216,6 +219,33 @@ Adott minden, hogy a *Device*-t is létrehozzuk.
} }
``` ```
!!! tip "" !!! note ""
Queue-k kérésekor meg kell adni egy köztük kialakított prioritási sorrendet, ami queue-k közti ütemezéshez hasznos.
Sajnos ha csak egy queue-t kérünk, annak a prioritását is specifikálni kell [0.0, 1.0] között.
Végül a `Renderer`-hez adjuk hozzá az így létrejövő `vk::UniqueDevice`-t, és a kiválasztott `vk::Queue`-t is.
```cpp title="Renderer.hpp"
class Renderer {
public:
Renderer();
private:
vk::UniqueInstance m_instance;
vk::PhysicalDevice m_physical_device;
uint32_t m_queue_family_index;
vk::UniqueDevice m_device;
vk::Queue m_queue;
};
```
A `Renderer`-hez adjuk hozzá az így létrejövő `vk::UniqueDevice`-t, és a kiválasztott `vk::Queue`-t is. (Utóbbi lentebb a végső kódban látható.) ```cpp title="Renderer.cpp"
Renderer::Renderer()
: m_instance{ create_instance() },
m_physical_device{ choose_physical_device(*m_instance) },
m_queue_family_index{ find_graphics_queue_family(m_physical_device) },
m_device{ create_device(m_physical_device) },
m_queue{ m_device->getQueue(m_queue_family_index, 0) }
{}
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment