v3dv/descriptor: handle not having a sampler when combining texture and sampler id

There are some texture operations (like mipmap query levels) that
doesn't require a sampler. In fact, you should ignore it. So we need
to take it into account when combining the
indexes. nir_tex_instr_src_index is returning a negative value to
identify that case, but as we are using a uint32_t to pack both values
(for convenience, easy to pack/unpack the hash table key), we just use
a uint value big enough to be a wrong sampler id.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
diff --git a/src/broadcom/vulkan/v3dv_cmd_buffer.c b/src/broadcom/vulkan/v3dv_cmd_buffer.c
index f26cc6a..cd77f7e 100644
--- a/src/broadcom/vulkan/v3dv_cmd_buffer.c
+++ b/src/broadcom/vulkan/v3dv_cmd_buffer.c
@@ -1976,13 +1976,17 @@
          if (image_view == NULL)
             return false;
 
-         const struct v3dv_sampler *sampler =
-            v3dv_descriptor_map_get_sampler(descriptor_state,
-                                            sampler_map,
-                                            cmd_buffer->state.pipeline->layout,
-                                            sampler_idx);
-         if (sampler == NULL)
-            return false;
+
+         const struct v3dv_sampler *sampler = NULL;
+         if (sampler_idx != V3DV_NO_SAMPLER_IDX) {
+            sampler =
+               v3dv_descriptor_map_get_sampler(descriptor_state,
+                                               sampler_map,
+                                               cmd_buffer->state.pipeline->layout,
+                                               sampler_idx);
+            if (sampler == NULL)
+               return false;
+         }
 
          key->tex[combined_idx].return_size =
             v3dv_get_tex_return_size(image_view->format,
diff --git a/src/broadcom/vulkan/v3dv_pipeline.c b/src/broadcom/vulkan/v3dv_pipeline.c
index b9b0403..11538ac 100644
--- a/src/broadcom/vulkan/v3dv_pipeline.c
+++ b/src/broadcom/vulkan/v3dv_pipeline.c
@@ -639,7 +639,9 @@
       return false;
 
    int combined_index =
-      get_combined_index(pipeline, instr->texture_index, instr->sampler_index);
+      get_combined_index(pipeline,
+                         instr->texture_index,
+                         sampler_idx < 0 ? V3DV_NO_SAMPLER_IDX : instr->sampler_index);
 
    instr->texture_index = combined_index;
    instr->sampler_index = combined_index;
diff --git a/src/broadcom/vulkan/v3dv_private.h b/src/broadcom/vulkan/v3dv_private.h
index cbbebc2..14af196 100644
--- a/src/broadcom/vulkan/v3dv_private.h
+++ b/src/broadcom/vulkan/v3dv_private.h
@@ -1030,6 +1030,8 @@
    struct v3dv_bo *state;
 };
 
+#define V3DV_NO_SAMPLER_IDX 666
+
 /*
  * Following two methods are using on the combined to/from texture/sampler
  * indices maps at v3dv_pipeline.
diff --git a/src/broadcom/vulkan/v3dv_uniforms.c b/src/broadcom/vulkan/v3dv_uniforms.c
index 49fac70..83268bf 100644
--- a/src/broadcom/vulkan/v3dv_uniforms.c
+++ b/src/broadcom/vulkan/v3dv_uniforms.c
@@ -127,6 +127,7 @@
 
    v3dv_pipeline_combined_index_key_unpack(pipeline->combined_index_to_key_map[unit],
                                            NULL, &sampler_idx);
+   assert(sampler_idx != V3DV_NO_SAMPLER_IDX);
 
    const struct v3dv_sampler *sampler =
       v3dv_descriptor_map_get_sampler(descriptor_state, &pipeline->sampler_map,