freedreno: make sure depth/stencil layouts are always tiled
authorAmber <amber@igalia.com>
Wed, 1 Feb 2023 15:38:36 +0000 (16:38 +0100)
committerMarge Bot <emma+marge@anholt.net>
Wed, 8 Feb 2023 22:55:52 +0000 (22:55 +0000)
Small depth/stencil textures were using linear tiling, but depth/stencil
attachments cannot use linear tiling for sysmem rendering.

Fixes:
 KHR-GL45.geometry_shader.layered_framebuffer.stencil_support
 KHR-GL45.geometry_shader.layered_framebuffer.depth_support

Signed-off-by: Amber Amber <amber@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21046>

src/freedreno/ci/freedreno-a618-fails.txt
src/freedreno/ci/freedreno-a630-fails.txt
src/gallium/drivers/freedreno/a6xx/fd6_blitter.c
src/gallium/drivers/freedreno/freedreno_resource.c
src/gallium/drivers/freedreno/freedreno_resource.h

index 0cb7d77..dd3cdad 100644 (file)
@@ -12,13 +12,6 @@ KHR-GL45.shading_language_420pack.binding_images,Fail
 KHR-GL45.compute_shader.conditional-dispatching,Fail
 KHR-GL45.buffer_storage.map_persistent_draw,Fail
 
-# Lots of errors like "[279] Check failed. Received: [3,0,0,2] instead of: [5,0,0,2]"
-KHR-GLES31.core.geometry_shader.layered_framebuffer.depth_support,Fail
-KHR-GL45.geometry_shader.layered_framebuffer.depth_support,Fail
-
-KHR-GLES31.core.geometry_shader.layered_framebuffer.stencil_support,Fail
-KHR-GL45.geometry_shader.layered_framebuffer.stencil_support,Fail
-
 # "Invalid value returned: expected:[1, 1, 1, 1] retrieved: [0, 0, 0, 0
 #  Invalid rendering result at esextcTessellationShaderBarrier.cpp:504"
 KHR-GLES31.core.tessellation_shader.tessellation_shader_tc_barriers.barrier_guarded_read_calls,Fail
index b36e643..38682ef 100644 (file)
@@ -11,13 +11,6 @@ KHR-GL45.shading_language_420pack.binding_images,Fail
 KHR-GL45.compute_shader.conditional-dispatching,Fail
 KHR-GL45.buffer_storage.map_persistent_draw,Fail
 
-# Lots of errors like "[279] Check failed. Received: [3,0,0,2] instead of: [5,0,0,2]"
-KHR-GLES31.core.geometry_shader.layered_framebuffer.depth_support,Fail
-KHR-GL45.geometry_shader.layered_framebuffer.depth_support,Fail
-
-KHR-GLES31.core.geometry_shader.layered_framebuffer.stencil_support,Fail
-KHR-GL45.geometry_shader.layered_framebuffer.stencil_support,Fail
-
 # "Invalid value returned: expected:[1, 1, 1, 1] retrieved: [0, 0, 0, 0
 #  Invalid rendering result at esextcTessellationShaderBarrier.cpp:504"
 KHR-GLES31.core.tessellation_shader.tessellation_shader_tc_barriers.barrier_guarded_read_calls,Fail
index 6976e6c..72c1108 100644 (file)
@@ -1307,7 +1307,8 @@ fd6_tile_mode(const struct pipe_resource *tmpl)
    /* if the mipmap level 0 is still too small to be tiled, then don't
     * bother pretending:
     */
