framework/replay: disable AA accounting when comparing with no tolerance
[piglit.git] / tests / spec / arb_transform_feedback2 / pause-counting.c
blob99b55f2ce8fd5b0efe99ba77c3aac44bdffb0a2c
1 /*
2 * Copyright © 2012 Intel Corporation
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 DEALINGS
21 * IN THE SOFTWARE.
24 /**
25 * \file pause-counting.c
26 * Verify behavior of XFB "counting" queries when pause and resume are used.
29 #include "piglit-util-gl.h"
31 PIGLIT_GL_TEST_CONFIG_BEGIN
33 config.supports_gl_compat_version = 10;
34 config.window_visual = PIGLIT_GL_VISUAL_RGB;
35 config.khr_no_error_support = PIGLIT_NO_ERRORS;
37 PIGLIT_GL_TEST_CONFIG_END
39 enum piglit_result
40 piglit_display(void)
42 return PIGLIT_FAIL;
45 static const float data[] = {
46 -1.0, -1.0,
47 1.0, -1.0,
48 1.0, 1.0,
49 -1.0, 1.0,
52 static const char vstext[] =
53 "varying vec4 x; void main() { gl_Position = gl_Vertex; x = vec4(0); }";
55 void piglit_init(int argc, char **argv)
57 static const char *varyings[] = {"x"};
58 GLuint id;
59 GLuint buffers[2];
60 GLuint prog;
61 GLuint vs;
62 GLuint queries[2];
63 bool pass = true;
64 GLuint generated;
65 GLuint written;
67 piglit_require_vertex_shader();
68 piglit_require_transform_feedback();
69 piglit_require_extension("GL_ARB_transform_feedback2");
71 /* This is all just the boot-strap work for the test.
73 glGenBuffers(2, buffers);
74 glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, buffers[0]);
75 glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER, 1024, NULL, GL_STREAM_READ);
77 glBindBuffer(GL_ARRAY_BUFFER, buffers[1]);
78 glBufferData(GL_ARRAY_BUFFER, sizeof(data), data, GL_STATIC_DRAW);
79 glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(GLfloat), 0);
80 glEnableVertexAttribArray(0);
82 vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vstext);
83 prog = glCreateProgram();
84 glAttachShader(prog, vs);
86 glTransformFeedbackVaryings(prog, 1, varyings, GL_INTERLEAVED_ATTRIBS);
87 glLinkProgram(prog);
88 if (!piglit_link_check_status(prog)) {
89 pass = false;
90 goto done;
93 glUseProgram(prog);
95 glGenTransformFeedbacks(1, &id);
97 glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, id);
98 glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buffers[0]);
100 glGenQueries(2, queries);
102 /* Here's the actual test. Start both kinds of query. Pause and
103 * resume transform feedback around some of the drawing. This should
104 * cause GL_PRIMITIVES_GENERATED to be larger than
105 * GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN.
107 glEnable(GL_RASTERIZER_DISCARD);
108 glBeginQuery(GL_PRIMITIVES_GENERATED, queries[0]);
109 glBeginQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, queries[1]);
110 glBeginTransformFeedback(GL_TRIANGLES);
112 glDrawArrays(GL_TRIANGLES, 0, 4);
114 glPauseTransformFeedback();
116 glDrawArrays(GL_TRIANGLES, 0, 4);
118 glResumeTransformFeedback();
120 glDrawArrays(GL_TRIANGLES, 0, 4);
122 glEndTransformFeedback();
123 glEndQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN);
124 glEndQuery(GL_PRIMITIVES_GENERATED);
126 glGetQueryObjectuiv(queries[0], GL_QUERY_RESULT, &generated);
127 glGetQueryObjectuiv(queries[1], GL_QUERY_RESULT, &written);
129 if (generated != 3) {
130 fprintf(stderr,
131 "GL_PRIMITIVES_GENERATED: "
132 "Expected %d, got %d\n",
133 3, generated);
134 pass = false;
137 if (written != 2) {
138 fprintf(stderr,
139 "GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN: "
140 "Expected %d, got %d\n",
141 2, written);
142 pass = false;
145 glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0);
147 done:
148 glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER, 0);
149 glDeleteBuffers(2, buffers);
150 glDeleteQueries(2, queries);
151 glDeleteTransformFeedbacks(1, &id);
153 glUseProgram(0);
154 glDeleteShader(vs);
155 glDeleteProgram(prog);
157 piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);