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

Author: Faith Ekstrand <faith.ekstr...@collabora.com>
Date:   Fri Dec  8 18:43:55 2023 -0600

nvk: Enable cbufs

Just in case this breaks and blows up the universe, we'll add a NO_CBUFS
debug flag as a back-door.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26615>

---

 src/nouveau/vulkan/nvk_shader.c     | 7 +++++--
 src/nouveau/winsys/nouveau_device.c | 1 +
 src/nouveau/winsys/nouveau_device.h | 6 ++++++
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/nouveau/vulkan/nvk_shader.c b/src/nouveau/vulkan/nvk_shader.c
index 9c42f12972c..88f83343b6e 100644
--- a/src/nouveau/vulkan/nvk_shader.c
+++ b/src/nouveau/vulkan/nvk_shader.c
@@ -80,18 +80,20 @@ use_nak(const struct nvk_physical_device *pdev, 
gl_shader_stage stage)
 uint64_t
 nvk_physical_device_compiler_flags(const struct nvk_physical_device *pdev)
 {
+   bool no_cbufs = pdev->debug_flags & NVK_DEBUG_NO_CBUF;
    uint64_t prog_debug = nvk_cg_get_prog_debug();
    uint64_t prog_optimize = nvk_cg_get_prog_optimize();
    uint64_t nak_stages = nvk_nak_stages(&pdev->info);
    uint64_t nak_flags = nak_debug_flags(pdev->nak);
 
    assert(prog_debug <= UINT8_MAX);
-   assert(prog_optimize <= UINT8_MAX);
+   assert(prog_optimize < 16);
    assert(nak_stages <= UINT32_MAX);
    assert(nak_flags <= UINT16_MAX);
 
    return prog_debug
       | (prog_optimize << 8)
+      | ((uint64_t)no_cbufs << 12)
       | (nak_stages << 16)
       | (nak_flags << 48);
 }
@@ -350,7 +352,8 @@ nvk_lower_nir(struct nvk_device *dev, nir_shader *nir,
    assert(dev->pdev->info.cls_eng3d >= MAXWELL_A || !nir_has_image_var(nir));
 
    struct nvk_cbuf_map *cbuf_map = NULL;
-   if (use_nak(pdev, nir->info.stage) && 0) {
+   if (use_nak(pdev, nir->info.stage) &&
+       !(pdev->debug_flags & NVK_DEBUG_NO_CBUF)) {
       cbuf_map = &shader->cbuf_map;
    } else {
       /* Codegen sometimes puts stuff in cbuf 1 and adds 1 to our cbuf indices
diff --git a/src/nouveau/winsys/nouveau_device.c 
b/src/nouveau/winsys/nouveau_device.c
index 255869fd0dd..904a7ad6241 100644
--- a/src/nouveau/winsys/nouveau_device.c
+++ b/src/nouveau/winsys/nouveau_device.c
@@ -132,6 +132,7 @@ nouveau_ws_device_set_dbg_flags(struct nouveau_ws_device 
*dev)
       { "push_sync", NVK_DEBUG_PUSH_SYNC },
       { "zero_memory", NVK_DEBUG_ZERO_MEMORY },
       { "vm", NVK_DEBUG_VM },
+      { "no_cbuf", NVK_DEBUG_NO_CBUF },
       { NULL, 0 },
    };
 
diff --git a/src/nouveau/winsys/nouveau_device.h 
b/src/nouveau/winsys/nouveau_device.h
index 3174aa2630d..413a2e827e1 100644
--- a/src/nouveau/winsys/nouveau_device.h
+++ b/src/nouveau/winsys/nouveau_device.h
@@ -34,6 +34,12 @@ enum nvk_debug {
    /* Dump VM bind/unbinds
     */
    NVK_DEBUG_VM = 1ull << 3,
+
+   /* Disable most cbufs
+    *
+    * Root descriptors still end up in a cbuf
+    */
+   NVK_DEBUG_NO_CBUF = 1ull << 5,
 };
 
 struct nouveau_ws_device {

Reply via email to