Re: [Mesa-dev] [PATCH 11/20] radeonsi: fix texture format reinterpretation with DCC

2016-08-29 Thread Marek Olšák
On Mon, Aug 29, 2016 at 8:29 PM, Bas Nieuwenhuizen
 wrote:
> Hi Marek,
>
> I don't think this accounts for the fast clear bits? unorm->uint and
> snorm<->sint should have compatible clear values, but otherwise we may
> need to eliminate the fast clears.

That's a good point.

I propose that this patch be pushed as-is (unless you have other
comments on it) and the fast clear can be fixed after we have proper
tests.

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


Re: [Mesa-dev] [PATCH 11/20] radeonsi: fix texture format reinterpretation with DCC

2016-08-29 Thread Bas Nieuwenhuizen
Hi Marek,

I don't think this accounts for the fast clear bits? unorm->uint and
snorm<->sint should have compatible clear values, but otherwise we may
need to eliminate the fast clears.

Yours sincerely,
Bas Nieuwenhuizen


On Mon, Aug 29, 2016 at 5:28 PM, Marek Olšák  wrote:
> From: Marek Olšák 
>
> DCC is limited in how texture formats can be reinterpreted using texture
> views. If we get a view format that is incompatible with the initial
> texture format with respect to DCC, disable DCC.
>
> There is a new piglit which tests all format combinations.
> What works and what doesn't was deduced by looking at the piglit failures.
> ---
>  src/gallium/drivers/radeon/r600_pipe_common.h |  6 ++
>  src/gallium/drivers/radeon/r600_texture.c | 96 
> +++
>  src/gallium/drivers/radeonsi/si_blit.c|  8 +++
>  src/gallium/drivers/radeonsi/si_descriptors.c |  3 +-
>  src/gallium/drivers/radeonsi/si_state.c   |  4 ++
>  5 files changed, 116 insertions(+), 1 deletion(-)
>
> diff --git a/src/gallium/drivers/radeon/r600_pipe_common.h 
> b/src/gallium/drivers/radeon/r600_pipe_common.h
> index 1924535..624dea3 100644
> --- a/src/gallium/drivers/radeon/r600_pipe_common.h
> +++ b/src/gallium/drivers/radeon/r600_pipe_common.h
> @@ -750,20 +750,26 @@ void r600_texture_get_fmask_info(struct 
> r600_common_screen *rscreen,
>  struct r600_fmask_info *out);
>  void r600_texture_get_cmask_info(struct r600_common_screen *rscreen,
>  struct r600_texture *rtex,
>  struct r600_cmask_info *out);
>  bool r600_init_flushed_depth_texture(struct pipe_context *ctx,
>  struct pipe_resource *texture,
>  struct r600_texture **staging);
>  void r600_print_texture_info(struct r600_texture *rtex, FILE *f);
>  struct pipe_resource *r600_texture_create(struct pipe_screen *screen,
> const struct pipe_resource *templ);
> +bool vi_dcc_formats_compatible(enum pipe_format format1,
> +  enum pipe_format format2);
> +void vi_dcc_disable_if_incompatible_format(struct r600_common_context *rctx,
> +  struct pipe_resource *tex,
> +  unsigned level,
> +  enum pipe_format view_format);
>  struct pipe_surface *r600_create_surface_custom(struct pipe_context *pipe,
> struct pipe_resource *texture,
> const struct pipe_surface 
> *templ,
> unsigned width, unsigned 
> height);
>  unsigned r600_translate_colorswap(enum pipe_format format, bool 
> do_endian_swap);
>  void vi_separate_dcc_start_query(struct pipe_context *ctx,
>  struct r600_texture *tex);
>  void vi_separate_dcc_stop_query(struct pipe_context *ctx,
> struct r600_texture *tex);
>  void vi_separate_dcc_process_and_reset_stats(struct pipe_context *ctx,
> diff --git a/src/gallium/drivers/radeon/r600_texture.c 
> b/src/gallium/drivers/radeon/r600_texture.c
> index 7bdceb1..2f04019 100644
> --- a/src/gallium/drivers/radeon/r600_texture.c
> +++ b/src/gallium/drivers/radeon/r600_texture.c
> @@ -1659,42 +1659,138 @@ static void r600_texture_transfer_unmap(struct 
> pipe_context *ctx,
>
>  static const struct u_resource_vtbl r600_texture_vtbl =
>  {
> NULL,   /* get_handle */
> r600_texture_destroy,   /* resource_destroy */
> r600_texture_transfer_map,  /* transfer_map */
> u_default_transfer_flush_region, /* transfer_flush_region */
> r600_texture_transfer_unmap,/* transfer_unmap */
>  };
>
> +/* DCC channel type categories within which formats can be reinterpreted
> + * while keeping the same DCC encoding. The swizzle must also match. */
> +enum dcc_channel_type {
> +   dcc_channel_any32,
> +   dcc_channel_int16,
> +   dcc_channel_float16,
> +   dcc_channel_any_10_10_10_2,
> +   dcc_channel_any8,
> +   dcc_channel_incompatible,
> +};
> +
> +/* Return the type of DCC encoding. */
> +static enum dcc_channel_type
> +vi_get_dcc_channel_type(const struct util_format_description *desc)
> +{
> +   int i;
> +
> +   /* Find the first non-void channel. */
> +   for (i = 0; i < desc->nr_channels; i++)
> +   if (desc->channel[i].type != UTIL_FORMAT_TYPE_VOID)
> +   break;
> +   if (i == desc->nr_channels)
> +   return dcc_channel_incompatible;
> +
> +   switch (desc->channel[i].size) {
> +   case 32:
> +   if (desc->nr_channels == 4)
> +   return dcc_channel_incompatible;
> +   else

[Mesa-dev] [PATCH 11/20] radeonsi: fix texture format reinterpretation with DCC

2016-08-29 Thread Marek Olšák
From: Marek Olšák 

DCC is limited in how texture formats can be reinterpreted using texture
views. If we get a view format that is incompatible with the initial
texture format with respect to DCC, disable DCC.

There is a new piglit which tests all format combinations.
What works and what doesn't was deduced by looking at the piglit failures.
---
 src/gallium/drivers/radeon/r600_pipe_common.h |  6 ++
 src/gallium/drivers/radeon/r600_texture.c | 96 +++
 src/gallium/drivers/radeonsi/si_blit.c|  8 +++
 src/gallium/drivers/radeonsi/si_descriptors.c |  3 +-
 src/gallium/drivers/radeonsi/si_state.c   |  4 ++
 5 files changed, 116 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/radeon/r600_pipe_common.h 
b/src/gallium/drivers/radeon/r600_pipe_common.h
index 1924535..624dea3 100644
--- a/src/gallium/drivers/radeon/r600_pipe_common.h
+++ b/src/gallium/drivers/radeon/r600_pipe_common.h
@@ -750,20 +750,26 @@ void r600_texture_get_fmask_info(struct 
r600_common_screen *rscreen,
 struct r600_fmask_info *out);
 void r600_texture_get_cmask_info(struct r600_common_screen *rscreen,
 struct r600_texture *rtex,
 struct r600_cmask_info *out);
 bool r600_init_flushed_depth_texture(struct pipe_context *ctx,
 struct pipe_resource *texture,
 struct r600_texture **staging);
 void r600_print_texture_info(struct r600_texture *rtex, FILE *f);
 struct pipe_resource *r600_texture_create(struct pipe_screen *screen,
const struct pipe_resource *templ);
+bool vi_dcc_formats_compatible(enum pipe_format format1,
+  enum pipe_format format2);
+void vi_dcc_disable_if_incompatible_format(struct r600_common_context *rctx,
+  struct pipe_resource *tex,
+  unsigned level,
+  enum pipe_format view_format);
 struct pipe_surface *r600_create_surface_custom(struct pipe_context *pipe,
struct pipe_resource *texture,
const struct pipe_surface 
*templ,
unsigned width, unsigned 
height);
 unsigned r600_translate_colorswap(enum pipe_format format, bool 
do_endian_swap);
 void vi_separate_dcc_start_query(struct pipe_context *ctx,
 struct r600_texture *tex);
 void vi_separate_dcc_stop_query(struct pipe_context *ctx,
struct r600_texture *tex);
 void vi_separate_dcc_process_and_reset_stats(struct pipe_context *ctx,
diff --git a/src/gallium/drivers/radeon/r600_texture.c 
b/src/gallium/drivers/radeon/r600_texture.c
index 7bdceb1..2f04019 100644
--- a/src/gallium/drivers/radeon/r600_texture.c
+++ b/src/gallium/drivers/radeon/r600_texture.c
@@ -1659,42 +1659,138 @@ static void r600_texture_transfer_unmap(struct 
pipe_context *ctx,
 
 static const struct u_resource_vtbl r600_texture_vtbl =
 {
NULL,   /* get_handle */
r600_texture_destroy,   /* resource_destroy */
r600_texture_transfer_map,  /* transfer_map */
u_default_transfer_flush_region, /* transfer_flush_region */
r600_texture_transfer_unmap,/* transfer_unmap */
 };
 
+/* DCC channel type categories within which formats can be reinterpreted
+ * while keeping the same DCC encoding. The swizzle must also match. */
+enum dcc_channel_type {
+   dcc_channel_any32,
+   dcc_channel_int16,
+   dcc_channel_float16,
+   dcc_channel_any_10_10_10_2,
+   dcc_channel_any8,
+   dcc_channel_incompatible,
+};
+
+/* Return the type of DCC encoding. */
+static enum dcc_channel_type
+vi_get_dcc_channel_type(const struct util_format_description *desc)
+{
+   int i;
+
+   /* Find the first non-void channel. */
+   for (i = 0; i < desc->nr_channels; i++)
+   if (desc->channel[i].type != UTIL_FORMAT_TYPE_VOID)
+   break;
+   if (i == desc->nr_channels)
+   return dcc_channel_incompatible;
+
+   switch (desc->channel[i].size) {
+   case 32:
+   if (desc->nr_channels == 4)
+   return dcc_channel_incompatible;
+   else
+   return dcc_channel_any32;
+   case 16:
+   if (desc->channel[i].type == UTIL_FORMAT_TYPE_FLOAT)
+   return dcc_channel_float16;
+   else
+   return dcc_channel_int16;
+   case 10:
+   return dcc_channel_any_10_10_10_2;
+   case 8:
+   return dcc_channel_any8;
+   default:
+   return dcc_channel_incompatible;
+   }
+}
+
+/* Return if it's