2 * Copyright © 2013 LunarG, Inc.
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
23 * Author: Jon Ashburn <jon@lunarg.com>
26 * Test valid and invalid queries using glGetFloati_v and glGetDoublei_v.
27 * NOTE: "index" parameter validity is tested in the depthrange-indices
28 * and viewport-indices tests for the glGet*i_v(). The "bounds" test
29 * does test some valid queries using glGet*i_v().
30 * Also test GL_SCISSOR_TEST default value and settable value can be
34 #include "piglit-util-gl.h"
36 PIGLIT_GL_TEST_CONFIG_BEGIN
38 config
.supports_gl_compat_version
= 32;
39 config
.supports_gl_core_version
= 32;
40 config
.supports_gl_es_version
= 31;
42 config
.window_visual
= PIGLIT_GL_VISUAL_RGBA
| PIGLIT_GL_VISUAL_DOUBLE
;
43 config
.khr_no_error_support
= PIGLIT_NO_ERRORS
;
45 PIGLIT_GL_TEST_CONFIG_END
54 piglit_init(int argc
, char **argv
)
59 #ifdef PIGLIT_USE_OPENGL
60 GLdouble vald
[4] = {0.0, 0.0, 0.0, 0.0};
62 GLfloat valf
[4] = {0.0, 0.0, 0.0, 0.0};
63 GLint vali
[4] = {0, 0, 0, 0};
65 const GLenum tokens
[] = {GL_MAX_VIEWPORTS
, GL_VIEWPORT_SUBPIXEL_BITS
,
66 GL_VIEWPORT_BOUNDS_RANGE
, GL_LAYER_PROVOKING_VERTEX
,
67 GL_VIEWPORT_INDEX_PROVOKING_VERTEX
};
68 const GLenum indexedTokens
[] = {GL_VIEWPORT
, GL_DEPTH_RANGE
,
71 #ifdef PIGLIT_USE_OPENGL
72 piglit_require_extension("GL_ARB_viewport_array");
74 piglit_require_extension("GL_OES_viewport_array");
77 glGetIntegerv(GL_MAX_VIEWPORTS
, &maxVP
);
79 if (!piglit_khr_no_error
) {
81 * Test for invalid (non-indexed "pname") parameters with
82 * GetFloati_v and GetDoublei_v
83 * NOTE: "index" parameter validity is tested in the
84 * depthrange-indices and viewport-indices tests.
85 * OpenGL 4.3 Core section 22.1 ref:
86 * "An INVALID_ENUM error is generated if target is not
87 * indexed state queriable with these commands."
89 for (i
= 0; i
< ARRAY_SIZE(tokens
); i
++) {
90 glGetFloati_v(tokens
[i
], 1, valf
);
91 pass
= piglit_check_gl_error(GL_INVALID_ENUM
) && pass
;
92 #ifdef PIGLIT_USE_OPENGL
93 glGetDoublei_v(tokens
[i
], 1, vald
);
94 pass
= piglit_check_gl_error(GL_INVALID_ENUM
) && pass
;
100 * Test default value for SCISSOR_TEST via query.
101 * OpenGL 4.3 Core section 13.6.1 ref:
102 * "Initially, the scissor test is disabled for all viewports."
104 for (i
= 0; i
< maxVP
; i
++) {
105 scEnabled
= glIsEnabledi(GL_SCISSOR_TEST
, i
);
106 if (scEnabled
== GL_TRUE
) {
107 printf("scissor test default value wrong for idx %d\n",
112 pass
= piglit_check_gl_error(GL_NO_ERROR
) && pass
;
115 * Test settable value for SCISSOR_TEST can be queried
117 /* first setup initial values */
118 for (i
= 0; i
< maxVP
; i
++) {
121 glEnablei(GL_SCISSOR_TEST
, i
);
123 glDisablei(GL_SCISSOR_TEST
, i
);
125 /* test can query these values */
126 for (i
= 0; i
< maxVP
; i
++) {
128 if (scEnabled
!= glIsEnabledi(GL_SCISSOR_TEST
, i
)) {
130 printf("Wrong queried value for GL_SCISSOR_TEST, idx=%d\n",
136 * Test for valid "pname" parameter used with various forms of glGet.
137 * return the same data.
139 glViewport(1, 2, 30, 40);
140 #ifdef PIGLIT_USE_OPENGL
141 glDepthRange(0.25, 0.75);
143 glDepthRangef(0.25, 0.75);
145 glScissor(3, 4, 50, 60);
146 for (i
=0; i
< ARRAY_SIZE(indexedTokens
); i
++) {
147 glGetFloati_v(indexedTokens
[i
], 1, valf
);
148 #ifdef PIGLIT_USE_OPENGL
149 glGetDoublei_v(indexedTokens
[i
], 1, vald
);
150 if (valf
[0] != vald
[0] || valf
[1] != vald
[1] ||
151 valf
[2] != vald
[2] || valf
[3] != vald
[3]) {
153 printf("mismatched valf and vald for %s\n",
154 piglit_get_gl_enum_name(indexedTokens
[i
]));
155 printf("valf[0-3]= %f %f %f %f\n", valf
[0], valf
[1],
157 printf("vald[0-3] = %f %f %f %f\n", vald
[0], vald
[1],
161 glGetIntegeri_v(indexedTokens
[i
], 1, vali
);
162 if ((int) (valf
[0] + 0.5) != vali
[0] ||
163 (int) (valf
[1] + 0.5) != vali
[1] ||
164 (int) (valf
[2] + 0.5) != vali
[2] ||
165 (int) (valf
[3] + 0.5) != vali
[3]) {
167 printf("mismatched valf and vali for %s\n",
168 piglit_get_gl_enum_name(indexedTokens
[i
]));
169 printf("valf[0-3]= %f %f %f %f\n", valf
[0], valf
[1],
171 printf("vali[0-3] = %d %d %d %d\n", vali
[0], vali
[1],
175 pass
= piglit_check_gl_error(GL_NO_ERROR
) && pass
;
177 piglit_report_result(pass
? PIGLIT_PASS
: PIGLIT_FAIL
);