Re: [Mesa-dev] [PATCH v3 56/63] radeonsi: decompress resident textures/images before graphics/compute

2017-06-13 Thread Marek Olšák
On Fri, Jun 9, 2017 at 3:35 PM, Samuel Pitoiset
 wrote:
> Similar to the existing decompression code path except that it
> loops over the list of resident textures/images.
>
> v3: - move the blitter check back to si_decompress_textures()
> - decompress resident textures directly in si_decompress_textures()
> - depth_texture -> needs_depth_decompress
> - compressed_colortex -> need_color_decompress
> - rebase on top of marek's cleanup
> v2: - store pipe_sampler_view instead of si_sampler_view
>
> Signed-off-by: Samuel Pitoiset 
> Reviewed-by: Marek Olšák  (v2)
> ---
>  src/gallium/drivers/radeonsi/si_blit.c| 65 
> +++
>  src/gallium/drivers/radeonsi/si_descriptors.c | 52 +
>  src/gallium/drivers/radeonsi/si_pipe.h|  3 ++
>  3 files changed, 120 insertions(+)
>
> diff --git a/src/gallium/drivers/radeonsi/si_blit.c 
> b/src/gallium/drivers/radeonsi/si_blit.c
> index 2740d040df..8b77242759 100644
> --- a/src/gallium/drivers/radeonsi/si_blit.c
> +++ b/src/gallium/drivers/radeonsi/si_blit.c
> @@ -22,6 +22,7 @@
>   */
>
>  #include "si_pipe.h"
> +#include "si_compute.h"
>  #include "util/u_format.h"
>  #include "util/u_surface.h"
>
> @@ -706,6 +707,67 @@ static void si_check_render_feedback(struct si_context 
> *sctx)
> sctx->need_check_render_feedback = false;
>  }
>
> +static void si_decompress_resident_textures(struct si_context *sctx)
> +{
> +   unsigned num_resident_tex_handles;
> +   unsigned i;
> +
> +   num_resident_tex_handles = sctx->resident_tex_handles.size /
> +  sizeof(struct si_texture_handle *);
> +
> +   for (i = 0; i < num_resident_tex_handles; i++) {
> +   struct si_texture_handle *tex_handle =
> +   *util_dynarray_element(&sctx->resident_tex_handles,
> +  struct si_texture_handle *, i);
> +   struct pipe_sampler_view *view = tex_handle->view;
> +   struct si_sampler_view *sview = (struct si_sampler_view 
> *)view;
> +   struct r600_texture *tex;
> +
> +   assert(view);

This assertion is unnecessary. view is guaranteed to be non-NULL.

> +   tex = (struct r600_texture *)view->texture;
> +
> +   if (view->texture->target == PIPE_BUFFER)
> +   continue;
> +
> +   if (tex_handle->needs_color_decompress)
> +   si_decompress_color_texture(sctx, tex, 
> view->u.tex.first_level,
> +   view->u.tex.last_level);
> +
> +   if (tex_handle->needs_depth_decompress)
> +   si_decompress_depth(sctx, tex,
> +   sview->is_stencil_sampler ? PIPE_MASK_S : 
> PIPE_MASK_Z,
> +   view->u.tex.first_level, 
> view->u.tex.last_level,
> +   0, util_max_layer(&tex->resource.b.b, 
> view->u.tex.first_level));
> +   }
> +}
> +
> +static void si_decompress_resident_images(struct si_context *sctx)
> +{
> +   unsigned num_resident_img_handles;
> +   unsigned i;
> +
> +   num_resident_img_handles = sctx->resident_img_handles.size /
> +  sizeof(struct si_image_handle *);
> +
> +   for (i = 0; i < num_resident_img_handles; i++) {
> +   struct si_image_handle *img_handle =
> +   *util_dynarray_element(&sctx->resident_img_handles,
> +  struct si_image_handle *, i);
> +   struct pipe_image_view *view = &img_handle->view;
> +   struct r600_texture *tex;
> +
> +   assert(view);

Same here.

Other than those, this is:

Reviewed-by: Marek Olšák 

Marek
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v3 56/63] radeonsi: decompress resident textures/images before graphics/compute

2017-06-09 Thread Samuel Pitoiset
Similar to the existing decompression code path except that it
loops over the list of resident textures/images.

v3: - move the blitter check back to si_decompress_textures()
- decompress resident textures directly in si_decompress_textures()
- depth_texture -> needs_depth_decompress
- compressed_colortex -> need_color_decompress
- rebase on top of marek's cleanup
v2: - store pipe_sampler_view instead of si_sampler_view

Signed-off-by: Samuel Pitoiset 
Reviewed-by: Marek Olšák  (v2)
---
 src/gallium/drivers/radeonsi/si_blit.c| 65 +++
 src/gallium/drivers/radeonsi/si_descriptors.c | 52 +
 src/gallium/drivers/radeonsi/si_pipe.h|  3 ++
 3 files changed, 120 insertions(+)

diff --git a/src/gallium/drivers/radeonsi/si_blit.c 
b/src/gallium/drivers/radeonsi/si_blit.c
index 2740d040df..8b77242759 100644
--- a/src/gallium/drivers/radeonsi/si_blit.c
+++ b/src/gallium/drivers/radeonsi/si_blit.c
@@ -22,6 +22,7 @@
  */
 
 #include "si_pipe.h"
+#include "si_compute.h"
 #include "util/u_format.h"
 #include "util/u_surface.h"
 
@@ -706,6 +707,67 @@ static void si_check_render_feedback(struct si_context 
*sctx)
sctx->need_check_render_feedback = false;
 }
 
