mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-06 07:06:10 +00:00
c/main: Refactor mesh descriptor and UBO upload
This commit is contained in:
parent
67430358c2
commit
765feb6fe1
|
@ -218,12 +218,25 @@ renderer_build_rendering(struct comp_renderer *r, struct comp_rendering *rr, uin
|
||||||
struct xrt_view *l_v = &r->c->xdev->hmd->views[0];
|
struct xrt_view *l_v = &r->c->xdev->hmd->views[0];
|
||||||
struct xrt_view *r_v = &r->c->xdev->hmd->views[1];
|
struct xrt_view *r_v = &r->c->xdev->hmd->views[1];
|
||||||
|
|
||||||
struct comp_mesh_ubo_data l_data = {
|
|
||||||
.vertex_rot = l_v->rot,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct comp_mesh_ubo_data r_data = {
|
/*
|
||||||
|
* Init
|
||||||
|
*/
|
||||||
|
|
||||||
|
comp_rendering_init(c, &c->nr, rr);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Update
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct comp_mesh_ubo_data distortion_data[2] = {
|
||||||
|
{
|
||||||
|
.vertex_rot = l_v->rot,
|
||||||
|
},
|
||||||
|
{
|
||||||
.vertex_rot = r_v->rot,
|
.vertex_rot = r_v->rot,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const struct xrt_matrix_2x2 rotation_90_cw = {{
|
const struct xrt_matrix_2x2 rotation_90_cw = {{
|
||||||
|
@ -235,15 +248,30 @@ renderer_build_rendering(struct comp_renderer *r, struct comp_rendering *rr, uin
|
||||||
}};
|
}};
|
||||||
|
|
||||||
if (pre_rotate) {
|
if (pre_rotate) {
|
||||||
math_matrix_2x2_multiply(&l_v->rot, &rotation_90_cw, &l_data.vertex_rot);
|
math_matrix_2x2_multiply(&distortion_data[0].vertex_rot, //
|
||||||
math_matrix_2x2_multiply(&r_v->rot, &rotation_90_cw, &r_data.vertex_rot);
|
&rotation_90_cw, //
|
||||||
|
&distortion_data[0].vertex_rot); //
|
||||||
|
math_matrix_2x2_multiply(&distortion_data[1].vertex_rot, //
|
||||||
|
&rotation_90_cw, //
|
||||||
|
&distortion_data[1].vertex_rot); //
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
comp_draw_update_distortion(rr, //
|
||||||
* Init
|
0, // view_index
|
||||||
*/
|
r->lr->framebuffers[0].sampler, //
|
||||||
|
r->lr->framebuffers[0].view, //
|
||||||
|
&distortion_data[0]); //
|
||||||
|
|
||||||
comp_rendering_init(c, &c->nr, rr);
|
comp_draw_update_distortion(rr, //
|
||||||
|
1, // view_index
|
||||||
|
r->lr->framebuffers[1].sampler, //
|
||||||
|
r->lr->framebuffers[1].view, //
|
||||||
|
&distortion_data[1]); //
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Target
|
||||||
|
*/
|
||||||
|
|
||||||
comp_draw_begin_target_single( //
|
comp_draw_begin_target_single( //
|
||||||
rr, //
|
rr, //
|
||||||
|
@ -260,10 +288,7 @@ renderer_build_rendering(struct comp_renderer *r, struct comp_rendering *rr, uin
|
||||||
0, // view_index
|
0, // view_index
|
||||||
&l_viewport_data); // viewport_data
|
&l_viewport_data); // viewport_data
|
||||||
|
|
||||||
comp_draw_distortion(rr, //
|
comp_draw_distortion(rr);
|
||||||
r->lr->framebuffers[0].sampler, //
|
|
||||||
r->lr->framebuffers[0].view, //
|
|
||||||
&l_data); //
|
|
||||||
|
|
||||||
comp_draw_end_view(rr);
|
comp_draw_end_view(rr);
|
||||||
|
|
||||||
|
@ -277,10 +302,7 @@ renderer_build_rendering(struct comp_renderer *r, struct comp_rendering *rr, uin
|
||||||
1, // view_index
|
1, // view_index
|
||||||
&r_viewport_data); // viewport_data
|
&r_viewport_data); // viewport_data
|
||||||
|
|
||||||
comp_draw_distortion(rr, //
|
comp_draw_distortion(rr);
|
||||||
r->lr->framebuffers[1].sampler, //
|
|
||||||
r->lr->framebuffers[1].view, //
|
|
||||||
&r_data); //
|
|
||||||
|
|
||||||
comp_draw_end_view(rr);
|
comp_draw_end_view(rr);
|
||||||
|
|
||||||
|
|
|
@ -390,12 +390,24 @@ comp_draw_cylinder_layer(
|
||||||
struct comp_rendering *rr, uint32_t layer, VkSampler sampler, VkImageView image_view, struct xrt_layer_data *data);
|
struct comp_rendering *rr, uint32_t layer, VkSampler sampler, VkImageView image_view, struct xrt_layer_data *data);
|
||||||
|
|
||||||
void
|
void
|
||||||
comp_draw_distortion(struct comp_rendering *rr,
|
comp_draw_distortion(struct comp_rendering *rr);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* Update functions.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
void
|
||||||
|
comp_draw_update_distortion(struct comp_rendering *rr,
|
||||||
|
uint32_t view,
|
||||||
VkSampler sampler,
|
VkSampler sampler,
|
||||||
VkImageView image_view,
|
VkImageView image_view,
|
||||||
struct comp_mesh_ubo_data *data);
|
struct comp_mesh_ubo_data *data);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* Compute distortion.
|
* Compute distortion.
|
||||||
|
|
|
@ -736,10 +736,7 @@ comp_draw_end_view(struct comp_rendering *rr)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
comp_draw_distortion(struct comp_rendering *rr,
|
comp_draw_distortion(struct comp_rendering *rr)
|
||||||
VkSampler sampler,
|
|
||||||
VkImageView image_view,
|
|
||||||
struct comp_mesh_ubo_data *data)
|
|
||||||
{
|
{
|
||||||
struct vk_bundle *vk = &rr->c->vk;
|
struct vk_bundle *vk = &rr->c->vk;
|
||||||
struct comp_resources *r = rr->r;
|
struct comp_resources *r = rr->r;
|
||||||
|
@ -751,18 +748,6 @@ comp_draw_distortion(struct comp_rendering *rr,
|
||||||
* Descriptors and pipeline.
|
* Descriptors and pipeline.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
comp_buffer_write(vk, &v->mesh.ubo, data, sizeof(struct comp_mesh_ubo_data));
|
|
||||||
|
|
||||||
update_mesh_discriptor_set( //
|
|
||||||
vk, // vk_bundle
|
|
||||||
r->mesh.src_binding, // src_binding
|
|
||||||
sampler, // sampler
|
|
||||||
image_view, // image_view
|
|
||||||
r->mesh.ubo_binding, // ubo_binding
|
|
||||||
v->mesh.ubo.buffer, // buffer
|
|
||||||
VK_WHOLE_SIZE, // size
|
|
||||||
v->mesh.descriptor_set); // descriptor_set
|
|
||||||
|
|
||||||
VkDescriptorSet descriptor_sets[1] = {v->mesh.descriptor_set};
|
VkDescriptorSet descriptor_sets[1] = {v->mesh.descriptor_set};
|
||||||
vk->vkCmdBindDescriptorSets( //
|
vk->vkCmdBindDescriptorSets( //
|
||||||
rr->cmd, // commandBuffer
|
rr->cmd, // commandBuffer
|
||||||
|
@ -823,3 +808,27 @@ comp_draw_distortion(struct comp_rendering *rr,
|
||||||
0); // firstInstance
|
0); // firstInstance
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
comp_draw_update_distortion(struct comp_rendering *rr,
|
||||||
|
uint32_t view_index,
|
||||||
|
VkSampler sampler,
|
||||||
|
VkImageView image_view,
|
||||||
|
struct comp_mesh_ubo_data *data)
|
||||||
|
{
|
||||||
|
struct vk_bundle *vk = &rr->c->vk;
|
||||||
|
struct comp_resources *r = rr->r;
|
||||||
|
struct comp_rendering_view *v = &rr->views[view_index];
|
||||||
|
|
||||||
|
comp_buffer_write(vk, &v->mesh.ubo, data, sizeof(struct comp_mesh_ubo_data));
|
||||||
|
|
||||||
|
update_mesh_discriptor_set( //
|
||||||
|
vk, // vk_bundle
|
||||||
|
r->mesh.src_binding, // src_binding
|
||||||
|
sampler, // sampler
|
||||||
|
image_view, // image_view
|
||||||
|
r->mesh.ubo_binding, // ubo_binding
|
||||||
|
v->mesh.ubo.buffer, // buffer
|
||||||
|
VK_WHOLE_SIZE, // size
|
||||||
|
v->mesh.descriptor_set); // descriptor_set
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue