Skip to content

Commit 3ca1335

Browse files
committed
Use regular signatures and proxying for glWaitSync/glClientWaitSync
I can't see why this was done this way in the first place? The `PARAM_I64` support existed back in cdf7bc5 when proxying was first added. Perhaps it was just that the `EM_FUNC_SIG_XX` macros were harder write before `I64` was replaced with `J` in #20678? Fixes: #25932
1 parent ffb1e90 commit 3ca1335

File tree

4 files changed

+14
-20
lines changed

4 files changed

+14
-20
lines changed

system/include/emscripten/threading_legacy.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ typedef struct em_queued_call em_queued_call;
113113
#define EM_FUNC_SIG_I (EM_FUNC_SIG_RETURN_VALUE_I | EM_FUNC_SIG_WITH_N_PARAMETERS(0))
114114
#define EM_FUNC_SIG_II (EM_FUNC_SIG_RETURN_VALUE_I | EM_FUNC_SIG_WITH_N_PARAMETERS(1) | EM_FUNC_SIG_SET_PARAM(0, EM_FUNC_SIG_PARAM_I))
115115
#define EM_FUNC_SIG_III (EM_FUNC_SIG_RETURN_VALUE_I | EM_FUNC_SIG_WITH_N_PARAMETERS(2) | EM_FUNC_SIG_SET_PARAM(0, EM_FUNC_SIG_PARAM_I) | EM_FUNC_SIG_SET_PARAM(1, EM_FUNC_SIG_PARAM_I))
116+
#define EM_FUNC_SIG_IIIJ (EM_FUNC_SIG_RETURN_VALUE_I | EM_FUNC_SIG_WITH_N_PARAMETERS(3) | EM_FUNC_SIG_SET_PARAM(0, EM_FUNC_SIG_PARAM_I) | EM_FUNC_SIG_SET_PARAM(1, EM_FUNC_SIG_PARAM_I) | EM_FUNC_SIG_SET_PARAM(2, EM_FUNC_SIG_PARAM_J))
116117
#define EM_FUNC_SIG_IIII (EM_FUNC_SIG_RETURN_VALUE_I | EM_FUNC_SIG_WITH_N_PARAMETERS(3) | EM_FUNC_SIG_SET_PARAM(0, EM_FUNC_SIG_PARAM_I) | EM_FUNC_SIG_SET_PARAM(1, EM_FUNC_SIG_PARAM_I) | EM_FUNC_SIG_SET_PARAM(2, EM_FUNC_SIG_PARAM_I))
117118
#define EM_FUNC_SIG_IIPP (EM_FUNC_SIG_RETURN_VALUE_I | EM_FUNC_SIG_WITH_N_PARAMETERS(3) | EM_FUNC_SIG_SET_PARAM(0, EM_FUNC_SIG_PARAM_I) | EM_FUNC_SIG_SET_PARAM(1, EM_FUNC_SIG_PARAM_P) | EM_FUNC_SIG_SET_PARAM(2, EM_FUNC_SIG_PARAM_P))
118119
#define EM_FUNC_SIG_IIIII (EM_FUNC_SIG_RETURN_VALUE_I | EM_FUNC_SIG_WITH_N_PARAMETERS(4) | EM_FUNC_SIG_SET_PARAM(0, EM_FUNC_SIG_PARAM_I) | EM_FUNC_SIG_SET_PARAM(1, EM_FUNC_SIG_PARAM_I) | EM_FUNC_SIG_SET_PARAM(2, EM_FUNC_SIG_PARAM_I) | EM_FUNC_SIG_SET_PARAM(3, EM_FUNC_SIG_PARAM_I))
@@ -128,6 +129,7 @@ typedef struct em_queued_call em_queued_call;
128129
#define EM_FUNC_SIG_PII (EM_FUNC_SIG_RETURN_VALUE_P | EM_FUNC_SIG_WITH_N_PARAMETERS(2) | EM_FUNC_SIG_SET_PARAM(0, EM_FUNC_SIG_PARAM_I) | EM_FUNC_SIG_SET_PARAM(1, EM_FUNC_SIG_PARAM_I))
129130
#define EM_FUNC_SIG_PIIII (EM_FUNC_SIG_RETURN_VALUE_P | EM_FUNC_SIG_WITH_N_PARAMETERS(4) | EM_FUNC_SIG_SET_PARAM(0, EM_FUNC_SIG_PARAM_I) | EM_FUNC_SIG_SET_PARAM(1, EM_FUNC_SIG_PARAM_I) | EM_FUNC_SIG_SET_PARAM(2, EM_FUNC_SIG_PARAM_I) | EM_FUNC_SIG_SET_PARAM(3, EM_FUNC_SIG_PARAM_I))
130131
#define EM_FUNC_SIG_VIIP (EM_FUNC_SIG_RETURN_VALUE_V | EM_FUNC_SIG_WITH_N_PARAMETERS(3) | EM_FUNC_SIG_SET_PARAM(0, EM_FUNC_SIG_PARAM_I) | EM_FUNC_SIG_SET_PARAM(1, EM_FUNC_SIG_PARAM_I) | EM_FUNC_SIG_SET_PARAM(2, EM_FUNC_SIG_PARAM_P))
132+
#define EM_FUNC_SIG_VIIJ (EM_FUNC_SIG_RETURN_VALUE_V | EM_FUNC_SIG_WITH_N_PARAMETERS(3) | EM_FUNC_SIG_SET_PARAM(0, EM_FUNC_SIG_PARAM_I) | EM_FUNC_SIG_SET_PARAM(1, EM_FUNC_SIG_PARAM_I) | EM_FUNC_SIG_SET_PARAM(2, EM_FUNC_SIG_PARAM_J))
131133
#define EM_FUNC_SIG_VIPI (EM_FUNC_SIG_RETURN_VALUE_V | EM_FUNC_SIG_WITH_N_PARAMETERS(3) | EM_FUNC_SIG_SET_PARAM(0, EM_FUNC_SIG_PARAM_I) | EM_FUNC_SIG_SET_PARAM(1, EM_FUNC_SIG_PARAM_P) | EM_FUNC_SIG_SET_PARAM(2, EM_FUNC_SIG_PARAM_I))
132134
#define EM_FUNC_SIG_VIP (EM_FUNC_SIG_RETURN_VALUE_V | EM_FUNC_SIG_WITH_N_PARAMETERS(2) | EM_FUNC_SIG_SET_PARAM(0, EM_FUNC_SIG_PARAM_I) | EM_FUNC_SIG_SET_PARAM(1, EM_FUNC_SIG_PARAM_P))
133135
#define EM_FUNC_SIG_IIP (EM_FUNC_SIG_RETURN_VALUE_I | EM_FUNC_SIG_WITH_N_PARAMETERS(2) | EM_FUNC_SIG_SET_PARAM(0, EM_FUNC_SIG_PARAM_I) | EM_FUNC_SIG_SET_PARAM(1, EM_FUNC_SIG_PARAM_P))

