我在使用 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
的原型(prototype)似乎符合以下描述:
VKAPI_ATTR void VKAPI_CALL vkCmdDebugMarkerBeginEXT(
VkCommandBuffer commandBuffer,
VkDebugMarkerMarkerInfoEXT* pMarkerInfo);
虽然我可以很容易地调用设备版本,如果失败,调用实例版本(以避免额外的调度成本,如果可能的话),我想知道这是预期的行为还是驱动程序错误?
最佳答案
是的,vkCmdDebugMarkerBeginEXT
符合该描述。
你应该引用 Vulkan spec相反(IMO 在这件事上应该有更高的指定权力)。
还有一个附加要求:必须在该设备
上启用特定扩展,vkGetDeviceProcAddr
才能工作。否则看起来像是驱动程序错误。
事实上,in-spec Example 2确实使用 vkGetDeviceProcAddr
。
关于c++ - Vulkan:AMD vkCmdDebugMarkerBeginEXT 仅在 vkGetInstanceProcAddr 中找到,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43005218/