iris: fix 3DSTATE_VERTEX_ELEMENTS / VF_INSTANCING for 0 elements
authorKenneth Graunke <kenneth@whitecape.org>
Tue, 26 Jun 2018 20:32:19 +0000 (13:32 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 21 Feb 2019 18:26:07 +0000 (10:26 -0800)
src/gallium/drivers/iris/iris_state.c

index 3f25737703d2a15d021a9ff4012d39c7d9777c36..49486c4432214329d2b9d182d9711ecb4e542924 100644 (file)
@@ -1502,7 +1502,7 @@ iris_create_vertex_elements(struct pipe_context *ctx,
    struct iris_vertex_element_state *cso =
       malloc(sizeof(struct iris_vertex_element_state));
 
-   cso->count = count;
+   cso->count = MAX2(count, 1);
 
    /* TODO:
     *  - create edge flag one
@@ -1510,13 +1510,26 @@ iris_create_vertex_elements(struct pipe_context *ctx,
     *  - if those are necessary, use count + 1/2/3... OR in the length
     */
    iris_pack_command(GENX(3DSTATE_VERTEX_ELEMENTS), cso->vertex_elements, ve) {
-      ve.DWordLength =
-         1 + GENX(VERTEX_ELEMENT_STATE_length) * MAX2(count, 1) - 2;
+      ve.DWordLength = 1 + GENX(VERTEX_ELEMENT_STATE_length) * cso->count - 2;
    }
 
    uint32_t *ve_pack_dest = &cso->vertex_elements[1];
    uint32_t *vfi_pack_dest = cso->vf_instancing;
 
+   if (count == 0) {
+      iris_pack_state(GENX(VERTEX_ELEMENT_STATE), ve_pack_dest, ve) {
+         ve.Valid = true;
+         ve.SourceElementFormat = ISL_FORMAT_R32G32B32A32_FLOAT;
+         ve.Component0Control = VFCOMP_STORE_0;
+         ve.Component1Control = VFCOMP_STORE_0;
+         ve.Component2Control = VFCOMP_STORE_0;
+         ve.Component3Control = VFCOMP_STORE_1_FP;
+      }
+
+      iris_pack_command(GENX(3DSTATE_VF_INSTANCING), vfi_pack_dest, vi) {
+      }
+   }
+
    for (int i = 0; i < count; i++) {
       enum isl_format isl_format =
          iris_isl_format_for_pipe_format(state[i].src_format);