Now i965 supports mesa_glthread=true like Gallium drivers do. According to Markus (degasus), the Citra emulator now runs ~30% faster. Emmanuel (linkmauve) also reported that the Dolphin emulator improved by 2.8x on one game. (Both of those still need to be added to drirc.)
An Intel Mesa CI run with mesa_glthread=true appears to be happy. I have not yet tested the applications that are currently whitelisted in drirc. We should do that before landing this patch. Tested-by: Markus Wick <mar...@selfnet.de> Tested-by: Emmanuel Gil Peyrot <linkma...@linkmauve.fr> --- src/mesa/drivers/dri/i965/brw_context.c | 44 +++++++++++++++++++++ src/mesa/drivers/dri/i965/intel_screen.c | 4 ++ src/mesa/drivers/dri/i965/intel_tex_image.c | 3 ++ 3 files changed, 51 insertions(+) diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index bd1e20845f0..4a20cacfa3c 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -36,6 +36,7 @@ #include "main/context.h" #include "main/fbobject.h" #include "main/extensions.h" +#include "main/glthread.h" #include "main/imports.h" #include "main/macros.h" #include "main/points.h" @@ -147,6 +148,24 @@ intel_get_string(struct gl_context * ctx, GLenum name) } } +static void +brw_set_background_context(struct gl_context *ctx, + struct util_queue_monitoring *queue_info) +{ + struct brw_context *brw = brw_context(ctx); + __DRIcontext *driContext = brw->driContext; + __DRIscreen *driScreen = driContext->driScreenPriv; + const __DRIbackgroundCallableExtension *backgroundCallable = + driScreen->dri2.backgroundCallable; + + /* Note: Mesa will only call this function if we've called + * _mesa_enable_multithreading(). We only do that if the loader exposed + * the __DRI_BACKGROUND_CALLABLE extension. So we know that + * backgroundCallable is not NULL. + */ + backgroundCallable->setBackgroundContext(driContext->loaderPrivate); +} + static void intel_viewport(struct gl_context *ctx) { @@ -343,6 +362,8 @@ brw_init_driver_functions(struct brw_context *brw, functions->ProgramBinarySerializeDriverBlob = brw_program_serialize_nir; functions->ProgramBinaryDeserializeDriverBlob = brw_deserialize_program_binary; + + functions->SetBackgroundContext = brw_set_background_context; } static void @@ -1089,6 +1110,12 @@ brwCreateContext(gl_api api, brw->ctx.Cache = brw->screen->disk_cache; + if (driContextPriv->driScreenPriv->dri2.backgroundCallable && + driQueryOptionb(&screen->optionCache, "mesa_glthread")) { + /* Loader supports multithreading, and so do we. */ + _mesa_glthread_init(ctx); + } + return true; } @@ -1099,6 +1126,18 @@ intelDestroyContext(__DRIcontext * driContextPriv) (struct brw_context *) driContextPriv->driverPrivate; struct gl_context *ctx = &brw->ctx; + GET_CURRENT_CONTEXT(curctx); + + if (curctx == NULL) { + /* No current context, but we need one to release + * renderbuffer surface when we release framebuffer. + * So temporarily bind the context. + */ + _mesa_make_current(ctx, NULL, NULL); + } + + _mesa_glthread_destroy(&brw->ctx); + _mesa_meta_free(&brw->ctx); if (INTEL_DEBUG & DEBUG_SHADER_TIME) { @@ -1159,6 +1198,9 @@ intelDestroyContext(__DRIcontext * driContextPriv) GLboolean intelUnbindContext(__DRIcontext * driContextPriv) { + GET_CURRENT_CONTEXT(ctx); + _mesa_glthread_finish(ctx); + /* Unset current context and dispath table */ _mesa_make_current(NULL, NULL, NULL); @@ -1262,6 +1304,8 @@ intelMakeCurrent(__DRIcontext * driContextPriv, _mesa_make_current(ctx, fb, readFb); } else { + GET_CURRENT_CONTEXT(ctx); + _mesa_glthread_finish(ctx); _mesa_make_current(NULL, NULL, NULL); } diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c index ab6c003b0fe..bde27cf0936 100644 --- a/src/mesa/drivers/dri/i965/intel_screen.c +++ b/src/mesa/drivers/dri/i965/intel_screen.c @@ -34,6 +34,7 @@ #include "main/hash.h" #include "main/fbobject.h" #include "main/version.h" +#include "main/glthread.h" #include "swrast/s_renderbuffer.h" #include "util/ralloc.h" #include "util/disk_cache.h" @@ -62,6 +63,7 @@ DRI_CONF_BEGIN DRI_CONF_DESC_END DRI_CONF_OPT_END DRI_CONF_MESA_NO_ERROR("false") + DRI_CONF_MESA_GLTHREAD("false") DRI_CONF_SECTION_END DRI_CONF_SECTION_QUALITY @@ -148,6 +150,8 @@ intel_dri2_flush_with_flags(__DRIcontext *cPriv, struct gl_context *ctx = &brw->ctx; + _mesa_glthread_finish(ctx); + FLUSH_VERTICES(ctx, 0); if (flags & __DRI2_FLUSH_DRAWABLE) diff --git a/src/mesa/drivers/dri/i965/intel_tex_image.c b/src/mesa/drivers/dri/i965/intel_tex_image.c index fae179214dd..289150564de 100644 --- a/src/mesa/drivers/dri/i965/intel_tex_image.c +++ b/src/mesa/drivers/dri/i965/intel_tex_image.c @@ -14,6 +14,7 @@ #include "main/texobj.h" #include "main/teximage.h" #include "main/texstore.h" +#include "main/glthread.h" #include "drivers/common/meta.h" @@ -444,6 +445,8 @@ intelSetTexBuffer2(__DRIcontext *pDRICtx, GLint target, mesa_format texFormat = MESA_FORMAT_NONE; GLenum internal_format = 0; + _mesa_glthread_finish(ctx); + texObj = _mesa_get_current_tex_object(ctx, target); if (!texObj) -- 2.17.0 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev