2 * Copyright 2017 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 * on the rights to use, copy, modify, merge, publish, distribute, sub
8 * license, and/or sell copies of the Software, and to permit persons to whom
9 * the 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 NON-INFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21 * USE OR OTHER DEALINGS IN THE SOFTWARE.
25 * Test error conditions of glMultiDrawArrays.
26 * glMultiDrawArrays is part of GL 1.4 and later.
28 * Based loosely on dlist-multidrawarrays.c.
31 #include "piglit-util-gl.h"
34 PIGLIT_GL_TEST_CONFIG_BEGIN
35 config
.supports_gl_compat_version
= 14;
36 config
.window_visual
= PIGLIT_GL_VISUAL_DOUBLE
| PIGLIT_GL_VISUAL_RGBA
;
37 config
.khr_no_error_support
= PIGLIT_HAS_ERRORS
;
38 PIGLIT_GL_TEST_CONFIG_END
41 static const float verts
[][2] = {
48 static const float zero
[] = { 0.0f
, 0.0f
, 0.0f
, 0.0f
};
51 test_draw_negative_primcount()
56 glClearColor(0.0, 0.0, 0.0, 0.0);
57 glClear(GL_COLOR_BUFFER_BIT
);
59 glEnableClientState(GL_VERTEX_ARRAY
);
60 glVertexPointer(2, GL_FLOAT
, 0, verts
);
62 /* Section 2.3.1 (Errors) of the OpenGL 4.5 (Core Profile) spec says:
64 * "Several error generation conditions are implicit in the
65 * description of every GL command.
69 * * If a negative number is provided where an argument of type
70 * sizei or sizeiptr is specified, an INVALID_VALUE error is
73 glMultiDrawArrays(GL_TRIANGLE_STRIP
, &first
, &count
, -1);
74 if (!piglit_check_gl_error(GL_INVALID_VALUE
))
77 return piglit_probe_rect_rgb(0, 0, piglit_width
, piglit_height
, zero
);
81 test_draw_negative_count()
83 static const int first
[2] = { 0, 0 };
84 static const GLsizei count
[2] = { 4, -1 };
86 glClearColor(0.0, 0.0, 0.0, 0.0);
87 glClear(GL_COLOR_BUFFER_BIT
);
89 glEnableClientState(GL_VERTEX_ARRAY
);
90 glVertexPointer(2, GL_FLOAT
, 0, verts
);
92 /* Section 10.4 (Drawing Commands Using Vertex Arrays) of the
93 * OpenGL 4.5 (Core Profile) spec describes the following error
94 * condition for glDrawArraysOneInstance, which is used to describe
95 * the semantics of glMultiDrawArrays:
97 * "An INVALID_VALUE error is generated if count is negative."
99 * Furthermore, section 2.3.1 (Errors) of the OpenGL 4.5 (Core Profile)
102 * "Currently, when an error flag is set, results of GL operation
103 * are undefined only if an OUT_OF_MEMORY error has occurred. In
104 * other cases, there are no side effects unless otherwise noted;
105 * the command which generates the error is ignored so that it has
106 * no effect on GL state or framebuffer contents."
108 * We explicitly check that no draw occurred, even though only the
109 * second primitive results in an error.
111 glMultiDrawArrays(GL_TRIANGLE_STRIP
, first
, count
, 2);
112 if (!piglit_check_gl_error(GL_INVALID_VALUE
))
115 return piglit_probe_rect_rgba(0, 0, piglit_width
, piglit_height
, zero
);
124 #define subtest(name) \
126 if (!test_##name()) { \
127 printf(#name " test failed.\n"); \
132 subtest(draw_negative_count
);
133 subtest(draw_negative_primcount
);
137 return pass
? PIGLIT_PASS
: PIGLIT_FAIL
;
142 piglit_init(int argc
, char **argv
)