From 562adc385db85fab1345849454b864f787f76a26 Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Sat, 22 Oct 2022 01:02:42 +0800 Subject: [PATCH] st: Turn st_api::make_current to be direct accessed function st_api_make_current MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Yonggang Luo Reviewed-by: Jesse Natalie Reviewed-by: Marek Olšák Part-of: --- src/gallium/frontends/dri/dri_context.c | 8 +++---- src/gallium/frontends/glx/xlib/xm_api.c | 4 ++-- src/gallium/frontends/osmesa/osmesa.c | 5 ++--- src/gallium/frontends/wgl/stw_context.c | 10 ++++----- src/gallium/include/frontend/api.h | 22 +++++++++---------- .../targets/haiku-softpipe/GalliumContext.cpp | 4 ++-- src/mesa/state_tracker/st_manager.c | 5 ++--- 7 files changed, 27 insertions(+), 31 deletions(-) diff --git a/src/gallium/frontends/dri/dri_context.c b/src/gallium/frontends/dri/dri_context.c index 843ecfe225e..5e9c643c1e1 100644 --- a/src/gallium/frontends/dri/dri_context.c +++ b/src/gallium/frontends/dri/dri_context.c @@ -264,10 +264,8 @@ GLboolean dri_unbind_context(__DRIcontext * cPriv) { /* dri_util.c ensures cPriv is not null */ - struct dri_screen *screen = dri_screen(cPriv->driScreenPriv); struct dri_context *ctx = dri_context(cPriv); struct st_context_iface *st = ctx->st; - struct st_api *stapi = screen->st_api; if (st == st_api_get_current()) { if (st->thread_finish) @@ -277,7 +275,7 @@ dri_unbind_context(__DRIcontext * cPriv) if (ctx->hud) hud_record_only(ctx->hud, st->pipe); - stapi->make_current(stapi, NULL, NULL, NULL); + st_api_make_current(NULL, NULL, NULL); } ctx->dPriv = NULL; ctx->rPriv = NULL; @@ -302,7 +300,7 @@ dri_make_current(__DRIcontext * cPriv, ctx->st->thread_finish(ctx->st); if (!draw && !read) - return ctx->stapi->make_current(ctx->stapi, ctx->st, NULL, NULL); + return st_api_make_current(ctx->st, NULL, NULL); else if (!draw || !read) return GL_FALSE; @@ -315,7 +313,7 @@ dri_make_current(__DRIcontext * cPriv, read->texture_stamp = driReadPriv->lastStamp - 1; } - ctx->stapi->make_current(ctx->stapi, ctx->st, &draw->base, &read->base); + st_api_make_current(ctx->st, &draw->base, &read->base); /* This is ok to call here. If they are already init, it's a no-op. */ if (ctx->pp && draw->textures[ST_ATTACHMENT_BACK_LEFT]) diff --git a/src/gallium/frontends/glx/xlib/xm_api.c b/src/gallium/frontends/glx/xlib/xm_api.c index 30f47fafb7c..939cdb5a1cf 100644 --- a/src/gallium/frontends/glx/xlib/xm_api.c +++ b/src/gallium/frontends/glx/xlib/xm_api.c @@ -1298,7 +1298,7 @@ GLboolean XMesaMakeCurrent2( XMesaContext c, XMesaBuffer drawBuffer, c->xm_buffer = drawBuffer; c->xm_read_buffer = readBuffer; - stapi->make_current(stapi, c->st, + st_api_make_current(c->st, drawBuffer ? drawBuffer->stfb : NULL, readBuffer ? readBuffer->stfb : NULL); @@ -1308,7 +1308,7 @@ GLboolean XMesaMakeCurrent2( XMesaContext c, XMesaBuffer drawBuffer, } else { /* Detach */ - stapi->make_current(stapi, NULL, NULL, NULL); + st_api_make_current(NULL, NULL, NULL); } return GL_TRUE; diff --git a/src/gallium/frontends/osmesa/osmesa.c b/src/gallium/frontends/osmesa/osmesa.c index 11644ef0be8..6d52748604f 100644 --- a/src/gallium/frontends/osmesa/osmesa.c +++ b/src/gallium/frontends/osmesa/osmesa.c @@ -755,11 +755,10 @@ GLAPI GLboolean GLAPIENTRY OSMesaMakeCurrent(OSMesaContext osmesa, void *buffer, GLenum type, GLsizei width, GLsizei height) { - struct st_api *stapi = get_st_api(); enum pipe_format color_format; if (!osmesa && !buffer) { - stapi->make_current(stapi, NULL, NULL, NULL); + st_api_make_current(NULL, NULL, NULL); return GL_TRUE; } @@ -798,7 +797,7 @@ OSMesaMakeCurrent(OSMesaContext osmesa, void *buffer, GLenum type, osmesa->type = type; - stapi->make_current(stapi, osmesa->stctx, osbuffer->stfb, osbuffer->stfb); + st_api_make_current(osmesa->stctx, osbuffer->stfb, osbuffer->stfb); /* XXX: We should probably load the current color value into the buffer here * to match classic swrast behavior (context's fb starts with the contents of diff --git a/src/gallium/frontends/wgl/stw_context.c b/src/gallium/frontends/wgl/stw_context.c index 5bbb36627cf..b3a7bb13cd4 100644 --- a/src/gallium/frontends/wgl/stw_context.c +++ b/src/gallium/frontends/wgl/stw_context.c @@ -322,7 +322,7 @@ DrvDeleteContext(DHGLRC dhglrc) /* Unbind current if deleting current context. */ if (curctx == ctx) - stw_dev->stapi->make_current(stw_dev->stapi, NULL, NULL, NULL); + st_api_make_current(NULL, NULL, NULL); stw_destroy_context(ctx); ret = TRUE; @@ -487,9 +487,9 @@ stw_make_current(struct stw_framebuffer *fb, struct stw_framebuffer *fbRead, str ctx->current_framebuffer = fb; ctx->current_read_framebuffer = fbRead; - ret = stw_dev->stapi->make_current(stw_dev->stapi, ctx->st, - fb ? fb->stfb : NULL, - fbRead ? fbRead->stfb : NULL); + ret = st_api_make_current(ctx->st, + fb ? fb->stfb : NULL, + fbRead ? fbRead->stfb : NULL); /* Release the old framebuffers from this context. */ release_old_framebuffers(old_fb, old_fbRead, ctx); @@ -508,7 +508,7 @@ fail: stw_make_current(NULL, NULL, NULL); } } else { - ret = stw_dev->stapi->make_current(stw_dev->stapi, NULL, NULL, NULL); + ret = st_api_make_current(NULL, NULL, NULL); } /* Unreference the previous framebuffer if any. It must be done after diff --git a/src/gallium/include/frontend/api.h b/src/gallium/include/frontend/api.h index 16b884e6d96..6cb698428cb 100644 --- a/src/gallium/include/frontend/api.h +++ b/src/gallium/include/frontend/api.h @@ -531,19 +531,19 @@ struct st_api const struct st_context_attribs *attribs, enum st_context_error *error, struct st_context_iface *stsharei); - - /** - * Bind the context to the calling thread with draw and read as drawables. - * - * The framebuffers might be NULL, or might have different visuals than the - * context does. - */ - bool (*make_current)(struct st_api *stapi, - struct st_context_iface *stctxi, - struct st_framebuffer_iface *stdrawi, - struct st_framebuffer_iface *streadi); }; +/** + * Bind the context to the calling thread with draw and read as drawables. + * + * The framebuffers might be NULL, or might have different visuals than the + * context does. + */ +bool +st_api_make_current(struct st_context_iface *stctxi, + struct st_framebuffer_iface *stdrawi, + struct st_framebuffer_iface *streadi); + /** * Get the currently bound context in the calling thread. */ diff --git a/src/gallium/targets/haiku-softpipe/GalliumContext.cpp b/src/gallium/targets/haiku-softpipe/GalliumContext.cpp index 205952745a6..fe7c967a243 100644 --- a/src/gallium/targets/haiku-softpipe/GalliumContext.cpp +++ b/src/gallium/targets/haiku-softpipe/GalliumContext.cpp @@ -301,7 +301,7 @@ GalliumContext::SetCurrentContext(bool set, context_id contextID) } if (!set) { - fDisplay->api->make_current(fDisplay->api, NULL, NULL, NULL); + st_api_make_current(NULL, NULL, NULL); Unlock(); return B_OK; } @@ -315,7 +315,7 @@ GalliumContext::SetCurrentContext(bool set, context_id contextID) } // We need to lock and unlock framebuffers before accessing them - fDisplay->api->make_current(fDisplay->api, context->st, context->buffer->stfbi, + st_api_make_current(context->st, context->buffer->stfbi, context->buffer->stfbi); Unlock(); diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c index f7dd14d80f4..69c73048a42 100644 --- a/src/mesa/state_tracker/st_manager.c +++ b/src/mesa/state_tracker/st_manager.c @@ -1207,8 +1207,8 @@ st_framebuffer_reuse_or_create(struct st_context *st, } -static bool -st_api_make_current(struct st_api *stapi, struct st_context_iface *stctxi, +bool +st_api_make_current(struct st_context_iface *stctxi, struct st_framebuffer_iface *stdrawi, struct st_framebuffer_iface *streadi) { @@ -1453,7 +1453,6 @@ static const struct st_api st_gl_api = { .name = "Mesa " PACKAGE_VERSION, .query_versions = st_api_query_versions, .create_context = st_api_create_context, - .make_current = st_api_make_current, };