From 2f851f0479959723d9057cde0a44e805d598b7e6 Mon Sep 17 00:00:00 2001 From: Emma Anholt Date: Sun, 10 Jul 2022 08:11:15 -0700 Subject: [PATCH] vc4: Work around a HW bug with 2-vert line loops. Reviewed-by: Adam Jackson Reviewed-by: Jose Maria Casanova Crespo Part-of: --- src/broadcom/ci/broadcom-rpi3-fails.txt | 5 ----- src/gallium/drivers/vc4/vc4_draw.c | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/broadcom/ci/broadcom-rpi3-fails.txt b/src/broadcom/ci/broadcom-rpi3-fails.txt index 44783d78f53..3a49166d1c2 100644 --- a/src/broadcom/ci/broadcom-rpi3-fails.txt +++ b/src/broadcom/ci/broadcom-rpi3-fails.txt @@ -15,11 +15,6 @@ dEQP-GLES2.functional.clipping.line.wide_line_clip_viewport_corner,Fail dEQP-GLES2.functional.depth_stencil_clear.depth_stencil_masked,Fail -# 2-count line loop incorrectly draws nothing (HW bug). Need to demote to being -# GL_LINES, though that wouldn't be correct with blending/logicop. -dEQP-GLES2.functional.draw.draw_arrays.line_loop.multiple_attributes,Fail -dEQP-GLES2.functional.draw.draw_arrays.line_loop.single_attribute,Fail - # A glTexImage, glDraw, glTexSubImage sequence into a texture is missing what looks like the drawing. dEQP-GLES2.functional.fbo.render.texsubimage.after_render_tex2d_rgba,Fail # A glTexImage, glDraw, glTexSubImage, glDraw sequence into a texture is missing what looks like the first drawing. diff --git a/src/gallium/drivers/vc4/vc4_draw.c b/src/gallium/drivers/vc4/vc4_draw.c index ebaddae7624..0143072fe12 100644 --- a/src/gallium/drivers/vc4/vc4_draw.c +++ b/src/gallium/drivers/vc4/vc4_draw.c @@ -287,6 +287,28 @@ vc4_hw_2116_workaround(struct pipe_context *pctx, int vert_count) } } +/* A HW bug fails to draw 2-vert line loops. Just draw it as two GL_LINES. */ +static bool +vc4_draw_workaround_line_loop_2(struct pipe_context *pctx, const struct pipe_draw_info *info, + unsigned drawid_offset, + const struct pipe_draw_indirect_info *indirect, + const struct pipe_draw_start_count_bias *draw) +{ + if (draw->count != 2 || info->mode != PIPE_PRIM_LINE_LOOP) + return false; + + struct pipe_draw_info local_info = *info; + local_info.mode = PIPE_PRIM_LINES; + + /* Draw twice. The vertex order will be wrong on the second prim, but + * that's probably not worth rewriting an index buffer over. + */ + for (int i = 0; i < 2; i++) + pctx->draw_vbo(pctx, &local_info, drawid_offset, indirect, draw, 1); + + return true; +} + static void vc4_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info, unsigned drawid_offset, @@ -309,6 +331,9 @@ vc4_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info, !u_trim_pipe_prim(info->mode, (unsigned*)&draws[0].count)) return; + if (vc4_draw_workaround_line_loop_2(pctx, info, drawid_offset, indirect, draws)) + return; + /* Before setting up the draw, do any fixup blits necessary. */ vc4_predraw_check_textures(pctx, &vc4->verttex); vc4_predraw_check_textures(pctx, &vc4->fragtex);