Lines Matching refs:scene
50 * Create a new scene object.
56 struct lp_scene *scene = CALLOC_STRUCT(lp_scene);
57 if (!scene)
60 scene->pipe = pipe;
62 scene->data.head =
65 pipe_mutex_init(scene->mutex);
67 return scene;
72 * Free all data associated with the given scene, and the scene itself.
75 lp_scene_destroy(struct lp_scene *scene)
77 lp_fence_reference(&scene->fence, NULL);
78 pipe_mutex_destroy(scene->mutex);
79 assert(scene->data.head->next == NULL);
80 FREE(scene->data.head);
81 FREE(scene);
86 * Check if the scene's bins are all empty.
90 lp_scene_is_empty(struct lp_scene *scene )
96 const struct cmd_bin *bin = lp_scene_get_bin(scene, x, y);
107 * this scene. Used in triangle emit to avoid having to check success
111 lp_scene_is_oom(struct lp_scene *scene)
113 return scene->alloc_failed;
121 lp_scene_bin_reset(struct lp_scene *scene, unsigned x, unsigned y)
123 struct cmd_bin *bin = lp_scene_get_bin(scene, x, y);
135 lp_scene_begin_rasterization(struct lp_scene *scene)
137 const struct pipe_framebuffer_state *fb = &scene->fb;
142 for (i = 0; i < scene->fb.nr_cbufs; i++) {
143 struct pipe_surface *cbuf = scene->fb.cbufs[i];
145 scene->cbufs[i].stride = llvmpipe_resource_stride(cbuf->texture,
148 scene->cbufs[i].map = llvmpipe_resource_map(cbuf->texture,
156 struct pipe_surface *zsbuf = scene->fb.zsbuf;
158 scene->zsbuf.stride = llvmpipe_resource_stride(zsbuf->texture, zsbuf->u.tex.level);
159 scene->zsbuf.blocksize =
162 scene->zsbuf.map = llvmpipe_resource_map(zsbuf->texture,
174 * Free all the temporary data in a scene.
177 lp_scene_end_rasterization(struct lp_scene *scene )
182 for (i = 0; i < scene->fb.nr_cbufs; i++) {
183 if (scene->cbufs[i].map) {
184 struct pipe_surface *cbuf = scene->fb.cbufs[i];
188 scene->cbufs[i].map = NULL;
193 if (scene->zsbuf.map) {
194 struct pipe_surface *zsbuf = scene->fb.zsbuf;
198 scene->zsbuf.map = NULL;
203 for (i = 0; i < scene->tiles_x; i++) {
204 for (j = 0; j < scene->tiles_y; j++) {
205 struct cmd_bin *bin = lp_scene_get_bin(scene, i, j);
215 assert(lp_scene_is_empty(scene));
223 for (ref = scene->resources; ref; ref = ref->next) {
238 debug_printf("scene %d resources, sz %d\n",
239 j, scene->resource_reference_size);
242 /* Free all scene data blocks:
245 struct data_block_list *list = &scene->data;
257 lp_fence_reference(&scene->fence, NULL);
259 scene->resources = NULL;
260 scene->scene_size = 0;
261 scene->resource_reference_size = 0;
263 scene->has_depthstencil_clear = FALSE;
264 scene->alloc_failed = FALSE;
266 util_unreference_framebuffer_state( &scene->fb );
275 lp_scene_new_cmd_block( struct lp_scene *scene,
278 struct cmd_block *block = lp_scene_alloc(scene, sizeof(struct cmd_block));
297 lp_scene_new_data_block( struct lp_scene *scene )
299 if (scene->scene_size + DATA_BLOCK_SIZE > LP_SCENE_MAX_SIZE) {
301 scene->alloc_failed = TRUE;
309 scene->scene_size += sizeof *block;
312 block->next = scene->data.head;
313 scene->data.head = block;
321 * Return number of bytes used for all bin data within a scene.
322 * This does not include resources (textures) referenced by the scene.
325 lp_scene_data_size( const struct lp_scene *scene )
329 for (block = scene->data.head; block; block = block->next) {
338 * Add a reference to a resource by the scene.
341 lp_scene_add_resource_reference(struct lp_scene *scene,
345 struct resource_ref *ref, **last = &scene->resources;
350 for (ref = scene->resources; ref; ref = ref->next) {
370 *last = lp_scene_alloc(scene, sizeof *ref);
381 scene->resource_reference_size += llvmpipe_resource_size(resource);
383 /* Heuristic to advise scene flushes. This isn't helpful in the
384 * initial setup of the scene, but after that point flush on the
389 scene->resource_reference_size >= LP_SCENE_MAX_RESOURCE_SIZE)
397 * Does this scene have a reference to the given resource?
400 lp_scene_is_resource_referenced(const struct lp_scene *scene,
406 for (ref = scene->resources; ref; ref = ref->next) {
420 next_bin(struct lp_scene *scene)
422 scene->curr_x++;
423 if (scene->curr_x >= scene->tiles_x) {
424 scene->curr_x = 0;
425 scene->curr_y++;
427 if (scene->curr_y >= scene->tiles_y) {
436 lp_scene_bin_iter_begin( struct lp_scene *scene )
438 scene->curr_x = scene->curr_y = -1;
449 lp_scene_bin_iter_next( struct lp_scene *scene )
453 pipe_mutex_lock(scene->mutex);
455 if (scene->curr_x < 0) {
457 scene->curr_x = 0;
458 scene->curr_y = 0;
460 else if (!next_bin(scene)) {
465 bin = lp_scene_get_bin(scene, scene->curr_x, scene->curr_y);
469 pipe_mutex_unlock(scene->mutex);
474 void lp_scene_begin_binning( struct lp_scene *scene,
477 assert(lp_scene_is_empty(scene));
479 util_copy_framebuffer_state(&scene->fb, fb);
481 scene->tiles_x = align(fb->width, TILE_SIZE) / TILE_SIZE;
482 scene->tiles_y = align(fb->height, TILE_SIZE) / TILE_SIZE;
484 assert(scene->tiles_x <= TILES_X);
485 assert(scene->tiles_y <= TILES_Y);
489 void lp_scene_end_binning( struct lp_scene *scene )
492 debug_printf("rasterize scene:\n");
494 scene->scene_size);
496 lp_scene_data_size(scene));
499 lp_debug_bins( scene );