Skip to content

Commit 242734e

Browse files
HgiVulkan: Incorrect Surface Check
The current code only checks if the base surface extension is available, but doesn't check if the platform specific surface extension is available. Resulting in the `_hasPresentation` to be set in cases where it shouldn't. Detected when trying to render via SSH using Vulkan. See https://projects.blender.org/blender/blender/issues/149631 for information.
1 parent b46f16c commit 242734e

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

pxr/imaging/hgiVulkan/instance.cpp

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -101,21 +101,26 @@ HgiVulkanInstance::HgiVulkanInstance()
101101
VkInstanceCreateInfo createInfo = {VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO};
102102
createInfo.pApplicationInfo = &appInfo;
103103

104+
const char * surfaceExtensionName = nullptr;
105+
// Pick platform specific surface extension
106+
#if defined(VK_USE_PLATFORM_WIN32_KHR)
107+
surfaceExtensionName = VK_KHR_WIN32_SURFACE_EXTENSION_NAME;
108+
#elif defined(VK_USE_PLATFORM_XLIB_KHR)
109+
surfaceExtensionName = VK_KHR_XLIB_SURFACE_EXTENSION_NAME;
110+
#elif defined(VK_USE_PLATFORM_METAL_EXT)
111+
surfaceExtensionName = VK_EXT_METAL_SURFACE_EXTENSION_NAME;
112+
#else
113+
#error Unsupported Platform
114+
#endif
115+
104116
// Setup instance extensions.
105117
std::vector<const char*> extensions = {
106118
VK_KHR_SURFACE_EXTENSION_NAME,
107-
108-
// Pick platform specific surface extension
109-
#if defined(VK_USE_PLATFORM_WIN32_KHR)
110-
VK_KHR_WIN32_SURFACE_EXTENSION_NAME,
111-
#elif defined(VK_USE_PLATFORM_XLIB_KHR)
112-
VK_KHR_XLIB_SURFACE_EXTENSION_NAME,
113-
#elif defined(VK_USE_PLATFORM_METAL_EXT)
114-
VK_EXT_METAL_SURFACE_EXTENSION_NAME,
119+
surfaceExtensionName,
120+
121+
#if defined(VK_USE_PLATFORM_METAL_EXT)
115122
// See: https://github.com/KhronosGroup/MoltenVK/blob/main/Docs/MoltenVK_Runtime_UserGuide.md#interacting-with-the-moltenvk-runtime
116123
VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME,
117-
#else
118-
#error Unsupported Platform
119124
#endif
120125

121126
// Extensions for interop with OpenGL
@@ -151,8 +156,8 @@ HgiVulkanInstance::HgiVulkanInstance()
151156
extensions = _RemoveUnsupportedInstanceExtensions(extensions);
152157

153158
_hasPresentation = std::any_of(extensions.begin(), extensions.end(),
154-
[](const char* extensionName) {
155-
return strcmp(extensionName, VK_KHR_SURFACE_EXTENSION_NAME) == 0;
159+
[&](const char* extensionName) {
160+
return strcmp(extensionName, surfaceExtensionName) == 0;
156161
});
157162

158163
createInfo.ppEnabledLayerNames = layers.data();

0 commit comments

Comments
 (0)