framework/replay: disable AA accounting when comparing with no tolerance
[piglit.git] / tests / spec / gl-4.4 / gl_max_vertex_attrib_stride.c
blob41bad0e9ce74cb18d77f3b86fd1de3164fb1e829
1 /*
2 * Copyright (c) 2014 Timothy Arceri <t_arceri@yahoo.com.au>
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
13 * Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 * NON-INFRINGEMENT. IN NO EVENT SHALL AUTHORS AND/OR THEIR SUPPLIERS
19 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
20 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
25 #include "piglit-util-gl.h"
26 #include "minmax-test.h"
28 PIGLIT_GL_TEST_CONFIG_BEGIN
30 config.supports_gl_core_version = 44;
31 config.khr_no_error_support = PIGLIT_NO_ERRORS;
33 PIGLIT_GL_TEST_CONFIG_END
35 static bool check_stride(char *function, bool check_valid)
37 bool pass = true;
39 if (check_valid) {
40 if (!piglit_check_gl_error(GL_NO_ERROR)) {
41 fprintf(stderr, "error when testing valid "
42 "MAX_VERTEX_ATTRIB_STRIDE with %s\n",
43 function);
44 pass = false;
46 } else {
47 if (!piglit_check_gl_error(GL_INVALID_VALUE)) {
48 fprintf(stderr, "GL_INVALID_VALUE should be generated when setting"
49 " %s stride too value large than MAX_VERTEX_ATTRIB_STRIDE\n",
50 function);
51 pass = false;
55 return pass;
58 static bool test_stride_vertex_attribl(GLint stride,
59 bool check_valid)
61 glVertexAttribLPointer(0, 4, GL_DOUBLE, stride, NULL);
63 return check_stride("glVertexAttribLPointer", check_valid);
66 static bool test_stride_vertex_attribi(GLint stride,
67 bool check_valid)
69 glVertexAttribIPointer(0, 4, GL_UNSIGNED_INT,
70 stride, NULL);
72 return check_stride("glVertexAttribIPointer", check_valid);
75 static bool test_stride_vertex_attrib(GLint stride,
76 bool check_valid)
78 glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE,
79 stride, NULL);
81 return check_stride("glVertexAttribPointer", check_valid);
84 static bool test_stride_bind_buffers(GLint stride,
85 bool check_valid)
87 GLint strides[2];
88 GLuint buf[2];
89 GLintptr offsets[2] = { 1024, 1024 };
91 glGetIntegerv(GL_MAX_VERTEX_ATTRIB_STRIDE, &strides[0]);
92 strides[1] = stride;
94 /* Create buffer objects */
95 glGenBuffers(2, buf);
96 glBindBuffer(GL_ARRAY_BUFFER, buf[0]);
97 glBindBuffer(GL_ARRAY_BUFFER, buf[1]);
99 glBindVertexBuffers(0, 2, buf, offsets, strides);
101 return check_stride("glBindVertexBuffers", check_valid);
104 static bool test_stride_bind_buffer(GLint stride,
105 bool check_valid)
107 GLuint vbo;
109 /* Create a buffer object */
110 glGenBuffers(1, &vbo);
111 glBindBuffer(GL_ARRAY_BUFFER, vbo);
113 glBindVertexBuffer(0, vbo, 1024, stride);
115 return check_stride("glBindVertexBuffer", check_valid);
118 void piglit_init(int argc, char **argv)
120 bool pass = true;
121 GLint stride_max, stride_max_plus_one;
122 GLuint vao;
124 /* Create and bind a vertex array object, this is needed
125 for glBindBuffer* tests */
126 glGenVertexArrays(1, &vao);
127 glBindVertexArray(vao);
129 glGetIntegerv(GL_MAX_VERTEX_ATTRIB_STRIDE, &stride_max);
130 stride_max_plus_one = stride_max + 1;
132 piglit_test_min_int(GL_MAX_VERTEX_ATTRIB_STRIDE, 2048);
133 pass = piglit_minmax_pass;
135 /* Try passing the max stride value */
136 pass = test_stride_bind_buffer(stride_max, true) && pass;
137 pass = test_stride_bind_buffers(stride_max, true) && pass;
138 pass = test_stride_vertex_attrib(stride_max, true) && pass;
139 pass = test_stride_vertex_attribi(stride_max, true) && pass;
140 pass = test_stride_vertex_attribl(stride_max, true) && pass;
142 /* Try passing a stride value that is to large */
143 if (!piglit_khr_no_error) {
144 pass = test_stride_bind_buffer(stride_max_plus_one, false) && pass;
145 pass = test_stride_bind_buffers(stride_max_plus_one, false) && pass;
146 pass = test_stride_vertex_attrib(stride_max_plus_one, false) && pass;
147 pass = test_stride_vertex_attribi(stride_max_plus_one, false) && pass;
148 pass = test_stride_vertex_attribl(stride_max_plus_one, false) && pass;
151 piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
154 enum piglit_result
155 piglit_display(void)
157 return PIGLIT_PASS;