diff --git a/vrclient_x64/unix_vrcompositor_manual.cpp b/vrclient_x64/unix_vrcompositor_manual.cpp index 14152120..2668e31b 100644 --- a/vrclient_x64/unix_vrcompositor_manual.cpp +++ b/vrclient_x64/unix_vrcompositor_manual.cpp @@ -4,6 +4,8 @@ #pragma makedep unix #endif +WINE_DEFAULT_DEBUG_CHANNEL(vrclient); + static u_VRVulkanTextureData_t *unwrap_texture_vkdata( const w_VRVulkanTextureData_t *w_vkdata, u_VRVulkanTextureData_t *u_vkdata ) { if (!w_vkdata) return NULL; @@ -112,8 +114,60 @@ static u_Texture_t *unwrap_submit_texture_data( const w_VRTextureWithPoseAndDept template NTSTATUS get_vulkan_device_extensions_required( Params *params, Iface *iface ) { + static const struct + { + const char *unix_ext; + const char *win_ext; + } + exts[] = + { + { "VK_KHR_external_memory_fd", "VK_KHR_external_memory_win32" }, + { "VK_KHR_external_semaphore_fd", "VK_KHR_external_semaphore_win32" }, + }; VkPhysicalDevice_T *host_device = p_get_native_VkPhysicalDevice( params->pPhysicalDevice ); - params->_ret = (uint32_t)iface->GetVulkanDeviceExtensionsRequired( host_device, params->pchValue, params->unBufferSize ); + char buffer[2048], *p, *end, *next; + uint32_t i, len; + + len = iface->GetVulkanDeviceExtensionsRequired( host_device, buffer, sizeof(buffer) ); + if (!len || len > sizeof(buffer)) + { + ERR( "len %u.\n", len ); + params->_ret = 0; + return 0; + } + + p = buffer; + end = p + strlen(p); + while (1) + { + while (isspace(*p)) ++p; + if (!*p) break; + next = p + 1; + while (*next && !isspace(*next)) ++next; + for (i = 0; i < ARRAY_SIZE(exts); ++i) + { + len = strlen( exts[i].unix_ext ); + if (len == next - p && !memcmp( p, exts[i].unix_ext, len )) + { + len = strlen( exts[i].win_ext ); + if (end - next + 1 + len + (p - buffer) > sizeof(buffer)) + { + ERR( "buffer overflow.\n" ); + params->_ret = 0; + return 0; + } + memmove( p + len, next, end - next + 1 ); + memcpy( p, exts[i].win_ext, len ); + end = p + len + (end - next); + next = p + len; + break; + } + } + p = next; + } + params->_ret = end - buffer + 1; + if (params->pchValue && params->unBufferSize >= params->_ret) + memcpy( params->pchValue, buffer, params->_ret ); return 0; }