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" |
| 15 | |
bsalomon@google.com | 42ab7ea | 2011-01-19 17:19:40 +0000 | [diff] [blame] | 16 | /** |
bsalomon@google.com | f987d1b | 2011-04-04 17:13:52 +0000 | [diff] [blame] | 17 | * Optional GL config file. |
twiz@google.com | b65e0cb | 2011-03-18 20:41:44 +0000 | [diff] [blame] | 18 | */ |
bsalomon@google.com | f987d1b | 2011-04-04 17:13:52 +0000 | [diff] [blame] | 19 | #ifdef GR_GL_CUSTOM_SETUP_HEADER |
| 20 | #include GR_GL_CUSTOM_SETUP_HEADER |
| 21 | #endif |
| 22 | |
| 23 | #if !defined(GR_GL_FUNCTION_TYPE) |
mtklein | 3d96cb8 | 2016-08-10 07:30:21 -0700 | [diff] [blame^] | 24 | #if defined(SK_BUILD_FOR_WIN32) |
| 25 | #define GR_GL_FUNCTION_TYPE __stdcall |
| 26 | #else |
| 27 | #define GR_GL_FUNCTION_TYPE |
| 28 | #endif |
bsalomon@google.com | f987d1b | 2011-04-04 17:13:52 +0000 | [diff] [blame] | 29 | #endif |
twiz@google.com | b65e0cb | 2011-03-18 20:41:44 +0000 | [diff] [blame] | 30 | |
| 31 | /** |
bsalomon@google.com | 3723a48 | 2011-02-17 21:47:25 +0000 | [diff] [blame] | 32 | * The following are optional defines that can be enabled at the compiler |
| 33 | * 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] | 34 | * file (if one is in use). If a GR_GL_CUSTOM_SETUP_HEADER is used they can |
| 35 | * also be placed there. |
bsalomon@google.com | 7acdb8e | 2011-02-11 14:07:02 +0000 | [diff] [blame] | 36 | * |
tfarina | 38406c8 | 2014-10-31 07:11:12 -0700 | [diff] [blame] | 37 | * GR_GL_LOG_CALLS: if 1 Gr can print every GL call using SkDebugf. Defaults to |
reed@google.com | 27a1e77 | 2011-03-08 15:34:06 +0000 | [diff] [blame] | 38 | * 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] | 39 | * global gLogCallsGL. The initial value of gLogCallsGL is controlled by |
| 40 | * GR_GL_LOG_CALLS_START. |
| 41 | * |
| 42 | * GR_GL_LOG_CALLS_START: controls the initial value of gLogCallsGL when |
| 43 | * GR_GL_LOG_CALLS is 1. Defaults to 0. |
| 44 | * |
| 45 | * GR_GL_CHECK_ERROR: if enabled Gr can do a glGetError() after every GL call. |
commit-bot@chromium.org | 515dcd3 | 2013-08-28 14:17:03 +0000 | [diff] [blame] | 46 | * Defaults to 1 if SK_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] | 47 | * this can be toggled in a debugger using the gCheckErrorGL global. The initial |
| 48 | * value of gCheckErrorGL is controlled by by GR_GL_CHECK_ERROR_START. |
| 49 | * |
| 50 | * GR_GL_CHECK_ERROR_START: controls the initial value of gCheckErrorGL |
| 51 | * when GR_GL_CHECK_ERROR is 1. Defaults to 1. |
bsalomon@google.com | 4be283f | 2011-04-19 21:15:09 +0000 | [diff] [blame] | 52 | * |
bsalomon@google.com | 9ae4429 | 2011-07-01 15:21:59 +0000 | [diff] [blame] | 53 | * GR_GL_USE_BUFFER_DATA_NULL_HINT: When specifing new data for a vertex/index |
| 54 | * buffer that replaces old data Ganesh can give a hint to the driver that the |
| 55 | * previous data will not be used in future draws like this: |
| 56 | * glBufferData(GL_..._BUFFER, size, NULL, usage); //<--hint, NULL means |
| 57 | * glBufferSubData(GL_..._BUFFER, 0, lessThanSize, data) // old data can't be |
| 58 | * // used again. |
bsalomon@google.com | 96e96df | 2011-10-10 14:49:29 +0000 | [diff] [blame] | 59 | * However, this can be an unoptimization on some platforms, esp. Chrome. |
| 60 | * Chrome's cmd buffer will create a new allocation and memset the whole thing |
| 61 | * to zero (for security reasons). Defaults to 1 (enabled). |
bsalomon@google.com | 56bfc5a | 2011-09-01 13:28:16 +0000 | [diff] [blame] | 62 | * |
bsalomon@google.com | 4f3c253 | 2012-01-19 16:16:52 +0000 | [diff] [blame] | 63 | * GR_GL_CHECK_ALLOC_WITH_GET_ERROR: If set to 1 this will then glTexImage, |
| 64 | * glBufferData, glRenderbufferStorage, etc will be checked for errors. This |
| 65 | * amounts to ensuring the error is GL_NO_ERROR, calling the allocating |
| 66 | * function, and then checking that the error is still GL_NO_ERROR. When the |
| 67 | * 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] | 68 | * |
| 69 | * GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT: We will normally check the FBO status |
| 70 | * every time we bind a texture or renderbuffer to an FBO. However, in some |
| 71 | * environments CheckFrameBufferStatus is very expensive. If this is set we will |
| 72 | * check the first time we use a color format or a combination of color / |
| 73 | * stencil formats as attachments. If the FBO is complete we will assume |
| 74 | * subsequent attachments with the same formats are complete as well. |
bsalomon@google.com | ded4f4b | 2012-06-28 18:48:06 +0000 | [diff] [blame] | 75 | * |
bsalomon@google.com | 96966a5 | 2013-02-21 16:34:21 +0000 | [diff] [blame] | 76 | * GR_GL_MUST_USE_VBO: Indicates that all vertices and indices must be rendered |
| 77 | * from VBOs. Chromium's command buffer doesn't allow glVertexAttribArray with |
| 78 | * ARARY_BUFFER 0 bound or glDrawElements with ELEMENT_ARRAY_BUFFER 0 bound. |
bsalomon@google.com | 26fb61a | 2013-02-28 19:26:04 +0000 | [diff] [blame] | 79 | * |
| 80 | * GR_GL_USE_NEW_SHADER_SOURCE_SIGNATURE is for compatibility with the new version |
| 81 | * of the OpenGLES2.0 headers from Khronos. glShaderSource now takes a const char * const *, |
| 82 | * instead of a const char |
bsalomon@google.com | 42ab7ea | 2011-01-19 17:19:40 +0000 | [diff] [blame] | 83 | */ |
| 84 | |
bsalomon@google.com | 7acdb8e | 2011-02-11 14:07:02 +0000 | [diff] [blame] | 85 | #if !defined(GR_GL_LOG_CALLS) |
commit-bot@chromium.org | 515dcd3 | 2013-08-28 14:17:03 +0000 | [diff] [blame] | 86 | #ifdef SK_DEBUG |
| 87 | #define GR_GL_LOG_CALLS 1 |
| 88 | #else |
| 89 | #define GR_GL_LOG_CALLS 0 |
| 90 | #endif |
bsalomon@google.com | 3723a48 | 2011-02-17 21:47:25 +0000 | [diff] [blame] | 91 | #endif |
| 92 | |
| 93 | #if !defined(GR_GL_LOG_CALLS_START) |
bsalomon@google.com | 4bcb0c6 | 2012-02-07 16:06:47 +0000 | [diff] [blame] | 94 | #define GR_GL_LOG_CALLS_START 0 |
bsalomon@google.com | 3723a48 | 2011-02-17 21:47:25 +0000 | [diff] [blame] | 95 | #endif |
| 96 | |
reed@google.com | 27a1e77 | 2011-03-08 15:34:06 +0000 | [diff] [blame] | 97 | #if !defined(GR_GL_CHECK_ERROR) |
commit-bot@chromium.org | 515dcd3 | 2013-08-28 14:17:03 +0000 | [diff] [blame] | 98 | #ifdef SK_DEBUG |
| 99 | #define GR_GL_CHECK_ERROR 1 |
| 100 | #else |
| 101 | #define GR_GL_CHECK_ERROR 0 |
| 102 | #endif |
bsalomon@google.com | 3723a48 | 2011-02-17 21:47:25 +0000 | [diff] [blame] | 103 | #endif |
| 104 | |
| 105 | #if !defined(GR_GL_CHECK_ERROR_START) |
bsalomon@google.com | 4bcb0c6 | 2012-02-07 16:06:47 +0000 | [diff] [blame] | 106 | #define GR_GL_CHECK_ERROR_START 1 |
bsalomon@google.com | 4be283f | 2011-04-19 21:15:09 +0000 | [diff] [blame] | 107 | #endif |
| 108 | |
joshualitt | 6df232d | 2015-10-23 13:54:12 -0700 | [diff] [blame] | 109 | #if !defined(GR_GL_USE_BUFFER_DATA_NULL_HINT) |
| 110 | #define GR_GL_USE_BUFFER_DATA_NULL_HINT 1 |
| 111 | #endif |
| 112 | |
bsalomon@google.com | 4f3c253 | 2012-01-19 16:16:52 +0000 | [diff] [blame] | 113 | #if !defined(GR_GL_CHECK_ALLOC_WITH_GET_ERROR) |
bsalomon@google.com | 4bcb0c6 | 2012-02-07 16:06:47 +0000 | [diff] [blame] | 114 | #define GR_GL_CHECK_ALLOC_WITH_GET_ERROR 1 |
| 115 | #endif |
| 116 | |
| 117 | #if !defined(GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT) |
| 118 | #define GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT 0 |
bsalomon@google.com | 4f3c253 | 2012-01-19 16:16:52 +0000 | [diff] [blame] | 119 | #endif |
| 120 | |
bsalomon@google.com | 96966a5 | 2013-02-21 16:34:21 +0000 | [diff] [blame] | 121 | #if !defined(GR_GL_MUST_USE_VBO) |
| 122 | #define GR_GL_MUST_USE_VBO 0 |
| 123 | #endif |
| 124 | |
bsalomon@google.com | 26fb61a | 2013-02-28 19:26:04 +0000 | [diff] [blame] | 125 | #if !defined(GR_GL_USE_NEW_SHADER_SOURCE_SIGNATURE) |
| 126 | #define GR_GL_USE_NEW_SHADER_SOURCE_SIGNATURE 0 |
| 127 | #endif |
| 128 | |
reed@google.com | 27a1e77 | 2011-03-08 15:34:06 +0000 | [diff] [blame] | 129 | #endif |