Skip to content

Commit 3eb318a

Browse files
MarijnS95claude
andauthored
[VK] Gate debug utils messenger on runtime config instead of NDEBUG (#1269)
`registerDebugUtilCallback` was only invoked inside `#ifndef NDEBUG`, leaving the function unused (and triggering `-Wunused-function`) in `NDEBUG` builds. The extension registration itself had already been converted to runtime config flags in #382; the call site was missed. Tie the callback to whether `VK_EXT_debug_utils` was actually enabled, and pull the extension in whenever either `EnableDebugLayer` or `EnableValidationLayer` is set — so validation messages route through the callback. This matches how the DX backend couples the two flags in `lib/API/DX/Device.cpp`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 43764b3 commit 3eb318a

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

lib/API/VK/Device.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3864,10 +3864,13 @@ llvm::Error offloadtest::initializeVulkanDevices(
38643864
}
38653865
const llvm::SmallVector<VkExtensionProperties, 0> AvailableExtensions =
38663866
queryInstanceExtensions(nullptr);
3867-
if (Config.EnableDebugLayer) {
3867+
bool DebugUtilsEnabled = false;
3868+
if (Config.EnableDebugLayer || Config.EnableValidationLayer) {
38683869
const llvm::StringRef DebugUtilsExtensionName = "VK_EXT_debug_utils";
3869-
if (isExtensionSupported(AvailableExtensions, DebugUtilsExtensionName))
3870+
if (isExtensionSupported(AvailableExtensions, DebugUtilsExtensionName)) {
38703871
EnabledInstanceExtensions.push_back(DebugUtilsExtensionName.data());
3872+
DebugUtilsEnabled = true;
3873+
}
38713874
}
38723875

38733876
CreateInfo.ppEnabledLayerNames = EnabledLayers.data();
@@ -3880,11 +3883,8 @@ llvm::Error offloadtest::initializeVulkanDevices(
38803883
"Failed to create Vulkan instance"))
38813884
return Err;
38823885

3883-
#ifndef NDEBUG
3884-
VkDebugUtilsMessengerEXT DebugMessenger = registerDebugUtilCallback(Instance);
3885-
#else
3886-
VkDebugUtilsMessengerEXT DebugMessenger = VK_NULL_HANDLE;
3887-
#endif
3886+
VkDebugUtilsMessengerEXT DebugMessenger =
3887+
DebugUtilsEnabled ? registerDebugUtilCallback(Instance) : VK_NULL_HANDLE;
38883888

38893889
const std::shared_ptr<VulkanInstance> VulkanInstanceShPtr =
38903890
std::make_shared<VulkanInstance>(Instance, DebugMessenger);

0 commit comments

Comments
 (0)