freedreno/a6xx: handle non-UBWC-compatible texture views
authorRob Clark <robdclark@chromium.org>
Fri, 7 Jun 2019 17:31:59 +0000 (10:31 -0700)
committerRob Clark <robdclark@chromium.org>
Tue, 11 Jun 2019 17:55:27 +0000 (10:55 -0700)
Signed-off-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
src/gallium/drivers/freedreno/a6xx/fd6_resource.c
src/gallium/drivers/freedreno/a6xx/fd6_resource.h
src/gallium/drivers/freedreno/a6xx/fd6_texture.c

index ca475f30ef6456701dff1f3be11ad1f1fbfc82ec..d855ad1d9d2db1e79aeebefdd158387f39956d07 100644 (file)
@@ -260,6 +260,24 @@ fd6_fill_ubwc_buffer_sizes(struct fd_resource *rsc)
        return meta_size;
 }
 
+/**
+ * Ensure the rsc is in an ok state to be used with the specified format.
+ * This handles the case of UBWC buffers used with non-UBWC compatible
+ * formats, by triggering an uncompress.
+ */
+void
+fd6_validate_format(struct fd_context *ctx, struct fd_resource *rsc,
+               enum pipe_format format)
+{
+       if (!rsc->ubwc_size)
+               return;
+
+       if (ok_ubwc_format(fd6_pipe2color(format)))
+               return;
+
+       fd_resource_uncompress(ctx, rsc);
+}
+
 uint32_t
 fd6_setup_slices(struct fd_resource *rsc)
 {
index 83b6fb246c7111d1508df462be3e6c40b88c354e..80751d49ca919ac5d40a3cc8f96f86f6a69f8fd2 100644 (file)
@@ -31,6 +31,8 @@
 #include "freedreno_resource.h"
 
 uint32_t fd6_fill_ubwc_buffer_sizes(struct fd_resource *rsc);
+void fd6_validate_format(struct fd_context *ctx, struct fd_resource *rsc,
+               enum pipe_format format);
 uint32_t fd6_setup_slices(struct fd_resource *rsc);
 
 #endif /* FD6_RESOURCE_H_ */
index 608aa08833e3fcd32bd1c9793953471b3e8e92c1..2cb69e01a2ee384cfadaeb30c69b330b29719818 100644 (file)
@@ -33,6 +33,7 @@
 #include "util/hash_table.h"
 
 #include "fd6_texture.h"
+#include "fd6_resource.h"
 #include "fd6_format.h"
 #include "fd6_emit.h"
 
@@ -225,6 +226,8 @@ fd6_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc,
        if (!so)
                return NULL;
 
+       fd6_validate_format(fd_context(pctx), rsc, format);
+
        if (format == PIPE_FORMAT_X32_S8X24_UINT) {
                rsc = rsc->stencil;
                format = rsc->base.format;