Skip to content

Commit bc1a4fd

Browse files
committed
opengl support for memory64
1 parent ae8d76b commit bc1a4fd

File tree

8 files changed

+266
-164
lines changed

8 files changed

+266
-164
lines changed

emcc.py

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

28442844
# check if we can address the 2GB mark and higher: either if we start at
28452845
# 2GB, or if we allow growth to either any amount or to 2GB or more.
2846-
if settings.INITIAL_MEMORY > 2 * 1024 * 1024 * 1024 or \
2847-
(settings.ALLOW_MEMORY_GROWTH and
2848-
(settings.MAXIMUM_MEMORY < 0 or
2849-
settings.MAXIMUM_MEMORY > 2 * 1024 * 1024 * 1024)):
2846+
if settings.MEMORY64 == 0 and \
2847+
(settings.INITIAL_MEMORY > 2 * 1024 * 1024 * 1024 or
2848+
(settings.ALLOW_MEMORY_GROWTH and
2849+
(settings.MAXIMUM_MEMORY < 0 or
2850+
settings.MAXIMUM_MEMORY > 2 * 1024 * 1024 * 1024))):
28502851
settings.CAN_ADDRESS_2GB = 1
28512852

28522853
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

@@ -445,7 +447,11 @@ var LibraryEmbind = {
445447
} else {
446448
throw new TypeError("Unknown boolean type size: " + name);
447449
}
450+
#if MEMORY64
451+
return this['fromWireType'](heap[pointer / (1 << shift)]);
452+
#else
448453
return this['fromWireType'](heap[pointer >> shift]);
454+
#endif
449455
},
450456
destructorFunction: null, // This type does not need a destructor
451457
});

src/library_egl.js

Lines changed: 2 additions & 0 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
/*

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'],
@@ -519,10 +525,10 @@ var LibraryHTML5 = {
519525
if (targetThread) {
520526
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.
521527
fillMouseEventData(mouseEventData, e, target);
522-
JSEvents.queueEventHandlerOnThread_iiii(targetThread, callbackfunc, eventTypeId, mouseEventData, userData);
528+
JSEvents.queueEventHandlerOnThread_iipp(targetThread, callbackfunc, eventTypeId, mouseEventData, userData);
523529
} else
524530
#endif
525-
if ({{{ makeDynCall('iiii', 'callbackfunc') }}}(eventTypeId, JSEvents.mouseEvent, userData)) e.preventDefault();
531+
if ({{{ makeDynCall('iipp', 'callbackfunc') }}}(eventTypeId, JSEvents.mouseEvent, userData)) e.preventDefault();
526532
};
527533

528534
var eventHandler = {
@@ -639,7 +645,7 @@ var LibraryHTML5 = {
639645
if (targetThread) JSEvents.queueEventHandlerOnThread_iiii(targetThread, callbackfunc, eventTypeId, wheelEvent, userData);
640646
else
641647
#endif
642-
if ({{{ makeDynCall('iiii', 'callbackfunc') }}}(eventTypeId, wheelEvent, userData)) e.preventDefault();
648+
if ({{{ makeDynCall('iipp', 'callbackfunc') }}}(eventTypeId, wheelEvent, userData)) e.preventDefault();
643649
};
644650
#if MIN_IE_VERSION <= 8 || MIN_SAFARI_VERSION < 60100 // Browsers that do not support https://caniuse.com/#feat=mdn-api_wheelevent
645651
// The 'mousewheel' event as implemented in Safari 6.0.5
@@ -651,7 +657,7 @@ var LibraryHTML5 = {
651657
{{{ makeSetValue('JSEvents.wheelEvent', C_STRUCTS.EmscriptenWheelEvent.deltaY, 'wheelDeltaY', 'double') }}};
652658
{{{ makeSetValue('JSEvents.wheelEvent', C_STRUCTS.EmscriptenWheelEvent.deltaZ, '0 /* Not available */', 'double') }}};
653659
{{{ makeSetValue('JSEvents.wheelEvent', C_STRUCTS.EmscriptenWheelEvent.deltaMode, '0 /* DOM_DELTA_PIXEL */', 'i32') }}};
654-
var shouldCancel = {{{ makeDynCall('iiii', 'callbackfunc') }}}( eventTypeId, JSEvents.wheelEvent, userData);
660+
var shouldCancel = {{{ makeDynCall('iipp', 'callbackfunc') }}}( eventTypeId, JSEvents.wheelEvent, userData);
655661
if (shouldCancel) {
656662
e.preventDefault();
657663
}

src/library_strings.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ mergeInto(LibraryManager.library, {
157157
#if CAN_ADDRESS_2GB
158158
outIdx >>>= 0;
159159
#endif
160+
#if MEMORY64
161+
outIdx = Number(outIdx);
162+
#endif
160163
#if ASSERTIONS
161164
assert(typeof str === 'string');
162165
#endif

0 commit comments

Comments
 (0)