ARB_ubo/referenced-by-shader: pass if shader compiler moves UBOs between shaders
[piglit.git] / tests / spec / arb_draw_indirect / draw-elements-prim-restart-ugly.c
blobc78fad52bb7457cb3b29bb7726a4ade7c1f5a1eb
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 glDrawElementsIndirect interaction with primitive restart,
26 * with a weird cut index. This requires a fallback on Ivybridge. */
28 #include "piglit-util-gl.h"
30 PIGLIT_GL_TEST_CONFIG_BEGIN
32 config.supports_gl_core_version = 31;
34 config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGB;
35 config.khr_no_error_support = PIGLIT_NO_ERRORS;
37 PIGLIT_GL_TEST_CONFIG_END
39 GLuint vao;
40 GLint prog;
42 float red[] = {1,0,0};
43 float blue[] = {0,0,1};
45 enum piglit_result
46 piglit_display(void)
48 bool pass = true;
50 glViewport(0, 0, 128, 128);
52 glClearColor(0,0,1,1);
53 glClear(GL_COLOR_BUFFER_BIT);
55 glBindVertexArray(vao);
56 glPrimitiveRestartIndex(42);
57 glEnable(GL_PRIMITIVE_RESTART);
59 glUseProgram(prog);
61 glDrawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_SHORT, (GLvoid const *)0);
63 glUseProgram(0);
65 piglit_present_results();
67 pass = piglit_probe_pixel_rgb(32, 32, red) && pass;
68 pass = piglit_probe_pixel_rgb(96, 96, blue) && pass;
70 return pass ? PIGLIT_PASS : PIGLIT_FAIL;
73 float vertices_data[] = {
74 -1, -1,
75 1, -1,
76 -1, 1,
77 1, 1,
80 unsigned short indices_data[] = {
81 3, 1, 42, 0, 1, 2, 0, 42,
84 GLuint indirect_data[] = {
85 8, /* count */
86 1, /* primcount */
87 0, /* first index */
88 0, /* base vertex */
89 0, /* mbz */
92 void
93 piglit_init(int argc, char **argv)
95 GLuint vertices_bo;
96 GLuint indices_bo;
97 GLuint indirect_bo;
99 piglit_require_extension("GL_ARB_draw_indirect");
101 glGenVertexArrays(1, &vao);
102 glBindVertexArray(vao);
104 glGenBuffers(1, &vertices_bo);
105 glBindBuffer(GL_ARRAY_BUFFER, vertices_bo);
106 glBufferData(GL_ARRAY_BUFFER, sizeof(vertices_data), vertices_data, GL_STATIC_DRAW);
107 glEnableVertexAttribArray(0);
108 glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, 0);
110 glGenBuffers(1, &indices_bo);
111 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indices_bo);
112 glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices_data), indices_data, GL_STATIC_DRAW);
114 glGenBuffers(1, &indirect_bo);
115 glBindBuffer(GL_DRAW_INDIRECT_BUFFER, indirect_bo);
116 glBufferData(GL_DRAW_INDIRECT_BUFFER, sizeof(indirect_data), indirect_data, GL_STATIC_DRAW);
118 prog = piglit_build_simple_program(
119 "#version 130\n"
120 "#extension GL_ARB_explicit_attrib_location: require\n"
121 "\n"
122 "layout(location=0) in vec2 pos;\n"
123 "\n"
124 "void main() {\n"
125 " gl_Position = vec4(pos, 0, 1);\n"
126 "}\n",
128 "#version 130\n"
129 "\n"
130 "void main() {\n"
131 " gl_FragColor = vec4(1,0,0,1);\n"
132 "}\n");
134 glBindVertexArray(0);