ipc: Replace IPC_CHK_CALL macro with other helper

This commit is contained in:
Jakob Bornecrantz 2023-11-13 17:25:31 +00:00
parent 8d61577081
commit bfaf615d4f

View file

@ -144,28 +144,20 @@ ipc_client_compositor_semaphore(struct xrt_compositor_semaphore *xcsem)
* *
*/ */
#define IPC_CALL_CHK(call) \
xrt_result_t res = (call); \
if (res != XRT_SUCCESS) { \
IPC_ERROR(icc->ipc_c, "Call error '%i'!", res); \
}
static xrt_result_t static xrt_result_t
get_info(struct xrt_compositor *xc, struct xrt_compositor_info *out_info) get_info(struct xrt_compositor *xc, struct xrt_compositor_info *out_info)
{ {
struct ipc_client_compositor *icc = ipc_client_compositor(xc); struct ipc_client_compositor *icc = ipc_client_compositor(xc);
IPC_CALL_CHK(ipc_call_compositor_get_info(icc->ipc_c, out_info)); xrt_result_t xret = ipc_call_compositor_get_info(icc->ipc_c, out_info);
IPC_CHK_ALWAYS_RET(icc->ipc_c, xret, "ipc_call_compositor_get_info");
return res;
} }
static xrt_result_t static xrt_result_t
get_system_info(struct ipc_client_compositor *icc, struct xrt_system_compositor_info *out_info) get_system_info(struct ipc_client_compositor *icc, struct xrt_system_compositor_info *out_info)
{ {
IPC_CALL_CHK(ipc_call_system_compositor_get_info(icc->ipc_c, out_info)); xrt_result_t xret = ipc_call_system_compositor_get_info(icc->ipc_c, out_info);
IPC_CHK_ALWAYS_RET(icc->ipc_c, xret, "ipc_call_system_compositor_get_info");
return res;
} }
@ -180,8 +172,12 @@ ipc_compositor_swapchain_destroy(struct xrt_swapchain *xsc)
{ {
struct ipc_client_swapchain *ics = ipc_client_swapchain(xsc); struct ipc_client_swapchain *ics = ipc_client_swapchain(xsc);
struct ipc_client_compositor *icc = ics->icc; struct ipc_client_compositor *icc = ics->icc;
xrt_result_t xret;
IPC_CALL_CHK(ipc_call_swapchain_destroy(icc->ipc_c, ics->id)); xret = ipc_call_swapchain_destroy(icc->ipc_c, ics->id);
// Can't return anything here, just continue.
IPC_CHK_ONLY_PRINT(icc->ipc_c, xret, "ipc_call_compositor_semaphore_destroy");
free(xsc); free(xsc);
} }
@ -191,10 +187,10 @@ ipc_compositor_swapchain_wait_image(struct xrt_swapchain *xsc, uint64_t timeout_
{ {
struct ipc_client_swapchain *ics = ipc_client_swapchain(xsc); struct ipc_client_swapchain *ics = ipc_client_swapchain(xsc);
struct ipc_client_compositor *icc = ics->icc; struct ipc_client_compositor *icc = ics->icc;
xrt_result_t xret;
IPC_CALL_CHK(ipc_call_swapchain_wait_image(icc->ipc_c, ics->id, timeout_ns, index)); xret = ipc_call_swapchain_wait_image(icc->ipc_c, ics->id, timeout_ns, index);
IPC_CHK_ALWAYS_RET(icc->ipc_c, xret, "ipc_call_swapchain_wait_image");
return res;
} }
static xrt_result_t static xrt_result_t
@ -202,10 +198,10 @@ ipc_compositor_swapchain_acquire_image(struct xrt_swapchain *xsc, uint32_t *out_
{ {
struct ipc_client_swapchain *ics = ipc_client_swapchain(xsc); struct ipc_client_swapchain *ics = ipc_client_swapchain(xsc);
struct ipc_client_compositor *icc = ics->icc; struct ipc_client_compositor *icc = ics->icc;
xrt_result_t xret;
IPC_CALL_CHK(ipc_call_swapchain_acquire_image(icc->ipc_c, ics->id, out_index)); xret = ipc_call_swapchain_acquire_image(icc->ipc_c, ics->id, out_index);
IPC_CHK_ALWAYS_RET(icc->ipc_c, xret, "ipc_call_swapchain_acquire_image");
return res;
} }
static xrt_result_t static xrt_result_t
@ -213,10 +209,10 @@ ipc_compositor_swapchain_release_image(struct xrt_swapchain *xsc, uint32_t index
{ {
struct ipc_client_swapchain *ics = ipc_client_swapchain(xsc); struct ipc_client_swapchain *ics = ipc_client_swapchain(xsc);
struct ipc_client_compositor *icc = ics->icc; struct ipc_client_compositor *icc = ics->icc;
xrt_result_t xret;
IPC_CALL_CHK(ipc_call_swapchain_release_image(icc->ipc_c, ics->id, index)); xret = ipc_call_swapchain_release_image(icc->ipc_c, ics->id, index);
IPC_CHK_ALWAYS_RET(icc->ipc_c, xret, "ipc_call_swapchain_release_image");
return res;
} }
@ -242,8 +238,12 @@ ipc_client_compositor_semaphore_destroy(struct xrt_compositor_semaphore *xcsem)
{ {
struct ipc_client_compositor_semaphore *iccs = ipc_client_compositor_semaphore(xcsem); struct ipc_client_compositor_semaphore *iccs = ipc_client_compositor_semaphore(xcsem);
struct ipc_client_compositor *icc = iccs->icc; struct ipc_client_compositor *icc = iccs->icc;
xrt_result_t xret;
IPC_CALL_CHK(ipc_call_compositor_semaphore_destroy(icc->ipc_c, iccs->id)); xret = ipc_call_compositor_semaphore_destroy(icc->ipc_c, iccs->id);
// Can't return anything here, just continue.
IPC_CHK_ONLY_PRINT(icc->ipc_c, xret, "ipc_call_compositor_semaphore_destroy");
free(iccs); free(iccs);
} }
@ -261,10 +261,10 @@ ipc_compositor_get_swapchain_create_properties(struct xrt_compositor *xc,
struct xrt_swapchain_create_properties *xsccp) struct xrt_swapchain_create_properties *xsccp)
{ {
struct ipc_client_compositor *icc = ipc_client_compositor(xc); struct ipc_client_compositor *icc = ipc_client_compositor(xc);
xrt_result_t xret;
IPC_CALL_CHK(ipc_call_swapchain_get_properties(icc->ipc_c, info, xsccp)); xret = ipc_call_swapchain_get_properties(icc->ipc_c, info, xsccp);
IPC_CHK_ALWAYS_RET(icc->ipc_c, xret, "ipc_call_swapchain_get_properties");
return res;
} }
static xrt_result_t static xrt_result_t
@ -273,23 +273,22 @@ swapchain_server_create(struct ipc_client_compositor *icc,
struct xrt_swapchain **out_xsc) struct xrt_swapchain **out_xsc)
{ {
xrt_graphics_buffer_handle_t remote_handles[XRT_MAX_SWAPCHAIN_IMAGES] = {0}; xrt_graphics_buffer_handle_t remote_handles[XRT_MAX_SWAPCHAIN_IMAGES] = {0};
xrt_result_t r = XRT_SUCCESS; xrt_result_t xret;
uint32_t handle; uint32_t handle;
uint32_t image_count; uint32_t image_count;
uint64_t size; uint64_t size;
bool use_dedicated_allocation; bool use_dedicated_allocation;
r = ipc_call_swapchain_create(icc->ipc_c, // connection xret = ipc_call_swapchain_create( //
info, // in icc->ipc_c, // connection
&handle, // out info, // in
&image_count, // out &handle, // out
&size, // out &image_count, // out
&use_dedicated_allocation, // out &size, // out
remote_handles, // handles &use_dedicated_allocation, // out
XRT_MAX_SWAPCHAIN_IMAGES); // handles remote_handles, // handles
if (r != XRT_SUCCESS) { XRT_MAX_SWAPCHAIN_IMAGES); // handles
return r; IPC_CHK_AND_RET(icc->ipc_c, xret, "ipc_call_swapchain_create");
}
struct ipc_client_swapchain *ics = U_TYPED_CALLOC(struct ipc_client_swapchain); struct ipc_client_swapchain *ics = U_TYPED_CALLOC(struct ipc_client_swapchain);
ics->base.base.image_count = image_count; ics->base.base.image_count = image_count;
@ -322,7 +321,7 @@ swapchain_server_import(struct ipc_client_compositor *icc,
{ {
struct ipc_arg_swapchain_from_native args = {0}; struct ipc_arg_swapchain_from_native args = {0};
xrt_graphics_buffer_handle_t handles[XRT_MAX_SWAPCHAIN_IMAGES] = {0}; xrt_graphics_buffer_handle_t handles[XRT_MAX_SWAPCHAIN_IMAGES] = {0};
xrt_result_t r = XRT_SUCCESS; xrt_result_t xret;
uint32_t id = 0; uint32_t id = 0;
for (uint32_t i = 0; i < image_count; i++) { for (uint32_t i = 0; i < image_count; i++) {
@ -339,15 +338,14 @@ swapchain_server_import(struct ipc_client_compositor *icc,
} }
// This does not consume the handles, it copies them. // This does not consume the handles, it copies them.
r = ipc_call_swapchain_import(icc->ipc_c, // connection xret = ipc_call_swapchain_import( //
info, // in icc->ipc_c, // connection
&args, // in info, // in
handles, // handles &args, // in
image_count, // handles handles, // handles
&id); // out image_count, // handles
if (r != XRT_SUCCESS) { &id); // out
return r; IPC_CHK_AND_RET(icc->ipc_c, xret, "ipc_call_swapchain_create");
}
struct ipc_client_swapchain *ics = U_TYPED_CALLOC(struct ipc_client_swapchain); struct ipc_client_swapchain *ics = U_TYPED_CALLOC(struct ipc_client_swapchain);
ics->base.base.image_count = image_count; ics->base.base.image_count = image_count;
@ -382,25 +380,21 @@ swapchain_allocator_create(struct ipc_client_compositor *icc,
// Get any needed properties. // Get any needed properties.
xret = ipc_compositor_get_swapchain_create_properties(&icc->base.base, info, &xsccp); xret = ipc_compositor_get_swapchain_create_properties(&icc->base.base, info, &xsccp);
if (xret != XRT_SUCCESS) { IPC_CHK_AND_RET(icc->ipc_c, xret, "ipc_compositor_get_swapchain_create_properties");
// IPC error already reported.
return xret;
}
// Alloc the array of structs for the images. // Alloc the array of structs for the images.
images = U_TYPED_ARRAY_CALLOC(struct xrt_image_native, xsccp.image_count); images = U_TYPED_ARRAY_CALLOC(struct xrt_image_native, xsccp.image_count);
// Now allocate the images themselves // Now allocate the images themselves
xret = xrt_images_allocate(xina, info, xsccp.image_count, images); xret = xrt_images_allocate(xina, info, xsccp.image_count, images);
if (xret != XRT_SUCCESS) { IPC_CHK_WITH_GOTO(icc->ipc_c, xret, "xrt_images_allocate", out_free);
goto out_free;
}
/* /*
* The import function takes ownership of the handles, * The import function takes ownership of the handles,
* we do not need free them if the call succeeds. * we do not need free them if the call succeeds.
*/ */
xret = swapchain_server_import(icc, info, images, xsccp.image_count, out_xsc); xret = swapchain_server_import(icc, info, images, xsccp.image_count, out_xsc);
IPC_CHK_ONLY_PRINT(icc->ipc_c, xret, "swapchain_server_import");
if (xret != XRT_SUCCESS) { if (xret != XRT_SUCCESS) {
xrt_images_free(xina, xsccp.image_count, images); xrt_images_free(xina, xsccp.image_count, images);
} }
@ -418,15 +412,16 @@ ipc_compositor_swapchain_create(struct xrt_compositor *xc,
{ {
struct ipc_client_compositor *icc = ipc_client_compositor(xc); struct ipc_client_compositor *icc = ipc_client_compositor(xc);
struct xrt_image_native_allocator *xina = icc->xina; struct xrt_image_native_allocator *xina = icc->xina;
xrt_result_t r; xrt_result_t xret;
if (xina == NULL) { if (xina == NULL) {
r = swapchain_server_create(icc, info, out_xsc); xret = swapchain_server_create(icc, info, out_xsc);
} else { } else {
r = swapchain_allocator_create(icc, xina, info, out_xsc); xret = swapchain_allocator_create(icc, xina, info, out_xsc);
} }
return r; // Errors already printed.
return xret;
} }
static xrt_result_t static xrt_result_t
@ -437,6 +432,8 @@ ipc_compositor_swapchain_import(struct xrt_compositor *xc,
struct xrt_swapchain **out_xsc) struct xrt_swapchain **out_xsc)
{ {
struct ipc_client_compositor *icc = ipc_client_compositor(xc); struct ipc_client_compositor *icc = ipc_client_compositor(xc);
// Errors already printed.
return swapchain_server_import(icc, info, native_images, image_count, out_xsc); return swapchain_server_import(icc, info, native_images, image_count, out_xsc);
} }
@ -446,13 +443,12 @@ ipc_compositor_semaphore_create(struct xrt_compositor *xc,
struct xrt_compositor_semaphore **out_xcsem) struct xrt_compositor_semaphore **out_xcsem)
{ {
struct ipc_client_compositor *icc = ipc_client_compositor(xc); struct ipc_client_compositor *icc = ipc_client_compositor(xc);
uint32_t id = 0;
xrt_graphics_sync_handle_t handle = XRT_GRAPHICS_SYNC_HANDLE_INVALID; xrt_graphics_sync_handle_t handle = XRT_GRAPHICS_SYNC_HANDLE_INVALID;
xrt_result_t xret;
uint32_t id = 0;
IPC_CALL_CHK(ipc_call_compositor_semaphore_create(icc->ipc_c, &id, &handle, 1)); xret = ipc_call_compositor_semaphore_create(icc->ipc_c, &id, &handle, 1);
if (res != XRT_SUCCESS) { IPC_CHK_AND_RET(icc->ipc_c, xret, "ipc_call_compositor_semaphore_create");
return res;
}
struct ipc_client_compositor_semaphore *iccs = U_TYPED_CALLOC(struct ipc_client_compositor_semaphore); struct ipc_client_compositor_semaphore *iccs = U_TYPED_CALLOC(struct ipc_client_compositor_semaphore);
iccs->base.reference.count = 1; iccs->base.reference.count = 1;
@ -471,24 +467,24 @@ static xrt_result_t
ipc_compositor_poll_events(struct xrt_compositor *xc, union xrt_compositor_event *out_xce) ipc_compositor_poll_events(struct xrt_compositor *xc, union xrt_compositor_event *out_xce)
{ {
struct ipc_client_compositor *icc = ipc_client_compositor(xc); struct ipc_client_compositor *icc = ipc_client_compositor(xc);
xrt_result_t xret;
IPC_TRACE(icc->ipc_c, "Polling for events."); IPC_TRACE(icc->ipc_c, "Polling for events.");
IPC_CALL_CHK(ipc_call_compositor_poll_events(icc->ipc_c, out_xce)); xret = ipc_call_compositor_poll_events(icc->ipc_c, out_xce);
IPC_CHK_ALWAYS_RET(icc->ipc_c, xret, "ipc_call_compositor_poll_events");
return res;
} }
static xrt_result_t static xrt_result_t
ipc_compositor_begin_session(struct xrt_compositor *xc, const struct xrt_begin_session_info *info) ipc_compositor_begin_session(struct xrt_compositor *xc, const struct xrt_begin_session_info *info)
{ {
struct ipc_client_compositor *icc = ipc_client_compositor(xc); struct ipc_client_compositor *icc = ipc_client_compositor(xc);
xrt_result_t xret;
IPC_TRACE(icc->ipc_c, "Compositor begin session."); IPC_TRACE(icc->ipc_c, "Compositor begin session.");
IPC_CALL_CHK(ipc_call_session_begin(icc->ipc_c)); xret = ipc_call_session_begin(icc->ipc_c);
IPC_CHK_ALWAYS_RET(icc->ipc_c, xret, "ipc_call_session_begin");
return res;
} }
static xrt_result_t static xrt_result_t
@ -497,12 +493,12 @@ ipc_compositor_end_session(struct xrt_compositor *xc)
IPC_TRACE_MARKER(); IPC_TRACE_MARKER();
struct ipc_client_compositor *icc = ipc_client_compositor(xc); struct ipc_client_compositor *icc = ipc_client_compositor(xc);
xrt_result_t xret;
IPC_TRACE(icc->ipc_c, "Compositor end session."); IPC_TRACE(icc->ipc_c, "Compositor end session.");
IPC_CALL_CHK(ipc_call_session_end(icc->ipc_c)); xret = ipc_call_session_end(icc->ipc_c);
IPC_CHK_ALWAYS_RET(icc->ipc_c, xret, "ipc_call_session_end");
return res;
} }
static xrt_result_t static xrt_result_t
@ -513,41 +509,44 @@ ipc_compositor_wait_frame(struct xrt_compositor *xc,
{ {
IPC_TRACE_MARKER(); IPC_TRACE_MARKER();
struct ipc_client_compositor *icc = ipc_client_compositor(xc); struct ipc_client_compositor *icc = ipc_client_compositor(xc);
xrt_result_t xret;
int64_t frame_id = -1; int64_t frame_id = -1;
uint64_t wake_up_time_ns = 0; uint64_t wake_up_time_ns = 0;
uint64_t predicted_display_time = 0; uint64_t predicted_display_time = 0;
uint64_t predicted_display_period = 0; uint64_t predicted_display_period = 0;
IPC_CALL_CHK(ipc_call_compositor_predict_frame( // xret = ipc_call_compositor_predict_frame( //
icc->ipc_c, // Connection icc->ipc_c, // Connection
&frame_id, // Frame id &frame_id, // Frame id
&wake_up_time_ns, // When we should wake up &wake_up_time_ns, // When we should wake up
&predicted_display_time, // Display time &predicted_display_time, // Display time
&predicted_display_period)); // Current period &predicted_display_period); // Current period
IPC_CHK_AND_RET(icc->ipc_c, xret, "ipc_call_compositor_predict_frame");
// Wait until the given wake up time. // Wait until the given wake up time.
u_wait_until(&icc->sleeper, wake_up_time_ns); u_wait_until(&icc->sleeper, wake_up_time_ns);
// Signal that we woke up. // Signal that we woke up.
res = ipc_call_compositor_wait_woke(icc->ipc_c, frame_id); xret = ipc_call_compositor_wait_woke(icc->ipc_c, frame_id);
IPC_CHK_AND_RET(icc->ipc_c, xret, "ipc_call_compositor_wait_woke");
// Only write arguments once we have fully waited. // Only write arguments once we have fully waited.
*out_frame_id = frame_id; *out_frame_id = frame_id;
*out_predicted_display_time = predicted_display_time; *out_predicted_display_time = predicted_display_time;
*out_predicted_display_period = predicted_display_period; *out_predicted_display_period = predicted_display_period;
return res; return xret;
} }
static xrt_result_t static xrt_result_t
ipc_compositor_begin_frame(struct xrt_compositor *xc, int64_t frame_id) ipc_compositor_begin_frame(struct xrt_compositor *xc, int64_t frame_id)
{ {
struct ipc_client_compositor *icc = ipc_client_compositor(xc); struct ipc_client_compositor *icc = ipc_client_compositor(xc);
xrt_result_t xret;
IPC_CALL_CHK(ipc_call_compositor_begin_frame(icc->ipc_c, frame_id)); xret = ipc_call_compositor_begin_frame(icc->ipc_c, frame_id);
IPC_CHK_ALWAYS_RET(icc->ipc_c, xret, "ipc_call_compositor_begin_frame");
return res;
} }
static xrt_result_t static xrt_result_t
@ -705,6 +704,7 @@ static xrt_result_t
ipc_compositor_layer_commit(struct xrt_compositor *xc, xrt_graphics_sync_handle_t sync_handle) ipc_compositor_layer_commit(struct xrt_compositor *xc, xrt_graphics_sync_handle_t sync_handle)
{ {
struct ipc_client_compositor *icc = ipc_client_compositor(xc); struct ipc_client_compositor *icc = ipc_client_compositor(xc);
xrt_result_t xret;
bool valid_sync = xrt_graphics_sync_handle_is_valid(sync_handle); bool valid_sync = xrt_graphics_sync_handle_is_valid(sync_handle);
@ -714,12 +714,18 @@ ipc_compositor_layer_commit(struct xrt_compositor *xc, xrt_graphics_sync_handle_
// Last bit of data to put in the shared memory area. // Last bit of data to put in the shared memory area.
slot->layer_count = icc->layers.layer_count; slot->layer_count = icc->layers.layer_count;
IPC_CALL_CHK(ipc_call_compositor_layer_sync( // xret = ipc_call_compositor_layer_sync( //
icc->ipc_c, // icc->ipc_c, //
icc->layers.slot_id, // icc->layers.slot_id, //
&sync_handle, // &sync_handle, //
valid_sync ? 1 : 0, // valid_sync ? 1 : 0, //
&icc->layers.slot_id)); // &icc->layers.slot_id); //
/*
* We are probably in a really bad state if we fail, at
* least print out the error and continue as best we can.
*/
IPC_CHK_ONLY_PRINT(icc->ipc_c, xret, "ipc_call_compositor_layer_sync_with_semaphore");
// Reset. // Reset.
icc->layers.layer_count = 0; icc->layers.layer_count = 0;
@ -729,7 +735,7 @@ ipc_compositor_layer_commit(struct xrt_compositor *xc, xrt_graphics_sync_handle_
u_graphics_sync_unref(&sync_handle); u_graphics_sync_unref(&sync_handle);
} }
return res; return xret;
} }
static xrt_result_t static xrt_result_t
@ -739,6 +745,7 @@ ipc_compositor_layer_commit_with_semaphore(struct xrt_compositor *xc,
{ {
struct ipc_client_compositor *icc = ipc_client_compositor(xc); struct ipc_client_compositor *icc = ipc_client_compositor(xc);
struct ipc_client_compositor_semaphore *iccs = ipc_client_compositor_semaphore(xcsem); struct ipc_client_compositor_semaphore *iccs = ipc_client_compositor_semaphore(xcsem);
xrt_result_t xret;
struct ipc_shared_memory *ism = icc->ipc_c->ism; struct ipc_shared_memory *ism = icc->ipc_c->ism;
struct ipc_layer_slot *slot = &ism->slots[icc->layers.slot_id]; struct ipc_layer_slot *slot = &ism->slots[icc->layers.slot_id];
@ -746,47 +753,61 @@ ipc_compositor_layer_commit_with_semaphore(struct xrt_compositor *xc,
// Last bit of data to put in the shared memory area. // Last bit of data to put in the shared memory area.
slot->layer_count = icc->layers.layer_count; slot->layer_count = icc->layers.layer_count;
IPC_CALL_CHK(ipc_call_compositor_layer_sync_with_semaphore( // xret = ipc_call_compositor_layer_sync_with_semaphore( //
icc->ipc_c, // icc->ipc_c, //
icc->layers.slot_id, // icc->layers.slot_id, //
iccs->id, // iccs->id, //
value, // value, //
&icc->layers.slot_id)); // &icc->layers.slot_id); //
/*
* We are probably in a really bad state if we fail, at
* least print out the error and continue as best we can.
*/
IPC_CHK_ONLY_PRINT(icc->ipc_c, xret, "ipc_call_compositor_layer_sync_with_semaphore");
// Reset. // Reset.
icc->layers.layer_count = 0; icc->layers.layer_count = 0;
return res; return xret;
} }
static xrt_result_t static xrt_result_t
ipc_compositor_discard_frame(struct xrt_compositor *xc, int64_t frame_id) ipc_compositor_discard_frame(struct xrt_compositor *xc, int64_t frame_id)
{ {
struct ipc_client_compositor *icc = ipc_client_compositor(xc); struct ipc_client_compositor *icc = ipc_client_compositor(xc);
xrt_result_t xret;
IPC_CALL_CHK(ipc_call_compositor_discard_frame(icc->ipc_c, frame_id)); xret = ipc_call_compositor_discard_frame(icc->ipc_c, frame_id);
IPC_CHK_ALWAYS_RET(icc->ipc_c, xret, "ipc_call_compositor_discard_frame");
return res;
} }
static xrt_result_t static xrt_result_t
ipc_compositor_set_thread_hint(struct xrt_compositor *xc, enum xrt_thread_hint hint, uint32_t thread_id) ipc_compositor_set_thread_hint(struct xrt_compositor *xc, enum xrt_thread_hint hint, uint32_t thread_id)
{ {
struct ipc_client_compositor *icc = ipc_client_compositor(xc); struct ipc_client_compositor *icc = ipc_client_compositor(xc);
xrt_result_t xret;
IPC_CALL_CHK(ipc_call_compositor_set_thread_hint(icc->ipc_c, hint, thread_id)); xret = ipc_call_compositor_set_thread_hint(icc->ipc_c, hint, thread_id);
IPC_CHK_ALWAYS_RET(icc->ipc_c, xret, "ipc_call_compositor_set_thread_hint");
return res;
} }
static void static void
ipc_compositor_destroy(struct xrt_compositor *xc) ipc_compositor_destroy(struct xrt_compositor *xc)
{ {
struct ipc_client_compositor *icc = ipc_client_compositor(xc); struct ipc_client_compositor *icc = ipc_client_compositor(xc);
xrt_result_t xret;
assert(icc->compositor_created); assert(icc->compositor_created);
IPC_CALL_CHK(ipc_call_session_destroy(icc->ipc_c)); xret = ipc_call_session_destroy(icc->ipc_c);
/*
* We are probably in a really bad state if we fail, at
* least print out the error and continue as best we can.
*/
IPC_CHK_ONLY_PRINT(icc->ipc_c, xret, "ipc_call_session_destroy");
os_precise_sleeper_deinit(&icc->sleeper); os_precise_sleeper_deinit(&icc->sleeper);
@ -845,7 +866,7 @@ ipc_compositor_images_allocate(struct xrt_image_native_allocator *xina,
struct ipc_client_compositor *icc = container_of(xina, struct ipc_client_compositor, loopback_xina); struct ipc_client_compositor *icc = container_of(xina, struct ipc_client_compositor, loopback_xina);
int remote_fds[IPC_MAX_SWAPCHAIN_FDS] = {0}; int remote_fds[IPC_MAX_SWAPCHAIN_FDS] = {0};
xrt_result_t r = XRT_SUCCESS; xrt_result_t xret;
uint32_t image_count; uint32_t image_count;
uint32_t handle; uint32_t handle;
uint64_t size; uint64_t size;
@ -859,23 +880,22 @@ ipc_compositor_images_allocate(struct xrt_image_native_allocator *xina,
out_images[i].size = 0; out_images[i].size = 0;
} }
r = ipc_call_swapchain_create(icc->ipc_c, // connection xret = ipc_call_swapchain_create( //
xsci, // in icc->ipc_c, // connection
&handle, // out xsci, // in
&image_count, // out &handle, // out
&size, // out &image_count, // out
remote_fds, // fds &size, // out
IPC_MAX_SWAPCHAIN_FDS); // fds remote_fds, // fds
if (r != XRT_SUCCESS) { IPC_MAX_SWAPCHAIN_FDS); // fds
return r; IPC_CHK_AND_RET(icc->ipc_c, xret, "ipc_call_swapchain_create");
}
/* /*
* It's okay to destroy it immediately, the native handles are * It's okay to destroy it immediately, the native handles are
* now owned by us and we keep the buffers alive that way. * now owned by us and we keep the buffers alive that way.
*/ */
r = ipc_call_swapchain_destroy(icc->ipc_c, handle); xret = ipc_call_swapchain_destroy(icc->ipc_c, handle);
assert(r == XRT_SUCCESS); assert(xret == XRT_SUCCESS);
// Clumsy way of handling this. // Clumsy way of handling this.
if (image_count < in_image_count) { if (image_count < in_image_count) {
@ -949,17 +969,15 @@ ipc_syscomp_create_native_compositor(struct xrt_system_compositor *xsc,
struct xrt_compositor_native **out_xcn) struct xrt_compositor_native **out_xcn)
{ {
struct ipc_client_compositor *icc = container_of(xsc, struct ipc_client_compositor, system); struct ipc_client_compositor *icc = container_of(xsc, struct ipc_client_compositor, system);
xrt_result_t xret;
if (icc->compositor_created) { if (icc->compositor_created) {
return XRT_ERROR_MULTI_SESSION_NOT_IMPLEMENTED; return XRT_ERROR_MULTI_SESSION_NOT_IMPLEMENTED;
} }
// Needs to be done before init. // Needs to be done before init.
IPC_CALL_CHK(ipc_call_session_create(icc->ipc_c, xsi)); xret = ipc_call_session_create(icc->ipc_c, xsi);
IPC_CHK_AND_RET(icc->ipc_c, xret, "ipc_call_session_create");
if (res != XRT_SUCCESS) {
return res;
}
// Needs to be done after session create call. // Needs to be done after session create call.
ipc_compositor_init(icc, out_xcn); ipc_compositor_init(icc, out_xcn);