ext_gpu_shader4: add compiler tests for everything
[piglit.git] / tests / spec / gl-3.2 / get-buffer-parameter-i64v.c
blobe7c79e9dca6d4425e8a5a7cffe19ce21e66ce48b
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 /**
25 * Test GetBufferParameteri64v()
27 * GL 3.2 core spec added GetBufferParameteri64v() in section 6.1.8
29 * GetBufferParameteri64v() returns an int64 value corresponding to the size, map
30 * offset, or map length of the target buffer
34 #include "piglit-util-gl.h"
36 PIGLIT_GL_TEST_CONFIG_BEGIN
38 config.supports_gl_core_version = 32;
39 config.supports_gl_compat_version = 32;
40 config.khr_no_error_support = PIGLIT_NO_ERRORS;
42 PIGLIT_GL_TEST_CONFIG_END
44 enum piglit_result
45 piglit_display(void)
47 /* UNREACHED */
48 return PIGLIT_FAIL;
51 static const GLenum buffers[] = { GL_ARRAY_BUFFER, GL_COPY_READ_BUFFER,
52 GL_COPY_WRITE_BUFFER, GL_ELEMENT_ARRAY_BUFFER,
53 GL_PIXEL_PACK_BUFFER, GL_PIXEL_UNPACK_BUFFER,
54 GL_TEXTURE_BUFFER, GL_TRANSFORM_FEEDBACK_BUFFER,
55 GL_UNIFORM_BUFFER };
57 void
58 piglit_init(int argc, char **argv)
60 bool pass = true;
61 GLint64 data = -2;
62 int i = 0;
64 int stuff[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
65 int size = sizeof(stuff);
66 int offset = 1;
67 int range = 5;
69 GLuint buff = 0;
70 glGenBuffers(1, &buff);
72 for (i = 0; i < ARRAY_SIZE(buffers); i++) {
73 glBindBuffer(buffers[i], buff);
74 glBufferData(buffers[i], size, stuff, GL_STATIC_READ);
75 glMapBufferRange(buffers[i], offset, range, GL_MAP_READ_BIT);
77 glGetBufferParameteri64v(buffers[i], GL_BUFFER_SIZE, &data);
78 if(data != size) {
79 printf("GL_BUFFER_SIZE for %s expected %d, but %d "
80 "was returned.\n",
81 piglit_get_gl_enum_name(buffers[i]),
82 size, (int)data);
83 pass = false;
85 pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
87 glGetBufferParameteri64v(buffers[i], GL_BUFFER_MAP_OFFSET, &data);
88 if(data != offset) {
89 printf("GL_BUFFER_MAP_OFFSET for %s expected %d, but "
90 "%d was returned.\n",
91 piglit_get_gl_enum_name(buffers[i]),
92 offset, (int)data);
93 pass = false;
95 pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
97 glGetBufferParameteri64v(buffers[i], GL_BUFFER_MAP_LENGTH, &data);
98 if(data != range) {
99 printf("GL_BUFFER_MAP_LENGTH for %s expected %d, but "
100 "%d was returned.\n",
101 piglit_get_gl_enum_name(buffers[i]),
102 range, (int)data);
103 pass = false;
105 glUnmapBuffer(buffers[i]);
106 pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
109 pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
111 piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);