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
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
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
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
,
58 piglit_init(int argc
, char **argv
)
64 int stuff
[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
65 int size
= sizeof(stuff
);
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
);
79 printf("GL_BUFFER_SIZE for %s expected %d, but %d "
81 piglit_get_gl_enum_name(buffers
[i
]),
85 pass
= piglit_check_gl_error(GL_NO_ERROR
) && pass
;
87 glGetBufferParameteri64v(buffers
[i
], GL_BUFFER_MAP_OFFSET
, &data
);
89 printf("GL_BUFFER_MAP_OFFSET for %s expected %d, but "
91 piglit_get_gl_enum_name(buffers
[i
]),
95 pass
= piglit_check_gl_error(GL_NO_ERROR
) && pass
;
97 glGetBufferParameteri64v(buffers
[i
], GL_BUFFER_MAP_LENGTH
, &data
);
99 printf("GL_BUFFER_MAP_LENGTH for %s expected %d, but "
100 "%d was returned.\n",
101 piglit_get_gl_enum_name(buffers
[i
]),
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
);