2 * Copyright 2014 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 texture-params.c
26 * Trivially validates all the TextureParameter and GetTextureParameter entry
27 * points by setting something, then getting it.
30 #include "piglit-util-gl.h"
33 /* Copied from Mesa. TODO: How do other drivers do this? */
34 /* a close approximation: */
35 #define FLOAT_TO_INT(X) ( (GLint) (2147483647.0 * (X)) )
37 PIGLIT_GL_TEST_CONFIG_BEGIN
39 config
.supports_gl_core_version
= 31;
40 config
.supports_gl_compat_version
= 20;
42 config
.window_visual
= PIGLIT_GL_VISUAL_RGBA
|
43 PIGLIT_GL_VISUAL_DOUBLE
;
44 config
.khr_no_error_support
= PIGLIT_NO_ERRORS
;
46 PIGLIT_GL_TEST_CONFIG_END
49 piglit_init(int argc
, char **argv
)
51 piglit_require_extension("GL_ARB_direct_state_access");
60 GLfloat scalarf
= -100.0f
;
62 GLfloat colorfv
[4] = { 1.0f
, 0.2f
, 0.3f
, 0.4f
};
66 GLenum scalare
= GL_NEAREST
;
69 GLint colorIiv
[4] = {256, 50, -75, 100};
71 GLuint colorIuiv
[4] = {256, 50, 75, 100};
73 GLenum swizzle
[4] = {GL_RED
, GL_BLUE
, GL_RED
, GL_BLUE
};
76 glCreateTextures(GL_TEXTURE_2D
, 1, &name
);
79 glTextureParameterf(name
, GL_TEXTURE_MIN_LOD
, scalarf
);
80 glGetTextureParameterfv(name
, GL_TEXTURE_MIN_LOD
, ¶mf
);
81 pass
= piglit_check_gl_error(GL_NO_ERROR
) && pass
;
82 if (paramf
!= scalarf
) {
83 printf("glTextureParameterf did not correctly set "
84 "GL_TEXTURE_MIN_LOD.\n\tValue returned by "
85 "glGetTextureParameterfv was %.2f (expected %.2f).\n",
91 glTextureParameterfv(name
, GL_TEXTURE_BORDER_COLOR
, colorfv
);
92 glGetTextureParameterfv(name
, GL_TEXTURE_BORDER_COLOR
, ¶mfv
[0]);
93 pass
= piglit_check_gl_error(GL_NO_ERROR
) && pass
;
94 for (i
= 0; i
< 4; ++i
) {
95 if (paramfv
[i
] != colorfv
[i
]) {
96 printf("glTextureParameterfv did not correctly set "
97 "GL_TEXTURE_BORDER_COLOR.\n\tValue %i "
99 "glGetTextureParameterfv was %.2f "
100 "(expected %.2f).\n",
101 i
, paramfv
[i
], colorfv
[i
]);
107 glTextureParameteri(name
, GL_TEXTURE_MAX_LEVEL
, scalari
);
108 glGetTextureParameteriv(name
, GL_TEXTURE_MAX_LEVEL
, ¶mi
);
109 pass
= piglit_check_gl_error(GL_NO_ERROR
) && pass
;
110 if (parami
!= scalari
) {
111 printf("glTextureParameteri did not correctly set "
112 "GL_TEXTURE_MAX_LEVEL.\n\tValue returned by "
113 "glGetTextureParameteriv was %i "
120 glTextureParameteri(name
, GL_TEXTURE_MIN_FILTER
, scalare
);
121 glGetTextureParameterIuiv(name
, GL_TEXTURE_MIN_FILTER
, ¶me
);
122 pass
= piglit_check_gl_error(GL_NO_ERROR
) && pass
;
123 if (parame
!= scalare
) {
124 printf("glTextureParameteri did not correctly set "
125 "GL_TEXTURE_MIN_FILTER.\n\tValue returned by "
126 "glGetTextureParameterIuiv was %s "
128 piglit_get_gl_enum_name(parame
),
129 piglit_get_gl_enum_name(scalare
));
134 for (i
= 0; i
< 4; ++i
) {
135 coloriv
[i
] = FLOAT_TO_INT(colorfv
[i
]);
137 glTextureParameteriv(name
, GL_TEXTURE_BORDER_COLOR
, coloriv
);
138 glGetTextureParameterfv(name
, GL_TEXTURE_BORDER_COLOR
, ¶mfv
[0]);
139 pass
= piglit_check_gl_error(GL_NO_ERROR
) && pass
;
140 for (i
= 0; i
< 4; ++i
) {
141 if (fabs(paramfv
[i
] - colorfv
[i
]) >= piglit_tolerance
[i
]) {
142 printf("glTextureParameteriv did not correctly set "
143 "GL_TEXTURE_BORDER_COLOR.\n\tValue %i "
145 "glGetTextureParameterfv was %.2f "
146 "(expected %.2f).\n",
147 i
, paramfv
[i
], colorfv
[i
]);
153 glTextureParameterIiv(name
, GL_TEXTURE_BORDER_COLOR
, colorIiv
);
154 glGetTextureParameterIiv(name
, GL_TEXTURE_BORDER_COLOR
, ¶mIiv
[0]);
155 pass
= piglit_check_gl_error(GL_NO_ERROR
) && pass
;
156 for (i
= 0; i
< 4; ++i
) {
157 if (paramIiv
[i
] != colorIiv
[i
]) {
158 printf("glTextureParameterIiv did not correctly set "
159 "GL_TEXTURE_BORDER_COLOR.\n\tValue %i "
161 "glGetTextureParameterIiv was %i "
163 i
, paramIiv
[i
], colorIiv
[i
]);
169 glTextureParameterIuiv(name
, GL_TEXTURE_BORDER_COLOR
, colorIuiv
);
170 glGetTextureParameterIuiv(name
, GL_TEXTURE_BORDER_COLOR
,
172 pass
= piglit_check_gl_error(GL_NO_ERROR
) && pass
;
173 for (i
= 0; i
< 4; ++i
) {
174 if (paramIuiv
[i
] != colorIuiv
[i
]) {
175 printf("glTextureParameterIuiv did not correctly set "
176 "GL_TEXTURE_BORDER_COLOR.\n\tValue %i "
178 "glGetTextureParameterIuiv was %i "
180 i
, paramIuiv
[i
], colorIuiv
[i
]);
185 /* Iuiv (enum) case */
186 glTextureParameterIuiv(name
, GL_TEXTURE_SWIZZLE_RGBA
, swizzle
);
187 glGetTextureParameterIuiv(name
, GL_TEXTURE_SWIZZLE_RGBA
, ¶mse
[0]);
188 pass
= piglit_check_gl_error(GL_NO_ERROR
) && pass
;
189 for (i
= 0; i
< 4; ++i
) {
190 if (paramse
[i
] != swizzle
[i
]) {
191 printf("glTextureParameterIuiv did not correctly set "
192 "GL_TEXTURE_SWIZZLE_RGBA.\n\tValue %i "
194 "glGetTextureParameterIuiv was %s "
197 piglit_get_gl_enum_name(paramse
[i
]),
198 piglit_get_gl_enum_name(swizzle
[i
]));
204 return pass
? PIGLIT_PASS
: PIGLIT_FAIL
;