system/include/webgl/webgl2.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ WEBGL_APICALL void GL_APIENTRY emscripten_glDrawElementsInstanced (GLenum mode,
7777
WEBGL_APICALL GLsync GL_APIENTRY emscripten_glFenceSync (GLenum condition, GLbitfield flags);
7878
WEBGL_APICALL GLboolean GL_APIENTRY emscripten_glIsSync (GLsync sync);
7979
WEBGL_APICALL void GL_APIENTRY emscripten_glDeleteSync (GLsync sync);
80-
WEBGL_APICALL GLenum GL_APIENTRY emscripten_glClientWaitSync (GLsync sync, GLbitfield flags, GLuint timeoutLo, GLuint timeoutHi);
81-
WEBGL_APICALL void GL_APIENTRY emscripten_glWaitSync (GLsync sync, GLbitfield flags, GLuint timeoutLo, GLuint timeoutHi);
80+
WEBGL_APICALL GLenum GL_APIENTRY emscripten_glClientWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout);
81+
WEBGL_APICALL void GL_APIENTRY emscripten_glWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout);
8282
WEBGL_APICALL void GL_APIENTRY emscripten_glGetInteger64v (GLenum pname, GLint64 *data);
8383
WEBGL_APICALL void GL_APIENTRY emscripten_glGetSynciv (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values);
8484
WEBGL_APICALL void GL_APIENTRY emscripten_glGetInteger64i_v (GLenum target, GLuint index, GLint64 *data);

