#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"
}
}
+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)
{
if (brw->screen->disk_cache) {
functions->ShaderCacheSerializeDriverBlob = brw_program_serialize_nir;
}
+
+ functions->SetBackgroundContext = brw_set_background_context;
}
static void
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;
}
(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) {
GLboolean
intelUnbindContext(__DRIcontext * driContextPriv)
{
+ GET_CURRENT_CONTEXT(ctx);
+ _mesa_glthread_finish(ctx);
+
/* Unset current context and dispath table */
_mesa_make_current(NULL, NULL, NULL);
_mesa_make_current(ctx, fb, readFb);
} else {
+ GET_CURRENT_CONTEXT(ctx);
+ _mesa_glthread_finish(ctx);
_mesa_make_current(NULL, NULL, NULL);
}