[Piglit] [PATCH] multisample-accuracy: Shift the reference image by 1/32th of a pixel

Neil Roberts neil at linux.intel.com
Fri Oct 23 07:33:49 PDT 2015


Ilia Mirkin kindly tested this with nvidia's driver and sadly the patch
causes the test to fail for 32x MSAA. At this point I think maybe the
best course of action is to abandon this patch and just relax the
accuracy requirements for the test. I will post some separate patches
for this.

- Neil

Neil Roberts <neil at linux.intel.com> writes:

> This fixes false negatives for hardware using the sampling positions
> described by D3D on 16x MSAA. Please see the comment explaining the
> issue.
> ---
>  tests/spec/ext_framebuffer_multisample/common.cpp | 37 ++++++++++++++++++++---
>  tests/spec/ext_framebuffer_multisample/common.h   |  3 +-
>  2 files changed, 35 insertions(+), 5 deletions(-)
>
> diff --git a/tests/spec/ext_framebuffer_multisample/common.cpp b/tests/spec/ext_framebuffer_multisample/common.cpp
> index d7be84f..944e45d 100644
> --- a/tests/spec/ext_framebuffer_multisample/common.cpp
> +++ b/tests/spec/ext_framebuffer_multisample/common.cpp
> @@ -371,7 +371,7 @@ Test::show(Fbo *src_fbo, int x_offset, int y_offset)
>   * full FBO.
>   */
>  void
> -Test::draw_pattern(int x_offset, int y_offset, int width, int height)
> +Test::draw_pattern(float x_offset, float y_offset, int width, int height)
>  {
>  	/* Need a projection matrix such that:
>  	 * xc = ((xe + 1) * pattern_width/2 - x_offset) * 2/width - 1
> @@ -449,6 +449,33 @@ Test::draw_to_default_framebuffer()
>  
>  /**
>   * Draw the entire test image, rendering it a piece at a time.
> + *
> + * The reference image is created as if it was super-sampled using an
> + * evenly spaced grid of supersample_factor*supersample_factor
> + * positions. Normally the sampling positions would effectively be in
> + * the center of each of the squares of this grid. However, the
> + * sampling positions used by most hardware is programmable in
> + * multiples of 1/16th of a pixel ranging from 0.0 to 0.9375 because
> + * that how it is described in D3D. That means it is possible to have
> + * a sampling position that is exactly on the left or top border of a
> + * pixel. If we let the sampling position be in the center of the grid
> + * then when supersample_factor is 16 there will be positions from
> + * 0.03125 to 0.96875. It is therefore possible that the sampling
> + * positions chosen by the hardware will be outside of the area of the
> + * chosen sampling positions for the reference image. That means it's
> + * possible for the reference image to report that a pixel is wholly
> + * unlit whereas the hardware legitimately lights up one of its samples.
> + * To fix this the reference image is shifted by half of the size of a
> + * square in this grid so that it is as if the sampling positions are
> + * at the bottom left corners of the squares. That way if the hardware
> + * is following the D3D model for the sampling positions then any
> + * possible position that can be programmed will coincide with one of
> + * the positions in the supersampled reference image. If this is not
> + * done then the test will report false negatives for hardware using
> + * the sampling positions recommended by D3D for 16x MSAA. There is a
> + * diagram explaining this problem here:
> + *
> + * http://busydoingnothing.co.uk/accuracy-test-is-broken/
>   */
>  void
>  Test::draw_reference_image()
> @@ -464,9 +491,11 @@ Test::draw_reference_image()
>  			glBindFramebuffer(GL_DRAW_FRAMEBUFFER,
>  					  supersample_fbo.handle);
>  			supersample_fbo.set_viewport();
> -			int x_offset = h * downsampled_width;
> -			int y_offset = v * downsampled_height;
> -			draw_pattern(x_offset, y_offset,
> +			float sample_shift = 0.5f / supersample_factor;
> +			float x_offset = h * downsampled_width;
> +			float y_offset = v * downsampled_height;
> +			draw_pattern(x_offset - sample_shift,
> +				     y_offset - sample_shift,
>  				     downsampled_width, downsampled_height);
>  
>  			if (manifest_program)
> diff --git a/tests/spec/ext_framebuffer_multisample/common.h b/tests/spec/ext_framebuffer_multisample/common.h
> index 948a1d4..c0452f4 100644
> --- a/tests/spec/ext_framebuffer_multisample/common.h
> +++ b/tests/spec/ext_framebuffer_multisample/common.h
> @@ -117,7 +117,8 @@ private:
>  	void resolve(piglit_util_fbo::Fbo *fbo, GLbitfield which_buffers);
>  	void downsample_color(int downsampled_width, int downsampled_height);
>  	void show(piglit_util_fbo::Fbo *src_fbo, int x_offset, int y_offset);
> -	void draw_pattern(int x_offset, int y_offset, int width, int height);
> +	void draw_pattern(float x_offset, float y_offset,
> +			  int width, int height);
>  
>  	/** The test pattern to draw. */
>  	piglit_util_test_pattern::TestPattern *pattern;
> -- 
> 1.9.3
>
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit


More information about the Piglit mailing list