diff options
author | Kenneth Graunke <[email protected]> | 2017-07-09 23:03:44 -0700 |
---|---|---|
committer | Kenneth Graunke <[email protected]> | 2019-03-05 00:49:05 -0800 |
commit | dca36d5516d0fdaf012b4476975c5d585c2d1a09 (patch) | |
tree | a8c258b8713c44840095377f50be74dc2d7d615a /src/mesa | |
parent | 0010d0348aa56e1097093628b1c1ec062c43c2fa (diff) |
i965: Implement threaded GL support.
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.
Bioshock Infinite's benchmark mode seems to be around 15-20% faster
on my Skylake GT4 at 1920x1080.
Tested-by: Markus Wick <[email protected]>
Tested-by: Emmanuel Gil Peyrot <[email protected]>
Tested-by: Kenneth Graunke <[email protected]>
Reviewed-by: Jordan Justen <[email protected]>
Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_context.c | 44 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/intel_screen.c | 4 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/intel_tex_image.c | 3 |
3 files changed, 51 insertions, 0 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index 505da9896b3..ab637ddf721 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" @@ -148,6 +149,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) { struct brw_context *brw = brw_context(ctx); @@ -376,6 +395,8 @@ brw_init_driver_functions(struct brw_context *brw, if (brw->screen->disk_cache) { functions->ShaderCacheSerializeDriverBlob = brw_program_serialize_nir; } + + functions->SetBackgroundContext = brw_set_background_context; } static void @@ -1126,6 +1147,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; } @@ -1136,6 +1163,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) { @@ -1196,6 +1235,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); @@ -1299,6 +1341,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 d34b161f41e..76c85047240 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 8d4ca7fed72..ccaa9ef7474 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" @@ -442,6 +443,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) |