[Piglit] [PATCH] gl-1.3-alpha_to_coverage_nop: new test of no-op GL_SAMPLE_ALPHA_TO_COVERAGE
Jose Fonseca
jfonseca at vmware.com
Fri Sep 16 09:56:32 UTC 2016
On 15/09/16 22:12, Brian Paul wrote:
> Currently fails with llvmpipe. Fragments with alpha <= 0.5 are discarded.
> Passes with softpipe, NVIDIA driver.
>
> v2: test with GL_MULTISAMPLE both enabled and disabled, fix all.py entry
> ---
> tests/all.py | 1 +
> tests/spec/CMakeLists.txt | 1 +
> tests/spec/gl-1.3/CMakeLists.gl.txt | 13 ++++
> tests/spec/gl-1.3/CMakeLists.txt | 1 +
> tests/spec/gl-1.3/alpha_to_coverage_nop.c | 110 ++++++++++++++++++++++++++++++
> 5 files changed, 126 insertions(+)
> create mode 100644 tests/spec/gl-1.3/CMakeLists.gl.txt
> create mode 100644 tests/spec/gl-1.3/CMakeLists.txt
> create mode 100644 tests/spec/gl-1.3/alpha_to_coverage_nop.c
>
> diff --git a/tests/all.py b/tests/all.py
> index a448331..b069548 100644
> --- a/tests/all.py
> +++ b/tests/all.py
> @@ -840,6 +840,7 @@ with profile.group_manager(
> g(['gl-1.1-xor'])
> g(['gl-1.1-xor-copypixels'])
> g(['gl-1.2-texture-base-level'])
> + g(['gl-1.3-alpha_to_coverage_nop'])
> g(['hiz'], run_concurrent=False)
> g(['infinite-spot-light'], run_concurrent=False)
> g(['line-aa-width'], run_concurrent=False)
> diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt
> index 9b0f73e..9972785 100644
> --- a/tests/spec/CMakeLists.txt
> +++ b/tests/spec/CMakeLists.txt
> @@ -106,6 +106,7 @@ add_subdirectory (glsl-es-3.00)
> add_subdirectory (gl-1.0)
> add_subdirectory (gl-1.1)
> add_subdirectory (gl-1.2)
> +add_subdirectory (gl-1.3)
> add_subdirectory (gl-1.4)
> add_subdirectory (gl-1.5)
> add_subdirectory (gl-2.0)
> diff --git a/tests/spec/gl-1.3/CMakeLists.gl.txt b/tests/spec/gl-1.3/CMakeLists.gl.txt
> new file mode 100644
> index 0000000..607d2c1
> --- /dev/null
> +++ b/tests/spec/gl-1.3/CMakeLists.gl.txt
> @@ -0,0 +1,13 @@
> +include_directories(
> + ${GLEXT_INCLUDE_DIR}
> + ${OPENGL_INCLUDE_PATH}
> +)
> +
> +link_libraries (
> + piglitutil_${piglit_target_api}
> + ${OPENGL_gl_LIBRARY}
> +)
> +
> +piglit_add_executable (gl-1.3-alpha_to_coverage_nop alpha_to_coverage_nop.c)
> +
> +# vim: ft=cmake:
> diff --git a/tests/spec/gl-1.3/CMakeLists.txt b/tests/spec/gl-1.3/CMakeLists.txt
> new file mode 100644
> index 0000000..4a012b9
> --- /dev/null
> +++ b/tests/spec/gl-1.3/CMakeLists.txt
> @@ -0,0 +1 @@
> +piglit_include_target_api()
> \ No newline at end of file
> diff --git a/tests/spec/gl-1.3/alpha_to_coverage_nop.c b/tests/spec/gl-1.3/alpha_to_coverage_nop.c
> new file mode 100644
> index 0000000..b343056
> --- /dev/null
> +++ b/tests/spec/gl-1.3/alpha_to_coverage_nop.c
> @@ -0,0 +1,110 @@
> +/*
> + * Copyright © 2016 VMware, Inc.
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice (including the next
> + * paragraph) shall be included in all copies or substantial portions of the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
> + * IN THE SOFTWARE.
> + */
> +
> +
> +/**
> + * Test that enabling GL_ALPHA_TO_COVERAGE has no effect for non-MSAA
> + * rendering.
> + */
> +
> +
> +#include "piglit-util-gl.h"
> +
> +PIGLIT_GL_TEST_CONFIG_BEGIN
> + config.supports_gl_compat_version = 13;
> + config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
> +PIGLIT_GL_TEST_CONFIG_END
> +
> +
> +void
> +piglit_init(int argc, char **argv)
> +{
> + /* nothing */
> +}
> +
> +static bool
> +test_coverage_nop(bool msaa_enabled)
> +{
> + float alpha;
> +
> + if (msaa_enabled)
> + glEnable(GL_MULTISAMPLE);
> + else
> + glDisable(GL_MULTISAMPLE);
> +
> + /* Render quad with varying alpha value. Make sure it draws
> + * and is not missing because of some kind of MSAA coverage bug.
> + */
> + for (alpha = 1.0; alpha >= 0.0; alpha -= 1.0/128) {
> + float expected[4] = {alpha, alpha, alpha, alpha};
> +
> + glClear(GL_COLOR_BUFFER_BIT);
> + glColor4fv(expected);
> + piglit_draw_rect(-1, -1, 2, 2);
> +
> + if (!piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height,
> + expected)) {
> + printf("Rect did not draw for alpha = %g "
> + "with GL_MULTISAMPLE %s\n",
> + alpha,
> + msaa_enabled ? "enabled" : "disabled");
> + return false;
> + }
> +
> + piglit_present_results();
> + }
> +
> + return true;
> +}
> +
> +
> +enum piglit_result
> +piglit_display(void)
> +{
> + GLint samples;
> + bool pass;
> +
> + glGetIntegerv(GL_SAMPLES, &samples);
> + if (samples != 0) {
> + printf("Unexpected GL_SAMPLES = %d\n", samples);
> + return PIGLIT_FAIL;
> + }
> +
> + glGetIntegerv(GL_SAMPLE_BUFFERS, &samples);
> + if (samples != 0) {
> + printf("Unexpected GL_SAMPLE_BUFFERS = %d\n", samples);
> + return PIGLIT_FAIL;
> + }
> +
> + glClearColor(1, 0, 0, 0);
> +
> + /* Enabling GL_SAMPLE_ALPHA_TO_COVERAGE should have no effect
> + * with a non-MSAA drawing surface.
> + */
> + glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE);
> +
> + pass = test_coverage_nop(true);
> + pass = test_coverage_nop(false) && pass;
> +
> + return pass ? PIGLIT_PASS : PIGLIT_FAIL;
> +}
>
Reviewed-by: Jose Fonseca <jfonseca at vmware.com>
More information about the Piglit
mailing list