From ef96273e60366158baad5e049397a2d0aac4cc5d Mon Sep 17 00:00:00 2001 From: Lukasz Kostyra Date: Mon, 17 Aug 2020 11:12:40 +0200 Subject: [PATCH] yagl: Remove api-local and backend-local ts variables (2/3) yagl_tls.h header was removed, as it is no longer necessary. Change-Id: I037c8fb7dd0419dafd652396412a47224721de63 --- hw/yagl/yagl_apis/egl/yagl_egl_api_ps.c | 5 +- hw/yagl/yagl_apis/egl/yagl_egl_api_ps.h | 3 +- hw/yagl/yagl_apis/egl/yagl_egl_api_ts.c | 9 +- hw/yagl/yagl_apis/egl/yagl_egl_api_ts.h | 3 +- hw/yagl/yagl_apis/egl/yagl_egl_calls.c | 2 +- hw/yagl/yagl_apis/egl/yagl_egl_config.c | 6 +- hw/yagl/yagl_apis/egl/yagl_egl_config.h | 2 +- hw/yagl/yagl_apis/egl/yagl_egl_context.c | 17 +- hw/yagl/yagl_apis/egl/yagl_egl_context.h | 5 +- hw/yagl/yagl_apis/egl/yagl_egl_display.c | 26 +- hw/yagl/yagl_apis/egl/yagl_egl_display.h | 11 +- hw/yagl/yagl_apis/egl/yagl_egl_surface.c | 10 +- hw/yagl/yagl_apis/egl/yagl_egl_surface.h | 2 +- hw/yagl/yagl_apis/egl/yagl_host_egl_calls.c | 162 ++- hw/yagl/yagl_apis/egl/yagl_host_egl_calls.h | 2 +- hw/yagl/yagl_apis/gles/yagl_gles_api_ts.c | 8 +- hw/yagl/yagl_apis/gles/yagl_host_gles_calls.c | 1066 ++++++++++---------- .../egl_offscreen/yagl_egl_offscreen.c | 27 +- .../egl_offscreen/yagl_egl_offscreen_context.c | 13 +- .../egl_offscreen/yagl_egl_offscreen_display.c | 14 +- .../egl_offscreen/yagl_egl_offscreen_surface.c | 13 +- .../egl_offscreen/yagl_egl_offscreen_ts.c | 4 +- .../egl_offscreen/yagl_egl_offscreen_ts.h | 5 +- .../yagl_backends/egl_onscreen/yagl_egl_onscreen.c | 72 +- .../egl_onscreen/yagl_egl_onscreen_context.c | 13 +- .../egl_onscreen/yagl_egl_onscreen_context.h | 3 +- .../egl_onscreen/yagl_egl_onscreen_display.c | 5 +- .../egl_onscreen/yagl_egl_onscreen_surface.c | 45 +- hw/yagl/yagl_device.c | 2 + hw/yagl/yagl_drivers/Makefile.objs | 1 + hw/yagl/yagl_drivers/egl_cgl/yagl_egl_cgl.c | 17 +- hw/yagl/yagl_drivers/egl_glx/yagl_egl_glx.c | 1 - hw/yagl/yagl_drivers/egl_wgl/yagl_egl_wgl.c | 15 +- hw/yagl/yagl_drivers/gles_offscreen/Makefile.objs | 3 + .../gles_offscreen/yagl_gles_offscreen.c | 94 ++ .../gles_offscreen/yagl_gles_offscreen.h} | 16 +- hw/yagl/yagl_drivers/gles_ogl/yagl_gles_ogl.c | 1 + .../gles_onscreen/yagl_gles_onscreen.c | 17 +- hw/yagl/yagl_egl_backend.h | 6 +- hw/yagl/yagl_egl_interface.h | 11 +- hw/yagl/yagl_eglb_context.h | 2 +- hw/yagl/yagl_eglb_surface.h | 5 +- hw/yagl/yagl_gles_driver.c | 16 +- hw/yagl/yagl_gles_driver.h | 7 +- hw/yagl/yagl_object_map.c | 39 +- hw/yagl/yagl_object_map.h | 16 +- hw/yagl/yagl_process.c | 2 +- hw/yagl/yagl_ref.c | 4 +- hw/yagl/yagl_ref.h | 4 +- hw/yagl/yagl_resource.c | 4 +- hw/yagl/yagl_resource.h | 4 +- hw/yagl/yagl_resource_list.c | 9 +- hw/yagl/yagl_resource_list.h | 5 +- hw/yagl/yagl_thread.c | 2 +- hw/yagl/yagl_thread.h | 9 +- 55 files changed, 1032 insertions(+), 833 deletions(-) create mode 100644 hw/yagl/yagl_drivers/gles_offscreen/Makefile.objs create mode 100644 hw/yagl/yagl_drivers/gles_offscreen/yagl_gles_offscreen.c rename hw/yagl/{yagl_tls.h => yagl_drivers/gles_offscreen/yagl_gles_offscreen.h} (74%) diff --git a/hw/yagl/yagl_apis/egl/yagl_egl_api_ps.c b/hw/yagl/yagl_apis/egl/yagl_egl_api_ps.c index 1733dfc..43e3051 100644 --- a/hw/yagl/yagl_apis/egl/yagl_egl_api_ps.c +++ b/hw/yagl/yagl_apis/egl/yagl_egl_api_ps.c @@ -43,13 +43,14 @@ void yagl_egl_api_ps_init(struct yagl_egl_api_ps *egl_api_ps, QLIST_INIT(&egl_api_ps->displays); } -void yagl_egl_api_ps_cleanup(struct yagl_egl_api_ps *egl_api_ps) +void yagl_egl_api_ps_cleanup(struct yagl_thread_state *cur_ts, + struct yagl_egl_api_ps *egl_api_ps) { struct yagl_egl_display *dpy, *next; QLIST_FOREACH_SAFE(dpy, &egl_api_ps->displays, entry, next) { QLIST_REMOVE(dpy, entry); - yagl_egl_display_destroy(dpy); + yagl_egl_display_destroy(cur_ts, dpy); } assert(QLIST_EMPTY(&egl_api_ps->displays)); diff --git a/hw/yagl/yagl_apis/egl/yagl_egl_api_ps.h b/hw/yagl/yagl_apis/egl/yagl_egl_api_ps.h index 8a3563a..95fd1df 100644 --- a/hw/yagl/yagl_apis/egl/yagl_egl_api_ps.h +++ b/hw/yagl/yagl_apis/egl/yagl_egl_api_ps.h @@ -52,7 +52,8 @@ void yagl_egl_api_ps_init(struct yagl_egl_api_ps *egl_api_ps, struct yagl_egl_backend *backend, struct yagl_egl_interface *egl_iface); -void yagl_egl_api_ps_cleanup(struct yagl_egl_api_ps *egl_api_ps); +void yagl_egl_api_ps_cleanup(struct yagl_thread_state *cur_ts, + struct yagl_egl_api_ps *egl_api_ps); struct yagl_egl_display *yagl_egl_api_ps_display_get(struct yagl_egl_api_ps *egl_api_ps, yagl_host_handle handle); diff --git a/hw/yagl/yagl_apis/egl/yagl_egl_api_ts.c b/hw/yagl/yagl_apis/egl/yagl_egl_api_ts.c index 7af8eef..d3da857 100644 --- a/hw/yagl/yagl_apis/egl/yagl_egl_api_ts.c +++ b/hw/yagl/yagl_apis/egl/yagl_egl_api_ts.c @@ -53,18 +53,19 @@ void yagl_egl_api_ts_cleanup(struct yagl_thread_state *cur_ts, */ egl_api_ts->backend->release_current(cur_ts, egl_api_ts->backend, true); - yagl_egl_context_update_surfaces(egl_api_ts->context, NULL, NULL); + yagl_egl_context_update_surfaces(cur_ts, egl_api_ts->context, NULL, NULL); } - yagl_egl_api_ts_update_context(egl_api_ts, NULL); + yagl_egl_api_ts_update_context(cur_ts, egl_api_ts, NULL); } -void yagl_egl_api_ts_update_context(struct yagl_egl_api_ts *egl_api_ts, +void yagl_egl_api_ts_update_context(struct yagl_thread_state *cur_ts, + struct yagl_egl_api_ts *egl_api_ts, struct yagl_egl_context *ctx) { yagl_egl_context_acquire(ctx); - yagl_egl_context_release(egl_api_ts->context); + yagl_egl_context_release(cur_ts, egl_api_ts->context); egl_api_ts->context = ctx; } diff --git a/hw/yagl/yagl_apis/egl/yagl_egl_api_ts.h b/hw/yagl/yagl_apis/egl/yagl_egl_api_ts.h index ba3d04a..3d95bda 100644 --- a/hw/yagl/yagl_apis/egl/yagl_egl_api_ts.h +++ b/hw/yagl/yagl_apis/egl/yagl_egl_api_ts.h @@ -61,7 +61,8 @@ void yagl_egl_api_ts_init(struct yagl_thread_state *cur_ts, void yagl_egl_api_ts_cleanup(struct yagl_thread_state *cur_ts, struct yagl_egl_api_ts *egl_api_ts); -void yagl_egl_api_ts_update_context(struct yagl_egl_api_ts *egl_api_ts, +void yagl_egl_api_ts_update_context(struct yagl_thread_state *cur_ts, + struct yagl_egl_api_ts *egl_api_ts, struct yagl_egl_context *ctx); void yagl_egl_api_ts_reset(struct yagl_egl_api_ts *egl_api_ts); diff --git a/hw/yagl/yagl_apis/egl/yagl_egl_calls.c b/hw/yagl/yagl_apis/egl/yagl_egl_calls.c index 52aa00d..7ae62a0 100644 --- a/hw/yagl/yagl_apis/egl/yagl_egl_calls.c +++ b/hw/yagl/yagl_apis/egl/yagl_egl_calls.c @@ -213,7 +213,7 @@ static void yagl_func_eglBindAPI(struct yagl_transport *t) EGLenum api; api = yagl_transport_get_out_EGLenum(t); YAGL_LOG_FUNC_ENTER_SPLIT1(eglBindAPI, EGLenum, api); - (void)yagl_host_eglBindAPI(api); + (void)yagl_host_eglBindAPI(cur_ts, api); YAGL_LOG_FUNC_EXIT(NULL); } diff --git a/hw/yagl/yagl_apis/egl/yagl_egl_config.c b/hw/yagl/yagl_apis/egl/yagl_egl_config.c index 71bcf23..0a365a6 100644 --- a/hw/yagl/yagl_apis/egl/yagl_egl_config.c +++ b/hw/yagl/yagl_apis/egl/yagl_egl_config.c @@ -36,7 +36,7 @@ #include "yagl_thread.h" #include -static void yagl_egl_config_destroy(struct yagl_ref *ref) +static void yagl_egl_config_destroy(struct yagl_thread_state *cur_ts, struct yagl_ref *ref) { struct yagl_egl_config *cfg = (struct yagl_egl_config*)ref; @@ -437,9 +437,9 @@ void yagl_egl_config_acquire(struct yagl_egl_config *cfg) } } -void yagl_egl_config_release(struct yagl_egl_config *cfg) +void yagl_egl_config_release(struct yagl_thread_state *cur_ts, struct yagl_egl_config *cfg) { if (cfg) { - yagl_resource_release(&cfg->res); + yagl_resource_release(cur_ts, &cfg->res); } } diff --git a/hw/yagl/yagl_apis/egl/yagl_egl_config.h b/hw/yagl/yagl_apis/egl/yagl_egl_config.h index c585485..3d851c4 100644 --- a/hw/yagl/yagl_apis/egl/yagl_egl_config.h +++ b/hw/yagl/yagl_apis/egl/yagl_egl_config.h @@ -85,7 +85,7 @@ void yagl_egl_config_acquire(struct yagl_egl_config *cfg); /* * Passing NULL won't hurt, this is for convenience. */ -void yagl_egl_config_release(struct yagl_egl_config *cfg); +void yagl_egl_config_release(struct yagl_thread_state *cur_ts, struct yagl_egl_config *cfg); /* * @} diff --git a/hw/yagl/yagl_apis/egl/yagl_egl_context.c b/hw/yagl/yagl_apis/egl/yagl_egl_context.c index c4d5db9..55387a5 100644 --- a/hw/yagl/yagl_apis/egl/yagl_egl_context.c +++ b/hw/yagl/yagl_apis/egl/yagl_egl_context.c @@ -34,16 +34,16 @@ #include "yagl_eglb_context.h" #include "yagl_eglb_display.h" -static void yagl_egl_context_destroy(struct yagl_ref *ref) +static void yagl_egl_context_destroy(struct yagl_thread_state *cur_ts, struct yagl_ref *ref) { struct yagl_egl_context *ctx = (struct yagl_egl_context*)ref; assert(!ctx->draw); assert(!ctx->read); - ctx->backend_ctx->destroy(ctx->backend_ctx); + ctx->backend_ctx->destroy(cur_ts, ctx->backend_ctx); - yagl_egl_config_release(ctx->cfg); + yagl_egl_config_release(cur_ts, ctx->cfg); yagl_resource_cleanup(&ctx->res); @@ -84,7 +84,8 @@ struct yagl_egl_context return ctx; } -void yagl_egl_context_update_surfaces(struct yagl_egl_context *ctx, +void yagl_egl_context_update_surfaces(struct yagl_thread_state *cur_ts, + struct yagl_egl_context *ctx, struct yagl_egl_surface *draw, struct yagl_egl_surface *read) { @@ -99,8 +100,8 @@ void yagl_egl_context_update_surfaces(struct yagl_egl_context *ctx, ctx->draw = draw; ctx->read = read; - yagl_egl_surface_release(tmp_draw); - yagl_egl_surface_release(tmp_read); + yagl_egl_surface_release(cur_ts, tmp_draw); + yagl_egl_surface_release(cur_ts, tmp_read); } void yagl_egl_context_acquire(struct yagl_egl_context *ctx) @@ -110,9 +111,9 @@ void yagl_egl_context_acquire(struct yagl_egl_context *ctx) } } -void yagl_egl_context_release(struct yagl_egl_context *ctx) +void yagl_egl_context_release(struct yagl_thread_state *cur_ts, struct yagl_egl_context *ctx) { if (ctx) { - yagl_resource_release(&ctx->res); + yagl_resource_release(cur_ts, &ctx->res); } } diff --git a/hw/yagl/yagl_apis/egl/yagl_egl_context.h b/hw/yagl/yagl_apis/egl/yagl_egl_context.h index 762f633..d6f065b 100644 --- a/hw/yagl/yagl_apis/egl/yagl_egl_context.h +++ b/hw/yagl/yagl_apis/egl/yagl_egl_context.h @@ -63,7 +63,8 @@ struct yagl_egl_context struct yagl_eglb_context *backend_share_ctx, int version); -void yagl_egl_context_update_surfaces(struct yagl_egl_context *ctx, +void yagl_egl_context_update_surfaces(struct yagl_thread_state *cur_ts, + struct yagl_egl_context *ctx, struct yagl_egl_surface *draw, struct yagl_egl_surface *read); @@ -80,7 +81,7 @@ void yagl_egl_context_acquire(struct yagl_egl_context *ctx); /* * Passing NULL won't hurt, this is for convenience. */ -void yagl_egl_context_release(struct yagl_egl_context *ctx); +void yagl_egl_context_release(struct yagl_thread_state *cur_ts, struct yagl_egl_context *ctx); /* * @} diff --git a/hw/yagl/yagl_apis/egl/yagl_egl_display.c b/hw/yagl/yagl_apis/egl/yagl_egl_display.c index 1557fca..13272eb 100644 --- a/hw/yagl/yagl_apis/egl/yagl_egl_display.c +++ b/hw/yagl/yagl_apis/egl/yagl_egl_display.c @@ -68,13 +68,13 @@ struct yagl_egl_display return dpy; } -void yagl_egl_display_destroy(struct yagl_egl_display *dpy) +void yagl_egl_display_destroy(struct yagl_thread_state *cur_ts, struct yagl_egl_display *dpy) { - yagl_egl_display_terminate(dpy); + yagl_egl_display_terminate(cur_ts, dpy); - yagl_resource_list_cleanup(&dpy->surfaces); - yagl_resource_list_cleanup(&dpy->contexts); - yagl_resource_list_cleanup(&dpy->configs); + yagl_resource_list_cleanup(cur_ts, &dpy->surfaces); + yagl_resource_list_cleanup(cur_ts, &dpy->contexts); + yagl_resource_list_cleanup(cur_ts, &dpy->configs); dpy->backend_dpy->destroy(dpy->backend_dpy); @@ -102,7 +102,7 @@ void yagl_egl_display_initialize(struct yagl_thread_state *cur_ts, struct yagl_e for (i = 0; i < num_configs; ++i) { yagl_resource_list_add(&dpy->configs, &cfgs[i]->res); - yagl_egl_config_release(cfgs[i]); + yagl_egl_config_release(cur_ts, cfgs[i]); } g_free(cfgs); @@ -124,7 +124,7 @@ bool yagl_egl_display_is_initialized(struct yagl_egl_display *dpy) return ret; } -void yagl_egl_display_terminate(struct yagl_egl_display *dpy) +void yagl_egl_display_terminate(struct yagl_thread_state *cur_ts, struct yagl_egl_display *dpy) { struct yagl_resource_list tmp_list; @@ -140,7 +140,7 @@ void yagl_egl_display_terminate(struct yagl_egl_display *dpy) dpy->initialized = false; - yagl_resource_list_cleanup(&tmp_list); + yagl_resource_list_cleanup(cur_ts, &tmp_list); } int32_t yagl_egl_display_get_config_count(struct yagl_egl_display *dpy) @@ -226,10 +226,11 @@ struct yagl_egl_context return (struct yagl_egl_context*)yagl_resource_list_acquire(&dpy->contexts, handle); } -bool yagl_egl_display_remove_context(struct yagl_egl_display *dpy, +bool yagl_egl_display_remove_context(struct yagl_thread_state *cur_ts, + struct yagl_egl_display *dpy, yagl_host_handle handle) { - return yagl_resource_list_remove(&dpy->contexts, handle); + return yagl_resource_list_remove(cur_ts, &dpy->contexts, handle); } void yagl_egl_display_add_surface(struct yagl_egl_display *dpy, @@ -245,8 +246,9 @@ struct yagl_egl_surface return (struct yagl_egl_surface*)yagl_resource_list_acquire(&dpy->surfaces, handle); } -bool yagl_egl_display_remove_surface(struct yagl_egl_display *dpy, +bool yagl_egl_display_remove_surface(struct yagl_thread_state *cur_ts, + struct yagl_egl_display *dpy, yagl_host_handle handle) { - return yagl_resource_list_remove(&dpy->surfaces, handle); + return yagl_resource_list_remove(cur_ts, &dpy->surfaces, handle); } diff --git a/hw/yagl/yagl_apis/egl/yagl_egl_display.h b/hw/yagl/yagl_apis/egl/yagl_egl_display.h index ffc06ec..f60c9df 100644 --- a/hw/yagl/yagl_apis/egl/yagl_egl_display.h +++ b/hw/yagl/yagl_apis/egl/yagl_egl_display.h @@ -68,14 +68,15 @@ struct yagl_egl_display struct yagl_egl_backend *backend, uint32_t display_id); -void yagl_egl_display_destroy(struct yagl_egl_display *dpy); +void yagl_egl_display_destroy(struct yagl_thread_state *cur_ts, + struct yagl_egl_display *dpy); void yagl_egl_display_initialize(struct yagl_thread_state *cur_ts, struct yagl_egl_display *dpy); bool yagl_egl_display_is_initialized(struct yagl_egl_display *dpy); -void yagl_egl_display_terminate(struct yagl_egl_display *dpy); +void yagl_egl_display_terminate(struct yagl_thread_state *cur_ts, struct yagl_egl_display *dpy); /* * Configs. @@ -136,7 +137,8 @@ struct yagl_egl_context *yagl_egl_display_acquire_context(struct yagl_egl_display *dpy, yagl_host_handle handle); -bool yagl_egl_display_remove_context(struct yagl_egl_display *dpy, +bool yagl_egl_display_remove_context(struct yagl_thread_state *cur_ts, + struct yagl_egl_display *dpy, yagl_host_handle handle); /* @@ -160,7 +162,8 @@ struct yagl_egl_surface *yagl_egl_display_acquire_surface(struct yagl_egl_display *dpy, yagl_host_handle handle); -bool yagl_egl_display_remove_surface(struct yagl_egl_display *dpy, +bool yagl_egl_display_remove_surface(struct yagl_thread_state *cur_ts, + struct yagl_egl_display *dpy, yagl_host_handle handle); /* diff --git a/hw/yagl/yagl_apis/egl/yagl_egl_surface.c b/hw/yagl/yagl_apis/egl/yagl_egl_surface.c index 386dc90..356c683 100644 --- a/hw/yagl/yagl_apis/egl/yagl_egl_surface.c +++ b/hw/yagl/yagl_apis/egl/yagl_egl_surface.c @@ -32,13 +32,13 @@ #include "yagl_egl_config.h" #include "yagl_eglb_surface.h" -static void yagl_egl_surface_destroy(struct yagl_ref *ref) +static void yagl_egl_surface_destroy(struct yagl_thread_state *cur_ts, struct yagl_ref *ref) { struct yagl_egl_surface *sfc = (struct yagl_egl_surface*)ref; - sfc->backend_sfc->destroy(sfc->backend_sfc); + sfc->backend_sfc->destroy(cur_ts, sfc->backend_sfc); - yagl_egl_config_release(sfc->cfg); + yagl_egl_config_release(cur_ts, sfc->cfg); yagl_resource_cleanup(&sfc->res); @@ -69,9 +69,9 @@ void yagl_egl_surface_acquire(struct yagl_egl_surface *sfc) } } -void yagl_egl_surface_release(struct yagl_egl_surface *sfc) +void yagl_egl_surface_release(struct yagl_thread_state *cur_ts, struct yagl_egl_surface *sfc) { if (sfc) { - yagl_resource_release(&sfc->res); + yagl_resource_release(cur_ts, &sfc->res); } } diff --git a/hw/yagl/yagl_apis/egl/yagl_egl_surface.h b/hw/yagl/yagl_apis/egl/yagl_egl_surface.h index c16fb04..5b67af1 100644 --- a/hw/yagl/yagl_apis/egl/yagl_egl_surface.h +++ b/hw/yagl/yagl_apis/egl/yagl_egl_surface.h @@ -69,7 +69,7 @@ void yagl_egl_surface_acquire(struct yagl_egl_surface *sfc); /* * Passing NULL won't hurt, this is for convenience. */ -void yagl_egl_surface_release(struct yagl_egl_surface *sfc); +void yagl_egl_surface_release(struct yagl_thread_state *cur_ts, struct yagl_egl_surface *sfc); /* * @} diff --git a/hw/yagl/yagl_apis/egl/yagl_host_egl_calls.c b/hw/yagl/yagl_apis/egl/yagl_host_egl_calls.c index 1c2849b..46f120f 100644 --- a/hw/yagl/yagl_apis/egl/yagl_host_egl_calls.c +++ b/hw/yagl/yagl_apis/egl/yagl_host_egl_calls.c @@ -43,7 +43,6 @@ #include "yagl_eglb_context.h" #include "yagl_eglb_surface.h" #include "yagl_log.h" -#include "yagl_tls.h" #include "yagl_thread.h" #include "yagl_process.h" #include "yagl_object_map.h" @@ -69,35 +68,36 @@ struct yagl_egl_interface_impl struct yagl_egl_backend *backend; }; -// TODO remove and pass via argument -static YAGL_DEFINE_TLS(struct yagl_egl_api_ts*, egl_api_ts); - -static uint32_t yagl_egl_get_ctx_id(struct yagl_egl_interface *iface) +static uint32_t yagl_egl_get_ctx_id(struct yagl_thread_state *cur_ts, struct yagl_egl_interface *iface) { - if (egl_api_ts) { - return egl_api_ts->context ? egl_api_ts->context->res.handle : 0; + if (cur_ts->egl_api_ts) { + return cur_ts->egl_api_ts->context ? cur_ts->egl_api_ts->context->res.handle : 0; } else { return 0; } } -static void yagl_egl_ensure_ctx(struct yagl_egl_interface *iface, uint32_t ctx_id) +static void yagl_egl_ensure_ctx(struct yagl_thread_state *cur_ts, + struct yagl_egl_interface *iface, + uint32_t ctx_id) { struct yagl_egl_interface_impl *egl_iface = (struct yagl_egl_interface_impl*)iface; - uint32_t current_ctx_id = yagl_egl_get_ctx_id(iface); + uint32_t current_ctx_id = yagl_egl_get_ctx_id(cur_ts, iface); if (!current_ctx_id || (ctx_id && (current_ctx_id != ctx_id))) { - egl_iface->backend->ensure_current(egl_iface->backend); + egl_iface->backend->ensure_current(cur_ts, egl_iface->backend); } } -static void yagl_egl_unensure_ctx(struct yagl_egl_interface *iface, uint32_t ctx_id) +static void yagl_egl_unensure_ctx(struct yagl_thread_state *cur_ts, + struct yagl_egl_interface *iface, + uint32_t ctx_id) { struct yagl_egl_interface_impl *egl_iface = (struct yagl_egl_interface_impl*)iface; - uint32_t current_ctx_id = yagl_egl_get_ctx_id(iface); + uint32_t current_ctx_id = yagl_egl_get_ctx_id(cur_ts, iface); if (!current_ctx_id || (ctx_id && (current_ctx_id != ctx_id))) { - egl_iface->backend->unensure_current(egl_iface->backend); + egl_iface->backend->unensure_current(cur_ts, egl_iface->backend); } } @@ -108,7 +108,7 @@ static __inline bool yagl_validate_display(struct yagl_thread_state *cur_ts, { YAGL_LOG_FUNC_SET(yagl_validate_display); - *dpy = yagl_egl_api_ps_display_get(egl_api_ts->api_ps, dpy_); + *dpy = yagl_egl_api_ps_display_get(cur_ts->egl_api_ts->api_ps, dpy_); if (!*dpy) { YAGL_SET_ERR(EGL_BAD_DISPLAY); @@ -179,6 +179,8 @@ static __inline bool yagl_validate_context(struct yagl_thread_state *cur_ts, static bool yagl_egl_release_current_context(struct yagl_thread_state *cur_ts, struct yagl_egl_display *dpy) { + struct yagl_egl_api_ts *egl_api_ts = (cur_ts ? cur_ts->egl_api_ts : NULL); + if (!egl_api_ts->context) { return true; } @@ -187,9 +189,9 @@ static bool yagl_egl_release_current_context(struct yagl_thread_state *cur_ts, s return false; } - yagl_egl_context_update_surfaces(egl_api_ts->context, NULL, NULL); + yagl_egl_context_update_surfaces(cur_ts, egl_api_ts->context, NULL, NULL); - yagl_egl_api_ts_update_context(egl_api_ts, NULL); + yagl_egl_api_ts_update_context(cur_ts, egl_api_ts, NULL); return true; } @@ -212,11 +214,9 @@ static void yagl_host_egl_thread_init(struct yagl_thread_state *cur_ts, struct y egl_api_ps->backend->thread_init(cur_ts, egl_api_ps->backend); - egl_api_ts = g_malloc0(sizeof(*egl_api_ts)); - - yagl_egl_api_ts_init(cur_ts, egl_api_ts, egl_api_ps); + cur_ts->egl_api_ts = g_malloc0(sizeof(struct yagl_egl_api_ts)); - cur_ts->egl_api_ts = egl_api_ts; + yagl_egl_api_ts_init(cur_ts, cur_ts->egl_api_ts, egl_api_ps); YAGL_LOG_FUNC_EXIT(NULL); } @@ -225,9 +225,6 @@ static void yagl_host_egl_batch_start(struct yagl_thread_state *cur_ts, struct y { struct yagl_egl_api_ps *egl_api_ps = (struct yagl_egl_api_ps*)api_ps; - // TODO also remove - egl_api_ts = cur_ts->egl_api_ts; - egl_api_ps->backend->batch_start(cur_ts, egl_api_ps->backend); } @@ -244,16 +241,13 @@ static void yagl_host_egl_thread_fini(struct yagl_thread_state *cur_ts, struct y YAGL_LOG_FUNC_ENTER(yagl_host_egl_thread_fini, NULL); - // TODO also remove - egl_api_ts = cur_ts->egl_api_ts; - egl_api_ps->backend->batch_start(cur_ts, egl_api_ps->backend); - yagl_egl_api_ts_cleanup(cur_ts, egl_api_ts); + yagl_egl_api_ts_cleanup(cur_ts, cur_ts->egl_api_ts); - g_free(egl_api_ts); + g_free(cur_ts->egl_api_ts); - egl_api_ts = cur_ts->egl_api_ts = NULL; + cur_ts->egl_api_ts = NULL; egl_api_ps->backend->batch_end(cur_ts, egl_api_ps->backend); egl_api_ps->backend->thread_fini(cur_ts, egl_api_ps->backend); @@ -267,7 +261,7 @@ static void yagl_host_egl_process_destroy(struct yagl_thread_state *cur_ts, stru YAGL_LOG_FUNC_ENTER(yagl_host_egl_process_destroy, NULL); - yagl_egl_api_ps_cleanup(egl_api_ps); + yagl_egl_api_ps_cleanup(cur_ts, egl_api_ps); yagl_process_unregister_egl_interface(cur_ts->ps); @@ -330,7 +324,7 @@ yagl_host_handle yagl_host_eglGetDisplay(struct yagl_thread_state *cur_ts, { struct yagl_egl_display *dpy; - dpy = yagl_egl_api_ps_display_add(cur_ts, egl_api_ts->api_ps, display_id); + dpy = yagl_egl_api_ps_display_add(cur_ts, cur_ts->egl_api_ts->api_ps, display_id); return (dpy ? dpy->handle : 0); } @@ -345,7 +339,7 @@ EGLBoolean yagl_host_eglInitialize(struct yagl_thread_state *cur_ts, YAGL_LOG_FUNC_SET(eglInitialize); - dpy = yagl_egl_api_ps_display_get(egl_api_ts->api_ps, dpy_); + dpy = yagl_egl_api_ps_display_get(cur_ts->egl_api_ts->api_ps, dpy_); if (!dpy) { YAGL_SET_ERR(EGL_BAD_DISPLAY); @@ -375,7 +369,7 @@ EGLBoolean yagl_host_eglTerminate(struct yagl_thread_state *cur_ts, return EGL_FALSE; } - yagl_egl_display_terminate(dpy); + yagl_egl_display_terminate(cur_ts, dpy); return EGL_TRUE; } @@ -639,7 +633,7 @@ EGLBoolean yagl_host_eglChooseConfig(struct yagl_thread_state *cur_ts, yagl_host if (cfg) { handle = cfg->res.handle; - yagl_egl_config_release(cfg); + yagl_egl_config_release(cur_ts, cfg); } YAGL_LOG_DEBUG("requesting config with id = %d", config_id); @@ -705,7 +699,7 @@ EGLBoolean yagl_host_eglGetConfigAttrib(struct yagl_thread_state *cur_ts, res = EGL_TRUE; out: - yagl_egl_config_release(config); + yagl_egl_config_release(cur_ts, config); return res; } @@ -729,7 +723,7 @@ EGLBoolean yagl_host_eglDestroySurface(struct yagl_thread_state *cur_ts, goto out; } - if (!yagl_egl_display_remove_surface(dpy, surface->res.handle)) { + if (!yagl_egl_display_remove_surface(cur_ts, dpy, surface->res.handle)) { YAGL_SET_ERR(EGL_BAD_SURFACE); goto out; } @@ -737,7 +731,7 @@ EGLBoolean yagl_host_eglDestroySurface(struct yagl_thread_state *cur_ts, res = EGL_TRUE; out: - yagl_egl_surface_release(surface); + yagl_egl_surface_release(cur_ts, surface); return res; } @@ -846,25 +840,25 @@ EGLBoolean yagl_host_eglQuerySurface(struct yagl_thread_state *cur_ts, res = EGL_TRUE; out: - yagl_egl_surface_release(surface); + yagl_egl_surface_release(cur_ts, surface); return res; } -void yagl_host_eglBindAPI(EGLenum api) +void yagl_host_eglBindAPI(struct yagl_thread_state *cur_ts, EGLenum api) { - egl_api_ts->api = api; + cur_ts->egl_api_ts->api = api; } void yagl_host_eglWaitClient(struct yagl_thread_state *cur_ts) { struct yagl_egl_surface *sfc = NULL; - if (!egl_api_ts->context) { + if (!cur_ts->egl_api_ts->context) { return; } - sfc = egl_api_ts->context->draw; + sfc = cur_ts->egl_api_ts->context->draw; if (!sfc) { return; @@ -880,14 +874,14 @@ EGLBoolean yagl_host_eglReleaseThread(struct yagl_thread_state *cur_ts, EGLint * YAGL_LOG_FUNC_SET(eglReleaseThread); - if (egl_api_ts->context) { - if (!yagl_egl_release_current_context(cur_ts, egl_api_ts->context->dpy)) { + if (cur_ts->egl_api_ts->context) { + if (!yagl_egl_release_current_context(cur_ts, cur_ts->egl_api_ts->context->dpy)) { YAGL_SET_ERR(EGL_BAD_ACCESS); goto out; } } - yagl_egl_api_ts_reset(egl_api_ts); + yagl_egl_api_ts_reset(cur_ts->egl_api_ts); res = EGL_TRUE; @@ -921,7 +915,7 @@ EGLBoolean yagl_host_eglSurfaceAttrib(struct yagl_thread_state *cur_ts, res = EGL_TRUE; out: - yagl_egl_surface_release(surface); + yagl_egl_surface_release(cur_ts, surface); return res; } @@ -950,7 +944,7 @@ yagl_host_handle yagl_host_eglCreateContext(struct yagl_thread_state *cur_ts, goto out; } - if (egl_api_ts->api == EGL_OPENGL_ES_API) { + if (cur_ts->egl_api_ts->api == EGL_OPENGL_ES_API) { if (!yagl_egl_is_attrib_list_empty(attrib_list)) { while (attrib_list[i] != EGL_NONE) { switch (attrib_list[i]) { @@ -985,13 +979,13 @@ yagl_host_handle yagl_host_eglCreateContext(struct yagl_thread_state *cur_ts, } yagl_egl_display_add_context(dpy, ctx); - yagl_egl_context_release(ctx); + yagl_egl_context_release(cur_ts, ctx); res = ctx->res.handle; out: - yagl_egl_context_release(share_context); - yagl_egl_config_release(config); + yagl_egl_context_release(cur_ts, share_context); + yagl_egl_config_release(cur_ts, config); return res; } @@ -1015,14 +1009,14 @@ EGLBoolean yagl_host_eglDestroyContext(struct yagl_thread_state *cur_ts, goto out; } - if (yagl_egl_display_remove_context(dpy, ctx->res.handle)) { + if (yagl_egl_display_remove_context(cur_ts, dpy, ctx->res.handle)) { res = EGL_TRUE; } else { YAGL_SET_ERR(EGL_BAD_CONTEXT); } out: - yagl_egl_context_release(ctx); + yagl_egl_context_release(cur_ts, ctx); return res; } @@ -1040,6 +1034,7 @@ void yagl_host_eglMakeCurrent(struct yagl_thread_state *cur_ts, struct yagl_egl_context *ctx = NULL; struct yagl_egl_surface *draw = NULL; struct yagl_egl_surface *read = NULL; + struct yagl_egl_api_ts *egl_api_ts = cur_ts->egl_api_ts; YAGL_LOG_FUNC_SET(eglMakeCurrent); @@ -1086,13 +1081,13 @@ void yagl_host_eglMakeCurrent(struct yagl_thread_state *cur_ts, goto out; } - yagl_egl_context_update_surfaces(ctx, draw, read); + yagl_egl_context_update_surfaces(cur_ts, ctx, draw, read); - yagl_egl_api_ts_update_context(egl_api_ts, ctx); + yagl_egl_api_ts_update_context(cur_ts, egl_api_ts, ctx); } if (release_context && prev_ctx) { - yagl_egl_context_update_surfaces(prev_ctx, NULL, NULL); + yagl_egl_context_update_surfaces(cur_ts, prev_ctx, NULL, NULL); } YAGL_LOG_TRACE("Context switched (%u, %u, %u, %u)", @@ -1102,10 +1097,10 @@ void yagl_host_eglMakeCurrent(struct yagl_thread_state *cur_ts, ctx_); out: - yagl_egl_surface_release(read); - yagl_egl_surface_release(draw); - yagl_egl_context_release(ctx); - yagl_egl_context_release(prev_ctx); + yagl_egl_surface_release(cur_ts, read); + yagl_egl_surface_release(cur_ts, draw); + yagl_egl_context_release(cur_ts, ctx); + yagl_egl_context_release(cur_ts, prev_ctx); } EGLBoolean yagl_host_eglQueryContext(struct yagl_thread_state *cur_ts, @@ -1167,7 +1162,7 @@ EGLBoolean yagl_host_eglQueryContext(struct yagl_thread_state *cur_ts, res = EGL_TRUE; out: - yagl_egl_context_release(ctx); + yagl_egl_context_release(cur_ts, ctx); return res; } @@ -1191,7 +1186,7 @@ void yagl_host_eglSwapBuffers(struct yagl_thread_state *cur_ts, surface->backend_sfc->swap_buffers(cur_ts, surface->backend_sfc); out: - yagl_egl_surface_release(surface); + yagl_egl_surface_release(cur_ts, surface); } void yagl_host_eglCopyBuffers(struct yagl_thread_state *cur_ts, @@ -1213,7 +1208,7 @@ void yagl_host_eglCopyBuffers(struct yagl_thread_state *cur_ts, surface->backend_sfc->copy_buffers(cur_ts, surface->backend_sfc); out: - yagl_egl_surface_release(surface); + yagl_egl_surface_release(cur_ts, surface); } yagl_host_handle yagl_host_eglCreateWindowSurfaceOffscreenYAGL(struct yagl_thread_state *cur_ts, @@ -1294,14 +1289,14 @@ yagl_host_handle yagl_host_eglCreateWindowSurfaceOffscreenYAGL(struct yagl_threa backend_sfc = NULL; yagl_egl_display_add_surface(dpy, surface); - yagl_egl_surface_release(surface); + yagl_egl_surface_release(cur_ts, surface); res = surface->res.handle; out: - yagl_egl_config_release(config); + yagl_egl_config_release(cur_ts, config); if (backend_sfc) { - backend_sfc->destroy(backend_sfc); + backend_sfc->destroy(cur_ts, backend_sfc); } return res; @@ -1415,14 +1410,14 @@ yagl_host_handle yagl_host_eglCreatePbufferSurfaceOffscreenYAGL(struct yagl_thre backend_sfc = NULL; yagl_egl_display_add_surface(dpy, surface); - yagl_egl_surface_release(surface); + yagl_egl_surface_release(cur_ts, surface); res = surface->res.handle; out: - yagl_egl_config_release(config); + yagl_egl_config_release(cur_ts, config); if (backend_sfc) { - backend_sfc->destroy(backend_sfc); + backend_sfc->destroy(cur_ts, backend_sfc); } return res; @@ -1496,14 +1491,14 @@ yagl_host_handle yagl_host_eglCreatePixmapSurfaceOffscreenYAGL(struct yagl_threa backend_sfc = NULL; yagl_egl_display_add_surface(dpy, surface); - yagl_egl_surface_release(surface); + yagl_egl_surface_release(cur_ts, surface); res = surface->res.handle; out: - yagl_egl_config_release(config); + yagl_egl_config_release(cur_ts, config); if (backend_sfc) { - backend_sfc->destroy(backend_sfc); + backend_sfc->destroy(cur_ts, backend_sfc); } return res; @@ -1524,6 +1519,7 @@ EGLBoolean yagl_host_eglResizeOffscreenSurfaceYAGL(struct yagl_thread_state *cur struct yagl_eglb_surface *backend_sfc = NULL; struct yagl_eglb_surface *draw_sfc = NULL; struct yagl_eglb_surface *read_sfc = NULL; + struct yagl_egl_api_ts *egl_api_ts = cur_ts->egl_api_ts; YAGL_LOG_FUNC_SET(eglResizeOffscreenSurfaceYAGL); @@ -1591,9 +1587,9 @@ EGLBoolean yagl_host_eglResizeOffscreenSurfaceYAGL(struct yagl_thread_state *cur out: if (backend_sfc) { - backend_sfc->destroy(backend_sfc); + backend_sfc->destroy(cur_ts, backend_sfc); } - yagl_egl_surface_release(surface); + yagl_egl_surface_release(cur_ts, surface); return res; } @@ -1670,14 +1666,14 @@ yagl_host_handle yagl_host_eglCreateWindowSurfaceOnscreenYAGL(struct yagl_thread backend_sfc = NULL; yagl_egl_display_add_surface(dpy, surface); - yagl_egl_surface_release(surface); + yagl_egl_surface_release(cur_ts, surface); res = surface->res.handle; out: - yagl_egl_config_release(config); + yagl_egl_config_release(cur_ts, config); if (backend_sfc) { - backend_sfc->destroy(backend_sfc); + backend_sfc->destroy(cur_ts, backend_sfc); } return res; @@ -1784,14 +1780,14 @@ yagl_host_handle yagl_host_eglCreatePbufferSurfaceOnscreenYAGL(struct yagl_threa backend_sfc = NULL; yagl_egl_display_add_surface(dpy, surface); - yagl_egl_surface_release(surface); + yagl_egl_surface_release(cur_ts, surface); res = surface->res.handle; out: - yagl_egl_config_release(config); + yagl_egl_config_release(cur_ts, config); if (backend_sfc) { - backend_sfc->destroy(backend_sfc); + backend_sfc->destroy(cur_ts, backend_sfc); } return res; @@ -1859,14 +1855,14 @@ yagl_host_handle yagl_host_eglCreatePixmapSurfaceOnscreenYAGL(struct yagl_thread backend_sfc = NULL; yagl_egl_display_add_surface(dpy, surface); - yagl_egl_surface_release(surface); + yagl_egl_surface_release(cur_ts, surface); res = surface->res.handle; out: - yagl_egl_config_release(config); + yagl_egl_config_release(cur_ts, config); if (backend_sfc) { - backend_sfc->destroy(backend_sfc); + backend_sfc->destroy(cur_ts, backend_sfc); } return res; @@ -1892,7 +1888,7 @@ void yagl_host_eglInvalidateOnscreenSurfaceYAGL(struct yagl_thread_state *cur_ts surface->backend_sfc->invalidate(cur_ts, surface->backend_sfc, buffer); out: - yagl_egl_surface_release(surface); + yagl_egl_surface_release(cur_ts, surface); } EGLBoolean yagl_host_eglCreateImageYAGL(struct yagl_thread_state *cur_ts, diff --git a/hw/yagl/yagl_apis/egl/yagl_host_egl_calls.h b/hw/yagl/yagl_apis/egl/yagl_host_egl_calls.h index 3a230cc..6012dc3 100644 --- a/hw/yagl/yagl_apis/egl/yagl_host_egl_calls.h +++ b/hw/yagl/yagl_apis/egl/yagl_host_egl_calls.h @@ -69,7 +69,7 @@ EGLBoolean yagl_host_eglQuerySurface(struct yagl_thread_state *cur_ts, EGLint attribute, EGLint *value, EGLint *error); -void yagl_host_eglBindAPI(EGLenum api); +void yagl_host_eglBindAPI(struct yagl_thread_state *cur_ts, EGLenum api); void yagl_host_eglWaitClient(struct yagl_thread_state *cur_ts); EGLBoolean yagl_host_eglReleaseThread(struct yagl_thread_state *cur_ts, EGLint *error); EGLBoolean yagl_host_eglSurfaceAttrib(struct yagl_thread_state *cur_ts, diff --git a/hw/yagl/yagl_apis/gles/yagl_gles_api_ts.c b/hw/yagl/yagl_apis/gles/yagl_gles_api_ts.c index e7868cb..23b153b 100644 --- a/hw/yagl/yagl_apis/gles/yagl_gles_api_ts.c +++ b/hw/yagl/yagl_apis/gles/yagl_gles_api_ts.c @@ -245,7 +245,7 @@ void yagl_gles_api_ts_init(struct yagl_thread_state *cur_ts, return; } - yagl_ensure_ctx(cur_ts->ps, 0); + yagl_ensure_ctx(cur_ts, 0); if (driver->gl_version > yagl_gl_2) { gles_api_ts->api->use_map_buffer_range = true; @@ -266,7 +266,7 @@ void yagl_gles_api_ts_init(struct yagl_thread_state *cur_ts, gles_api_ts->api->broken_ubo = false; } - yagl_unensure_ctx(cur_ts->ps, 0); + yagl_unensure_ctx(cur_ts, 0); gles_api_ts->api->checked = true; } @@ -277,7 +277,7 @@ void yagl_gles_api_ts_cleanup(struct yagl_thread_state *cur_ts, if (gles_api_ts->num_arrays > 0) { uint32_t i; - yagl_ensure_ctx(cur_ts->ps, 0); + yagl_ensure_ctx(cur_ts, 0); if (gles_api_ts->ebo) { gles_api_ts->driver->DeleteBuffers(1, &gles_api_ts->ebo); @@ -288,7 +288,7 @@ void yagl_gles_api_ts_cleanup(struct yagl_thread_state *cur_ts, &gles_api_ts->arrays[i].vbo); } - yagl_unensure_ctx(cur_ts->ps, 0); + yagl_unensure_ctx(cur_ts, 0); } g_free(gles_api_ts->arrays); diff --git a/hw/yagl/yagl_apis/gles/yagl_host_gles_calls.c b/hw/yagl/yagl_apis/gles/yagl_host_gles_calls.c index e46f32e..09131dc 100644 --- a/hw/yagl/yagl_apis/gles/yagl_host_gles_calls.c +++ b/hw/yagl/yagl_apis/gles/yagl_host_gles_calls.c @@ -33,7 +33,6 @@ #include "yagl_gles_driver.h" #include "yagl_gles_api_ps.h" #include "yagl_gles_api_ts.h" -#include "yagl_tls.h" #include "yagl_log.h" #include "yagl_process.h" #include "yagl_thread.h" @@ -41,9 +40,6 @@ #include "yagl_object_map.h" #include "yagl_transport.h" -// TODO remove and pass via argument -static YAGL_DEFINE_TLS(struct yagl_gles_api_ts*, gles_api_ts); - struct yagl_gles_object { struct yagl_object base; @@ -72,6 +68,7 @@ static GLuint yagl_gles_bind_array(struct yagl_thread_state *cur_ts, GLuint current_vbo; uint32_t size; void *ptr; + struct yagl_gles_api_ts *gles_api_ts = cur_ts->gles_api_ts; YAGL_LOG_FUNC_SET(yagl_gles_bind_array); @@ -96,10 +93,10 @@ static GLuint yagl_gles_bind_array(struct yagl_thread_state *cur_ts, gles_api_ts->num_arrays = indx + 1; } - gles_api_ts->driver->GetIntegerv(GL_ARRAY_BUFFER_BINDING, + cur_ts->gles_api_ts->driver->GetIntegerv(GL_ARRAY_BUFFER_BINDING, (GLint*)¤t_vbo); - gles_api_ts->driver->BindBuffer(GL_ARRAY_BUFFER, gles_api_ts->arrays[indx].vbo); + cur_ts->gles_api_ts->driver->BindBuffer(GL_ARRAY_BUFFER, gles_api_ts->arrays[indx].vbo); size = first * stride + data_count; @@ -148,6 +145,7 @@ static GLuint yagl_gles_bind_ebo(struct yagl_thread_state *cur_ts, { GLuint current_ebo; void *ptr; + struct yagl_gles_api_ts *gles_api_ts = cur_ts->gles_api_ts; YAGL_LOG_FUNC_SET(yagl_gles_bind_ebo); @@ -155,10 +153,10 @@ static GLuint yagl_gles_bind_ebo(struct yagl_thread_state *cur_ts, gles_api_ts->driver->GenBuffers(1, &gles_api_ts->ebo); } - gles_api_ts->driver->GetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, + cur_ts->gles_api_ts->driver->GetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, (GLint*)¤t_ebo); - gles_api_ts->driver->BindBuffer(GL_ELEMENT_ARRAY_BUFFER, gles_api_ts->ebo); + cur_ts->gles_api_ts->driver->BindBuffer(GL_ELEMENT_ARRAY_BUFFER, gles_api_ts->ebo); if (size > gles_api_ts->ebo_size) { gles_api_ts->driver->BufferData(GL_ELEMENT_ARRAY_BUFFER, @@ -208,6 +206,7 @@ static bool yagl_gles_program_get_uniform_type(struct yagl_thread_state *cur_ts, GLint uniform_name_max_length = 0; GLchar *uniform_name = NULL; bool res = false; + struct yagl_gles_api_ts *gles_api_ts = cur_ts->gles_api_ts; YAGL_LOG_FUNC_SET(yagl_gles_program_get_uniform_type); @@ -215,7 +214,7 @@ static bool yagl_gles_program_get_uniform_type(struct yagl_thread_state *cur_ts, return false; } - gles_api_ts->driver->GetProgramiv(program, + cur_ts->gles_api_ts->driver->GetProgramiv(program, GL_LINK_STATUS, &link_status); @@ -223,11 +222,11 @@ static bool yagl_gles_program_get_uniform_type(struct yagl_thread_state *cur_ts, return false; } - gles_api_ts->driver->GetProgramiv(program, + cur_ts->gles_api_ts->driver->GetProgramiv(program, GL_ACTIVE_UNIFORMS, &num_active_uniforms); - gles_api_ts->driver->GetProgramiv(program, + cur_ts->gles_api_ts->driver->GetProgramiv(program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &uniform_name_max_length); @@ -321,181 +320,180 @@ static bool yagl_gles_get_array_param_count(GLenum pname, int *count) return true; } -static void yagl_gles_object_add(struct yagl_process_state *ps, +static void yagl_gles_object_add(struct yagl_thread_state *cur_ts, GLuint local_name, GLuint global_name, uint32_t ctx_id, - void (*destroy_func)(struct yagl_object */*obj*/)) + yagl_object_destroy_func destroy_func) { struct yagl_gles_object *obj; obj = g_malloc(sizeof(*obj)); obj->base.global_name = global_name; - obj->base.ps = ps; obj->base.destroy = destroy_func; - obj->driver = gles_api_ts->driver; + obj->driver = cur_ts->gles_api_ts->driver; obj->ctx_id = ctx_id; - yagl_object_map_add(ps->object_map, + yagl_object_map_add(cur_ts->ps->object_map, local_name, &obj->base); } -static void yagl_gles_buffer_destroy(struct yagl_object *obj) +static void yagl_gles_buffer_destroy(struct yagl_thread_state *cur_ts, + struct yagl_object *obj) { struct yagl_gles_object *gles_obj = (struct yagl_gles_object*)obj; - YAGL_LOG_NO_TS; YAGL_LOG_FUNC_ENTER(yagl_gles_buffer_destroy, "%u", obj->global_name); - yagl_ensure_ctx(obj->ps, 0); + yagl_ensure_ctx(cur_ts, 0); gles_obj->driver->DeleteBuffers(1, &obj->global_name); - yagl_unensure_ctx(obj->ps, 0); + yagl_unensure_ctx(cur_ts, 0); g_free(gles_obj); YAGL_LOG_FUNC_EXIT(NULL); } -static void yagl_gles_texture_destroy(struct yagl_object *obj) +static void yagl_gles_texture_destroy(struct yagl_thread_state *cur_ts, + struct yagl_object *obj) { struct yagl_gles_object *gles_obj = (struct yagl_gles_object*)obj; - YAGL_LOG_NO_TS; YAGL_LOG_FUNC_ENTER(yagl_gles_texture_destroy, "%u", obj->global_name); - yagl_ensure_ctx(obj->ps, 0); + yagl_ensure_ctx(cur_ts, 0); gles_obj->driver->DeleteTextures(1, &obj->global_name); - yagl_unensure_ctx(obj->ps, 0); + yagl_unensure_ctx(cur_ts, 0); g_free(gles_obj); YAGL_LOG_FUNC_EXIT(NULL); } -static void yagl_gles_framebuffer_destroy(struct yagl_object *obj) +static void yagl_gles_framebuffer_destroy(struct yagl_thread_state *cur_ts, + struct yagl_object *obj) { struct yagl_gles_object *gles_obj = (struct yagl_gles_object*)obj; - YAGL_LOG_NO_TS; YAGL_LOG_FUNC_ENTER(yagl_gles_framebuffer_destroy, "%u", obj->global_name); - yagl_ensure_ctx(obj->ps, gles_obj->ctx_id); + yagl_ensure_ctx(cur_ts, gles_obj->ctx_id); gles_obj->driver->DeleteFramebuffers(1, &obj->global_name); - yagl_unensure_ctx(obj->ps, gles_obj->ctx_id); + yagl_unensure_ctx(cur_ts, gles_obj->ctx_id); g_free(gles_obj); YAGL_LOG_FUNC_EXIT(NULL); } -static void yagl_gles_renderbuffer_destroy(struct yagl_object *obj) +static void yagl_gles_renderbuffer_destroy(struct yagl_thread_state *cur_ts, + struct yagl_object *obj) { struct yagl_gles_object *gles_obj = (struct yagl_gles_object*)obj; - YAGL_LOG_NO_TS; YAGL_LOG_FUNC_ENTER(yagl_gles_renderbuffer_destroy, "%u", obj->global_name); - yagl_ensure_ctx(obj->ps, 0); + yagl_ensure_ctx(cur_ts, 0); gles_obj->driver->DeleteRenderbuffers(1, &obj->global_name); - yagl_unensure_ctx(obj->ps, 0); + yagl_unensure_ctx(cur_ts, 0); g_free(gles_obj); YAGL_LOG_FUNC_EXIT(NULL); } -static void yagl_gles_program_destroy(struct yagl_object *obj) +static void yagl_gles_program_destroy(struct yagl_thread_state *cur_ts, + struct yagl_object *obj) { struct yagl_gles_object *gles_obj = (struct yagl_gles_object*)obj; - YAGL_LOG_NO_TS; YAGL_LOG_FUNC_ENTER(yagl_gles_program_destroy, "%u", obj->global_name); - yagl_ensure_ctx(obj->ps, 0); + yagl_ensure_ctx(cur_ts, 0); gles_obj->driver->DeleteProgram(obj->global_name); - yagl_unensure_ctx(obj->ps, 0); + yagl_unensure_ctx(cur_ts, 0); g_free(gles_obj); YAGL_LOG_FUNC_EXIT(NULL); } -static void yagl_gles_shader_destroy(struct yagl_object *obj) +static void yagl_gles_shader_destroy(struct yagl_thread_state *cur_ts, + struct yagl_object *obj) { struct yagl_gles_object *gles_obj = (struct yagl_gles_object*)obj; - YAGL_LOG_NO_TS; YAGL_LOG_FUNC_ENTER(yagl_gles_shader_destroy, "%u", obj->global_name); - yagl_ensure_ctx(obj->ps, 0); + yagl_ensure_ctx(cur_ts, 0); gles_obj->driver->DeleteShader(obj->global_name); - yagl_unensure_ctx(obj->ps, 0); + yagl_unensure_ctx(cur_ts, 0); g_free(gles_obj); YAGL_LOG_FUNC_EXIT(NULL); } -static void yagl_gles_vertex_array_destroy(struct yagl_object *obj) +static void yagl_gles_vertex_array_destroy(struct yagl_thread_state *cur_ts, + struct yagl_object *obj) { struct yagl_gles_object *gles_obj = (struct yagl_gles_object*)obj; - YAGL_LOG_NO_TS; YAGL_LOG_FUNC_ENTER(yagl_gles_vertex_array_destroy, "%u", obj->global_name); - yagl_ensure_ctx(obj->ps, gles_obj->ctx_id); + yagl_ensure_ctx(cur_ts, gles_obj->ctx_id); gles_obj->driver->DeleteVertexArrays(1, &obj->global_name); - yagl_unensure_ctx(obj->ps, gles_obj->ctx_id); + yagl_unensure_ctx(cur_ts, gles_obj->ctx_id); g_free(gles_obj); YAGL_LOG_FUNC_EXIT(NULL); } -static void yagl_gles_transform_feedback_destroy(struct yagl_object *obj) +static void yagl_gles_transform_feedback_destroy(struct yagl_thread_state *cur_ts, + struct yagl_object *obj) { struct yagl_gles_object *gles_obj = (struct yagl_gles_object*)obj; - YAGL_LOG_NO_TS; YAGL_LOG_FUNC_ENTER(yagl_gles_transform_feedback_destroy, "%u", obj->global_name); - yagl_ensure_ctx(obj->ps, gles_obj->ctx_id); + yagl_ensure_ctx(cur_ts, gles_obj->ctx_id); gles_obj->driver->DeleteTransformFeedbacks(1, &obj->global_name); - yagl_unensure_ctx(obj->ps, gles_obj->ctx_id); + yagl_unensure_ctx(cur_ts, gles_obj->ctx_id); g_free(gles_obj); YAGL_LOG_FUNC_EXIT(NULL); } -static void yagl_gles_query_destroy(struct yagl_object *obj) +static void yagl_gles_query_destroy(struct yagl_thread_state *cur_ts, + struct yagl_object *obj) { struct yagl_gles_object *gles_obj = (struct yagl_gles_object*)obj; - YAGL_LOG_NO_TS; YAGL_LOG_FUNC_ENTER(yagl_gles_query_destroy, "%u", obj->global_name); - yagl_ensure_ctx(obj->ps, gles_obj->ctx_id); + yagl_ensure_ctx(cur_ts, gles_obj->ctx_id); gles_obj->driver->DeleteQueries(1, &obj->global_name); - yagl_unensure_ctx(obj->ps, gles_obj->ctx_id); + yagl_unensure_ctx(cur_ts, gles_obj->ctx_id); g_free(gles_obj); YAGL_LOG_FUNC_EXIT(NULL); } -static void yagl_gles_sampler_destroy(struct yagl_object *obj) +static void yagl_gles_sampler_destroy(struct yagl_thread_state *cur_ts, + struct yagl_object *obj) { struct yagl_gles_object *gles_obj = (struct yagl_gles_object*)obj; - YAGL_LOG_NO_TS; YAGL_LOG_FUNC_ENTER(yagl_gles_sampler_destroy, "%u", obj->global_name); - yagl_ensure_ctx(obj->ps, 0); + yagl_ensure_ctx(cur_ts, 0); gles_obj->driver->DeleteSamplers(1, &obj->global_name); - yagl_unensure_ctx(obj->ps, 0); + yagl_unensure_ctx(cur_ts, 0); g_free(gles_obj); @@ -525,11 +523,9 @@ static void yagl_host_gles_thread_init(struct yagl_thread_state *cur_ts, YAGL_LOG_FUNC_ENTER(yagl_host_gles_thread_init, NULL); - gles_api_ts = g_malloc0(sizeof(*gles_api_ts)); - - yagl_gles_api_ts_init(cur_ts, gles_api_ts, gles_api_ps->driver, gles_api_ps); + cur_ts->gles_api_ts = g_malloc0(sizeof(struct yagl_gles_api_ts)); - cur_ts->gles_api_ts = gles_api_ts; + yagl_gles_api_ts_init(cur_ts, cur_ts->gles_api_ts, gles_api_ps->driver, gles_api_ps); YAGL_LOG_FUNC_EXIT(NULL); } @@ -537,7 +533,6 @@ static void yagl_host_gles_thread_init(struct yagl_thread_state *cur_ts, static void yagl_host_gles_batch_start(struct yagl_thread_state *cur_ts, struct yagl_api_ps *api_ps) { - gles_api_ts = cur_ts->gles_api_ts; } static void yagl_host_gles_batch_end(struct yagl_thread_state *cur_ts, @@ -550,13 +545,11 @@ static void yagl_host_gles_thread_fini(struct yagl_thread_state *cur_ts, { YAGL_LOG_FUNC_ENTER(yagl_host_gles_thread_fini, NULL); - gles_api_ts = cur_ts->gles_api_ts; - - yagl_gles_api_ts_cleanup(cur_ts, gles_api_ts); + yagl_gles_api_ts_cleanup(cur_ts, cur_ts->gles_api_ts); - g_free(gles_api_ts); + g_free(cur_ts->gles_api_ts); - gles_api_ts = cur_ts->gles_api_ts = NULL; + cur_ts->gles_api_ts = NULL; YAGL_LOG_FUNC_EXIT(NULL); } @@ -608,7 +601,7 @@ void yagl_host_glDrawArrays(struct yagl_thread_state *cur_ts, GLint first, GLsizei count) { - gles_api_ts->driver->DrawArrays(mode, first, count); + cur_ts->gles_api_ts->driver->DrawArrays(mode, first, count); } void yagl_host_glDrawElements(struct yagl_thread_state *cur_ts, @@ -620,12 +613,12 @@ void yagl_host_glDrawElements(struct yagl_thread_state *cur_ts, if (indices) { GLuint current_ebo = yagl_gles_bind_ebo(cur_ts, indices, indices_count); - gles_api_ts->driver->DrawElements(mode, count, type, NULL); + cur_ts->gles_api_ts->driver->DrawElements(mode, count, type, NULL); - gles_api_ts->driver->BindBuffer(GL_ELEMENT_ARRAY_BUFFER, current_ebo); + cur_ts->gles_api_ts->driver->BindBuffer(GL_ELEMENT_ARRAY_BUFFER, current_ebo); } else { - gles_api_ts->driver->DrawElements(mode, count, type, - (const GLvoid*)(uintptr_t)indices_count); + cur_ts->gles_api_ts->driver->DrawElements(mode, count, type, + (const GLvoid*)(uintptr_t)indices_count); } } @@ -638,13 +631,13 @@ void yagl_host_glReadPixelsData(struct yagl_thread_state *cur_ts, GLenum type, GLvoid *pixels, int32_t pixels_maxcount, int32_t *pixels_count) { - gles_api_ts->driver->ReadPixels(x, - y, - width, - height, - format, - type, - pixels); + cur_ts->gles_api_ts->driver->ReadPixels(x, + y, + width, + height, + format, + type, + pixels); *pixels_count = pixels_maxcount; } @@ -658,13 +651,13 @@ void yagl_host_glReadPixelsOffset(struct yagl_thread_state *cur_ts, GLenum type, uintptr_t pixels) { - gles_api_ts->driver->ReadPixels(x, - y, - width, - height, - format, - type, - (GLvoid*)pixels); + cur_ts->gles_api_ts->driver->ReadPixels(x, + y, + width, + height, + format, + type, + (GLvoid*)pixels); } void yagl_host_glDrawArraysInstanced(struct yagl_thread_state *cur_ts, @@ -673,7 +666,7 @@ void yagl_host_glDrawArraysInstanced(struct yagl_thread_state *cur_ts, GLsizei count, GLsizei primcount) { - gles_api_ts->driver->DrawArraysInstanced(mode, start, count, primcount); + cur_ts->gles_api_ts->driver->DrawArraysInstanced(mode, start, count, primcount); } void yagl_host_glDrawElementsInstanced(struct yagl_thread_state *cur_ts, @@ -686,15 +679,15 @@ void yagl_host_glDrawElementsInstanced(struct yagl_thread_state *cur_ts, if (indices) { GLuint current_ebo = yagl_gles_bind_ebo(cur_ts, indices, indices_count); - gles_api_ts->driver->DrawElementsInstanced(mode, count, type, NULL, primcount); + cur_ts->gles_api_ts->driver->DrawElementsInstanced(mode, count, type, NULL, primcount); - gles_api_ts->driver->BindBuffer(GL_ELEMENT_ARRAY_BUFFER, current_ebo); + cur_ts->gles_api_ts->driver->BindBuffer(GL_ELEMENT_ARRAY_BUFFER, current_ebo); } else { - gles_api_ts->driver->DrawElementsInstanced(mode, - count, - type, - (const GLvoid*)(uintptr_t)indices_count, - primcount); + cur_ts->gles_api_ts->driver->DrawElementsInstanced(mode, + count, + type, + (const GLvoid*)(uintptr_t)indices_count, + primcount); } } @@ -709,12 +702,12 @@ void yagl_host_glDrawRangeElements(struct yagl_thread_state *cur_ts, if (indices) { GLuint current_ebo = yagl_gles_bind_ebo(cur_ts, indices, indices_count); - gles_api_ts->driver->DrawRangeElements(mode, start, end, count, type, NULL); + cur_ts->gles_api_ts->driver->DrawRangeElements(mode, start, end, count, type, NULL); - gles_api_ts->driver->BindBuffer(GL_ELEMENT_ARRAY_BUFFER, current_ebo); + cur_ts->gles_api_ts->driver->BindBuffer(GL_ELEMENT_ARRAY_BUFFER, current_ebo); } else { - gles_api_ts->driver->DrawRangeElements(mode, start, end, count, type, - (const GLvoid*)(uintptr_t)indices_count); + cur_ts->gles_api_ts->driver->DrawRangeElements(mode, start, end, count, type, + (const GLvoid*)(uintptr_t)indices_count); } } @@ -726,12 +719,12 @@ void yagl_host_glGenVertexArrays(struct yagl_thread_state *cur_ts, for (i = 0; i < arrays_count; ++i) { GLuint global_name; - gles_api_ts->driver->GenVertexArrays(1, &global_name); + cur_ts->gles_api_ts->driver->GenVertexArrays(1, &global_name); - yagl_gles_object_add(cur_ts->ps, + yagl_gles_object_add(cur_ts, arrays[i], global_name, - yagl_get_ctx_id(cur_ts->ps), + yagl_get_ctx_id(cur_ts), &yagl_gles_vertex_array_destroy); } } @@ -739,19 +732,19 @@ void yagl_host_glGenVertexArrays(struct yagl_thread_state *cur_ts, void yagl_host_glBindVertexArray(struct yagl_thread_state *cur_ts, GLuint array) { - gles_api_ts->driver->BindVertexArray(yagl_gles_object_get(cur_ts, array)); + cur_ts->gles_api_ts->driver->BindVertexArray(yagl_gles_object_get(cur_ts, array)); } void yagl_host_glDisableVertexAttribArray(struct yagl_thread_state *cur_ts, GLuint index) { - gles_api_ts->driver->DisableVertexAttribArray(index); + cur_ts->gles_api_ts->driver->DisableVertexAttribArray(index); } void yagl_host_glEnableVertexAttribArray(struct yagl_thread_state *cur_ts, GLuint index) { - gles_api_ts->driver->EnableVertexAttribArray(index); + cur_ts->gles_api_ts->driver->EnableVertexAttribArray(index); } void yagl_host_glVertexAttribPointerData(struct yagl_thread_state *cur_ts, @@ -766,11 +759,11 @@ void yagl_host_glVertexAttribPointerData(struct yagl_thread_state *cur_ts, GLuint current_vbo = yagl_gles_bind_array(cur_ts, indx, first, stride, data, data_count); - gles_api_ts->driver->VertexAttribPointer(indx, size, type, normalized, - stride, - NULL); + cur_ts->gles_api_ts->driver->VertexAttribPointer(indx, size, type, normalized, + stride, + NULL); - gles_api_ts->driver->BindBuffer(GL_ARRAY_BUFFER, current_vbo); + cur_ts->gles_api_ts->driver->BindBuffer(GL_ARRAY_BUFFER, current_vbo); } void yagl_host_glVertexAttribPointerOffset(struct yagl_thread_state *cur_ts, @@ -781,9 +774,9 @@ void yagl_host_glVertexAttribPointerOffset(struct yagl_thread_state *cur_ts, GLsizei stride, uintptr_t offset) { - gles_api_ts->driver->VertexAttribPointer(indx, size, type, normalized, - stride, - (const GLvoid*)offset); + cur_ts->gles_api_ts->driver->VertexAttribPointer(indx, size, type, normalized, + stride, + (const GLvoid*)offset); } void yagl_host_glVertexPointerData(struct yagl_thread_state *cur_ts, @@ -797,9 +790,9 @@ void yagl_host_glVertexPointerData(struct yagl_thread_state *cur_ts, first, stride, data, data_count); - gles_api_ts->driver->VertexPointer(size, type, stride, NULL); + cur_ts->gles_api_ts->driver->VertexPointer(size, type, stride, NULL); - gles_api_ts->driver->BindBuffer(GL_ARRAY_BUFFER, current_vbo); + cur_ts->gles_api_ts->driver->BindBuffer(GL_ARRAY_BUFFER, current_vbo); } void yagl_host_glVertexPointerOffset(struct yagl_thread_state *cur_ts, @@ -808,7 +801,7 @@ void yagl_host_glVertexPointerOffset(struct yagl_thread_state *cur_ts, GLsizei stride, uintptr_t offset) { - gles_api_ts->driver->VertexPointer(size, type, stride, (const GLvoid*)offset); + cur_ts->gles_api_ts->driver->VertexPointer(size, type, stride, (const GLvoid*)offset); } void yagl_host_glNormalPointerData(struct yagl_thread_state *cur_ts, @@ -821,9 +814,9 @@ void yagl_host_glNormalPointerData(struct yagl_thread_state *cur_ts, first, stride, data, data_count); - gles_api_ts->driver->NormalPointer(type, stride, NULL); + cur_ts->gles_api_ts->driver->NormalPointer(type, stride, NULL); - gles_api_ts->driver->BindBuffer(GL_ARRAY_BUFFER, current_vbo); + cur_ts->gles_api_ts->driver->BindBuffer(GL_ARRAY_BUFFER, current_vbo); } void yagl_host_glNormalPointerOffset(struct yagl_thread_state *cur_ts, @@ -831,7 +824,7 @@ void yagl_host_glNormalPointerOffset(struct yagl_thread_state *cur_ts, GLsizei stride, uintptr_t offset) { - gles_api_ts->driver->NormalPointer(type, stride, (const GLvoid*)offset); + cur_ts->gles_api_ts->driver->NormalPointer(type, stride, (const GLvoid*)offset); } void yagl_host_glColorPointerData(struct yagl_thread_state *cur_ts, @@ -845,9 +838,9 @@ void yagl_host_glColorPointerData(struct yagl_thread_state *cur_ts, first, stride, data, data_count); - gles_api_ts->driver->ColorPointer(size, type, stride, NULL); + cur_ts->gles_api_ts->driver->ColorPointer(size, type, stride, NULL); - gles_api_ts->driver->BindBuffer(GL_ARRAY_BUFFER, current_vbo); + cur_ts->gles_api_ts->driver->BindBuffer(GL_ARRAY_BUFFER, current_vbo); } void yagl_host_glColorPointerOffset(struct yagl_thread_state *cur_ts, @@ -856,7 +849,7 @@ void yagl_host_glColorPointerOffset(struct yagl_thread_state *cur_ts, GLsizei stride, uintptr_t offset) { - gles_api_ts->driver->ColorPointer(size, type, stride, (const GLvoid*)offset); + cur_ts->gles_api_ts->driver->ColorPointer(size, type, stride, (const GLvoid*)offset); } void yagl_host_glTexCoordPointerData(struct yagl_thread_state *cur_ts, @@ -871,9 +864,9 @@ void yagl_host_glTexCoordPointerData(struct yagl_thread_state *cur_ts, first, stride, data, data_count); - gles_api_ts->driver->TexCoordPointer(size, type, stride, NULL); + cur_ts->gles_api_ts->driver->TexCoordPointer(size, type, stride, NULL); - gles_api_ts->driver->BindBuffer(GL_ARRAY_BUFFER, current_vbo); + cur_ts->gles_api_ts->driver->BindBuffer(GL_ARRAY_BUFFER, current_vbo); } void yagl_host_glTexCoordPointerOffset(struct yagl_thread_state *cur_ts, @@ -882,26 +875,26 @@ void yagl_host_glTexCoordPointerOffset(struct yagl_thread_state *cur_ts, GLsizei stride, uintptr_t offset) { - gles_api_ts->driver->TexCoordPointer(size, type, stride, (const GLvoid*)offset); + cur_ts->gles_api_ts->driver->TexCoordPointer(size, type, stride, (const GLvoid*)offset); } void yagl_host_glDisableClientState(struct yagl_thread_state *cur_ts, GLenum array) { - gles_api_ts->driver->DisableClientState(array); + cur_ts->gles_api_ts->driver->DisableClientState(array); } void yagl_host_glEnableClientState(struct yagl_thread_state *cur_ts, GLenum array) { - gles_api_ts->driver->EnableClientState(array); + cur_ts->gles_api_ts->driver->EnableClientState(array); } void yagl_host_glVertexAttribDivisor(struct yagl_thread_state *cur_ts, GLuint index, GLuint divisor) { - gles_api_ts->driver->VertexAttribDivisor(index, divisor); + cur_ts->gles_api_ts->driver->VertexAttribDivisor(index, divisor); } void yagl_host_glVertexAttribIPointerData(struct yagl_thread_state *cur_ts, @@ -915,9 +908,9 @@ void yagl_host_glVertexAttribIPointerData(struct yagl_thread_state *cur_ts, GLuint current_vbo = yagl_gles_bind_array(cur_ts, index, first, stride, data, data_count); - gles_api_ts->driver->VertexAttribIPointer(index, size, type, stride, NULL); + cur_ts->gles_api_ts->driver->VertexAttribIPointer(index, size, type, stride, NULL); - gles_api_ts->driver->BindBuffer(GL_ARRAY_BUFFER, current_vbo); + cur_ts->gles_api_ts->driver->BindBuffer(GL_ARRAY_BUFFER, current_vbo); } void yagl_host_glVertexAttribIPointerOffset(struct yagl_thread_state *cur_ts, @@ -927,9 +920,9 @@ void yagl_host_glVertexAttribIPointerOffset(struct yagl_thread_state *cur_ts, GLsizei stride, uintptr_t offset) { - gles_api_ts->driver->VertexAttribIPointer(index, size, type, - stride, - (const GLvoid*)offset); + cur_ts->gles_api_ts->driver->VertexAttribIPointer(index, size, type, + stride, + (const GLvoid*)offset); } void yagl_host_glGenBuffers(struct yagl_thread_state *cur_ts, @@ -940,9 +933,9 @@ void yagl_host_glGenBuffers(struct yagl_thread_state *cur_ts, for (i = 0; i < buffers_count; ++i) { GLuint global_name; - gles_api_ts->driver->GenBuffers(1, &global_name); + cur_ts->gles_api_ts->driver->GenBuffers(1, &global_name); - yagl_gles_object_add(cur_ts->ps, + yagl_gles_object_add(cur_ts, buffers[i], global_name, 0, @@ -954,7 +947,7 @@ void yagl_host_glBindBuffer(struct yagl_thread_state *cur_ts, GLenum target, GLuint buffer) { - gles_api_ts->driver->BindBuffer(target, yagl_gles_object_get(cur_ts, buffer)); + cur_ts->gles_api_ts->driver->BindBuffer(target, yagl_gles_object_get(cur_ts, buffer)); } void yagl_host_glBufferData(struct yagl_thread_state *cur_ts, @@ -962,7 +955,7 @@ void yagl_host_glBufferData(struct yagl_thread_state *cur_ts, const GLvoid *data, int32_t data_count, GLenum usage) { - gles_api_ts->driver->BufferData(target, data_count, data, usage); + cur_ts->gles_api_ts->driver->BufferData(target, data_count, data, usage); } void yagl_host_glBufferSubData(struct yagl_thread_state *cur_ts, @@ -971,6 +964,7 @@ void yagl_host_glBufferSubData(struct yagl_thread_state *cur_ts, const GLvoid *data, int32_t data_count) { void *ptr; + struct yagl_gles_api_ts *gles_api_ts = cur_ts->gles_api_ts; YAGL_LOG_FUNC_SET(glBufferSubData); @@ -1015,8 +1009,8 @@ void yagl_host_glBindBufferBase(struct yagl_thread_state *cur_ts, GLuint index, GLuint buffer) { - gles_api_ts->driver->BindBufferBase(target, index, - yagl_gles_object_get(cur_ts, buffer)); + cur_ts->gles_api_ts->driver->BindBufferBase(target, index, + yagl_gles_object_get(cur_ts, buffer)); } void yagl_host_glBindBufferRange(struct yagl_thread_state *cur_ts, @@ -1026,9 +1020,9 @@ void yagl_host_glBindBufferRange(struct yagl_thread_state *cur_ts, GLint offset, GLsizei size) { - gles_api_ts->driver->BindBufferRange(target, index, - yagl_gles_object_get(cur_ts, buffer), - offset, size); + cur_ts->gles_api_ts->driver->BindBufferRange(target, index, + yagl_gles_object_get(cur_ts, buffer), + offset, size); } void yagl_host_glMapBuffer(struct yagl_thread_state *cur_ts, @@ -1042,12 +1036,12 @@ void yagl_host_glMapBuffer(struct yagl_thread_state *cur_ts, YAGL_LOG_FUNC_SET(glMapBuffer); - gles_api_ts->driver->GetIntegerv(GL_PIXEL_PACK_BUFFER_BINDING_ARB, + cur_ts->gles_api_ts->driver->GetIntegerv(GL_PIXEL_PACK_BUFFER_BINDING_ARB, (GLint*)¤t_pbo); - gles_api_ts->driver->BindBuffer(GL_PIXEL_PACK_BUFFER_ARB, yagl_gles_object_get(cur_ts, buffer)); + cur_ts->gles_api_ts->driver->BindBuffer(GL_PIXEL_PACK_BUFFER_ARB, yagl_gles_object_get(cur_ts, buffer)); - map_ptr = gles_api_ts->driver->MapBuffer(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY); + map_ptr = cur_ts->gles_api_ts->driver->MapBuffer(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY); if (!map_ptr) { YAGL_LOG_ERROR("glMapBuffer failed"); @@ -1077,9 +1071,9 @@ void yagl_host_glMapBuffer(struct yagl_thread_state *cur_ts, *data_count = data_ptr - data; out2: - gles_api_ts->driver->UnmapBuffer(GL_PIXEL_PACK_BUFFER_ARB); + cur_ts->gles_api_ts->driver->UnmapBuffer(GL_PIXEL_PACK_BUFFER_ARB); out1: - gles_api_ts->driver->BindBuffer(GL_PIXEL_PACK_BUFFER_ARB, current_pbo); + cur_ts->gles_api_ts->driver->BindBuffer(GL_PIXEL_PACK_BUFFER_ARB, current_pbo); } void yagl_host_glCopyBufferSubData(struct yagl_thread_state *cur_ts, @@ -1089,8 +1083,8 @@ void yagl_host_glCopyBufferSubData(struct yagl_thread_state *cur_ts, GLintptr writeOffset, GLsizei size) { - gles_api_ts->driver->CopyBufferSubData(readTarget, writeTarget, - readOffset, writeOffset, size); + cur_ts->gles_api_ts->driver->CopyBufferSubData(readTarget, writeTarget, + readOffset, writeOffset, size); } void yagl_host_glGenTextures(struct yagl_thread_state *cur_ts, @@ -1106,11 +1100,11 @@ void yagl_host_glGenTextures(struct yagl_thread_state *cur_ts, * might be called without an active context, but * which needs to create a texture. */ - yagl_ensure_ctx(cur_ts->ps, 0); - gles_api_ts->driver->GenTextures(1, &global_name); - yagl_unensure_ctx(cur_ts->ps, 0); + yagl_ensure_ctx(cur_ts, 0); + cur_ts->gles_api_ts->driver->GenTextures(1, &global_name); + yagl_unensure_ctx(cur_ts, 0); - yagl_gles_object_add(cur_ts->ps, + yagl_gles_object_add(cur_ts, textures[i], global_name, 0, @@ -1122,13 +1116,13 @@ void yagl_host_glBindTexture(struct yagl_thread_state *cur_ts, GLenum target, GLuint texture) { - gles_api_ts->driver->BindTexture(target, yagl_gles_object_get(cur_ts, texture)); + cur_ts->gles_api_ts->driver->BindTexture(target, yagl_gles_object_get(cur_ts, texture)); } void yagl_host_glActiveTexture(struct yagl_thread_state *cur_ts, GLenum texture) { - gles_api_ts->driver->ActiveTexture(texture); + cur_ts->gles_api_ts->driver->ActiveTexture(texture); } void yagl_host_glCopyTexImage2D(struct yagl_thread_state *cur_ts, @@ -1141,7 +1135,7 @@ void yagl_host_glCopyTexImage2D(struct yagl_thread_state *cur_ts, GLsizei height, GLint border) { - gles_api_ts->driver->CopyTexImage2D(target, + cur_ts->gles_api_ts->driver->CopyTexImage2D(target, level, internalformat, x, @@ -1161,7 +1155,7 @@ void yagl_host_glCopyTexSubImage2D(struct yagl_thread_state *cur_ts, GLsizei width, GLsizei height) { - gles_api_ts->driver->CopyTexSubImage2D(target, + cur_ts->gles_api_ts->driver->CopyTexSubImage2D(target, level, xoffset, yoffset, @@ -1178,7 +1172,7 @@ void yagl_host_glGetTexParameterfv(struct yagl_thread_state *cur_ts, { GLfloat params[10]; - gles_api_ts->driver->GetTexParameterfv(target, + cur_ts->gles_api_ts->driver->GetTexParameterfv(target, pname, params); @@ -1194,7 +1188,7 @@ void yagl_host_glGetTexParameteriv(struct yagl_thread_state *cur_ts, { GLint params[10]; - gles_api_ts->driver->GetTexParameteriv(target, + cur_ts->gles_api_ts->driver->GetTexParameteriv(target, pname, params); @@ -1214,7 +1208,7 @@ void yagl_host_glTexImage2DData(struct yagl_thread_state *cur_ts, GLenum type, const GLvoid *pixels, int32_t pixels_count) { - gles_api_ts->driver->TexImage2D(target, + cur_ts->gles_api_ts->driver->TexImage2D(target, level, internalformat, width, @@ -1236,7 +1230,7 @@ void yagl_host_glTexImage2DOffset(struct yagl_thread_state *cur_ts, GLenum type, uintptr_t pixels) { - gles_api_ts->driver->TexImage2D(target, + cur_ts->gles_api_ts->driver->TexImage2D(target, level, internalformat, width, @@ -1252,7 +1246,7 @@ void yagl_host_glTexParameterf(struct yagl_thread_state *cur_ts, GLenum pname, GLfloat param) { - gles_api_ts->driver->TexParameterf(target, pname, param); + cur_ts->gles_api_ts->driver->TexParameterf(target, pname, param); } void yagl_host_glTexParameterfv(struct yagl_thread_state *cur_ts, @@ -1268,9 +1262,9 @@ void yagl_host_glTexParameterfv(struct yagl_thread_state *cur_ts, tmp[0] = *params; } - gles_api_ts->driver->TexParameterfv(target, - pname, - (params ? tmp : NULL)); + cur_ts->gles_api_ts->driver->TexParameterfv(target, + pname, + (params ? tmp : NULL)); } void yagl_host_glTexParameteri(struct yagl_thread_state *cur_ts, @@ -1278,7 +1272,7 @@ void yagl_host_glTexParameteri(struct yagl_thread_state *cur_ts, GLenum pname, GLint param) { - gles_api_ts->driver->TexParameteri(target, pname, param); + cur_ts->gles_api_ts->driver->TexParameteri(target, pname, param); } void yagl_host_glTexParameteriv(struct yagl_thread_state *cur_ts, @@ -1294,9 +1288,9 @@ void yagl_host_glTexParameteriv(struct yagl_thread_state *cur_ts, tmp[0] = *params; } - gles_api_ts->driver->TexParameteriv(target, - pname, - (params ? tmp : NULL)); + cur_ts->gles_api_ts->driver->TexParameteriv(target, + pname, + (params ? tmp : NULL)); } void yagl_host_glTexSubImage2DData(struct yagl_thread_state *cur_ts, @@ -1311,6 +1305,7 @@ void yagl_host_glTexSubImage2DData(struct yagl_thread_state *cur_ts, const GLvoid *pixels, int32_t pixels_count) { GLint row_length; + struct yagl_gles_api_ts *gles_api_ts = cur_ts->gles_api_ts; /* * Nvidia Windows OpenGL drivers don't account for GL_UNPACK_ALIGNMENT @@ -1358,6 +1353,7 @@ void yagl_host_glTexSubImage2DOffset(struct yagl_thread_state *cur_ts, uintptr_t pixels) { GLint row_length; + struct yagl_gles_api_ts *gles_api_ts = cur_ts->gles_api_ts; /* * Nvidia Windows OpenGL drivers don't account for GL_UNPACK_ALIGNMENT @@ -1396,7 +1392,7 @@ void yagl_host_glTexSubImage2DOffset(struct yagl_thread_state *cur_ts, void yagl_host_glClientActiveTexture(struct yagl_thread_state *cur_ts, GLenum texture) { - gles_api_ts->driver->ClientActiveTexture(texture); + cur_ts->gles_api_ts->driver->ClientActiveTexture(texture); } void yagl_host_glTexEnvi(struct yagl_thread_state *cur_ts, @@ -1404,7 +1400,7 @@ void yagl_host_glTexEnvi(struct yagl_thread_state *cur_ts, GLenum pname, GLint param) { - gles_api_ts->driver->TexEnvi(target, pname, param); + cur_ts->gles_api_ts->driver->TexEnvi(target, pname, param); } void yagl_host_glTexEnvf(struct yagl_thread_state *cur_ts, @@ -1412,7 +1408,7 @@ void yagl_host_glTexEnvf(struct yagl_thread_state *cur_ts, GLenum pname, GLfloat param) { - gles_api_ts->driver->TexEnvf(target, pname, param); + cur_ts->gles_api_ts->driver->TexEnvf(target, pname, param); } void yagl_host_glMultiTexCoord4f(struct yagl_thread_state *cur_ts, @@ -1422,7 +1418,7 @@ void yagl_host_glMultiTexCoord4f(struct yagl_thread_state *cur_ts, GLfloat r, GLfloat q) { - gles_api_ts->driver->MultiTexCoord4f(target, s, tt, r, q); + cur_ts->gles_api_ts->driver->MultiTexCoord4f(target, s, tt, r, q); } void yagl_host_glTexEnviv(struct yagl_thread_state *cur_ts, @@ -1430,7 +1426,7 @@ void yagl_host_glTexEnviv(struct yagl_thread_state *cur_ts, GLenum pname, const GLint *params, int32_t params_count) { - gles_api_ts->driver->TexEnviv(target, pname, params); + cur_ts->gles_api_ts->driver->TexEnviv(target, pname, params); } void yagl_host_glTexEnvfv(struct yagl_thread_state *cur_ts, @@ -1438,7 +1434,7 @@ void yagl_host_glTexEnvfv(struct yagl_thread_state *cur_ts, GLenum pname, const GLfloat *params, int32_t params_count) { - gles_api_ts->driver->TexEnvfv(target, pname, params); + cur_ts->gles_api_ts->driver->TexEnvfv(target, pname, params); } void yagl_host_glGetTexEnviv(struct yagl_thread_state *cur_ts, @@ -1446,7 +1442,7 @@ void yagl_host_glGetTexEnviv(struct yagl_thread_state *cur_ts, GLenum pname, GLint *params, int32_t params_maxcount, int32_t *params_count) { - gles_api_ts->driver->GetTexEnviv(env, pname, params); + cur_ts->gles_api_ts->driver->GetTexEnviv(env, pname, params); *params_count = params_maxcount; } @@ -1455,7 +1451,7 @@ void yagl_host_glGetTexEnvfv(struct yagl_thread_state *cur_ts, GLenum pname, GLfloat *params, int32_t params_maxcount, int32_t *params_count) { - gles_api_ts->driver->GetTexEnvfv(env, pname, params); + cur_ts->gles_api_ts->driver->GetTexEnvfv(env, pname, params); *params_count = params_maxcount; } @@ -1471,16 +1467,16 @@ void yagl_host_glTexImage3DData(struct yagl_thread_state *cur_ts, GLenum type, const void *pixels, int32_t pixels_count) { - gles_api_ts->driver->TexImage3D(target, - level, - internalformat, - width, - height, - depth, - border, - format, - type, - pixels); + cur_ts->gles_api_ts->driver->TexImage3D(target, + level, + internalformat, + width, + height, + depth, + border, + format, + type, + pixels); } void yagl_host_glTexImage3DOffset(struct yagl_thread_state *cur_ts, @@ -1495,16 +1491,16 @@ void yagl_host_glTexImage3DOffset(struct yagl_thread_state *cur_ts, GLenum type, uintptr_t pixels) { - gles_api_ts->driver->TexImage3D(target, - level, - internalformat, - width, - height, - depth, - border, - format, - type, - (const void*)pixels); + cur_ts->gles_api_ts->driver->TexImage3D(target, + level, + internalformat, + width, + height, + depth, + border, + format, + type, + (const void*)pixels); } void yagl_host_glTexSubImage3DData(struct yagl_thread_state *cur_ts, @@ -1520,17 +1516,17 @@ void yagl_host_glTexSubImage3DData(struct yagl_thread_state *cur_ts, GLenum type, const void *pixels, int32_t pixels_count) { - gles_api_ts->driver->TexSubImage3D(target, - level, - xoffset, - yoffset, - zoffset, - width, - height, - depth, - format, - type, - pixels); + cur_ts->gles_api_ts->driver->TexSubImage3D(target, + level, + xoffset, + yoffset, + zoffset, + width, + height, + depth, + format, + type, + pixels); } void yagl_host_glTexSubImage3DOffset(struct yagl_thread_state *cur_ts, @@ -1546,17 +1542,17 @@ void yagl_host_glTexSubImage3DOffset(struct yagl_thread_state *cur_ts, GLenum type, uintptr_t pixels) { - gles_api_ts->driver->TexSubImage3D(target, - level, - xoffset, - yoffset, - zoffset, - width, - height, - depth, - format, - type, - (const void*)pixels); + cur_ts->gles_api_ts->driver->TexSubImage3D(target, + level, + xoffset, + yoffset, + zoffset, + width, + height, + depth, + format, + type, + (const void*)pixels); } void yagl_host_glCopyTexSubImage3D(struct yagl_thread_state *cur_ts, @@ -1570,15 +1566,15 @@ void yagl_host_glCopyTexSubImage3D(struct yagl_thread_state *cur_ts, GLsizei width, GLsizei height) { - gles_api_ts->driver->CopyTexSubImage3D(target, - level, - xoffset, - yoffset, - zoffset, - x, - y, - width, - height); + cur_ts->gles_api_ts->driver->CopyTexSubImage3D(target, + level, + xoffset, + yoffset, + zoffset, + x, + y, + width, + height); } void yagl_host_glGenFramebuffers(struct yagl_thread_state *cur_ts, @@ -1589,12 +1585,12 @@ void yagl_host_glGenFramebuffers(struct yagl_thread_state *cur_ts, for (i = 0; i < framebuffers_count; ++i) { GLuint global_name; - gles_api_ts->driver->GenFramebuffers(1, &global_name); + cur_ts->gles_api_ts->driver->GenFramebuffers(1, &global_name); - yagl_gles_object_add(cur_ts->ps, + yagl_gles_object_add(cur_ts, framebuffers[i], global_name, - yagl_get_ctx_id(cur_ts->ps), + yagl_get_ctx_id(cur_ts), &yagl_gles_framebuffer_destroy); } } @@ -1603,8 +1599,9 @@ void yagl_host_glBindFramebuffer(struct yagl_thread_state *cur_ts, GLenum target, GLuint framebuffer) { - gles_api_ts->driver->BindFramebuffer(target, - yagl_gles_object_get(cur_ts, framebuffer)); + cur_ts->gles_api_ts->driver->BindFramebufferYAGL(cur_ts, + target, + yagl_gles_object_get(cur_ts, framebuffer)); } void yagl_host_glFramebufferTexture2D(struct yagl_thread_state *cur_ts, @@ -1614,10 +1611,10 @@ void yagl_host_glFramebufferTexture2D(struct yagl_thread_state *cur_ts, GLuint texture, GLint level) { - gles_api_ts->driver->FramebufferTexture2D(target, attachment, - textarget, - yagl_gles_object_get(cur_ts, texture), - level); + cur_ts->gles_api_ts->driver->FramebufferTexture2D(target, attachment, + textarget, + yagl_gles_object_get(cur_ts, texture), + level); } void yagl_host_glFramebufferRenderbuffer(struct yagl_thread_state *cur_ts, @@ -1626,10 +1623,10 @@ void yagl_host_glFramebufferRenderbuffer(struct yagl_thread_state *cur_ts, GLenum renderbuffertarget, GLuint renderbuffer) { - gles_api_ts->driver->FramebufferRenderbuffer(target, - attachment, - renderbuffertarget, - yagl_gles_object_get(cur_ts, renderbuffer)); + cur_ts->gles_api_ts->driver->FramebufferRenderbuffer(target, + attachment, + renderbuffertarget, + yagl_gles_object_get(cur_ts, renderbuffer)); } void yagl_host_glBlitFramebuffer(struct yagl_thread_state *cur_ts, @@ -1644,21 +1641,21 @@ void yagl_host_glBlitFramebuffer(struct yagl_thread_state *cur_ts, GLbitfield mask, GLenum filter) { - gles_api_ts->driver->BlitFramebuffer(srcX0, srcY0, srcX1, srcY1, - dstX0, dstY0, dstX1, dstY1, - mask, filter); + cur_ts->gles_api_ts->driver->BlitFramebuffer(srcX0, srcY0, srcX1, srcY1, + dstX0, dstY0, dstX1, dstY1, + mask, filter); } void yagl_host_glDrawBuffers(struct yagl_thread_state *cur_ts, const GLenum *bufs, int32_t bufs_count) { - gles_api_ts->driver->DrawBuffers(bufs_count, bufs); + cur_ts->gles_api_ts->driver->DrawBuffers(bufs_count, bufs); } void yagl_host_glReadBuffer(struct yagl_thread_state *cur_ts, GLenum mode) { - gles_api_ts->driver->ReadBuffer(mode); + cur_ts->gles_api_ts->driver->ReadBuffer(mode); } void yagl_host_glFramebufferTexture3D(struct yagl_thread_state *cur_ts, @@ -1669,10 +1666,10 @@ void yagl_host_glFramebufferTexture3D(struct yagl_thread_state *cur_ts, GLint level, GLint zoffset) { - gles_api_ts->driver->FramebufferTexture3D(target, attachment, - textarget, - yagl_gles_object_get(cur_ts, texture), - level, zoffset); + cur_ts->gles_api_ts->driver->FramebufferTexture3D(target, attachment, + textarget, + yagl_gles_object_get(cur_ts, texture), + level, zoffset); } void yagl_host_glFramebufferTextureLayer(struct yagl_thread_state *cur_ts, @@ -1682,9 +1679,9 @@ void yagl_host_glFramebufferTextureLayer(struct yagl_thread_state *cur_ts, GLint level, GLint layer) { - gles_api_ts->driver->FramebufferTextureLayer(target, attachment, - yagl_gles_object_get(cur_ts, texture), - level, layer); + cur_ts->gles_api_ts->driver->FramebufferTextureLayer(target, attachment, + yagl_gles_object_get(cur_ts, texture), + level, layer); } void yagl_host_glClearBufferiv(struct yagl_thread_state *cur_ts, @@ -1692,7 +1689,7 @@ void yagl_host_glClearBufferiv(struct yagl_thread_state *cur_ts, GLint drawbuffer, const GLint *value, int32_t value_count) { - gles_api_ts->driver->ClearBufferiv(buffer, drawbuffer, value); + cur_ts->gles_api_ts->driver->ClearBufferiv(buffer, drawbuffer, value); } void yagl_host_glClearBufferuiv(struct yagl_thread_state *cur_ts, @@ -1700,7 +1697,7 @@ void yagl_host_glClearBufferuiv(struct yagl_thread_state *cur_ts, GLint drawbuffer, const GLuint *value, int32_t value_count) { - gles_api_ts->driver->ClearBufferuiv(buffer, drawbuffer, value); + cur_ts->gles_api_ts->driver->ClearBufferuiv(buffer, drawbuffer, value); } void yagl_host_glClearBufferfi(struct yagl_thread_state *cur_ts, @@ -1709,7 +1706,7 @@ void yagl_host_glClearBufferfi(struct yagl_thread_state *cur_ts, GLfloat depth, GLint stencil) { - gles_api_ts->driver->ClearBufferfi(buffer, drawbuffer, depth, stencil); + cur_ts->gles_api_ts->driver->ClearBufferfi(buffer, drawbuffer, depth, stencil); } void yagl_host_glClearBufferfv(struct yagl_thread_state *cur_ts, @@ -1717,7 +1714,7 @@ void yagl_host_glClearBufferfv(struct yagl_thread_state *cur_ts, GLint drawbuffer, const GLfloat *value, int32_t value_count) { - gles_api_ts->driver->ClearBufferfv(buffer, drawbuffer, value); + cur_ts->gles_api_ts->driver->ClearBufferfv(buffer, drawbuffer, value); } void yagl_host_glGenRenderbuffers(struct yagl_thread_state *cur_ts, @@ -1728,9 +1725,9 @@ void yagl_host_glGenRenderbuffers(struct yagl_thread_state *cur_ts, for (i = 0; i < renderbuffers_count; ++i) { GLuint global_name; - gles_api_ts->driver->GenRenderbuffers(1, &global_name); + cur_ts->gles_api_ts->driver->GenRenderbuffers(1, &global_name); - yagl_gles_object_add(cur_ts->ps, + yagl_gles_object_add(cur_ts, renderbuffers[i], global_name, 0, @@ -1742,7 +1739,7 @@ void yagl_host_glBindRenderbuffer(struct yagl_thread_state *cur_ts, GLenum target, GLuint renderbuffer) { - gles_api_ts->driver->BindRenderbuffer(target, + cur_ts->gles_api_ts->driver->BindRenderbuffer(target, yagl_gles_object_get(cur_ts, renderbuffer)); } @@ -1752,7 +1749,7 @@ void yagl_host_glRenderbufferStorage(struct yagl_thread_state *cur_ts, GLsizei width, GLsizei height) { - gles_api_ts->driver->RenderbufferStorage(target, internalformat, width, height); + cur_ts->gles_api_ts->driver->RenderbufferStorage(target, internalformat, width, height); } void yagl_host_glGetRenderbufferParameteriv(struct yagl_thread_state *cur_ts, @@ -1762,7 +1759,7 @@ void yagl_host_glGetRenderbufferParameteriv(struct yagl_thread_state *cur_ts, { GLint params[10]; - gles_api_ts->driver->GetRenderbufferParameteriv(target, + cur_ts->gles_api_ts->driver->GetRenderbufferParameteriv(target, pname, params); @@ -1778,15 +1775,15 @@ void yagl_host_glRenderbufferStorageMultisample(struct yagl_thread_state *cur_ts GLsizei width, GLsizei height) { - gles_api_ts->driver->RenderbufferStorageMultisample(target, samples, internalformat, width, height); + cur_ts->gles_api_ts->driver->RenderbufferStorageMultisample(target, samples, internalformat, width, height); } void yagl_host_glCreateProgram(struct yagl_thread_state *cur_ts, GLuint program) { - GLuint global_name = gles_api_ts->driver->CreateProgram(); + GLuint global_name = cur_ts->gles_api_ts->driver->CreateProgram(); - yagl_gles_object_add(cur_ts->ps, + yagl_gles_object_add(cur_ts, program, global_name, 0, @@ -1797,9 +1794,9 @@ void yagl_host_glCreateShader(struct yagl_thread_state *cur_ts, GLuint shader, GLenum type) { - GLuint global_name = gles_api_ts->driver->CreateShader(type); + GLuint global_name = cur_ts->gles_api_ts->driver->CreateShader(type); - yagl_gles_object_add(cur_ts->ps, + yagl_gles_object_add(cur_ts, shader, global_name, 0, @@ -1816,31 +1813,32 @@ void yagl_host_glShaderSource(struct yagl_thread_state *cur_ts, strings[0] = string; lenghts[0] = string_count - 1; - gles_api_ts->driver->ShaderSource(yagl_gles_object_get(cur_ts, shader), - 1, - strings, - lenghts); + cur_ts->gles_api_ts->driver->ShaderSource(yagl_gles_object_get(cur_ts, shader), + 1, + strings, + lenghts); } void yagl_host_glAttachShader(struct yagl_thread_state *cur_ts, GLuint program, GLuint shader) { - gles_api_ts->driver->AttachShader(yagl_gles_object_get(cur_ts, program), - yagl_gles_object_get(cur_ts, shader)); + cur_ts->gles_api_ts->driver->AttachShader(yagl_gles_object_get(cur_ts, program), + yagl_gles_object_get(cur_ts, shader)); } void yagl_host_glDetachShader(struct yagl_thread_state *cur_ts, GLuint program, GLuint shader) { - gles_api_ts->driver->DetachShader(yagl_gles_object_get(cur_ts, program), - yagl_gles_object_get(cur_ts, shader)); + cur_ts->gles_api_ts->driver->DetachShader(yagl_gles_object_get(cur_ts, program), + yagl_gles_object_get(cur_ts, shader)); } void yagl_host_glCompileShader(struct yagl_thread_state *cur_ts, GLuint shader) { + struct yagl_gles_api_ts *gles_api_ts = cur_ts->gles_api_ts; #ifndef CONFIG_DARWIN gles_api_ts->driver->CompileShader(yagl_gles_object_get(cur_ts, shader)); #else @@ -1915,9 +1913,9 @@ void yagl_host_glBindAttribLocation(struct yagl_thread_state *cur_ts, GLuint index, const GLchar *name, int32_t name_count) { - gles_api_ts->driver->BindAttribLocation(yagl_gles_object_get(cur_ts, program), - index, - name); + cur_ts->gles_api_ts->driver->BindAttribLocation(yagl_gles_object_get(cur_ts, program), + index, + name); } void yagl_host_glGetActiveAttrib(struct yagl_thread_state *cur_ts, @@ -1929,13 +1927,13 @@ void yagl_host_glGetActiveAttrib(struct yagl_thread_state *cur_ts, { GLsizei tmp = -1; - gles_api_ts->driver->GetActiveAttrib(yagl_gles_object_get(cur_ts, program), - index, - name_maxcount, - &tmp, - size, - type, - name); + cur_ts->gles_api_ts->driver->GetActiveAttrib(yagl_gles_object_get(cur_ts, program), + index, + name_maxcount, + &tmp, + size, + type, + name); if (tmp >= 0) { *name_count = MIN(tmp + 1, name_maxcount); @@ -1951,13 +1949,13 @@ void yagl_host_glGetActiveUniform(struct yagl_thread_state *cur_ts, { GLsizei tmp = -1; - gles_api_ts->driver->GetActiveUniform(yagl_gles_object_get(cur_ts, program), - index, - name_maxcount, - &tmp, - size, - type, - name); + cur_ts->gles_api_ts->driver->GetActiveUniform(yagl_gles_object_get(cur_ts, program), + index, + name_maxcount, + &tmp, + size, + type, + name); if (tmp >= 0) { *name_count = MIN(tmp + 1, name_maxcount); @@ -1968,8 +1966,8 @@ int yagl_host_glGetAttribLocation(struct yagl_thread_state *cur_ts, GLuint program, const GLchar *name, int32_t name_count) { - return gles_api_ts->driver->GetAttribLocation(yagl_gles_object_get(cur_ts, program), - name); + return cur_ts->gles_api_ts->driver->GetAttribLocation(yagl_gles_object_get(cur_ts, program), + name); } void yagl_host_glGetProgramiv(struct yagl_thread_state *cur_ts, @@ -1977,9 +1975,9 @@ void yagl_host_glGetProgramiv(struct yagl_thread_state *cur_ts, GLenum pname, GLint *param) { - gles_api_ts->driver->GetProgramiv(yagl_gles_object_get(cur_ts, program), - pname, - param); + cur_ts->gles_api_ts->driver->GetProgramiv(yagl_gles_object_get(cur_ts, program), + pname, + param); } GLboolean yagl_host_glGetProgramInfoLog(struct yagl_thread_state *cur_ts, @@ -1988,10 +1986,10 @@ GLboolean yagl_host_glGetProgramInfoLog(struct yagl_thread_state *cur_ts, { GLsizei tmp = -1; - gles_api_ts->driver->GetProgramInfoLog(yagl_gles_object_get(cur_ts, program), - infolog_maxcount, - &tmp, - infolog); + cur_ts->gles_api_ts->driver->GetProgramInfoLog(yagl_gles_object_get(cur_ts, program), + infolog_maxcount, + &tmp, + infolog); if (tmp >= 0) { *infolog_count = MIN(tmp + 1, infolog_maxcount); @@ -2006,9 +2004,9 @@ void yagl_host_glGetShaderiv(struct yagl_thread_state *cur_ts, GLenum pname, GLint *param) { - gles_api_ts->driver->GetShaderiv(yagl_gles_object_get(cur_ts, shader), - pname, - param); + cur_ts->gles_api_ts->driver->GetShaderiv(yagl_gles_object_get(cur_ts, shader), + pname, + param); } GLboolean yagl_host_glGetShaderInfoLog(struct yagl_thread_state *cur_ts, @@ -2017,10 +2015,10 @@ GLboolean yagl_host_glGetShaderInfoLog(struct yagl_thread_state *cur_ts, { GLsizei tmp = -1; - gles_api_ts->driver->GetShaderInfoLog(yagl_gles_object_get(cur_ts, shader), - infolog_maxcount, - &tmp, - infolog); + cur_ts->gles_api_ts->driver->GetShaderInfoLog(yagl_gles_object_get(cur_ts, shader), + infolog_maxcount, + &tmp, + infolog); if (tmp >= 0) { *infolog_count = MIN(tmp + 1, infolog_maxcount); @@ -2038,7 +2036,7 @@ void yagl_host_glGetUniformfv(struct yagl_thread_state *cur_ts, { GLenum type; GLuint global_name = yagl_gles_object_get(cur_ts, program); - GLint actual_location = yagl_gles_api_ps_translate_location(gles_api_ts->ps, + GLint actual_location = yagl_gles_api_ps_translate_location(cur_ts->gles_api_ts->ps, tl, location); @@ -2053,9 +2051,9 @@ void yagl_host_glGetUniformfv(struct yagl_thread_state *cur_ts, return; } - gles_api_ts->driver->GetUniformfv(global_name, - actual_location, - params); + cur_ts->gles_api_ts->driver->GetUniformfv(global_name, + actual_location, + params); } void yagl_host_glGetUniformiv(struct yagl_thread_state *cur_ts, @@ -2066,7 +2064,7 @@ void yagl_host_glGetUniformiv(struct yagl_thread_state *cur_ts, { GLenum type; GLuint global_name = yagl_gles_object_get(cur_ts, program); - GLint actual_location = yagl_gles_api_ps_translate_location(gles_api_ts->ps, + GLint actual_location = yagl_gles_api_ps_translate_location(cur_ts->gles_api_ts->ps, tl, location); @@ -2081,17 +2079,17 @@ void yagl_host_glGetUniformiv(struct yagl_thread_state *cur_ts, return; } - gles_api_ts->driver->GetUniformiv(global_name, - actual_location, - params); + cur_ts->gles_api_ts->driver->GetUniformiv(global_name, + actual_location, + params); } int yagl_host_glGetUniformLocation(struct yagl_thread_state *cur_ts, GLuint program, const GLchar *name, int32_t name_count) { - return gles_api_ts->driver->GetUniformLocation(yagl_gles_object_get(cur_ts, program), - name); + return cur_ts->gles_api_ts->driver->GetUniformLocation(yagl_gles_object_get(cur_ts, program), + name); } void yagl_host_glGetVertexAttribfv(struct yagl_thread_state *cur_ts, @@ -2103,7 +2101,7 @@ void yagl_host_glGetVertexAttribfv(struct yagl_thread_state *cur_ts, return; } - gles_api_ts->driver->GetVertexAttribfv(index, pname, params); + cur_ts->gles_api_ts->driver->GetVertexAttribfv(index, pname, params); } void yagl_host_glGetVertexAttribiv(struct yagl_thread_state *cur_ts, @@ -2115,7 +2113,7 @@ void yagl_host_glGetVertexAttribiv(struct yagl_thread_state *cur_ts, return; } - gles_api_ts->driver->GetVertexAttribiv(index, pname, params); + cur_ts->gles_api_ts->driver->GetVertexAttribiv(index, pname, params); } void yagl_host_glLinkProgram(struct yagl_thread_state *cur_ts, @@ -2123,6 +2121,7 @@ void yagl_host_glLinkProgram(struct yagl_thread_state *cur_ts, GLint *params, int32_t params_maxcount, int32_t *params_count) { GLuint obj = yagl_gles_object_get(cur_ts, program); + struct yagl_gles_api_ts *gles_api_ts = cur_ts->gles_api_ts; gles_api_ts->driver->LinkProgram(obj); @@ -2152,8 +2151,8 @@ void yagl_host_glUniform1f(struct yagl_thread_state *cur_ts, uint32_t location, GLfloat x) { - gles_api_ts->driver->Uniform1f( - yagl_gles_api_ps_translate_location(gles_api_ts->ps, tl, location), x); + cur_ts->gles_api_ts->driver->Uniform1f( + yagl_gles_api_ps_translate_location(cur_ts->gles_api_ts->ps, tl, location), x); } void yagl_host_glUniform1fv(struct yagl_thread_state *cur_ts, @@ -2161,8 +2160,8 @@ void yagl_host_glUniform1fv(struct yagl_thread_state *cur_ts, uint32_t location, const GLfloat *v, int32_t v_count) { - gles_api_ts->driver->Uniform1fv( - yagl_gles_api_ps_translate_location(gles_api_ts->ps, tl, location), + cur_ts->gles_api_ts->driver->Uniform1fv( + yagl_gles_api_ps_translate_location(cur_ts->gles_api_ts->ps, tl, location), v_count, v); } @@ -2171,8 +2170,8 @@ void yagl_host_glUniform1i(struct yagl_thread_state *cur_ts, uint32_t location, GLint x) { - gles_api_ts->driver->Uniform1i( - yagl_gles_api_ps_translate_location(gles_api_ts->ps, tl, location), + cur_ts->gles_api_ts->driver->Uniform1i( + yagl_gles_api_ps_translate_location(cur_ts->gles_api_ts->ps, tl, location), x); } @@ -2181,8 +2180,8 @@ void yagl_host_glUniform1iv(struct yagl_thread_state *cur_ts, uint32_t location, const GLint *v, int32_t v_count) { - gles_api_ts->driver->Uniform1iv( - yagl_gles_api_ps_translate_location(gles_api_ts->ps, tl, location), + cur_ts->gles_api_ts->driver->Uniform1iv( + yagl_gles_api_ps_translate_location(cur_ts->gles_api_ts->ps, tl, location), v_count, v); } @@ -2192,8 +2191,8 @@ void yagl_host_glUniform2f(struct yagl_thread_state *cur_ts, GLfloat x, GLfloat y) { - gles_api_ts->driver->Uniform2f( - yagl_gles_api_ps_translate_location(gles_api_ts->ps, tl, location), + cur_ts->gles_api_ts->driver->Uniform2f( + yagl_gles_api_ps_translate_location(cur_ts->gles_api_ts->ps, tl, location), x, y); } @@ -2202,8 +2201,8 @@ void yagl_host_glUniform2fv(struct yagl_thread_state *cur_ts, uint32_t location, const GLfloat *v, int32_t v_count) { - gles_api_ts->driver->Uniform2fv( - yagl_gles_api_ps_translate_location(gles_api_ts->ps, tl, location), + cur_ts->gles_api_ts->driver->Uniform2fv( + yagl_gles_api_ps_translate_location(cur_ts->gles_api_ts->ps, tl, location), (v_count / 2), v); } @@ -2213,8 +2212,8 @@ void yagl_host_glUniform2i(struct yagl_thread_state *cur_ts, GLint x, GLint y) { - gles_api_ts->driver->Uniform2i( - yagl_gles_api_ps_translate_location(gles_api_ts->ps, tl, location), + cur_ts->gles_api_ts->driver->Uniform2i( + yagl_gles_api_ps_translate_location(cur_ts->gles_api_ts->ps, tl, location), x, y); } @@ -2223,8 +2222,8 @@ void yagl_host_glUniform2iv(struct yagl_thread_state *cur_ts, uint32_t location, const GLint *v, int32_t v_count) { - gles_api_ts->driver->Uniform2iv( - yagl_gles_api_ps_translate_location(gles_api_ts->ps, tl, location), + cur_ts->gles_api_ts->driver->Uniform2iv( + yagl_gles_api_ps_translate_location(cur_ts->gles_api_ts->ps, tl, location), (v_count / 2), v); } @@ -2235,8 +2234,8 @@ void yagl_host_glUniform3f(struct yagl_thread_state *cur_ts, GLfloat y, GLfloat z) { - gles_api_ts->driver->Uniform3f( - yagl_gles_api_ps_translate_location(gles_api_ts->ps, tl, location), + cur_ts->gles_api_ts->driver->Uniform3f( + yagl_gles_api_ps_translate_location(cur_ts->gles_api_ts->ps, tl, location), x, y, z); } @@ -2245,8 +2244,8 @@ void yagl_host_glUniform3fv(struct yagl_thread_state *cur_ts, uint32_t location, const GLfloat *v, int32_t v_count) { - gles_api_ts->driver->Uniform3fv( - yagl_gles_api_ps_translate_location(gles_api_ts->ps, tl, location), + cur_ts->gles_api_ts->driver->Uniform3fv( + yagl_gles_api_ps_translate_location(cur_ts->gles_api_ts->ps, tl, location), (v_count / 3), v); } @@ -2257,8 +2256,8 @@ void yagl_host_glUniform3i(struct yagl_thread_state *cur_ts, GLint y, GLint z) { - gles_api_ts->driver->Uniform3i( - yagl_gles_api_ps_translate_location(gles_api_ts->ps, tl, location), + cur_ts->gles_api_ts->driver->Uniform3i( + yagl_gles_api_ps_translate_location(cur_ts->gles_api_ts->ps, tl, location), x, y, z); } @@ -2267,8 +2266,8 @@ void yagl_host_glUniform3iv(struct yagl_thread_state *cur_ts, uint32_t location, const GLint *v, int32_t v_count) { - gles_api_ts->driver->Uniform3iv( - yagl_gles_api_ps_translate_location(gles_api_ts->ps, tl, location), + cur_ts->gles_api_ts->driver->Uniform3iv( + yagl_gles_api_ps_translate_location(cur_ts->gles_api_ts->ps, tl, location), (v_count / 3), v); } @@ -2280,8 +2279,8 @@ void yagl_host_glUniform4f(struct yagl_thread_state *cur_ts, GLfloat z, GLfloat w) { - gles_api_ts->driver->Uniform4f( - yagl_gles_api_ps_translate_location(gles_api_ts->ps, tl, location), + cur_ts->gles_api_ts->driver->Uniform4f( + yagl_gles_api_ps_translate_location(cur_ts->gles_api_ts->ps, tl, location), x, y, z, w); } @@ -2290,8 +2289,8 @@ void yagl_host_glUniform4fv(struct yagl_thread_state *cur_ts, uint32_t location, const GLfloat *v, int32_t v_count) { - gles_api_ts->driver->Uniform4fv( - yagl_gles_api_ps_translate_location(gles_api_ts->ps, tl, location), + cur_ts->gles_api_ts->driver->Uniform4fv( + yagl_gles_api_ps_translate_location(cur_ts->gles_api_ts->ps, tl, location), (v_count / 4), v); } @@ -2303,8 +2302,8 @@ void yagl_host_glUniform4i(struct yagl_thread_state *cur_ts, GLint z, GLint w) { - gles_api_ts->driver->Uniform4i( - yagl_gles_api_ps_translate_location(gles_api_ts->ps, tl, location), + cur_ts->gles_api_ts->driver->Uniform4i( + yagl_gles_api_ps_translate_location(cur_ts->gles_api_ts->ps, tl, location), x, y, z, w); } @@ -2313,8 +2312,8 @@ void yagl_host_glUniform4iv(struct yagl_thread_state *cur_ts, uint32_t location, const GLint *v, int32_t v_count) { - gles_api_ts->driver->Uniform4iv( - yagl_gles_api_ps_translate_location(gles_api_ts->ps, tl, location), + cur_ts->gles_api_ts->driver->Uniform4iv( + yagl_gles_api_ps_translate_location(cur_ts->gles_api_ts->ps, tl, location), (v_count / 4), v); } @@ -2324,8 +2323,8 @@ void yagl_host_glUniformMatrix2fv(struct yagl_thread_state *cur_ts, GLboolean transpose, const GLfloat *value, int32_t value_count) { - gles_api_ts->driver->UniformMatrix2fv( - yagl_gles_api_ps_translate_location(gles_api_ts->ps, tl, location), + cur_ts->gles_api_ts->driver->UniformMatrix2fv( + yagl_gles_api_ps_translate_location(cur_ts->gles_api_ts->ps, tl, location), value_count / (2 * 2), transpose, value); } @@ -2335,8 +2334,8 @@ void yagl_host_glUniformMatrix3fv(struct yagl_thread_state *cur_ts, GLboolean transpose, const GLfloat *value, int32_t value_count) { - gles_api_ts->driver->UniformMatrix3fv( - yagl_gles_api_ps_translate_location(gles_api_ts->ps, tl, location), + cur_ts->gles_api_ts->driver->UniformMatrix3fv( + yagl_gles_api_ps_translate_location(cur_ts->gles_api_ts->ps, tl, location), value_count / (3 * 3), transpose, value); } @@ -2346,35 +2345,35 @@ void yagl_host_glUniformMatrix4fv(struct yagl_thread_state *cur_ts, GLboolean transpose, const GLfloat *value, int32_t value_count) { - gles_api_ts->driver->UniformMatrix4fv( - yagl_gles_api_ps_translate_location(gles_api_ts->ps, tl, location), + cur_ts->gles_api_ts->driver->UniformMatrix4fv( + yagl_gles_api_ps_translate_location(cur_ts->gles_api_ts->ps, tl, location), value_count / (4 * 4), transpose, value); } void yagl_host_glUseProgram(struct yagl_thread_state *cur_ts, GLuint program) { - gles_api_ts->driver->UseProgram(yagl_gles_object_get(cur_ts, program)); + cur_ts->gles_api_ts->driver->UseProgram(yagl_gles_object_get(cur_ts, program)); } void yagl_host_glValidateProgram(struct yagl_thread_state *cur_ts, GLuint program) { - gles_api_ts->driver->ValidateProgram(yagl_gles_object_get(cur_ts, program)); + cur_ts->gles_api_ts->driver->ValidateProgram(yagl_gles_object_get(cur_ts, program)); } void yagl_host_glVertexAttrib1f(struct yagl_thread_state *cur_ts, GLuint indx, GLfloat x) { - gles_api_ts->driver->VertexAttrib1f(indx, x); + cur_ts->gles_api_ts->driver->VertexAttrib1f(indx, x); } void yagl_host_glVertexAttrib1fv(struct yagl_thread_state *cur_ts, GLuint indx, const GLfloat *values, int32_t values_count) { - gles_api_ts->driver->VertexAttrib1fv(indx, values); + cur_ts->gles_api_ts->driver->VertexAttrib1fv(indx, values); } void yagl_host_glVertexAttrib2f(struct yagl_thread_state *cur_ts, @@ -2382,14 +2381,14 @@ void yagl_host_glVertexAttrib2f(struct yagl_thread_state *cur_ts, GLfloat x, GLfloat y) { - gles_api_ts->driver->VertexAttrib2f(indx, x, y); + cur_ts->gles_api_ts->driver->VertexAttrib2f(indx, x, y); } void yagl_host_glVertexAttrib2fv(struct yagl_thread_state *cur_ts, GLuint indx, const GLfloat *values, int32_t values_count) { - gles_api_ts->driver->VertexAttrib2fv(indx, values); + cur_ts->gles_api_ts->driver->VertexAttrib2fv(indx, values); } void yagl_host_glVertexAttrib3f(struct yagl_thread_state *cur_ts, @@ -2398,14 +2397,14 @@ void yagl_host_glVertexAttrib3f(struct yagl_thread_state *cur_ts, GLfloat y, GLfloat z) { - gles_api_ts->driver->VertexAttrib3f(indx, x, y, z); + cur_ts->gles_api_ts->driver->VertexAttrib3f(indx, x, y, z); } void yagl_host_glVertexAttrib3fv(struct yagl_thread_state *cur_ts, GLuint indx, const GLfloat *values, int32_t values_count) { - gles_api_ts->driver->VertexAttrib3fv(indx, values); + cur_ts->gles_api_ts->driver->VertexAttrib3fv(indx, values); } void yagl_host_glVertexAttrib4f(struct yagl_thread_state *cur_ts, @@ -2415,14 +2414,14 @@ void yagl_host_glVertexAttrib4f(struct yagl_thread_state *cur_ts, GLfloat z, GLfloat w) { - gles_api_ts->driver->VertexAttrib4f(indx, x, y, z, w); + cur_ts->gles_api_ts->driver->VertexAttrib4f(indx, x, y, z, w); } void yagl_host_glVertexAttrib4fv(struct yagl_thread_state *cur_ts, GLuint indx, const GLfloat *values, int32_t values_count) { - gles_api_ts->driver->VertexAttrib4fv(indx, values); + cur_ts->gles_api_ts->driver->VertexAttrib4fv(indx, values); } void yagl_host_glGetActiveUniformsiv(struct yagl_thread_state *cur_ts, @@ -2449,11 +2448,11 @@ void yagl_host_glGetActiveUniformsiv(struct yagl_thread_state *cur_ts, } for (i = 0; i < num_pnames; ++i) { - gles_api_ts->driver->GetActiveUniformsiv(obj, - uniformIndices_count, - uniformIndices, - pnames[i], - params); + cur_ts->gles_api_ts->driver->GetActiveUniformsiv(obj, + uniformIndices_count, + uniformIndices, + pnames[i], + params); params += uniformIndices_count; } @@ -2470,6 +2469,7 @@ void yagl_host_glGetUniformIndices(struct yagl_thread_state *cur_ts, const GLchar **name_pointers; int num_active_uniforms = 0; GLchar *uniform_name; + struct yagl_gles_api_ts *gles_api_ts = cur_ts->gles_api_ts; YAGL_LOG_FUNC_SET(glGetUniformIndices); @@ -2592,8 +2592,8 @@ GLuint yagl_host_glGetUniformBlockIndex(struct yagl_thread_state *cur_ts, GLuint program, const GLchar *uniformBlockName, int32_t uniformBlockName_count) { - return gles_api_ts->driver->GetUniformBlockIndex(yagl_gles_object_get(cur_ts, program), - uniformBlockName); + return cur_ts->gles_api_ts->driver->GetUniformBlockIndex(yagl_gles_object_get(cur_ts, program), + uniformBlockName); } void yagl_host_glUniformBlockBinding(struct yagl_thread_state *cur_ts, @@ -2601,9 +2601,9 @@ void yagl_host_glUniformBlockBinding(struct yagl_thread_state *cur_ts, GLuint uniformBlockIndex, GLuint uniformBlockBinding) { - gles_api_ts->driver->UniformBlockBinding(yagl_gles_object_get(cur_ts, program), - uniformBlockIndex, - uniformBlockBinding); + cur_ts->gles_api_ts->driver->UniformBlockBinding(yagl_gles_object_get(cur_ts, program), + uniformBlockIndex, + uniformBlockBinding); } void yagl_host_glGetActiveUniformBlockName(struct yagl_thread_state *cur_ts, @@ -2613,11 +2613,11 @@ void yagl_host_glGetActiveUniformBlockName(struct yagl_thread_state *cur_ts, { GLsizei tmp = -1; - gles_api_ts->driver->GetActiveUniformBlockName(yagl_gles_object_get(cur_ts, program), - uniformBlockIndex, - uniformBlockName_maxcount, - &tmp, - uniformBlockName); + cur_ts->gles_api_ts->driver->GetActiveUniformBlockName(yagl_gles_object_get(cur_ts, program), + uniformBlockIndex, + uniformBlockName_maxcount, + &tmp, + uniformBlockName); if (tmp >= 0) { *uniformBlockName_count = MIN(tmp + 1, uniformBlockName_maxcount); @@ -2657,10 +2657,10 @@ void yagl_host_glGetActiveUniformBlockiv(struct yagl_thread_state *cur_ts, } for (i = 0; i < num_pnames; ++i) { - gles_api_ts->driver->GetActiveUniformBlockiv(obj, - uniformBlockIndex, - pnames[i], - ¶ms[i]); + cur_ts->gles_api_ts->driver->GetActiveUniformBlockiv(obj, + uniformBlockIndex, + pnames[i], + ¶ms[i]); } *params_count = num_pnames; @@ -2671,10 +2671,10 @@ void yagl_host_glGetActiveUniformBlockiv(struct yagl_thread_state *cur_ts, * Return active uniform indices only. */ - gles_api_ts->driver->GetActiveUniformBlockiv(obj, - uniformBlockIndex, - GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES, - params); + cur_ts->gles_api_ts->driver->GetActiveUniformBlockiv(obj, + uniformBlockIndex, + GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES, + params); *params_count = params_maxcount; @@ -2693,7 +2693,7 @@ void yagl_host_glGetVertexAttribIiv(struct yagl_thread_state *cur_ts, return; } - gles_api_ts->driver->GetVertexAttribIiv(index, pname, params); + cur_ts->gles_api_ts->driver->GetVertexAttribIiv(index, pname, params); } void yagl_host_glGetVertexAttribIuiv(struct yagl_thread_state *cur_ts, @@ -2705,7 +2705,7 @@ void yagl_host_glGetVertexAttribIuiv(struct yagl_thread_state *cur_ts, return; } - gles_api_ts->driver->GetVertexAttribIuiv(index, pname, params); + cur_ts->gles_api_ts->driver->GetVertexAttribIuiv(index, pname, params); } void yagl_host_glVertexAttribI4i(struct yagl_thread_state *cur_ts, @@ -2715,7 +2715,7 @@ void yagl_host_glVertexAttribI4i(struct yagl_thread_state *cur_ts, GLint z, GLint w) { - gles_api_ts->driver->VertexAttribI4i(index, x, y, z, w); + cur_ts->gles_api_ts->driver->VertexAttribI4i(index, x, y, z, w); } void yagl_host_glVertexAttribI4ui(struct yagl_thread_state *cur_ts, @@ -2725,21 +2725,21 @@ void yagl_host_glVertexAttribI4ui(struct yagl_thread_state *cur_ts, GLuint z, GLuint w) { - gles_api_ts->driver->VertexAttribI4ui(index, x, y, z, w); + cur_ts->gles_api_ts->driver->VertexAttribI4ui(index, x, y, z, w); } void yagl_host_glVertexAttribI4iv(struct yagl_thread_state *cur_ts, GLuint index, const GLint *v, int32_t v_count) { - gles_api_ts->driver->VertexAttribI4iv(index, v); + cur_ts->gles_api_ts->driver->VertexAttribI4iv(index, v); } void yagl_host_glVertexAttribI4uiv(struct yagl_thread_state *cur_ts, GLuint index, const GLuint *v, int32_t v_count) { - gles_api_ts->driver->VertexAttribI4uiv(index, v); + cur_ts->gles_api_ts->driver->VertexAttribI4uiv(index, v); } void yagl_host_glGetUniformuiv(struct yagl_thread_state *cur_ts, @@ -2750,7 +2750,7 @@ void yagl_host_glGetUniformuiv(struct yagl_thread_state *cur_ts, { GLenum type; GLuint global_name = yagl_gles_object_get(cur_ts, program); - GLint actual_location = yagl_gles_api_ps_translate_location(gles_api_ts->ps, + GLint actual_location = yagl_gles_api_ps_translate_location(cur_ts->gles_api_ts->ps, tl, location); @@ -2765,9 +2765,9 @@ void yagl_host_glGetUniformuiv(struct yagl_thread_state *cur_ts, return; } - gles_api_ts->driver->GetUniformuiv(global_name, - actual_location, - params); + cur_ts->gles_api_ts->driver->GetUniformuiv(global_name, + actual_location, + params); } void yagl_host_glUniform1ui(struct yagl_thread_state *cur_ts, @@ -2775,8 +2775,8 @@ void yagl_host_glUniform1ui(struct yagl_thread_state *cur_ts, uint32_t location, GLuint v0) { - gles_api_ts->driver->Uniform1ui( - yagl_gles_api_ps_translate_location(gles_api_ts->ps, tl, location), + cur_ts->gles_api_ts->driver->Uniform1ui( + yagl_gles_api_ps_translate_location(cur_ts->gles_api_ts->ps, tl, location), v0); } @@ -2786,8 +2786,8 @@ void yagl_host_glUniform2ui(struct yagl_thread_state *cur_ts, GLuint v0, GLuint v1) { - gles_api_ts->driver->Uniform2ui( - yagl_gles_api_ps_translate_location(gles_api_ts->ps, tl, location), + cur_ts->gles_api_ts->driver->Uniform2ui( + yagl_gles_api_ps_translate_location(cur_ts->gles_api_ts->ps, tl, location), v0, v1); } @@ -2798,8 +2798,8 @@ void yagl_host_glUniform3ui(struct yagl_thread_state *cur_ts, GLuint v1, GLuint v2) { - gles_api_ts->driver->Uniform3ui( - yagl_gles_api_ps_translate_location(gles_api_ts->ps, tl, location), + cur_ts->gles_api_ts->driver->Uniform3ui( + yagl_gles_api_ps_translate_location(cur_ts->gles_api_ts->ps, tl, location), v0, v1, v2); } @@ -2811,8 +2811,8 @@ void yagl_host_glUniform4ui(struct yagl_thread_state *cur_ts, GLuint v2, GLuint v3) { - gles_api_ts->driver->Uniform4ui( - yagl_gles_api_ps_translate_location(gles_api_ts->ps, tl, location), + cur_ts->gles_api_ts->driver->Uniform4ui( + yagl_gles_api_ps_translate_location(cur_ts->gles_api_ts->ps, tl, location), v0, v1, v2, v3); } @@ -2821,8 +2821,8 @@ void yagl_host_glUniform1uiv(struct yagl_thread_state *cur_ts, uint32_t location, const GLuint *v, int32_t v_count) { - gles_api_ts->driver->Uniform1uiv( - yagl_gles_api_ps_translate_location(gles_api_ts->ps, tl, location), + cur_ts->gles_api_ts->driver->Uniform1uiv( + yagl_gles_api_ps_translate_location(cur_ts->gles_api_ts->ps, tl, location), v_count, v); } @@ -2831,8 +2831,8 @@ void yagl_host_glUniform2uiv(struct yagl_thread_state *cur_ts, uint32_t location, const GLuint *v, int32_t v_count) { - gles_api_ts->driver->Uniform2uiv( - yagl_gles_api_ps_translate_location(gles_api_ts->ps, tl, location), + cur_ts->gles_api_ts->driver->Uniform2uiv( + yagl_gles_api_ps_translate_location(cur_ts->gles_api_ts->ps, tl, location), (v_count / 2), v); } @@ -2841,8 +2841,8 @@ void yagl_host_glUniform3uiv(struct yagl_thread_state *cur_ts, uint32_t location, const GLuint *v, int32_t v_count) { - gles_api_ts->driver->Uniform3uiv( - yagl_gles_api_ps_translate_location(gles_api_ts->ps, tl, location), + cur_ts->gles_api_ts->driver->Uniform3uiv( + yagl_gles_api_ps_translate_location(cur_ts->gles_api_ts->ps, tl, location), (v_count / 3), v); } @@ -2851,8 +2851,8 @@ void yagl_host_glUniform4uiv(struct yagl_thread_state *cur_ts, uint32_t location, const GLuint *v, int32_t v_count) { - gles_api_ts->driver->Uniform4uiv( - yagl_gles_api_ps_translate_location(gles_api_ts->ps, tl, location), + cur_ts->gles_api_ts->driver->Uniform4uiv( + yagl_gles_api_ps_translate_location(cur_ts->gles_api_ts->ps, tl, location), (v_count / 4), v); } @@ -2862,8 +2862,8 @@ void yagl_host_glUniformMatrix2x3fv(struct yagl_thread_state *cur_ts, GLboolean transpose, const GLfloat *value, int32_t value_count) { - gles_api_ts->driver->UniformMatrix2x3fv( - yagl_gles_api_ps_translate_location(gles_api_ts->ps, tl, location), + cur_ts->gles_api_ts->driver->UniformMatrix2x3fv( + yagl_gles_api_ps_translate_location(cur_ts->gles_api_ts->ps, tl, location), value_count / (2 * 3), transpose, value); } @@ -2873,8 +2873,8 @@ void yagl_host_glUniformMatrix2x4fv(struct yagl_thread_state *cur_ts, GLboolean transpose, const GLfloat *value, int32_t value_count) { - gles_api_ts->driver->UniformMatrix2x4fv( - yagl_gles_api_ps_translate_location(gles_api_ts->ps, tl, location), + cur_ts->gles_api_ts->driver->UniformMatrix2x4fv( + yagl_gles_api_ps_translate_location(cur_ts->gles_api_ts->ps, tl, location), value_count / (2 * 4), transpose, value); } @@ -2884,8 +2884,8 @@ void yagl_host_glUniformMatrix3x2fv(struct yagl_thread_state *cur_ts, GLboolean transpose, const GLfloat *value, int32_t value_count) { - gles_api_ts->driver->UniformMatrix3x2fv( - yagl_gles_api_ps_translate_location(gles_api_ts->ps, tl, location), + cur_ts->gles_api_ts->driver->UniformMatrix3x2fv( + yagl_gles_api_ps_translate_location(cur_ts->gles_api_ts->ps, tl, location), value_count / (3 * 2), transpose, value); } @@ -2895,8 +2895,8 @@ void yagl_host_glUniformMatrix3x4fv(struct yagl_thread_state *cur_ts, GLboolean transpose, const GLfloat *value, int32_t value_count) { - gles_api_ts->driver->UniformMatrix3x4fv( - yagl_gles_api_ps_translate_location(gles_api_ts->ps, tl, location), + cur_ts->gles_api_ts->driver->UniformMatrix3x4fv( + yagl_gles_api_ps_translate_location(cur_ts->gles_api_ts->ps, tl, location), value_count / (3 * 4), transpose, value); } @@ -2906,8 +2906,8 @@ void yagl_host_glUniformMatrix4x2fv(struct yagl_thread_state *cur_ts, GLboolean transpose, const GLfloat *value, int32_t value_count) { - gles_api_ts->driver->UniformMatrix4x2fv( - yagl_gles_api_ps_translate_location(gles_api_ts->ps, tl, location), + cur_ts->gles_api_ts->driver->UniformMatrix4x2fv( + yagl_gles_api_ps_translate_location(cur_ts->gles_api_ts->ps, tl, location), value_count / (4 * 2), transpose, value); } @@ -2917,8 +2917,8 @@ void yagl_host_glUniformMatrix4x3fv(struct yagl_thread_state *cur_ts, GLboolean transpose, const GLfloat *value, int32_t value_count) { - gles_api_ts->driver->UniformMatrix4x3fv( - yagl_gles_api_ps_translate_location(gles_api_ts->ps, tl, location), + cur_ts->gles_api_ts->driver->UniformMatrix4x3fv( + yagl_gles_api_ps_translate_location(cur_ts->gles_api_ts->ps, tl, location), value_count / (4 * 3), transpose, value); } @@ -2926,15 +2926,15 @@ int yagl_host_glGetFragDataLocation(struct yagl_thread_state *cur_ts, GLuint program, const GLchar *name, int32_t name_count) { - return gles_api_ts->driver->GetFragDataLocation(yagl_gles_object_get(cur_ts, program), - name); + return cur_ts->gles_api_ts->driver->GetFragDataLocation(yagl_gles_object_get(cur_ts, program), + name); } void yagl_host_glGetIntegerv(struct yagl_thread_state *cur_ts, GLenum pname, GLint *params, int32_t params_maxcount, int32_t *params_count) { - gles_api_ts->driver->GetIntegerv(pname, params); + cur_ts->gles_api_ts->driver->GetIntegerv(pname, params); *params_count = params_maxcount; } @@ -2943,7 +2943,7 @@ void yagl_host_glGetFloatv(struct yagl_thread_state *cur_ts, GLenum pname, GLfloat *params, int32_t params_maxcount, int32_t *params_count) { - gles_api_ts->driver->GetFloatv(pname, params); + cur_ts->gles_api_ts->driver->GetFloatv(pname, params); *params_count = params_maxcount; } @@ -2953,6 +2953,7 @@ void yagl_host_glGetString(struct yagl_thread_state *cur_ts, GLchar *str, int32_t str_maxcount, int32_t *str_count) { const char *tmp; + struct yagl_gles_api_ts *gles_api_ts = cur_ts->gles_api_ts; if ((name == GL_EXTENSIONS) && (gles_api_ts->driver->gl_version > yagl_gl_2)) { @@ -3009,7 +3010,7 @@ void yagl_host_glGetString(struct yagl_thread_state *cur_ts, GLboolean yagl_host_glIsEnabled(struct yagl_thread_state *cur_ts, GLenum cap) { - return gles_api_ts->driver->IsEnabled(cap); + return cur_ts->gles_api_ts->driver->IsEnabled(cap); } void yagl_host_glGenTransformFeedbacks(struct yagl_thread_state *cur_ts, @@ -3020,12 +3021,12 @@ void yagl_host_glGenTransformFeedbacks(struct yagl_thread_state *cur_ts, for (i = 0; i < ids_count; ++i) { GLuint global_name; - gles_api_ts->driver->GenTransformFeedbacks(1, &global_name); + cur_ts->gles_api_ts->driver->GenTransformFeedbacks(1, &global_name); - yagl_gles_object_add(cur_ts->ps, + yagl_gles_object_add(cur_ts, ids[i], global_name, - yagl_get_ctx_id(cur_ts->ps), + yagl_get_ctx_id(cur_ts), &yagl_gles_transform_feedback_destroy); } } @@ -3034,29 +3035,29 @@ void yagl_host_glBindTransformFeedback(struct yagl_thread_state *cur_ts, GLenum target, GLuint id) { - gles_api_ts->driver->BindTransformFeedback(target, - yagl_gles_object_get(cur_ts, id)); + cur_ts->gles_api_ts->driver->BindTransformFeedback(target, + yagl_gles_object_get(cur_ts, id)); } void yagl_host_glBeginTransformFeedback(struct yagl_thread_state *cur_ts, GLenum primitiveMode) { - gles_api_ts->driver->BeginTransformFeedback(primitiveMode); + cur_ts->gles_api_ts->driver->BeginTransformFeedback(primitiveMode); } void yagl_host_glEndTransformFeedback(struct yagl_thread_state *cur_ts) { - gles_api_ts->driver->EndTransformFeedback(); + cur_ts->gles_api_ts->driver->EndTransformFeedback(); } void yagl_host_glPauseTransformFeedback(struct yagl_thread_state *cur_ts) { - gles_api_ts->driver->PauseTransformFeedback(); + cur_ts->gles_api_ts->driver->PauseTransformFeedback(); } void yagl_host_glResumeTransformFeedback(struct yagl_thread_state *cur_ts) { - gles_api_ts->driver->ResumeTransformFeedback(); + cur_ts->gles_api_ts->driver->ResumeTransformFeedback(); } void yagl_host_glTransformFeedbackVaryings(struct yagl_thread_state *cur_ts, @@ -3072,10 +3073,10 @@ void yagl_host_glTransformFeedbackVaryings(struct yagl_thread_state *cur_ts, varyings_count, &num_strings); - gles_api_ts->driver->TransformFeedbackVaryings(yagl_gles_object_get(cur_ts, program), - num_strings, - strings, - bufferMode); + cur_ts->gles_api_ts->driver->TransformFeedbackVaryings(yagl_gles_object_get(cur_ts, program), + num_strings, + strings, + bufferMode); g_free(strings); } @@ -3096,10 +3097,10 @@ void yagl_host_glGetTransformFeedbackVaryings(struct yagl_thread_state *cur_ts, GLsizei length = -1; GLchar c[2]; - gles_api_ts->driver->GetTransformFeedbackVarying(obj, - i, sizeof(c), &length, - &sizes[i], &types[i], - c); + cur_ts->gles_api_ts->driver->GetTransformFeedbackVarying(obj, + i, sizeof(c), &length, + &sizes[i], &types[i], + c); if (length <= 0) { sizes[i] = 0; @@ -3118,12 +3119,12 @@ void yagl_host_glGenQueries(struct yagl_thread_state *cur_ts, for (i = 0; i < ids_count; ++i) { GLuint global_name; - gles_api_ts->driver->GenQueries(1, &global_name); + cur_ts->gles_api_ts->driver->GenQueries(1, &global_name); - yagl_gles_object_add(cur_ts->ps, + yagl_gles_object_add(cur_ts, ids[i], global_name, - yagl_get_ctx_id(cur_ts->ps), + yagl_get_ctx_id(cur_ts), &yagl_gles_query_destroy); } } @@ -3132,13 +3133,13 @@ void yagl_host_glBeginQuery(struct yagl_thread_state *cur_ts, GLenum target, GLuint id) { - gles_api_ts->driver->BeginQuery(target, yagl_gles_object_get(cur_ts, id)); + cur_ts->gles_api_ts->driver->BeginQuery(target, yagl_gles_object_get(cur_ts, id)); } void yagl_host_glEndQuery(struct yagl_thread_state *cur_ts, GLenum target) { - gles_api_ts->driver->EndQuery(target); + cur_ts->gles_api_ts->driver->EndQuery(target); } GLboolean yagl_host_glGetQueryObjectuiv(struct yagl_thread_state *cur_ts, @@ -3149,12 +3150,12 @@ GLboolean yagl_host_glGetQueryObjectuiv(struct yagl_thread_state *cur_ts, GLuint tmp = 0; if (pname == GL_QUERY_RESULT_AVAILABLE) { - gles_api_ts->driver->GetQueryObjectuiv(obj, GL_QUERY_RESULT_AVAILABLE, &tmp); + cur_ts->gles_api_ts->driver->GetQueryObjectuiv(obj, GL_QUERY_RESULT_AVAILABLE, &tmp); if (tmp) { - gles_api_ts->driver->GetQueryObjectuiv(obj, GL_QUERY_RESULT, result); + cur_ts->gles_api_ts->driver->GetQueryObjectuiv(obj, GL_QUERY_RESULT, result); } } else { - gles_api_ts->driver->GetQueryObjectuiv(obj, GL_QUERY_RESULT, result); + cur_ts->gles_api_ts->driver->GetQueryObjectuiv(obj, GL_QUERY_RESULT, result); tmp = GL_TRUE; } @@ -3169,9 +3170,9 @@ void yagl_host_glGenSamplers(struct yagl_thread_state *cur_ts, for (i = 0; i < samplers_count; ++i) { GLuint global_name; - gles_api_ts->driver->GenSamplers(1, &global_name); + cur_ts->gles_api_ts->driver->GenSamplers(1, &global_name); - yagl_gles_object_add(cur_ts->ps, + yagl_gles_object_add(cur_ts, samplers[i], global_name, 0, @@ -3183,7 +3184,7 @@ void yagl_host_glBindSampler(struct yagl_thread_state *cur_ts, GLuint unit, GLuint sampler) { - gles_api_ts->driver->BindSampler(unit, yagl_gles_object_get(cur_ts, sampler)); + cur_ts->gles_api_ts->driver->BindSampler(unit, yagl_gles_object_get(cur_ts, sampler)); } void yagl_host_glSamplerParameteri(struct yagl_thread_state *cur_ts, @@ -3191,7 +3192,7 @@ void yagl_host_glSamplerParameteri(struct yagl_thread_state *cur_ts, GLenum pname, GLint param) { - gles_api_ts->driver->SamplerParameteri(yagl_gles_object_get(cur_ts, sampler), pname, param); + cur_ts->gles_api_ts->driver->SamplerParameteri(yagl_gles_object_get(cur_ts, sampler), pname, param); } void yagl_host_glSamplerParameteriv(struct yagl_thread_state *cur_ts, @@ -3199,7 +3200,7 @@ void yagl_host_glSamplerParameteriv(struct yagl_thread_state *cur_ts, GLenum pname, const GLint *param, int32_t param_count) { - gles_api_ts->driver->SamplerParameteriv(yagl_gles_object_get(cur_ts, sampler), pname, param); + cur_ts->gles_api_ts->driver->SamplerParameteriv(yagl_gles_object_get(cur_ts, sampler), pname, param); } void yagl_host_glSamplerParameterf(struct yagl_thread_state *cur_ts, @@ -3207,7 +3208,7 @@ void yagl_host_glSamplerParameterf(struct yagl_thread_state *cur_ts, GLenum pname, GLfloat param) { - gles_api_ts->driver->SamplerParameterf(yagl_gles_object_get(cur_ts, sampler), pname, param); + cur_ts->gles_api_ts->driver->SamplerParameterf(yagl_gles_object_get(cur_ts, sampler), pname, param); } void yagl_host_glSamplerParameterfv(struct yagl_thread_state *cur_ts, @@ -3215,7 +3216,7 @@ void yagl_host_glSamplerParameterfv(struct yagl_thread_state *cur_ts, GLenum pname, const GLfloat *param, int32_t param_count) { - gles_api_ts->driver->SamplerParameterfv(yagl_gles_object_get(cur_ts, sampler), pname, param); + cur_ts->gles_api_ts->driver->SamplerParameterfv(yagl_gles_object_get(cur_ts, sampler), pname, param); } void yagl_host_glDeleteObjects(struct yagl_thread_state *cur_ts, @@ -3224,28 +3225,28 @@ void yagl_host_glDeleteObjects(struct yagl_thread_state *cur_ts, int i; for (i = 0; i < objects_count; ++i) { - yagl_object_map_remove(cur_ts->ps->object_map, objects[i]); + yagl_object_map_remove(cur_ts, cur_ts->ps->object_map, objects[i]); } } void yagl_host_glBlendEquation(struct yagl_thread_state *cur_ts, GLenum mode) { - gles_api_ts->driver->BlendEquation(mode); + cur_ts->gles_api_ts->driver->BlendEquation(mode); } void yagl_host_glBlendEquationSeparate(struct yagl_thread_state *cur_ts, GLenum modeRGB, GLenum modeAlpha) { - gles_api_ts->driver->BlendEquationSeparate(modeRGB, modeAlpha); + cur_ts->gles_api_ts->driver->BlendEquationSeparate(modeRGB, modeAlpha); } void yagl_host_glBlendFunc(struct yagl_thread_state *cur_ts, GLenum sfactor, GLenum dfactor) { - gles_api_ts->driver->BlendFunc(sfactor, dfactor); + cur_ts->gles_api_ts->driver->BlendFunc(sfactor, dfactor); } void yagl_host_glBlendFuncSeparate(struct yagl_thread_state *cur_ts, @@ -3254,7 +3255,7 @@ void yagl_host_glBlendFuncSeparate(struct yagl_thread_state *cur_ts, GLenum srcAlpha, GLenum dstAlpha) { - gles_api_ts->driver->BlendFuncSeparate(srcRGB, + cur_ts->gles_api_ts->driver->BlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha); @@ -3266,13 +3267,13 @@ void yagl_host_glBlendColor(struct yagl_thread_state *cur_ts, GLclampf blue, GLclampf alpha) { - gles_api_ts->driver->BlendColor(red, green, blue, alpha); + cur_ts->gles_api_ts->driver->BlendColor(red, green, blue, alpha); } void yagl_host_glClear(struct yagl_thread_state *cur_ts, GLbitfield mask) { - gles_api_ts->driver->Clear(mask); + cur_ts->gles_api_ts->driver->Clear(mask); } void yagl_host_glClearColor(struct yagl_thread_state *cur_ts, @@ -3281,19 +3282,19 @@ void yagl_host_glClearColor(struct yagl_thread_state *cur_ts, GLclampf blue, GLclampf alpha) { - gles_api_ts->driver->ClearColor(red, green, blue, alpha); + cur_ts->gles_api_ts->driver->ClearColor(red, green, blue, alpha); } void yagl_host_glClearDepthf(struct yagl_thread_state *cur_ts, GLclampf depth) { - gles_api_ts->driver->ClearDepth(depth); + cur_ts->gles_api_ts->driver->ClearDepth(depth); } void yagl_host_glClearStencil(struct yagl_thread_state *cur_ts, GLint s) { - gles_api_ts->driver->ClearStencil(s); + cur_ts->gles_api_ts->driver->ClearStencil(s); } void yagl_host_glColorMask(struct yagl_thread_state *cur_ts, @@ -3302,88 +3303,88 @@ void yagl_host_glColorMask(struct yagl_thread_state *cur_ts, GLboolean blue, GLboolean alpha) { - gles_api_ts->driver->ColorMask(red, green, blue, alpha); + cur_ts->gles_api_ts->driver->ColorMask(red, green, blue, alpha); } void yagl_host_glCullFace(struct yagl_thread_state *cur_ts, GLenum mode) { - gles_api_ts->driver->CullFace(mode); + cur_ts->gles_api_ts->driver->CullFace(mode); } void yagl_host_glDepthFunc(struct yagl_thread_state *cur_ts, GLenum func) { - gles_api_ts->driver->DepthFunc(func); + cur_ts->gles_api_ts->driver->DepthFunc(func); } void yagl_host_glDepthMask(struct yagl_thread_state *cur_ts, GLboolean flag) { - gles_api_ts->driver->DepthMask(flag); + cur_ts->gles_api_ts->driver->DepthMask(flag); } void yagl_host_glDepthRangef(struct yagl_thread_state *cur_ts, GLclampf zNear, GLclampf zFar) { - gles_api_ts->driver->DepthRange(zNear, zFar); + cur_ts->gles_api_ts->driver->DepthRange(zNear, zFar); } void yagl_host_glEnable(struct yagl_thread_state *cur_ts, GLenum cap) { - gles_api_ts->driver->Enable(cap); + cur_ts->gles_api_ts->driver->Enable(cap); } void yagl_host_glDisable(struct yagl_thread_state *cur_ts, GLenum cap) { - gles_api_ts->driver->Disable(cap); + cur_ts->gles_api_ts->driver->Disable(cap); } void yagl_host_glFlush(struct yagl_thread_state *cur_ts) { - gles_api_ts->driver->Flush(); + cur_ts->gles_api_ts->driver->Flush(); } void yagl_host_glFrontFace(struct yagl_thread_state *cur_ts, GLenum mode) { - gles_api_ts->driver->FrontFace(mode); + cur_ts->gles_api_ts->driver->FrontFace(mode); } void yagl_host_glGenerateMipmap(struct yagl_thread_state *cur_ts, GLenum target) { - gles_api_ts->driver->GenerateMipmap(target); + cur_ts->gles_api_ts->driver->GenerateMipmap(target); } void yagl_host_glHint(struct yagl_thread_state *cur_ts, GLenum target, GLenum mode) { - gles_api_ts->driver->Hint(target, mode); + cur_ts->gles_api_ts->driver->Hint(target, mode); } void yagl_host_glLineWidth(struct yagl_thread_state *cur_ts, GLfloat width) { - gles_api_ts->driver->LineWidth(width); + cur_ts->gles_api_ts->driver->LineWidth(width); } void yagl_host_glPixelStorei(struct yagl_thread_state *cur_ts, GLenum pname, GLint param) { - gles_api_ts->driver->PixelStorei(pname, param); + cur_ts->gles_api_ts->driver->PixelStorei(pname, param); } void yagl_host_glPolygonOffset(struct yagl_thread_state *cur_ts, GLfloat factor, GLfloat units) { - gles_api_ts->driver->PolygonOffset(factor, units); + cur_ts->gles_api_ts->driver->PolygonOffset(factor, units); } void yagl_host_glScissor(struct yagl_thread_state *cur_ts, @@ -3392,7 +3393,7 @@ void yagl_host_glScissor(struct yagl_thread_state *cur_ts, GLsizei width, GLsizei height) { - gles_api_ts->driver->Scissor(x, y, width, height); + cur_ts->gles_api_ts->driver->Scissor(x, y, width, height); } void yagl_host_glStencilFunc(struct yagl_thread_state *cur_ts, @@ -3400,13 +3401,13 @@ void yagl_host_glStencilFunc(struct yagl_thread_state *cur_ts, GLint ref, GLuint mask) { - gles_api_ts->driver->StencilFunc(func, ref, mask); + cur_ts->gles_api_ts->driver->StencilFunc(func, ref, mask); } void yagl_host_glStencilMask(struct yagl_thread_state *cur_ts, GLuint mask) { - gles_api_ts->driver->StencilMask(mask); + cur_ts->gles_api_ts->driver->StencilMask(mask); } void yagl_host_glStencilOp(struct yagl_thread_state *cur_ts, @@ -3414,14 +3415,14 @@ void yagl_host_glStencilOp(struct yagl_thread_state *cur_ts, GLenum zfail, GLenum zpass) { - gles_api_ts->driver->StencilOp(fail, zfail, zpass); + cur_ts->gles_api_ts->driver->StencilOp(fail, zfail, zpass); } void yagl_host_glSampleCoverage(struct yagl_thread_state *cur_ts, GLclampf value, GLboolean invert) { - gles_api_ts->driver->SampleCoverage(value, invert); + cur_ts->gles_api_ts->driver->SampleCoverage(value, invert); } void yagl_host_glViewport(struct yagl_thread_state *cur_ts, @@ -3430,7 +3431,7 @@ void yagl_host_glViewport(struct yagl_thread_state *cur_ts, GLsizei width, GLsizei height) { - gles_api_ts->driver->Viewport(x, y, width, height); + cur_ts->gles_api_ts->driver->Viewport(x, y, width, height); } void yagl_host_glStencilFuncSeparate(struct yagl_thread_state *cur_ts, @@ -3439,14 +3440,14 @@ void yagl_host_glStencilFuncSeparate(struct yagl_thread_state *cur_ts, GLint ref, GLuint mask) { - gles_api_ts->driver->StencilFuncSeparate(face, func, ref, mask); + cur_ts->gles_api_ts->driver->StencilFuncSeparate(face, func, ref, mask); } void yagl_host_glStencilMaskSeparate(struct yagl_thread_state *cur_ts, GLenum face, GLuint mask) { - gles_api_ts->driver->StencilMaskSeparate(face, mask); + cur_ts->gles_api_ts->driver->StencilMaskSeparate(face, mask); } void yagl_host_glStencilOpSeparate(struct yagl_thread_state *cur_ts, @@ -3455,41 +3456,41 @@ void yagl_host_glStencilOpSeparate(struct yagl_thread_state *cur_ts, GLenum zfail, GLenum zpass) { - gles_api_ts->driver->StencilOpSeparate(face, fail, zfail, zpass); + cur_ts->gles_api_ts->driver->StencilOpSeparate(face, fail, zfail, zpass); } void yagl_host_glPointSize(struct yagl_thread_state *cur_ts, GLfloat size) { - gles_api_ts->driver->PointSize(size); + cur_ts->gles_api_ts->driver->PointSize(size); } void yagl_host_glAlphaFunc(struct yagl_thread_state *cur_ts, GLenum func, GLclampf ref) { - gles_api_ts->driver->AlphaFunc(func, ref); + cur_ts->gles_api_ts->driver->AlphaFunc(func, ref); } void yagl_host_glMatrixMode(struct yagl_thread_state *cur_ts, GLenum mode) { - gles_api_ts->driver->MatrixMode(mode); + cur_ts->gles_api_ts->driver->MatrixMode(mode); } void yagl_host_glLoadIdentity(struct yagl_thread_state *cur_ts) { - gles_api_ts->driver->LoadIdentity(); + cur_ts->gles_api_ts->driver->LoadIdentity(); } void yagl_host_glPopMatrix(struct yagl_thread_state *cur_ts) { - gles_api_ts->driver->PopMatrix(); + cur_ts->gles_api_ts->driver->PopMatrix(); } void yagl_host_glPushMatrix(struct yagl_thread_state *cur_ts) { - gles_api_ts->driver->PushMatrix(); + cur_ts->gles_api_ts->driver->PushMatrix(); } void yagl_host_glRotatef(struct yagl_thread_state *cur_ts, @@ -3498,7 +3499,7 @@ void yagl_host_glRotatef(struct yagl_thread_state *cur_ts, GLfloat y, GLfloat z) { - gles_api_ts->driver->Rotatef(angle, x, y, z); + cur_ts->gles_api_ts->driver->Rotatef(angle, x, y, z); } void yagl_host_glTranslatef(struct yagl_thread_state *cur_ts, @@ -3506,7 +3507,7 @@ void yagl_host_glTranslatef(struct yagl_thread_state *cur_ts, GLfloat y, GLfloat z) { - gles_api_ts->driver->Translatef(x, y, z); + cur_ts->gles_api_ts->driver->Translatef(x, y, z); } void yagl_host_glScalef(struct yagl_thread_state *cur_ts, @@ -3514,7 +3515,7 @@ void yagl_host_glScalef(struct yagl_thread_state *cur_ts, GLfloat y, GLfloat z) { - gles_api_ts->driver->Scalef(x, y, z); + cur_ts->gles_api_ts->driver->Scalef(x, y, z); } void yagl_host_glOrthof(struct yagl_thread_state *cur_ts, @@ -3525,7 +3526,7 @@ void yagl_host_glOrthof(struct yagl_thread_state *cur_ts, GLfloat zNear, GLfloat zFar) { - gles_api_ts->driver->Ortho(left, right, bottom, top, zNear, zFar); + cur_ts->gles_api_ts->driver->Ortho(left, right, bottom, top, zNear, zFar); } void yagl_host_glColor4f(struct yagl_thread_state *cur_ts, @@ -3534,7 +3535,7 @@ void yagl_host_glColor4f(struct yagl_thread_state *cur_ts, GLfloat blue, GLfloat alpha) { - gles_api_ts->driver->Color4f(red, green, blue, alpha); + cur_ts->gles_api_ts->driver->Color4f(red, green, blue, alpha); } void yagl_host_glColor4ub(struct yagl_thread_state *cur_ts, @@ -3543,7 +3544,7 @@ void yagl_host_glColor4ub(struct yagl_thread_state *cur_ts, GLubyte blue, GLubyte alpha) { - gles_api_ts->driver->Color4ub(red, green, blue, alpha); + cur_ts->gles_api_ts->driver->Color4ub(red, green, blue, alpha); } void yagl_host_glNormal3f(struct yagl_thread_state *cur_ts, @@ -3551,35 +3552,35 @@ void yagl_host_glNormal3f(struct yagl_thread_state *cur_ts, GLfloat ny, GLfloat nz) { - gles_api_ts->driver->Normal3f(nx, ny, nz); + cur_ts->gles_api_ts->driver->Normal3f(nx, ny, nz); } void yagl_host_glPointParameterf(struct yagl_thread_state *cur_ts, GLenum pname, GLfloat param) { - gles_api_ts->driver->PointParameterf(pname, param); + cur_ts->gles_api_ts->driver->PointParameterf(pname, param); } void yagl_host_glPointParameterfv(struct yagl_thread_state *cur_ts, GLenum pname, const GLfloat *params, int32_t params_count) { - gles_api_ts->driver->PointParameterfv(pname, params); + cur_ts->gles_api_ts->driver->PointParameterfv(pname, params); } void yagl_host_glFogf(struct yagl_thread_state *cur_ts, GLenum pname, GLfloat param) { - gles_api_ts->driver->Fogf(pname, param); + cur_ts->gles_api_ts->driver->Fogf(pname, param); } void yagl_host_glFogfv(struct yagl_thread_state *cur_ts, GLenum pname, const GLfloat *params, int32_t params_count) { - gles_api_ts->driver->Fogfv(pname, params); + cur_ts->gles_api_ts->driver->Fogfv(pname, params); } void yagl_host_glFrustumf(struct yagl_thread_state *cur_ts, @@ -3590,7 +3591,7 @@ void yagl_host_glFrustumf(struct yagl_thread_state *cur_ts, GLfloat zNear, GLfloat zFar) { - gles_api_ts->driver->Frustum(left, right, bottom, top, zNear, zFar); + cur_ts->gles_api_ts->driver->Frustum(left, right, bottom, top, zNear, zFar); } void yagl_host_glLightf(struct yagl_thread_state *cur_ts, @@ -3598,7 +3599,7 @@ void yagl_host_glLightf(struct yagl_thread_state *cur_ts, GLenum pname, GLfloat param) { - gles_api_ts->driver->Lightf(light, pname, param); + cur_ts->gles_api_ts->driver->Lightf(light, pname, param); } void yagl_host_glLightfv(struct yagl_thread_state *cur_ts, @@ -3606,7 +3607,7 @@ void yagl_host_glLightfv(struct yagl_thread_state *cur_ts, GLenum pname, const GLfloat *params, int32_t params_count) { - gles_api_ts->driver->Lightfv(light, pname, params); + cur_ts->gles_api_ts->driver->Lightfv(light, pname, params); } void yagl_host_glGetLightfv(struct yagl_thread_state *cur_ts, @@ -3614,7 +3615,7 @@ void yagl_host_glGetLightfv(struct yagl_thread_state *cur_ts, GLenum pname, GLfloat *params, int32_t params_maxcount, int32_t *params_count) { - gles_api_ts->driver->GetLightfv(light, pname, params); + cur_ts->gles_api_ts->driver->GetLightfv(light, pname, params); *params_count = params_maxcount; } @@ -3622,14 +3623,14 @@ void yagl_host_glLightModelf(struct yagl_thread_state *cur_ts, GLenum pname, GLfloat param) { - gles_api_ts->driver->LightModelf(pname, param); + cur_ts->gles_api_ts->driver->LightModelf(pname, param); } void yagl_host_glLightModelfv(struct yagl_thread_state *cur_ts, GLenum pname, const GLfloat *params, int32_t params_count) { - gles_api_ts->driver->LightModelfv(pname, params); + cur_ts->gles_api_ts->driver->LightModelfv(pname, params); } void yagl_host_glMaterialf(struct yagl_thread_state *cur_ts, @@ -3637,7 +3638,7 @@ void yagl_host_glMaterialf(struct yagl_thread_state *cur_ts, GLenum pname, GLfloat param) { - gles_api_ts->driver->Materialf(face, pname, param); + cur_ts->gles_api_ts->driver->Materialf(face, pname, param); } void yagl_host_glMaterialfv(struct yagl_thread_state *cur_ts, @@ -3645,7 +3646,7 @@ void yagl_host_glMaterialfv(struct yagl_thread_state *cur_ts, GLenum pname, const GLfloat *params, int32_t params_count) { - gles_api_ts->driver->Materialfv(face, pname, params); + cur_ts->gles_api_ts->driver->Materialfv(face, pname, params); } void yagl_host_glGetMaterialfv(struct yagl_thread_state *cur_ts, @@ -3653,32 +3654,32 @@ void yagl_host_glGetMaterialfv(struct yagl_thread_state *cur_ts, GLenum pname, GLfloat *params, int32_t params_maxcount, int32_t *params_count) { - gles_api_ts->driver->GetMaterialfv(face, pname, params); + cur_ts->gles_api_ts->driver->GetMaterialfv(face, pname, params); *params_count = params_maxcount; } void yagl_host_glShadeModel(struct yagl_thread_state *cur_ts, GLenum mode) { - gles_api_ts->driver->ShadeModel(mode); + cur_ts->gles_api_ts->driver->ShadeModel(mode); } void yagl_host_glLogicOp(struct yagl_thread_state *cur_ts, GLenum opcode) { - gles_api_ts->driver->LogicOp(opcode); + cur_ts->gles_api_ts->driver->LogicOp(opcode); } void yagl_host_glMultMatrixf(struct yagl_thread_state *cur_ts, const GLfloat *m, int32_t m_count) { - gles_api_ts->driver->MultMatrixf(m); + cur_ts->gles_api_ts->driver->MultMatrixf(m); } void yagl_host_glLoadMatrixf(struct yagl_thread_state *cur_ts, const GLfloat *m, int32_t m_count) { - gles_api_ts->driver->LoadMatrixf(m); + cur_ts->gles_api_ts->driver->LoadMatrixf(m); } void yagl_host_glClipPlanef(struct yagl_thread_state *cur_ts, @@ -3692,9 +3693,9 @@ void yagl_host_glClipPlanef(struct yagl_thread_state *cur_ts, equationd[1] = equation[1]; equationd[2] = equation[2]; equationd[3] = equation[3]; - gles_api_ts->driver->ClipPlane(plane, equationd); + cur_ts->gles_api_ts->driver->ClipPlane(plane, equationd); } else { - gles_api_ts->driver->ClipPlane(plane, NULL); + cur_ts->gles_api_ts->driver->ClipPlane(plane, NULL); } } @@ -3704,7 +3705,7 @@ void yagl_host_glGetClipPlanef(struct yagl_thread_state *cur_ts, { yagl_GLdouble eqnd[4]; - gles_api_ts->driver->GetClipPlane(pname, eqnd); + cur_ts->gles_api_ts->driver->GetClipPlane(pname, eqnd); if (eqn) { eqn[0] = eqnd[0]; @@ -3725,6 +3726,7 @@ void yagl_host_glUpdateOffscreenImageYAGL(struct yagl_thread_state *cur_ts, GLenum format = 0; GLuint cur_tex = 0; GLsizei unpack[3]; + struct yagl_gles_api_ts *gles_api_ts = cur_ts->gles_api_ts; YAGL_LOG_FUNC_SET(glUpdateOffscreenImageYAGL); @@ -3779,9 +3781,9 @@ void yagl_host_glGenUniformLocationYAGL(struct yagl_thread_state *cur_ts, GLuint program, const GLchar *name, int32_t name_count) { - yagl_gles_api_ps_add_location(gles_api_ts->ps, + yagl_gles_api_ps_add_location(cur_ts->gles_api_ts->ps, location, - gles_api_ts->driver->GetUniformLocation(yagl_gles_object_get(cur_ts, program), name)); + cur_ts->gles_api_ts->driver->GetUniformLocation(yagl_gles_object_get(cur_ts, program), name)); } void yagl_host_glDeleteUniformLocationsYAGL(struct yagl_thread_state *cur_ts, @@ -3790,6 +3792,6 @@ void yagl_host_glDeleteUniformLocationsYAGL(struct yagl_thread_state *cur_ts, int i; for (i = 0; i < locations_count; ++i) { - yagl_gles_api_ps_remove_location(gles_api_ts->ps, locations[i]); + yagl_gles_api_ps_remove_location(cur_ts->gles_api_ts->ps, locations[i]); } } diff --git a/hw/yagl/yagl_backends/egl_offscreen/yagl_egl_offscreen.c b/hw/yagl/yagl_backends/egl_offscreen/yagl_egl_offscreen.c index b4d4260..f554df0 100644 --- a/hw/yagl/yagl_backends/egl_offscreen/yagl_egl_offscreen.c +++ b/hw/yagl/yagl_backends/egl_offscreen/yagl_egl_offscreen.c @@ -38,17 +38,14 @@ #include "yagl_thread.h" #include "yagl_gles_driver.h" -// TODO remove and pass via argument -YAGL_DEFINE_TLS(struct yagl_egl_offscreen_ts*, egl_offscreen_ts); - static void yagl_egl_offscreen_thread_init(struct yagl_thread_state *cur_ts, struct yagl_egl_backend *backend) { - YAGL_LOG_FUNC_ENTER(yagl_egl_offscreen_thread_init, NULL); + struct yagl_egl_offscreen *egl_offscreen = (struct yagl_egl_offscreen*)backend; - egl_offscreen_ts = yagl_egl_offscreen_ts_create(); + YAGL_LOG_FUNC_ENTER(yagl_egl_offscreen_thread_init, NULL); - cur_ts->egl_offscreen_ts = egl_offscreen_ts; + cur_ts->egl_offscreen_ts = yagl_egl_offscreen_ts_create(egl_offscreen->gles_driver); YAGL_LOG_FUNC_EXIT(NULL); } @@ -57,8 +54,7 @@ static void yagl_egl_offscreen_batch_start(struct yagl_thread_state *cur_ts, struct yagl_egl_backend *backend) { struct yagl_egl_offscreen *egl_offscreen = (struct yagl_egl_offscreen*)backend; - - egl_offscreen_ts = cur_ts->egl_offscreen_ts; + struct yagl_egl_offscreen_ts *egl_offscreen_ts = cur_ts->egl_offscreen_ts; if (!egl_offscreen_ts->dpy) { return; @@ -75,6 +71,7 @@ static void yagl_egl_offscreen_batch_end(struct yagl_thread_state *cur_ts, struct yagl_egl_backend *backend) { struct yagl_egl_offscreen *egl_offscreen = (struct yagl_egl_offscreen*)backend; + struct yagl_egl_offscreen_ts *egl_offscreen_ts = cur_ts->egl_offscreen_ts; if (!egl_offscreen_ts->dpy) { return; @@ -104,6 +101,7 @@ static bool yagl_egl_offscreen_make_current(struct yagl_thread_state *cur_ts, struct yagl_eglb_surface *read) { struct yagl_egl_offscreen *egl_offscreen = (struct yagl_egl_offscreen*)backend; + struct yagl_egl_offscreen_ts *egl_offscreen_ts = cur_ts->egl_offscreen_ts; struct yagl_egl_offscreen_display *egl_offscreen_dpy = (struct yagl_egl_offscreen_display*)dpy; struct yagl_egl_offscreen_context *egl_offscreen_ctx = (struct yagl_egl_offscreen_context*)ctx; struct yagl_egl_offscreen_surface *egl_offscreen_draw = (struct yagl_egl_offscreen_surface*)draw; @@ -147,6 +145,7 @@ static bool yagl_egl_offscreen_release_current(struct yagl_thread_state *cur_ts, bool force) { struct yagl_egl_offscreen *egl_offscreen = (struct yagl_egl_offscreen*)backend; + struct yagl_egl_offscreen_ts *egl_offscreen_ts = cur_ts->egl_offscreen_ts; bool res; YAGL_LOG_FUNC_ENTER(yagl_egl_offscreen_release_current, NULL); @@ -182,13 +181,14 @@ static void yagl_egl_offscreen_thread_fini(struct yagl_thread_state *cur_ts, { YAGL_LOG_FUNC_ENTER(yagl_egl_offscreen_thread_fini, NULL); - yagl_egl_offscreen_ts_destroy(egl_offscreen_ts); - egl_offscreen_ts = cur_ts->egl_offscreen_ts = NULL; + yagl_egl_offscreen_ts_destroy(cur_ts->egl_offscreen_ts); + cur_ts->egl_offscreen_ts = NULL; YAGL_LOG_FUNC_EXIT(NULL); } -static void yagl_egl_offscreen_ensure_current(struct yagl_egl_backend *backend) +static void yagl_egl_offscreen_ensure_current(struct yagl_thread_state *cur_ts, + struct yagl_egl_backend *backend) { struct yagl_egl_offscreen *egl_offscreen = (struct yagl_egl_offscreen*)backend; @@ -199,9 +199,12 @@ static void yagl_egl_offscreen_ensure_current(struct yagl_egl_backend *backend) egl_offscreen->ensure_ctx); } -static void yagl_egl_offscreen_unensure_current(struct yagl_egl_backend *backend) +static void yagl_egl_offscreen_unensure_current(struct yagl_thread_state *cur_ts, + struct yagl_egl_backend *backend) { struct yagl_egl_offscreen *egl_offscreen = (struct yagl_egl_offscreen*)backend; + // cur_ts may be NULL here if called from main thread + struct yagl_egl_offscreen_ts *egl_offscreen_ts = (cur_ts ? cur_ts->egl_offscreen_ts : NULL); if (egl_offscreen_ts && egl_offscreen_ts->dpy) { egl_offscreen->egl_driver->make_current(egl_offscreen->egl_driver, diff --git a/hw/yagl/yagl_backends/egl_offscreen/yagl_egl_offscreen_context.c b/hw/yagl/yagl_backends/egl_offscreen/yagl_egl_offscreen_context.c index 1da33c2..889ebc6 100644 --- a/hw/yagl/yagl_backends/egl_offscreen/yagl_egl_offscreen_context.c +++ b/hw/yagl/yagl_backends/egl_offscreen/yagl_egl_offscreen_context.c @@ -34,11 +34,11 @@ #include "yagl_egl_native_config.h" #include "yagl_gles_driver.h" #include "yagl_log.h" -#include "yagl_tls.h" #include "yagl_process.h" #include "yagl_thread.h" -static void yagl_egl_offscreen_context_destroy(struct yagl_eglb_context *ctx) +static void yagl_egl_offscreen_context_destroy(struct yagl_thread_state *cur_ts, + struct yagl_eglb_context *ctx) { struct yagl_egl_offscreen_context *egl_offscreen_ctx = (struct yagl_egl_offscreen_context*)ctx; @@ -46,14 +46,13 @@ static void yagl_egl_offscreen_context_destroy(struct yagl_eglb_context *ctx) (struct yagl_egl_offscreen_display*)ctx->dpy; struct yagl_egl_offscreen *egl_offscreen = (struct yagl_egl_offscreen*)ctx->dpy->backend; - YAGL_LOG_NO_TS; YAGL_LOG_FUNC_ENTER(yagl_egl_offscreen_context_destroy, NULL); if (egl_offscreen_ctx->rp_pbo) { - yagl_ensure_ctx(ctx->ps, 0); + yagl_ensure_ctx(cur_ts, 0); egl_offscreen->gles_driver->DeleteBuffers(1, &egl_offscreen_ctx->rp_pbo); - yagl_unensure_ctx(ctx->ps, 0); + yagl_unensure_ctx(cur_ts, 0); } egl_offscreen->egl_driver->context_destroy(egl_offscreen->egl_driver, @@ -136,7 +135,7 @@ bool yagl_egl_offscreen_context_read_pixels(struct yagl_thread_state *cur_ts, gles_driver->GetIntegerv(GL_READ_FRAMEBUFFER_BINDING, (GLint*)¤t_fb); - gles_driver->BindFramebuffer(GL_READ_FRAMEBUFFER, 0); + gles_driver->BindFramebufferYAGL(cur_ts, GL_READ_FRAMEBUFFER, 0); gles_driver->GetIntegerv(GL_PACK_ALIGNMENT, ¤t_pack[0]); gles_driver->GetIntegerv(GL_PACK_ROW_LENGTH, ¤t_pack[1]); @@ -230,7 +229,7 @@ out: gles_driver->PixelStorei(GL_PACK_IMAGE_HEIGHT, current_pack[2]); gles_driver->BindBuffer(GL_PIXEL_PACK_BUFFER_ARB, current_pbo); - gles_driver->BindFramebuffer(GL_READ_FRAMEBUFFER, current_fb); + gles_driver->BindFramebufferYAGL(cur_ts, GL_READ_FRAMEBUFFER, current_fb); YAGL_LOG_FUNC_EXIT(NULL); diff --git a/hw/yagl/yagl_backends/egl_offscreen/yagl_egl_offscreen_display.c b/hw/yagl/yagl_backends/egl_offscreen/yagl_egl_offscreen_display.c index 9f2f8de..54908ea 100644 --- a/hw/yagl/yagl_backends/egl_offscreen/yagl_egl_offscreen_display.c +++ b/hw/yagl/yagl_backends/egl_offscreen/yagl_egl_offscreen_display.c @@ -34,7 +34,6 @@ #include "yagl_egl_offscreen.h" #include "yagl_egl_native_config.h" #include "yagl_log.h" -#include "yagl_tls.h" #include "yagl_process.h" #include "yagl_thread.h" #include "yagl_object_map.h" @@ -47,16 +46,16 @@ struct yagl_egl_offscreen_image struct yagl_gles_driver *driver; }; -static void yagl_egl_offscreen_image_destroy(struct yagl_object *obj) +static void yagl_egl_offscreen_image_destroy(struct yagl_thread_state *cur_ts, + struct yagl_object *obj) { struct yagl_egl_offscreen_image *image = (struct yagl_egl_offscreen_image*)obj; - YAGL_LOG_NO_TS; YAGL_LOG_FUNC_ENTER(yagl_egl_offscreen_image_destroy, "%u", obj->global_name); - yagl_ensure_ctx(obj->ps, 0); + yagl_ensure_ctx(cur_ts, 0); image->driver->DeleteTextures(1, &obj->global_name); - yagl_unensure_ctx(obj->ps, 0); + yagl_unensure_ctx(cur_ts, 0); g_free(image); @@ -164,11 +163,10 @@ static struct yagl_object *yagl_egl_offscreen_display_create_image(struct yagl_t image = g_malloc(sizeof(*image)); - yagl_ensure_ctx(cur_ts->ps, 0); + yagl_ensure_ctx(cur_ts, 0); egl_offscreen->gles_driver->GenTextures(1, &image->base.global_name); - yagl_unensure_ctx(cur_ts->ps, 0); + yagl_unensure_ctx(cur_ts, 0); image->base.destroy = &yagl_egl_offscreen_image_destroy; - image->base.ps = cur_ts->ps; image->driver = egl_offscreen->gles_driver; return &image->base; diff --git a/hw/yagl/yagl_backends/egl_offscreen/yagl_egl_offscreen_surface.c b/hw/yagl/yagl_backends/egl_offscreen/yagl_egl_offscreen_surface.c index 1d7a16c..85c2083 100644 --- a/hw/yagl/yagl_backends/egl_offscreen/yagl_egl_offscreen_surface.c +++ b/hw/yagl/yagl_backends/egl_offscreen/yagl_egl_offscreen_surface.c @@ -34,15 +34,11 @@ #include "yagl_egl_offscreen_ts.h" #include "yagl_egl_offscreen.h" #include "yagl_egl_native_config.h" -#include "yagl_tls.h" #include "yagl_log.h" #include "yagl_process.h" #include "yagl_thread.h" #include "yagl_compiled_transfer.h" -// TODO remove and pass via argument -YAGL_DECLARE_TLS(struct yagl_egl_offscreen_ts*, egl_offscreen_ts); - static void yagl_egl_offscreen_surface_cleanup(struct yagl_egl_offscreen_surface *sfc) { struct yagl_egl_offscreen_display *dpy = @@ -126,7 +122,7 @@ static void yagl_egl_offscreen_surface_swap_buffers(struct yagl_thread_state *cu { struct yagl_egl_offscreen_surface *osfc = (struct yagl_egl_offscreen_surface*)sfc; - struct yagl_egl_offscreen_context *octx = egl_offscreen_ts->ctx; // TODO get from cur_ts + struct yagl_egl_offscreen_context *octx = cur_ts->egl_offscreen_ts->ctx; // TODO get from cur_ts YAGL_LOG_FUNC_SET(yagl_egl_offscreen_surface_swap_buffers); @@ -152,7 +148,7 @@ static void yagl_egl_offscreen_surface_copy_buffers(struct yagl_thread_state *cu { struct yagl_egl_offscreen_surface *osfc = (struct yagl_egl_offscreen_surface*)sfc; - struct yagl_egl_offscreen_context *octx = egl_offscreen_ts->ctx; // TODO get from cur_ts + struct yagl_egl_offscreen_context *octx = cur_ts->egl_offscreen_ts->ctx; // TODO get from cur_ts YAGL_LOG_FUNC_SET(yagl_egl_offscreen_surface_copy_buffers); @@ -178,11 +174,11 @@ static void yagl_egl_offscreen_surface_wait_gl(struct yagl_thread_state *cur_ts, { } -static void yagl_egl_offscreen_surface_destroy(struct yagl_eglb_surface *sfc) +static void yagl_egl_offscreen_surface_destroy(struct yagl_thread_state *cur_ts, + struct yagl_eglb_surface *sfc) { struct yagl_egl_offscreen_surface *egl_offscreen_sfc = (struct yagl_egl_offscreen_surface*)sfc; - YAGL_LOG_NO_TS; YAGL_LOG_FUNC_ENTER(yagl_egl_offscreen_surface_destroy, NULL); @@ -278,7 +274,6 @@ struct yagl_egl_offscreen_surface sfc->base.copy_buffers = &yagl_egl_offscreen_surface_copy_buffers; sfc->base.wait_gl = &yagl_egl_offscreen_surface_wait_gl; sfc->base.destroy = &yagl_egl_offscreen_surface_destroy; - sfc->base.ps = cur_ts->ps; YAGL_LOG_FUNC_EXIT(NULL); diff --git a/hw/yagl/yagl_backends/egl_offscreen/yagl_egl_offscreen_ts.c b/hw/yagl/yagl_backends/egl_offscreen/yagl_egl_offscreen_ts.c index 4547e8e..9c73f07 100644 --- a/hw/yagl/yagl_backends/egl_offscreen/yagl_egl_offscreen_ts.c +++ b/hw/yagl/yagl_backends/egl_offscreen/yagl_egl_offscreen_ts.c @@ -29,11 +29,13 @@ #include "yagl_egl_offscreen_ts.h" -struct yagl_egl_offscreen_ts *yagl_egl_offscreen_ts_create(void) +struct yagl_egl_offscreen_ts *yagl_egl_offscreen_ts_create(struct yagl_gles_driver *gles_driver) { struct yagl_egl_offscreen_ts *egl_offscreen_ts = g_malloc0(sizeof(struct yagl_egl_offscreen_ts)); + egl_offscreen_ts->gles_driver = gles_driver; + return egl_offscreen_ts; } diff --git a/hw/yagl/yagl_backends/egl_offscreen/yagl_egl_offscreen_ts.h b/hw/yagl/yagl_backends/egl_offscreen/yagl_egl_offscreen_ts.h index 7c3f341..28dc490 100644 --- a/hw/yagl/yagl_backends/egl_offscreen/yagl_egl_offscreen_ts.h +++ b/hw/yagl/yagl_backends/egl_offscreen/yagl_egl_offscreen_ts.h @@ -33,19 +33,22 @@ #include "yagl_types.h" #include +struct yagl_gles_driver; struct yagl_egl_offscreen_display; struct yagl_egl_offscreen_context; struct yagl_egl_offscreen_surface; struct yagl_egl_offscreen_ts { + struct yagl_gles_driver *gles_driver; + struct yagl_egl_offscreen_display *dpy; struct yagl_egl_offscreen_context *ctx; EGLSurface sfc_draw; EGLSurface sfc_read; }; -struct yagl_egl_offscreen_ts *yagl_egl_offscreen_ts_create(void); +struct yagl_egl_offscreen_ts *yagl_egl_offscreen_ts_create(struct yagl_gles_driver *gles_driver); void yagl_egl_offscreen_ts_destroy(struct yagl_egl_offscreen_ts *egl_offscreen_ts); diff --git a/hw/yagl/yagl_backends/egl_onscreen/yagl_egl_onscreen.c b/hw/yagl/yagl_backends/egl_onscreen/yagl_egl_onscreen.c index 31b8161..827603c 100644 --- a/hw/yagl/yagl_backends/egl_onscreen/yagl_egl_onscreen.c +++ b/hw/yagl/yagl_backends/egl_onscreen/yagl_egl_onscreen.c @@ -33,23 +33,21 @@ #include "yagl_egl_onscreen_display.h" #include "yagl_egl_onscreen_context.h" #include "yagl_egl_onscreen_surface.h" -#include "yagl_tls.h" #include "yagl_log.h" #include "yagl_process.h" #include "yagl_thread.h" #include "yagl_gles_driver.h" #include "hw/vigs/winsys_gl.h" -// TODO remove and pass via argument -YAGL_DEFINE_TLS(struct yagl_egl_onscreen_ts*, egl_onscreen_ts); - -static void yagl_egl_onscreen_setup_framebuffer_zero(struct yagl_egl_onscreen *egl_onscreen) +static void yagl_egl_onscreen_setup_framebuffer_zero(struct yagl_thread_state *cur_ts, + struct yagl_egl_onscreen *egl_onscreen) { GLuint cur_fb = 0; + struct yagl_egl_onscreen_ts *egl_onscreen_ts = cur_ts->egl_onscreen_ts; assert(egl_onscreen_ts->dpy); - yagl_egl_onscreen_context_setup(egl_onscreen_ts->ctx); + yagl_egl_onscreen_context_setup(cur_ts, egl_onscreen_ts->ctx); if (!egl_onscreen_ts->sfc_draw) { return; @@ -60,14 +58,31 @@ static void yagl_egl_onscreen_setup_framebuffer_zero(struct yagl_egl_onscreen *e egl_onscreen->gles_driver->GetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, (GLint*)&cur_fb); - egl_onscreen->gles_driver->BindFramebuffer(GL_DRAW_FRAMEBUFFER, - egl_onscreen_ts->ctx->fb); + // this might be called when BindFramebufferYAGL was not yet setup + if (egl_onscreen->gles_driver->BindFramebufferYAGL) + { + egl_onscreen->gles_driver->BindFramebufferYAGL(cur_ts, + GL_DRAW_FRAMEBUFFER, + egl_onscreen_ts->ctx->fb); + + yagl_egl_onscreen_surface_attach_to_framebuffer(egl_onscreen_ts->sfc_draw, + GL_DRAW_FRAMEBUFFER); - yagl_egl_onscreen_surface_attach_to_framebuffer(egl_onscreen_ts->sfc_draw, - GL_DRAW_FRAMEBUFFER); + egl_onscreen->gles_driver->BindFramebufferYAGL(cur_ts, + GL_DRAW_FRAMEBUFFER, + cur_fb); + } + else + { + egl_onscreen->gles_driver->BindFramebuffer(GL_DRAW_FRAMEBUFFER, + egl_onscreen_ts->ctx->fb); - egl_onscreen->gles_driver->BindFramebuffer(GL_DRAW_FRAMEBUFFER, - cur_fb); + yagl_egl_onscreen_surface_attach_to_framebuffer(egl_onscreen_ts->sfc_draw, + GL_DRAW_FRAMEBUFFER); + + egl_onscreen->gles_driver->BindFramebuffer(GL_DRAW_FRAMEBUFFER, + cur_fb); + } } static void yagl_egl_onscreen_thread_init(struct yagl_thread_state *cur_ts, @@ -77,9 +92,7 @@ static void yagl_egl_onscreen_thread_init(struct yagl_thread_state *cur_ts, YAGL_LOG_FUNC_ENTER(yagl_egl_onscreen_thread_init, NULL); - egl_onscreen_ts = yagl_egl_onscreen_ts_create(egl_onscreen->gles_driver); - - cur_ts->egl_onscreen_ts = egl_onscreen_ts; + cur_ts->egl_onscreen_ts = yagl_egl_onscreen_ts_create(egl_onscreen->gles_driver); YAGL_LOG_FUNC_EXIT(NULL); } @@ -88,8 +101,7 @@ static void yagl_egl_onscreen_batch_start(struct yagl_thread_state *cur_ts, struct yagl_egl_backend *backend) { struct yagl_egl_onscreen *egl_onscreen = (struct yagl_egl_onscreen*)backend; - - egl_onscreen_ts = cur_ts->egl_onscreen_ts; + struct yagl_egl_onscreen_ts *egl_onscreen_ts = cur_ts->egl_onscreen_ts; if (!egl_onscreen_ts->dpy) { return; @@ -114,6 +126,7 @@ static void yagl_egl_onscreen_batch_end(struct yagl_thread_state *cur_ts, struct yagl_egl_backend *backend) { struct yagl_egl_onscreen *egl_onscreen = (struct yagl_egl_onscreen*)backend; + struct yagl_egl_onscreen_ts *egl_onscreen_ts = cur_ts->egl_onscreen_ts; if (!egl_onscreen_ts->dpy) { return; @@ -143,6 +156,7 @@ static bool yagl_egl_onscreen_make_current(struct yagl_thread_state *cur_ts, struct yagl_eglb_surface *read) { struct yagl_egl_onscreen *egl_onscreen = (struct yagl_egl_onscreen*)backend; + struct yagl_egl_onscreen_ts *egl_onscreen_ts = cur_ts->egl_onscreen_ts; struct yagl_egl_onscreen_display *egl_onscreen_dpy = (struct yagl_egl_onscreen_display*)dpy; struct yagl_egl_onscreen_context *egl_onscreen_ctx = (struct yagl_egl_onscreen_context*)ctx; struct yagl_egl_onscreen_surface *egl_onscreen_draw = (struct yagl_egl_onscreen_surface*)draw; @@ -181,7 +195,7 @@ static bool yagl_egl_onscreen_make_current(struct yagl_thread_state *cur_ts, egl_onscreen_ts->sfc_draw = egl_onscreen_draw; egl_onscreen_ts->sfc_read = egl_onscreen_read; - yagl_egl_onscreen_setup_framebuffer_zero(egl_onscreen); + yagl_egl_onscreen_setup_framebuffer_zero(cur_ts, egl_onscreen); egl_onscreen->gles_driver->GetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, (GLint*)&cur_fb); @@ -191,8 +205,14 @@ static bool yagl_egl_onscreen_make_current(struct yagl_thread_state *cur_ts, * No framebuffer, then bind our framebuffer zero. */ - egl_onscreen->gles_driver->BindFramebuffer(GL_FRAMEBUFFER, - egl_onscreen_ctx->fb); + if (egl_onscreen->gles_driver->BindFramebufferYAGL) { + egl_onscreen->gles_driver->BindFramebufferYAGL(cur_ts, + GL_FRAMEBUFFER, + egl_onscreen_ctx->fb); + } else { + egl_onscreen->gles_driver->BindFramebuffer(GL_FRAMEBUFFER, + egl_onscreen_ctx->fb); + } /* * Setup default viewport and scissor. @@ -229,6 +249,7 @@ static bool yagl_egl_onscreen_release_current(struct yagl_thread_state *cur_ts, bool force) { struct yagl_egl_onscreen *egl_onscreen = (struct yagl_egl_onscreen*)backend; + struct yagl_egl_onscreen_ts *egl_onscreen_ts = cur_ts->egl_onscreen_ts; bool res; YAGL_LOG_FUNC_ENTER(yagl_egl_onscreen_release_current, NULL); @@ -264,13 +285,14 @@ static void yagl_egl_onscreen_thread_fini(struct yagl_thread_state *cur_ts, { YAGL_LOG_FUNC_ENTER(yagl_egl_onscreen_thread_fini, NULL); - yagl_egl_onscreen_ts_destroy(egl_onscreen_ts); - egl_onscreen_ts = cur_ts->egl_onscreen_ts = NULL; + yagl_egl_onscreen_ts_destroy(cur_ts->egl_onscreen_ts); + cur_ts->egl_onscreen_ts = NULL; YAGL_LOG_FUNC_EXIT(NULL); } -static void yagl_egl_onscreen_ensure_current(struct yagl_egl_backend *backend) +static void yagl_egl_onscreen_ensure_current(struct yagl_thread_state *cur_ts, + struct yagl_egl_backend *backend) { struct yagl_egl_onscreen *egl_onscreen = (struct yagl_egl_onscreen*)backend; @@ -281,9 +303,11 @@ static void yagl_egl_onscreen_ensure_current(struct yagl_egl_backend *backend) egl_onscreen->ensure_ctx); } -static void yagl_egl_onscreen_unensure_current(struct yagl_egl_backend *backend) +static void yagl_egl_onscreen_unensure_current(struct yagl_thread_state *cur_ts, + struct yagl_egl_backend *backend) { struct yagl_egl_onscreen *egl_onscreen = (struct yagl_egl_onscreen*)backend; + struct yagl_egl_onscreen_ts *egl_onscreen_ts = (cur_ts ? cur_ts->egl_onscreen_ts : NULL); if (egl_onscreen_ts && egl_onscreen_ts->dpy) { if (egl_onscreen_ts->sfc_draw && egl_onscreen_ts->sfc_read) { diff --git a/hw/yagl/yagl_backends/egl_onscreen/yagl_egl_onscreen_context.c b/hw/yagl/yagl_backends/egl_onscreen/yagl_egl_onscreen_context.c index 899f3ec..8dd9523 100644 --- a/hw/yagl/yagl_backends/egl_onscreen/yagl_egl_onscreen_context.c +++ b/hw/yagl/yagl_backends/egl_onscreen/yagl_egl_onscreen_context.c @@ -34,11 +34,10 @@ #include "yagl_egl_surface_attribs.h" #include "yagl_gles_driver.h" #include "yagl_log.h" -#include "yagl_tls.h" #include "yagl_process.h" #include "yagl_thread.h" -static void yagl_egl_onscreen_context_destroy(struct yagl_eglb_context *ctx) +static void yagl_egl_onscreen_context_destroy(struct yagl_thread_state *cur_ts, struct yagl_eglb_context *ctx) { struct yagl_egl_onscreen_context *egl_onscreen_ctx = (struct yagl_egl_onscreen_context*)ctx; @@ -46,14 +45,13 @@ static void yagl_egl_onscreen_context_destroy(struct yagl_eglb_context *ctx) (struct yagl_egl_onscreen_display*)ctx->dpy; struct yagl_egl_onscreen *egl_onscreen = (struct yagl_egl_onscreen*)ctx->dpy->backend; - YAGL_LOG_NO_TS; YAGL_LOG_FUNC_ENTER(yagl_egl_onscreen_context_destroy, NULL); if (egl_onscreen_ctx->fb) { - yagl_ensure_ctx(ctx->ps, egl_onscreen_ctx->fb_ctx_id); + yagl_ensure_ctx(cur_ts, egl_onscreen_ctx->fb_ctx_id); egl_onscreen->gles_driver->DeleteFramebuffers(1, &egl_onscreen_ctx->fb); - yagl_unensure_ctx(ctx->ps, egl_onscreen_ctx->fb_ctx_id); + yagl_unensure_ctx(cur_ts, egl_onscreen_ctx->fb_ctx_id); } if (egl_onscreen_ctx->null_sfc != EGL_NO_SURFACE) { @@ -123,7 +121,8 @@ struct yagl_egl_onscreen_context return ctx; } -void yagl_egl_onscreen_context_setup(struct yagl_egl_onscreen_context *ctx) +void yagl_egl_onscreen_context_setup(struct yagl_thread_state *cur_ts, + struct yagl_egl_onscreen_context *ctx) { struct yagl_egl_onscreen *egl_onscreen = (struct yagl_egl_onscreen*)ctx->base.dpy->backend; @@ -133,7 +132,7 @@ void yagl_egl_onscreen_context_setup(struct yagl_egl_onscreen_context *ctx) } egl_onscreen->gles_driver->GenFramebuffers(1, &ctx->fb); - ctx->fb_ctx_id = yagl_get_ctx_id(ctx->base.ps); + ctx->fb_ctx_id = yagl_get_ctx_id(cur_ts); } bool yagl_egl_onscreen_context_setup_surfaceless(struct yagl_egl_onscreen_context *ctx) diff --git a/hw/yagl/yagl_backends/egl_onscreen/yagl_egl_onscreen_context.h b/hw/yagl/yagl_backends/egl_onscreen/yagl_egl_onscreen_context.h index 10018c3..a482f38 100644 --- a/hw/yagl/yagl_backends/egl_onscreen/yagl_egl_onscreen_context.h +++ b/hw/yagl/yagl_backends/egl_onscreen/yagl_egl_onscreen_context.h @@ -78,7 +78,8 @@ struct yagl_egl_onscreen_context struct yagl_egl_onscreen_context *share_context, int version); -void yagl_egl_onscreen_context_setup(struct yagl_egl_onscreen_context *ctx); +void yagl_egl_onscreen_context_setup(struct yagl_thread_state *cur_ts, + struct yagl_egl_onscreen_context *ctx); bool yagl_egl_onscreen_context_setup_surfaceless(struct yagl_egl_onscreen_context *ctx); diff --git a/hw/yagl/yagl_backends/egl_onscreen/yagl_egl_onscreen_display.c b/hw/yagl/yagl_backends/egl_onscreen/yagl_egl_onscreen_display.c index f8861cc..8d09635 100644 --- a/hw/yagl/yagl_backends/egl_onscreen/yagl_egl_onscreen_display.c +++ b/hw/yagl/yagl_backends/egl_onscreen/yagl_egl_onscreen_display.c @@ -34,7 +34,6 @@ #include "yagl_egl_onscreen.h" #include "yagl_egl_native_config.h" #include "yagl_log.h" -#include "yagl_tls.h" #include "yagl_process.h" #include "yagl_thread.h" #include "yagl_object_map.h" @@ -47,10 +46,10 @@ struct yagl_egl_onscreen_image struct winsys_gl_surface *ws_sfc; }; -static void yagl_egl_onscreen_image_destroy(struct yagl_object *obj) +static void yagl_egl_onscreen_image_destroy(struct yagl_thread_state *cur_ts, + struct yagl_object *obj) { struct yagl_egl_onscreen_image *image = (struct yagl_egl_onscreen_image*)obj; - YAGL_LOG_NO_TS; YAGL_LOG_FUNC_ENTER(yagl_egl_onscreen_image_destroy, "%u", obj->global_name); diff --git a/hw/yagl/yagl_backends/egl_onscreen/yagl_egl_onscreen_surface.c b/hw/yagl/yagl_backends/egl_onscreen/yagl_egl_onscreen_surface.c index 105db72..63bfb2e 100644 --- a/hw/yagl/yagl_backends/egl_onscreen/yagl_egl_onscreen_surface.c +++ b/hw/yagl/yagl_backends/egl_onscreen/yagl_egl_onscreen_surface.c @@ -39,9 +39,6 @@ #include "yagl_gles_driver.h" #include "hw/vigs/winsys_gl.h" -// TODO remove and pass via argument -YAGL_DECLARE_TLS(struct yagl_egl_onscreen_ts*, egl_onscreen_ts); - static void yagl_egl_onscreen_surface_invalidate(struct yagl_thread_state *cur_ts, struct yagl_eglb_surface *sfc, yagl_winsys_id id) @@ -71,16 +68,16 @@ static void yagl_egl_onscreen_surface_invalidate(struct yagl_thread_state *cur_t if (((osfc->ws_sfc->base.width != ws_sfc->base.width) || (osfc->ws_sfc->base.height != ws_sfc->base.height)) && osfc->rb) { - yagl_ensure_ctx(cur_ts->ps, 0); + yagl_ensure_ctx(cur_ts, 0); egl_onscreen->gles_driver->DeleteRenderbuffers(1, &osfc->rb); - yagl_unensure_ctx(cur_ts->ps, 0); + yagl_unensure_ctx(cur_ts, 0); osfc->rb = 0; } osfc->ws_sfc->base.release(&osfc->ws_sfc->base); osfc->ws_sfc = ws_sfc; - if (egl_onscreen_ts->sfc_draw == osfc) { + if (cur_ts->egl_onscreen_ts->sfc_draw == osfc) { GLuint cur_fb = 0; yagl_egl_onscreen_surface_setup(osfc); @@ -88,14 +85,27 @@ static void yagl_egl_onscreen_surface_invalidate(struct yagl_thread_state *cur_t egl_onscreen->gles_driver->GetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, (GLint*)&cur_fb); - egl_onscreen->gles_driver->BindFramebuffer(GL_DRAW_FRAMEBUFFER, - egl_onscreen_ts->ctx->fb); + if (egl_onscreen->gles_driver->BindFramebufferYAGL) { + egl_onscreen->gles_driver->BindFramebufferYAGL(cur_ts, + GL_DRAW_FRAMEBUFFER, + cur_ts->egl_onscreen_ts->ctx->fb); + + yagl_egl_onscreen_surface_attach_to_framebuffer(osfc, + GL_DRAW_FRAMEBUFFER); - yagl_egl_onscreen_surface_attach_to_framebuffer(osfc, - GL_DRAW_FRAMEBUFFER); + egl_onscreen->gles_driver->BindFramebufferYAGL(cur_ts, + GL_DRAW_FRAMEBUFFER, + cur_fb); + } else { + egl_onscreen->gles_driver->BindFramebuffer(GL_DRAW_FRAMEBUFFER, + cur_ts->egl_onscreen_ts->ctx->fb); - egl_onscreen->gles_driver->BindFramebuffer(GL_DRAW_FRAMEBUFFER, - cur_fb); + yagl_egl_onscreen_surface_attach_to_framebuffer(osfc, + GL_DRAW_FRAMEBUFFER); + + egl_onscreen->gles_driver->BindFramebuffer(GL_DRAW_FRAMEBUFFER, + cur_fb); + } } YAGL_LOG_FUNC_EXIT(NULL); @@ -162,13 +172,13 @@ static void yagl_egl_onscreen_surface_wait_gl(struct yagl_thread_state *cur_ts, osfc->ws_sfc->base.set_dirty(&osfc->ws_sfc->base); } -static void yagl_egl_onscreen_surface_destroy(struct yagl_eglb_surface *sfc) +static void yagl_egl_onscreen_surface_destroy(struct yagl_thread_state *cur_ts, + struct yagl_eglb_surface *sfc) { struct yagl_egl_onscreen_surface *osfc = (struct yagl_egl_onscreen_surface*)sfc; struct yagl_egl_onscreen *egl_onscreen = (struct yagl_egl_onscreen*)sfc->dpy->backend; - YAGL_LOG_NO_TS; YAGL_LOG_FUNC_ENTER(yagl_egl_onscreen_surface_destroy, NULL); @@ -184,9 +194,9 @@ static void yagl_egl_onscreen_surface_destroy(struct yagl_eglb_surface *sfc) } if (osfc->rb) { - yagl_ensure_ctx(sfc->ps, 0); + yagl_ensure_ctx(cur_ts, 0); egl_onscreen->gles_driver->DeleteRenderbuffers(1, &osfc->rb); - yagl_unensure_ctx(sfc->ps, 0); + yagl_unensure_ctx(cur_ts, 0); } yagl_eglb_surface_cleanup(sfc); @@ -248,7 +258,6 @@ struct yagl_egl_onscreen_surface sfc->base.copy_buffers = &yagl_egl_onscreen_surface_copy_buffers; sfc->base.wait_gl = &yagl_egl_onscreen_surface_wait_gl; sfc->base.destroy = &yagl_egl_onscreen_surface_destroy; - sfc->base.ps = cur_ts->ps; YAGL_LOG_FUNC_EXIT(NULL); @@ -316,7 +325,6 @@ struct yagl_egl_onscreen_surface sfc->base.copy_buffers = &yagl_egl_onscreen_surface_copy_buffers; sfc->base.wait_gl = &yagl_egl_onscreen_surface_wait_gl; sfc->base.destroy = &yagl_egl_onscreen_surface_destroy; - sfc->base.ps = cur_ts->ps; YAGL_LOG_FUNC_EXIT(NULL); @@ -384,7 +392,6 @@ struct yagl_egl_onscreen_surface sfc->base.copy_buffers = &yagl_egl_onscreen_surface_copy_buffers; sfc->base.wait_gl = &yagl_egl_onscreen_surface_wait_gl; sfc->base.destroy = &yagl_egl_onscreen_surface_destroy; - sfc->base.ps = cur_ts->ps; YAGL_LOG_FUNC_EXIT(NULL); diff --git a/hw/yagl/yagl_device.c b/hw/yagl/yagl_device.c index f1ac3a4..02fd612 100644 --- a/hw/yagl/yagl_device.c +++ b/hw/yagl/yagl_device.c @@ -35,6 +35,7 @@ #include "yagl_thread.h" #include "yagl_egl_driver.h" #include "yagl_drivers/gles_ogl/yagl_gles_ogl.h" +#include "yagl_drivers/gles_offscreen/yagl_gles_offscreen.h" #include "yagl_drivers/gles_onscreen/yagl_gles_onscreen.h" #include "yagl_backends/egl_offscreen/yagl_egl_offscreen.h" #include "yagl_backends/egl_onscreen/yagl_egl_onscreen.h" @@ -325,6 +326,7 @@ static int yagl_device_init(PCIDevice *dev) gles_driver = yagl_gles_onscreen_create(gles_driver); } else { egl_backend = yagl_egl_offscreen_create(egl_driver, gles_driver); + gles_driver = yagl_gles_offscreen_create(gles_driver); } if (!egl_backend) { diff --git a/hw/yagl/yagl_drivers/Makefile.objs b/hw/yagl/yagl_drivers/Makefile.objs index 773972b..bdcd9ab 100644 --- a/hw/yagl/yagl_drivers/Makefile.objs +++ b/hw/yagl/yagl_drivers/Makefile.objs @@ -3,4 +3,5 @@ obj-$(CONFIG_WIN32) += egl_wgl/ obj-$(CONFIG_DARWIN) += egl_cgl/ obj-y += gles_ogl/ obj-y += gles_onscreen/ +obj-y += gles_offscreen/ diff --git a/hw/yagl/yagl_drivers/egl_cgl/yagl_egl_cgl.c b/hw/yagl/yagl_drivers/egl_cgl/yagl_egl_cgl.c index 90cd0bc..a42b5f7 100644 --- a/hw/yagl/yagl_drivers/egl_cgl/yagl_egl_cgl.c +++ b/hw/yagl/yagl_drivers/egl_cgl/yagl_egl_cgl.c @@ -35,7 +35,6 @@ #include "yagl_egl_native_config.h" #include "yagl_egl_surface_attribs.h" #include "yagl_process.h" -#include "yagl_tls.h" #include "yagl_thread.h" #define LIBGL_IMAGE_NAME \ @@ -145,6 +144,7 @@ static bool yagl_egl_cgl_get_gl_version(struct yagl_egl_cgl *egl_cgl, CGLPixelFormatObj pixel_format; int n; unsigned int i; + YAGL_LOG_NO_TS; YAGL_LOG_FUNC_ENTER(yagl_egl_cgl_get_gl_version, NULL); @@ -213,6 +213,8 @@ out: static EGLNativeDisplayType yagl_egl_cgl_display_open(struct yagl_egl_driver *driver) { + YAGL_LOG_NO_TS; + YAGL_LOG_FUNC_ENTER(yagl_egl_cgl_display_open, NULL); YAGL_LOG_FUNC_EXIT("%p", (void*)1); @@ -223,6 +225,8 @@ static EGLNativeDisplayType yagl_egl_cgl_display_open(struct yagl_egl_driver *dr static void yagl_egl_cgl_display_close(struct yagl_egl_driver *driver, EGLNativeDisplayType dpy) { + YAGL_LOG_NO_TS; + YAGL_LOG_FUNC_ENTER(yagl_egl_cgl_display_close, "%p", dpy); YAGL_LOG_FUNC_EXIT(NULL); @@ -238,6 +242,7 @@ static bool yagl_egl_cgl_config_fill(CGLPixelFormatObj pixel_format, int stencil_size = 0; int samples_per_pixel = 0; CGLError error; + YAGL_LOG_NO_TS; YAGL_LOG_FUNC_ENTER(yagl_egl_cgl_config_fill, NULL); @@ -290,6 +295,7 @@ static struct yagl_egl_native_config int n = 0, n_ms = 0; int screen_idx, cfg_idx; CGLError error; + YAGL_LOG_NO_TS; YAGL_LOG_FUNC_ENTER(yagl_egl_cgl_config_enum, "%p", dpy); @@ -363,6 +369,8 @@ static void yagl_egl_cgl_config_cleanup(struct yagl_egl_driver *driver, EGLNativeDisplayType dpy, const struct yagl_egl_native_config *cfg) { + YAGL_LOG_NO_TS; + YAGL_LOG_FUNC_ENTER(yagl_egl_cgl_config_cleanup, "dpy = %p, cfg = %d", dpy, @@ -380,6 +388,7 @@ static EGLSurface yagl_egl_cgl_pbuffer_surface_create(struct yagl_egl_driver *dr { CGLPBufferObj pbuffer = NULL; CGLError error; + YAGL_LOG_NO_TS; YAGL_LOG_FUNC_ENTER(yagl_egl_cgl_pbuffer_surface_create, "dpy = %p, width = %d, height = %d", @@ -415,6 +424,7 @@ static void yagl_egl_cgl_pbuffer_surface_destroy(struct yagl_egl_driver *driver, EGLSurface sfc) { CGLError error; + YAGL_LOG_NO_TS; YAGL_LOG_FUNC_ENTER(yagl_egl_cgl_pbuffer_surface_destroy, "dpy = %p, sfc = %p", @@ -441,6 +451,7 @@ static EGLContext yagl_egl_cgl_context_create(struct yagl_egl_driver *driver, struct yagl_egl_cgl_context *ctx = NULL; CGLContextObj share_ctx; CGLError error; + YAGL_LOG_NO_TS; YAGL_LOG_FUNC_ENTER(yagl_egl_cgl_context_create, "dpy = %p, share_context = %p, version = %d", @@ -481,6 +492,7 @@ static void yagl_egl_cgl_context_destroy(struct yagl_egl_driver *driver, EGLContext ctx) { CGLError error; + YAGL_LOG_NO_TS; YAGL_LOG_FUNC_ENTER(yagl_egl_cgl_context_destroy, "dpy = %p, ctx = %p", @@ -508,6 +520,7 @@ static bool yagl_egl_cgl_make_current(struct yagl_egl_driver *driver, CGLPBufferObj draw_pbuffer = (CGLPBufferObj)draw; CGLPBufferObj read_pbuffer = (CGLPBufferObj)read; CGLError error; + YAGL_LOG_NO_TS; YAGL_LOG_FUNC_ENTER(yagl_egl_cgl_make_current, "dpy = %p, draw = %p, read = %p, ctx = %p", @@ -556,6 +569,7 @@ fail: static void yagl_egl_cgl_destroy(struct yagl_egl_driver *driver) { struct yagl_egl_cgl *egl_cgl = (struct yagl_egl_cgl*)driver; + YAGL_LOG_NO_TS; YAGL_LOG_FUNC_ENTER(yagl_egl_cgl_destroy, NULL); @@ -583,6 +597,7 @@ struct yagl_egl_driver *yagl_egl_driver_create(void *display, CGLError error; struct yagl_egl_cgl *egl_cgl; int n; + YAGL_LOG_NO_TS; YAGL_LOG_FUNC_ENTER(yagl_egl_driver_create, NULL); diff --git a/hw/yagl/yagl_drivers/egl_glx/yagl_egl_glx.c b/hw/yagl/yagl_drivers/egl_glx/yagl_egl_glx.c index d71a7a0..f287faa 100644 --- a/hw/yagl/yagl_drivers/egl_glx/yagl_egl_glx.c +++ b/hw/yagl/yagl_drivers/egl_glx/yagl_egl_glx.c @@ -30,7 +30,6 @@ #include "yagl_egl_driver.h" #include "yagl_dyn_lib.h" #include "yagl_log.h" -#include "yagl_tls.h" #include "yagl_thread.h" #include "yagl_process.h" #include "yagl_egl_native_config.h" diff --git a/hw/yagl/yagl_drivers/egl_wgl/yagl_egl_wgl.c b/hw/yagl/yagl_drivers/egl_wgl/yagl_egl_wgl.c index 09599fd..846063a 100644 --- a/hw/yagl/yagl_drivers/egl_wgl/yagl_egl_wgl.c +++ b/hw/yagl/yagl_drivers/egl_wgl/yagl_egl_wgl.c @@ -38,7 +38,6 @@ #include "yagl_egl_native_config.h" #include "yagl_egl_surface_attribs.h" #include "yagl_process.h" -#include "yagl_tls.h" #include "yagl_thread.h" #define YAGL_EGL_WGL_WIN_CLASS "YaGLwinClass" @@ -190,6 +189,7 @@ static bool yagl_egl_wgl_get_gl_version(YaglEglWglDriver *egl_wgl, GLint i, num_extensions = 0; unsigned int j; bool skip_compatibility_check = 1; + YAGL_LOG_NO_TS; YAGL_EGL_WGL_ENTER(yagl_egl_wgl_get_gl_version, NULL); @@ -419,6 +419,7 @@ static EGLNativeDisplayType yagl_egl_wgl_display_open(struct yagl_egl_driver *driver) { YaglEglWglDpy *dpy; + YAGL_LOG_NO_TS; YAGL_EGL_WGL_ENTER(yagl_egl_wgl_display_open, NULL); @@ -446,6 +447,7 @@ static void yagl_egl_wgl_display_close(struct yagl_egl_driver *driver, EGLNativeDisplayType egl_dpy) { YaglEglWglDpy *dpy = (YaglEglWglDpy *)egl_dpy; + YAGL_LOG_NO_TS; YAGL_EGL_WGL_ENTER(yagl_egl_wgl_display_close, "%p", dpy); @@ -608,6 +610,7 @@ static struct yagl_egl_native_config WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB, 0, }; + YAGL_LOG_NO_TS; YAGL_EGL_WGL_ENTER(yagl_egl_wgl_config_enum, "display %p", dpy); @@ -696,6 +699,8 @@ static void yagl_egl_wgl_config_cleanup(struct yagl_egl_driver *driver, EGLNativeDisplayType dpy, const struct yagl_egl_native_config *cfg) { + YAGL_LOG_NO_TS; + YAGL_EGL_WGL_ENTER(yagl_egl_wgl_config_cleanup, "dpy = %p, cfg = %d", dpy, cfg->config_id); @@ -778,6 +783,7 @@ static EGLContext yagl_egl_wgl_context_create(struct yagl_egl_driver *driver, }; HGLRC egl_wgl_ctx; HDC dc; + YAGL_LOG_NO_TS; YAGL_EGL_WGL_ENTER(yagl_egl_wgl_context_create, "dpy = %p, share_context = %p, cfgid=%d", @@ -834,6 +840,7 @@ static bool yagl_egl_wgl_make_current(struct yagl_egl_driver *driver, YaglEglWglSurface *egl_read_sfc = egl_read_surf; HGLRC glc = NULL; BOOL res; + YAGL_LOG_NO_TS; YAGL_EGL_WGL_ENTER(yagl_egl_wgl_make_current, "dpy = %p, draw = %p, read = %p, ctx = %p", @@ -875,6 +882,7 @@ static void yagl_egl_wgl_context_destroy(struct yagl_egl_driver *driver, EGLContext egl_glc) { YaglEglWglDriver *egl_wgl = (YaglEglWglDriver *)(driver); + YAGL_LOG_NO_TS; YAGL_EGL_WGL_ENTER(yagl_egl_wgl_context_destroy, "dpy = %p, ctx = %p", @@ -904,6 +912,7 @@ static EGLSurface yagl_egl_wgl_pbuffer_surface_create(struct yagl_egl_driver *dr WGL_TEXTURE_FORMAT_ARB, WGL_NO_TEXTURE_ARB, 0 }; + YAGL_LOG_NO_TS; YAGL_EGL_WGL_ENTER(yagl_egl_wgl_pbuffer_surface_create, "dpy = %p, width = %d, height = %d, cfgid=%d", @@ -973,6 +982,7 @@ static void yagl_egl_wgl_pbuffer_surface_destroy(struct yagl_egl_driver *driver, { YaglEglWglDriver *egl_wgl = (YaglEglWglDriver *)(driver); YaglEglWglSurface *egl_sfc = surf; + YAGL_LOG_NO_TS; YAGL_EGL_WGL_ENTER(yagl_egl_wgl_pbuffer_surface_destroy, "dpy = %p, sfc = %p", @@ -991,6 +1001,7 @@ static void yagl_egl_wgl_pbuffer_surface_destroy(struct yagl_egl_driver *driver, static void yagl_egl_wgl_destroy(struct yagl_egl_driver *driver) { YaglEglWglDriver *egl_wgl = (YaglEglWglDriver *)driver; + YAGL_LOG_NO_TS; YAGL_LOG_FUNC_ENTER(yagl_egl_wgl_destroy, NULL); @@ -1054,6 +1065,7 @@ static bool yagl_egl_wgl_init_ext(YaglEglWglDriver *egl_wgl) HGLRC glc = NULL; const char *ext_str = NULL; bool ext_initialized = false; + YAGL_LOG_NO_TS; YAGL_LOG_FUNC_ENTER(yagl_egl_wgl_init_ext, NULL); @@ -1141,6 +1153,7 @@ struct yagl_egl_driver *yagl_egl_driver_create(void *display, YaglEglWglDriver *egl_wgl; struct yagl_egl_driver *egl_driver; WNDCLASSEXA yagl_win_class; + YAGL_LOG_NO_TS; YAGL_LOG_FUNC_ENTER(yagl_egl_wgl_create, NULL); diff --git a/hw/yagl/yagl_drivers/gles_offscreen/Makefile.objs b/hw/yagl/yagl_drivers/gles_offscreen/Makefile.objs new file mode 100644 index 0000000..3d3f290 --- /dev/null +++ b/hw/yagl/yagl_drivers/gles_offscreen/Makefile.objs @@ -0,0 +1,3 @@ +# GLES offscreen driver +obj-y += yagl_gles_offscreen.o + diff --git a/hw/yagl/yagl_drivers/gles_offscreen/yagl_gles_offscreen.c b/hw/yagl/yagl_drivers/gles_offscreen/yagl_gles_offscreen.c new file mode 100644 index 0000000..7f9f299 --- /dev/null +++ b/hw/yagl/yagl_drivers/gles_offscreen/yagl_gles_offscreen.c @@ -0,0 +1,94 @@ +/* + * yagl + * + * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Stanislav Vorobiov + * Jinhyung Jo + * YeongKyoon Lee + * Lukasz Kostyra + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#include +#include "yagl_gles_offscreen.h" +#include "yagl_gles_driver.h" +#include "yagl_log.h" +#include "yagl_process.h" +#include "yagl_thread.h" +#include "yagl_backends/egl_offscreen/yagl_egl_offscreen_ts.h" + +struct yagl_gles_offscreen +{ + struct yagl_gles_driver base; + + struct yagl_gles_driver *orig_driver; +}; + +static void YAGL_GLES_APIENTRY yagl_gles_offscreen_BindFramebufferYAGL(struct yagl_thread_state *cur_ts, + GLenum target, + GLuint framebuffer) +{ + cur_ts->egl_offscreen_ts->gles_driver->BindFramebuffer(target, framebuffer); +} + +static void yagl_gles_offscreen_destroy(struct yagl_gles_driver *driver) +{ + struct yagl_gles_offscreen *gles_offscreen = (struct yagl_gles_offscreen*)driver; + YAGL_LOG_NO_TS; + + YAGL_LOG_FUNC_ENTER(yagl_gles_offscreen_destroy, NULL); + + gles_offscreen->orig_driver->destroy(gles_offscreen->orig_driver); + gles_offscreen->orig_driver = NULL; + + yagl_gles_driver_cleanup(driver); + g_free(gles_offscreen); + + YAGL_LOG_FUNC_EXIT(NULL); +} + +struct yagl_gles_driver + *yagl_gles_offscreen_create(struct yagl_gles_driver *orig_driver) +{ + struct yagl_gles_offscreen *driver = NULL; + YAGL_LOG_NO_TS; + + YAGL_LOG_FUNC_ENTER(yagl_gles_offscreen_create, NULL); + + driver = g_malloc0(sizeof(*driver)); + + /* + * Just copy over everything, then init our fields. + */ + memcpy(&driver->base, orig_driver, sizeof(*orig_driver)); + driver->orig_driver = orig_driver; + + yagl_gles_driver_init(&driver->base, orig_driver->gl_version); + + driver->base.BindFramebufferYAGL = &yagl_gles_offscreen_BindFramebufferYAGL; + + driver->base.destroy = &yagl_gles_offscreen_destroy; + + YAGL_LOG_FUNC_EXIT(NULL); + + return &driver->base; +} diff --git a/hw/yagl/yagl_tls.h b/hw/yagl/yagl_drivers/gles_offscreen/yagl_gles_offscreen.h similarity index 74% rename from hw/yagl/yagl_tls.h rename to hw/yagl/yagl_drivers/gles_offscreen/yagl_gles_offscreen.h index 19c6388..cea05ba 100644 --- a/hw/yagl/yagl_tls.h +++ b/hw/yagl/yagl_drivers/gles_offscreen/yagl_gles_offscreen.h @@ -1,12 +1,13 @@ /* * yagl * - * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved. + * Copyright (c) 2000 - 2020 Samsung Electronics Co., Ltd. All rights reserved. * * Contact: * Stanislav Vorobiov * Jinhyung Jo * YeongKyoon Lee + * Lukasz Kostyra * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -27,12 +28,17 @@ * */ -#ifndef _QEMU_YAGL_TLS_H -#define _QEMU_YAGL_TLS_H +#ifndef _QEMU_YAGL_GLES_OFFSCREEN_H +#define _QEMU_YAGL_GLES_OFFSCREEN_H #include "yagl_types.h" -#define YAGL_DEFINE_TLS(type, x) type x -#define YAGL_DECLARE_TLS(type, x) extern YAGL_DEFINE_TLS(type, x) +struct yagl_gles_driver; + +/* + * Takes ownership of 'orig_driver'. + */ +struct yagl_gles_driver + *yagl_gles_offscreen_create(struct yagl_gles_driver *orig_driver); #endif diff --git a/hw/yagl/yagl_drivers/gles_ogl/yagl_gles_ogl.c b/hw/yagl/yagl_drivers/gles_ogl/yagl_gles_ogl.c index b3855bb..3b089b7 100644 --- a/hw/yagl/yagl_drivers/gles_ogl/yagl_gles_ogl.c +++ b/hw/yagl/yagl_drivers/gles_ogl/yagl_gles_ogl.c @@ -35,6 +35,7 @@ #include "yagl_dyn_lib.h" #include "yagl_process.h" #include "yagl_thread.h" +#include "yagl_server.h" static void yagl_gles_ogl_destroy(struct yagl_gles_driver *driver) { diff --git a/hw/yagl/yagl_drivers/gles_onscreen/yagl_gles_onscreen.c b/hw/yagl/yagl_drivers/gles_onscreen/yagl_gles_onscreen.c index 2da307e..790f3e6 100644 --- a/hw/yagl/yagl_drivers/gles_onscreen/yagl_gles_onscreen.c +++ b/hw/yagl/yagl_drivers/gles_onscreen/yagl_gles_onscreen.c @@ -31,7 +31,6 @@ #include "yagl_gles_onscreen.h" #include "yagl_gles_driver.h" #include "yagl_log.h" -#include "yagl_tls.h" #include "yagl_process.h" #include "yagl_thread.h" #include "yagl_backends/egl_onscreen/yagl_egl_onscreen_ts.h" @@ -44,23 +43,21 @@ struct yagl_gles_onscreen struct yagl_gles_driver *orig_driver; }; -// TODO remove and pass via argument -YAGL_DECLARE_TLS(struct yagl_egl_onscreen_ts*, egl_onscreen_ts); - -static void YAGL_GLES_APIENTRY yagl_gles_onscreen_BindFramebuffer(GLenum target, +static void YAGL_GLES_APIENTRY yagl_gles_onscreen_BindFramebufferYAGL(struct yagl_thread_state *cur_ts, + GLenum target, GLuint framebuffer) { - if (!egl_onscreen_ts || !egl_onscreen_ts->dpy) { + if (!cur_ts || !cur_ts->egl_onscreen_ts || !cur_ts->egl_onscreen_ts->dpy) { return; } - assert(framebuffer != egl_onscreen_ts->ctx->fb); + assert(framebuffer != cur_ts->egl_onscreen_ts->ctx->fb); if (framebuffer == 0) { - framebuffer = egl_onscreen_ts->ctx->fb; + framebuffer = cur_ts->egl_onscreen_ts->ctx->fb; } - egl_onscreen_ts->gles_driver->BindFramebuffer(target, framebuffer); + cur_ts->egl_onscreen_ts->gles_driver->BindFramebuffer(target, framebuffer); } static void yagl_gles_onscreen_destroy(struct yagl_gles_driver *driver) @@ -97,7 +94,7 @@ struct yagl_gles_driver yagl_gles_driver_init(&driver->base, orig_driver->gl_version); - driver->base.BindFramebuffer = &yagl_gles_onscreen_BindFramebuffer; + driver->base.BindFramebufferYAGL = &yagl_gles_onscreen_BindFramebufferYAGL; driver->base.destroy = &yagl_gles_onscreen_destroy; diff --git a/hw/yagl/yagl_egl_backend.h b/hw/yagl/yagl_egl_backend.h index 686f41a..1010f07 100644 --- a/hw/yagl/yagl_egl_backend.h +++ b/hw/yagl/yagl_egl_backend.h @@ -74,9 +74,11 @@ struct yagl_egl_backend * @{ */ - void (*ensure_current)(struct yagl_egl_backend */*backend*/); + void (*ensure_current)(struct yagl_thread_state */*cur_ts*/, + struct yagl_egl_backend */*backend*/); - void (*unensure_current)(struct yagl_egl_backend */*backend*/); + void (*unensure_current)(struct yagl_thread_state */*cur_ts*/, + struct yagl_egl_backend */*backend*/); /* * @} diff --git a/hw/yagl/yagl_egl_interface.h b/hw/yagl/yagl_egl_interface.h index 85a8115..1c9b721 100644 --- a/hw/yagl/yagl_egl_interface.h +++ b/hw/yagl/yagl_egl_interface.h @@ -34,11 +34,16 @@ struct yagl_egl_interface { - uint32_t (*get_ctx_id)(struct yagl_egl_interface */*iface*/); + uint32_t (*get_ctx_id)(struct yagl_thread_state */*cur_ts*/, + struct yagl_egl_interface */*iface*/); - void (*ensure_ctx)(struct yagl_egl_interface */*iface*/, uint32_t /*ctx_id*/); + void (*ensure_ctx)(struct yagl_thread_state */*cur_ts*/, + struct yagl_egl_interface */*iface*/, + uint32_t /*ctx_id*/); - void (*unensure_ctx)(struct yagl_egl_interface */*iface*/, uint32_t /*ctx_id*/); + void (*unensure_ctx)(struct yagl_thread_state */*cur_ts*/, + struct yagl_egl_interface */*iface*/, + uint32_t /*ctx_id*/); }; #endif diff --git a/hw/yagl/yagl_eglb_context.h b/hw/yagl/yagl_eglb_context.h index 84c93aa..90c46f0 100644 --- a/hw/yagl/yagl_eglb_context.h +++ b/hw/yagl/yagl_eglb_context.h @@ -39,7 +39,7 @@ struct yagl_eglb_context struct yagl_eglb_display *dpy; struct yagl_process_state *ps; - void (*destroy)(struct yagl_eglb_context */*ctx*/); + void (*destroy)(struct yagl_thread_state */*cur_ts*/, struct yagl_eglb_context */*ctx*/); }; void yagl_eglb_context_init(struct yagl_eglb_context *ctx, diff --git a/hw/yagl/yagl_eglb_surface.h b/hw/yagl/yagl_eglb_surface.h index 2a67281..0f393ed 100644 --- a/hw/yagl/yagl_eglb_surface.h +++ b/hw/yagl/yagl_eglb_surface.h @@ -40,8 +40,6 @@ struct yagl_eglb_surface { struct yagl_eglb_display *dpy; - struct yagl_process_state *ps; - EGLenum type; union @@ -85,7 +83,8 @@ struct yagl_eglb_surface void (*wait_gl)(struct yagl_thread_state */*cur_ts*/, struct yagl_eglb_surface */*sfc*/); - void (*destroy)(struct yagl_eglb_surface */*sfc*/); + void (*destroy)(struct yagl_thread_state */*cur_ts*/, + struct yagl_eglb_surface */*sfc*/); }; void yagl_eglb_surface_init(struct yagl_eglb_surface *sfc, diff --git a/hw/yagl/yagl_gles_driver.c b/hw/yagl/yagl_gles_driver.c index 1f69b17..59ceef7 100644 --- a/hw/yagl/yagl_gles_driver.c +++ b/hw/yagl/yagl_gles_driver.c @@ -43,20 +43,18 @@ void yagl_gles_driver_cleanup(struct yagl_gles_driver *driver) { } -uint32_t yagl_get_ctx_id(struct yagl_process_state *ps) +uint32_t yagl_get_ctx_id(struct yagl_thread_state *cur_ts) { - assert(ps); - return ps->egl_iface->get_ctx_id(ps->egl_iface); + assert(cur_ts); + return cur_ts->ps->egl_iface->get_ctx_id(cur_ts, cur_ts->ps->egl_iface); } -void yagl_ensure_ctx(struct yagl_process_state *ps, uint32_t ctx_id) +void yagl_ensure_ctx(struct yagl_thread_state *cur_ts, uint32_t ctx_id) { - assert(ps); - ps->egl_iface->ensure_ctx(ps->egl_iface, ctx_id); + cur_ts->ps->egl_iface->ensure_ctx(cur_ts, cur_ts->ps->egl_iface, ctx_id); } -void yagl_unensure_ctx(struct yagl_process_state *ps, uint32_t ctx_id) +void yagl_unensure_ctx(struct yagl_thread_state *cur_ts, uint32_t ctx_id) { - assert(ps); - ps->egl_iface->unensure_ctx(ps->egl_iface, ctx_id); + cur_ts->ps->egl_iface->unensure_ctx(cur_ts, cur_ts->ps->egl_iface, ctx_id); } diff --git a/hw/yagl/yagl_gles_driver.h b/hw/yagl/yagl_gles_driver.h index c4bf142..57b7e8b 100644 --- a/hw/yagl/yagl_gles_driver.h +++ b/hw/yagl/yagl_gles_driver.h @@ -155,6 +155,7 @@ struct yagl_gles_driver YAGL_GLES_DRIVER_FUNC9(CopyTexSubImage3D, GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei, target, level, xoffset, yoffset, zoffset, x, y, width, height); YAGL_GLES_DRIVER_FUNC2(GenFramebuffers, GLsizei, GLuint*, n, framebuffers) YAGL_GLES_DRIVER_FUNC2(BindFramebuffer, GLenum, GLuint, target, framebuffer) + YAGL_GLES_DRIVER_FUNC3(BindFramebufferYAGL, struct yagl_thread_state *, GLenum, GLuint, cur_ts, target, framebuffer) YAGL_GLES_DRIVER_FUNC5(FramebufferTexture2D, GLenum, GLenum, GLenum, GLuint, GLint, target, attachment, textarget, texture, level) YAGL_GLES_DRIVER_FUNC4(FramebufferRenderbuffer, GLenum, GLenum, GLenum, GLuint, target, attachment, renderbuffertarget, renderbuffer) YAGL_GLES_DRIVER_FUNC2(DeleteFramebuffers, GLsizei, const GLuint*, n, framebuffers) @@ -409,9 +410,9 @@ void yagl_gles_driver_cleanup(struct yagl_gles_driver *driver); * @{ */ -uint32_t yagl_get_ctx_id(struct yagl_process_state *ps); -void yagl_ensure_ctx(struct yagl_process_state *ps, uint32_t ctx_id); -void yagl_unensure_ctx(struct yagl_process_state *ps, uint32_t ctx_id); +uint32_t yagl_get_ctx_id(struct yagl_thread_state *cur_ts); +void yagl_ensure_ctx(struct yagl_thread_state *cur_ts, uint32_t ctx_id); +void yagl_unensure_ctx(struct yagl_thread_state *cur_ts, uint32_t ctx_id); /* * @} diff --git a/hw/yagl/yagl_object_map.c b/hw/yagl/yagl_object_map.c index d8262dc..40f5791 100644 --- a/hw/yagl/yagl_object_map.c +++ b/hw/yagl/yagl_object_map.c @@ -29,29 +29,34 @@ #include "yagl_object_map.h" -static void yagl_object_map_entry_destroy_func(gpointer data) +static gboolean yagl_object_map_entry_remove_all_func(gpointer key, + gpointer value, + gpointer user_data) { - struct yagl_object *item = data; + struct yagl_object *item = value; + struct yagl_thread_state *cur_ts = user_data; - item->destroy(item); + item->destroy(cur_ts, item); + return TRUE; } struct yagl_object_map *yagl_object_map_create(void) { struct yagl_object_map *object_map = g_malloc0(sizeof(struct yagl_object_map)); - object_map->entries = g_hash_table_new_full(g_direct_hash, - g_direct_equal, - NULL, - &yagl_object_map_entry_destroy_func); + object_map->entries = g_hash_table_new(g_direct_hash, + g_direct_equal); assert(object_map->entries); return object_map; } -void yagl_object_map_destroy(struct yagl_object_map *object_map) +void yagl_object_map_destroy(struct yagl_thread_state *cur_ts, + struct yagl_object_map *object_map) { + yagl_object_map_remove_all(cur_ts, object_map); + g_hash_table_destroy(object_map->entries); object_map->entries = NULL; @@ -72,19 +77,31 @@ void yagl_object_map_add(struct yagl_object_map *object_map, assert(g_hash_table_size(object_map->entries) > size); } -void yagl_object_map_remove(struct yagl_object_map *object_map, +void yagl_object_map_remove(struct yagl_thread_state *cur_ts, + struct yagl_object_map *object_map, yagl_object_name local_name) { guint size = g_hash_table_size(object_map->entries); + // TODO g_hash_table_steal_extended is introduced in fairly new glib 2.58 + // and would be better suitable here. For now - lookup the value, + // call the destructor and remove it from the hash table. + struct yagl_object *item = g_hash_table_lookup(object_map->entries, + GUINT_TO_POINTER(local_name)); + + item->destroy(cur_ts, item); + g_hash_table_remove(object_map->entries, GUINT_TO_POINTER(local_name)); assert(g_hash_table_size(object_map->entries) < size); } -void yagl_object_map_remove_all(struct yagl_object_map *object_map) +void yagl_object_map_remove_all(struct yagl_thread_state *cur_ts, + struct yagl_object_map *object_map) { - g_hash_table_remove_all(object_map->entries); + g_hash_table_foreach_remove(object_map->entries, + &yagl_object_map_entry_remove_all_func, + (gpointer)cur_ts); } yagl_object_name yagl_object_map_get(struct yagl_object_map *object_map, diff --git a/hw/yagl/yagl_object_map.h b/hw/yagl/yagl_object_map.h index 373f9a4..e97dc17 100644 --- a/hw/yagl/yagl_object_map.h +++ b/hw/yagl/yagl_object_map.h @@ -33,12 +33,15 @@ #include "yagl_types.h" #include +struct yagl_object; + +typedef void (*yagl_object_destroy_func)(struct yagl_thread_state */*cur_ts*/, struct yagl_object */*obj*/); + struct yagl_object { yagl_object_name global_name; - struct yagl_process_state *ps; - void (*destroy)(struct yagl_object */*obj*/); + yagl_object_destroy_func destroy; }; struct yagl_object_map @@ -49,16 +52,19 @@ struct yagl_object_map struct yagl_object_map *yagl_object_map_create(void); -void yagl_object_map_destroy(struct yagl_object_map *object_map); +void yagl_object_map_destroy(struct yagl_thread_state *cur_ts, + struct yagl_object_map *object_map); void yagl_object_map_add(struct yagl_object_map *object_map, yagl_object_name local_name, struct yagl_object *obj); -void yagl_object_map_remove(struct yagl_object_map *object_map, +void yagl_object_map_remove(struct yagl_thread_state *cur_ts, + struct yagl_object_map *object_map, yagl_object_name local_name); -void yagl_object_map_remove_all(struct yagl_object_map *object_map); +void yagl_object_map_remove_all(struct yagl_thread_state *cur_ts, + struct yagl_object_map *object_map); yagl_object_name yagl_object_map_get(struct yagl_object_map *object_map, yagl_object_name local_name); diff --git a/hw/yagl/yagl_process.c b/hw/yagl/yagl_process.c index 1b38ed4..0091b23 100644 --- a/hw/yagl/yagl_process.c +++ b/hw/yagl/yagl_process.c @@ -84,7 +84,7 @@ void yagl_process_state_destroy(struct yagl_process_state *ps) assert(QLIST_EMPTY(&ps->threads)); - yagl_object_map_destroy(ps->object_map); + yagl_object_map_destroy(NULL, ps->object_map); g_free(ps); diff --git a/hw/yagl/yagl_ref.c b/hw/yagl/yagl_ref.c index e01ea4f..bd7ada5 100644 --- a/hw/yagl/yagl_ref.c +++ b/hw/yagl/yagl_ref.c @@ -59,7 +59,7 @@ void yagl_ref_acquire(struct yagl_ref *ref) ++ref->count; } -void yagl_ref_release(struct yagl_ref *ref) +void yagl_ref_release(struct yagl_thread_state *cur_ts, struct yagl_ref *ref) { assert(ref); assert(ref->count > 0); @@ -67,6 +67,6 @@ void yagl_ref_release(struct yagl_ref *ref) if (--ref->count == 0) { assert(ref->destroy); - ref->destroy(ref); + ref->destroy(cur_ts, ref); } } diff --git a/hw/yagl/yagl_ref.h b/hw/yagl/yagl_ref.h index 902296e..9d2d205 100644 --- a/hw/yagl/yagl_ref.h +++ b/hw/yagl/yagl_ref.h @@ -34,7 +34,7 @@ struct yagl_ref; -typedef void (*yagl_ref_destroy_func)(struct yagl_ref */*ref*/); +typedef void (*yagl_ref_destroy_func)(struct yagl_thread_state */*cur_ts*/, struct yagl_ref */*ref*/); struct yagl_ref { @@ -58,6 +58,6 @@ void yagl_ref_acquire(struct yagl_ref *ref); /* * Decrements ref count and releases when 0. */ -void yagl_ref_release(struct yagl_ref *ref); +void yagl_ref_release(struct yagl_thread_state *cur_ts, struct yagl_ref *ref); #endif diff --git a/hw/yagl/yagl_resource.c b/hw/yagl/yagl_resource.c index d70dca9..d0fc960 100644 --- a/hw/yagl/yagl_resource.c +++ b/hw/yagl/yagl_resource.c @@ -50,9 +50,9 @@ void yagl_resource_acquire(struct yagl_resource *res) } } -void yagl_resource_release(struct yagl_resource *res) +void yagl_resource_release(struct yagl_thread_state *cur_ts, struct yagl_resource *res) { if (res) { - yagl_ref_release(&res->ref); + yagl_ref_release(cur_ts, &res->ref); } } diff --git a/hw/yagl/yagl_resource.h b/hw/yagl/yagl_resource.h index 68e91e6..f05c2ef 100644 --- a/hw/yagl/yagl_resource.h +++ b/hw/yagl/yagl_resource.h @@ -62,8 +62,8 @@ void yagl_resource_cleanup(struct yagl_resource *res); void yagl_resource_acquire(struct yagl_resource *res); /* - * Passing NULL won't hurt, this is for convenience. + * Passing NULL res won't hurt, this is for convenience. */ -void yagl_resource_release(struct yagl_resource *res); +void yagl_resource_release(struct yagl_thread_state *cur_ts, struct yagl_resource *res); #endif diff --git a/hw/yagl/yagl_resource_list.c b/hw/yagl/yagl_resource_list.c index ad7cee6..54ca4f9 100644 --- a/hw/yagl/yagl_resource_list.c +++ b/hw/yagl/yagl_resource_list.c @@ -36,13 +36,13 @@ void yagl_resource_list_init(struct yagl_resource_list *list) list->count = 0; } -void yagl_resource_list_cleanup(struct yagl_resource_list *list) +void yagl_resource_list_cleanup(struct yagl_thread_state *cur_ts, struct yagl_resource_list *list) { struct yagl_resource *res, *next; QTAILQ_FOREACH_SAFE(res, &list->resources, entry, next) { QTAILQ_REMOVE(&list->resources, res, entry); - yagl_resource_release(res); + yagl_resource_release(cur_ts, res); } assert(QTAILQ_EMPTY(&list->resources)); @@ -93,7 +93,8 @@ struct yagl_resource return NULL; } -bool yagl_resource_list_remove(struct yagl_resource_list *list, +bool yagl_resource_list_remove(struct yagl_thread_state *cur_ts, + struct yagl_resource_list *list, yagl_host_handle handle) { struct yagl_resource *res; @@ -101,7 +102,7 @@ bool yagl_resource_list_remove(struct yagl_resource_list *list, QTAILQ_FOREACH(res, &list->resources, entry) { if (res->handle == handle) { QTAILQ_REMOVE(&list->resources, res, entry); - yagl_resource_release(res); + yagl_resource_release(cur_ts, res); return true; } } diff --git a/hw/yagl/yagl_resource_list.h b/hw/yagl/yagl_resource_list.h index 5ef3ae8..e3df257 100644 --- a/hw/yagl/yagl_resource_list.h +++ b/hw/yagl/yagl_resource_list.h @@ -55,7 +55,7 @@ void yagl_resource_list_init(struct yagl_resource_list *list); * Release all resources in the list and empty the list. The * list should be initialized again in order to be used after this. */ -void yagl_resource_list_cleanup(struct yagl_resource_list *list); +void yagl_resource_list_cleanup(struct yagl_thread_state *cur_ts, struct yagl_resource_list *list); int yagl_resource_list_get_count(struct yagl_resource_list *list); @@ -88,7 +88,8 @@ struct yagl_resource * Removes a resource from the end of the list, this also releases * the resource. */ -bool yagl_resource_list_remove(struct yagl_resource_list *list, +bool yagl_resource_list_remove(struct yagl_thread_state *cur_ts, + struct yagl_resource_list *list, yagl_host_handle handle); #endif diff --git a/hw/yagl/yagl_thread.c b/hw/yagl/yagl_thread.c index 2615d02..3326282 100644 --- a/hw/yagl/yagl_thread.c +++ b/hw/yagl/yagl_thread.c @@ -208,7 +208,7 @@ void yagl_thread_state_destroy(struct yagl_thread_state *ts, * First, remove all objects. */ - yagl_object_map_remove_all(ts->ps->object_map); + yagl_object_map_remove_all(ts, ts->ps->object_map); /* * Destroy APIs (process). diff --git a/hw/yagl/yagl_thread.h b/hw/yagl/yagl_thread.h index c848914..f1f5737 100644 --- a/hw/yagl/yagl_thread.h +++ b/hw/yagl/yagl_thread.h @@ -32,7 +32,6 @@ #include "yagl_types.h" #include "yagl_event.h" -#include "yagl_tls.h" #include "hw/vigs/work_queue.h" #include "qemu/queue.h" #include "qemu/thread.h" @@ -56,10 +55,10 @@ struct yagl_thread_state * Fake TLS. * @{ */ - void *egl_api_ts; - void *gles_api_ts; - void *egl_offscreen_ts; - void *egl_onscreen_ts; + struct yagl_egl_api_ts *egl_api_ts; + struct yagl_gles_api_ts *gles_api_ts; + struct yagl_egl_offscreen_ts *egl_offscreen_ts; + struct yagl_egl_onscreen_ts *egl_onscreen_ts; /* * @} */ -- 2.7.4