Skip to content

Commit 5b64c81

Browse files
authored
[wasm64] Run glbook tests under browser64. NFC (#20633)
As part of this EGLNativeDisplayType was fixed to match X11 This allows `Display*` (a pointer type) to be passed into our eglGetDisplay function without a cast warning on wasm64 (where pointers and int have a different width). Split out from #20516
1 parent cc81d25 commit 5b64c81

File tree

5 files changed

+24
-28
lines changed

5 files changed

+24
-28
lines changed

.circleci/config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,8 @@ jobs:
809809
browser64.test_idbstore*
810810
browser64.test_fs_idbfs*
811811
browser64.test_webgl*
812+
browser64.test_glbook
813+
browser64.test_gles2_emulation*
812814
"
813815
test-browser-firefox:
814816
executor: bionic

src/library_egl.js

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -102,18 +102,13 @@ var LibraryEGL = {
102102
eglGetDisplay__proxy: 'sync',
103103
eglGetDisplay: (nativeDisplayType) => {
104104
EGL.setErrorCode(0x3000 /* EGL_SUCCESS */);
105-
// Note: As a 'conformant' implementation of EGL, we would prefer to init here only if the user
106-
// calls this function with EGL_DEFAULT_DISPLAY. Other display IDs would be preferred to be unsupported
107-
// and EGL_NO_DISPLAY returned. Uncomment the following code lines to do this.
108-
// Instead, an alternative route has been preferred, namely that the Emscripten EGL implementation
109-
// "emulates" X11, and eglGetDisplay is expected to accept/receive a pointer to an X11 Display object.
110-
// Therefore, be lax and allow anything to be passed in, and return the magic handle to our default EGLDisplay object.
111-
112-
// if (nativeDisplayType == 0 /* EGL_DEFAULT_DISPLAY */) {
113-
return {{{ eglDefaultDisplay }}};
114-
// }
115-
// else
116-
// return 0; // EGL_NO_DISPLAY
105+
// Emscripten EGL implementation "emulates" X11, and eglGetDisplay is
106+
// expected to accept/receive a pointer to an X11 Display object (or
107+
// EGL_DEFAULT_DISPLAY).
108+
if (nativeDisplayType != 0 /* EGL_DEFAULT_DISPLAY */ && nativeDisplayType != 1 /* see library_xlib.js */) {
109+
return 0; // EGL_NO_DISPLAY
110+
}
111+
return {{{ eglDefaultDisplay }}};
117112
},
118113

119114
// EGLAPI EGLBoolean EGLAPIENTRY eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor);

src/library_sigs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ sigs = {
545545
eglGetCurrentContext__sig: 'p',
546546
eglGetCurrentDisplay__sig: 'p',
547547
eglGetCurrentSurface__sig: 'pi',
548-
eglGetDisplay__sig: 'pi',
548+
eglGetDisplay__sig: 'pp',
549549
eglGetError__sig: 'i',
550550
eglInitialize__sig: 'ippp',
551551
eglMakeCurrent__sig: 'ipppp',

system/include/EGL/eglplatform.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ typedef HWND EGLNativeWindowType;
7979

8080
#elif defined(__EMSCRIPTEN__)
8181

82-
typedef int EGLNativeDisplayType;
82+
typedef void* EGLNativeDisplayType;
8383
typedef int EGLNativePixmapType;
8484
typedef int EGLNativeWindowType;
8585

test/test_browser.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1839,19 +1839,19 @@ def test_glbook(self):
18391839
'Chapter_13/ParticleSystem/CH13_ParticleSystem.o',
18401840
], configure=None)
18411841

1842-
def book_path(*pathelems):
1843-
return test_file('third_party/glbook', *pathelems)
1842+
def book_path(path):
1843+
return test_file('third_party/glbook', path)
18441844

18451845
for program in programs:
18461846
print(program)
18471847
basename = os.path.basename(program)
18481848
args = ['-lGL', '-lEGL', '-lX11']
18491849
if basename == 'CH10_MultiTexture.o':
1850-
shutil.copyfile(book_path('Chapter_10', 'MultiTexture', 'basemap.tga'), 'basemap.tga')
1851-
shutil.copyfile(book_path('Chapter_10', 'MultiTexture', 'lightmap.tga'), 'lightmap.tga')
1850+
shutil.copyfile(book_path('Chapter_10/MultiTexture/basemap.tga'), 'basemap.tga')
1851+
shutil.copyfile(book_path('Chapter_10/MultiTexture/lightmap.tga'), 'lightmap.tga')
18521852
args += ['--preload-file', 'basemap.tga', '--preload-file', 'lightmap.tga']
18531853
elif basename == 'CH13_ParticleSystem.o':
1854-
shutil.copyfile(book_path('Chapter_13', 'ParticleSystem', 'smoke.tga'), 'smoke.tga')
1854+
shutil.copyfile(book_path('Chapter_13/ParticleSystem/smoke.tga'), 'smoke.tga')
18551855
args += ['--preload-file', 'smoke.tga', '-O2'] # test optimizations and closure here as well for more coverage
18561856

18571857
self.btest(program,
@@ -1865,23 +1865,22 @@ def book_path(*pathelems):
18651865
'full_es3': (['-sFULL_ES3'],)
18661866
})
18671867
def test_gles2_emulation(self, args):
1868-
print(args)
18691868
shutil.copyfile(test_file('third_party/glbook/Chapter_10/MultiTexture/basemap.tga'), 'basemap.tga')
18701869
shutil.copyfile(test_file('third_party/glbook/Chapter_10/MultiTexture/lightmap.tga'), 'lightmap.tga')
18711870
shutil.copyfile(test_file('third_party/glbook/Chapter_13/ParticleSystem/smoke.tga'), 'smoke.tga')
18721871

