epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 2 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 3 | * Copyright 2011 Google Inc. |
| 4 | * |
| 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 10 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 11 | #ifndef GrGLConfig_DEFINED |
| 12 | #define GrGLConfig_DEFINED |
| 13 | |
| 14 | #include "GrTypes.h" |
twiz@google.com | 0f31ca7 | 2011-03-18 17:38:11 +0000 | [diff] [blame] | 15 | #include "GrGLDefines.h" |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 16 | |
bsalomon@google.com | 42ab7ea | 2011-01-19 17:19:40 +0000 | [diff] [blame] | 17 | /** |
bsalomon@google.com | f987d1b | 2011-04-04 17:13:52 +0000 | [diff] [blame] | 18 | * Optional GL config file. |
twiz@google.com | b65e0cb | 2011-03-18 20:41:44 +0000 | [diff] [blame] | 19 | */ |
bsalomon@google.com | f987d1b | 2011-04-04 17:13:52 +0000 | [diff] [blame] | 20 | #ifdef GR_GL_CUSTOM_SETUP_HEADER |
| 21 | #include GR_GL_CUSTOM_SETUP_HEADER |
| 22 | #endif |
| 23 | |
| 24 | #if !defined(GR_GL_FUNCTION_TYPE) |
| 25 | #define GR_GL_FUNCTION_TYPE |
| 26 | #endif |
twiz@google.com | b65e0cb | 2011-03-18 20:41:44 +0000 | [diff] [blame] | 27 | |
| 28 | /** |
bsalomon@google.com | 3723a48 | 2011-02-17 21:47:25 +0000 | [diff] [blame] | 29 | * The following are optional defines that can be enabled at the compiler |
| 30 | * command line, in a IDE project, in a GrUserConfig.h file, or in a GL custom |
bsalomon@google.com | f987d1b | 2011-04-04 17:13:52 +0000 | [diff] [blame] | 31 | * file (if one is in use). If a GR_GL_CUSTOM_SETUP_HEADER is used they can |
| 32 | * also be placed there. |
bsalomon@google.com | 7acdb8e | 2011-02-11 14:07:02 +0000 | [diff] [blame] | 33 | * |
bsalomon@google.com | 3723a48 | 2011-02-17 21:47:25 +0000 | [diff] [blame] | 34 | * GR_GL_LOG_CALLS: if 1 Gr can print every GL call using GrPrintf. Defaults to |
reed@google.com | 27a1e77 | 2011-03-08 15:34:06 +0000 | [diff] [blame] | 35 | * 0. Logging can be enabled and disabled at runtime using a debugger via to |
bsalomon@google.com | 3723a48 | 2011-02-17 21:47:25 +0000 | [diff] [blame] | 36 | * global gLogCallsGL. The initial value of gLogCallsGL is controlled by |
| 37 | * GR_GL_LOG_CALLS_START. |
| 38 | * |
| 39 | * GR_GL_LOG_CALLS_START: controls the initial value of gLogCallsGL when |
| 40 | * GR_GL_LOG_CALLS is 1. Defaults to 0. |
| 41 | * |
| 42 | * GR_GL_CHECK_ERROR: if enabled Gr can do a glGetError() after every GL call. |
reed@google.com | 27a1e77 | 2011-03-08 15:34:06 +0000 | [diff] [blame] | 43 | * Defaults to 1 if GR_DEBUG is set, otherwise 0. When GR_GL_CHECK_ERROR is 1 |
bsalomon@google.com | 3723a48 | 2011-02-17 21:47:25 +0000 | [diff] [blame] | 44 | * this can be toggled in a debugger using the gCheckErrorGL global. The initial |
| 45 | * value of gCheckErrorGL is controlled by by GR_GL_CHECK_ERROR_START. |
| 46 | * |
| 47 | * GR_GL_CHECK_ERROR_START: controls the initial value of gCheckErrorGL |
| 48 | * when GR_GL_CHECK_ERROR is 1. Defaults to 1. |
bsalomon@google.com | 4be283f | 2011-04-19 21:15:09 +0000 | [diff] [blame] | 49 | * |
| 50 | * GR_GL_NO_CONSTANT_ATTRIBUTES: if this evaluates to true then the GL backend |
| 51 | * will use uniforms instead of attributes in all cases when there is not |
| 52 | * per-vertex data. This is important when the underlying GL implementation |
| 53 | * doesn't actually support immediate style attribute values (e.g. when |
| 54 | * the GL stream is converted to DX as in ANGLE on Chrome). Defaults to 0. |
| 55 | * |
| 56 | * GR_GL_ATTRIBUTE_MATRICES: If changing uniforms is very expensive it may be |
| 57 | * faster to use vertex attributes for matrices (set via glVertexAttrib3fv). |
| 58 | * Setting this build flag enables this behavior. GR_GL_NO_CONSTANT_ATTRIBUTES |
| 59 | * must not be set since this uses constant attributes for the matrices. |
| 60 | * Defaults to 0. |
bsalomon@google.com | 9ae4429 | 2011-07-01 15:21:59 +0000 | [diff] [blame] | 61 | * |
| 62 | * GR_GL_USE_BUFFER_DATA_NULL_HINT: When specifing new data for a vertex/index |
| 63 | * buffer that replaces old data Ganesh can give a hint to the driver that the |
| 64 | * previous data will not be used in future draws like this: |
| 65 | * glBufferData(GL_..._BUFFER, size, NULL, usage); //<--hint, NULL means |
| 66 | * glBufferSubData(GL_..._BUFFER, 0, lessThanSize, data) // old data can't be |
| 67 | * // used again. |
bsalomon@google.com | 96e96df | 2011-10-10 14:49:29 +0000 | [diff] [blame] | 68 | * However, this can be an unoptimization on some platforms, esp. Chrome. |
| 69 | * Chrome's cmd buffer will create a new allocation and memset the whole thing |
| 70 | * to zero (for security reasons). Defaults to 1 (enabled). |
bsalomon@google.com | 56bfc5a | 2011-09-01 13:28:16 +0000 | [diff] [blame] | 71 | * |
| 72 | * GR_GL_PER_GL_FUNC_CALLBACK: When set to 1 the GrGLInterface object provides |
| 73 | * a function pointer that is called just before every gl function. The ptr must |
| 74 | * be valid (i.e. there is no NULL check). However, by default the callback will |
| 75 | * be set to a function that does nothing. The signature of the function is: |
| 76 | * void function(const GrGLInterface*) |
| 77 | * It is not extern "C". |
| 78 | * The GrGLInterface field fCallback specifies the function ptr and there is an |
| 79 | * additional field fCallbackData of type intptr_t for client data. |
bsalomon@google.com | 0a97be2 | 2011-11-08 19:20:57 +0000 | [diff] [blame] | 80 | * |
bsalomon@google.com | a85449d | 2011-11-19 02:36:05 +0000 | [diff] [blame] | 81 | * GR_GL_RGBA_8888_PIXEL_OPS_SLOW: Set this to 1 if it is known that performing |
| 82 | * glReadPixels / glTex(Sub)Image with format=GL_RGBA, type=GL_UNISIGNED_BYTE is |
| 83 | * significantly slower than format=GL_BGRA, type=GL_UNISIGNED_BYTE. |
bsalomon@google.com | 56d11e0 | 2011-11-30 19:59:08 +0000 | [diff] [blame] | 84 | * |
| 85 | * GR_GL_FULL_READPIXELS_FASTER_THAN_PARTIAL: Set this to 1 if calling |
| 86 | * glReadPixels to read the entire framebuffer is faster than calling it with |
| 87 | * the same sized rectangle but with a framebuffer bound that is larger than |
| 88 | * the rectangle read. |
bsalomon@google.com | 4f3c253 | 2012-01-19 16:16:52 +0000 | [diff] [blame] | 89 | * |
| 90 | * GR_GL_CHECK_ALLOC_WITH_GET_ERROR: If set to 1 this will then glTexImage, |
| 91 | * glBufferData, glRenderbufferStorage, etc will be checked for errors. This |
| 92 | * amounts to ensuring the error is GL_NO_ERROR, calling the allocating |
| 93 | * function, and then checking that the error is still GL_NO_ERROR. When the |
| 94 | * value is 0 we will assume no error was generated without checking. |
bsalomon@google.com | 4bcb0c6 | 2012-02-07 16:06:47 +0000 | [diff] [blame^] | 95 | * |
| 96 | * GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT: We will normally check the FBO status |
| 97 | * every time we bind a texture or renderbuffer to an FBO. However, in some |
| 98 | * environments CheckFrameBufferStatus is very expensive. If this is set we will |
| 99 | * check the first time we use a color format or a combination of color / |
| 100 | * stencil formats as attachments. If the FBO is complete we will assume |
| 101 | * subsequent attachments with the same formats are complete as well. |
bsalomon@google.com | 42ab7ea | 2011-01-19 17:19:40 +0000 | [diff] [blame] | 102 | */ |
| 103 | |
bsalomon@google.com | 7acdb8e | 2011-02-11 14:07:02 +0000 | [diff] [blame] | 104 | #if !defined(GR_GL_LOG_CALLS) |
bsalomon@google.com | 4bcb0c6 | 2012-02-07 16:06:47 +0000 | [diff] [blame^] | 105 | #define GR_GL_LOG_CALLS GR_DEBUG |
bsalomon@google.com | 3723a48 | 2011-02-17 21:47:25 +0000 | [diff] [blame] | 106 | #endif |
| 107 | |
| 108 | #if !defined(GR_GL_LOG_CALLS_START) |
bsalomon@google.com | 4bcb0c6 | 2012-02-07 16:06:47 +0000 | [diff] [blame^] | 109 | #define GR_GL_LOG_CALLS_START 0 |
bsalomon@google.com | 3723a48 | 2011-02-17 21:47:25 +0000 | [diff] [blame] | 110 | #endif |
| 111 | |
reed@google.com | 27a1e77 | 2011-03-08 15:34:06 +0000 | [diff] [blame] | 112 | #if !defined(GR_GL_CHECK_ERROR) |
bsalomon@google.com | 4bcb0c6 | 2012-02-07 16:06:47 +0000 | [diff] [blame^] | 113 | #define GR_GL_CHECK_ERROR GR_DEBUG |
bsalomon@google.com | 3723a48 | 2011-02-17 21:47:25 +0000 | [diff] [blame] | 114 | #endif |
| 115 | |
| 116 | #if !defined(GR_GL_CHECK_ERROR_START) |
bsalomon@google.com | 4bcb0c6 | 2012-02-07 16:06:47 +0000 | [diff] [blame^] | 117 | #define GR_GL_CHECK_ERROR_START 1 |
bsalomon@google.com | 4be283f | 2011-04-19 21:15:09 +0000 | [diff] [blame] | 118 | #endif |
| 119 | |
| 120 | #if !defined(GR_GL_NO_CONSTANT_ATTRIBUTES) |
bsalomon@google.com | 4bcb0c6 | 2012-02-07 16:06:47 +0000 | [diff] [blame^] | 121 | #define GR_GL_NO_CONSTANT_ATTRIBUTES 0 |
bsalomon@google.com | 4be283f | 2011-04-19 21:15:09 +0000 | [diff] [blame] | 122 | #endif |
| 123 | |
| 124 | #if !defined(GR_GL_ATTRIBUTE_MATRICES) |
bsalomon@google.com | 4bcb0c6 | 2012-02-07 16:06:47 +0000 | [diff] [blame^] | 125 | #define GR_GL_ATTRIBUTE_MATRICES 0 |
bsalomon@google.com | 4be283f | 2011-04-19 21:15:09 +0000 | [diff] [blame] | 126 | #endif |
| 127 | |
bsalomon@google.com | 9ae4429 | 2011-07-01 15:21:59 +0000 | [diff] [blame] | 128 | #if !defined(GR_GL_USE_BUFFER_DATA_NULL_HINT) |
bsalomon@google.com | 4bcb0c6 | 2012-02-07 16:06:47 +0000 | [diff] [blame^] | 129 | #define GR_GL_USE_BUFFER_DATA_NULL_HINT 1 |
bsalomon@google.com | 56bfc5a | 2011-09-01 13:28:16 +0000 | [diff] [blame] | 130 | #endif |
| 131 | |
| 132 | #if !defined(GR_GL_PER_GL_FUNC_CALLBACK) |
bsalomon@google.com | 4bcb0c6 | 2012-02-07 16:06:47 +0000 | [diff] [blame^] | 133 | #define GR_GL_PER_GL_FUNC_CALLBACK 0 |
bsalomon@google.com | 9ae4429 | 2011-07-01 15:21:59 +0000 | [diff] [blame] | 134 | #endif |
| 135 | |
bsalomon@google.com | a85449d | 2011-11-19 02:36:05 +0000 | [diff] [blame] | 136 | #if !defined(GR_GL_RGBA_8888_PIXEL_OPS_SLOW) |
bsalomon@google.com | 4bcb0c6 | 2012-02-07 16:06:47 +0000 | [diff] [blame^] | 137 | #define GR_GL_RGBA_8888_PIXEL_OPS_SLOW 0 |
bsalomon@google.com | 0a97be2 | 2011-11-08 19:20:57 +0000 | [diff] [blame] | 138 | #endif |
| 139 | |
bsalomon@google.com | 56d11e0 | 2011-11-30 19:59:08 +0000 | [diff] [blame] | 140 | #if !defined(GR_GL_FULL_READPIXELS_FASTER_THAN_PARTIAL) |
bsalomon@google.com | 4bcb0c6 | 2012-02-07 16:06:47 +0000 | [diff] [blame^] | 141 | #define GR_GL_FULL_READPIXELS_FASTER_THAN_PARTIAL 0 |
bsalomon@google.com | 56d11e0 | 2011-11-30 19:59:08 +0000 | [diff] [blame] | 142 | #endif |
| 143 | |
bsalomon@google.com | 4f3c253 | 2012-01-19 16:16:52 +0000 | [diff] [blame] | 144 | #if !defined(GR_GL_CHECK_ALLOC_WITH_GET_ERROR) |
bsalomon@google.com | 4bcb0c6 | 2012-02-07 16:06:47 +0000 | [diff] [blame^] | 145 | #define GR_GL_CHECK_ALLOC_WITH_GET_ERROR 1 |
| 146 | #endif |
| 147 | |
| 148 | #if !defined(GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT) |
| 149 | #define GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT 0 |
bsalomon@google.com | 4f3c253 | 2012-01-19 16:16:52 +0000 | [diff] [blame] | 150 | #endif |
| 151 | |
bsalomon@google.com | 4be283f | 2011-04-19 21:15:09 +0000 | [diff] [blame] | 152 | #if(GR_GL_NO_CONSTANT_ATTRIBUTES) && (GR_GL_ATTRIBUTE_MATRICES) |
| 153 | #error "Cannot combine GR_GL_NO_CONSTANT_ATTRIBUTES and GR_GL_ATTRIBUTE_MATRICES" |
bsalomon@google.com | 7acdb8e | 2011-02-11 14:07:02 +0000 | [diff] [blame] | 154 | #endif |
| 155 | |
bsalomon@google.com | 42ab7ea | 2011-01-19 17:19:40 +0000 | [diff] [blame] | 156 | //////////////////////////////////////////////////////////////////////////////// |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 157 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 158 | #if GR_SCALAR_IS_FIXED |
| 159 | #define GrGLType GL_FIXED |
| 160 | #elif GR_SCALAR_IS_FLOAT |
twiz@google.com | 0f31ca7 | 2011-03-18 17:38:11 +0000 | [diff] [blame] | 161 | #define GrGLType GR_GL_FLOAT |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 162 | #else |
| 163 | #error "unknown GR_SCALAR type" |
| 164 | #endif |
| 165 | |
| 166 | #if GR_TEXT_SCALAR_IS_USHORT |
twiz@google.com | 0f31ca7 | 2011-03-18 17:38:11 +0000 | [diff] [blame] | 167 | #define GrGLTextType GR_GL_UNSIGNED_SHORT |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 168 | #define GR_GL_TEXT_TEXTURE_NORMALIZED 1 |
| 169 | #elif GR_TEXT_SCALAR_IS_FLOAT |
twiz@google.com | 0f31ca7 | 2011-03-18 17:38:11 +0000 | [diff] [blame] | 170 | #define GrGLTextType GR_GL_FLOAT |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 171 | #define GR_GL_TEXT_TEXTURE_NORMALIZED 0 |
| 172 | #elif GR_TEXT_SCALAR_IS_FIXED |
twiz@google.com | 0f31ca7 | 2011-03-18 17:38:11 +0000 | [diff] [blame] | 173 | #define GrGLTextType GR_GL_FIXED |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 174 | #define GR_GL_TEXT_TEXTURE_NORMALIZED 0 |
reed@google.com | 63100f9 | 2011-01-18 21:32:14 +0000 | [diff] [blame] | 175 | #else |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 176 | #error "unknown GR_TEXT_SCALAR type" |
| 177 | #endif |
| 178 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 179 | //////////////////////////////////////////////////////////////////////////////// |
reed@google.com | 63100f9 | 2011-01-18 21:32:14 +0000 | [diff] [blame] | 180 | |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 181 | struct GrGLInterface; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 182 | |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 183 | extern void GrGLCheckErr(const GrGLInterface* gl, |
| 184 | const char* location, |
| 185 | const char* call); |
| 186 | |
| 187 | extern void GrGLClearErr(const GrGLInterface* gl); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 188 | |
bsalomon@google.com | 3723a48 | 2011-02-17 21:47:25 +0000 | [diff] [blame] | 189 | #if GR_GL_CHECK_ERROR |
| 190 | extern bool gCheckErrorGL; |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 191 | #define GR_GL_CHECK_ERROR_IMPL(IFACE, X) \ |
| 192 | if (gCheckErrorGL) \ |
| 193 | GrGLCheckErr(IFACE, GR_FILE_AND_LINE_STR, #X) |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 194 | #else |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 195 | #define GR_GL_CHECK_ERROR_IMPL(IFACE, X) |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 196 | #endif |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 197 | |
| 198 | #if GR_GL_LOG_CALLS |
bsalomon@google.com | 3723a48 | 2011-02-17 21:47:25 +0000 | [diff] [blame] | 199 | extern bool gLogCallsGL; |
bsalomon@google.com | dec9f2d | 2011-08-30 18:05:17 +0000 | [diff] [blame] | 200 | #define GR_GL_LOG_CALLS_IMPL(X) \ |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 201 | if (gLogCallsGL) \ |
| 202 | GrPrintf(GR_FILE_AND_LINE_STR "GL: " #X "\n") |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 203 | #else |
bsalomon@google.com | 3723a48 | 2011-02-17 21:47:25 +0000 | [diff] [blame] | 204 | #define GR_GL_LOG_CALLS_IMPL(X) |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 205 | #endif |
| 206 | |
bsalomon@google.com | 56bfc5a | 2011-09-01 13:28:16 +0000 | [diff] [blame] | 207 | #if GR_GL_PER_GL_FUNC_CALLBACK |
| 208 | #define GR_GL_CALLBACK_IMPL(IFACE) (IFACE)->fCallback(IFACE) |
| 209 | #else |
| 210 | #define GR_GL_CALLBACK_IMPL(IFACE) |
| 211 | #endif |
| 212 | |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 213 | #define GR_GL_CALL(IFACE, X) \ |
bsalomon@google.com | 56bfc5a | 2011-09-01 13:28:16 +0000 | [diff] [blame] | 214 | do { \ |
| 215 | GR_GL_CALL_NOERRCHECK(IFACE, X); \ |
| 216 | GR_GL_CHECK_ERROR_IMPL(IFACE, X); \ |
| 217 | } while (false) |
bsalomon@google.com | 8895a7a | 2011-02-18 16:09:55 +0000 | [diff] [blame] | 218 | |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 219 | #define GR_GL_CALL_NOERRCHECK(IFACE, X) \ |
bsalomon@google.com | 56bfc5a | 2011-09-01 13:28:16 +0000 | [diff] [blame] | 220 | do { \ |
| 221 | GR_GL_CALLBACK_IMPL(IFACE); \ |
| 222 | (IFACE)->f##X; \ |
| 223 | GR_GL_LOG_CALLS_IMPL(X); \ |
| 224 | } while (false) |
| 225 | |
| 226 | #define GR_GL_CALL_RET(IFACE, RET, X) \ |
| 227 | do { \ |
| 228 | GR_GL_CALL_RET_NOERRCHECK(IFACE, RET, X); \ |
| 229 | GR_GL_CHECK_ERROR_IMPL(IFACE, X); \ |
| 230 | } while (false) |
| 231 | |
| 232 | #define GR_GL_CALL_RET_NOERRCHECK(IFACE, RET, X) \ |
| 233 | do { \ |
| 234 | GR_GL_CALLBACK_IMPL(IFACE); \ |
| 235 | (RET) = (IFACE)->f##X; \ |
| 236 | GR_GL_LOG_CALLS_IMPL(X); \ |
| 237 | } while (false) |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 238 | |
| 239 | #define GR_GL_GET_ERROR(IFACE) (IFACE)->fGetError() |
twiz@google.com | b65e0cb | 2011-03-18 20:41:44 +0000 | [diff] [blame] | 240 | |
bsalomon@google.com | 8895a7a | 2011-02-18 16:09:55 +0000 | [diff] [blame] | 241 | //////////////////////////////////////////////////////////////////////////////// |
| 242 | |
| 243 | /** |
bsalomon@google.com | 8895a7a | 2011-02-18 16:09:55 +0000 | [diff] [blame] | 244 | * Some drivers want the var-int arg to be zero-initialized on input. |
| 245 | */ |
| 246 | #define GR_GL_INIT_ZERO 0 |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 247 | #define GR_GL_GetIntegerv(gl, e, p) \ |
bsalomon@google.com | 8895a7a | 2011-02-18 16:09:55 +0000 | [diff] [blame] | 248 | do { \ |
| 249 | *(p) = GR_GL_INIT_ZERO; \ |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 250 | GR_GL_CALL(gl, GetIntegerv(e, p)); \ |
bsalomon@google.com | 8895a7a | 2011-02-18 16:09:55 +0000 | [diff] [blame] | 251 | } while (0) |
| 252 | |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 253 | #define GR_GL_GetFramebufferAttachmentParameteriv(gl, t, a, pname, p) \ |
| 254 | do { \ |
| 255 | *(p) = GR_GL_INIT_ZERO; \ |
| 256 | GR_GL_CALL(gl, GetFramebufferAttachmentParameteriv(t, a, pname, p)); \ |
bsalomon@google.com | cee661a | 2011-07-26 12:32:36 +0000 | [diff] [blame] | 257 | } while (0) |
| 258 | |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 259 | #define GR_GL_GetRenderbufferParameteriv(gl, t, pname, p) \ |
| 260 | do { \ |
| 261 | *(p) = GR_GL_INIT_ZERO; \ |
| 262 | GR_GL_CALL(gl, GetRenderbufferParameteriv(t, pname, p)); \ |
bsalomon@google.com | cee661a | 2011-07-26 12:32:36 +0000 | [diff] [blame] | 263 | } while (0) |
| 264 | |
bsalomon@google.com | 0b77d68 | 2011-08-19 13:28:54 +0000 | [diff] [blame] | 265 | #define GR_GL_GetTexLevelParameteriv(gl, t, l, pname, p) \ |
| 266 | do { \ |
| 267 | *(p) = GR_GL_INIT_ZERO; \ |
| 268 | GR_GL_CALL(gl, GetTexLevelParameteriv(t, l, pname, p)); \ |
bsalomon@google.com | cee661a | 2011-07-26 12:32:36 +0000 | [diff] [blame] | 269 | } while (0) |
| 270 | |
bsalomon@google.com | 8895a7a | 2011-02-18 16:09:55 +0000 | [diff] [blame] | 271 | //////////////////////////////////////////////////////////////////////////////// |
| 272 | |
reed@google.com | 27a1e77 | 2011-03-08 15:34:06 +0000 | [diff] [blame] | 273 | #endif |