Changeset 208997 in webkit
- Timestamp:
- Nov 28, 2016 7:00:41 AM (7 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r208995 r208997 1 2016-11-28 Miguel Gomez <magomez@igalia.com> 2 3 [GTK] Dramatic increase on memory usage since 2.14.x 4 https://bugs.webkit.org/show_bug.cgi?id=164049 5 6 Reviewed by Žan Doberšek. 7 8 Use OpenGL version 3.2 Core for rendering when available. 9 Update some operations that have changed when using 3.2 Core: 10 - Use glGetStringi to get the extensions list. 11 - Do not use GL_POINT_SPRITE. 12 - Always use a VAO when rendering. 13 - Use a GLSL 1.50 compatible shader. 14 15 No new tests needed. 16 17 * platform/graphics/GLContext.cpp: 18 (WebCore::GLContext::version): 19 Add a method to get OpenGL version we are using. 20 * platform/graphics/GLContext.h: 21 Ditto. 22 * platform/graphics/GraphicsContext3D.h: 23 Add an attribute to store the VAO used for rendering. 24 * platform/graphics/OpenGLShims.cpp: 25 (WebCore::initializeOpenGLShims): 26 Add glGetStringi to the list of functions. 27 * platform/graphics/OpenGLShims.h: 28 Ditto. 29 * platform/graphics/cairo/GraphicsContext3DCairo.cpp: 30 (WebCore::GraphicsContext3D::GraphicsContext3D): 31 Set appropriate output to the shader compiler and initalize the VAO if needed. 32 (WebCore::GraphicsContext3D::~GraphicsContext3D): 33 Delete the VAO if needed. 34 (WebCore::GraphicsContext3D::getExtensions): 35 Use glGetExtensionsi for OpenGL versions >= 3.2. 36 * platform/graphics/glx/GLContextGLX.cpp: 37 (WebCore::hasGLXARBCreateContextExtension): 38 Check whether the GLX_ARB_create_context extension is available. 39 (WebCore::GLContextGLX::createWindowContext): 40 Use glXCreateContextAttribsARB() if possible to request an OpenGL 3.2 context. 41 (WebCore::GLContextGLX::createPbufferContext): 42 Ditto. 43 * platform/graphics/opengl/Extensions3DOpenGLCommon.cpp: 44 (WebCore::Extensions3DOpenGLCommon::initializeAvailableExtensions): 45 Enable glGetStringi for GTK. 46 * platform/graphics/opengl/GraphicsContext3DOpenGL.cpp: 47 Do not use default getExtensions() method for GTK. 48 * platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp: 49 Ditto. 50 1 51 2016-11-24 Sergio Villar Senin <svillar@igalia.com> 2 52 -
trunk/Source/WebCore/platform/graphics/GLContext.cpp
r207615 r208997 161 161 } 162 162 163 unsigned GLContext::version() 164 { 165 if (!m_version) { 166 GC3Dint major = 0; 167 GC3Dint minor = 0; 168 ::glGetIntegerv(GL_MAJOR_VERSION, &major); 169 ::glGetIntegerv(GL_MINOR_VERSION, &minor); 170 m_version = major * 100 + minor * 10; 171 } 172 return m_version; 173 } 174 163 175 } // namespace WebCore 164 176 -
trunk/Source/WebCore/platform/graphics/GLContext.h
r207615 r208997 48 48 49 49 PlatformDisplay& display() const { return m_display; } 50 unsigned version(); 50 51 51 52 virtual ~GLContext(); … … 78 79 79 80 PlatformDisplay& m_display; 81 unsigned m_version { 0 }; 80 82 }; 81 83 -
trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h
r208910 r208997 1437 1437 1438 1438 bool m_isForWebGL2 { false }; 1439 1440 #if USE(CAIRO) 1441 Platform3DObject m_vao { 0 }; 1442 #endif 1443 1439 1444 }; 1440 1445 -
trunk/Source/WebCore/platform/graphics/OpenGLShims.cpp
r183432 r208997 163 163 ASSIGN_FUNCTION_TABLE_ENTRY(glGetShaderiv, success); 164 164 ASSIGN_FUNCTION_TABLE_ENTRY(glGetShaderSource, success); 165 // glGetStringi is only available on OpenGL or GLES versions >= 3.0. 166 // Add it with _EXT so it doesn't cause an initialization failure on lower versions. 167 ASSIGN_FUNCTION_TABLE_ENTRY_EXT(glGetStringi); 165 168 ASSIGN_FUNCTION_TABLE_ENTRY(glGetUniformfv, success); 166 169 ASSIGN_FUNCTION_TABLE_ENTRY(glGetUniformiv, success); -
trunk/Source/WebCore/platform/graphics/OpenGLShims.h
r164525 r208997 93 93 typedef void (GLAPIENTRY *glGetShaderivType) (GLuint, GLenum, GLint*); 94 94 typedef void (GLAPIENTRY *glGetShaderSourceType) (GLuint, GLsizei, GLsizei*, char*); 95 typedef const GLubyte* (GLAPIENTRY *glGetStringiType) (GLenum, GLuint); 95 96 typedef GLint (GLAPIENTRY *glGetUniformLocationType) (GLuint, const char*); 96 97 typedef void (GLAPIENTRY *glGetUniformfvType) (GLuint, GLint, GLfloat*); … … 199 200 FUNCTION_TABLE_ENTRY(glGetShaderiv); 200 201 FUNCTION_TABLE_ENTRY(glGetShaderSource); 202 FUNCTION_TABLE_ENTRY(glGetStringi); 201 203 FUNCTION_TABLE_ENTRY(glGetUniformfv); 202 204 FUNCTION_TABLE_ENTRY(glGetUniformiv); … … 326 328 #define glGetShaderiv LOOKUP_GL_FUNCTION(glGetShaderiv) 327 329 #define glGetShaderSource LOOKUP_GL_FUNCTION(glGetShaderSource) 330 #define glGetStringi LOOKUP_GL_FUNCTION(glGetStringi) 328 331 #define glGetUniformfv LOOKUP_GL_FUNCTION(glGetUniformfv) 329 332 #define glGetUniformiv LOOKUP_GL_FUNCTION(glGetUniformiv) -
trunk/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp
r207332 r208997 80 80 : m_currentWidth(0) 81 81 , m_currentHeight(0) 82 , m_compiler(isGLES2Compliant() ? SH_ESSL_OUTPUT : SH_GLSL_COMPATIBILITY_OUTPUT)83 82 , m_attrs(attributes) 84 83 , m_texture(0) … … 146 145 } 147 146 147 #if !USE(OPENGL_ES_2) 148 ::glEnable(GL_VERTEX_PROGRAM_POINT_SIZE); 149 150 if (GLContext::current()->version() >= 320) { 151 // From version 3.2 on we use the OpenGL Core profile, so request that ouput to the shader compiler. 152 // OpenGL version 3.2 uses GLSL version 1.50. 153 m_compiler = ANGLEWebKitBridge(SH_GLSL_150_CORE_OUTPUT); 154 155 // From version 3.2 on we use the OpenGL Core profile, and we need a VAO for rendering. 156 // A VAO could be created and bound by each component using GL rendering (TextureMapper, WebGL, etc). This is 157 // a simpler solution: the first GraphicsContext3D created on a GLContext will create and bind a VAO for that context. 158 GC3Dint currentVAO = 0; 159 getIntegerv(GraphicsContext3D::VERTEX_ARRAY_BINDING, ¤tVAO); 160 if (!currentVAO) { 161 m_vao = createVertexArray(); 162 bindVertexArray(m_vao); 163 } 164 } else { 165 // For lower versions request the compatibility output to the shader compiler. 166 m_compiler = ANGLEWebKitBridge(SH_GLSL_COMPATIBILITY_OUTPUT); 167 168 // GL_POINT_SPRITE is needed in lower versions. 169 ::glEnable(GL_POINT_SPRITE); 170 } 171 #else 172 m_compiler = ANGLEWebKitBridge(SH_ESSL_OUTPUT); 173 #endif 174 148 175 // ANGLE initialization. 149 176 ShBuiltInResources ANGLEResources; … … 166 193 167 194 m_compiler.setResources(ANGLEResources); 168 169 #if !USE(OPENGL_ES_2)170 ::glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);171 ::glEnable(GL_POINT_SPRITE);172 #endif173 195 174 196 ::glClearColor(0, 0, 0, 0); … … 199 221 ::glDeleteTextures(1, &m_intermediateTexture); 200 222 #endif 223 224 if (m_vao) 225 deleteVertexArray(m_vao); 201 226 } 202 227 … … 345 370 } 346 371 372 #if PLATFORM(GTK) 373 Extensions3D& GraphicsContext3D::getExtensions() 374 { 375 if (!m_extensions) { 376 #if USE(OPENGL_ES_2) 377 // glGetStringi is not available on GLES2. 378 m_extensions = std::make_unique<Extensions3DOpenGLES>(this, false); 379 #else 380 // From OpenGL 3.2 on we use the Core profile, and there we must use glGetStringi. 381 m_extensions = std::make_unique<Extensions3DOpenGL>(this, GLContext::current()->version() >= 320); 382 #endif 383 } 384 return *m_extensions; 385 } 386 #endif 387 347 388 } // namespace WebCore 348 389 -
trunk/Source/WebCore/platform/graphics/glx/GLContextGLX.cpp
r207615 r208997 36 36 typedef int (*PFNGLXSWAPINTERVALSGIPROC) (int); 37 37 #endif 38 #if !defined(PFNGLXCREATECONTEXTATTRIBSARBPROC) 39 typedef GLXContext (*PFNGLXCREATECONTEXTATTRIBSARBPROC) (Display *dpy, GLXFBConfig config, GLXContext share_context, Bool direct, const int *attrib_list); 40 #endif 38 41 39 42 static PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalSGI; 43 static PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribsARB; 40 44 41 45 static bool hasSGISwapControlExtension(Display* display) … … 53 57 } 54 58 59 static bool hasGLXARBCreateContextExtension(Display* display) 60 { 61 static bool initialized = false; 62 if (initialized) 63 return !!glXCreateContextAttribsARB; 64 65 initialized = true; 66 if (!GLContext::isExtensionSupported(glXQueryExtensionsString(display, 0), "GLX_ARB_create_context")) 67 return false; 68 69 glXCreateContextAttribsARB = reinterpret_cast<PFNGLXCREATECONTEXTATTRIBSARBPROC>(glXGetProcAddress(reinterpret_cast<const unsigned char*>("glXCreateContextAttribsARB"))); 70 return !!glXCreateContextAttribsARB; 71 } 72 55 73 std::unique_ptr<GLContextGLX> GLContextGLX::createWindowContext(GLNativeWindowType window, PlatformDisplay& platformDisplay, GLXContext sharingContext) 56 74 { … … 63 81 visualInfo.visualid = XVisualIDFromVisual(attributes.visual); 64 82 65 int numReturned = 0; 66 XUniquePtr<XVisualInfo> visualInfoList(XGetVisualInfo(display, VisualIDMask, &visualInfo, &numReturned)); 67 68 XUniqueGLXContext context(glXCreateContext(display, visualInfoList.get(), sharingContext, True)); 83 int numConfigs = 0; 84 GLXFBConfig config = nullptr; 85 XUniquePtr<GLXFBConfig> configs(glXGetFBConfigs(display, DefaultScreen(display), &numConfigs)); 86 for (int i = 0; i < numConfigs; i++) { 87 XUniquePtr<XVisualInfo> glxVisualInfo(glXGetVisualFromFBConfig(display, configs.get()[i])); 88 if (!glxVisualInfo) 89 continue; 90 91 if (glxVisualInfo.get()->visualid == visualInfo.visualid) { 92 config = configs.get()[i]; 93 break; 94 } 95 } 96 ASSERT(config); 97 98 XUniqueGLXContext context; 99 if (hasGLXARBCreateContextExtension(display)) { 100 // Request OpenGL version 3.2 and core profile, which guarantees that the i965 driver doesn't use the software renderer. 101 static const int contextAttributes[] = { 102 GLX_CONTEXT_MAJOR_VERSION_ARB, 3, 103 GLX_CONTEXT_MINOR_VERSION_ARB, 2, 104 0 105 }; 106 context.reset(glXCreateContextAttribsARB(display, config, sharingContext, GL_TRUE, contextAttributes)); 107 } 108 109 if (!context) { 110 // Fallback to legacy OpenGL version. 111 XUniquePtr<XVisualInfo> visualInfoList(glXGetVisualFromFBConfig(display, config)); 112 context.reset(glXCreateContext(display, visualInfoList.get(), sharingContext, True)); 113 } 114 69 115 if (!context) 70 116 return nullptr; … … 98 144 return nullptr; 99 145 100 XUniqueGLXContext context(glXCreateNewContext(display, configs.get()[0], GLX_RGBA_TYPE, sharingContext, GL_TRUE)); 146 XUniqueGLXContext context; 147 148 if (hasGLXARBCreateContextExtension(display)) { 149 // Request OpenGL version 3.2 and core profile, which guarantees that the i965 driver doesn't use the software renderer. 150 static const int contextAttributes[] = { 151 GLX_CONTEXT_MAJOR_VERSION_ARB, 3, 152 GLX_CONTEXT_MINOR_VERSION_ARB, 2, 153 0 154 }; 155 context.reset(glXCreateContextAttribsARB(display, configs.get()[0], sharingContext, GL_TRUE, contextAttributes)); 156 } 157 158 if (!context) { 159 // Fallback to legacy OpenGL version. 160 context.reset(glXCreateNewContext(display, configs.get()[0], GLX_RGBA_TYPE, sharingContext, GL_TRUE)); 161 } 162 101 163 if (!context) 102 164 return nullptr; -
trunk/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp
r208910 r208997 210 210 void Extensions3DOpenGLCommon::initializeAvailableExtensions() 211 211 { 212 #if PLATFORM(MAC) 212 #if PLATFORM(MAC) || PLATFORM(GTK) 213 213 if (m_useIndexedGetString) { 214 214 GLint numExtensions = 0; -
trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp
r208740 r208997 408 408 } 409 409 410 #if !PLATFORM(GTK) 410 411 Extensions3D& GraphicsContext3D::getExtensions() 411 412 { … … 414 415 return *m_extensions; 415 416 } 417 #endif 416 418 417 419 void GraphicsContext3D::readPixels(GC3Dint x, GC3Dint y, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, void* data) -
trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp
r208873 r208997 239 239 } 240 240 241 #if !PLATFORM(GTK) 241 242 Extensions3D& GraphicsContext3D::getExtensions() 242 243 { … … 245 246 return *m_extensions; 246 247 } 248 #endif 247 249 248 250 }
Note: See TracChangeset
for help on using the changeset viewer.