Discussion:
[PATCH] radeonsi: update non-resident bindless descriptors if needed
(too old to reply)
Samuel Pitoiset
2017-08-09 13:47:22 UTC
Permalink
Raw Message
Only resident bindless descriptors are currently updated and
re-uploaded, this makes sure that the non-resident ones are
also updated.

Signed-off-by: Samuel Pitoiset <***@gmail.com>
Cc: "17.2" <mesa-***@lists.freedesktop.org>
---
src/gallium/drivers/radeonsi/si_descriptors.c | 85 +++++++++++++++++----------
1 file changed, 55 insertions(+), 30 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c b/src/gallium/drivers/radeonsi/si_descriptors.c
index 1e0c422fb4..537dc7fa50 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -1997,45 +1997,55 @@ static void si_upload_bindless_descriptors(struct si_context *sctx)
}

/* Update mutable image descriptor fields of all resident textures. */
-static void si_update_all_resident_texture_descriptors(struct si_context *sctx)
+static void si_update_resident_texture_descriptor(struct si_context *sctx,
+ struct si_texture_handle *tex_handle)
{
- util_dynarray_foreach(&sctx->resident_tex_handles,
- struct si_texture_handle *, tex_handle) {
- struct si_bindless_descriptor *desc = (*tex_handle)->desc;
- struct si_sampler_view *sview =
- (struct si_sampler_view *)(*tex_handle)->view;
- uint32_t desc_list[16];
+ struct si_sampler_view *sview = (struct si_sampler_view *)tex_handle->view;
+ struct si_bindless_descriptor *desc = tex_handle->desc;
+ uint32_t desc_list[16];

- if (sview->base.texture->target == PIPE_BUFFER)
- continue;
+ if (sview->base.texture->target == PIPE_BUFFER)
+ return;

- memcpy(desc_list, desc->desc_list, sizeof(desc_list));
- si_set_sampler_view_desc(sctx, sview, &(*tex_handle)->sstate,
- &desc->desc_list[0]);
+ memcpy(desc_list, desc->desc_list, sizeof(desc_list));
+ si_set_sampler_view_desc(sctx, sview, &tex_handle->sstate,
+ &desc->desc_list[0]);

- if (memcmp(desc_list, desc->desc_list, sizeof(desc_list))) {
- desc->dirty = true;
- sctx->bindless_descriptors_dirty = true;
- }
+ if (memcmp(desc_list, desc->desc_list, sizeof(desc_list))) {
+ desc->dirty = true;
+ sctx->bindless_descriptors_dirty = true;
}
+}

- util_dynarray_foreach(&sctx->resident_img_handles,
- struct si_image_handle *, img_handle) {
- struct si_bindless_descriptor *desc = (*img_handle)->desc;
- struct pipe_image_view *view = &(*img_handle)->view;
- uint32_t desc_list[16];
+static void si_update_resident_image_descriptor(struct si_context *sctx,
+ struct si_image_handle *img_handle)
+{
+ struct si_bindless_descriptor *desc = img_handle->desc;
+ struct pipe_image_view *view = &img_handle->view;
+ uint32_t desc_list[16];

- if (view->resource->target == PIPE_BUFFER)
- continue;
+ if (view->resource->target == PIPE_BUFFER)
+ return;

- memcpy(desc_list, desc->desc_list, sizeof(desc_list));
- si_set_shader_image_desc(sctx, view, true,
- &desc->desc_list[0]);
+ memcpy(desc_list, desc->desc_list, sizeof(desc_list));
+ si_set_shader_image_desc(sctx, view, true, &desc->desc_list[0]);

- if (memcmp(desc_list, desc->desc_list, sizeof(desc_list))) {
- desc->dirty = true;
- sctx->bindless_descriptors_dirty = true;
- }
+ if (memcmp(desc_list, desc->desc_list, sizeof(desc_list))) {
+ desc->dirty = true;
+ sctx->bindless_descriptors_dirty = true;
+ }
+}
+
+static void si_update_all_resident_texture_descriptors(struct si_context *sctx)
+{
+ util_dynarray_foreach(&sctx->resident_tex_handles,
+ struct si_texture_handle *, tex_handle) {
+ si_update_resident_texture_descriptor(sctx, *tex_handle);
+ }
+
+ util_dynarray_foreach(&sctx->resident_img_handles,
+ struct si_image_handle *, img_handle) {
+ si_update_resident_image_descriptor(sctx, *img_handle);
}

si_upload_bindless_descriptors(sctx);
@@ -2513,6 +2523,13 @@ static void si_make_texture_handle_resident(struct pipe_context *ctx,
if (rtex->dcc_offset &&
p_atomic_read(&rtex->framebuffers_bound))
sctx->need_check_render_feedback = true;
+
+ /* Re-upload the descriptor if it has been updated
+ * while it wasn't resident.
+ */
+ si_update_resident_texture_descriptor(sctx, tex_handle);
+ if (tex_handle->desc->dirty)
+ sctx->bindless_descriptors_dirty = true;
} else {
si_invalidate_bindless_buf_desc(sctx, tex_handle->desc,
sview->base.texture,
@@ -2649,6 +2666,14 @@ static void si_make_image_handle_resident(struct pipe_context *ctx,
if (vi_dcc_enabled(rtex, level) &&
p_atomic_read(&rtex->framebuffers_bound))
sctx->need_check_render_feedback = true;
+
+ /* Re-upload the descriptor if it has been updated
+ * while it wasn't resident.
+ */
+ si_update_resident_image_descriptor(sctx, img_handle);
+ if (img_handle->desc->dirty)
+ sctx->bindless_descriptors_dirty = true;
+
} else {
si_invalidate_bindless_buf_desc(sctx, img_handle->desc,
view->resource,
--
2.14.0
Marek Olšák
2017-08-11 17:44:21 UTC
Permalink
Raw Message
Reviewed-by: Marek Olšák <***@amd.com>

Marek

On Wed, Aug 9, 2017 at 3:47 PM, Samuel Pitoiset
Post by Samuel Pitoiset
Only resident bindless descriptors are currently updated and
re-uploaded, this makes sure that the non-resident ones are
also updated.
---
src/gallium/drivers/radeonsi/si_descriptors.c | 85 +++++++++++++++++----------
1 file changed, 55 insertions(+), 30 deletions(-)
diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c b/src/gallium/drivers/radeonsi/si_descriptors.c
index 1e0c422fb4..537dc7fa50 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -1997,45 +1997,55 @@ static void si_upload_bindless_descriptors(struct si_context *sctx)
}
/* Update mutable image descriptor fields of all resident textures. */
-static void si_update_all_resident_texture_descriptors(struct si_context *sctx)
+static void si_update_resident_texture_descriptor(struct si_context *sctx,
+ struct si_texture_handle *tex_handle)
{
- util_dynarray_foreach(&sctx->resident_tex_handles,
- struct si_texture_handle *, tex_handle) {
- struct si_bindless_descriptor *desc = (*tex_handle)->desc;
- struct si_sampler_view *sview =
- (struct si_sampler_view *)(*tex_handle)->view;
- uint32_t desc_list[16];
+ struct si_sampler_view *sview = (struct si_sampler_view *)tex_handle->view;
+ struct si_bindless_descriptor *desc = tex_handle->desc;
+ uint32_t desc_list[16];
- if (sview->base.texture->target == PIPE_BUFFER)
- continue;
+ if (sview->base.texture->target == PIPE_BUFFER)
+ return;
- memcpy(desc_list, desc->desc_list, sizeof(desc_list));
- si_set_sampler_view_desc(sctx, sview, &(*tex_handle)->sstate,
- &desc->desc_list[0]);
+ memcpy(desc_list, desc->desc_list, sizeof(desc_list));
+ si_set_sampler_view_desc(sctx, sview, &tex_handle->sstate,
+ &desc->desc_list[0]);
- if (memcmp(desc_list, desc->desc_list, sizeof(desc_list))) {
- desc->dirty = true;
- sctx->bindless_descriptors_dirty = true;
- }
+ if (memcmp(desc_list, desc->desc_list, sizeof(desc_list))) {
+ desc->dirty = true;
+ sctx->bindless_descriptors_dirty = true;
}
+}
- util_dynarray_foreach(&sctx->resident_img_handles,
- struct si_image_handle *, img_handle) {
- struct si_bindless_descriptor *desc = (*img_handle)->desc;
- struct pipe_image_view *view = &(*img_handle)->view;
- uint32_t desc_list[16];
+static void si_update_resident_image_descriptor(struct si_context *sctx,
+ struct si_image_handle *img_handle)
+{
+ struct si_bindless_descriptor *desc = img_handle->desc;
+ struct pipe_image_view *view = &img_handle->view;
+ uint32_t desc_list[16];
- if (view->resource->target == PIPE_BUFFER)
- continue;
+ if (view->resource->target == PIPE_BUFFER)
+ return;
- memcpy(desc_list, desc->desc_list, sizeof(desc_list));
- si_set_shader_image_desc(sctx, view, true,
- &desc->desc_list[0]);
+ memcpy(desc_list, desc->desc_list, sizeof(desc_list));
+ si_set_shader_image_desc(sctx, view, true, &desc->desc_list[0]);
- if (memcmp(desc_list, desc->desc_list, sizeof(desc_list))) {
- desc->dirty = true;
- sctx->bindless_descriptors_dirty = true;
- }
+ if (memcmp(desc_list, desc->desc_list, sizeof(desc_list))) {
+ desc->dirty = true;
+ sctx->bindless_descriptors_dirty = true;
+ }
+}
+
+static void si_update_all_resident_texture_descriptors(struct si_context *sctx)
+{
+ util_dynarray_foreach(&sctx->resident_tex_handles,
+ struct si_texture_handle *, tex_handle) {
+ si_update_resident_texture_descriptor(sctx, *tex_handle);
+ }
+
+ util_dynarray_foreach(&sctx->resident_img_handles,
+ struct si_image_handle *, img_handle) {
+ si_update_resident_image_descriptor(sctx, *img_handle);
}
si_upload_bindless_descriptors(sctx);
@@ -2513,6 +2523,13 @@ static void si_make_texture_handle_resident(struct pipe_context *ctx,
if (rtex->dcc_offset &&
p_atomic_read(&rtex->framebuffers_bound))
sctx->need_check_render_feedback = true;
+
+ /* Re-upload the descriptor if it has been updated
+ * while it wasn't resident.
+ */
+ si_update_resident_texture_descriptor(sctx, tex_handle);
+ if (tex_handle->desc->dirty)
+ sctx->bindless_descriptors_dirty = true;
} else {
si_invalidate_bindless_buf_desc(sctx, tex_handle->desc,
sview->base.texture,
@@ -2649,6 +2666,14 @@ static void si_make_image_handle_resident(struct pipe_context *ctx,
if (vi_dcc_enabled(rtex, level) &&
p_atomic_read(&rtex->framebuffers_bound))
sctx->need_check_render_feedback = true;
+
+ /* Re-upload the descriptor if it has been updated
+ * while it wasn't resident.
+ */
+ si_update_resident_image_descriptor(sctx, img_handle);
+ if (img_handle->desc->dirty)
+ sctx->bindless_descriptors_dirty = true;
+
} else {
si_invalidate_bindless_buf_desc(sctx, img_handle->desc,
view->resource,
--
2.14.0
_______________________________________________
mesa-stable mailing list
https://lists.freedesktop.org/mailman/listinfo/mesa-stable
Emil Velikov
2017-08-18 23:49:06 UTC
Permalink
Raw Message
Hi Samuel,
Post by Samuel Pitoiset
Only resident bindless descriptors are currently updated and
re-uploaded, this makes sure that the non-resident ones are
also updated.
AFAICT the patch has not landed in master hence It won't be in stable, yet.
Has it fallen through the cracks or it's been superseded?

Thanks
Emil
Marek Olšák
2017-08-19 01:37:33 UTC
Permalink
Raw Message
Post by Emil Velikov
Hi Samuel,
Post by Samuel Pitoiset
Only resident bindless descriptors are currently updated and
re-uploaded, this makes sure that the non-resident ones are
also updated.
AFAICT the patch has not landed in master hence It won't be in stable, yet.
Has it fallen through the cracks or it's been superseded?
I don't know where Samuel is, but "vacation" would be my guess.

Marek
Samuel Pitoiset
2017-08-21 13:23:15 UTC
Permalink
Raw Message
Post by Marek Olšák
Post by Emil Velikov
Hi Samuel,
Post by Samuel Pitoiset
Only resident bindless descriptors are currently updated and
re-uploaded, this makes sure that the non-resident ones are
also updated.
AFAICT the patch has not landed in master hence It won't be in stable, yet.
Has it fallen through the cracks or it's been superseded?
I don't know where Samuel is, but "vacation" would be my guess.
That was a good guess, I will push it right now.

Sorry for the delay.
Post by Marek Olšák
Marek
Marek Olšák
2017-08-21 13:29:52 UTC
Permalink
Raw Message
On Mon, Aug 21, 2017 at 3:23 PM, Samuel Pitoiset
Post by Samuel Pitoiset
Post by Marek Olšák
Post by Emil Velikov
Hi Samuel,
Post by Samuel Pitoiset
Only resident bindless descriptors are currently updated and
re-uploaded, this makes sure that the non-resident ones are
also updated.
AFAICT the patch has not landed in master hence It won't be in stable, yet.
Has it fallen through the cracks or it's been superseded?
I don't know where Samuel is, but "vacation" would be my guess.
That was a good guess, I will push it right now.
Sorry for the delay.
No problem. i'm happy that you're back.

Marek

Loading...