st/oxr: Fixes crash bug in xrGetVisibilityMaskKHR for in-process builds

Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2210>
This commit is contained in:
Korcan Hussein 2024-05-15 16:02:32 +01:00 committed by Marge Bot
parent 6cd8181b22
commit 2639d830b6
2 changed files with 10 additions and 0 deletions

View file

@ -667,6 +667,10 @@ xrt_device_get_visibility_mask(struct xrt_device *xdev,
uint32_t view_index, uint32_t view_index,
struct xrt_visibility_mask **out_mask) struct xrt_visibility_mask **out_mask)
{ {
if (xdev->get_visibility_mask == NULL) {
return XRT_ERROR_DEVICE_FUNCTION_NOT_IMPLEMENTED;
}
return xdev->get_visibility_mask(xdev, type, view_index, out_mask); return xdev->get_visibility_mask(xdev, type, view_index, out_mask);
} }

View file

@ -29,6 +29,7 @@
#include "util/u_debug.h" #include "util/u_debug.h"
#include "util/u_misc.h" #include "util/u_misc.h"
#include "util/u_time.h" #include "util/u_time.h"
#include "util/u_visibility_mask.h"
#include "util/u_verify.h" #include "util/u_verify.h"
#include "math/m_api.h" #include "math/m_api.h"
@ -1417,6 +1418,11 @@ oxr_session_get_visibility_mask(struct oxr_logger *log,
// If we didn't have any cached mask get it. // If we didn't have any cached mask get it.
if (mask == NULL) { if (mask == NULL) {
xret = xrt_device_get_visibility_mask(xdev, type, viewIndex, &mask); xret = xrt_device_get_visibility_mask(xdev, type, viewIndex, &mask);
if (xret == XRT_ERROR_DEVICE_FUNCTION_NOT_IMPLEMENTED && xdev->hmd != NULL) {
const struct xrt_fov fov = xdev->hmd->distortion.fov[viewIndex];
u_visibility_mask_get_default(type, &fov, &mask);
xret = XRT_SUCCESS;
}
OXR_CHECK_XRET(log, sess, xret, get_visibility_mask); OXR_CHECK_XRET(log, sess, xret, get_visibility_mask);
sys->visibility_mask[viewIndex] = mask; sys->visibility_mask[viewIndex] = mask;
} }