This is a commit message.

This commit is contained in:
TheBrokenRail 2024-06-08 04:23:15 -04:00
parent 3414fb817c
commit 2d9659f273
5 changed files with 85 additions and 100 deletions

@ -1 +1 @@
Subproject commit 027e58ee9bdcfef285c16e731c8db218082b9639 Subproject commit 06e9f4d7c8505a1e8c8ec4d65e21e93161eae6f7

View File

@ -12,7 +12,7 @@ static int get_glFogfv_params_length(GLenum pname) {
#endif #endif
CALL(11, glFogfv, void, (GLenum pname, const GLfloat *params)) CALL(11, glFogfv, void, (GLenum pname, const GLfloat *params))
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
trampoline(pname, copy_array(get_glFogfv_params_length(pname), params)); trampoline(true, pname, copy_array(get_glFogfv_params_length(pname), params));
#else #else
GLenum pname = args.next<GLenum>(); GLenum pname = args.next<GLenum>();
const GLfloat *params = args.next_arr<GLfloat>(); const GLfloat *params = args.next_arr<GLfloat>();
@ -90,7 +90,7 @@ static gl_state_t gl_state;
state.type = type; \ state.type = type; \
state.stride = stride; \ state.stride = stride; \
state.pointer = uint32_t(pointer); \ state.pointer = uint32_t(pointer); \
trampoline(state); \ trampoline(true, state); \
} \ } \
} }
#else #else
@ -106,7 +106,7 @@ CALL_GL_POINTER(12, glVertexPointer)
CALL(13, glLineWidth, void, (GLfloat width)) CALL(13, glLineWidth, void, (GLfloat width))
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
trampoline(width); trampoline(true, width);
#else #else
func(args.next<float>()); func(args.next<float>());
return 0; return 0;
@ -115,7 +115,7 @@ CALL(13, glLineWidth, void, (GLfloat width))
CALL(14, glBlendFunc, void, (GLenum sfactor, GLenum dfactor)) CALL(14, glBlendFunc, void, (GLenum sfactor, GLenum dfactor))
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
trampoline(sfactor, dfactor); trampoline(true, sfactor, dfactor);
#else #else
GLenum sfactor = args.next<GLenum>(); GLenum sfactor = args.next<GLenum>();
GLenum dfactor = args.next<GLenum>(); GLenum dfactor = args.next<GLenum>();
@ -126,7 +126,7 @@ CALL(14, glBlendFunc, void, (GLenum sfactor, GLenum dfactor))
CALL(15, glDrawArrays, void, (GLenum mode, GLint first, GLsizei count)) CALL(15, glDrawArrays, void, (GLenum mode, GLint first, GLsizei count))
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
trampoline(gl_state, mode, first, count); trampoline(true, gl_state, mode, first, count);
#else #else
gl_state_t gl_state = args.next<gl_state_t>(); gl_state_t gl_state = args.next<gl_state_t>();
gl_state.send_to_driver(); gl_state.send_to_driver();
@ -140,7 +140,7 @@ CALL(15, glDrawArrays, void, (GLenum mode, GLint first, GLsizei count))
CALL(16, glColor4f, void, (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)) CALL(16, glColor4f, void, (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha))
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
trampoline(red, green, blue, alpha); trampoline(true, red, green, blue, alpha);
#else #else
GLfloat red = args.next<float>(); GLfloat red = args.next<float>();
GLfloat green = args.next<float>(); GLfloat green = args.next<float>();
@ -153,7 +153,7 @@ CALL(16, glColor4f, void, (GLfloat red, GLfloat green, GLfloat blue, GLfloat alp
CALL(17, glClear, void, (GLbitfield mask)) CALL(17, glClear, void, (GLbitfield mask))
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
trampoline(mask); trampoline(true, mask);
#else #else
func(args.next<GLbitfield>()); func(args.next<GLbitfield>());
return 0; return 0;
@ -162,7 +162,7 @@ CALL(17, glClear, void, (GLbitfield mask))
CALL(18, glBufferData, void, (GLenum target, GLsizeiptr size, const void *data, GLenum usage)) CALL(18, glBufferData, void, (GLenum target, GLsizeiptr size, const void *data, GLenum usage))
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
trampoline(gl_state.bound_array_buffer, target, copy_array(size, (unsigned char *) data), usage); trampoline(true, gl_state.bound_array_buffer, target, copy_array(size, (unsigned char *) data), usage);
#else #else
glBindBuffer(GL_ARRAY_BUFFER, args.next<GLuint>()); glBindBuffer(GL_ARRAY_BUFFER, args.next<GLuint>());
GLenum target = args.next<GLenum>(); GLenum target = args.next<GLenum>();
@ -176,7 +176,7 @@ CALL(18, glBufferData, void, (GLenum target, GLsizeiptr size, const void *data,
CALL(19, glFogx, void, (GLenum pname, GLfixed param)) CALL(19, glFogx, void, (GLenum pname, GLfixed param))
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
trampoline(pname, param); trampoline(true, pname, param);
#else #else
GLenum pname = args.next<GLenum>(); GLenum pname = args.next<GLenum>();
GLfixed param = args.next<GLfixed>(); GLfixed param = args.next<GLfixed>();
@ -187,7 +187,7 @@ CALL(19, glFogx, void, (GLenum pname, GLfixed param))
CALL(20, glFogf, void, (GLenum pname, GLfloat param)) CALL(20, glFogf, void, (GLenum pname, GLfloat param))
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
trampoline(pname, param); trampoline(true, pname, param);
#else #else
GLenum pname = args.next<GLenum>(); GLenum pname = args.next<GLenum>();
GLfloat param = args.next<GLfloat>(); GLfloat param = args.next<GLfloat>();
@ -198,7 +198,7 @@ CALL(20, glFogf, void, (GLenum pname, GLfloat param))
CALL(21, glMatrixMode, void, (GLenum mode)) CALL(21, glMatrixMode, void, (GLenum mode))
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
trampoline(mode); trampoline(true, mode);
#else #else
func(args.next<GLenum>()); func(args.next<GLenum>());
return 0; return 0;
@ -209,7 +209,7 @@ CALL_GL_POINTER(22, glColorPointer)
CALL(23, glScissor, void, (GLint x, GLint y, GLsizei width, GLsizei height)) CALL(23, glScissor, void, (GLint x, GLint y, GLsizei width, GLsizei height))
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
trampoline(x, y, width, height); trampoline(true, x, y, width, height);
#else #else
GLint x = args.next<GLint>(); GLint x = args.next<GLint>();
GLint y = args.next<GLint>(); GLint y = args.next<GLint>();
@ -222,7 +222,7 @@ CALL(23, glScissor, void, (GLint x, GLint y, GLsizei width, GLsizei height))
CALL(24, glTexParameteri, void, (GLenum target, GLenum pname, GLint param)) CALL(24, glTexParameteri, void, (GLenum target, GLenum pname, GLint param))
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
trampoline(gl_state.bound_texture, target, pname, param); trampoline(true, gl_state.bound_texture, target, pname, param);
#else #else
glBindTexture(GL_TEXTURE_2D, args.next<GLuint>()); glBindTexture(GL_TEXTURE_2D, args.next<GLuint>());
GLenum target = args.next<GLenum>(); GLenum target = args.next<GLenum>();
@ -271,7 +271,7 @@ static int get_texture_size(const GLsizei width, const GLsizei height, const GLe
CALL(25, glTexImage2D, void, (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels)) CALL(25, glTexImage2D, void, (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels))
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
trampoline(gl_state.bound_texture, target, level, internalformat, width, height, border, format, type, copy_array(get_texture_size(width, height, format, type, true), (const unsigned char *) pixels)); trampoline(true, gl_state.bound_texture, target, level, internalformat, width, height, border, format, type, copy_array(get_texture_size(width, height, format, type, true), (const unsigned char *) pixels));
#else #else
glBindTexture(GL_TEXTURE_2D, args.next<GLuint>()); glBindTexture(GL_TEXTURE_2D, args.next<GLuint>());
GLenum target = args.next<GLenum>(); GLenum target = args.next<GLenum>();
@ -290,7 +290,7 @@ CALL(25, glTexImage2D, void, (GLenum target, GLint level, GLint internalformat,
CALL(26, glEnable, void, (GLenum cap)) CALL(26, glEnable, void, (GLenum cap))
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
trampoline(cap); trampoline(true, cap);
#else #else
func(args.next<GLenum>()); func(args.next<GLenum>());
return 0; return 0;
@ -305,7 +305,7 @@ void glEnableClientState(const GLenum array) {
CALL(28, glPolygonOffset, void, (GLfloat factor, GLfloat units)) CALL(28, glPolygonOffset, void, (GLfloat factor, GLfloat units))
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
trampoline(factor, units); trampoline(true, factor, units);
#else #else
GLfloat factor = args.next<GLfloat>(); GLfloat factor = args.next<GLfloat>();
GLfloat units = args.next<GLfloat>(); GLfloat units = args.next<GLfloat>();
@ -324,7 +324,7 @@ void glDisableClientState(const GLenum array) {
CALL(30, glDepthRangef, void, (GLclampf near, GLclampf far)) CALL(30, glDepthRangef, void, (GLclampf near, GLclampf far))
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
trampoline(near, far); trampoline(true, near, far);
#else #else
GLclampf near = args.next<GLclampf>(); GLclampf near = args.next<GLclampf>();
GLclampf far = args.next<GLclampf>(); GLclampf far = args.next<GLclampf>();
@ -335,7 +335,7 @@ CALL(30, glDepthRangef, void, (GLclampf near, GLclampf far))
CALL(31, glDepthFunc, void, (GLenum func)) CALL(31, glDepthFunc, void, (GLenum func))
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
trampoline(func); trampoline(true, func);
#else #else
func(args.next<GLenum>()); func(args.next<GLenum>());
return 0; return 0;
@ -354,7 +354,7 @@ void glBindBuffer(const GLenum target, const GLuint buffer) {
CALL(33, glClearColor, void, (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)) CALL(33, glClearColor, void, (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha))
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
trampoline(red, green, blue, alpha); trampoline(true, red, green, blue, alpha);
#else #else
GLclampf red = args.next<GLclampf>(); GLclampf red = args.next<GLclampf>();
GLclampf green = args.next<GLclampf>(); GLclampf green = args.next<GLclampf>();
@ -367,7 +367,7 @@ CALL(33, glClearColor, void, (GLclampf red, GLclampf green, GLclampf blue, GLcla
CALL(34, glPopMatrix, void, ()) CALL(34, glPopMatrix, void, ())
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
trampoline(); trampoline(true);
#else #else
func(); func();
return 0; return 0;
@ -376,7 +376,7 @@ CALL(34, glPopMatrix, void, ())
CALL(35, glLoadIdentity, void, ()) CALL(35, glLoadIdentity, void, ())
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
trampoline(); trampoline(true);
#else #else
func(); func();
return 0; return 0;
@ -385,7 +385,7 @@ CALL(35, glLoadIdentity, void, ())
CALL(36, glScalef, void, (GLfloat x, GLfloat y, GLfloat z)) CALL(36, glScalef, void, (GLfloat x, GLfloat y, GLfloat z))
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
trampoline(x, y, z); trampoline(true, x, y, z);
#else #else
GLfloat x = args.next<GLfloat>(); GLfloat x = args.next<GLfloat>();
GLfloat y = args.next<GLfloat>(); GLfloat y = args.next<GLfloat>();
@ -397,7 +397,7 @@ CALL(36, glScalef, void, (GLfloat x, GLfloat y, GLfloat z))
CALL(37, glPushMatrix, void, ()) CALL(37, glPushMatrix, void, ())
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
trampoline(); trampoline(true);
#else #else
func(); func();
return 0; return 0;
@ -406,7 +406,7 @@ CALL(37, glPushMatrix, void, ())
CALL(38, glDepthMask, void, (GLboolean flag)) CALL(38, glDepthMask, void, (GLboolean flag))
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
trampoline(flag); trampoline(true, flag);
#else #else
func(args.next<GLboolean>()); func(args.next<GLboolean>());
return 0; return 0;
@ -415,7 +415,7 @@ CALL(38, glDepthMask, void, (GLboolean flag))
CALL(39, glHint, void, (GLenum target, GLenum mode)) CALL(39, glHint, void, (GLenum target, GLenum mode))
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
trampoline(target, mode); trampoline(true, target, mode);
#else #else
GLenum target = args.next<GLenum>(); GLenum target = args.next<GLenum>();
GLenum mode = args.next<GLenum>(); GLenum mode = args.next<GLenum>();
@ -431,7 +431,7 @@ static int get_glMultMatrixf_size() {
#endif #endif
CALL(40, glMultMatrixf, void, (const GLfloat *m)) CALL(40, glMultMatrixf, void, (const GLfloat *m))
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
trampoline(copy_array(get_glMultMatrixf_size(), m)); trampoline(true, copy_array(get_glMultMatrixf_size(), m));
#else #else
func(args.next_arr<GLfloat>()); func(args.next_arr<GLfloat>());
return 0; return 0;
@ -440,7 +440,7 @@ CALL(40, glMultMatrixf, void, (const GLfloat *m))
CALL(42, glDeleteBuffers, void, (GLsizei n, const GLuint *buffers)) CALL(42, glDeleteBuffers, void, (GLsizei n, const GLuint *buffers))
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
trampoline(copy_array(n, buffers)); trampoline(true, copy_array(n, buffers));
#else #else
uint32_t n; uint32_t n;
const GLuint *buffers = args.next_arr<GLuint>(&n); const GLuint *buffers = args.next_arr<GLuint>(&n);
@ -451,7 +451,7 @@ CALL(42, glDeleteBuffers, void, (GLsizei n, const GLuint *buffers))
CALL(43, glColorMask, void, (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)) CALL(43, glColorMask, void, (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha))
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
trampoline(red, green, blue, alpha); trampoline(true, red, green, blue, alpha);
#else #else
GLboolean red = args.next<GLboolean>(); GLboolean red = args.next<GLboolean>();
GLboolean green = args.next<GLboolean>(); GLboolean green = args.next<GLboolean>();
@ -464,7 +464,7 @@ CALL(43, glColorMask, void, (GLboolean red, GLboolean green, GLboolean blue, GLb
CALL(44, glTexSubImage2D, void, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels)) CALL(44, glTexSubImage2D, void, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels))
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
trampoline(gl_state.bound_texture, target, level, xoffset, yoffset, width, height, format, type, copy_array(get_texture_size(width, height, format, type, true), (const unsigned char *) pixels)); trampoline(true, gl_state.bound_texture, target, level, xoffset, yoffset, width, height, format, type, copy_array(get_texture_size(width, height, format, type, true), (const unsigned char *) pixels));
#else #else
glBindTexture(GL_TEXTURE_2D, args.next<GLuint>()); glBindTexture(GL_TEXTURE_2D, args.next<GLuint>());
GLenum target = args.next<GLenum>(); GLenum target = args.next<GLenum>();
@ -483,7 +483,7 @@ CALL(44, glTexSubImage2D, void, (GLenum target, GLint level, GLint xoffset, GLin
CALL(45, glGenTextures, void, (GLsizei n, GLuint *textures)) CALL(45, glGenTextures, void, (GLsizei n, GLuint *textures))
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
trampoline(n, uint32_t(textures)); trampoline(false, n, uint32_t(textures));
#else #else
GLsizei n = args.next<GLsizei>(); GLsizei n = args.next<GLsizei>();
GLuint *textures = new GLuint[n]; GLuint *textures = new GLuint[n];
@ -496,7 +496,7 @@ CALL(45, glGenTextures, void, (GLsizei n, GLuint *textures))
CALL(46, glDeleteTextures, void, (GLsizei n, const GLuint *textures)) CALL(46, glDeleteTextures, void, (GLsizei n, const GLuint *textures))
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
trampoline(copy_array(n, textures)); trampoline(true, copy_array(n, textures));
#else #else
uint32_t n; uint32_t n;
const GLuint *textures = args.next_arr<GLuint>(&n); const GLuint *textures = args.next_arr<GLuint>(&n);
@ -507,7 +507,7 @@ CALL(46, glDeleteTextures, void, (GLsizei n, const GLuint *textures))
CALL(47, glAlphaFunc, void, (GLenum func, GLclampf ref)) CALL(47, glAlphaFunc, void, (GLenum func, GLclampf ref))
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
trampoline(func, ref); trampoline(true, func, ref);
#else #else
GLenum func2 = args.next<GLenum>(); GLenum func2 = args.next<GLenum>();
GLclampf ref = args.next<GLclampf>(); GLclampf ref = args.next<GLclampf>();
@ -535,7 +535,7 @@ static int get_glGetFloatv_params_size(GLenum pname) {
#endif #endif
CALL(48, glGetFloatv, void, (GLenum pname, GLfloat *params)) CALL(48, glGetFloatv, void, (GLenum pname, GLfloat *params))
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
trampoline(pname, uint32_t(params)); trampoline(false, pname, uint32_t(params));
#else #else
GLenum pname = args.next<GLenum>(); GLenum pname = args.next<GLenum>();
int size = get_glGetFloatv_params_size(pname); int size = get_glGetFloatv_params_size(pname);
@ -559,7 +559,7 @@ void glBindTexture(const GLenum target, const GLuint texture) {
CALL(50, glTranslatef, void, (GLfloat x, GLfloat y, GLfloat z)) CALL(50, glTranslatef, void, (GLfloat x, GLfloat y, GLfloat z))
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
trampoline(x, y, z); trampoline(true, x, y, z);
#else #else
GLfloat x = args.next<GLfloat>(); GLfloat x = args.next<GLfloat>();
GLfloat y = args.next<GLfloat>(); GLfloat y = args.next<GLfloat>();
@ -571,7 +571,7 @@ CALL(50, glTranslatef, void, (GLfloat x, GLfloat y, GLfloat z))
CALL(51, glShadeModel, void, (GLenum mode)) CALL(51, glShadeModel, void, (GLenum mode))
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
trampoline(mode); trampoline(true, mode);
#else #else
func(args.next<GLenum>()); func(args.next<GLenum>());
return 0; return 0;
@ -580,7 +580,7 @@ CALL(51, glShadeModel, void, (GLenum mode))
CALL(52, glOrthof, void, (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat near, GLfloat far)) CALL(52, glOrthof, void, (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat near, GLfloat far))
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
trampoline(left, right, bottom, top, near, far); trampoline(true, left, right, bottom, top, near, far);
#else #else
GLfloat left = args.next<GLfloat>(); GLfloat left = args.next<GLfloat>();
GLfloat right = args.next<GLfloat>(); GLfloat right = args.next<GLfloat>();
@ -595,7 +595,7 @@ CALL(52, glOrthof, void, (GLfloat left, GLfloat right, GLfloat bottom, GLfloat t
CALL(53, glDisable, void, (GLenum cap)) CALL(53, glDisable, void, (GLenum cap))
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
trampoline(cap); trampoline(true, cap);
#else #else
func(args.next<GLenum>()); func(args.next<GLenum>());
return 0; return 0;
@ -604,7 +604,7 @@ CALL(53, glDisable, void, (GLenum cap))
CALL(54, glCullFace, void, (GLenum mode)) CALL(54, glCullFace, void, (GLenum mode))
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
trampoline(mode); trampoline(true, mode);
#else #else
func(args.next<GLenum>()); func(args.next<GLenum>());
return 0; return 0;
@ -613,7 +613,7 @@ CALL(54, glCullFace, void, (GLenum mode))
CALL(55, glRotatef, void, (GLfloat angle, GLfloat x, GLfloat y, GLfloat z)) CALL(55, glRotatef, void, (GLfloat angle, GLfloat x, GLfloat y, GLfloat z))
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
trampoline(angle, x, y, z); trampoline(true, angle, x, y, z);
#else #else
GLfloat angle = args.next<GLfloat>(); GLfloat angle = args.next<GLfloat>();
GLfloat x = args.next<GLfloat>(); GLfloat x = args.next<GLfloat>();
@ -626,7 +626,7 @@ CALL(55, glRotatef, void, (GLfloat angle, GLfloat x, GLfloat y, GLfloat z))
CALL(56, glViewport, void, (GLint x, GLint y, GLsizei width, GLsizei height)) CALL(56, glViewport, void, (GLint x, GLint y, GLsizei width, GLsizei height))
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
trampoline(x, y, width, height); trampoline(true, x, y, width, height);
#else #else
GLint x = args.next<GLint>(); GLint x = args.next<GLint>();
GLint y = args.next<GLint>(); GLint y = args.next<GLint>();
@ -639,7 +639,7 @@ CALL(56, glViewport, void, (GLint x, GLint y, GLsizei width, GLsizei height))
CALL(57, glNormal3f, void, (GLfloat nx, GLfloat ny, GLfloat nz)) CALL(57, glNormal3f, void, (GLfloat nx, GLfloat ny, GLfloat nz))
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
trampoline(nx, ny, nz); trampoline(true, nx, ny, nz);
#else #else
GLfloat nx = args.next<GLfloat>(); GLfloat nx = args.next<GLfloat>();
GLfloat ny = args.next<GLfloat>(); GLfloat ny = args.next<GLfloat>();
@ -651,7 +651,7 @@ CALL(57, glNormal3f, void, (GLfloat nx, GLfloat ny, GLfloat nz))
CALL(58, glIsEnabled, GLboolean, (GLenum cap)) CALL(58, glIsEnabled, GLboolean, (GLenum cap))
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
return trampoline(cap); return trampoline(false, cap);
#else #else
return func(args.next<GLenum>()); return func(args.next<GLenum>());
#endif #endif
@ -676,7 +676,7 @@ static int get_glGetIntegerv_params_size(GLenum pname) {
#endif #endif
CALL(61, glGetIntegerv, void, (GLenum pname, GLint *params)) CALL(61, glGetIntegerv, void, (GLenum pname, GLint *params))
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
trampoline(pname, uint32_t(params)); trampoline(false, pname, uint32_t(params));
#else #else
GLenum pname = args.next<GLenum>(); GLenum pname = args.next<GLenum>();
int size = get_glGetIntegerv_params_size(pname); int size = get_glGetIntegerv_params_size(pname);
@ -690,7 +690,7 @@ CALL(61, glGetIntegerv, void, (GLenum pname, GLint *params))
CALL(65, glReadPixels, void, (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *data)) CALL(65, glReadPixels, void, (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *data))
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
trampoline(x, y, width, height, format, type, uint32_t(data)); trampoline(false, x, y, width, height, format, type, uint32_t(data));
#else #else
GLint x = args.next<GLint>(); GLint x = args.next<GLint>();
GLint y = args.next<GLint>(); GLint y = args.next<GLint>();
@ -709,7 +709,7 @@ CALL(65, glReadPixels, void, (GLint x, GLint y, GLsizei width, GLsizei height, G
CALL(67, glGenBuffers, void, (GLsizei n, GLuint *buffers)) CALL(67, glGenBuffers, void, (GLsizei n, GLuint *buffers))
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
trampoline(n, uint32_t(buffers)); trampoline(false, n, uint32_t(buffers));
#else #else
GLsizei n = args.next<GLsizei>(); GLsizei n = args.next<GLsizei>();
GLuint *buffers = new GLuint[n]; GLuint *buffers = new GLuint[n];

View File

@ -26,7 +26,7 @@ static int get_pipe(const char *env) {
std::string str = value; std::string str = value;
return std::stoi(str); return std::stoi(str);
} }
static uint32_t trampoline_pipe(const uint32_t id) { static uint32_t trampoline_pipe(const uint32_t id, const bool allow_early_return, const uint32_t length, const unsigned char *args) {
// Get Pipes // Get Pipes
static int arguments_pipe = -1; static int arguments_pipe = -1;
static int return_value_pipe = -1; static int return_value_pipe = -1;
@ -34,20 +34,30 @@ static uint32_t trampoline_pipe(const uint32_t id) {
arguments_pipe = get_pipe(TRAMPOLINE_ARGUMENTS_PIPE_ENV); arguments_pipe = get_pipe(TRAMPOLINE_ARGUMENTS_PIPE_ENV);
return_value_pipe = get_pipe(TRAMPOLINE_RETURN_VALUE_PIPE_ENV); return_value_pipe = get_pipe(TRAMPOLINE_RETURN_VALUE_PIPE_ENV);
} }
// Write ID // Write Command
if (write(arguments_pipe, &id, sizeof(uint32_t)) != sizeof(uint32_t)) { const trampoline_pipe_arguments cmd = {
.id = id,
.allow_early_return = allow_early_return,
.length = length,
.args_addr = uint32_t(args)
};
if (write(arguments_pipe, &cmd, sizeof(trampoline_pipe_arguments)) != sizeof(trampoline_pipe_arguments)) {
ERR("Unable To Write Trampoline Command"); ERR("Unable To Write Trampoline Command");
} }
// Return // Return
uint32_t ret; if (length > 0 || !allow_early_return) {
if (read(return_value_pipe, &ret, sizeof(uint32_t)) != sizeof(uint32_t)) { uint32_t ret;
ERR("Unable To Read Trampoline Return Value"); if (read(return_value_pipe, &ret, sizeof(uint32_t)) != sizeof(uint32_t)) {
ERR("Unable To Read Trampoline Return Value");
}
return ret;
} else {
return 0;
} }
return ret;
} }
// Main Function // Main Function
uint32_t _raw_trampoline(const uint32_t id, const uint32_t length, const unsigned char *args) { uint32_t _raw_trampoline(const uint32_t id, const bool allow_early_return, const uint32_t length, const unsigned char *args) {
// Configure Method // Configure Method
static int use_syscall = -1; static int use_syscall = -1;
if (use_syscall == -1) { if (use_syscall == -1) {
@ -57,30 +67,6 @@ uint32_t _raw_trampoline(const uint32_t id, const uint32_t length, const unsigne
if (use_syscall) { if (use_syscall) {
return trampoline_syscall(id, length, args); return trampoline_syscall(id, length, args);
} else { } else {
return trampoline_pipe(id); return trampoline_pipe(id, allow_early_return, length, args);
} }
} }
// Arguments Memory
unsigned char *get_arguments_memory() {
static unsigned char fallback[MAX_TRAMPOLINE_ARGS_SIZE];
// Find Result
static unsigned char *ret = nullptr;
if (ret == nullptr) {
ret = fallback;
// Try Shared Memory
const char *shared_memory_name = getenv(TRAMPOLINE_SHARED_MEMORY_ENV);
if (shared_memory_name != nullptr) {
int fd = shm_open(shared_memory_name, O_RDWR, 0600);
if (fd == -1) {
ERR("Unable To Open Shared Memory: %s", strerror(errno));
}
ret = (unsigned char *) mmap(nullptr, MAX_TRAMPOLINE_ARGS_SIZE, PROT_WRITE, MAP_SHARED, fd, 0);
if (ret == MAP_FAILED) {
ERR("Unable To Map Shared Memory: %s", strerror(errno));
}
}
}
// Return
return ret;
}

View File

@ -5,8 +5,7 @@
#include "../common/common.h" #include "../common/common.h"
// Trampoline Function // Trampoline Function
unsigned char *get_arguments_memory(); uint32_t _raw_trampoline(uint32_t id, bool allow_early_return, uint32_t length, const unsigned char *args);
uint32_t _raw_trampoline(uint32_t id, uint32_t length, const unsigned char *args);
// Compile Trampoline Arguments // Compile Trampoline Arguments
template <typename T> template <typename T>
@ -53,12 +52,12 @@ void _add_to_trampoline_args(unsigned char *&out, const T &first, const Args...
// Main Trampoline Function // Main Trampoline Function
template <typename... Args> template <typename... Args>
unsigned int _trampoline(unsigned int id, Args... args) { unsigned int _trampoline(const unsigned int id, const bool allow_early_return, Args... args) {
static unsigned char *out = get_arguments_memory(); static unsigned char out[MAX_TRAMPOLINE_ARGS_SIZE];
unsigned char *end = out; unsigned char *end = out;
_add_to_trampoline_args(end, args...); _add_to_trampoline_args(end, args...);
const uint32_t length = end - out; const uint32_t length = end - out;
return _raw_trampoline(id, length, out); return _raw_trampoline(id, allow_early_return, length, out);
} }
#define trampoline(...) _trampoline(_id, ##__VA_ARGS__) #define trampoline(...) _trampoline(_id, ##__VA_ARGS__)

View File

@ -13,7 +13,7 @@
CALL(0, SDL_Init, int, (uint32_t flags)) CALL(0, SDL_Init, int, (uint32_t flags))
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
return trampoline(flags); return trampoline(false, flags);
#else #else
uint32_t flags = args.next<uint32_t>(); uint32_t flags = args.next<uint32_t>();
return func(flags); return func(flags);
@ -22,7 +22,7 @@ CALL(0, SDL_Init, int, (uint32_t flags))
CALL(1, SDL_PollEvent, int, (SDL_Event *event)) CALL(1, SDL_PollEvent, int, (SDL_Event *event))
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
return trampoline(uint32_t(event)); return trampoline(false, uint32_t(event));
#else #else
SDL_Event event; SDL_Event event;
const int ret = func(&event); const int ret = func(&event);
@ -33,7 +33,7 @@ CALL(1, SDL_PollEvent, int, (SDL_Event *event))
CALL(2, SDL_PushEvent, int, (SDL_Event *event)) CALL(2, SDL_PushEvent, int, (SDL_Event *event))
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
return trampoline(*event); return trampoline(false, *event);
#else #else
SDL_Event event = args.next<SDL_Event>(); SDL_Event event = args.next<SDL_Event>();
return func(&event); return func(&event);
@ -42,7 +42,7 @@ CALL(2, SDL_PushEvent, int, (SDL_Event *event))
CALL(3, SDL_WM_SetCaption, void, (const char *title, const char *icon)) CALL(3, SDL_WM_SetCaption, void, (const char *title, const char *icon))
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
trampoline(copy_array(title), copy_array(icon)); trampoline(true, copy_array(title), copy_array(icon));
#else #else
const char *title = args.next_arr<char>(); const char *title = args.next_arr<char>();
const char *icon = args.next_arr<char>(); const char *icon = args.next_arr<char>();
@ -53,7 +53,7 @@ CALL(3, SDL_WM_SetCaption, void, (const char *title, const char *icon))
CALL(4, media_toggle_fullscreen, void, ()) CALL(4, media_toggle_fullscreen, void, ())
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
trampoline(); trampoline(true);
#else #else
func(); func();
return 0; return 0;
@ -62,7 +62,7 @@ CALL(4, media_toggle_fullscreen, void, ())
CALL(5, SDL_WM_GrabInput, SDL_GrabMode, (SDL_GrabMode mode)) CALL(5, SDL_WM_GrabInput, SDL_GrabMode, (SDL_GrabMode mode))
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
return (SDL_GrabMode) trampoline(mode); return (SDL_GrabMode) trampoline(false, mode);
#else #else
return func(args.next<SDL_GrabMode>()); return func(args.next<SDL_GrabMode>());
#endif #endif
@ -70,7 +70,7 @@ CALL(5, SDL_WM_GrabInput, SDL_GrabMode, (SDL_GrabMode mode))
CALL(6, SDL_ShowCursor, int, (int32_t toggle)) CALL(6, SDL_ShowCursor, int, (int32_t toggle))
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
return trampoline(toggle); return trampoline(false, toggle);
#else #else
return func(args.next<int32_t>()); return func(args.next<int32_t>());
#endif #endif
@ -78,7 +78,7 @@ CALL(6, SDL_ShowCursor, int, (int32_t toggle))
CALL(8, media_swap_buffers, void, ()) CALL(8, media_swap_buffers, void, ())
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
trampoline(); trampoline(true);
#else #else
func(); func();
return 0; return 0;
@ -96,7 +96,7 @@ CALL(9, media_cleanup, void, ())
CALL(10, media_get_framebuffer_size, void, (int *width, int *height)) CALL(10, media_get_framebuffer_size, void, (int *width, int *height))
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
trampoline(uint32_t(width), uint32_t(height)); trampoline(false, uint32_t(width), uint32_t(height));
#else #else
int width; int width;
int height; int height;
@ -109,7 +109,7 @@ CALL(10, media_get_framebuffer_size, void, (int *width, int *height))
CALL(59, media_audio_update, void, (float volume, float x, float y, float z, float yaw)) CALL(59, media_audio_update, void, (float volume, float x, float y, float z, float yaw))
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
trampoline(volume, x, y, z, yaw); trampoline(true, volume, x, y, z, yaw);
#else #else
float volume = args.next<float>(); float volume = args.next<float>();
float x = args.next<float>(); float x = args.next<float>();
@ -123,7 +123,7 @@ CALL(59, media_audio_update, void, (float volume, float x, float y, float z, flo
CALL(60, media_audio_play, void, (const char *source, const char *name, float x, float y, float z, float pitch, float volume, int is_ui)) CALL(60, media_audio_play, void, (const char *source, const char *name, float x, float y, float z, float pitch, float volume, int is_ui))
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
trampoline(copy_array(source), copy_array(name), x, y, z, pitch, volume, is_ui); trampoline(true, copy_array(source), copy_array(name), x, y, z, pitch, volume, is_ui);
#else #else
const char *source = args.next_arr<char>(); const char *source = args.next_arr<char>();
const char *name = args.next_arr<char>(); const char *name = args.next_arr<char>();
@ -140,7 +140,7 @@ CALL(60, media_audio_play, void, (const char *source, const char *name, float x,
CALL(62, media_set_interactable, void, (int is_interactable)) CALL(62, media_set_interactable, void, (int is_interactable))
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
trampoline(is_interactable); trampoline(true, is_interactable);
#else #else
func(args.next<int>()); func(args.next<int>());
return 0; return 0;
@ -149,7 +149,7 @@ CALL(62, media_set_interactable, void, (int is_interactable))
CALL(63, media_disable_vsync, void, ()) CALL(63, media_disable_vsync, void, ())
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
trampoline(); trampoline(true);
#else #else
func(); func();
return 0; return 0;
@ -158,7 +158,7 @@ CALL(63, media_disable_vsync, void, ())
CALL(64, media_set_raw_mouse_motion_enabled, void, (int enabled)) CALL(64, media_set_raw_mouse_motion_enabled, void, (int enabled))
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
trampoline(enabled); trampoline(true, enabled);
#else #else
func(args.next<int>()); func(args.next<int>());
return 0; return 0;
@ -167,7 +167,7 @@ CALL(64, media_set_raw_mouse_motion_enabled, void, (int enabled))
CALL(66, media_force_egl, void, ()) CALL(66, media_force_egl, void, ())
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
trampoline(); trampoline(true);
#else #else
func(); func();
return 0; return 0;
@ -176,7 +176,7 @@ CALL(66, media_force_egl, void, ())
CALL(68, media_ensure_loaded, void, ()) CALL(68, media_ensure_loaded, void, ())
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
trampoline(); trampoline(true);
#else #else
func(); func();
return 0; return 0;