Commit Graph

104 Commits

Author SHA1 Message Date
BinBashBanana 2d3c18e48d Emscripten improvements pt. 4 2025-05-08 11:01:43 -07:00
BinBashBanana 05cefc9a4d AudioWorklet driver, misc. emscripten fixes 2025-03-28 19:41:40 -07:00
BinBashBanana f6eb1ed5c5 Threaded emscripten improvements 2025-03-05 10:39:43 -08:00
Joe Osborn 56014a27d6
Enable pthreads on Emscripten (#17586)
* workerized RA

* Workerized (non-async) web player, using OPFS

This patch eliminates the need for asyncify and uses modern filesystem
APIs instead of the deprecated, unmaintained BrowserFS.

This is a WIP patch because it won't fully work until these two
Emscripten PRs land and are released:

https://github.com/emscripten-core/emscripten/pull/23518
https://github.com/emscripten-core/emscripten/pull/23021

The former fixes an offscreen canvas context recreation bug, and the
latter adds an equivalent to BrowserFS's XHR filesystem (but without
the hazardous running-XHR-on-the-main-thread problem).

The biggest issue is that local storage of users who were using the
old version of the webplayer will be gone when they switch to the new
webplayer.  I don't have a good story for converting the old BrowserFS
IDBFS contents into the new OPFS filesystem (the move is worth doing
because OPFS supports seeking and reading only bits of a file, and
because BrowserFS is dead).

I've kept around the old libretro webplayer under
pkg/emscripten/libretro-classic, and with these make flags you can
build a non-workerized RA that uses asyncify to sleep as before:

make -f Makefile.emscripten libretro=$CORE HAVE_WORKER=0 HAVE_WASMFS=0 PTHREAD=0 HAVE_AL=1

I also moved the default directory for core content on emscripten to
not be a subdirectory of the local filesystem mount, because it's
confusing to have a subdirectory that's lazily fetched and not
mirrored to the local storage.  I think it won't impact existing users
of the classic web player because they already have a retroarch.cfg in
place.

* Get fetchfs working without manifest support

* makefile fixes

* fix scaling, remove zip dependency

* Support asset/cheats/etc downloaders for emscripten

- Add http transfer support for emscripten
  - At the task_http level, not the net_http level --- so no netplay
    or webdav.
- Change default paths to be more like other platforms
- Gives us smaller bundles and a faster boot time
- Had to work around a task queue bug on Emscripten
  - I made the smallest possible change to do it, but it may be better
    to fix in rthread.c

* Load an emscripten file_packager package on first run

If no ozone assets are present, load a libretro_minimal package
created using Emscripten's built-in file packager.

* updated readme, removed indexer from wasmfs libretro-web

* Put back zip dependency, load asset bundle into opfs on first run

* fix upload path

* Remove unused function

* easy testing setup for two multithreaded conditions

1. make PROXY_TO_PTHREAD=1 (slower)
2. make PROXY_TO_PTHREAD=0 (bad audio, because doesn't sleep in
openal.c)

* Remove condition on sleep in openal

also make input_driver check existence of drv->axis, drv->button
before calling them.

* Fix resizing under EGL

* Don't force config file path on emscripten

* Add time.h include to netplay, default HAVE_NETPLAYDISCOVERY to 0

* Remove nearly all proxied joypad calls under emscripten

* Fix file uploads under firefox

* Fix safari API uses, but Safari still hangs in OPFS filesystem mount

I think this can be fixed by moving the backend creation off the main
thread.

* Move filesystem init into emscripten C entry point

* Setup filesystems off of main thread

* re-set default player to async

Also improve Safari compatibility under proxy-to-pthread condition

* Safari upload file fixes

* Remove some excess prints

