xrt: Use new info struct for compositor formats

This commit is contained in:
Jakob Bornecrantz 2020-07-30 18:01:17 +01:00 committed by Jakob Bornecrantz
parent 0adfeb77a1
commit d1d841e7c3
7 changed files with 25 additions and 28 deletions

View file

@ -380,15 +380,15 @@ client_gl_compositor_init(struct client_gl_compositor *c,
// Passthrough our formats from the native compositor to the client. // Passthrough our formats from the native compositor to the client.
size_t count = 0; size_t count = 0;
for (uint32_t i = 0; i < xcn->base.num_formats; i++) { for (uint32_t i = 0; i < xcn->base.info.num_formats; i++) {
int64_t f = vk_format_to_gl(xcn->base.formats[i]); int64_t f = vk_format_to_gl(xcn->base.info.formats[i]);
if (f == 0) { if (f == 0) {
continue; 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) #if defined(XRT_HAVE_OPENGL)
gladLoadGL(get_gl_procaddr); gladLoadGL(get_gl_procaddr);

View file

@ -474,11 +474,11 @@ client_vk_compositor_create(struct xrt_compositor_native *xcn,
c->xcn = xcn; c->xcn = xcn;
// passthrough our formats from the native compositor to the client // passthrough our formats from the native compositor to the client
for (uint32_t i = 0; i < xcn->base.num_formats; i++) { for (uint32_t i = 0; i < xcn->base.info.num_formats; i++) {
c->base.base.formats[i] = xcn->base.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, ret = vk_init_from_given(&c->vk, getProc, instance, physicalDevice,
device, queueFamilyIndex, queueIndex); device, queueFamilyIndex, queueIndex);

View file

@ -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 * two formats should not be used as they are linear but doesn't have
* enough bits to express it without resulting in banding. * enough bits to express it without resulting in banding.
*/ */
c->base.base.formats[0] = VK_FORMAT_R8G8B8A8_SRGB; // OGL VK // clang-format off
c->base.base.formats[1] = VK_FORMAT_A2B10G10R10_UNORM_PACK32; // OGL VK c->base.base.info.formats[0] = VK_FORMAT_R8G8B8A8_SRGB; // OGL VK
c->base.base.formats[2] = VK_FORMAT_R16G16B16A16_SFLOAT; // OGL VK c->base.base.info.formats[1] = VK_FORMAT_A2B10G10R10_UNORM_PACK32; // OGL VK
c->base.base.formats[3] = VK_FORMAT_B8G8R8A8_SRGB; // VK c->base.base.info.formats[2] = VK_FORMAT_R16G16B16A16_SFLOAT; // OGL VK
c->base.base.formats[4] = VK_FORMAT_R8G8B8A8_UNORM; // OGL VK c->base.base.info.formats[3] = VK_FORMAT_B8G8R8A8_SRGB; // VK
c->base.base.formats[5] = VK_FORMAT_B8G8R8A8_UNORM; // VK c->base.base.info.formats[4] = VK_FORMAT_R8G8B8A8_UNORM; // OGL VK
c->base.base.num_formats = 6; 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_root(c, "Compositor", true);
u_var_add_ro_f32(c, &c->compositor_frame_times.fps, "FPS (Compositor)"); u_var_add_ro_f32(c, &c->compositor_frame_times.fps, "FPS (Compositor)");

View file

@ -453,14 +453,9 @@ struct xrt_compositor_info
struct xrt_compositor struct xrt_compositor
{ {
/*! /*!
* Number of formats. * Capabilities and recommended values information.
*/ */
uint32_t num_formats; struct xrt_compositor_info info;
/*!
* Supported formats.
*/
int64_t formats[XRT_MAX_SWAPCHAIN_FORMATS];
/*! /*!
* Create a swapchain with a set of images. * Create a swapchain with a set of images.

View file

@ -535,11 +535,11 @@ ipc_client_compositor_create(struct ipc_connection *ipc_c,
uint32_t num_formats = 0; uint32_t num_formats = 0;
ipc_compositor_get_formats(&(c->base.base), &num_formats, formats); ipc_compositor_get_formats(&(c->base.base), &num_formats, formats);
// TODO: client compositor format count is hardcoded // 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++) { for (uint32_t i = 0; i < 8; i++) {
if (i < num_formats) { if (i < num_formats) {
c->base.base.formats[i] = formats[i]; c->base.base.info.formats[i] = formats[i];
c->base.base.num_formats++; c->base.base.info.num_formats++;
} }
} }

View file

@ -127,9 +127,9 @@ xrt_result_t
ipc_handle_compositor_get_formats(volatile struct ipc_client_state *ics, ipc_handle_compositor_get_formats(volatile struct ipc_client_state *ics,
struct ipc_formats_info *out_info) struct ipc_formats_info *out_info)
{ {
out_info->num_formats = ics->xc->num_formats; out_info->num_formats = ics->xc->info.num_formats;
for (size_t i = 0; i < ics->xc->num_formats; i++) { for (size_t i = 0; i < ics->xc->info.num_formats; i++) {
out_info->formats[i] = ics->xc->formats[i]; out_info->formats[i] = ics->xc->info.formats[i];
} }
return XRT_SUCCESS; return XRT_SUCCESS;

View file

@ -112,7 +112,7 @@ oxr_session_enumerate_formats(struct oxr_logger *log,
} }
OXR_TWO_CALL_HELPER(log, formatCapacityInput, formatCountOutput, 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)); oxr_session_success_result(sess));
} }