Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request DLSS extensions only when they are supported #12

Merged
merged 1 commit into from
Apr 17, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions Source/VulkanDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1406,6 +1406,14 @@ void VulkanDevice::CreateInstance(const RgInstanceCreateInfo &info)
layerNames.push_back("VK_LAYER_LUNARG_monitor");
}

std::vector<VkExtensionProperties> supportedInstanceExtensions;
uint32_t supportedExtensionsCount;

if (vkEnumerateInstanceExtensionProperties(nullptr, &supportedExtensionsCount, nullptr) == VK_SUCCESS)
{
supportedInstanceExtensions.resize(supportedExtensionsCount);
vkEnumerateInstanceExtensionProperties(nullptr, &supportedExtensionsCount, supportedInstanceExtensions.data());
}

std::vector<const char *> extensions =
{
Expand Down Expand Up @@ -1441,6 +1449,18 @@ void VulkanDevice::CreateInstance(const RgInstanceCreateInfo &info)

for (const char *n : DLSS::GetDlssVulkanInstanceExtensions())
{
const bool isSupported = std::any_of(supportedInstanceExtensions.cbegin(), supportedInstanceExtensions.cend(),
[&](const VkExtensionProperties& ext)
{
return !std::strcmp(ext.extensionName, n);
}
);

if (!isSupported)
{
continue;
}

extensions.push_back(n);
}

Expand Down Expand Up @@ -1580,6 +1600,14 @@ void VulkanDevice::CreateDevice()
physicalDeviceFeatures2.pNext = &asFeatures;
physicalDeviceFeatures2.features = features;

std::vector<VkExtensionProperties> supportedDeviceExtensions;
uint32_t supportedExtensionsCount;

if (vkEnumerateDeviceExtensionProperties(physDevice->Get(), nullptr, &supportedExtensionsCount, nullptr) == VK_SUCCESS)
{
supportedDeviceExtensions.resize(supportedExtensionsCount);
vkEnumerateInstanceExtensionProperties(nullptr, &supportedExtensionsCount, supportedDeviceExtensions.data());
}

std::vector<const char *> deviceExtensions = {
VK_KHR_SWAPCHAIN_EXTENSION_NAME,
Expand All @@ -1593,6 +1621,18 @@ void VulkanDevice::CreateDevice()

for (const char *n : DLSS::GetDlssVulkanDeviceExtensions())
{
const bool isSupported = std::any_of(supportedDeviceExtensions.cbegin(), supportedDeviceExtensions.cend(),
[&](const VkExtensionProperties& ext)
{
return !std::strcmp(ext.extensionName, n);
}
);

if (!isSupported)
{
continue;
}

deviceExtensions.push_back(n);
}

Expand Down