cl: Correct CL_DEVICE_DOUBLE_FP_CONFIG check for OpenCL > 1.2
[piglit.git] / tests / fast_color_clear / front-buffer-distraction.c
blobe823627756786e63f44e09c30be28e1740fd1f29
1 /*
2 * Copyright © 2013 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
21 * DEALINGS IN THE SOFTWARE.
24 /**
25 * \file front-buffer-distraction.c
27 * Test that a fast color clear of the back buffer is properly
28 * resolved even if we try to "distract" the implementation by forcing
29 * a fast color clear resolve in the front buffer. This verifies that
30 * either (a) fast color clears are independently tracked between the
31 * front and back buffers, or (b) the implementation resolves fast
32 * clears before switching from back buffer rendering to front buffer
33 * rendering.
35 * The test operates by fast clearing the back buffer, then fast
36 * clearing the front buffer, then reading from the front buffer
37 * (forcing a front buffer resolve), then reading from the back buffer
38 * (forcing a back buffer resolve).
41 #include "piglit-util-gl.h"
43 PIGLIT_GL_TEST_CONFIG_BEGIN
44 config.supports_gl_compat_version = 11;
45 config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
46 config.khr_no_error_support = PIGLIT_NO_ERRORS;
47 PIGLIT_GL_TEST_CONFIG_END
50 void
51 piglit_init(int argc, char **argv)
55 enum piglit_result
56 piglit_display(void)
58 bool pass = true;
59 static const GLfloat green[] = { 0.0, 1.0, 0.0, 1.0 };
60 static const GLfloat red[] = { 1.0, 0.0, 0.0, 1.0 };
62 /* Clear the back buffer to green */
63 glClearColor(0, 1, 0, 1);
64 glClear(GL_COLOR_BUFFER_BIT);
66 /* Clear the front buffer to red */
67 glDrawBuffer(GL_FRONT);
68 glClearColor(1, 0, 0, 1);
69 glClear(GL_COLOR_BUFFER_BIT);
70 glDrawBuffer(GL_BACK);
72 /* Read from the front buffer and make sure that it's red */
73 glReadBuffer(GL_FRONT);
74 pass = piglit_probe_rect_rgba(0, 0, piglit_width,
75 piglit_height, red) && pass;
76 glReadBuffer(GL_BACK);
78 /* Read from the back buffer and make sure that it's green */
79 pass = piglit_probe_rect_rgba(0, 0, piglit_width,
80 piglit_height, green) && pass;
82 if (!piglit_check_gl_error(GL_NO_ERROR))
83 pass = false;
85 piglit_present_results();
86 return pass ? PIGLIT_PASS : PIGLIT_FAIL;