diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2020-09-03 07:17:28 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2020-09-03 07:17:28 +0000 |
commit | b0915d54037185ab191fbbbd1973f7de15b1be68 (patch) | |
tree | 90f2287f1fc5f927663b0bd10f75062b01ace42e /lib/mesa/src/gallium | |
parent | 53d4023d5d022dee9188af50de693343e5ab3842 (diff) |
Merge Mesa 20.1.7
Diffstat (limited to 'lib/mesa/src/gallium')
12 files changed, 84 insertions, 54 deletions
diff --git a/lib/mesa/src/gallium/auxiliary/gallivm/lp_bld_init.c b/lib/mesa/src/gallium/auxiliary/gallivm/lp_bld_init.c index e3fd26cd2..077b65da9 100644 --- a/lib/mesa/src/gallium/auxiliary/gallivm/lp_bld_init.c +++ b/lib/mesa/src/gallium/auxiliary/gallivm/lp_bld_init.c @@ -169,7 +169,9 @@ create_pass_manager(struct gallivm_state *gallivm) */ LLVMAddReassociatePass(gallivm->passmgr); LLVMAddPromoteMemoryToRegisterPass(gallivm->passmgr); +#if LLVM_VERSION_MAJOR <= 11 LLVMAddConstantPropagationPass(gallivm->passmgr); +#endif LLVMAddInstructionCombiningPass(gallivm->passmgr); LLVMAddGVNPass(gallivm->passmgr); } diff --git a/lib/mesa/src/gallium/docs/source/screen.rst b/lib/mesa/src/gallium/docs/source/screen.rst index bf8d8c75d..1c4a345c9 100644 --- a/lib/mesa/src/gallium/docs/source/screen.rst +++ b/lib/mesa/src/gallium/docs/source/screen.rst @@ -581,6 +581,7 @@ The integer capabilities: * ``PIPE_CAP_SYSTEM_SVM``: True if all application memory can be shared with the GPU without explicit mapping. * ``PIPE_CAP_VIEWPORT_MASK``: Whether ``TGSI_SEMANTIC_VIEWPORT_MASK`` and ``TGSI_PROPERTY_LAYER_VIEWPORT_RELATIVE`` are supported (see GL_NV_viewport_array2). * ``PIPE_CAP_MAP_UNSYNCHRONIZED_THREAD_SAFE``: Whether mapping a buffer as unsynchronized from any thread is safe. +* ``PIPE_CAP_NO_CLIP_ON_COPY_TEX``: Driver doesn't want x/y/width/height clipped based on src size when doing a copy texture operation (eg: may want out-of-bounds reads that produce 0 instead of leaving the texture content undefined) .. _pipe_capf: diff --git a/lib/mesa/src/gallium/drivers/etnaviv/etnaviv_context.c b/lib/mesa/src/gallium/drivers/etnaviv/etnaviv_context.c index 34698ce56..832cecbf6 100644 --- a/lib/mesa/src/gallium/drivers/etnaviv/etnaviv_context.c +++ b/lib/mesa/src/gallium/drivers/etnaviv/etnaviv_context.c @@ -93,6 +93,7 @@ etna_context_destroy(struct pipe_context *pctx) struct etna_context *ctx = etna_context(pctx); mtx_lock(&ctx->lock); + if (ctx->used_resources_read) { /* @@ -103,7 +104,9 @@ etna_context_destroy(struct pipe_context *pctx) set_foreach(ctx->used_resources_read, entry) { struct etna_resource *rsc = (struct etna_resource *)entry->key; + mtx_lock(&rsc->lock); _mesa_set_remove_key(rsc->pending_ctx, ctx); + mtx_unlock(&rsc->lock); } _mesa_set_destroy(ctx->used_resources_read, NULL); @@ -118,7 +121,9 @@ etna_context_destroy(struct pipe_context *pctx) set_foreach(ctx->used_resources_write, entry) { struct etna_resource *rsc = (struct etna_resource *)entry->key; + mtx_lock(&rsc->lock); _mesa_set_remove_key(rsc->pending_ctx, ctx); + mtx_unlock(&rsc->lock); } _mesa_set_destroy(ctx->used_resources_write, NULL); @@ -487,12 +492,16 @@ etna_flush(struct pipe_context *pctx, struct pipe_fence_handle **fence, struct etna_resource *rsc = (struct etna_resource *)entry->key; struct pipe_resource *referenced = &rsc->base; + mtx_lock(&rsc->lock); + _mesa_set_remove_key(rsc->pending_ctx, ctx); /* if resource has no pending ctx's reset its status */ if (_mesa_set_next_entry(rsc->pending_ctx, NULL) == NULL) rsc->status &= ~ETNA_PENDING_READ; + mtx_unlock(&rsc->lock); + pipe_resource_reference(&referenced, NULL); } _mesa_set_clear(ctx->used_resources_read, NULL); @@ -501,11 +510,13 @@ etna_flush(struct pipe_context *pctx, struct pipe_fence_handle **fence, struct etna_resource *rsc = (struct etna_resource *)entry->key; struct pipe_resource *referenced = &rsc->base; + mtx_lock(&rsc->lock); _mesa_set_remove_key(rsc->pending_ctx, ctx); /* if resource has no pending ctx's reset its status */ if (_mesa_set_next_entry(rsc->pending_ctx, NULL) == NULL) rsc->status &= ~ETNA_PENDING_WRITE; + mtx_unlock(&rsc->lock); pipe_resource_reference(&referenced, NULL); } diff --git a/lib/mesa/src/gallium/drivers/etnaviv/etnaviv_resource.c b/lib/mesa/src/gallium/drivers/etnaviv/etnaviv_resource.c index 4a992b5f6..e2ef97f28 100644 --- a/lib/mesa/src/gallium/drivers/etnaviv/etnaviv_resource.c +++ b/lib/mesa/src/gallium/drivers/etnaviv/etnaviv_resource.c @@ -321,6 +321,7 @@ etna_resource_alloc(struct pipe_screen *pscreen, unsigned layout, memset(map, 0, size); } + mtx_init(&rsc->lock, mtx_recursive); rsc->pending_ctx = _mesa_set_create(NULL, _mesa_hash_pointer, _mesa_key_pointer_equal); if (!rsc->pending_ctx) @@ -463,8 +464,10 @@ etna_resource_destroy(struct pipe_screen *pscreen, struct pipe_resource *prsc) { struct etna_resource *rsc = etna_resource(prsc); + mtx_lock(&rsc->lock); assert(!_mesa_set_next_entry(rsc->pending_ctx, NULL)); _mesa_set_destroy(rsc->pending_ctx, NULL); + mtx_unlock(&rsc->lock); if (rsc->bo) etna_bo_del(rsc->bo); @@ -483,6 +486,8 @@ etna_resource_destroy(struct pipe_screen *pscreen, struct pipe_resource *prsc) for (unsigned i = 0; i < ETNA_NUM_LOD; i++) FREE(rsc->levels[i].patch_offsets); + mtx_destroy(&rsc->lock); + FREE(rsc); } @@ -559,6 +564,7 @@ etna_resource_from_handle(struct pipe_screen *pscreen, goto fail; } + mtx_init(&rsc->lock, mtx_recursive); rsc->pending_ctx = _mesa_set_create(NULL, _mesa_hash_pointer, _mesa_key_pointer_equal); if (!rsc->pending_ctx) @@ -603,34 +609,6 @@ etna_resource_get_handle(struct pipe_screen *pscreen, } } -enum etna_resource_status -etna_resource_get_status(struct etna_context *ctx, struct etna_resource *rsc) -{ - enum etna_resource_status newstatus = 0; - - set_foreach(rsc->pending_ctx, entry) { - struct etna_context *extctx = (struct etna_context *)entry->key; - - set_foreach(extctx->used_resources_read, entry2) { - struct etna_resource *rsc2 = (struct etna_resource *)entry2->key; - if (ctx == extctx || rsc2 != rsc) - continue; - - newstatus |= ETNA_PENDING_READ; - } - - set_foreach(extctx->used_resources_write, entry2) { - struct etna_resource *rsc2 = (struct etna_resource *)entry2->key; - if (ctx == extctx || rsc2 != rsc) - continue; - - newstatus |= ETNA_PENDING_WRITE; - } - } - - return newstatus; -} - void etna_resource_used(struct etna_context *ctx, struct pipe_resource *prsc, enum etna_resource_status status) @@ -644,18 +622,41 @@ etna_resource_used(struct etna_context *ctx, struct pipe_resource *prsc, mtx_lock(&ctx->lock); rsc = etna_resource(prsc); +again: + mtx_lock(&rsc->lock); set_foreach(rsc->pending_ctx, entry) { struct etna_context *extctx = (struct etna_context *)entry->key; struct pipe_context *pctx = &extctx->base; + bool need_flush = false; + + if (mtx_trylock(&extctx->lock) != thrd_success) { + /* + * The other context could be locked in etna_flush() and + * stuck waiting for the resource lock, so release the + * resource lock here, let etna_flush() finish, and try + * again. + */ + mtx_unlock(&rsc->lock); + thrd_yield(); + goto again; + } set_foreach(extctx->used_resources_read, entry2) { struct etna_resource *rsc2 = (struct etna_resource *)entry2->key; if (ctx == extctx || rsc2 != rsc) continue; - if (status & ETNA_PENDING_WRITE) - pctx->flush(pctx, NULL, 0); + if (status & ETNA_PENDING_WRITE) { + need_flush = true; + break; + } + } + + if (need_flush) { + pctx->flush(pctx, NULL, 0); + mtx_unlock(&extctx->lock); + continue; } set_foreach(extctx->used_resources_write, entry2) { @@ -663,8 +664,14 @@ etna_resource_used(struct etna_context *ctx, struct pipe_resource *prsc, if (ctx == extctx || rsc2 != rsc) continue; - pctx->flush(pctx, NULL, 0); + need_flush = true; + break; } + + if (need_flush) + pctx->flush(pctx, NULL, 0); + + mtx_unlock(&extctx->lock); } rsc->status = status; @@ -676,6 +683,7 @@ etna_resource_used(struct etna_context *ctx, struct pipe_resource *prsc, _mesa_set_add(rsc->pending_ctx, ctx); } + mtx_unlock(&rsc->lock); mtx_unlock(&ctx->lock); } diff --git a/lib/mesa/src/gallium/drivers/etnaviv/etnaviv_resource.h b/lib/mesa/src/gallium/drivers/etnaviv/etnaviv_resource.h index 1da0315ab..cb83e891d 100644 --- a/lib/mesa/src/gallium/drivers/etnaviv/etnaviv_resource.h +++ b/lib/mesa/src/gallium/drivers/etnaviv/etnaviv_resource.h @@ -96,6 +96,7 @@ struct etna_resource { enum etna_resource_status status; + mtx_t lock; /* Lock to protect pending_ctx */ struct set *pending_ctx; }; @@ -150,9 +151,6 @@ etna_resource(struct pipe_resource *p) return (struct etna_resource *)p; } -enum etna_resource_status -etna_resource_get_status(struct etna_context *ctx, struct etna_resource *rsc); - void etna_resource_used(struct etna_context *ctx, struct pipe_resource *prsc, enum etna_resource_status status); diff --git a/lib/mesa/src/gallium/drivers/etnaviv/etnaviv_transfer.c b/lib/mesa/src/gallium/drivers/etnaviv/etnaviv_transfer.c index 0d0324ec0..27f3ebe58 100644 --- a/lib/mesa/src/gallium/drivers/etnaviv/etnaviv_transfer.c +++ b/lib/mesa/src/gallium/drivers/etnaviv/etnaviv_transfer.c @@ -391,12 +391,14 @@ etna_transfer_map(struct pipe_context *pctx, struct pipe_resource *prsc, (!trans->rsc && (((usage & PIPE_TRANSFER_READ) && (rsc->status & ETNA_PENDING_WRITE)) || ((usage & PIPE_TRANSFER_WRITE) && rsc->status)))) { + mtx_lock(&rsc->lock); set_foreach(rsc->pending_ctx, entry) { struct etna_context *pend_ctx = (struct etna_context *)entry->key; struct pipe_context *pend_pctx = &pend_ctx->base; pend_pctx->flush(pend_pctx, NULL, 0); } + mtx_unlock(&rsc->lock); } mtx_unlock(&ctx->lock); diff --git a/lib/mesa/src/gallium/drivers/freedreno/freedreno_resource.c b/lib/mesa/src/gallium/drivers/freedreno/freedreno_resource.c index c9e408fe9..e6016189e 100644 --- a/lib/mesa/src/gallium/drivers/freedreno/freedreno_resource.c +++ b/lib/mesa/src/gallium/drivers/freedreno/freedreno_resource.c @@ -216,6 +216,9 @@ do_blit(struct fd_context *ctx, const struct pipe_blit_info *blit, bool fallback } } +static void +flush_resource(struct fd_context *ctx, struct fd_resource *rsc, unsigned usage); + /** * @rsc: the resource to shadow * @level: the level to discard (if box != NULL, otherwise ignored) @@ -233,6 +236,21 @@ fd_try_shadow_resource(struct fd_context *ctx, struct fd_resource *rsc, if (prsc->next) return false; + /* If you have a sequence where there is a single rsc associated + * with the current render target, and then you end up shadowing + * that same rsc on the 3d pipe (u_blitter), because of how we + * swap the new shadow and rsc before the back-blit, you could end + * up confusing things into thinking that u_blitter's framebuffer + * state is the same as the current framebuffer state, which has + * the result of blitting to rsc rather than shadow. + * + * Normally we wouldn't want to unconditionally trigger a flush, + * since that defeats the purpose of shadowing, but this is a + * case where we'd have to flush anyways. + */ + if (rsc->write_batch == ctx->batch) + flush_resource(ctx, rsc, 0); + /* TODO: somehow munge dimensions and format to copy unsupported * render target format to something that is supported? */ diff --git a/lib/mesa/src/gallium/drivers/radeonsi/si_pipe.c b/lib/mesa/src/gallium/drivers/radeonsi/si_pipe.c index e0420934c..81614cbfb 100644 --- a/lib/mesa/src/gallium/drivers/radeonsi/si_pipe.c +++ b/lib/mesa/src/gallium/drivers/radeonsi/si_pipe.c @@ -885,7 +885,7 @@ static void si_disk_cache_create(struct si_screen *sscreen) disk_cache_format_hex_id(cache_id, sha1, 20 * 2); /* These flags affect shader compilation. */ -#define ALL_FLAGS (DBG(GISEL)) +#define ALL_FLAGS (DBG(GISEL) | DBG(CLAMP_DIV_BY_ZERO)) uint64_t shader_debug_flags = sscreen->debug_flags & ALL_FLAGS; /* Add the high bits of 32-bit addresses, which affects @@ -1002,6 +1002,9 @@ static struct pipe_screen *radeonsi_screen_create_impl(struct radeon_winsys *ws, #include "si_debug_options.h" } + if (sscreen->options.clamp_div_by_zero) + sscreen->debug_flags |= DBG(CLAMP_DIV_BY_ZERO); + si_disk_cache_create(sscreen); /* Determine the number of shader compiler threads. */ diff --git a/lib/mesa/src/gallium/drivers/radeonsi/si_pipe.h b/lib/mesa/src/gallium/drivers/radeonsi/si_pipe.h index de4f0e342..2b576a8fe 100644 --- a/lib/mesa/src/gallium/drivers/radeonsi/si_pipe.h +++ b/lib/mesa/src/gallium/drivers/radeonsi/si_pipe.h @@ -159,6 +159,7 @@ enum DBG_W64_GE, DBG_W64_PS, DBG_W64_CS, + DBG_CLAMP_DIV_BY_ZERO, /* Shader compiler options (with no effect on the shader cache): */ DBG_CHECK_IR, diff --git a/lib/mesa/src/gallium/include/pipe/p_defines.h b/lib/mesa/src/gallium/include/pipe/p_defines.h index dd0c7331b..9ab7fe63d 100644 --- a/lib/mesa/src/gallium/include/pipe/p_defines.h +++ b/lib/mesa/src/gallium/include/pipe/p_defines.h @@ -947,6 +947,7 @@ enum pipe_cap PIPE_CAP_VIEWPORT_MASK, PIPE_CAP_ALPHA_TO_COVERAGE_DITHER_CONTROL, PIPE_CAP_MAP_UNSYNCHRONIZED_THREAD_SAFE, + PIPE_CAP_NO_CLIP_ON_COPY_TEX, }; /** diff --git a/lib/mesa/src/gallium/state_trackers/clover/llvm/invocation.cpp b/lib/mesa/src/gallium/state_trackers/clover/llvm/invocation.cpp index 95a9d0366..bedba9fa5 100644 --- a/lib/mesa/src/gallium/state_trackers/clover/llvm/invocation.cpp +++ b/lib/mesa/src/gallium/state_trackers/clover/llvm/invocation.cpp @@ -439,11 +439,6 @@ clover::llvm::compile_to_spirv(const std::string &source, debug::log(".ll", print_module_bitcode(*mod)); std::string error_msg; - if (!::llvm::regularizeLlvmForSpirv(mod.get(), error_msg)) { - r_log += "Failed to regularize LLVM IR for SPIR-V: " + error_msg + ".\n"; - throw error(CL_INVALID_VALUE); - } - std::ostringstream os; if (!::llvm::writeSpirv(mod.get(), os, error_msg)) { r_log += "Translation from LLVM IR to SPIR-V failed: " + error_msg + ".\n"; diff --git a/lib/mesa/src/gallium/state_trackers/dri/dri2.c b/lib/mesa/src/gallium/state_trackers/dri/dri2.c index ec78d0985..d2032dc1e 100644 --- a/lib/mesa/src/gallium/state_trackers/dri/dri2.c +++ b/lib/mesa/src/gallium/state_trackers/dri/dri2.c @@ -868,7 +868,7 @@ dri2_get_modifier_num_planes(uint64_t modifier, int fourcc) case I915_FORMAT_MOD_X_TILED: case I915_FORMAT_MOD_Y_TILED: case DRM_FORMAT_MOD_INVALID: - return map->nplanes; + return util_format_get_num_planes(map->pipe_format); default: return 0; } @@ -885,24 +885,14 @@ dri2_create_image_from_fd(__DRIscreen *_screen, const struct dri2_format_mapping *map = dri2_get_mapping_by_fourcc(fourcc); __DRIimage *img = NULL; unsigned err = __DRI_IMAGE_ERROR_SUCCESS; - int i, expected_num_fds; - int num_handles = dri2_get_modifier_num_planes(modifier, fourcc); + int i; + const int expected_num_fds = dri2_get_modifier_num_planes(modifier, fourcc); - if (!map || num_handles == 0) { + if (!map || expected_num_fds == 0) { err = __DRI_IMAGE_ERROR_BAD_MATCH; goto exit; } - switch (fourcc) { - case DRM_FORMAT_YUYV: - case DRM_FORMAT_UYVY: - expected_num_fds = 1; - break; - default: - expected_num_fds = num_handles; - break; - } - if (num_fds != expected_num_fds) { err = __DRI_IMAGE_ERROR_BAD_MATCH; goto exit; |