Skip to content

♻️Refactor Core Runtime Queries #88

Description

@mrparmesan01

Brief Task

Vulkan requires you to have to make two distinct API calls for retrieving the size of the data before retrieving the underlying data as a secondary call.

This means we have to make two separate calls everytime, we need to query information such as Physical Devices, Layer Properties, etc.

I was thinking about how we may want to handle this to reduce the calls that need to happen and to just retrieve the data directly.

Task Requirement

Currently, how we enumerate physical devices would not change. Rather the underlying logic, would be changed.

Here is how vk::instance::enumerate_physical_devices is implemented:

uint32_t device_count = 0;
VkResult res = vkEnumeratePhysicalDevices(m_instance, &device_count, nullptr);

if (res != VK_SUCCESS) {
    return std::unexpected(res);
}

std::vector<VkPhysicalDevice> physical_devices(device_count);
res = vkEnumeratePhysicalDevices(m_instance, &device_count, physical_devices.data());

if (res != VK_SUCCESS) {
    return std::unexpected(res);
}

 for (const auto& device : physical_devices) {
    VkPhysicalDeviceProperties device_properties;
    vkGetPhysicalDeviceProperties(device, &device_properties);

    if (device_properties.deviceType ==
        static_cast<VkPhysicalDeviceType>(p_device_type)) {
        return physical_device(device);
    }
}

Introducing vk::fetch_query, where we reduce these calls that need to occur.

Task Completion Expectation

Here is a pseudo-code in how the API may be used:

std::array<VkPhysicalDevice, 3> device_storage{};

std::span<const VkPhysicalDevice> physical_devices = fetch_queries(device_storage, vkEnumeratePhysicalDevices, m_instance);

Metadata

Metadata

Assignees

No one assigned

    Labels

    ✨improvementImproving existing designs.💳 Tech DebtTasks that have some kind of user API tech debt📐designTasks that involve the core systems. Highly involve in API design.

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions