From 1adf46b02a9adcddc6594c884b27c30b4a912a33 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Fri, 7 Apr 2023 19:08:04 +0100 Subject: [PATCH] c/client: Use correct format in get_swapchain_create_properties funtions --- src/xrt/compositor/client/comp_d3d11_client.cpp | 11 ++++++++++- src/xrt/compositor/client/comp_d3d12_client.cpp | 11 ++++++++++- src/xrt/compositor/client/comp_gl_client.c | 9 +++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/xrt/compositor/client/comp_d3d11_client.cpp b/src/xrt/compositor/client/comp_d3d11_client.cpp index 002bc8dc5..af206a3b8 100644 --- a/src/xrt/compositor/client/comp_d3d11_client.cpp +++ b/src/xrt/compositor/client/comp_d3d11_client.cpp @@ -691,7 +691,16 @@ client_d3d11_compositor_get_swapchain_create_properties(struct xrt_compositor *x { struct client_d3d11_compositor *c = as_client_d3d11_compositor(xc); - return xrt_comp_get_swapchain_create_properties(&c->xcn->base, info, xsccp); + int64_t vk_format = d3d_dxgi_format_to_vk((DXGI_FORMAT)info->format); + if (vk_format == 0) { + D3D_ERROR(c, "Invalid format!"); + return XRT_ERROR_SWAPCHAIN_FORMAT_UNSUPPORTED; + } + + struct xrt_swapchain_create_info xinfo = *info; + xinfo.format = vk_format; + + return xrt_comp_get_swapchain_create_properties(&c->xcn->base, &xinfo, xsccp); } static xrt_result_t diff --git a/src/xrt/compositor/client/comp_d3d12_client.cpp b/src/xrt/compositor/client/comp_d3d12_client.cpp index 9486fa635..dc94f7077 100644 --- a/src/xrt/compositor/client/comp_d3d12_client.cpp +++ b/src/xrt/compositor/client/comp_d3d12_client.cpp @@ -791,7 +791,16 @@ client_d3d12_compositor_get_swapchain_create_properties(struct xrt_compositor *x { struct client_d3d12_compositor *c = as_client_d3d12_compositor(xc); - return xrt_comp_get_swapchain_create_properties(&c->xcn->base, info, xsccp); + int64_t vk_format = d3d_dxgi_format_to_vk((DXGI_FORMAT)info->format); + if (vk_format == 0) { + D3D_ERROR(c, "Invalid format!"); + return XRT_ERROR_SWAPCHAIN_FORMAT_UNSUPPORTED; + } + + struct xrt_swapchain_create_info xinfo = *info; + xinfo.format = vk_format; + + return xrt_comp_get_swapchain_create_properties(&c->xcn->base, &xinfo, xsccp); } static xrt_result_t diff --git a/src/xrt/compositor/client/comp_gl_client.c b/src/xrt/compositor/client/comp_gl_client.c index 4ab92f0fb..29f24370a 100644 --- a/src/xrt/compositor/client/comp_gl_client.c +++ b/src/xrt/compositor/client/comp_gl_client.c @@ -398,6 +398,15 @@ client_gl_compositor_get_swapchain_create_properties(struct xrt_compositor *xc, { struct client_gl_compositor *c = client_gl_compositor(xc); + int64_t vk_format = gl_format_to_vk(info->format); + if (vk_format == 0) { + U_LOG_E("Invalid format!"); + return XRT_ERROR_SWAPCHAIN_FORMAT_UNSUPPORTED; + } + + struct xrt_swapchain_create_info vkinfo = *info; + vkinfo.format = vk_format; + return xrt_comp_get_swapchain_create_properties(&c->xcn->base, info, xsccp); }