+static void si_decompress_resident_textures(struct si_context *sctx)
+{
+   unsigned num_resident_tex_handles;
+   unsigned i;
+
+   num_resident_tex_handles = sctx->resident_tex_handles.size /
+  sizeof(struct si_texture_handle *);
+
+   for (i = 0; i < num_resident_tex_handles; i++) {
+   struct si_texture_handle *tex_handle =
+   *util_dynarray_element(&sctx->resident_tex_handles,
+  struct si_texture_handle *, i);
+   struct pipe_sampler_view *view = tex_handle->view;
+   struct si_sampler_view *sview = (struct si_sampler_view *)view;
+   struct r600_texture *tex;
+
+   assert(view);
+   tex = (struct r600_texture *)view->texture;
+
+   if (view->texture->target == PIPE_BUFFER)
+   continue;
+
+   if (tex_handle->needs_color_decompress)
+   si_decompress_color_texture(sctx, tex, 
view->u.tex.first_level,
+   view->u.tex.last_level);
+
+   if (tex_handle->needs_depth_decompress)
+   si_decompress_depth(sctx, tex,
+   sview->is_stencil_sampler ? PIPE_MASK_S : 
PIPE_MASK_Z,
+   view->u.tex.first_level, view->u.tex.last_level,
+   0, util_max_layer(&tex->resource.b.b, 
view->u.tex.first_level));
+   }
+}
+
+static void si_decompress_resident_images(struct si_context *sctx)
+{
+   unsigned num_resident_img_handles;
+   unsigned i;
+
+   num_resident_img_handles = sctx->resident_img_handles.size /
+  sizeof(struct si_image_handle *);
+
+   for (i = 0; i < num_resident_img_handles; i++) {
+   struct si_image_handle *img_handle =
+   *util_dynarray_element(&sctx->resident_img_handles,
+  struct si_image_handle *, i);
+   struct pipe_image_view *view = &img_handle->view;
+   struct r600_texture *tex;
+
+   assert(view);
+   tex = (struct r600_texture *)view->resource;
+
+   if (view->resource->target == PIPE_BUFFER)
+   continue;
+
+   if (img_handle->needs_color_decompress)
+   si_decompress_color_texture(sctx, tex, 
view->u.tex.level,
+   view->u.tex.level);
+   }
+}
+
 static void si_decompress_textures(struct si_context *sctx, unsigned 
shader_mask)
 {
unsigned compressed_colortex_counter, mask;
@@ -736,6 +798,9 @@ static void si_decompress_textures(struct si_context *sctx, 
unsigned shader_mask
}
}
 
+   si_decompress_resident_textures(sctx);
+   si_decompress_resident_images(sctx);
+
si_check_render_feedback(sctx);
 }
 
diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c 
b/src/gallium/drivers/radeonsi/si_descriptors.c
index 980448181c..6ab9b77e54 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -1615,6 +1615,48 @@ static void si_set_polygon_stipple(struct pipe_context 
*ctx,
 
 /* TEXTURE METADATA ENABLE/DISABLE */
 
+static void
+si_resident_handles_update_compressed_colortex(struct si_context *sctx)
+{
+   unsigned num_resident_tex_handles, num_resident_img_handles;
+   unsigned i;
+
+   num_resident_tex_handles = sctx->resident_tex_handles.size /
+  sizeof(struct si_texture_handle *);
+
+   for (i = 0; i < num_resident_tex_ha