-   if (fd_resource_level_linear(tmpl, 0))
+   if ((tmpl->width0 < FDL_MIN_UBWC_WIDTH) &&
+         !util_format_is_depth_or_stencil(tmpl->format))
       return TILE6_LINEAR;
 
    /* basically just has to be a format we can blit, so uploads/downloads
index f5d20b1..48dc555 100644 (file)
@@ -1207,7 +1207,7 @@ has_explicit_modifier(const uint64_t *modifiers, int count)
 }
 
 static enum fd_layout_type
-get_best_layout(struct fd_screen *screen, struct pipe_resource *prsc,
+get_best_layout(struct fd_screen *screen,
                 const struct pipe_resource *tmpl, const uint64_t *modifiers,
                 int count)
 {
@@ -1218,7 +1218,7 @@ get_best_layout(struct fd_screen *screen, struct pipe_resource *prsc,
    if (!screen->tile_mode)
       return LINEAR;
 
-   if (!screen->tile_mode(prsc))
+   if (!screen->tile_mode(tmpl))
       return LINEAR;
 
    if (tmpl->target == PIPE_BUFFER)
@@ -1227,7 +1227,7 @@ get_best_layout(struct fd_screen *screen, struct pipe_resource *prsc,
    if (tmpl->bind & PIPE_BIND_LINEAR) {
       if (tmpl->usage != PIPE_USAGE_STAGING)
          perf_debug("%" PRSC_FMT ": forcing linear: bind flags",
-                    PRSC_ARGS(prsc));
+                    PRSC_ARGS(tmpl));
       return LINEAR;
    }
 
@@ -1238,7 +1238,7 @@ get_best_layout(struct fd_screen *screen, struct pipe_resource *prsc,
    if (!can_explicit && (tmpl->bind & PIPE_BIND_SHARED)) {
       perf_debug("%" PRSC_FMT
                  ": forcing linear: shared resource + implicit modifiers",
-                 PRSC_ARGS(prsc));
+                 PRSC_ARGS(tmpl));
       return LINEAR;
    }
 
@@ -1257,7 +1257,7 @@ get_best_layout(struct fd_screen *screen, struct pipe_resource *prsc,
        !drm_find_modifier(DRM_FORMAT_MOD_QCOM_COMPRESSED, modifiers, count)) {
       perf_debug("%" PRSC_FMT
                  ": not using UBWC: not in acceptable modifier set",
-                 PRSC_ARGS(prsc));
+                 PRSC_ARGS(tmpl));
       ubwc_ok = false;
    }
 
@@ -1277,12 +1277,12 @@ get_best_layout(struct fd_screen *screen, struct pipe_resource *prsc,
 
    if (!drm_find_modifier(DRM_FORMAT_MOD_LINEAR, modifiers, count)) {
       perf_debug("%" PRSC_FMT ": need linear but not in modifier set",
-                 PRSC_ARGS(prsc));
+                 PRSC_ARGS(tmpl));
       return ERROR;
    }
 
    perf_debug("%" PRSC_FMT ": not using tiling: explicit modifiers and no UBWC",
-              PRSC_ARGS(prsc));
+              PRSC_ARGS(tmpl));
    return LINEAR;
 }
 
@@ -1323,7 +1323,7 @@ fd_resource_allocate_and_resolve(struct pipe_screen *pscreen,
    fd_resource_layout_init(prsc);
 
    enum fd_layout_type layout =
-      get_best_layout(screen, prsc, tmpl, modifiers, count);
+      get_best_layout(screen, tmpl, modifiers, count);
    if (layout == ERROR) {
       free(prsc);
       return NULL;
index d076de0..0d95f7c 100644 (file)
@@ -180,12 +180,6 @@ fd_resource(struct pipe_resource *ptex)
    return (struct fd_resource *)ptex;
 }
 
-static inline const struct fd_resource *
-fd_resource_const(const struct pipe_resource *ptex)
-{
-   return (const struct fd_resource *)ptex;
-}
-
 static inline struct fd_memory_object *
 fd_memory_object(struct pipe_memory_object *pmemobj)
 {
@@ -310,15 +304,6 @@ fd_resource_ubwc_offset(struct fd_resource *rsc, unsigned level, unsigned layer)
    return offset;
 }
 
-/* This might be a5xx specific, but higher mipmap levels are always linear: */
-static inline bool
-fd_resource_level_linear(const struct pipe_resource *prsc, int level)
-{
-   assert(!is_a3xx(fd_screen(prsc->screen)));
-
-   return fdl_level_linear(&fd_resource_const(prsc)->layout, level);
-}
-
 static inline uint32_t
 fd_resource_tile_mode(struct pipe_resource *prsc, int level)
 {