The open source OpenXR runtime

ipc: Refactor xrt_hmd_parts handling

Now also handles there not being a head device.

Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2636>

authored by

Jakob Bornecrantz and committed by
Marge Bot
d886e0e5 52a5a266

+15 -11
+15 -11
src/xrt/ipc/server/ipc_server_process.c
··· 422 422 423 423 // Setup the HMD 424 424 // set view count 425 - assert(s->xsysd->static_roles.head->hmd); 426 - ism->hmd.view_count = s->xsysd->static_roles.head->hmd->view_count; 427 - for (uint32_t view = 0; view < s->xsysd->static_roles.head->hmd->view_count; ++view) { 428 - ism->hmd.views[view].display.w_pixels = s->xsysd->static_roles.head->hmd->views[view].display.w_pixels; 429 - ism->hmd.views[view].display.h_pixels = s->xsysd->static_roles.head->hmd->views[view].display.h_pixels; 430 - } 425 + const struct xrt_device *xhead = s->xsysd->static_roles.head; 426 + const struct xrt_hmd_parts *xhmd = xhead != NULL ? xhead->hmd : NULL; 427 + U_ZERO(&ism->hmd); 428 + if (xhmd != NULL) { 429 + ism->hmd.view_count = xhmd->view_count; 430 + for (uint32_t view = 0; view < xhmd->view_count; ++view) { 431 + ism->hmd.views[view].display.w_pixels = xhmd->views[view].display.w_pixels; 432 + ism->hmd.views[view].display.h_pixels = xhmd->views[view].display.h_pixels; 433 + } 431 434 432 - for (size_t i = 0; i < s->xsysd->static_roles.head->hmd->blend_mode_count; i++) { 433 - // Not super necessary, we also do this assert in oxr_system.c 434 - assert(u_verify_blend_mode_valid(s->xsysd->static_roles.head->hmd->blend_modes[i])); 435 - ism->hmd.blend_modes[i] = s->xsysd->static_roles.head->hmd->blend_modes[i]; 435 + for (uint32_t i = 0; i < xhmd->blend_mode_count; i++) { 436 + // Not super necessary, we also do this assert in oxr_system.c 437 + assert(u_verify_blend_mode_valid(xhmd->blend_modes[i])); 438 + ism->hmd.blend_modes[i] = xhmd->blend_modes[i]; 439 + } 440 + ism->hmd.blend_mode_count = xhmd->blend_mode_count; 436 441 } 437 - ism->hmd.blend_mode_count = s->xsysd->static_roles.head->hmd->blend_mode_count; 438 442 439 443 // Finally tell the client how many devices we have. 440 444 ism->isdev_count = count;