diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp')
-rw-r--r-- | Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp | 112 |
1 files changed, 70 insertions, 42 deletions
diff --git a/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp b/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp index 9b7c5ab65..d28d765df 100644 --- a/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp +++ b/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp @@ -26,7 +26,7 @@ #include "config.h" -#if USE(3D_GRAPHICS) +#if ENABLE(GRAPHICS_CONTEXT_3D) #include "Extensions3DOpenGLCommon.h" #include "ANGLEWebKitBridge.h" @@ -34,14 +34,18 @@ #if PLATFORM(IOS) #include <OpenGLES/ES2/glext.h> +#include <OpenGLES/ES3/gl.h> #else #if USE(OPENGL_ES_2) #include "OpenGLESShims.h" #include <GLES2/gl2.h> #include <GLES2/gl2ext.h> #elif PLATFORM(MAC) +#define GL_DO_NOT_WARN_IF_MULTI_GL_VERSION_HEADERS_INCLUDED #include <OpenGL/gl.h> -#elif PLATFORM(GTK) || PLATFORM(EFL) || PLATFORM(WIN) +#include <OpenGL/gl3.h> +#undef GL_DO_NOT_WARN_IF_MULTI_GL_VERSION_HEADERS_INCLUDED +#elif PLATFORM(GTK) || PLATFORM(WIN) #include "OpenGLShims.h" #endif #endif @@ -49,54 +53,39 @@ #include <wtf/MainThread.h> #include <wtf/Vector.h> -#if PLATFORM(WIN) || (PLATFORM(GTK) && OS(WINDOWS)) -#undef NO_ERROR -#endif - namespace WebCore { -Extensions3DOpenGLCommon::Extensions3DOpenGLCommon(GraphicsContext3D* context) +Extensions3DOpenGLCommon::Extensions3DOpenGLCommon(GraphicsContext3D* context, bool useIndexedGetString) : m_initializedAvailableExtensions(false) , m_context(context) , m_isNVIDIA(false) , m_isAMD(false) , m_isIntel(false) - , m_maySupportMultisampling(true) + , m_isImagination(false) , m_requiresBuiltInFunctionEmulation(false) + , m_requiresRestrictedMaximumTextureSize(false) + , m_useIndexedGetString(useIndexedGetString) { m_vendor = String(reinterpret_cast<const char*>(::glGetString(GL_VENDOR))); + m_renderer = String(reinterpret_cast<const char*>(::glGetString(GL_RENDERER))); Vector<String> vendorComponents; - m_vendor.lower().split(' ', vendorComponents); + m_vendor.convertToASCIILowercase().split(' ', vendorComponents); if (vendorComponents.contains("nvidia")) m_isNVIDIA = true; if (vendorComponents.contains("ati") || vendorComponents.contains("amd")) m_isAMD = true; if (vendorComponents.contains("intel")) m_isIntel = true; + if (vendorComponents.contains("imagination")) + m_isImagination = true; -#if PLATFORM(MAC) && !PLATFORM(IOS) +#if PLATFORM(MAC) if (m_isAMD || m_isIntel) m_requiresBuiltInFunctionEmulation = true; - // Currently in Mac we only allow multisampling if the vendor is NVIDIA, - // or if the vendor is AMD/ATI and the system is 10.7.2 and above. - - bool systemSupportsMultisampling = true; -#if !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED < 1080 - ASSERT(isMainThread()); - static SInt32 version; - if (!version) { - if (Gestalt(gestaltSystemVersion, &version) != noErr) - systemSupportsMultisampling = false; - } - // See https://bugs.webkit.org/show_bug.cgi?id=77922 for more details - if (systemSupportsMultisampling) - systemSupportsMultisampling = version >= 0x1072; -#endif // SNOW_LEOPARD and LION - - if (m_isAMD && !systemSupportsMultisampling) - m_maySupportMultisampling = false; + // Intel HD 3000 devices have problems with large textures. <rdar://problem/16649140> + m_requiresRestrictedMaximumTextureSize = m_renderer.startsWith("Intel HD Graphics 3000"); #endif } @@ -109,6 +98,12 @@ bool Extensions3DOpenGLCommon::supports(const String& name) if (!m_initializedAvailableExtensions) initializeAvailableExtensions(); + // We explicitly do not support this extension until + // we fix the following bug: + // https://bugs.webkit.org/show_bug.cgi?id=149734 + if (name == "GL_ANGLE_translated_shader_source") + return false; + return supportsExtension(name); } @@ -131,6 +126,22 @@ void Extensions3DOpenGLCommon::ensureEnabled(const String& name) m_context->getIntegerv(Extensions3D::MAX_DRAW_BUFFERS_EXT, &ANGLEResources.MaxDrawBuffers); compiler.setResources(ANGLEResources); } + } else if (name == "GL_EXT_shader_texture_lod") { + // Enable support in ANGLE (if not enabled already) + ANGLEWebKitBridge& compiler = m_context->m_compiler; + ShBuiltInResources ANGLEResources = compiler.getResources(); + if (!ANGLEResources.EXT_shader_texture_lod) { + ANGLEResources.EXT_shader_texture_lod = 1; + compiler.setResources(ANGLEResources); + } + } else if (name == "GL_EXT_frag_depth") { + // Enable support in ANGLE (if not enabled already) + ANGLEWebKitBridge& compiler = m_context->m_compiler; + ShBuiltInResources ANGLEResources = compiler.getResources(); + if (!ANGLEResources.EXT_frag_depth) { + ANGLEResources.EXT_frag_depth = 1; + compiler.setResources(ANGLEResources); + } } } @@ -174,22 +185,20 @@ String Extensions3DOpenGLCommon::getTranslatedShaderSourceANGLE(Platform3DObject String translatedShaderSource; String shaderInfoLog; - int extraCompileOptions = SH_MAP_LONG_VARIABLE_NAMES | SH_CLAMP_INDIRECT_ARRAY_BOUNDS | SH_UNFOLD_SHORT_CIRCUIT | SH_ENFORCE_PACKING_RESTRICTIONS; + int extraCompileOptions = SH_CLAMP_INDIRECT_ARRAY_BOUNDS | SH_UNFOLD_SHORT_CIRCUIT | SH_INIT_OUTPUT_VARIABLES | SH_ENFORCE_PACKING_RESTRICTIONS | SH_LIMIT_EXPRESSION_COMPLEXITY | SH_LIMIT_CALL_STACK_DEPTH; if (m_requiresBuiltInFunctionEmulation) - extraCompileOptions |= SH_EMULATE_BUILT_IN_FUNCTIONS; + extraCompileOptions |= SH_EMULATE_ABS_INT_FUNCTION; - Vector<ANGLEShaderSymbol> symbols; + Vector<std::pair<ANGLEShaderSymbolType, sh::ShaderVariable>> symbols; bool isValid = compiler.compileShaderSource(entry.source.utf8().data(), shaderType, translatedShaderSource, shaderInfoLog, symbols, extraCompileOptions); entry.log = shaderInfoLog; entry.isValid = isValid; - size_t numSymbols = symbols.size(); - for (size_t i = 0; i < numSymbols; ++i) { - ANGLEShaderSymbol shaderSymbol = symbols[i]; - GraphicsContext3D::SymbolInfo symbolInfo(shaderSymbol.dataType, shaderSymbol.size, shaderSymbol.mappedName, shaderSymbol.precision, shaderSymbol.staticUse); - entry.symbolMap(shaderSymbol.symbolType).set(shaderSymbol.name, symbolInfo); + for (const std::pair<ANGLEShaderSymbolType, sh::ShaderVariable>& pair : symbols) { + const std::string& name = pair.second.name; + entry.symbolMap(pair.first).set(String(name.c_str(), name.length()), pair.second); } if (!isValid) @@ -200,11 +209,30 @@ String Extensions3DOpenGLCommon::getTranslatedShaderSourceANGLE(Platform3DObject void Extensions3DOpenGLCommon::initializeAvailableExtensions() { - String extensionsString = getExtensions(); - Vector<String> availableExtensions; - extensionsString.split(" ", availableExtensions); - for (size_t i = 0; i < availableExtensions.size(); ++i) - m_availableExtensions.add(availableExtensions[i]); +#if PLATFORM(MAC) || (PLATFORM(GTK) && !USE(OPENGL_ES_2)) + if (m_useIndexedGetString) { + GLint numExtensions = 0; + ::glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions); + for (GLint i = 0; i < numExtensions; ++i) + m_availableExtensions.add(glGetStringi(GL_EXTENSIONS, i)); + + if (!m_availableExtensions.contains(ASCIILiteral("GL_ARB_texture_storage"))) { + GLint majorVersion; + glGetIntegerv(GL_MAJOR_VERSION, &majorVersion); + GLint minorVersion; + glGetIntegerv(GL_MINOR_VERSION, &minorVersion); + if (majorVersion > 4 || (majorVersion == 4 && minorVersion >= 2)) + m_availableExtensions.add(ASCIILiteral("GL_ARB_texture_storage")); + } + } else +#endif + { + String extensionsString = getExtensions(); + Vector<String> availableExtensions; + extensionsString.split(' ', availableExtensions); + for (size_t i = 0; i < availableExtensions.size(); ++i) + m_availableExtensions.add(availableExtensions[i]); + } m_initializedAvailableExtensions = true; } @@ -225,4 +253,4 @@ void Extensions3DOpenGLCommon::getnUniformivEXT(GC3Duint, int, GC3Dsizei, int *) } // namespace WebCore -#endif // USE(3D_GRAPHICS) +#endif // ENABLE(GRAPHICS_CONTEXT_3D) |