mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-01 12:46:12 +00:00
c/render: Use sub-allocation for mesh shader UBOs
This commit is contained in:
parent
06ddfe32df
commit
d1ce6c15ac
|
@ -806,6 +806,36 @@ do_gfx_mesh(struct comp_renderer *r,
|
|||
VkImageView src_image_views[2],
|
||||
const struct xrt_normalized_rect src_norm_rects[2])
|
||||
{
|
||||
struct vk_bundle *vk = &r->c->base.vk;
|
||||
VkResult ret;
|
||||
|
||||
/*
|
||||
* Reserve UBOs and fill in any data a head of time, if we ever want to
|
||||
* copy UBO data this lets us do that easily write a copy command before
|
||||
* the other gfx commands.
|
||||
*/
|
||||
struct render_sub_alloc ubos[2];
|
||||
for (uint32_t i = 0; i < 2; i++) {
|
||||
|
||||
struct render_gfx_mesh_ubo_data data = {
|
||||
.vertex_rot = vertex_rots[i],
|
||||
.post_transform = src_norm_rects[i],
|
||||
};
|
||||
|
||||
ret = render_sub_alloc_ubo_alloc_and_write( //
|
||||
vk, // vk_bundle
|
||||
&rr->ubo_tracker, // rsat
|
||||
&data, // ptr
|
||||
sizeof(data), // size
|
||||
&ubos[i]); // out_rsa
|
||||
VK_CHK_WITH_GOTO(ret, "render_sub_alloc_ubo_alloc_and_write", err_no_memory);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Do command writing here.
|
||||
*/
|
||||
|
||||
render_gfx_begin_target( //
|
||||
rr, //
|
||||
rtr); //
|
||||
|
@ -819,15 +849,20 @@ do_gfx_mesh(struct comp_renderer *r,
|
|||
render_gfx_distortion( //
|
||||
rr, //
|
||||
i, //
|
||||
&vertex_rots[i], //
|
||||
&ubos[i], //
|
||||
src_samplers[i], //
|
||||
src_image_views[i], //
|
||||
&src_norm_rects[i]); //
|
||||
src_image_views[i]); //
|
||||
|
||||
render_gfx_end_view(rr);
|
||||
}
|
||||
|
||||
render_gfx_end_target(rr);
|
||||
|
||||
return;
|
||||
|
||||
err_no_memory:
|
||||
// Allocator reset at end of frame, nothing to clean up.
|
||||
VK_ERROR(vk, "Could not allocate all UBOs for frame, that's really strange and shouldn't happen!");
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
@ -356,6 +356,7 @@ update_mesh_discriptor_set(struct vk_bundle *vk,
|
|||
VkImageView image_view,
|
||||
uint32_t ubo_binding,
|
||||
VkBuffer buffer,
|
||||
VkDeviceSize offset,
|
||||
VkDeviceSize size,
|
||||
VkDescriptorSet descriptor_set)
|
||||
{
|
||||
|
@ -367,7 +368,7 @@ update_mesh_discriptor_set(struct vk_bundle *vk,
|
|||
|
||||
VkDescriptorBufferInfo buffer_info = {
|
||||
.buffer = buffer,
|
||||
.offset = 0,
|
||||
.offset = offset,
|
||||
.range = size,
|
||||
};
|
||||
|
||||
|
@ -714,12 +715,8 @@ render_gfx_end_view(struct render_gfx *rr)
|
|||
}
|
||||
|
||||
void
|
||||
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)
|
||||
render_gfx_distortion(
|
||||
struct render_gfx *rr, uint32_t view_index, struct render_sub_alloc *ubo, VkSampler sampler, VkImageView image_view)
|
||||
{
|
||||
struct vk_bundle *vk = vk_from_rr(rr);
|
||||
struct render_resources *r = rr->r;
|
||||
|
@ -728,20 +725,8 @@ render_gfx_distortion(struct render_gfx *rr,
|
|||
|
||||
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.
|
||||
|
@ -754,7 +739,8 @@ render_gfx_distortion(struct render_gfx *rr,
|
|||
image_view, // image_view
|
||||
r->mesh.ubo_binding, // ubo_binding
|
||||
ubo->buffer, // buffer
|
||||
VK_WHOLE_SIZE, // size
|
||||
ubo->offset, // offset
|
||||
ubo->size, // size
|
||||
descriptor_set); // descriptor_set
|
||||
|
||||
VkDescriptorSet descriptor_sets[1] = {descriptor_set};
|
||||
|
|
|
@ -898,10 +898,9 @@ render_gfx_end_view(struct render_gfx *rr);
|
|||
void
|
||||
render_gfx_distortion(struct render_gfx *rr,
|
||||
uint32_t view_index,
|
||||
const struct xrt_matrix_2x2 *vertex_rot,
|
||||
struct render_sub_alloc *ubo,
|
||||
VkSampler sampler,
|
||||
VkImageView image_view,
|
||||
const struct xrt_normalized_rect *src_rect);
|
||||
VkImageView image_view);
|
||||
|
||||
/*!
|
||||
* @}
|
||||
|
|
Loading…
Reference in a new issue