st/oxr: Handle view index for visibility mask

This commit is contained in:
Jakob Bornecrantz 2023-11-14 21:26:43 +00:00
parent 9a09d7956d
commit 6e8a40112b
4 changed files with 21 additions and 11 deletions

View file

@ -303,7 +303,7 @@ oxr_xrGetVisibilityMaskKHR(XrSession session,
OXR_VERIFY_ARG_NOT_NULL(&log, visibilityMask->indices);
}
return oxr_session_get_visibility_mask(&log, sess, visibilityMaskType, visibilityMask);
return oxr_session_get_visibility_mask(&log, sess, visibilityMaskType, viewIndex, visibilityMask);
}
#endif // OXR_HAVE_KHR_visibility_mask

View file

@ -69,8 +69,10 @@ oxr_instance_destroy(struct oxr_logger *log, struct oxr_handle_base *hb)
u_hashset_destroy(&inst->action_sets.loc_store);
// Free the mask here, no system destroy yet.
free(inst->system.visibility_mask);
inst->system.visibility_mask = NULL;
for (uint32_t i = 0; i < ARRAY_SIZE(inst->system.visibility_mask); i++) {
free(inst->system.visibility_mask[i]);
inst->system.visibility_mask[i] = NULL;
}
xrt_space_overseer_destroy(&inst->system.xso);
os_mutex_destroy(&inst->system.sync_actions_mutex);

View file

@ -766,6 +766,7 @@ XrResult
oxr_session_get_visibility_mask(struct oxr_logger *log,
struct oxr_session *session,
XrVisibilityMaskTypeKHR visibilityMaskType,
uint32_t viewIndex,
XrVisibilityMaskKHR *visibilityMask);
#endif // OXR_HAVE_KHR_visibility_mask
@ -1291,7 +1292,7 @@ struct oxr_system
struct xrt_system_roles dynamic_roles_cache;
struct os_mutex sync_actions_mutex;
struct xrt_visibility_mask *visibility_mask;
struct xrt_visibility_mask *visibility_mask[2];
#ifdef XR_USE_GRAPHICS_API_VULKAN
//! The instance/device we create when vulkan_enable2 is used

View file

@ -1177,23 +1177,30 @@ XrResult
oxr_session_get_visibility_mask(struct oxr_logger *log,
struct oxr_session *sess,
XrVisibilityMaskTypeKHR visibilityMaskType,
uint32_t viewIndex,
XrVisibilityMaskKHR *visibilityMask)
{
struct oxr_system *sys = sess->sys;
struct xrt_device *xdev = GET_XDEV_BY_ROLE(sess->sys, head);
enum xrt_visibility_mask_type type = convert_mask_type(visibilityMaskType);
if (sys->visibility_mask && sys->visibility_mask->type != type) {
free(sys->visibility_mask);
sys->visibility_mask = NULL;
assert(viewIndex < ARRAY_SIZE(sys->visibility_mask));
struct xrt_visibility_mask *mask = sys->visibility_mask[viewIndex];
// Do we need to free the mask.
if (mask != NULL && mask->type != type) {
free(mask);
mask = NULL;
sys->visibility_mask[viewIndex] = NULL;
}
if (sys->visibility_mask == NULL) {
xrt_device_get_visibility_mask(xdev, type, 0, &sys->visibility_mask);
// If we didn't have any cached mask get it.
if (mask == NULL) {
xrt_device_get_visibility_mask(xdev, type, viewIndex, &mask);
sys->visibility_mask[viewIndex] = mask;
}
struct xrt_visibility_mask *mask = sys->visibility_mask;
visibilityMask->vertexCountOutput = mask->vertex_count;
visibilityMask->indexCountOutput = mask->index_count;