From 5687a8b5ecd79dabe50e0b5e64bdc6315a73173e Mon Sep 17 00:00:00 2001 From: Krzysztof Bogacki Date: Wed, 25 Dec 2024 17:16:47 +0100 Subject: [PATCH] nvapi-vulkan: Log unsupported latency marker types only once (per thread) --- src/nvapi_private.h | 1 + src/nvapi_vulkan.cpp | 15 +++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/nvapi_private.h b/src/nvapi_private.h index 796341dc..66d8bd7f 100644 --- a/src/nvapi_private.h +++ b/src/nvapi_private.h @@ -27,6 +27,7 @@ #include #include #include +#include #include #include diff --git a/src/nvapi_vulkan.cpp b/src/nvapi_vulkan.cpp index c0730d44..74ff1137 100644 --- a/src/nvapi_vulkan.cpp +++ b/src/nvapi_vulkan.cpp @@ -197,14 +197,17 @@ extern "C" { if (!lowLatencyDevice) return HandleInvalidated(n); - auto marker = NvapiVulkanLowLatencyDevice::ToVkLatencyMarkerNV(pSetLatencyMarkerParams->markerType); + auto markerType = pSetLatencyMarkerParams->markerType; + auto marker = NvapiVulkanLowLatencyDevice::ToVkLatencyMarkerNV(markerType); - if (marker == VK_LATENCY_MARKER_MAX_ENUM_NV) { - log::info(str::format("unsupported NV_VULKAN_LATENCY_MARKER_TYPE (", pSetLatencyMarkerParams->markerType, "), frameID = ", pSetLatencyMarkerParams->frameID, ", ignoring")); - return Ok(n); - } + if (marker != VK_LATENCY_MARKER_MAX_ENUM_NV) { + lowLatencyDevice->SetLatencyMarker(pSetLatencyMarkerParams->frameID, marker); + } else { + thread_local std::unordered_set unsupportedMarkerTypes{}; - lowLatencyDevice->SetLatencyMarker(pSetLatencyMarkerParams->frameID, marker); + if (auto [it, inserted] = unsupportedMarkerTypes.insert(markerType); inserted) + log::info(str::format("unsupported NV_VULKAN_LATENCY_MARKER_TYPE (", markerType, "), ignoring")); + } return Ok(n, alreadyLoggedOk); }