2 * Copyright © 2014 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
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
24 * Neil Roberts <neil@linux.intel.com>
28 * \file occlusion_query_meta_save.c
30 * Verify that doing a clear (which is potentially implemented as a
31 * meta operation) doesn't reset the samples-passed count back to
35 #include "piglit-util-gl.h"
37 PIGLIT_GL_TEST_CONFIG_BEGIN
39 config
.supports_gl_compat_version
= 10;
40 config
.window_visual
= PIGLIT_GL_VISUAL_RGB
;
41 config
.khr_no_error_support
= PIGLIT_NO_ERRORS
;
43 PIGLIT_GL_TEST_CONFIG_END
47 run_test(bool scissor_clear
)
52 piglit_ortho_projection(piglit_width
, piglit_height
, GL_FALSE
);
54 glClearColor(0.0, 1.0, 0.0, 0.0);
55 glClear(GL_COLOR_BUFFER_BIT
);
57 glGenQueries(1, &query
);
59 glBeginQuery(GL_SAMPLES_PASSED
, query
);
61 /* Render 64 pixels. This should affect the query */
62 piglit_draw_rect(0, 0, 8, 8);
64 /* Clear the framebuffer. This shouldn't affect the query */
65 glClearColor(0.0, 0.0, 1.0, 0.0);
67 glScissor(0, 0, piglit_width
/ 2, piglit_height
/ 2);
68 glEnable(GL_SCISSOR_TEST
);
70 glClear(GL_COLOR_BUFFER_BIT
);
72 glDisable(GL_SCISSOR_TEST
);
75 /* Render another 64 pixels. This should continue adding to
77 piglit_draw_rect(4, 0, 8, 8);
79 glEndQuery(GL_SAMPLES_PASSED
);
81 glGetQueryObjectiv(query
, GL_QUERY_RESULT
, &result
);
83 glDeleteQueries(1, &query
);
85 piglit_present_results();
88 printf("Failure: \n");
89 printf(" Occlusion query resulted in %d samples "
92 printf(" Scissor enabled? %s\n", scissor_clear
? "yes" : "no");
102 bool pass
= run_test(false);
103 pass
= run_test(true) && pass
;
105 return pass
? PIGLIT_PASS
: PIGLIT_FAIL
;
109 piglit_init(int argc
, char **argv
)
113 piglit_require_extension("GL_ARB_occlusion_query");
115 /* It is legal for a driver to support the query API but not have
116 * any query bits. I wonder how many applications actually check for
119 glGetQueryiv(GL_SAMPLES_PASSED
, GL_QUERY_COUNTER_BITS
, &query_bits
);
121 piglit_report_result(PIGLIT_SKIP
);