fix the spelling in whole piglit
[piglit.git] / tests / spec / arb_viewport_array / queries.c
blobaf9c20537326f1be9ef31f7df0eb0e52dc25b392
1 /*
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
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 * Author: Jon Ashburn <jon@lunarg.com>
25 /**
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
31 * correctly queried.
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
47 enum piglit_result
48 piglit_display(void)
50 return PIGLIT_FAIL;
53 void
54 piglit_init(int argc, char **argv)
56 bool pass = true;
57 GLint maxVP;
58 GLboolean scEnabled;
59 #ifdef PIGLIT_USE_OPENGL
60 GLdouble vald[4] = {0.0, 0.0, 0.0, 0.0};
61 #endif
62 GLfloat valf[4] = {0.0, 0.0, 0.0, 0.0};
63 GLint vali[4] = {0, 0, 0, 0};
64 int i;
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,
69 GL_SCISSOR_BOX};
71 #ifdef PIGLIT_USE_OPENGL
72 piglit_require_extension("GL_ARB_viewport_array");
73 #else
74 piglit_require_extension("GL_OES_viewport_array");
75 #endif
77 glGetIntegerv(GL_MAX_VIEWPORTS, &maxVP);
79 if (!piglit_khr_no_error) {
80 /**
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 queryable 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;
95 #endif
99 /**
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",
109 pass = false;
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++) {
119 scEnabled = i & 0x1;
120 if (scEnabled)
121 glEnablei(GL_SCISSOR_TEST, i);
122 else
123 glDisablei(GL_SCISSOR_TEST, i);
125 /* test can query these values */
126 for (i = 0; i < maxVP; i++) {
127 scEnabled = i & 0x1;
128 if (scEnabled != glIsEnabledi(GL_SCISSOR_TEST, i)) {
129 pass = false;
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);
142 #else
143 glDepthRangef(0.25, 0.75);
144 #endif
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]) {
152 pass = false;
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],
156 valf[2], valf[3]);
157 printf("vald[0-3] = %f %f %f %f\n", vald[0], vald[1],
158 vald[2], vald[3]);
160 #endif
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]) {
166 pass = false;
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],
170 valf[2], valf[3]);
171 printf("vali[0-3] = %d %d %d %d\n", vali[0], vali[1],
172 vali[2], vali[3]);
175 pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
177 piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);