blob: c91537cc380a891f2023527bb58b9519bb1ccfac [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
reed@google.comac10a2d2010-12-22 21:39:39 +00002/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00003 * 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.comac10a2d2010-12-22 21:39:39 +00007 */
8
9
epoger@google.comec3ed6a2011-07-28 14:26:00 +000010
reed@google.comac10a2d2010-12-22 21:39:39 +000011#ifndef GrGLConfig_DEFINED
12#define GrGLConfig_DEFINED
13
14#include "GrTypes.h"
15
bsalomon@google.com42ab7ea2011-01-19 17:19:40 +000016/**
bsalomon@google.comf987d1b2011-04-04 17:13:52 +000017 * Optional GL config file.
twiz@google.comb65e0cb2011-03-18 20:41:44 +000018 */
bsalomon@google.comf987d1b2011-04-04 17:13:52 +000019#ifdef GR_GL_CUSTOM_SETUP_HEADER
20 #include GR_GL_CUSTOM_SETUP_HEADER
21#endif
22
23#if !defined(GR_GL_FUNCTION_TYPE)
24 #define GR_GL_FUNCTION_TYPE
25#endif
twiz@google.comb65e0cb2011-03-18 20:41:44 +000026
27/**
bsalomon@google.com3723a482011-02-17 21:47:25 +000028 * The following are optional defines that can be enabled at the compiler
29 * command line, in a IDE project, in a GrUserConfig.h file, or in a GL custom
bsalomon@google.comf987d1b2011-04-04 17:13:52 +000030 * file (if one is in use). If a GR_GL_CUSTOM_SETUP_HEADER is used they can
31 * also be placed there.
bsalomon@google.com7acdb8e2011-02-11 14:07:02 +000032 *
tfarina38406c82014-10-31 07:11:12 -070033 * GR_GL_LOG_CALLS: if 1 Gr can print every GL call using SkDebugf. Defaults to
reed@google.com27a1e772011-03-08 15:34:06 +000034 * 0. Logging can be enabled and disabled at runtime using a debugger via to
bsalomon@google.com3723a482011-02-17 21:47:25 +000035 * global gLogCallsGL. The initial value of gLogCallsGL is controlled by
36 * GR_GL_LOG_CALLS_START.
37 *
38 * GR_GL_LOG_CALLS_START: controls the initial value of gLogCallsGL when
39 * GR_GL_LOG_CALLS is 1. Defaults to 0.
40 *
41 * GR_GL_CHECK_ERROR: if enabled Gr can do a glGetError() after every GL call.
commit-bot@chromium.org515dcd32013-08-28 14:17:03 +000042 * Defaults to 1 if SK_DEBUG is set, otherwise 0. When GR_GL_CHECK_ERROR is 1
bsalomon@google.com3723a482011-02-17 21:47:25 +000043 * this can be toggled in a debugger using the gCheckErrorGL global. The initial
44 * value of gCheckErrorGL is controlled by by GR_GL_CHECK_ERROR_START.
45 *
46 * GR_GL_CHECK_ERROR_START: controls the initial value of gCheckErrorGL
47 * when GR_GL_CHECK_ERROR is 1. Defaults to 1.
bsalomon@google.com4be283f2011-04-19 21:15:09 +000048 *
bsalomon@google.com9ae44292011-07-01 15:21:59 +000049 * GR_GL_USE_BUFFER_DATA_NULL_HINT: When specifing new data for a vertex/index
50 * buffer that replaces old data Ganesh can give a hint to the driver that the
51 * previous data will not be used in future draws like this:
52 * glBufferData(GL_..._BUFFER, size, NULL, usage); //<--hint, NULL means
53 * glBufferSubData(GL_..._BUFFER, 0, lessThanSize, data) // old data can't be
54 * // used again.
bsalomon@google.com96e96df2011-10-10 14:49:29 +000055 * However, this can be an unoptimization on some platforms, esp. Chrome.
56 * Chrome's cmd buffer will create a new allocation and memset the whole thing
57 * to zero (for security reasons). Defaults to 1 (enabled).
bsalomon@google.com56bfc5a2011-09-01 13:28:16 +000058 *
59 * GR_GL_PER_GL_FUNC_CALLBACK: When set to 1 the GrGLInterface object provides
60 * a function pointer that is called just before every gl function. The ptr must
61 * be valid (i.e. there is no NULL check). However, by default the callback will
62 * be set to a function that does nothing. The signature of the function is:
63 * void function(const GrGLInterface*)
64 * It is not extern "C".
65 * The GrGLInterface field fCallback specifies the function ptr and there is an
66 * additional field fCallbackData of type intptr_t for client data.
bsalomon@google.com0a97be22011-11-08 19:20:57 +000067 *
bsalomon@google.com4f3c2532012-01-19 16:16:52 +000068 * GR_GL_CHECK_ALLOC_WITH_GET_ERROR: If set to 1 this will then glTexImage,
69 * glBufferData, glRenderbufferStorage, etc will be checked for errors. This
70 * amounts to ensuring the error is GL_NO_ERROR, calling the allocating
71 * function, and then checking that the error is still GL_NO_ERROR. When the
72 * value is 0 we will assume no error was generated without checking.
bsalomon@google.com4bcb0c62012-02-07 16:06:47 +000073 *
74 * GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT: We will normally check the FBO status
75 * every time we bind a texture or renderbuffer to an FBO. However, in some
76 * environments CheckFrameBufferStatus is very expensive. If this is set we will
77 * check the first time we use a color format or a combination of color /
78 * stencil formats as attachments. If the FBO is complete we will assume
79 * subsequent attachments with the same formats are complete as well.
bsalomon@google.comded4f4b2012-06-28 18:48:06 +000080 *
bsalomon@google.com96966a52013-02-21 16:34:21 +000081 * GR_GL_MUST_USE_VBO: Indicates that all vertices and indices must be rendered
82 * from VBOs. Chromium's command buffer doesn't allow glVertexAttribArray with
83 * ARARY_BUFFER 0 bound or glDrawElements with ELEMENT_ARRAY_BUFFER 0 bound.
bsalomon@google.com26fb61a2013-02-28 19:26:04 +000084 *
85 * GR_GL_USE_NEW_SHADER_SOURCE_SIGNATURE is for compatibility with the new version
86 * of the OpenGLES2.0 headers from Khronos. glShaderSource now takes a const char * const *,
87 * instead of a const char
bsalomon@google.com42ab7ea2011-01-19 17:19:40 +000088 */
89
bsalomon@google.com7acdb8e2011-02-11 14:07:02 +000090#if !defined(GR_GL_LOG_CALLS)
commit-bot@chromium.org515dcd32013-08-28 14:17:03 +000091 #ifdef SK_DEBUG
92 #define GR_GL_LOG_CALLS 1
93 #else
94 #define GR_GL_LOG_CALLS 0
95 #endif
bsalomon@google.com3723a482011-02-17 21:47:25 +000096#endif
97
98#if !defined(GR_GL_LOG_CALLS_START)
bsalomon@google.com4bcb0c62012-02-07 16:06:47 +000099 #define GR_GL_LOG_CALLS_START 0
bsalomon@google.com3723a482011-02-17 21:47:25 +0000100#endif
101
reed@google.com27a1e772011-03-08 15:34:06 +0000102#if !defined(GR_GL_CHECK_ERROR)
commit-bot@chromium.org515dcd32013-08-28 14:17:03 +0000103 #ifdef SK_DEBUG
104 #define GR_GL_CHECK_ERROR 1
105 #else
106 #define GR_GL_CHECK_ERROR 0
107 #endif
bsalomon@google.com3723a482011-02-17 21:47:25 +0000108#endif
109
110#if !defined(GR_GL_CHECK_ERROR_START)
bsalomon@google.com4bcb0c62012-02-07 16:06:47 +0000111 #define GR_GL_CHECK_ERROR_START 1
bsalomon@google.com4be283f2011-04-19 21:15:09 +0000112#endif
113
joshualitt6df232d2015-10-23 13:54:12 -0700114#if !defined(GR_GL_USE_BUFFER_DATA_NULL_HINT)
115 #define GR_GL_USE_BUFFER_DATA_NULL_HINT 1
116#endif
117
bsalomon@google.com56bfc5a2011-09-01 13:28:16 +0000118#if !defined(GR_GL_PER_GL_FUNC_CALLBACK)
bsalomon@google.com4bcb0c62012-02-07 16:06:47 +0000119 #define GR_GL_PER_GL_FUNC_CALLBACK 0
bsalomon@google.com9ae44292011-07-01 15:21:59 +0000120#endif
121
bsalomon@google.com4f3c2532012-01-19 16:16:52 +0000122#if !defined(GR_GL_CHECK_ALLOC_WITH_GET_ERROR)
bsalomon@google.com4bcb0c62012-02-07 16:06:47 +0000123 #define GR_GL_CHECK_ALLOC_WITH_GET_ERROR 1
124#endif
125
126#if !defined(GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT)
127 #define GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT 0
bsalomon@google.com4f3c2532012-01-19 16:16:52 +0000128#endif
129
bsalomon@google.com96966a52013-02-21 16:34:21 +0000130#if !defined(GR_GL_MUST_USE_VBO)
131 #define GR_GL_MUST_USE_VBO 0
132#endif
133
bsalomon@google.com26fb61a2013-02-28 19:26:04 +0000134#if !defined(GR_GL_USE_NEW_SHADER_SOURCE_SIGNATURE)
135 #define GR_GL_USE_NEW_SHADER_SOURCE_SIGNATURE 0
136#endif
137
reed@google.com27a1e772011-03-08 15:34:06 +0000138#endif