mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-01 12:46:12 +00:00
c/render: Refactor gfx distortion dispatch
This commit is contained in:
parent
996195f544
commit
975ca891c3
|
@ -816,19 +816,13 @@ do_gfx_mesh(struct comp_renderer *r,
|
|||
i, // view_index
|
||||
&viewport_datas[i]); // viewport_data
|
||||
|
||||
struct render_gfx_mesh_ubo_data data = {
|
||||
.vertex_rot = vertex_rots[i],
|
||||
.post_transform = src_norm_rects[i],
|
||||
};
|
||||
|
||||
render_gfx_update_distortion( //
|
||||
rr, // rr
|
||||
i, // view,
|
||||
src_samplers[i], // sampler,
|
||||
src_image_views[i], // image_view,
|
||||
&data); // data
|
||||
|
||||
render_gfx_distortion(rr);
|
||||
render_gfx_distortion( //
|
||||
rr, //
|
||||
i, //
|
||||
&vertex_rots[i], //
|
||||
src_samplers[i], //
|
||||
src_image_views[i], //
|
||||
&src_norm_rects[i]); //
|
||||
|
||||
render_gfx_end_view(rr);
|
||||
}
|
||||
|
|
|
@ -711,19 +711,50 @@ render_gfx_end_view(struct render_gfx *rr)
|
|||
}
|
||||
|
||||
void
|
||||
render_gfx_distortion(struct render_gfx *rr)
|
||||
render_gfx_distortion(struct render_gfx *rr,
|
||||
uint32_t view_index,
|
||||
const struct xrt_matrix_2x2 *vertex_rot,
|
||||
VkSampler sampler,
|
||||
VkImageView image_view,
|
||||
const struct xrt_normalized_rect *src_rect)
|
||||
{
|
||||
struct vk_bundle *vk = vk_from_rr(rr);
|
||||
struct render_resources *r = rr->r;
|
||||
|
||||
uint32_t view = rr->current_view;
|
||||
struct render_gfx_view *v = &rr->views[view];
|
||||
assert(view_index == rr->current_view);
|
||||
|
||||
struct render_gfx_view *v = &rr->views[view_index];
|
||||
|
||||
struct render_buffer *ubo = &r->mesh.ubos[view_index];
|
||||
VkDescriptorSet descriptor_set = v->mesh.descriptor_set;
|
||||
|
||||
/*
|
||||
* UBO data.
|
||||
*/
|
||||
|
||||
struct render_gfx_mesh_ubo_data data = {
|
||||
.vertex_rot = *vertex_rot,
|
||||
.post_transform = *src_rect,
|
||||
};
|
||||
|
||||
render_buffer_write(vk, ubo, &data, sizeof(struct render_gfx_mesh_ubo_data));
|
||||
|
||||
|
||||
/*
|
||||
* Descriptors and pipeline.
|
||||
*/
|
||||
|
||||
VkDescriptorSet descriptor_sets[1] = {v->mesh.descriptor_set};
|
||||
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
|
||||
ubo->buffer, // buffer
|
||||
VK_WHOLE_SIZE, // size
|
||||
descriptor_set); // descriptor_set
|
||||
|
||||
VkDescriptorSet descriptor_sets[1] = {descriptor_set};
|
||||
vk->vkCmdBindDescriptorSets( //
|
||||
r->cmd, // commandBuffer
|
||||
VK_PIPELINE_BIND_POINT_GRAPHICS, // pipelineBindPoint
|
||||
|
@ -767,13 +798,13 @@ render_gfx_distortion(struct render_gfx *rr)
|
|||
0, // offset
|
||||
VK_INDEX_TYPE_UINT32); // indexType
|
||||
|
||||
vk->vkCmdDrawIndexed( //
|
||||
r->cmd, // commandBuffer
|
||||
r->mesh.index_counts[view], // indexCount
|
||||
1, // instanceCount
|
||||
r->mesh.index_offsets[view], // firstIndex
|
||||
0, // vertexOffset
|
||||
0); // firstInstance
|
||||
vk->vkCmdDrawIndexed( //
|
||||
r->cmd, // commandBuffer
|
||||
r->mesh.index_counts[view_index], // indexCount
|
||||
1, // instanceCount
|
||||
r->mesh.index_offsets[view_index], // firstIndex
|
||||
0, // vertexOffset
|
||||
0); // firstInstance
|
||||
} else {
|
||||
vk->vkCmdDraw( //
|
||||
r->cmd, // commandBuffer
|
||||
|
@ -783,27 +814,3 @@ render_gfx_distortion(struct render_gfx *rr)
|
|||
0); // firstInstance
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
render_gfx_update_distortion(struct render_gfx *rr,
|
||||
uint32_t view_index,
|
||||
VkSampler sampler,
|
||||
VkImageView image_view,
|
||||
struct render_gfx_mesh_ubo_data *data)
|
||||
{
|
||||
struct vk_bundle *vk = vk_from_rr(rr);
|
||||
struct render_resources *r = rr->r;
|
||||
struct render_gfx_view *v = &rr->views[view_index];
|
||||
|
||||
render_buffer_write(vk, &r->mesh.ubos[view_index], data, sizeof(struct render_gfx_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
|
||||
r->mesh.ubos[view_index].buffer, // buffer
|
||||
VK_WHOLE_SIZE, // size
|
||||
v->mesh.descriptor_set); // descriptor_set
|
||||
}
|
||||
|
|
|
@ -759,36 +759,22 @@ void
|
|||
render_gfx_end_view(struct render_gfx *rr);
|
||||
|
||||
/*!
|
||||
* Dispatch one mesh shader instance into the current view.
|
||||
*
|
||||
* @public @memberof render_gfx
|
||||
*/
|
||||
void
|
||||
render_gfx_distortion(struct render_gfx *rr);
|
||||
render_gfx_distortion(struct render_gfx *rr,
|
||||
uint32_t view_index,
|
||||
const struct xrt_matrix_2x2 *vertex_rot,
|
||||
VkSampler sampler,
|
||||
VkImageView image_view,
|
||||
const struct xrt_normalized_rect *src_rect);
|
||||
|
||||
/*!
|
||||
* @}
|
||||
*/
|
||||
|
||||
/*
|
||||
*
|
||||
* Update functions.
|
||||
*
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @name Update functions
|
||||
* @{
|
||||
*/
|
||||
/*!
|
||||
* @public @memberof render_gfx
|
||||
*/
|
||||
void
|
||||
render_gfx_update_distortion(struct render_gfx *rr,
|
||||
uint32_t view,
|
||||
VkSampler sampler,
|
||||
VkImageView image_view,
|
||||
struct render_gfx_mesh_ubo_data *data);
|
||||
//! @}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue