iris: don't emit garbage 3DSTATE_VERTEX_BUFFERS when there aren't any
authorKenneth Graunke <kenneth@whitecape.org>
Tue, 26 Jun 2018 20:25:22 +0000 (13:25 -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 8e5818d9f3d43889a303dc029c49ef6c7aeba2c2..3f25737703d2a15d021a9ff4012d39c7d9777c36 100644 (file)
@@ -2784,12 +2784,14 @@ iris_upload_render_state(struct iris_context *ice,
       struct iris_vertex_buffer_state *cso = ice->state.cso_vertex_buffers;
       const unsigned vb_dwords = GENX(VERTEX_BUFFER_STATE_length);
 
-      iris_batch_emit(batch, cso->vertex_buffers,
-                      sizeof(uint32_t) * (1 + vb_dwords * cso->num_buffers));
+      if (cso->num_buffers > 0) {
+         iris_batch_emit(batch, cso->vertex_buffers, sizeof(uint32_t) *
+                         (1 + vb_dwords * cso->num_buffers));
 
-      for (unsigned i = 0; i < cso->num_buffers; i++) {
-         struct iris_resource *res = (void *) cso->resources[i];
-         iris_use_pinned_bo(batch, res->bo, false);
+         for (unsigned i = 0; i < cso->num_buffers; i++) {
+            struct iris_resource *res = (void *) cso->resources[i];
+            iris_use_pinned_bo(batch, res->bo, false);
+         }
       }
    }