2010-08-16 Paul Sawaya <psawaya@apple.com>
authorcmarrin@apple.com <cmarrin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 Aug 2010 19:18:45 +0000 (19:18 +0000)
committercmarrin@apple.com <cmarrin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 Aug 2010 19:18:45 +0000 (19:18 +0000)
        Reviewed by Chris Marrin.

        Added shader validation via ANGLE
        https://bugs.webkit.org/show_bug.cgi?id=42405

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@65446 268f45cc-cd09-0410-ab3c-d52691b4dbfc

21 files changed:
ChangeLog
LayoutTests/ChangeLog
LayoutTests/fast/canvas/webgl/context-attributes-alpha-depth-stencil-antialias.html
LayoutTests/fast/canvas/webgl/gl-bind-attrib-location-test.html
LayoutTests/fast/canvas/webgl/read-pixels-pack-alignment.html
LayoutTests/fast/canvas/webgl/resources/fragmentShader.frag
LayoutTests/fast/canvas/webgl/texImage2DImageDataTest.html
LayoutTests/fast/canvas/webgl/texture-active-bind.html
LayoutTests/fast/canvas/webgl/texture-complete.html
LayoutTests/fast/canvas/webgl/texture-transparent-pixels-initialized.html
Makefile
WebCore/ChangeLog
WebCore/Configurations/WebCore.xcconfig
WebCore/WebCore.gypi
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/platform/graphics/ANGLEWebKitBridge.cpp [new file with mode: 0644]
WebCore/platform/graphics/ANGLEWebKitBridge.h [new file with mode: 0644]
WebCore/platform/graphics/GraphicsContext3D.h
WebCore/platform/graphics/mac/GraphicsContext3DMac.mm
WebKitTools/ChangeLog
WebKitTools/Scripts/build-webkit

index 755109e..c3d2c84 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2010-08-16  Paul Sawaya  <psawaya@apple.com>
+
+        Reviewed by Chris Marrin.
+
+        Added shader validation via ANGLE
+        https://bugs.webkit.org/show_bug.cgi?id=42405
+
+        Added ANGLE build to Makefile
+
+        * Makefile:
+
 2010-08-16  Kevin Ollivier  <kevino@theolliviers.com>
 
         [wx] Build fix, do not build WebCore as a convenience library as this leads to
 2010-08-16  Kevin Ollivier  <kevino@theolliviers.com>
 
         [wx] Build fix, do not build WebCore as a convenience library as this leads to
index feae80d..d556c4b 100644 (file)
@@ -1,3 +1,21 @@
+2010-08-16  Chris Marrin  <cmarrin@apple.com>
+
+        Reviewed by Chris Marrin.
+
+        Added shader validation via ANGLE
+        https://bugs.webkit.org/show_bug.cgi?id=42405
+
+        Updated tests to pass with shader validation
+
+        * fast/canvas/webgl/context-attributes-alpha-depth-stencil-antialias.html:
+        * fast/canvas/webgl/gl-bind-attrib-location-test.html:
+        * fast/canvas/webgl/read-pixels-pack-alignment.html:
+        * fast/canvas/webgl/resources/fragmentShader.frag:
+        * fast/canvas/webgl/texImage2DImageDataTest.html:
+        * fast/canvas/webgl/texture-active-bind.html:
+        * fast/canvas/webgl/texture-complete.html:
+        * fast/canvas/webgl/texture-transparent-pixels-initialized.html:
+
 2010-08-16  Mihai Parparita  <mihaip@chromium.org>
 
         Reviewed by Nate Chapin.
 2010-08-16  Mihai Parparita  <mihaip@chromium.org>
 
         Reviewed by Nate Chapin.
index 0c7d040..3b7c354 100644 (file)
@@ -16,7 +16,7 @@ void main()
 </script>
 
 <script id="fshader" type="x-shader/x-fragment">
 </script>
 
 <script id="fshader" type="x-shader/x-fragment">
-varying vec4 color;
+varying highp vec4 color;
 
 void main()
 {
 
 void main()
 {
index ee8be57..d76a81f 100644 (file)
@@ -23,7 +23,7 @@ void main()
 }
 </script>
 <script id="fshader" type="text/something-not-javascript">
 }
 </script>
 <script id="fshader" type="text/something-not-javascript">
