ext_gpu_shader4: add compiler tests for everything
[piglit.git] / tests / spec / nv_conditional_render / dlist.c
blobf7759536649d27720df3519a40000489b377cc08
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 dlist.c
29 * Tests that conditional rendering appropriately affects commands
30 * inside of display lists.
33 PIGLIT_GL_TEST_CONFIG_BEGIN
35 config.supports_gl_compat_version = 10;
36 config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
37 config.khr_no_error_support = PIGLIT_NO_ERRORS;
39 PIGLIT_GL_TEST_CONFIG_END
41 enum piglit_result
42 piglit_display(void)
44 bool pass = true;
45 float green[4] = {0.0, 1.0, 0.0, 0.0};
46 GLuint q;
47 GLuint list;
49 list = glGenLists(1);
50 glNewList(list, GL_COMPILE);
51 glClearColor(0.5, 0.5, 0.5, 0.5);
52 glClear(GL_COLOR_BUFFER_BIT);
54 glGenQueries(1, &q);
56 /* Generate query pass: draw bottom half of screen. */
57 glColor4f(0.0, 1.0, 0.0, 0.0);
58 glBeginQuery(GL_SAMPLES_PASSED, q);
59 piglit_draw_rect(-1, -1, 2, 1);
60 glEndQuery(GL_SAMPLES_PASSED);
62 /* Conditional render that should draw top half of screen. */
63 glBeginConditionalRenderNV(q, GL_QUERY_WAIT_NV);
64 piglit_draw_rect(-1, 0, 2, 1);
65 glEndConditionalRenderNV();
67 /* Generate query fail */
68 glBeginQuery(GL_SAMPLES_PASSED, q);
69 glEndQuery(GL_SAMPLES_PASSED);
71 /* Conditional render that should not draw full screen. */
72 glBeginConditionalRenderNV(q, GL_QUERY_WAIT_NV);
73 glColor4f(1.0, 0.0, 0.0, 0.0);
74 piglit_draw_rect(-1, -1, 2, 2);
75 glEndConditionalRenderNV();
76 glEndList();
78 glCallList(list);
80 pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height,
81 green);
83 piglit_present_results();
85 glDeleteQueries(1, &q);
87 return pass ? PIGLIT_PASS : PIGLIT_FAIL;
90 void
91 piglit_init(int argc, char **argv)
93 piglit_require_gl_version(20);
95 piglit_require_extension("GL_NV_conditional_render");