ext_gpu_shader4: add compiler tests for everything
[piglit.git] / tests / spec / arb_occlusion_query / gen_delete_while_active.c
blobdf37091624978268c5632279f8320c2f20088698
1 /*
2 * Copyright © 2009,2012,2013 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.
23 * Authors:
24 * Ian Romanick <ian.d.romanick@intel.com>
25 * Carl Worth <cworth@cworth.org>
28 /**
29 * \file gen-delete-while-active.c
31 * Ensure that both glGenQueries and glDeleteQuery can be called on a
32 * new object while another query object is active. Also, that
33 * glDeleteQuery can be called on an active query object.
36 #include "piglit-util-gl.h"
38 PIGLIT_GL_TEST_CONFIG_BEGIN
40 config.supports_gl_compat_version = 10;
42 config.window_visual = PIGLIT_GL_VISUAL_RGB;
44 config.khr_no_error_support = PIGLIT_NO_ERRORS;
46 PIGLIT_GL_TEST_CONFIG_END
48 enum piglit_result
49 piglit_display(void)
51 GLuint active, inactive;
52 GLint elapsed;
54 /* Generate and start a query. */
55 glGenQueries(1, &active);
57 glBeginQuery(GL_SAMPLES_PASSED, active);
59 printf ("Testing Gen/Delete of query while another query is active.\n");
61 /* While first query is active, gen a new one. */
62 glGenQueries(1, &inactive);
64 if (!piglit_check_gl_error(GL_NO_ERROR))
65 return PIGLIT_FAIL;
67 /* Delete the inactive query. */
68 glDeleteQueries(1, &inactive);
70 if (!piglit_check_gl_error(GL_NO_ERROR))
71 return PIGLIT_FAIL;
73 /* Finish and get result from active query. */
74 glEndQuery(GL_SAMPLES_PASSED);
76 glGetQueryObjectiv(active, GL_QUERY_RESULT, &elapsed);
79 printf ("Testing Delete of currently-active query.\n");
81 /* Finally, ensure that an active query can be deleted. */
82 glGenQueries(1, &active);
84 glBeginQuery(GL_SAMPLES_PASSED, active);
86 glDeleteQueries(1, &active);
88 if (!piglit_check_gl_error(GL_NO_ERROR))
89 return PIGLIT_FAIL;
92 if (!piglit_khr_no_error) {
93 printf ("Testing that glEndQuery on deleted query (expecting error).\n");
95 /* And ensure that we get an error if we try to end a deleted
96 * query. */
97 glEndQuery(GL_SAMPLES_PASSED);
99 if (!piglit_check_gl_error(GL_INVALID_OPERATION))
100 return PIGLIT_FAIL;
104 return PIGLIT_PASS;
107 void
108 piglit_init(int argc, char **argv)
110 piglit_require_extension("GL_ARB_occlusion_query");