llvmpipe: do not always use pixel-rounded coordinates for points

LLVMpipe always used the bounding-box to rasterize-points, rather than
the actual rasterization-planes. This happened because the primitive was
expanded by one unit outside the bounding box. While this kinda work for
non-multisampled cases, it's not really quite *correct*.

Rasterization of non-legacy points in OpenGL is defined as the
intersection of a the pixel centers with a rectangle of size width and
height, centered around the point in viewport coordinates. This applies
both to multi-sampled and non-multisampled cases.

So let's fix the rasterizer to use the correct definition in both cases.

We leave the legacy case as-is, and just do the inverse adjustment
there so the end result should be the same.

This fixes the following dEQP test-cases:
- dEQP-GLES3.functional.rasterization.fbo.rbo_multisample_4.primitives.points
- dEQP-GLES3.functional.rasterization.fbo.rbo_multisample_max.primitives.points

...as well as this one for Lavapipe:
- dEQP-VK.rasterization.primitives_multisample_4_bit.no_stipple.points

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11183>
This commit is contained in:
Erik Faye-Lund 2021-06-07 16:06:15 +02:00
parent cef08f0557
commit f530e72ea0
5 changed files with 28 additions and 16 deletions

View File

@ -47,8 +47,6 @@ dEQP-GLES3.functional.polygon_offset.fixed16_render_with_units,Fail
dEQP-GLES3.functional.polygon_offset.fixed24_displacement_with_units,Fail
dEQP-GLES3.functional.polygon_offset.fixed24_render_with_units,Fail
dEQP-GLES3.functional.polygon_offset.float32_displacement_with_units,Fail
dEQP-GLES3.functional.rasterization.fbo.rbo_multisample_4.primitives.points,Fail
dEQP-GLES3.functional.rasterization.fbo.rbo_multisample_max.primitives.points,Fail
dEQP-GLES3.functional.rasterization.fbo.rbo_singlesample.interpolation.lines_wide,Fail
dEQP-GLES3.functional.rasterization.fbo.texture_2d.interpolation.lines_wide,Fail
dEQP-GLES3.functional.rasterization.interpolation.basic.line_loop_wide,Fail

View File

