Skip to content

Commit 6d06901

Browse files
committed
opengl support for memory64
1 parent 6f793af commit 6d06901

8 files changed

+346
-241
lines changed

emcc.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2847,10 +2847,11 @@ def get_full_import_name(name):
28472847

28482848
# check if we can address the 2GB mark and higher: either if we start at
28492849
# 2GB, or if we allow growth to either any amount or to 2GB or more.
2850-
if settings.INITIAL_MEMORY > 2 * 1024 * 1024 * 1024 or \
2851-
(settings.ALLOW_MEMORY_GROWTH and
2852-
(settings.MAXIMUM_MEMORY < 0 or
2853-
settings.MAXIMUM_MEMORY > 2 * 1024 * 1024 * 1024)):
2850+
if settings.MEMORY64 == 0 and \
2851+
(settings.INITIAL_MEMORY > 2 * 1024 * 1024 * 1024 or
2852+
(settings.ALLOW_MEMORY_GROWTH and
2853+
(settings.MAXIMUM_MEMORY < 0 or
2854+
settings.MAXIMUM_MEMORY > 2 * 1024 * 1024 * 1024))):
28542855
settings.CAN_ADDRESS_2GB = 1
28552856

28562857
settings.EMSCRIPTEN_VERSION = shared.EMSCRIPTEN_VERSION

src/embind/embind.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Emscripten is available under two separate licenses, the MIT license and the
33
// University of Illinois/NCSA Open Source License. Both these licenses can be
44
// found in the LICENSE file.
5+
// SPDX-FileCopyrightText: Portions Copyright 2023 Siemens
6+
// Modified on February 2023 by Siemens and/or its affiliates to improve memory64 support
57

68
/*global LibraryManager, mergeInto*/
79

@@ -447,7 +449,11 @@ var LibraryEmbind = {
447449
} else {
448450
throw new TypeError("Unknown boolean type size: " + name);
449451
}
452+
#if MEMORY64
453+
return this['fromWireType'](heap[pointer / (1 << shift)]);
454+
#else
450455
return this['fromWireType'](heap[pointer >> shift]);
456+
#endif
451457
},
452458
destructorFunction: null, // This type does not need a destructor
453459
});

src/library_egl.js

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
* @license
33
* Copyright 2012 The Emscripten Authors
44
* SPDX-License-Identifier: MIT
5+
* SPDX-FileCopyrightText: Portions Copyright 2023 Siemens
6+
* Modified on February 2023 by Siemens and/or its affiliates to improve memory64 support
57
*/
68

