diff --git a/src/xrt/include/xrt/xrt_defines.h b/src/xrt/include/xrt/xrt_defines.h index a436578b2..7ef822a78 100644 --- a/src/xrt/include/xrt/xrt_defines.h +++ b/src/xrt/include/xrt/xrt_defines.h @@ -1293,6 +1293,18 @@ enum xrt_form_factor XRT_FORM_FACTOR_HANDHELD, //!< Handheld display. }; +/*! + * Visibility mask, mirror of XrVisibilityMaskKHR + * + * @ingroup xrt_iface + */ +enum xrt_visibility_mask_type +{ + XRT_VISIBILITY_MASK_TYPE_HIDDEN_TRIANGLE_MESH = 1, + XRT_VISIBILITY_MASK_TYPE_VISIBLE_TRIANGLE_MESH = 2, + XRT_VISIBILITY_MASK_TYPE_LINE_LOOP = 3, +}; + #ifdef __cplusplus } #endif diff --git a/src/xrt/include/xrt/xrt_device.h b/src/xrt/include/xrt/xrt_device.h index f902be00e..079c87395 100644 --- a/src/xrt/include/xrt/xrt_device.h +++ b/src/xrt/include/xrt/xrt_device.h @@ -11,6 +11,7 @@ #pragma once #include "xrt/xrt_defines.h" +#include "xrt/xrt_visibility_mask.h" #ifdef __cplusplus @@ -396,6 +397,13 @@ struct xrt_device bool (*compute_distortion)( struct xrt_device *xdev, uint32_t view, float u, float v, struct xrt_uv_triplet *out_result); + /*! + * Get the visibility mask for this device. + */ + void (*get_visibility_mask)(struct xrt_device *xdev, + enum xrt_visibility_mask_type type, + struct xrt_visibility_mask **out_mask); + /*! * Destroy device. */ diff --git a/src/xrt/include/xrt/xrt_visibility_mask.h b/src/xrt/include/xrt/xrt_visibility_mask.h new file mode 100644 index 000000000..f5b52bfc3 --- /dev/null +++ b/src/xrt/include/xrt/xrt_visibility_mask.h @@ -0,0 +1,69 @@ +// Copyright 2023, Collabora, Ltd. +// SPDX-License-Identifier: BSL-1.0 +/*! + * @file + * @brief Header defining visibility mask helper struct. + * @author Jakob Bornecrantz + * @ingroup xrt_iface + */ + +#pragma once + +#include "xrt/xrt_defines.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*! + * Visibility mask helper, the indices and vertices are tightly packed after + * this struct. + * + * @ingroup xrt_iface + */ +struct xrt_visibility_mask +{ + enum xrt_visibility_mask_type type; + uint32_t index_count; + uint32_t vertex_count; +}; + +/*! + * Visibility mask helper function to get the indices. + * + * @ingroup xrt_iface + */ +static inline uint32_t * +xrt_visibility_mask_get_indices(const struct xrt_visibility_mask *mask) +{ + return (uint32_t *)&mask[1]; +} + +/*! + * Visibility mask helper function to get the vertices. + * + * @ingroup xrt_iface + */ +static inline struct xrt_vec2 * +xrt_visibility_mask_get_vertices(const struct xrt_visibility_mask *mask) +{ + const uint32_t *indices = xrt_visibility_mask_get_indices(mask); + return (struct xrt_vec2 *)&indices[mask->index_count]; +} + +/*! + * Visibility mask helper function to get the total size of the struct. + * + * @ingroup xrt_iface + */ +static inline size_t +xrt_visibility_mask_get_size(const struct xrt_visibility_mask *mask) +{ + return sizeof(*mask) + // + sizeof(uint32_t) * mask->index_count + // + sizeof(struct xrt_vec2) * mask->vertex_count; // +} + +#ifdef __cplusplus +} +#endif