mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-01 12:46:12 +00:00
c/layers: Don't build equirect code if not enabled.
This commit is contained in:
parent
4995854d06
commit
200fb5aeed
|
@ -522,6 +522,7 @@ compositor_layer_commit(struct xrt_compositor *xc, int64_t frame_id)
|
|||
image = &layer->scs[0]->images[cyl->sub.image_index];
|
||||
comp_renderer_set_cylinder_layer(c->r, i, image, data);
|
||||
} break;
|
||||
#ifdef XRT_FEATURE_OPENXR_LAYER_EQUIRECT1
|
||||
case XRT_LAYER_EQUIRECT1: {
|
||||
struct xrt_layer_equirect1_data *eq =
|
||||
&layer->data.equirect1;
|
||||
|
@ -529,6 +530,8 @@ compositor_layer_commit(struct xrt_compositor *xc, int64_t frame_id)
|
|||
image = &layer->scs[0]->images[eq->sub.image_index];
|
||||
comp_renderer_set_equirect1_layer(c->r, i, image, data);
|
||||
} break;
|
||||
#endif
|
||||
#ifdef XRT_FEATURE_OPENXR_LAYER_EQUIRECT2
|
||||
case XRT_LAYER_EQUIRECT2: {
|
||||
struct xrt_layer_equirect2_data *eq =
|
||||
&layer->data.equirect2;
|
||||
|
@ -536,6 +539,7 @@ compositor_layer_commit(struct xrt_compositor *xc, int64_t frame_id)
|
|||
image = &layer->scs[0]->images[eq->sub.image_index];
|
||||
comp_renderer_set_equirect2_layer(c->r, i, image, data);
|
||||
} break;
|
||||
#endif
|
||||
case XRT_LAYER_CUBE:
|
||||
// Should never end up here.
|
||||
assert(false);
|
||||
|
|
|
@ -83,6 +83,7 @@ _init_ubos(struct comp_render_layer *self)
|
|||
return true;
|
||||
}
|
||||
|
||||
#ifdef XRT_FEATURE_OPENXR_LAYER_EQUIRECT1
|
||||
static bool
|
||||
_init_equirect1_ubo(struct comp_render_layer *self)
|
||||
{
|
||||
|
@ -107,7 +108,8 @@ _init_equirect1_ubo(struct comp_render_layer *self)
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef XRT_FEATURE_OPENXR_LAYER_EQUIRECT2
|
||||
static bool
|
||||
_init_equirect2_ubo(struct comp_render_layer *self)
|
||||
{
|
||||
|
@ -132,6 +134,7 @@ _init_equirect2_ubo(struct comp_render_layer *self)
|
|||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
_update_descriptor(struct comp_render_layer *self,
|
||||
|
@ -176,6 +179,8 @@ _update_descriptor(struct comp_render_layer *self,
|
|||
vk->vkUpdateDescriptorSets(vk->device, 2, sets, 0, NULL);
|
||||
}
|
||||
|
||||
#if defined(XRT_FEATURE_OPENXR_LAYER_EQUIRECT1) || \
|
||||
defined(XRT_FEATURE_OPENXR_LAYER_EQUIRECT2)
|
||||
static void
|
||||
_update_descriptor_equirect(struct comp_render_layer *self,
|
||||
VkDescriptorSet set,
|
||||
|
@ -200,6 +205,7 @@ _update_descriptor_equirect(struct comp_render_layer *self,
|
|||
|
||||
self->vk->vkUpdateDescriptorSets(self->vk->device, 1, sets, 0, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
comp_layer_update_descriptors(struct comp_render_layer *self,
|
||||
|
@ -212,6 +218,7 @@ comp_layer_update_descriptors(struct comp_render_layer *self,
|
|||
sampler, image_view);
|
||||
}
|
||||
|
||||
#ifdef XRT_FEATURE_OPENXR_LAYER_EQUIRECT1
|
||||
void
|
||||
comp_layer_update_equirect1_descriptor(struct comp_render_layer *self,
|
||||
struct xrt_layer_equirect1_data *data)
|
||||
|
@ -227,7 +234,8 @@ comp_layer_update_equirect1_descriptor(struct comp_render_layer *self,
|
|||
memcpy(self->equirect1_ubo.data, &self->equirect1_data,
|
||||
sizeof(struct layer_equirect1_data));
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef XRT_FEATURE_OPENXR_LAYER_EQUIRECT2
|
||||
void
|
||||
comp_layer_update_equirect2_descriptor(struct comp_render_layer *self,
|
||||
struct xrt_layer_equirect2_data *data)
|
||||
|
@ -244,6 +252,7 @@ comp_layer_update_equirect2_descriptor(struct comp_render_layer *self,
|
|||
memcpy(self->equirect2_ubo.data, &self->equirect2_data,
|
||||
sizeof(struct layer_equirect2_data));
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
comp_layer_update_stereo_descriptors(struct comp_render_layer *self,
|
||||
|
@ -277,11 +286,14 @@ _init(struct comp_render_layer *self,
|
|||
if (!_init_ubos(self))
|
||||
return false;
|
||||
|
||||
#ifdef XRT_FEATURE_OPENXR_LAYER_EQUIRECT1
|
||||
if (!_init_equirect1_ubo(self))
|
||||
return false;
|
||||
|
||||
#endif
|
||||
#ifdef XRT_FEATURE_OPENXR_LAYER_EQUIRECT2
|
||||
if (!_init_equirect2_ubo(self))
|
||||
return false;
|
||||
#endif
|
||||
|
||||
VkDescriptorPoolSize pool_sizes[] = {
|
||||
{
|
||||
|
@ -305,11 +317,13 @@ _init(struct comp_render_layer *self,
|
|||
&self->descriptor_sets[eye]))
|
||||
return false;
|
||||
|
||||
#if defined(XRT_FEATURE_OPENXR_LAYER_EQUIRECT1) || \
|
||||
defined(XRT_FEATURE_OPENXR_LAYER_EQUIRECT2)
|
||||
if (!vk_allocate_descriptor_sets(self->vk, self->descriptor_pool, 1,
|
||||
layout_equirect,
|
||||
&self->descriptor_equirect))
|
||||
return false;
|
||||
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -523,9 +537,12 @@ comp_layer_destroy(struct comp_render_layer *self)
|
|||
for (uint32_t eye = 0; eye < 2; eye++)
|
||||
vk_buffer_destroy(&self->transformation_ubos[eye], self->vk);
|
||||
|
||||
#ifdef XRT_FEATURE_OPENXR_LAYER_EQUIRECT1
|
||||
vk_buffer_destroy(&self->equirect1_ubo, self->vk);
|
||||
#endif
|
||||
#ifdef XRT_FEATURE_OPENXR_LAYER_EQUIRECT2
|
||||
vk_buffer_destroy(&self->equirect2_ubo, self->vk);
|
||||
|
||||
#endif
|
||||
self->vk->vkDestroyDescriptorPool(self->vk->device,
|
||||
self->descriptor_pool, NULL);
|
||||
|
||||
|
|
|
@ -20,13 +20,16 @@ struct layer_transformation
|
|||
bool flip_y;
|
||||
};
|
||||
|
||||
#ifdef XRT_FEATURE_OPENXR_LAYER_EQUIRECT1
|
||||
struct layer_equirect1_data
|
||||
{
|
||||
struct xrt_vec2 scale;
|
||||
struct xrt_vec2 bias;
|
||||
float radius;
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef XRT_FEATURE_OPENXR_LAYER_EQUIRECT2
|
||||
struct layer_equirect2_data
|
||||
{
|
||||
float radius;
|
||||
|
@ -34,6 +37,7 @@ struct layer_equirect2_data
|
|||
float upper_vertical_angle;
|
||||
float lower_vertical_angle;
|
||||
};
|
||||
#endif
|
||||
|
||||
struct comp_render_layer
|
||||
{
|
||||
|
@ -48,12 +52,14 @@ struct comp_render_layer
|
|||
struct layer_transformation transformation[2];
|
||||
struct vk_buffer transformation_ubos[2];
|
||||
|
||||
#ifdef XRT_FEATURE_OPENXR_LAYER_EQUIRECT1
|
||||
struct layer_equirect1_data equirect1_data;
|
||||
struct vk_buffer equirect1_ubo;
|
||||
|
||||
#endif
|
||||
#ifdef XRT_FEATURE_OPENXR_LAYER_EQUIRECT2
|
||||
struct layer_equirect2_data equirect2_data;
|
||||
struct vk_buffer equirect2_ubo;
|
||||
|
||||
#endif
|
||||
VkDescriptorPool descriptor_pool;
|
||||
VkDescriptorSet descriptor_sets[2];
|
||||
VkDescriptorSet descriptor_equirect;
|
||||
|
@ -114,10 +120,13 @@ bool
|
|||
comp_layer_update_cylinder_vertex_buffer(struct comp_render_layer *self,
|
||||
float central_angle);
|
||||
|
||||
#ifdef XRT_FEATURE_OPENXR_LAYER_EQUIRECT1
|
||||
void
|
||||
comp_layer_update_equirect1_descriptor(struct comp_render_layer *self,
|
||||
struct xrt_layer_equirect1_data *data);
|
||||
|
||||
#endif
|
||||
#ifdef XRT_FEATURE_OPENXR_LAYER_EQUIRECT2
|
||||
void
|
||||
comp_layer_update_equirect2_descriptor(struct comp_render_layer *self,
|
||||
struct xrt_layer_equirect2_data *data);
|
||||
#endif
|
||||
|
|
|
@ -574,6 +574,7 @@ comp_renderer_set_projection_layer(struct comp_renderer *r,
|
|||
l->transformation[1].extent = data->stereo.r.sub.rect.extent;
|
||||
}
|
||||
|
||||
#ifdef XRT_FEATURE_OPENXR_LAYER_EQUIRECT1
|
||||
void
|
||||
comp_renderer_set_equirect1_layer(struct comp_renderer *r,
|
||||
uint32_t layer,
|
||||
|
@ -608,7 +609,8 @@ comp_renderer_set_equirect1_layer(struct comp_renderer *r,
|
|||
l->transformation[i].extent = data->equirect1.sub.rect.extent;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef XRT_FEATURE_OPENXR_LAYER_EQUIRECT2
|
||||
void
|
||||
comp_renderer_set_equirect2_layer(struct comp_renderer *r,
|
||||
uint32_t layer,
|
||||
|
@ -643,6 +645,7 @@ comp_renderer_set_equirect2_layer(struct comp_renderer *r,
|
|||
l->transformation[i].extent = data->equirect2.sub.rect.extent;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
comp_renderer_draw(struct comp_renderer *r)
|
||||
|
|
|
@ -73,17 +73,20 @@ comp_renderer_set_cylinder_layer(struct comp_renderer *r,
|
|||
struct comp_swapchain_image *image,
|
||||
struct xrt_layer_data *data);
|
||||
|
||||
#ifdef XRT_FEATURE_OPENXR_LAYER_EQUIRECT1
|
||||
void
|
||||
comp_renderer_set_equirect1_layer(struct comp_renderer *r,
|
||||
uint32_t layer,
|
||||
struct comp_swapchain_image *image,
|
||||
struct xrt_layer_data *data);
|
||||
|
||||
#endif
|
||||
#ifdef XRT_FEATURE_OPENXR_LAYER_EQUIRECT2
|
||||
void
|
||||
comp_renderer_set_equirect2_layer(struct comp_renderer *r,
|
||||
uint32_t layer,
|
||||
struct comp_swapchain_image *image,
|
||||
struct xrt_layer_data *data);
|
||||
#endif
|
||||
|
||||
void
|
||||
comp_renderer_allocate_layers(struct comp_renderer *self, uint32_t num_layers);
|
||||
|
|
Loading…
Reference in a new issue