From d1d841e7c3b7887831e5dce38b51b2ca42fcab3c Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 30 Jul 2020 18:01:17 +0100 Subject: [PATCH] xrt: Use new info struct for compositor formats --- src/xrt/compositor/client/comp_gl_client.c | 8 ++++---- src/xrt/compositor/client/comp_vk_client.c | 6 +++--- src/xrt/compositor/main/comp_compositor.c | 16 +++++++++------- src/xrt/include/xrt/xrt_compositor.h | 9 ++------- src/xrt/ipc/ipc_client_compositor.c | 6 +++--- src/xrt/ipc/ipc_server_client.c | 6 +++--- src/xrt/state_trackers/oxr/oxr_session.c | 2 +- 7 files changed, 25 insertions(+), 28 deletions(-) diff --git a/src/xrt/compositor/client/comp_gl_client.c b/src/xrt/compositor/client/comp_gl_client.c index ae82cd43d..74fcabc03 100644 --- a/src/xrt/compositor/client/comp_gl_client.c +++ b/src/xrt/compositor/client/comp_gl_client.c @@ -380,15 +380,15 @@ client_gl_compositor_init(struct client_gl_compositor *c, // Passthrough our formats from the native compositor to the client. size_t count = 0; - for (uint32_t i = 0; i < xcn->base.num_formats; i++) { - int64_t f = vk_format_to_gl(xcn->base.formats[i]); + for (uint32_t i = 0; i < xcn->base.info.num_formats; i++) { + int64_t f = vk_format_to_gl(xcn->base.info.formats[i]); if (f == 0) { continue; } - c->base.base.formats[count++] = f; + c->base.base.info.formats[count++] = f; } - c->base.base.num_formats = count; + c->base.base.info.num_formats = count; #if defined(XRT_HAVE_OPENGL) gladLoadGL(get_gl_procaddr); diff --git a/src/xrt/compositor/client/comp_vk_client.c b/src/xrt/compositor/client/comp_vk_client.c index 049862a3a..99cf17183 100644 --- a/src/xrt/compositor/client/comp_vk_client.c +++ b/src/xrt/compositor/client/comp_vk_client.c @@ -474,11 +474,11 @@ client_vk_compositor_create(struct xrt_compositor_native *xcn, c->xcn = xcn; // passthrough our formats from the native compositor to the client - for (uint32_t i = 0; i < xcn->base.num_formats; i++) { - c->base.base.formats[i] = xcn->base.formats[i]; + for (uint32_t i = 0; i < xcn->base.info.num_formats; i++) { + c->base.base.info.formats[i] = xcn->base.info.formats[i]; } - c->base.base.num_formats = xcn->base.num_formats; + c->base.base.info.num_formats = xcn->base.info.num_formats; ret = vk_init_from_given(&c->vk, getProc, instance, physicalDevice, device, queueFamilyIndex, queueIndex); diff --git a/src/xrt/compositor/main/comp_compositor.c b/src/xrt/compositor/main/comp_compositor.c index cb910fcf7..cea4edb54 100644 --- a/src/xrt/compositor/main/comp_compositor.c +++ b/src/xrt/compositor/main/comp_compositor.c @@ -998,13 +998,15 @@ xrt_gfx_provider_create_native(struct xrt_device *xdev) * two formats should not be used as they are linear but doesn't have * enough bits to express it without resulting in banding. */ - c->base.base.formats[0] = VK_FORMAT_R8G8B8A8_SRGB; // OGL VK - c->base.base.formats[1] = VK_FORMAT_A2B10G10R10_UNORM_PACK32; // OGL VK - c->base.base.formats[2] = VK_FORMAT_R16G16B16A16_SFLOAT; // OGL VK - c->base.base.formats[3] = VK_FORMAT_B8G8R8A8_SRGB; // VK - c->base.base.formats[4] = VK_FORMAT_R8G8B8A8_UNORM; // OGL VK - c->base.base.formats[5] = VK_FORMAT_B8G8R8A8_UNORM; // VK - c->base.base.num_formats = 6; + // clang-format off + c->base.base.info.formats[0] = VK_FORMAT_R8G8B8A8_SRGB; // OGL VK + c->base.base.info.formats[1] = VK_FORMAT_A2B10G10R10_UNORM_PACK32; // OGL VK + c->base.base.info.formats[2] = VK_FORMAT_R16G16B16A16_SFLOAT; // OGL VK + c->base.base.info.formats[3] = VK_FORMAT_B8G8R8A8_SRGB; // VK + c->base.base.info.formats[4] = VK_FORMAT_R8G8B8A8_UNORM; // OGL VK + c->base.base.info.formats[5] = VK_FORMAT_B8G8R8A8_UNORM; // VK + c->base.base.info.num_formats = 6; + // clang-format on u_var_add_root(c, "Compositor", true); u_var_add_ro_f32(c, &c->compositor_frame_times.fps, "FPS (Compositor)"); diff --git a/src/xrt/include/xrt/xrt_compositor.h b/src/xrt/include/xrt/xrt_compositor.h index 6f10af0f8..47fcc744a 100644 --- a/src/xrt/include/xrt/xrt_compositor.h +++ b/src/xrt/include/xrt/xrt_compositor.h @@ -453,14 +453,9 @@ struct xrt_compositor_info struct xrt_compositor { /*! - * Number of formats. + * Capabilities and recommended values information. */ - uint32_t num_formats; - - /*! - * Supported formats. - */ - int64_t formats[XRT_MAX_SWAPCHAIN_FORMATS]; + struct xrt_compositor_info info; /*! * Create a swapchain with a set of images. diff --git a/src/xrt/ipc/ipc_client_compositor.c b/src/xrt/ipc/ipc_client_compositor.c index cdc665cb6..79bb4e7d1 100644 --- a/src/xrt/ipc/ipc_client_compositor.c +++ b/src/xrt/ipc/ipc_client_compositor.c @@ -535,11 +535,11 @@ ipc_client_compositor_create(struct ipc_connection *ipc_c, uint32_t num_formats = 0; ipc_compositor_get_formats(&(c->base.base), &num_formats, formats); // TODO: client compositor format count is hardcoded - c->base.base.num_formats = 0; + c->base.base.info.num_formats = 0; for (uint32_t i = 0; i < 8; i++) { if (i < num_formats) { - c->base.base.formats[i] = formats[i]; - c->base.base.num_formats++; + c->base.base.info.formats[i] = formats[i]; + c->base.base.info.num_formats++; } } diff --git a/src/xrt/ipc/ipc_server_client.c b/src/xrt/ipc/ipc_server_client.c index d030d5001..2a446322f 100644 --- a/src/xrt/ipc/ipc_server_client.c +++ b/src/xrt/ipc/ipc_server_client.c @@ -127,9 +127,9 @@ xrt_result_t ipc_handle_compositor_get_formats(volatile struct ipc_client_state *ics, struct ipc_formats_info *out_info) { - out_info->num_formats = ics->xc->num_formats; - for (size_t i = 0; i < ics->xc->num_formats; i++) { - out_info->formats[i] = ics->xc->formats[i]; + out_info->num_formats = ics->xc->info.num_formats; + for (size_t i = 0; i < ics->xc->info.num_formats; i++) { + out_info->formats[i] = ics->xc->info.formats[i]; } return XRT_SUCCESS; diff --git a/src/xrt/state_trackers/oxr/oxr_session.c b/src/xrt/state_trackers/oxr/oxr_session.c index 967b1328d..fec4d1a87 100644 --- a/src/xrt/state_trackers/oxr/oxr_session.c +++ b/src/xrt/state_trackers/oxr/oxr_session.c @@ -112,7 +112,7 @@ oxr_session_enumerate_formats(struct oxr_logger *log, } OXR_TWO_CALL_HELPER(log, formatCapacityInput, formatCountOutput, - formats, xc->num_formats, xc->formats, + formats, xc->info.num_formats, xc->info.formats, oxr_session_success_result(sess)); }