ARB_ubo/referenced-by-shader: pass if shader compiler moves UBOs between shaders
[piglit.git] / tests / spec / nv_conditional_render / bitmap.c
blobdc1c58a47552910764591bc1a736504f2eb52441
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 bitmap.c
29 * Tests that conditional rendering appropriately affects glBitmap().
31 * From the NV_conditional_render spec:
33 * "If the result (SAMPLES_PASSED) of the query is zero, all
34 * rendering commands between BeginConditionalRenderNV and the
35 * corresponding EndConditionalRenderNV are discarded. In this
36 * case, Begin, End, all vertex array commands performing an
37 * implicit Begin and End, DrawPixels (section 3.6), Bitmap
38 * (section 3.7), Clear (section 4.2.3), Accum (section 4.2.4),
39 * CopyPixels (section 4.3.3), EvalMesh1, and EvalMesh2 (section
40 * 5.1) have no effect."
43 PIGLIT_GL_TEST_CONFIG_BEGIN
45 config.supports_gl_compat_version = 10;
46 config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
47 config.khr_no_error_support = PIGLIT_NO_ERRORS;
49 PIGLIT_GL_TEST_CONFIG_END
51 enum piglit_result
52 piglit_display(void)
54 bool pass = true;
55 float green[4] = {0.0, 1.0, 0.0, 0.0};
56 void *buf;
57 GLuint q;
59 glClearColor(0.5, 0.5, 0.5, 0.5);
60 glClear(GL_COLOR_BUFFER_BIT);
62 /* Massively overallocate the bitmap, and set it to all on */
63 buf = malloc(piglit_width * piglit_height);
64 memset(buf, 0xff, piglit_width * piglit_height);
66 glGenQueries(1, &q);
68 /* Generate query pass: draw top half of screen. */
69 glColor4f(0.0, 1.0, 0.0, 0.0);
70 glBeginQuery(GL_SAMPLES_PASSED, q);
71 piglit_draw_rect(-1, 0, 2, 1);
72 glEndQuery(GL_SAMPLES_PASSED);
74 /* Conditional render that should draw the whole screen. */
75 glBeginConditionalRenderNV(q, GL_QUERY_WAIT_NV);
76 glRasterPos2i(-1, -1);
77 glBitmap(piglit_width, piglit_height, 0, 0, 0, 0, buf);
78 glEndConditionalRenderNV();
80 /* Generate query fail */
81 glBeginQuery(GL_SAMPLES_PASSED, q);
82 glEndQuery(GL_SAMPLES_PASSED);
84 /* Conditional render that should not draw full screen. */
85 glBeginConditionalRenderNV(q, GL_QUERY_WAIT_NV);
86 glColor4f(1.0, 0.0, 0.0, 0.0);
87 glRasterPos2i(-1, -1);
88 glBitmap(piglit_width, piglit_height, 0, 0, 0, 0, buf);
89 glEndConditionalRenderNV();
91 pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height,
92 green);
94 piglit_present_results();
96 glDeleteQueries(1, &q);
97 free(buf);
99 return pass ? PIGLIT_PASS : PIGLIT_FAIL;
102 void
103 piglit_init(int argc, char **argv)
105 piglit_require_gl_version(20);
107 piglit_require_extension("GL_NV_conditional_render");