ext_gpu_shader4: add compiler tests for everything
[piglit.git] / tests / spec / ext_transform_feedback / pipeline-basic-primgen.c
blob162f78dd8c824884675bdfb1f63d0bcb5f55c4a8
1 /*
2 * Copyright © 2013 Marek Olšák <maraeo@gmail.com>
3 * Copyright © 2013 Intel Corporation
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:
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.
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.
25 /**
26 * Tests if PRIMITIVES_GENERATED works with transform feedback disabled.
28 * From EXT_transform_feedback:
29 * "the primitives-generated count is incremented every time a primitive
30 * reaches the Discarding Rasterization stage"
33 #include "piglit-util-gl.h"
35 PIGLIT_GL_TEST_CONFIG_BEGIN
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;
41 PIGLIT_GL_TEST_CONFIG_END
43 static const char *vstext = "void main() { gl_Position = gl_Vertex; }";
45 void piglit_init(int argc, char **argv)
47 unsigned qresult;
48 int expected = 2;
49 GLuint vs;
50 GLuint prog;
51 GLuint q;
53 /* Check the driver. */
54 piglit_require_gl_version(15);
55 piglit_require_GLSL();
56 piglit_require_transform_feedback();
58 glGenQueries(1, &q);
60 glEnable(GL_RASTERIZER_DISCARD);
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);
71 glUseProgram(prog);
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);
79 if (qresult != expected) {
80 printf("Primitives generated: %i, Expected: %i\n",
81 qresult, expected);
82 piglit_report_result(PIGLIT_FAIL);
85 piglit_report_result(PIGLIT_PASS);
88 enum piglit_result piglit_display(void)
90 return PIGLIT_FAIL; /* should not get here */