diff options
Diffstat (limited to 'src/gallium/drivers/llvmpipe')
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_flush.c | 4 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_flush.h | 2 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_rast.c | 11 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_rast_priv.h | 4 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_scene.c | 28 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_screen.c | 5 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_surface.c | 46 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_texture.c | 103 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_texture.h | 8 |
9 files changed, 102 insertions, 109 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_flush.c b/src/gallium/drivers/llvmpipe/lp_flush.c index e8d00cf5169..85e3cdec82c 100644 --- a/src/gallium/drivers/llvmpipe/lp_flush.c +++ b/src/gallium/drivers/llvmpipe/lp_flush.c @@ -108,8 +108,8 @@ llvmpipe_finish( struct pipe_context *pipe, boolean llvmpipe_flush_resource(struct pipe_context *pipe, struct pipe_resource *resource, - unsigned face, unsigned level, + int layer, unsigned flush_flags, boolean read_only, boolean cpu_access, @@ -118,7 +118,7 @@ llvmpipe_flush_resource(struct pipe_context *pipe, { unsigned referenced; - referenced = pipe->is_resource_referenced(pipe, resource, face, level); + referenced = pipe->is_resource_referenced(pipe, resource, level, layer); if ((referenced & PIPE_REFERENCED_FOR_WRITE) || ((referenced & PIPE_REFERENCED_FOR_READ) && !read_only)) { diff --git a/src/gallium/drivers/llvmpipe/lp_flush.h b/src/gallium/drivers/llvmpipe/lp_flush.h index 3626ce4a86c..579d24c68ad 100644 --- a/src/gallium/drivers/llvmpipe/lp_flush.h +++ b/src/gallium/drivers/llvmpipe/lp_flush.h @@ -47,8 +47,8 @@ llvmpipe_finish( struct pipe_context *pipe, boolean llvmpipe_flush_resource(struct pipe_context *pipe, struct pipe_resource *resource, - unsigned face, unsigned level, + int layer, unsigned flush_flags, boolean read_only, boolean cpu_access, diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c b/src/gallium/drivers/llvmpipe/lp_rast.c index dd6e6d566b2..dafadc1ea9b 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast.c +++ b/src/gallium/drivers/llvmpipe/lp_rast.c @@ -120,8 +120,8 @@ lp_rast_tile_begin(struct lp_rasterizer_task *task, * and update the tile's layout info. */ (void) llvmpipe_get_texture_tile(lpt, - zsbuf->face + zsbuf->zslice, - zsbuf->level, + zsbuf->u.tex.first_layer, + zsbuf->u.tex.level, usage, task->x, task->y); @@ -289,7 +289,6 @@ lp_rast_clear_zstencil(struct lp_rasterizer_task *task, - /** * Convert the color tile from tiled to linear layout. * This is generally only done when we're flushing the scene just prior to @@ -307,15 +306,15 @@ lp_rast_store_linear_color( struct lp_rasterizer_task *task ) for (buf = 0; buf < scene->fb.nr_cbufs; buf++) { struct pipe_surface *cbuf = scene->fb.cbufs[buf]; - const unsigned face_slice = cbuf->face + cbuf->zslice; - const unsigned level = cbuf->level; + const unsigned layer = cbuf->u.tex.first_layer; + const unsigned level = cbuf->u.tex.level; struct llvmpipe_resource *lpt = llvmpipe_resource(cbuf->texture); if (!task->color_tiles[buf]) continue; llvmpipe_unswizzle_cbuf_tile(lpt, - face_slice, + layer, level, task->x, task->y, task->color_tiles[buf]); diff --git a/src/gallium/drivers/llvmpipe/lp_rast_priv.h b/src/gallium/drivers/llvmpipe/lp_rast_priv.h index 6864aeea78a..cd686bc82c1 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast_priv.h +++ b/src/gallium/drivers/llvmpipe/lp_rast_priv.h @@ -194,8 +194,8 @@ lp_rast_get_color_tile_pointer(struct lp_rasterizer_task *task, if (usage != LP_TEX_USAGE_WRITE_ALL) { llvmpipe_swizzle_cbuf_tile(lpt, - cbuf->face + cbuf->zslice, - cbuf->level, + cbuf->u.tex.first_layer, + cbuf->u.tex.level, task->x, task->y, task->color_tiles[buf]); } diff --git a/src/gallium/drivers/llvmpipe/lp_scene.c b/src/gallium/drivers/llvmpipe/lp_scene.c index a4fdf7cff36..978d17c5754 100644 --- a/src/gallium/drivers/llvmpipe/lp_scene.c +++ b/src/gallium/drivers/llvmpipe/lp_scene.c @@ -136,30 +136,30 @@ lp_scene_begin_rasterization(struct lp_scene *scene) int i; //LP_DBG(DEBUG_RAST, "%s\n", __FUNCTION__); - + for (i = 0; i < scene->fb.nr_cbufs; i++) { struct pipe_surface *cbuf = scene->fb.cbufs[i]; + assert(cbuf->u.tex.first_layer == cbuf->u.tex.last_layer); scene->cbufs[i].stride = llvmpipe_resource_stride(cbuf->texture, - cbuf->level); + cbuf->u.tex.level); scene->cbufs[i].map = llvmpipe_resource_map(cbuf->texture, - cbuf->face, - cbuf->level, - cbuf->zslice, + cbuf->u.tex.level, + cbuf->u.tex.first_layer, LP_TEX_USAGE_READ_WRITE, LP_TEX_LAYOUT_LINEAR); } if (fb->zsbuf) { struct pipe_surface *zsbuf = scene->fb.zsbuf; - scene->zsbuf.stride = llvmpipe_resource_stride(zsbuf->texture, zsbuf->level); + assert(zsbuf->u.tex.first_layer == zsbuf->u.tex.last_layer); + scene->zsbuf.stride = llvmpipe_resource_stride(zsbuf->texture, zsbuf->u.tex.level); scene->zsbuf.blocksize = util_format_get_blocksize(zsbuf->texture->format); scene->zsbuf.map = llvmpipe_resource_map(zsbuf->texture, - zsbuf->face, - zsbuf->level, - zsbuf->zslice, + zsbuf->u.tex.level, + zsbuf->u.tex.first_layer, LP_TEX_USAGE_READ_WRITE, LP_TEX_LAYOUT_NONE); } @@ -181,9 +181,8 @@ lp_scene_end_rasterization(struct lp_scene *scene ) if (scene->cbufs[i].map) { struct pipe_surface *cbuf = scene->fb.cbufs[i]; llvmpipe_resource_unmap(cbuf->texture, - cbuf->face, - cbuf->level, - cbuf->zslice); + cbuf->u.tex.level, + cbuf->u.tex.first_layer); scene->cbufs[i].map = NULL; } } @@ -192,9 +191,8 @@ lp_scene_end_rasterization(struct lp_scene *scene ) if (scene->zsbuf.map) { struct pipe_surface *zsbuf = scene->fb.zsbuf; llvmpipe_resource_unmap(zsbuf->texture, - zsbuf->face, - zsbuf->level, - zsbuf->zslice); + zsbuf->u.tex.level, + zsbuf->u.tex.first_layer); scene->zsbuf.map = NULL; } diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c index ad0ea75b3a3..9459a3cd113 100644 --- a/src/gallium/drivers/llvmpipe/lp_screen.c +++ b/src/gallium/drivers/llvmpipe/lp_screen.c @@ -287,12 +287,13 @@ llvmpipe_is_format_supported( struct pipe_screen *_screen, static void llvmpipe_flush_frontbuffer(struct pipe_screen *_screen, - struct pipe_surface *surface, + struct pipe_resource *resource, + unsigned level, unsigned layer, void *context_private) { struct llvmpipe_screen *screen = llvmpipe_screen(_screen); struct sw_winsys *winsys = screen->winsys; - struct llvmpipe_resource *texture = llvmpipe_resource(surface->texture); + struct llvmpipe_resource *texture = llvmpipe_resource(resource); assert(texture->dt); if (texture->dt) diff --git a/src/gallium/drivers/llvmpipe/lp_surface.c b/src/gallium/drivers/llvmpipe/lp_surface.c index 164242eda67..e7e46a628a1 100644 --- a/src/gallium/drivers/llvmpipe/lp_surface.c +++ b/src/gallium/drivers/llvmpipe/lp_surface.c @@ -52,19 +52,23 @@ adjust_to_tile_bounds(unsigned x, unsigned y, unsigned width, unsigned height, static void lp_resource_copy(struct pipe_context *pipe, - struct pipe_resource *dst, struct pipe_subresource subdst, + struct pipe_resource *dst, unsigned dst_level, unsigned dstx, unsigned dsty, unsigned dstz, - struct pipe_resource *src, struct pipe_subresource subsrc, - unsigned srcx, unsigned srcy, unsigned srcz, - unsigned width, unsigned height) + struct pipe_resource *src, unsigned src_level, + const struct pipe_box *src_box) { - /* XXX what about the dstz/srcz parameters - zslice wasn't used... */ + /* XXX this used to ignore srcz/dstz + * assume it works the same for cube and 3d + */ struct llvmpipe_resource *src_tex = llvmpipe_resource(src); struct llvmpipe_resource *dst_tex = llvmpipe_resource(dst); const enum pipe_format format = src_tex->base.format; + unsigned width = src_box->width; + unsigned height = src_box->height; + assert(src_box->depth == 1); llvmpipe_flush_resource(pipe, - dst, subdst.face, subdst.level, + dst, dst_level, dstz, 0, /* flush_flags */ FALSE, /* read_only */ TRUE, /* cpu_access */ @@ -72,7 +76,7 @@ lp_resource_copy(struct pipe_context *pipe, "blit dest"); llvmpipe_flush_resource(pipe, - src, subsrc.face, subsrc.level, + src, src_level, src_box->z, 0, /* flush_flags */ TRUE, /* read_only */ TRUE, /* cpu_access */ @@ -80,9 +84,10 @@ lp_resource_copy(struct pipe_context *pipe, "blit src"); /* - printf("surface copy from %u to %u: %u,%u to %u,%u %u x %u\n", - src_tex->id, dst_tex->id, - srcx, srcy, dstx, dsty, width, height); + printf("surface copy from %u lvl %u to %u lvl %u: %u,%u,%u to %u,%u,%u %u x %u x %u\n", + src_tex->id, src_level, dst_tex->id, dst_level, + src_box->x, src_box->y, src_box->z, dstx, dsty, dstz, + src_box->width, src_box->height, src_box->depth); */ /* set src tiles to linear layout */ @@ -90,12 +95,13 @@ lp_resource_copy(struct pipe_context *pipe, unsigned tx, ty, tw, th; unsigned x, y; - adjust_to_tile_bounds(srcx, srcy, width, height, &tx, &ty, &tw, &th); + adjust_to_tile_bounds(src_box->x, src_box->y, width, height, + &tx, &ty, &tw, &th); for (y = 0; y < th; y += TILE_SIZE) { for (x = 0; x < tw; x += TILE_SIZE) { (void) llvmpipe_get_texture_tile_linear(src_tex, - subsrc.face, subsrc.level, + src_box->z, src_level, LP_TEX_USAGE_READ, tx + x, ty + y); } @@ -130,7 +136,7 @@ lp_resource_copy(struct pipe_context *pipe, usage = LP_TEX_USAGE_READ_WRITE; (void) llvmpipe_get_texture_tile_linear(dst_tex, - subdst.face, subdst.level, + dstz, dst_level, usage, tx + x, ty + y); } @@ -140,22 +146,22 @@ lp_resource_copy(struct pipe_context *pipe, /* copy */ { const ubyte *src_linear_ptr - = llvmpipe_get_texture_image_address(src_tex, subsrc.face, - subsrc.level, + = llvmpipe_get_texture_image_address(src_tex, src_box->z, + src_level, LP_TEX_LAYOUT_LINEAR); ubyte *dst_linear_ptr - = llvmpipe_get_texture_image_address(dst_tex, subdst.face, - subdst.level, + = llvmpipe_get_texture_image_address(dst_tex, dstz, + dst_level, LP_TEX_LAYOUT_LINEAR); if (dst_linear_ptr && src_linear_ptr) { util_copy_rect(dst_linear_ptr, format, - llvmpipe_resource_stride(&dst_tex->base, subdst.level), + llvmpipe_resource_stride(&dst_tex->base, dst_level), dstx, dsty, width, height, src_linear_ptr, - llvmpipe_resource_stride(&src_tex->base, subsrc.level), - srcx, srcy); + llvmpipe_resource_stride(&src_tex->base, src_level), + src_box->x, src_box->y); } } } diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c index f78cd60b37c..9753da5e57e 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.c +++ b/src/gallium/drivers/llvmpipe/lp_texture.c @@ -243,6 +243,7 @@ llvmpipe_resource_create(struct pipe_screen *_screen, /* other data (vertex buffer, const buffer, etc) */ const enum pipe_format format = templat->format; const uint w = templat->width0 / util_format_get_blockheight(format); + /* XXX buffers should only have one dimension, those values should be 1 */ const uint h = templat->height0 / util_format_get_blockwidth(format); const uint d = templat->depth0; const uint bpp = util_format_get_blocksize(format); @@ -330,17 +331,16 @@ llvmpipe_resource_destroy(struct pipe_screen *pscreen, */ void * llvmpipe_resource_map(struct pipe_resource *resource, - unsigned face, - unsigned level, - unsigned zslice, + unsigned level, + unsigned layer, enum lp_texture_usage tex_usage, enum lp_texture_layout layout) { struct llvmpipe_resource *lpr = llvmpipe_resource(resource); uint8_t *map; - assert(face < 6); assert(level < LP_MAX_TEXTURE_LEVELS); + assert(layer < (u_minify(resource->depth0, level) + resource->array_size - 1)); assert(tex_usage == LP_TEX_USAGE_READ || tex_usage == LP_TEX_USAGE_READ_WRITE || @@ -364,9 +364,8 @@ llvmpipe_resource_map(struct pipe_resource *resource, dt_usage = PIPE_TRANSFER_READ_WRITE; } - assert(face == 0); assert(level == 0); - assert(zslice == 0); + assert(layer == 0); /* FIXME: keep map count? */ map = winsys->displaytarget_map(winsys, lpr->dt, dt_usage); @@ -382,15 +381,8 @@ llvmpipe_resource_map(struct pipe_resource *resource, return map2; } else if (resource_is_texture(resource)) { - /* regular texture */ - if (resource->target != PIPE_TEXTURE_CUBE) { - assert(face == 0); - } - if (resource->target != PIPE_TEXTURE_3D) { - assert(zslice == 0); - } - map = llvmpipe_get_texture_image(lpr, face + zslice, level, + map = llvmpipe_get_texture_image(lpr, layer, level, tex_usage, layout); return map; } @@ -405,9 +397,8 @@ llvmpipe_resource_map(struct pipe_resource *resource, */ void llvmpipe_resource_unmap(struct pipe_resource *resource, - unsigned face, unsigned level, - unsigned zslice) + unsigned layer) { struct llvmpipe_resource *lpr = llvmpipe_resource(resource); @@ -416,12 +407,11 @@ llvmpipe_resource_unmap(struct pipe_resource *resource, struct llvmpipe_screen *lp_screen = llvmpipe_screen(resource->screen); struct sw_winsys *winsys = lp_screen->winsys; - assert(face == 0); assert(level == 0); - assert(zslice == 0); + assert(layer == 0); /* make sure linear image is up to date */ - (void) llvmpipe_get_texture_image(lpr, face + zslice, level, + (void) llvmpipe_get_texture_image(lpr, layer, level, LP_TEX_USAGE_READ, LP_TEX_LAYOUT_LINEAR); @@ -521,34 +511,35 @@ llvmpipe_resource_get_handle(struct pipe_screen *screen, static struct pipe_surface * -llvmpipe_get_tex_surface(struct pipe_screen *screen, - struct pipe_resource *pt, - unsigned face, unsigned level, unsigned zslice, - unsigned usage) +llvmpipe_create_surface(struct pipe_context *pipe, + struct pipe_resource *pt, + const struct pipe_surface *surf_tmpl) { struct pipe_surface *ps; - assert(level <= pt->last_level); + assert(surf_tmpl->u.tex.level <= pt->last_level); ps = CALLOC_STRUCT(pipe_surface); if (ps) { pipe_reference_init(&ps->reference, 1); pipe_resource_reference(&ps->texture, pt); - ps->format = pt->format; - ps->width = u_minify(pt->width0, level); - ps->height = u_minify(pt->height0, level); - ps->usage = usage; - - ps->face = face; - ps->level = level; - ps->zslice = zslice; + ps->context = pipe; + ps->format = surf_tmpl->format; + ps->width = u_minify(pt->width0, surf_tmpl->u.tex.level); + ps->height = u_minify(pt->height0, surf_tmpl->u.tex.level); + ps->usage = surf_tmpl->usage; + + ps->u.tex.level = surf_tmpl->u.tex.level; + ps->u.tex.first_layer = surf_tmpl->u.tex.first_layer; + ps->u.tex.last_layer = surf_tmpl->u.tex.last_layer; } return ps; } static void -llvmpipe_tex_surface_destroy(struct pipe_surface *surf) +llvmpipe_surface_destroy(struct pipe_context *pipe, + struct pipe_surface *surf) { /* Effectively do the texture_update work here - if texture images * needed post-processing to put them into hardware layout, this is @@ -562,17 +553,17 @@ llvmpipe_tex_surface_destroy(struct pipe_surface *surf) static struct pipe_transfer * llvmpipe_get_transfer(struct pipe_context *pipe, - struct pipe_resource *resource, - struct pipe_subresource sr, - unsigned usage, - const struct pipe_box *box) + struct pipe_resource *resource, + unsigned level, + unsigned usage, + const struct pipe_box *box) { struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe); struct llvmpipe_resource *lprex = llvmpipe_resource(resource); struct llvmpipe_transfer *lpr; assert(resource); - assert(sr.level <= resource->last_level); + assert(level <= resource->last_level); /* * Transfers, like other pipe operations, must happen in order, so flush the @@ -582,7 +573,8 @@ llvmpipe_get_transfer(struct pipe_context *pipe, boolean read_only = !(usage & PIPE_TRANSFER_WRITE); boolean do_not_block = !!(usage & PIPE_TRANSFER_DONTBLOCK); if (!llvmpipe_flush_resource(pipe, resource, - sr.face, sr.level, + level, + box->depth > 1 ? -1 : box->z, 0, /* flush_flags */ read_only, TRUE, /* cpu_access */ @@ -604,9 +596,9 @@ llvmpipe_get_transfer(struct pipe_context *pipe, struct pipe_transfer *pt = &lpr->base; pipe_resource_reference(&pt->resource, resource); pt->box = *box; - pt->sr = sr; - pt->stride = lprex->row_stride[sr.level]; - pt->slice_stride = lprex->img_stride[sr.level]; + pt->level = level; + pt->stride = lprex->row_stride[level]; + pt->layer_stride = lprex->img_stride[level]; pt->usage = usage; return pt; @@ -640,8 +632,7 @@ llvmpipe_transfer_map( struct pipe_context *pipe, enum lp_texture_usage tex_usage; const char *mode; - assert(transfer->sr.face < 6); - assert(transfer->sr.level < LP_MAX_TEXTURE_LEVELS); + assert(transfer->level < LP_MAX_TEXTURE_LEVELS); /* printf("tex_transfer_map(%d, %d %d x %d of %d x %d, usage %d )\n", @@ -671,9 +662,8 @@ llvmpipe_transfer_map( struct pipe_context *pipe, format = lpr->base.format; map = llvmpipe_resource_map(transfer->resource, - transfer->sr.face, - transfer->sr.level, - transfer->box.z, + transfer->level, + transfer->box.z, tex_usage, LP_TEX_LAYOUT_LINEAR); @@ -685,7 +675,7 @@ llvmpipe_transfer_map( struct pipe_context *pipe, */ screen->timestamp++; } - + map += transfer->box.y / util_format_get_blockheight(format) * transfer->stride + transfer->box.x / util_format_get_blockwidth(format) * util_format_get_blocksize(format); @@ -701,21 +691,20 @@ llvmpipe_transfer_unmap(struct pipe_context *pipe, assert(transfer->resource); llvmpipe_resource_unmap(transfer->resource, - transfer->sr.face, - transfer->sr.level, - transfer->box.z); + transfer->level, + transfer->box.z); } static unsigned int llvmpipe_is_resource_referenced( struct pipe_context *pipe, - struct pipe_resource *presource, - unsigned face, unsigned level) + struct pipe_resource *presource, + unsigned level, int layer) { struct llvmpipe_context *llvmpipe = llvmpipe_context( pipe ); if (presource->target == PIPE_BUFFER) return PIPE_UNREFERENCED; - + return lp_setup_is_resource_referenced(llvmpipe->setup, presource); } @@ -745,6 +734,7 @@ llvmpipe_user_buffer_create(struct pipe_screen *screen, buffer->base.width0 = bytes; buffer->base.height0 = 1; buffer->base.depth0 = 1; + buffer->base.array_size = 1; buffer->userBuffer = TRUE; buffer->data = ptr; @@ -1401,8 +1391,6 @@ llvmpipe_init_screen_resource_funcs(struct pipe_screen *screen) screen->resource_get_handle = llvmpipe_resource_get_handle; screen->user_buffer_create = llvmpipe_user_buffer_create; - screen->get_tex_surface = llvmpipe_get_tex_surface; - screen->tex_surface_destroy = llvmpipe_tex_surface_destroy; } @@ -1417,4 +1405,7 @@ llvmpipe_init_context_resource_funcs(struct pipe_context *pipe) pipe->transfer_flush_region = u_default_transfer_flush_region; pipe->transfer_inline_write = u_default_transfer_inline_write; + + pipe->create_surface = llvmpipe_create_surface; + pipe->surface_destroy = llvmpipe_surface_destroy; } diff --git a/src/gallium/drivers/llvmpipe/lp_texture.h b/src/gallium/drivers/llvmpipe/lp_texture.h index 4e4a65dcb40..b789c0f4090 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.h +++ b/src/gallium/drivers/llvmpipe/lp_texture.h @@ -172,17 +172,15 @@ llvmpipe_resource_stride(struct pipe_resource *resource, void * llvmpipe_resource_map(struct pipe_resource *resource, - unsigned face_slice, - unsigned level, - unsigned zslice, + unsigned level, + unsigned layer, enum lp_texture_usage tex_usage, enum lp_texture_layout layout); void llvmpipe_resource_unmap(struct pipe_resource *resource, - unsigned face_slice, unsigned level, - unsigned zslice); + unsigned layer); void * |