Lines Matching defs:scene
61 * Create a new scene object.
67 struct lp_scene *scene = slab_alloc_st(&setup->scene_slab);
68 if (!scene)
71 memset(scene, 0, sizeof(struct lp_scene));
72 scene->pipe = setup->pipe;
73 scene->setup = setup;
74 scene->data.head = &scene->data.first;
76 (void) mtx_init(&scene->mutex, mtx_plain);
79 /* Do some scene limit sanity checks here */
85 * less than the max allowed scene size.
93 return scene;
98 * Free all data associated with the given scene, and the scene itself.
101 lp_scene_destroy(struct lp_scene *scene)
103 lp_scene_end_rasterization(scene);
104 mtx_destroy(&scene->mutex);
105 free(scene->tiles);
106 assert(scene->data.head == &scene->data.first);
107 slab_free_st(&scene->setup->scene_slab, scene);
112 * Check if the scene's bins are all empty.
116 lp_scene_is_empty(struct lp_scene *scene )
120 for (y = 0; y < scene->tiles_y; y++) {
121 for (x = 0; x < scene->tiles_x; x++) {
122 const struct cmd_bin *bin = lp_scene_get_bin(scene, x, y);
133 * this scene. Used in triangle/rectangle emit to avoid having to
137 lp_scene_is_oom(struct lp_scene *scene)
139 return scene->alloc_failed;
147 lp_scene_bin_reset(struct lp_scene *scene, unsigned x, unsigned y)
149 struct cmd_bin *bin = lp_scene_get_bin(scene, x, y);
199 lp_scene_begin_rasterization(struct lp_scene *scene)
201 const struct pipe_framebuffer_state *fb = &scene->fb;
206 for (i = 0; i < scene->fb.nr_cbufs; i++) {
207 struct pipe_surface *cbuf = scene->fb.cbufs[i];
208 init_scene_texture(&scene->cbufs[i], cbuf);
212 struct pipe_surface *zsbuf = scene->fb.zsbuf;
213 init_scene_texture(&scene->zsbuf, zsbuf);
219 * Free all the temporary data in a scene.
222 lp_scene_end_rasterization(struct lp_scene *scene )
227 for (i = 0; i < scene->fb.nr_cbufs; i++) {
228 if (scene->cbufs[i].map) {
229 struct pipe_surface *cbuf = scene->fb.cbufs[i];
235 scene->cbufs[i].map = NULL;
240 if (scene->zsbuf.map) {
241 struct pipe_surface *zsbuf = scene->fb.zsbuf;
245 scene->zsbuf.map = NULL;
250 memset(scene->tiles, 0, sizeof(struct cmd_bin) * scene->num_alloced_tiles);
255 for (struct resource_ref *ref = scene->resources; ref; ref = ref->next) {
270 for (struct resource_ref *ref = scene->writeable_resources; ref;
287 debug_printf("scene %d resources, sz %d\n",
288 j, scene->resource_reference_size);
294 for (struct shader_ref *ref = scene->frag_shaders; ref; ref = ref->next) {
299 lp_fs_variant_reference(llvmpipe_context(scene->pipe),
304 /* Free all scene data blocks:
307 struct data_block_list *list = &scene->data;
320 lp_fence_reference(&scene->fence, NULL);
322 scene->resources = NULL;
323 scene->writeable_resources = NULL;
324 scene->frag_shaders = NULL;
325 scene->scene_size = 0;
326 scene->resource_reference_size = 0;
328 scene->alloc_failed = FALSE;
330 util_unreference_framebuffer_state( &scene->fb );
339 lp_scene_new_cmd_block( struct lp_scene *scene,
342 struct cmd_block *block = lp_scene_alloc(scene, sizeof(struct cmd_block));
361 lp_scene_new_data_block( struct lp_scene *scene )
363 if (scene->scene_size + DATA_BLOCK_SIZE > LP_SCENE_MAX_SIZE) {
365 scene->alloc_failed = TRUE;
373 scene->scene_size += sizeof *block;
376 block->next = scene->data.head;
377 scene->data.head = block;
385 * Return number of bytes used for all bin data within a scene.
386 * This does not include resources (textures) referenced by the scene.
389 lp_scene_data_size( const struct lp_scene *scene )
393 for (block = scene->data.head; block; block = block->next) {
402 * Add a reference to a resource by the scene.
405 lp_scene_add_resource_reference(struct lp_scene *scene,
412 struct resource_ref **list = writeable ? &scene->writeable_resources : &scene->resources;
437 *last = lp_scene_alloc(scene, sizeof *ref);
448 * finalizing scene rasterization. */
454 scene->resource_reference_size += llvmpipe_resource_size(resource);
456 /* Heuristic to advise scene flushes. This isn't helpful in the
457 * initial setup of the scene, but after that point flush on the
462 scene->resource_reference_size >= LP_SCENE_MAX_RESOURCE_SIZE)
474 lp_scene_add_frag_shader_reference(struct lp_scene *scene,
477 struct shader_ref *ref, **last = &scene->frag_shaders;
481 for (ref = scene->frag_shaders; ref; ref = ref->next) {
501 *last = lp_scene_alloc(scene, sizeof *ref);
511 lp_fs_variant_reference(llvmpipe_context(scene->pipe), &ref->variant[ref->count++], variant);
517 * Does this scene have a reference to the given resource?
520 lp_scene_is_resource_referenced(const struct lp_scene *scene,
526 for (ref = scene->resources; ref; ref = ref->next) {
532 for (ref = scene->writeable_resources; ref; ref = ref->next) {
546 next_bin(struct lp_scene *scene)
548 scene->curr_x++;
549 if (scene->curr_x >= scene->tiles_x) {
550 scene->curr_x = 0;
551 scene->curr_y++;
553 if (scene->curr_y >= scene->tiles_y) {
562 lp_scene_bin_iter_begin( struct lp_scene *scene )
564 scene->curr_x = scene->curr_y = -1;
575 lp_scene_bin_iter_next( struct lp_scene *scene , int *x, int *y)
579 mtx_lock(&scene->mutex);
581 if (scene->curr_x < 0) {
583 scene->curr_x = 0;
584 scene->curr_y = 0;
586 else if (!next_bin(scene)) {
591 bin = lp_scene_get_bin(scene, scene->curr_x, scene->curr_y);
592 *x = scene->curr_x;
593 *y = scene->curr_y;
597 mtx_unlock(&scene->mutex);
602 void lp_scene_begin_binning(struct lp_scene *scene,
608 assert(lp_scene_is_empty(scene));
610 util_copy_framebuffer_state(&scene->fb, fb);
612 scene->tiles_x = align(fb->width, TILE_SIZE) / TILE_SIZE;
613 scene->tiles_y = align(fb->height, TILE_SIZE) / TILE_SIZE;
614 assert(scene->tiles_x <= TILES_X);
615 assert(scene->tiles_y <= TILES_Y);
617 unsigned num_required_tiles = scene->tiles_x * scene->tiles_y;
618 if (scene->num_alloced_tiles < num_required_tiles) {
619 scene->tiles = reallocarray(scene->tiles, num_required_tiles, sizeof(struct cmd_bin));
620 if (!scene->tiles)
622 memset(scene->tiles, 0, sizeof(struct cmd_bin) * num_required_tiles);
623 scene->num_alloced_tiles = num_required_tiles;
632 for (i = 0; i < scene->fb.nr_cbufs; i++) {
633 struct pipe_surface *cbuf = scene->fb.cbufs[i];
645 struct pipe_surface *zsbuf = scene->fb.zsbuf;
648 scene->fb_max_layer = max_layer;
649 scene->fb_max_samples = util_framebuffer_get_num_samples(fb);
650 if (scene->fb_max_samples == 4) {
652 scene->fixed_sample_pos[i][0] = util_iround(lp_sample_pos_4x[i][0] * FIXED_ONE);
653 scene->fixed_sample_pos[i][1] = util_iround(lp_sample_pos_4x[i][1] * FIXED_ONE);
659 void lp_scene_end_binning( struct lp_scene *scene )
662 debug_printf("rasterize scene:\n");
664 scene->scene_size);
666 lp_scene_data_size(scene));
669 lp_debug_bins( scene );