PKGBUILDs/qt5-webkit/mingw-w64/0009-Establish-compatibilit...

242 lines
10 KiB
Diff

From ec2f7c510e98db427adef02879330a06daa7f3f7 Mon Sep 17 00:00:00 2001
From: Martchus <martchus@gmx.net>
Date: Sun, 25 Sep 2016 22:19:57 +0200
Subject: [PATCH 09/11] Establish compatibility with latest ANGLE
---
.../platform/graphics/ANGLEWebKitBridge.cpp | 126 ++++-----------------
.../WebCore/platform/graphics/ANGLEWebKitBridge.h | 15 +--
.../graphics/opengl/Extensions3DOpenGLCommon.cpp | 2 +-
3 files changed, 28 insertions(+), 115 deletions(-)
diff --git a/Source/WebCore/platform/graphics/ANGLEWebKitBridge.cpp b/Source/WebCore/platform/graphics/ANGLEWebKitBridge.cpp
index 9876c9f..84d3a2f 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 83c2e00..9540cc0 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,17 +54,17 @@ 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);
}
};
diff --git a/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp b/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp
index 29a13c8..9069957 100644
--- a/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp
+++ b/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp
@@ -172,7 +172,7 @@ 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;
--
2.10.2