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
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
25 * Test that GL_DEPTH_CLAMP_FAR_AMD and GL_DEPTH_CLAMP_NEAR_AMD is a
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
42 check_all_enum_queries(GLenum e
, const char *name
, GLboolean expected
)
49 if (glIsEnabled(e
) != expected
) {
50 fprintf(stderr
, "%s was not enabled properly\n", name
);
55 if (i
!= (GLint
) expected
) {
56 fprintf(stderr
, "%s: i expected to be 0, but returned %d\n",
62 if (f
!= (GLfloat
) expected
) {
63 fprintf(stderr
, "%s: f expected to be 0.0, but returned %f\n",
70 fprintf(stderr
, "%s: b expected to be 0, but returned %d\n",
76 if (d
!= (GLdouble
) expected
) {
77 fprintf(stderr
, "%s: d expected to be 0.0, but returned %f\n",
86 piglit_init(int argc
, char **argv
)
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",
96 pass
= check_all_enum_queries(GL_DEPTH_CLAMP_FAR_AMD
,
97 "GL_DEPTH_CLAMP_FAR_AMD",
99 pass
= check_all_enum_queries(GL_DEPTH_CLAMP_NEAR_AMD
,
100 "GL_DEPTH_CLAMP_NEAR_AMD",
103 glEnable(GL_DEPTH_CLAMP_NEAR_AMD
);
104 pass
= check_all_enum_queries(GL_DEPTH_CLAMP
, "GL_DEPTH_CLAMP",
106 pass
= check_all_enum_queries(GL_DEPTH_CLAMP_FAR_AMD
,
107 "GL_DEPTH_CLAMP_FAR_AMD",
109 pass
= check_all_enum_queries(GL_DEPTH_CLAMP_NEAR_AMD
,
110 "GL_DEPTH_CLAMP_NEAR_AMD",
113 glEnable(GL_DEPTH_CLAMP_FAR_AMD
);
114 pass
= check_all_enum_queries(GL_DEPTH_CLAMP
, "GL_DEPTH_CLAMP",
116 pass
= check_all_enum_queries(GL_DEPTH_CLAMP_FAR_AMD
,
117 "GL_DEPTH_CLAMP_FAR_AMD",
119 pass
= check_all_enum_queries(GL_DEPTH_CLAMP_NEAR_AMD
,
120 "GL_DEPTH_CLAMP_NEAR_AMD",
123 glDisable(GL_DEPTH_CLAMP_NEAR_AMD
);
124 pass
= check_all_enum_queries(GL_DEPTH_CLAMP
, "GL_DEPTH_CLAMP",
126 pass
= check_all_enum_queries(GL_DEPTH_CLAMP_FAR_AMD
,
127 "GL_DEPTH_CLAMP_FAR_AMD",
129 pass
= check_all_enum_queries(GL_DEPTH_CLAMP_NEAR_AMD
,
130 "GL_DEPTH_CLAMP_NEAR_AMD",
133 glDisable(GL_DEPTH_CLAMP_FAR_AMD
);
134 pass
= check_all_enum_queries(GL_DEPTH_CLAMP
, "GL_DEPTH_CLAMP",
136 pass
= check_all_enum_queries(GL_DEPTH_CLAMP_FAR_AMD
,
137 "GL_DEPTH_CLAMP_FAR_AMD",
139 pass
= check_all_enum_queries(GL_DEPTH_CLAMP_NEAR_AMD
,
140 "GL_DEPTH_CLAMP_NEAR_AMD",
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",
152 pass
= check_all_enum_queries(GL_DEPTH_CLAMP_FAR_AMD
,
153 "GL_DEPTH_CLAMP_FAR_AMD",
155 pass
= check_all_enum_queries(GL_DEPTH_CLAMP_NEAR_AMD
,
156 "GL_DEPTH_CLAMP_NEAR_AMD",
159 glDisable(GL_DEPTH_CLAMP
);
160 pass
= check_all_enum_queries(GL_DEPTH_CLAMP
, "GL_DEPTH_CLAMP",
162 pass
= check_all_enum_queries(GL_DEPTH_CLAMP_FAR_AMD
,
163 "GL_DEPTH_CLAMP_FAR_AMD",
165 pass
= check_all_enum_queries(GL_DEPTH_CLAMP_NEAR_AMD
,
166 "GL_DEPTH_CLAMP_NEAR_AMD",
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",
174 pass
= check_all_enum_queries(GL_DEPTH_CLAMP_FAR_AMD
,
175 "GL_DEPTH_CLAMP_FAR_AMD",
177 pass
= check_all_enum_queries(GL_DEPTH_CLAMP_NEAR_AMD
,
178 "GL_DEPTH_CLAMP_NEAR_AMD",
181 piglit_report_result(pass
? PIGLIT_PASS
: PIGLIT_FAIL
);