diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2017-08-14 09:45:54 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2017-08-14 09:45:54 +0000 |
commit | 4c58069f5013f0a621503525f7d5193bfe9976b3 (patch) | |
tree | bd8f8a08b889e9a8b99c9de01ae12459d527ea6d /lib/mesa/src/gallium/state_trackers/dri | |
parent | 5caa025e6b62d0456faad86c89f239a14d1eaadb (diff) |
Import Mesa 17.1.6
Diffstat (limited to 'lib/mesa/src/gallium/state_trackers/dri')
5 files changed, 136 insertions, 24 deletions
diff --git a/lib/mesa/src/gallium/state_trackers/dri/dri2.c b/lib/mesa/src/gallium/state_trackers/dri/dri2.c index 9ec069b30..3bd67bf21 100644 --- a/lib/mesa/src/gallium/state_trackers/dri/dri2.c +++ b/lib/mesa/src/gallium/state_trackers/dri/dri2.c @@ -1038,20 +1038,23 @@ dri2_query_image(__DRIimage *image, int attrib, int *value) switch (attrib) { case __DRI_IMAGE_ATTRIB_STRIDE: whandle.type = DRM_API_HANDLE_TYPE_KMS; - image->texture->screen->resource_get_handle(image->texture->screen, - NULL, image->texture, &whandle, usage); + if (!image->texture->screen->resource_get_handle(image->texture->screen, + NULL, image->texture, &whandle, usage)) + return GL_FALSE; *value = whandle.stride; return GL_TRUE; case __DRI_IMAGE_ATTRIB_HANDLE: whandle.type = DRM_API_HANDLE_TYPE_KMS; - image->texture->screen->resource_get_handle(image->texture->screen, - NULL, image->texture, &whandle, usage); + if (!image->texture->screen->resource_get_handle(image->texture->screen, + NULL, image->texture, &whandle, usage)) + return GL_FALSE; *value = whandle.handle; return GL_TRUE; case __DRI_IMAGE_ATTRIB_NAME: whandle.type = DRM_API_HANDLE_TYPE_SHARED; - image->texture->screen->resource_get_handle(image->texture->screen, - NULL, image->texture, &whandle, usage); + if (!image->texture->screen->resource_get_handle(image->texture->screen, + NULL, image->texture, &whandle, usage)) + return GL_FALSE; *value = whandle.handle; return GL_TRUE; case __DRI_IMAGE_ATTRIB_FD: @@ -1168,6 +1171,10 @@ dri2_from_planar(__DRIimage *image, int plane, void *loaderPrivate) if (img == NULL) return NULL; + if (img->texture->screen->resource_changed) + img->texture->screen->resource_changed(img->texture->screen, + img->texture); + /* set this to 0 for sub images. */ img->dri_components = 0; return img; @@ -1427,10 +1434,10 @@ dri2_load_opencl_interop(struct dri_screen *screen) #if defined(RTLD_DEFAULT) bool success; - pipe_mutex_lock(screen->opencl_func_mutex); + mtx_lock(&screen->opencl_func_mutex); if (dri2_is_opencl_interop_loaded_locked(screen)) { - pipe_mutex_unlock(screen->opencl_func_mutex); + mtx_unlock(&screen->opencl_func_mutex); return true; } @@ -1444,7 +1451,7 @@ dri2_load_opencl_interop(struct dri_screen *screen) dlsym(RTLD_DEFAULT, "opencl_dri_event_get_fence"); success = dri2_is_opencl_interop_loaded_locked(screen); - pipe_mutex_unlock(screen->opencl_func_mutex); + mtx_unlock(&screen->opencl_func_mutex); return success; #else return false; @@ -1457,6 +1464,18 @@ struct dri2_fence { void *cl_event; }; +static unsigned dri2_fence_get_caps(__DRIscreen *_screen) +{ + struct dri_screen *driscreen = dri_screen(_screen); + struct pipe_screen *screen = driscreen->base.screen; + unsigned caps = 0; + + if (screen->get_param(screen, PIPE_CAP_NATIVE_FENCE_FD)) + caps |= __DRI_FENCE_CAP_NATIVE_FD; + + return caps; +} + static void * dri2_create_fence(__DRIcontext *_ctx) { @@ -1478,6 +1497,39 @@ dri2_create_fence(__DRIcontext *_ctx) } static void * +dri2_create_fence_fd(__DRIcontext *_ctx, int fd) +{ + struct pipe_context *ctx = dri_context(_ctx)->st->pipe; + struct dri2_fence *fence = CALLOC_STRUCT(dri2_fence); + + if (fd == -1) { + /* exporting driver created fence, flush: */ + ctx->flush(ctx, &fence->pipe_fence, + PIPE_FLUSH_DEFERRED | PIPE_FLUSH_FENCE_FD); + } else { + /* importing a foreign fence fd: */ + ctx->create_fence_fd(ctx, &fence->pipe_fence, fd); + } + if (!fence->pipe_fence) { + FREE(fence); + return NULL; + } + + fence->driscreen = dri_screen(_ctx->driScreenPriv); + return fence; +} + +static int +dri2_get_fence_fd(__DRIscreen *_screen, void *_fence) +{ + struct dri_screen *driscreen = dri_screen(_screen); + struct pipe_screen *screen = driscreen->base.screen; + struct dri2_fence *fence = (struct dri2_fence*)_fence; + + return screen->fence_get_fd(screen, fence->pipe_fence); +} + +static void * dri2_get_fence_from_cl_event(__DRIscreen *_screen, intptr_t cl_event) { struct dri_screen *driscreen = dri_screen(_screen); @@ -1548,17 +1600,24 @@ dri2_client_wait_sync(__DRIcontext *_ctx, void *_fence, unsigned flags, static void dri2_server_wait_sync(__DRIcontext *_ctx, void *_fence, unsigned flags) { - /* AFAIK, no driver currently supports parallel context execution. */ + struct pipe_context *ctx = dri_context(_ctx)->st->pipe; + struct dri2_fence *fence = (struct dri2_fence*)_fence; + + if (ctx->fence_server_sync) + ctx->fence_server_sync(ctx, fence->pipe_fence); } static __DRI2fenceExtension dri2FenceExtension = { - .base = { __DRI2_FENCE, 1 }, + .base = { __DRI2_FENCE, 2 }, .create_fence = dri2_create_fence, .get_fence_from_cl_event = dri2_get_fence_from_cl_event, .destroy_fence = dri2_destroy_fence, .client_wait_sync = dri2_client_wait_sync, - .server_wait_sync = dri2_server_wait_sync + .server_wait_sync = dri2_server_wait_sync, + .get_capabilities = dri2_fence_get_caps, + .create_fence_fd = dri2_create_fence_fd, + .get_fence_fd = dri2_get_fence_fd, }; static const __DRIrobustnessExtension dri2Robustness = { @@ -1752,7 +1811,7 @@ dri2_interop_export_object(__DRIcontext *_ctx, return MESA_GLINTEROP_INVALID_MIP_LEVEL; } - if (!st_finalize_texture(ctx, st->pipe, obj)) { + if (!st_finalize_texture(ctx, st->pipe, obj, 0)) { mtx_unlock(&ctx->Shared->Mutex); return MESA_GLINTEROP_OUT_OF_RESOURCES; } @@ -1874,7 +1933,7 @@ dri2_init_screen(__DRIscreen * sPriv) screen->sPriv = sPriv; screen->fd = sPriv->fd; - pipe_mutex_init(screen->opencl_func_mutex); + (void) mtx_init(&screen->opencl_func_mutex, mtx_plain); sPriv->driverPrivate = (void *)screen; diff --git a/lib/mesa/src/gallium/state_trackers/dri/dri_context.c b/lib/mesa/src/gallium/state_trackers/dri/dri_context.c index 3d8af65ca..92d79849c 100644 --- a/lib/mesa/src/gallium/state_trackers/dri/dri_context.c +++ b/lib/mesa/src/gallium/state_trackers/dri/dri_context.c @@ -156,6 +156,13 @@ dri_create_context(gl_api api, const struct gl_config * visual, ctx->hud = hud_create(ctx->st->pipe, ctx->st->cso_context); } + /* Do this last. */ + if (ctx->st->start_thread && + /* the driver loader must implement this */ + screen->sPriv->dri2.backgroundCallable && + driQueryOptionb(&screen->optionCache, "mesa_glthread")) + ctx->st->start_thread(ctx->st); + *error = __DRI_CTX_ERROR_SUCCESS; return GL_TRUE; @@ -199,6 +206,9 @@ dri_unbind_context(__DRIcontext * cPriv) if (--ctx->bind_count == 0) { if (ctx->st == ctx->stapi->get_current(ctx->stapi)) { + if (ctx->st->thread_finish) + ctx->st->thread_finish(ctx->st); + /* For conformance, unbind is supposed to flush the context. * However, if we do it here we might end up flushing a partially * destroyed context. Instead, we flush in dri_make_current and @@ -222,6 +232,9 @@ dri_make_current(__DRIcontext * cPriv, struct dri_drawable *read = dri_drawable(driReadPriv); struct st_context_iface *old_st = ctx->stapi->get_current(ctx->stapi); + if (old_st && old_st->thread_finish) + old_st->thread_finish(old_st); + /* Flush the old context here so we don't have to flush on unbind() */ if (old_st && old_st != ctx->st) old_st->flush(old_st, ST_FLUSH_FRONT, NULL); diff --git a/lib/mesa/src/gallium/state_trackers/dri/dri_drawable.c b/lib/mesa/src/gallium/state_trackers/dri/dri_drawable.c index edcd0e684..3c2e30752 100644 --- a/lib/mesa/src/gallium/state_trackers/dri/dri_drawable.c +++ b/lib/mesa/src/gallium/state_trackers/dri/dri_drawable.c @@ -217,9 +217,13 @@ dri_set_tex_buffer2(__DRIcontext *pDRICtx, GLint target, GLint format, __DRIdrawable *dPriv) { struct dri_context *ctx = dri_context(pDRICtx); + struct st_context_iface *st = ctx->st; struct dri_drawable *drawable = dri_drawable(dPriv); struct pipe_resource *pt; + if (st->thread_finish) + st->thread_finish(st); + dri_drawable_validate_att(ctx, drawable, ST_ATTACHMENT_FRONT_LEFT); /* Use the pipe resource associated with the X drawable */ @@ -443,6 +447,7 @@ dri_flush(__DRIcontext *cPriv, { struct dri_context *ctx = dri_context(cPriv); struct dri_drawable *drawable = dri_drawable(dPriv); + struct st_context_iface *st; unsigned flush_flags; boolean swap_msaa_buffers = FALSE; @@ -451,6 +456,10 @@ dri_flush(__DRIcontext *cPriv, return; } + st = ctx->st; + if (st->thread_finish) + st->thread_finish(st); + if (drawable) { /* prevent recursion */ if (drawable->flushing) @@ -465,12 +474,12 @@ dri_flush(__DRIcontext *cPriv, /* Flush the drawable. */ if ((flags & __DRI2_FLUSH_DRAWABLE) && drawable->textures[ST_ATTACHMENT_BACK_LEFT]) { - struct pipe_context *pipe = ctx->st->pipe; + struct pipe_context *pipe = st->pipe; if (drawable->stvis.samples > 1 && reason == __DRI2_THROTTLE_SWAPBUFFER) { /* Resolve the MSAA back buffer. */ - dri_pipe_blit(ctx->st->pipe, + dri_pipe_blit(st->pipe, drawable->textures[ST_ATTACHMENT_BACK_LEFT], drawable->msaa_textures[ST_ATTACHMENT_BACK_LEFT]); @@ -529,7 +538,7 @@ dri_flush(__DRIcontext *cPriv, screen->fence_reference(screen, &fence, NULL); } - ctx->st->flush(ctx->st, flush_flags, &fence); + st->flush(st, flush_flags, &fence); if (fence) { swap_fences_push_back(drawable, fence); @@ -537,7 +546,7 @@ dri_flush(__DRIcontext *cPriv, } } else if (flags & (__DRI2_FLUSH_DRAWABLE | __DRI2_FLUSH_CONTEXT)) { - ctx->st->flush(ctx->st, flush_flags, NULL); + st->flush(st, flush_flags, NULL); } if (drawable) { diff --git a/lib/mesa/src/gallium/state_trackers/dri/dri_screen.c b/lib/mesa/src/gallium/state_trackers/dri/dri_screen.c index aa0ad09ce..998e8ef8c 100644 --- a/lib/mesa/src/gallium/state_trackers/dri/dri_screen.c +++ b/lib/mesa/src/gallium/state_trackers/dri/dri_screen.c @@ -33,6 +33,7 @@ #include "xmlpool.h" #include "dri_screen.h" +#include "dri_context.h" #include "util/u_inlines.h" #include "pipe/p_screen.h" @@ -53,6 +54,10 @@ const __DRIconfigOptionsExtension gallium_config_options = { .xml = DRI_CONF_BEGIN + DRI_CONF_SECTION_PERFORMANCE + DRI_CONF_MESA_GLTHREAD("false") + DRI_CONF_SECTION_END + DRI_CONF_SECTION_QUALITY DRI_CONF_FORCE_S3TC_ENABLE("false") DRI_CONF_PP_CELSHADE(0) @@ -70,6 +75,8 @@ const __DRIconfigOptionsExtension gallium_config_options = { DRI_CONF_DISABLE_SHADER_BIT_ENCODING("false") DRI_CONF_FORCE_GLSL_VERSION(0) DRI_CONF_ALLOW_GLSL_EXTENSION_DIRECTIVE_MIDSHADER("false") + DRI_CONF_ALLOW_HIGHER_COMPAT_VERSION("false") + DRI_CONF_FORCE_GLSL_ABS_SQRT("false") DRI_CONF_SECTION_END DRI_CONF_SECTION_MISCELLANEOUS @@ -82,9 +89,11 @@ const __DRIconfigOptionsExtension gallium_config_options = { #define false 0 static void -dri_fill_st_options(struct st_config_options *options, - const struct driOptionCache * optionCache) +dri_fill_st_options(struct dri_screen *screen) { + struct st_config_options *options = &screen->options; + const struct driOptionCache *optionCache = &screen->optionCache; + options->disable_blend_func_extended = driQueryOptionb(optionCache, "disable_blend_func_extended"); options->disable_glsl_line_continuations = @@ -99,7 +108,13 @@ dri_fill_st_options(struct st_config_options *options, driQueryOptionb(optionCache, "force_s3tc_enable"); options->allow_glsl_extension_directive_midshader = driQueryOptionb(optionCache, "allow_glsl_extension_directive_midshader"); + options->allow_higher_compat_version = + driQueryOptionb(optionCache, "allow_higher_compat_version"); options->glsl_zero_init = driQueryOptionb(optionCache, "glsl_zero_init"); + options->force_glsl_abs_sqrt = + driQueryOptionb(optionCache, "force_glsl_abs_sqrt"); + + driComputeOptionsSha1(optionCache, options->config_options_sha1); } static const __DRIconfig ** @@ -143,7 +158,7 @@ dri_fill_in_modes(struct dri_screen *screen) stencil_bits_array[0] = 0; depth_buffer_factor = 1; } - + msaa_samples_max = (screen->st_api->feature_mask & ST_API_FEATURE_MS_VISUALS_MASK) ? MSAA_VISUAL_MAX_SAMPLES : 1; @@ -397,7 +412,7 @@ dri_destroy_screen_helper(struct dri_screen * screen) screen->base.screen->destroy(screen->base.screen); dri_destroy_option_cache(screen); - pipe_mutex_destroy(screen->opencl_func_mutex); + mtx_destroy(&screen->opencl_func_mutex); } void @@ -425,6 +440,21 @@ dri_postprocessing_init(struct dri_screen *screen) } } +static void +dri_set_background_context(struct st_context_iface *st) +{ + struct dri_context *ctx = (struct dri_context *)st->st_manager_private; + const __DRIbackgroundCallableExtension *backgroundCallable = + ctx->sPriv->dri2.backgroundCallable; + + /* Note: Mesa will only call this function if GL multithreading is enabled + * We only do that if the loader exposed the __DRI_BACKGROUND_CALLABLE + * extension. So we know that backgroundCallable is not NULL. + */ + assert(backgroundCallable); + backgroundCallable->setBackgroundContext(ctx->cPriv->loaderPrivate); +} + const __DRIconfig ** dri_init_screen_helper(struct dri_screen *screen, struct pipe_screen *pscreen, @@ -433,6 +463,7 @@ dri_init_screen_helper(struct dri_screen *screen, screen->base.screen = pscreen; screen->base.get_egl_image = dri_get_egl_image; screen->base.get_param = dri_get_param; + screen->base.set_background_context = dri_set_background_context; screen->st_api = st_gl_api_create(); if (!screen->st_api) @@ -450,7 +481,7 @@ dri_init_screen_helper(struct dri_screen *screen, screen->sPriv->myNum, driver_name); - dri_fill_st_options(&screen->options, &screen->optionCache); + dri_fill_st_options(screen); /* Handle force_s3tc_enable. */ if (!util_format_s3tc_enabled && screen->options.force_s3tc_enable) { diff --git a/lib/mesa/src/gallium/state_trackers/dri/dri_screen.h b/lib/mesa/src/gallium/state_trackers/dri/dri_screen.h index dc4692a1c..7f5fd1363 100644 --- a/lib/mesa/src/gallium/state_trackers/dri/dri_screen.h +++ b/lib/mesa/src/gallium/state_trackers/dri/dri_screen.h @@ -89,7 +89,7 @@ struct dri_screen __DRIimage * (*lookup_egl_image)(struct dri_screen *ctx, void *handle); /* OpenCL interop */ - pipe_mutex opencl_func_mutex; + mtx_t opencl_func_mutex; opencl_dri_event_add_ref_t opencl_dri_event_add_ref; opencl_dri_event_release_t opencl_dri_event_release; opencl_dri_event_wait_t opencl_dri_event_wait; |