2 * Copyright © 2013 Chris Forbes
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.
23 #include "piglit-util-gl.h"
25 PIGLIT_GL_TEST_CONFIG_BEGIN
27 config
.supports_gl_compat_version
= 30;
29 config
.window_visual
= PIGLIT_GL_VISUAL_RGBA
| PIGLIT_GL_VISUAL_DOUBLE
;
31 config
.khr_no_error_support
= PIGLIT_HAS_ERRORS
;
33 PIGLIT_GL_TEST_CONFIG_END
42 check_zero_texture(void)
44 /* attempting to call TexStorage*Multisample on the zero texture
45 * must fail with INVALID_OPERATION
48 glBindTexture(GL_TEXTURE_2D_MULTISAMPLE
, 0);
49 glTexStorage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE
,
50 4, GL_RGBA8
, 64, 64, GL_TRUE
);
52 piglit_report_subtest_result(
53 piglit_check_gl_error(GL_INVALID_OPERATION
) ? PIGLIT_PASS
: PIGLIT_FAIL
,
58 check_unsized_format(void)
60 /* attempting to call TexStorage*Multisample with an unsized internalformat
61 * must fail with INVALID_ENUM
65 glGenTextures(1, &tex
);
66 glBindTexture(GL_TEXTURE_2D_MULTISAMPLE
, tex
);
68 glTexStorage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE
,
69 4, GL_RGBA
, 64, 64, GL_TRUE
);
71 /* unsized formats may not be used with TexStorage* */
72 piglit_report_subtest_result(
73 piglit_check_gl_error(GL_INVALID_ENUM
) ? PIGLIT_PASS
: PIGLIT_FAIL
,
84 glGetIntegerv(GL_MAX_COLOR_TEXTURE_SAMPLES
, &max_samples
);
86 glGenTextures(1, &tex
);
87 glBindTexture(GL_TEXTURE_2D_MULTISAMPLE
, tex
);
89 /* specify storage for the texture, and mark it immutable-format */
90 glTexStorage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE
,
91 max_samples
, GL_RGBA8
, 64, 64, GL_TRUE
);
93 if (!piglit_check_gl_error(GL_NO_ERROR
)) {
94 piglit_report_subtest_result(PIGLIT_FAIL
, "immutable");
98 /* should now have TEXTURE_IMMUTABLE_FORMAT */
99 glGetTexParameteriv(GL_TEXTURE_2D_MULTISAMPLE
,
100 GL_TEXTURE_IMMUTABLE_FORMAT
, ¶m
);
102 if (!piglit_check_gl_error(GL_NO_ERROR
)) {
103 printf("failed to fetch texture parameter TEXTURE_IMMUTABLE_FORMAT\n");
104 piglit_report_subtest_result(PIGLIT_FAIL
, "immutable");
108 if (param
!= GL_TRUE
) {
109 printf("expected TEXTURE_IMMUTABLE_FORMAT to be true, got %d\n", param
);
110 piglit_report_subtest_result(PIGLIT_FAIL
, "immutable");
114 /* calling TexStorage2DMultisample again on the same texture should fail */
115 glTexStorage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE
,
116 max_samples
, GL_RGBA8
, 32, 32, GL_TRUE
);
118 if (!piglit_check_gl_error(GL_INVALID_OPERATION
)) {
119 printf("expected respecifying an immutable-format texture (with TexStorage*Multisample) to fail\n");
120 piglit_report_subtest_result(PIGLIT_FAIL
, "immutable");
124 /* calling TexImage2DMultisample should fail too */
125 glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE
,
126 max_samples
, GL_RGBA8
, 32, 32, GL_TRUE
);
128 if (!piglit_check_gl_error(GL_INVALID_OPERATION
)) {
129 printf("expected respecifying an immutable-format texture (with TexImage*Multisample) to fail\n");
130 piglit_report_subtest_result(PIGLIT_FAIL
, "immutable");
134 piglit_report_subtest_result(PIGLIT_PASS
, "immutable");
139 piglit_init(int argc
, char **argv
)
141 piglit_require_extension("GL_ARB_texture_storage_multisample");
143 check_zero_texture();
145 check_unsized_format();
147 piglit_report_result(PIGLIT_SKIP
);