summarylogtreecommitdiffstats
path: root/qt5-qtwebkit-fix-compatibility-with-latest-angle.patch
blob: d20ba2c0d83e172325a3061006cdab3b27cb9e2e (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
--- qtwebkit-opensource-src-5.5.1/Source/WebCore/platform/graphics/ANGLEWebKitBridge.h.orig	2015-10-13 06:37:18.000000000 +0200
+++ qtwebkit-opensource-src-5.5.1/Source/WebCore/platform/graphics/ANGLEWebKitBridge.h	2016-03-09 17:17:26.000000000 +0100
@@ -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,17 +54,17 @@
     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);
     }
 };
 
--- qtwebkit-opensource-src-5.5.1/Source/WebCore/platform/graphics/ANGLEWebKitBridge.cpp.orig	2015-10-13 06:37:17.000000000 +0200
+++ qtwebkit-opensource-src-5.5.1/Source/WebCore/platform/graphics/ANGLEWebKitBridge.cpp	2016-03-09 20:45:20.000000000 +0100
@@ -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 @@
 {
     // 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 @@
 
     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;
--- qtwebkit-opensource-src-5.5.1/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp.orig	2015-10-13 06:37:17.000000000 +0200
+++ qtwebkit-opensource-src-5.5.1/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp	2016-03-09 17:17:26.000000000 +0100
@@ -172,7 +172,7 @@
 
     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;