ext_gpu_shader4: add compiler tests for everything
[piglit.git] / tests / spec / arb_texture_storage_multisample / tex-param.c
blobbc40ecc82ddf651ed18d290ec7b1fea537c80633
1 /*
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
14 * Software.
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)
40 * says:
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
50 * (29.10.2014) says:
52 * "An INVALID_ENUM error is generated if target is
53 * TEXTURE_2D_MULTISAMPLE, and pname is any sampler state from table
54 * 20.11."
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."
61 struct subtest
63 GLenum param;
64 GLint initial_value;
65 GLint value;
66 GLenum expected_error;
67 const char *label; // if null, the enum name is used as the label
68 } subtests[] =
70 /* readonly */
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" },
86 { 0 } /* sentinel */
89 enum piglit_result
90 check_subtest(struct subtest *t)
92 GLint val;
93 const char *test_name = t->label ? t->label : piglit_get_gl_enum_name(t->param);
94 GLint expected_val;
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);
101 return PIGLIT_FAIL;
104 if (t->initial_value != val) {
105 printf("parameter %s expected initially %d, got %d\n",
106 piglit_get_gl_enum_name(t->param),
107 t->initial_value,
108 val);
109 piglit_report_subtest_result(PIGLIT_FAIL, "%s", test_name);
110 return PIGLIT_FAIL;
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);
119 return PIGLIT_FAIL;
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),
129 expected_val,
130 val);
131 piglit_report_subtest_result(PIGLIT_FAIL, "%s", test_name);
132 return PIGLIT_FAIL;
135 piglit_report_subtest_result(PIGLIT_PASS, "%s", test_name);
136 return PIGLIT_PASS;
139 void
140 piglit_init(int argc, char **argv)
142 piglit_require_extension("GL_ARB_texture_storage_multisample");
145 enum piglit_result
146 piglit_display(void)
148 GLuint tex;
149 struct subtest *t;
150 enum piglit_result result = PIGLIT_PASS;
151 enum piglit_result subtest_result;
152 GLint num_samples;
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;
168 return result;