Mesa (main): crocus: don't create staging resources > half aperture

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Dec 30 04:11:05 UTC 2021


Module: Mesa
Branch: main
Commit: f1c1fcfdce45280ab13e70e246d0c662dfe6830d
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=f1c1fcfdce45280ab13e70e246d0c662dfe6830d

Author: Dave Airlie <airlied at redhat.com>
Date:   Thu Dec 30 11:52:32 2021 +1000

crocus: don't create staging resources > half aperture

The theory here is that a staging resource will need to be transferred
into or out of a non-staging resource. If the staging resource is too
big for 1/2 aperture threshold, then it the corresponding non-stage
resource will be similiarly sized. This means there's no hope of fitting
both of them in.

This will cause the st blit transfer path to fall back and allow
max-texture-size to pass.

Fixes piglit max-texture-size

Reviewed-by: Emma Anholt <emma at anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14347>

---

 src/gallium/drivers/crocus/ci/crocus-hsw-fails.txt | 3 ---
 src/gallium/drivers/crocus/crocus_resource.c       | 9 +++++++++
 src/gallium/drivers/crocus/crocus_screen.c         | 3 ++-
 src/gallium/drivers/crocus/crocus_screen.h         | 1 +
 4 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/crocus/ci/crocus-hsw-fails.txt b/src/gallium/drivers/crocus/ci/crocus-hsw-fails.txt
index 6d4fb1a24c6..05303e0a374 100644
--- a/src/gallium/drivers/crocus/ci/crocus-hsw-fails.txt
+++ b/src/gallium/drivers/crocus/ci/crocus-hsw-fails.txt
@@ -39,9 +39,6 @@ spec@!opengl 1.1 at linestipple@Factor 3x,Fail
 spec@!opengl 1.1 at linestipple@Line loop,Fail
 spec@!opengl 1.1 at linestipple@Line strip,Fail
 
-# max-texture-size: ../src/gallium/drivers/crocus/crocus_resource.c:693: crocus_resource_create_with_modifiers: Assertion `isl_surf_created_successfully' failed.
-spec@!opengl 1.1 at max-texture-size,Crash
-
 spec@!opengl 3.0 at clearbuffer-bug,Fail
 
 # "../src/mesa/state_tracker/st_cb_texture.c:1164:st_get_blit_mask: Assertion `0' failed."
diff --git a/src/gallium/drivers/crocus/crocus_resource.c b/src/gallium/drivers/crocus/crocus_resource.c
index 9d4336d3317..3ee44e7713a 100644
--- a/src/gallium/drivers/crocus/crocus_resource.c
+++ b/src/gallium/drivers/crocus/crocus_resource.c
@@ -254,6 +254,15 @@ crocus_resource_configure_main(const struct crocus_screen *screen,
    if (!isl_surf_init_s(&screen->isl_dev, &res->surf, &init_info))
       return false;
 
+   /*
+    * Don't create staging surfaces that will use > half the aperture
+    * since staging implies you are sending to another resource,
+    * which there is no way to fit both into aperture.
+    */
+   if (templ->usage == PIPE_USAGE_STAGING)
+      if (res->surf.size_B > screen->aperture_threshold / 2)
+         return false;
+
    res->internal_format = templ->format;
 
    return true;
diff --git a/src/gallium/drivers/crocus/crocus_screen.c b/src/gallium/drivers/crocus/crocus_screen.c
index 9e2a7004d42..2c23beeddd8 100644
--- a/src/gallium/drivers/crocus/crocus_screen.c
+++ b/src/gallium/drivers/crocus/crocus_screen.c
@@ -351,7 +351,7 @@ crocus_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
        * flushing, etc.  That's the big cliff apps will care about.
        */
       const unsigned gpu_mappable_megabytes =
-         (screen->aperture_bytes * 3 / 4) / (1024 * 1024);
+         (screen->aperture_threshold) / (1024 * 1024);
 
       const long system_memory_pages = sysconf(_SC_PHYS_PAGES);
       const long system_page_size = sysconf(_SC_PAGE_SIZE);
@@ -743,6 +743,7 @@ crocus_screen_create(int fd, const struct pipe_screen_config *config)
    p_atomic_set(&screen->refcount, 1);
 
    screen->aperture_bytes = get_aperture_size(fd);
+   screen->aperture_threshold = screen->aperture_bytes * 3 / 4;
 
    driParseConfigFiles(config->options, config->options_info, 0, "crocus",
                        NULL, NULL, NULL, 0, NULL, 0);
diff --git a/src/gallium/drivers/crocus/crocus_screen.h b/src/gallium/drivers/crocus/crocus_screen.h
index 38e392e75cb..c5b5a2c8df2 100644
--- a/src/gallium/drivers/crocus/crocus_screen.h
+++ b/src/gallium/drivers/crocus/crocus_screen.h
@@ -202,6 +202,7 @@ struct crocus_screen {
    } driconf;
 
    uint64_t aperture_bytes;
+   uint64_t aperture_threshold;
 
    struct intel_device_info devinfo;
    struct isl_device isl_dev;



More information about the mesa-commit mailing list