ext_gpu_shader4: add compiler tests for everything
[piglit.git] / tests / spec / arb_transform_feedback3 / query_with_invalid_index.c
blob54198309427a0e2bcf06cbafb6fa90b5bafdc0bd
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.
24 #include "piglit-util-gl.h"
26 /**
27 * @file query_with_invalid_index.c
29 * Tests that invalid index given to BeginQueryIndexed(), EndQueryIndexed() or
30 * GetQueryIndexediv() is detected and an error is set. The spec says:
32 * "The error INVALID_VALUE is generated by BeginQueryIndexed, EndQueryIndexed
33 * or GetQueryIndexediv if <target> is TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN
34 * or PRIMITIVES_GENERATED and <index> is greater or equal
35 * to MAX_VERTEX_STREAMS."
38 PIGLIT_GL_TEST_CONFIG_BEGIN
40 config.supports_gl_compat_version = 32;
41 config.supports_gl_core_version = 32;
42 config.khr_no_error_support = PIGLIT_NO_ERRORS;
44 PIGLIT_GL_TEST_CONFIG_END
46 void
47 piglit_init(int argc, char **argv)
49 /**
50 * Separate queries for four different cases preventing the test from
51 * re-using a query that got possibly activated by the previous attempt.
53 * generated with maximum
54 * generated with maximum + 1
55 * written with maximum
56 * written with maximum + 1
58 GLuint queries[4];
59 GLint max_streams;
60 bool pass = true;
62 piglit_require_extension("GL_ARB_transform_feedback3");
64 glGetIntegerv(GL_MAX_VERTEX_STREAMS, &max_streams);
65 if (!piglit_check_gl_error(GL_NO_ERROR)) {
66 printf("failed to resolve the maximum number of streams\n");
67 piglit_report_result(PIGLIT_FAIL);
70 if (max_streams <= 0) {
71 printf("invalid maximum number of streams: %d\n", max_streams);
72 piglit_report_result(PIGLIT_FAIL);
75 glGenQueries(ARRAY_SIZE(queries), queries);
77 glBeginQueryIndexed(GL_PRIMITIVES_GENERATED, max_streams - 1,
78 queries[0]);
79 if (!piglit_check_gl_error(GL_NO_ERROR)) {
80 printf("failed to activate primitives generated query for the "
81 "maximum supported stream\n");
82 pass = false;
85 if (!piglit_khr_no_error) {
86 glBeginQueryIndexed(GL_PRIMITIVES_GENERATED, max_streams,
87 queries[1]);
88 pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass;
91 glBeginQueryIndexed(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN,
92 max_streams - 1, queries[2]);
93 if (!piglit_check_gl_error(GL_NO_ERROR)) {
94 printf("failed to activate primitives written query for the "
95 "maximum supported stream\n");
96 pass = false;
99 if (!piglit_khr_no_error) {
100 glBeginQueryIndexed(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN,
101 max_streams, queries[3]);
102 pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass;
105 glDeleteQueries(ARRAY_SIZE(queries), queries);
107 piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
110 enum piglit_result
111 piglit_display(void)
113 /* Should never be reached */
114 return PIGLIT_FAIL;