ext_gpu_shader4: add compiler tests for everything
[piglit.git] / tests / spec / arb_texture_storage_multisample / tex-storage.c
blob949be325400035fa59b757692ec9fa63fdde82ec
1 /*
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
13 * Software.
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
35 enum piglit_result
36 piglit_display(void)
38 return PIGLIT_FAIL;
41 static void
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,
54 "zero-texture");
57 static void
58 check_unsized_format(void)
60 /* attempting to call TexStorage*Multisample with an unsized internalformat
61 * must fail with INVALID_ENUM
64 GLuint tex;
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,
74 "unsized-format");
77 static void
78 check_immutable(void)
80 GLuint tex;
81 GLint param;
82 GLint max_samples;
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");
95 return;
98 /* should now have TEXTURE_IMMUTABLE_FORMAT */
99 glGetTexParameteriv(GL_TEXTURE_2D_MULTISAMPLE,
100 GL_TEXTURE_IMMUTABLE_FORMAT, &param);
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");
105 return;
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");
111 return;
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");
121 return;
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");
131 return;
134 piglit_report_subtest_result(PIGLIT_PASS, "immutable");
138 void
139 piglit_init(int argc, char **argv)
141 piglit_require_extension("GL_ARB_texture_storage_multisample");
143 check_zero_texture();
144 check_immutable();
145 check_unsized_format();
147 piglit_report_result(PIGLIT_SKIP);