Skip to content

Commit 2870a0a

Browse files
Revert "Workerized emscripten retroarch (WIP) (#17484)" (#17492)
This reverts commit cacd5a9.
1 parent cacd5a9 commit 2870a0a

File tree

17 files changed

+180
-1199
lines changed

17 files changed

+180
-1199
lines changed

Makefile.common

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1526,10 +1526,7 @@ ifeq ($(HAVE_GL_CONTEXT), 1)
15261526
endif
15271527

15281528
ifeq ($(HAVE_EMSCRIPTEN), 1)
1529-
ifeq ($(HAVE_EGL), 1)
1530-
OBJ += gfx/drivers_context/emscriptenegl_ctx.o
1531-
endif
1532-
OBJ += gfx/drivers_context/emscriptenwebgl_ctx.o
1529+
OBJ += gfx/drivers_context/emscriptenegl_ctx.o
15331530
endif
15341531

15351532
ifeq ($(HAVE_MALI_FBDEV), 1)

Makefile.emscripten

Lines changed: 29 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ HAVE_SCREENSHOTS = 1
2424
HAVE_REWIND = 1
2525
HAVE_AUDIOMIXER = 1
2626
HAVE_CC_RESAMPLER = 1
27-
HAVE_EGL ?= 0
28-
HAVE_OPENGLES = 1
27+
HAVE_EGL = 1
2928
HAVE_RJPEG = 0
3029
HAVE_RPNG = 1
3130
HAVE_EMSCRIPTEN = 1
@@ -49,8 +48,6 @@ HAVE_7ZIP = 1
4948
HAVE_BSV_MOVIE = 1
5049
HAVE_AL = 1
5150
HAVE_CHD ?= 0
52-
HAVE_WASMFS ?= 1
53-
HAVE_WORKER ?= 1
5451

5552
# WARNING -- READ BEFORE ENABLING
5653
# The rwebaudio driver is known to have several audio bugs, such as
@@ -71,7 +68,7 @@ HAVE_OPENGLES3 ?= 0
7168

7269
ASYNC ?= 0
7370
LTO ?= 0
74-
PTHREAD ?= 4
71+
PTHREAD ?= 0
7572

7673
STACK_SIZE ?= 4194304
7774
INITIAL_HEAP ?= 134217728
@@ -95,52 +92,11 @@ _cmd_toggle_menu,_cmd_reload_config,_cmd_toggle_grab_mouse,_cmd_toggle_game_focu
9592
_cmd_set_volume,_cmd_set_shader,_cmd_cheat_set_code,_cmd_cheat_get_code,_cmd_cheat_toggle_index,_cmd_cheat_get_code_state,_cmd_cheat_realloc,\
9693
_cmd_cheat_get_size,_cmd_cheat_apply_cheats
9794

98-
EXPORTS := callMain,FS,PATH,ERRNO_CODES,stringToNewUTF8,UTF8ToString
99-
10095
LIBS := -s USE_ZLIB=1
101-
102-
ifeq ($(HAVE_WASMFS), 1)
103-
LIBS += -s WASMFS -s FORCE_FILESYSTEM=1 -lfetchfs.js -lopfs.js
104-
EXPORTS := $(EXPORTS),FETCHFS,OPFS
105-
endif
106-
107-
ifeq ($(HAVE_WORKER), 1)
108-
LIBS += -s PROXY_TO_PTHREAD -s USE_ES6_IMPORT_META=0 -sENVIRONMENT=worker,web
109-
else
110-
ifeq ($(HAVE_AL), 1)
111-
override ASYNC = 1
112-
endif
113-
endif
114-
115-
ifeq ($(HAVE_OPENGLES), 1)
116-
ifeq ($(HAVE_OPENGLES3), 1)
117-
LDFLAGS += -s FULL_ES3=1 -s MIN_WEBGL_VERSION=2 -s MAX_WEBGL_VERSION=2
118-
else
119-
LDFLAGS += -s FULL_ES2=1
120-
endif
121-
endif
122-
123-
ifeq ($(GL_DEBUG), 1)
124-
LDFLAGS += -s GL_ASSERTIONS=1 -s GL_DEBUG=1
125-
endif
126-
127-
ifeq ($(FS_DEBUG), 1)
128-
LDFLAGS += -s FS_DEBUG=1
129-
endif
130-
131-
ifeq ($(HAVE_SDL2), 1)
132-
LIBS += -s USE_SDL=2
133-
DEFINES += -DHAVE_SDL2
134-
endif
135-
136-
13796
LDFLAGS := -L. --no-heap-copy -s $(LIBS) -s STACK_SIZE=$(STACK_SIZE) -s INITIAL_MEMORY=$(INITIAL_HEAP) \
138-
-s EXPORTED_RUNTIME_METHODS=$(EXPORTS) \
97+
-s EXPORTED_RUNTIME_METHODS=callMain,FS,PATH,ERRNO_CODES,stringToNewUTF8,UTF8ToString \
13998
-s ALLOW_MEMORY_GROWTH=1 -s EXPORTED_FUNCTIONS="$(EXPORTED_FUNCTIONS)" \
14099
-s MODULARIZE=1 -s EXPORT_ES6=1 -s EXPORT_NAME="libretro_$(subst -,_,$(LIBRETRO))" \
141-
-s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=0 \
142-
-s OFFSCREENCANVAS_SUPPORT \
143-
-s OFFSCREEN_FRAMEBUFFER \
144100
--extern-pre-js emscripten/pre.js \
145101
--js-library emscripten/library_rwebcam.js \
146102
--js-library emscripten/library_platform_emscripten.js
@@ -149,29 +105,48 @@ ifeq ($(HAVE_RWEBAUDIO), 1)
149105
LDFLAGS += --js-library emscripten/library_rwebaudio.js
150106
DEFINES += -DHAVE_RWEBAUDIO
151107
endif
152-
153108
ifeq ($(HAVE_AL), 1)
154109
LDFLAGS += -lopenal
155110
DEFINES += -DHAVE_AL
111+
override ASYNC = 1
156112
endif
157113

158114
ifneq ($(PTHREAD), 0)
159-
LDFLAGS += -s WASM_MEM_MAX=1073741824 -pthread -s PTHREAD_POOL_SIZE=$(PTHREAD)
160-
CFLAGS += -pthread -s SHARED_MEMORY
115+
LDFLAGS += -s MAXIMUM_MEMORY=1073741824 -pthread -s PTHREAD_POOL_SIZE=$(PTHREAD)
116+
CFLAGS += -pthread
161117
HAVE_THREADS=1
162118
else
163119
HAVE_THREADS=0
164120
endif
165121

166-
167122
ifeq ($(ASYNC), 1)
168-
DEFINES += -DEMSCRIPTEN_ASYNCIFY
169123
LDFLAGS += -s ASYNCIFY=$(ASYNC) -s ASYNCIFY_STACK_SIZE=8192
170124
ifeq ($(DEBUG), 1)
171125
LDFLAGS += -s ASYNCIFY_DEBUG=1 # -s ASYNCIFY_ADVISE
172126
endif
173127
endif
174128

129+
ifeq ($(HAVE_OPENGLES), 1)
130+
ifeq ($(HAVE_OPENGLES3), 1)
131+
LDFLAGS += -s FULL_ES3=1 -s MIN_WEBGL_VERSION=2 -s MAX_WEBGL_VERSION=2
132+
else
133+
LDFLAGS += -s FULL_ES2=1
134+
endif
135+
endif
136+
137+
ifeq ($(GL_DEBUG), 1)
138+
LDFLAGS += -s GL_ASSERTIONS=1 -s GL_DEBUG=1
139+
endif
140+
141+
ifeq ($(FS_DEBUG), 1)
142+
LDFLAGS += -s FS_DEBUG=1
143+
endif
144+
145+
ifeq ($(HAVE_SDL2), 1)
146+
LIBS += -s USE_SDL=2
147+
DEFINES += -DHAVE_SDL2
148+
endif
149+
175150
include Makefile.common
176151

177152
CFLAGS += $(DEF_FLAGS) -Ideps -Ideps/stb
@@ -208,10 +183,8 @@ RARCH_OBJ := $(addprefix $(OBJDIR)/,$(OBJ))
208183

209184
all: $(TARGET)
210185

211-
$(libretro_new) : $(libretro)
212-
mv -f $(libretro) $(libretro_new)
213-
214-
$(TARGET): $(RARCH_OBJ) $(libretro_new)
186+
$(TARGET): $(RARCH_OBJ) $(libretro)
187+
@$(if $(libretro), mv -f $(libretro) $(libretro_new),)
215188
@$(if $(Q), $(shell echo echo "LD $@ \<obj\> $(libretro_new) $(LIBS) $(LDFLAGS)"),)
216189
$(Q)$(LD) -o $@ $(RARCH_OBJ) $(libretro_new) $(LIBS) $(LDFLAGS)
217190

frontend/drivers/platform_emscripten.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,8 @@ static void frontend_emscripten_get_env(int *argc, char *argv[],
235235
"config", sizeof(g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG]));
236236
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_MENU_CONTENT], user_path,
237237
"content", sizeof(g_defaults.dirs[DEFAULT_DIR_MENU_CONTENT]));
238-
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_ASSETS], base_path,
239-
"downloads", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_ASSETS]));
238+
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_ASSETS], user_path,
239+
"content/downloads", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_ASSETS]));
240240
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_PLAYLIST], user_path,
241241
"playlists", sizeof(g_defaults.dirs[DEFAULT_DIR_PLAYLIST]));
242242
fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_REMAP], g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG],
@@ -308,10 +308,7 @@ int main(int argc, char *argv[])
308308
specialHTMLTargets["!canvas"] = Module.canvas;
309309
});
310310

311-
emscripten_set_canvas_element_size("!canvas", 800, 600);
312-
emscripten_set_element_css_size("!canvas", 800.0, 600.0);
313311
emscripten_set_main_loop(emscripten_mainloop, 0, 0);
314-
emscripten_set_main_loop_timing(EM_TIMING_RAF, 1);
315312
rarch_main(argc, argv, NULL);
316313

317314
return 0;

gfx/drivers_context/emscriptenegl_ctx.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,11 @@ static void gfx_ctx_emscripten_destroy(void *data)
124124

125125
if (!emscripten)
126126
return;
127+
127128
#ifdef HAVE_EGL
128129
egl_destroy(&emscripten->egl);
129130
#endif
131+
130132
free(data);
131133
}
132134

@@ -189,6 +191,7 @@ static void *gfx_ctx_emscripten_init(void *video_driver)
189191
#endif
190192

191193
return emscripten;
194+
192195
error:
193196
gfx_ctx_emscripten_destroy(video_driver);
194197
return NULL;

0 commit comments

Comments
 (0)