diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2016-05-29 10:21:21 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2016-05-29 10:21:21 +0000 |
commit | 99b70277b7a71ca729b7723c0be213c9db46702c (patch) | |
tree | 756afa5d954f14d117bad3856a5eb9d5ab1b1a0d /lib/mesa/src/gallium/auxiliary | |
parent | 3e40341f9dcd7c1bbc9afb8ddb812304820396cf (diff) |
Import Mesa 11.2.2
Diffstat (limited to 'lib/mesa/src/gallium/auxiliary')
7 files changed, 95 insertions, 140 deletions
diff --git a/lib/mesa/src/gallium/auxiliary/pipebuffer/pb_cache.c b/lib/mesa/src/gallium/auxiliary/pipebuffer/pb_cache.c index 9b75ff0c1..ebd06b0e0 100644 --- a/lib/mesa/src/gallium/auxiliary/pipebuffer/pb_cache.c +++ b/lib/mesa/src/gallium/auxiliary/pipebuffer/pb_cache.c @@ -38,23 +38,22 @@ static void destroy_buffer_locked(struct pb_cache_entry *entry) { struct pb_cache *mgr = entry->mgr; - struct pb_buffer *buf = entry->buffer; - assert(!pipe_is_referenced(&buf->reference)); + assert(!pipe_is_referenced(&entry->buffer->reference)); if (entry->head.next) { LIST_DEL(&entry->head); assert(mgr->num_buffers); --mgr->num_buffers; - mgr->cache_size -= buf->size; + mgr->cache_size -= entry->buffer->size; } - mgr->destroy_buffer(buf); + entry->mgr->destroy_buffer(entry->buffer); } /** * Free as many cache buffers from the list head as possible. */ static void -release_expired_buffers_locked(struct list_head *cache) +release_expired_buffers_locked(struct pb_cache *mgr) { struct list_head *curr, *next; struct pb_cache_entry *entry; @@ -62,9 +61,9 @@ release_expired_buffers_locked(struct list_head *cache) now = os_time_get(); - curr = cache->next; + curr = mgr->cache.next; next = curr->next; - while (curr != cache) { + while (curr != &mgr->cache) { entry = LIST_ENTRY(struct pb_cache_entry, curr, head); if (!os_time_timeout(entry->start, entry->end, now)) @@ -85,29 +84,25 @@ void pb_cache_add_buffer(struct pb_cache_entry *entry) { struct pb_cache *mgr = entry->mgr; - struct list_head *cache = &mgr->buckets[entry->bucket_index]; - struct pb_buffer *buf = entry->buffer; - unsigned i; - mtx_lock(&mgr->mutex); - assert(!pipe_is_referenced(&buf->reference)); + pipe_mutex_lock(mgr->mutex); + assert(!pipe_is_referenced(&entry->buffer->reference)); - for (i = 0; i < ARRAY_SIZE(mgr->buckets); i++) - release_expired_buffers_locked(&mgr->buckets[i]); + release_expired_buffers_locked(mgr); /* Directly release any buffer that exceeds the limit. */ - if (mgr->cache_size + buf->size > mgr->max_cache_size) { - mgr->destroy_buffer(buf); - mtx_unlock(&mgr->mutex); + if (mgr->cache_size + entry->buffer->size > mgr->max_cache_size) { + entry->mgr->destroy_buffer(entry->buffer); + pipe_mutex_unlock(mgr->mutex); return; } entry->start = os_time_get(); entry->end = entry->start + mgr->usecs; - LIST_ADDTAIL(&entry->head, cache); + LIST_ADDTAIL(&entry->head, &mgr->cache); ++mgr->num_buffers; - mgr->cache_size += buf->size; - mtx_unlock(&mgr->mutex); + mgr->cache_size += entry->buffer->size; + pipe_mutex_unlock(mgr->mutex); } /** @@ -119,24 +114,25 @@ static int pb_cache_is_buffer_compat(struct pb_cache_entry *entry, pb_size size, unsigned alignment, unsigned usage) { - struct pb_cache *mgr = entry->mgr; struct pb_buffer *buf = entry->buffer; - if (!pb_check_usage(usage, buf->usage)) + if (usage & entry->mgr->bypass_usage) return 0; - /* be lenient with size */ - if (buf->size < size || - buf->size > (unsigned) (mgr->size_factor * size)) + if (buf->size < size) return 0; - if (usage & mgr->bypass_usage) + /* be lenient with size */ + if (buf->size > (unsigned) (entry->mgr->size_factor * size)) return 0; if (!pb_check_alignment(alignment, buf->alignment)) return 0; - return mgr->can_reclaim(buf) ? 1 : -1; + if (!pb_check_usage(usage, buf->usage)) + return 0; + + return entry->mgr->can_reclaim(buf) ? 1 : -1; } /** @@ -145,25 +141,23 @@ pb_cache_is_buffer_compat(struct pb_cache_entry *entry, */ struct pb_buffer * pb_cache_reclaim_buffer(struct pb_cache *mgr, pb_size size, - unsigned alignment, unsigned usage, - unsigned bucket_index) + unsigned alignment, unsigned usage) { struct pb_cache_entry *entry; struct pb_cache_entry *cur_entry; struct list_head *cur, *next; int64_t now; int ret = 0; - struct list_head *cache = &mgr->buckets[bucket_index]; - mtx_lock(&mgr->mutex); + pipe_mutex_lock(mgr->mutex); entry = NULL; - cur = cache->next; + cur = mgr->cache.next; next = cur->next; /* search in the expired buffers, freeing them in the process */ now = os_time_get(); - while (cur != cache) { + while (cur != &mgr->cache) { cur_entry = LIST_ENTRY(struct pb_cache_entry, cur, head); if (!entry && (ret = pb_cache_is_buffer_compat(cur_entry, size, @@ -185,7 +179,7 @@ pb_cache_reclaim_buffer(struct pb_cache *mgr, pb_size size, /* keep searching in the hot buffers */ if (!entry && ret != -1) { - while (cur != cache) { + while (cur != &mgr->cache) { cur_entry = LIST_ENTRY(struct pb_cache_entry, cur, head); ret = pb_cache_is_buffer_compat(cur_entry, size, alignment, usage); @@ -208,13 +202,13 @@ pb_cache_reclaim_buffer(struct pb_cache *mgr, pb_size size, mgr->cache_size -= buf->size; LIST_DEL(&entry->head); --mgr->num_buffers; - mtx_unlock(&mgr->mutex); + pipe_mutex_unlock(mgr->mutex); /* Increase refcount */ pipe_reference_init(&buf->reference, 1); return buf; } - mtx_unlock(&mgr->mutex); + pipe_mutex_unlock(mgr->mutex); return NULL; } @@ -226,32 +220,26 @@ pb_cache_release_all_buffers(struct pb_cache *mgr) { struct list_head *curr, *next; struct pb_cache_entry *buf; - unsigned i; - mtx_lock(&mgr->mutex); - for (i = 0; i < ARRAY_SIZE(mgr->buckets); i++) { - struct list_head *cache = &mgr->buckets[i]; - - curr = cache->next; + pipe_mutex_lock(mgr->mutex); + curr = mgr->cache.next; + next = curr->next; + while (curr != &mgr->cache) { + buf = LIST_ENTRY(struct pb_cache_entry, curr, head); + destroy_buffer_locked(buf); + curr = next; next = curr->next; - while (curr != cache) { - buf = LIST_ENTRY(struct pb_cache_entry, curr, head); - destroy_buffer_locked(buf); - curr = next; - next = curr->next; - } } - mtx_unlock(&mgr->mutex); + pipe_mutex_unlock(mgr->mutex); } void pb_cache_init_entry(struct pb_cache *mgr, struct pb_cache_entry *entry, - struct pb_buffer *buf, unsigned bucket_index) + struct pb_buffer *buf) { memset(entry, 0, sizeof(*entry)); entry->buffer = buf; entry->mgr = mgr; - entry->bucket_index = bucket_index; } /** @@ -275,12 +263,8 @@ pb_cache_init(struct pb_cache *mgr, uint usecs, float size_factor, void (*destroy_buffer)(struct pb_buffer *buf), bool (*can_reclaim)(struct pb_buffer *buf)) { - unsigned i; - - for (i = 0; i < ARRAY_SIZE(mgr->buckets); i++) - LIST_INITHEAD(&mgr->buckets[i]); - - (void) mtx_init(&mgr->mutex, mtx_plain); + LIST_INITHEAD(&mgr->cache); + pipe_mutex_init(mgr->mutex); mgr->cache_size = 0; mgr->max_cache_size = maximum_cache_size; mgr->usecs = usecs; @@ -298,5 +282,5 @@ void pb_cache_deinit(struct pb_cache *mgr) { pb_cache_release_all_buffers(mgr); - mtx_destroy(&mgr->mutex); + pipe_mutex_destroy(mgr->mutex); } diff --git a/lib/mesa/src/gallium/auxiliary/pipebuffer/pb_cache.h b/lib/mesa/src/gallium/auxiliary/pipebuffer/pb_cache.h index d082eca8b..f0fa01226 100644 --- a/lib/mesa/src/gallium/auxiliary/pipebuffer/pb_cache.h +++ b/lib/mesa/src/gallium/auxiliary/pipebuffer/pb_cache.h @@ -42,17 +42,12 @@ struct pb_cache_entry struct pb_buffer *buffer; /**< Pointer to the structure this is part of. */ struct pb_cache *mgr; int64_t start, end; /**< Caching time interval */ - unsigned bucket_index; }; struct pb_cache { - /* The cache is divided into buckets for minimizing cache misses. - * The driver controls which buffer goes into which bucket. - */ - struct list_head buckets[4]; - - mtx_t mutex; + struct list_head cache; + pipe_mutex mutex; uint64_t cache_size; uint64_t max_cache_size; unsigned usecs; @@ -66,11 +61,10 @@ struct pb_cache void pb_cache_add_buffer(struct pb_cache_entry *entry); struct pb_buffer *pb_cache_reclaim_buffer(struct pb_cache *mgr, pb_size size, - unsigned alignment, unsigned usage, - unsigned bucket_index); + unsigned alignment, unsigned usage); void pb_cache_release_all_buffers(struct pb_cache *mgr); void pb_cache_init_entry(struct pb_cache *mgr, struct pb_cache_entry *entry, - struct pb_buffer *buf, unsigned bucket_index); + struct pb_buffer *buf); void pb_cache_init(struct pb_cache *mgr, uint usecs, float size_factor, unsigned bypass_usage, uint64_t maximum_cache_size, void (*destroy_buffer)(struct pb_buffer *buf), diff --git a/lib/mesa/src/gallium/auxiliary/target-helpers/drm_helper.h b/lib/mesa/src/gallium/auxiliary/target-helpers/drm_helper.h index 3159df6c5..90820d3fe 100644 --- a/lib/mesa/src/gallium/auxiliary/target-helpers/drm_helper.h +++ b/lib/mesa/src/gallium/auxiliary/target-helpers/drm_helper.h @@ -34,6 +34,35 @@ pipe_i915_create_screen(int fd) #endif +#ifdef GALLIUM_ILO +#include "intel/drm/intel_drm_public.h" +#include "ilo/ilo_public.h" + +struct pipe_screen * +pipe_ilo_create_screen(int fd) +{ + struct intel_winsys *iws; + struct pipe_screen *screen; + + iws = intel_winsys_create_for_fd(fd); + if (!iws) + return NULL; + + screen = ilo_screen_create(iws); + return screen ? debug_screen_wrap(screen) : NULL; +} + +#else + +struct pipe_screen * +pipe_ilo_create_screen(int fd) +{ + fprintf(stderr, "ilo: driver missing\n"); + return NULL; +} + +#endif + #ifdef GALLIUM_NOUVEAU #include "nouveau/drm/nouveau_drm_public.h" @@ -237,51 +266,5 @@ pipe_vc4_create_screen(int fd) #endif -#ifdef GALLIUM_ETNAVIV -#include "etnaviv/drm/etnaviv_drm_public.h" - -struct pipe_screen * -pipe_etna_create_screen(int fd) -{ - struct pipe_screen *screen; - - screen = etna_drm_screen_create(fd); - return screen ? debug_screen_wrap(screen) : NULL; -} - -#else - -struct pipe_screen * -pipe_etna_create_screen(int fd) -{ - fprintf(stderr, "etnaviv: driver missing\n"); - return NULL; -} - -#endif - -#ifdef GALLIUM_IMX -#include "imx/drm/imx_drm_public.h" - -struct pipe_screen * -pipe_imx_drm_create_screen(int fd) -{ - struct pipe_screen *screen; - - screen = imx_drm_screen_create(fd); - return screen ? debug_screen_wrap(screen) : NULL; -} - -#else - -struct pipe_screen * -pipe_imx_drm_create_screen(int fd) -{ - fprintf(stderr, "imx-drm: driver missing\n"); - return NULL; -} - -#endif - #endif /* DRM_HELPER_H */ diff --git a/lib/mesa/src/gallium/auxiliary/target-helpers/drm_helper_public.h b/lib/mesa/src/gallium/auxiliary/target-helpers/drm_helper_public.h index bc12b2155..d1f9382a6 100644 --- a/lib/mesa/src/gallium/auxiliary/target-helpers/drm_helper_public.h +++ b/lib/mesa/src/gallium/auxiliary/target-helpers/drm_helper_public.h @@ -34,10 +34,4 @@ pipe_virgl_create_screen(int fd); struct pipe_screen * pipe_vc4_create_screen(int fd); -struct pipe_screen * -pipe_etna_create_screen(int fd); - -struct pipe_screen * -pipe_imx_drm_create_screen(int fd); - #endif /* _DRM_HELPER_PUBLIC_H */ diff --git a/lib/mesa/src/gallium/auxiliary/tgsi/tgsi_aa_point.c b/lib/mesa/src/gallium/auxiliary/tgsi/tgsi_aa_point.c index 4b14a2fc9..9016effd3 100644 --- a/lib/mesa/src/gallium/auxiliary/tgsi/tgsi_aa_point.c +++ b/lib/mesa/src/gallium/auxiliary/tgsi/tgsi_aa_point.c @@ -148,16 +148,16 @@ aa_prolog(struct tgsi_transform_context *ctx) tmp0 = ts->tmp; /* SUB t0.xy, texIn, (0.5, 0,5) */ - tgsi_transform_op2_inst(ctx, TGSI_OPCODE_ADD, + tgsi_transform_op2_inst(ctx, TGSI_OPCODE_SUB, TGSI_FILE_TEMPORARY, tmp0, TGSI_WRITEMASK_XY, TGSI_FILE_INPUT, texIn, - TGSI_FILE_IMMEDIATE, imm, true); + TGSI_FILE_IMMEDIATE, imm); /* DP2 t0.x, t0.xy, t0.xy; # t0.x = x^2 + y^2 */ tgsi_transform_op2_inst(ctx, TGSI_OPCODE_DP2, TGSI_FILE_TEMPORARY, tmp0, TGSI_WRITEMASK_X, TGSI_FILE_TEMPORARY, tmp0, - TGSI_FILE_TEMPORARY, tmp0, false); + TGSI_FILE_TEMPORARY, tmp0); /* SQRT t0.x, t0.x */ tgsi_transform_op1_inst(ctx, TGSI_OPCODE_SQRT, @@ -167,22 +167,22 @@ aa_prolog(struct tgsi_transform_context *ctx) /* compute coverage factor = (0.5-d)/(0.5-k) */ /* SUB t0.w, 0.5, texIn.z; # t0.w = 0.5-k */ - tgsi_transform_op2_swz_inst(ctx, TGSI_OPCODE_ADD, + tgsi_transform_op2_swz_inst(ctx, TGSI_OPCODE_SUB, TGSI_FILE_TEMPORARY, tmp0, TGSI_WRITEMASK_W, TGSI_FILE_IMMEDIATE, imm, TGSI_SWIZZLE_X, - TGSI_FILE_INPUT, texIn, TGSI_SWIZZLE_Z, true); + TGSI_FILE_INPUT, texIn, TGSI_SWIZZLE_Z); /* SUB t0.y, 0.5, t0.x; # t0.y = 0.5-d */ - tgsi_transform_op2_swz_inst(ctx, TGSI_OPCODE_ADD, + tgsi_transform_op2_swz_inst(ctx, TGSI_OPCODE_SUB, TGSI_FILE_TEMPORARY, tmp0, TGSI_WRITEMASK_Y, TGSI_FILE_IMMEDIATE, imm, TGSI_SWIZZLE_X, - TGSI_FILE_TEMPORARY, tmp0, TGSI_SWIZZLE_X, true); + TGSI_FILE_TEMPORARY, tmp0, TGSI_SWIZZLE_X); /* DIV t0.w, t0.y, t0.w; # coverage = (0.5-d)/(0.5-k) */ tgsi_transform_op2_swz_inst(ctx, TGSI_OPCODE_DIV, TGSI_FILE_TEMPORARY, tmp0, TGSI_WRITEMASK_W, TGSI_FILE_TEMPORARY, tmp0, TGSI_SWIZZLE_Y, - TGSI_FILE_TEMPORARY, tmp0, TGSI_SWIZZLE_W, false); + TGSI_FILE_TEMPORARY, tmp0, TGSI_SWIZZLE_W); /* If the coverage value is negative, it means the fragment is outside * the point's circular boundary. Kill it. @@ -198,7 +198,7 @@ aa_prolog(struct tgsi_transform_context *ctx) tgsi_transform_op2_swz_inst(ctx, TGSI_OPCODE_MIN, TGSI_FILE_TEMPORARY, tmp0, TGSI_WRITEMASK_W, TGSI_FILE_TEMPORARY, tmp0, TGSI_SWIZZLE_W, - TGSI_FILE_IMMEDIATE, imm, TGSI_SWIZZLE_W, false); + TGSI_FILE_IMMEDIATE, imm, TGSI_SWIZZLE_W); } /** @@ -249,7 +249,7 @@ aa_epilog(struct tgsi_transform_context *ctx) TGSI_FILE_OUTPUT, ts->color_out, TGSI_WRITEMASK_W, TGSI_FILE_TEMPORARY, ts->color_tmp, - TGSI_FILE_TEMPORARY, ts->tmp, false); + TGSI_FILE_TEMPORARY, ts->tmp); } /** diff --git a/lib/mesa/src/gallium/auxiliary/tgsi/tgsi_point_sprite.c b/lib/mesa/src/gallium/auxiliary/tgsi/tgsi_point_sprite.c index f60a17c78..cb8dbcb29 100644 --- a/lib/mesa/src/gallium/auxiliary/tgsi/tgsi_point_sprite.c +++ b/lib/mesa/src/gallium/auxiliary/tgsi/tgsi_point_sprite.c @@ -96,7 +96,7 @@ struct psprite_transform_context unsigned stream_out_point_pos:1; // set if to stream out original point pos unsigned aa_point:1; // set if doing aa point unsigned out_tmp_index[PIPE_MAX_SHADER_OUTPUTS]; - int max_generic; // max generic semantic index + int max_generic; }; static inline struct psprite_transform_context * @@ -133,7 +133,7 @@ psprite_decl(struct tgsi_transform_context *ctx, else if (decl->Semantic.Name == TGSI_SEMANTIC_GENERIC && decl->Semantic.Index < 32) { ts->point_coord_decl |= 1 << decl->Semantic.Index; - ts->max_generic = MAX2(ts->max_generic, (int)decl->Semantic.Index); + ts->max_generic = MAX2(ts->max_generic, decl->Semantic.Index); } ts->num_out = MAX2(ts->num_out, decl->Range.Last + 1); } @@ -216,7 +216,7 @@ psprite_prolog(struct tgsi_transform_context *ctx) if (en & 0x1) { tgsi_transform_output_decl(ctx, ts->num_out++, TGSI_SEMANTIC_GENERIC, i, 0); - ts->max_generic = MAX2(ts->max_generic, (int)i); + ts->max_generic = MAX2(ts->max_generic, i); } } } @@ -295,7 +295,7 @@ psprite_emit_vertex_inst(struct tgsi_transform_context *ctx, tgsi_transform_op2_swz_inst(ctx, TGSI_OPCODE_MUL, TGSI_FILE_TEMPORARY, ts->point_scale_tmp, TGSI_WRITEMASK_X, TGSI_FILE_TEMPORARY, ts->point_size_tmp, TGSI_SWIZZLE_X, - TGSI_FILE_TEMPORARY, ts->point_pos_tmp, TGSI_SWIZZLE_W, false); + TGSI_FILE_TEMPORARY, ts->point_pos_tmp, TGSI_SWIZZLE_W); /* MUL point_scale.xy, point_scale.xx, inverseViewport.xy */ inst = tgsi_default_full_instruction(); @@ -323,15 +323,15 @@ psprite_emit_vertex_inst(struct tgsi_transform_context *ctx, TGSI_FILE_IMMEDIATE, ts->point_imm, TGSI_SWIZZLE_Y, TGSI_FILE_TEMPORARY, ts->point_size_tmp, - TGSI_SWIZZLE_X, false); + TGSI_SWIZZLE_X); - tgsi_transform_op2_swz_inst(ctx, TGSI_OPCODE_ADD, + tgsi_transform_op2_swz_inst(ctx, TGSI_OPCODE_SUB, TGSI_FILE_TEMPORARY, ts->point_coord_k, TGSI_WRITEMASK_X, TGSI_FILE_IMMEDIATE, ts->point_imm, TGSI_SWIZZLE_Z, TGSI_FILE_TEMPORARY, ts->point_coord_k, - TGSI_SWIZZLE_X, true); + TGSI_SWIZZLE_X); } @@ -442,13 +442,13 @@ psprite_inst(struct tgsi_transform_context *ctx, tgsi_transform_op2_swz_inst(ctx, TGSI_OPCODE_MAX, TGSI_FILE_TEMPORARY, ts->point_size_tmp, TGSI_WRITEMASK_X, TGSI_FILE_TEMPORARY, ts->point_size_tmp, TGSI_SWIZZLE_X, - TGSI_FILE_IMMEDIATE, ts->point_imm, TGSI_SWIZZLE_Y, false); + TGSI_FILE_IMMEDIATE, ts->point_imm, TGSI_SWIZZLE_Y); /* MIN point_size_tmp.x, point_size_tmp.x, point_ivp.w */ tgsi_transform_op2_swz_inst(ctx, TGSI_OPCODE_MIN, TGSI_FILE_TEMPORARY, ts->point_size_tmp, TGSI_WRITEMASK_X, TGSI_FILE_TEMPORARY, ts->point_size_tmp, TGSI_SWIZZLE_X, - TGSI_FILE_CONSTANT, ts->point_ivp, TGSI_SWIZZLE_W, false); + TGSI_FILE_CONSTANT, ts->point_ivp, TGSI_SWIZZLE_W); } else if (inst->Dst[0].Register.File == TGSI_FILE_OUTPUT && inst->Dst[0].Register.Index == ts->point_pos_out) { diff --git a/lib/mesa/src/gallium/auxiliary/util/u_prim_restart.c b/lib/mesa/src/gallium/auxiliary/util/u_prim_restart.c index e45aa562a..a4d7c1433 100644 --- a/lib/mesa/src/gallium/auxiliary/util/u_prim_restart.c +++ b/lib/mesa/src/gallium/auxiliary/util/u_prim_restart.c @@ -117,7 +117,7 @@ error: if (dst_transfer) pipe_buffer_unmap(context, dst_transfer); if (*dst_buffer) - pipe_resource_reference(dst_buffer, NULL); + screen->resource_destroy(screen, *dst_buffer); return PIPE_ERROR_OUT_OF_MEMORY; } |