diff options
Diffstat (limited to 'src/gallium')
33 files changed, 114 insertions, 140 deletions
diff --git a/src/gallium/auxiliary/util/u_blit.c b/src/gallium/auxiliary/util/u_blit.c index 12a4ff6b48..da27637de1 100644 --- a/src/gallium/auxiliary/util/u_blit.c +++ b/src/gallium/auxiliary/util/u_blit.c @@ -377,7 +377,7 @@ util_blit_pixels_writemask(struct blit_state *ctx, return; texSurf = screen->get_tex_surface(screen, tex, 0, 0, 0, - PIPE_BUFFER_USAGE_GPU_WRITE); + PIPE_BUFFER_USAGE_BLIT_DESTINATION); /* load temp texture */ if (pipe->surface_copy) { diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c index b4a49b7213..c4ad4920f8 100644 --- a/src/gallium/auxiliary/util/u_blitter.c +++ b/src/gallium/auxiliary/util/u_blitter.c @@ -734,8 +734,8 @@ static void util_blitter_overlap_copy(struct blitter_context *blitter, return; tex_surf = screen->get_tex_surface(screen, texture, 0, 0, 0, - PIPE_BUFFER_USAGE_GPU_READ | - PIPE_BUFFER_USAGE_GPU_WRITE); + PIPE_BUFFER_USAGE_BLIT_SOURCE | + PIPE_BUFFER_USAGE_BLIT_DESTINATION); /* blit from the src to the temp */ util_blitter_do_copy(blitter, tex_surf, 0, 0, diff --git a/src/gallium/auxiliary/util/u_gen_mipmap.c b/src/gallium/auxiliary/util/u_gen_mipmap.c index a2c5f772e6..5673ff5218 100644 --- a/src/gallium/auxiliary/util/u_gen_mipmap.c +++ b/src/gallium/auxiliary/util/u_gen_mipmap.c @@ -1539,7 +1539,7 @@ util_gen_mipmap(struct gen_mipmap_state *ctx, struct pipe_surface *surf = screen->get_tex_surface(screen, pt, face, dstLevel, zslice, - PIPE_BUFFER_USAGE_GPU_WRITE); + PIPE_BUFFER_USAGE_RENDER_TARGET); /* * Setup framebuffer / dest surface diff --git a/src/gallium/auxiliary/util/u_surface.c b/src/gallium/auxiliary/util/u_surface.c index e21e81dcd2..67c856566c 100644 --- a/src/gallium/auxiliary/util/u_surface.c +++ b/src/gallium/auxiliary/util/u_surface.c @@ -91,7 +91,12 @@ util_create_rgba_surface(struct pipe_screen *screen, return FALSE; /* create surface / view into texture */ - *surfaceOut = screen->get_tex_surface(screen, *textureOut, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE); + *surfaceOut = screen->get_tex_surface(screen, + *textureOut, + 0, 0, 0, + (PIPE_BUFFER_USAGE_RENDER_TARGET | + PIPE_BUFFER_USAGE_BLIT_SOURCE | + PIPE_BUFFER_USAGE_BLIT_DESTINATION)); if (!*surfaceOut) { pipe_resource_reference(textureOut, NULL); return FALSE; diff --git a/src/gallium/auxiliary/util/u_upload_mgr.c b/src/gallium/auxiliary/util/u_upload_mgr.c index ea17b74815..56280805cd 100644 --- a/src/gallium/auxiliary/util/u_upload_mgr.c +++ b/src/gallium/auxiliary/util/u_upload_mgr.c @@ -150,7 +150,7 @@ u_upload_alloc_buffer( struct u_upload_mgr *upload, upload->buffer = pipe_buffer_create( upload->pipe->screen, upload->alignment, - upload->usage | PIPE_BUFFER_USAGE_CPU_WRITE, + upload->usage, size ); if (upload->buffer == NULL) goto fail; diff --git a/src/gallium/drivers/i915/i915_resource_buffer.c b/src/gallium/drivers/i915/i915_resource_buffer.c index 9dcd50cdee..ecf948f09b 100644 --- a/src/gallium/drivers/i915/i915_resource_buffer.c +++ b/src/gallium/drivers/i915/i915_resource_buffer.c @@ -148,7 +148,7 @@ i915_user_buffer_create(struct pipe_screen *screen, buf->b.vtbl = &i915_buffer_vtbl; buf->b.b.screen = screen; buf->b.b.format = PIPE_FORMAT_R8_UNORM; /* ?? */ - buf->b.b.usage = PIPE_BUFFER_USAGE_CPU_READ | usage; + buf->b.b.usage = usage; buf->b.b.width0 = bytes; buf->b.b.height0 = 1; buf->b.b.depth0 = 1; diff --git a/src/gallium/drivers/i965/brw_resource_buffer.c b/src/gallium/drivers/i965/brw_resource_buffer.c index db5883e67b..2f4a40d0de 100644 --- a/src/gallium/drivers/i965/brw_resource_buffer.c +++ b/src/gallium/drivers/i965/brw_resource_buffer.c @@ -145,7 +145,6 @@ brw_buffer_create(struct pipe_screen *screen, switch (template->usage & (PIPE_BUFFER_USAGE_VERTEX | PIPE_BUFFER_USAGE_INDEX | - PIPE_BUFFER_USAGE_PIXEL | PIPE_BUFFER_USAGE_CONSTANT)) { case PIPE_BUFFER_USAGE_VERTEX: @@ -154,10 +153,6 @@ brw_buffer_create(struct pipe_screen *screen, buffer_type = BRW_BUFFER_TYPE_VERTEX; break; - case PIPE_BUFFER_USAGE_PIXEL: - buffer_type = BRW_BUFFER_TYPE_PIXEL; - break; - case PIPE_BUFFER_USAGE_CONSTANT: buffer_type = BRW_BUFFER_TYPE_SHADER_CONSTANTS; break; @@ -194,7 +189,7 @@ brw_user_buffer_create(struct pipe_screen *screen, buf->b.vtbl = &brw_buffer_vtbl; buf->b.b.screen = screen; buf->b.b.format = PIPE_FORMAT_R8_UNORM; /* ?? */ - buf->b.b.usage = PIPE_BUFFER_USAGE_CPU_READ | usage; + buf->b.b.usage = usage; buf->b.b.width0 = bytes; buf->b.b.height0 = 1; buf->b.b.depth0 = 1; diff --git a/src/gallium/drivers/llvmpipe/lp_scene.c b/src/gallium/drivers/llvmpipe/lp_scene.c index a8aab157ed..36b5613125 100644 --- a/src/gallium/drivers/llvmpipe/lp_scene.c +++ b/src/gallium/drivers/llvmpipe/lp_scene.c @@ -398,10 +398,14 @@ static boolean lp_scene_map_buffers( struct lp_scene *scene ) { struct pipe_surface *cbuf, *zsbuf; + unsigned usage; int i; LP_DBG(DEBUG_RAST, "%s\n", __FUNCTION__); + /* XXX: try to improve on this: + */ + usage = PIPE_TRANSFER_READ_WRITE; /* Map all color buffers */ @@ -409,9 +413,10 @@ lp_scene_map_buffers( struct lp_scene *scene ) cbuf = scene->fb.cbufs[i]; if (cbuf) { scene->cbuf_map[i] = llvmpipe_resource_map(cbuf->texture, - cbuf->face, - cbuf->level, - cbuf->zslice); + usage, + cbuf->face, + cbuf->level, + cbuf->zslice); if (!scene->cbuf_map[i]) goto fail; } @@ -422,9 +427,10 @@ lp_scene_map_buffers( struct lp_scene *scene ) zsbuf = scene->fb.zsbuf; if (zsbuf) { scene->zsbuf_map = llvmpipe_resource_map(zsbuf->texture, - zsbuf->face, - zsbuf->level, - zsbuf->zslice); + usage, + zsbuf->face, + zsbuf->level, + zsbuf->zslice); if (!scene->zsbuf_map) goto fail; } diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c index 7080a0a996..1231a31d62 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup.c +++ b/src/gallium/drivers/llvmpipe/lp_setup.c @@ -492,7 +492,7 @@ lp_setup_set_fragment_sampler_views(struct lp_setup_context *setup, struct llvmpipe_screen *screen = llvmpipe_screen(tex->screen); struct sw_winsys *winsys = screen->winsys; jit_tex->data[0] = winsys->displaytarget_map(winsys, lp_tex->dt, - PIPE_BUFFER_USAGE_CPU_READ); + PIPE_TRANSFER_READ); jit_tex->row_stride[0] = lp_tex->stride[0]; assert(jit_tex->data[0]); } diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c index 9c1651dded..eaf1f90f31 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.c +++ b/src/gallium/drivers/llvmpipe/lp_texture.c @@ -172,9 +172,10 @@ llvmpipe_resource_destroy(struct pipe_screen *pscreen, */ void * llvmpipe_resource_map(struct pipe_resource *texture, - unsigned face, - unsigned level, - unsigned zslice) + unsigned usage, + unsigned face, + unsigned level, + unsigned zslice) { struct llvmpipe_resource *lpt = llvmpipe_resource(texture); uint8_t *map; @@ -183,7 +184,6 @@ llvmpipe_resource_map(struct pipe_resource *texture, /* display target */ struct llvmpipe_screen *screen = llvmpipe_screen(texture->screen); struct sw_winsys *winsys = screen->winsys; - const unsigned usage = PIPE_BUFFER_USAGE_CPU_READ_WRITE; assert(face == 0); assert(level == 0); @@ -259,7 +259,6 @@ llvmpipe_get_tex_surface(struct pipe_screen *screen, unsigned face, unsigned level, unsigned zslice, unsigned usage) { - struct llvmpipe_resource *lpt = llvmpipe_resource(pt); struct pipe_surface *ps; assert(level <= pt->last_level); @@ -273,26 +272,6 @@ llvmpipe_get_tex_surface(struct pipe_screen *screen, ps->height = u_minify(pt->height0, level); ps->usage = usage; - /* Because we are llvmpipe, anything that the state tracker - * thought was going to be done with the GPU will actually get - * done with the CPU. Let's adjust the flags to take that into - * account. - */ - if (ps->usage & PIPE_BUFFER_USAGE_GPU_WRITE) { - /* GPU_WRITE means "render" and that can involve reads (blending) */ - ps->usage |= PIPE_BUFFER_USAGE_CPU_WRITE | PIPE_BUFFER_USAGE_CPU_READ; - } - - if (ps->usage & PIPE_BUFFER_USAGE_GPU_READ) - ps->usage |= PIPE_BUFFER_USAGE_CPU_READ; - - if (ps->usage & (PIPE_BUFFER_USAGE_CPU_WRITE | - PIPE_BUFFER_USAGE_GPU_WRITE)) { - /* Mark the surface as dirty. */ - lpt->timestamp++; - llvmpipe_screen(screen)->timestamp++; - } - ps->face = face; ps->level = level; ps->zslice = zslice; @@ -382,6 +361,7 @@ llvmpipe_transfer_map( struct pipe_context *pipe, FALSE); /* do_not_flush */ map = llvmpipe_resource_map(transfer->resource, + transfer->usage, transfer->sr.face, transfer->sr.level, transfer->box.z); @@ -448,7 +428,7 @@ llvmpipe_user_buffer_create(struct pipe_screen *screen, pipe_reference_init(&buffer->base.reference, 1); buffer->base.screen = screen; buffer->base.format = PIPE_FORMAT_R8_UNORM; /* ?? */ - buffer->base.usage = PIPE_BUFFER_USAGE_CPU_READ | usage; + buffer->base.usage = usage; buffer->base.width0 = bytes; buffer->base.height0 = 1; buffer->base.depth0 = 1; diff --git a/src/gallium/drivers/llvmpipe/lp_texture.h b/src/gallium/drivers/llvmpipe/lp_texture.h index ca67b5bdb0..54c93778b7 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.h +++ b/src/gallium/drivers/llvmpipe/lp_texture.h @@ -111,9 +111,10 @@ llvmpipe_resource_stride(struct pipe_resource *texture, void * llvmpipe_resource_map(struct pipe_resource *texture, - unsigned face, - unsigned level, - unsigned zslice); + unsigned usage, + unsigned face, + unsigned level, + unsigned zslice); void llvmpipe_resource_unmap(struct pipe_resource *texture, diff --git a/src/gallium/drivers/softpipe/sp_texture.c b/src/gallium/drivers/softpipe/sp_texture.c index e24c46ba84..a2250ccf8b 100644 --- a/src/gallium/drivers/softpipe/sp_texture.c +++ b/src/gallium/drivers/softpipe/sp_texture.c @@ -189,26 +189,6 @@ softpipe_get_tex_surface(struct pipe_screen *screen, ps->offset = spt->level_offset[level]; ps->usage = usage; - /* Because we are softpipe, anything that the state tracker - * thought was going to be done with the GPU will actually get - * done with the CPU. Let's adjust the flags to take that into - * account. - */ - if (ps->usage & PIPE_BUFFER_USAGE_GPU_WRITE) { - /* GPU_WRITE means "render" and that can involve reads (blending) */ - ps->usage |= PIPE_BUFFER_USAGE_CPU_WRITE | PIPE_BUFFER_USAGE_CPU_READ; - } - - if (ps->usage & PIPE_BUFFER_USAGE_GPU_READ) - ps->usage |= PIPE_BUFFER_USAGE_CPU_READ; - - if (ps->usage & (PIPE_BUFFER_USAGE_CPU_WRITE | - PIPE_BUFFER_USAGE_GPU_WRITE)) { - /* Mark the surface as dirty. The tile cache will look for this. */ - spt->timestamp++; - softpipe_screen(screen)->timestamp++; - } - ps->face = face; ps->level = level; ps->zslice = zslice; @@ -397,7 +377,7 @@ softpipe_user_buffer_create(struct pipe_screen *screen, pipe_reference_init(&buffer->base.reference, 1); buffer->base.screen = screen; buffer->base.format = PIPE_FORMAT_R8_UNORM; /* ?? */ - buffer->base.usage = PIPE_BUFFER_USAGE_CPU_READ | usage; + buffer->base.usage = usage; buffer->base.width0 = bytes; buffer->base.height0 = 1; buffer->base.depth0 = 1; diff --git a/src/gallium/drivers/svga/svga_cmd.c b/src/gallium/drivers/svga/svga_cmd.c index d58082cae3..7b2dfe2549 100644 --- a/src/gallium/drivers/svga/svga_cmd.c +++ b/src/gallium/drivers/svga/svga_cmd.c @@ -280,7 +280,7 @@ SVGA3D_BeginDefineSurface(struct svga_winsys_context *swc, if(!cmd) return PIPE_ERROR_OUT_OF_MEMORY; - swc->surface_relocation(swc, &cmd->sid, sid, PIPE_BUFFER_USAGE_GPU_WRITE); + swc->surface_relocation(swc, &cmd->sid, sid, SVGA_RELOC_WRITE); cmd->surfaceFlags = flags; cmd->format = format; @@ -366,7 +366,7 @@ SVGA3D_DestroySurface(struct svga_winsys_context *swc, if(!cmd) return PIPE_ERROR_OUT_OF_MEMORY; - swc->surface_relocation(swc, &cmd->sid, sid, PIPE_BUFFER_USAGE_GPU_READ); + swc->surface_relocation(swc, &cmd->sid, sid, SVGA_RELOC_READ); swc->commit(swc);; return PIPE_OK; @@ -432,12 +432,12 @@ SVGA3D_SurfaceDMA(struct svga_winsys_context *swc, unsigned surface_flags; if(transfer == SVGA3D_WRITE_HOST_VRAM) { - region_flags = PIPE_BUFFER_USAGE_GPU_READ; - surface_flags = PIPE_BUFFER_USAGE_GPU_WRITE; + region_flags = SVGA_RELOC_READ; + surface_flags = SVGA_RELOC_WRITE; } else if(transfer == SVGA3D_READ_HOST_VRAM) { - region_flags = PIPE_BUFFER_USAGE_GPU_WRITE; - surface_flags = PIPE_BUFFER_USAGE_GPU_READ; + region_flags = SVGA_RELOC_WRITE; + surface_flags = SVGA_RELOC_READ; } else { assert(0); @@ -490,12 +490,12 @@ SVGA3D_BufferDMA(struct svga_winsys_context *swc, unsigned surface_flags; if(transfer == SVGA3D_WRITE_HOST_VRAM) { - region_flags = PIPE_BUFFER_USAGE_GPU_READ; - surface_flags = PIPE_BUFFER_USAGE_GPU_WRITE; + region_flags = SVGA_RELOC_READ; + surface_flags = SVGA_RELOC_WRITE; } else if(transfer == SVGA3D_READ_HOST_VRAM) { - region_flags = PIPE_BUFFER_USAGE_GPU_WRITE; - surface_flags = PIPE_BUFFER_USAGE_GPU_READ; + region_flags = SVGA_RELOC_WRITE; + surface_flags = SVGA_RELOC_READ; } else { assert(0); @@ -585,7 +585,7 @@ SVGA3D_SetRenderTarget(struct svga_winsys_context *swc, cmd->type = type; - surface_to_surfaceid(swc, surface, &cmd->target, PIPE_BUFFER_USAGE_GPU_WRITE); + surface_to_surfaceid(swc, surface, &cmd->target, SVGA_RELOC_WRITE); swc->commit(swc); @@ -1001,8 +1001,8 @@ SVGA3D_BeginSurfaceCopy(struct svga_winsys_context *swc, if(!cmd) return PIPE_ERROR_OUT_OF_MEMORY; - surface_to_surfaceid(swc, src, &cmd->src, PIPE_BUFFER_USAGE_GPU_READ); - surface_to_surfaceid(swc, dest, &cmd->dest, PIPE_BUFFER_USAGE_GPU_WRITE); + surface_to_surfaceid(swc, src, &cmd->src, SVGA_RELOC_READ); + surface_to_surfaceid(swc, dest, &cmd->dest, SVGA_RELOC_WRITE); *boxes = (SVGA3dCopyBox*) &cmd[1]; memset(*boxes, 0, boxesSize); @@ -1044,8 +1044,8 @@ SVGA3D_SurfaceStretchBlt(struct svga_winsys_context *swc, if(!cmd) return PIPE_ERROR_OUT_OF_MEMORY; - surface_to_surfaceid(swc, src, &cmd->src, PIPE_BUFFER_USAGE_GPU_READ); - surface_to_surfaceid(swc, dest, &cmd->dest, PIPE_BUFFER_USAGE_GPU_WRITE); + surface_to_surfaceid(swc, src, &cmd->src, SVGA_RELOC_READ); + surface_to_surfaceid(swc, dest, &cmd->dest, SVGA_RELOC_WRITE); cmd->boxSrc = *boxSrc; cmd->boxDest = *boxDest; cmd->mode = mode; @@ -1374,7 +1374,7 @@ SVGA3D_EndQuery(struct svga_winsys_context *swc, cmd->type = type; swc->region_relocation(swc, &cmd->guestResult, buffer, 0, - PIPE_BUFFER_USAGE_GPU_WRITE); + SVGA_RELOC_WRITE); swc->commit(swc); @@ -1421,7 +1421,7 @@ SVGA3D_WaitForQuery(struct svga_winsys_context *swc, cmd->type = type; swc->region_relocation(swc, &cmd->guestResult, buffer, 0, - PIPE_BUFFER_USAGE_GPU_WRITE); + SVGA_RELOC_WRITE); swc->commit(swc); diff --git a/src/gallium/drivers/svga/svga_draw.c b/src/gallium/drivers/svga/svga_draw.c index efc84d56bd..81dd4778d0 100644 --- a/src/gallium/drivers/svga/svga_draw.c +++ b/src/gallium/drivers/svga/svga_draw.c @@ -198,7 +198,7 @@ svga_hwtnl_flush( struct svga_hwtnl *hwtnl ) swc->surface_relocation(swc, &vdecl[i].array.surfaceId, vb_handle[i], - PIPE_BUFFER_USAGE_GPU_READ); + SVGA_RELOC_READ); } memcpy( prim, @@ -209,7 +209,7 @@ svga_hwtnl_flush( struct svga_hwtnl *hwtnl ) swc->surface_relocation(swc, &prim[i].indexArray.surfaceId, ib_handle[i], - PIPE_BUFFER_USAGE_GPU_READ); + SVGA_RELOC_READ); pipe_resource_reference(&hwtnl->cmd.prim_ib[i], NULL); } diff --git a/src/gallium/drivers/svga/svga_draw_arrays.c b/src/gallium/drivers/svga/svga_draw_arrays.c index dc01a8c30a..1e4fbdf5ea 100644 --- a/src/gallium/drivers/svga/svga_draw_arrays.c +++ b/src/gallium/drivers/svga/svga_draw_arrays.c @@ -52,14 +52,12 @@ static enum pipe_error generate_indices( struct svga_hwtnl *hwtnl, void *dst_map = NULL; dst = pipe_buffer_create( pipe->screen, 32, - PIPE_BUFFER_USAGE_INDEX | - PIPE_BUFFER_USAGE_CPU_WRITE | - PIPE_BUFFER_USAGE_GPU_READ, + PIPE_BUFFER_USAGE_INDEX, size ); if (dst == NULL) goto fail; - dst_map = pipe_buffer_map( pipe, dst, PIPE_BUFFER_USAGE_CPU_WRITE, + dst_map = pipe_buffer_map( pipe, dst, PIPE_TRANSFER_WRITE, &transfer); if (dst_map == NULL) goto fail; diff --git a/src/gallium/drivers/svga/svga_draw_elements.c b/src/gallium/drivers/svga/svga_draw_elements.c index e131686fd0..78c20a8ff2 100644 --- a/src/gallium/drivers/svga/svga_draw_elements.c +++ b/src/gallium/drivers/svga/svga_draw_elements.c @@ -55,18 +55,16 @@ translate_indices( struct svga_hwtnl *hwtnl, void *dst_map = NULL; dst = pipe_buffer_create( pipe->screen, 32, - PIPE_BUFFER_USAGE_INDEX | - PIPE_BUFFER_USAGE_CPU_WRITE | - PIPE_BUFFER_USAGE_GPU_READ, + PIPE_BUFFER_USAGE_INDEX, size ); if (dst == NULL) goto fail; - src_map = pipe_buffer_map( pipe, src, PIPE_BUFFER_USAGE_CPU_READ, &src_transfer ); + src_map = pipe_buffer_map( pipe, src, PIPE_TRANSFER_READ, &src_transfer ); if (src_map == NULL) goto fail; - dst_map = pipe_buffer_map( pipe, dst, PIPE_BUFFER_USAGE_CPU_WRITE, &dst_transfer ); + dst_map = pipe_buffer_map( pipe, dst, PIPE_TRANSFER_WRITE, &dst_transfer ); if (dst_map == NULL) goto fail; diff --git a/src/gallium/drivers/svga/svga_pipe_query.c b/src/gallium/drivers/svga/svga_pipe_query.c index 04397790b4..9c6f5858ba 100644 --- a/src/gallium/drivers/svga/svga_pipe_query.c +++ b/src/gallium/drivers/svga/svga_pipe_query.c @@ -89,7 +89,7 @@ static struct pipe_query *svga_create_query( struct pipe_context *pipe, sq->queryResult = (SVGA3dQueryResult *)sws->buffer_map(sws, sq->hwbuf, - PIPE_BUFFER_USAGE_CPU_WRITE); + PIPE_TRANSFER_WRITE); if(!sq->queryResult) goto no_query_result; diff --git a/src/gallium/drivers/svga/svga_resource_buffer.c b/src/gallium/drivers/svga/svga_resource_buffer.c index b35abc007e..445358b303 100644 --- a/src/gallium/drivers/svga/svga_resource_buffer.c +++ b/src/gallium/drivers/svga/svga_resource_buffer.c @@ -336,7 +336,7 @@ svga_user_buffer_create(struct pipe_screen *screen, sbuf->b.vtbl = &svga_buffer_vtbl; sbuf->b.b.screen = screen; sbuf->b.b.format = PIPE_FORMAT_R8_UNORM; /* ?? */ - sbuf->b.b.usage = PIPE_BUFFER_USAGE_CPU_READ | usage; + sbuf->b.b.usage = usage; sbuf->b.b.width0 = bytes; sbuf->b.b.height0 = 1; sbuf->b.b.depth0 = 1; diff --git a/src/gallium/drivers/svga/svga_resource_buffer_upload.c b/src/gallium/drivers/svga/svga_resource_buffer_upload.c index 78fda66478..31c014e4d6 100644 --- a/src/gallium/drivers/svga/svga_resource_buffer_upload.c +++ b/src/gallium/drivers/svga/svga_resource_buffer_upload.c @@ -182,12 +182,12 @@ svga_buffer_upload_command(struct svga_context *svga, struct pipe_resource *dummy; if(transfer == SVGA3D_WRITE_HOST_VRAM) { - region_flags = PIPE_BUFFER_USAGE_GPU_READ; - surface_flags = PIPE_BUFFER_USAGE_GPU_WRITE; + region_flags = SVGA_RELOC_READ; + surface_flags = SVGA_RELOC_WRITE; } else if(transfer == SVGA3D_READ_HOST_VRAM) { - region_flags = PIPE_BUFFER_USAGE_GPU_WRITE; - surface_flags = PIPE_BUFFER_USAGE_GPU_READ; + region_flags = SVGA_RELOC_WRITE; + surface_flags = SVGA_RELOC_READ; } else { assert(0); @@ -415,7 +415,7 @@ svga_buffer_update_hw(struct svga_screen *ss, struct svga_buffer *sbuf) return ret; pipe_mutex_lock(ss->swc_mutex); - map = ss->sws->buffer_map(ss->sws, sbuf->hwbuf, PIPE_BUFFER_USAGE_CPU_WRITE); + map = ss->sws->buffer_map(ss->sws, sbuf->hwbuf, PIPE_TRANSFER_WRITE); assert(map); if(!map) { pipe_mutex_unlock(ss->swc_mutex); diff --git a/src/gallium/drivers/svga/svga_resource_texture.c b/src/gallium/drivers/svga/svga_resource_texture.c index a288aa589e..5fc8875257 100644 --- a/src/gallium/drivers/svga/svga_resource_texture.c +++ b/src/gallium/drivers/svga/svga_resource_texture.c @@ -263,7 +263,7 @@ svga_transfer_dma(struct svga_transfer *st, sws->fence_reference(sws, &fence, NULL); } - hw = sws->buffer_map(sws, st->hwbuf, PIPE_BUFFER_USAGE_CPU_WRITE); + hw = sws->buffer_map(sws, st->hwbuf, PIPE_TRANSFER_WRITE); assert(hw); if(hw) { memcpy(hw, sw, length); @@ -277,7 +277,7 @@ svga_transfer_dma(struct svga_transfer *st, svga_screen_flush(screen, &fence); sws->fence_finish(sws, fence, 0); - hw = sws->buffer_map(sws, st->hwbuf, PIPE_BUFFER_USAGE_CPU_READ); + hw = sws->buffer_map(sws, st->hwbuf, PIPE_TRANSFER_READ); assert(hw); if(hw) { memcpy(sw, hw, length); diff --git a/src/gallium/drivers/svga/svga_state_constants.c b/src/gallium/drivers/svga/svga_state_constants.c index 558031592f..97c818cd37 100644 --- a/src/gallium/drivers/svga/svga_state_constants.c +++ b/src/gallium/drivers/svga/svga_state_constants.c @@ -95,7 +95,7 @@ static int emit_consts( struct svga_context *svga, data = (const float (*)[4])pipe_buffer_map(&svga->pipe, svga->curr.cb[unit], - PIPE_BUFFER_USAGE_CPU_READ, + PIPE_TRANSFER_READ, &transfer); if (data == NULL) { ret = PIPE_ERROR_OUT_OF_MEMORY; diff --git a/src/gallium/drivers/svga/svga_state_tss.c b/src/gallium/drivers/svga/svga_state_tss.c index a8d9f6d5c1..76a2dae143 100644 --- a/src/gallium/drivers/svga/svga_state_tss.c +++ b/src/gallium/drivers/svga/svga_state_tss.c @@ -135,7 +135,7 @@ update_tss_binding(struct svga_context *svga, svga->swc->surface_relocation(svga->swc, &ts[i].value, queue.bind[i].view->v->handle, - PIPE_BUFFER_USAGE_GPU_READ); + SVGA_RELOC_READ); } else { ts[i].value = SVGA3D_INVALID_ID; diff --git a/src/gallium/drivers/svga/svga_state_vs.c b/src/gallium/drivers/svga/svga_state_vs.c index e9ed0f9d4f..a6215c68cb 100644 --- a/src/gallium/drivers/svga/svga_state_vs.c +++ b/src/gallium/drivers/svga/svga_state_vs.c @@ -224,7 +224,7 @@ static int update_zero_stride( struct svga_context *svga, vbuffer->buffer, vel->src_offset, util_format_get_blocksize(vel->src_format), - PIPE_BUFFER_USAGE_CPU_READ, + PIPE_TRANSFER_READ, &transfer); translate->set_buffer(translate, vel->vertex_buffer_index, diff --git a/src/gallium/drivers/svga/svga_surface.c b/src/gallium/drivers/svga/svga_surface.c index 6051eb4e07..2547406d4a 100644 --- a/src/gallium/drivers/svga/svga_surface.c +++ b/src/gallium/drivers/svga/svga_surface.c @@ -210,7 +210,8 @@ svga_get_tex_surface(struct pipe_screen *screen, { struct svga_texture *tex = svga_texture(pt); struct svga_surface *s; - boolean render = flags & PIPE_BUFFER_USAGE_GPU_WRITE ? TRUE : FALSE; + boolean render = (flags & (PIPE_BUFFER_USAGE_RENDER_TARGET | + PIPE_BUFFER_USAGE_DEPTH_STENCIL)) ? TRUE : FALSE; boolean view = FALSE; SVGA3dSurfaceFormat format; @@ -234,8 +235,6 @@ svga_get_tex_surface(struct pipe_screen *screen, format = svga_translate_format_render(pt->format); assert(format != SVGA3D_FORMAT_INVALID); - assert(!(flags & PIPE_BUFFER_USAGE_CPU_READ_WRITE)); - if (svga_screen(screen)->debug.force_surface_view) view = TRUE; diff --git a/src/gallium/drivers/svga/svga_swtnl_draw.c b/src/gallium/drivers/svga/svga_swtnl_draw.c index ee12c9ac36..0037bbd5fe 100644 --- a/src/gallium/drivers/svga/svga_swtnl_draw.c +++ b/src/gallium/drivers/svga/svga_swtnl_draw.c @@ -69,7 +69,7 @@ svga_swtnl_draw_range_elements(struct svga_context *svga, for (i = 0; i < svga->curr.num_vertex_buffers; i++) { map = pipe_buffer_map(&svga->pipe, svga->curr.vb[i].buffer, - PIPE_BUFFER_USAGE_CPU_READ, + PIPE_TRANSFER_READ, &vb_transfer[i]); draw_set_mapped_vertex_buffer(draw, i, map); @@ -78,7 +78,7 @@ svga_swtnl_draw_range_elements(struct svga_context *svga, /* Map index buffer, if present */ if (indexBuffer) { map = pipe_buffer_map(&svga->pipe, indexBuffer, - PIPE_BUFFER_USAGE_CPU_READ, + PIPE_TRANSFER_READ, &ib_transfer); draw_set_mapped_element_buffer_range(draw, @@ -91,7 +91,7 @@ svga_swtnl_draw_range_elements(struct svga_context *svga, if (svga->curr.cb[PIPE_SHADER_VERTEX]) { map = pipe_buffer_map(&svga->pipe, svga->curr.cb[PIPE_SHADER_VERTEX], - PIPE_BUFFER_USAGE_CPU_READ, + PIPE_TRANSFER_READ, &cb_transfer); assert(map); draw_set_mapped_constant_buffer( diff --git a/src/gallium/drivers/svga/svga_winsys.h b/src/gallium/drivers/svga/svga_winsys.h index 225c2ba55f..dc4888b065 100644 --- a/src/gallium/drivers/svga/svga_winsys.h +++ b/src/gallium/drivers/svga/svga_winsys.h @@ -58,6 +58,11 @@ struct winsys_handle; #define SVGA_BUFFER_USAGE_WRAPPED (PIPE_BUFFER_USAGE_CUSTOM << 1) +#define SVGA_RELOC_WRITE 0x1 +#define SVGA_RELOC_READ 0x2 + + + /** Opaque surface handle */ struct svga_winsys_surface; diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h index 62e1401f07..e3154097a7 100644 --- a/src/gallium/include/pipe/p_defines.h +++ b/src/gallium/include/pipe/p_defines.h @@ -287,19 +287,22 @@ enum pipe_transfer_usage { /* - * Buffer usage flags + * Resource usage flags -- state tracker must specify in advance all + * the ways a resource might be used. + * + * XXX: add a method to extend the flags? */ -#define PIPE_BUFFER_USAGE_CPU_READ (1 << 0) -#define PIPE_BUFFER_USAGE_CPU_WRITE (1 << 1) -#define PIPE_BUFFER_USAGE_GPU_READ (1 << 2) -#define PIPE_BUFFER_USAGE_GPU_WRITE (1 << 3) -#define PIPE_BUFFER_USAGE_PIXEL (1 << 4) -#define PIPE_BUFFER_USAGE_VERTEX (1 << 5) -#define PIPE_BUFFER_USAGE_INDEX (1 << 6) -#define PIPE_BUFFER_USAGE_CONSTANT (1 << 7) +#define PIPE_BUFFER_USAGE_DEPTH_STENCIL (1 << 0) +#define PIPE_BUFFER_USAGE_RENDER_TARGET (1 << 1) +#define PIPE_BUFFER_USAGE_SAMPLER (1 << 2) +#define PIPE_BUFFER_USAGE_VERTEX (1 << 3) +#define PIPE_BUFFER_USAGE_INDEX (1 << 4) +#define PIPE_BUFFER_USAGE_CONSTANT (1 << 5) +#define PIPE_BUFFER_USAGE_BLIT_SOURCE (1 << 6) /* will go away */ +#define PIPE_BUFFER_USAGE_BLIT_DESTINATION (1 << 7) /* will go away */ -#define PIPE_BUFFER_USAGE_CUSTOM (1 << 16) +#define PIPE_BUFFER_USAGE_CUSTOM (1 << 16) /* Convenient shortcuts */ #define PIPE_BUFFER_USAGE_CPU_READ_WRITE \ diff --git a/src/gallium/state_trackers/vega/api_filters.c b/src/gallium/state_trackers/vega/api_filters.c index 01c9896edd..6400f1f3c6 100644 --- a/src/gallium/state_trackers/vega/api_filters.c +++ b/src/gallium/state_trackers/vega/api_filters.c @@ -98,7 +98,7 @@ static INLINE struct pipe_surface * setup_framebuffer(struct vg_image *dst) struct pipe_framebuffer_state fb; struct pipe_surface *dst_surf = pipe->screen->get_tex_surface( pipe->screen, dst->texture, 0, 0, 0, - PIPE_BUFFER_USAGE_GPU_WRITE); + PIPE_BUFFER_USAGE_RENDER_TARGET); /* drawing dest */ memset(&fb, 0, sizeof(fb)); diff --git a/src/gallium/state_trackers/vega/image.c b/src/gallium/state_trackers/vega/image.c index 2f55d80601..ba3397fd66 100644 --- a/src/gallium/state_trackers/vega/image.c +++ b/src/gallium/state_trackers/vega/image.c @@ -567,7 +567,7 @@ void image_set_pixels(VGint dx, VGint dy, pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL); surf = screen->get_tex_surface(screen, image_texture(src), 0, 0, 0, - PIPE_BUFFER_USAGE_GPU_READ); + PIPE_BUFFER_USAGE_BLIT_SOURCE); vg_copy_surface(ctx, strb->surface, dx, dy, surf, sx+src->x, sy+src->y, width, height); @@ -592,8 +592,8 @@ void image_get_pixels(struct vg_image *dst, VGint dx, VGint dy, pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL); surf = screen->get_tex_surface(screen, image_texture(dst), 0, 0, 0, - PIPE_BUFFER_USAGE_GPU_WRITE | - PIPE_BUFFER_USAGE_GPU_READ); + PIPE_BUFFER_USAGE_BLIT_SOURCE); + vg_copy_surface(ctx, surf, dst->x + dx, dst->y + dy, strb->surface, sx, sy, width, height); diff --git a/src/gallium/state_trackers/vega/mask.c b/src/gallium/state_trackers/vega/mask.c index 379e46b275..5f097e7107 100644 --- a/src/gallium/state_trackers/vega/mask.c +++ b/src/gallium/state_trackers/vega/mask.c @@ -418,7 +418,7 @@ static void mask_using_texture(struct pipe_resource *texture, { struct vg_context *ctx = vg_current_context(); struct pipe_surface *surface = - alpha_mask_surface(ctx, PIPE_BUFFER_USAGE_GPU_WRITE); + alpha_mask_surface(ctx, PIPE_BUFFER_USAGE_RENDER_TARGET); VGint offsets[4], loc[4]; if (!surface) @@ -654,7 +654,7 @@ void mask_fill(VGint x, VGint y, VGint width, VGint height, struct vg_context *ctx = vg_current_context(); VGfloat alpha_color[4] = {.0f, .0f, .0f, value}; struct pipe_surface *surf = alpha_mask_surface( - ctx, PIPE_BUFFER_USAGE_GPU_WRITE); + ctx, PIPE_BUFFER_USAGE_RENDER_TARGET); #if DEBUG_MASKS debug_printf("mask_fill(%d, %d, %d, %d) with rgba(%f, %f, %f, %f)\n", diff --git a/src/gallium/state_trackers/vega/renderer.c b/src/gallium/state_trackers/vega/renderer.c index 415dd5e1a8..05897c05d9 100644 --- a/src/gallium/state_trackers/vega/renderer.c +++ b/src/gallium/state_trackers/vega/renderer.c @@ -278,7 +278,7 @@ void renderer_copy_texture(struct renderer *ctx, struct pipe_resource *buf; struct pipe_surface *dst_surf = screen->get_tex_surface( screen, dst, 0, 0, 0, - PIPE_BUFFER_USAGE_GPU_WRITE); + PIPE_BUFFER_USAGE_RENDER_TARGET); struct pipe_framebuffer_state fb; float s0, t0, s1, t1; @@ -461,7 +461,7 @@ void renderer_copy_surface(struct renderer *ctx, return; texSurf = screen->get_tex_surface(screen, tex, 0, 0, 0, - PIPE_BUFFER_USAGE_GPU_WRITE); + PIPE_BUFFER_USAGE_RENDER_TARGET); /* load temp texture */ if (pipe->surface_copy) { diff --git a/src/gallium/state_trackers/vega/vg_context.c b/src/gallium/state_trackers/vega/vg_context.c index 49ddb34a20..887fd356ef 100644 --- a/src/gallium/state_trackers/vega/vg_context.c +++ b/src/gallium/state_trackers/vega/vg_context.c @@ -442,7 +442,8 @@ void vg_prepare_blend_surface(struct vg_context *ctx) dest_surface = pipe->screen->get_tex_surface(pipe->screen, stfb->blend_texture, 0, 0, 0, - PIPE_BUFFER_USAGE_GPU_WRITE); + PIPE_BUFFER_USAGE_BLIT_DESTINATION | + PIPE_BUFFER_USAGE_RENDER_TARGET); /* flip it, because we want to use it as a sampler */ util_blit_pixels_tex(ctx->blit, strb->texture, @@ -476,7 +477,8 @@ void vg_prepare_blend_surface_from_mask(struct vg_context *ctx) dest_surface = pipe->screen->get_tex_surface(pipe->screen, stfb->blend_texture, 0, 0, 0, - PIPE_BUFFER_USAGE_GPU_WRITE); + PIPE_BUFFER_USAGE_BLIT_DESTINATION | + PIPE_BUFFER_USAGE_RENDER_TARGET); /* flip it, because we want to use it as a sampler */ util_blit_pixels_tex(ctx->blit, diff --git a/src/gallium/state_trackers/vega/vg_tracker.c b/src/gallium/state_trackers/vega/vg_tracker.c index 4e5921632e..658ef03046 100644 --- a/src/gallium/state_trackers/vega/vg_tracker.c +++ b/src/gallium/state_trackers/vega/vg_tracker.c @@ -112,8 +112,9 @@ st_renderbuffer_alloc_storage(struct vg_context * ctx, /* Probably need dedicated flags for surface usage too: */ - surface_usage = (PIPE_BUFFER_USAGE_GPU_READ | - PIPE_BUFFER_USAGE_GPU_WRITE); + surface_usage = (PIPE_BUFFER_USAGE_RENDER_TARGET | + PIPE_BUFFER_USAGE_BLIT_SOURCE | + PIPE_BUFFER_USAGE_BLIT_DESTINATION); strb->texture = create_texture(pipe, strb->format, width, height); @@ -233,12 +234,13 @@ static void setup_new_alpha_mask(struct vg_context *ctx, pipe->screen, stfb->alpha_mask, 0, 0, 0, - PIPE_BUFFER_USAGE_GPU_WRITE); + PIPE_BUFFER_USAGE_RENDER_TARGET | + PIPE_BUFFER_USAGE_BLIT_DESTINATION); struct pipe_surface *old_surface = pipe->screen->get_tex_surface( pipe->screen, old_texture, 0, 0, 0, - PIPE_BUFFER_USAGE_GPU_READ); + PIPE_BUFFER_USAGE_BLIT_SOURCE); if (pipe->surface_copy) { pipe->surface_copy(pipe, surface, |