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

Author: Mike Blumenkrantz <[email protected]>
Date:   Mon Jan  3 14:34:44 2022 -0500

zink: fake sparse R9G9B9E5 support as needed

these just allocate the whole thing now, which means they aren't actually
sparse, but who cares because nobody but cts is actually going to use it
and those tests pass just fine

Acked-by: Dave Airlie <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14381>

---

 src/gallium/drivers/zink/zink_bo.c       | 3 +++
 src/gallium/drivers/zink/zink_resource.c | 4 ++++
 2 files changed, 7 insertions(+)

diff --git a/src/gallium/drivers/zink/zink_bo.c 
b/src/gallium/drivers/zink/zink_bo.c
index 60d21cfb54f..7fd3688000a 100644
--- a/src/gallium/drivers/zink/zink_bo.c
+++ b/src/gallium/drivers/zink/zink_bo.c
@@ -861,6 +861,9 @@ zink_bo_commit(struct zink_screen *screen, struct 
zink_resource *res, unsigned l
    bool ok = true;
    struct zink_bo *bo = res->obj->bo;
 
+   if (screen->faked_e5sparse && res->base.b.format == 
PIPE_FORMAT_R9G9B9E5_FLOAT)
+      return true;
+
    simple_mtx_lock(&screen->queue_lock);
    simple_mtx_lock(&bo->lock);
    if (res->base.b.target == PIPE_BUFFER) {
diff --git a/src/gallium/drivers/zink/zink_resource.c 
b/src/gallium/drivers/zink/zink_resource.c
index d172a4654a1..a82015dc3b3 100644
--- a/src/gallium/drivers/zink/zink_resource.c
+++ b/src/gallium/drivers/zink/zink_resource.c
@@ -782,6 +782,10 @@ resource_create(struct pipe_screen *pscreen,
    struct pipe_resource templ2 = *templ;
    if (templ2.flags & PIPE_RESOURCE_FLAG_SPARSE)
       templ2.bind |= PIPE_BIND_SHADER_IMAGE;
+   if (screen->faked_e5sparse && templ->format == PIPE_FORMAT_R9G9B9E5_FLOAT) {
+      templ2.flags &= ~PIPE_RESOURCE_FLAG_SPARSE;
+      res->base.b.flags &= ~PIPE_RESOURCE_FLAG_SPARSE;
+   }
    unsigned scanout_flags = templ->bind & (PIPE_BIND_SCANOUT | 
PIPE_BIND_SHARED);
    if (whandle && whandle->type == ZINK_EXTERNAL_MEMORY_HANDLE)
       scanout_flags = 0;

Reply via email to