ext_gpu_shader4: add compiler tests for everything
[piglit.git] / tests / spec / arb_blend_func_extended / api / error-at-begin.c
blob7acf333968c36fe931d6ee9f4d552b86acdf887b
1 /*
2 * Copyright © 2011 Red Hat
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 /**
25 * \file error-at-begin.c
27 * \author Dave Airlie
28 * ARB_blend_func_extended states in ERRORS section
29 * "The error INVALID_OPERATION is generated by Begin or any procedure that
30 * implicitly calls Begin if any draw buffer has a blend function requiring the
31 * second color input (SRC1_COLOR, ONE_MINUS_SRC1_COLOR, SRC1_ALPHA or
32 * ONE_MINUS_SRC1_ALPHA), and a framebuffer is bound that has more than
33 * the value of MAX_DUAL_SOURCE_DRAW_BUFFERS-1 active color attachements."
35 #include "piglit-util-gl.h"
37 PIGLIT_GL_TEST_CONFIG_BEGIN
39 config.supports_gl_compat_version = 10;
40 config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
41 config.khr_no_error_support = PIGLIT_HAS_ERRORS;
43 PIGLIT_GL_TEST_CONFIG_END
45 enum piglit_result
46 piglit_display(void)
48 return PIGLIT_FAIL;
51 static GLuint fbo;
52 static GLuint max_buffers;
54 static void
55 create_fbo(void)
57 GLuint rb[32];
58 int i;
60 glGenFramebuffers(1, &fbo);
61 glBindFramebuffer(GL_FRAMEBUFFER_EXT, fbo);
63 glGenRenderbuffers(max_buffers, rb);
65 for (i = 0; i < max_buffers; i++) {
66 glBindRenderbuffer(GL_RENDERBUFFER_EXT, rb[i]);
68 glFramebufferRenderbuffer(GL_FRAMEBUFFER_EXT,
69 GL_COLOR_ATTACHMENT0 + i,
70 GL_RENDERBUFFER_EXT,
71 rb[i]);
72 glRenderbufferStorage(GL_RENDERBUFFER_EXT, GL_RGBA,
73 piglit_width, piglit_height);
77 void piglit_init(int argc, char **argv)
79 GLint max_dual_source;
80 GLenum buffers[32];
81 int i;
82 piglit_require_gl_version(30);
83 piglit_require_extension("GL_ARB_blend_func_extended");
84 piglit_require_extension("GL_ARB_draw_buffers_blend");
87 /* This test needs some number of draw buffers, so make sure the
88 * implementation isn't broken. This enables the test to generate a
89 * useful failure message.
91 glGetIntegerv(GL_MAX_DUAL_SOURCE_DRAW_BUFFERS, &max_dual_source);
92 if (max_dual_source < 1) {
93 fprintf(stderr,
94 "ARB_blend_func_extended requires GL_MAX_DUAL_SOURCE_DRAW_BUFFERS >= 1. "
95 "Only got %d!\n",
96 max_dual_source);
97 piglit_report_result(PIGLIT_FAIL);
100 max_buffers = max_dual_source + 1;
102 create_fbo();
104 for (i = 0; i < max_buffers; i++)
105 buffers[i] = GL_COLOR_ATTACHMENT0_EXT + i;
107 glDrawBuffersARB(max_buffers, buffers);
109 for (i = 0; i < max_buffers; i++) {
110 if (i >= max_dual_source)
111 glBlendFunciARB(i, GL_SRC1_ALPHA, GL_ONE_MINUS_SRC1_ALPHA);
112 else
113 glBlendFunciARB(i, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
114 glEnableIndexedEXT(GL_BLEND, i);
117 glBegin(GL_QUADS);
119 if (!piglit_check_gl_error(GL_INVALID_OPERATION))
120 piglit_report_result(PIGLIT_FAIL);
121 else
122 piglit_report_result(PIGLIT_PASS);