From 00627b4f8db5465daae08ddd7dfffa3a06e2c902 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Tue, 28 Jun 2022 10:49:14 -0400 Subject: [PATCH] aux/draw: add guardband clipping for lines to comply with ES2+ line clipping rules, guardband clipping should be used so that the rasterizer will clip lines without using clip planes fixes (llvmpipe): dEQP-GLES*.functional.clipping.line.wide_line_clip_viewport_center dEQP-GLES*.functional.clipping.line.wide_line_clip_viewport_corner Reviewed-by: Erik Faye-Lund Reviewed-by: Roland Scheidegger Part-of: --- src/gallium/auxiliary/draw/draw_pipe_clip.c | 36 +++++++++++++++++++++- src/gallium/drivers/llvmpipe/ci/llvmpipe-fails.txt | 4 --- src/gallium/drivers/virgl/ci/virgl-gles-fails.txt | 4 --- src/gallium/drivers/zink/ci/zink-lvp-fails.txt | 4 --- 4 files changed, 35 insertions(+), 13 deletions(-) diff --git a/src/gallium/auxiliary/draw/draw_pipe_clip.c b/src/gallium/auxiliary/draw/draw_pipe_clip.c index dec59f8..b7f7caf 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_clip.c +++ b/src/gallium/auxiliary/draw/draw_pipe_clip.c @@ -710,6 +710,40 @@ clip_line(struct draw_stage *stage, struct prim_header *header) /* else, totally clipped */ } +static void +clip_line_guard_xy(struct draw_stage *stage, struct prim_header *header) +{ + unsigned clipmask = (header->v[0]->clipmask | + header->v[1]->clipmask); + + if ((clipmask & 0xffffffff) == 0) { + stage->next->line(stage->next, header); + } + else if ((clipmask & 0xfffffff0) == 0) { + while (clipmask) { + const unsigned plane_idx = ffs(clipmask)-1; + clipmask &= ~(1 << plane_idx); /* turn off this plane's bit */ + /* TODO: this should really do proper guardband clipping, + * currently just throw out infs/nans. + * Also note that vertices with negative w values MUST be tossed + * out (not sure if proper guardband clipping would do this + * automatically). These would usually be captured by depth clip + * too but this can be disabled. + */ + if ((header->v[0]->clip_pos[3] <= 0.0f && + header->v[1]->clip_pos[3] <= 0.0f) || + util_is_nan(header->v[0]->clip_pos[0]) || + util_is_nan(header->v[0]->clip_pos[1]) || + util_is_nan(header->v[1]->clip_pos[0]) || + util_is_nan(header->v[1]->clip_pos[1])) + return; + } + stage->next->line(stage->next, header); + } else if ((header->v[0]->clipmask & + header->v[1]->clipmask) == 0) { + do_clip_line(stage, header, clipmask & 0xfffffff0); + } +} static void clip_tri(struct draw_stage *stage, struct prim_header *header) @@ -894,7 +928,6 @@ clip_init_state(struct draw_stage *stage) } stage->tri = clip_tri; - stage->line = clip_line; } @@ -912,6 +945,7 @@ clip_first_line(struct draw_stage *stage, struct prim_header *header) { clip_init_state(stage); + stage->line = stage->draw->guard_band_points_lines_xy ? clip_line_guard_xy : clip_line; stage->line(stage, header); } diff --git a/src/gallium/drivers/llvmpipe/ci/llvmpipe-fails.txt b/src/gallium/drivers/llvmpipe/ci/llvmpipe-fails.txt index e4fca54..2fd68cf 100644 --- a/src/gallium/drivers/llvmpipe/ci/llvmpipe-fails.txt +++ b/src/gallium/drivers/llvmpipe/ci/llvmpipe-fails.txt @@ -7,10 +7,6 @@ dEQP-EGL.functional.robustness.reset_context.shaders.infinite_loop.reset_status. dEQP-EGL.functional.robustness.reset_context.shaders.infinite_loop.sync_status.compute,Fail dEQP-EGL.functional.robustness.reset_context.shaders.infinite_loop.sync_status.vertex,Fail dEQP-EGL.functional.robustness.reset_context.shaders.infinite_loop.sync_status.vertex_and_fragment,Fail -dEQP-GLES2.functional.clipping.line.wide_line_clip_viewport_center,Fail -dEQP-GLES2.functional.clipping.line.wide_line_clip_viewport_corner,Fail -dEQP-GLES3.functional.clipping.line.wide_line_clip_viewport_center,Fail -dEQP-GLES3.functional.clipping.line.wide_line_clip_viewport_corner,Fail dEQP-GLES3.functional.fbo.blit.rect.nearest_consistency_mag,Fail dEQP-GLES3.functional.fbo.blit.rect.nearest_consistency_mag_reverse_dst_x,Fail dEQP-GLES3.functional.fbo.blit.rect.nearest_consistency_mag_reverse_src_dst_x,Fail diff --git a/src/gallium/drivers/virgl/ci/virgl-gles-fails.txt b/src/gallium/drivers/virgl/ci/virgl-gles-fails.txt index a8f3034..7063a0a 100644 --- a/src/gallium/drivers/virgl/ci/virgl-gles-fails.txt +++ b/src/gallium/drivers/virgl/ci/virgl-gles-fails.txt @@ -1,9 +1,5 @@ -dEQP-GLES2.functional.clipping.line.wide_line_clip_viewport_center,Fail -dEQP-GLES2.functional.clipping.line.wide_line_clip_viewport_corner,Fail dEQP-GLES2.functional.clipping.point.wide_point_clip_viewport_center,Fail dEQP-GLES2.functional.clipping.point.wide_point_clip_viewport_corner,Fail -dEQP-GLES3.functional.clipping.line.wide_line_clip_viewport_center,Fail -dEQP-GLES3.functional.clipping.line.wide_line_clip_viewport_corner,Fail dEQP-GLES3.functional.clipping.point.wide_point_clip,Fail dEQP-GLES3.functional.clipping.point.wide_point_clip_viewport_corner,Fail dEQP-GLES3.functional.fbo.blit.rect.nearest_consistency_mag,Fail diff --git a/src/gallium/drivers/zink/ci/zink-lvp-fails.txt b/src/gallium/drivers/zink/ci/zink-lvp-fails.txt index c139ea3..ad4ba0b 100644 --- a/src/gallium/drivers/zink/ci/zink-lvp-fails.txt +++ b/src/gallium/drivers/zink/ci/zink-lvp-fails.txt @@ -13,8 +13,6 @@ spec@egl_chromium_sync_control@conformance@eglGetSyncValuesCHROMIUM_msc_and_sbc_ spec@egl_chromium_sync_control@conformance@eglGetSyncValuesCHROMIUM_ust_test,Fail -dEQP-GLES3.functional.clipping.line.wide_line_clip_viewport_center,Fail -dEQP-GLES3.functional.clipping.line.wide_line_clip_viewport_corner,Fail dEQP-GLES3.functional.fbo.blit.rect.nearest_consistency_mag,Fail dEQP-GLES3.functional.fbo.blit.rect.nearest_consistency_mag_reverse_dst_x,Fail dEQP-GLES3.functional.fbo.blit.rect.nearest_consistency_mag_reverse_src_dst_x,Fail @@ -25,8 +23,6 @@ dEQP-GLES3.functional.fbo.blit.rect.nearest_consistency_min_reverse_dst_x,Fail dEQP-GLES3.functional.fbo.blit.rect.nearest_consistency_min_reverse_src_dst_x,Fail dEQP-GLES3.functional.fbo.blit.rect.nearest_consistency_min_reverse_src_dst_y,Fail dEQP-GLES3.functional.fbo.blit.rect.nearest_consistency_min_reverse_src_x,Fail -dEQP-GLES2.functional.clipping.line.wide_line_clip_viewport_center,Fail -dEQP-GLES2.functional.clipping.line.wide_line_clip_viewport_corner,Fail # this test tries to be error-compatible with nvidia. spoiler: mesa isn't, and no driver can pass it glx@glx_arb_create_context@invalid flag,Fail -- 2.7.4