2 * Copyright © 2012 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
21 * DEALINGS IN THE SOFTWARE.
26 * \brief Workarounds for building with GLES2 and GLES3.
28 * When building shader_runner against GLESX and libpiglitutil_glesX, there
29 * are many macros and symbols that are not defined. This header defines such
30 * macros to have the same value found in <GL/gl*.h>, and defines such
31 * functions to print an error message and then report PIGLIT_SKIP, just as
32 * piglit-dispatch does for unsupported extension functions.
36 #include "piglit-util.h"
40 __attribute__((unused
))
42 unsupported_function(const char *name
, ...)
44 printf("Function \"%s\" not supported on this implementation\n", name
);
45 piglit_report_result(PIGLIT_SKIP
);
49 * This macro should be sufficient for most functions. If one of the actual
50 * function's parameters causes an unused-variable warning, you must
51 * special-case the function. See glBindProgramARB for example.
53 * GLES doesn't exist on Windows. So we're free to use the GCC/Clang extension
54 * for statement expressions.
56 #define UNSUPPORTED_FUNCTION(name, return_value, ...) \
58 unsupported_function(#name, __VA_ARGS__); \
62 #if defined(PIGLIT_USE_OPENGL_ES3) || defined(PIGLIT_USE_OPENGL_ES2)
64 #define piglit_frustum_projection(...) UNSUPPORTED_FUNCTION(piglit_frustum_projection, 0, __VA_ARGS__)
65 #define piglit_gen_ortho_projection(...) UNSUPPORTED_FUNCTION(piglit_gen_ortho_projection, 0, __VA_ARGS__)
66 #define piglit_miptree_texture() UNSUPPORTED_FUNCTION(piglit_miptree_texture, 0, 0)
67 #define piglit_depth_texture(...) UNSUPPORTED_FUNCTION(piglit_depth_texture, 0, __VA_ARGS__)
68 #define piglit_ortho_projection(...) UNSUPPORTED_FUNCTION(piglit_ortho_projection, 0, __VA_ARGS__)
69 #define piglit_compile_program(...) UNSUPPORTED_FUNCTION(piglit_compile_program, 0, __VA_ARGS__)
71 #if defined(PIGLIT_USE_OPENGL_ES3)
75 glMapBuffer(GLenum target
, GLbitfield map_buffer_access
)
77 /* Emulate with glMapBufferRange. */
79 GLsizeiptr length
= 0;
80 GLbitfield map_buffer_range_access
;
82 glGetBufferParameteri64v(target
, GL_BUFFER_SIZE
, (GLint64
*) &length
);
83 if (!piglit_check_gl_error(GL_NO_ERROR
))
84 piglit_report_result(PIGLIT_FAIL
);
86 switch (map_buffer_access
) {
88 map_buffer_range_access
= GL_MAP_READ_BIT
;
91 map_buffer_range_access
= GL_MAP_WRITE_BIT
;
94 map_buffer_range_access
= GL_MAP_READ_BIT
| GL_MAP_WRITE_BIT
;
97 map_buffer_range_access
= 0;
100 return glMapBufferRange(target
, 0, length
, map_buffer_range_access
);
102 #endif /* PIGLIT_USE_OPENGL_ES3 */
104 #endif /* PIGLIT_USE_OPENGL_ES3 || PIGLIT_USE_OPENGL_ES2 */