From 870b8717b25eceadac8dd653debe8346826227cb Mon Sep 17 00:00:00 2001
From: Dave Airlie <airlied@redhat.com>
Date: Mon, 9 Jun 2025 09:19:28 +1000
Subject: [PATCH] Revert "hasvk/elk: stop turning load_push_constants into
 load_uniform"

This reverts commit b036d2ded2de32e81730ec8ce37c803bad112efa.

This seems to break gtk4 and other stuff.

Cc: mesa-stable
(taking ack from Lionel saying we should revert)

Acked-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35407>
---
 src/intel/compiler/elk/elk_fs_nir.cpp                  | 4 ++--
 src/intel/vulkan_hasvk/anv_nir_apply_pipeline_layout.c | 6 +++---
 src/intel/vulkan_hasvk/anv_nir_compute_push_layout.c   | 3 +--
 3 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/src/intel/compiler/elk/elk_fs_nir.cpp b/src/intel/compiler/elk/elk_fs_nir.cpp
index 459e2d966b7..6b78d6cf9f8 100644
--- a/src/intel/compiler/elk/elk_fs_nir.cpp
+++ b/src/intel/compiler/elk/elk_fs_nir.cpp
@@ -4969,8 +4969,7 @@ fs_nir_emit_intrinsic(nir_to_elk_state &ntb,
       break;
    }
 
-   case nir_intrinsic_load_uniform:
-   case nir_intrinsic_load_push_constant: {
+   case nir_intrinsic_load_uniform: {
       /* Offsets are in bytes but they should always aligned to
        * the type size
        */
@@ -7058,3 +7057,4 @@ nir_to_elk(elk_fs_visitor *s)
 
    ralloc_free(ntb.mem_ctx);
 }
+
diff --git a/src/intel/vulkan_hasvk/anv_nir_apply_pipeline_layout.c b/src/intel/vulkan_hasvk/anv_nir_apply_pipeline_layout.c
index 2bedf9017ed..1c613a9ebe7 100644
--- a/src/intel/vulkan_hasvk/anv_nir_apply_pipeline_layout.c
+++ b/src/intel/vulkan_hasvk/anv_nir_apply_pipeline_layout.c
@@ -463,9 +463,9 @@ build_buffer_addr_for_res_index(nir_builder *b,
          nir_iadd(b, res.dyn_offset_base, res.array_index);
 
       nir_def *dyn_load =
-         nir_load_uniform(b, 1, 32, nir_imul_imm(b, dyn_offset_idx, 4),
-                          .base = offsetof(struct anv_push_constants, dynamic_offsets),
-                          .range = MAX_DYNAMIC_BUFFERS * 4);
+         nir_load_push_constant(b, 1, 32, nir_imul_imm(b, dyn_offset_idx, 4),
+                                .base = offsetof(struct anv_push_constants, dynamic_offsets),
+                                .range = MAX_DYNAMIC_BUFFERS * 4);
 
       nir_def *dynamic_offset =
          nir_bcsel(b, nir_ieq_imm(b, res.dyn_offset_base, 0xff),
diff --git a/src/intel/vulkan_hasvk/anv_nir_compute_push_layout.c b/src/intel/vulkan_hasvk/anv_nir_compute_push_layout.c
index ed314af8b98..8a3f83f2c26 100644
--- a/src/intel/vulkan_hasvk/anv_nir_compute_push_layout.c
+++ b/src/intel/vulkan_hasvk/anv_nir_compute_push_layout.c
@@ -55,7 +55,6 @@ anv_nir_compute_push_layout(nir_shader *nir,
                   has_const_ubo = true;
                break;
 
-            case nir_intrinsic_load_uniform:
             case nir_intrinsic_load_push_constant: {
                unsigned base = nir_intrinsic_base(intrin);
                unsigned range = nir_intrinsic_range(intrin);
@@ -132,7 +131,6 @@ anv_nir_compute_push_layout(nir_shader *nir,
 
                nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);
                switch (intrin->intrinsic) {
-               case nir_intrinsic_load_uniform:
                case nir_intrinsic_load_push_constant: {
                   /* With bindless shaders we load uniforms with SEND
                    * messages. All the push constants are located after the
@@ -141,6 +139,7 @@ anv_nir_compute_push_layout(nir_shader *nir,
                    * elk_nir_lower_rt_intrinsics.c).
                    */
                   unsigned base_offset = push_start;
+                  intrin->intrinsic = nir_intrinsic_load_uniform;
                   nir_intrinsic_set_base(intrin,
                                          nir_intrinsic_base(intrin) -
                                          base_offset);
-- 
2.49.0

