mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2024-12-29 11:06:18 +00:00
xrt: Add visibility mask interface
This commit is contained in:
parent
a77e35fdaf
commit
69afb62742
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
|
|
69
src/xrt/include/xrt/xrt_visibility_mask.h
Normal file
69
src/xrt/include/xrt/xrt_visibility_mask.h
Normal file
|
@ -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 <jakob@collabora.com>
|
||||
* @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
|
Loading…
Reference in a new issue