2 * Copyright © 2017 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
26 * Tests GL_EXT_occlusion_query_boolean extension. Test does not to cover
27 * the whole API as that is tested throughly by existing arb_occlusion_query
28 * and arb_occlusion_query2 tests. Main objective is to test that boolean
29 * query works on OpenGL ES 2.0.
32 #include "piglit-util-gl.h"
34 PIGLIT_GL_TEST_CONFIG_BEGIN
35 config
.supports_gl_es_version
= 20;
36 config
.window_visual
= PIGLIT_GL_VISUAL_RGBA
;
37 PIGLIT_GL_TEST_CONFIG_END
39 static const char vs_source
[] =
40 "attribute vec2 piglit_vertex;\n"
44 " gl_Position = vec4(piglit_vertex, 0.0, 1.0);\n"
47 static const char fs_source
[] =
50 " gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);\n"
56 GLuint query
, samples
;
59 glGenQueriesEXT(1, &query
);
61 if (!piglit_check_gl_error(GL_NO_ERROR
))
62 piglit_report_result(PIGLIT_FAIL
);
64 glBeginQueryEXT(GL_ANY_SAMPLES_PASSED_EXT
, query
);
66 if (!piglit_check_gl_error(GL_NO_ERROR
))
67 piglit_report_result(PIGLIT_FAIL
);
69 if (!glIsQueryEXT(query
))
70 piglit_report_result(PIGLIT_FAIL
);
72 glGetQueryivEXT(GL_ANY_SAMPLES_PASSED_EXT
, GL_CURRENT_QUERY_EXT
,
76 piglit_report_result(PIGLIT_FAIL
);
78 /* 0x8864 equals to ARB_occlusion_query GL_QUERY_COUNTER_BITS_ARB */
79 glGetQueryivEXT(GL_ANY_SAMPLES_PASSED_EXT
, 0x8864, ¤t
);
81 /* The error INVALID_ENUM is generated if GetQueryivEXT is called where
82 * <pname> is not CURRENT_QUERY_EXT.
84 if (!piglit_check_gl_error(GL_INVALID_ENUM
))
85 piglit_report_result(PIGLIT_FAIL
);
87 GLint prog
= piglit_build_simple_program(vs_source
, fs_source
);
90 piglit_draw_rect(-1, -1, 2, 2);
92 glDeleteProgram(prog
);
94 glEndQueryEXT(GL_ANY_SAMPLES_PASSED_EXT
);
96 if (!piglit_check_gl_error(GL_NO_ERROR
))
97 piglit_report_result(PIGLIT_FAIL
);
99 glGetQueryObjectuivEXT(query
, GL_QUERY_RESULT_EXT
, &samples
);
101 if (!piglit_check_gl_error(GL_NO_ERROR
))
102 piglit_report_result(PIGLIT_FAIL
);
105 piglit_report_result(PIGLIT_FAIL
);
108 glDeleteQueriesEXT(1, &query
);
110 if (!piglit_check_gl_error(GL_NO_ERROR
))
111 piglit_report_result(PIGLIT_FAIL
);
117 piglit_init(int argc
, char **argv
)
119 piglit_require_extension("GL_EXT_occlusion_query_boolean");