From 84cfc08c1059f6190b0ada811003abe93c624e39 Mon Sep 17 00:00:00 2001 From: Chad Versace Date: Fri, 28 Aug 2015 08:07:15 -0700 Subject: [PATCH] vk/pipeline: Fix crash when the pipeline has no attributes If there are no attributes, don't emit 3DSTATE_VERTEX_ELEMENTS. That packet does not allow 0 attributes. --- src/vulkan/gen7_pipeline.c | 6 ++++-- src/vulkan/gen8_pipeline.c | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/vulkan/gen7_pipeline.c b/src/vulkan/gen7_pipeline.c index a5c7a201690..0ed4727c37f 100644 --- a/src/vulkan/gen7_pipeline.c +++ b/src/vulkan/gen7_pipeline.c @@ -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 = diff --git a/src/vulkan/gen8_pipeline.c b/src/vulkan/gen8_pipeline.c index b1cb16234d5..fae09f3fbbe 100644 --- a/src/vulkan/gen8_pipeline.c +++ b/src/vulkan/gen8_pipeline.c @@ -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 = -- 2.30.2