ovr_multiview: add some basic glsl tests
[piglit.git] / tests / spec / amd_depth_clamp_separate / depth-clamp-separate-status.c
blob582405d56f7ea9068c9fba1df947b006652f108a
1 /**
2 * Copyright © 2018 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
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.
24 /**
25 * Test that GL_DEPTH_CLAMP_FAR_AMD and GL_DEPTH_CLAMP_NEAR_AMD is a
26 * valid state
28 * Table 6.9 (Transformation state) of OpenGL 4.1 Core added
29 * DEPTH_CLAMP_FAR_AMD and DEPTH_CLAMP_NEAR_AMD
33 #include "piglit-util-gl.h"
35 PIGLIT_GL_TEST_CONFIG_BEGIN
37 config.supports_gl_compat_version = 10;
39 PIGLIT_GL_TEST_CONFIG_END
41 static bool
42 check_all_enum_queries(GLenum e, const char *name, GLboolean expected)
44 GLint i;
45 GLfloat f;
46 GLboolean b;
47 GLdouble d;
49 if (glIsEnabled(e) != expected) {
50 fprintf(stderr, "%s was not enabled properly\n", name);
51 return false;
54 glGetIntegerv(e, &i);
55 if (i != (GLint) expected) {
56 fprintf(stderr, "%s: i expected to be 0, but returned %d\n",
57 name, i);
58 return false;
61 glGetFloatv(e, &f);
62 if (f != (GLfloat) expected) {
63 fprintf(stderr, "%s: f expected to be 0.0, but returned %f\n",
64 name, f);
65 return false;
68 glGetBooleanv(e, &b);
69 if (b != expected) {
70 fprintf(stderr, "%s: b expected to be 0, but returned %d\n",
71 name, (int)b);
72 return false;
75 glGetDoublev(e, &d);
76 if (d != (GLdouble) expected) {
77 fprintf(stderr, "%s: d expected to be 0.0, but returned %f\n",
78 name, d);
79 return false;
82 return true;
85 void
86 piglit_init(int argc, char **argv)
88 bool pass = true;
90 piglit_require_extension("GL_AMD_depth_clamp_separate");
91 piglit_require_extension("GL_ARB_depth_clamp");
93 /* Check the initial state */
94 pass = check_all_enum_queries(GL_DEPTH_CLAMP, "GL_DEPTH_CLAMP",
95 GL_FALSE) && pass;
96 pass = check_all_enum_queries(GL_DEPTH_CLAMP_FAR_AMD,
97 "GL_DEPTH_CLAMP_FAR_AMD",
98 GL_FALSE) && pass;
99 pass = check_all_enum_queries(GL_DEPTH_CLAMP_NEAR_AMD,
100 "GL_DEPTH_CLAMP_NEAR_AMD",
101 GL_FALSE) && pass;
103 glEnable(GL_DEPTH_CLAMP_NEAR_AMD);
104 pass = check_all_enum_queries(GL_DEPTH_CLAMP, "GL_DEPTH_CLAMP",
105 GL_TRUE) && pass;
106 pass = check_all_enum_queries(GL_DEPTH_CLAMP_FAR_AMD,
107 "GL_DEPTH_CLAMP_FAR_AMD",
108 GL_FALSE) && pass;
109 pass = check_all_enum_queries(GL_DEPTH_CLAMP_NEAR_AMD,
110 "GL_DEPTH_CLAMP_NEAR_AMD",
111 GL_TRUE) && pass;
113 glEnable(GL_DEPTH_CLAMP_FAR_AMD);
114 pass = check_all_enum_queries(GL_DEPTH_CLAMP, "GL_DEPTH_CLAMP",
115 GL_TRUE) && pass;
116 pass = check_all_enum_queries(GL_DEPTH_CLAMP_FAR_AMD,
117 "GL_DEPTH_CLAMP_FAR_AMD",
118 GL_TRUE) && pass;
119 pass = check_all_enum_queries(GL_DEPTH_CLAMP_NEAR_AMD,
120 "GL_DEPTH_CLAMP_NEAR_AMD",
121 GL_TRUE) && pass;
123 glDisable(GL_DEPTH_CLAMP_NEAR_AMD);
124 pass = check_all_enum_queries(GL_DEPTH_CLAMP, "GL_DEPTH_CLAMP",
125 GL_TRUE) && pass;
126 pass = check_all_enum_queries(GL_DEPTH_CLAMP_FAR_AMD,
127 "GL_DEPTH_CLAMP_FAR_AMD",
128 GL_TRUE) && pass;
129 pass = check_all_enum_queries(GL_DEPTH_CLAMP_NEAR_AMD,
130 "GL_DEPTH_CLAMP_NEAR_AMD",
131 GL_FALSE) && pass;
133 glDisable(GL_DEPTH_CLAMP_FAR_AMD);
134 pass = check_all_enum_queries(GL_DEPTH_CLAMP, "GL_DEPTH_CLAMP",
135 GL_FALSE) && pass;
136 pass = check_all_enum_queries(GL_DEPTH_CLAMP_FAR_AMD,
137 "GL_DEPTH_CLAMP_FAR_AMD",
138 GL_FALSE) && pass;
139 pass = check_all_enum_queries(GL_DEPTH_CLAMP_NEAR_AMD,
140 "GL_DEPTH_CLAMP_NEAR_AMD",
141 GL_FALSE) && pass;
143 /* The GL_AMD_depth_clamp_separate spec says:
145 * In addition to DEPTH_CLAMP_NEAR_AMD and DEPTH_CLAMP_FAR_AMD,
146 * the token DEPTH_CLAMP may be used to simultaneously enable or
147 * disable depth clamping at both the near and far planes.
149 glEnable(GL_DEPTH_CLAMP);
150 pass = check_all_enum_queries(GL_DEPTH_CLAMP, "GL_DEPTH_CLAMP",
151 GL_TRUE) && pass;
152 pass = check_all_enum_queries(GL_DEPTH_CLAMP_FAR_AMD,
153 "GL_DEPTH_CLAMP_FAR_AMD",
154 GL_TRUE) && pass;
155 pass = check_all_enum_queries(GL_DEPTH_CLAMP_NEAR_AMD,
156 "GL_DEPTH_CLAMP_NEAR_AMD",
157 GL_TRUE) && pass;
159 glDisable(GL_DEPTH_CLAMP);
160 pass = check_all_enum_queries(GL_DEPTH_CLAMP, "GL_DEPTH_CLAMP",
161 GL_FALSE) && pass;
162 pass = check_all_enum_queries(GL_DEPTH_CLAMP_FAR_AMD,
163 "GL_DEPTH_CLAMP_FAR_AMD",
164 GL_FALSE) && pass;
165 pass = check_all_enum_queries(GL_DEPTH_CLAMP_NEAR_AMD,
166 "GL_DEPTH_CLAMP_NEAR_AMD",
167 GL_FALSE) && pass;
169 glEnable(GL_DEPTH_CLAMP_FAR_AMD);
170 glEnable(GL_DEPTH_CLAMP_NEAR_AMD);
171 glDisable(GL_DEPTH_CLAMP);
172 pass = check_all_enum_queries(GL_DEPTH_CLAMP, "GL_DEPTH_CLAMP",
173 GL_FALSE) && pass;
174 pass = check_all_enum_queries(GL_DEPTH_CLAMP_FAR_AMD,
175 "GL_DEPTH_CLAMP_FAR_AMD",
176 GL_FALSE) && pass;
177 pass = check_all_enum_queries(GL_DEPTH_CLAMP_NEAR_AMD,
178 "GL_DEPTH_CLAMP_NEAR_AMD",
179 GL_FALSE) && pass;
181 piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
184 enum piglit_result
185 piglit_display(void)
187 return PIGLIT_FAIL;