[Mesa-dev] [RFC PATCH 62/65] radeonsi: invalidate buffers which are made resident if needed
Samuel Pitoiset
samuel.pitoiset at gmail.com
Fri May 19 16:53:07 UTC 2017
When a buffer becomes resident, check if it has been invalidated,
if so update the descriptor and the dirty flag.
Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
---
src/gallium/drivers/radeonsi/si_descriptors.c | 34 +++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c b/src/gallium/drivers/radeonsi/si_descriptors.c
index 6adad06757..0866c54c23 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -2419,6 +2419,32 @@ si_create_resident_descriptor(struct si_context *sctx, uint32_t *desc_list,
return desc;
}
+static void si_invalidate_resident_buf_desc(struct si_context *sctx,
+ struct si_resident_descriptor *desc,
+ struct pipe_resource *resource,
+ uint64_t offset)
+{
+ struct r600_resource *buf = r600_resource(resource);
+ uint32_t *desc_list = desc->desc_list;
+ uint64_t old_desc_va;
+
+ assert(resource->target == PIPE_BUFFER);
+
+ /* Retrieve the old buffer addr from the descriptor. */
+ old_desc_va = desc_list[0];
+ old_desc_va |= ((uint64_t)G_008F04_BASE_ADDRESS_HI(desc_list[1]) << 32);
+
+ if (old_desc_va != buf->gpu_address + offset) {
+ /* The buffer has been invalidated when the handle wasn't
+ * resident, update the descriptor and the dirty flag.
+ */
+ si_set_buf_desc_address(buf, offset, &desc_list[4]);
+
+ desc->dirty = true;
+ sctx->resident_descriptors_dirty = true;
+ }
+}
+
static uint64_t si_create_texture_handle(struct pipe_context *ctx,
struct pipe_resource *texture,
struct pipe_sampler_view *view,
@@ -2515,6 +2541,10 @@ static void si_make_texture_handle_resident(struct pipe_context *ctx,
is_compressed_colortex(rtex);
si_update_check_render_feedback(sctx, rtex);
+ } else {
+ si_invalidate_resident_buf_desc(sctx, tex_handle->desc,
+ sview->base.texture,
+ sview->base.u.buf.offset);
}
si_add_resident_tex_handle(sctx, tex_handle);
@@ -2624,6 +2654,10 @@ static void si_make_image_handle_resident(struct pipe_context *ctx,
is_compressed_colortex(rtex);
si_update_check_render_feedback(sctx, rtex);
+ } else {
+ si_invalidate_resident_buf_desc(sctx, img_handle->desc,
+ view->resource,
+ view->u.buf.offset);
}
si_add_resident_img_handle(sctx, img_handle);
--
2.13.0
More information about the mesa-dev
mailing list