aboutsummaryrefslogtreecommitdiff
path: root/src/physical_device_context.cc
blob: 45be10e82fa5d9c7031d53313a59f4e395303126 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "physical_device_context.hh"
#include <vulkan/vulkan_core.h>

namespace low_latency {

PhysicalDeviceContext::PhysicalDeviceContext(
    InstanceContext& instance_context, const VkPhysicalDevice& physical_device)
    : instance(instance_context), physical_device(physical_device) {

    const auto& vtable = instance_context.vtable;

    this->properties = [&]() {
        auto props = VkPhysicalDeviceProperties{};
        vtable.GetPhysicalDeviceProperties(physical_device, &props);
        return std::make_unique<VkPhysicalDeviceProperties>(std::move(props));
    }();

    this->queue_properties = [&]() {
        auto count = std::uint32_t{};
        vtable.GetPhysicalDeviceQueueFamilyProperties2(physical_device, &count,
                                                       nullptr);

        using qp_t = PhysicalDeviceContext::queue_properties_t;
        auto result = qp_t(
            count, VkQueueFamilyProperties2{
                       .sType = VK_STRUCTURE_TYPE_QUEUE_FAMILY_PROPERTIES_2});
        vtable.GetPhysicalDeviceQueueFamilyProperties2(physical_device, &count,
                                                       std::data(result));

        return std::make_unique<qp_t>(std::move(result));
    }();
}

PhysicalDeviceContext::~PhysicalDeviceContext() {}

} // namespace low_latency