1 /*
2 * Copyright © 2013 Marek Olšák <maraeo@gmail.com>
3 * Copyright © 2013 Intel Corporation
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22 * IN THE SOFTWARE.
23 */
24
25 /**
26 * Tests if PRIMITIVES_GENERATED works with transform feedback disabled.
27 *
28 * From EXT_transform_feedback:
29 * "the primitives-generated count is incremented every time a primitive
30 * reaches the Discarding Rasterization stage"
31 */
32
33 #include "piglit-util-gl.h"
34
35 PIGLIT_GL_TEST_CONFIG_BEGIN
36
37 config.supports_gl_compat_version = 10;
38 config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
39 config.khr_no_error_support = PIGLIT_NO_ERRORS;
40
41 PIGLIT_GL_TEST_CONFIG_END
42
43 static const char *vstext = "void main() { gl_Position = gl_Vertex; }";
44
piglit_init(int argc,char ** argv)45 void piglit_init(int argc, char **argv)
46 {
47 unsigned qresult;
48 int expected = 2;
49 GLuint vs;
50 GLuint prog;
51 GLuint q;
52
53 /* Check the driver. */
54 piglit_require_gl_version(15);
55 piglit_require_GLSL();
56 piglit_require_transform_feedback();
57
58 glGenQueries(1, &q);
59
60 glEnable(GL_RASTERIZER_DISCARD);
61
62 /* Create shaders. */
63 vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vstext);
64 prog = glCreateProgram();
65 glAttachShader(prog, vs);
66 glLinkProgram(prog);
67 if (!piglit_link_check_status(prog)) {
68 glDeleteProgram(prog);
69 piglit_report_result(PIGLIT_FAIL);
70 }
71 glUseProgram(prog);
72
73 /* Draw a rectangle; make sure two primitives were generated. */
74 glBeginQuery(GL_PRIMITIVES_GENERATED, q);
75 piglit_draw_rect(-1, -1, 2, 2);
76 glEndQuery(GL_PRIMITIVES_GENERATED);
77 glGetQueryObjectuiv(q, GL_QUERY_RESULT, &qresult);
78
79 if (qresult != expected) {
80 printf("Primitives generated: %i, Expected: %i\n",
81 qresult, expected);
82 piglit_report_result(PIGLIT_FAIL);
83 }
84
85 piglit_report_result(PIGLIT_PASS);
86 }
87
piglit_display(void)88 enum piglit_result piglit_display(void)
89 {
90 return PIGLIT_FAIL; /* should not get here */
91 }
92