Commit Graph

173 Commits

Author SHA1 Message Date
Joe Osborn f2a86f34d1
Remove unnecessary rigmarole around importing the script as a blob (#17642) 2025-03-01 17:34:05 -08:00
Joe Osborn c413bcc626
Threaded emscripten fixes (#17614)
* Actually read CLI args in emscripten

* Fix fetchfs manifest parsing, increase download chunk size

The chunk size should probably be made a parameter in the future.  The
larger chunk size trades longer hitches for fewer hitches.

* Add exec command driver and API functions for emscripten.

Under WASMFS, stdin/stdout can't be customized the way they can with
the JS FS implementation.  Also, this approach frees up stdin/stdout
and simplifies interaction with the command interface for web embedders.

* fixup upload paths, show use of new emscripten cmd interface

* Add JS library function names to EXPORTS as well as EXPORTED_FUNCTIONS for older emsdk versions
2025-02-24 09:25:05 -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
Ethan O'Brien ec54cdfcf0
Add HAVE_CHD flag for emscripten makefile (#17423) 2025-01-17 19:55:02 +01:00
Joe Osborn 499e12c655
replace dashes with underscores in core names (#15910) 2023-11-15 13:18:41 -08:00
Joe Osborn 936ff84204
Prefix core name with libretro_ for exports so that cores like 81, 2048 don't cause errors (#15908) 2023-11-15 02:08:12 -08: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
Joe Osborn f4ed975d44
Force async emscripten when HAVE_AL (#15559) 2023-08-07 01:20:59 +02:00
Ethan O'Brien e5c0ab17e4 Make openal default audio driver 2023-07-14 21:24:15 +02:00
Joe Osborn 807640fed3
Associate states with replays (#15070)
* change bsv file suffix to replay, update strings

* add trivial RPLY block to save states

* WIP rerecording support, doesn't load states properly yet--issue with checking identifiers?

* Fixed a type error to get time identifiers working right, ready for testing

* handle case where state without replay data is loaded during replay

* cleanups

* whitespace cleanup

* Cleanups, change replay file format magic, fix logic around future states

* Remove failed future message

* Add play-replay-from-slot command, fix load-state-from-slot to use given slot

* build fixes

* Fix race conditions in emscripten build and incorrect replay state incrementing

* Style fix for single line if

---------

Co-authored-by: Joseph C. Osborn <jcoa2018@pomona.edu>
2023-03-08 00:10:59 +01:00
Joe Osborn a1903eee15
Emscripten pthread tweaks (#15033)
* add more documentation to emscripten, pthread support, and flag to not show asset warnings

* typo in docs

---------

Co-authored-by: thelamer <ryankuba@gmail.com>
2023-02-27 19:56:12 +01:00
Joe Osborn e1afca5392
add command and stdin_cmd features to emscripten RA. update libretro.js to show how commands could be sent over emscripten stdin. (#15017)
Co-authored-by: Joseph C. Osborn <jcoa2018@pomona.edu>
2023-02-24 22:06:04 +01:00
libretroadmin 51d238875e Get rid of obsolete HAVE_VIDEO_LAYOUT - obsolete spec, was only
ever implemented for OpenGL2 driver, lots of code debt, best to
instead just keep improving the overlay system instead which is
already available for most video drivers
2023-02-23 21:03:41 +01:00
Joe Osborn 951f5a76a5
Add bsv to emscripten builds (#14905)
* Add bsv to emscripten builds

BSV has no external dependencies so this addition should be fine.

Co-authored-by: Joseph C. Osborn <jcoa2018@pomona.edu>
2023-01-26 05:46:39 +01:00
libretroadmin 3277d7b8fa (Emscripten) Add HAVE_PATCH support for Emscripten
(Patch) if HAVE_PATCH is not defined, silence warnings
2023-01-07 05:15:36 +01:00
LibretroAdmin 879674d4c3 Had to update Makefile.emscripten too 2022-08-05 23:51:34 +02:00
Vladimir Serbinenko 80cf91417c
Enable 7zip on emscripten (#13533)
This makes it more in-line with other static platforms
2022-02-01 13:53:03 +01:00
twinaphex 28cac5c5a4 Add HAVE_CORE_INFO_CACHE - disable this for Steam build 2021-10-14 15:57:28 +02:00
jdgleaver ddef98fe11 (Emscripten) Makefile.emscripten: Allow linker 'TOTAL_MEMORY' value to be set via command line 2021-01-08 14:52:52 +00:00
jdgleaver be1c7b8e4c (.gitlab-ci.yml) Add Emscripten target 2021-01-06 14:42:06 +00:00
SimpleTease 8017ecd2b8 ibxm: update to 20191214
- Fix music playback (sample skipping)
- Add more platforms
- Fix Mr. Boom music
2020-11-21 20:30:19 +00:00
twinaphex 47e22d69bf Add HAVE_VIDEO_FILTER 2020-07-02 06:28:14 +02:00
twinaphex 3ee788def2 Add HAVE_DSP_FILTER 2020-07-02 02:13:04 +02:00
twinaphex 87b9c2a367 Add HAVE_REWIND switch 2020-07-01 21:04:05 +02:00
twinaphex 7862166ed2 Add back HAVE_SCREENSHOTS define from SSNES days 2020-07-01 17:47:13 +02:00
twinaphex 223d76680a Add HAVE_CHEATS ifdef 2020-06-30 19:35:55 +02:00
twinaphex 7c7d0f596a HAVE_MENU_WIDGETS now decoupled from HAVE_MENU 2020-02-17 21:28:42 +01:00
twinaphex e0fdd8d39e Add back HAVE_CONFIGFILE ifdef - will strip out remaps and overrides
support as well
2020-02-02 21:27:38 +01:00
Toad King 776568a429 fix images not loading in menu in emscripten
add changes to work with latest emscripten SDK
2020-01-02 21:29:25 -06:00
Toad King 15e8be4074 changes to support upgraded emscripten SDK 2019-12-14 20:24:41 -06:00
Toad King 618da66073 emscripten: add hack to prevent ERRNO_CODES from being optimized away 2019-08-07 22:07:09 -05:00
Toad King 2874c5ee6e emscripten: Fix GLSL not being built in
fix gamepad builds to work with newer emscripten
2019-08-06 20:51:18 -05:00
orbea 63a92a3f78 Update the zlib include directory paths. 2019-07-25 11:18:33 -07:00
orbea 84f4dcba2b Remove WANT_ZLIB. 2019-07-25 11:18:33 -07:00
twinaphex b2bf822f13 Add HAVE_AUDIOMIXER switch 2019-07-11 11:51:06 +02:00
twinaphex 7ee8a4de3e (Emscripten) Try to use builtin zlib 2019-05-28 15:32:26 +02:00
twinaphex 22d762be67 We need to split up zlib headers in libretro-common to its own separate
dir
2019-05-27 03:40:14 +02:00
twinaphex ebaa5b9941 Undefine HAVE_VIDEO_LAYOUT for now instead of implicitly enabling
it for every platform - will have to be individually enabled for
each platform first after rigorous testing
2019-05-13 01:57:26 +02:00
Huw Pascoe 7e0592198d video_layout build 2019-05-11 09:58:46 +01:00
twinaphex b9cdeebf35 Make menu widgets the new default 2019-05-03 15:55:44 +02:00
orbea 65c6caf5a6 qb: Add '--disable-menu'. (#7910)
This adds '--disable-menu' which will disable all of the menu drivers
including Qt. This will also allow disabling only rgui and not the other
menu drivers.
2019-01-06 17:30:50 -05:00
orbea fb6fe1a87c Makefile: Better respect CFLAGS and CXXFLAGS as environment variables.
This fixes a few subtle problems with passing CFLAGS and CXXFLAGS as
environment variables for configure.

First it will now only add these variables to config.mk when they are
actually set. If they are unset then the default optimizations in the
Makefile are set. This avoids passing more than one conflicting
optimization level to the compiler.

Next all CFLAGS are added to CXXFLAGS to avoid issues with forgetting to
set both CFLAGS and CXXFLAGS. This results in the cxx compiler getting
passed several redundant optimization levels when both the CFLAGS and
CXXFLAGS environment variabls are used. Now these uses of CFLAGS in
Makefile.common are set to DEF_FLAGS. This allows adding $(DEF_FLAGS)
to the CXXFLAGS variable without adding redundant flags from CFLAGS.

v2: Update other build files.
2018-12-30 17:17:19 -08:00
radius 3c8264e9f2 use stb font in emscripten (untested) 2018-09-30 17:41:24 -05:00
twinaphex ca9dd89975 Revert "(3DS/Emscripten/Vita/Wiiu) Add HAVE_CHD support"
This reverts commit d4c691527a.
2018-04-22 12:02:40 +02:00
twinaphex d4c691527a (3DS/Emscripten/Vita/Wiiu) Add HAVE_CHD support 2018-04-22 11:58:11 +02:00
Toad King a634994809 no longer compile with SDL support by default 2018-01-18 22:57:46 -06:00
Toad King 99472beeb6 more build modifications to emscripten (needed for mupen64 to work) 2018-01-15 21:02:01 -06:00