perf/pixel-rate: new pixel throughput microbenchmark
[piglit.git] / tests / spec / gl-2.0 / edgeflag.c
blob0b3b9b84a252d2906a30a84160d8252551987e2b
1 /* Copyright © 2012 Intel Corporation
3 * Permission is hereby granted, free of charge, to any person obtaining a
4 * copy of this software and associated documentation files (the "Software"),
5 * to deal in the Software without restriction, including without limitation
6 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
7 * and/or sell copies of the Software, and to permit persons to whom the
8 * Software is furnished to do so, subject to the following conditions:
10 * The above copyright notice and this permission notice (including the next
11 * paragraph) shall be included in all copies or substantial portions of the
12 * Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 * IN THE SOFTWARE.
23 /** @file edgeflag.c
25 * Test for glEdgeFlagPointerv() API working with a GLSL program enabled.
27 * The i965 driver had a bug where edge flags didn't work under GLSL.
28 * We also use both gl_Vertex and a user attribute so that edge flags
29 * sit in the middle of the list of vertex attributes and results
30 * in Mesa.
33 #include "piglit-util-gl.h"
34 #include "minmax-test.h"
36 PIGLIT_GL_TEST_CONFIG_BEGIN
38 config.supports_gl_compat_version = 10;
40 config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
41 config.khr_no_error_support = PIGLIT_NO_ERRORS;
43 PIGLIT_GL_TEST_CONFIG_END
45 static GLuint color_index;
47 enum piglit_result
48 piglit_display(void)
50 bool pass = true;
51 float green[] = {0, 1, 0, 0};
52 float clear[] = {0.5, 0.5, 0.5, 0.5};
53 struct {
54 GLfloat x, y;
55 GLfloat r, g, b, a;
56 GLboolean edgeflag;
57 } verts[] = {
58 { 1.5, 1.5, 0.0, 1.0, 0.0, 0.0, GL_TRUE },
59 { 5.5, 1.5, 0.0, 1.0, 0.0, 0.0, GL_FALSE },
60 { 5.5, 5.5, 0.0, 1.0, 0.0, 0.0, GL_TRUE },
61 { 1.5, 5.5, 0.0, 1.0, 0.0, 0.0, GL_FALSE },
64 piglit_ortho_projection(piglit_width, piglit_height, false);
66 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
68 glClearColor(0.5, 0.5, 0.5, 0.5);
69 glClear(GL_COLOR_BUFFER_BIT);
71 glColor4f(0, 1, 0, 0);
73 glVertexPointer(2, GL_FLOAT, sizeof(verts[0]), &verts[0].x);
74 glVertexAttribPointer(color_index, 4, GL_FLOAT, GL_FALSE,
75 sizeof(verts[0]), &verts[0].r);
76 glEdgeFlagPointer(sizeof(verts[0]), &verts[0].edgeflag);
77 glEnableClientState(GL_VERTEX_ARRAY);
78 glEnableVertexAttribArray(color_index);
79 glEnableClientState(GL_EDGE_FLAG_ARRAY);
81 glDrawArrays(GL_POLYGON, 0, 4);
83 pass = piglit_probe_pixel_rgba(3, 1, green) && pass;
84 pass = piglit_probe_pixel_rgba(3, 5, green) && pass;
85 pass = piglit_probe_pixel_rgba(1, 3, clear) && pass;
86 pass = piglit_probe_pixel_rgba(5, 3, clear) && pass;
88 piglit_present_results();
90 return pass ? PIGLIT_PASS : PIGLIT_FAIL;
93 const char *vs_source =
94 "attribute vec4 in_color;\n"
95 "varying vec4 color;\n"
96 "\n"
97 "void main()\n"
98 "{\n"
99 " gl_Position = ftransform();\n"
100 " color = in_color;\n"
101 "}\n";
103 const char *fs_source =
104 "varying vec4 color;\n"
105 "\n"
106 "void main()\n"
107 "{\n"
108 " gl_FragColor = color;\n"
109 "}\n";
111 void
112 piglit_init(int argc, char **argv)
114 GLuint prog;
116 prog = piglit_build_simple_program(vs_source, fs_source);
117 glUseProgram(prog);
118 color_index = glGetAttribLocation(prog, "in_color");