From cb400f368a79f2ef2633d135dbd16accf7fa1c0d Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Tue, 7 Dec 2021 11:37:07 +1000 Subject: [PATCH] mesa/st: move clear/flush/finish to direct call MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Acked-by: Marek Olšák Part-of: --- src/mesa/main/context.c | 14 +++++--------- src/mesa/main/dd.h | 18 ------------------ src/mesa/main/performance_query.c | 3 ++- src/mesa/main/state.c | 3 ++- src/mesa/main/texobj.c | 4 ++-- src/mesa/state_tracker/st_cb_flush.c | 15 ++------------- src/mesa/state_tracker/st_cb_flush.h | 3 +++ src/mesa/state_tracker/st_context.c | 6 +----- src/mesa/state_tracker/st_context.h | 3 +++ 9 files changed, 20 insertions(+), 49 deletions(-) diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 522ad005a92..278e7e45b23 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -155,6 +155,7 @@ #include "util/u_memory.h" #include "state_tracker/st_cb_texture.h" +#include "state_tracker/st_cb_flush.h" #ifndef MESA_VERBOSE int MESA_VERBOSE = 0; @@ -1633,8 +1634,7 @@ _mesa_make_current( struct gl_context *newCtx, curCtx->Const.ContextReleaseBehavior == GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH) { FLUSH_VERTICES(curCtx, 0, 0); - if (curCtx->Driver.Flush) - curCtx->Driver.Flush(curCtx, 0); + st_glFlush(curCtx, 0); } /* Call this periodically to detect when the user has begun using @@ -1789,12 +1789,10 @@ _mesa_get_dispatch(struct gl_context *ctx) void _mesa_flush(struct gl_context *ctx) { + bool async = !ctx->Shared->HasExternallySharedImages; FLUSH_VERTICES(ctx, 0, 0); - if (ctx->Driver.Flush) { - bool async = !ctx->Shared->HasExternallySharedImages; - ctx->Driver.Flush(ctx, async ? PIPE_FLUSH_ASYNC : 0); - } + st_glFlush(ctx, async ? PIPE_FLUSH_ASYNC : 0); } @@ -1813,9 +1811,7 @@ _mesa_Finish(void) FLUSH_VERTICES(ctx, 0, 0); - if (ctx->Driver.Finish) { - ctx->Driver.Finish(ctx); - } + st_glFinish(ctx); } diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h index 22fd2e60a36..06f8154e41c 100644 --- a/src/mesa/main/dd.h +++ b/src/mesa/main/dd.h @@ -116,24 +116,6 @@ struct pipe_vertex_element; * file should be updated too!!! */ struct dd_function_table { - /** - * Notify the driver after Mesa has made some internal state changes. - * - * This is in addition to any state change callbacks Mesa may already have - * made. - */ - void (*UpdateState)(struct gl_context *ctx); - - /** - * This is called whenever glFinish() is called. - */ - void (*Finish)( struct gl_context *ctx ); - - /** - * This is called whenever glFlush() is called. - */ - void (*Flush)(struct gl_context *ctx, unsigned gallium_flush_flags); - /** * Called by glCopyImageSubData(). * diff --git a/src/mesa/main/performance_query.c b/src/mesa/main/performance_query.c index 5f1b120f505..b44f7f94303 100644 --- a/src/mesa/main/performance_query.c +++ b/src/mesa/main/performance_query.c @@ -37,6 +37,7 @@ #include "util/ralloc.h" #include "state_tracker/st_cb_perfquery.h" +#include "state_tracker/st_cb_flush.h" void _mesa_init_performance_queries(struct gl_context *ctx) @@ -640,7 +641,7 @@ _mesa_GetPerfQueryDataINTEL(GLuint queryHandle, GLuint flags, if (!obj->Ready) { if (flags == GL_PERFQUERY_FLUSH_INTEL) { - ctx->Driver.Flush(ctx, 0); + st_glFlush(ctx, 0); } else if (flags == GL_PERFQUERY_WAIT_INTEL) { st_WaitPerfQuery(ctx, obj); obj->Ready = true; diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index 9a61d86c238..e75b31f95b8 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -55,6 +55,7 @@ #include "viewport.h" #include "blend.h" +#include "state_tracker/st_context.h" void _mesa_update_allow_draw_out_of_order(struct gl_context *ctx) @@ -487,7 +488,7 @@ _mesa_update_state_locked( struct gl_context *ctx ) * Also, this is where the driver can invalidate the state of any * active modules (such as swrast_setup, swrast, tnl, etc). */ - ctx->Driver.UpdateState(ctx); + st_invalidate_state(ctx); ctx->NewState = 0; } diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c index 8130213201f..dda57b6ffad 100644 --- a/src/mesa/main/texobj.c +++ b/src/mesa/main/texobj.c @@ -48,6 +48,7 @@ #include "state_tracker/st_cb_texture.h" #include "state_tracker/st_format.h" +#include "state_tracker/st_cb_flush.h" /**********************************************************************/ /** \name Internal functions */ @@ -1029,8 +1030,7 @@ _mesa_get_fallback_texture(struct gl_context *ctx, gl_texture_index tex) /* Complete the driver's operation in case another context will also * use the same fallback texture. */ - if (ctx->Driver.Finish) - ctx->Driver.Finish(ctx); + st_glFinish(ctx); } return ctx->Shared->FallbackTex[tex]; } diff --git a/src/mesa/state_tracker/st_cb_flush.c b/src/mesa/state_tracker/st_cb_flush.c index 97e0c73dcfd..a0107cc6b45 100644 --- a/src/mesa/state_tracker/st_cb_flush.c +++ b/src/mesa/state_tracker/st_cb_flush.c @@ -82,11 +82,7 @@ st_finish(struct st_context *st) } - -/** - * Called via ctx->Driver.Flush() - */ -static void +void st_glFlush(struct gl_context *ctx, unsigned gallium_flush_flags) { struct st_context *st = st_context(ctx); @@ -101,11 +97,7 @@ st_glFlush(struct gl_context *ctx, unsigned gallium_flush_flags) st_manager_flush_frontbuffer(st); } - -/** - * Called via ctx->Driver.Finish() - */ -static void +void st_glFinish(struct gl_context *ctx) { struct st_context *st = st_context(ctx); @@ -187,9 +179,6 @@ void st_init_flush_functions(struct pipe_screen *screen, struct dd_function_table *functions) { - functions->Flush = st_glFlush; - functions->Finish = st_glFinish; - if (screen->get_param(screen, PIPE_CAP_DEVICE_RESET_STATUS_QUERY)) functions->GetGraphicsResetStatus = st_get_graphics_reset_status; } diff --git a/src/mesa/state_tracker/st_cb_flush.h b/src/mesa/state_tracker/st_cb_flush.h index 5be68c9b68a..daee0408c76 100644 --- a/src/mesa/state_tracker/st_cb_flush.h +++ b/src/mesa/state_tracker/st_cb_flush.h @@ -40,6 +40,9 @@ extern void st_init_flush_functions(struct pipe_screen *screen, struct dd_function_table *functions); +void st_glFlush(struct gl_context *ctx, unsigned gallium_flush_flags); +void st_glFinish(struct gl_context *ctx); + extern void st_flush(struct st_context *st, struct pipe_fence_handle **fence, diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index e3e2c74150f..99d8da1b762 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -183,10 +183,7 @@ st_vp_uses_current_values(const struct gl_context *ctx) } -/** - * Called via ctx->Driver.UpdateState() - */ -static void +void st_invalidate_state(struct gl_context *ctx) { GLbitfield new_state = ctx->NewState; @@ -945,7 +942,6 @@ st_init_driver_functions(struct pipe_screen *screen, if (screen->get_param(screen, PIPE_CAP_STRING_MARKER)) functions->EmitStringMarker = st_emit_string_marker; - functions->UpdateState = st_invalidate_state; functions->SetBackgroundContext = st_set_background_context; functions->GetDriverUuid = st_get_driver_uuid; functions->GetDeviceUuid = st_get_device_uuid; diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 081b68aef58..b6506966467 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -455,6 +455,9 @@ struct st_framebuffer void st_Enable(struct gl_context *ctx, GLenum cap); void st_query_memory_info(struct gl_context *ctx, struct gl_memory_info *out); + +void st_invalidate_state(struct gl_context *ctx); + #ifdef __cplusplus } #endif