summarylogtreecommitdiffstats
path: root/0006-Establish-compatibility-with-latest-ANGLE.patch
blob: 72c23fb11bb0b4968df2be1238cce3f6f968accf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
From f956920ce7932e20e315656e72282007087b6ab9 Mon Sep 17 00:00:00 2001
From: Martchus <martchus@gmx.net>
Date: Sun, 25 Sep 2016 22:19:57 +0200
Subject: [PATCH 6/9] Establish compatibility with latest ANGLE

---
 .../platform/graphics/ANGLEWebKitBridge.cpp        | 126 ++++-----------------
 .../WebCore/platform/graphics/ANGLEWebKitBridge.h  |  17 +--
 .../graphics/cairo/GraphicsContext3DCairo.cpp      |   2 +-
 .../platform/graphics/efl/GraphicsContext3DEfl.cpp |   2 +-
 .../graphics/opengl/Extensions3DOpenGLCommon.cpp   |   4 +-
 .../platform/graphics/qt/GraphicsContext3DQt.cpp   |   2 +-
 6 files changed, 33 insertions(+), 120 deletions(-)

diff --git a/Source/WebCore/platform/graphics/ANGLEWebKitBridge.cpp b/Source/WebCore/platform/graphics/ANGLEWebKitBridge.cpp
index 9876c9f04..84d3a2f34 100644
--- a/Source/WebCore/platform/graphics/ANGLEWebKitBridge.cpp
+++ b/Source/WebCore/platform/graphics/ANGLEWebKitBridge.cpp
@@ -32,98 +32,25 @@
 
 namespace WebCore {
 
-// Temporary typedef to support an incompatible change in the ANGLE API.
-#if !defined(ANGLE_SH_VERSION) || ANGLE_SH_VERSION < 108
-typedef int ANGLEGetInfoType;
-#else
-typedef size_t ANGLEGetInfoType;
-#endif
-
-inline static ANGLEGetInfoType getValidationResultValue(const ShHandle compiler, ShShaderInfo shaderInfo)
-{
-    ANGLEGetInfoType value = 0;
-    ShGetInfo(compiler, shaderInfo, &value);
-    return value;
-}
-
-static bool getSymbolInfo(ShHandle compiler, ShShaderInfo symbolType, Vector<ANGLEShaderSymbol>& symbols)
-{
-    ShShaderInfo symbolMaxNameLengthType;
-
-    switch (symbolType) {
-    case SH_ACTIVE_ATTRIBUTES:
-        symbolMaxNameLengthType = SH_ACTIVE_ATTRIBUTE_MAX_LENGTH;
-        break;
-    case SH_ACTIVE_UNIFORMS:
-        symbolMaxNameLengthType = SH_ACTIVE_UNIFORM_MAX_LENGTH;
-        break;
-    default:
-        ASSERT_NOT_REACHED();
+template<typename vectype>
+bool readSymbols(const vectype *vec, Vector<ANGLEShaderSymbol> &symbols) {
+    if(!vec) {
         return false;
     }
-
-    ANGLEGetInfoType numSymbols = getValidationResultValue(compiler, symbolType);
-
-    ANGLEGetInfoType maxNameLength = getValidationResultValue(compiler, symbolMaxNameLengthType);
-    if (maxNameLength <= 1)
-        return false;
-
-    ANGLEGetInfoType maxMappedNameLength = getValidationResultValue(compiler, SH_MAPPED_NAME_MAX_LENGTH);
-    if (maxMappedNameLength <= 1)
-        return false;
-
-    // The maximum allowed symbol name length is 256 characters.
-    Vector<char, 256> nameBuffer(maxNameLength);
-    Vector<char, 256> mappedNameBuffer(maxMappedNameLength);
-    
-    for (ANGLEGetInfoType i = 0; i < numSymbols; ++i) {
+    for(typename vectype::const_iterator i = vec->begin(), end = vec->end(); i != end; ++i) {
         ANGLEShaderSymbol symbol;
-        ANGLEGetInfoType nameLength = 0;
-        switch (symbolType) {
-        case SH_ACTIVE_ATTRIBUTES:
-            symbol.symbolType = SHADER_SYMBOL_TYPE_ATTRIBUTE;
-            ShGetActiveAttrib(compiler, i, &nameLength, &symbol.size, &symbol.dataType, nameBuffer.data(), mappedNameBuffer.data());
-            break;
-        case SH_ACTIVE_UNIFORMS:
-            symbol.symbolType = SHADER_SYMBOL_TYPE_UNIFORM;
-            ShGetActiveUniform(compiler, i, &nameLength, &symbol.size, &symbol.dataType, nameBuffer.data(), mappedNameBuffer.data());
-            break;
-        default:
-            ASSERT_NOT_REACHED();
-            return false;
-        }
-        if (!nameLength)
-            return false;
-        
-        // The ShGetActive* calls above are guaranteed to produce null-terminated strings for
-        // nameBuffer and mappedNameBuffer. Also, the character set for symbol names
-        // is a subset of Latin-1 as specified by the OpenGL ES Shading Language, Section 3.1 and
-        // WebGL, Section "Characters Outside the GLSL Source Character Set".
-
-        String name = String(nameBuffer.data());
-        String mappedName = String(mappedNameBuffer.data());
-        
-        // ANGLE returns array names in the format "array[0]".
-        // The only way to know if a symbol is an array is to check if it ends with "[0]".
-        // We can't check the size because regular symbols and arrays of length 1 both have a size of 1.
-        symbol.isArray = name.endsWith("[0]") && mappedName.endsWith("[0]");
-        if (symbol.isArray) {
-            // Add a symbol for the array name without the "[0]" suffix.
-            name.truncate(name.length() - 3);
-            mappedName.truncate(mappedName.length() - 3);
-        }
-
-        symbol.name = name;
-        symbol.mappedName = mappedName;
+        symbol.name = i->name.data();
+        symbol.mappedName = i->mappedName.data();
+        symbol.isArray = i->isArray();
         symbols.append(symbol);
-    
         if (symbol.isArray) {
             // Add symbols for each array element.
+            symbol.size = i->arraySize;
             symbol.isArray = false;
-            for (int i = 0; i < symbol.size; i++) {
-                String arrayBrackets = "[" + String::number(i) + "]";
-                symbol.name = name + arrayBrackets;
-                symbol.mappedName = mappedName + arrayBrackets;
+            for (int index = 0; index < symbol.size; index++) {
+                String arrayBrackets = "[" + String::number(index) + "]";
+                symbol.name = i->name.data() + arrayBrackets;
+                symbol.mappedName = i->mappedName.data() + arrayBrackets;
                 symbols.append(symbol);
             }
         }
@@ -163,15 +90,14 @@ void ANGLEWebKitBridge::setResources(ShBuiltInResources resources)
 {
     // Resources are (possibly) changing - cleanup compilers if we had them already
     cleanupCompilers();
-    
     m_resources = resources;
 }
 
 bool ANGLEWebKitBridge::compileShaderSource(const char* shaderSource, ANGLEShaderType shaderType, String& translatedShaderSource, String& shaderValidationLog, Vector<ANGLEShaderSymbol>& symbols, int extraCompileOptions)
 {
     if (!builtCompilers) {
-        m_fragmentCompiler = ShConstructCompiler(SH_FRAGMENT_SHADER, m_shaderSpec, m_shaderOutput, &m_resources);
-        m_vertexCompiler = ShConstructCompiler(SH_VERTEX_SHADER, m_shaderSpec, m_shaderOutput, &m_resources);
+        m_fragmentCompiler = ShConstructCompiler(GL_FRAGMENT_SHADER, m_shaderSpec, m_shaderOutput, &m_resources);
+        m_vertexCompiler = ShConstructCompiler(GL_VERTEX_SHADER, m_shaderSpec, m_shaderOutput, &m_resources);
         if (!m_fragmentCompiler || !m_vertexCompiler) {
             cleanupCompilers();
             return false;
@@ -189,31 +115,17 @@ bool ANGLEWebKitBridge::compileShaderSource(const char* shaderSource, ANGLEShade
 
     const char* const shaderSourceStrings[] = { shaderSource };
 
-    bool validateSuccess = ShCompile(compiler, shaderSourceStrings, 1, SH_OBJECT_CODE | SH_ATTRIBUTES_UNIFORMS | extraCompileOptions);
+    bool validateSuccess = ShCompile(compiler, shaderSourceStrings, 1, SH_OBJECT_CODE | SH_VARIABLES | extraCompileOptions);
     if (!validateSuccess) {
-        int logSize = getValidationResultValue(compiler, SH_INFO_LOG_LENGTH);
-        if (logSize > 1) {
-            OwnArrayPtr<char> logBuffer = adoptArrayPtr(new char[logSize]);
-            if (logBuffer) {
-                ShGetInfoLog(compiler, logBuffer.get());
-                shaderValidationLog = logBuffer.get();
-            }
-        }
+        shaderValidationLog = ShGetInfoLog(compiler).data();
         return false;
     }
 
-    int translationLength = getValidationResultValue(compiler, SH_OBJECT_CODE_LENGTH);
-    if (translationLength > 1) {
-        OwnArrayPtr<char> translationBuffer = adoptArrayPtr(new char[translationLength]);
-        if (!translationBuffer)
-            return false;
-        ShGetObjectCode(compiler, translationBuffer.get());
-        translatedShaderSource = translationBuffer.get();
-    }
+    translatedShaderSource = ShGetObjectCode(compiler).data();
     
-    if (!getSymbolInfo(compiler, SH_ACTIVE_ATTRIBUTES, symbols))
+    if (!readSymbols(ShGetAttributes(compiler), symbols))
         return false;
-    if (!getSymbolInfo(compiler, SH_ACTIVE_UNIFORMS, symbols))
+    if (!readSymbols(ShGetUniforms(compiler), symbols))
         return false;
 
     return true;
diff --git a/Source/WebCore/platform/graphics/ANGLEWebKitBridge.h b/Source/WebCore/platform/graphics/ANGLEWebKitBridge.h
index 83c2e004c..825c2d0bc 100644
--- a/Source/WebCore/platform/graphics/ANGLEWebKitBridge.h
+++ b/Source/WebCore/platform/graphics/ANGLEWebKitBridge.h
@@ -35,13 +35,14 @@
 #include "GLSLANG/ShaderLang.h"
 #else
 #include "ShaderLang.h"
+#include "angle_gl.h"
 #endif
 
 namespace WebCore {
 
 enum ANGLEShaderType {
-    SHADER_TYPE_VERTEX = SH_VERTEX_SHADER,
-    SHADER_TYPE_FRAGMENT = SH_FRAGMENT_SHADER,
+    SHADER_TYPE_VERTEX = GL_VERTEX_SHADER,
+    SHADER_TYPE_FRAGMENT = GL_FRAGMENT_SHADER,
 };
 
 enum ANGLEShaderSymbolType {
@@ -53,24 +54,24 @@ struct ANGLEShaderSymbol {
     ANGLEShaderSymbolType symbolType;
     String name;
     String mappedName;
-    ShDataType dataType;
+    sh::GLenum dataType;
     int size;
     bool isArray;
 
     bool isSampler() const
     {
         return symbolType == SHADER_SYMBOL_TYPE_UNIFORM
-            && (dataType == SH_SAMPLER_2D
-            || dataType == SH_SAMPLER_CUBE
-            || dataType == SH_SAMPLER_2D_RECT_ARB
-            || dataType == SH_SAMPLER_EXTERNAL_OES);
+            && (dataType == GL_SAMPLER_2D
+            || dataType == GL_SAMPLER_CUBE
+            || dataType == GL_SAMPLER_2D_RECT_ARB
+            || dataType == GL_SAMPLER_EXTERNAL_OES);
     }
 };
 
 class ANGLEWebKitBridge {
 public:
 
-    ANGLEWebKitBridge(ShShaderOutput = SH_GLSL_OUTPUT, ShShaderSpec = SH_WEBGL_SPEC);
+    ANGLEWebKitBridge(ShShaderOutput = SH_GLSL_COMPATIBILITY_OUTPUT, ShShaderSpec = SH_WEBGL_SPEC);
     ~ANGLEWebKitBridge();
     
     ShBuiltInResources getResources() { return m_resources; }
diff --git a/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp b/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp
index d31adf326..3b99ad9d9 100644
--- a/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp
+++ b/Source/WebCore/platform/graphics/cairo/GraphicsContext3DCairo.cpp
@@ -80,7 +80,7 @@ PassRefPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attri
 GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attributes, HostWindow*, GraphicsContext3D::RenderStyle renderStyle)
     : m_currentWidth(0)
     , m_currentHeight(0)
-    , m_compiler(isGLES2Compliant() ? SH_ESSL_OUTPUT : SH_GLSL_OUTPUT)
+    , m_compiler(isGLES2Compliant() ? SH_ESSL_OUTPUT : SH_GLSL_COMPATIBILITY_OUTPUT)
     , m_attrs(attributes)
     , m_texture(0)
     , m_fbo(0)
diff --git a/Source/WebCore/platform/graphics/efl/GraphicsContext3DEfl.cpp b/Source/WebCore/platform/graphics/efl/GraphicsContext3DEfl.cpp
index ea25e4355..a28c55ff4 100644
--- a/Source/WebCore/platform/graphics/efl/GraphicsContext3DEfl.cpp
+++ b/Source/WebCore/platform/graphics/efl/GraphicsContext3DEfl.cpp
@@ -41,7 +41,7 @@ PassRefPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attri
 GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle)
     : m_currentWidth(0)
     , m_currentHeight(0)
-    , m_compiler(isGLES2Compliant() ? SH_ESSL_OUTPUT : SH_GLSL_OUTPUT)
+    , m_compiler(isGLES2Compliant() ? SH_ESSL_OUTPUT : SH_GLSL_COMPATIBILITY_OUTPUT)
     , m_attrs(attrs)
     , m_renderStyle(renderStyle)
     , m_texture(0)
diff --git a/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp b/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp
index 29a13c842..11f88f183 100644
--- a/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp
+++ b/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp
@@ -172,10 +172,10 @@ String Extensions3DOpenGLCommon::getTranslatedShaderSourceANGLE(Platform3DObject
 
     String translatedShaderSource;
     String shaderInfoLog;
-    int extraCompileOptions = SH_MAP_LONG_VARIABLE_NAMES | SH_CLAMP_INDIRECT_ARRAY_BOUNDS;
+    int extraCompileOptions = SH_CLAMP_INDIRECT_ARRAY_BOUNDS;
 
     if (m_requiresBuiltInFunctionEmulation)
-        extraCompileOptions |= SH_EMULATE_BUILT_IN_FUNCTIONS;
+        extraCompileOptions |= SH_EMULATE_ABS_INT_FUNCTION;
 
     Vector<ANGLEShaderSymbol> symbols;
     bool isValid = compiler.compileShaderSource(entry.source.utf8().data(), shaderType, translatedShaderSource, shaderInfoLog, symbols, extraCompileOptions);
diff --git a/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp b/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp
index 43b546d18..73b61e2cd 100644
--- a/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp
+++ b/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp
@@ -428,7 +428,7 @@ GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWi
     , m_multisampleColorBuffer(0)
     , m_functions(0)
     , m_private(adoptPtr(new GraphicsContext3DPrivate(this, hostWindow, renderStyle)))
-    , m_compiler(isGLES2Compliant() ? SH_ESSL_OUTPUT : SH_GLSL_OUTPUT)
+    , m_compiler(isGLES2Compliant() ? SH_ESSL_OUTPUT : SH_GLSL_COMPATIBILITY_OUTPUT)
 {
     if (!m_private->m_surface || !m_private->m_platformContext) {
         LOG_ERROR("GraphicsContext3D: GL context creation failed.");
-- 
2.13.0