vk/pipeline: Fix crash when the pipeline has no attributes
authorChad Versace <chad.versace@intel.com>
Fri, 28 Aug 2015 15:07:15 +0000 (08:07 -0700)
committerChad Versace <chad.versace@intel.com>
Fri, 28 Aug 2015 15:07:15 +0000 (08:07 -0700)
If there are no attributes, don't emit 3DSTATE_VERTEX_ELEMENTS.
That packet does not allow 0 attributes.

src/vulkan/gen7_pipeline.c
src/vulkan/gen8_pipeline.c

index a5c7a201690ccdad0626b578e786676ba0100e3e..0ed4727c37f4f58f1eebd0347aef4937f5b59669 100644 (file)
@@ -39,8 +39,10 @@ gen7_emit_vertex_input(struct anv_pipeline *pipeline,
    const uint32_t num_dwords = 1 + element_count * 2;
    uint32_t *p;
 
-   p = anv_batch_emitn(&pipeline->batch, num_dwords,
-                       GEN7_3DSTATE_VERTEX_ELEMENTS);
+   if (info->attributeCount > 0) {
+      p = anv_batch_emitn(&pipeline->batch, num_dwords,
+                          GEN7_3DSTATE_VERTEX_ELEMENTS);
+   }
 
    for (uint32_t i = 0; i < info->attributeCount; i++) {
       const VkVertexInputAttributeDescription *desc =
index b1cb16234d5c239b5e7caf6b23901de6d0ba3eb0..fae09f3fbbefe2553cdb9481779ae149369ed136 100644 (file)
@@ -36,8 +36,10 @@ emit_vertex_input(struct anv_pipeline *pipeline,
    const uint32_t num_dwords = 1 + info->attributeCount * 2;
    uint32_t *p;
 
-   p = anv_batch_emitn(&pipeline->batch, num_dwords,
-                       GEN8_3DSTATE_VERTEX_ELEMENTS);
+   if (info->attributeCount > 0) {
+      p = anv_batch_emitn(&pipeline->batch, num_dwords,
+                          GEN8_3DSTATE_VERTEX_ELEMENTS);
+   }
 
    for (uint32_t i = 0; i < info->attributeCount; i++) {
       const VkVertexInputAttributeDescription *desc =