/** * XXX this might get moved someday * Set the framebuffer surface info: color buffers, zbuffer, stencil buffer. * Here, we flush the old surfaces and update the tile cache to point to the new * surfaces. */ void softpipe_set_framebuffer_state(struct pipe_context *pipe, const struct pipe_framebuffer_state *fb) { struct softpipe_context *sp = softpipe_context(pipe); uint i; draw_flush(sp->draw); for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) { struct pipe_surface *cb = i < fb->nr_cbufs ? fb->cbufs[i] : NULL; /* check if changing cbuf */ if (sp->framebuffer.cbufs[i] != cb) { /* flush old */ sp_flush_tile_cache(sp->cbuf_cache[i]); /* assign new */ pipe_surface_reference(&sp->framebuffer.cbufs[i], cb); /* update cache */ sp_tile_cache_set_surface(sp->cbuf_cache[i], cb); } } sp->framebuffer.nr_cbufs = fb->nr_cbufs; /* zbuf changing? */ if (sp->framebuffer.zsbuf != fb->zsbuf) { /* flush old */ sp_flush_tile_cache(sp->zsbuf_cache); /* assign new */ pipe_surface_reference(&sp->framebuffer.zsbuf, fb->zsbuf); /* update cache */ sp_tile_cache_set_surface(sp->zsbuf_cache, fb->zsbuf); /* Tell draw module how deep the Z/depth buffer is * * If no depth buffer is bound, send the utility function the * format for no bound depth (PIPE_FORMAT_NONE). */ draw_set_zs_format(sp->draw, (sp->framebuffer.zsbuf) ? sp->framebuffer.zsbuf->format : PIPE_FORMAT_NONE); } sp->framebuffer.width = fb->width; sp->framebuffer.height = fb->height; sp->framebuffer.samples = fb->samples; sp->framebuffer.layers = fb->layers; sp->dirty |= SP_NEW_FRAMEBUFFER; }
void softpipe_flush( struct pipe_context *pipe, unsigned flags, struct pipe_fence_handle **fence ) { struct softpipe_context *softpipe = softpipe_context(pipe); uint i; draw_flush(softpipe->draw); if (flags & SP_FLUSH_TEXTURE_CACHE) { unsigned sh; for (sh = 0; sh < Elements(softpipe->tex_cache); sh++) { for (i = 0; i < softpipe->num_sampler_views[sh]; i++) { sp_flush_tex_tile_cache(softpipe->tex_cache[sh][i]); } } } /* If this is a swapbuffers, just flush color buffers. * * The zbuffer changes are not discarded, but held in the cache * in the hope that a later clear will wipe them out. */ for (i = 0; i < softpipe->framebuffer.nr_cbufs; i++) if (softpipe->cbuf_cache[i]) sp_flush_tile_cache(softpipe->cbuf_cache[i]); if (softpipe->zsbuf_cache) sp_flush_tile_cache(softpipe->zsbuf_cache); softpipe->dirty_render_cache = FALSE; /* Enable to dump BMPs of the color/depth buffers each frame */ #if 0 if (flags & PIPE_FLUSH_END_OF_FRAME) { static unsigned frame_no = 1; static char filename[256]; util_snprintf(filename, sizeof(filename), "cbuf_%u.bmp", frame_no); debug_dump_surface_bmp(pipe, filename, softpipe->framebuffer.cbufs[0]); util_snprintf(filename, sizeof(filename), "zsbuf_%u.bmp", frame_no); debug_dump_surface_bmp(pipe, filename, softpipe->framebuffer.zsbuf); ++frame_no; } #endif if (fence) *fence = (void*)(intptr_t)1; }
void softpipe_flush( struct pipe_context *pipe, unsigned flags, struct pipe_fence_handle **fence ) { struct softpipe_context *softpipe = softpipe_context(pipe); uint i; draw_flush(softpipe->draw); if (flags & PIPE_FLUSH_TEXTURE_CACHE) { for (i = 0; i < softpipe->num_sampler_views; i++) { sp_flush_tex_tile_cache(softpipe->tex_cache[i]); } for (i = 0; i < softpipe->num_vertex_sampler_views; i++) { sp_flush_tex_tile_cache(softpipe->vertex_tex_cache[i]); } for (i = 0; i < softpipe->num_geometry_sampler_views; i++) { sp_flush_tex_tile_cache(softpipe->geometry_tex_cache[i]); } } if (flags & PIPE_FLUSH_SWAPBUFFERS) { /* If this is a swapbuffers, just flush color buffers. * * The zbuffer changes are not discarded, but held in the cache * in the hope that a later clear will wipe them out. */ for (i = 0; i < softpipe->framebuffer.nr_cbufs; i++) if (softpipe->cbuf_cache[i]) sp_flush_tile_cache(softpipe->cbuf_cache[i]); /* Need this call for hardware buffers before swapbuffers. * * there should probably be another/different flush-type function * that's called before swapbuffers because we don't always want * to unmap surfaces when flushing. */ softpipe_unmap_transfers(softpipe); } else if (flags & PIPE_FLUSH_RENDER_CACHE) { for (i = 0; i < softpipe->framebuffer.nr_cbufs; i++) if (softpipe->cbuf_cache[i]) sp_flush_tile_cache(softpipe->cbuf_cache[i]); if (softpipe->zsbuf_cache) sp_flush_tile_cache(softpipe->zsbuf_cache); softpipe->dirty_render_cache = FALSE; } /* Enable to dump BMPs of the color/depth buffers each frame */ #if 0 if(flags & PIPE_FLUSH_FRAME) { static unsigned frame_no = 1; static char filename[256]; util_snprintf(filename, sizeof(filename), "cbuf_%u.bmp", frame_no); debug_dump_surface_bmp(softpipe, filename, softpipe->framebuffer.cbufs[0]); util_snprintf(filename, sizeof(filename), "zsbuf_%u.bmp", frame_no); debug_dump_surface_bmp(softpipe, filename, softpipe->framebuffer.zsbuf); ++frame_no; } #endif if (fence) *fence = NULL; }
/** * XXX this might get moved someday * Set the framebuffer surface info: color buffers, zbuffer, stencil buffer. * Here, we flush the old surfaces and update the tile cache to point to the new * surfaces. */ void softpipe_set_framebuffer_state(struct pipe_context *pipe, const struct pipe_framebuffer_state *fb) { struct softpipe_context *sp = softpipe_context(pipe); uint i; for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) { /* check if changing cbuf */ if (sp->framebuffer.cbufs[i] != fb->cbufs[i]) { /* flush old */ sp_flush_tile_cache(sp, sp->cbuf_cache[i]); /* assign new */ sp->framebuffer.cbufs[i] = fb->cbufs[i]; /* update cache */ sp_tile_cache_set_surface(sp->cbuf_cache[i], fb->cbufs[i]); } } sp->framebuffer.num_cbufs = fb->num_cbufs; /* zbuf changing? */ if (sp->framebuffer.zsbuf != fb->zsbuf) { /* flush old */ sp_flush_tile_cache(sp, sp->zsbuf_cache); /* assign new */ sp->framebuffer.zsbuf = fb->zsbuf; /* update cache */ sp_tile_cache_set_surface(sp->zsbuf_cache, fb->zsbuf); } #if 0 /* XXX combined depth/stencil here */ /* sbuf changing? */ if (sp->framebuffer.sbuf != fb->sbuf) { /* flush old */ sp_flush_tile_cache(sp, sp->sbuf_cache_sep); /* assign new */ sp->framebuffer.sbuf = fb->sbuf; /* update cache */ if (fb->sbuf != fb->zbuf) { /* separate stencil buf */ sp->sbuf_cache = sp->sbuf_cache_sep; sp_tile_cache_set_surface(sp->sbuf_cache, fb->sbuf); } else { /* combined depth/stencil */ sp->sbuf_cache = sp->zbuf_cache; sp_tile_cache_set_surface(sp->sbuf_cache, fb->sbuf); } } #endif sp->framebuffer.width = fb->width; sp->framebuffer.height = fb->height; sp->dirty |= SP_NEW_FRAMEBUFFER; }