Ping?

This reveals real bugs in virgl drivers, so it would be nice to get it
upstream, so it's "on the record"...

On Thu, 2018-09-20 at 20:17 +0200, Erik Faye-Lund wrote:
> Drivers who implement GL_ALPHA textures by swizzling a GL_R texture
> needs to be prepared to offer multiple blend-colors, otherwise they
> will produce the wrong result, because the blend-color will also
> need per-format swizzling.
> 
> Similarly, when drivers implement GL_RGB with GL_RGBA and adjust the
> blend-factors, they need to have separate blend-factors for all
> framebuffer attachments or the results will be wrong.
> 
> This reveals a couple of bugs in virgl, where these currently fail.
> 
> Signed-off-by: Erik Faye-Lund <erik.faye-l...@collabora.com>
> ---
>  tests/fbo/CMakeLists.gl.txt            |   1 +
>  tests/fbo/fbo-blending-format-quirks.c | 175
> +++++++++++++++++++++++++
>  tests/opengl.py                        |   1 +
>  3 files changed, 177 insertions(+)
>  create mode 100644 tests/fbo/fbo-blending-format-quirks.c
> 
> diff --git a/tests/fbo/CMakeLists.gl.txt
> b/tests/fbo/CMakeLists.gl.txt
> index d594c24d3..1a1a60765 100644
> --- a/tests/fbo/CMakeLists.gl.txt
> +++ b/tests/fbo/CMakeLists.gl.txt
> @@ -29,6 +29,7 @@ piglit_add_executable (fbo-blit fbo-blit.c)
>  piglit_add_executable (fbo-blit-d24s8 fbo-blit-d24s8.c)
>  piglit_add_executable (fbo-blit-stretch fbo-blit-stretch.cpp)
>  piglit_add_executable (fbo-blending-formats fbo-blending-formats.c)
> +piglit_add_executable (fbo-blending-format-quirks fbo-blending-
> format-quirks.c)
>  piglit_add_executable (fbo-blending-snorm fbo-blending-snorm.c)
>  piglit_add_executable (fbo-colormask-formats fbo-colormask-
> formats.c)
>  piglit_add_executable (fbo-copypix fbo-copypix.c)
> diff --git a/tests/fbo/fbo-blending-format-quirks.c b/tests/fbo/fbo-
> blending-format-quirks.c
> new file mode 100644
> index 000000000..f6865d42b
> --- /dev/null
> +++ b/tests/fbo/fbo-blending-format-quirks.c
> @@ -0,0 +1,175 @@
> +/*
> + * Copyright © 2018 Collabora Ltd
> + *
> + * 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.
> + *
> + * Authors:
> + *    Erik Faye-Lund <erik.faye-l...@collabora.com>
> + *
> + */
> +
> +#include "piglit-util-gl.h"
> +
> +PIGLIT_GL_TEST_CONFIG_BEGIN
> +
> +     config.supports_gl_compat_version = 10;
> +
> +     /* Drivers that do not support GL_ARB_texture_non_power_of_two
> require
> +      * window dimensions that are powers of two for this test.
> +      */
> +     config.window_width = next_power_of_two(config.window_width);
> +     config.window_height = next_power_of_two(config.window_height);
> +
> +     config.window_visual = PIGLIT_GL_VISUAL_RGBA |
> PIGLIT_GL_VISUAL_DOUBLE;
> +     config.khr_no_error_support = PIGLIT_NO_ERRORS;
> +
> +PIGLIT_GL_TEST_CONFIG_END
> +
> +static enum piglit_result test_formats(const char *name, GLenum
> formats[2],
> +                                    float expect[2][4], GLenum
> factors[2])
> +{
> +     GLboolean pass = GL_TRUE;
> +     GLuint tex[2], fb;
> +     GLenum draw_bufs[] = { GL_COLOR_ATTACHMENT0,
> GL_COLOR_ATTACHMENT1 };
> +     GLenum status;
> +     int i;
> +
> +     glGenFramebuffersEXT(1, &fb);
> +     glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb);
> +     glViewport(0, 0, piglit_width, piglit_height);
> +
> +     glGenTextures(2, tex);
> +     for (i = 0; i < 2; ++i) {
> +             glBindTexture(GL_TEXTURE_2D, tex[i]);
> +             glTexImage2D(GL_TEXTURE_2D, 0, formats[i],
> +                          piglit_width, piglit_height, 0,
> +                          GL_RGBA, GL_FLOAT, NULL);
> +
> +             glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
> +                                       GL_COLOR_ATTACHMENT0_EXT + i,
> +                                       GL_TEXTURE_2D,
> +                                       tex[i],
> +                                       0);
> +     }
> +     if (!piglit_check_gl_error(GL_NO_ERROR))
> +             piglit_report_result(PIGLIT_FAIL);
> +
> +     status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
> +     if (status != GL_FRAMEBUFFER_COMPLETE_EXT) {
> +             printf(" - fbo incomplete (status = %s)\n",
> +                    piglit_get_gl_enum_name(status));
> +             return PIGLIT_SKIP;
> +     }
> +
> +     printf("Testing %s\n", name);
> +
> +     glClearColor(0.0, 0.0, 0.0, 0.5);
> +     glClear(GL_COLOR_BUFFER_BIT);
> +
> +     glEnable(GL_BLEND);
> +     glBlendFunc(factors[0], factors[1]);
> +     glBlendColor(1.0, 0.5, 0.25, 0.125);
> +     glColor4f(1.0, 1.0, 1.0, 1.0);
> +
> +     glDrawBuffers(2, draw_bufs);
> +     piglit_draw_rect(-1.0, -1.0, 2.0, 2.0);
> +
> +     glReadBuffer(GL_COLOR_ATTACHMENT0);
> +     if (!piglit_probe_pixel_rgba(piglit_width / 2, piglit_height /
> 2,
> +                                  expect[0])) {
> +             printf("  when testing GL_COLOR_ATTACHMENT0.\n");
> +             pass = GL_FALSE;
> +     }
> +
> +     glReadBuffer(GL_COLOR_ATTACHMENT1);
> +     if (!piglit_probe_pixel_rgba(piglit_width / 2, piglit_height /
> 2,
> +                                  expect[1])) {
> +             printf("  when testing GL_COLOR_ATTACHMENT1.\n");
> +             pass = GL_FALSE;
> +     }
> +
> +     return pass ? PIGLIT_PASS : PIGLIT_FAIL;
> +}
> +
> +enum piglit_result piglit_display(void)
> +{
> +     int i;
> +        enum piglit_result result, end_result = PIGLIT_PASS;
> +        bool all_skip = true;
> +
> +     struct {
> +             const char *name;
> +             GLenum formats[2];
> +             GLenum factors[2];
> +             float expect[2][4];
> +     } cases[] = {
> +             { "alpha expand",
> +                     { GL_RGBA, GL_RGB },
> +                     { GL_DST_ALPHA, GL_ZERO }, {
> +                             { 0.5, 0.5, 0.5, 0.5 },
> +                             { 1.0, 1.0, 1.0, 1.0 }
> +                     }
> +             },
> +
> +             { "alpha swizzle, variant 1",
> +                     { GL_RGBA, GL_ALPHA },
> +                     { GL_DST_ALPHA, GL_ZERO }, {
> +                             { 0.5, 0.5, 0.5, 0.5 },
> +                             { 0.0, 0.0, 0.0, 0.0 }
> +                     }
> +             },
> +
> +             { "alpha swizzle, variant 2",
> +                     { GL_RGBA, GL_ALPHA },
> +                     { GL_CONSTANT_COLOR, GL_ZERO }, {
> +                             { 1.0, 0.5, 0.25, 0.125 },
> +                             { 0.0, 0.0, 0.0, 0.125 }
> +                     }
> +             },
> +
> +             { "alpha swizzle, variant 3",
> +                     { GL_ALPHA, GL_RGBA },
> +                     { GL_CONSTANT_COLOR, GL_ZERO }, {
> +                             { 0.0, 0.0, 0.0, 0.125 },
> +                             { 1.0, 0.5, 0.25, 0.125 }
> +                     }
> +             }
> +     };
> +
> +     for (i = 0; i < ARRAY_SIZE(cases); ++i) {
> +             result = test_formats(cases[i].name, cases[i].formats,
> +                                   cases[i].expect,
> cases[i].factors);
> +
> +             if (result != PIGLIT_SKIP)
> +                     all_skip = false;
> +
> +             if (result == PIGLIT_FAIL)
> +                     end_result = result;
> +     }
> +
> +     if (all_skip)
> +             return PIGLIT_SKIP;
> +     return end_result;
> +}
> +
> +void piglit_init(int argc, char **argv)
> +{
> +     glDisable(GL_DITHER);
> +}
> diff --git a/tests/opengl.py b/tests/opengl.py
> index c599eb180..195f711ee 100644
> --- a/tests/opengl.py
> +++ b/tests/opengl.py
> @@ -2953,6 +2953,7 @@ with profile.test_list.group_manager(
>      g(['fbo-alphatest-nocolor'])
>      g(['fbo-alphatest-nocolor-ff'])
>      g(['fbo-blending-formats'])
> +    g(['fbo-blending-format-quirks'])
>      g(['fbo-blending-snorm'])
>      g(['fbo-bind-renderbuffer'])
>      g(['fbo-clearmipmap'])

_______________________________________________
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit

Reply via email to