The open source OpenXR runtime

st/oxr: Getting vendor id/name from server

+67 -6
+9
src/xrt/auxiliary/util/u_system.c
··· 16 16 #include "util/u_misc.h" 17 17 #include "util/u_logging.h" 18 18 19 + #include <stdio.h> 19 20 20 21 /* 21 22 * ··· 213 214 214 215 usys->xsysc = xsysc; 215 216 } 217 + 218 + void 219 + u_system_fill_properties(struct u_system *usys, const char *name) 220 + { 221 + usys->base.properties.vendor_id = 42; 222 + // The magical 247 number, is to silence warnings. 223 + snprintf(usys->base.properties.name, XRT_MAX_SYSTEM_NAME_SIZE, "Monado: %.*s", 247, name); 224 + }
+9
src/xrt/auxiliary/util/u_system.h
··· 110 110 u_system_set_system_compositor(struct u_system *usys, struct xrt_system_compositor *xsysc); 111 111 112 112 /*! 113 + * Fill system properties. 114 + * 115 + * @public @memberof u_system 116 + * @ingroup aux_util 117 + */ 118 + void 119 + u_system_fill_properties(struct u_system *usys, const char *name); 120 + 121 + /*! 113 122 * Destroy an @ref u_system_create allocated @ref u_system - helper function. 114 123 * 115 124 * @param[in,out] usys_ptr A pointer to the @ref u_system_create allocated
+15
src/xrt/include/xrt/xrt_system.h
··· 32 32 * 33 33 */ 34 34 35 + #define XRT_SYSTEM_ID 1 36 + 37 + #define XRT_MAX_SYSTEM_NAME_SIZE 256 38 + 39 + /*! 40 + * Properties provided by the system. 41 + */ 42 + struct xrt_system_properties 43 + { 44 + uint32_t vendor_id; 45 + char name[XRT_MAX_SYSTEM_NAME_SIZE]; 46 + }; 47 + 35 48 /*! 36 49 * A system is a collection of devices, policies and optionally a compositor 37 50 * that is organised into a chosive group that is usable by one user, most of ··· 69 82 * @param xsys Pointer to self 70 83 */ 71 84 void (*destroy)(struct xrt_system *xsys); 85 + 86 + struct xrt_system_properties properties; 72 87 }; 73 88 74 89 /*!
+3
src/xrt/ipc/client/ipc_client_system.c
··· 13 13 14 14 #include "ipc_client_generated.h" 15 15 16 + #include <assert.h> 16 17 17 18 /*! 18 19 * IPC client implementation of @ref xrt_system. ··· 134 135 ipc_client_system_create(struct ipc_connection *ipc_c, struct xrt_system_compositor *xsysc) 135 136 { 136 137 struct ipc_client_system *icsys = U_TYPED_CALLOC(struct ipc_client_system); 138 + xrt_result_t xret = ipc_call_system_get_properties(ipc_c, &icsys->base.properties); 139 + assert(xret == XRT_SUCCESS); 137 140 icsys->base.create_session = ipc_client_system_create_session; 138 141 icsys->base.destroy = ipc_client_system_destroy; 139 142 icsys->ipc_c = ipc_c;
+3
src/xrt/ipc/server/ipc_server.h
··· 461 461 */ 462 462 void 463 463 ipc_server_handle_shutdown_signal(struct ipc_server *vs); 464 + 465 + xrt_result_t 466 + ipc_server_get_system_properties(struct ipc_server *vs, struct xrt_system_properties *out_properties); 464 467 //! @} 465 468 466 469 /*
+8
src/xrt/ipc/server/ipc_server_handler.c
··· 1144 1144 } 1145 1145 1146 1146 xrt_result_t 1147 + ipc_handle_system_get_properties(volatile struct ipc_client_state *_ics, struct xrt_system_properties *out_properties) 1148 + { 1149 + struct ipc_server *s = _ics->server; 1150 + 1151 + return ipc_server_get_system_properties(s, out_properties); 1152 + } 1153 + 1154 + xrt_result_t 1147 1155 ipc_handle_system_get_client_info(volatile struct ipc_client_state *_ics, 1148 1156 uint32_t client_id, 1149 1157 struct ipc_app_state *out_ias)
+7
src/xrt/ipc/server/ipc_server_process.c
··· 965 965 os_mutex_unlock(&vs->global_state.lock); 966 966 } 967 967 968 + xrt_result_t 969 + ipc_server_get_system_properties(struct ipc_server *vs, struct xrt_system_properties *out_properties) 970 + { 971 + memcpy(out_properties, &vs->xsys->properties, sizeof(*out_properties)); 972 + return XRT_SUCCESS; 973 + } 974 + 968 975 #ifndef XRT_OS_ANDROID 969 976 int 970 977 ipc_server_main(int argc, char **argv)
+6
src/xrt/ipc/shared/proto.json
··· 11 11 ] 12 12 }, 13 13 14 + "system_get_properties": { 15 + "out": [ 16 + {"name": "properties", "type": "struct xrt_system_properties"} 17 + ] 18 + }, 19 + 14 20 "system_get_client_info": { 15 21 "in": [ 16 22 {"name": "id", "type": "uint32_t"}
+1 -1
src/xrt/state_trackers/oxr/oxr_instance.c
··· 350 350 return ret; 351 351 } 352 352 353 - ret = oxr_system_fill_in(log, inst, 1, &inst->system); 353 + ret = oxr_system_fill_in(log, inst, XRT_SYSTEM_ID, &inst->system); 354 354 if (ret != XR_SUCCESS) { 355 355 oxr_instance_destroy(log, &inst->handle); 356 356 return ret;
+3 -5
src/xrt/state_trackers/oxr/oxr_system.c
··· 83 83 XrResult 84 84 oxr_system_verify_id(struct oxr_logger *log, const struct oxr_instance *inst, XrSystemId systemId) 85 85 { 86 - if (systemId != 1) { 86 + if (systemId != XRT_SYSTEM_ID) { 87 87 return oxr_error(log, XR_ERROR_SYSTEM_INVALID, "Invalid system %" PRIu64, systemId); 88 88 } 89 89 return XR_SUCCESS; ··· 272 272 XrResult 273 273 oxr_system_get_properties(struct oxr_logger *log, struct oxr_system *sys, XrSystemProperties *properties) 274 274 { 275 - properties->vendorId = 42; 276 275 properties->systemId = sys->systemId; 276 + properties->vendorId = sys->xsys->properties.vendor_id; 277 + memcpy(properties->systemName, sys->xsys->properties.name, sizeof(properties->systemName)); 277 278 278 279 struct xrt_device *xdev = GET_XDEV_BY_ROLE(sys, head); 279 - 280 - // The magical 247 number, is to silence warnings. 281 - snprintf(properties->systemName, XR_MAX_SYSTEM_NAME_SIZE, "Monado: %.*s", 247, xdev->str); 282 280 283 281 // Get from compositor. 284 282 struct xrt_system_compositor_info *info = sys->xsysc ? &sys->xsysc->info : NULL;
+1
src/xrt/targets/common/target_instance.c
··· 86 86 } 87 87 88 88 struct xrt_device *head = xsysd->static_roles.head; 89 + u_system_fill_properties(usys, head->str); 89 90 90 91 bool use_null = debug_get_bool_option_use_null(); 91 92
+1
src/xrt/targets/common/target_instance_no_comp.c
··· 56 56 return xret; 57 57 } 58 58 59 + u_system_fill_properties(usys, xsysd->static_roles.head->str); 59 60 *out_xsys = &usys->base; 60 61 *out_xsysd = xsysd; 61 62 *out_xso = xso;
+1
src/xrt/targets/sdl_test/sdl_instance.c
··· 82 82 83 83 struct sdl_program *sp = from_xinst(xinst); 84 84 85 + u_system_fill_properties(sp->usys, sp->xsysd_base.static_roles.head->str); 85 86 *out_xsys = &sp->usys->base; 86 87 *out_xsysd = &sp->xsysd_base; 87 88 *out_xso = sp->xso;