lima: Fix crash when there are no vertex shader attributes
authorAndreas Baierl <ichgeh@imkreisrum.de>
Fri, 27 Sep 2019 06:32:12 +0000 (08:32 +0200)
committerVasily Khoruzhick <anarsoul@gmail.com>
Wed, 16 Oct 2019 16:45:05 +0000 (16:45 +0000)
Signed-off-by: Andreas Baierl <ichgeh@imkreisrum.de>
Reviewed-by: Vasily Khoruzhick <anarsoul@gmail.com>
src/gallium/drivers/lima/lima_draw.c

index bd6b62a3bb645e4562633e8defa44f485b56a51b..3d22ae92781d4c7a929fc5441ec2db3f877ba4c4 100644 (file)
@@ -741,13 +741,13 @@ lima_pack_vs_cmd(struct lima_context *ctx, const struct pipe_draw_info *info)
 
    int num_varryings = ctx->vs->num_varying;
    int num_attributes = ctx->vertex_elements->num_elements;
-   VS_CMD_VARYING_ATTRIBUTE_COUNT(num_varryings, num_attributes);
+   VS_CMD_VARYING_ATTRIBUTE_COUNT(num_varryings, MAX2(1, num_attributes));
 
    VS_CMD_UNKNOWN1();
 
    VS_CMD_ATTRIBUTES_ADDRESS(
       lima_ctx_buff_va(ctx, lima_ctx_buff_gp_attribute_info, LIMA_CTX_BUFF_SUBMIT_GP),
-      num_attributes);
+      MAX2(1, num_attributes));
 
    VS_CMD_VARYINGS_ADDRESS(
       lima_ctx_buff_va(ctx, lima_ctx_buff_gp_varying_info, LIMA_CTX_BUFF_SUBMIT_GP),
@@ -1140,7 +1140,7 @@ lima_update_gp_attribute_info(struct lima_context *ctx, const struct pipe_draw_i
 
    uint32_t *attribute =
       lima_ctx_buff_alloc(ctx, lima_ctx_buff_gp_attribute_info,
-                          ve->num_elements * 8, true);
+                          MAX2(1, ve->num_elements) * 8, true);
 
    int n = 0;
    for (int i = 0; i < ve->num_elements; i++) {