system/lib/gl/webgl2.c

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -95,20 +95,8 @@ ASYNC_GL_FUNCTION_5(EM_FUNC_SIG_VIIIII, void, glDrawElementsInstanced, GLenum, G
9595
RET_PTR_SYNC_GL_FUNCTION_2(EM_FUNC_SIG_PII, GLsync, glFenceSync, GLenum, GLbitfield);
9696
RET_SYNC_GL_FUNCTION_1(EM_FUNC_SIG_II, GLboolean, glIsSync, GLsync);
9797
ASYNC_GL_FUNCTION_1(EM_FUNC_SIG_VI, void, glDeleteSync, GLsync);
98-
GLenum glClientWaitSync(GLsync p0, GLbitfield p1, GLuint64 p2) {
99-
GL_FUNCTION_TRACE();
100-
if (pthread_getspecific(currentThreadOwnsItsWebGLContext))
101-
return emscripten_glClientWaitSync(p0, p1, p2 & 0xFFFFFFFF, (p2 >> 32) & 0xFFFFFFFF);
102-
else
103-
return (GLenum)emscripten_sync_run_in_main_runtime_thread(EM_FUNC_SIG_IIIII, &emscripten_glClientWaitSync, p0, p1, p2 & 0xFFFFFFFF, (p2 >> 32) & 0xFFFFFFFF);
104-
}
105-
void glWaitSync(GLsync p0, GLbitfield p1, GLuint64 p2) {
106-
GL_FUNCTION_TRACE();
107-
if (pthread_getspecific(currentThreadOwnsItsWebGLContext))
108-
emscripten_glWaitSync(p0, p1, p2 & 0xFFFFFFFF, (p2 >> 32) & 0xFFFFFFFF);
109-
else
110-
emscripten_sync_run_in_main_runtime_thread(EM_FUNC_SIG_VIIII, &emscripten_glWaitSync, p0, p1, p2 & 0xFFFFFFFF, (p2 >> 32) & 0xFFFFFFFF);
111-
}
98+
RET_SYNC_GL_FUNCTION_3(EM_FUNC_SIG_IIIJ, GLenum, glClientWaitSync, GLsync, GLbitfield, GLuint64);
99+
VOID_SYNC_GL_FUNCTION_3(EM_FUNC_SIG_VIIJ, void, glWaitSync, GLsync, GLbitfield, GLuint64);
112100
VOID_SYNC_GL_FUNCTION_2(EM_FUNC_SIG_VII, void, glGetInteger64v, GLenum, GLint64 *);
113101
VOID_SYNC_GL_FUNCTION_5(EM_FUNC_SIG_VIIIII, void, glGetSynciv, GLsync, GLenum, GLsizei, GLsizei *, GLint *);
114102
VOID_SYNC_GL_FUNCTION_3(EM_FUNC_SIG_VIII, void, glGetInteger64i_v, GLenum, GLuint, GLint64 *);

system/lib/pthread/proxying_legacy.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ typedef void (*em_func_vii)(int, int);
5858
typedef void (*em_func_vif)(int, float);
5959
typedef void (*em_func_vff)(float, float);
6060
typedef void (*em_func_viii)(int, int, int);
61+
typedef void (*em_func_viij)(int, int, uint64_t);
6162
typedef void (*em_func_viif)(int, int, float);
6263
typedef void (*em_func_viff)(int, float, float);
6364
typedef void (*em_func_vfff)(float, float, float);
@@ -76,6 +77,7 @@ typedef void (*em_func_viiiiiiiiiii)(int, int, int, int, int, int, int, int, int
7677
typedef int (*em_func_i)(void);
7778
typedef int (*em_func_ii)(int);
7879
typedef int (*em_func_iii)(int, int);
80+
typedef int (*em_func_iiij)(int, int, uint64_t);
7981
typedef int (*em_func_iiii)(int, int, int);
8082
typedef int (*em_func_iiiii)(int, int, int, int);
8183
typedef int (*em_func_iiiiii)(int, int, int, int, int);
@@ -92,7 +94,6 @@ typedef int (*em_func_iij)(int, uint64_t);
9294
typedef int (*em_func_iijj)(int, uint64_t, uint64_t);
9395
typedef uint64_t (*em_func_jjj)(uint64_t, uint64_t);
9496
typedef void (*em_func_vij)(int, uint64_t);
95-
typedef void (*em_func_viij)(int, int, uint64_t);
9697
typedef void (*em_func_viji)(int, uint64_t, int);
9798
typedef void (*em_func_vijji)(int, uint64_t, uint64_t, int);
9899
typedef void (*em_func_viijj)(int, int, uint64_t, uint64_t);
@@ -191,6 +192,9 @@ static void _do_call(void* arg) {
191192
case EM_FUNC_SIG_VIII:
192193
((em_func_viii)q->functionPtr)(q->args[0].i, q->args[1].i, q->args[2].i);
193194
break;
195+
case EM_FUNC_SIG_VIIJ:
196+
((em_func_viij)q->functionPtr)(q->args[0].i, q->args[1].i, q->args[2].j);
197+
break;
194198
case EM_FUNC_SIG_VIIF:
195199
((em_func_viif)q->functionPtr)(q->args[0].i, q->args[1].i, q->args[2].f);
196200
break;
@@ -265,9 +269,6 @@ static void _do_call(void* arg) {
265269
case EM_FUNC_SIG_VIP:
266270
((em_func_vij)q->functionPtr)(q->args[0].i, q->args[1].j);
267271
break;
268-
case EM_FUNC_SIG_VIIP:
269-
((em_func_viij)q->functionPtr)(q->args[0].i, q->args[1].i, q->args[2].j);
270-
break;
271272
case EM_FUNC_SIG_VIIPP:
272273
((em_func_viijj)q->functionPtr)(q->args[0].i, q->args[1].i, q->args[2].j, q->args[3].j);
273274
break;
@@ -305,6 +306,9 @@ static void _do_call(void* arg) {
305306
case EM_FUNC_SIG_IIII:
306307
q->returnValue.i = ((em_func_iiii)q->functionPtr)(q->args[0].i, q->args[1].i, q->args[2].i);
307308
break;
309+
case EM_FUNC_SIG_IIIJ:
310+
q->returnValue.i = ((em_func_iiij)q->functionPtr)(q->args[0].i, q->args[1].i, q->args[2].j);
311+
break;
308312
case EM_FUNC_SIG_IIIII:
309313
q->returnValue.i =
310314
((em_func_iiiii)q->functionPtr)(q->args[0].i, q->args[1].i, q->args[2].i, q->args[3].i);

0 commit comments

Comments
 (0)