ARB_ubo/referenced-by-shader: pass if shader compiler moves UBOs between shaders
[piglit.git] / tests / spec / arb_draw_indirect / draw-arrays-compat.c
blobfd906fe2f6ae9732c09f2f46cb1d6234a3f0ed50
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 DEALINGS
21 * IN THE SOFTWARE.
25 /* Basic test of glDrawArraysIndirect for compat profile. Test that indirect
26 * data can be passed directly when GL_DRAW_INDIRECT_BUFFER is 0 (the default
27 * value).
29 * This test is adapted from draw-arrays.c
32 #include "piglit-util-gl.h"
34 PIGLIT_GL_TEST_CONFIG_BEGIN
36 config.supports_gl_compat_version = 31;
38 config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGB;
39 config.khr_no_error_support = PIGLIT_NO_ERRORS;
41 PIGLIT_GL_TEST_CONFIG_END
43 GLuint vao;
44 GLint prog;
46 float red[] = {1,0,0};
47 float blue[] = {0,0,1};
49 float vertices_data[] = {
50 -1, -1,
51 1, -1,
52 -1, 1,
55 GLuint indirect_data[] = {
56 3, /* count */
57 1, /* primcount */
58 0, /* first vertex */
59 0, /* mbz */
62 enum piglit_result
63 piglit_display(void)
65 bool pass = true;
67 glViewport(0, 0, 128, 128);
69 glClearColor(0,0,1,1);
70 glClear(GL_COLOR_BUFFER_BIT);
72 glBindVertexArray(vao);
73 glUseProgram(prog);
75 glDrawArraysIndirect(GL_TRIANGLES, indirect_data);
77 glUseProgram(0);
79 piglit_present_results();
81 pass = piglit_probe_pixel_rgb(32, 32, red) && pass;
82 pass = piglit_probe_pixel_rgb(96, 96, blue) && pass;
84 return pass ? PIGLIT_PASS : PIGLIT_FAIL;
87 void
88 piglit_init(int argc, char **argv)
90 GLuint vertices_bo;
92 piglit_require_extension("GL_ARB_draw_indirect");
94 glGenVertexArrays(1, &vao);
95 glBindVertexArray(vao);
97 glGenBuffers(1, &vertices_bo);
98 glBindBuffer(GL_ARRAY_BUFFER, vertices_bo);
99 glBufferData(GL_ARRAY_BUFFER, sizeof(vertices_data), vertices_data, GL_STATIC_DRAW);
100 glEnableVertexAttribArray(0);
101 glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, 0);
103 prog = piglit_build_simple_program(
104 "#version 130\n"
105 "#extension GL_ARB_explicit_attrib_location: require\n"
106 "\n"
107 "layout(location=0) in vec2 pos;\n"
108 "\n"
109 "void main() {\n"
110 " gl_Position = vec4(pos, 0, 1);\n"
111 "}\n",
113 "#version 130\n"
114 "\n"
115 "void main() {\n"
116 " gl_FragColor = vec4(1,0,0,1);\n"
117 "}\n");
119 glBindVertexArray(0);