* Fix typo
2025-02-20 00:59:25 +01:00
LibretroAdmin 2870a0a8ad
Revert "Workerized emscripten retroarch (WIP) (#17484)" (#17492)
This reverts commit cacd5a9a23.
2025-01-30 21:35:58 +01:00
Joe Osborn cacd5a9a23
Workerized emscripten retroarch (WIP) (#17484)
* workerized RA

* Workerized (non-async) web player, using OPFS

This patch eliminates the need for asyncify and uses modern filesystem
APIs instead of the deprecated, unmaintained BrowserFS.

This is a WIP patch because it won't fully work until these two
Emscripten PRs land and are released:

https://github.com/emscripten-core/emscripten/pull/23518
https://github.com/emscripten-core/emscripten/pull/23021

The former fixes an offscreen canvas context recreation bug, and the
latter adds an equivalent to BrowserFS's XHR filesystem (but without
the hazardous running-XHR-on-the-main-thread problem).

The biggest issue is that local storage of users who were using the
old version of the webplayer will be gone when they switch to the new
webplayer.  I don't have a good story for converting the old BrowserFS
IDBFS contents into the new OPFS filesystem (the move is worth doing
because OPFS supports seeking and reading only bits of a file, and
because BrowserFS is dead).

I've kept around the old libretro webplayer under
pkg/emscripten/libretro-classic, and with these make flags you can
build a non-workerized RA that uses asyncify to sleep as before:

make -f Makefile.emscripten libretro=$CORE HAVE_WORKER=0 HAVE_WASMFS=0 PTHREAD=0 HAVE_AL=1

I also moved the default directory for core content on emscripten to
not be a subdirectory of the local filesystem mount, because it's
confusing to have a subdirectory that's lazily fetched and not
mirrored to the local storage.  I think it won't impact existing users
of the classic web player because they already have a retroarch.cfg in
place.

* Get fetchfs working without manifest support

* makefile fixes
2025-01-30 19:58:18 +01:00
BinBashBanana ed1810de86
Emscripten improvements (#17422) 2025-01-29 05:29:16 +01:00
Joe Osborn 862bebf687
(Emscripten) Modularize the JavaScript and clean up the web build (#15688)
* Increase emscripten stack size and decrease path size to fix emscripten builds broken since de45fc2

* use modularize flags for better-behaved javascript output

* makefile and loader changes

* use specialHTMLTargets to support modular access to canvas

* bind key events to canvas, not document

This way focus means focus and we can have multiple RA instances in
one page.

* Work around an emscripten bug in strict mode

* (Emscripten) Use console.error() for error messages

* increase asyncify stack size

* Fix `-lm` flag-related compile warnings in emscripten

---------

Co-authored-by: Rob Loach <robloach@gmail.com>
2023-11-02 13:25:50 -07:00
libretroadmin f96ff71416 (video context drivers) Cleanups 2023-02-21 09:49:46 +01:00
twinaphex 4b5951bda3 Rename gl_common.h to gl2_common.h and remove some file dependencies
on it
2021-09-26 17:42:12 +02:00
twinaphex 5f08605680 Refactor joypad drivers 2020-08-30 05:29:32 +02:00
twinaphex 465e84d60c (context drivers) Make names uniform 2020-07-20 18:22:33 +02:00
twinaphex 34662e8fe8 (Context drivers) Cleanups - use egl_get_proc_address directly instead
of wrapper functions
2020-07-18 17:22:24 +02:00
twinaphex 5deb8f8bd8 Cleanups 2020-07-17 14:59:19 +02:00
twinaphex 707b40d116 Cleanups 2020-07-17 01:09:00 +02:00
twinaphex 0d543baa4b (Drivers context) Move more static global state to structs 2020-03-07 18:21:49 +01:00
twinaphex 4598f186a8 Get rid of video_frame_info dependency 2020-03-07 00:39:06 +01:00
twinaphex 4d7b627421 Get rid of video_info dependency for set_video_mode 2020-03-06 22:58:12 +01:00
twinaphex e20151a048 Get rid of video_info struct for swap_buffers too 2020-03-06 22:29:51 +01:00
twinaphex 4aae293e3d Remove is_shutdown from check_window 2020-03-06 20:29:31 +01:00
twinaphex fa7859ad13 (Gfx drivers context) Cleanup EGL calls 2020-01-06 18:27:18 +01:00
twinaphex 53dbd69751 (EGL) Create egl_bind_api 2020-01-04 15:09:42 +01:00
twinaphex 65b4c2595e Update set keyboard mapping code for input driver 2019-07-27 02:21:24 +02:00
twinaphex 453cc3dcbd (video context driver) has_Windowed can be degraded to a simple
boolean variable
2019-07-26 06:23:20 +02:00
twinaphex ee3208ac39 Integrate video_driver.c into retroarch.c 2019-06-17 15:10:22 +02:00
twinaphex b347b26d61 Reimplement shader flags being set - GL core should have only
Slang support and no GLSL, with the GL2 driver it is dependent
on the context driver
2019-03-13 14:06:50 +01:00
twinaphex 62bea6ad11 SOme header cleanups 2019-02-02 22:02:24 +01:00
orbea bfc366decc Squeeze extra blank lines with cat(1).
Example:

find . -type f -iname '*.c' | while read -r i; do
  cat -s "$i" > "$i.new"
  mv "$i.new" "$i"
done
2019-01-08 11:04:58 -08:00
Themaister 868465ad01 EGL: Add callback to select EGLConfig.
A more robust fix for DRM/GBM shenanigans.
2018-12-11 20:12:25 +01:00
twinaphex 4738ef545c Change interval type to signed int 2018-09-12 00:08:13 +02:00
Brandon Wright 533f898132 Add get refresh rate context function. Implement for X11 and Wayland. 2018-04-15 17:56:12 -05:00
twinaphex 16c1bd7a03 Create context get_api function 2018-03-01 21:16:54 +01:00
twinaphex 6f73bdf287 (Emscripten) Cleanups 2018-01-20 02:05:37 +01:00
Toad King 19facdb066 reset drivers shortly after toggling fullscreen mode
fixes black screen after going fullscreen in game
2018-01-15 02:12:53 -06:00
Toad King b75f4b4f67 implement setting vsync and swapinterval
vsync is not "true" vsync (that's always on in browsers) but changes the main loop timer from immediate to window.requestAnimationFrame
2018-01-14 23:29:20 -06:00
Toad King 60f203d344 fix emscripten build 2018-01-14 16:03:44 -06:00
Toad King c8f03b4640 fix fullscreen sometimes losing state 2018-01-14 15:19:37 -06:00
Toad King 5ef595be1a fix fullscreen 2018-01-14 02:33:22 -06:00
Toad King 77b158e6a2 fix compiler warning 2018-01-13 20:47:30 -06:00
Toad King a77f9c37c6 start on bringing the emscripten video code up to speed with latest emscripten
fix rwebinput
2018-01-13 00:05:07 -06:00
twinaphex b0398c1482 C89 build fixes 2017-05-19 03:34:53 +02:00
twinaphex f928e57064 Combine video_context_driver.c and video_driver.c 2017-05-09 01:25:59 +02:00
Kyle Brenneman fcccc9dc0b Use eglGetPlatformDisplay when it's available.
Added a platform parameter to egl_init_context. If the caller provides a
platform other than EGL_NONE, then it will try to use eglGetPlatformDisplay or
eglGetPlatformDisplayEXT instead of eglGetDisplay.

If neither eglGetPlatformDisplay or eglGetPlatformDisplayEXT is supported, then
it will still fall back to calling eglGetDisplay.

Updated the Wayland, X11, and DRM callers to use the correct platform enum.
Those are the callers that don't just pass EGL_DEFAULT_DISPLAY as the native
display handle.

Calling eglGetDisplay with any value other than EGL_DEFAULT_DISPLAY is
inherently unreliable, because it requires the EGL implementation to guess a
platform type based on a (void *) pointer. Some implementations might not
identify a particular platform, or worse, might guess wrong.

Fixes https://github.com/libretro/RetroArch/issues/4790
2017-04-16 14:19:40 -06:00
twinaphex 6247d6ea1d Update check_window - we no longer need runloop.h inside context driver 2017-01-23 01:02:33 +01:00
twinaphex 4ea31e99aa Remove some header includes 2017-01-23 00:39:20 +01:00
twinaphex 1ea3bea0ee Don't pass video_info by value to context_driver init function 2017-01-22 18:29:22 +01:00
twinaphex 96c8ca5a09 Header update #1 2017-01-22 13:40:32 +01:00
twinaphex 9d1de5c974 Rewrite video_context_driver_set_resize 2017-01-19 14:31:57 +01:00
twinaphex b96e0bb820 Remove stub update_title functions 2017-01-19 01:58:44 +01:00
twinaphex 34da27c36b Don't need 'frame_count' variable for check_window 2017-01-18 21:47:12 +01:00