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); 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 #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); u_hashset_destroy(&inst->action_sets.loc_store);
// Free the mask here, no system destroy yet. // Free the mask here, no system destroy yet.
free(inst->system.visibility_mask); for (uint32_t i = 0; i < ARRAY_SIZE(inst->system.visibility_mask); i++) {
inst->system.visibility_mask = NULL; free(inst->system.visibility_mask[i]);
inst->system.visibility_mask[i] = NULL;
}
xrt_space_overseer_destroy(&inst->system.xso); xrt_space_overseer_destroy(&inst->system.xso);
os_mutex_destroy(&inst->system.sync_actions_mutex); os_mutex_destroy(&inst->system.sync_actions_mutex);

View file

@ -766,6 +766,7 @@ XrResult
oxr_session_get_visibility_mask(struct oxr_logger *log, oxr_session_get_visibility_mask(struct oxr_logger *log,
struct oxr_session *session, struct oxr_session *session,
XrVisibilityMaskTypeKHR visibilityMaskType, XrVisibilityMaskTypeKHR visibilityMaskType,
uint32_t viewIndex,
XrVisibilityMaskKHR *visibilityMask); XrVisibilityMaskKHR *visibilityMask);
#endif // OXR_HAVE_KHR_visibility_mask #endif // OXR_HAVE_KHR_visibility_mask
@ -1291,7 +1292,7 @@ struct oxr_system
struct xrt_system_roles dynamic_roles_cache; struct xrt_system_roles dynamic_roles_cache;
struct os_mutex sync_actions_mutex; 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 #ifdef XR_USE_GRAPHICS_API_VULKAN
//! The instance/device we create when vulkan_enable2 is used //! 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, oxr_session_get_visibility_mask(struct oxr_logger *log,
struct oxr_session *sess, struct oxr_session *sess,
XrVisibilityMaskTypeKHR visibilityMaskType, XrVisibilityMaskTypeKHR visibilityMaskType,
uint32_t viewIndex,
XrVisibilityMaskKHR *visibilityMask) XrVisibilityMaskKHR *visibilityMask)
{ {
struct oxr_system *sys = sess->sys; struct oxr_system *sys = sess->sys;
struct xrt_device *xdev = GET_XDEV_BY_ROLE(sess->sys, head); struct xrt_device *xdev = GET_XDEV_BY_ROLE(sess->sys, head);
enum xrt_visibility_mask_type type = convert_mask_type(visibilityMaskType); enum xrt_visibility_mask_type type = convert_mask_type(visibilityMaskType);
if (sys->visibility_mask && sys->visibility_mask->type != type) { assert(viewIndex < ARRAY_SIZE(sys->visibility_mask));
free(sys->visibility_mask);
sys->visibility_mask = NULL; 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) { // If we didn't have any cached mask get it.
xrt_device_get_visibility_mask(xdev, type, 0, &sys->visibility_mask); 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->vertexCountOutput = mask->vertex_count;
visibilityMask->indexCountOutput = mask->index_count; visibilityMask->indexCountOutput = mask->index_count;