The open source OpenXR runtime
0
fork

Configure Feed

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

st/oxr: Fill XrViewConfigurationView with new two call helper

The previous two call helper macro copied the entire input struct to output struct.
In particular this did not keep the .type and .next fields intact.

Rather than trying to keep those intact, each struct type should have its own fill function,
only filling in the data we actually want to fill in.

+40 -3
+17 -2
src/xrt/state_trackers/oxr/oxr_system.c
··· 278 278 return XR_SUCCESS; 279 279 } 280 280 281 + static void 282 + view_configuration_view_fill_in(XrViewConfigurationView *target_view, 283 + XrViewConfigurationView *source_view) 284 + { 285 + // clang-format off 286 + target_view->recommendedImageRectWidth = source_view->recommendedImageRectWidth; 287 + target_view->maxImageRectWidth = source_view->maxImageRectWidth; 288 + target_view->recommendedImageRectHeight = source_view->recommendedImageRectHeight; 289 + target_view->maxImageRectHeight = source_view->maxImageRectHeight; 290 + target_view->recommendedSwapchainSampleCount = source_view->recommendedSwapchainSampleCount; 291 + target_view->maxSwapchainSampleCount = source_view->maxSwapchainSampleCount; 292 + // clang-format on 293 + } 294 + 281 295 XrResult 282 296 oxr_system_enumerate_view_conf_views( 283 297 struct oxr_logger *log, ··· 293 307 "invalid view configuration type"); 294 308 } 295 309 296 - OXR_TWO_CALL_HELPER(log, viewCapacityInput, viewCountOutput, views, 2, 297 - sys->views, XR_SUCCESS); 310 + OXR_TWO_CALL_FILL_IN_HELPER(log, viewCapacityInput, viewCountOutput, 311 + views, 2, view_configuration_view_fill_in, 312 + sys->views, XR_SUCCESS); 298 313 }
+23 -1
src/xrt/state_trackers/oxr/oxr_two_call.h
··· 37 37 return sval; \ 38 38 } while (false) 39 39 40 - 40 + //! Calls fill_fn(&output_struct[i], &source_struct[i]) to fill output_structs 41 + #define OXR_TWO_CALL_FILL_IN_HELPER(log, cnt_input, cnt_output, \ 42 + output_structs, count, fill_fn, \ 43 + source_structs, sval) \ 44 + do { \ 45 + if (cnt_output == NULL) { \ 46 + return oxr_error(log, XR_ERROR_VALIDATION_FAILURE, \ 47 + #cnt_output); \ 48 + } \ 49 + *cnt_output = count; \ 50 + \ 51 + if (cnt_input == 0) { \ 52 + return sval; \ 53 + } \ 54 + if (cnt_input < count) { \ 55 + return oxr_error(log, XR_ERROR_SIZE_INSUFFICIENT, \ 56 + #cnt_input); \ 57 + } \ 58 + for (uint32_t i = 0; i < count; i++) { \ 59 + fill_fn(&output_structs[i], &source_structs[i]); \ 60 + } \ 61 + return sval; \ 62 + } while (false) 41 63 42 64 #ifdef __cplusplus 43 65 }