[Piglit] [PATCH v4] tests: add nvidia conservative rasterization tests
Rhys Perry
pendingchaos02 at gmail.com
Fri May 11 12:23:47 UTC 2018
Both approaches look like they would be more robust that the current one.
I think I'll create a new version of the patch using the first one.
On Fri, May 11, 2018 at 4:06 AM, Brian Paul <brianp at vmware.com> wrote:
> Reviewed-by: Brian Paul <brianp at vmware.com>
>
> Though, I can't help but think that we could do something better for the
> drawing test.
>
> My first approach would be to draw a triangle with conservative
> rasterization on then off and compare how many pixels are written. The
> conservative rasterization should generate more fragments than the normal
> rasterization. And the difference should, I think, be proportional to the
> perimeter of the triangle. As long as there's no vertical/horizontal edges
> exactly on pixel bounds.
>
> Another approach would be to draw two adjacent gray triangles with blend-add
> mode and check that pixels along the shared edge are white (hit twice).
>
> What do you think?
>
> -Brian
>
>
>
> On 05/09/2018 02:05 PM, Rhys Perry wrote:
>>
>> Ping I guess?
>>
>> On Fri, Mar 30, 2018 at 10:56 PM, Rhys Perry <pendingchaos02 at gmail.com>
>> wrote:
>>>
>>> Adds tests for GL_NV_conservative_raster,
>>> GL_NV_conservative_raster_dilate
>>> and GL_NV_conservative_raster_pre_snap_triangles.
>>>
>>> Changes in v2:
>>> - cleanup the tests
>>> - fix some test failures
>>> - remove the gles version of the dilation test as the extension is not
>>> exposed in gl.xml
>>> Changes in v3:
>>> - fix accidently luck-based pre-snap-triangles test
>>> Changes in v4:
>>> - apply formatting changes
>>> - elaborate on various comments describing the test source code files
>>>
>>> Signed-off-by: Rhys Perry <pendingchaos02 at gmail.com>
>>> ---
>>> I am new to this project and don't have commit access.
>>>
>>> tests/all.py | 20 ++
>>> tests/spec/CMakeLists.txt | 3 +
>>> .../spec/nv_conservative_raster/CMakeLists.gl.txt | 13 +
>>> .../nv_conservative_raster/CMakeLists.gles2.txt | 3 +
>>> tests/spec/nv_conservative_raster/CMakeLists.txt | 1 +
>>> tests/spec/nv_conservative_raster/attrib.c | 107 +++++++
>>> tests/spec/nv_conservative_raster/dlist.c | 110 +++++++
>>> tests/spec/nv_conservative_raster/draw.c | 338
>>> +++++++++++++++++++++
>>> .../CMakeLists.gl.txt | 11 +
>>> .../nv_conservative_raster_dilate/CMakeLists.txt | 1 +
>>> tests/spec/nv_conservative_raster_dilate/draw.c | 151 +++++++++
>>> .../CMakeLists.gl.txt | 11 +
>>> .../CMakeLists.gles2.txt | 3 +
>>> .../CMakeLists.txt | 1 +
>>> .../draw.c | 148 +++++++++
>>> 15 files changed, 921 insertions(+)
>>> create mode 100644 tests/spec/nv_conservative_raster/CMakeLists.gl.txt
>>> create mode 100644
>>> tests/spec/nv_conservative_raster/CMakeLists.gles2.txt
>>> create mode 100644 tests/spec/nv_conservative_raster/CMakeLists.txt
>>> create mode 100644 tests/spec/nv_conservative_raster/attrib.c
>>> create mode 100644 tests/spec/nv_conservative_raster/dlist.c
>>> create mode 100644 tests/spec/nv_conservative_raster/draw.c
>>> create mode 100644
>>> tests/spec/nv_conservative_raster_dilate/CMakeLists.gl.txt
>>> create mode 100644
>>> tests/spec/nv_conservative_raster_dilate/CMakeLists.txt
>>> create mode 100644 tests/spec/nv_conservative_raster_dilate/draw.c
>>> create mode 100644
>>> tests/spec/nv_conservative_raster_pre_snap_triangles/CMakeLists.gl.txt
>>> create mode 100644
>>> tests/spec/nv_conservative_raster_pre_snap_triangles/CMakeLists.gles2.txt
>>> create mode 100644
>>> tests/spec/nv_conservative_raster_pre_snap_triangles/CMakeLists.txt
>>> create mode 100644
>>> tests/spec/nv_conservative_raster_pre_snap_triangles/draw.c
>>>
>>> diff --git a/tests/all.py b/tests/all.py
>>> index 7c8580ef0..5fa219ca0 100644
>>> --- a/tests/all.py
>>> +++ b/tests/all.py
>>> @@ -4995,5 +4995,25 @@ with profile.test_list.group_manager(
>>> g(['arb_bindless_texture-uint64_attribs'], 'uint64_attribs')
>>> g(['arb_bindless_texture-uniform'], 'uniform')
>>>
>>> +# Group NV_conservative_raster
>>> +with profile.test_list.group_manager(
>>> + PiglitGLTest,
>>> + grouptools.join('spec', 'NV_conservative_raster')) as g:
>>> + g(['nv_conservative_raster-draw'], 'draw')
>>> + g(['nv_conservative_raster-dlist'], 'dlist')
>>> + g(['nv_conservative_raster-attrib'], 'attrib')
>>> +
>>> +# Group NV_conservative_raster_dilate
>>> +with profile.test_list.group_manager(
>>> + PiglitGLTest,
>>> + grouptools.join('spec', 'NV_conservative_raster_dilate')) as g:
>>> + g(['nv_conservative_raster_dilate-draw'], 'draw')
>>> +
>>> +# Group NV_conservative_raster_pre_snap_triangles
>>> +with profile.test_list.group_manager(
>>> + PiglitGLTest,
>>> + grouptools.join('spec',
>>> 'NV_conservative_raster_pre_snap_triangles')) as g:
>>> + g(['nv_conservative_raster_pre_snap_triangles-draw'], 'draw')
>>> +
>>> if platform.system() is 'Windows':
>>> profile.filters.append(lambda p, _: not p.startswith('glx'))
>>> diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt
>>> index dc14beb4e..a0bc845c5 100644
>>> --- a/tests/spec/CMakeLists.txt
>>> +++ b/tests/spec/CMakeLists.txt
>>> @@ -101,6 +101,9 @@ add_subdirectory (ext_texture_swizzle)
>>> add_subdirectory (ext_timer_query)
>>> add_subdirectory (ext_transform_feedback)
>>> add_subdirectory (nv_conditional_render)
>>> +add_subdirectory (nv_conservative_raster)
>>> +add_subdirectory (nv_conservative_raster_dilate)
>>> +add_subdirectory (nv_conservative_raster_pre_snap_triangles)
>>> add_subdirectory (nv_fill_rectangle)
>>> add_subdirectory (nv_image_formats)
>>> add_subdirectory (nv_texture_barrier)
>>> diff --git a/tests/spec/nv_conservative_raster/CMakeLists.gl.txt
>>> b/tests/spec/nv_conservative_raster/CMakeLists.gl.txt
>>> new file mode 100644
>>> index 000000000..5f632c864
>>> --- /dev/null
>>> +++ b/tests/spec/nv_conservative_raster/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 (nv_conservative_raster-draw draw.c)
>>> +piglit_add_executable (nv_conservative_raster-dlist dlist.c)
>>> +piglit_add_executable (nv_conservative_raster-attrib attrib.c)
>>> diff --git a/tests/spec/nv_conservative_raster/CMakeLists.gles2.txt
>>> b/tests/spec/nv_conservative_raster/CMakeLists.gles2.txt
>>> new file mode 100644
>>> index 000000000..b33576074
>>> --- /dev/null
>>> +++ b/tests/spec/nv_conservative_raster/CMakeLists.gles2.txt
>>> @@ -0,0 +1,3 @@
>>> +link_libraries(piglitutil_${piglit_target_api})
>>> +
>>> +piglit_add_executable (nv_conservative_raster-draw_gles2 draw.c)
>>> diff --git a/tests/spec/nv_conservative_raster/CMakeLists.txt
>>> b/tests/spec/nv_conservative_raster/CMakeLists.txt
>>> new file mode 100644
>>> index 000000000..144a306f4
>>> --- /dev/null
>>> +++ b/tests/spec/nv_conservative_raster/CMakeLists.txt
>>> @@ -0,0 +1 @@
>>> +piglit_include_target_api()
>>> diff --git a/tests/spec/nv_conservative_raster/attrib.c
>>> b/tests/spec/nv_conservative_raster/attrib.c
>>> new file mode 100644
>>> index 000000000..3e1c753d9
>>> --- /dev/null
>>> +++ b/tests/spec/nv_conservative_raster/attrib.c
>>> @@ -0,0 +1,107 @@
>>> +/*
>>> + * Copyright (c) 2018 Rhys Perry
>>> + *
>>> + * 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
>>> + * on the rights to use, copy, modify, merge, publish, distribute, sub
>>> + * license, 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
>>> + * NON-INFRINGEMENT. IN NO EVENT SHALL AUTHORS AND/OR THEIR SUPPLIERS
>>> + * 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.
>>> + */
>>> +
>>> +#include "piglit-util-gl.h"
>>> +
>>> +/**
>>> + * @file attrib.c
>>> + *
>>> + * This test verifies that glPushAttrib()/glPopAttrib() is implemented
>>> correctly
>>> + * for GL_NV_conservative_raster.
>>> + */
>>> +
>>> +static const struct piglit_subtest subtests[];
>>> +
>>> +PIGLIT_GL_TEST_CONFIG_BEGIN
>>> +
>>> + config.supports_gl_compat_version = 10;
>>> + config.subtests = subtests;
>>> +
>>> +PIGLIT_GL_TEST_CONFIG_END
>>> +
>>> +static enum piglit_result
>>> +test_enable(void* data)
>>> +{
>>> + glEnable(GL_CONSERVATIVE_RASTERIZATION_NV);
>>> + glPushAttrib(GL_ENABLE_BIT);
>>> + glDisable(GL_CONSERVATIVE_RASTERIZATION_NV);
>>> + glPopAttrib();
>>> +
>>> + return glIsEnabled(GL_CONSERVATIVE_RASTERIZATION_NV) ?
>>> PIGLIT_PASS : PIGLIT_FAIL;
>>> +}
>>> +
>>> +static enum piglit_result
>>> +test_viewport(void* data)
>>> +{
>>> + GLint biasx, biasy;
>>> +
>>> + glSubpixelPrecisionBiasNV(0, 1);
>>> + glPushAttrib(GL_VIEWPORT_BIT);
>>> + glSubpixelPrecisionBiasNV(2, 3);
>>> + glPopAttrib(GL_VIEWPORT_BIT);
>>> +
>>> + glGetIntegerv(GL_SUBPIXEL_PRECISION_BIAS_X_BITS_NV, &biasx);
>>> + glGetIntegerv(GL_SUBPIXEL_PRECISION_BIAS_Y_BITS_NV, &biasy);
>>> + return (biasx==0 && biasy==1) ? PIGLIT_PASS : PIGLIT_FAIL;
>>> +}
>>> +
>>> +static const struct piglit_subtest subtests[] = {
>>> + {
>>> + "nv_conservative_raster-enable_attrib",
>>> + "nv_conservative_raster-enable_attrib",
>>> + test_enable,
>>> + NULL
>>> + },
>>> + {
>>> + "nv_conservative_raster-viewport_attrib",
>>> + "nv_conservative_raster-viewport_attrib",
>>> + test_viewport,
>>> + NULL
>>> + },
>>> + {0},
>>> +};
>>> +
>>> +void
>>> +piglit_init(int argc, char **argv)
>>> +{
>>> + GLint max_subpixel_bits_bias;
>>> + const char **selected_subtests = NULL;
>>> + size_t num_selected_subtests = 0;
>>> +
>>> + piglit_require_extension("GL_NV_conservative_raster");
>>> +
>>> + glGetIntegerv(GL_MAX_SUBPIXEL_PRECISION_BIAS_BITS_NV,
>>> &max_subpixel_bits_bias);
>>> + if (max_subpixel_bits_bias<3)
>>> + piglit_report_result(PIGLIT_SKIP);
>>> +
>>> + num_selected_subtests =
>>> piglit_get_selected_tests(&selected_subtests);
>>> + piglit_report_result(piglit_run_selected_subtests(subtests,
>>> selected_subtests,
>>> +
>>> num_selected_subtests, PIGLIT_SKIP));
>>> +}
>>> +
>>> +enum piglit_result
>>> +piglit_display(void)
>>> +{
>>> + return PIGLIT_FAIL;
>>> +}
>>> diff --git a/tests/spec/nv_conservative_raster/dlist.c
>>> b/tests/spec/nv_conservative_raster/dlist.c
>>> new file mode 100644
>>> index 000000000..36ad85fb2
>>> --- /dev/null
>>> +++ b/tests/spec/nv_conservative_raster/dlist.c
>>> @@ -0,0 +1,110 @@
>>> +/*
>>> + * Copyright (c) 2018 Rhys Perry
>>> + *
>>> + * 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
>>> + * on the rights to use, copy, modify, merge, publish, distribute, sub
>>> + * license, 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
>>> + * NON-INFRINGEMENT. IN NO EVENT SHALL AUTHORS AND/OR THEIR SUPPLIERS
>>> + * 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.
>>> + */
>>> +
>>> +#include "piglit-util-gl.h"
>>> +
>>> +/**
>>> + * @file dlist.c
>>> + *
>>> + * This test verifies that display lists are implemented correctly for
>>> + * GL_NV_conservative_raster.
>>> + */
>>> +
>>> +static const struct piglit_subtest subtests[];
>>> +
>>> +PIGLIT_GL_TEST_CONFIG_BEGIN
>>> +
>>> + config.supports_gl_compat_version = 10;
>>> + config.subtests = subtests;
>>> +
>>> +PIGLIT_GL_TEST_CONFIG_END
>>> +
>>> +static GLuint compiled_list;
>>> +
>>> +static enum piglit_result
>>> +test_compiled(void* data)
>>> +{
>>> + GLint biasx, biasy;
>>> + glCallList(compiled_list);
>>> + glGetIntegerv(GL_SUBPIXEL_PRECISION_BIAS_X_BITS_NV, &biasx);
>>> + glGetIntegerv(GL_SUBPIXEL_PRECISION_BIAS_Y_BITS_NV, &biasy);
>>> + return (biasx==0 && biasy==1) ? PIGLIT_PASS : PIGLIT_FAIL;
>>> +}
>>> +
>>> +static enum piglit_result
>>> +test_exec(void* data)
>>> +{
>>> + GLint biasx, biasy;
>>> + glNewList(glGenLists(1), GL_COMPILE_AND_EXECUTE);
>>> + glSubpixelPrecisionBiasNV(2, 3);
>>> + glEndList();
>>> + glGetIntegerv(GL_SUBPIXEL_PRECISION_BIAS_X_BITS_NV, &biasx);
>>> + glGetIntegerv(GL_SUBPIXEL_PRECISION_BIAS_Y_BITS_NV, &biasy);
>>> + return (biasx==2 && biasy==3) ? PIGLIT_PASS : PIGLIT_FAIL;
>>> +}
>>> +
>>> +static const struct piglit_subtest subtests[] = {
>>> + {
>>> + "nv_conservative_raster-compiled_dlist",
>>> + "nv_conservative_raster-compiled_dlist",
>>> + test_compiled,
>>> + NULL
>>> + },
>>> + {
>>> + "nv_conservative_raster-exec_dlist",
>>> + "nv_conservative_raster-exec_dlist",
>>> + test_exec,
>>> + NULL
>>> + },
>>> + {0},
>>> +};
>>> +
>>> +void
>>> +piglit_init(int argc, char **argv)
>>> +{
>>> + GLint max_subpixel_bits_bias;
>>> + const char **selected_subtests = NULL;
>>> + size_t num_selected_subtests = 0;
>>> +
>>> + piglit_require_extension("GL_NV_conservative_raster");
>>> +
>>> + glGetIntegerv(GL_MAX_SUBPIXEL_PRECISION_BIAS_BITS_NV,
>>> &max_subpixel_bits_bias);
>>> + if (max_subpixel_bits_bias<3)
>>> + piglit_report_result(PIGLIT_SKIP);
>>> +
>>> + compiled_list = glGenLists(1);
>>> + glNewList(compiled_list, GL_COMPILE);
>>> + glSubpixelPrecisionBiasNV(0, 1);
>>> + glEndList();
>>> +
>>> + num_selected_subtests =
>>> piglit_get_selected_tests(&selected_subtests);
>>> + piglit_report_result(piglit_run_selected_subtests(subtests,
>>> selected_subtests,
>>> +
>>> num_selected_subtests, PIGLIT_SKIP));
>>> +}
>>> +
>>> +enum piglit_result
>>> +piglit_display(void)
>>> +{
>>> + return PIGLIT_FAIL;
>>> +}
>>> diff --git a/tests/spec/nv_conservative_raster/draw.c
>>> b/tests/spec/nv_conservative_raster/draw.c
>>> new file mode 100644
>>> index 000000000..c057fee47
>>> --- /dev/null
>>> +++ b/tests/spec/nv_conservative_raster/draw.c
>>> @@ -0,0 +1,338 @@
>>> +/*
>>> + * Copyright (c) 2018 Rhys Perry
>>> + *
>>> + * 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
>>> + * on the rights to use, copy, modify, merge, publish, distribute, sub
>>> + * license, 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
>>> + * NON-INFRINGEMENT. IN NO EVENT SHALL AUTHORS AND/OR THEIR SUPPLIERS
>>> + * 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.
>>> + */
>>> +
>>> +#include "piglit-util-gl.h"
>>> +
>>> +/**
>>> + * @file draw.c
>>> + *
>>> + * This test verifies that primitives are rasterized correctly with
>>> conservative
>>> + * rasterization enabled. It was created with a window size of 250x250
>>> in mind
>>> + * and may not work with other sizes.
>>> + *
>>> + * The test works by probing various pixels of a rendered primitive that
>>> differ
>>> + * between the image with the tested feature enabled and one with it
>>> disabled.
>>> + */
>>> +
>>> +static const struct piglit_subtest subtests[];
>>> +
>>> +PIGLIT_GL_TEST_CONFIG_BEGIN
>>> +
>>> + config.supports_gl_compat_version = 21;
>>> + config.supports_gl_es_version = 20;
>>> + config.subtests = subtests;
>>> + config.window_width = 250;
>>> + config.window_height = 250;
>>> + config.window_visual = PIGLIT_GL_VISUAL_RGB |
>>> PIGLIT_GL_VISUAL_DOUBLE;
>>> +
>>> +PIGLIT_GL_TEST_CONFIG_END
>>> +
>>> +GLuint program, buf_triangle, buf_lines, buf_point, buf_degenerate;
>>> +
>>> +static const float verts_triangle[6] = {
>>> + -0.799998779, -0.799998779,
>>> + 0.799998779, 0.799998779,
>>> + 0.799998779, -0.799998779};
>>> +
>>> +static const float verts_lines[6] = {
>>> + 0.799998779, 0.799998779,
>>> + 0.799998779, -0.799998779,
>>> + -0.799998779, -0.799998779};
>>> +
>>> +static const float verts_point[2] = {
>>> + 0.001601953, 0.001601953};
>>> +
>>> +static const float verts_degenerate[6] = {
>>> + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
>>> +
>>> +static const float white[4] = {1.0f, 1.0f, 1.0f, 1.0f};
>>> +static const float black[4] = {0.0f, 0.0f, 0.0f, 1.0f};
>>> +
>>> +static void
>>> +draw(GLenum prim)
>>> +{
>>> + glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
>>> + glClear(GL_COLOR_BUFFER_BIT);
>>> +
>>> + switch (prim) {
>>> + case GL_TRIANGLES:
>>> + glBindBuffer(GL_ARRAY_BUFFER, buf_triangle);
>>> + break;
>>> + case GL_LINE_STRIP:
>>> + glBindBuffer(GL_ARRAY_BUFFER, buf_lines);
>>> + break;
>>> + case GL_POINTS:
>>> + glBindBuffer(GL_ARRAY_BUFFER, buf_point);
>>> + break;
>>> + }
>>> + glEnableVertexAttribArray(0);
>>> + glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, (const GLvoid
>>> *)0);
>>> +
>>> + glUseProgram(program);
>>> + glDrawArrays(prim, 0, prim==GL_POINTS?1:3);
>>> +}
>>> +
>>> +static bool
>>> +test_triangle(bool conservative, bool xbias, bool ybias)
>>> +{
>>> + bool c1 = conservative ? 1 : 0;
>>> + draw(GL_TRIANGLES);
>>> + int c = 0;
>>> + if (ybias) {
>>> + c += piglit_probe_pixel_rgba(58, 25, white);
>>> + c += piglit_probe_pixel_rgba(58, 24, black);
>>> + } else {
>>> + c += piglit_probe_pixel_rgba(58, 25-c1, white);
>>> + c += piglit_probe_pixel_rgba(58, 24-c1, black);
>>> + }
>>> + if (xbias != ybias) { //precision problems mess up these probes
>>> when xbias and ybias differ
>>> + c += 2;
>>> + } else {
>>> + c += piglit_probe_pixel_rgba(180, 180+c1, white);
>>> + c += piglit_probe_pixel_rgba(180, 181+c1, black);
>>> + }
>>> + if (xbias) {
>>> + c += piglit_probe_pixel_rgba(224, 189, white);
>>> + c += piglit_probe_pixel_rgba(225, 189, black);
>>> + } else {
>>> + c += piglit_probe_pixel_rgba(224+c1, 189, white);
>>> + c += piglit_probe_pixel_rgba(225+c1, 189, black);
>>> + }
>>> + if (xbias && ybias)
>>> + c += piglit_probe_pixel_rgba(224, 24, black);
>>> + else if (xbias)
>>> + c += piglit_probe_pixel_rgba(224, 225, white);
>>> + else if (ybias)
>>> + c += piglit_probe_pixel_rgba(225, 225, black);
>>> + else
>>> + c += piglit_probe_pixel_rgba(225, 225,
>>> conservative?white:black);
>>> + return c == 7;
>>> +}
>>> +
>>> +static bool
>>> +test_lines(bool conservative, bool xbias, bool ybias)
>>> +{
>>> + int c1 = conservative ? 1 : 0;
>>> + draw(GL_LINE_STRIP);
>>> + int c = piglit_probe_pixel_rgba(224+c1, 149, white);
>>> + c += piglit_probe_pixel_rgba(225+c1, 149, black);
>>> + c += piglit_probe_pixel_rgba(100, 25-c1, white);
>>> + c += piglit_probe_pixel_rgba(100, 24-c1, black);
>>> + if (conservative) {
>>> + c += piglit_probe_pixel_rgba(24, 24, xbias?black:white);
>>> + c += piglit_probe_pixel_rgba(225, 225,
>>> ybias?black:white);
>>> + c += piglit_probe_pixel_rgba(225, 24,
>>> (xbias&&ybias)?black:white);
>>> + } else {
>>> + c += 3;
>>> + }
>>> + return c == 7;
>>> +}
>>> +
>>> +static bool
>>> +test_line_stipple()
>>> +{
>>> + draw(GL_LINE_STRIP);
>>> + return piglit_probe_pixel_rgba(26, 25, white);
>>> +}
>>> +
>>> +static bool
>>> +test_point(bool conservative, bool _0, bool _1)
>>> +{
>>> + draw(GL_POINTS);
>>> + int c = 0;
>>> + if (conservative) {
>>> + c += piglit_probe_pixel_rgba(124, 128, white);
>>> + c += piglit_probe_pixel_rgba(124, 129, black);
>>> + c += piglit_probe_pixel_rgba(128, 124, white);
>>> + c += piglit_probe_pixel_rgba(129, 124, black);
>>> + } else {
>>> + c += piglit_probe_pixel_rgba(123, 123, white);
>>> + c += piglit_probe_pixel_rgba(122, 123, black);
>>> + c += piglit_probe_pixel_rgba(125, 127, white);
>>> + c += piglit_probe_pixel_rgba(125, 128, black);
>>> + }
>>> + return c == 4;
>>> +}
>>> +
>>> +static enum piglit_result
>>> +test(const char* data)
>>> +{
>>> + bool bias[2] = {strstr(data, "x"), strstr(data, "y")};
>>> + bool conservative = strstr(data, "c");
>>> + bool pass = false;
>>> +
>>> + //Workaround for when normal_line renders slightly differently with
>>> -fbo
>>> + //(like with test_triangle()'s precision problems when xbias!=ybias)
>>> + if (strcmp(data, "l")==0 && piglit_use_fbo)
>>> + return PIGLIT_SKIP;
>>> +
>>> + if (conservative)
>>> + glEnable(GL_CONSERVATIVE_RASTERIZATION_NV);
>>> + else
>>> + glDisable(GL_CONSERVATIVE_RASTERIZATION_NV);
>>> + #if PIGLIT_USE_OPENGL
>>> + if (strstr(data, "s")) {
>>> + glEnable(GL_BLEND);
>>> + glEnable(GL_POLYGON_SMOOTH);
>>> + glEnable(GL_LINE_SMOOTH);
>>> + glEnable(GL_POINT_SMOOTH);
>>> + } else {
>>> + glDisable(GL_BLEND);
>>> + glDisable(GL_POLYGON_SMOOTH);
>>> + glDisable(GL_LINE_SMOOTH);
>>> + glDisable(GL_POINT_SMOOTH);
>>> + }
>>> + if (strstr(data, "i"))
>>> + glEnable(GL_LINE_STIPPLE);
>>> + else
>>> + glDisable(GL_LINE_STIPPLE);
>>> + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
>>> + glLineStipple(3, 0xaaaa);
>>> + glPointSize(5.0);
>>> + #endif
>>> +
>>> + glSubpixelPrecisionBiasNV(bias[0]?8:0, bias[1]?8:0);
>>> +
>>> + if (strstr(data, "t"))
>>> + pass = test_triangle(conservative, bias[0], bias[1]);
>>> + else if (strstr(data, "l"))
>>> + pass = test_lines(conservative, bias[0], bias[1]);
>>> + else if (strstr(data, "p"))
>>> + pass = test_point(conservative, bias[0], bias[1]);
>>> + else if (strstr(data, "i"))
>>> + pass = test_line_stipple();
>>> +
>>> + return pass ? PIGLIT_PASS : PIGLIT_FAIL;
>>> +}
>>> +
>>> +static enum piglit_result
>>> +test_degenerate(void* data)
>>> +{
>>> + glEnable(GL_CONSERVATIVE_RASTERIZATION_NV);
>>> + glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
>>> + glClear(GL_COLOR_BUFFER_BIT);
>>> +
>>> + glBindBuffer(GL_ARRAY_BUFFER, buf_degenerate);
>>> + glEnableVertexAttribArray(0);
>>> + glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, (const GLvoid
>>> *)0);
>>> +
>>> + glUseProgram(program);
>>> + glDrawArrays(GL_TRIANGLES, 0, 3);
>>> +
>>> + return piglit_probe_pixel_rgba(125, 125, black) ? PIGLIT_PASS :
>>> PIGLIT_FAIL;
>>> +}
>>> +
>>> +//test data:
>>> +//t=triangle, l=line, p=point i=line stipple
>>> +//s=smooth, c=conservative, x=xbias, y=ybias
>>> +static const struct piglit_subtest subtests[] = {
>>> +#define ST(name, data) {\
>>> + "nv_conservative_raster-"name,\
>>> + "nv_conservative_raster-"name,\
>>> + (enum piglit_result(*)(void*))&test,\
>>> + data\
>>> + },
>>> + ST("normal_triangle", "t")
>>> + ST("bias00_triangle", "tc")
>>> + ST("bias80_triangle", "tcx")
>>> + ST("bias08_triangle", "tcy")
>>> + ST("bias88_triangle", "tcxy")
>>> +#if PIGLIT_USE_OPENGL
>>> + ST("smooth_triangle", "tsc")
>>> +#endif
>>> + ST("normal_line", "l")
>>> + ST("bias00_line", "lc")
>>> + ST("bias80_line", "lcx")
>>> + ST("bias08_line", "lcy")
>>> + ST("bias88_line", "lcxy")
>>> +#if PIGLIT_USE_OPENGL
>>> + ST("smooth_line", "lsc")
>>> + ST("stipple_line", "ic")
>>> + ST("normal_point", "p")
>>> + ST("bias00_point", "pc")
>>> + ST("smooth_point", "psc")
>>> +#endif
>>> +#undef ST
>>> + {
>>> + "nv_conservative_raster-degenerate_triangle",
>>> + "nv_conservative_raster-degenerate_triangle",
>>> + &test_degenerate,
>>> + NULL
>>> + },
>>> + {0},
>>> +};
>>> +
>>> +void
>>> +piglit_init(int argc, char **argv)
>>> +{
>>> + GLint max_subpixel_bits_bias;
>>> + const char **selected_subtests = NULL;
>>> + size_t num_selected_subtests = 0;
>>> +
>>> + piglit_require_extension("GL_NV_conservative_raster");
>>> +
>>> + glGetIntegerv(GL_MAX_SUBPIXEL_PRECISION_BIAS_BITS_NV,
>>> &max_subpixel_bits_bias);
>>> + if (max_subpixel_bits_bias<8)
>>> + piglit_report_result(PIGLIT_SKIP);
>>> +
>>> + program = piglit_build_simple_program(
>>> +#ifdef PIGLIT_USE_OPENGL
>>> + "#version 120\n"
>>> +#else
>>> + "#version 100\n"
>>> + "precision highp float;\n"
>>> +#endif
>>> + "attribute vec2 piglit_vertex;"
>>> + "void main() { gl_Position = vec4(piglit_vertex,
>>> 0.0, 1.0); }\n",
>>> +#ifdef PIGLIT_USE_OPENGL
>>> + "#version 120\n"
>>> +#else
>>> + "#version 100\n"
>>> + "precision highp float;\n"
>>> +#endif
>>> + "void main() { gl_FragColor = vec4(1.0); }\n");
>>> +
>>> + glGenBuffers(1, &buf_triangle);
>>> + glGenBuffers(1, &buf_lines);
>>> + glGenBuffers(1, &buf_point);
>>> + glGenBuffers(1, &buf_degenerate);
>>> + glBindBuffer(GL_ARRAY_BUFFER, buf_triangle);
>>> + glBufferData(GL_ARRAY_BUFFER, sizeof(verts_triangle),
>>> verts_triangle, GL_STATIC_DRAW);
>>> + glBindBuffer(GL_ARRAY_BUFFER, buf_lines);
>>> + glBufferData(GL_ARRAY_BUFFER, sizeof(verts_lines), verts_lines,
>>> GL_STATIC_DRAW);
>>> + glBindBuffer(GL_ARRAY_BUFFER, buf_point);
>>> + glBufferData(GL_ARRAY_BUFFER, sizeof(verts_point), verts_point,
>>> GL_STATIC_DRAW);
>>> + glBindBuffer(GL_ARRAY_BUFFER, buf_degenerate);
>>> + glBufferData(GL_ARRAY_BUFFER, sizeof(verts_degenerate),
>>> verts_degenerate, GL_STATIC_DRAW);
>>> +
>>> + num_selected_subtests =
>>> piglit_get_selected_tests(&selected_subtests);
>>> + piglit_report_result(piglit_run_selected_subtests(subtests,
>>> selected_subtests,
>>> +
>>> num_selected_subtests, PIGLIT_SKIP));
>>> +}
>>> +
>>> +enum piglit_result
>>> +piglit_display(void)
>>> +{
>>> + return PIGLIT_FAIL;
>>> +}
>>> diff --git a/tests/spec/nv_conservative_raster_dilate/CMakeLists.gl.txt
>>> b/tests/spec/nv_conservative_raster_dilate/CMakeLists.gl.txt
>>> new file mode 100644
>>> index 000000000..5485eb1a6
>>> --- /dev/null
>>> +++ b/tests/spec/nv_conservative_raster_dilate/CMakeLists.gl.txt
>>> @@ -0,0 +1,11 @@
>>> +include_directories(
>>> + ${GLEXT_INCLUDE_DIR}
>>> + ${OPENGL_INCLUDE_PATH}
>>> +)
>>> +
>>> +link_libraries (
>>> + piglitutil_${piglit_target_api}
>>> + ${OPENGL_gl_LIBRARY}
>>> +)
>>> +
>>> +piglit_add_executable (nv_conservative_raster_dilate-draw draw.c)
>>> diff --git a/tests/spec/nv_conservative_raster_dilate/CMakeLists.txt
>>> b/tests/spec/nv_conservative_raster_dilate/CMakeLists.txt
>>> new file mode 100644
>>> index 000000000..144a306f4
>>> --- /dev/null
>>> +++ b/tests/spec/nv_conservative_raster_dilate/CMakeLists.txt
>>> @@ -0,0 +1 @@
>>> +piglit_include_target_api()
>>> diff --git a/tests/spec/nv_conservative_raster_dilate/draw.c
>>> b/tests/spec/nv_conservative_raster_dilate/draw.c
>>> new file mode 100644
>>> index 000000000..477fe610f
>>> --- /dev/null
>>> +++ b/tests/spec/nv_conservative_raster_dilate/draw.c
>>> @@ -0,0 +1,151 @@
>>> +/*
>>> + * Copyright (c) 2018 Rhys Perry
>>> + *
>>> + * 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
>>> + * on the rights to use, copy, modify, merge, publish, distribute, sub
>>> + * license, 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
>>> + * NON-INFRINGEMENT. IN NO EVENT SHALL AUTHORS AND/OR THEIR SUPPLIERS
>>> + * 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.
>>> + */
>>> +
>>> +#include "piglit-util-gl.h"
>>> +
>>> +/**
>>> + * @file draw.c
>>> + *
>>> + * This test verifies that primitive dialation is implemented correctly
>>> + * for GL_NV_conservative_raster_dilate. It was created with a window
>>> size of
>>> + * 250x250 in mind and may not work with other sizes.
>>> + *
>>> + * The test works by probing various pixels of a rendered primitive that
>>> differ
>>> + * between the image with the tested feature enabled and one with it
>>> disabled.
>>> + */
>>> +
>>> +static const struct piglit_subtest subtests[];
>>> +
>>> +PIGLIT_GL_TEST_CONFIG_BEGIN
>>> +
>>> + config.supports_gl_compat_version = 21;
>>> + config.subtests = subtests;
>>> + config.window_width = 250;
>>> + config.window_height = 250;
>>> + config.window_visual = PIGLIT_GL_VISUAL_RGB |
>>> PIGLIT_GL_VISUAL_DOUBLE;
>>> +
>>> +PIGLIT_GL_TEST_CONFIG_END
>>> +
>>> +GLuint program, buf_triangle;
>>> +
>>> +static const float verts_triangle[6] = {
>>> + -0.799998779, -0.799998779,
>>> + 0.799998779, 0.799998779,
>>> + 0.799998779, -0.799998779};
>>> +
>>> +static const float white[4] = {1.0f, 1.0f, 1.0f, 1.0f};
>>> +static const float black[4] = {0.0f, 0.0f, 0.0f, 1.0f};
>>> +
>>> +static void
>>> +draw(GLenum prim)
>>> +{
>>> + glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
>>> + glClear(GL_COLOR_BUFFER_BIT);
>>> +
>>> + glUseProgram(program);
>>> + glDrawArrays(GL_TRIANGLES, 0, 3);
>>> +}
>>> +
>>> +static enum piglit_result
>>> +test(const char* data)
>>> +{
>>> + bool dilate = strcmp(data, "dilate") == 0;
>>> + int d1 = dilate ? 1 : 0;
>>> + glEnable(GL_CONSERVATIVE_RASTERIZATION_NV);
>>> +
>>> glConservativeRasterParameterfNV(GL_CONSERVATIVE_RASTER_DILATE_NV,
>>> dilate?0.75:0.0);
>>> + draw(GL_TRIANGLES);
>>> + int c = 0;
>>> +
>>> + c += piglit_probe_pixel_rgba(90-d1, 92, black);
>>> + c += piglit_probe_pixel_rgba(90-d1, 91, white);
>>> +
>>> + c += piglit_probe_pixel_rgba(179, 181+d1, black);
>>> + c += piglit_probe_pixel_rgba(180, 181+d1, white);
>>> +
>>> + c += piglit_probe_pixel_rgba(226, 119, black);
>>> + c += piglit_probe_pixel_rgba(225, 119, white);
>>> +
>>> + c += piglit_probe_pixel_rgba(130, 23, black);
>>> + c += piglit_probe_pixel_rgba(130, 24, white);
>>> +
>>> + return c==8 ? PIGLIT_PASS : PIGLIT_FAIL;
>>> +}
>>> +
>>> +static const struct piglit_subtest subtests[] = {
>>> + {
>>> + "nv_conservative_raster_dilate-normal",
>>> + "nv_conservative_raster_dilate-normal",
>>> + (enum piglit_result(*)(void*))&test,
>>> + ""
>>> + },
>>> + {
>>> + "nv_conservative_raster_dilate-dilate",
>>> + "nv_conservative_raster_dilate-dilate",
>>> + (enum piglit_result(*)(void*))&test,
>>> + "dilate"
>>> + },
>>> + {0},
>>> +};
>>> +
>>> +void
>>> +piglit_init(int argc, char **argv)
>>> +{
>>> + const char **selected_subtests = NULL;
>>> + size_t num_selected_subtests = 0;
>>> +
>>> + piglit_require_extension("GL_NV_conservative_raster_dilate");
>>> +
>>> + program = piglit_build_simple_program(
>>> +#ifdef PIGLIT_USE_OPENGL
>>> + "#version 120\n"
>>> +#else
>>> + "#version 100\n"
>>> + "precision highp float;\n"
>>> +#endif
>>> + "attribute vec2 piglit_vertex;"
>>> + "void main() { gl_Position = vec4(piglit_vertex,
>>> 0.0, 1.0); }\n",
>>> +#ifdef PIGLIT_USE_OPENGL
>>> + "#version 120\n"
>>> +#else
>>> + "#version 100\n"
>>> + "precision highp float;\n"
>>> +#endif
>>> + "void main() { gl_FragColor = vec4(1.0); }\n");
>>> +
>>> + glGenBuffers(1, &buf_triangle);
>>> + glBindBuffer(GL_ARRAY_BUFFER, buf_triangle);
>>> + glBufferData(GL_ARRAY_BUFFER, sizeof(verts_triangle),
>>> verts_triangle, GL_STATIC_DRAW);
>>> + glEnableVertexAttribArray(0);
>>> + glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, (const GLvoid
>>> *)0);
>>> +
>>> + num_selected_subtests =
>>> piglit_get_selected_tests(&selected_subtests);
>>> + piglit_report_result(piglit_run_selected_subtests(subtests,
>>> selected_subtests,
>>> +
>>> num_selected_subtests, PIGLIT_SKIP));
>>> +}
>>> +
>>> +enum piglit_result
>>> +piglit_display(void)
>>> +{
>>> + return PIGLIT_FAIL;
>>> +}
>>> diff --git
>>> a/tests/spec/nv_conservative_raster_pre_snap_triangles/CMakeLists.gl.txt
>>> b/tests/spec/nv_conservative_raster_pre_snap_triangles/CMakeLists.gl.txt
>>> new file mode 100644
>>> index 000000000..8fe798531
>>> --- /dev/null
>>> +++
>>> b/tests/spec/nv_conservative_raster_pre_snap_triangles/CMakeLists.gl.txt
>>> @@ -0,0 +1,11 @@
>>> +include_directories(
>>> + ${GLEXT_INCLUDE_DIR}
>>> + ${OPENGL_INCLUDE_PATH}
>>> +)
>>> +
>>> +link_libraries (
>>> + piglitutil_${piglit_target_api}
>>> + ${OPENGL_gl_LIBRARY}
>>> +)
>>> +
>>> +piglit_add_executable (nv_conservative_raster_pre_snap_triangles-draw
>>> draw.c)
>>> diff --git
>>> a/tests/spec/nv_conservative_raster_pre_snap_triangles/CMakeLists.gles2.txt
>>> b/tests/spec/nv_conservative_raster_pre_snap_triangles/CMakeLists.gles2.txt
>>> new file mode 100644
>>> index 000000000..9e663ce72
>>> --- /dev/null
>>> +++
>>> b/tests/spec/nv_conservative_raster_pre_snap_triangles/CMakeLists.gles2.txt
>>> @@ -0,0 +1,3 @@
>>> +link_libraries(piglitutil_${piglit_target_api})
>>> +
>>> +piglit_add_executable
>>> (nv_conservative_raster_pre_snap_triangles-draw_gles2 draw.c)
>>> diff --git
>>> a/tests/spec/nv_conservative_raster_pre_snap_triangles/CMakeLists.txt
>>> b/tests/spec/nv_conservative_raster_pre_snap_triangles/CMakeLists.txt
>>> new file mode 100644
>>> index 000000000..144a306f4
>>> --- /dev/null
>>> +++ b/tests/spec/nv_conservative_raster_pre_snap_triangles/CMakeLists.txt
>>> @@ -0,0 +1 @@
>>> +piglit_include_target_api()
>>> diff --git a/tests/spec/nv_conservative_raster_pre_snap_triangles/draw.c
>>> b/tests/spec/nv_conservative_raster_pre_snap_triangles/draw.c
>>> new file mode 100644
>>> index 000000000..1453bd514
>>> --- /dev/null
>>> +++ b/tests/spec/nv_conservative_raster_pre_snap_triangles/draw.c
>>> @@ -0,0 +1,148 @@
>>> +/*
>>> + * Copyright (c) 2018 Rhys Perry
>>> + *
>>> + * 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
>>> + * on the rights to use, copy, modify, merge, publish, distribute, sub
>>> + * license, 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
>>> + * NON-INFRINGEMENT. IN NO EVENT SHALL AUTHORS AND/OR THEIR SUPPLIERS
>>> + * 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.
>>> + */
>>> +
>>> +#include "piglit-util-gl.h"
>>> +
>>> +/**
>>> + * @file draw.c
>>> + *
>>> + * This test verifies that
>>> GL_CONSERVATIVE_RASTER_MODE_PRE_SNAP_TRIANGLES_NV is
>>> + * implemented correctly for
>>> GL_NV_conservative_raster_pre_snap_triangles. It
>>> + * was created with a window size of 250x250 in mind and may not work
>>> with
>>> + * other sizes.
>>> + *
>>> + * The test works by probing various pixels of a rendered primitive that
>>> differ
>>> + * between the image with the tested feature enabled and one with it
>>> disabled.
>>> + */
>>> +
>>> +static const struct piglit_subtest subtests[];
>>> +
>>> +PIGLIT_GL_TEST_CONFIG_BEGIN
>>> +
>>> + config.supports_gl_compat_version = 21;
>>> + config.supports_gl_es_version = 20;
>>> + config.subtests = subtests;
>>> + config.window_width = 250;
>>> + config.window_height = 250;
>>> + config.window_visual = PIGLIT_GL_VISUAL_RGB |
>>> PIGLIT_GL_VISUAL_DOUBLE;
>>> +
>>> +PIGLIT_GL_TEST_CONFIG_END
>>> +
>>> +GLuint program, buf_triangle, buf_zero;
>>> +
>>> +static const float verts_triangle[6] = {
>>> + -0.399991212, -0.799982424,
>>> + 0.799982424, 0.399991212,
>>> + 0.399991212, -0.799982424};
>>> +
>>> +static const float verts_zero[6] = {
>>> + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
>>> +
>>> +static const float white[3] = {1.0f, 1.0f, 1.0f};
>>> +static const float black[3] = {0.0f, 0.0f, 0.0f};
>>> +
>>> +static enum piglit_result
>>> +test(const char* data)
>>> +{
>>> + glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
>>> + glClear(GL_COLOR_BUFFER_BIT);
>>> +
>>> + glBindBuffer(GL_ARRAY_BUFFER, strcmp(data,
>>> "0")?buf_triangle:buf_zero);
>>> + glEnableVertexAttribArray(0);
>>> + glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, (const GLvoid
>>> *)0);
>>> +
>>> + glUseProgram(program);
>>> + glDrawArrays(GL_TRIANGLES, 0, 3);
>>> +
>>> + if (strcmp(data, "0") == 0) {
>>> + bool pass = piglit_probe_pixel_rgb(125, 125, white);
>>> + return pass ? PIGLIT_PASS : PIGLIT_FAIL;
>>> + } else {
>>> + bool pass = piglit_probe_pixel_rgb(177, 30, white);
>>> + pass = pass && piglit_probe_pixel_rgb(177, 29, black);
>>> + return pass ? PIGLIT_PASS : PIGLIT_FAIL;
>>> + }
>>> +}
>>> +
>>> +static const struct piglit_subtest subtests[] = {
>>> + {
>>> + "nv_conservative_raster_pre_snap_triangles-degenerate",
>>> + "nv_conservative_raster_pre_snap_triangles-degenerate",
>>> + (enum piglit_result(*)(void*))&test,
>>> + "0"
>>> + },
>>> + {
>>> + "nv_conservative_raster_pre_snap_triangles-normal",
>>> + "nv_conservative_raster_pre_snap_triangles-normal",
>>> + (enum piglit_result(*)(void*))&test,
>>> + ""
>>> + },
>>> + {0},
>>> +};
>>> +
>>> +void
>>> +piglit_init(int argc, char **argv)
>>> +{
>>> + const char **selected_subtests = NULL;
>>> + size_t num_selected_subtests = 0;
>>> +
>>> +
>>> piglit_require_extension("GL_NV_conservative_raster_pre_snap_triangles");
>>> +
>>> + program = piglit_build_simple_program(
>>> +#ifdef PIGLIT_USE_OPENGL
>>> + "#version 120\n"
>>> +#else
>>> + "#version 100\n"
>>> + "precision highp float;\n"
>>> +#endif
>>> + "attribute vec2 piglit_vertex;"
>>> + "void main() { gl_Position = vec4(piglit_vertex,
>>> 0.0, 1.0); }\n",
>>> +#ifdef PIGLIT_USE_OPENGL
>>> + "#version 120\n"
>>> +#else
>>> + "#version 100\n"
>>> + "precision highp float;\n"
>>> +#endif
>>> + "void main() { gl_FragColor = vec4(1.0); }\n");
>>> +
>>> + glGenBuffers(1, &buf_triangle);
>>> + glBindBuffer(GL_ARRAY_BUFFER, buf_triangle);
>>> + glBufferData(GL_ARRAY_BUFFER, sizeof(verts_triangle),
>>> verts_triangle, GL_STATIC_DRAW);
>>> + glGenBuffers(1, &buf_zero);
>>> + glBindBuffer(GL_ARRAY_BUFFER, buf_zero);
>>> + glBufferData(GL_ARRAY_BUFFER, sizeof(verts_zero), verts_zero,
>>> GL_STATIC_DRAW);
>>> +
>>> + glEnable(GL_CONSERVATIVE_RASTERIZATION_NV);
>>> + glConservativeRasterParameteriNV(GL_CONSERVATIVE_RASTER_MODE_NV,
>>> GL_CONSERVATIVE_RASTER_MODE_PRE_SNAP_TRIANGLES_NV);
>>> +
>>> + num_selected_subtests =
>>> piglit_get_selected_tests(&selected_subtests);
>>> + piglit_report_result(piglit_run_selected_subtests(subtests,
>>> selected_subtests,
>>> +
>>> num_selected_subtests, PIGLIT_SKIP));
>>> +}
>>> +
>>> +enum piglit_result
>>> +piglit_display(void)
>>> +{
>>> + return PIGLIT_FAIL;
>>> +}
>>> --
>>> 2.14.3
>>>
>> _______________________________________________
>> Piglit mailing list
>> Piglit at lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/piglit
>>
>
More information about the Piglit
mailing list