fbo-mrt-alphatest: Actually require MRTs to be available.
[piglit.git] / tests / spec / ext_transform_feedback / discard-copypixels.c
blobb3c2f5fe911398331a61799d655b8ebe0ae05742
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 discard-copypixels.c
29 * Tests that GL_RASTERIZER_DISCARD appropriately affects glCopyPixels().
31 * From the EXT_transform_feedback spec:
33 * "Primitives can be optionally discarded before rasterization by
34 * calling Enable and Disable with RASTERIZER_DISCARD_EXT. When
35 * enabled, primitives are discarded right before the
36 * rasterization stage, but after the optional transform feedback
37 * stage. When disabled, primitives are passed through to the
38 * rasterization stage to be processed
39 * normally. RASTERIZER_DISCARD_EXT applies to the DrawPixels,
40 * CopyPixels, Bitmap, Clear and Accum commands as well."
43 PIGLIT_GL_TEST_CONFIG_BEGIN
45 config.supports_gl_compat_version = 10;
47 config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
48 config.khr_no_error_support = PIGLIT_NO_ERRORS;
50 PIGLIT_GL_TEST_CONFIG_END
52 enum piglit_result
53 piglit_display(void)
55 bool pass = true;
56 float green[4] = {0.0, 1.0, 0.0, 0.0};
58 /* Clear red. */
59 glClearColor(1.0, 0.0, 0.0, 0.0);
60 glClear(GL_COLOR_BUFFER_BIT);
62 /* Draw top half of screen green. */
63 glColor4f(0.0, 1.0, 0.0, 0.0);
64 piglit_draw_rect(-1, 0, 2, 1);
66 /* Discard a copy over the bottom red over the top green. */
67 glEnable(GL_RASTERIZER_DISCARD);
68 glRasterPos2i(-1, 0);
69 glCopyPixels(0, 0, piglit_width, piglit_height / 2, GL_COLOR);
71 /* Don't discard a copy of the green over the remaining red. */
72 glDisable(GL_RASTERIZER_DISCARD);
73 glRasterPos2i(-1, -1);
74 glCopyPixels(0, piglit_height / 2, piglit_width, piglit_height / 2,
75 GL_COLOR);
77 pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height, green);
79 piglit_present_results();
81 return pass ? PIGLIT_PASS : PIGLIT_FAIL;
84 void
85 piglit_init(int argc, char **argv)
87 piglit_require_transform_feedback();