summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Olšák <marek.olsak@amd.com>2020-11-22 02:09:58 -0500
committerMarek Olšák <marek.olsak@amd.com>2021-01-04 19:22:33 -0500
commit40c3a743efcf8bd1c5a3598d71192d02ca2411d4 (patch)
treeff2f9107f1200d510a106c142a47f895ace99650
parent609d25c1613e83fc7007e8f06b4b7b44e049ea5a (diff)
svga: fix handling draw info
index_bias is undefined if index_size == 0. index bounds are undefined if index_bounds_valid == false. Reviewed-by: Roland Scheidegger <sroland@vmware.com> Reviewed-by: Charmaine Lee <charmainel@vmware.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7679>
-rw-r--r--src/gallium/drivers/svga/svga_draw_elements.c8
-rw-r--r--src/gallium/drivers/svga/svga_pipe_draw.c5
-rw-r--r--src/gallium/drivers/svga/svga_swtnl_backend.c1
3 files changed, 8 insertions, 6 deletions
diff --git a/src/gallium/drivers/svga/svga_draw_elements.c b/src/gallium/drivers/svga/svga_draw_elements.c
index 336a1182c39..9987cefcc41 100644
--- a/src/gallium/drivers/svga/svga_draw_elements.c
+++ b/src/gallium/drivers/svga/svga_draw_elements.c
@@ -279,8 +279,8 @@ svga_hwtnl_draw_range_elements(struct svga_hwtnl *hwtnl,
ret = svga_hwtnl_simple_draw_range_elements(hwtnl, index_buffer,
info->index_size,
info->index_bias,
- info->min_index,
- info->max_index,
+ info->index_bounds_valid ? info->min_index : 0,
+ info->index_bounds_valid ? info->max_index : ~0,
gen_prim, index_offset, count,
info->start_instance,
info->instance_count,
@@ -307,8 +307,8 @@ svga_hwtnl_draw_range_elements(struct svga_hwtnl *hwtnl,
gen_buf,
gen_size,
info->index_bias,
- info->min_index,
- info->max_index,
+ info->index_bounds_valid ? info->min_index : 0,
+ info->index_bounds_valid ? info->max_index : ~0,
gen_prim, gen_offset,
gen_nr,
info->start_instance,
diff --git a/src/gallium/drivers/svga/svga_pipe_draw.c b/src/gallium/drivers/svga/svga_pipe_draw.c
index db149c37401..d33bbc06ee5 100644
--- a/src/gallium/drivers/svga/svga_pipe_draw.c
+++ b/src/gallium/drivers/svga/svga_pipe_draw.c
@@ -265,8 +265,9 @@ svga_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info,
* always start from 0 for DrawArrays and does not include baseVertex for
* DrawIndexed.
*/
- if (svga->curr.vertex_id_bias != (draws[0].start + info->index_bias)) {
- svga->curr.vertex_id_bias = draws[0].start + info->index_bias;
+ unsigned index_bias = info->index_size ? info->index_bias : 0;
+ if (svga->curr.vertex_id_bias != (draws[0].start + index_bias)) {
+ svga->curr.vertex_id_bias = draws[0].start + index_bias;
svga->dirty |= SVGA_NEW_VS_CONSTS;
}
diff --git a/src/gallium/drivers/svga/svga_swtnl_backend.c b/src/gallium/drivers/svga/svga_swtnl_backend.c
index 01e9736af13..53ca5835707 100644
--- a/src/gallium/drivers/svga/svga_swtnl_backend.c
+++ b/src/gallium/drivers/svga/svga_swtnl_backend.c
@@ -330,6 +330,7 @@ svga_vbuf_render_draw_elements(struct vbuf_render *render,
.start_instance = 0,
.instance_count = 1,
.index_bias = bias,
+ .index_bounds_valid = true,
.min_index = svga_render->min_index,
.max_index = svga_render->max_index,
};