ext_gpu_shader4: add compiler tests for everything
[piglit.git] / tests / spec / ext_framebuffer_multisample / negative-copyteximage.c
blob3f6221491ccfc102eeced6ebc57aacf4f2adb36d
1 /*
2 * Copyright © 2011 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
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 DEALINGS
21 * IN THE SOFTWARE.
24 #include "piglit-util-gl.h"
26 /**
27 * @file negative-copyteximage.c
29 * From the EXT_framebuffer_multisample spec:
31 * "Finally, the behavior of several GL operations is specified
32 * "as if the arguments were passed to CopyPixels." These
33 * operations include: CopyTex{Sub}Image*, CopyColor{Sub}Table,
34 * and CopyConvolutionFilter*. INVALID_FRAMEBUFFER_OPERATION_EXT
35 * will be generated if an attempt is made to execute one of
36 * these operations, or CopyPixels, while the object bound to
37 * READ_FRAMEBUFFER_BINDING_EXT (section 4.4) is not "framebuffer
38 * complete" (as defined in section 4.4.4.2). INVALID_OPERATION
39 * will be generated if the object bound to
40 * READ_FRAMEBUFFER_BINDING_EXT is "framebuffer complete" and the
41 * value of SAMPLE_BUFFERS is greater than zero."
43 * The Errors section says that these and ReadPixels report
44 * "INVALID_OPERATION_EXT", but that appears to be a typo.
47 PIGLIT_GL_TEST_CONFIG_BEGIN
49 config.supports_gl_compat_version = 10;
51 config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
52 config.khr_no_error_support = PIGLIT_HAS_ERRORS;
54 PIGLIT_GL_TEST_CONFIG_END
56 enum piglit_result
57 piglit_display(void)
59 /* UNREACHED */
60 return PIGLIT_FAIL;
63 void
64 piglit_init(int argc, char **argv)
66 GLint max_samples;
67 GLuint rb, fb, tex;
68 GLenum status;
69 bool pass = true;
71 piglit_require_extension("GL_EXT_framebuffer_multisample");
73 glGetIntegerv(GL_MAX_SAMPLES, &max_samples);
75 glGenFramebuffersEXT(1, &fb);
76 glBindFramebufferEXT(GL_FRAMEBUFFER, fb);
78 glGenRenderbuffersEXT(1, &rb);
79 glBindRenderbufferEXT(GL_RENDERBUFFER, rb);
80 glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER, max_samples,
81 GL_RGBA, 1, 1);
83 glFramebufferRenderbufferEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
84 GL_RENDERBUFFER, rb);
86 glDrawBuffer(GL_COLOR_ATTACHMENT0);
87 glReadBuffer(GL_COLOR_ATTACHMENT0);
89 status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER);
90 if (status != GL_FRAMEBUFFER_COMPLETE_EXT) {
91 fprintf(stderr, "FBO incomplete\n");
92 piglit_report_result(PIGLIT_FAIL);
95 glGenTextures(1, &tex);
96 glBindTexture(GL_TEXTURE_2D, tex);
98 /* Finally, the actual test! */
99 glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 1, 1, 0);
100 if (!piglit_check_gl_error(GL_INVALID_OPERATION))
101 piglit_report_result(PIGLIT_FAIL);
103 glDeleteTextures(1, &tex);
104 glDeleteRenderbuffersEXT(1, &rb);
105 glDeleteFramebuffersEXT(1, &fb);
107 piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);