Skip to content

Commit e7f5ec0

Browse files
committed
Update ANGLE binaries.
- the binaries are pulled from Chrome 131 binary dirs - load the entry points via a loader, using code from ANGLE - use the WebGL compatibility mode extension in ANGLE - replace Linux and Mac gyp builds with binaries There's one WebGL regression due to a minor bug in ANGLE: it accepts two desktop GL enums in WebGL compatibility mode when it shouldn't. This contribution is funded by https://higharc.com/
1 parent c16e31e commit e7f5ec0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+30904
-487
lines changed

binding.gyp

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,20 @@
1616
'sources': [
1717
'src/native/bindings.cc',
1818
'src/native/webgl.cc',
19-
'src/native/procs.cc'
19+
'src/native/SharedLibrary.cc',
20+
'src/native/angle-loader/egl_loader.cc',
21+
'src/native/angle-loader/gles_loader.cc'
2022
],
2123
'include_dirs': [
2224
"<!(node -e \"require('nan')\")",
2325
'<(module_root_dir)/deps/include',
24-
"angle/include"
26+
"src/native/angle-includes"
2527
],
2628
'library_dirs': [
2729
'<(module_root_dir)/deps/<(platform)'
2830
],
2931
'conditions': [
3032
['OS=="mac"', {
31-
'dependencies':
32-
[
33-
'angle/src/angle.gyp:libEGL',
34-
'angle/src/angle.gyp:libGLESv2'
35-
],
3633
'libraries': [
3734
'-framework QuartzCore',
3835
'-framework Quartz'
@@ -45,22 +42,28 @@
4542
'CLANG_CXX_LANGUAGE_STANDARD':'c++17',
4643
'GCC_VERSION': 'com.apple.compilers.llvm.clang.1_0'
4744
},
45+
"copies": [
46+
{
47+
'destination': '<(PRODUCT_DIR)',
48+
'files': [
49+
'<(module_root_dir)/deps/darwin/dylib/libEGL.dylib',
50+
'<(module_root_dir)/deps/darwin/dylib/libGLESv2.dylib',
51+
]
52+
}
53+
]
4854
}],
4955
['OS=="linux"', {
50-
'dependencies':
51-
[
52-
'angle/src/angle.gyp:libEGL',
53-
'angle/src/angle.gyp:libGLESv2'
54-
]
56+
"copies": [
57+
{
58+
'destination': '<(PRODUCT_DIR)',
59+
'files': [
60+
'<(module_root_dir)/deps/linux/so/libEGL.so',
61+
'<(module_root_dir)/deps/linux/so/libGLESv2.so',
62+
]
63+
}
64+
]
5565
}],
5666
['OS=="win"', {
57-
'library_dirs': [
58-
'<(module_root_dir)/deps/windows/lib/<(target_arch)',
59-
],
60-
'libraries': [
61-
'libEGL.lib',
62-
'libGLESv2.lib'
63-
],
6467
'defines' : [
6568
'WIN32_LEAN_AND_MEAN',
6669
'VC_EXTRALEAN'
@@ -102,11 +105,11 @@
102105
},
103106
"copies": [
104107
{
105-
'destination': '$(SolutionDir)$(ConfigurationName)',
108+
'destination': '<(PRODUCT_DIR)',
106109
'files': [
107-
'<(module_root_dir)/deps/windows/dll/<(target_arch)/libEGL.dll',
108-
'<(module_root_dir)/deps/windows/dll/<(target_arch)/libGLESv2.dll',
109-
'<(module_root_dir)/deps/windows/dll/<(target_arch)/d3dcompiler_47.dll'
110+
'<(module_root_dir)/deps/windows/dll/libEGL.dll',
111+
'<(module_root_dir)/deps/windows/dll/libGLESv2.dll',
112+
'<(module_root_dir)/deps/windows/dll/d3dcompiler_47.dll'
110113
]
111114
}
112115
]

deps/darwin/dylib/libEGL.dylib

479 KB
Binary file not shown.

deps/darwin/dylib/libGLESv2.dylib

14.4 MB
Binary file not shown.

deps/linux/so/libEGL.so

235 KB
Binary file not shown.

deps/linux/so/libGLESv2.so

6.62 MB
Binary file not shown.

deps/windows/dll/d3dcompiler_47.dll

4.69 MB
Binary file not shown.

deps/windows/dll/libEGL.dll

493 KB
Binary file not shown.

deps/windows/dll/libGLESv2.dll

7.86 MB
Binary file not shown.
-3.98 MB
Binary file not shown.

deps/windows/dll/x64/libEGL.dll

-85.5 KB
Binary file not shown.

deps/windows/dll/x64/libGLESv2.dll

-2.6 MB
Binary file not shown.

deps/windows/lib/x64/libEGL.lib

-12.6 KB
Binary file not shown.

deps/windows/lib/x64/libGLESv2.lib

-166 KB
Binary file not shown.

src/javascript/webgl-rendering-context.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,15 +1213,15 @@ class WebGLRenderingContext extends NativeWebGLRenderingContext {
12131213
exts.push('OES_texture_float_linear')
12141214
}
12151215

1216-
if (supportedExts.indexOf('EXT_draw_buffers') >= 0) {
1216+
if (supportedExts.indexOf('GL_EXT_draw_buffers') >= 0) {
12171217
exts.push('WEBGL_draw_buffers')
12181218
}
12191219

1220-
if (supportedExts.indexOf('EXT_blend_minmax') >= 0) {
1220+
if (supportedExts.indexOf('GL_EXT_blend_minmax') >= 0) {
12211221
exts.push('EXT_blend_minmax')
12221222
}
12231223

1224-
if (supportedExts.indexOf('EXT_texture_filter_anisotropic') >= 0) {
1224+
if (supportedExts.indexOf('GL_EXT_texture_filter_anisotropic') >= 0) {
12251225
exts.push('EXT_texture_filter_anisotropic')
12261226
}
12271227

src/native/SharedLibrary.cc

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#include <string>
2+
#include <array>
3+
4+
#ifdef _WIN32
5+
#include <windows.h>
6+
#else
7+
#include <dlfcn.h>
8+
#endif
9+
10+
#ifdef _WIN32
11+
std::string Narrow(const std::wstring_view &utf16)
12+
{
13+
if (utf16.empty())
14+
{
15+
return {};
16+
}
17+
int requiredSize = WideCharToMultiByte(CP_UTF8, 0, utf16.data(), static_cast<int>(utf16.size()),
18+
nullptr, 0, nullptr, nullptr);
19+
std::string utf8(requiredSize, '\0');
20+
WideCharToMultiByte(CP_UTF8, 0, utf16.data(), static_cast<int>(utf16.size()), &utf8[0],
21+
requiredSize, nullptr, nullptr);
22+
return utf8;
23+
}
24+
25+
std::string GetPath(HMODULE module)
26+
{
27+
std::array<wchar_t, MAX_PATH> executableFileBuf;
28+
DWORD executablePathLen = GetModuleFileNameW(module, executableFileBuf.data(),
29+
static_cast<DWORD>(executableFileBuf.size()));
30+
return Narrow(executablePathLen > 0 ? executableFileBuf.data() : L"");
31+
}
32+
33+
std::string GetModulePath(void *moduleOrSymbol)
34+
{
35+
HMODULE module = nullptr;
36+
if (GetModuleHandleExW(
37+
GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
38+
reinterpret_cast<LPCWSTR>(moduleOrSymbol), &module))
39+
{
40+
return GetPath(module);
41+
}
42+
43+
return "";
44+
}
45+
#else
46+
std::string GetModulePath(void *moduleOrSymbol)
47+
{
48+
Dl_info dlInfo;
49+
if (dladdr(moduleOrSymbol, &dlInfo) == 0)
50+
{
51+
return "";
52+
}
53+
54+
return dlInfo.dli_fname;
55+
}
56+
#endif
57+
58+
std::string StripFilenameFromPath(const std::string &path)
59+
{
60+
size_t lastPathSepLoc = path.find_last_of("\\/");
61+
return (lastPathSepLoc != std::string::npos) ? path.substr(0, lastPathSepLoc) : "";
62+
}
63+
64+
std::string GetModuleDirectory()
65+
{
66+
static int placeholderSymbol = 0;
67+
std::string moduleName = GetModulePath(&placeholderSymbol);
68+
return StripFilenameFromPath(moduleName);
69+
}

src/native/SharedLibrary.h

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#pragma once
2+
3+
#include <iostream>
4+
#include <stdexcept>
5+
#include <string>
6+
7+
#ifdef _WIN32
8+
#include <windows.h>
9+
#else
10+
#include <dlfcn.h>
11+
#endif
12+
13+
inline std::string GetSharedLibraryExtension() {
14+
#ifdef _WIN32
15+
return ".dll"; // Windows
16+
#elif __APPLE__
17+
return ".dylib"; // OSX
18+
#elif __linux__
19+
return ".so"; // Linux
20+
#else
21+
#error Unsupported platform
22+
#endif
23+
}
24+
25+
std::string GetModuleDirectory();
26+
27+
class SharedLibrary {
28+
public:
29+
SharedLibrary() {}
30+
31+
bool open(const std::string& libraryPath) {
32+
const std::string libraryPathWithExt = GetModuleDirectory() + "/" + libraryPath + GetSharedLibraryExtension();
33+
#ifdef _WIN32
34+
handle = LoadLibraryA(libraryPathWithExt.c_str());
35+
#else
36+
handle = dlopen(libraryPathWithExt.c_str(), RTLD_LAZY);
37+
#endif
38+
return handle != nullptr;
39+
}
40+
41+
~SharedLibrary() {
42+
if (handle) {
43+
#ifdef _WIN32
44+
FreeLibrary(static_cast<HMODULE>(handle));
45+
#else
46+
dlclose(handle);
47+
#endif
48+
}
49+
}
50+
51+
template <typename Func>
52+
Func getFunction(const std::string& functionName) {
53+
#ifdef _WIN32
54+
auto func = reinterpret_cast<Func>(GetProcAddress(static_cast<HMODULE>(handle), functionName.c_str()));
55+
#else
56+
auto func = reinterpret_cast<Func>(dlsym(handle, functionName.c_str()));
57+
#endif
58+
return func;
59+
}
60+
61+
private:
62+
void* handle = nullptr;
63+
};
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
DisableFormat: true
2+
SortIncludes: false

0 commit comments

Comments
 (0)