diff --git a/runtime/src/gpu_gl_renderer.c b/runtime/src/gpu_gl_renderer.c index e1442922..44223c83 100644 --- a/runtime/src/gpu_gl_renderer.c +++ b/runtime/src/gpu_gl_renderer.c @@ -4709,11 +4709,14 @@ static void gpu_geometry(GLenum mode, const int *xs, const int *ys, } line_to_quad(lv, quad); if (s_fb_n > 0 && (s_fb_mode != GL_TRIANGLES || s_fb_semi != semi || - s_fb_mask != (int)s_mask_set || s_fb_depth != 0)) + s_fb_mask != (int)s_mask_set || s_fb_gate != 0 || s_fb_depth != 0)) flush_flat_batch(); if (s_fb_n + 6 > FLATBATCH_MAXV) flush_flat_batch(); s_fb_mode = GL_TRIANGLES; + /* The expanded line is still world geometry. A previous backdrop + * batch may have left its stretch key set even after being flushed. */ + s_fb_gate = 0; s_fb_semi = semi; s_fb_mask = (int)s_mask_set; s_fb_depth = 0; /* lines are 2D: never depth-tested (G1.14) */ diff --git a/runtime/tests/test_gl_scale_invariance.c b/runtime/tests/test_gl_scale_invariance.c index 828242a4..9716c348 100644 --- a/runtime/tests/test_gl_scale_invariance.c +++ b/runtime/tests/test_gl_scale_invariance.c @@ -1298,10 +1298,15 @@ static int backdrop_lines_main(int scale) { g_ws_bd_stretch_on = 1; g_ws_bd_phase_mode = 1; g_ws_bd_stretch_pct = 0; - for (int policy = 0; policy < 2; ++policy) { + for (int policy = 0; policy < 2; ++policy) for (int order = 0; order < 3; ++order) { glb_wide_clear(0, 0, 512, 0); test_flat_backdrop = policy == 0; test_backdrop_phase = policy == 1; + /* Cover both a pending backdrop batch and its key remaining after a + * flush. Supersampled lines expand to triangles, but must not join + * that backdrop batch or inherit its horizontal stretch. */ + if (order) glb_draw_flat_triangle(4, 4, 20, 4, 4, 12, 0x4210); + if (order == 2) gl_renderer_sync_cpu(); glb_draw_line(64, 20, 64, 100, 0x7fff); glb_draw_shaded_line(100, 20, 0x7fff, 100, 100, 0x7fff); test_backdrop_phase = 0;