Vulkan:AMD vkCmdDebugMarkerBeginEXT 仅在 vkGetInstanceProcAddr 中找到

Vulkan: AMD vkCmdDebugMarkerBeginEXT only found with vkGetInstanceProcAddr

我 运行 使用 vkGetDeviceProcAddr 获取 vkCmdDebugMarkerBeginEXT 的句柄时出现了一些奇怪的行为,这在 AMD 和 Nvidia 之间是不同的。但是,使用 vkGetInstanceProcAddr 是可行的。

VkDevice device = ...; // valid initialized device
VkInstance instance = ...; // valid initialized instance

PFN_vkVoidFunction fnDevice = vkGetDeviceProcAddr(device, "vkCmdDebugMarkerBeginEXT");
// fnDevice == nullptr on AMD. Non-null on Nvidia
PFN_vkVoidFunction fnInstance = vkGetInstanceProcAddr(instance, "vkCmdDebugMarkerBeginEXT");
// fnInstance == Non-null on both

来自 layer interface 文档:

vkGetDeviceProcAddr can only be used to query for device extension or core device entry points. Device entry points include any command that uses a VkDevice as the first parameter or a dispatchable object that is a child of a VkDevice (currently this includes VkQueue and VkCommandBuffer). vkGetInstanceProcAddr can be used to query either device or instance extension entry points in addition to all core entry points.

vkCmdDebugMarkerBeginEXT 的原型似乎符合以下描述:

VKAPI_ATTR void VKAPI_CALL vkCmdDebugMarkerBeginEXT(
    VkCommandBuffer                             commandBuffer,
    VkDebugMarkerMarkerInfoEXT*                 pMarkerInfo);

虽然我可以很容易地调用设备版本,如果失败,调用实例版本(以避免额外的调度成本,如果可能的话),我想知道这是预期的行为还是驱动程序错误?

是的,vkCmdDebugMarkerBeginEXT符合该描述。

你应该引用 Vulkan spec 代替(IMO 在这件事上应该有更高的指定权力)。

还有一个额外的要求:必须在 device 上启用特定的扩展,vkGetDeviceProcAddr 才能工作。否则似乎是驱动程序错误。

事实上,in-spec Example 2确实使用了vkGetDeviceProcAddr