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
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
25 /* Basic test of glDrawElementsIndirect */
27 #include "piglit-util-gl.h"
29 PIGLIT_GL_TEST_CONFIG_BEGIN
31 config
.supports_gl_core_version
= 31;
33 config
.window_visual
= PIGLIT_GL_VISUAL_DOUBLE
| PIGLIT_GL_VISUAL_RGB
;
34 config
.khr_no_error_support
= PIGLIT_NO_ERRORS
;
36 PIGLIT_GL_TEST_CONFIG_END
41 float green
[] = {0,1,0};
42 float blue
[] = {0,0,1};
50 glViewport(0, 0, 128, 128);
52 glClearColor(0,0,1,1);
53 glClear(GL_COLOR_BUFFER_BIT
);
55 glBindVertexArray(vao
);
58 glDrawArraysIndirect(GL_TRIANGLE_STRIP
, (GLvoid
const *)0);
62 piglit_present_results();
64 for (i
= 0; i
< 8; i
++)
65 pass
= piglit_probe_pixel_rgb( 8 + 16 * i
, 64, green
) && pass
;
67 return pass
? PIGLIT_PASS
: PIGLIT_FAIL
;
70 float vertices_data
[] = {
77 GLuint indirect_data
[] = {
85 piglit_init(int argc
, char **argv
)
90 piglit_require_extension("GL_ARB_draw_indirect");
92 glGenVertexArrays(1, &vao
);
93 glBindVertexArray(vao
);
95 glGenBuffers(1, &vertices_bo
);
96 glBindBuffer(GL_ARRAY_BUFFER
, vertices_bo
);
97 glBufferData(GL_ARRAY_BUFFER
, sizeof(vertices_data
), vertices_data
, GL_STATIC_DRAW
);
98 glEnableVertexAttribArray(0);
99 glVertexAttribPointer(0, 2, GL_FLOAT
, GL_FALSE
, 0, 0);
101 glGenBuffers(1, &indirect_bo
);
102 glBindBuffer(GL_DRAW_INDIRECT_BUFFER
, indirect_bo
);
103 glBufferData(GL_DRAW_INDIRECT_BUFFER
, sizeof(indirect_data
), indirect_data
, GL_STATIC_DRAW
);
105 prog
= piglit_build_simple_program(
107 "#extension GL_ARB_explicit_attrib_location: require\n"
109 "layout(location=0) in vec2 pos;\n"
112 " float x = -0.875 + gl_InstanceID * 0.25 + 0.075 * pos.x;\n"
113 " float y = 0.075 * pos.y;\n"
114 " gl_Position = vec4(x, y, 0, 1);\n"
120 " gl_FragColor = vec4(0,1,0,1);\n"
123 glBindVertexArray(0);