Commit dd7ba137 authored by Keith Whitwell's avatar Keith Whitwell

gallium: start a cleanup of buffer_usage

Remove fairly meaningless CPU/GPU READ/WRITE flags and
replace with proper usages.
parent c1d47741
......@@ -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) {
......
......@@ -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,
......
......@@ -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
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
}
......
......@@ -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]);
}
......
......@@ -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;
......
......@@ -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,
......
......@@ -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;
......
......@@ -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);
......
......@@ -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);
}
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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);
......
......@@ -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);
......
......@@ -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;
......
......@@ -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;
......
......@@ -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,
......
......@@ -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;
......
......@@ -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(
......
......@@ -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;
......
......@@ -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 \
......
......@@ -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));
......
......@@ -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);
......
......@@ -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