Changeset 247315 in webkit
- Timestamp:
- Jul 10, 2019 11:43:02 AM (5 years ago)
- Location:
- trunk/Source
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/ThirdParty/ANGLE/ANGLE.xcodeproj/project.pbxproj
r246554 r247315 511 511 5CB305021DE4164800D2C405 /* TransformFeedbackImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CB304D81DE4164800D2C405 /* TransformFeedbackImpl.h */; }; 512 512 5CB305031DE4164800D2C405 /* VertexArrayImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CB304D91DE4164800D2C405 /* VertexArrayImpl.h */; }; 513 5CB5E1A71DFB8AF600F90FC9 /* libEGL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5CB300B51DE39E6300D2C405 /* libEGL.cpp */; };514 513 5CC7D457191024E4000B8C1F /* ValidateOutputs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5CC7D450191024E4000B8C1F /* ValidateOutputs.cpp */; }; 515 514 5CC7D458191024E4000B8C1F /* ValidateOutputs.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CC7D451191024E4000B8C1F /* ValidateOutputs.h */; }; … … 591 590 5CCD81B51DBFEA5C006066B8 /* QualifierTypes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5CCD819E1DBFEA5C006066B8 /* QualifierTypes.cpp */; }; 592 591 5CCD81B61DBFEA5C006066B8 /* QualifierTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CCD819F1DBFEA5C006066B8 /* QualifierTypes.h */; }; 592 6E344AB122BC35C3001DDB2C /* entry_points_enum_autogen.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E344AAD22BC35C3001DDB2C /* entry_points_enum_autogen.h */; }; 593 6E344AB222BC35C3001DDB2C /* entry_points_gles_ext_autogen.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E344AAE22BC35C3001DDB2C /* entry_points_gles_ext_autogen.h */; settings = {ATTRIBUTES = (Public, ); }; }; 594 6E344AB322BC35C3001DDB2C /* entry_points_gles_ext_autogen.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6E344AAF22BC35C3001DDB2C /* entry_points_gles_ext_autogen.cpp */; }; 595 6E344AB622BC57C8001DDB2C /* entry_points_gles_1_0_autogen.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6E344AB422BC57C8001DDB2C /* entry_points_gles_1_0_autogen.cpp */; }; 596 6E344AB722BC57C8001DDB2C /* entry_points_gles_1_0_autogen.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E344AB522BC57C8001DDB2C /* entry_points_gles_1_0_autogen.h */; }; 597 6ED70A0C22CD630E008688CE /* gl.h in Headers */ = {isa = PBXBuildFile; fileRef = 6ED70A0922CD630E008688CE /* gl.h */; settings = {ATTRIBUTES = (Public, ); }; }; 598 6ED70A0D22CD630E008688CE /* glext.h in Headers */ = {isa = PBXBuildFile; fileRef = 6ED70A0A22CD630E008688CE /* glext.h */; settings = {ATTRIBUTES = (Public, ); }; }; 599 6ED70A0E22CD630E008688CE /* glplatform.h in Headers */ = {isa = PBXBuildFile; fileRef = 6ED70A0B22CD630E008688CE /* glplatform.h */; settings = {ATTRIBUTES = (Public, ); }; }; 600 6ED70A1022CD6822008688CE /* glext_angle.h in Headers */ = {isa = PBXBuildFile; fileRef = 6ED70A0F22CD6822008688CE /* glext_angle.h */; settings = {ATTRIBUTES = (Public, ); }; }; 601 6EE2FD2D22BAE99C001D369E /* eglext_angle.h in Headers */ = {isa = PBXBuildFile; fileRef = 6EE2FD2C22BAE99C001D369E /* eglext_angle.h */; settings = {ATTRIBUTES = (Public, ); }; }; 602 6EE2FD2F22BAE9CD001D369E /* gl2ext_angle.h in Headers */ = {isa = PBXBuildFile; fileRef = 6EE2FD2E22BAE9CD001D369E /* gl2ext_angle.h */; settings = {ATTRIBUTES = (Public, ); }; }; 593 603 72309A56183C27DE00370B93 /* Tokenizer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 72309A55183C27DB00370B93 /* Tokenizer.cpp */; settings = {COMPILER_FLAGS = "-Wno-unreachable-code"; }; }; 594 604 72309A58183C27F300370B93 /* ExpressionParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 72309A57183C27F100370B93 /* ExpressionParser.cpp */; settings = {COMPILER_FLAGS = "-Wno-unreachable-code"; }; }; … … 1050 1060 5C9FFF4C19102A000025B8FA /* FlagStd140Structs.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FlagStd140Structs.cpp; sourceTree = "<group>"; }; 1051 1061 5C9FFF4D19102A000025B8FA /* FlagStd140Structs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FlagStd140Structs.h; sourceTree = "<group>"; }; 1052 5CB300B51DE39E6300D2C405 /* libEGL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = libEGL.cpp; sourceTree = "<group>"; };1053 1062 5CB300B81DE39E6300D2C405 /* resource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = resource.h; sourceTree = "<group>"; }; 1054 1063 5CB300BB1DE39E7500D2C405 /* entry_points_egl_ext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = entry_points_egl_ext.cpp; sourceTree = "<group>"; }; … … 1238 1247 5D7C59C61208C68B001C873E /* Base.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Base.xcconfig; sourceTree = "<group>"; }; 1239 1248 5D7C59C71208C68B001C873E /* DebugRelease.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = DebugRelease.xcconfig; sourceTree = "<group>"; }; 1249 6E344AAD22BC35C3001DDB2C /* entry_points_enum_autogen.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = entry_points_enum_autogen.h; sourceTree = "<group>"; }; 1250 6E344AAE22BC35C3001DDB2C /* entry_points_gles_ext_autogen.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = entry_points_gles_ext_autogen.h; sourceTree = "<group>"; }; 1251 6E344AAF22BC35C3001DDB2C /* entry_points_gles_ext_autogen.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = entry_points_gles_ext_autogen.cpp; sourceTree = "<group>"; }; 1252 6E344AB422BC57C8001DDB2C /* entry_points_gles_1_0_autogen.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = entry_points_gles_1_0_autogen.cpp; sourceTree = "<group>"; }; 1253 6E344AB522BC57C8001DDB2C /* entry_points_gles_1_0_autogen.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = entry_points_gles_1_0_autogen.h; sourceTree = "<group>"; }; 1254 6ED70A0922CD630E008688CE /* gl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = gl.h; path = include/GLES/gl.h; sourceTree = "<group>"; }; 1255 6ED70A0A22CD630E008688CE /* glext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = glext.h; path = include/GLES/glext.h; sourceTree = "<group>"; }; 1256 6ED70A0B22CD630E008688CE /* glplatform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = glplatform.h; path = include/GLES/glplatform.h; sourceTree = "<group>"; }; 1257 6ED70A0F22CD6822008688CE /* glext_angle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = glext_angle.h; path = include/GLES/glext_angle.h; sourceTree = "<group>"; }; 1258 6EE2FD2C22BAE99C001D369E /* eglext_angle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = eglext_angle.h; path = include/EGL/eglext_angle.h; sourceTree = "<group>"; }; 1259 6EE2FD2E22BAE9CD001D369E /* gl2ext_angle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = gl2ext_angle.h; path = include/GLES2/gl2ext_angle.h; sourceTree = "<group>"; }; 1240 1260 72309A55183C27DB00370B93 /* Tokenizer.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Tokenizer.cpp; sourceTree = "<group>"; }; 1241 1261 72309A57183C27F100370B93 /* ExpressionParser.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ExpressionParser.cpp; sourceTree = "<group>"; }; … … 1506 1526 5C1BAAA61DFB6124002906BB /* egl.h */, 1507 1527 5C1BAAA71DFB6124002906BB /* eglext.h */, 1528 6EE2FD2C22BAE99C001D369E /* eglext_angle.h */, 1508 1529 5C1BAAA81DFB6124002906BB /* eglplatform.h */, 1509 1530 ); … … 1516 1537 5C1BAA9E1DFB610E002906BB /* gl2.h */, 1517 1538 5C1BAA9F1DFB610E002906BB /* gl2ext.h */, 1539 6EE2FD2E22BAE9CD001D369E /* gl2ext_angle.h */, 1518 1540 5C1BAAA01DFB610E002906BB /* gl2platform.h */, 1519 1541 ); … … 1697 1719 isa = PBXGroup; 1698 1720 children = ( 1699 5CB300B51DE39E6300D2C405 /* libEGL.cpp */,1700 1721 5CB300B81DE39E6300D2C405 /* resource.h */, 1701 1722 ); … … 1710 1731 5CB300BB1DE39E7500D2C405 /* entry_points_egl_ext.cpp */, 1711 1732 5CB300BC1DE39E7500D2C405 /* entry_points_egl_ext.h */, 1733 6E344AAD22BC35C3001DDB2C /* entry_points_enum_autogen.h */, 1734 6E344AB422BC57C8001DDB2C /* entry_points_gles_1_0_autogen.cpp */, 1735 6E344AB522BC57C8001DDB2C /* entry_points_gles_1_0_autogen.h */, 1712 1736 315EBE021FCE456200AC7A89 /* entry_points_gles_2_0_autogen.cpp */, 1713 1737 315EBDFE1FCE456100AC7A89 /* entry_points_gles_2_0_autogen.h */, … … 1716 1740 315EBE011FCE456100AC7A89 /* entry_points_gles_3_1_autogen.cpp */, 1717 1741 315EBDFF1FCE456100AC7A89 /* entry_points_gles_3_1_autogen.h */, 1742 6E344AAF22BC35C3001DDB2C /* entry_points_gles_ext_autogen.cpp */, 1743 6E344AAE22BC35C3001DDB2C /* entry_points_gles_ext_autogen.h */, 1718 1744 5CB300C71DE39E7500D2C405 /* global_state.cpp */, 1719 1745 5CB300C81DE39E7500D2C405 /* global_state.h */, … … 2074 2100 sourceTree = "<group>"; 2075 2101 }; 2102 6ED70A0822CD62E8008688CE /* GLES */ = { 2103 isa = PBXGroup; 2104 children = ( 2105 6ED70A0922CD630E008688CE /* gl.h */, 2106 6ED70A0A22CD630E008688CE /* glext.h */, 2107 6ED70A0F22CD6822008688CE /* glext_angle.h */, 2108 6ED70A0B22CD630E008688CE /* glplatform.h */, 2109 ); 2110 name = GLES; 2111 sourceTree = "<group>"; 2112 }; 2076 2113 A08C3CD816D6CB35003F0B83 /* third_party */ = { 2077 2114 isa = PBXGroup; … … 2105 2142 children = ( 2106 2143 5C1BAA931DFB60E2002906BB /* EGL */, 2144 6ED70A0822CD62E8008688CE /* GLES */, 2107 2145 5C1BAA941DFB60EA002906BB /* GLES2 */, 2108 2146 5C1BAA951DFB60EF002906BB /* GLES3 */, … … 2270 2308 5C1BAAAA1DFB6124002906BB /* egl.h in Headers */, 2271 2309 5C1BAAAB1DFB6124002906BB /* eglext.h in Headers */, 2310 6EE2FD2D22BAE99C001D369E /* eglext_angle.h in Headers */, 2272 2311 5CB304E31DE4164800D2C405 /* EGLImplFactory.h in Headers */, 2273 2312 5C1BAAAC1DFB6124002906BB /* eglplatform.h in Headers */, … … 2278 2317 5CB304981DE4157B00D2C405 /* entry_points_egl.h in Headers */, 2279 2318 5CB304961DE4157B00D2C405 /* entry_points_egl_ext.h in Headers */, 2319 6E344AB122BC35C3001DDB2C /* entry_points_enum_autogen.h in Headers */, 2320 6E344AB722BC57C8001DDB2C /* entry_points_gles_1_0_autogen.h in Headers */, 2280 2321 315EBE061FCE456200AC7A89 /* entry_points_gles_2_0_autogen.h in Headers */, 2281 2322 315EBE051FCE456200AC7A89 /* entry_points_gles_3_0_autogen.h in Headers */, 2282 2323 315EBE071FCE456200AC7A89 /* entry_points_gles_3_1_autogen.h in Headers */, 2324 6E344AB222BC35C3001DDB2C /* entry_points_gles_ext_autogen.h in Headers */, 2283 2325 5C1DBDEB1B0438D300235552 /* Error.h in Headers */, 2284 2326 315EBDE91FCE452D00AC7A89 /* ErrorStrings.h in Headers */, … … 2313 2355 5CB3012A1DE39F1A00D2C405 /* functionsgl_typedefs.h in Headers */, 2314 2356 5CCD59942284FC400018F2D8 /* generatemip.h in Headers */, 2357 6ED70A0C22CD630E008688CE /* gl.h in Headers */, 2315 2358 5C1BAAA21DFB610E002906BB /* gl2.h in Headers */, 2316 2359 5C1BAAA31DFB610E002906BB /* gl2ext.h in Headers */, 2360 6EE2FD2F22BAE9CD001D369E /* gl2ext_angle.h in Headers */, 2317 2361 5C1BAAA41DFB610E002906BB /* gl2platform.h in Headers */, 2318 2362 5C1BAA9A1DFB60FF002906BB /* gl3.h in Headers */, … … 2322 2366 5CCD59602284F7960018F2D8 /* GLES1Renderer.h in Headers */, 2323 2367 5CCD59622284F7960018F2D8 /* GLES1State.h in Headers */, 2368 6ED70A0D22CD630E008688CE /* glext.h in Headers */, 2369 6ED70A1022CD6822008688CE /* glext_angle.h in Headers */, 2324 2370 5CB304EC1DE4164800D2C405 /* GLImplFactory.h in Headers */, 2325 2371 5CB304A21DE4157B00D2C405 /* global_state.h in Headers */, 2372 6ED70A0E22CD630E008688CE /* glplatform.h in Headers */, 2326 2373 31012E2D18B97B9B0039062F /* glslang.h in Headers */, 2327 2374 31012E3218B97B9B0039062F /* glslang_tab.h in Headers */, … … 2684 2731 5C1BAAB51DFB6F54002906BB /* entry_points_egl.cpp in Sources */, 2685 2732 5C1BAAB61DFB6F58002906BB /* entry_points_egl_ext.cpp in Sources */, 2733 6E344AB622BC57C8001DDB2C /* entry_points_gles_1_0_autogen.cpp in Sources */, 2686 2734 315EBE0A1FCE456200AC7A89 /* entry_points_gles_2_0_autogen.cpp in Sources */, 2687 2735 315EBE081FCE456200AC7A89 /* entry_points_gles_3_0_autogen.cpp in Sources */, 2688 2736 315EBE091FCE456200AC7A89 /* entry_points_gles_3_1_autogen.cpp in Sources */, 2737 6E344AB322BC35C3001DDB2C /* entry_points_gles_ext_autogen.cpp in Sources */, 2689 2738 5C1DBDEA1B0438D300235552 /* Error.cpp in Sources */, 2690 2739 315EBDEF1FCE452D00AC7A89 /* es3_copy_conversion_table_autogen.cpp in Sources */, … … 2737 2786 315EBD9C1FCE443600AC7A89 /* IsASTDepthBelowLimit.cpp in Sources */, 2738 2787 A264F8B616974DED006FAA5A /* Lexer.cpp in Sources */, 2739 5CB5E1A71DFB8AF600F90FC9 /* libEGL.cpp in Sources */,2740 2788 5CB304EF1DE4164800D2C405 /* load_functions_table_autogen.cpp in Sources */, 2741 2789 5CCD59952284FC400018F2D8 /* loadimage.cpp in Sources */, -
trunk/Source/ThirdParty/ANGLE/ChangeLog
r246892 r247315 1 2019-07-10 Kenneth Russell <kbr@chromium.org> 2 3 Hook up WebGL's back buffer in ANGLE backend on macOS 4 https://bugs.webkit.org/show_bug.cgi?id=198982 5 6 Reviewed by Alex Christensen. 7 8 Add source files needed to implement and call ANGLE extensions, and 9 export headers necessary for those extensions. Update the script which 10 adjusts include paths to handle the new headers. 11 12 Cherry-pick fix for ANGLE bug crbug.com/angleproject/3669 to support 13 antialias:true for ANGLE-backed WebGL contexts. 14 15 * ANGLE.xcodeproj/project.pbxproj: 16 * adjust-angle-include-paths.sh: 17 * src/libANGLE/FramebufferAttachment.cpp: 18 (gl::FramebufferAttachment::getTextureImageIndex const): Deleted. 19 * src/libANGLE/FramebufferAttachment.h: 20 (gl::FramebufferAttachment::getTextureImageIndex const): 21 * src/libANGLE/validationES2.cpp: 22 (gl::ValidateBlitFramebufferANGLE): 23 1 24 2019-06-27 Beth Dakin <bdakin@apple.com> 2 25 -
trunk/Source/ThirdParty/ANGLE/adjust-angle-include-paths.sh
r246842 r247315 32 32 sed -e ' 33 33 s/^#include <EGL\/\(.*\)>/#include <ANGLE\/\1>/ 34 s/^#include <GLES\/\(.*\)>/#include <ANGLE\/\1>/ 34 35 s/^#include <GLES2\/\(.*\)>/#include <ANGLE\/\1>/ 35 36 s/^#include <GLES3\/\(.*\)>/#include <ANGLE\/\1>/ -
trunk/Source/ThirdParty/ANGLE/src/libANGLE/FramebufferAttachment.cpp
r245088 r247315 179 179 } 180 180 181 const ImageIndex &FramebufferAttachment::getTextureImageIndex() const182 {183 ASSERT(type() == GL_TEXTURE);184 return mTarget.textureIndex();185 }186 187 181 TextureTarget FramebufferAttachment::cubeMapFace() const 188 182 { -
trunk/Source/ThirdParty/ANGLE/src/libANGLE/FramebufferAttachment.h
r245088 r247315 217 217 }; 218 218 219 inline const ImageIndex &FramebufferAttachment::getTextureImageIndex() const 220 { 221 ASSERT(type() == GL_TEXTURE); 222 return mTarget.textureIndex(); 223 } 224 219 225 inline Extents FramebufferAttachment::getSize() const 220 226 { -
trunk/Source/ThirdParty/ANGLE/src/libANGLE/validationES2.cpp
r245088 r247315 2573 2573 { 2574 2574 if (!(readColorAttachment->type() == GL_TEXTURE && 2575 readColorAttachment->getTextureImageIndex().getType() == TextureType::_2D) && 2575 (readColorAttachment->getTextureImageIndex().getType() == TextureType::_2D || 2576 readColorAttachment->getTextureImageIndex().getType() == TextureType::Rectangle)) && 2576 2577 readColorAttachment->type() != GL_RENDERBUFFER && 2577 2578 readColorAttachment->type() != GL_FRAMEBUFFER_DEFAULT) … … 2590 2591 { 2591 2592 if (!(attachment->type() == GL_TEXTURE && 2592 attachment->getTextureImageIndex().getType() == TextureType::_2D) && 2593 (attachment->getTextureImageIndex().getType() == TextureType::_2D || 2594 attachment->getTextureImageIndex().getType() == TextureType::Rectangle)) && 2593 2595 attachment->type() != GL_RENDERBUFFER && 2594 2596 attachment->type() != GL_FRAMEBUFFER_DEFAULT) -
trunk/Source/WebCore/ChangeLog
r247313 r247315 1 2019-07-10 Kenneth Russell <kbr@chromium.org> 2 3 Hook up WebGL's back buffer in ANGLE backend on macOS 4 https://bugs.webkit.org/show_bug.cgi?id=198982 5 6 Reviewed by Alex Christensen. 7 8 Fix a few places which were accidentally calling desktop OpenGL rather 9 than ANGLE. Fix some calls which were using ANGLE's OpenGL ES 3.0 10 entry points rather than the OpenGL ES 2.0 extension APIs, causing 11 them to generate errors in WebGL 1.0's backend. Change 12 Extensions3DANGLE to use ANGLE's requestable extension mechanism. 13 14 Fix framebuffer setup when using ANGLE for WebGL 1.0 contexts, for 15 both antialias:true and false. 16 17 Remove ANGLEWebKitBridge in ANGLE backend. It interfered with the 18 correct operation of ANGLE's internal shader compiler, and was 19 unnecessary given the use of ANGLE. Remove all manual shader name 20 hashing and mapping in ANGLE backend. 21 22 Tested with parts of the WebGL conformance suite and the San 23 Angeles demo, which now runs properly with WebKit's ANGLE backend 24 for WebGL. 25 26 * html/canvas/WebGLRenderingContextBase.cpp: 27 (WebCore::WebGLRenderingContextBase::getProgramParameter): 28 (WebCore::WebGLRenderingContextBase::getUniformLocation): 29 (WebCore::WebGLRenderingContextBase::linkProgramWithoutInvalidatingAttribLocations): 30 * platform/graphics/GraphicsContext3D.h: 31 * platform/graphics/angle/Extensions3DANGLE.cpp: 32 (WebCore::Extensions3DANGLE::Extensions3DANGLE): 33 (WebCore::Extensions3DANGLE::supports): 34 (WebCore::Extensions3DANGLE::ensureEnabled): 35 (WebCore::Extensions3DANGLE::isEnabled): 36 (WebCore::Extensions3DANGLE::getTranslatedShaderSourceANGLE): 37 (WebCore::Extensions3DANGLE::initializeAvailableExtensions): 38 (WebCore::Extensions3DANGLE::blitFramebuffer): 39 (WebCore::Extensions3DANGLE::renderbufferStorageMultisample): 40 (WebCore::Extensions3DANGLE::createVertexArrayOES): 41 (WebCore::Extensions3DANGLE::deleteVertexArrayOES): 42 (WebCore::Extensions3DANGLE::isVertexArrayOES): 43 (WebCore::Extensions3DANGLE::bindVertexArrayOES): 44 (WebCore::Extensions3DANGLE::supportsExtension): 45 (WebCore::Extensions3DANGLE::drawBuffersEXT): 46 (WebCore::Extensions3DANGLE::drawArraysInstanced): 47 (WebCore::Extensions3DANGLE::drawElementsInstanced): 48 (WebCore::Extensions3DANGLE::vertexAttribDivisor): 49 * platform/graphics/angle/Extensions3DANGLE.h: 50 * platform/graphics/angle/GraphicsContext3DANGLE.cpp: 51 (WebCore::GraphicsContext3D::validateAttributes): 52 (WebCore::GraphicsContext3D::reshapeFBOs): 53 (WebCore::GraphicsContext3D::attachDepthAndStencilBufferIfNeeded): 54 (WebCore::GraphicsContext3D::resolveMultisamplingIfNecessary): 55 (WebCore::GraphicsContext3D::validateDepthStencil): 56 (WebCore::GraphicsContext3D::prepareTexture): 57 (WebCore::GraphicsContext3D::attachShader): 58 (WebCore::GraphicsContext3D::bindAttribLocation): 59 (WebCore::GraphicsContext3D::compileShader): 60 (WebCore::GraphicsContext3D::compileShaderDirect): 61 (WebCore::GraphicsContext3D::detachShader): 62 (WebCore::GraphicsContext3D::getActiveAttribImpl): 63 (WebCore::GraphicsContext3D::getActiveAttrib): 64 (WebCore::GraphicsContext3D::getActiveUniformImpl): 65 (WebCore::GraphicsContext3D::getActiveUniform): 66 (WebCore::GraphicsContext3D::getAttribLocation): 67 (WebCore::GraphicsContext3D::getAttribLocationDirect): 68 (WebCore::GraphicsContext3D::moveErrorsToSyntheticErrorList): 69 (WebCore::GraphicsContext3D::linkProgram): 70 (WebCore::GraphicsContext3D::shaderSource): 71 (WebCore::GraphicsContext3D::getUnmangledInfoLog): 72 (WebCore::GraphicsContext3D::getShaderiv): 73 (WebCore::GraphicsContext3D::getShaderInfoLog): 74 (WebCore::GraphicsContext3D::getUniformLocation): 75 (WebCore::GraphicsContext3D::createBuffer): 76 (WebCore::GraphicsContext3D::createFramebuffer): 77 (WebCore::GraphicsContext3D::createProgram): 78 (WebCore::GraphicsContext3D::createRenderbuffer): 79 (WebCore::GraphicsContext3D::createShader): 80 (WebCore::GraphicsContext3D::createTexture): 81 (WebCore::GraphicsContext3D::deleteBuffer): 82 (WebCore::GraphicsContext3D::deleteFramebuffer): 83 (WebCore::GraphicsContext3D::deleteProgram): 84 (WebCore::GraphicsContext3D::deleteRenderbuffer): 85 (WebCore::GraphicsContext3D::deleteShader): 86 (WebCore::GraphicsContext3D::deleteTexture): 87 (WebCore::GraphicsContext3D::synthesizeGLError): 88 (): Deleted. 89 (WebCore::setCurrentNameHashMapForShader): Deleted. 90 (WebCore::nameHashForShader): Deleted. 91 (WebCore::GraphicsContext3D::checkVaryingsPacking const): Deleted. 92 (WebCore::GraphicsContext3D::precisionsMatch const): Deleted. 93 (WebCore::generateHashedName): Deleted. 94 (WebCore::GraphicsContext3D::mappedSymbolInShaderSourceMap): Deleted. 95 (WebCore::GraphicsContext3D::mappedSymbolName): Deleted. 96 (WebCore::GraphicsContext3D::originalSymbolInShaderSourceMap): Deleted. 97 (WebCore::GraphicsContext3D::originalSymbolName): Deleted. 98 (WebCore::GraphicsContext3D::getNonBuiltInActiveSymbolCount): Deleted. 99 (WebCore::GraphicsContext3D::getShaderSource): Deleted. 100 * platform/graphics/cocoa/GraphicsContext3DCocoa.mm: 101 (WebCore::GraphicsContext3D::GraphicsContext3D): 102 (WebCore::GraphicsContext3D::~GraphicsContext3D): 103 (WebCore::GraphicsContext3D::makeContextCurrent): 104 (WebCore::GraphicsContext3D::checkGPUStatus): 105 (WebCore::GraphicsContext3D::allocateIOSurfaceBackingStore): 106 (WebCore::GraphicsContext3D::updateFramebufferTextureBackingStoreFromLayer): 107 * platform/graphics/cocoa/WebGLLayer.h: 108 * platform/graphics/cocoa/WebGLLayer.mm: 109 (-[WebGLLayer initWithGraphicsContext3D:]): 110 (-[WebGLLayer copyImageSnapshotWithColorSpace:]): 111 (-[WebGLLayer display]): 112 (-[WebGLLayer setEGLDisplay:andConfig:]): 113 (-[WebGLLayer dealloc]): 114 (-[WebGLLayer allocateIOSurfaceBackingStoreWithSize:usingAlpha:]): 115 (-[WebGLLayer bindFramebufferToNextAvailableSurface]): 116 1 117 2019-07-10 Youenn Fablet <youenn@apple.com> 2 118 -
trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp
r243887 r247315 2676 2676 case GraphicsContext3D::ACTIVE_ATTRIBUTES: 2677 2677 case GraphicsContext3D::ACTIVE_UNIFORMS: 2678 #if USE(ANGLE) 2679 m_context->getProgramiv(objectOrZero(program), pname, &value); 2680 #else 2678 2681 m_context->getNonBuiltInActiveSymbolCount(objectOrZero(program), pname, &value); 2682 #endif // USE(ANGLE) 2679 2683 return value; 2680 2684 default: … … 2995 2999 2996 3000 GC3Dint activeUniforms = 0; 3001 #if USE(ANGLE) 3002 m_context->getProgramiv(objectOrZero(program), GraphicsContext3D::ACTIVE_UNIFORMS, &activeUniforms); 3003 #else 2997 3004 m_context->getNonBuiltInActiveSymbolCount(objectOrZero(program), GraphicsContext3D::ACTIVE_UNIFORMS, &activeUniforms); 3005 #endif 2998 3006 for (GC3Dint i = 0; i < activeUniforms; i++) { 2999 3007 ActiveInfo info; … … 3209 3217 RefPtr<WebGLShader> vertexShader = program->getAttachedShader(GraphicsContext3D::VERTEX_SHADER); 3210 3218 RefPtr<WebGLShader> fragmentShader = program->getAttachedShader(GraphicsContext3D::FRAGMENT_SHADER); 3211 if (!vertexShader || !vertexShader->isValid() || !fragmentShader || !fragmentShader->isValid() || !m_context->precisionsMatch(objectOrZero(vertexShader.get()), objectOrZero(fragmentShader.get())) || !m_context->checkVaryingsPacking(objectOrZero(vertexShader.get()), objectOrZero(fragmentShader.get()))) {3219 if (!vertexShader || !vertexShader->isValid() || !fragmentShader || !fragmentShader->isValid()) { 3212 3220 program->setLinkStatus(false); 3213 3221 return false; 3214 3222 } 3223 3224 #if !USE(ANGLE) 3225 if (!m_context->precisionsMatch(objectOrZero(vertexShader.get()), objectOrZero(fragmentShader.get())) 3226 || !m_context->checkVaryingsPacking(objectOrZero(vertexShader.get()), objectOrZero(fragmentShader.get()))) { 3227 program->setLinkStatus(false); 3228 return false; 3229 } 3230 #endif 3215 3231 3216 3232 m_context->linkProgram(objectOrZero(program)); -
trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h
r246554 r247315 72 72 #if USE(ANGLE) 73 73 typedef void* PlatformGraphicsContext3D; 74 typedef void* PlatformGraphicsContext3DDisplay; 75 typedef void* PlatformGraphicsContext3DSurface; 76 typedef void* PlatformGraphicsContext3DConfig; 74 77 #endif // USE(ANGLE) 75 78 … … 1055 1058 void getInteger64v(GC3Denum pname, GC3Dint64* value); 1056 1059 void getProgramiv(Platform3DObject program, GC3Denum pname, GC3Dint* value); 1060 #if !USE(ANGLE) 1057 1061 void getNonBuiltInActiveSymbolCount(Platform3DObject program, GC3Denum pname, GC3Dint* value); 1062 #endif // !USE(ANGLE) 1058 1063 String getProgramInfoLog(Platform3DObject); 1059 1064 String getUnmangledInfoLog(Platform3DObject[2], GC3Dsizei, const String&); … … 1062 1067 String getShaderInfoLog(Platform3DObject); 1063 1068 void getShaderPrecisionFormat(GC3Denum shaderType, GC3Denum precisionType, GC3Dint* range, GC3Dint* precision); 1069 #if !USE(ANGLE) 1064 1070 String getShaderSource(Platform3DObject); 1071 #endif // !USE(ANGLE) 1065 1072 String getString(GC3Denum name); 1066 1073 void getTexParameterfv(GC3Denum target, GC3Denum pname, GC3Dfloat* value); … … 1128 1135 void useProgram(Platform3DObject); 1129 1136 void validateProgram(Platform3DObject); 1137 #if !USE(ANGLE) 1130 1138 bool checkVaryingsPacking(Platform3DObject vertexShader, Platform3DObject fragmentShader) const; 1131 1139 bool precisionsMatch(Platform3DObject vertexShader, Platform3DObject fragmentShader) const; 1140 #endif 1132 1141 1133 1142 void vertexAttrib1f(GC3Duint index, GC3Dfloat x); … … 1186 1195 void updateFramebufferTextureBackingStoreFromLayer(); 1187 1196 void updateCGLContext(); 1197 #endif 1198 1199 #if USE(ANGLE) && PLATFORM(MAC) 1200 void allocateIOSurfaceBackingStore(IntSize); 1201 void updateFramebufferTextureBackingStoreFromLayer(); 1188 1202 #endif 1189 1203 #endif // PLATFORM(COCOA) … … 1363 1377 RetainPtr<WebGLLayer> m_webGLLayer; 1364 1378 PlatformGraphicsContext3D m_contextObj { nullptr }; 1365 #endif 1379 #if USE(ANGLE) 1380 PlatformGraphicsContext3DDisplay m_displayObj { nullptr }; 1381 #endif // USE(ANGLE) 1382 #endif // PLATFORM(COCOA) 1366 1383 1367 1384 #if PLATFORM(WIN) && USE(CA) … … 1397 1414 }; 1398 1415 1416 #if !USE(ANGLE) 1399 1417 // FIXME: Shaders are never removed from this map, even if they and their program are deleted. 1400 1418 // This is bad, and it also relies on the fact we never reuse Platform3DObject numbers. … … 1435 1453 1436 1454 std::unique_ptr<ShaderNameHash> nameHashMapForShaders; 1455 #endif // !USE(ANGLE) 1437 1456 1438 1457 #if !PLATFORM(COCOA) && USE(OPENGL_ES) … … 1454 1473 Vector<Vector<float>> m_vertexArray; 1455 1474 1475 #if !USE(ANGLE) 1456 1476 ANGLEWebKitBridge m_compiler; 1477 #endif 1457 1478 1458 1479 GC3Duint m_texture { 0 }; … … 1469 1490 bool m_layerComposited { false }; 1470 1491 GC3Duint m_internalColorFormat { 0 }; 1492 1493 #if USE(ANGLE) 1494 PlatformGraphicsContext3DSurface m_pbuffer; 1495 #endif 1471 1496 1472 1497 struct GraphicsContext3DState { -
trunk/Source/WebCore/platform/graphics/angle/Extensions3DANGLE.cpp
r246554 r247315 33 33 #include <ANGLE/entry_points_gles_2_0_autogen.h> 34 34 #include <ANGLE/entry_points_gles_3_0_autogen.h> 35 // Skip the inclusion of ANGLE's explicit context entry points for now. 36 #define GL_ANGLE_explicit_context 37 #define GL_ANGLE_explicit_context_gles1 38 typedef void* GLeglContext; 39 #include <ANGLE/entry_points_gles_ext_autogen.h> 35 40 36 41 // Note: this file can't be compiled in the same unified source file … … 52 57 // FIXME: ideally, remove this initialization altogether. ANGLE 53 58 // subsumes the responsibility for graphics driver workarounds. 54 m_vendor = String(reinterpret_cast<const char*>( ::glGetString(GL_VENDOR)));55 m_renderer = String(reinterpret_cast<const char*>( ::glGetString(GL_RENDERER)));59 m_vendor = String(reinterpret_cast<const char*>(gl::GetString(GL_VENDOR))); 60 m_renderer = String(reinterpret_cast<const char*>(gl::GetString(GL_RENDERER))); 56 61 57 62 Vector<String> vendorComponents = m_vendor.convertToASCIILowercase().split(' '); … … 73 78 initializeAvailableExtensions(); 74 79 75 // We explicitly do not support this extension until76 // we fix the following bug:77 // https://bugs.webkit.org/show_bug.cgi?id=14973478 // FIXME: given that ANGLE is in use, rewrite this in terms of79 // ANGLE queries and enable this extension.80 if (name == "GL_ANGLE_translated_shader_source")81 return false;82 83 80 return supportsExtension(name); 84 81 } … … 86 83 void Extensions3DANGLE::ensureEnabled(const String& name) 87 84 { 88 if (name == "GL_OES_standard_derivatives") { 89 // Enable support in ANGLE (if not enabled already). 90 ANGLEWebKitBridge& compiler = m_context->m_compiler; 91 ShBuiltInResources ANGLEResources = compiler.getResources(); 92 if (!ANGLEResources.OES_standard_derivatives) { 93 ANGLEResources.OES_standard_derivatives = 1; 94 compiler.setResources(ANGLEResources); 95 } 96 } else if (name == "GL_EXT_draw_buffers") { 97 // Enable support in ANGLE (if not enabled already). 98 ANGLEWebKitBridge& compiler = m_context->m_compiler; 99 ShBuiltInResources ANGLEResources = compiler.getResources(); 100 if (!ANGLEResources.EXT_draw_buffers) { 101 ANGLEResources.EXT_draw_buffers = 1; 102 m_context->getIntegerv(Extensions3D::MAX_DRAW_BUFFERS_EXT, &ANGLEResources.MaxDrawBuffers); 103 compiler.setResources(ANGLEResources); 104 } 105 } else if (name == "GL_EXT_shader_texture_lod") { 106 // Enable support in ANGLE (if not enabled already). 107 ANGLEWebKitBridge& compiler = m_context->m_compiler; 108 ShBuiltInResources ANGLEResources = compiler.getResources(); 109 if (!ANGLEResources.EXT_shader_texture_lod) { 110 ANGLEResources.EXT_shader_texture_lod = 1; 111 compiler.setResources(ANGLEResources); 112 } 113 } else if (name == "GL_EXT_frag_depth") { 114 // Enable support in ANGLE (if not enabled already). 115 ANGLEWebKitBridge& compiler = m_context->m_compiler; 116 ShBuiltInResources ANGLEResources = compiler.getResources(); 117 if (!ANGLEResources.EXT_frag_depth) { 118 ANGLEResources.EXT_frag_depth = 1; 119 compiler.setResources(ANGLEResources); 120 } 85 // Enable support in ANGLE (if not enabled already). 86 if (m_requestableExtensions.contains(name) && !m_enabledExtensions.contains(name)) { 87 m_context->makeContextCurrent(); 88 gl::RequestExtensionANGLE(name.ascii().data()); 89 m_enabledExtensions.add(name); 121 90 } 122 91 } … … 124 93 bool Extensions3DANGLE::isEnabled(const String& name) 125 94 { 126 if (name == "GL_OES_standard_derivatives") { 127 ANGLEWebKitBridge& compiler = m_context->m_compiler; 128 return compiler.getResources().OES_standard_derivatives; 129 } 130 return supports(name); 95 return m_availableExtensions.contains(name) || m_enabledExtensions.contains(name); 131 96 } 132 97 … … 138 103 String Extensions3DANGLE::getTranslatedShaderSourceANGLE(Platform3DObject shader) 139 104 { 140 // FIXME: port to use ANGLE's implementation directly. 141 ASSERT(shader); 142 int GLshaderType; 143 ANGLEShaderType shaderType; 144 145 ANGLEWebKitBridge& compiler = m_context->m_compiler; 146 147 m_context->getShaderiv(shader, GraphicsContext3D::SHADER_TYPE, &GLshaderType); 148 149 if (GLshaderType == GraphicsContext3D::VERTEX_SHADER) 150 shaderType = SHADER_TYPE_VERTEX; 151 else if (GLshaderType == GraphicsContext3D::FRAGMENT_SHADER) 152 shaderType = SHADER_TYPE_FRAGMENT; 153 else 154 return emptyString(); // Invalid shader type. 155 156 HashMap<Platform3DObject, GraphicsContext3D::ShaderSourceEntry>::iterator result = m_context->m_shaderSourceMap.find(shader); 157 158 if (result == m_context->m_shaderSourceMap.end()) 105 int sourceLength = 0; 106 m_context->getShaderiv(shader, GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE, &sourceLength); 107 if (!sourceLength) 159 108 return emptyString(); 160 161 GraphicsContext3D::ShaderSourceEntry& entry = result->value; 162 163 String translatedShaderSource; 164 String shaderInfoLog; 165 uint64_t 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 | SH_INITIALIZE_UNINITIALIZED_LOCALS; 166 167 if (m_requiresBuiltInFunctionEmulation) 168 extraCompileOptions |= SH_EMULATE_ABS_INT_FUNCTION; 169 170 Vector<std::pair<ANGLEShaderSymbolType, sh::ShaderVariable>> symbols; 171 bool isValid = compiler.compileShaderSource(entry.source.utf8().data(), shaderType, translatedShaderSource, shaderInfoLog, symbols, extraCompileOptions); 172 173 entry.log = shaderInfoLog; 174 entry.isValid = isValid; 175 176 for (const std::pair<ANGLEShaderSymbolType, sh::ShaderVariable>& pair : symbols) { 177 const std::string& name = pair.second.name; 178 entry.symbolMap(pair.first).set(String(name.c_str(), name.length()), pair.second); 179 } 180 181 if (!isValid) 109 Vector<GLchar> name(sourceLength); // GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE includes null termination. 110 int returnedLength = 0; 111 gl::GetTranslatedShaderSourceANGLE(shader, sourceLength, &returnedLength, name.data()); 112 if (!returnedLength) 182 113 return emptyString(); 183 184 return translatedShaderSource;114 ASSERT(returnedLength == sourceLength); 115 return String(name.data(), returnedLength); 185 116 } 186 117 … … 191 122 gl::GetIntegerv(GL_NUM_EXTENSIONS, &numExtensions); 192 123 for (GLint i = 0; i < numExtensions; ++i) 193 m_availableExtensions.add(glGetStringi(GL_EXTENSIONS, i)); 124 m_availableExtensions.add(gl::GetStringi(GL_EXTENSIONS, i)); 125 gl::GetIntegerv(GL_NUM_REQUESTABLE_EXTENSIONS_ANGLE, &numExtensions); 126 for (GLint i = 0; i < numExtensions; ++i) 127 m_requestableExtensions.add(gl::GetStringi(GL_REQUESTABLE_EXTENSIONS_ANGLE, i)); 194 128 } else { 195 129 String extensionsString = getExtensions(); 196 130 for (auto& extension : extensionsString.split(' ')) 197 131 m_availableExtensions.add(extension); 132 extensionsString = String(reinterpret_cast<const char*>(gl::GetString(GL_REQUESTABLE_EXTENSIONS_ANGLE))); 133 for (auto& extension : extensionsString.split(' ')) 134 m_requestableExtensions.add(extension); 198 135 } 199 136 m_initializedAvailableExtensions = true; … … 218 155 { 219 156 // FIXME: consider adding support for APPLE_framebuffer_multisample. 220 gl::BlitFramebuffer (srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);157 gl::BlitFramebufferANGLE(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); 221 158 } 222 159 223 160 void Extensions3DANGLE::renderbufferStorageMultisample(unsigned long target, unsigned long samples, unsigned long internalformat, unsigned long width, unsigned long height) 224 161 { 225 gl::RenderbufferStorageMultisample (target, samples, internalformat, width, height);162 gl::RenderbufferStorageMultisampleANGLE(target, samples, internalformat, width, height); 226 163 } 227 164 … … 230 167 m_context->makeContextCurrent(); 231 168 GLuint array = 0; 232 gl::GenVertexArrays (1, &array);169 gl::GenVertexArraysOES(1, &array); 233 170 return array; 234 171 } … … 240 177 241 178 m_context->makeContextCurrent(); 242 gl::DeleteVertexArrays (1, &array);179 gl::DeleteVertexArraysOES(1, &array); 243 180 } 244 181 … … 249 186 250 187 m_context->makeContextCurrent(); 251 return gl::IsVertexArray (array);188 return gl::IsVertexArrayOES(array); 252 189 } 253 190 … … 255 192 { 256 193 m_context->makeContextCurrent(); 257 gl::BindVertexArray (array);194 gl::BindVertexArrayOES(array); 258 195 } 259 196 … … 278 215 bool Extensions3DANGLE::supportsExtension(const String& name) 279 216 { 280 return m_availableExtensions.contains(name) ;217 return m_availableExtensions.contains(name) || m_requestableExtensions.contains(name); 281 218 } 282 219 283 220 void Extensions3DANGLE::drawBuffersEXT(GC3Dsizei n, const GC3Denum* bufs) 284 221 { 285 gl::DrawBuffers (n, bufs);222 gl::DrawBuffersEXT(n, bufs); 286 223 } 287 224 … … 289 226 { 290 227 m_context->makeContextCurrent(); 291 gl::DrawArraysInstanced (mode, first, count, primcount);228 gl::DrawArraysInstancedANGLE(mode, first, count, primcount); 292 229 } 293 230 … … 295 232 { 296 233 m_context->makeContextCurrent(); 297 gl::DrawElementsInstanced (mode, count, type, reinterpret_cast<GLvoid*>(static_cast<intptr_t>(offset)), primcount);234 gl::DrawElementsInstancedANGLE(mode, count, type, reinterpret_cast<GLvoid*>(static_cast<intptr_t>(offset)), primcount); 298 235 } 299 236 … … 301 238 { 302 239 m_context->makeContextCurrent(); 303 gl::VertexAttribDivisor (index, divisor);240 gl::VertexAttribDivisorANGLE(index, divisor); 304 241 } 305 242 -
trunk/Source/WebCore/platform/graphics/angle/Extensions3DANGLE.h
r246554 r247315 85 85 bool m_initializedAvailableExtensions; 86 86 HashSet<String> m_availableExtensions; 87 HashSet<String> m_requestableExtensions; 88 HashSet<String> m_enabledExtensions; 87 89 88 90 // Weak pointer back to GraphicsContext3D. -
trunk/Source/WebCore/platform/graphics/angle/GraphicsContext3DANGLE.cpp
r246554 r247315 53 53 #endif 54 54 55 // Skip the inclusion of ANGLE's explicit context entry points for now. 56 #define GL_ANGLE_explicit_context 57 #define GL_ANGLE_explicit_context_gles1 58 typedef void* GLeglContext; 55 59 #include <ANGLE/entry_points_gles_2_0_autogen.h> 56 60 #include <ANGLE/entry_points_gles_3_0_autogen.h> 61 #include <ANGLE/entry_points_gles_ext_autogen.h> 62 #include <ANGLE/gl2ext.h> 63 #include <ANGLE/gl2ext_angle.h> 57 64 58 65 // Note: this file can't be compiled in the same unified source file … … 64 71 65 72 namespace WebCore { 73 74 static const char* packedDepthStencilExtensionName = "GL_OES_packed_depth_stencil"; 66 75 67 76 void GraphicsContext3D::releaseShaderCompiler() … … 116 125 void GraphicsContext3D::validateAttributes() 117 126 { 118 validateDepthStencil( "GL_EXT_packed_depth_stencil");127 validateDepthStencil(packedDepthStencilExtensionName); 119 128 } 120 129 … … 138 147 // Use a 24 bit depth buffer where we know we have it. 139 148 if (extensions.supports("GL_OES_packed_depth_stencil")) 140 internalDepthStencilFormat = GL_DEPTH24_STENCIL8 ;149 internalDepthStencilFormat = GL_DEPTH24_STENCIL8_OES; 141 150 else 142 151 internalDepthStencilFormat = GL_DEPTH_COMPONENT16; … … 146 155 if (m_attrs.antialias) { 147 156 GLint maxSampleCount; 148 gl::GetIntegerv(GL_MAX_SAMPLES_ EXT, &maxSampleCount);157 gl::GetIntegerv(GL_MAX_SAMPLES_ANGLE, &maxSampleCount); 149 158 // Using more than 4 samples is slow on some hardware and is unlikely to 150 159 // produce a significantly better result. … … 152 161 gl::BindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO); 153 162 gl::BindRenderbuffer(GL_RENDERBUFFER, m_multisampleColorBuffer); 154 g l::RenderbufferStorageMultisample(GL_RENDERBUFFER, sampleCount, GL_RGBA8, width, height);163 getExtensions().renderbufferStorageMultisample(GL_RENDERBUFFER, sampleCount, GL_RGBA8, width, height); 155 164 gl::FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_multisampleColorBuffer); 156 165 if (m_attrs.stencil || m_attrs.depth) { 157 166 gl::BindRenderbuffer(GL_RENDERBUFFER, m_multisampleDepthStencilBuffer); 158 gl::RenderbufferStorageMultisample(GL_RENDERBUFFER, sampleCount, internalDepthStencilFormat, width, height); 159 if (m_attrs.stencil) 160 gl::FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_multisampleDepthStencilBuffer); 161 if (m_attrs.depth) 162 gl::FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_multisampleDepthStencilBuffer); 167 getExtensions().renderbufferStorageMultisample(GL_RENDERBUFFER, sampleCount, internalDepthStencilFormat, width, height); 168 // WebGL 1.0's rules state that combined depth/stencil renderbuffers 169 // have to be attached to the synthetic DEPTH_STENCIL_ATTACHMENT point. 170 if (!isGLES2Compliant() && internalDepthStencilFormat == GL_DEPTH24_STENCIL8_OES) 171 gl::FramebufferRenderbuffer(GL_FRAMEBUFFER, DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_multisampleDepthStencilBuffer); 172 else { 173 if (m_attrs.stencil) 174 gl::FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_multisampleDepthStencilBuffer); 175 if (m_attrs.depth) 176 gl::FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_multisampleDepthStencilBuffer); 177 } 163 178 } 164 179 gl::BindRenderbuffer(GL_RENDERBUFFER, 0); 165 if (gl CheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {180 if (gl::CheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { 166 181 // FIXME: cleanup. 167 182 notImplemented(); … … 175 190 176 191 #if PLATFORM(MAC) 177 // FIXME: implement back buffer path using ANGLE and pbuffers. 178 // allocateIOSurfaceBackingStore(IntSize(width, height)); 179 // updateFramebufferTextureBackingStoreFromLayer(); 180 // gl::FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_RECTANGLE_ARB, m_texture, 0); 192 allocateIOSurfaceBackingStore(IntSize(width, height)); 193 updateFramebufferTextureBackingStoreFromLayer(); 194 gl::FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_RECTANGLE_ANGLE, m_texture, 0); 181 195 #elif PLATFORM(IOS_FAMILY) 182 196 // FIXME (kbr): implement iOS path, ideally using glFramebufferTexture2DMultisample. … … 185 199 // setRenderbufferStorageFromDrawable(m_currentWidth, m_currentHeight); 186 200 #else 187 #error Unknown platform201 #error Unknown Cocoa platform 188 202 #endif 189 203 #else 190 gl::BindTexture(GL_TEXTURE_2D, m_texture); 191 gl::TexImage2D(GL_TEXTURE_2D, 0, m_internalColorFormat, width, height, 0, colorFormat, GL_UNSIGNED_BYTE, 0); 192 gl::FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_texture, 0); 193 194 #if USE(COORDINATED_GRAPHICS) 195 if (m_compositorTexture) { 196 gl::BindTexture(GL_TEXTURE_2D, m_compositorTexture); 197 gl::TexImage2D(GL_TEXTURE_2D, 0, m_internalColorFormat, width, height, 0, colorFormat, GL_UNSIGNED_BYTE, 0); 198 gl::BindTexture(GL_TEXTURE_2D, 0); 199 gl::BindTexture(GL_TEXTURE_2D, m_intermediateTexture); 200 gl::TexImage2D(GL_TEXTURE_2D, 0, m_internalColorFormat, width, height, 0, colorFormat, GL_UNSIGNED_BYTE, 0); 201 gl::BindTexture(GL_TEXTURE_2D, 0); 202 } 203 #endif 204 205 #error Must port to non-Cocoa platforms 206 204 207 #endif // PLATFORM(COCOA) 205 208 … … 224 227 gl::BindRenderbuffer(GL_RENDERBUFFER, m_depthStencilBuffer); 225 228 gl::RenderbufferStorage(GL_RENDERBUFFER, internalDepthStencilFormat, width, height); 226 if (m_attrs.stencil) 227 gl::FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_depthStencilBuffer); 228 if (m_attrs.depth) 229 gl::FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_depthStencilBuffer); 229 // WebGL 1.0's rules state that combined depth/stencil renderbuffers 230 // have to be attached to the synthetic DEPTH_STENCIL_ATTACHMENT point. 231 if (!isGLES2Compliant() && internalDepthStencilFormat == GL_DEPTH24_STENCIL8_OES) 232 gl::FramebufferRenderbuffer(GL_FRAMEBUFFER, DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_depthStencilBuffer); 233 else { 234 if (m_attrs.stencil) 235 gl::FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_depthStencilBuffer); 236 if (m_attrs.depth) 237 gl::FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_depthStencilBuffer); 238 } 230 239 gl::BindRenderbuffer(GL_RENDERBUFFER, 0); 231 240 } 232 241 233 if (gl CheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {242 if (gl::CheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { 234 243 // FIXME: cleanup 235 244 notImplemented(); … … 241 250 TemporaryANGLESetting scopedScissor(GL_SCISSOR_TEST, GL_FALSE); 242 251 TemporaryANGLESetting scopedDither(GL_DITHER, GL_FALSE); 243 TemporaryANGLESetting scopedDepth(GL_DEPTH_TEST, GL_FALSE); 244 TemporaryANGLESetting scopedStencil(GL_STENCIL_TEST, GL_FALSE); 252 253 GLint boundFrameBuffer; 254 gl::GetIntegerv(GL_FRAMEBUFFER_BINDING, &boundFrameBuffer); 255 gl::BindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, m_multisampleFBO); 256 gl::BindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, m_fbo); 245 257 246 258 // FIXME: figure out more efficient solution for iOS. 247 259 IntRect resolveRect = rect; 248 if (rect.isEmpty()) 260 // When using an ES 2.0 context, the full framebuffer must always be 261 // resolved; partial blits are not allowed. 262 if (!isGLES2Compliant() || rect.isEmpty()) 249 263 resolveRect = IntRect(0, 0, m_currentWidth, m_currentHeight); 250 264 251 gl::BlitFramebuffer(resolveRect.x(), resolveRect.y(), resolveRect.maxX(), resolveRect.maxY(), resolveRect.x(), resolveRect.y(), resolveRect.maxX(), resolveRect.maxY(), GL_COLOR_BUFFER_BIT, GL_LINEAR); 265 gl::BlitFramebufferANGLE(resolveRect.x(), resolveRect.y(), resolveRect.maxX(), resolveRect.maxY(), resolveRect.x(), resolveRect.y(), resolveRect.maxX(), resolveRect.maxY(), GL_COLOR_BUFFER_BIT, GL_NEAREST); 266 gl::BindFramebuffer(GL_FRAMEBUFFER, boundFrameBuffer); 252 267 } 253 268 … … 376 391 // The contents of GraphicsContext3DOpenGLCommon follow, ported to use ANGLE. 377 392 378 static ThreadSpecific<ShaderNameHash*>& getCurrentNameHashMapForShader()379 {380 static std::once_flag onceFlag;381 static ThreadSpecific<ShaderNameHash*>* sharedNameHash;382 std::call_once(onceFlag, [] {383 sharedNameHash = new ThreadSpecific<ShaderNameHash*>;384 });385 386 return *sharedNameHash;387 }388 389 static void setCurrentNameHashMapForShader(ShaderNameHash* shaderNameHash)390 {391 *getCurrentNameHashMapForShader() = shaderNameHash;392 }393 394 // Hash function used by the ANGLE translator/compiler to do395 // symbol name mangling. Since this is a static method, before396 // calling compileShader we set currentNameHashMapForShader397 // to point to the map kept by the current instance of GraphicsContext3D.398 399 static uint64_t nameHashForShader(const char* name, size_t length)400 {401 if (!length)402 return 0;403 404 CString nameAsCString = CString(name);405 406 // Look up name in our local map.407 ShaderNameHash*& currentNameHashMapForShader = *getCurrentNameHashMapForShader();408 ShaderNameHash::iterator findResult = currentNameHashMapForShader->find(nameAsCString);409 if (findResult != currentNameHashMapForShader->end())410 return findResult->value;411 412 unsigned hashValue = nameAsCString.hash();413 414 // Convert the 32-bit hash from CString::hash into a 64-bit result415 // by shifting then adding the size of our table. Overflow would416 // only be a problem if we're already hashing to the same value (and417 // we're hoping that over the lifetime of the context we418 // don't have that many symbols).419 420 uint64_t result = hashValue;421 result = (result << 32) + (currentNameHashMapForShader->size() + 1);422 423 currentNameHashMapForShader->set(nameAsCString, result);424 return result;425 }426 427 393 void GraphicsContext3D::validateDepthStencil(const char* packedDepthStencilExtension) 428 394 { 395 // Note there are no Extensions3D::ensureEnabled calls here. The ANGLE 396 // backend currently assumes at a fairly deep level that 397 // EGL_EXTENSIONS_ENABLED_ANGLE is set to true during context creation: for 398 // the allocation of rectangular textures, etc. 429 399 Extensions3D& extensions = getExtensions(); 430 400 if (m_attrs.stencil) { 431 401 if (extensions.supports(packedDepthStencilExtension)) { 432 extensions.ensureEnabled(packedDepthStencilExtension);433 402 // Force depth if stencil is true. 434 403 m_attrs.depth = true; 435 404 } else 436 405 m_attrs.stencil = false; 406 437 407 } 438 408 if (m_attrs.antialias) { 439 if (!extensions.supports("GL_ANGLE_framebuffer_multisample") || isGLES2Compliant()) 409 // FIXME: must adjust this when upgrading to WebGL 2.0 / OpenGL ES 3.0 support. 410 if (!extensions.supports("GL_ANGLE_framebuffer_multisample") || !extensions.supports("GL_ANGLE_framebuffer_blit") || !extensions.supports("GL_OES_rgb8_rgba8") || isGLES2Compliant()) 440 411 m_attrs.antialias = false; 441 else442 extensions.ensureEnabled("GL_ANGLE_framebuffer_multisample");443 412 } 444 413 } … … 514 483 makeContextCurrent(); 515 484 516 #if !USE(COORDINATED_GRAPHICS)517 TemporaryANGLESetting scopedScissor(GL_SCISSOR_TEST, GL_FALSE);518 TemporaryANGLESetting scopedDither(GL_DITHER, GL_FALSE);519 #endif520 521 485 if (m_attrs.antialias) 522 486 resolveMultisamplingIfNecessary(); 523 487 524 #if USE(COORDINATED_GRAPHICS)525 std::swap(m_texture, m_compositorTexture);526 std::swap(m_texture, m_intermediateTexture);527 gl::BindFramebuffer(GL_FRAMEBUFFER, m_fbo);528 gl::FramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_texture, 0);529 glFlush();530 531 if (m_state.boundFBO != m_fbo)532 gl::BindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_state.boundFBO);533 else534 gl::BindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo);535 return;536 #endif537 538 gl::ActiveTexture(GL_TEXTURE0);539 gl::BindTexture(GL_TEXTURE_2D, m_state.boundTarget(GL_TEXTURE0) == GL_TEXTURE_2D ? m_state.boundTexture(GL_TEXTURE0) : 0);540 gl::ActiveTexture(m_state.activeTextureUnit);541 if (m_state.boundFBO != m_fbo)542 gl::BindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_state.boundFBO);543 488 gl::Flush(); 544 489 } … … 652 597 } 653 598 654 bool GraphicsContext3D::checkVaryingsPacking(Platform3DObject vertexShader, Platform3DObject fragmentShader) const655 {656 ASSERT(m_shaderSourceMap.contains(vertexShader));657 ASSERT(m_shaderSourceMap.contains(fragmentShader));658 const auto& vertexEntry = m_shaderSourceMap.find(vertexShader)->value;659 const auto& fragmentEntry = m_shaderSourceMap.find(fragmentShader)->value;660 661 HashMap<String, sh::ShaderVariable> combinedVaryings;662 for (const auto& vertexSymbol : vertexEntry.varyingMap) {663 const String& symbolName = vertexSymbol.key;664 // The varying map includes variables for each index of an array variable.665 // We only want a single variable to represent the array.666 if (symbolName.endsWith("]"))667 continue;668 669 // Don't count built in varyings.670 if (symbolName == "gl_FragCoord" || symbolName == "gl_FrontFacing" || symbolName == "gl_PointCoord")671 continue;672 673 const auto& fragmentSymbol = fragmentEntry.varyingMap.find(symbolName);674 if (fragmentSymbol != fragmentEntry.varyingMap.end())675 combinedVaryings.add(symbolName, fragmentSymbol->value);676 }677 678 size_t numVaryings = combinedVaryings.size();679 if (!numVaryings)680 return true;681 682 std::vector<sh::ShaderVariable> variables;683 variables.reserve(combinedVaryings.size());684 for (const auto& varyingSymbol : combinedVaryings.values())685 variables.push_back(varyingSymbol);686 687 GC3Dint maxVaryingVectors = 0;688 gl::GetIntegerv(MAX_VARYING_VECTORS, &maxVaryingVectors);689 return sh::CheckVariablesWithinPackingLimits(maxVaryingVectors, variables);690 }691 692 bool GraphicsContext3D::precisionsMatch(Platform3DObject vertexShader, Platform3DObject fragmentShader) const693 {694 ASSERT(m_shaderSourceMap.contains(vertexShader));695 ASSERT(m_shaderSourceMap.contains(fragmentShader));696 const auto& vertexEntry = m_shaderSourceMap.find(vertexShader)->value;697 const auto& fragmentEntry = m_shaderSourceMap.find(fragmentShader)->value;698 699 HashMap<String, sh::GLenum> vertexSymbolPrecisionMap;700 701 for (const auto& entry : vertexEntry.uniformMap) {702 const std::string& mappedName = entry.value.mappedName;703 vertexSymbolPrecisionMap.add(String(mappedName.c_str(), mappedName.length()), entry.value.precision);704 }705 706 for (const auto& entry : fragmentEntry.uniformMap) {707 const std::string& mappedName = entry.value.mappedName;708 const auto& vertexSymbol = vertexSymbolPrecisionMap.find(String(mappedName.c_str(), mappedName.length()));709 if (vertexSymbol != vertexSymbolPrecisionMap.end() && vertexSymbol->value != entry.value.precision)710 return false;711 }712 713 return true;714 }715 716 599 IntSize GraphicsContext3D::getInternalFramebufferSize() const 717 600 { … … 731 614 ASSERT(shader); 732 615 makeContextCurrent(); 733 m_shaderProgramSymbolCountMap.remove(program);734 616 gl::AttachShader(program, shader); 735 617 } … … 739 621 ASSERT(program); 740 622 makeContextCurrent(); 741 742 String mappedName = mappedSymbolName(program, SHADER_SYMBOL_TYPE_ATTRIBUTE, name); 743 LOG(WebGL, "::bindAttribLocation is mapping %s to %s", name.utf8().data(), mappedName.utf8().data()); 744 gl::BindAttribLocation(program, index, mappedName.utf8().data()); 623 gl::BindAttribLocation(program, index, name.utf8().data()); 745 624 } 746 625 … … 915 794 ASSERT(shader); 916 795 makeContextCurrent(); 917 918 // Turn on name mapping. Due to the way ANGLE name hashing works, we 919 // point a global hashmap to the map owned by this context. 920 ShBuiltInResources ANGLEResources = m_compiler.getResources(); 921 ShHashFunction64 previousHashFunction = ANGLEResources.HashFunction; 922 ANGLEResources.HashFunction = nameHashForShader; 923 924 if (!nameHashMapForShaders) 925 nameHashMapForShaders = std::make_unique<ShaderNameHash>(); 926 setCurrentNameHashMapForShader(nameHashMapForShaders.get()); 927 m_compiler.setResources(ANGLEResources); 928 929 String translatedShaderSource = m_extensions->getTranslatedShaderSourceANGLE(shader); 930 931 ANGLEResources.HashFunction = previousHashFunction; 932 m_compiler.setResources(ANGLEResources); 933 setCurrentNameHashMapForShader(nullptr); 934 935 if (!translatedShaderSource.length()) 936 return; 937 938 const CString& translatedShaderCString = translatedShaderSource.utf8(); 939 const char* translatedShaderPtr = translatedShaderCString.data(); 940 int translatedShaderLength = translatedShaderCString.length(); 941 942 LOG(WebGL, "--- begin original shader source ---\n%s\n--- end original shader source ---\n", getShaderSource(shader).utf8().data()); 943 LOG(WebGL, "--- begin translated shader source ---\n%s\n--- end translated shader source ---", translatedShaderPtr); 944 945 gl::ShaderSource(shader, 1, &translatedShaderPtr, &translatedShaderLength); 946 947 ::glCompileShader(shader); 948 949 int compileStatus; 950 951 gl::GetShaderiv(shader, COMPILE_STATUS, &compileStatus); 952 953 ShaderSourceMap::iterator result = m_shaderSourceMap.find(shader); 954 GraphicsContext3D::ShaderSourceEntry& entry = result->value; 955 956 // Populate the shader log 957 GLint length = 0; 958 gl::GetShaderiv(shader, GL_INFO_LOG_LENGTH, &length); 959 960 if (length) { 961 GLsizei size = 0; 962 Vector<GLchar> info(length); 963 gl::GetShaderInfoLog(shader, length, &size, info.data()); 964 965 Platform3DObject shaders[2] = { shader, 0 }; 966 entry.log = getUnmangledInfoLog(shaders, 1, String(info.data(), size)); 967 } 968 969 if (compileStatus != GL_TRUE) { 970 entry.isValid = false; 971 LOG(WebGL, "Error: shader translator produced a shader that OpenGL would not compile."); 972 } 796 gl::CompileShader(shader); 973 797 } 974 798 975 799 void GraphicsContext3D::compileShaderDirect(Platform3DObject shader) 976 800 { 977 ASSERT(shader); 978 makeContextCurrent(); 979 980 HashMap<Platform3DObject, ShaderSourceEntry>::iterator result = m_shaderSourceMap.find(shader); 981 982 if (result == m_shaderSourceMap.end()) 983 return; 984 985 ShaderSourceEntry& entry = result->value; 986 987 const CString& shaderSourceCString = entry.source.utf8(); 988 const char* shaderSourcePtr = shaderSourceCString.data(); 989 int shaderSourceLength = shaderSourceCString.length(); 990 991 LOG(WebGL, "--- begin direct shader source ---\n%s\n--- end direct shader source ---\n", shaderSourcePtr); 992 993 gl::ShaderSource(shader, 1, &shaderSourcePtr, &shaderSourceLength); 994 995 gl::CompileShader(shader); 996 997 int compileStatus; 998 999 gl::GetShaderiv(shader, COMPILE_STATUS, &compileStatus); 1000 1001 if (compileStatus == GL_TRUE) { 1002 entry.isValid = true; 1003 LOG(WebGL, "Direct compilation of shader succeeded."); 1004 } else { 1005 entry.isValid = false; 1006 LOG(WebGL, "Error: direct compilation of shader failed."); 1007 } 801 compileShader(shader); 1008 802 } 1009 803 … … 1055 849 ASSERT(shader); 1056 850 makeContextCurrent(); 1057 m_shaderProgramSymbolCountMap.remove(program);1058 851 gl::DetachShader(program, shader); 1059 852 } … … 1151 944 return false; 1152 945 1153 String originalName = originalSymbolName(program, SHADER_SYMBOL_TYPE_ATTRIBUTE, String(name.data(), nameLength)); 1154 1155 #ifndef NDEBUG 1156 String uniformName(name.data(), nameLength); 1157 LOG(WebGL, "Program %d is mapping active attribute %d from '%s' to '%s'", program, index, uniformName.utf8().data(), originalName.utf8().data()); 1158 #endif 1159 1160 info.name = originalName; 946 info.name = String(name.data(), nameLength); 1161 947 info.type = type; 1162 948 info.size = size; … … 1166 952 bool GraphicsContext3D::getActiveAttrib(Platform3DObject program, GC3Duint index, ActiveInfo& info) 1167 953 { 1168 GC3Dint symbolCount; 1169 auto result = m_shaderProgramSymbolCountMap.find(program); 1170 if (result == m_shaderProgramSymbolCountMap.end()) { 1171 getNonBuiltInActiveSymbolCount(program, GraphicsContext3D::ACTIVE_ATTRIBUTES, &symbolCount); 1172 result = m_shaderProgramSymbolCountMap.find(program); 1173 } 1174 1175 ActiveShaderSymbolCounts& symbolCounts = result->value; 1176 GC3Duint rawIndex = (index < symbolCounts.filteredToActualAttributeIndexMap.size()) ? symbolCounts.filteredToActualAttributeIndexMap[index] : -1; 1177 1178 return getActiveAttribImpl(program, rawIndex, info); 954 return getActiveAttribImpl(program, index, info); 1179 955 } 1180 956 … … 1198 974 return false; 1199 975 1200 String originalName = originalSymbolName(program, SHADER_SYMBOL_TYPE_UNIFORM, String(name.data(), nameLength)); 1201 1202 #ifndef NDEBUG 1203 String uniformName(name.data(), nameLength); 1204 LOG(WebGL, "Program %d is mapping active uniform %d from '%s' to '%s'", program, index, uniformName.utf8().data(), originalName.utf8().data()); 1205 #endif 1206 1207 info.name = originalName; 976 info.name = String(name.data(), nameLength); 1208 977 info.type = type; 1209 978 info.size = size; … … 1213 982 bool GraphicsContext3D::getActiveUniform(Platform3DObject program, GC3Duint index, ActiveInfo& info) 1214 983 { 1215 GC3Dint symbolCount; 1216 auto result = m_shaderProgramSymbolCountMap.find(program); 1217 if (result == m_shaderProgramSymbolCountMap.end()) { 1218 getNonBuiltInActiveSymbolCount(program, GraphicsContext3D::ACTIVE_UNIFORMS, &symbolCount); 1219 result = m_shaderProgramSymbolCountMap.find(program); 1220 } 1221 1222 ActiveShaderSymbolCounts& symbolCounts = result->value; 1223 GC3Duint rawIndex = (index < symbolCounts.filteredToActualUniformIndexMap.size()) ? symbolCounts.filteredToActualUniformIndexMap[index] : -1; 1224 1225 return getActiveUniformImpl(program, rawIndex, info); 984 return getActiveUniformImpl(program, index, info); 1226 985 } 1227 986 … … 1236 995 } 1237 996 1238 static String generateHashedName(const String& name)1239 {1240 if (name.isEmpty())1241 return name;1242 uint64_t number = nameHashForShader(name.utf8().data(), name.length());1243 StringBuilder builder;1244 builder.appendLiteral("webgl_");1245 appendUnsignedAsHex(number, builder, Lowercase);1246 return builder.toString();1247 }1248 1249 Optional<String> GraphicsContext3D::mappedSymbolInShaderSourceMap(Platform3DObject shader, ANGLEShaderSymbolType symbolType, const String& name)1250 {1251 auto result = m_shaderSourceMap.find(shader);1252 if (result == m_shaderSourceMap.end())1253 return WTF::nullopt;1254 1255 const auto& symbolMap = result->value.symbolMap(symbolType);1256 auto symbolEntry = symbolMap.find(name);1257 if (symbolEntry == symbolMap.end())1258 return WTF::nullopt;1259 1260 auto& mappedName = symbolEntry->value.mappedName;1261 return String(mappedName.c_str(), mappedName.length());1262 }1263 1264 String GraphicsContext3D::mappedSymbolName(Platform3DObject program, ANGLEShaderSymbolType symbolType, const String& name)1265 {1266 GC3Dsizei count = 0;1267 Platform3DObject shaders[2] = { };1268 getAttachedShaders(program, 2, &count, shaders);1269 1270 for (GC3Dsizei i = 0; i < count; ++i) {1271 auto mappedName = mappedSymbolInShaderSourceMap(shaders[i], symbolType, name);1272 if (mappedName)1273 return mappedName.value();1274 }1275 1276 // We might have detached or deleted the shaders after linking.1277 auto result = m_linkedShaderMap.find(program);1278 if (result != m_linkedShaderMap.end()) {1279 auto linkedShaders = result->value;1280 auto mappedName = mappedSymbolInShaderSourceMap(linkedShaders.first, symbolType, name);1281 if (mappedName)1282 return mappedName.value();1283 mappedName = mappedSymbolInShaderSourceMap(linkedShaders.second, symbolType, name);1284 if (mappedName)1285 return mappedName.value();1286 }1287 1288 if (symbolType == SHADER_SYMBOL_TYPE_ATTRIBUTE && !name.isEmpty()) {1289 // Attributes are a special case: they may be requested before any shaders have been compiled,1290 // and aren't even required to be used in any shader program.1291 if (!nameHashMapForShaders)1292 nameHashMapForShaders = std::make_unique<ShaderNameHash>();1293 setCurrentNameHashMapForShader(nameHashMapForShaders.get());1294 1295 auto generatedName = generateHashedName(name);1296 1297 setCurrentNameHashMapForShader(nullptr);1298 1299 m_possiblyUnusedAttributeMap.set(generatedName, name);1300 1301 return generatedName;1302 }1303 1304 return name;1305 }1306 1307 Optional<String> GraphicsContext3D::originalSymbolInShaderSourceMap(Platform3DObject shader, ANGLEShaderSymbolType symbolType, const String& name)1308 {1309 auto result = m_shaderSourceMap.find(shader);1310 if (result == m_shaderSourceMap.end())1311 return WTF::nullopt;1312 1313 const auto& symbolMap = result->value.symbolMap(symbolType);1314 for (const auto& symbolEntry : symbolMap) {1315 if (name == symbolEntry.value.mappedName.c_str())1316 return symbolEntry.key;1317 }1318 return WTF::nullopt;1319 }1320 1321 String GraphicsContext3D::originalSymbolName(Platform3DObject program, ANGLEShaderSymbolType symbolType, const String& name)1322 {1323 GC3Dsizei count;1324 Platform3DObject shaders[2];1325 getAttachedShaders(program, 2, &count, shaders);1326 1327 for (GC3Dsizei i = 0; i < count; ++i) {1328 auto originalName = originalSymbolInShaderSourceMap(shaders[i], symbolType, name);1329 if (originalName)1330 return originalName.value();1331 }1332 1333 // We might have detached or deleted the shaders after linking.1334 auto result = m_linkedShaderMap.find(program);1335 if (result != m_linkedShaderMap.end()) {1336 auto linkedShaders = result->value;1337 auto originalName = originalSymbolInShaderSourceMap(linkedShaders.first, symbolType, name);1338 if (originalName)1339 return originalName.value();1340 originalName = originalSymbolInShaderSourceMap(linkedShaders.second, symbolType, name);1341 if (originalName)1342 return originalName.value();1343 }1344 1345 if (symbolType == SHADER_SYMBOL_TYPE_ATTRIBUTE && !name.isEmpty()) {1346 // Attributes are a special case: they may be requested before any shaders have been compiled,1347 // and aren't even required to be used in any shader program.1348 1349 const auto& cached = m_possiblyUnusedAttributeMap.find(name);1350 if (cached != m_possiblyUnusedAttributeMap.end())1351 return cached->value;1352 }1353 1354 return name;1355 }1356 1357 String GraphicsContext3D::mappedSymbolName(Platform3DObject shaders[2], size_t count, const String& name)1358 {1359 for (size_t symbolType = 0; symbolType <= static_cast<size_t>(SHADER_SYMBOL_TYPE_VARYING); ++symbolType) {1360 for (size_t i = 0; i < count; ++i) {1361 ShaderSourceMap::iterator result = m_shaderSourceMap.find(shaders[i]);1362 if (result == m_shaderSourceMap.end())1363 continue;1364 1365 const ShaderSymbolMap& symbolMap = result->value.symbolMap(static_cast<enum ANGLEShaderSymbolType>(symbolType));1366 for (const auto& symbolEntry : symbolMap) {1367 if (name == symbolEntry.value.mappedName.c_str())1368 return symbolEntry.key;1369 }1370 }1371 }1372 return name;1373 }1374 1375 997 int GraphicsContext3D::getAttribLocation(Platform3DObject program, const String& name) 1376 998 { … … 1380 1002 makeContextCurrent(); 1381 1003 1382 String mappedName = mappedSymbolName(program, SHADER_SYMBOL_TYPE_ATTRIBUTE, name); 1383 LOG(WebGL, "gl::GetAttribLocation is mapping %s to %s", name.utf8().data(), mappedName.utf8().data()); 1384 return gl::GetAttribLocation(program, mappedName.utf8().data()); 1004 return gl::GetAttribLocation(program, name.utf8().data()); 1385 1005 } 1386 1006 1387 1007 int GraphicsContext3D::getAttribLocationDirect(Platform3DObject program, const String& name) 1388 1008 { 1389 if (!program) 1390 return -1; 1391 1392 makeContextCurrent(); 1393 1394 return gl::GetAttribLocation(program, name.utf8().data()); 1009 return getAttribLocation(program, name); 1395 1010 } 1396 1011 … … 1409 1024 // Otherwise, we would just loop until we got NO_ERROR. 1410 1025 for (unsigned i = 0; i < 100; ++i) { 1411 GC3Denum error = gl GetError();1026 GC3Denum error = gl::GetError(); 1412 1027 if (error == NO_ERROR) 1413 1028 break; … … 1515 1130 ASSERT(program); 1516 1131 makeContextCurrent(); 1517 1518 GC3Dsizei count = 0;1519 Platform3DObject shaders[2] = { };1520 getAttachedShaders(program, 2, &count, shaders);1521 1522 if (count == 2)1523 m_linkedShaderMap.set(program, std::make_pair(shaders[0], shaders[1]));1524 1525 1132 gl::LinkProgram(program); 1526 1133 } … … 1556 1163 makeContextCurrent(); 1557 1164 1558 ShaderSourceEntry entry; 1559 1560 entry.source = string; 1561 1562 m_shaderSourceMap.set(shader, entry); 1165 const CString& shaderSourceCString = string.utf8(); 1166 const char* shaderSourcePtr = shaderSourceCString.data(); 1167 int shaderSourceLength = shaderSourceCString.length(); 1168 gl::ShaderSource(shader, 1, &shaderSourcePtr, &shaderSourceLength); 1563 1169 } 1564 1170 … … 1879 1485 } 1880 1486 1881 void GraphicsContext3D::getNonBuiltInActiveSymbolCount(Platform3DObject program, GC3Denum pname, GC3Dint* value)1882 {1883 ASSERT(ACTIVE_ATTRIBUTES == pname || ACTIVE_UNIFORMS == pname);1884 if (!value)1885 return;1886 1887 makeContextCurrent();1888 const auto& result = m_shaderProgramSymbolCountMap.find(program);1889 if (result != m_shaderProgramSymbolCountMap.end()) {1890 *value = result->value.countForType(pname);1891 return;1892 }1893 1894 m_shaderProgramSymbolCountMap.set(program, ActiveShaderSymbolCounts());1895 ActiveShaderSymbolCounts& symbolCounts = m_shaderProgramSymbolCountMap.find(program)->value;1896 1897 // Retrieve the active attributes, build a filtered count, and a mapping of1898 // our internal attributes indexes to the real unfiltered indexes inside OpenGL.1899 GC3Dint attributeCount = 0;1900 gl::GetProgramiv(program, ACTIVE_ATTRIBUTES, &attributeCount);1901 for (GC3Dint i = 0; i < attributeCount; ++i) {1902 ActiveInfo info;1903 getActiveAttribImpl(program, i, info);1904 if (info.name.startsWith("gl_"))1905 continue;1906 1907 symbolCounts.filteredToActualAttributeIndexMap.append(i);1908 }1909 1910 // Do the same for uniforms.1911 GC3Dint uniformCount = 0;1912 gl::GetProgramiv(program, ACTIVE_UNIFORMS, &uniformCount);1913 for (GC3Dint i = 0; i < uniformCount; ++i) {1914 ActiveInfo info;1915 getActiveUniformImpl(program, i, info);1916 if (info.name.startsWith("gl_"))1917 continue;1918 1919 symbolCounts.filteredToActualUniformIndexMap.append(i);1920 }1921 1922 *value = symbolCounts.countForType(pname);1923 }1924 1925 1487 String GraphicsContext3D::getUnmangledInfoLog(Platform3DObject shaders[2], GC3Dsizei count, const String& log) 1926 1488 { 1489 UNUSED_PARAM(shaders); 1490 UNUSED_PARAM(count); 1927 1491 LOG(WebGL, "Original ShaderInfoLog:\n%s", log.utf8().data()); 1928 1492 1929 JSC::Yarr::RegularExpression regExp("webgl_[0123456789abcdefABCDEF]+");1930 1931 1493 StringBuilder processedLog; 1932 1494 1933 1495 // ANGLE inserts a "#extension" line into the shader source that 1934 1496 // causes a warning in some compilers. There is no point showing … … 1937 1499 static const NeverDestroyed<String> angleWarning { "WARNING: 0:1: extension 'GL_ARB_gpu_shader5' is not supported\n"_s }; 1938 1500 int startFrom = log.startsWith(angleWarning) ? angleWarning.get().length() : 0; 1939 int matchedLength = 0;1940 1941 do {1942 int start = regExp.match(log, startFrom, &matchedLength);1943 if (start == -1)1944 break;1945 1946 processedLog.append(log.substring(startFrom, start - startFrom));1947 startFrom = start + matchedLength;1948 1949 const String& mangledSymbol = log.substring(start, matchedLength);1950 const String& mappedSymbol = mappedSymbolName(shaders, count, mangledSymbol);1951 LOG(WebGL, "Demangling: %s to %s", mangledSymbol.utf8().data(), mappedSymbol.utf8().data());1952 processedLog.append(mappedSymbol);1953 } while (startFrom < static_cast<int>(log.length()));1954 1955 1501 processedLog.append(log.substring(startFrom, log.length() - startFrom)); 1956 1502 … … 1991 1537 1992 1538 makeContextCurrent(); 1993 1994 const auto& result = m_shaderSourceMap.find(shader); 1995 1996 switch (pname) { 1997 case DELETE_STATUS: 1998 case SHADER_TYPE: 1999 gl::GetShaderiv(shader, pname, value); 2000 break; 2001 case COMPILE_STATUS: 2002 if (result == m_shaderSourceMap.end()) { 2003 *value = static_cast<int>(false); 2004 return; 2005 } 2006 *value = static_cast<int>(result->value.isValid); 2007 break; 2008 case INFO_LOG_LENGTH: 2009 if (result == m_shaderSourceMap.end()) { 2010 *value = 0; 2011 return; 2012 } 2013 *value = getShaderInfoLog(shader).length(); 2014 break; 2015 case SHADER_SOURCE_LENGTH: 2016 *value = getShaderSource(shader).length(); 2017 break; 2018 default: 2019 synthesizeGLError(INVALID_ENUM); 2020 } 1539 gl::GetShaderiv(shader, pname, value); 2021 1540 } 2022 1541 … … 2026 1545 2027 1546 makeContextCurrent(); 2028 2029 const auto& result = m_shaderSourceMap.find(shader);2030 if (result == m_shaderSourceMap.end())2031 return String();2032 2033 const ShaderSourceEntry& entry = result->value;2034 if (!entry.isValid)2035 return entry.log;2036 2037 1547 GLint length = 0; 2038 1548 gl::GetShaderiv(shader, GL_INFO_LOG_LENGTH, &length); … … 2048 1558 } 2049 1559 2050 String GraphicsContext3D::getShaderSource(Platform3DObject shader)2051 {2052 ASSERT(shader);2053 2054 makeContextCurrent();2055 2056 const auto& result = m_shaderSourceMap.find(shader);2057 if (result == m_shaderSourceMap.end())2058 return String();2059 2060 return result->value.source;2061 }2062 2063 2064 1560 void GraphicsContext3D::getTexParameterfv(GC3Denum target, GC3Denum pname, GC3Dfloat* value) 2065 1561 { … … 2091 1587 2092 1588 makeContextCurrent(); 2093 2094 String mappedName = mappedSymbolName(program, SHADER_SYMBOL_TYPE_UNIFORM, name); 2095 LOG(WebGL, "::getUniformLocation is mapping %s to %s", name.utf8().data(), mappedName.utf8().data()); 2096 return gl::GetUniformLocation(program, mappedName.utf8().data()); 1589 return gl::GetUniformLocation(program, name.utf8().data()); 2097 1590 } 2098 1591 … … 2145 1638 makeContextCurrent(); 2146 1639 GLuint o = 0; 2147 gl GenBuffers(1, &o);1640 gl::GenBuffers(1, &o); 2148 1641 return o; 2149 1642 } … … 2153 1646 makeContextCurrent(); 2154 1647 GLuint o = 0; 2155 gl GenFramebuffers(1, &o);1648 gl::GenFramebuffers(1, &o); 2156 1649 return o; 2157 1650 } … … 2160 1653 { 2161 1654 makeContextCurrent(); 2162 return gl CreateProgram();1655 return gl::CreateProgram(); 2163 1656 } 2164 1657 … … 2167 1660 makeContextCurrent(); 2168 1661 GLuint o = 0; 2169 gl GenRenderbuffers(1, &o);1662 gl::GenRenderbuffers(1, &o); 2170 1663 return o; 2171 1664 } … … 2174 1667 { 2175 1668 makeContextCurrent(); 2176 return gl CreateShader((type == FRAGMENT_SHADER) ? GL_FRAGMENT_SHADER : GL_VERTEX_SHADER);1669 return gl::CreateShader((type == FRAGMENT_SHADER) ? GL_FRAGMENT_SHADER : GL_VERTEX_SHADER); 2177 1670 } 2178 1671 … … 2181 1674 makeContextCurrent(); 2182 1675 GLuint o = 0; 2183 gl GenTextures(1, &o);1676 gl::GenTextures(1, &o); 2184 1677 m_state.textureSeedCount.add(o); 2185 1678 return o; … … 2189 1682 { 2190 1683 makeContextCurrent(); 2191 gl DeleteBuffers(1, &buffer);1684 gl::DeleteBuffers(1, &buffer); 2192 1685 } 2193 1686 … … 2200 1693 bindFramebuffer(FRAMEBUFFER, 0); 2201 1694 } 2202 gl DeleteFramebuffers(1, &framebuffer);1695 gl::DeleteFramebuffers(1, &framebuffer); 2203 1696 } 2204 1697 … … 2206 1699 { 2207 1700 makeContextCurrent(); 2208 m_shaderProgramSymbolCountMap.remove(program); 2209 glDeleteProgram(program); 1701 gl::DeleteProgram(program); 2210 1702 } 2211 1703 … … 2213 1705 { 2214 1706 makeContextCurrent(); 2215 gl DeleteRenderbuffers(1, &renderbuffer);1707 gl::DeleteRenderbuffers(1, &renderbuffer); 2216 1708 } 2217 1709 … … 2219 1711 { 2220 1712 makeContextCurrent(); 2221 gl DeleteShader(shader);1713 gl::DeleteShader(shader); 2222 1714 } 2223 1715 … … 2228 1720 return keyValue.value.first == texture; 2229 1721 }); 2230 gl DeleteTextures(1, &texture);1722 gl::DeleteTextures(1, &texture); 2231 1723 m_state.textureSeedCount.removeAll(texture); 2232 1724 } … … 2236 1728 // Need to move the current errors to the synthetic error list to 2237 1729 // preserve the order of errors, so a caller to getError will get 2238 // any errors from gl Error before the error we are synthesizing.1730 // any errors from gl::Error before the error we are synthesizing. 2239 1731 moveErrorsToSyntheticErrorList(); 2240 1732 m_syntheticErrors.add(error); -
trunk/Source/WebCore/platform/graphics/cocoa/GraphicsContext3DCocoa.mm
r246554 r247315 61 61 #import <OpenGL/gl.h> 62 62 #elif USE(ANGLE) 63 #define EGL_EGL_PROTOTYPES 0 64 // Skip the inclusion of ANGLE's explicit context entry points for now. 65 #define GL_ANGLE_explicit_context 66 #define GL_ANGLE_explicit_context_gles1 67 typedef void* GLeglContext; 68 #include <ANGLE/egl.h> 69 #include <ANGLE/eglext.h> 70 #include <ANGLE/eglext_angle.h> 71 #include <ANGLE/entry_points_egl.h> 63 72 #include <ANGLE/entry_points_gles_2_0_autogen.h> 73 #include <ANGLE/entry_points_gles_ext_autogen.h> 74 #include <ANGLE/gl2ext.h> 75 #include <ANGLE/gl2ext_angle.h> 64 76 #endif 65 77 … … 255 267 { 256 268 #if USE(ANGLE) 257 if (m_attrs.isWebGL2) 258 m_compiler = ANGLEWebKitBridge(SH_ESSL_OUTPUT, SH_WEBGL2_SPEC); 259 else 260 m_compiler = ANGLEWebKitBridge(SH_ESSL_OUTPUT); 269 // In the ANGLE backend, the only shader compiler instantiated is 270 // the one ANGLE uses internally. 261 271 #else 262 272 #if PLATFORM(IOS_FAMILY) … … 369 379 370 380 #elif USE(ANGLE) 371 372 // FIXME: implement context setup via ANGLE.373 381 UNUSED_PARAM(hostWindow); 374 382 UNUSED_PARAM(sharedContext); 375 383 376 #endif 377 384 m_displayObj = EGL_GetDisplay(EGL_DEFAULT_DISPLAY); 385 if (m_displayObj == EGL_NO_DISPLAY) 386 return; 387 EGLint majorVersion, minorVersion; 388 if (EGL_Initialize(m_displayObj, &majorVersion, &minorVersion) == EGL_FALSE) { 389 LOG(WebGL, "EGLDisplay Initialization failed."); 390 return; 391 } 392 LOG(WebGL, "ANGLE initialised Major: %d Minor: %d", majorVersion, minorVersion); 393 const char *displayExtensions = EGL_QueryString(m_displayObj, EGL_EXTENSIONS); 394 LOG(WebGL, "Extensions: %s", displayExtensions); 395 396 EGLConfig config; 397 EGLint configAttributes[] = { 398 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, 399 EGL_RED_SIZE, 8, 400 EGL_GREEN_SIZE, 8, 401 EGL_BLUE_SIZE, 8, 402 EGL_ALPHA_SIZE, 8, 403 EGL_NONE 404 }; 405 EGLint numberConfigsReturned = 0; 406 EGL_ChooseConfig(m_displayObj, configAttributes, &config, 1, &numberConfigsReturned); 407 if (numberConfigsReturned != 1) { 408 LOG(WebGL, "EGLConfig Initialization failed."); 409 return; 410 } 411 LOG(WebGL, "Got EGLConfig"); 412 413 EGL_BindAPI(EGL_OPENGL_ES_API); 414 if (EGL_GetError() != EGL_SUCCESS) { 415 LOG(WebGL, "Unable to bind to OPENGL_ES_API"); 416 return; 417 } 418 419 std::vector<EGLint> contextAttributes; 420 contextAttributes.push_back(EGL_CONTEXT_CLIENT_VERSION); 421 contextAttributes.push_back(2); 422 contextAttributes.push_back(EGL_CONTEXT_WEBGL_COMPATIBILITY_ANGLE); 423 contextAttributes.push_back(EGL_TRUE); 424 contextAttributes.push_back(EGL_EXTENSIONS_ENABLED_ANGLE); 425 contextAttributes.push_back(EGL_TRUE); 426 if (strstr(displayExtensions, "EGL_ANGLE_power_preference")) { 427 contextAttributes.push_back(EGL_POWER_PREFERENCE_ANGLE); 428 // EGL_LOW_POWER_ANGLE is the default. Change to 429 // EGL_HIGH_POWER_ANGLE if desired. 430 contextAttributes.push_back(EGL_LOW_POWER_ANGLE); 431 } 432 contextAttributes.push_back(EGL_NONE); 433 434 m_contextObj = EGL_CreateContext(m_displayObj, config, EGL_NO_CONTEXT, contextAttributes.data()); 435 if (m_contextObj == EGL_NO_CONTEXT) { 436 LOG(WebGL, "EGLContext Initialization failed."); 437 return; 438 } 439 LOG(WebGL, "Got EGLContext"); 440 441 EGL_MakeCurrent(m_displayObj, EGL_NO_SURFACE, EGL_NO_SURFACE, m_contextObj); 442 443 #endif // #elif USE(ANGLE) 444 378 445 validateAttributes(); 379 446 … … 383 450 #ifndef NDEBUG 384 451 [m_webGLLayer setName:@"WebGL Layer"]; 452 #endif 453 #if USE(ANGLE) 454 [m_webGLLayer setEGLDisplay:m_displayObj andConfig:config]; 385 455 #endif 386 456 END_BLOCK_OBJC_EXCEPTIONS … … 405 475 ::glBindTexture(GL_TEXTURE_RECTANGLE_EXT, 0); 406 476 #elif USE(ANGLE) 407 // FIXME: implement back buffer setup via ANGLE. 477 gl::GenTextures(1, &m_texture); 478 gl::BindTexture(GL_TEXTURE_RECTANGLE_ANGLE, m_texture); 479 gl::TexParameteri(GL_TEXTURE_RECTANGLE_ANGLE, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 480 gl::TexParameteri(GL_TEXTURE_RECTANGLE_ANGLE, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 481 gl::TexParameteri(GL_TEXTURE_RECTANGLE_ANGLE, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 482 gl::TexParameteri(GL_TEXTURE_RECTANGLE_ANGLE, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 483 gl::BindTexture(GL_TEXTURE_RECTANGLE_ANGLE, 0); 408 484 #else 409 485 #error Unsupported configuration … … 428 504 ::glGenRenderbuffersEXT(1, &m_multisampleDepthStencilBuffer); 429 505 } 430 #endif // USE(ANGLE) || USE(OPENGL_ES) 431 432 // ANGLE initialization. 506 #elif USE(ANGLE) 507 gl::GenFramebuffers(1, &m_fbo); 508 gl::BindFramebuffer(GL_FRAMEBUFFER, m_fbo); 509 m_state.boundFBO = m_fbo; 510 511 if (!m_attrs.antialias && (m_attrs.stencil || m_attrs.depth)) 512 gl::GenRenderbuffers(1, &m_depthStencilBuffer); 513 514 // If necessary, create another framebuffer for the multisample results. 515 if (m_attrs.antialias) { 516 gl::GenFramebuffers(1, &m_multisampleFBO); 517 gl::BindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO); 518 m_state.boundFBO = m_multisampleFBO; 519 gl::GenRenderbuffers(1, &m_multisampleColorBuffer); 520 if (m_attrs.stencil || m_attrs.depth) 521 gl::GenRenderbuffers(1, &m_multisampleDepthStencilBuffer); 522 } 523 524 #endif // USE(ANGLE) 525 526 #if !USE(ANGLE) 527 // ANGLE shader compiler initialization. 433 528 434 529 ShBuiltInResources ANGLEResources; … … 451 546 452 547 m_compiler.setResources(ANGLEResources); 548 #endif // !USE(ANGLE) 453 549 454 550 #if USE(OPENGL) … … 460 556 #if USE(OPENGL) || USE(OPENGL_ES) 461 557 ::glClearColor(0, 0, 0, 0); 558 #elif USE(ANGLE) 559 gl::ClearColor(0, 0, 0, 0); 462 560 #endif 463 561 … … 478 576 ::glDeleteTextures(1, &m_texture); 479 577 #elif USE(ANGLE) 480 // FIXME: make context current via ANGLE. 578 EGL_MakeCurrent(m_displayObj, EGL_NO_SURFACE, EGL_NO_SURFACE, m_contextObj); 579 gl::DeleteTextures(1, &m_texture); 481 580 #endif 482 581 … … 492 591 } 493 592 ::glDeleteFramebuffersEXT(1, &m_fbo); 593 #elif USE(ANGLE) 594 if (m_attrs.antialias) { 595 gl::DeleteRenderbuffers(1, &m_multisampleColorBuffer); 596 if (m_attrs.stencil || m_attrs.depth) 597 gl::DeleteRenderbuffers(1, &m_multisampleDepthStencilBuffer); 598 gl::DeleteFramebuffers(1, &m_multisampleFBO); 599 } else { 600 if (m_attrs.stencil || m_attrs.depth) 601 gl::DeleteRenderbuffers(1, &m_depthStencilBuffer); 602 } 603 gl::DeleteFramebuffers(1, &m_fbo); 494 604 #endif 495 605 … … 501 611 CGLDestroyContext(m_contextObj); 502 612 #elif USE(ANGLE) 503 // FIXME: implement context teardown via ANGLE. 613 EGL_MakeCurrent(m_displayObj, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); 614 EGL_DestroyContext(m_displayObj, m_contextObj); 504 615 #endif 505 616 [m_webGLLayer setContext:nullptr]; … … 538 649 return CGLSetCurrentContext(m_contextObj) == kCGLNoError; 539 650 #elif USE(ANGLE) 540 // FIXME: implement making context current via ANGLE. 651 if (EGL_GetCurrentContext() != m_contextObj) 652 return EGL_MakeCurrent(m_displayObj, EGL_NO_SURFACE, EGL_NO_SURFACE, m_contextObj); 541 653 #endif 542 654 return true; … … 554 666 [EAGLContext setCurrentContext:0]; 555 667 #elif USE(ANGLE) 556 // FIXME: implement forced context loss via ANGLE.668 EGL_MakeCurrent(m_displayObj, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); 557 669 #endif 558 670 return; … … 658 770 } 659 771 } 660 #endif 772 #endif // USE(OPENGL) 773 774 #if USE(ANGLE) 775 void GraphicsContext3D::allocateIOSurfaceBackingStore(IntSize size) 776 { 777 LOG(WebGL, "GraphicsContext3D::allocateIOSurfaceBackingStore at %d x %d. (%p)", size.width(), size.height(), this); 778 [m_webGLLayer allocateIOSurfaceBackingStoreWithSize:size usingAlpha:m_attrs.alpha]; 779 } 780 781 void GraphicsContext3D::updateFramebufferTextureBackingStoreFromLayer() 782 { 783 LOG(WebGL, "GraphicsContext3D::updateFramebufferTextureBackingStoreFromLayer(). (%p)", this); 784 [m_webGLLayer bindFramebufferToNextAvailableSurface]; 785 } 786 #endif // USE(ANGLE) 661 787 662 788 bool GraphicsContext3D::isGLES2Compliant() const -
trunk/Source/WebCore/platform/graphics/cocoa/WebGLLayer.h
r246554 r247315 51 51 WebCore::GraphicsContext3D* _context; 52 52 float _devicePixelRatio; 53 #if USE(OPENGL) 53 #if USE(OPENGL) || (USE(ANGLE) && PLATFORM(MAC)) 54 54 std::unique_ptr<WebCore::IOSurface> _contentsBuffer; 55 55 std::unique_ptr<WebCore::IOSurface> _drawingBuffer; … … 57 57 WebCore::IntSize _bufferSize; 58 58 BOOL _usingAlpha; 59 #endif 60 #if USE(ANGLE) && PLATFORM(MAC) 61 void* _eglDisplay; 62 void* _eglConfig; 63 void* _contentsPbuffer; 64 void* _drawingPbuffer; 65 void* _sparePbuffer; 66 void* _latchedPbuffer; 59 67 #endif 60 68 } … … 66 74 - (CGImageRef)copyImageSnapshotWithColorSpace:(CGColorSpaceRef)colorSpace; 67 75 68 #if USE(OPENGL) 76 #if USE(OPENGL) || (USE(ANGLE) && PLATFORM(MAC)) 69 77 - (void)allocateIOSurfaceBackingStoreWithSize:(WebCore::IntSize)size usingAlpha:(BOOL)usingAlpha; 70 78 - (void)bindFramebufferToNextAvailableSurface; 79 #endif 80 81 #if (USE(ANGLE) && PLATFORM(MAC)) 82 - (void)setEGLDisplay:(void*)eglDisplay andConfig:(void*)eglConfig; 83 - (void)dealloc; 71 84 #endif 72 85 -
trunk/Source/WebCore/platform/graphics/cocoa/WebGLLayer.mm
r246554 r247315 44 44 #endif 45 45 46 #if USE(ANGLE) 47 #define EGL_EGL_PROTOTYPES 0 48 #include <ANGLE/egl.h> 49 #include <ANGLE/eglext.h> 50 #include <ANGLE/eglext_angle.h> 51 #include <ANGLE/entry_points_egl.h> 52 #include <ANGLE/entry_points_gles_2_0_autogen.h> 53 // Skip the inclusion of ANGLE's explicit context entry points for now. 54 #define GL_ANGLE_explicit_context 55 #include <ANGLE/gl2ext.h> 56 #include <ANGLE/gl2ext_angle.h> 57 #endif 58 46 59 @implementation WebGLLayer 47 60 … … 53 66 self = [super init]; 54 67 _devicePixelRatio = context->getContextAttributes().devicePixelRatio; 55 #if USE(OPENGL) 68 #if USE(OPENGL) || USE(ANGLE) && PLATFORM(MAC) 56 69 self.contentsOpaque = !context->getContextAttributes().alpha; 57 70 self.transform = CATransform3DIdentity; … … 63 76 } 64 77 65 #if USE(OPENGL) 78 #if USE(OPENGL) || (USE(ANGLE) && PLATFORM(MAC)) 66 79 // When using an IOSurface as layer contents, we need to flip the 67 80 // layer to take into account that the IOSurface provides content … … 79 92 [super setAnchorPoint:CGPointMake(p.x, 1.0 - p.y)]; 80 93 } 81 94 #endif // USE(OPENGL) || (USE(ANGLE) && PLATFORM(MAC)) 95 96 #if USE(OPENGL) 82 97 static void freeData(void *, const void *data, size_t /* size */) 83 98 { 84 99 fastFree(const_cast<void *>(data)); 85 100 } 86 #endif 101 #endif // USE(OPENGL) 87 102 88 103 - (CGImageRef)copyImageSnapshotWithColorSpace:(CGColorSpaceRef)colorSpace … … 119 134 return image; 120 135 #else 136 // FIXME: implement. 121 137 UNUSED_PARAM(colorSpace); 122 138 return nullptr; … … 140 156 _context->presentRenderbuffer(); 141 157 #elif USE(ANGLE) 142 // FIXME: display rendering results via ANGLE. 158 _context->prepareTexture(); 159 if (_drawingBuffer) { 160 if (_latchedPbuffer) { 161 GC3Denum texture = _context->platformTexture(); 162 gl::BindTexture(GL_TEXTURE_RECTANGLE_ANGLE, texture); 163 if (!EGL_ReleaseTexImage(_eglDisplay, _latchedPbuffer, EGL_BACK_BUFFER)) { 164 // FIXME: report error. 165 notImplemented(); 166 } 167 _latchedPbuffer = nullptr; 168 } 169 std::swap(_contentsBuffer, _drawingBuffer); 170 std::swap(_contentsPbuffer, _drawingPbuffer); 171 self.contents = _contentsBuffer->asLayerContents(); 172 [self reloadValueForKeyPath:@"contents"]; 173 [self bindFramebufferToNextAvailableSurface]; 174 } 143 175 #endif 144 176 … … 149 181 } 150 182 151 #if USE(OPENGL) 183 #if (USE(ANGLE) && PLATFORM(MAC)) 184 - (void)setEGLDisplay:(void*)display andConfig:(void*)config 185 { 186 _eglDisplay = display; 187 _eglConfig = config; 188 } 189 190 - (void)dealloc 191 { 192 EGL_DestroySurface(_eglDisplay, _contentsPbuffer); 193 EGL_DestroySurface(_eglDisplay, _drawingPbuffer); 194 EGL_DestroySurface(_eglDisplay, _sparePbuffer); 195 [super dealloc]; 196 } 197 #endif 198 199 #if USE(OPENGL) || (USE(ANGLE) && PLATFORM(MAC)) 152 200 - (void)allocateIOSurfaceBackingStoreWithSize:(WebCore::IntSize)size usingAlpha:(BOOL)usingAlpha 153 201 { … … 165 213 _drawingBuffer->migrateColorSpaceToProperties(); 166 214 _spareBuffer->migrateColorSpaceToProperties(); 215 216 #if USE(ANGLE) && PLATFORM(MAC) 217 const EGLint surfaceAttributes[] = { 218 EGL_WIDTH, size.width(), 219 EGL_HEIGHT, size.height(), 220 EGL_IOSURFACE_PLANE_ANGLE, 0, 221 EGL_TEXTURE_TARGET, EGL_TEXTURE_RECTANGLE_ANGLE, 222 EGL_TEXTURE_INTERNAL_FORMAT_ANGLE, GL_BGRA_EXT, 223 EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGBA, 224 EGL_TEXTURE_TYPE_ANGLE, GL_UNSIGNED_BYTE, 225 EGL_NONE, EGL_NONE 226 }; 227 228 _contentsPbuffer = EGL_CreatePbufferFromClientBuffer(_eglDisplay, EGL_IOSURFACE_ANGLE, _contentsBuffer->surface(), _eglConfig, surfaceAttributes); 229 _drawingPbuffer = EGL_CreatePbufferFromClientBuffer(_eglDisplay, EGL_IOSURFACE_ANGLE, _drawingBuffer->surface(), _eglConfig, surfaceAttributes); 230 _sparePbuffer = EGL_CreatePbufferFromClientBuffer(_eglDisplay, EGL_IOSURFACE_ANGLE, _spareBuffer->surface(), _eglConfig, surfaceAttributes); 231 #endif 167 232 } 168 233 169 234 - (void)bindFramebufferToNextAvailableSurface 170 235 { 236 #if USE(OPENGL) 171 237 GC3Denum texture = _context->platformTexture(); 172 238 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, texture); … … 181 247 CGLError error = CGLTexImageIOSurface2D(_context->platformGraphicsContext3D(), GL_TEXTURE_RECTANGLE_ARB, internalFormat, _bufferSize.width(), _bufferSize.height(), GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, ioSurface, 0); 182 248 ASSERT_UNUSED(error, error == kCGLNoError); 183 } 184 #endif 249 #elif USE(ANGLE) 250 GC3Denum texture = _context->platformTexture(); 251 gl::BindTexture(GL_TEXTURE_RECTANGLE_ANGLE, texture); 252 253 if (_latchedPbuffer) { 254 if (!EGL_ReleaseTexImage(_eglDisplay, _latchedPbuffer, EGL_BACK_BUFFER)) { 255 // FIXME: report error. 256 notImplemented(); 257 } 258 _latchedPbuffer = nullptr; 259 } 260 261 if (_drawingBuffer && _drawingBuffer->isInUse()) { 262 std::swap(_drawingBuffer, _spareBuffer); 263 std::swap(_drawingPbuffer, _sparePbuffer); 264 } 265 266 // Link the IOSurface to the texture via the previously-created pbuffer. 267 if (!EGL_BindTexImage(_eglDisplay, _drawingPbuffer, EGL_BACK_BUFFER)) { 268 // FIXME: report error. 269 notImplemented(); 270 } 271 _latchedPbuffer = _drawingPbuffer; 272 #endif 273 } 274 #endif // USE(OPENGL) || (USE(ANGLE) && PLATFORM(MAC)) 185 275 186 276 @end
Note: See TracChangeset
for help on using the changeset viewer.