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

Author: Dave Airlie <[email protected]>
Date:   Fri Oct  6 16:52:48 2023 +1000

lavapipe: handle planes in texture lowering.

This uses the descriptor set info to lower the texture/sampler
handlers properly using the stride.

Reviewed-by: Roland Scheidegger <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25609>

---

 src/gallium/frontends/lavapipe/lvp_lower_vulkan_resource.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/gallium/frontends/lavapipe/lvp_lower_vulkan_resource.c 
b/src/gallium/frontends/lavapipe/lvp_lower_vulkan_resource.c
index 2255c28c523..55593c3e2c1 100644
--- a/src/gallium/frontends/lavapipe/lvp_lower_vulkan_resource.c
+++ b/src/gallium/frontends/lavapipe/lvp_lower_vulkan_resource.c
@@ -87,7 +87,8 @@ static nir_def *lower_vri_intrin_lvd(struct nir_builder *b,
 }
 
 static nir_def *
-vulkan_resource_from_deref(nir_builder *b, nir_deref_instr *deref, const 
struct lvp_pipeline_layout *layout)
+vulkan_resource_from_deref(nir_builder *b, nir_deref_instr *deref, const 
struct lvp_pipeline_layout *layout,
+                           unsigned plane)
 {
    nir_def *index = nir_imm_int(b, 0);
 
@@ -102,7 +103,9 @@ vulkan_resource_from_deref(nir_builder *b, nir_deref_instr 
*deref, const struct
 
    nir_variable *var = deref->var;
 
-   uint32_t binding_base = get_binding_layout(layout, 
var->data.descriptor_set, var->data.binding)->descriptor_index;
+   const struct lvp_descriptor_set_binding_layout *binding = 
get_binding_layout(layout, var->data.descriptor_set, var->data.binding);
+   uint32_t binding_base = binding->descriptor_index + plane;
+   index = nir_imul_imm(b, index, binding->stride);
 
    return nir_vec3(b, nir_imm_int(b, var->data.descriptor_set + 1),
                    nir_iadd_imm(b, index, binding_base),
@@ -113,6 +116,9 @@ static void lower_vri_instr_tex(struct nir_builder *b,
                                 nir_tex_instr *tex, void *data_cb)
 {
    struct lvp_pipeline_layout *layout = data_cb;
+   nir_def *plane_ssa = nir_steal_tex_src(tex, nir_tex_src_plane);
+   const uint32_t plane =
+      plane_ssa ? nir_src_as_uint(nir_src_for_ssa(plane_ssa)) : 0;
 
    for (unsigned i = 0; i < tex->num_srcs; i++) {
       nir_deref_instr *deref;
@@ -129,7 +135,7 @@ static void lower_vri_instr_tex(struct nir_builder *b,
          continue;
       }
 
-      nir_def *resource = vulkan_resource_from_deref(b, deref, layout);
+      nir_def *resource = vulkan_resource_from_deref(b, deref, layout, plane);
       nir_src_rewrite(&tex->src[i].src, resource);
    }
 }
@@ -143,7 +149,7 @@ lower_image_intrinsic(nir_builder *b,
 
    nir_deref_instr *deref = nir_src_as_deref(intrin->src[0]);
 
-   nir_def *resource = vulkan_resource_from_deref(b, deref, layout);
+   nir_def *resource = vulkan_resource_from_deref(b, deref, layout, 0);
    nir_rewrite_image_intrinsic(intrin, resource, true);
 }
 

Reply via email to