Skip to content

Commit

Permalink
fixup! layer: Add a Vulkan layer required for Reflex support
Browse files Browse the repository at this point in the history
  • Loading branch information
Saancreed committed Dec 26, 2024
1 parent b124c98 commit 30a741b
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions layer/vulkan_reflex_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ static bool PhysicalDeviceSupportsExtension(PFN_vkEnumerateDeviceExtensionProper
std::vector<VkExtensionProperties> properties{count};
vr = pvkEnumerateDeviceExtensionProperties(physicalDevice, nullptr, &count, properties.data());

if (vr != VK_SUCCESS && vr != VK_INCOMPLETE)
if (vr != VK_SUCCESS)
return false;

auto extName = std::string_view{extensionName};
Expand All @@ -169,7 +169,7 @@ static inline void ProcessDeviceQueue(VkDevice device, VkQueue* pQueue) {

if (auto context = ::GetContext(device); context && pQueue) {
if (auto queue = *pQueue) {
if (context->queues.insert(queue).second)
if (auto [it, inserted] = context->queues.insert(queue); inserted)
ReflexQueueContext::create(queue, {.device = device});
}
}
Expand Down Expand Up @@ -307,6 +307,7 @@ struct VkInstanceOverrides {
if (!exposeExtension)
return pDispatch->EnumerateDeviceExtensionProperties(physicalDevice, pLayerName, pPropertyCount, pProperties);

static constexpr auto layerName = "VK_LAYER_DXVK_NVAPI_reflex"sv;
static constexpr auto exts = std::array<VkExtensionProperties, 1>{{
{
.extensionName = VK_NV_LOW_LATENCY_EXTENSION_NAME,
Expand All @@ -315,7 +316,7 @@ struct VkInstanceOverrides {
}};

if (pLayerName) {
if (pLayerName == "VK_LAYER_DXVK_NVAPI_reflex"sv) {
if (pLayerName == layerName) {
if (PhysicalDeviceSupportsExtension(pDispatch->EnumerateDeviceExtensionProperties, physicalDevice, ll2.data(), 2))
return vkroots::helpers::array(exts, pPropertyCount, pProperties);
else
Expand Down Expand Up @@ -353,7 +354,7 @@ struct VkInstanceOverrides {
? std::vector<char const*>{
info.ppEnabledExtensionNames,
info.ppEnabledExtensionNames + info.enabledExtensionCount}
: injectFrameIDs ? std::vector<char const*>{{pid.data(), ts.data(), ll2.data()}}
: injectFrameIDs ? std::vector<char const*>{{ts.data(), ll2.data(), pid.data()}}
: std::vector<char const*>{{ts.data(), ll2.data()}};

auto presentIdFeatures = VkPhysicalDevicePresentIdFeaturesKHR{
Expand Down Expand Up @@ -435,7 +436,7 @@ struct VkDeviceOverrides {
for (auto queue : context->queues)
ReflexQueueContext::remove(queue);

node.remove(device);
ReflexDeviceContext::remove(device);
}

pDispatch->DestroyDevice(device, pAllocator);
Expand Down

0 comments on commit 30a741b

Please sign in to comment.