2 * Copyright 2015 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
21 * DEALINGS IN THE SOFTWARE.
24 /** @file create-queries.c
26 * Tests glCreateQueries to see if it behaves in the expected way, throwing
27 * the correct errors, etc.
29 * From OpenGL 4.5, section 4.2 "Query Objects and Asynchronous Queries",
32 * "void CreateQueries( enum target, sizei n, uint *ids );
34 * CreateQueries returns n previously unused query object names in ids, each
35 * representing a new query object with the specified target. target may be
36 * one of SAMPLES_PASSED, ANY_SAMPLES_PASSED, ANY_SAMPLES_PASSED_CONSERVATIVE,
37 * TIME_ELAPSED, TIMESTAMP, PRIMITIVES_GENERATED, and
38 * TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN. The initial state of the resulting
39 * query object is that the result is marked available (the value of
40 * QUERY_RESULT_AVAILABLE for the query object is TRUE) and the result
41 * value (the value of QUERY_RESULT) is zero.
44 * An INVALID_ENUM error is generated if target is not one of the targets
46 * An INVALID_VALUE error is generated if n is negative.
49 #include "piglit-util-gl.h"
50 #include "dsa-utils.h"
52 PIGLIT_GL_TEST_CONFIG_BEGIN
54 config
.supports_gl_core_version
= 31;
56 config
.window_visual
= PIGLIT_GL_VISUAL_RGBA
|
57 PIGLIT_GL_VISUAL_DOUBLE
;
58 config
.khr_no_error_support
= PIGLIT_NO_ERRORS
;
60 PIGLIT_GL_TEST_CONFIG_END
63 piglit_init(int argc
, char **argv
)
65 piglit_require_extension("GL_ARB_direct_state_access");
66 piglit_require_extension("GL_ARB_timer_query");
76 /* Throw some invalid inputs at glCreateQueries */
77 if (!piglit_khr_no_error
) {
79 glCreateQueries(GL_SAMPLES_PASSED
, -1, ids
);
80 PIGLIT_SUBTEST_ERROR(GL_INVALID_VALUE
, pass
, "n < 0");
83 glCreateQueries(GL_RGBA
, 0, ids
);
84 PIGLIT_SUBTEST_ERROR(GL_INVALID_ENUM
, pass
, "invalid target");
87 /* Throw some valid inputs at glCreateQueries. */
90 glCreateQueries(GL_SAMPLES_PASSED
, 0, NULL
);
91 PIGLIT_SUBTEST_ERROR(GL_NO_ERROR
, pass
, "n == 0");
93 /* n is more than 1 */
94 glCreateQueries(GL_SAMPLES_PASSED
, 10, ids
);
95 PIGLIT_SUBTEST_ERROR(GL_NO_ERROR
, pass
, "n > 1");
97 /* test the default state of dsa-created query objects */
98 PIGLIT_SUBTEST_CONDITION(glIsQuery(ids
[2]), pass
, "IsQuery()");
99 glGetQueryObjectiv(ids
[2], GL_QUERY_RESULT_AVAILABLE
, ¶m
);
100 piglit_check_gl_error(GL_NO_ERROR
);
101 PIGLIT_SUBTEST_CONDITION(param
== GL_TRUE
, pass
,
102 "default AVAILABLE state(%d) == TRUE", param
);
103 glGetQueryObjectiv(ids
[2], GL_QUERY_RESULT
, ¶m
);
104 piglit_check_gl_error(GL_NO_ERROR
);
105 PIGLIT_SUBTEST_CONDITION(param
== 0, pass
, "default RESULT(%d) == 0",
108 /* test the target */
109 glGetQueryObjectiv(ids
[2], GL_QUERY_TARGET
, ¶m
);
110 piglit_check_gl_error(GL_NO_ERROR
);
111 PIGLIT_SUBTEST_CONDITION(param
== GL_SAMPLES_PASSED
, pass
, "TARGET(%s) == "
112 "GL_SAMPLES_PASSED", piglit_get_gl_enum_name(param
));
115 glDeleteQueries(10, ids
);
117 return pass
? PIGLIT_PASS
: PIGLIT_FAIL
;