-varying vec4 color;
+varying highp vec4 color;
 void main()
 {
   gl_FragColor = color;
 void main()
 {
   gl_FragColor = color;
index c8dc910..f8bd2fa 100644 (file)
@@ -16,7 +16,7 @@ void main()
 </script>
 
 <script id="fshader" type="x-shader/x-fragment">
 </script>
 
 <script id="fshader" type="x-shader/x-fragment">
-varying vec4 color;
+varying highp vec4 color;
 
 void main()
 {
 
 void main()
 {
index e8e9f08..e9173c7 100644 (file)
@@ -16,7 +16,7 @@
 
     <script id="fshader" type="x-shader/x-fragment">
         uniform sampler2D tex;
 
     <script id="fshader" type="x-shader/x-fragment">
         uniform sampler2D tex;
-        varying vec2 texCoord;
+        varying highp vec2 texCoord;
         void main()
         {
             gl_FragColor = texture2D(tex, texCoord);
         void main()
         {
             gl_FragColor = texture2D(tex, texCoord);
index 83224c8..8391b3c 100644 (file)
@@ -26,7 +26,7 @@ void main()
 
 <script id="fshader" type="x-shader/x-fragment">
 uniform sampler2D tex;
 
 <script id="fshader" type="x-shader/x-fragment">
 uniform sampler2D tex;
-varying vec2 texCoord;
+varying highp vec2 texCoord;
 void main()
 {
   gl_FragColor = texture2D(tex, texCoord);
 void main()
 {
   gl_FragColor = texture2D(tex, texCoord);
index 9c6ab36..c3b15f7 100644 (file)
@@ -15,7 +15,7 @@
 <script id="vshader" type="x-shader/x-vertex">
 attribute vec4 vPosition;
 attribute vec2 texCoord0;
 <script id="vshader" type="x-shader/x-vertex">
 attribute vec4 vPosition;
 attribute vec2 texCoord0;
-varying vec2 texCoord;
+varying highp vec2 texCoord;
 void main()
 {
     gl_Position = vPosition;
 void main()
 {
     gl_Position = vPosition;
@@ -25,7 +25,7 @@ void main()
 
 <script id="fshader" type="x-shader/x-fragment">
 uniform sampler2D tex;
 
 <script id="fshader" type="x-shader/x-fragment">
 uniform sampler2D tex;
-varying vec2 texCoord;
+varying highp vec2 texCoord;
 void main()
 {
     gl_FragColor = texture2D(tex, texCoord);
 void main()
 {
     gl_FragColor = texture2D(tex, texCoord);
index 26eb02a..9c9d117 100644 (file)
@@ -18,7 +18,7 @@ void main()
 
 <script id="fshader" type="x-shader/x-fragment">
 uniform sampler2D tex;
 
 <script id="fshader" type="x-shader/x-fragment">
 uniform sampler2D tex;
-varying vec2 texCoord;
+varying highp vec2 texCoord;
 
 void main()
 {
 
 void main()
 {
index 1e50d1d..cdee9da 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-MODULES = JavaScriptCore JavaScriptGlue WebCore WebKit WebKit2 WebKitTools 
+MODULES = JavaScriptCore JavaScriptGlue ANGLE WebCore WebKit WebKit2 WebKitTools 
 
 all:
        @for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
 
 all:
        @for dir in $(MODULES); do ${MAKE} $@ -C $$dir; exit_status=$$?; \
index 316c954..163f6c5 100644 (file)
@@ -1,3 +1,32 @@
+2010-08-16  Paul Sawaya  <psawaya@apple.com>
+
+        Reviewed by Chris Marrin.
+
+        Added shader validation via ANGLE
+        https://bugs.webkit.org/show_bug.cgi?id=42405
+
+        Added validation to WebGL via ANGLE
+
+        * Configurations/WebCore.xcconfig:
+        * WebCore.gypi:
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/graphics/ANGLEWebKitBridge.cpp: Added.
+        (WebCore::ANGLEWebKitBridge::ANGLEWebKitBridge):
+        (WebCore::ANGLEWebKitBridge::~ANGLEWebKitBridge):
+        (WebCore::ANGLEWebKitBridge::validateShaderSource):
+        * platform/graphics/ANGLEWebKitBridge.h: Added.
+        (WebCore::):
+        (WebCore::ANGLEWebKitBridge::setResources):
+        * platform/graphics/GraphicsContext3D.h:
+        (WebCore::GraphicsContext3D::):
+        * platform/graphics/mac/GraphicsContext3DMac.mm:
+        (WebCore::GraphicsContext3D::GraphicsContext3D):
+        (WebCore::GraphicsContext3D::compileShader):
+        (WebCore::GraphicsContext3D::shaderSource):
+        (WebCore::GraphicsContext3D::getShaderiv):
+        (WebCore::GraphicsContext3D::getShaderInfoLog):
+        (WebCore::GraphicsContext3D::getShaderSource):
+
 2010-08-16  Kevin Ollivier  <kevino@theolliviers.com>
 
         [wx] Build fix, do not build WebCore as a convenience library as this leads to
 2010-08-16  Kevin Ollivier  <kevino@theolliviers.com>
 
         [wx] Build fix, do not build WebCore as a convenience library as this leads to
index 73e3519..83e535c 100644 (file)
@@ -43,14 +43,14 @@ FRAMEWORK_SEARCH_PATHS_iphoneos_Production = $(PRODUCTION_FRAMEWORKS_DIR);
 FRAMEWORK_SEARCH_PATHS_iphonesimulator = $(FRAMEWORK_SEARCH_PATHS_iphoneos_$(CONFIGURATION));
 FRAMEWORK_SEARCH_PATHS_macosx = $(SYSTEM_LIBRARY_DIR)/Frameworks/Carbon.framework/Frameworks $(SYSTEM_LIBRARY_DIR)/Frameworks/ApplicationServices.framework/Frameworks $(FRAMEWORK_SEARCH_PATHS);
 
 FRAMEWORK_SEARCH_PATHS_iphonesimulator = $(FRAMEWORK_SEARCH_PATHS_iphoneos_$(CONFIGURATION));
 FRAMEWORK_SEARCH_PATHS_macosx = $(SYSTEM_LIBRARY_DIR)/Frameworks/Carbon.framework/Frameworks $(SYSTEM_LIBRARY_DIR)/Frameworks/ApplicationServices.framework/Frameworks $(FRAMEWORK_SEARCH_PATHS);
 
-HEADER_SEARCH_PATHS = ForwardingHeaders icu /usr/include/libxslt /usr/include/libxml2 $(SQLITE3_HEADER_SEARCH_PATHS) "${BUILT_PRODUCTS_DIR}/DerivedSources/WebCore" $(HEADER_SEARCH_PATHS);
+HEADER_SEARCH_PATHS = ForwardingHeaders icu /usr/include/libxslt /usr/include/libxml2 $(SQLITE3_HEADER_SEARCH_PATHS) "${BUILT_PRODUCTS_DIR}/DerivedSources/WebCore" "${BUILT_PRODUCTS_DIR}/usr/local/include" $(HEADER_SEARCH_PATHS);
 INFOPLIST_FILE = Info.plist;
 INSTALL_PATH = $(INSTALL_PATH_$(REAL_PLATFORM_NAME));
 INSTALL_PATH_macosx = $(SYSTEM_LIBRARY_DIR)/Frameworks/WebKit.framework/Versions/A/Frameworks;
 INSTALLHDRS_COPY_PHASE = YES;
 INSTALLHDRS_SCRIPT_PHASE = YES;
 PRODUCT_NAME = WebCore;
 INFOPLIST_FILE = Info.plist;
 INSTALL_PATH = $(INSTALL_PATH_$(REAL_PLATFORM_NAME));
 INSTALL_PATH_macosx = $(SYSTEM_LIBRARY_DIR)/Frameworks/WebKit.framework/Versions/A/Frameworks;
 INSTALLHDRS_COPY_PHASE = YES;
 INSTALLHDRS_SCRIPT_PHASE = YES;
 PRODUCT_NAME = WebCore;
-OTHER_LDFLAGS_BASE = -l$(SQLITE3_LIBRARY) -lobjc;
+OTHER_LDFLAGS_BASE = -l$(SQLITE3_LIBRARY) -lobjc -lANGLE;
 OTHER_LDFLAGS = $(OTHER_LDFLAGS_$(REAL_PLATFORM_NAME));
 OTHER_LDFLAGS_iphoneos = $(OTHER_LDFLAGS_BASE) -framework CFNetwork -framework CoreFoundation -framework CoreGraphics -framework CoreText -framework Foundation -framework GraphicsServices -framework ImageIO -framework QuartzCore;
 OTHER_LDFLAGS_iphonesimulator = $(OTHER_LDFLAGS_iphoneos);
 OTHER_LDFLAGS = $(OTHER_LDFLAGS_$(REAL_PLATFORM_NAME));
 OTHER_LDFLAGS_iphoneos = $(OTHER_LDFLAGS_BASE) -framework CFNetwork -framework CoreFoundation -framework CoreGraphics -framework CoreText -framework Foundation -framework GraphicsServices -framework ImageIO -framework QuartzCore;
 OTHER_LDFLAGS_iphonesimulator = $(OTHER_LDFLAGS_iphoneos);
index b7d0b31..bd1f1b6 100644 (file)
             'platform/graphics/wx/PenWx.cpp',
             'platform/graphics/wx/SimpleFontDataWx.cpp',
             'platform/graphics/wx/TransformationMatrixWx.cpp',
             'platform/graphics/wx/PenWx.cpp',
             'platform/graphics/wx/SimpleFontDataWx.cpp',
             'platform/graphics/wx/TransformationMatrixWx.cpp',
+            'platform/graphics/ANGLEWebkitBridge.cpp',
+            'platform/graphics/ANGLEWebkitBridge.h',
             'platform/graphics/BitmapImage.cpp',
             'platform/graphics/BitmapImage.h',
             'platform/graphics/Color.cpp',
             'platform/graphics/BitmapImage.cpp',
             'platform/graphics/BitmapImage.h',
             'platform/graphics/Color.cpp',
index cc702b8..0e7b4d4 100644 (file)
                46F9D5DD0B0D60170028EE36 /* aliasCursor.png in Resources */ = {isa = PBXBuildFile; fileRef = 46F9D5DA0B0D60170028EE36 /* aliasCursor.png */; };
                46F9D5DE0B0D60170028EE36 /* noDropCursor.png in Resources */ = {isa = PBXBuildFile; fileRef = 46F9D5DB0B0D60170028EE36 /* noDropCursor.png */; };
                46F9D5DF0B0D60170028EE36 /* progressCursor.png in Resources */ = {isa = PBXBuildFile; fileRef = 46F9D5DC0B0D60170028EE36 /* progressCursor.png */; };
                46F9D5DD0B0D60170028EE36 /* aliasCursor.png in Resources */ = {isa = PBXBuildFile; fileRef = 46F9D5DA0B0D60170028EE36 /* aliasCursor.png */; };
                46F9D5DE0B0D60170028EE36 /* noDropCursor.png in Resources */ = {isa = PBXBuildFile; fileRef = 46F9D5DB0B0D60170028EE36 /* noDropCursor.png */; };
                46F9D5DF0B0D60170028EE36 /* progressCursor.png in Resources */ = {isa = PBXBuildFile; fileRef = 46F9D5DC0B0D60170028EE36 /* progressCursor.png */; };
+               490707E61219C04300D90E51 /* ANGLEWebKitBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 490707E41219C04300D90E51 /* ANGLEWebKitBridge.cpp */; };
+               490707E71219C04300D90E51 /* ANGLEWebKitBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 490707E51219C04300D90E51 /* ANGLEWebKitBridge.h */; };
                492273A31083B3B100EE5C84 /* JSArrayBufferViewCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 492273A21083B3B100EE5C84 /* JSArrayBufferViewCustom.cpp */; };
                49484FC1102CF23C00187DD3 /* CanvasGradient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49484FB3102CF23C00187DD3 /* CanvasGradient.cpp */; };
                49484FC2102CF23C00187DD3 /* CanvasGradient.h in Headers */ = {isa = PBXBuildFile; fileRef = 49484FB4102CF23C00187DD3 /* CanvasGradient.h */; };
                492273A31083B3B100EE5C84 /* JSArrayBufferViewCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 492273A21083B3B100EE5C84 /* JSArrayBufferViewCustom.cpp */; };
                49484FC1102CF23C00187DD3 /* CanvasGradient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49484FB3102CF23C00187DD3 /* CanvasGradient.cpp */; };
                49484FC2102CF23C00187DD3 /* CanvasGradient.h in Headers */ = {isa = PBXBuildFile; fileRef = 49484FB4102CF23C00187DD3 /* CanvasGradient.h */; };
                46F9D5DA0B0D60170028EE36 /* aliasCursor.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = aliasCursor.png; sourceTree = "<group>"; };
                46F9D5DB0B0D60170028EE36 /* noDropCursor.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = noDropCursor.png; sourceTree = "<group>"; };
                46F9D5DC0B0D60170028EE36 /* progressCursor.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = progressCursor.png; sourceTree = "<group>"; };
                46F9D5DA0B0D60170028EE36 /* aliasCursor.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = aliasCursor.png; sourceTree = "<group>"; };
                46F9D5DB0B0D60170028EE36 /* noDropCursor.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = noDropCursor.png; sourceTree = "<group>"; };
                46F9D5DC0B0D60170028EE36 /* progressCursor.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = progressCursor.png; sourceTree = "<group>"; };
+               490707E41219C04300D90E51 /* ANGLEWebKitBridge.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ANGLEWebKitBridge.cpp; sourceTree = "<group>"; };
+               490707E51219C04300D90E51 /* ANGLEWebKitBridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ANGLEWebKitBridge.h; sourceTree = "<group>"; };
                492273A21083B3B100EE5C84 /* JSArrayBufferViewCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSArrayBufferViewCustom.cpp; sourceTree = "<group>"; };
                49484FB3102CF23C00187DD3 /* CanvasGradient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CanvasGradient.cpp; path = canvas/CanvasGradient.cpp; sourceTree = "<group>"; };
                49484FB4102CF23C00187DD3 /* CanvasGradient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CanvasGradient.h; path = canvas/CanvasGradient.h; sourceTree = "<group>"; };
                492273A21083B3B100EE5C84 /* JSArrayBufferViewCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSArrayBufferViewCustom.cpp; sourceTree = "<group>"; };
                49484FB3102CF23C00187DD3 /* CanvasGradient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CanvasGradient.cpp; path = canvas/CanvasGradient.cpp; sourceTree = "<group>"; };
                49484FB4102CF23C00187DD3 /* CanvasGradient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CanvasGradient.h; path = canvas/CanvasGradient.h; sourceTree = "<group>"; };
                B2A015910AF6CD53006BCE0E /* graphics */ = {
                        isa = PBXGroup;
                        children = (
                B2A015910AF6CD53006BCE0E /* graphics */ = {
                        isa = PBXGroup;
                        children = (
+                               490707E41219C04300D90E51 /* ANGLEWebKitBridge.cpp */,
+                               490707E51219C04300D90E51 /* ANGLEWebKitBridge.h */,
                                B27535290B053814002CE64F /* cg */,
                                A75E8B7F0E1DE2B0007F2481 /* filters */,
                                B27535490B053814002CE64F /* mac */,
                                B27535290B053814002CE64F /* cg */,
                                A75E8B7F0E1DE2B0007F2481 /* filters */,
                                B27535490B053814002CE64F /* mac */,
                                97DD4D870FDF4D6E00ECF9A4 /* XSSAuditor.h in Headers */,
                                CE172E011136E8CE0062A533 /* ZoomMode.h in Headers */,
                                C50B561712119D23008B46E0 /* GroupSettings.h in Headers */,
                                97DD4D870FDF4D6E00ECF9A4 /* XSSAuditor.h in Headers */,
                                CE172E011136E8CE0062A533 /* ZoomMode.h in Headers */,
                                C50B561712119D23008B46E0 /* GroupSettings.h in Headers */,
+                               490707E71219C04300D90E51 /* ANGLEWebKitBridge.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                        isa = PBXProject;
                        buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */;
                        compatibilityVersion = "Xcode 2.4";
                        isa = PBXProject;
                        buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */;
                        compatibilityVersion = "Xcode 2.4";
+                       developmentRegion = English;
                        hasScannedForEncodings = 1;
                        knownRegions = (
                                English,
                        hasScannedForEncodings = 1;
                        knownRegions = (
                                English,
                                E1BE512D0CF6C512002EA959 /* XSLTUnicodeSort.cpp in Sources */,
                                97DD4D860FDF4D6E00ECF9A4 /* XSSAuditor.cpp in Sources */,
                                C50B561612119D23008B46E0 /* GroupSettings.cpp in Sources */,
                                E1BE512D0CF6C512002EA959 /* XSLTUnicodeSort.cpp in Sources */,
                                97DD4D860FDF4D6E00ECF9A4 /* XSSAuditor.cpp in Sources */,
                                C50B561612119D23008B46E0 /* GroupSettings.cpp in Sources */,
+                               490707E61219C04300D90E51 /* ANGLEWebKitBridge.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
diff --git a/WebCore/platform/graphics/ANGLEWebKitBridge.cpp b/WebCore/platform/graphics/ANGLEWebKitBridge.cpp
new file mode 100644 (file)
index 0000000..3757d77
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+
+#if ENABLE(3D_CANVAS)
+
+#include "ANGLEWebKitBridge.h"
+
+namespace WebCore {
+
+
+ANGLEWebKitBridge::ANGLEWebKitBridge() :
+    builtCompilers(false)
+{
+    ShInitialize();
+}
+
+ANGLEWebKitBridge::~ANGLEWebKitBridge()
+{
+    if (builtCompilers) {
+        ShDestruct(m_fragmentCompiler);
+        ShDestruct(m_vertexCompiler);
+    }
+    
+    ShFinalize();
+}
+
+bool ANGLEWebKitBridge::validateShaderSource(const char* shaderSource, ANGLEShaderType shaderType, String& translatedShaderSource, String& shaderValidationLog)
+{
+    if (!builtCompilers) {
+        m_fragmentCompiler = ShConstructCompiler(EShLangFragment, EShSpecWebGL, &m_resources);
+        m_vertexCompiler = ShConstructCompiler(EShLangVertex, EShSpecWebGL, &m_resources);
+
+        builtCompilers = true;
+    }
+    
+    ShHandle compiler;
+
+    if (shaderType == SHADER_TYPE_VERTEX)
+        compiler = m_vertexCompiler;
+    else if (shaderType == SHADER_TYPE_FRAGMENT)
+        compiler = m_fragmentCompiler;
+
+    const char* const shaderSourceStrings[] = { shaderSource };
+
+    bool validateSuccess = ShCompile(compiler, shaderSourceStrings, 1, EShOptNone, EDebugOpIntermediate);
+
+    translatedShaderSource = ShGetObjectCode(compiler);
+    shaderValidationLog = ShGetInfoLog(compiler);
+
+    return validateSuccess;
+}
+
+}
+
+#endif // ENABLE(3D_CANVAS)
diff --git a/WebCore/platform/graphics/ANGLEWebKitBridge.h b/WebCore/platform/graphics/ANGLEWebKitBridge.h
new file mode 100644 (file)
index 0000000..d01de8f
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef ANGLEWebKitBridge_h
+#define ANGLEWebKitBridge_h
+
+#include "ANGLE/ShaderLang.h"
+#include "PlatformString.h"
+
+#include <wtf/text/CString.h>
+
+namespace WebCore {
+
+enum ANGLEShaderType {
+    SHADER_TYPE_VERTEX = EShLangVertex,
+    SHADER_TYPE_FRAGMENT = EShLangFragment
+};
+
+class ANGLEWebKitBridge {
+public:
+
+    ANGLEWebKitBridge();
+    ~ANGLEWebKitBridge();
+    
+    void setResources(TBuiltInResource resources) { m_resources = resources; }
+    
+    bool validateShaderSource(const char* shaderSource, ANGLEShaderType shaderType, String& translatedShaderSource, String& shaderValidationLog);
+
+private:
+
+    ShHandle m_fragmentCompiler;
+    ShHandle m_vertexCompiler;
+
+    bool builtCompilers;
+
+    TBuiltInResource m_resources;
+};
+
+} // namespace WebCore
+
+#endif
index dabd0ae..3c5eb50 100644 (file)
 #ifndef GraphicsContext3D_h
 #define GraphicsContext3D_h
 
 #ifndef GraphicsContext3D_h
 #define GraphicsContext3D_h
 
+#include "ANGLEWebKitBridge.h"
 #include "GraphicsLayer.h"
 #include "PlatformString.h"
 
 #include "GraphicsLayer.h"
 #include "PlatformString.h"
 
+#include <wtf/HashMap.h>
 #include <wtf/ListHashSet.h>
 #include <wtf/Noncopyable.h>
 #include <wtf/PassOwnPtr.h>
 #include <wtf/ListHashSet.h>
 #include <wtf/Noncopyable.h>
 #include <wtf/PassOwnPtr.h>
@@ -811,6 +813,15 @@ public:
 
     int m_currentWidth, m_currentHeight;
 
 
     int m_currentWidth, m_currentHeight;
 
+    typedef struct { 
+        String source; 
+        String log; 
+        bool isValid;
+    } ShaderSourceEntry;
+    HashMap<Platform3DObject, ShaderSourceEntry> m_shaderSourceMap;
+
+    ANGLEWebKitBridge m_compiler;
+
 #if PLATFORM(MAC)
     Attributes m_attrs;
     Vector<Vector<float> > m_vertexArray;
 #if PLATFORM(MAC)
     Attributes m_attrs;
     Vector<Vector<float> > m_vertexArray;
index fd503fc..b798832 100644 (file)
@@ -31,6 +31,7 @@
 
 #import "BlockExceptions.h"
 
 
 #import "BlockExceptions.h"
 
+#include "ANGLE/ResourceLimits.h"
 #include "ArrayBuffer.h"
 #include "ArrayBufferView.h"
 #include "WebGLObject.h"
 #include "ArrayBuffer.h"
 #include "ArrayBufferView.h"
 #include "WebGLObject.h"
@@ -181,6 +182,30 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWi
             ::glGenRenderbuffersEXT(1, &m_multisampleDepthStencilBuffer);
     }
     
             ::glGenRenderbuffersEXT(1, &m_multisampleDepthStencilBuffer);
     }
     
+    // ANGLE initialization.
+
+    TBuiltInResource ANGLEResources;
+
+    ANGLEResources.maxVertexAttribs = 0;
+    getIntegerv(GraphicsContext3D::MAX_VERTEX_ATTRIBS, &ANGLEResources.maxVertexAttribs);
+    ANGLEResources.maxVertexUniformVectors = 0;
+    getIntegerv(GraphicsContext3D::MAX_VERTEX_UNIFORM_VECTORS, &ANGLEResources.maxVertexUniformVectors);
+    ANGLEResources.maxVaryingVectors = 0;
+    getIntegerv(GraphicsContext3D::MAX_VARYING_VECTORS, &ANGLEResources.maxVaryingVectors);
+    ANGLEResources.maxVertexTextureImageUnits = 0;
+    getIntegerv(GraphicsContext3D::MAX_VERTEX_TEXTURE_IMAGE_UNITS, &ANGLEResources.maxVertexTextureImageUnits);
+    ANGLEResources.maxCombinedTextureImageUnits = 0;
+    getIntegerv(GraphicsContext3D::MAX_COMBINED_TEXTURE_IMAGE_UNITS, &ANGLEResources.maxCombinedTextureImageUnits);
+    ANGLEResources.maxTextureImageUnits = 0;
+    getIntegerv(GraphicsContext3D::MAX_TEXTURE_IMAGE_UNITS, &ANGLEResources.maxTextureImageUnits);
+    ANGLEResources.maxFragmentUniformVectors = 0;
+    getIntegerv(GraphicsContext3D::MAX_FRAGMENT_UNIFORM_VECTORS, &ANGLEResources.maxFragmentUniformVectors);
+
+    // Always set to 1 for OpenGL ES.
+    ANGLEResources.maxDrawBuffers = 1;
+    
+    m_compiler.setResources(ANGLEResources);
+    
     ::glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
     ::glClearColor(0, 0, 0, 0);
 }
     ::glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
     ::glClearColor(0, 0, 0, 0);
 }
@@ -617,7 +642,52 @@ void GraphicsContext3D::compileShader(Platform3DObject shader)
 {
     ASSERT(shader);
     ensureContext(m_contextObj);
 {
     ASSERT(shader);
     ensureContext(m_contextObj);
+
+    int GLshaderType;
+    ANGLEShaderType shaderType;
+
+    glGetShaderiv(shader, SHADER_TYPE, &GLshaderType);
+    
+    if (GLshaderType == VERTEX_SHADER)
+        shaderType = SHADER_TYPE_VERTEX;
+    else if (GLshaderType == FRAGMENT_SHADER)
+        shaderType = SHADER_TYPE_FRAGMENT;
+    else
+        return; // Invalid shader type.
+
+    HashMap<Platform3DObject, ShaderSourceEntry>::iterator result = m_shaderSourceMap.find(shader);
+
+    if (result == m_shaderSourceMap.end())
+        return;
+
+    ShaderSourceEntry& entry = result->second;
+
+    String translatedShaderSource;
+    String shaderInfoLog;
+
+    bool isValid = m_compiler.validateShaderSource(entry.source.utf8().data(), shaderType, translatedShaderSource, shaderInfoLog);
+
+    entry.log = shaderInfoLog;
+    entry.isValid = isValid;
+
+    if (!isValid)
+        return; // Shader didn't validate, don't move forward with compiling translated source    
+
+    int translatedShaderLength = translatedShaderSource.length();
+
+    const CString& translatedShaderCString = translatedShaderSource.utf8();
+    const char* translatedShaderPtr = translatedShaderCString.data();
+    
+    ::glShaderSource((GLuint) shader, 1, &translatedShaderPtr, &translatedShaderLength);
+    
     ::glCompileShader((GLuint) shader);
     ::glCompileShader((GLuint) shader);
+    
+    int GLCompileSuccess;
+    
+    ::glGetShaderiv((GLuint) shader, COMPILE_STATUS, &GLCompileSuccess);
+    
+    // ASSERT that ANGLE generated GLSL will be accepted by OpenGL
+    ASSERT(GLCompileSuccess == GL_TRUE);
 }
 
 void GraphicsContext3D::copyTexImage2D(unsigned long target, long level, unsigned long internalformat, long x, long y, unsigned long width, unsigned long height, long border)
 }
 
 void GraphicsContext3D::copyTexImage2D(unsigned long target, long level, unsigned long internalformat, long x, long y, unsigned long width, unsigned long height, long border)
@@ -998,11 +1068,12 @@ void GraphicsContext3D::shaderSource(Platform3DObject shader, const String& stri
     ASSERT(shader);
     
     ensureContext(m_contextObj);
     ASSERT(shader);
     
     ensureContext(m_contextObj);
-    const CString& cs = string.utf8();
-    const char* s = cs.data();
-    
-    int length = string.length();
-    ::glShaderSource((GLuint) shader, 1, &s, &length);
+
+    ShaderSourceEntry entry;
+
+    entry.source = string;
+
+    m_shaderSourceMap.set(shader, entry);
 }
 
 void GraphicsContext3D::stencilFunc(unsigned long func, long ref, unsigned long mask)
 }
 
 void GraphicsContext3D::stencilFunc(unsigned long func, long ref, unsigned long mask)
@@ -1346,26 +1417,77 @@ void GraphicsContext3D::getShaderiv(Platform3DObject shader, unsigned long pname
     ASSERT(shader);
     
     ensureContext(m_contextObj);
     ASSERT(shader);
     
     ensureContext(m_contextObj);
-    ::glGetShaderiv((GLuint) shader, pname, value);
+    
+    HashMap<Platform3DObject, ShaderSourceEntry>::iterator result = m_shaderSourceMap.find(shader);
+    
+    switch (pname) {
+        case DELETE_STATUS:
+        case SHADER_TYPE:
+            // Let OpenGL handle these.
+        
+            ::glGetShaderiv((GLuint) shader, pname, value);
+            break;
+
+        case COMPILE_STATUS:
+            if (result == m_shaderSourceMap.end()) {
+                (*value) = static_cast<int>(false);
+                return;
+            }
+                
+            (*value) = static_cast<int>(result->second.isValid);
+            break;
+            
+        case INFO_LOG_LENGTH:
+            if (result == m_shaderSourceMap.end()) {
+                (*value) = 0;
+                return;
+            }
+            
+            (*value) = getShaderInfoLog(shader).length();
+            break;
+            
+        case SHADER_SOURCE_LENGTH:
+            (*value) = getShaderSource(shader).length();
+            break;
+        
+        default:
+            synthesizeGLError(INVALID_ENUM);
+    }
 }
 
 String GraphicsContext3D::getShaderInfoLog(Platform3DObject shader)
 {
     ASSERT(shader);
 }
 
 String GraphicsContext3D::getShaderInfoLog(Platform3DObject shader)
 {
     ASSERT(shader);
-    
+
     ensureContext(m_contextObj);
     GLint length;
     ::glGetShaderiv((GLuint) shader, GL_INFO_LOG_LENGTH, &length);
     ensureContext(m_contextObj);
     GLint length;
     ::glGetShaderiv((GLuint) shader, GL_INFO_LOG_LENGTH, &length);
-    
-    GLsizei size;
-    GLchar* info = (GLchar*) fastMalloc(length);
-    if (!info)
-        return "";
-        
-    ::glGetShaderInfoLog((GLuint) shader, length, &size, info);
-    String s(info);
-    fastFree(info);
-    return s;
+
+    HashMap<Platform3DObject, ShaderSourceEntry>::iterator result = m_shaderSourceMap.find(shader);
+
+    if (result == m_shaderSourceMap.end())
+         return "";
+
+     ShaderSourceEntry entry = result->second;
+
+     if (entry.isValid) {
+         GLint length;
+         ::glGetShaderiv((GLuint) shader, GL_INFO_LOG_LENGTH, &length);
+
+         GLsizei size;
+         GLchar* info = (GLchar*) fastMalloc(length);
+         if (!info)
+             return "";
+
+         ::glGetShaderInfoLog((GLuint) shader, length, &size, info);
+
+         String s(info);
+         fastFree(info);
+         return s;
+     }
+     else {
+         return entry.log;
+     }
 }
 
 String GraphicsContext3D::getShaderSource(Platform3DObject shader)
 }
 
 String GraphicsContext3D::getShaderSource(Platform3DObject shader)
@@ -1373,18 +1495,13 @@ String GraphicsContext3D::getShaderSource(Platform3DObject shader)
     ASSERT(shader);
 
     ensureContext(m_contextObj);
     ASSERT(shader);
 
     ensureContext(m_contextObj);
-    GLint length;
-    ::glGetShaderiv((GLuint) shader, GL_SHADER_SOURCE_LENGTH, &length);
-    
-    GLsizei size;
-    GLchar* info = (GLchar*) fastMalloc(length);
-    if (!info)
+
+    HashMap<Platform3DObject, ShaderSourceEntry>::iterator result = m_shaderSourceMap.find(shader);
+
+    if (result == m_shaderSourceMap.end())
         return "";
         return "";
-        
-    ::glGetShaderSource((GLuint) shader, length, &size, info);
-    String s(info);
-    fastFree(info);
-    return s;
+
+    return result->second.source;
 }
 
 
 }
 
 
index beca330..8b85ea3 100644 (file)
@@ -1,3 +1,14 @@
+2010-08-16  Paul Sawaya  <psawaya@apple.com>
+
+        Reviewed by Chris Marrin.
+
+        Added shader validation via ANGLE
+        https://bugs.webkit.org/show_bug.cgi?id=42405
+
+        Added ANGLE to webkit build
+
+        * Scripts/build-webkit:
+
 2010-08-16  Kevin Ollivier  <kevino@theolliviers.com>
 
         [wx] Build fix, do not build WebCore as a convenience library as this leads to
 2010-08-16  Kevin Ollivier  <kevino@theolliviers.com>
 
         [wx] Build fix, do not build WebCore as a convenience library as this leads to
index b12fc42..036011e 100755 (executable)
@@ -341,6 +341,9 @@ if (isGtk()) {
     # Apple builds JavaScriptGlue, and only on the Mac.
     splice @projects, 1, 0, "JavaScriptGlue";
 
     # Apple builds JavaScriptGlue, and only on the Mac.
     splice @projects, 1, 0, "JavaScriptGlue";
 
+    # ANGLE is only supported in SnowLeopard and later at present, and must come before WebCore
+    splice @projects, 0, 0, "ANGLE" if osXVersion()->{"minor"} >= 6;
+
     # WebKit2 is only supported in SnowLeopard and later at present.
     push @projects, ("WebKit2", "WebKitTools/MiniBrowser") if osXVersion()->{"minor"} >= 6;
 
     # WebKit2 is only supported in SnowLeopard and later at present.
     push @projects, ("WebKit2", "WebKitTools/MiniBrowser") if osXVersion()->{"minor"} >= 6;