79
/*
@@ -91,7 +93,7 @@ var LibraryEGL = {
9193

9294
// EGLAPI EGLDisplay EGLAPIENTRY eglGetDisplay(EGLNativeDisplayType display_id);
9395
eglGetDisplay__proxy: 'sync',
94-
eglGetDisplay__sig: 'ii',
96+
eglGetDisplay__sig: 'pp',
9597
eglGetDisplay: function(nativeDisplayType) {
9698
EGL.setErrorCode(0x3000 /* EGL_SUCCESS */);
9799
// Note: As a 'conformant' implementation of EGL, we would prefer to init here only if the user
@@ -110,7 +112,7 @@ var LibraryEGL = {
110112

111113
// EGLAPI EGLBoolean EGLAPIENTRY eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor);
112114
eglInitialize__proxy: 'sync',
113-
eglInitialize__sig: 'iiii',
115+
eglInitialize__sig: 'ippp',
114116
eglInitialize: function(display, majorVersion, minorVersion) {
115117
if (display != 62000 /* Magic ID for Emscripten 'default display' */) {
116118
EGL.setErrorCode(0x3008 /* EGL_BAD_DISPLAY */);
@@ -129,7 +131,7 @@ var LibraryEGL = {
129131

130132
// EGLAPI EGLBoolean EGLAPIENTRY eglTerminate(EGLDisplay dpy);
131133
eglTerminate__proxy: 'sync',
132-
eglTerminate__sig: 'ii',
134+
eglTerminate__sig: 'ip',
133135
eglTerminate: function(display) {
134136
if (display != 62000 /* Magic ID for Emscripten 'default display' */) {
135137
EGL.setErrorCode(0x3008 /* EGL_BAD_DISPLAY */);
@@ -145,21 +147,21 @@ var LibraryEGL = {
145147

146148
// EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigs(EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config);
147149
eglGetConfigs__proxy: 'sync',
148-
eglGetConfigs__sig: 'iiiii',
150+
eglGetConfigs__sig: 'ippip',
149151
eglGetConfigs: function(display, configs, config_size, numConfigs) {
150152
return EGL.chooseConfig(display, 0, configs, config_size, numConfigs);
151153
},
152154

153155
// EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config);
154156
eglChooseConfig__proxy: 'sync',
155-
eglChooseConfig__sig: 'iiiiii',
157+
eglChooseConfig__sig: 'ipppip',
156158
eglChooseConfig: function(display, attrib_list, configs, config_size, numConfigs) {
157159
return EGL.chooseConfig(display, attrib_list, configs, config_size, numConfigs);
158160
},
159161

160162
// EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value);
161163
eglGetConfigAttrib__proxy: 'sync',
162-
eglGetConfigAttrib__sig: 'iiiii',
164+
eglGetConfigAttrib__sig: 'ippip',
163165
eglGetConfigAttrib: function(display, config, attribute, value) {
164166
if (display != 62000 /* Magic ID for Emscripten 'default display' */) {
165167
EGL.setErrorCode(0x3008 /* EGL_BAD_DISPLAY */);
@@ -277,7 +279,7 @@ var LibraryEGL = {
277279

278280
// EGLAPI EGLSurface EGLAPIENTRY eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list);
279281
eglCreateWindowSurface__proxy: 'sync',
280-
eglCreateWindowSurface__sig: 'iiiii',
282+
eglCreateWindowSurface__sig: 'ppppp',
281283
eglCreateWindowSurface: function(display, config, win, attrib_list) {
282284
if (display != 62000 /* Magic ID for Emscripten 'default display' */) {
283285
EGL.setErrorCode(0x3008 /* EGL_BAD_DISPLAY */);
@@ -297,7 +299,7 @@ var LibraryEGL = {
297299

298300
// EGLAPI EGLBoolean EGLAPIENTRY eglDestroySurface(EGLDisplay display, EGLSurface surface);
299301
eglDestroySurface__proxy: 'sync',
300-
eglDestroySurface__sig: 'iii',
302+
eglDestroySurface__sig: 'ipp',
301303
eglDestroySurface: function(display, surface) {
302304
if (display != 62000 /* Magic ID for Emscripten 'default display' */) {
303305
EGL.setErrorCode(0x3008 /* EGL_BAD_DISPLAY */);
@@ -321,7 +323,7 @@ var LibraryEGL = {
321323

322324
// EGLAPI EGLContext EGLAPIENTRY eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list);
323325
eglCreateContext__proxy: 'sync',
324-
eglCreateContext__sig: 'iiiii',
326+
eglCreateContext__sig: 'ppppp',
325327
eglCreateContext: function(display, config, hmm, contextAttribs) {
326328
if (display != 62000 /* Magic ID for Emscripten 'default display' */) {
327329
EGL.setErrorCode(0x3008 /* EGL_BAD_DISPLAY */);
@@ -386,7 +388,7 @@ var LibraryEGL = {
386388

387389
// EGLAPI EGLBoolean EGLAPIENTRY eglDestroyContext(EGLDisplay dpy, EGLContext context);
388390
eglDestroyContext__proxy: 'sync',
389-
eglDestroyContext__sig: 'iii',
391+
eglDestroyContext__sig: 'ipp',
390392
eglDestroyContext: function(display, context) {
391393
if (display != 62000 /* Magic ID for Emscripten 'default display' */) {
392394
EGL.setErrorCode(0x3008 /* EGL_BAD_DISPLAY */);
@@ -407,7 +409,7 @@ var LibraryEGL = {
407409

408410
// EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value);
409411
eglQuerySurface__proxy: 'sync',
410-
eglQuerySurface__sig: 'iiiii',
412+
eglQuerySurface__sig: 'ippip',
411413
eglQuerySurface: function(display, surface, attribute, value) {
412414
if (display != 62000 /* Magic ID for Emscripten 'default display' */) {
413415
EGL.setErrorCode(0x3008 /* EGL_BAD_DISPLAY */);
@@ -474,7 +476,7 @@ var LibraryEGL = {
474476

475477
// EGLAPI EGLBoolean EGLAPIENTRY eglQueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value);
476478
eglQueryContext__proxy: 'sync',
477-
eglQueryContext__sig: 'iiiii',
479+
eglQueryContext__sig: 'ippip',
478480
eglQueryContext: function(display, context, attribute, value) {
479481
if (display != 62000 /* Magic ID for Emscripten 'default display' */) {
480482
EGL.setErrorCode(0x3008 /* EGL_BAD_DISPLAY */);
@@ -522,7 +524,7 @@ var LibraryEGL = {
522524
// EGLAPI const char * EGLAPIENTRY eglQueryString(EGLDisplay dpy, EGLint name);
523525
eglQueryString__deps: ['$allocateUTF8'],
524526
eglQueryString__proxy: 'sync',
525-
eglQueryString__sig: 'iii',
527+
eglQueryString__sig: 'ppi',
526528
eglQueryString: function(display, name) {
527529
if (display != 62000 /* Magic ID for Emscripten 'default display' */) {
528530
EGL.setErrorCode(0x3008 /* EGL_BAD_DISPLAY */);
@@ -589,7 +591,7 @@ var LibraryEGL = {
589591
// EGLAPI EGLBoolean EGLAPIENTRY eglSwapInterval(EGLDisplay dpy, EGLint interval);
590592
eglSwapInterval__deps: ['emscripten_set_main_loop_timing'],
591593
eglSwapInterval__proxy: 'sync',
592-
eglSwapInterval__sig: 'iii',
594+
eglSwapInterval__sig: 'ipi',
593595
eglSwapInterval: function(display, interval) {
594596
if (display != 62000 /* Magic ID for Emscripten 'default display' */) {
595597
EGL.setErrorCode(0x3008 /* EGL_BAD_DISPLAY */);
@@ -605,7 +607,7 @@ var LibraryEGL = {
605607
// EGLAPI EGLBoolean EGLAPIENTRY eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);
606608
eglMakeCurrent__deps: ['$GL'],
607609
eglMakeCurrent__proxy: 'sync',
608-
eglMakeCurrent__sig: 'iiiii',
610+
eglMakeCurrent__sig: 'ipppp',
609611
eglMakeCurrent: function(display, draw, read, context) {
610612
if (display != 62000 /* Magic ID for Emscripten 'default display' */) {
611613
EGL.setErrorCode(0x3008 /* EGL_BAD_DISPLAY */);
@@ -632,14 +634,14 @@ var LibraryEGL = {
632634

633635
// EGLAPI EGLContext EGLAPIENTRY eglGetCurrentContext(void);
634636
eglGetCurrentContext__proxy: 'sync',
635-
eglGetCurrentContext__sig: 'i',
637+
eglGetCurrentContext__sig: 'p',
636638
eglGetCurrentContext: function() {
637639
return EGL.currentContext;
638640
},
639641

640642
// EGLAPI EGLSurface EGLAPIENTRY eglGetCurrentSurface(EGLint readdraw);
641643
eglGetCurrentSurface__proxy: 'sync',
642-
eglGetCurrentSurface__sig: 'ii',
644+
eglGetCurrentSurface__sig: 'pi',
643645
eglGetCurrentSurface: function(readdraw) {
644646
if (readdraw == 0x305A /* EGL_READ */) {
645647
return EGL.currentReadSurface;
@@ -653,15 +655,15 @@ var LibraryEGL = {
653655

654656
// EGLAPI EGLDisplay EGLAPIENTRY eglGetCurrentDisplay(void);
655657
eglGetCurrentDisplay__proxy: 'sync',
656-
eglGetCurrentDisplay__sig: 'i',
658+
eglGetCurrentDisplay__sig: 'p',
657659
eglGetCurrentDisplay: function() {
658660
return EGL.currentContext ? 62000 /* Magic ID for Emscripten 'default display' */ : 0;
659661
},
660662

661663
// EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay dpy, EGLSurface surface);
662664
eglSwapBuffers__proxy: 'sync',
663-
eglSwapBuffers__sig: 'iii',
664-
eglSwapBuffers: function() {
665+
eglSwapBuffers__sig: 'ipp',
666+
eglSwapBuffers: function(dpy, surface) {
665667
#if PROXY_TO_WORKER
666668
if (Browser.doSwapBuffers) Browser.doSwapBuffers();
667669
#endif

src/library_html5.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
* @license
33
* Copyright 2014 The Emscripten Authors
44
* SPDX-License-Identifier: MIT
5+
* SPDX-FileCopyrightText: Portions Copyright 2023 Siemens
6+
* Modified on February 2023 by Siemens and/or its affiliates to improve memory64 support
57
*/
68

79
var LibraryHTML5 = {
@@ -314,7 +316,11 @@ var LibraryHTML5 = {
314316
// values we accept here, EMSCRIPTEN_EVENT_TARGET_* (which map to 0, 1, 2).
315317
// In other words, if cString > 2 then it's a pointer to a valid place in
316318
// memory, and points to a C string.
319+
#if MEMORY64
320+
return cString > 2 ? UTF8ToString(Number(cString)) : cString;
321+
#else
317322
return cString > 2 ? UTF8ToString(cString) : cString;
323+
#endif
318324
},
319325

320326
$findEventTarget__deps: ['$maybeCStringToJsString', '$specialHTMLTargets'],
@@ -522,10 +528,10 @@ var LibraryHTML5 = {
522528
if (targetThread) {
523529
var mouseEventData = _malloc( {{{ C_STRUCTS.EmscriptenMouseEvent.__size__ }}} ); // This allocated block is passed as satellite data to the proxied function call, so the call frees up the data block when done.
524530
fillMouseEventData(mouseEventData, e, target);
525-
JSEvents.queueEventHandlerOnThread_iiii(targetThread, callbackfunc, eventTypeId, mouseEventData, userData);
531+
JSEvents.queueEventHandlerOnThread_iipp(targetThread, callbackfunc, eventTypeId, mouseEventData, userData);
526532
} else
527533
#endif
528-
if ({{{ makeDynCall('iiii', 'callbackfunc') }}}(eventTypeId, JSEvents.mouseEvent, userData)) e.preventDefault();
534+
if ({{{ makeDynCall('iipp', 'callbackfunc') }}}(eventTypeId, JSEvents.mouseEvent, userData)) e.preventDefault();
529535
};
530536

531537
var eventHandler = {
@@ -652,7 +658,7 @@ var LibraryHTML5 = {
652658
if (targetThread) JSEvents.queueEventHandlerOnThread_iiii(targetThread, callbackfunc, eventTypeId, wheelEvent, userData);
653659
else
654660
#endif
655-
if ({{{ makeDynCall('iiii', 'callbackfunc') }}}(eventTypeId, wheelEvent, userData)) e.preventDefault();
661+
if ({{{ makeDynCall('iipp', 'callbackfunc') }}}(eventTypeId, wheelEvent, userData)) e.preventDefault();
656662
};
657663
#if MIN_IE_VERSION <= 8 || MIN_SAFARI_VERSION < 60100 // Browsers that do not support https://caniuse.com/#feat=mdn-api_wheelevent
658664
// The 'mousewheel' event as implemented in Safari 6.0.5
@@ -664,7 +670,7 @@ var LibraryHTML5 = {
664670
{{{ makeSetValue('JSEvents.wheelEvent', C_STRUCTS.EmscriptenWheelEvent.deltaY, 'wheelDeltaY', 'double') }}};
665671
{{{ makeSetValue('JSEvents.wheelEvent', C_STRUCTS.EmscriptenWheelEvent.deltaZ, '0 /* Not available */', 'double') }}};
666672
{{{ makeSetValue('JSEvents.wheelEvent', C_STRUCTS.EmscriptenWheelEvent.deltaMode, '0 /* DOM_DELTA_PIXEL */', 'i32') }}};
667-
var shouldCancel = {{{ makeDynCall('iiii', 'callbackfunc') }}}( eventTypeId, JSEvents.wheelEvent, userData);
673+
var shouldCancel = {{{ makeDynCall('iipp', 'callbackfunc') }}}( eventTypeId, JSEvents.wheelEvent, userData);
668674
if (shouldCancel) {
669675
e.preventDefault();
670676
}

0 commit comments

Comments
 (0)