ext_gpu_shader4: add compiler tests for everything
[piglit.git] / tests / spec / arb_occlusion_query / occlusion_query_lifetime.c
blob37a15cb14469444abdca3d8f7bd9f6f8ed22cbac
1 /*
2 * Copyright © 2009,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.
23 * Authors:
24 * Ian Romanick <ian.d.romanick@intel.com>
25 * Carl Worth <cworth@cworth.org>
28 /**
29 * \file occlusion_query_lifetime.c
31 * Ensure that glIsQuery reports correct values throughout each stage
32 * of a query's lifetime.
35 #include "piglit-util-gl.h"
37 PIGLIT_GL_TEST_CONFIG_BEGIN
39 config.supports_gl_compat_version = 10;
41 config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_DEPTH;
43 PIGLIT_GL_TEST_CONFIG_END
45 /* Check is glIsQuery() for 'query' returns 'expected'
47 static bool
48 is_query_matches(GLuint query, GLboolean expected, const char *lifetime)
50 int is_query = glIsQuery(query);
52 if (is_query != expected) {
53 fprintf(stderr, "glIsQuery returned %d (expected %d) %s\n",
54 is_query, expected, lifetime);
55 return false;
58 return true;
61 enum piglit_result
62 piglit_display(void)
64 int test_pass = 1;
65 GLuint query;
66 GLint result;
68 piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
69 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
71 /* Guaranteed to be random, see: http://xkcd.com/221
73 query = 3243;
74 test_pass &= is_query_matches(query, 0, "with un-generated name");
76 glGenQueries(1, &query);
77 test_pass &= is_query_matches(query, 0, "after glGenQueries");
79 glBeginQuery(GL_SAMPLES_PASSED, query);
80 test_pass &= is_query_matches(query, 1, "after glBeginQuery");
82 /* Do a little drawing at least */
83 glColor3ub(0x00, 0xff, 0x00);
84 piglit_draw_rect(0, 0, piglit_width, piglit_height);
86 glEndQuery(GL_SAMPLES_PASSED);
87 test_pass &= is_query_matches(query, 1, "after glEndQuery");
89 glGetQueryObjectiv(query, GL_QUERY_RESULT, &result);
90 test_pass &= is_query_matches(query, 1, "after glGetQueryObjectiv");
92 glDeleteQueries(1, &query);
93 test_pass &= is_query_matches(query, 0, "after glDeleteQueries");
95 piglit_present_results();
97 return test_pass ? PIGLIT_PASS : PIGLIT_FAIL;
100 void
101 piglit_init(int argc, char **argv)
103 piglit_require_extension("GL_ARB_occlusion_query");