vrclient: Substitute Win32 extensions in GetVulkanDeviceExtensionsRequired().

CW-Bug-Id: #24553
This commit is contained in:
Paul Gofman 2024-12-05 14:42:31 -06:00
parent 322e0489c2
commit 8c3e86c52c

View File

@ -4,6 +4,8 @@
#pragma makedep unix #pragma makedep unix
#endif #endif
WINE_DEFAULT_DEBUG_CHANNEL(vrclient);
static u_VRVulkanTextureData_t *unwrap_texture_vkdata( const w_VRVulkanTextureData_t *w_vkdata, u_VRVulkanTextureData_t *u_vkdata ) static u_VRVulkanTextureData_t *unwrap_texture_vkdata( const w_VRVulkanTextureData_t *w_vkdata, u_VRVulkanTextureData_t *u_vkdata )
{ {
if (!w_vkdata) return NULL; if (!w_vkdata) return NULL;
@ -112,8 +114,60 @@ static u_Texture_t *unwrap_submit_texture_data( const w_VRTextureWithPoseAndDept
template <typename Params, typename Iface> template <typename Params, typename Iface>
NTSTATUS get_vulkan_device_extensions_required( Params *params, Iface *iface ) 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 ); 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; return 0;
} }