Re: [Mesa-dev] [PATCH 2/3] radeonsi: only do depth-only or stencil-only in-place decompression

2015-09-09 Thread Michel Dänzer
On 07.09.2015 07:17, Marek Olšák wrote:
> From: Marek Olšák 
> 
> instead of always doing both.
> Usually, only depth is needed, so stencil decompression is useless.

[...]

> @@ -247,6 +256,7 @@ void si_flush_depth_textures(struct si_context *sctx,
>   assert(tex->is_depth && !tex->is_flushing_texture);
>  
>   si_blit_decompress_depth_in_place(sctx, tex,
> +   ((struct 
> si_sampler_view*)view)->is_stencil_sampler,

This cast is a bit ugly, please use a separate local variable of type
struct si_sampler_view* for this.


With that fixed,

Reviewed-by: Michel Dänzer 


Correspondingly for patch 3.


-- 
Earthling Michel Dänzer   |   http://www.amd.com
Libre software enthusiast | Mesa and X developer
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 2/3] radeonsi: only do depth-only or stencil-only in-place decompression

2015-09-06 Thread Marek Olšák
From: Marek Olšák 

instead of always doing both.
Usually, only depth is needed, so stencil decompression is useless.
---
 src/gallium/drivers/radeonsi/si_blit.c  | 26 --
 src/gallium/drivers/radeonsi/si_pipe.h  |  4 +++-
 src/gallium/drivers/radeonsi/si_state.c | 12 +---
 3 files changed, 32 insertions(+), 10 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_blit.c 
b/src/gallium/drivers/radeonsi/si_blit.c
index 93fa67a..a8a271e 100644
--- a/src/gallium/drivers/radeonsi/si_blit.c
+++ b/src/gallium/drivers/radeonsi/si_blit.c
@@ -180,19 +180,27 @@ static void si_blit_decompress_depth(struct pipe_context 
*ctx,
 
 static void si_blit_decompress_depth_in_place(struct si_context *sctx,
   struct r600_texture *texture,
+ bool is_stencil_sampler,
   unsigned first_level, unsigned 
last_level,
   unsigned first_layer, unsigned 
last_layer)
 {
struct pipe_surface *zsurf, surf_tmpl = {{0}};
unsigned layer, max_layer, checked_last_layer, level;
-
-   sctx->db_inplace_flush_enabled = true;
+   unsigned *dirty_level_mask;
+
+   if (is_stencil_sampler) {
+   sctx->db_flush_stencil_inplace = true;
+   dirty_level_mask = >stencil_dirty_level_mask;
+   } else {
+   sctx->db_flush_depth_inplace = true;
+   dirty_level_mask = >dirty_level_mask;
+   }
si_mark_atom_dirty(sctx, >db_render_state);
 
surf_tmpl.format = texture->resource.b.b.format;
 
for (level = first_level; level <= last_level; level++) {
-   if (!(texture->dirty_level_mask & (1 << level)))
+   if (!(*dirty_level_mask & (1 << level)))
continue;
 
surf_tmpl.u.tex.level = level;
@@ -220,11 +228,12 @@ static void si_blit_decompress_depth_in_place(struct 
si_context *sctx,
/* The texture will always be dirty if some layers aren't 
flushed.
 * I don't think this case occurs often though. */
if (first_layer == 0 && last_layer == max_layer) {
-   texture->dirty_level_mask &= ~(1 << level);
+   *dirty_level_mask &= ~(1 << level);
}
}
 
-   sctx->db_inplace_flush_enabled = false;
+   sctx->db_flush_depth_inplace = false;
+   sctx->db_flush_stencil_inplace = false;
si_mark_atom_dirty(sctx, >db_render_state);
 }
 
@@ -247,6 +256,7 @@ void si_flush_depth_textures(struct si_context *sctx,
assert(tex->is_depth && !tex->is_flushing_texture);
 
si_blit_decompress_depth_in_place(sctx, tex,
+ ((struct 
si_sampler_view*)view)->is_stencil_sampler,
  view->u.tex.first_level, 
view->u.tex.last_level,
  0, 
util_max_layer(>resource.b.b, view->u.tex.first_level));
}
@@ -436,9 +446,13 @@ static void si_decompress_subresource(struct pipe_context 
*ctx,
struct r600_texture *rtex = (struct r600_texture*)tex;
 
if (rtex->is_depth && !rtex->is_flushing_texture) {
-   si_blit_decompress_depth_in_place(sctx, rtex,
+   si_blit_decompress_depth_in_place(sctx, rtex, false,
  level, level,
  first_layer, last_layer);
+   if (rtex->surface.flags & RADEON_SURF_SBUFFER)
+   si_blit_decompress_depth_in_place(sctx, rtex, true,
+ level, level,
+ first_layer, 
last_layer);
} else if (rtex->fmask.size || rtex->cmask.size) {
si_blit_decompress_color(ctx, rtex, level, level,
 first_layer, last_layer);
diff --git a/src/gallium/drivers/radeonsi/si_pipe.h 
b/src/gallium/drivers/radeonsi/si_pipe.h
index 847853e..9143c77 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.h
+++ b/src/gallium/drivers/radeonsi/si_pipe.h
@@ -100,6 +100,7 @@ struct si_sampler_view {
  * [4..7] = buffer descriptor */
uint32_tstate[8];
uint32_tfmask_state[8];
+   bool is_stencil_sampler;
 };
 
 struct si_sampler_state {
@@ -237,7 +238,8 @@ struct si_context {
booldbcb_depth_copy_enabled;
booldbcb_stencil_copy_enabled;
unsigneddbcb_copy_sample;
-   booldb_inplace_flush_enabled;
+   booldb_flush_depth_inplace;
+   booldb_flush_stencil_inplace;
bool