gfx/skia/trunk/include/gpu/gl/GrGLConfig.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/skia/trunk/include/gpu/gl/GrGLConfig.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,194 @@
     1.4 +
     1.5 +/*
     1.6 + * Copyright 2011 Google Inc.
     1.7 + *
     1.8 + * Use of this source code is governed by a BSD-style license that can be
     1.9 + * found in the LICENSE file.
    1.10 + */
    1.11 +
    1.12 +
    1.13 +
    1.14 +#ifndef GrGLConfig_DEFINED
    1.15 +#define GrGLConfig_DEFINED
    1.16 +
    1.17 +#include "GrTypes.h"
    1.18 +
    1.19 +/**
    1.20 + * Optional GL config file.
    1.21 + */
    1.22 +#ifdef GR_GL_CUSTOM_SETUP_HEADER
    1.23 +    #include GR_GL_CUSTOM_SETUP_HEADER
    1.24 +#endif
    1.25 +
    1.26 +#if !defined(GR_GL_FUNCTION_TYPE)
    1.27 +    #define GR_GL_FUNCTION_TYPE
    1.28 +#endif
    1.29 +
    1.30 +/**
    1.31 + * The following are optional defines that can be enabled at the compiler
    1.32 + * command line, in a IDE project, in a GrUserConfig.h file, or in a GL custom
    1.33 + * file (if one is in use). If a GR_GL_CUSTOM_SETUP_HEADER is used they can
    1.34 + * also be placed there.
    1.35 + *
    1.36 + * GR_GL_LOG_CALLS: if 1 Gr can print every GL call using GrPrintf. Defaults to
    1.37 + * 0. Logging can be enabled and disabled at runtime using a debugger via to
    1.38 + * global gLogCallsGL. The initial value of gLogCallsGL is controlled by
    1.39 + * GR_GL_LOG_CALLS_START.
    1.40 + *
    1.41 + * GR_GL_LOG_CALLS_START: controls the initial value of gLogCallsGL when
    1.42 + * GR_GL_LOG_CALLS is 1. Defaults to 0.
    1.43 + *
    1.44 + * GR_GL_CHECK_ERROR: if enabled Gr can do a glGetError() after every GL call.
    1.45 + * Defaults to 1 if SK_DEBUG is set, otherwise 0. When GR_GL_CHECK_ERROR is 1
    1.46 + * this can be toggled in a debugger using the gCheckErrorGL global. The initial
    1.47 + * value of gCheckErrorGL is controlled by by GR_GL_CHECK_ERROR_START.
    1.48 + *
    1.49 + * GR_GL_CHECK_ERROR_START: controls the initial value of gCheckErrorGL
    1.50 + * when GR_GL_CHECK_ERROR is 1.  Defaults to 1.
    1.51 + *
    1.52 + * GR_GL_NO_CONSTANT_ATTRIBUTES: if this evaluates to true then the GL backend
    1.53 + * will use uniforms instead of attributes in all cases when there is not
    1.54 + * per-vertex data. This is important when the underlying GL implementation
    1.55 + * doesn't actually support immediate style attribute values (e.g. when
    1.56 + * the GL stream is converted to DX as in ANGLE on Chrome). Defaults to 0.
    1.57 + *
    1.58 + * GR_GL_USE_BUFFER_DATA_NULL_HINT: When specifing new data for a vertex/index
    1.59 + * buffer that replaces old data Ganesh can give a hint to the driver that the
    1.60 + * previous data will not be used in future draws like this:
    1.61 + *  glBufferData(GL_..._BUFFER, size, NULL, usage);       //<--hint, NULL means
    1.62 + *  glBufferSubData(GL_..._BUFFER, 0, lessThanSize, data) //   old data can't be
    1.63 + *                                                        //   used again.
    1.64 + * However, this can be an unoptimization on some platforms, esp. Chrome.
    1.65 + * Chrome's cmd buffer will create a new allocation and memset the whole thing
    1.66 + * to zero (for security reasons). Defaults to 1 (enabled).
    1.67 + *
    1.68 + * GR_GL_PER_GL_FUNC_CALLBACK: When set to 1 the GrGLInterface object provides
    1.69 + * a function pointer that is called just before every gl function. The ptr must
    1.70 + * be valid (i.e. there is no NULL check). However, by default the callback will
    1.71 + * be set to a function that does nothing. The signature of the function is:
    1.72 + *    void function(const GrGLInterface*)
    1.73 + * It is not extern "C".
    1.74 + * The GrGLInterface field fCallback specifies the function ptr and there is an
    1.75 + * additional field fCallbackData of type intptr_t for client data.
    1.76 + *
    1.77 + * GR_GL_RGBA_8888_PIXEL_OPS_SLOW: Set this to 1 if it is known that performing
    1.78 + * glReadPixels / glTex(Sub)Image with format=GL_RGBA, type=GL_UNISIGNED_BYTE is
    1.79 + * significantly slower than format=GL_BGRA, type=GL_UNISIGNED_BYTE.
    1.80 + *
    1.81 + * GR_GL_FULL_READPIXELS_FASTER_THAN_PARTIAL: Set this to 1 if calling
    1.82 + * glReadPixels to read the entire framebuffer is faster than calling it with
    1.83 + * the same sized rectangle but with a framebuffer bound that is larger than
    1.84 + * the rectangle read.
    1.85 + *
    1.86 + * GR_GL_CHECK_ALLOC_WITH_GET_ERROR: If set to 1 this will then glTexImage,
    1.87 + * glBufferData, glRenderbufferStorage, etc will be checked for errors. This
    1.88 + * amounts to ensuring the error is GL_NO_ERROR, calling the allocating
    1.89 + * function, and then checking that the error is still GL_NO_ERROR. When the
    1.90 + * value is 0 we will assume no error was generated without checking.
    1.91 + *
    1.92 + * GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT: We will normally check the FBO status
    1.93 + * every time we bind a texture or renderbuffer to an FBO. However, in some
    1.94 + * environments CheckFrameBufferStatus is very expensive. If this is set we will
    1.95 + * check the first time we use a color format or a combination of color /
    1.96 + * stencil formats as attachments. If the FBO is complete we will assume
    1.97 + * subsequent attachments with the same formats are complete as well.
    1.98 + *
    1.99 + * GR_GL_MUST_USE_VBO: Indicates that all vertices and indices must be rendered
   1.100 + * from VBOs. Chromium's command buffer doesn't allow glVertexAttribArray with
   1.101 + * ARARY_BUFFER 0 bound or glDrawElements with ELEMENT_ARRAY_BUFFER 0 bound.
   1.102 + *
   1.103 + * GR_GL_USE_NEW_SHADER_SOURCE_SIGNATURE is for compatibility with the new version
   1.104 + * of the OpenGLES2.0 headers from Khronos.  glShaderSource now takes a const char * const *,
   1.105 + * instead of a const char
   1.106 + */
   1.107 +
   1.108 +#if !defined(GR_GL_LOG_CALLS)
   1.109 +    #ifdef SK_DEBUG
   1.110 +        #define GR_GL_LOG_CALLS 1
   1.111 +    #else
   1.112 +        #define GR_GL_LOG_CALLS 0
   1.113 +    #endif
   1.114 +#endif
   1.115 +
   1.116 +#if !defined(GR_GL_LOG_CALLS_START)
   1.117 +    #define GR_GL_LOG_CALLS_START                       0
   1.118 +#endif
   1.119 +
   1.120 +#if !defined(GR_GL_CHECK_ERROR)
   1.121 +    #ifdef SK_DEBUG
   1.122 +        #define GR_GL_CHECK_ERROR 1
   1.123 +    #else
   1.124 +        #define GR_GL_CHECK_ERROR 0
   1.125 +    #endif
   1.126 +#endif
   1.127 +
   1.128 +#if !defined(GR_GL_CHECK_ERROR_START)
   1.129 +    #define GR_GL_CHECK_ERROR_START                     1
   1.130 +#endif
   1.131 +
   1.132 +#if !defined(GR_GL_NO_CONSTANT_ATTRIBUTES)
   1.133 +    #define GR_GL_NO_CONSTANT_ATTRIBUTES                0
   1.134 +#endif
   1.135 +
   1.136 +#if !defined(GR_GL_USE_BUFFER_DATA_NULL_HINT)
   1.137 +    #define GR_GL_USE_BUFFER_DATA_NULL_HINT             1
   1.138 +#endif
   1.139 +
   1.140 +#if !defined(GR_GL_PER_GL_FUNC_CALLBACK)
   1.141 +    #define GR_GL_PER_GL_FUNC_CALLBACK                  0
   1.142 +#endif
   1.143 +
   1.144 +#if !defined(GR_GL_RGBA_8888_PIXEL_OPS_SLOW)
   1.145 +    #define GR_GL_RGBA_8888_PIXEL_OPS_SLOW              0
   1.146 +#endif
   1.147 +
   1.148 +#if !defined(GR_GL_FULL_READPIXELS_FASTER_THAN_PARTIAL)
   1.149 +    #define GR_GL_FULL_READPIXELS_FASTER_THAN_PARTIAL   0
   1.150 +#endif
   1.151 +
   1.152 +#if !defined(GR_GL_CHECK_ALLOC_WITH_GET_ERROR)
   1.153 +    #define GR_GL_CHECK_ALLOC_WITH_GET_ERROR            1
   1.154 +#endif
   1.155 +
   1.156 +#if !defined(GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT)
   1.157 +    #define GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT      0
   1.158 +#endif
   1.159 +
   1.160 +#if !defined(GR_GL_MUST_USE_VBO)
   1.161 +    #define GR_GL_MUST_USE_VBO                          0
   1.162 +#endif
   1.163 +
   1.164 +#if !defined(GR_GL_USE_NEW_SHADER_SOURCE_SIGNATURE)
   1.165 +    #define GR_GL_USE_NEW_SHADER_SOURCE_SIGNATURE       0
   1.166 +#endif
   1.167 +
   1.168 +/**
   1.169 + * There is a strange bug that occurs on Macs with NVIDIA GPUs. We don't
   1.170 + * fully understand it. When (element) array buffers are continually
   1.171 + * respecified using glBufferData performance can fall off of a cliff. The
   1.172 + * driver winds up performing many DMA mapping / unmappings and chews up ~50% of
   1.173 + * the core. However, it has been observed that occaisonally respecifiying the
   1.174 + * buffer using glBufferData and then writing data using glBufferSubData
   1.175 + * prevents the bad behavior.
   1.176 + *
   1.177 + * There is a lot of uncertainty around this issue. In Chrome backgrounding
   1.178 + * the tab somehow initiates this behavior and we don't know what the connection
   1.179 + * is. Another observation is that Chrome's cmd buffer server will actually
   1.180 + * create a buffer full of zeros when it sees a NULL data param (for security
   1.181 + * reasons). If this is disabled and NULL is actually passed all the way to the
   1.182 + * driver then the workaround doesn't help.
   1.183 + *
   1.184 + * The issue is tracked at:
   1.185 + * http://code.google.com/p/chromium/issues/detail?id=114865
   1.186 + *
   1.187 + * When the workaround is enabled we will use the glBufferData / glBufferSubData
   1.188 + * trick every 128 array buffer uploads.
   1.189 + *
   1.190 + * Hopefully we will understand this better and have a cleaner fix or get a
   1.191 + * OS/driver level fix.
   1.192 + */
   1.193 +#define GR_GL_MAC_BUFFER_OBJECT_PERFOMANCE_WORKAROUND   \
   1.194 +    (defined(SK_BUILD_FOR_MAC) &&                       \
   1.195 +     !GR_GL_USE_BUFFER_DATA_NULL_HINT)
   1.196 +
   1.197 +#endif

mercurial