pipe_mutex_init(scene->mutex);
+#ifdef DEBUG
+ /* Do some scene limit sanity checks here */
+ {
+ size_t maxBins = TILES_X * TILES_Y;
+ size_t maxCommandBytes = sizeof(struct cmd_block) * maxBins;
+ size_t maxCommandPlusData = maxCommandBytes + DATA_BLOCK_SIZE;
+ /* We'll need at least one command block per bin. Make sure that's
+ * less than the max allowed scene size.
+ */
+ assert(maxCommandBytes < LP_SCENE_MAX_SIZE);
+ /* We'll also need space for at least one other data block */
+ assert(maxCommandPlusData <= LP_SCENE_MAX_SIZE);
+ }
+#endif
+
return scene;
}
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->u.tex.level);
-
- scene->cbufs[i].map = llvmpipe_resource_map(cbuf->texture,
- cbuf->u.tex.level,
- cbuf->u.tex.first_layer,
- LP_TEX_USAGE_READ_WRITE,
- LP_TEX_LAYOUT_LINEAR);
+ if (llvmpipe_resource_is_texture(cbuf->texture)) {
+ scene->cbufs[i].stride = llvmpipe_resource_stride(cbuf->texture,
+ cbuf->u.tex.level);
+
+ scene->cbufs[i].map = llvmpipe_resource_map(cbuf->texture,
+ cbuf->u.tex.level,
+ cbuf->u.tex.first_layer,
+ LP_TEX_USAGE_READ_WRITE);
+ }
+ else {
+ struct llvmpipe_resource *lpr = llvmpipe_resource(cbuf->texture);
+ unsigned pixstride = util_format_get_blocksize(cbuf->format);
+ scene->cbufs[i].stride = cbuf->texture->width0;
+ scene->cbufs[i].map = lpr->data;
+ scene->cbufs[i].map += cbuf->u.buf.first_element * pixstride;
+ }
}
if (fb->zsbuf) {
struct pipe_surface *zsbuf = scene->fb.zsbuf;
- 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->u.tex.level,
zsbuf->u.tex.first_layer,
- LP_TEX_USAGE_READ_WRITE,
- LP_TEX_LAYOUT_NONE);
+ LP_TEX_USAGE_READ_WRITE);
}
}
for (i = 0; i < scene->fb.nr_cbufs; i++) {
if (scene->cbufs[i].map) {
struct pipe_surface *cbuf = scene->fb.cbufs[i];
- llvmpipe_resource_unmap(cbuf->texture,
- cbuf->u.tex.level,
- cbuf->u.tex.first_layer);
+ if (llvmpipe_resource_is_texture(cbuf->texture)) {
+ llvmpipe_resource_unmap(cbuf->texture,
+ cbuf->u.tex.level,
+ cbuf->u.tex.first_layer);
+ }
scene->cbufs[i].map = NULL;
}
}
* of work (a bin) to work on.
*/
struct cmd_bin *
-lp_scene_bin_iter_next( struct lp_scene *scene )
+lp_scene_bin_iter_next( struct lp_scene *scene , int *x, int *y)
{
struct cmd_bin *bin = NULL;
}
bin = lp_scene_get_bin(scene, scene->curr_x, scene->curr_y);
+ *x = scene->curr_x;
+ *y = scene->curr_y;
end:
/*printf("return bin %p at %d, %d\n", (void *) bin, *bin_x, *bin_y);*/