diff options
Diffstat (limited to 'src')
56 files changed, 457 insertions, 1174 deletions
diff --git a/src/gallium/auxiliary/Makefile b/src/gallium/auxiliary/Makefile index 425576db83..5fa51dcff5 100644 --- a/src/gallium/auxiliary/Makefile +++ b/src/gallium/auxiliary/Makefile @@ -54,16 +54,16 @@ C_SOURCES = \ os/os_stream_str.c \ os/os_stream_null.c \ os/os_time.c \ -# pipebuffer/pb_buffer_fenced.c \ -# pipebuffer/pb_buffer_malloc.c \ -# pipebuffer/pb_bufmgr_alt.c \ -# pipebuffer/pb_bufmgr_cache.c \ -# pipebuffer/pb_bufmgr_debug.c \ -# pipebuffer/pb_bufmgr_mm.c \ -# pipebuffer/pb_bufmgr_ondemand.c \ -# pipebuffer/pb_bufmgr_pool.c \ -# pipebuffer/pb_bufmgr_slab.c \ -# pipebuffer/pb_validate.c \ + pipebuffer/pb_buffer_fenced.c \ + pipebuffer/pb_buffer_malloc.c \ + pipebuffer/pb_bufmgr_alt.c \ + pipebuffer/pb_bufmgr_cache.c \ + pipebuffer/pb_bufmgr_debug.c \ + pipebuffer/pb_bufmgr_mm.c \ + pipebuffer/pb_bufmgr_ondemand.c \ + pipebuffer/pb_bufmgr_pool.c \ + pipebuffer/pb_bufmgr_slab.c \ + pipebuffer/pb_validate.c \ rbug/rbug_connection.c \ rbug/rbug_core.c \ rbug/rbug_texture.c \ @@ -125,9 +125,7 @@ C_SOURCES = \ util/u_surface.c \ util/u_texture.c \ util/u_tile.c \ - util/u_timed_winsys.c \ util/u_upload_mgr.c \ - util/u_simple_screen.c # Disabling until pipe-video branch gets merged in #vl/vl_bitstream_parser.c \ #vl/vl_mpeg12_mc_renderer.c \ diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c index 648ba10a99..f92702fbe9 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.c +++ b/src/gallium/auxiliary/cso_cache/cso_context.c @@ -71,7 +71,7 @@ struct cso_context { unsigned nr_vertex_samplers_saved; void *vertex_samplers_saved[PIPE_MAX_VERTEX_SAMPLERS]; - struct pipe_texture *textures[PIPE_MAX_SAMPLERS]; + struct pipe_resource *textures[PIPE_MAX_SAMPLERS]; uint nr_fragment_sampler_views; struct pipe_sampler_view *fragment_sampler_views[PIPE_MAX_SAMPLERS]; uint nr_textures; @@ -80,7 +80,7 @@ struct cso_context { struct pipe_sampler_view *vertex_sampler_views[PIPE_MAX_VERTEX_SAMPLERS]; uint nr_textures_saved; - struct pipe_texture *textures_saved[PIPE_MAX_SAMPLERS]; + struct pipe_resource *textures_saved[PIPE_MAX_SAMPLERS]; uint nr_fragment_sampler_views_saved; struct pipe_sampler_view *fragment_sampler_views_saved[PIPE_MAX_SAMPLERS]; @@ -299,8 +299,8 @@ void cso_release_all( struct cso_context *ctx ) } for (i = 0; i < PIPE_MAX_SAMPLERS; i++) { - pipe_texture_reference(&ctx->textures[i], NULL); - pipe_texture_reference(&ctx->textures_saved[i], NULL); + pipe_resource_reference(&ctx->textures[i], NULL); + pipe_resource_reference(&ctx->textures_saved[i], NULL); pipe_sampler_view_reference(&ctx->fragment_sampler_views[i], NULL); pipe_sampler_view_reference(&ctx->fragment_sampler_views_saved[i], NULL); } @@ -626,7 +626,7 @@ cso_restore_vertex_samplers(struct cso_context *ctx) enum pipe_error cso_set_sampler_textures( struct cso_context *ctx, uint count, - struct pipe_texture **textures ) + struct pipe_resource **textures ) { uint i; diff --git a/src/gallium/auxiliary/cso_cache/cso_context.h b/src/gallium/auxiliary/cso_cache/cso_context.h index a24077e009..18c2e43588 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.h +++ b/src/gallium/auxiliary/cso_cache/cso_context.h @@ -106,7 +106,7 @@ cso_single_vertex_sampler_done(struct cso_context *cso); enum pipe_error cso_set_sampler_textures( struct cso_context *cso, uint count, - struct pipe_texture **textures ); + struct pipe_resource **textures ); void cso_save_sampler_textures( struct cso_context *cso ); void cso_restore_sampler_textures( struct cso_context *cso ); diff --git a/src/gallium/auxiliary/draw/draw_pipe_aaline.c b/src/gallium/auxiliary/draw/draw_pipe_aaline.c index a715eb230f..ff29fe7456 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_aaline.c +++ b/src/gallium/auxiliary/draw/draw_pipe_aaline.c @@ -88,7 +88,7 @@ struct aaline_stage uint pos_slot; void *sampler_cso; - struct pipe_texture *texture; + struct pipe_resource *texture; struct pipe_sampler_view *sampler_view; uint num_samplers; uint num_sampler_views; @@ -753,7 +753,7 @@ aaline_destroy(struct draw_stage *stage) aaline->pipe->delete_sampler_state(aaline->pipe, aaline->sampler_cso); if (aaline->texture) - pipe_texture_reference(&aaline->texture, NULL); + pipe_resource_reference(&aaline->texture, NULL); if (aaline->sampler_view) { pipe_sampler_view_reference(&aaline->sampler_view, NULL); diff --git a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c index 2436ce373b..bd433deeca 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c +++ b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c @@ -75,7 +75,7 @@ struct pstip_stage struct draw_stage stage; void *sampler_cso; - struct pipe_texture *texture; + struct pipe_resource *texture; struct pipe_sampler_view *sampler_view; uint num_samplers; uint num_sampler_views; @@ -426,7 +426,7 @@ pstip_create_texture(struct pstip_stage *pstip) { struct pipe_context *pipe = pstip->pipe; struct pipe_screen *screen = pipe->screen; - struct pipe_texture texTemp; + struct pipe_resource texTemp; struct pipe_sampler_view viewTempl; memset(&texTemp, 0, sizeof(texTemp)); @@ -591,7 +591,7 @@ pstip_destroy(struct draw_stage *stage) pstip->pipe->delete_sampler_state(pstip->pipe, pstip->sampler_cso); - pipe_texture_reference(&pstip->texture, NULL); + pipe_resource_reference(&pstip->texture, NULL); if (pstip->sampler_view) { pipe_sampler_view_reference(&pstip->sampler_view, NULL); diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer.h b/src/gallium/auxiliary/pipebuffer/pb_buffer.h index c4c9577c7c..a6c50dcf0c 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_buffer.h +++ b/src/gallium/auxiliary/pipebuffer/pb_buffer.h @@ -48,7 +48,6 @@ #include "util/u_debug.h" #include "util/u_inlines.h" #include "pipe/p_defines.h" -#include "pipe/p_state.h" #ifdef __cplusplus @@ -58,8 +57,23 @@ extern "C" { struct pb_vtbl; struct pb_validate; +struct pipe_fence_handle; +#define PB_USAGE_CPU_READ (1 << 0) +#define PB_USAGE_CPU_WRITE (1 << 1) +#define PB_USAGE_GPU_READ (1 << 2) +#define PB_USAGE_GPU_WRITE (1 << 3) +#define PB_USAGE_UNSYNCHRONIZED (1 << 10) +#define PB_USAGE_DONTBLOCK (1 << 9) + +#define PB_USAGE_CPU_READ_WRITE \ + ( PB_USAGE_CPU_READ | PB_USAGE_CPU_WRITE ) +#define PB_USAGE_GPU_READ_WRITE \ + ( PB_USAGE_GPU_READ | PB_USAGE_GPU_WRITE ) +#define PB_USAGE_WRITE \ + ( PB_USAGE_CPU_WRITE | PB_USAGE_GPU_WRITE ) + /** * Buffer description. * @@ -83,7 +97,14 @@ typedef unsigned pb_size; */ struct pb_buffer { - struct pipe_resource base; + /* This used to be a pipe_buffer struct: + */ + struct { + struct pipe_reference reference; + unsigned size; + unsigned alignment; + unsigned usage; + } base; /** * Pointer to the virtual function table. @@ -106,7 +127,7 @@ struct pb_vtbl /** * Map the entire data store of a buffer object into the client's address. - * flags is bitmask of PIPE_BUFFER_FLAG_READ/WRITE. + * flags is bitmask of PB_USAGE_CPU_READ/WRITE. */ void *(*map)( struct pb_buffer *buf, unsigned flags ); @@ -138,23 +159,6 @@ struct pb_vtbl }; -static INLINE struct pipe_buffer * -pb_pipe_buffer( struct pb_buffer *pbuf ) -{ - assert(pbuf); - return &pbuf->base; -} - - -static INLINE struct pb_buffer * -pb_buffer( struct pipe_buffer *buf ) -{ - assert(buf); - /* Could add a magic cookie check on debug builds. - */ - return (struct pb_buffer *)buf; -} - /* Accessor functions for pb->vtbl: */ @@ -196,7 +200,7 @@ pb_get_base_buffer( struct pb_buffer *buf, assert(buf->vtbl->get_base_buffer); buf->vtbl->get_base_buffer(buf, base_buf, offset); assert(*base_buf); - assert(*offset < (*base_buf)->base.width0); + assert(*offset < (*base_buf)->base.size); } diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c index 5bc717b9c4..d6cf640582 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c +++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c @@ -135,7 +135,7 @@ struct fenced_buffer void *data; /** - * A bitmask of PIPE_BUFFER_USAGE_CPU/GPU_READ/WRITE describing the current + * A bitmask of PB_USAGE_CPU/GPU_READ/WRITE describing the current * buffer usage. */ unsigned flags; @@ -210,7 +210,7 @@ fenced_manager_dump_locked(struct fenced_manager *fenced_mgr) assert(!fenced_buf->fence); debug_printf("%10p %7u %8u %7s\n", (void *) fenced_buf, - fenced_buf->base.base.width0, + fenced_buf->base.base.size, p_atomic_read(&fenced_buf->base.base.reference.count), fenced_buf->buffer ? "gpu" : (fenced_buf->data ? "cpu" : "none")); curr = next; @@ -226,7 +226,7 @@ fenced_manager_dump_locked(struct fenced_manager *fenced_mgr) signaled = ops->fence_signalled(ops, fenced_buf->fence, 0); debug_printf("%10p %7u %8u %7s %10p %s\n", (void *) fenced_buf, - fenced_buf->base.base.width0, + fenced_buf->base.base.size, p_atomic_read(&fenced_buf->base.base.reference.count), "gpu", (void *) fenced_buf->fence, @@ -270,7 +270,7 @@ fenced_buffer_add_locked(struct fenced_manager *fenced_mgr, struct fenced_buffer *fenced_buf) { assert(pipe_is_referenced(&fenced_buf->base.base.reference)); - assert(fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_READ_WRITE); + assert(fenced_buf->flags & PB_USAGE_GPU_READ_WRITE); assert(fenced_buf->fence); p_atomic_inc(&fenced_buf->base.base.reference.count); @@ -299,7 +299,7 @@ fenced_buffer_remove_locked(struct fenced_manager *fenced_mgr, assert(fenced_buf->mgr == fenced_mgr); ops->fence_reference(ops, &fenced_buf->fence, NULL); - fenced_buf->flags &= ~PIPE_BUFFER_USAGE_GPU_READ_WRITE; + fenced_buf->flags &= ~PB_USAGE_GPU_READ_WRITE; assert(fenced_buf->head.prev); assert(fenced_buf->head.next); @@ -377,7 +377,7 @@ fenced_buffer_finish_locked(struct fenced_manager *fenced_mgr, assert(!destroyed); - fenced_buf->flags &= ~PIPE_BUFFER_USAGE_GPU_READ_WRITE; + fenced_buf->flags &= ~PB_USAGE_GPU_READ_WRITE; ret = PIPE_OK; } @@ -624,7 +624,7 @@ fenced_buffer_copy_storage_to_gpu_locked(struct fenced_buffer *fenced_buf) assert(fenced_buf->data); assert(fenced_buf->buffer); - map = pb_map(fenced_buf->buffer, PIPE_BUFFER_USAGE_CPU_WRITE); + map = pb_map(fenced_buf->buffer, PB_USAGE_CPU_WRITE); if(!map) return PIPE_ERROR; @@ -644,7 +644,7 @@ fenced_buffer_copy_storage_to_cpu_locked(struct fenced_buffer *fenced_buf) assert(fenced_buf->data); assert(fenced_buf->buffer); - map = pb_map(fenced_buf->buffer, PIPE_BUFFER_USAGE_CPU_READ); + map = pb_map(fenced_buf->buffer, PB_USAGE_CPU_READ); if(!map) return PIPE_ERROR; @@ -683,24 +683,24 @@ fenced_buffer_map(struct pb_buffer *buf, pipe_mutex_lock(fenced_mgr->mutex); - assert(!(flags & PIPE_BUFFER_USAGE_GPU_READ_WRITE)); + assert(!(flags & PB_USAGE_GPU_READ_WRITE)); /* * Serialize writes. */ - while((fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_WRITE) || - ((fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_READ) && - (flags & PIPE_BUFFER_USAGE_CPU_WRITE))) { + while((fenced_buf->flags & PB_USAGE_GPU_WRITE) || + ((fenced_buf->flags & PB_USAGE_GPU_READ) && + (flags & PB_USAGE_CPU_WRITE))) { /* * Don't wait for the GPU to finish accessing it, if blocking is forbidden. */ - if((flags & PIPE_BUFFER_USAGE_DONTBLOCK) && + if((flags & PB_USAGE_DONTBLOCK) && ops->fence_signalled(ops, fenced_buf->fence, 0) != 0) { goto done; } - if (flags & PIPE_BUFFER_USAGE_UNSYNCHRONIZED) { + if (flags & PB_USAGE_UNSYNCHRONIZED) { break; } @@ -721,7 +721,7 @@ fenced_buffer_map(struct pb_buffer *buf, if(map) { ++fenced_buf->mapcount; - fenced_buf->flags |= flags & PIPE_BUFFER_USAGE_CPU_READ_WRITE; + fenced_buf->flags |= flags & PB_USAGE_CPU_READ_WRITE; } done: @@ -745,7 +745,7 @@ fenced_buffer_unmap(struct pb_buffer *buf) pb_unmap(fenced_buf->buffer); --fenced_buf->mapcount; if(!fenced_buf->mapcount) - fenced_buf->flags &= ~PIPE_BUFFER_USAGE_CPU_READ_WRITE; + fenced_buf->flags &= ~PB_USAGE_CPU_READ_WRITE; } pipe_mutex_unlock(fenced_mgr->mutex); @@ -771,9 +771,9 @@ fenced_buffer_validate(struct pb_buffer *buf, goto done; } - assert(flags & PIPE_BUFFER_USAGE_GPU_READ_WRITE); - assert(!(flags & ~PIPE_BUFFER_USAGE_GPU_READ_WRITE)); - flags &= PIPE_BUFFER_USAGE_GPU_READ_WRITE; + assert(flags & PB_USAGE_GPU_READ_WRITE); + assert(!(flags & ~PB_USAGE_GPU_READ_WRITE)); + flags &= PB_USAGE_GPU_READ_WRITE; /* Buffer cannot be validated in two different lists */ if(fenced_buf->vl && fenced_buf->vl != vl) { diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.h b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.h index 0372f81d0a..004c2b939a 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.h +++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.h @@ -59,7 +59,6 @@ extern "C" { #endif -struct pipe_buffer; struct pipe_fence_handle; diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c b/src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c index b22cf6c642..b706f429be 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c +++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c @@ -136,9 +136,8 @@ pb_malloc_buffer_create(pb_size size, pipe_reference_init(&buf->base.base.reference, 1); buf->base.base.usage = desc->usage; - buf->base.base.width0 = size; - buf->base.base.height0 = 1; - buf->base.base.depth0 = 1; + buf->base.base.size = size; + buf->base.base.alignment = desc->alignment; buf->base.vtbl = &malloc_buffer_vtbl; buf->data = align_malloc(size, desc->alignment < sizeof(void*) ? sizeof(void*) : desc->alignment); diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h b/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h index 06669917ff..cec2524da2 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h @@ -60,7 +60,6 @@ extern "C" { struct pb_desc; -struct pipe_buffer; /** diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c index a5dbded2bc..0dc5b31a75 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c @@ -158,7 +158,7 @@ pb_debug_buffer_fill(struct pb_debug_buffer *buf) { uint8_t *map; - map = pb_map(buf->buffer, PIPE_BUFFER_USAGE_CPU_WRITE); + map = pb_map(buf->buffer, PB_USAGE_CPU_WRITE); assert(map); if(map) { fill_random_pattern(map, buf->underflow_size); @@ -180,8 +180,8 @@ pb_debug_buffer_check(struct pb_debug_buffer *buf) uint8_t *map; map = pb_map(buf->buffer, - PIPE_BUFFER_USAGE_CPU_READ | - PIPE_BUFFER_USAGE_UNSYNCHRONIZED); + PB_USAGE_CPU_READ | + PB_USAGE_UNSYNCHRONIZED); assert(map); if(map) { boolean underflow, overflow; @@ -382,8 +382,8 @@ pb_debug_manager_create_buffer(struct pb_manager *_mgr, real_size = mgr->underflow_size + size + mgr->overflow_size; real_desc = *desc; - real_desc.usage |= PIPE_BUFFER_USAGE_CPU_WRITE; - real_desc.usage |= PIPE_BUFFER_USAGE_CPU_READ; + real_desc.usage |= PB_USAGE_CPU_WRITE; + real_desc.usage |= PB_USAGE_CPU_READ; buf->buffer = mgr->provider->create_buffer(mgr->provider, real_size, diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c index 63195715d6..faf7c35267 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c @@ -268,8 +268,8 @@ mm_bufmgr_create_from_buffer(struct pb_buffer *buffer, mm->buffer = buffer; mm->map = pb_map(mm->buffer, - PIPE_BUFFER_USAGE_CPU_READ | - PIPE_BUFFER_USAGE_CPU_WRITE); + PB_USAGE_CPU_READ | + PB_USAGE_CPU_WRITE); if(!mm->map) goto failure; diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_ondemand.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_ondemand.c index cb32d25136..31f1ebbeb7 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_ondemand.c +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_ondemand.c @@ -150,7 +150,7 @@ pb_ondemand_buffer_instantiate(struct pb_ondemand_buffer *buf) if(!buf->buffer) return PIPE_ERROR_OUT_OF_MEMORY; - map = pb_map(buf->buffer, PIPE_BUFFER_USAGE_CPU_READ); + map = pb_map(buf->buffer, PB_USAGE_CPU_READ); if(!map) { pb_reference(&buf->buffer, NULL); return PIPE_ERROR; diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c index fea234ae8c..fdcce42878 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c @@ -284,8 +284,8 @@ pool_bufmgr_create(struct pb_manager *provider, goto failure; pool->map = pb_map(pool->buffer, - PIPE_BUFFER_USAGE_CPU_READ | - PIPE_BUFFER_USAGE_CPU_WRITE); + PB_USAGE_CPU_READ | + PB_USAGE_CPU_WRITE); if(!pool->map) goto failure; diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c index 24e2820f88..7a3305aaf3 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c @@ -315,8 +315,8 @@ pb_slab_create(struct pb_slab_manager *mgr) /* Note down the slab virtual address. All mappings are accessed directly * through this address so it is required that the buffer is pinned. */ slab->virtual = pb_map(slab->bo, - PIPE_BUFFER_USAGE_CPU_READ | - PIPE_BUFFER_USAGE_CPU_WRITE); + PB_USAGE_CPU_READ | + PB_USAGE_CPU_WRITE); if(!slab->virtual) { ret = PIPE_ERROR_OUT_OF_MEMORY; goto out_err1; diff --git a/src/gallium/auxiliary/pipebuffer/pb_validate.c b/src/gallium/auxiliary/pipebuffer/pb_validate.c index 903afc749d..b585422460 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_validate.c +++ b/src/gallium/auxiliary/pipebuffer/pb_validate.c @@ -69,9 +69,9 @@ pb_validate_add_buffer(struct pb_validate *vl, if(!buf) return PIPE_ERROR; - assert(flags & PIPE_BUFFER_USAGE_GPU_READ_WRITE); - assert(!(flags & ~PIPE_BUFFER_USAGE_GPU_READ_WRITE)); - flags &= PIPE_BUFFER_USAGE_GPU_READ_WRITE; + assert(flags & PB_USAGE_GPU_READ_WRITE); + assert(!(flags & ~PB_USAGE_GPU_READ_WRITE)); + flags &= PB_USAGE_GPU_READ_WRITE; /* We only need to store one reference for each buffer, so avoid storing * consecutive references for the same buffer. It might not be the most diff --git a/src/gallium/auxiliary/util/u_blit.c b/src/gallium/auxiliary/util/u_blit.c index 4d0737ccd3..12a4ff6b48 100644 --- a/src/gallium/auxiliary/util/u_blit.c +++ b/src/gallium/auxiliary/util/u_blit.c @@ -68,7 +68,7 @@ struct blit_state void *vs; void *fs[TGSI_WRITEMASK_XYZW + 1]; - struct pipe_buffer *vbuf; /**< quad vertices */ + struct pipe_resource *vbuf; /**< quad vertices */ unsigned vbuf_slot; float vertices[4][2][4]; /**< vertex/texcoords for quad */ @@ -166,7 +166,7 @@ util_destroy_blit(struct blit_state *ctx) if (ctx->fs[i]) pipe->delete_fs_state(pipe, ctx->fs[i]); - pipe_buffer_reference(&ctx->vbuf, NULL); + pipe_resource_reference(&ctx->vbuf, NULL); FREE(ctx); } @@ -235,7 +235,7 @@ setup_vertex_data_tex(struct blit_state *ctx, offset = get_next_slot( ctx ); - pipe_buffer_write_nooverlap(ctx->pipe->screen, ctx->vbuf, + pipe_buffer_write_nooverlap(ctx->pipe, ctx->vbuf, offset, sizeof(ctx->vertices), ctx->vertices); return offset; @@ -290,7 +290,7 @@ util_blit_pixels_writemask(struct blit_state *ctx, { struct pipe_context *pipe = ctx->pipe; struct pipe_screen *screen = pipe->screen; - struct pipe_texture *tex = NULL; + struct pipe_resource *tex = NULL; struct pipe_framebuffer_state fb; const int srcW = abs(srcX1 - srcX0); const int srcH = abs(srcY1 - srcY0); @@ -344,7 +344,7 @@ util_blit_pixels_writemask(struct blit_state *ctx, src->texture->target != PIPE_TEXTURE_2D || src->texture->last_level != 0) { - struct pipe_texture texTemp; + struct pipe_resource texTemp; struct pipe_surface *texSurf; const int srcLeft = MIN2(srcX0, srcX1); const int srcTop = MIN2(srcY0, srcY1); @@ -372,7 +372,7 @@ util_blit_pixels_writemask(struct blit_state *ctx, texTemp.height0 = srcH; texTemp.depth0 = 1; - tex = screen->texture_create(screen, &texTemp); + tex = screen->resource_create(screen, &texTemp); if (!tex) return; @@ -401,7 +401,7 @@ util_blit_pixels_writemask(struct blit_state *ctx, t1 = 1.0f; } else { - pipe_texture_reference(&tex, src->texture); + pipe_resource_reference(&tex, src->texture); s0 = srcX0 / (float)tex->width0; s1 = srcX1 / (float)tex->width0; t0 = srcY0 / (float)tex->height0; @@ -494,7 +494,7 @@ util_blit_pixels_writemask(struct blit_state *ctx, cso_restore_clip(ctx->cso); cso_restore_vertex_elements(ctx->cso); - pipe_texture_reference(&tex, NULL); + pipe_resource_reference(&tex, NULL); } @@ -524,7 +524,7 @@ util_blit_pixels(struct blit_state *ctx, */ void util_blit_flush( struct blit_state *ctx ) { - pipe_buffer_reference(&ctx->vbuf, NULL); + pipe_resource_reference(&ctx->vbuf, NULL); ctx->vbuf_slot = 0; } @@ -539,7 +539,7 @@ void util_blit_flush( struct blit_state *ctx ) */ void util_blit_pixels_tex(struct blit_state *ctx, - struct pipe_texture *tex, + struct pipe_resource *tex, int srcX0, int srcY0, int srcX1, int srcY1, struct pipe_surface *dst, diff --git a/src/gallium/auxiliary/util/u_blit.h b/src/gallium/auxiliary/util/u_blit.h index a102021529..ad35ac60ce 100644 --- a/src/gallium/auxiliary/util/u_blit.h +++ b/src/gallium/auxiliary/util/u_blit.h @@ -37,7 +37,7 @@ extern "C" { struct pipe_context; struct pipe_surface; -struct pipe_texture; +struct pipe_resource; struct cso_context; @@ -73,7 +73,7 @@ util_blit_pixels_writemask(struct blit_state *ctx, extern void util_blit_pixels_tex(struct blit_state *ctx, - struct pipe_texture *tex, + struct pipe_resource *tex, int srcX0, int srcY0, int srcX1, int srcY1, struct pipe_surface *dst, diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c index 1692987e8e..b4a49b7213 100644 --- a/src/gallium/auxiliary/util/u_blitter.c +++ b/src/gallium/auxiliary/util/u_blitter.c @@ -56,7 +56,7 @@ struct blitter_context_priv struct blitter_context blitter; struct pipe_context *pipe; /**< pipe context */ - struct pipe_buffer *vbuf; /**< quad */ + struct pipe_resource *vbuf; /**< quad */ float vertices[4][2][4]; /**< {pos, color} or {pos, texcoord} */ @@ -259,7 +259,7 @@ void util_blitter_destroy(struct blitter_context *blitter) pipe_sampler_view_reference(&ctx->sampler_view, NULL); } - pipe_buffer_reference(&ctx->vbuf, NULL); + pipe_resource_reference(&ctx->vbuf, NULL); FREE(ctx); } @@ -451,7 +451,7 @@ static void blitter_draw_quad(struct blitter_context_priv *ctx) struct pipe_context *pipe = ctx->pipe; /* write vertices and draw them */ - pipe_buffer_write(pipe->screen, ctx->vbuf, + pipe_buffer_write(pipe, ctx->vbuf, 0, sizeof(ctx->vertices), ctx->vertices); util_draw_vertex_buffer(pipe, ctx->vbuf, 0, PIPE_PRIM_TRIANGLE_FAN, @@ -714,8 +714,8 @@ static void util_blitter_overlap_copy(struct blitter_context *blitter, struct pipe_context *pipe = ctx->pipe; struct pipe_screen *screen = pipe->screen; - struct pipe_texture texTemp; - struct pipe_texture *texture; + struct pipe_resource texTemp; + struct pipe_resource *texture; struct pipe_surface *tex_surf; /* check whether the states are properly saved */ @@ -729,7 +729,7 @@ static void util_blitter_overlap_copy(struct blitter_context *blitter, texTemp.height0 = height; texTemp.depth0 = 1; - texture = screen->texture_create(screen, &texTemp); + texture = screen->resource_create(screen, &texTemp); if (!texture) return; @@ -747,7 +747,7 @@ static void util_blitter_overlap_copy(struct blitter_context *blitter, width, height, FALSE); pipe_surface_reference(&tex_surf, NULL); - pipe_texture_reference(&texture, NULL); + pipe_resource_reference(&texture, NULL); blitter_restore_CSOs(ctx); } diff --git a/src/gallium/auxiliary/util/u_debug.c b/src/gallium/auxiliary/util/u_debug.c index 619bae57b7..8373fe99e2 100644 --- a/src/gallium/auxiliary/util/u_debug.c +++ b/src/gallium/auxiliary/util/u_debug.c @@ -425,7 +425,7 @@ void debug_dump_surface(struct pipe_context *pipe, const char *prefix, struct pipe_surface *surface) { - struct pipe_texture *texture; + struct pipe_resource *texture; struct pipe_transfer *transfer; void *data; @@ -440,7 +440,7 @@ void debug_dump_surface(struct pipe_context *pipe, */ texture = surface->texture; - transfer = pipe->get_transfer(pipe, texture, surface->face, + transfer = pipe_get_transfer(pipe, texture, surface->face, surface->level, surface->zslice, PIPE_TRANSFER_READ, 0, 0, surface->width, surface->height); @@ -452,20 +452,20 @@ void debug_dump_surface(struct pipe_context *pipe, debug_dump_image(prefix, texture->format, util_format_get_blocksize(texture->format), - util_format_get_nblocksx(texture->format, transfer->width), - util_format_get_nblocksy(texture->format, transfer->height), + util_format_get_nblocksx(texture->format, surface->width), + util_format_get_nblocksy(texture->format, surface->height), transfer->stride, data); pipe->transfer_unmap(pipe, transfer); error: - pipe->tex_transfer_destroy(pipe, transfer); + pipe->transfer_destroy(pipe, transfer); } void debug_dump_texture(struct pipe_context *pipe, const char *prefix, - struct pipe_texture *texture) + struct pipe_resource *texture) { struct pipe_surface *surface; struct pipe_screen *screen; @@ -523,16 +523,16 @@ debug_dump_surface_bmp(struct pipe_context *pipe, { #ifndef PIPE_SUBSYSTEM_WINDOWS_MINIPORT struct pipe_transfer *transfer; - struct pipe_texture *texture = surface->texture; + struct pipe_resource *texture = surface->texture; - transfer = pipe->get_transfer(pipe, texture, surface->face, - surface->level, surface->zslice, - PIPE_TRANSFER_READ, 0, 0, surface->width, - surface->height); + transfer = pipe_get_transfer(pipe, texture, surface->face, + surface->level, surface->zslice, + PIPE_TRANSFER_READ, 0, 0, surface->width, + surface->height); debug_dump_transfer_bmp(pipe, filename, transfer); - pipe->tex_transfer_destroy(pipe, transfer); + pipe->transfer_destroy(pipe, transfer); #endif } @@ -547,17 +547,20 @@ debug_dump_transfer_bmp(struct pipe_context *pipe, if (!transfer) goto error1; - rgba = MALLOC(transfer->width*transfer->height*4*sizeof(float)); + rgba = MALLOC(transfer->box.width * + transfer->box.height * + transfer->box.depth * + 4*sizeof(float)); if(!rgba) goto error1; pipe_get_tile_rgba(pipe, transfer, 0, 0, - transfer->width, transfer->height, + transfer->box.width, transfer->box.height, rgba); debug_dump_float_rgba_bmp(filename, - transfer->width, transfer->height, - rgba, transfer->width); + transfer->box.width, transfer->box.height, + rgba, transfer->box.width); FREE(rgba); error1: diff --git a/src/gallium/auxiliary/util/u_debug.h b/src/gallium/auxiliary/util/u_debug.h index 98addeb372..b6d0b508e3 100644 --- a/src/gallium/auxiliary/util/u_debug.h +++ b/src/gallium/auxiliary/util/u_debug.h @@ -315,7 +315,7 @@ debug_memory_end(unsigned long beginning); struct pipe_context; struct pipe_surface; struct pipe_transfer; -struct pipe_texture; +struct pipe_resource; void debug_dump_image(const char *prefix, unsigned format, unsigned cpp, @@ -327,7 +327,7 @@ void debug_dump_surface(struct pipe_context *pipe, struct pipe_surface *surface); void debug_dump_texture(struct pipe_context *pipe, const char *prefix, - struct pipe_texture *texture); + struct pipe_resource *texture); void debug_dump_surface_bmp(struct pipe_context *pipe, const char *filename, struct pipe_surface *surface); diff --git a/src/gallium/auxiliary/util/u_draw_quad.c b/src/gallium/auxiliary/util/u_draw_quad.c index ec90c2fd65..a6b9d0f19e 100644 --- a/src/gallium/auxiliary/util/u_draw_quad.c +++ b/src/gallium/auxiliary/util/u_draw_quad.c @@ -30,6 +30,7 @@ #include "pipe/p_defines.h" #include "util/u_inlines.h" #include "util/u_draw_quad.h" +#include "util/u_memory.h" /** @@ -66,60 +67,63 @@ util_draw_vertex_buffer(struct pipe_context *pipe, /** * Draw screen-aligned textured quad. - * Note: this function allocs/destroys a vertex buffer and isn't especially - * efficient. + * Note: this isn't especially efficient. */ void util_draw_texquad(struct pipe_context *pipe, float x0, float y0, float x1, float y1, float z) { - struct pipe_resource *vbuf; - uint numAttribs = 2, vertexBytes, i, j; - - vertexBytes = 4 * (4 * numAttribs * sizeof(float)); - - /* XXX create one-time */ - vbuf = pipe_buffer_create(pipe->screen, 32, - PIPE_BUFFER_USAGE_VERTEX, vertexBytes); - if (vbuf) { - float *v = (float *) pipe_buffer_map(pipe->screen, vbuf, - PIPE_BUFFER_USAGE_CPU_WRITE); - if (v) { - /* - * Load vertex buffer - */ - for (i = j = 0; i < 4; i++) { - v[j + 2] = z; /* z */ - v[j + 3] = 1.0; /* w */ - v[j + 6] = 0.0; /* r */ - v[j + 7] = 1.0; /* q */ - j += 8; - } - - v[0] = x0; - v[1] = y0; - v[4] = 0.0; /*s*/ - v[5] = 0.0; /*t*/ - - v[8] = x1; - v[9] = y0; - v[12] = 1.0; - v[13] = 0.0; - - v[16] = x1; - v[17] = y1; - v[20] = 1.0; - v[21] = 1.0; - - v[24] = x0; - v[25] = y1; - v[28] = 0.0; - v[29] = 1.0; - - pipe_buffer_unmap(pipe->screen, vbuf); - util_draw_vertex_buffer(pipe, vbuf, 0, PIPE_PRIM_TRIANGLE_FAN, 4, 2); - } - - pipe_buffer_reference(&vbuf, NULL); + uint numAttribs = 2, i, j; + uint vertexBytes = 4 * (4 * numAttribs * sizeof(float)); + struct pipe_resource *vbuf = NULL; + uint *v = NULL; + + v = MALLOC(vertexBytes); + if (v == NULL) + goto out; + + /* + * Load vertex buffer + */ + for (i = j = 0; i < 4; i++) { + v[j + 2] = z; /* z */ + v[j + 3] = 1.0; /* w */ + v[j + 6] = 0.0; /* r */ + v[j + 7] = 1.0; /* q */ + j += 8; } + + v[0] = x0; + v[1] = y0; + v[4] = 0.0; /*s*/ + v[5] = 0.0; /*t*/ + + v[8] = x1; + v[9] = y0; + v[12] = 1.0; + v[13] = 0.0; + + v[16] = x1; + v[17] = y1; + v[20] = 1.0; + v[21] = 1.0; + + v[24] = x0; + v[25] = y1; + v[28] = 0.0; + v[29] = 1.0; + + vbuf = pipe_user_buffer_create(pipe->screen, v, vertexBytes, + PIPE_BUFFER_USAGE_VERTEX); + if (!vbuf) + goto out; + + util_draw_vertex_buffer(pipe, vbuf, 0, PIPE_PRIM_TRIANGLE_FAN, 4, 2); + +out: + if (vbuf) + pipe_resource_reference(&vbuf, NULL); + + if (v) + FREE(v); } diff --git a/src/gallium/auxiliary/util/u_draw_quad.h b/src/gallium/auxiliary/util/u_draw_quad.h index 00d3f5b715..42eb184428 100644 --- a/src/gallium/auxiliary/util/u_draw_quad.h +++ b/src/gallium/auxiliary/util/u_draw_quad.h @@ -33,11 +33,11 @@ extern "C" { #endif -struct pipe_buffer; +struct pipe_resource; extern void util_draw_vertex_buffer(struct pipe_context *pipe, - struct pipe_buffer *vbuf, uint offset, + struct pipe_resource *vbuf, uint offset, uint num_attribs, uint num_verts, uint prim_type); diff --git a/src/gallium/auxiliary/util/u_dump.h b/src/gallium/auxiliary/util/u_dump.h index 379f18ef38..bdc73ac47d 100644 --- a/src/gallium/auxiliary/util/u_dump.h +++ b/src/gallium/auxiliary/util/u_dump.h @@ -92,7 +92,7 @@ util_dump_tex_filter(unsigned value, boolean shortened); void util_dump_template(struct os_stream *stream, - const struct pipe_texture *templat); + const struct pipe_resource *templat); void util_dump_rasterizer_state(struct os_stream *stream, diff --git a/src/gallium/auxiliary/util/u_dump_state.c b/src/gallium/auxiliary/util/u_dump_state.c index 52cf3ef4ce..08557d5553 100644 --- a/src/gallium/auxiliary/util/u_dump_state.c +++ b/src/gallium/auxiliary/util/u_dump_state.c @@ -255,7 +255,7 @@ util_dump_enum_func(struct os_stream *stream, unsigned value) void -util_dump_template(struct os_stream *stream, const struct pipe_texture *templat) +util_dump_template(struct os_stream *stream, const struct pipe_resource *templat) { if(!templat) { util_dump_null(stream); @@ -653,16 +653,13 @@ util_dump_transfer(struct os_stream *stream, const struct pipe_transfer *state) util_dump_struct_begin(stream, "pipe_transfer"); - util_dump_member(stream, uint, state, width); - util_dump_member(stream, uint, state, height); + util_dump_member(stream, ptr, state, resource); +// util_dump_member(stream, uint, state, box); util_dump_member(stream, uint, state, stride); - util_dump_member(stream, uint, state, usage); + util_dump_member(stream, uint, state, slice_stride); - util_dump_member(stream, ptr, state, texture); - util_dump_member(stream, uint, state, face); - util_dump_member(stream, uint, state, level); - util_dump_member(stream, uint, state, zslice); +// util_dump_member(stream, ptr, state, data); util_dump_struct_end(stream); } diff --git a/src/gallium/auxiliary/util/u_gen_mipmap.c b/src/gallium/auxiliary/util/u_gen_mipmap.c index 5487923cf7..52f3a4d013 100644 --- a/src/gallium/auxiliary/util/u_gen_mipmap.c +++ b/src/gallium/auxiliary/util/u_gen_mipmap.c @@ -67,7 +67,7 @@ struct gen_mipmap_state void *vs; void *fs2d, *fsCube; - struct pipe_buffer *vbuf; /**< quad vertices */ + struct pipe_resource *vbuf; /**< quad vertices */ unsigned vbuf_slot; float vertices[4][2][4]; /**< vertex/texcoords for quad */ @@ -1115,7 +1115,7 @@ reduce_3d(enum pipe_format pformat, static void make_1d_mipmap(struct gen_mipmap_state *ctx, - struct pipe_texture *pt, + struct pipe_resource *pt, uint face, uint baseLevel, uint lastLevel) { struct pipe_context *pipe = ctx->pipe; @@ -1127,11 +1127,11 @@ make_1d_mipmap(struct gen_mipmap_state *ctx, struct pipe_transfer *srcTrans, *dstTrans; void *srcMap, *dstMap; - srcTrans = pipe->get_transfer(pipe, pt, face, srcLevel, zslice, + srcTrans = pipe_get_transfer(pipe, pt, face, srcLevel, zslice, PIPE_TRANSFER_READ, 0, 0, u_minify(pt->width0, srcLevel), u_minify(pt->height0, srcLevel)); - dstTrans = pipe->get_transfer(pipe, pt, face, dstLevel, zslice, + dstTrans = pipe_get_transfer(pipe, pt, face, dstLevel, zslice, PIPE_TRANSFER_WRITE, 0, 0, u_minify(pt->width0, dstLevel), u_minify(pt->height0, dstLevel)); @@ -1140,21 +1140,21 @@ make_1d_mipmap(struct gen_mipmap_state *ctx, dstMap = (ubyte *) pipe->transfer_map(pipe, dstTrans); reduce_1d(pt->format, - srcTrans->width, srcMap, - dstTrans->width, dstMap); + srcTrans->box.width, srcMap, + dstTrans->box.width, dstMap); pipe->transfer_unmap(pipe, srcTrans); pipe->transfer_unmap(pipe, dstTrans); - pipe->tex_transfer_destroy(pipe, srcTrans); - pipe->tex_transfer_destroy(pipe, dstTrans); + pipe->transfer_destroy(pipe, srcTrans); + pipe->transfer_destroy(pipe, dstTrans); } } static void make_2d_mipmap(struct gen_mipmap_state *ctx, - struct pipe_texture *pt, + struct pipe_resource *pt, uint face, uint baseLevel, uint lastLevel) { struct pipe_context *pipe = ctx->pipe; @@ -1169,36 +1169,36 @@ make_2d_mipmap(struct gen_mipmap_state *ctx, struct pipe_transfer *srcTrans, *dstTrans; ubyte *srcMap, *dstMap; - srcTrans = pipe->get_transfer(pipe, pt, face, srcLevel, zslice, - PIPE_TRANSFER_READ, 0, 0, - u_minify(pt->width0, srcLevel), - u_minify(pt->height0, srcLevel)); - dstTrans = pipe->get_transfer(pipe, pt, face, dstLevel, zslice, - PIPE_TRANSFER_WRITE, 0, 0, - u_minify(pt->width0, dstLevel), - u_minify(pt->height0, dstLevel)); + srcTrans = pipe_get_transfer(pipe, pt, face, srcLevel, zslice, + PIPE_TRANSFER_READ, 0, 0, + u_minify(pt->width0, srcLevel), + u_minify(pt->height0, srcLevel)); + dstTrans = pipe_get_transfer(pipe, pt, face, dstLevel, zslice, + PIPE_TRANSFER_WRITE, 0, 0, + u_minify(pt->width0, dstLevel), + u_minify(pt->height0, dstLevel)); srcMap = (ubyte *) pipe->transfer_map(pipe, srcTrans); dstMap = (ubyte *) pipe->transfer_map(pipe, dstTrans); reduce_2d(pt->format, - srcTrans->width, srcTrans->height, + srcTrans->box.width, srcTrans->box.height, srcTrans->stride, srcMap, - dstTrans->width, dstTrans->height, + dstTrans->box.width, dstTrans->box.height, dstTrans->stride, dstMap); pipe->transfer_unmap(pipe, srcTrans); pipe->transfer_unmap(pipe, dstTrans); - pipe->tex_transfer_destroy(pipe, srcTrans); - pipe->tex_transfer_destroy(pipe, dstTrans); + pipe->transfer_destroy(pipe, srcTrans); + pipe->transfer_destroy(pipe, dstTrans); } } static void make_3d_mipmap(struct gen_mipmap_state *ctx, - struct pipe_texture *pt, + struct pipe_resource *pt, uint face, uint baseLevel, uint lastLevel) { #if 0 @@ -1235,8 +1235,8 @@ make_3d_mipmap(struct gen_mipmap_state *ctx, pipe->transfer_unmap(pipe, srcTrans); pipe->transfer_unmap(pipe, dstTrans); - pipe->tex_transfer_destroy(pipe, srcTrans); - pipe->tex_transfer_destroy(pipe, dstTrans); + pipe->transfer_destroy(pipe, srcTrans); + pipe->transfer_destroy(pipe, dstTrans); } #else (void) reduce_3d; @@ -1246,7 +1246,7 @@ make_3d_mipmap(struct gen_mipmap_state *ctx, static void fallback_gen_mipmap(struct gen_mipmap_state *ctx, - struct pipe_texture *pt, + struct pipe_resource *pt, uint face, uint baseLevel, uint lastLevel) { switch (pt->target) { @@ -1439,7 +1439,7 @@ util_destroy_gen_mipmap(struct gen_mipmap_state *ctx) pipe->delete_fs_state(pipe, ctx->fs2d); pipe->delete_fs_state(pipe, ctx->fsCube); - pipe_buffer_reference(&ctx->vbuf, NULL); + pipe_resource_reference(&ctx->vbuf, NULL); FREE(ctx); } @@ -1451,7 +1451,7 @@ util_destroy_gen_mipmap(struct gen_mipmap_state *ctx) */ void util_gen_mipmap_flush( struct gen_mipmap_state *ctx ) { - pipe_buffer_reference(&ctx->vbuf, NULL); + pipe_resource_reference(&ctx->vbuf, NULL); ctx->vbuf_slot = 0; } @@ -1469,7 +1469,7 @@ void util_gen_mipmap_flush( struct gen_mipmap_state *ctx ) */ void util_gen_mipmap(struct gen_mipmap_state *ctx, - struct pipe_texture *pt, + struct pipe_resource *pt, uint face, uint baseLevel, uint lastLevel, uint filter) { struct pipe_context *pipe = ctx->pipe; diff --git a/src/gallium/auxiliary/util/u_gen_mipmap.h b/src/gallium/auxiliary/util/u_gen_mipmap.h index 54608f9466..6783325ef2 100644 --- a/src/gallium/auxiliary/util/u_gen_mipmap.h +++ b/src/gallium/auxiliary/util/u_gen_mipmap.h @@ -37,7 +37,7 @@ extern "C" { struct pipe_context; -struct pipe_texture; +struct pipe_resource; struct cso_context; struct gen_mipmap_state; @@ -59,7 +59,7 @@ util_gen_mipmap_flush( struct gen_mipmap_state *ctx ); extern void util_gen_mipmap(struct gen_mipmap_state *ctx, - struct pipe_texture *pt, + struct pipe_resource *pt, uint face, uint baseLevel, uint lastLevel, uint filter); diff --git a/src/gallium/auxiliary/util/u_inlines.h b/src/gallium/auxiliary/util/u_inlines.h index 2599be554e..022b8aec1d 100644 --- a/src/gallium/auxiliary/util/u_inlines.h +++ b/src/gallium/auxiliary/util/u_inlines.h @@ -106,12 +106,10 @@ pipe_resource_reference(struct pipe_resource **ptr, struct pipe_resource *tex) struct pipe_resource *old_tex = *ptr; if (pipe_reference(&(*ptr)->reference, &tex->reference)) - old_tex->screen->resource_destroy(old_tex); + old_tex->screen->resource_destroy(old_tex->screen, old_tex); *ptr = tex; } -#define pipe_buffer_reference pipe_resource_reference -#define pipe_texture_reference pipe_resource_reference static INLINE void pipe_sampler_view_reference(struct pipe_sampler_view **ptr, struct pipe_sampler_view *view) @@ -145,7 +143,8 @@ pipe_buffer_create( struct pipe_screen *screen, static INLINE struct pipe_resource * -pipe_user_buffer_create( struct pipe_screen *screen, void *ptr, unsigned size ) +pipe_user_buffer_create( struct pipe_screen *screen, void *ptr, unsigned size, + unsigned usage ) { return screen->user_buffer_create(screen, ptr, size); } @@ -228,12 +227,7 @@ pipe_buffer_write(struct pipe_context *pipe, subresource.face = 0; subresource.level = 0; - box.x = offset; - box.y = 0; - box.z = 0; - box.w = size; - box.h = 1; - box.d = 1; + u_box_1d(offset, size, &box); pipe->transfer_inline_write( pipe, buf, @@ -261,12 +255,7 @@ pipe_buffer_write_nooverlap(struct pipe_context *pipe, subresource.face = 0; subresource.level = 0; - box.x = offset; - box.y = 0; - box.z = 0; - box.w = size; - box.h = 1; - box.d = 1; + u_box_1d(offset, size, &box); pipe->transfer_inline_write(pipe, buf, @@ -289,12 +278,7 @@ pipe_buffer_read(struct pipe_context *pipe, subresource.face = 0; subresource.level = 0; - box.x = offset; - box.y = 0; - box.z = 0; - box.w = size; - box.h = 1; - box.d = 1; + u_box_1d(offset, size, &box); pipe->transfer_inline_read( pipe, buf, diff --git a/src/gallium/auxiliary/util/u_rect.c b/src/gallium/auxiliary/util/u_rect.c index 82ee36b08e..098cdfd58b 100644 --- a/src/gallium/auxiliary/util/u_rect.c +++ b/src/gallium/auxiliary/util/u_rect.c @@ -35,6 +35,7 @@ #include "pipe/p_context.h" #include "pipe/p_screen.h" #include "util/u_format.h" +#include "util/u_inlines.h" #include "util/u_rect.h" @@ -181,21 +182,21 @@ util_surface_copy(struct pipe_context *pipe, src_format = src->texture->format; dst_format = dst->texture->format; - src_trans = pipe->get_transfer(pipe, - src->texture, - src->face, - src->level, - src->zslice, - PIPE_TRANSFER_READ, - src_x, src_y, w, h); - - dst_trans = pipe->get_transfer(pipe, - dst->texture, - dst->face, - dst->level, - dst->zslice, - PIPE_TRANSFER_WRITE, - dst_x, dst_y, w, h); + src_trans = pipe_get_transfer(pipe, + src->texture, + src->face, + src->level, + src->zslice, + PIPE_TRANSFER_READ, + src_x, src_y, w, h); + + dst_trans = pipe_get_transfer(pipe, + dst->texture, + dst->face, + dst->level, + dst->zslice, + PIPE_TRANSFER_WRITE, + dst_x, dst_y, w, h); assert(util_format_get_blocksize(dst_format) == util_format_get_blocksize(src_format)); assert(util_format_get_blockwidth(dst_format) == util_format_get_blockwidth(src_format)); @@ -223,8 +224,8 @@ util_surface_copy(struct pipe_context *pipe, pipe->transfer_unmap(pipe, src_trans); pipe->transfer_unmap(pipe, dst_trans); - pipe->tex_transfer_destroy(pipe, src_trans); - pipe->tex_transfer_destroy(pipe, dst_trans); + pipe->transfer_destroy(pipe, src_trans); + pipe->transfer_destroy(pipe, dst_trans); } @@ -248,13 +249,13 @@ util_surface_fill(struct pipe_context *pipe, assert(dst->texture); if (!dst->texture) return; - dst_trans = pipe->get_transfer(pipe, - dst->texture, - dst->face, - dst->level, - dst->zslice, - PIPE_TRANSFER_WRITE, - dstx, dsty, width, height); + dst_trans = pipe_get_transfer(pipe, + dst->texture, + dst->face, + dst->level, + dst->zslice, + PIPE_TRANSFER_WRITE, + dstx, dsty, width, height); dst_map = pipe->transfer_map(pipe, dst_trans); @@ -263,37 +264,38 @@ util_surface_fill(struct pipe_context *pipe, if (dst_map) { assert(dst_trans->stride > 0); - switch (util_format_get_blocksize(dst_trans->texture->format)) { + switch (util_format_get_blocksize(dst->texture->format)) { case 1: case 2: case 4: - util_fill_rect(dst_map, dst_trans->texture->format, dst_trans->stride, + util_fill_rect(dst_map, dst->texture->format, + dst_trans->stride, 0, 0, width, height, value); break; case 8: - { - /* expand the 4-byte clear value to an 8-byte value */ - ushort *row = (ushort *) dst_map; - ushort val0 = UBYTE_TO_USHORT((value >> 0) & 0xff); - ushort val1 = UBYTE_TO_USHORT((value >> 8) & 0xff); - ushort val2 = UBYTE_TO_USHORT((value >> 16) & 0xff); - ushort val3 = UBYTE_TO_USHORT((value >> 24) & 0xff); - unsigned i, j; - val0 = (val0 << 8) | val0; - val1 = (val1 << 8) | val1; - val2 = (val2 << 8) | val2; - val3 = (val3 << 8) | val3; - for (i = 0; i < height; i++) { - for (j = 0; j < width; j++) { - row[j*4+0] = val0; - row[j*4+1] = val1; - row[j*4+2] = val2; - row[j*4+3] = val3; - } - row += dst_trans->stride/2; - } - } - break; + { + /* expand the 4-byte clear value to an 8-byte value */ + ushort *row = (ushort *) dst_map; + ushort val0 = UBYTE_TO_USHORT((value >> 0) & 0xff); + ushort val1 = UBYTE_TO_USHORT((value >> 8) & 0xff); + ushort val2 = UBYTE_TO_USHORT((value >> 16) & 0xff); + ushort val3 = UBYTE_TO_USHORT((value >> 24) & 0xff); + unsigned i, j; + val0 = (val0 << 8) | val0; + val1 = (val1 << 8) | val1; + val2 = (val2 << 8) | val2; + val3 = (val3 << 8) | val3; + for (i = 0; i < height; i++) { + for (j = 0; j < width; j++) { + row[j*4+0] = val0; + row[j*4+1] = val1; + row[j*4+2] = val2; + row[j*4+3] = val3; + } + row += dst_trans->stride/2; + } + } + break; default: assert(0); break; @@ -301,5 +303,5 @@ util_surface_fill(struct pipe_context *pipe, } pipe->transfer_unmap(pipe, dst_trans); - pipe->tex_transfer_destroy(pipe, dst_trans); + pipe->transfer_destroy(pipe, dst_trans); } diff --git a/src/gallium/auxiliary/util/u_simple_screen.c b/src/gallium/auxiliary/util/u_simple_screen.c deleted file mode 100644 index 9203cb6580..0000000000 --- a/src/gallium/auxiliary/util/u_simple_screen.c +++ /dev/null @@ -1,137 +0,0 @@ -/************************************************************************** - * - * Copyright 2009 VMware, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -#include "u_simple_screen.h" - -#include "pipe/p_screen.h" -#include "pipe/p_state.h" -#include "util/u_simple_screen.h" - - -static struct pipe_buffer * -pass_buffer_create(struct pipe_screen *screen, - unsigned alignment, - unsigned usage, - unsigned size) -{ - struct pipe_buffer *buffer = - screen->winsys->buffer_create(screen->winsys, alignment, usage, size); - - buffer->screen = screen; - - return buffer; -} - -static struct pipe_buffer * -pass_user_buffer_create(struct pipe_screen *screen, - void *ptr, - unsigned bytes) -{ - struct pipe_buffer *buffer = - screen->winsys->user_buffer_create(screen->winsys, ptr, bytes); - - buffer->screen = screen; - - return buffer; -} - - - -static void * -pass_buffer_map(struct pipe_screen *screen, - struct pipe_buffer *buf, - unsigned usage) -{ - return screen->winsys->buffer_map(screen->winsys, buf, usage); -} - -static void -pass_buffer_unmap(struct pipe_screen *screen, - struct pipe_buffer *buf) -{ - screen->winsys->buffer_unmap(screen->winsys, buf); -} - -static void -pass_buffer_destroy(struct pipe_buffer *buf) -{ - buf->screen->winsys->buffer_destroy(buf); -} - - -static void -pass_flush_frontbuffer(struct pipe_screen *screen, - struct pipe_surface *surf, - void *context_private) -{ - screen->winsys->flush_frontbuffer(screen->winsys, surf, context_private); -} - -static void -pass_fence_reference(struct pipe_screen *screen, - struct pipe_fence_handle **ptr, - struct pipe_fence_handle *fence) -{ - screen->winsys->fence_reference(screen->winsys, ptr, fence); -} - -static int -pass_fence_signalled(struct pipe_screen *screen, - struct pipe_fence_handle *fence, - unsigned flag) -{ - return screen->winsys->fence_signalled(screen->winsys, fence, flag); -} - -static int -pass_fence_finish(struct pipe_screen *screen, - struct pipe_fence_handle *fence, - unsigned flag) -{ - return screen->winsys->fence_finish(screen->winsys, fence, flag); -} - -void -u_simple_screen_init(struct pipe_screen *screen) -{ - screen->buffer_create = pass_buffer_create; - screen->user_buffer_create = pass_user_buffer_create; - - screen->buffer_map = pass_buffer_map; - screen->buffer_unmap = pass_buffer_unmap; - screen->buffer_destroy = pass_buffer_destroy; - screen->flush_frontbuffer = pass_flush_frontbuffer; - screen->fence_reference = pass_fence_reference; - screen->fence_signalled = pass_fence_signalled; - screen->fence_finish = pass_fence_finish; -} - -const char * -u_simple_screen_winsys_name(struct pipe_screen *screen) -{ - return screen->winsys->get_name(screen->winsys); -} diff --git a/src/gallium/auxiliary/util/u_simple_screen.h b/src/gallium/auxiliary/util/u_simple_screen.h deleted file mode 100644 index bb3f5ba102..0000000000 --- a/src/gallium/auxiliary/util/u_simple_screen.h +++ /dev/null @@ -1,184 +0,0 @@ -/************************************************************************** - * - * Copyright 2009 VMware, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -#ifndef U_SIMPLE_SCREEN_H -#define U_SIMPLE_SCREEN_H - -#include "pipe/p_format.h" - -struct pipe_screen; -struct pipe_fence_handle; -struct pipe_surface; -struct pipe_buffer; - -/** - * Gallium3D drivers are (meant to be!) independent of both GL and the - * window system. The window system provides a buffer manager and a - * set of additional hooks for things like command buffer submission, - * etc. - * - * There clearly has to be some agreement between the window system - * driver and the hardware driver about the format of command buffers, - * etc. - */ -struct pipe_winsys -{ - void (*destroy)( struct pipe_winsys *ws ); - - /** Returns name of this winsys interface */ - const char *(*get_name)( struct pipe_winsys *ws ); - - /** - * Do any special operations to ensure buffer size is correct - */ - void (*update_buffer)( struct pipe_winsys *ws, - void *context_private ); - /** - * Do any special operations to ensure frontbuffer contents are - * displayed, eg copy fake frontbuffer. - */ - void (*flush_frontbuffer)( struct pipe_winsys *ws, - struct pipe_surface *surf, - void *context_private ); - - - /** - * Buffer management. Buffer attributes are mostly fixed over its lifetime. - * - * Remember that gallium gets to choose the interface it needs, and the - * window systems must then implement that interface (rather than the - * other way around...). - * - * usage is a bitmask of PIPE_BUFFER_USAGE_PIXEL/VERTEX/INDEX/CONSTANT. This - * usage argument is only an optimization hint, not a guarantee, therefore - * proper behavior must be observed in all circumstances. - * - * alignment indicates the client's alignment requirements, eg for - * SSE instructions. - */ - struct pipe_buffer *(*buffer_create)( struct pipe_winsys *ws, - unsigned alignment, - unsigned usage, - unsigned size ); - - /** - * Create a buffer that wraps user-space data. - * - * Effectively this schedules a delayed call to buffer_create - * followed by an upload of the data at *some point in the future*, - * or perhaps never. Basically the allocate/upload is delayed - * until the buffer is actually passed to hardware. - * - * The intention is to provide a quick way to turn regular data - * into a buffer, and secondly to avoid a copy operation if that - * data subsequently turns out to be only accessed by the CPU. - * - * Common example is OpenGL vertex buffers that are subsequently - * processed either by software TNL in the driver or by passing to - * hardware. - * - * XXX: What happens if the delayed call to buffer_create() fails? - * - * Note that ptr may be accessed at any time upto the time when the - * buffer is destroyed, so the data must not be freed before then. - */ - struct pipe_buffer *(*user_buffer_create)(struct pipe_winsys *ws, - void *ptr, - unsigned bytes); - - /** - * Allocate storage for a display target surface. - * - * Often surfaces which are meant to be blitted to the front screen (i.e., - * display targets) must be allocated with special characteristics, memory - * pools, or obtained directly from the windowing system. - * - * This callback is invoked by the pipe_screenwhen creating a texture marked - * with the PIPE_TEXTURE_USAGE_DISPLAY_TARGET flag to get the underlying - * buffer storage. - */ - struct pipe_buffer *(*surface_buffer_create)(struct pipe_winsys *ws, - unsigned width, unsigned height, - enum pipe_format format, - unsigned usage, - unsigned tex_usage, - unsigned *stride); - - - /** - * Map the entire data store of a buffer object into the client's address. - * flags is bitmask of PIPE_BUFFER_USAGE_CPU_READ/WRITE flags. - */ - void *(*buffer_map)( struct pipe_winsys *ws, - struct pipe_buffer *buf, - unsigned usage ); - - void (*buffer_unmap)( struct pipe_winsys *ws, - struct pipe_buffer *buf ); - - void (*buffer_destroy)( struct pipe_buffer *buf ); - - - /** Set ptr = fence, with reference counting */ - void (*fence_reference)( struct pipe_winsys *ws, - struct pipe_fence_handle **ptr, - struct pipe_fence_handle *fence ); - - /** - * Checks whether the fence has been signalled. - * \param flags driver-specific meaning - * \return zero on success. - */ - int (*fence_signalled)( struct pipe_winsys *ws, - struct pipe_fence_handle *fence, - unsigned flag ); - - /** - * Wait for the fence to finish. - * \param flags driver-specific meaning - * \return zero on success. - */ - int (*fence_finish)( struct pipe_winsys *ws, - struct pipe_fence_handle *fence, - unsigned flag ); - -}; - -/** - * The following function initializes a simple passthrough screen. - * - * All the relevant screen function pointers will forwarded to the - * winsys. - */ -void u_simple_screen_init(struct pipe_screen *screen); - -/** - * Returns the name of the winsys associated with this screen. - */ -const char* u_simple_screen_winsys_name(struct pipe_screen *screen); - -#endif diff --git a/src/gallium/auxiliary/util/u_surface.c b/src/gallium/auxiliary/util/u_surface.c index 33306bbc2a..e21e81dcd2 100644 --- a/src/gallium/auxiliary/util/u_surface.c +++ b/src/gallium/auxiliary/util/u_surface.c @@ -50,7 +50,7 @@ boolean util_create_rgba_surface(struct pipe_screen *screen, uint width, uint height, - struct pipe_texture **textureOut, + struct pipe_resource **textureOut, struct pipe_surface **surfaceOut) { static const enum pipe_format rgbaFormats[] = { @@ -62,7 +62,7 @@ util_create_rgba_surface(struct pipe_screen *screen, const uint target = PIPE_TEXTURE_2D; const uint usage = PIPE_TEXTURE_USAGE_RENDER_TARGET; enum pipe_format format = PIPE_FORMAT_NONE; - struct pipe_texture templ; + struct pipe_resource templ; uint i; /* Choose surface format */ @@ -86,14 +86,14 @@ util_create_rgba_surface(struct pipe_screen *screen, templ.depth0 = 1; templ.tex_usage = usage; - *textureOut = screen->texture_create(screen, &templ); + *textureOut = screen->resource_create(screen, &templ); if (!*textureOut) return FALSE; /* create surface / view into texture */ *surfaceOut = screen->get_tex_surface(screen, *textureOut, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE); if (!*surfaceOut) { - pipe_texture_reference(textureOut, NULL); + pipe_resource_reference(textureOut, NULL); return FALSE; } @@ -105,11 +105,11 @@ util_create_rgba_surface(struct pipe_screen *screen, * Release the surface and texture from util_create_rgba_surface(). */ void -util_destroy_rgba_surface(struct pipe_texture *texture, +util_destroy_rgba_surface(struct pipe_resource *texture, struct pipe_surface *surface) { pipe_surface_reference(&surface, NULL); - pipe_texture_reference(&texture, NULL); + pipe_resource_reference(&texture, NULL); } diff --git a/src/gallium/auxiliary/util/u_surface.h b/src/gallium/auxiliary/util/u_surface.h index 3c60df2c3e..6428c3f91c 100644 --- a/src/gallium/auxiliary/util/u_surface.h +++ b/src/gallium/auxiliary/util/u_surface.h @@ -53,12 +53,12 @@ util_same_surface(const struct pipe_surface *s1, const struct pipe_surface *s2) extern boolean util_create_rgba_surface(struct pipe_screen *screen, uint width, uint height, - struct pipe_texture **textureOut, + struct pipe_resource **textureOut, struct pipe_surface **surfaceOut); extern void -util_destroy_rgba_surface(struct pipe_texture *texture, +util_destroy_rgba_surface(struct pipe_resource *texture, struct pipe_surface *surface); diff --git a/src/gallium/auxiliary/util/u_tile.c b/src/gallium/auxiliary/util/u_tile.c index 82e44192aa..5eabe5a69a 100644 --- a/src/gallium/auxiliary/util/u_tile.c +++ b/src/gallium/auxiliary/util/u_tile.c @@ -53,7 +53,7 @@ pipe_get_tile_raw(struct pipe_context *pipe, const void *src; if (dst_stride == 0) - dst_stride = util_format_get_stride(pt->texture->format, w); + dst_stride = util_format_get_stride(pt->resource->format, w); if (pipe_clip_tile(x, y, &w, &h, pt)) return; @@ -63,7 +63,7 @@ pipe_get_tile_raw(struct pipe_context *pipe, if(!src) return; - util_copy_rect(dst, pt->texture->format, dst_stride, 0, 0, w, h, src, pt->stride, x, y); + util_copy_rect(dst, pt->resource->format, dst_stride, 0, 0, w, h, src, pt->stride, x, y); pipe->transfer_unmap(pipe, pt); } @@ -79,7 +79,7 @@ pipe_put_tile_raw(struct pipe_context *pipe, const void *src, int src_stride) { void *dst; - enum pipe_format format = pt->texture->format; + enum pipe_format format = pt->resource->format; if (src_stride == 0) src_stride = util_format_get_stride(format, w); @@ -1253,7 +1253,7 @@ pipe_get_tile_rgba(struct pipe_context *pipe, { unsigned dst_stride = w * 4; void *packed; - enum pipe_format format = pt->texture->format; + enum pipe_format format = pt->resource->format; if (pipe_clip_tile(x, y, &w, &h, pt)) return; @@ -1345,7 +1345,7 @@ pipe_put_tile_rgba(struct pipe_context *pipe, { unsigned src_stride = w * 4; void *packed; - enum pipe_format format = pt->texture->format; + enum pipe_format format = pt->resource->format; if (pipe_clip_tile(x, y, &w, &h, pt)) return; @@ -1447,7 +1447,7 @@ pipe_get_tile_z(struct pipe_context *pipe, ubyte *map; uint *pDest = z; uint i, j; - enum pipe_format format = pt->texture->format; + enum pipe_format format = pt->resource->format; if (pipe_clip_tile(x, y, &w, &h, pt)) return; @@ -1532,7 +1532,7 @@ pipe_put_tile_z(struct pipe_context *pipe, const uint *ptrc = zSrc; ubyte *map; uint i, j; - enum pipe_format format = pt->texture->format; + enum pipe_format format = pt->resource->format; if (pipe_clip_tile(x, y, &w, &h, pt)) return; @@ -1557,7 +1557,7 @@ pipe_put_tile_z(struct pipe_context *pipe, case PIPE_FORMAT_Z24S8_UNORM: { uint *pDest = (uint *) (map + y * pt->stride + x*4); - assert((pt->usage & PIPE_TRANSFER_READ_WRITE) == PIPE_TRANSFER_READ_WRITE); + //assert((pt->usage & PIPE_TRANSFER_READ_WRITE) == PIPE_TRANSFER_READ_WRITE); for (i = 0; i < h; i++) { for (j = 0; j < w; j++) { /* convert 32-bit Z to 24-bit Z, preserve stencil */ @@ -1584,7 +1584,7 @@ pipe_put_tile_z(struct pipe_context *pipe, case PIPE_FORMAT_S8Z24_UNORM: { uint *pDest = (uint *) (map + y * pt->stride + x*4); - assert((pt->usage & PIPE_TRANSFER_READ_WRITE) == PIPE_TRANSFER_READ_WRITE); + //assert((pt->usage & PIPE_TRANSFER_READ_WRITE) == PIPE_TRANSFER_READ_WRITE); for (i = 0; i < h; i++) { for (j = 0; j < w; j++) { /* convert 32-bit Z to 24-bit Z, preserve stencil */ diff --git a/src/gallium/auxiliary/util/u_timed_winsys.c b/src/gallium/auxiliary/util/u_timed_winsys.c deleted file mode 100644 index d88298bc14..0000000000 --- a/src/gallium/auxiliary/util/u_timed_winsys.c +++ /dev/null @@ -1,312 +0,0 @@ -/************************************************************************** - * - * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - * USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * - **************************************************************************/ -/* - * Authors: Keith Whitwell <keithw-at-tungstengraphics-dot-com> - */ - -#include "pipe/p_state.h" -#include "util/u_simple_screen.h" -#include "u_timed_winsys.h" -#include "util/u_memory.h" -#include "os/os_time.h" - - -struct timed_winsys { - struct pipe_winsys base; - struct pipe_winsys *backend; - uint64_t last_dump; - struct { - const char *name_key; - double total; - unsigned calls; - } funcs[13]; -}; - - -static struct timed_winsys *timed_winsys( struct pipe_winsys *winsys ) -{ - return (struct timed_winsys *)winsys; -} - - -static void time_display( struct pipe_winsys *winsys ) -{ - struct timed_winsys *tws = timed_winsys(winsys); - unsigned i; - double overall = 0; - - for (i = 0; i < Elements(tws->funcs); i++) { - if (tws->funcs[i].name_key) { - debug_printf("*** %-25s %5.3fms (%d calls, avg %.3fms)\n", - tws->funcs[i].name_key, - tws->funcs[i].total, - tws->funcs[i].calls, - tws->funcs[i].total / tws->funcs[i].calls); - overall += tws->funcs[i].total; - tws->funcs[i].calls = 0; - tws->funcs[i].total = 0; - } - } - - debug_printf("*** %-25s %5.3fms\n", - "OVERALL WINSYS", - overall); -} - -static void time_finish( struct pipe_winsys *winsys, - long long startval, - unsigned idx, - const char *name ) -{ - struct timed_winsys *tws = timed_winsys(winsys); - int64_t endval = os_time_get(); - double elapsed = (endval - startval)/1000.0; - - if (endval - startval > 1000LL) - debug_printf("*** %s %.3f\n", name, elapsed ); - - assert( tws->funcs[idx].name_key == name || - tws->funcs[idx].name_key == NULL); - - tws->funcs[idx].name_key = name; - tws->funcs[idx].total += elapsed; - tws->funcs[idx].calls++; - - if (endval - tws->last_dump > 10LL * 1000LL * 1000LL) { - time_display( winsys ); - tws->last_dump = endval; - } -} - - -/* Pipe has no concept of pools, but the psb driver passes a flag that - * can be mapped onto pools in the backend. - */ -static struct pipe_buffer * -timed_buffer_create(struct pipe_winsys *winsys, - unsigned alignment, - unsigned usage, - unsigned size ) -{ - struct pipe_winsys *backend = timed_winsys(winsys)->backend; - int64_t start = os_time_get(); - - struct pipe_buffer *buf = - backend->buffer_create( backend, alignment, usage, size ); - - time_finish(winsys, start, 0, __FUNCTION__); - - return buf; -} - - - - -static struct pipe_buffer * -timed_user_buffer_create(struct pipe_winsys *winsys, - void *data, - unsigned bytes) -{ - struct pipe_winsys *backend = timed_winsys(winsys)->backend; - int64_t start = os_time_get(); - - struct pipe_buffer *buf = backend->user_buffer_create( backend, data, bytes ); - - time_finish(winsys, start, 1, __FUNCTION__); - - return buf; -} - - -static void * -timed_buffer_map(struct pipe_winsys *winsys, - struct pipe_buffer *buf, - unsigned flags) -{ - struct pipe_winsys *backend = timed_winsys(winsys)->backend; - int64_t start = os_time_get(); - - void *map = backend->buffer_map( backend, buf, flags ); - - time_finish(winsys, start, 2, __FUNCTION__); - - return map; -} - - -static void -timed_buffer_unmap(struct pipe_winsys *winsys, - struct pipe_buffer *buf) -{ - struct pipe_winsys *backend = timed_winsys(winsys)->backend; - int64_t start = os_time_get(); - - backend->buffer_unmap( backend, buf ); - - time_finish(winsys, start, 3, __FUNCTION__); -} - - -static void -timed_buffer_destroy(struct pipe_buffer *buf) -{ - struct pipe_winsys *winsys = buf->screen->winsys; - struct pipe_winsys *backend = timed_winsys(winsys)->backend; - int64_t start = os_time_get(); - - backend->buffer_destroy( buf ); - - time_finish(winsys, start, 4, __FUNCTION__); -} - - -static void -timed_flush_frontbuffer( struct pipe_winsys *winsys, - struct pipe_surface *surf, - void *context_private) -{ - struct pipe_winsys *backend = timed_winsys(winsys)->backend; - int64_t start = os_time_get(); - - backend->flush_frontbuffer( backend, surf, context_private ); - - time_finish(winsys, start, 5, __FUNCTION__); -} - - - - -static struct pipe_buffer * -timed_surface_buffer_create(struct pipe_winsys *winsys, - unsigned width, unsigned height, - enum pipe_format format, - unsigned usage, - unsigned tex_usage, - unsigned *stride) -{ - struct pipe_winsys *backend = timed_winsys(winsys)->backend; - int64_t start = os_time_get(); - - struct pipe_buffer *ret = backend->surface_buffer_create( backend, width, height, - format, usage, tex_usage, stride ); - - time_finish(winsys, start, 7, __FUNCTION__); - - return ret; -} - - -static const char * -timed_get_name( struct pipe_winsys *winsys ) -{ - struct pipe_winsys *backend = timed_winsys(winsys)->backend; - int64_t start = os_time_get(); - - const char *ret = backend->get_name( backend ); - - time_finish(winsys, start, 9, __FUNCTION__); - - return ret; -} - -static void -timed_fence_reference(struct pipe_winsys *winsys, - struct pipe_fence_handle **ptr, - struct pipe_fence_handle *fence) -{ - struct pipe_winsys *backend = timed_winsys(winsys)->backend; - int64_t start = os_time_get(); - - backend->fence_reference( backend, ptr, fence ); - - time_finish(winsys, start, 10, __FUNCTION__); -} - - -static int -timed_fence_signalled( struct pipe_winsys *winsys, - struct pipe_fence_handle *fence, - unsigned flag ) -{ - struct pipe_winsys *backend = timed_winsys(winsys)->backend; - int64_t start = os_time_get(); - - int ret = backend->fence_signalled( backend, fence, flag ); - - time_finish(winsys, start, 11, __FUNCTION__); - - return ret; -} - -static int -timed_fence_finish( struct pipe_winsys *winsys, - struct pipe_fence_handle *fence, - unsigned flag ) -{ - struct pipe_winsys *backend = timed_winsys(winsys)->backend; - int64_t start = os_time_get(); - - int ret = backend->fence_finish( backend, fence, flag ); - - time_finish(winsys, start, 12, __FUNCTION__); - - return ret; -} - -static void -timed_winsys_destroy( struct pipe_winsys *winsys ) -{ - struct pipe_winsys *backend = timed_winsys(winsys)->backend; - backend->destroy( backend ); - FREE(winsys); -} - - - -struct pipe_winsys *u_timed_winsys_create( struct pipe_winsys *backend ) -{ - struct timed_winsys *ws = CALLOC_STRUCT(timed_winsys); - - ws->base.user_buffer_create = timed_user_buffer_create; - ws->base.buffer_map = timed_buffer_map; - ws->base.buffer_unmap = timed_buffer_unmap; - ws->base.buffer_destroy = timed_buffer_destroy; - ws->base.buffer_create = timed_buffer_create; - ws->base.surface_buffer_create = timed_surface_buffer_create; - ws->base.flush_frontbuffer = timed_flush_frontbuffer; - ws->base.get_name = timed_get_name; - ws->base.fence_reference = timed_fence_reference; - ws->base.fence_signalled = timed_fence_signalled; - ws->base.fence_finish = timed_fence_finish; - ws->base.destroy = timed_winsys_destroy; - - ws->backend = backend; - - return &ws->base; -} - diff --git a/src/gallium/auxiliary/util/u_timed_winsys.h b/src/gallium/auxiliary/util/u_timed_winsys.h deleted file mode 100644 index 542365112d..0000000000 --- a/src/gallium/auxiliary/util/u_timed_winsys.h +++ /dev/null @@ -1,41 +0,0 @@ -/************************************************************************** - * - * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - * USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * - **************************************************************************/ -/* - * Authors: Keith Whitwell <keithw-at-tungstengraphics-dot-com> - */ - - -#ifndef U_TIMED_WINSYS_H -#define U_TIMED_WINSYS_H - - -struct pipe_winsys; -struct pipe_winsys *u_timed_winsys_create( struct pipe_winsys *backend ); - - -#endif diff --git a/src/gallium/auxiliary/util/u_upload_mgr.c b/src/gallium/auxiliary/util/u_upload_mgr.c index 012b2ae233..ea17b74815 100644 --- a/src/gallium/auxiliary/util/u_upload_mgr.c +++ b/src/gallium/auxiliary/util/u_upload_mgr.c @@ -31,7 +31,7 @@ #include "pipe/p_defines.h" #include "util/u_inlines.h" -#include "pipe/p_screen.h" +#include "pipe/p_context.h" #include "util/u_memory.h" #include "util/u_math.h" @@ -39,7 +39,7 @@ struct u_upload_mgr { - struct pipe_screen *screen; + struct pipe_context *pipe; unsigned default_size; unsigned alignment; @@ -47,21 +47,21 @@ struct u_upload_mgr { /* The active buffer: */ - struct pipe_buffer *buffer; + struct pipe_resource *buffer; unsigned size; unsigned offset; }; -struct u_upload_mgr *u_upload_create( struct pipe_screen *screen, +struct u_upload_mgr *u_upload_create( struct pipe_context *pipe, unsigned default_size, unsigned alignment, unsigned usage ) { struct u_upload_mgr *upload = CALLOC_STRUCT( u_upload_mgr ); + upload->pipe = pipe; upload->default_size = default_size; - upload->screen = screen; upload->alignment = alignment; upload->usage = usage; upload->buffer = NULL; @@ -69,31 +69,44 @@ struct u_upload_mgr *u_upload_create( struct pipe_screen *screen, return upload; } - +/* Slightly specialized version of buffer_write designed to maximize + * chances of the driver consolidating successive writes into a single + * upload. + * + * dirty_size may be slightly greater than size to cope with + * alignment. We don't want to leave holes between succesively mapped + * regions as that may prevent the driver from consolidating uploads. + * + * Note that the 'data' pointer has probably come from the application + * and we cannot read even a byte past its end without risking + * segfaults, or at least complaints from valgrind.. + */ static INLINE enum pipe_error -my_buffer_write(struct pipe_screen *screen, - struct pipe_buffer *buf, +my_buffer_write(struct pipe_context *pipe, + struct pipe_resource *buf, unsigned offset, unsigned size, unsigned dirty_size, const void *data) { + struct pipe_transfer *transfer = NULL; uint8_t *map; - assert(offset < buf->size); - assert(offset + size <= buf->size); + assert(offset < buf->width0); + assert(offset + size <= buf->width0); assert(dirty_size >= size); assert(size); - map = pipe_buffer_map_range(screen, buf, offset, size, - PIPE_BUFFER_USAGE_CPU_WRITE | - PIPE_BUFFER_USAGE_FLUSH_EXPLICIT | - PIPE_BUFFER_USAGE_DISCARD | - PIPE_BUFFER_USAGE_UNSYNCHRONIZED); + map = pipe_buffer_map_range(pipe, buf, offset, size, + PIPE_TRANSFER_WRITE | + PIPE_TRANSFER_FLUSH_EXPLICIT | + PIPE_TRANSFER_DISCARD | + PIPE_TRANSFER_UNSYNCHRONIZED, + &transfer); if (map == NULL) return PIPE_ERROR_OUT_OF_MEMORY; memcpy(map + offset, data, size); - pipe_buffer_flush_mapped_range(screen, buf, offset, dirty_size); - pipe_buffer_unmap(screen, buf); + pipe_buffer_flush_mapped_range(pipe, transfer, offset, dirty_size); + pipe_buffer_unmap(pipe, buf, transfer); return PIPE_OK; } @@ -109,7 +122,7 @@ my_buffer_write(struct pipe_screen *screen, */ void u_upload_flush( struct u_upload_mgr *upload ) { - pipe_buffer_reference( &upload->buffer, NULL ); + pipe_resource_reference( &upload->buffer, NULL ); upload->size = 0; } @@ -135,7 +148,7 @@ u_upload_alloc_buffer( struct u_upload_mgr *upload, */ size = align(MAX2(upload->default_size, min_size), 4096); - upload->buffer = pipe_buffer_create( upload->screen, + upload->buffer = pipe_buffer_create( upload->pipe->screen, upload->alignment, upload->usage | PIPE_BUFFER_USAGE_CPU_WRITE, size ); @@ -149,7 +162,7 @@ u_upload_alloc_buffer( struct u_upload_mgr *upload, fail: if (upload->buffer) - pipe_buffer_reference( &upload->buffer, NULL ); + pipe_resource_reference( &upload->buffer, NULL ); return PIPE_ERROR_OUT_OF_MEMORY; } @@ -159,7 +172,7 @@ enum pipe_error u_upload_data( struct u_upload_mgr *upload, unsigned size, const void *data, unsigned *out_offset, - struct pipe_buffer **outbuf ) + struct pipe_resource **outbuf ) { unsigned alloc_size = align( size, upload->alignment ); enum pipe_error ret = PIPE_OK; @@ -172,7 +185,7 @@ enum pipe_error u_upload_data( struct u_upload_mgr *upload, /* Copy the data, using map_range if available: */ - ret = my_buffer_write( upload->screen, + ret = my_buffer_write( upload->pipe, upload->buffer, upload->offset, size, @@ -183,7 +196,7 @@ enum pipe_error u_upload_data( struct u_upload_mgr *upload, /* Emit the return values: */ - pipe_buffer_reference( outbuf, upload->buffer ); + pipe_resource_reference( outbuf, upload->buffer ); *out_offset = upload->offset; upload->offset += alloc_size; return PIPE_OK; @@ -198,15 +211,18 @@ enum pipe_error u_upload_data( struct u_upload_mgr *upload, enum pipe_error u_upload_buffer( struct u_upload_mgr *upload, unsigned offset, unsigned size, - struct pipe_buffer *inbuf, + struct pipe_resource *inbuf, unsigned *out_offset, - struct pipe_buffer **outbuf ) + struct pipe_resource **outbuf ) { enum pipe_error ret = PIPE_OK; + struct pipe_transfer *transfer = NULL; const char *map = NULL; - map = (const char *)pipe_buffer_map( - upload->screen, inbuf, PIPE_BUFFER_USAGE_CPU_READ ); + map = (const char *)pipe_buffer_map(upload->pipe, + inbuf, + PIPE_TRANSFER_READ, + &transfer); if (map == NULL) { ret = PIPE_ERROR_OUT_OF_MEMORY; @@ -226,7 +242,7 @@ enum pipe_error u_upload_buffer( struct u_upload_mgr *upload, done: if (map) - pipe_buffer_unmap( upload->screen, inbuf ); + pipe_buffer_unmap( upload->pipe, inbuf, transfer ); return ret; } diff --git a/src/gallium/auxiliary/util/u_upload_mgr.h b/src/gallium/auxiliary/util/u_upload_mgr.h index e158bed9d0..a124924fc8 100644 --- a/src/gallium/auxiliary/util/u_upload_mgr.h +++ b/src/gallium/auxiliary/util/u_upload_mgr.h @@ -35,11 +35,11 @@ #include "pipe/p_defines.h" struct pipe_screen; -struct pipe_buffer; +struct pipe_resource; struct u_upload_mgr; -struct u_upload_mgr *u_upload_create( struct pipe_screen *screen, +struct u_upload_mgr *u_upload_create( struct pipe_context *pipe, unsigned default_size, unsigned alignment, unsigned usage ); @@ -61,15 +61,15 @@ enum pipe_error u_upload_data( struct u_upload_mgr *upload, unsigned size, const void *data, unsigned *out_offset, - struct pipe_buffer **outbuf ); + struct pipe_resource **outbuf ); enum pipe_error u_upload_buffer( struct u_upload_mgr *upload, unsigned offset, unsigned size, - struct pipe_buffer *inbuf, + struct pipe_resource *inbuf, unsigned *out_offset, - struct pipe_buffer **outbuf ); + struct pipe_resource **outbuf ); diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c index d62bfa3d63..20368eadca 100644 --- a/src/gallium/drivers/softpipe/sp_screen.c +++ b/src/gallium/drivers/softpipe/sp_screen.c @@ -206,7 +206,7 @@ softpipe_flush_frontbuffer(struct pipe_screen *_screen, { struct softpipe_screen *screen = softpipe_screen(_screen); struct sw_winsys *winsys = screen->winsys; - struct softpipe_texture *texture = softpipe_texture(surface->texture); + struct softpipe_resource *texture = softpipe_resource(surface->texture); assert(texture->dt); if (texture->dt) diff --git a/src/gallium/drivers/softpipe/sp_state_derived.c b/src/gallium/drivers/softpipe/sp_state_derived.c index d2eda7324c..4c6d4909f5 100644 --- a/src/gallium/drivers/softpipe/sp_state_derived.c +++ b/src/gallium/drivers/softpipe/sp_state_derived.c @@ -202,7 +202,7 @@ update_tgsi_samplers( struct softpipe_context *softpipe ) for (i = 0; i < PIPE_MAX_SAMPLERS; i++) { struct softpipe_tex_tile_cache *tc = softpipe->tex_cache[i]; if (tc->texture) { - struct softpipe_texture *spt = softpipe_texture(tc->texture); + struct softpipe_resource *spt = softpipe_resource(tc->texture); if (spt->timestamp != tc->timestamp) { sp_tex_tile_cache_validate_texture( tc ); /* @@ -217,7 +217,7 @@ update_tgsi_samplers( struct softpipe_context *softpipe ) struct softpipe_tex_tile_cache *tc = softpipe->vertex_tex_cache[i]; if (tc->texture) { - struct softpipe_texture *spt = softpipe_texture(tc->texture); + struct softpipe_resource *spt = softpipe_resource(tc->texture); if (spt->timestamp != tc->timestamp) { sp_tex_tile_cache_validate_texture(tc); diff --git a/src/gallium/drivers/softpipe/sp_state_fs.c b/src/gallium/drivers/softpipe/sp_state_fs.c index 9bd9c514f1..b422d2794f 100644 --- a/src/gallium/drivers/softpipe/sp_state_fs.c +++ b/src/gallium/drivers/softpipe/sp_state_fs.c @@ -179,7 +179,7 @@ softpipe_set_constant_buffer(struct pipe_context *pipe, draw_flush(softpipe->draw); /* note: reference counting */ - pipe_buffer_reference(&softpipe->constants[shader][index], constants); + pipe_resource_reference(&softpipe->constants[shader][index], constants); if(shader == PIPE_SHADER_VERTEX) { draw_set_mapped_constant_buffer(softpipe->draw, PIPE_SHADER_VERTEX, index, diff --git a/src/gallium/drivers/softpipe/sp_state_sampler.c b/src/gallium/drivers/softpipe/sp_state_sampler.c index d501952bba..925b55c089 100644 --- a/src/gallium/drivers/softpipe/sp_state_sampler.c +++ b/src/gallium/drivers/softpipe/sp_state_sampler.c @@ -123,7 +123,7 @@ softpipe_bind_vertex_sampler_states(struct pipe_context *pipe, struct pipe_sampler_view * softpipe_create_sampler_view(struct pipe_context *pipe, - struct pipe_texture *texture, + struct pipe_resource *resource, const struct pipe_sampler_view *templ) { struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view); @@ -132,7 +132,7 @@ softpipe_create_sampler_view(struct pipe_context *pipe, *view = *templ; view->reference.count = 1; view->texture = NULL; - pipe_texture_reference(&view->texture, texture); + pipe_resource_reference(&view->resource, resource); view->context = pipe; } @@ -223,10 +223,10 @@ softpipe_set_vertex_sampler_views(struct pipe_context *pipe, static struct sp_sampler_varient * get_sampler_varient( unsigned unit, struct sp_sampler *sampler, - struct pipe_texture *texture, + struct pipe_resource *resource, unsigned processor ) { - struct softpipe_texture *sp_texture = softpipe_texture(texture); + struct softpipe_texture *sp_texture = softpipe_resource(resource); struct sp_sampler_varient *v = NULL; union sp_sampler_key key; @@ -274,7 +274,7 @@ softpipe_reset_sampler_varients(struct softpipe_context *softpipe) */ for (i = 0; i <= softpipe->vs->max_sampler; i++) { if (softpipe->vertex_samplers[i]) { - struct pipe_texture *texture = NULL; + struct pipe_resource *texture = NULL; if (softpipe->vertex_sampler_views[i]) { texture = softpipe->vertex_sampler_views[i]->texture; diff --git a/src/gallium/drivers/softpipe/sp_tex_tile_cache.c b/src/gallium/drivers/softpipe/sp_tex_tile_cache.c index edd8e5c187..d2f422e000 100644 --- a/src/gallium/drivers/softpipe/sp_tex_tile_cache.c +++ b/src/gallium/drivers/softpipe/sp_tex_tile_cache.c @@ -244,13 +244,13 @@ sp_find_cached_tile_tex(struct softpipe_tex_tile_cache *tc, } tc->tex_trans = - tc->pipe->get_transfer(tc->pipe, tc->texture, - addr.bits.face, - addr.bits.level, - addr.bits.z, - PIPE_TRANSFER_READ, 0, 0, - u_minify(tc->texture->width0, addr.bits.level), - u_minify(tc->texture->height0, addr.bits.level)); + pipe_get_transfer(tc->pipe, tc->texture, + addr.bits.face, + addr.bits.level, + addr.bits.z, + PIPE_TRANSFER_READ, 0, 0, + u_minify(tc->texture->width0, addr.bits.level), + u_minify(tc->texture->height0, addr.bits.level)); tc->tex_trans_map = tc->pipe->transfer_map(tc->pipe, tc->tex_trans); diff --git a/src/gallium/drivers/softpipe/sp_texture.c b/src/gallium/drivers/softpipe/sp_texture.c index d108bef002..2e8871b820 100644 --- a/src/gallium/drivers/softpipe/sp_texture.c +++ b/src/gallium/drivers/softpipe/sp_texture.c @@ -257,49 +257,52 @@ softpipe_tex_surface_destroy(struct pipe_surface *surf) */ static struct pipe_transfer * softpipe_get_transfer(struct pipe_context *pipe, - struct pipe_resource *resource, - struct pipe_subresource subresource, - enum pipe_transfer_usage usage, - const struct pipe_box *box) + struct pipe_resource *resource, + struct pipe_subresource sr, + enum pipe_transfer_usage usage, + const struct pipe_box *box) { - struct softpipe_texture *sptex = softpipe_texture(texture); + struct softpipe_texture *sptex = softpipe_texture(resource); struct softpipe_transfer *spt; - assert(texture); - assert(level <= texture->last_level); + assert(resource); + assert(sr.level <= resource->last_level); /* make sure the requested region is in the image bounds */ - assert(x + w <= u_minify(texture->width0, level)); - assert(y + h <= u_minify(texture->height0, level)); + assert(box->x + box->width <= u_minify(resource->width0, sr.level)); + assert(box->y + box->height <= u_minify(resource->height0, sr.level)); + assert(box->z + box->depth <= u_minify(resource->depth0, sr.level)); spt = CALLOC_STRUCT(softpipe_transfer); if (spt) { struct pipe_transfer *pt = &spt->base; - int nblocksy = util_format_get_nblocksy(texture->format, - u_minify(texture->height0, level)); - pipe_texture_reference(&resource, texture); - pt->x = x; - pt->y = y; - pt->width = w; - pt->height = h; - pt->stride = sptex->stride[level]; - pt->usage = usage; - pt->face = face; - pt->level = level; - pt->zslice = zslice; - - spt->offset = sptex->level_offset[level]; - - if (texture->target == PIPE_TEXTURE_CUBE) { - spt->offset += face * nblocksy * pt->stride; + enum pipe_format format = resource->format; + int nblocksy = util_format_get_nblocksy(resource->format, + u_minify(resource->height0, sr.level)); + pipe_resource_reference(&resource, resource); + pt->box = *box; + pt->stride = sptex->stride[sr.level]; + //pt->usage = usage; + //pt->face = face; + //pt->level = level; + + spt->offset = sptex->level_offset[sr.level]; + + if (resource->target == PIPE_TEXTURE_CUBE) { + spt->offset += sr.face * nblocksy * pt->stride; } - else if (texture->target == PIPE_TEXTURE_3D) { - spt->offset += zslice * nblocksy * pt->stride; + else if (resource->target == PIPE_TEXTURE_3D) { + spt->offset += box->z * nblocksy * pt->stride; } else { - assert(face == 0); - assert(zslice == 0); + assert(sr.face == 0); + assert(box->z == 0); } + + spt->offset += + box->y / util_format_get_blockheight(format) * spt->base.stride + + box->x / util_format_get_blockwidth(format) * util_format_get_blocksize(format); + return pt; } return NULL; @@ -318,8 +321,8 @@ softpipe_transfer_destroy(struct pipe_context *pipe, * needed post-processing to put them into hardware layout, this is * where it would happen. For softpipe, nothing to do. */ - assert (transfer->texture); - pipe_texture_reference(&transfer->texture, NULL); + assert (transfer->resource); + pipe_resource_reference(&transfer->resource, NULL); FREE(transfer); } @@ -333,11 +336,9 @@ softpipe_transfer_map( struct pipe_context *pipe, { ubyte *map, *xfer_map; struct softpipe_texture *spt; - enum pipe_format format; - assert(transfer->texture); - spt = softpipe_texture(transfer->texture); - format = transfer->texture->format; + assert(transfer->resource); + spt = softpipe_texture(transfer->resource); if (spt->dt) { /* display target */ @@ -357,16 +358,14 @@ softpipe_transfer_map( struct pipe_context *pipe, /* May want to different things here depending on read/write nature * of the map: */ - if (transfer->texture && (transfer->usage & PIPE_TRANSFER_WRITE)) { + if (transfer->resource && (transfer->usage & PIPE_TRANSFER_WRITE)) { /* Do something to notify sharing contexts of a texture change. * In softpipe, that would mean flushing the texture cache. */ softpipe_screen(pipe->screen)->timestamp++; } - xfer_map = map + softpipe_transfer(transfer)->offset + - transfer->y / util_format_get_blockheight(format) * transfer->stride + - transfer->x / util_format_get_blockwidth(format) * util_format_get_blocksize(format); + xfer_map = map + softpipe_transfer(transfer)->offset; /*printf("map = %p xfer map = %p\n", map, xfer_map);*/ return xfer_map; } @@ -381,8 +380,8 @@ softpipe_transfer_unmap(struct pipe_context *pipe, { struct softpipe_texture *spt; - assert(transfer->texture); - spt = softpipe_texture(transfer->texture); + assert(transfer->resource); + spt = softpipe_texture(transfer->resource); if (spt->dt) { /* display target */ @@ -397,56 +396,6 @@ softpipe_transfer_unmap(struct pipe_context *pipe, } -static struct pipe_video_surface* -softpipe_video_surface_create(struct pipe_screen *screen, - enum pipe_video_chroma_format chroma_format, - unsigned width, unsigned height) -{ - struct softpipe_video_surface *sp_vsfc; - struct pipe_texture template; - - assert(screen); - assert(width && height); - - sp_vsfc = CALLOC_STRUCT(softpipe_video_surface); - if (!sp_vsfc) - return NULL; - - pipe_reference_init(&sp_vsfc->base.reference, 1); - sp_vsfc->base.screen = screen; - sp_vsfc->base.chroma_format = chroma_format; - /*sp_vsfc->base.surface_format = PIPE_VIDEO_SURFACE_FORMAT_VUYA;*/ - sp_vsfc->base.width = width; - sp_vsfc->base.height = height; - - memset(&template, 0, sizeof(struct pipe_texture)); - template.target = PIPE_TEXTURE_2D; - template.format = PIPE_FORMAT_B8G8R8X8_UNORM; - template.last_level = 0; - /* vl_mpeg12_mc_renderer expects this when it's initialized with pot_buffers=true */ - template.width0 = util_next_power_of_two(width); - template.height0 = util_next_power_of_two(height); - template.depth0 = 1; - template.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER | PIPE_TEXTURE_USAGE_RENDER_TARGET; - - sp_vsfc->tex = screen->texture_create(screen, &template); - if (!sp_vsfc->tex) { - FREE(sp_vsfc); - return NULL; - } - - return &sp_vsfc->base; -} - - -static void -softpipe_video_surface_destroy(struct pipe_video_surface *vsfc) -{ - struct softpipe_video_surface *sp_vsfc = softpipe_video_surface(vsfc); - - pipe_texture_reference(&sp_vsfc->tex, NULL); - FREE(sp_vsfc); -} void @@ -461,14 +410,11 @@ softpipe_init_texture_funcs(struct pipe_context *pipe) void softpipe_init_screen_texture_funcs(struct pipe_screen *screen) { - screen->texture_create = softpipe_texture_create; - screen->texture_destroy = softpipe_texture_destroy; + screen->resource_create = softpipe_texture_create; + screen->resource_destroy = softpipe_texture_destroy; screen->get_tex_surface = softpipe_get_tex_surface; screen->tex_surface_destroy = softpipe_tex_surface_destroy; - - screen->video_surface_create = softpipe_video_surface_create; - screen->video_surface_destroy = softpipe_video_surface_destroy; } diff --git a/src/gallium/drivers/softpipe/sp_texture.h b/src/gallium/drivers/softpipe/sp_texture.h index c0e6ba8a86..5d2e3cea81 100644 --- a/src/gallium/drivers/softpipe/sp_texture.h +++ b/src/gallium/drivers/softpipe/sp_texture.h @@ -44,7 +44,7 @@ struct softpipe_context; struct softpipe_texture { - struct pipe_texture base; + struct pipe_resource base; unsigned long level_offset[SP_MAX_TEXTURE_2D_LEVELS]; unsigned stride[SP_MAX_TEXTURE_2D_LEVELS]; @@ -85,10 +85,10 @@ struct softpipe_video_surface /** cast wrappers */ -static INLINE struct softpipe_texture * -softpipe_texture(struct pipe_texture *pt) +static INLINE struct softpipe_resource * +softpipe_resource(struct pipe_resource *pt) { - return (struct softpipe_texture *) pt; + return (struct softpipe_resource *) pt; } static INLINE struct softpipe_transfer * diff --git a/src/gallium/drivers/softpipe/sp_tile_cache.c b/src/gallium/drivers/softpipe/sp_tile_cache.c index cd99a92237..dde9f0e1b9 100644 --- a/src/gallium/drivers/softpipe/sp_tile_cache.c +++ b/src/gallium/drivers/softpipe/sp_tile_cache.c @@ -276,14 +276,14 @@ static void sp_tile_cache_flush_clear(struct softpipe_tile_cache *tc) { struct pipe_transfer *pt = tc->transfer; - const uint w = tc->transfer->width; - const uint h = tc->transfer->height; + const uint w = tc->transfer->box.width; + const uint h = tc->transfer->box.height; uint x, y; uint numCleared = 0; - assert(pt->texture); + assert(pt->resource); /* clear the scratch tile to the clear value */ - clear_tile(&tc->tile, pt->texture->format, tc->clear_val); + clear_tile(&tc->tile, pt->resource->format, tc->clear_val); /* push the tile to all positions marked as clear */ for (y = 0; y < h; y += TILE_SIZE) { @@ -372,7 +372,7 @@ sp_find_cached_tile(struct softpipe_tile_cache *tc, if (addr.value != tile->addr.value) { - assert(pt->texture); + assert(pt->resource); if (tile->addr.bits.invalid == 0) { /* put dirty tile back in framebuffer */ if (tc->depth_stencil) { @@ -396,10 +396,10 @@ sp_find_cached_tile(struct softpipe_tile_cache *tc, if (is_clear_flag_set(tc->clear_flags, addr)) { /* don't get tile from framebuffer, just clear it */ if (tc->depth_stencil) { - clear_tile(tile, pt->texture->format, tc->clear_val); + clear_tile(tile, pt->resource->format, tc->clear_val); } else { - clear_tile_rgba(tile, pt->texture->format, tc->clear_color); + clear_tile_rgba(tile, pt->resource->format, tc->clear_color); } clear_clear_flag(tc->clear_flags, addr); } diff --git a/src/gallium/include/pipe/p_screen.h b/src/gallium/include/pipe/p_screen.h index e355f74f8b..a2cc0a8953 100644 --- a/src/gallium/include/pipe/p_screen.h +++ b/src/gallium/include/pipe/p_screen.h @@ -128,7 +128,8 @@ struct pipe_screen { struct winsys_handle *handle); - void (*resource_destroy)(struct pipe_resource *pt); + void (*resource_destroy)(struct pipe_screen *, + struct pipe_resource *pt); /** Get a 2D surface which is a "view" into a texture * \param usage bitmaks of PIPE_BUFFER_USAGE_* read/write flags diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h index 4803ff7295..dac210ba07 100644 --- a/src/gallium/include/pipe/p_state.h +++ b/src/gallium/include/pipe/p_state.h @@ -309,12 +309,25 @@ struct pipe_sampler_view }; +struct pipe_box +{ + unsigned x; + unsigned y; + unsigned z; + unsigned width; + unsigned height; + unsigned depth; +}; + + + /** * Transfer object. For data transfer to/from a texture. */ struct pipe_transfer { struct pipe_resource *resource; /**< resource to transfer to/from */ + struct pipe_box box; unsigned stride; unsigned slice_stride; void *data; @@ -342,8 +355,8 @@ struct pipe_resource unsigned tex_usage; /**< bitmask of PIPE_TEXTURE_USAGE_* */ }; -#define pipe_texture pipe_resource -#define pipe_buffer pipe_resource +//#define pipe_texture pipe_resource +//#define pipe_buffer pipe_resource struct pipe_subresource { @@ -351,17 +364,6 @@ struct pipe_subresource unsigned level:16; }; -struct pipe_box -{ - unsigned x; - unsigned y; - unsigned z; - unsigned w; - unsigned h; - unsigned d; -}; - - /** * A vertex buffer. Typically, all the vertex data/attributes for diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c index ccf75fe599..6185e4dc3e 100644 --- a/src/mesa/state_tracker/st_cb_bitmap.c +++ b/src/mesa/state_tracker/st_cb_bitmap.c @@ -652,7 +652,7 @@ st_flush_bitmap( struct st_context *st ) /* Release vertex buffer to avoid synchronous rendering if we were * to map it in the next frame. */ - pipe_buffer_reference(&st->bitmap.vbuf, NULL); + pipe_resource_reference(&st->bitmap.vbuf, NULL); st->bitmap.vbuf_slot = 0; } @@ -843,7 +843,7 @@ st_destroy_bitmap(struct st_context *st) } if (st->bitmap.vbuf) { - pipe_buffer_reference(&st->bitmap.vbuf, NULL); + pipe_resource_reference(&st->bitmap.vbuf, NULL); st->bitmap.vbuf = NULL; } diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.c b/src/mesa/state_tracker/st_cb_bufferobjects.c index 2e14aeb268..af3bc4f9b5 100644 --- a/src/mesa/state_tracker/st_cb_bufferobjects.c +++ b/src/mesa/state_tracker/st_cb_bufferobjects.c @@ -79,7 +79,7 @@ st_bufferobj_free(GLcontext *ctx, struct gl_buffer_object *obj) assert(st_obj->transfer == NULL); if (st_obj->buffer) - pipe_buffer_reference(&st_obj->buffer, NULL); + pipe_resource_reference(&st_obj->buffer, NULL); free(st_obj); } @@ -193,7 +193,7 @@ st_bufferobj_data(GLcontext *ctx, buffer_usage = 0; } - pipe_buffer_reference( &st_obj->buffer, NULL ); + pipe_resource_reference( &st_obj->buffer, NULL ); if (size != 0) { st_obj->buffer = pipe_buffer_create(pipe->screen, 32, buffer_usage, size); diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index de86062fc4..66e41624cc 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -94,7 +94,7 @@ st_destroy_clear(struct st_context *st) st->clear.vs = NULL; } if (st->clear.vbuf) { - pipe_buffer_reference(&st->clear.vbuf, NULL); + pipe_resource_reference(&st->clear.vbuf, NULL); st->clear.vbuf = NULL; } } @@ -126,7 +126,7 @@ draw_quad(GLcontext *ctx, GLuint i; if (st->clear.vbuf_slot >= max_slots) { - pipe_buffer_reference(&st->clear.vbuf, NULL); + pipe_resource_reference(&st->clear.vbuf, NULL); st->clear.vbuf_slot = 0; } @@ -422,7 +422,7 @@ void st_flush_clear( struct st_context *st ) /* Release vertex buffer to avoid synchronous rendering if we were * to map it in the next frame. */ - pipe_buffer_reference(&st->clear.vbuf, NULL); + pipe_resource_reference(&st->clear.vbuf, NULL); st->clear.vbuf_slot = 0; } diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index fc6ad5671d..5b168e92e5 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -515,7 +515,7 @@ draw_quad(GLcontext *ctx, GLfloat x0, GLfloat y0, GLfloat z, PIPE_PRIM_QUADS, 4, /* verts */ 3); /* attribs/vert */ - pipe_buffer_reference(&buf, NULL); + pipe_resource_reference(&buf, NULL); } } diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index ce1a2ea33c..85dd9df7ce 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -221,7 +221,7 @@ static void st_destroy_context_priv( struct st_context *st ) for (i = 0; i < Elements(st->state.constants); i++) { if (st->state.constants[i]) { - pipe_buffer_reference(&st->state.constants[i], NULL); + pipe_resource_reference(&st->state.constants[i], NULL); } } diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index f2f706665a..7dd50797e4 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -360,12 +360,13 @@ setup_interleaved_attribs(GLcontext *ctx, offset0 = low; if (userSpace) { vbuffer->buffer = - pipe_user_buffer_create(pipe->screen, (void *) low, high - low); + pipe_user_buffer_create(pipe->screen, (void *) low, high - low, + PIPE_BUFFER_USAGE_VERTEX); vbuffer->buffer_offset = 0; } else { vbuffer->buffer = NULL; - pipe_buffer_reference(&vbuffer->buffer, stobj->buffer); + pipe_resource_reference(&vbuffer->buffer, stobj->buffer); vbuffer->buffer_offset = pointer_to_offset(low); } vbuffer->stride = stride; /* in bytes */ @@ -422,7 +423,7 @@ setup_non_interleaved_attribs(GLcontext *ctx, /*printf("stobj %u = %p\n", attr, (void*) stobj);*/ vbuffer[attr].buffer = NULL; - pipe_buffer_reference(&vbuffer[attr].buffer, stobj->buffer); + pipe_resource_reference(&vbuffer[attr].buffer, stobj->buffer); vbuffer[attr].buffer_offset = pointer_to_offset(arrays[mesaAttr]->Ptr); velements[attr].src_offset = 0; } @@ -443,14 +444,19 @@ setup_non_interleaved_attribs(GLcontext *ctx, bytes = arrays[mesaAttr]->Size * _mesa_sizeof_type(arrays[mesaAttr]->Type); } - vbuffer[attr].buffer = pipe_user_buffer_create(pipe->screen, - (void *) arrays[mesaAttr]->Ptr, bytes); + vbuffer[attr].buffer = + pipe_user_buffer_create(pipe->screen, + (void *) arrays[mesaAttr]->Ptr, bytes, + PIPE_BUFFER_USAGE_VERTEX); } else { /* no array, use ctx->Current.Attrib[] value */ bytes = sizeof(ctx->Current.Attrib[0]); - vbuffer[attr].buffer = pipe_user_buffer_create(pipe->screen, - (void *) ctx->Current.Attrib[mesaAttr], bytes); + vbuffer[attr].buffer = + pipe_user_buffer_create(pipe->screen, + (void *) ctx->Current.Attrib[mesaAttr], + bytes, + PIPE_BUFFER_USAGE_VERTEX); stride = 0; } @@ -641,13 +647,14 @@ st_draw_vbo(GLcontext *ctx, if (bufobj && bufobj->Name) { /* elements/indexes are in a real VBO */ struct st_buffer_object *stobj = st_buffer_object(bufobj); - pipe_buffer_reference(&indexBuf, stobj->buffer); + pipe_resource_reference(&indexBuf, stobj->buffer); indexOffset = pointer_to_offset(ib->ptr) / indexSize; } else { /* element/indicies are in user space memory */ indexBuf = pipe_user_buffer_create(pipe->screen, (void *) ib->ptr, - ib->count * indexSize); + ib->count * indexSize, + PIPE_BUFFER_USAGE_INDEX); indexOffset = 0; } @@ -675,7 +682,7 @@ st_draw_vbo(GLcontext *ctx, } } - pipe_buffer_reference(&indexBuf, NULL); + pipe_resource_reference(&indexBuf, NULL); } else { /* non-indexed */ @@ -691,7 +698,7 @@ st_draw_vbo(GLcontext *ctx, /* unreference buffers (frees wrapped user-space buffer objects) */ for (attr = 0; attr < num_vbuffers; attr++) { - pipe_buffer_reference(&vbuffer[attr].buffer, NULL); + pipe_resource_reference(&vbuffer[attr].buffer, NULL); assert(!vbuffer[attr].buffer); } diff --git a/src/mesa/state_tracker/st_draw_feedback.c b/src/mesa/state_tracker/st_draw_feedback.c index d0fdfecc2b..b5900733bb 100644 --- a/src/mesa/state_tracker/st_draw_feedback.c +++ b/src/mesa/state_tracker/st_draw_feedback.c @@ -158,7 +158,7 @@ st_feedback_draw_vbo(GLcontext *ctx, assert(stobj->buffer); vbuffers[attr].buffer = NULL; - pipe_buffer_reference(&vbuffers[attr].buffer, stobj->buffer); + pipe_resource_reference(&vbuffers[attr].buffer, stobj->buffer); vbuffers[attr].buffer_offset = pointer_to_offset(arrays[0]->Ptr); velements[attr].src_offset = arrays[mesaAttr]->Ptr - arrays[0]->Ptr; } @@ -171,7 +171,8 @@ st_feedback_draw_vbo(GLcontext *ctx, /* wrap user data */ vbuffers[attr].buffer = pipe_user_buffer_create(pipe->screen, (void *) arrays[mesaAttr]->Ptr, - bytes); + bytes, + PIPE_BUFFER_USAGE_VERTEX); vbuffers[attr].buffer_offset = 0; velements[attr].src_offset = 0; } @@ -268,7 +269,7 @@ st_feedback_draw_vbo(GLcontext *ctx, if (draw->pt.vertex_buffer[i].buffer) { pipe_buffer_unmap(pipe, draw->pt.vertex_buffer[i].buffer, vb_transfer[i]); - pipe_buffer_reference(&draw->pt.vertex_buffer[i].buffer, NULL); + pipe_resource_reference(&draw->pt.vertex_buffer[i].buffer, NULL); draw_set_mapped_vertex_buffer(draw, i, NULL); } } diff --git a/src/mesa/state_tracker/st_inlines.h b/src/mesa/state_tracker/st_inlines.h index 4a7523a3d4..32584b25c2 100644 --- a/src/mesa/state_tracker/st_inlines.h +++ b/src/mesa/state_tracker/st_inlines.h @@ -61,12 +61,7 @@ st_cond_flush_get_tex_transfer(struct st_context *st, subresource.face = face; subresource.level = level; - box.x = x; - box.y = y; - box.z = zslice; - box.w = w; - box.h = h; - box.d = 1; + u_box_2d_zslice(x, y, zslice, w, h, &box); st_teximage_flush_before_map(st, pt, face, level, usage); |