anv/pipeline: Don't look at blend state unless we have an attachment
authorJason Ekstrand <jason.ekstrand@intel.com>
Thu, 18 Jan 2018 01:10:34 +0000 (17:10 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Fri, 26 Jan 2018 09:44:45 +0000 (01:44 -0800)
Without this, we may end up dereferencing blend before we check for
binding->index != UINT32_MAX.  However, Vulkan allows the blend state to
be NULL so long as you don't have any color attachments.  This fixes a
segfault when running The Talos Principal.

Fixes: 12f4e00b69e724a23504b7bd3958fb75dc462950
Cc: mesa-stable@lists.freedesktop.org
Reviewed-by: Alex Smith <asmith@feralinteractive.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
src/intel/vulkan/genX_pipeline.c

index 82fdf206a953ab9121d7561f7fa768c86cb576c6..10efe5421061f5bd0dcc77ec93d7e4a72f15d1ac 100644 (file)
@@ -1351,10 +1351,10 @@ has_color_buffer_write_enabled(const struct anv_pipeline *pipeline,
       if (binding->set != ANV_DESCRIPTOR_SET_COLOR_ATTACHMENTS)
          continue;
 
-      const VkPipelineColorBlendAttachmentState *a =
-         &blend->pAttachments[binding->index];
+      if (binding->index == UINT32_MAX)
+         continue;
 
-      if (binding->index != UINT32_MAX && a->colorWriteMask != 0)
+      if (blend->pAttachments[binding->index].colorWriteMask != 0)
          return true;
    }