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 DEALINGS
25 * Test that when target is TEXTURE_RECTANGLE, the correct error messages are
26 * generated when certain texture parameter values are specified.
28 * Section 8.10 (Texture Parameters) of the OpenGL 4.5 Core spec (30.10.2014)
30 * "An INVALID_ENUM error is generated if the effective target is
31 * TEXTURE_RECTANGLE and either of pnames TEXTURE_WRAP_S or
32 * TEXTURE_WRAP_T is set to either MIRROR_CLAMP_TO_EDGE , MIRRORED_REPEAT
35 * "An INVALID_ENUM error is generated if the effective target is
36 * TEXTURE_RECTANGLE and pname TEXTURE_MIN_FILTER is set to a value other
37 * than NEAREST or LINEAR (no mipmap filtering is permitted)."
39 * "An INVALID_OPERATION error is generated if the effective target is
40 * TEXTURE_RECTANGLE and pname TEXTURE_BASE_LEVEL is set to any value
43 * Note that the third error condition above directly conflicts with what
44 * Section 3.8.8(Texture Parameters) of OpenGL 3.3 Core says:
46 * "When target is TEXTURE_RECTANGLE, certain texture parameter values may
47 * not be specified. In this case, the error INVALID_ENUM is generated if
48 * the TEXTURE_WRAP_S, TEXTURE_WRAP_T, or TEXTURE_WRAP_R parameter is set
49 * to REPEAT or MIRRORED_REPEAT. The error INVALID_ENUM is generated if
50 * TEXTURE_MIN_FILTER is set to a value other than NEAREST or LINEAR (no
51 * mipmap filtering is permitted). The error INVALID_VALUE is generated if
52 * TEXTURE_BASE_LEVEL is set to any value other than zero."
54 * This conflict is resolved in favor of the GL 4.5 spec because the OpenGL ES
55 * 3.1 spec (Section 8.10, Texture Queries, 29.10.2014) says:
57 * "An INVALID_OPERATION error is generated if target is
58 * TEXTURE_2D_MULTISAMPLE, and pname TEXTURE_BASE_LEVEL is set to a
59 * value other than zero."
61 * Therefore, the change from INVALID_VALUE to INVALID_OPERATION moves OpenGL
62 * toward improved consistency.
65 * The GL_ATI_texture_mirror_repeat_once spec is silent on the topic of
66 * rectangle textures, but GL_ARB_texture_mirror_clamp_to_edge says:
68 * "The error INVALID_ENUM is generated when TexParameter* is called with
69 * a target of TEXTURE_RECTANGLE and the TEXTURE_WRAP_S, TEXTURE_WRAP_T,
70 * or TEXTURE_WRAP_R parameter is set to REPEAT, MIRRORED_REPEAT, or
71 * MIRROR_CLAMP_TO_EDGE."
73 * And GL_NV_texture_mirror_clamp says:
75 * "Certain texture parameter values may not be specified for textures
76 * with a target of TEXTURE_RECTANGLE_NV. The error INVALID_ENUM is
77 * generated if the target is TEXTURE_RECTANGLE_NV and the TEXTURE_WRAP_S,
78 * TEXTURE_WRAP_T, or TEXTURE_WRAP_R parameter is set to REPEAT,
79 * MIRRORED_REPEAT_IBM, MIRROR_CLAMP_EXT, MIRROR_CLAMP_TO_EDGE_EXT, and
80 * MIRROR_CLAMP_TO_BORDER_EXT."
82 * So also verify that the GL_MIRROR_CLAMP_* values also generate
83 * GL_INVALID_ENUM. Note that we don't need to check for the extensions for
84 * this test. If the extensions are not supported, the values should generate
85 * GL_INVALID_ENUM anyway!
88 #include "piglit-util-gl.h"
90 PIGLIT_GL_TEST_CONFIG_BEGIN
92 config
.supports_gl_core_version
= 31;
93 config
.supports_gl_compat_version
= 10;
94 config
.khr_no_error_support
= PIGLIT_HAS_ERRORS
;
96 PIGLIT_GL_TEST_CONFIG_END
99 piglit_init(int argc
, char **argv
)
103 static const GLenum invalidWrapParams
[] = {
107 GL_MIRROR_CLAMP_TO_BORDER_EXT
,
109 /* This has the same value as GL_MIRROR_CLAMP_TO_EDGE, but
110 * glext.h may not be new enough. Just use the _EXT version.
112 GL_MIRROR_CLAMP_TO_EDGE_EXT
,
114 static const GLenum invalidFilterParams
[] = {
115 GL_NEAREST_MIPMAP_NEAREST
,
116 GL_NEAREST_MIPMAP_LINEAR
,
117 GL_LINEAR_MIPMAP_NEAREST
,
118 GL_LINEAR_MIPMAP_LINEAR
121 if (piglit_get_gl_version() < 33)
122 piglit_require_extension("GL_ARB_texture_rectangle");
124 /* "...the error INVALID_ENUM is generated if the TEXTURE_WRAP_S,
125 * TEXTURE_WRAP_T, or TEXTURE_WRAP_R parameter is set to REPEAT or
128 for(i
= 0; i
< ARRAY_SIZE(invalidWrapParams
); i
++) {
129 glTexParameteri(GL_TEXTURE_RECTANGLE
, GL_TEXTURE_WRAP_S
,
130 invalidWrapParams
[i
]);
131 pass
= piglit_check_gl_error(GL_INVALID_ENUM
) && pass
;
133 glTexParameteri(GL_TEXTURE_RECTANGLE
, GL_TEXTURE_WRAP_T
,
134 invalidWrapParams
[i
]);
135 pass
= piglit_check_gl_error(GL_INVALID_ENUM
) && pass
;
137 glTexParameteri(GL_TEXTURE_RECTANGLE
, GL_TEXTURE_WRAP_R
,
138 invalidWrapParams
[i
]);
139 pass
= piglit_check_gl_error(GL_INVALID_ENUM
) && pass
;
142 /* "The error INVALID_ENUM is generated if TEXTURE_MIN_FILTER is set
143 * to a value other than NEAREST or LINEAR."
145 for (i
= 0; i
< ARRAY_SIZE(invalidFilterParams
); i
++) {
146 glTexParameteri(GL_TEXTURE_RECTANGLE
, GL_TEXTURE_MIN_FILTER
,
147 invalidFilterParams
[i
]);
148 pass
= piglit_check_gl_error(GL_INVALID_ENUM
) && pass
;
151 /* "The error INVALID_OPERATION is generated if TEXTURE_BASE_LEVEL is
152 * set to any value other than zero."
154 glTexParameteri(GL_TEXTURE_RECTANGLE
, GL_TEXTURE_BASE_LEVEL
, 37);
155 pass
= piglit_check_gl_error(GL_INVALID_OPERATION
) && pass
;
157 piglit_report_result(pass
? PIGLIT_PASS
: PIGLIT_FAIL
);