2 * Copyright © 2014 Advanced Micro Devices, Inc.
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
21 * DEALINGS IN THE SOFTWARE.
25 * Test if primitive restart is ignored by glDrawArraysIndirect.
27 * glspec45 says since version 20141030 primitive restart only affects
28 * glDrawElements* calls. This is supposed to be a retroactive change.
29 * (See also https://bugs.freedesktop.org/show_bug.cgi?id=93308)
32 #include "piglit-util-gl.h"
34 PIGLIT_GL_TEST_CONFIG_BEGIN
35 config
.supports_gl_compat_version
= 33;
36 config
.supports_gl_core_version
= 33;
37 config
.window_visual
= PIGLIT_GL_VISUAL_RGBA
| PIGLIT_GL_VISUAL_DOUBLE
;
38 config
.khr_no_error_support
= PIGLIT_NO_ERRORS
;
39 PIGLIT_GL_TEST_CONFIG_END
41 static const GLchar
*vstext
=
43 "attribute vec2 piglit_vertex;\n"
44 "attribute int piglit_texcoord;\n"
48 " gl_Position = vec4(piglit_vertex, 0.0, 1.0);\n"
49 " color = vec4(0.0, 1.0, 0.0, 1.0);\n"
52 static const char *fstext
=
56 " gl_FragColor = color;\n"
64 static const float green
[] = {0, 1, 0, 1};
65 enum piglit_result result
;
67 glClear(GL_COLOR_BUFFER_BIT
);
68 glDrawArraysIndirect(GL_TRIANGLES
, NULL
);
70 result
= piglit_probe_rect_rgba(0, 0, piglit_width
, piglit_height
,
72 ? PIGLIT_PASS
: PIGLIT_FAIL
;
74 piglit_present_results();
79 piglit_init(int argc
, char **argv
)
81 static const float pos
[] = {
90 static const int indices
[] = {
92 1, /* instance count */
94 0, /* start instance */
96 GLuint vao
, buf
, indirect_buf
;
98 piglit_require_gl_version(33);
99 piglit_require_extension("GL_ARB_draw_indirect");
100 prog
= piglit_build_simple_program(vstext
, fstext
);
103 glGenVertexArrays(1, &vao
);
104 glBindVertexArray(vao
);
106 glGenBuffers(1, &buf
);
107 glBindBuffer(GL_ARRAY_BUFFER
, buf
);
108 glBufferData(GL_ARRAY_BUFFER
, sizeof(pos
), pos
, GL_STATIC_DRAW
);
110 glGenBuffers(1, &indirect_buf
);
111 glBindBuffer(GL_DRAW_INDIRECT_BUFFER
, indirect_buf
);
112 glBufferData(GL_DRAW_INDIRECT_BUFFER
, sizeof(indices
), indices
,
115 glEnableVertexAttribArray(PIGLIT_ATTRIB_POS
);
116 glVertexAttribPointer(PIGLIT_ATTRIB_POS
, 2, GL_FLOAT
, 0, 0, NULL
);
118 glEnable(GL_PRIMITIVE_RESTART
);
119 glPrimitiveRestartIndex(3);