fbo-mrt-alphatest: Actually require MRTs to be available.
[piglit.git] / tests / general / degenerate-prims.c
blob3001d34e586264ceacb62d74bbccb28b697269f0
1 /*
2 * Copyright © 2013 VMware, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
26 /**
27 * Test drawing primitives with too few vertices. In particular,
28 * GL_QUADS and GL_QUAD_STRIP with 3 verts seems to regress every
29 * once in a while in Mesa.
31 * Brian Paul
32 * Feb 2013
36 #include "piglit-util-gl.h"
38 PIGLIT_GL_TEST_CONFIG_BEGIN
39 config.supports_gl_compat_version = 10;
40 config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
41 config.khr_no_error_support = PIGLIT_NO_ERRORS;
42 PIGLIT_GL_TEST_CONFIG_END
44 struct test_data {
45 GLenum prim;
46 unsigned numVerts;
47 const void *verts;
50 /**
51 * Test a specific degenerate primitive.
52 * The expected outcome is that nothing will be drawn.
54 static enum piglit_result
55 test_prim(void *_data)
57 struct test_data *data = _data;
58 static const float black[] = {0, 0, 0, 0};
59 bool pass;
61 glClear(GL_COLOR_BUFFER_BIT);
63 glVertexPointer(2, GL_FLOAT, 0, data->verts);
64 glEnable(GL_VERTEX_ARRAY);
65 glDrawArrays(data->prim, 0, data->numVerts);
67 /* Nothing should have been drawn / look for all black */
68 pass = piglit_probe_rect_rgb(0, 0, piglit_width, piglit_height, black);
70 piglit_present_results();
72 piglit_report_subtest_result(pass ? PIGLIT_PASS : PIGLIT_FAIL,
73 "Primitive: %s", piglit_get_prim_name(data->prim));
75 return pass ? PIGLIT_PASS : PIGLIT_FAIL;
79 enum piglit_result
80 piglit_display(void)
82 static const float
83 verts2[2][2] = { {-1, -1}, {1, 1} },
84 verts3[3][2] = { {-1, -1}, {1, -1}, {0, 1} },
85 verts4[4][2] = { {-1, -1}, {1, -1}, {1, 1}, {-1, 1} };
86 enum piglit_result result = PIGLIT_PASS;
88 glMatrixMode(GL_PROJECTION);
89 glLoadIdentity();
90 glOrtho(-1, 1, -1, 1, -1, 1);
92 glColor3f(1, 1, 1);
94 struct test_data data[] = {
95 { GL_POINTS, 0, verts2 },
96 { GL_LINES, 1, verts2 },
97 { GL_LINE_STRIP, 1, verts2 },
98 { GL_LINE_LOOP, 1, verts2 },
99 { GL_TRIANGLES, 2, verts3 },
100 { GL_TRIANGLE_STRIP, 2, verts3 },
101 { GL_TRIANGLE_FAN, 2, verts3 },
102 { GL_QUADS, 3, verts4 },
103 { GL_QUAD_STRIP, 3, verts4 },
104 { GL_POLYGON, 2, verts4 },
107 struct piglit_subtest tests[ARRAY_SIZE(data) + 1];
108 for (int i = 0; i < ARRAY_SIZE(data); ++i) {
109 tests[i].name = piglit_get_prim_name(data[i].prim);
110 tests[i].option = "";
111 tests[i].subtest_func = test_prim;
112 tests[i].data = &data[i];
114 tests[ARRAY_SIZE(data)].name = NULL;
116 result = piglit_run_selected_subtests(tests, NULL, 0, result);
118 return result;
122 void
123 piglit_init(int argc, char **argv)
125 /* nop */