fix(render): give degenerate segments area, pin font bit order, clarify vertex_count

This commit is contained in:
Martino Ferrari committed 2026-09-27 22:10:53 +02:00
1 parent 7cbc1c9955
commit b4e88fe0c1
5 files changed
+76 -15

No files matched your search

+21 -8
View File
@@ -269,13 +269,15 @@ PLOT_TEST(line_pipeline_draws_an_aa_strip) {
plot::render::LineVertexArray lines;
PLOT_CHECK(lines.create(&st));
// Two instances, so a wrong attribute divisor cannot pass: with a divisor of
// zero the second quad would be assembled from the first instance's leftover
// attribute values instead of its own segment. Data space is pixels here, and
// u_offset lands the two axes at Rect y = 100 and Rect y = 120.
const f32 segments[8] = {0.0f, 0.0f, 40.0f, 0.0f, 0.0f, 20.0f, 40.0f, 20.0f};
lines.upload(segments, 2);
PLOT_CHECK(lines.instance_count() == 2);
// Three instances: two segments at different y, so a wrong attribute divisor
// cannot pass (with a divisor of zero the second quad would be assembled from
// the first instance's leftover attribute values), plus a degenerate one at
// Rect (64, 140) — the shape a dense trace's min == max bucket stages, which
// must still leave a mark instead of collapsing to zero area.
const f32 segments[12] = {0.0f, 0.0f, 40.0f, 0.0f, 0.0f, 20.0f,
40.0f, 20.0f, 0.0f, 40.0f, 0.0f, 40.0f};
lines.upload(segments, 3);
PLOT_CHECK(lines.instance_count() == 3);
plot::gl::glViewport(0, 0, static_cast<plot::gl::GLsizei>(ctx.width),
static_cast<plot::gl::GLsizei>(ctx.height));
@@ -291,7 +293,7 @@ PLOT_TEST(line_pipeline_draws_an_aa_strip) {
program.set_width(3.0f);
program.set_color(plot::Color::hex(0xFF00FF));
lines.bind();
plot::gl::glDrawArraysInstanced(plot::gl::GL_TRIANGLE_STRIP, 0, 4, 2);
plot::gl::glDrawArraysInstanced(plot::gl::GL_TRIANGLE_STRIP, 0, 4, 3);
plot::u8 px[4] = {};
// Rect y = 100 is GL row 155.5, so rows 155 and 156 straddle the axis
@@ -318,6 +320,17 @@ PLOT_TEST(line_pipeline_draws_an_aa_strip) {
// Past the end of the segment (flat cap) and far from both strips.
PLOT_CHECK(ctx.read_pixel(110, 155, px));
PLOT_CHECK(px[0] + px[2] < 40);
// The degenerate instance: Rect y = 140 is rows 115/116 at x = 64, and the
// mark must be visible rather than a zero-area quad, while staying inside its
// own stroke width + fringe (columns 62..66).
PLOT_CHECK(ctx.read_pixel(64, 115, px));
PLOT_CHECK(px[0] > 200 && px[2] > 200);
PLOT_CHECK(ctx.read_pixel(64, 116, px));
PLOT_CHECK(px[0] > 200 && px[2] > 200);
PLOT_CHECK(ctx.read_pixel(64, 121, px));
PLOT_CHECK(px[0] + px[2] < 40);
PLOT_CHECK(ctx.read_pixel(70, 115, px));
PLOT_CHECK(px[0] + px[2] < 40);
PLOT_CHECK(ctx.read_pixel(128, 0, px));
PLOT_CHECK(px[0] + px[2] < 40);
PLOT_CHECK(plot::gl::glGetError() == plot::gl::GL_NO_ERROR);