Skip to content

Commit

Permalink
opengl support for memory64
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippMuigg committed May 11, 2023
1 parent ae8d76b commit bc1a4fd
Show file tree
Hide file tree
Showing 8 changed files with 266 additions and 164 deletions.
9 changes: 5 additions & 4 deletions emcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2843,10 +2843,11 @@ def get_full_import_name(name):

# check if we can address the 2GB mark and higher: either if we start at
# 2GB, or if we allow growth to either any amount or to 2GB or more.
if settings.INITIAL_MEMORY > 2 * 1024 * 1024 * 1024 or \
(settings.ALLOW_MEMORY_GROWTH and
(settings.MAXIMUM_MEMORY < 0 or
settings.MAXIMUM_MEMORY > 2 * 1024 * 1024 * 1024)):
if settings.MEMORY64 == 0 and \
(settings.INITIAL_MEMORY > 2 * 1024 * 1024 * 1024 or
(settings.ALLOW_MEMORY_GROWTH and
(settings.MAXIMUM_MEMORY < 0 or
settings.MAXIMUM_MEMORY > 2 * 1024 * 1024 * 1024))):
settings.CAN_ADDRESS_2GB = 1

settings.EMSCRIPTEN_VERSION = shared.EMSCRIPTEN_VERSION
Expand Down
6 changes: 6 additions & 0 deletions src/embind/embind.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Emscripten is available under two separate licenses, the MIT license and the
// University of Illinois/NCSA Open Source License. Both these licenses can be
// found in the LICENSE file.
// SPDX-FileCopyrightText: Portions Copyright 2023 Siemens
// Modified on February 2023 by Siemens and/or its affiliates to improve memory64 support

/*global LibraryManager, mergeInto*/

Expand Down Expand Up @@ -445,7 +447,11 @@ var LibraryEmbind = {
} else {
throw new TypeError("Unknown boolean type size: " + name);
}
#if MEMORY64
return this['fromWireType'](heap[pointer / (1 << shift)]);
#else
return this['fromWireType'](heap[pointer >> shift]);
#endif
},
destructorFunction: null, // This type does not need a destructor
});
Expand Down
2 changes: 2 additions & 0 deletions src/library_egl.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
* @license
* Copyright 2012 The Emscripten Authors
* SPDX-License-Identifier: MIT
* SPDX-FileCopyrightText: Portions Copyright 2023 Siemens
* Modified on February 2023 by Siemens and/or its affiliates to improve memory64 support
*/

/*
Expand Down
14 changes: 10 additions & 4 deletions src/library_html5.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
* @license
* Copyright 2014 The Emscripten Authors
* SPDX-License-Identifier: MIT
* SPDX-FileCopyrightText: Portions Copyright 2023 Siemens
* Modified on February 2023 by Siemens and/or its affiliates to improve memory64 support
*/

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

$findEventTarget__deps: ['$maybeCStringToJsString', '$specialHTMLTargets'],
Expand Down Expand Up @@ -519,10 +525,10 @@ var LibraryHTML5 = {
if (targetThread) {
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.
fillMouseEventData(mouseEventData, e, target);
JSEvents.queueEventHandlerOnThread_iiii(targetThread, callbackfunc, eventTypeId, mouseEventData, userData);
JSEvents.queueEventHandlerOnThread_iipp(targetThread, callbackfunc, eventTypeId, mouseEventData, userData);
} else
#endif
if ({{{ makeDynCall('iiii', 'callbackfunc') }}}(eventTypeId, JSEvents.mouseEvent, userData)) e.preventDefault();
if ({{{ makeDynCall('iipp', 'callbackfunc') }}}(eventTypeId, JSEvents.mouseEvent, userData)) e.preventDefault();
};

var eventHandler = {
Expand Down Expand Up @@ -639,7 +645,7 @@ var LibraryHTML5 = {
if (targetThread) JSEvents.queueEventHandlerOnThread_iiii(targetThread, callbackfunc, eventTypeId, wheelEvent, userData);
else
#endif
if ({{{ makeDynCall('iiii', 'callbackfunc') }}}(eventTypeId, wheelEvent, userData)) e.preventDefault();
if ({{{ makeDynCall('iipp', 'callbackfunc') }}}(eventTypeId, wheelEvent, userData)) e.preventDefault();
};
#if MIN_IE_VERSION <= 8 || MIN_SAFARI_VERSION < 60100 // Browsers that do not support https://caniuse.com/#feat=mdn-api_wheelevent
// The 'mousewheel' event as implemented in Safari 6.0.5
Expand All @@ -651,7 +657,7 @@ var LibraryHTML5 = {
{{{ makeSetValue('JSEvents.wheelEvent', C_STRUCTS.EmscriptenWheelEvent.deltaY, 'wheelDeltaY', 'double') }}};
{{{ makeSetValue('JSEvents.wheelEvent', C_STRUCTS.EmscriptenWheelEvent.deltaZ, '0 /* Not available */', 'double') }}};
{{{ makeSetValue('JSEvents.wheelEvent', C_STRUCTS.EmscriptenWheelEvent.deltaMode, '0 /* DOM_DELTA_PIXEL */', 'i32') }}};
var shouldCancel = {{{ makeDynCall('iiii', 'callbackfunc') }}}( eventTypeId, JSEvents.wheelEvent, userData);
var shouldCancel = {{{ makeDynCall('iipp', 'callbackfunc') }}}( eventTypeId, JSEvents.wheelEvent, userData);
if (shouldCancel) {
e.preventDefault();
}
Expand Down
3 changes: 3 additions & 0 deletions src/library_strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ mergeInto(LibraryManager.library, {
#if CAN_ADDRESS_2GB
outIdx >>>= 0;
#endif
#if MEMORY64
outIdx = Number(outIdx);
#endif
#if ASSERTIONS
assert(typeof str === 'string');
#endif
Expand Down
Loading

0 comments on commit bc1a4fd

Please sign in to comment.