Module: Mesa
Branch: 17.2
Commit: 8f8b5c0ad3981929730747498c232d47976f178c
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8f8b5c0ad3981929730747498c232d47976f178c

Author: Bas Nieuwenhuizen <b...@basnieuwenhuizen.nl>
Date:   Sun Dec  3 15:35:39 2017 +0100

spirv: Fix loading an entire block at once.

There is no chain, so  checking the length ends with a SEGFAULT.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=103579
Cc: <mesa-sta...@lists.freedesktop.org>
Reviewed-by: Emil Velikov <emil.veli...@collabora.com>
Reviewed-by: Jason Ekstrand <ja...@jlekstrand.net>
(cherry picked from commit b926da241a4221376afe195c476f6a05621e5c75)
[Andres Gomez: 16 bits types and vtn_assert/fail not yet in 17.2]
Signed-off-by: Andres Gomez <ago...@igalia.com>

Conflicts:
        src/compiler/spirv/vtn_variables.c

---

 src/compiler/spirv/vtn_variables.c | 57 ++++++++++++++++++++------------------
 1 file changed, 30 insertions(+), 27 deletions(-)

diff --git a/src/compiler/spirv/vtn_variables.c 
b/src/compiler/spirv/vtn_variables.c
index 9a1542c400..873b8f4b0a 100644
--- a/src/compiler/spirv/vtn_variables.c
+++ b/src/compiler/spirv/vtn_variables.c
@@ -513,35 +513,38 @@ vtn_pointer_to_offset(struct vtn_builder *b, struct 
vtn_pointer *ptr,
    *index_out = get_vulkan_resource_index(b, ptr, &type, &idx);
 
    nir_ssa_def *offset = nir_imm_int(&b->nb, 0);
-   for (; idx < ptr->chain->length; idx++) {
-      enum glsl_base_type base_type = glsl_get_base_type(type->type);
-      switch (base_type) {
-      case GLSL_TYPE_UINT:
-      case GLSL_TYPE_INT:
-      case GLSL_TYPE_UINT64:
-      case GLSL_TYPE_INT64:
-      case GLSL_TYPE_FLOAT:
-      case GLSL_TYPE_DOUBLE:
-      case GLSL_TYPE_BOOL:
-      case GLSL_TYPE_ARRAY:
-         offset = nir_iadd(&b->nb, offset,
-                           vtn_access_link_as_ssa(b, ptr->chain->link[idx],
-                                                  type->stride));
 
-         type = type->array_element;
-         break;
-
-      case GLSL_TYPE_STRUCT: {
-         assert(ptr->chain->link[idx].mode == vtn_access_mode_literal);
-         unsigned member = ptr->chain->link[idx].id;
-         offset = nir_iadd(&b->nb, offset,
-                           nir_imm_int(&b->nb, type->offsets[member]));
-         type = type->members[member];
-         break;
-      }
+   if (ptr->chain) {
+      for (; idx < ptr->chain->length; idx++) {
+         enum glsl_base_type base_type = glsl_get_base_type(type->type);
+         switch (base_type) {
+         case GLSL_TYPE_UINT:
+         case GLSL_TYPE_INT:
+         case GLSL_TYPE_UINT64:
+         case GLSL_TYPE_INT64:
+         case GLSL_TYPE_FLOAT:
+         case GLSL_TYPE_DOUBLE:
+         case GLSL_TYPE_BOOL:
+         case GLSL_TYPE_ARRAY:
+            offset = nir_iadd(&b->nb, offset,
+                              vtn_access_link_as_ssa(b, ptr->chain->link[idx],
+                                                     type->stride));
+
+            type = type->array_element;
+            break;
+
+         case GLSL_TYPE_STRUCT: {
+            assert(ptr->chain->link[idx].mode == vtn_access_mode_literal);
+            unsigned member = ptr->chain->link[idx].id;
+            offset = nir_iadd(&b->nb, offset,
+                              nir_imm_int(&b->nb, type->offsets[member]));
+            type = type->members[member];
+            break;
+         }
 
-      default:
-         unreachable("Invalid type for deref");
+         default:
+            unreachable("Invalid type for deref");
+         }
       }
    }
 

_______________________________________________
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to