2 * Copyright © 2013 Chris Forbes
3 * Copyright 2014 Intel Corporation
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
24 #include "piglit-util-gl.h"
26 PIGLIT_GL_TEST_CONFIG_BEGIN
28 config
.supports_gl_compat_version
= 30;
30 config
.window_visual
= PIGLIT_GL_VISUAL_RGBA
|
31 PIGLIT_GL_VISUAL_DOUBLE
;
33 config
.khr_no_error_support
= PIGLIT_HAS_ERRORS
;
35 PIGLIT_GL_TEST_CONFIG_END
37 /* Exercises GetTexParameter/TexParameter with multisample textures */
39 /* In Section 8.11 Texture Queries, the OpenGL 4.5 core spec (30.10.2014)
41 * "An INVALID_ENUM error is generated if the effective target is either
42 * TEXTURE_2D_MULTISAMPLE or TEXTURE_2D_MULTISAMPLE_ARRAY, and pname is
43 * any sampler state from table 23.18."
45 * "An INVALID_OPERATION error is generated if the effective target is
46 * either TEXTURE_2D_MULTISAMPLE or TEXTURE_2D_MULTISAMPLE_ARRAY, and
47 * pname TEXTURE_BASE_LEVEL is set to a value other than zero."
49 * Likewise, Section 8.10 Texture Queries of the OpenGL ES 3.1 spec
52 * "An INVALID_ENUM error is generated if target is
53 * TEXTURE_2D_MULTISAMPLE, and pname is any sampler state from table
56 * "An INVALID_OPERATION error is generated if target is
57 * TEXTURE_2D_MULTISAMPLE, and pname TEXTURE_BASE_LEVEL is set to a
58 * value other than zero."
66 GLenum expected_error
;
67 const char *label
; // if null, the enum name is used as the label
71 { GL_TEXTURE_IMMUTABLE_FORMAT
, GL_FALSE
, GL_TRUE
, GL_INVALID_ENUM
},
73 { GL_TEXTURE_MAG_FILTER
, GL_NEAREST
, GL_LINEAR
, GL_INVALID_ENUM
},
74 { GL_TEXTURE_MIN_FILTER
, GL_NEAREST
, GL_LINEAR
, GL_INVALID_ENUM
},
75 { GL_TEXTURE_WRAP_S
, GL_CLAMP_TO_EDGE
, GL_REPEAT
, GL_INVALID_ENUM
},
76 { GL_TEXTURE_WRAP_T
, GL_CLAMP_TO_EDGE
, GL_REPEAT
, GL_INVALID_ENUM
},
77 { GL_TEXTURE_WRAP_R
, GL_CLAMP_TO_EDGE
, GL_REPEAT
, GL_INVALID_ENUM
},
78 { GL_TEXTURE_COMPARE_MODE
, GL_NONE
, GL_COMPARE_REF_TO_TEXTURE
, GL_INVALID_ENUM
},
79 { GL_TEXTURE_COMPARE_FUNC
, GL_LEQUAL
, GL_ALWAYS
, GL_INVALID_ENUM
},
80 { GL_TEXTURE_MIN_LOD
, -1000, 0, GL_INVALID_ENUM
},
81 { GL_TEXTURE_MAX_LOD
, 1000, 0, GL_INVALID_ENUM
},
83 { GL_TEXTURE_BASE_LEVEL
, 0, 0, GL_NO_ERROR
, "GL_TEXTURE_BASE_LEVEL zero" },
84 { GL_TEXTURE_BASE_LEVEL
, 0, 1, GL_INVALID_OPERATION
, "GL_TEXTURE_BASE_LEVEL nonzero" },
90 check_subtest(struct subtest
*t
)
93 const char *test_name
= t
->label
? t
->label
: piglit_get_gl_enum_name(t
->param
);
96 glGetTexParameteriv(GL_TEXTURE_2D_MULTISAMPLE
, t
->param
, &val
);
98 if (!piglit_check_gl_error(GL_NO_ERROR
)) {
99 printf("GetTexParameteriv failed\n");
100 piglit_report_subtest_result(PIGLIT_FAIL
, "%s", test_name
);
104 if (t
->initial_value
!= val
) {
105 printf("parameter %s expected initially %d, got %d\n",
106 piglit_get_gl_enum_name(t
->param
),
109 piglit_report_subtest_result(PIGLIT_FAIL
, "%s", test_name
);
113 glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE
, t
->param
, t
->value
);
115 if (!piglit_check_gl_error(t
->expected_error
)) {
116 printf("error setting parameter %s\n",
117 piglit_get_gl_enum_name(t
->param
));
118 piglit_report_subtest_result(PIGLIT_FAIL
, "%s", test_name
);
122 /* verify that the new value stuck (or didnt, if we expected failure) */
123 glGetTexParameteriv(GL_TEXTURE_2D_MULTISAMPLE
, t
->param
, &val
);
124 expected_val
= t
->expected_error
== GL_NO_ERROR
? t
->value
: t
->initial_value
;
126 if (expected_val
!= val
) {
127 printf("after setting parameter %s expected %d, got %d\n",
128 piglit_get_gl_enum_name(t
->param
),
131 piglit_report_subtest_result(PIGLIT_FAIL
, "%s", test_name
);
135 piglit_report_subtest_result(PIGLIT_PASS
, "%s", test_name
);
140 piglit_init(int argc
, char **argv
)
142 piglit_require_extension("GL_ARB_texture_storage_multisample");
150 enum piglit_result result
= PIGLIT_PASS
;
151 enum piglit_result subtest_result
;
154 /* Use the max number of samples for testing */
155 glGetIntegerv(GL_MAX_COLOR_TEXTURE_SAMPLES
, &num_samples
);
157 glGenTextures(1, &tex
);
158 glBindTexture(GL_TEXTURE_2D_MULTISAMPLE
, tex
);
159 glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE
,
160 num_samples
, GL_RGBA
, 64, 64, GL_TRUE
);
162 for (t
= subtests
; t
->param
; t
++) {
163 subtest_result
= check_subtest(t
);
164 if (subtest_result
!= PIGLIT_PASS
)
165 result
= PIGLIT_FAIL
;