freedreno: reorder format check
authorFritz Koenig <frkoenig@google.com>
Thu, 5 Dec 2019 00:16:43 +0000 (16:16 -0800)
committerEric Anholt <eric@anholt.net>
Fri, 6 Dec 2019 21:27:10 +0000 (21:27 +0000)
With the addition of the planar formats helper, the
planar formats no longer have a valid block.bits field.
Calling util_format_get_blocksize therefore asserts.

Reorder the check to see if the format is supported
before doing the query to get the blocksize.

Fixes: 20f132e5eff2d ("gallium/util: add planar format layouts and helpers")
Signed-off-by: Fritz Koenig <frkoenig@google.com>
Reviewed-by: Rob Clark <robdclark@chromium.org>
src/gallium/drivers/freedreno/a4xx/fd4_screen.c
src/gallium/drivers/freedreno/a5xx/fd5_screen.c
src/gallium/drivers/freedreno/a6xx/fd6_screen.c

index 98287b95145aaa08fd27962e34896ce77b3bacdc..db639c72c1280d051e6611f0ee617cbc46e90091 100644 (file)
@@ -60,9 +60,9 @@ fd4_screen_is_format_supported(struct pipe_screen *pscreen,
        }
 
        if ((usage & PIPE_BIND_SAMPLER_VIEW) &&
+                       (fd4_pipe2tex(format) != (enum a4xx_tex_fmt)~0) &&
                        (target == PIPE_BUFFER ||
-                        util_format_get_blocksize(format) != 12) &&
-                       (fd4_pipe2tex(format) != (enum a4xx_tex_fmt)~0)) {
+                        util_format_get_blocksize(format) != 12)) {
                retval |= PIPE_BIND_SAMPLER_VIEW;
        }
 
index b478be3aa66809f535408b85e5f9f87fdf072cbd..12dcb8a6e8014bec63bcf425e8f6099ed2d1d1bb 100644 (file)
@@ -76,9 +76,9 @@ fd5_screen_is_format_supported(struct pipe_screen *pscreen,
        }
 
        if ((usage & (PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_SHADER_IMAGE)) &&
+                       (fd5_pipe2tex(format) != (enum a5xx_tex_fmt)~0) &&
                        (target == PIPE_BUFFER ||
-                        util_format_get_blocksize(format) != 12) &&
-                       (fd5_pipe2tex(format) != (enum a5xx_tex_fmt)~0)) {
+                        util_format_get_blocksize(format) != 12)) {
                retval |= usage & (PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_SHADER_IMAGE);
        }
 
index d5caf9513ca42ac25d4cea99c4297075c95c1da4..6e046cfa8c6d793f8cc8362d89a0869920c31248 100644 (file)
@@ -82,9 +82,9 @@ fd6_screen_is_format_supported(struct pipe_screen *pscreen,
        }
 
        if ((usage & (PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_SHADER_IMAGE)) &&
+                       (fd6_pipe2tex(format) != (enum a6xx_tex_fmt)~0) &&
                        (target == PIPE_BUFFER ||
-                        util_format_get_blocksize(format) != 12) &&
-                       (fd6_pipe2tex(format) != (enum a6xx_tex_fmt)~0)) {
+                        util_format_get_blocksize(format) != 12)) {
                retval |= usage & (PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_SHADER_IMAGE);
        }