@ -355,6 +355,7 @@ try_setup_point( struct lp_setup_context *setup,
struct lp_rast_triangle *point;
unsigned bytes;
struct u_rect bbox;
int x[2], y[2];
unsigned nr_planes = 4;
struct point_info info;
unsigned viewport_index = 0;
@ -374,7 +375,7 @@ try_setup_point( struct lp_setup_context *setup,
print_point(setup, v0, size);
/* Bounding rectangle (in pixels) */
if (!setup->legacy_points) {
if (!setup->legacy_points || setup->multisample) {
/*
* Rasterize points as quads.
*/
@ -387,10 +388,14 @@ try_setup_point( struct lp_setup_context *setup,
x0 = subpixel_snap(v0[0][0] - pixel_offset) - fixed_width/2;
y0 = subpixel_snap(v0[0][1] - pixel_offset) - fixed_width/2;
bbox.x0 = (x0 + (FIXED_ONE-1)) >> FIXED_ORDER;
bbox.x1 = (x0 + fixed_width + (FIXED_ONE-1)) >> FIXED_ORDER;
bbox.y0 = (y0 + (FIXED_ONE-1) + adj) >> FIXED_ORDER;
bbox.y1 = (y0 + fixed_width + (FIXED_ONE-1) + adj) >> FIXED_ORDER;
x[0] = x0;
x[1] = x0 + fixed_width;
y[0] = y0;
y[1] = y0 + fixed_width;
bbox.x0 = x[0] >> FIXED_ORDER;
bbox.x1 = (x[1] + (FIXED_ONE-1)) >> FIXED_ORDER;
bbox.y0 = (y[0] + adj) >> FIXED_ORDER;
bbox.y1 = (y[1] + (FIXED_ONE-1) + adj) >> FIXED_ORDER;
/* Inclusive coordinates:
*/
@ -438,6 +443,11 @@ try_setup_point( struct lp_setup_context *setup,
bbox.x1 = bbox.x0 + int_width - 1;
bbox.y1 = bbox.y0 + int_width - 1;
}
x[0] = (bbox.x0 - 1) << 8;
x[1] = (bbox.x1 + 1) << 8;
y[0] = (bbox.y0 - 1) << 8;
y[1] = (bbox.y1 + 1) << 8;
}
if (0) {
@ -504,23 +514,32 @@ try_setup_point( struct lp_setup_context *setup,
plane[0].dcdx = ~0U << 8;
plane[0].dcdy = 0;
plane[0].c = (1-bbox.x0) << 8;
plane[0].c = -x[0];
plane[0].eo = 1 << 8;
plane[1].dcdx = 1 << 8;
plane[1].dcdy = 0;
plane[1].c = (bbox.x1+1) << 8;
plane[1].c = x[1];
plane[1].eo = 0;
plane[2].dcdx = 0;
plane[2].dcdy = 1 << 8;
plane[2].c = (1-bbox.y0) << 8;
plane[2].c = -y[0];
plane[2].eo = 1 << 8;
plane[3].dcdx = 0;
plane[3].dcdy = ~0U << 8;
plane[3].c = (bbox.y1+1) << 8;
plane[3].c = y[1];
plane[3].eo = 0;
if (!setup->legacy_points || setup->multisample) {
/* adjust for fill-rule*/
plane[0].c++; /* left */
if (setup->bottom_edge_rule == 0)
plane[2].c++; /* top-left */
else
plane[3].c++; /* bottom-left */
}
}
return lp_setup_bin_triangle(setup, point, &bbox, &bbox, nr_planes, viewport_index);

View File

@ -38,8 +38,6 @@ dEQP-GLES3.functional.polygon_offset.fixed16_render_with_units,Fail
dEQP-GLES3.functional.polygon_offset.fixed24_displacement_with_units,Fail
dEQP-GLES3.functional.polygon_offset.fixed24_render_with_units,Fail
dEQP-GLES3.functional.polygon_offset.float32_displacement_with_units,Fail
dEQP-GLES3.functional.rasterization.fbo.rbo_multisample_4.primitives.points,Fail
dEQP-GLES3.functional.rasterization.fbo.rbo_multisample_max.primitives.points,Fail
dEQP-GLES3.functional.rasterization.fbo.rbo_singlesample.interpolation.lines_wide,Fail
dEQP-GLES3.functional.rasterization.fbo.texture_2d.interpolation.lines_wide,Fail
dEQP-GLES3.functional.rasterization.interpolation.basic.line_loop_wide,Fail

View File

@ -37,8 +37,6 @@ dEQP-GLES3.functional.polygon_offset.fixed16_render_with_units,Fail
dEQP-GLES3.functional.polygon_offset.fixed24_displacement_with_units,Fail
dEQP-GLES3.functional.polygon_offset.fixed24_render_with_units,Fail
dEQP-GLES3.functional.polygon_offset.float32_displacement_with_units,Fail
dEQP-GLES3.functional.rasterization.fbo.rbo_multisample_4.primitives.points,Fail
dEQP-GLES3.functional.rasterization.fbo.rbo_multisample_max.primitives.points,Fail
dEQP-GLES3.functional.rasterization.fbo.rbo_singlesample.interpolation.lines_wide,Fail
dEQP-GLES3.functional.rasterization.fbo.texture_2d.interpolation.lines_wide,Fail
dEQP-GLES3.functional.rasterization.interpolation.basic.line_loop_wide,Fail

View File

@ -33,7 +33,6 @@ dEQP-VK.image.mismatched_formats.image_write.a8b8g8r8_srgb_pack32_with_rgb10a2,C
dEQP-VK.image.mismatched_formats.image_write.b8g8r8a8_srgb_with_rgba8,Crash
dEQP-VK.image.mismatched_formats.image_write.r8g8b8a8_srgb_with_rgb10a2,Crash
dEQP-VK.rasterization.interpolation.projected.non_strict_lines,Fail
dEQP-VK.rasterization.primitives_multisample_4_bit.no_stipple.points,Fail
dEQP-VK.texture.filtering.2d.combinations.linear_mipmap_linear.linear.clamp_to_edge.repeat,Fail
dEQP-VK.texture.filtering.2d.combinations.linear_mipmap_linear.linear.mirror_clamp_to_edge.repeat,Fail
dEQP-VK.texture.filtering.2d.combinations.linear_mipmap_linear.linear.mirrored_repeat.mirror_clamp_to_edge,Fail