2 * Copyright © 2014 VMware, 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
21 * DEALINGS IN THE SOFTWARE.
25 * Test GL_EXT_texture_swizzle API functions.
31 #include "piglit-util-gl.h"
33 PIGLIT_GL_TEST_CONFIG_BEGIN
34 config
.supports_gl_compat_version
= 12;
35 config
.window_visual
= PIGLIT_GL_VISUAL_RGBA
| PIGLIT_GL_VISUAL_DOUBLE
;
36 config
.khr_no_error_support
= PIGLIT_NO_ERRORS
;
37 PIGLIT_GL_TEST_CONFIG_END
41 test_get(GLenum pname
, GLint expected
)
45 glGetTexParameteriv(GL_TEXTURE_2D
, pname
, &val
);
47 if (val
!= expected
) {
48 printf("glGetTexParameteriv(%s) returned %s instead of %s\n",
49 piglit_get_gl_enum_name(pname
),
50 piglit_get_gl_enum_name(val
),
51 piglit_get_gl_enum_name(expected
));
62 static const GLint swz
[4] = { GL_BLUE
, GL_GREEN
, GL_ALPHA
, GL_ZERO
};
65 if (!piglit_khr_no_error
) {
66 /* test bad param value */
67 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_SWIZZLE_R_EXT
, GL_RGBA
);
68 if (!piglit_check_gl_error(GL_INVALID_ENUM
))
72 /* test good param values */
73 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_SWIZZLE_R_EXT
, GL_ONE
);
74 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_SWIZZLE_G_EXT
, GL_ZERO
);
75 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_SWIZZLE_B_EXT
, GL_RED
);
76 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_SWIZZLE_A_EXT
, GL_BLUE
);
78 if (!piglit_check_gl_error(GL_NO_ERROR
))
81 if (!test_get(GL_TEXTURE_SWIZZLE_R_EXT
, GL_ONE
))
84 if (!test_get(GL_TEXTURE_SWIZZLE_G_EXT
, GL_ZERO
))
87 if (!test_get(GL_TEXTURE_SWIZZLE_B_EXT
, GL_RED
))
90 if (!test_get(GL_TEXTURE_SWIZZLE_A_EXT
, GL_BLUE
))
94 glTexParameteriv(GL_TEXTURE_2D
, GL_TEXTURE_SWIZZLE_RGBA_EXT
, swz
);
96 if (!piglit_check_gl_error(GL_NO_ERROR
))
99 glGetTexParameteriv(GL_TEXTURE_2D
, GL_TEXTURE_SWIZZLE_RGBA_EXT
, swzOut
);
100 if (swzOut
[0] != swz
[0] ||
101 swzOut
[1] != swz
[1] ||
102 swzOut
[2] != swz
[2] ||
103 swzOut
[3] != swz
[3]) {
104 printf("glGetTexParameteriv(GL_TEXTURE_SWIZZLE_RGBA_EXT) failed\n");
121 piglit_init(int argc
, char **argv
)
125 piglit_require_extension("GL_EXT_texture_swizzle");
128 piglit_report_result(p
? PIGLIT_PASS
: PIGLIT_FAIL
);