mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-02-16 10:40:06 +00:00
c/util: Replace is_view_index_visible helper by is_layer_view_visible
This commit is contained in:
parent
d7f84585ad
commit
c4251cb907
src/xrt/compositor/util
|
@ -331,6 +331,10 @@ comp_render_cs_layer(struct render_compute *crc,
|
|||
const struct comp_layer *layer = &layers[c_layer_i];
|
||||
const struct xrt_layer_data *data = &layer->data;
|
||||
|
||||
if (!is_layer_view_visible(data, view_index)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Stop compositing layers if device's sampled image limit is
|
||||
* reached. For most hardware this isn't a problem, most have
|
||||
|
@ -342,13 +346,7 @@ comp_render_cs_layer(struct render_compute *crc,
|
|||
switch (data->type) {
|
||||
case XRT_LAYER_STEREO_PROJECTION: required_image_samplers = 1; break;
|
||||
case XRT_LAYER_STEREO_PROJECTION_DEPTH: required_image_samplers = 2; break;
|
||||
case XRT_LAYER_QUAD:
|
||||
if (!is_view_index_visible(view_index, data->quad.visibility)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
required_image_samplers = 1;
|
||||
break;
|
||||
case XRT_LAYER_QUAD: required_image_samplers = 1; break;
|
||||
default:
|
||||
VK_ERROR(crc->r->vk, "Skipping layer #%u, unknown type: %u", c_layer_i, data->type);
|
||||
continue; // Skip this layer if don't know about it.
|
||||
|
|
|
@ -176,11 +176,6 @@ do_cylinder_layer(struct render_gfx *rr,
|
|||
struct vk_bundle *vk = rr->r->vk;
|
||||
VkResult ret;
|
||||
|
||||
// Should we actually do a layer here?
|
||||
if (!is_view_index_visible(view_index, c->visibility)) {
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
const uint32_t array_index = c->sub.array_index;
|
||||
const struct comp_swapchain_image *image = &layer->sc_array[0]->images[c->sub.image_index];
|
||||
|
||||
|
@ -243,11 +238,6 @@ do_equirect2_layer(struct render_gfx *rr,
|
|||
struct vk_bundle *vk = rr->r->vk;
|
||||
VkResult ret;
|
||||
|
||||
// Should we actually do a layer here?
|
||||
if (!is_view_index_visible(view_index, eq2->visibility)) {
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
const uint32_t array_index = eq2->sub.array_index;
|
||||
const struct comp_swapchain_image *image = &layer->sc_array[0]->images[eq2->sub.image_index];
|
||||
|
||||
|
@ -370,11 +360,6 @@ do_quad_layer(struct render_gfx *rr,
|
|||
struct vk_bundle *vk = rr->r->vk;
|
||||
VkResult ret;
|
||||
|
||||
// Should we actually do a layer here?
|
||||
if (!is_view_index_visible(view_index, q->visibility)) {
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
const uint32_t array_index = q->sub.array_index;
|
||||
const struct comp_swapchain_image *image = &layer->sc_array[0]->images[q->sub.image_index];
|
||||
|
||||
|
@ -473,7 +458,12 @@ do_layers(struct render_gfx *rr,
|
|||
|
||||
for (uint32_t view = 0; view < ARRAY_SIZE(views); view++) {
|
||||
for (uint32_t i = 0; i < layer_count; i++) {
|
||||
switch (layers[i].data.type) {
|
||||
const struct xrt_layer_data *data = &layers[i].data;
|
||||
if (!is_layer_view_visible(data, view)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (data->type) {
|
||||
case XRT_LAYER_CYLINDER:
|
||||
ret = do_cylinder_layer( //
|
||||
rr, // rr
|
||||
|
|
|
@ -45,17 +45,6 @@ is_view_index_right(uint32_t view_index)
|
|||
return view_index % 2 == 1;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
is_view_index_visible(uint32_t view_index, enum xrt_layer_eye_visibility visibility)
|
||||
{
|
||||
switch (visibility) {
|
||||
case XRT_LAYER_EYE_VISIBILITY_NONE: return false;
|
||||
case XRT_LAYER_EYE_VISIBILITY_LEFT_BIT: return !is_view_index_right(view_index);
|
||||
case XRT_LAYER_EYE_VISIBILITY_RIGHT_BIT: return is_view_index_right(view_index);
|
||||
case XRT_LAYER_EYE_VISIBILITY_BOTH: return true;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
view_index_to_projection_data(uint32_t view_index,
|
||||
const struct xrt_layer_data *data,
|
||||
|
@ -94,6 +83,30 @@ view_index_to_depth_data(uint32_t view_index,
|
|||
*
|
||||
*/
|
||||
|
||||
static inline bool
|
||||
is_layer_view_visible(const struct xrt_layer_data *data, uint32_t view_index)
|
||||
{
|
||||
enum xrt_layer_eye_visibility visibility;
|
||||
switch (data->type) {
|
||||
case XRT_LAYER_CUBE: visibility = data->cube.visibility; break;
|
||||
case XRT_LAYER_CYLINDER: visibility = data->cylinder.visibility; break;
|
||||
case XRT_LAYER_EQUIRECT1: visibility = data->equirect1.visibility; break;
|
||||
case XRT_LAYER_EQUIRECT2: visibility = data->equirect2.visibility; break;
|
||||
case XRT_LAYER_QUAD: visibility = data->quad.visibility; break;
|
||||
case XRT_LAYER_STEREO_PROJECTION:
|
||||
case XRT_LAYER_STEREO_PROJECTION_DEPTH: return true;
|
||||
default: return false;
|
||||
};
|
||||
|
||||
switch (visibility) {
|
||||
case XRT_LAYER_EYE_VISIBILITY_LEFT_BIT: return !is_view_index_right(view_index);
|
||||
case XRT_LAYER_EYE_VISIBILITY_RIGHT_BIT: return is_view_index_right(view_index);
|
||||
case XRT_LAYER_EYE_VISIBILITY_BOTH: return true;
|
||||
case XRT_LAYER_EYE_VISIBILITY_NONE:
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
|
||||
static inline bool
|
||||
is_layer_view_space(const struct xrt_layer_data *data)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue