The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

ipc: Add support for device provided bindings

+129 -3
+26
src/xrt/ipc/client/ipc_client_device.c
··· 188 188 icd->base.outputs = NULL; 189 189 } 190 190 191 + if (isdev->num_binding_profiles > 0) { 192 + icd->base.binding_profiles = U_TYPED_ARRAY_CALLOC( 193 + struct xrt_binding_profile, isdev->num_binding_profiles); 194 + icd->base.num_binding_profiles = isdev->num_binding_profiles; 195 + } 196 + 197 + for (size_t i = 0; i < isdev->num_binding_profiles; i++) { 198 + struct xrt_binding_profile *xbp = 199 + &icd->base.binding_profiles[i]; 200 + struct ipc_shared_binding_profile *isbp = 201 + &ism->binding_profiles[isdev->first_binding_profile_index + 202 + i]; 203 + 204 + xbp->name = isbp->name; 205 + if (isbp->num_inputs > 0) { 206 + xbp->inputs = 207 + &ism->input_pairs[isbp->first_input_index]; 208 + xbp->num_inputs = isbp->num_inputs; 209 + } 210 + if (isbp->num_outputs > 0) { 211 + xbp->outputs = 212 + &ism->output_pairs[isbp->first_output_index]; 213 + xbp->num_outputs = isbp->num_inputs; 214 + } 215 + } 216 + 191 217 // Setup variable tracker. 192 218 u_var_add_root(icd, icd->base.str, true); 193 219 u_var_add_ro_u32(icd, &icd->device_id, "device_id");
+59
src/xrt/ipc/server/ipc_server_process.c
··· 138 138 return 0; 139 139 } 140 140 141 + static void 142 + handle_binding(struct ipc_shared_memory *ism, 143 + struct xrt_binding_profile *xbp, 144 + struct ipc_shared_binding_profile *isbp, 145 + uint32_t *input_pair_index_ptr, 146 + uint32_t *output_pair_index_ptr) 147 + { 148 + uint32_t input_pair_index = *input_pair_index_ptr; 149 + uint32_t output_pair_index = *output_pair_index_ptr; 150 + 151 + isbp->name = xbp->name; 152 + 153 + // Copy the initial state and also count the number in input_pairs. 154 + size_t input_pair_start = input_pair_index; 155 + for (size_t k = 0; k < xbp->num_inputs; k++) { 156 + ism->input_pairs[input_pair_index++] = xbp->inputs[k]; 157 + } 158 + 159 + // Setup the 'offsets' and number of input_pairs. 160 + if (input_pair_start != input_pair_index) { 161 + isbp->num_inputs = input_pair_index - input_pair_start; 162 + isbp->first_input_index = input_pair_start; 163 + } 164 + 165 + // Copy the initial state and also count the number in outputs. 166 + size_t output_pair_start = output_pair_index; 167 + for (size_t k = 0; k < xbp->num_outputs; k++) { 168 + ism->output_pairs[output_pair_index++] = xbp->outputs[k]; 169 + } 170 + 171 + // Setup the 'offsets' and number of output_pairs. 172 + if (output_pair_start != output_pair_index) { 173 + isbp->num_outputs = output_pair_index - output_pair_start; 174 + isbp->first_output_index = output_pair_start; 175 + } 176 + 177 + *input_pair_index_ptr = input_pair_index; 178 + *output_pair_index_ptr = output_pair_index; 179 + } 180 + 141 181 static int 142 182 init_shm(struct ipc_server *s) 143 183 { ··· 185 225 count = 0; 186 226 uint32_t input_index = 0; 187 227 uint32_t output_index = 0; 228 + uint32_t binding_index = 0; 229 + uint32_t input_pair_index = 0; 230 + uint32_t output_pair_index = 0; 231 + 188 232 for (size_t i = 0; i < IPC_SERVER_NUM_XDEVS; i++) { 189 233 struct xrt_device *xdev = s->idevs[i].xdev; 190 234 if (xdev == NULL) { ··· 232 276 233 277 // Initial update. 234 278 xrt_device_update_inputs(xdev); 279 + 280 + // Bindings 281 + size_t binding_start = binding_index; 282 + for (size_t k = 0; k < xdev->num_binding_profiles; k++) { 283 + handle_binding(ism, &xdev->binding_profiles[k], 284 + &ism->binding_profiles[binding_index++], 285 + &input_pair_index, &output_pair_index); 286 + } 287 + 288 + // Setup the 'offsets' and number of bindings. 289 + if (binding_start != binding_index) { 290 + isdev->num_binding_profiles = 291 + binding_index - binding_start; 292 + isdev->first_binding_profile_index = binding_start; 293 + } 235 294 236 295 // Copy the initial state and also count the number in inputs. 237 296 size_t input_start = input_index;
+44 -3
src/xrt/ipc/shared/ipc_protocol.h
··· 35 35 #define IPC_SHARED_MAX_DEVICES 8 36 36 #define IPC_SHARED_MAX_INPUTS 1024 37 37 #define IPC_SHARED_MAX_OUTPUTS 128 38 + #define IPC_SHARED_MAX_BINDINGS 64 39 + 38 40 39 41 /* 40 42 * ··· 42 44 * 43 45 */ 44 46 47 + /*! 48 + * A tracking in the shared memory area. 49 + * 50 + * @ingroup ipc 51 + */ 45 52 struct ipc_shared_tracking_origin 46 53 { 47 54 //! For debugging. ··· 54 61 struct xrt_pose offset; 55 62 }; 56 63 64 + /*! 65 + * A binding in the shared memory area. 66 + * 67 + * @ingroup ipc 68 + */ 69 + struct ipc_shared_binding_profile 70 + { 71 + enum xrt_device_name name; 72 + 73 + //! Number of inputs. 74 + uint32_t num_inputs; 75 + //! Offset into the array of pairs where this input bindings starts. 76 + uint32_t first_input_index; 77 + 78 + //! Number of outputs. 79 + uint32_t num_outputs; 80 + //! Offset into the array of pairs where this output bindings starts. 81 + uint32_t first_output_index; 82 + }; 83 + 84 + /*! 85 + * A device in the shared memory area. 86 + * 87 + * @ingroup ipc 88 + */ 57 89 struct ipc_shared_device 58 90 { 59 91 //! Enum identifier of the device. ··· 66 98 //! A string describing the device. 67 99 char str[XRT_DEVICE_NAME_LEN]; 68 100 101 + //! Number of bindings. 102 + uint32_t num_binding_profiles; 103 + //! 'Offset' into the array of bindings where the bindings starts. 104 + uint32_t first_binding_profile_index; 105 + 69 106 //! Number of inputs. 70 107 uint32_t num_inputs; 71 - //! 'Offset' into the array of inputs where this devices inputs starts. 108 + //! 'Offset' into the array of inputs where the inputs starts. 72 109 uint32_t first_input_index; 73 110 74 111 //! Number of outputs. 75 112 uint32_t num_outputs; 76 - //! 'Offset' into the array of outputs where this devices outputs 77 - //! starts. 113 + //! 'Offset' into the array of outputs where the outputs starts. 78 114 uint32_t first_output_index; 79 115 80 116 bool orientation_tracking_supported; ··· 193 229 struct xrt_input inputs[IPC_SHARED_MAX_INPUTS]; 194 230 195 231 struct xrt_output outputs[IPC_SHARED_MAX_OUTPUTS]; 232 + 233 + struct ipc_shared_binding_profile 234 + binding_profiles[IPC_SHARED_MAX_BINDINGS]; 235 + struct xrt_binding_input_pair input_pairs[IPC_SHARED_MAX_INPUTS]; 236 + struct xrt_binding_output_pair output_pairs[IPC_SHARED_MAX_OUTPUTS]; 196 237 197 238 struct ipc_layer_slot slots[IPC_MAX_SLOTS]; 198 239 };