Bug 1371190 - Part1: Modify gecko to be compatible to newer ANGLE
MozReview-Commit-ID: 5iK1L4ioVFK
--- a/dom/canvas/WebGLContextValidate.cpp
+++ b/dom/canvas/WebGLContextValidate.cpp
@@ -686,17 +686,17 @@ WebGLContext::InitAndValidateGL(FailureR
if (gl->IsSupported(gl::GLFeature::seamless_cube_map_opt_in)) {
gl->fEnable(LOCAL_GL_TEXTURE_CUBE_MAP_SEAMLESS);
}
// Check the shader validator pref
mBypassShaderValidation = gfxPrefs::WebGLBypassShaderValidator();
// initialize shader translator
- if (!ShInitialize()) {
+ if (!sh::Initialize()) {
*out_failReason = { "FEATURE_FAILURE_WEBGL_GLSL",
"GLSL translator initialization failed!" };
return false;
}
// Mesa can only be detected with the GL_VERSION string, of the form
// "2.1 Mesa 7.11.0"
const char* versionStr = (const char*)(gl->fGetString(LOCAL_GL_VERSION));
--- a/dom/canvas/WebGLShaderValidator.cpp
+++ b/dom/canvas/WebGLShaderValidator.cpp
@@ -132,17 +132,17 @@ WebGLContext::CreateShaderValidator(GLen
if (mBypassShaderValidation)
return nullptr;
const auto spec = (IsWebGL2() ? SH_WEBGL2_SPEC : SH_WEBGL_SPEC);
const auto outputLanguage = ShaderOutput(gl);
ShBuiltInResources resources;
memset(&resources, 0, sizeof(resources));
- ShInitBuiltInResources(&resources);
+ sh::InitBuiltInResources(&resources);
resources.HashFunction = webgl::IdentifierHashFunc;
resources.MaxVertexAttribs = mGLMaxVertexAttribs;
resources.MaxVertexUniformVectors = mGLMaxVertexUniformVectors;
resources.MaxVaryingVectors = mGLMaxVaryingVectors;
resources.MaxVertexTextureImageUnits = mGLMaxVertexTextureImageUnits;
resources.MaxCombinedTextureImageUnits = mGLMaxCombinedTextureImageUnits;
@@ -188,55 +188,55 @@ WebGLContext::CreateShaderValidator(GLen
namespace webgl {
/*static*/ ShaderValidator*
ShaderValidator::Create(GLenum shaderType, ShShaderSpec spec,
ShShaderOutput outputLanguage,
const ShBuiltInResources& resources,
ShCompileOptions compileOptions)
{
- ShHandle handle = ShConstructCompiler(shaderType, spec, outputLanguage, &resources);
+ ShHandle handle = sh::ConstructCompiler(shaderType, spec, outputLanguage, &resources);
if (!handle)
return nullptr;
return new ShaderValidator(handle, compileOptions, resources.MaxVaryingVectors);
}
ShaderValidator::~ShaderValidator()
{
- ShDestruct(mHandle);
+ sh::Destruct(mHandle);
}
bool
ShaderValidator::ValidateAndTranslate(const char* source)
{
MOZ_ASSERT(!mHasRun);
mHasRun = true;
const char* const parts[] = {
source
};
- return ShCompile(mHandle, parts, ArrayLength(parts), mCompileOptions);
+ return sh::Compile(mHandle, parts, ArrayLength(parts), mCompileOptions);
}
void
ShaderValidator::GetInfoLog(nsACString* out) const
{
MOZ_ASSERT(mHasRun);
- const std::string &log = ShGetInfoLog(mHandle);
+ const std::string &log = sh::GetInfoLog(mHandle);
out->Assign(log.data(), log.length());
}
void
ShaderValidator::GetOutput(nsACString* out) const
{
MOZ_ASSERT(mHasRun);
- const std::string &output = ShGetObjectCode(mHandle);
+ const std::string &output = sh::GetObjectCode(mHandle);
out->Assign(output.data(), output.length());
}
template<size_t N>
static bool
StartsWith(const std::string& haystack, const char (&needle)[N])
{
return haystack.compare(0, N - 1, needle) == 0;
@@ -246,29 +246,29 @@ bool
ShaderValidator::CanLinkTo(const ShaderValidator* prev, nsCString* const out_log) const
{
if (!prev) {
nsPrintfCString error("Passed in NULL prev ShaderValidator.");
*out_log = error;
return false;
}
- const auto shaderVersion = ShGetShaderVersion(mHandle);
- if (ShGetShaderVersion(prev->mHandle) != shaderVersion) {
+ const auto shaderVersion = sh::GetShaderVersion(mHandle);
+ if (sh::GetShaderVersion(prev->mHandle) != shaderVersion) {
nsPrintfCString error("Vertex shader version %d does not match"
" fragment shader version %d.",
- ShGetShaderVersion(prev->mHandle),
- ShGetShaderVersion(mHandle));
+ sh::GetShaderVersion(prev->mHandle),
+ sh::GetShaderVersion(mHandle));
*out_log = error;
return false;
}
{
- const std::vector<sh::Uniform>* vertPtr = ShGetUniforms(prev->mHandle);
- const std::vector<sh::Uniform>* fragPtr = ShGetUniforms(mHandle);
+ const std::vector<sh::Uniform>* vertPtr = sh::GetUniforms(prev->mHandle);
+ const std::vector<sh::Uniform>* fragPtr = sh::GetUniforms(mHandle);
if (!vertPtr || !fragPtr) {
nsPrintfCString error("Could not create uniform list.");
*out_log = error;
return false;
}
for (auto itrFrag = fragPtr->begin(); itrFrag != fragPtr->end(); ++itrFrag) {
for (auto itrVert = vertPtr->begin(); itrVert != vertPtr->end(); ++itrVert) {
@@ -309,18 +309,18 @@ ShaderValidator::CanLinkTo(const ShaderV
return false;
}
break;
}
}
}
- const auto& vertVaryings = ShGetVaryings(prev->mHandle);
- const auto& fragVaryings = ShGetVaryings(mHandle);
+ const auto& vertVaryings = sh::GetVaryings(prev->mHandle);
+ const auto& fragVaryings = sh::GetVaryings(mHandle);
if (!vertVaryings || !fragVaryings) {
nsPrintfCString error("Could not create varying list.");
*out_log = error;
return false;
}
{
std::vector<sh::ShaderVariable> staticUseVaryingList;
@@ -362,17 +362,17 @@ ShaderValidator::CanLinkTo(const ShaderV
return false;
}
if (staticVertUse && fragVarying.staticUse) {
staticUseVaryingList.push_back(fragVarying);
}
}
- if (!ShCheckVariablesWithinPackingLimits(mMaxVaryingVectors,
+ if (!sh::CheckVariablesWithinPackingLimits(mMaxVaryingVectors,
staticUseVaryingList))
{
*out_log = "Statically used varyings do not fit within packing limits. (see"
" GLSL ES Specification 1.0.17, p111)";
return false;
}
}
@@ -424,119 +424,119 @@ ShaderValidator::CanLinkTo(const ShaderV
return true;
}
size_t
ShaderValidator::CalcNumSamplerUniforms() const
{
size_t accum = 0;
- const std::vector<sh::Uniform>& uniforms = *ShGetUniforms(mHandle);
+ const std::vector<sh::Uniform>& uniforms = *sh::GetUniforms(mHandle);
for (auto itr = uniforms.begin(); itr != uniforms.end(); ++itr) {
GLenum type = itr->type;
if (type == LOCAL_GL_SAMPLER_2D ||
type == LOCAL_GL_SAMPLER_CUBE)
{
accum += itr->arraySize;
}
}
return accum;
}
size_t
ShaderValidator::NumAttributes() const
{
- return ShGetAttributes(mHandle)->size();
+ return sh::GetAttributes(mHandle)->size();
}
// Attribs cannot be structs or arrays, and neither can vertex inputs in ES3.
// Therefore, attrib names are always simple.
bool
ShaderValidator::FindAttribUserNameByMappedName(const std::string& mappedName,
const std::string** const out_userName) const
{
- const std::vector<sh::Attribute>& attribs = *ShGetAttributes(mHandle);
+ const std::vector<sh::Attribute>& attribs = *sh::GetAttributes(mHandle);
for (auto itr = attribs.begin(); itr != attribs.end(); ++itr) {
if (itr->mappedName == mappedName) {
*out_userName = &(itr->name);
return true;
}
}
return false;
}
bool
ShaderValidator::FindAttribMappedNameByUserName(const std::string& userName,
const std::string** const out_mappedName) const
{
- const std::vector<sh::Attribute>& attribs = *ShGetAttributes(mHandle);
+ const std::vector<sh::Attribute>& attribs = *sh::GetAttributes(mHandle);
for (auto itr = attribs.begin(); itr != attribs.end(); ++itr) {
if (itr->name == userName) {
*out_mappedName = &(itr->mappedName);
return true;
}
}
return false;
}
bool
ShaderValidator::FindVaryingByMappedName(const std::string& mappedName,
std::string* const out_userName,
bool* const out_isArray) const
{
- const std::vector<sh::Varying>& varyings = *ShGetVaryings(mHandle);
+ const std::vector<sh::Varying>& varyings = *sh::GetVaryings(mHandle);
for (auto itr = varyings.begin(); itr != varyings.end(); ++itr) {
const sh::ShaderVariable* found;
if (!itr->findInfoByMappedName(mappedName, &found, out_userName))
continue;
*out_isArray = found->isArray();
return true;
}
return false;
}
bool
ShaderValidator::FindVaryingMappedNameByUserName(const std::string& userName,
const std::string** const out_mappedName) const
{
- const std::vector<sh::Varying>& attribs = *ShGetVaryings(mHandle);
+ const std::vector<sh::Varying>& attribs = *sh::GetVaryings(mHandle);
for (auto itr = attribs.begin(); itr != attribs.end(); ++itr) {
if (itr->name == userName) {
*out_mappedName = &(itr->mappedName);
return true;
}
}
return false;
}
// This must handle names like "foo.bar[0]".
bool
ShaderValidator::FindUniformByMappedName(const std::string& mappedName,
std::string* const out_userName,
bool* const out_isArray) const
{
- const std::vector<sh::Uniform>& uniforms = *ShGetUniforms(mHandle);
+ const std::vector<sh::Uniform>& uniforms = *sh::GetUniforms(mHandle);
for (auto itr = uniforms.begin(); itr != uniforms.end(); ++itr) {
const sh::ShaderVariable* found;
if (!itr->findInfoByMappedName(mappedName, &found, out_userName))
continue;
*out_isArray = found->isArray();
return true;
}
const size_t dotPos = mappedName.find(".");
- const std::vector<sh::InterfaceBlock>& interfaces = *ShGetInterfaceBlocks(mHandle);
+ const std::vector<sh::InterfaceBlock>& interfaces = *sh::GetInterfaceBlocks(mHandle);
for (const auto& interface : interfaces) {
std::string mappedFieldName;
const bool hasInstanceName = !interface.instanceName.empty();
// If the InterfaceBlock has an instanceName, all variables defined
// within the block are qualified with the block name, as opposed
// to being placed in the global scope.
@@ -574,33 +574,33 @@ ShaderValidator::FindUniformByMappedName
return false;
}
bool
ShaderValidator::UnmapUniformBlockName(const nsACString& baseMappedName,
nsCString* const out_baseUserName) const
{
- const std::vector<sh::InterfaceBlock>& interfaces = *ShGetInterfaceBlocks(mHandle);
+ const std::vector<sh::InterfaceBlock>& interfaces = *sh::GetInterfaceBlocks(mHandle);
for (const auto& interface : interfaces) {
const nsDependentCString interfaceMappedName(interface.mappedName.data(),
interface.mappedName.size());
if (baseMappedName == interfaceMappedName) {
*out_baseUserName = interface.name.data();
return true;
}
}
return false;
}
void
ShaderValidator::EnumerateFragOutputs(std::map<nsCString, const nsCString> &out_FragOutputs) const
{
- const auto* fragOutputs = ShGetOutputVariables(mHandle);
+ const auto* fragOutputs = sh::GetOutputVariables(mHandle);
if (fragOutputs) {
for (const auto& fragOutput : *fragOutputs) {
out_FragOutputs.insert({nsCString(fragOutput.name.c_str()),
nsCString(fragOutput.mappedName.c_str())});
}
}
}
--- a/gfx/gl/GLLibraryEGL.cpp
+++ b/gfx/gl/GLLibraryEGL.cpp
@@ -183,29 +183,29 @@ GetAndInitDisplay(GLLibraryEGL& egl, voi
return EGL_NO_DISPLAY;
if (!egl.fInitialize(display, nullptr, nullptr))
return EGL_NO_DISPLAY;
return display;
}
-class AngleErrorReporting: public angle::Platform {
+class AngleErrorReporting {
public:
AngleErrorReporting()
{
// No static constructor
}
void SetFailureId(nsACString* const aFailureId)
{
mFailureId = aFailureId;
}
- void logError(const char *errorMessage) override
+ void logError(const char *errorMessage)
{
if (!mFailureId) {
return;
}
nsCString str(errorMessage);
Tokenizer tokenizer(str);
@@ -249,17 +249,16 @@ GetAndInitDisplayForAccelANGLE(GLLibrary
if (!gfxPrefs::WebGLANGLETryD3D11())
d3d11ANGLE.UserDisable("User disabled D3D11 ANGLE by pref",
NS_LITERAL_CSTRING("FAILURE_ID_ANGLE_PREF"));
if (gfxPrefs::WebGLANGLEForceD3D11())
d3d11ANGLE.UserForceEnable("User force-enabled D3D11 ANGLE on disabled hardware");
gAngleErrorReporter.SetFailureId(out_failureId);
- egl.fANGLEPlatformInitialize(&gAngleErrorReporter);
auto guardShutdown = mozilla::MakeScopeExit([&] {
gAngleErrorReporter.SetFailureId(nullptr);
// NOTE: Ideally we should be calling ANGLEPlatformShutdown after the
// ANGLE display is destroyed. However gAngleErrorReporter
// will live longer than the ANGLE display so we're fine.
});
@@ -451,18 +450,16 @@ GLLibraryEGL::EnsureInitialized(bool for
EGLDisplay chosenDisplay = nullptr;
// Client exts are ready. (But not display exts!)
if (mIsANGLE) {
MOZ_ASSERT(IsExtensionSupported(ANGLE_platform_angle_d3d));
const GLLibraryLoader::SymLoadStruct angleSymbols[] = {
- { (PRFuncPtr*)&mSymbols.fANGLEPlatformInitialize, { "ANGLEPlatformInitialize", nullptr } },
- { (PRFuncPtr*)&mSymbols.fANGLEPlatformShutdown, { "ANGLEPlatformShutdown", nullptr } },
SYMBOL(GetPlatformDisplayEXT),
END_OF_SYMBOLS
};
if (!fnLoadSymbols(angleSymbols)) {
gfxCriticalError() << "Failed to load ANGLE symbols!";
return false;
}
}
--- a/gfx/gl/GLLibraryEGL.h
+++ b/gfx/gl/GLLibraryEGL.h
@@ -329,22 +329,16 @@ public:
// ANGLE_device_creation
EGLDeviceEXT fCreateDeviceANGLE(EGLint device_type, void* native_device, const EGLAttrib* attrib_list) const
WRAP( fCreateDeviceANGLE(device_type, native_device, attrib_list) )
EGLBoolean fReleaseDeviceANGLE(EGLDeviceEXT device)
WRAP( fReleaseDeviceANGLE(device) )
- void fANGLEPlatformInitialize(angle::Platform* platform) const
- VOID_WRAP( fANGLEPlatformInitialize(platform) )
-
- void fANGLEPlatformShutdown() const
- VOID_WRAP( fANGLEPlatformShutdown() )
-
#undef WRAP
#undef VOID_WRAP
#undef PROFILE_CALL
#undef BEFORE_CALL
#undef AFTER_CALL
#undef MOZ_FUNCTION_NAME
////
@@ -496,18 +490,16 @@ private:
void* texture,
const EGLAttrib* attrib_list);
// ANGLE_device_creation
EGLDeviceEXT (GLAPIENTRY * fCreateDeviceANGLE) (EGLint device_type,
void* native_device,
const EGLAttrib* attrib_list);
EGLBoolean (GLAPIENTRY * fReleaseDeviceANGLE) (EGLDeviceEXT device);
- void (GLAPIENTRY * fANGLEPlatformInitialize)(angle::Platform* platform);
- void (GLAPIENTRY * fANGLEPlatformShutdown)();
} mSymbols;
private:
bool mInitialized;
PRLibrary* mEGLLibrary;
EGLDisplay mEGLDisplay;
RefPtr<GLContext> mReadbackGL;