From a8eaba973d39e81b1852240c2feba6e3891bc99b Mon Sep 17 00:00:00 2001 From: Nicolas James Date: Sat, 21 Feb 2026 23:40:03 +1100 Subject: Advertise antilag 2 as available extension + small cleanup --- src/physical_device_context.cc | 54 ++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 31 deletions(-) (limited to 'src/physical_device_context.cc') diff --git a/src/physical_device_context.cc b/src/physical_device_context.cc index 2d1afc3..45be10e 100644 --- a/src/physical_device_context.cc +++ b/src/physical_device_context.cc @@ -3,42 +3,34 @@ namespace low_latency { -static std::unique_ptr -make_pd_props(const InstanceContext& instance_context, - const VkPhysicalDevice& physical_device) { - const auto& vtable = instance_context.vtable; - - auto props = VkPhysicalDeviceProperties{}; - vtable.GetPhysicalDeviceProperties(physical_device, &props); - return std::make_unique(std::move(props)); -} - -static std::unique_ptr -make_qf_props(const InstanceContext& instance_context, - const VkPhysicalDevice& physical_device) { +PhysicalDeviceContext::PhysicalDeviceContext( + InstanceContext& instance_context, const VkPhysicalDevice& physical_device) + : instance(instance_context), physical_device(physical_device) { const auto& vtable = instance_context.vtable; - auto count = std::uint32_t{}; - vtable.GetPhysicalDeviceQueueFamilyProperties2(physical_device, &count, - nullptr); - - auto result = std::vector( - count, VkQueueFamilyProperties2{ - .sType = VK_STRUCTURE_TYPE_QUEUE_FAMILY_PROPERTIES_2}); - vtable.GetPhysicalDeviceQueueFamilyProperties2(physical_device, &count, - std::data(result)); - - using qp_t = PhysicalDeviceContext::queue_properties_t; - return std::make_unique(std::move(result)); + this->properties = [&]() { + auto props = VkPhysicalDeviceProperties{}; + vtable.GetPhysicalDeviceProperties(physical_device, &props); + return std::make_unique(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(std::move(result)); + }(); } -PhysicalDeviceContext::PhysicalDeviceContext( - InstanceContext& instance_context, const VkPhysicalDevice& physical_device) - : instance(instance_context), physical_device(physical_device), - properties(make_pd_props(instance, physical_device)), - queue_properties(make_qf_props(instance, physical_device)) {} - PhysicalDeviceContext::~PhysicalDeviceContext() {} } // namespace low_latency \ No newline at end of file -- cgit v1.2.3