18731872
for source, reference in [
1874-
(Path('third_party/glbook/Chapter_2', 'Hello_Triangle', 'Hello_Triangle_orig.c'), test_file('third_party/glbook/CH02_HelloTriangle.png')),
1875-
# (Path('third_party/glbook/Chapter_8', 'Simple_VertexShader', 'Simple_VertexShader_orig.c'), test_file('third_party/glbook/CH08_SimpleVertexShader.png')), # XXX needs INT extension in WebGL
1876-
(Path('third_party/glbook/Chapter_9', 'TextureWrap', 'TextureWrap_orig.c'), test_file('third_party/glbook/CH09_TextureWrap.png')),
1877-
# (Path('third_party/glbook/Chapter_9', 'Simple_TextureCubemap', 'Simple_TextureCubemap_orig.c'), test_file('third_party/glbook/CH09_TextureCubemap.png')), # XXX needs INT extension in WebGL
1878-
(Path('third_party/glbook/Chapter_9', 'Simple_Texture2D', 'Simple_Texture2D_orig.c'), test_file('third_party/glbook/CH09_SimpleTexture2D.png')),
1879-
(Path('third_party/glbook/Chapter_10', 'MultiTexture', 'MultiTexture_orig.c'), test_file('third_party/glbook/CH10_MultiTexture.png')),
1880-
(Path('third_party/glbook/Chapter_13', 'ParticleSystem', 'ParticleSystem_orig.c'), test_file('third_party/glbook/CH13_ParticleSystem.png')),
1873+
('third_party/glbook/Chapter_2/Hello_Triangle/Hello_Triangle_orig.c', 'third_party/glbook/CH02_HelloTriangle.png'),
1874+
# ('third_party/glbook/Chapter_8/Simple_VertexShader/Simple_VertexShader_orig.c', 'third_party/glbook/CH08_SimpleVertexShader.png'), # XXX needs INT extension in WebGL
1875+
('third_party/glbook/Chapter_9/TextureWrap/TextureWrap_orig.c', 'third_party/glbook/CH09_TextureWrap.png'),
1876+
# ('third_party/glbook/Chapter_9/Simple_TextureCubemap/Simple_TextureCubemap_orig.c', 'third_party/glbook/CH09_TextureCubemap.png'), # XXX needs INT extension in WebGL
1877+
('third_party/glbook/Chapter_9/Simple_Texture2D/Simple_Texture2D_orig.c', 'third_party/glbook/CH09_SimpleTexture2D.png'),
1878+
('third_party/glbook/Chapter_10/MultiTexture/MultiTexture_orig.c', 'third_party/glbook/CH10_MultiTexture.png'),
1879+
('third_party/glbook/Chapter_13/ParticleSystem/ParticleSystem_orig.c', 'third_party/glbook/CH13_ParticleSystem.png'),
18811880
]:
18821881
print(source)
18831882
self.btest(source,
1884-
reference=reference,
1883+
reference=test_file(reference),
18851884
args=['-I' + test_file('third_party/glbook/Common'),
18861885
test_file('third_party/glbook/Common/esUtil.c'),
18871886
test_file('third_party/glbook/Common/esShader.c'),

0 commit comments

Comments
 (0)