/** * \param fence if non-null, returns pointer to a fence which can be waited on */ void llvmpipe_flush( struct pipe_context *pipe, struct pipe_fence_handle **fence, const char *reason) { struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe); draw_flush(llvmpipe->draw); /* ask the setup module to flush */ lp_setup_flush(llvmpipe->setup, fence, reason); /* Enable to dump BMPs of the color/depth buffers each frame */ if (0) { static unsigned frame_no = 1; char filename[256]; unsigned i; for (i = 0; i < llvmpipe->framebuffer.nr_cbufs; i++) { util_snprintf(filename, sizeof(filename), "cbuf%u_%u", i, frame_no); debug_dump_surface_bmp(&llvmpipe->pipe, filename, llvmpipe->framebuffer.cbufs[i]); } if (0) { util_snprintf(filename, sizeof(filename), "zsbuf_%u", frame_no); debug_dump_surface_bmp(&llvmpipe->pipe, filename, llvmpipe->framebuffer.zsbuf); } ++frame_no; } }
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; }
static void draw( void ) { float clear_color[4] = {1,0,1,1}; struct pipe_draw_info info; ctx->clear(ctx, PIPE_CLEAR_COLOR, clear_color, 0, 0); util_draw_init_info(&info); info.indexed = (draw_elements != 0); info.mode = PIPE_PRIM_TRIANGLES; info.start = 0; info.count = 3; /* draw NUM_INST triangles */ info.instance_count = NUM_INST; ctx->draw_vbo(ctx, &info); ctx->flush(ctx, PIPE_FLUSH_RENDER_CACHE, NULL); #if 0 /* At the moment, libgraw leaks out/makes available some of the * symbols from gallium/auxiliary, including these debug helpers. * Will eventually want to bless some of these paths, and lock the * others down so they aren't accessible from test programs. * * This currently just happens to work on debug builds - a release * build will probably fail to link here: */ debug_dump_surface_bmp(ctx, "result.bmp", surf); #endif screen->flush_frontbuffer(screen, surf, window); }
static void draw( void ) { float clear_color[4] = {.1,.3,.5,0}; ctx->clear(ctx, PIPE_CLEAR_COLOR, clear_color, 0, 0); if (draw_strip) util_draw_arrays(ctx, PIPE_PRIM_TRIANGLE_STRIP, 0, 4); else util_draw_arrays(ctx, PIPE_PRIM_TRIANGLES, 0, 3); ctx->flush(ctx, PIPE_FLUSH_RENDER_CACHE, NULL); #if 0 /* At the moment, libgraw leaks out/makes available some of the * symbols from gallium/auxiliary, including these debug helpers. * Will eventually want to bless some of these paths, and lock the * others down so they aren't accessible from test programs. * * This currently just happens to work on debug builds - a release * build will probably fail to link here: */ debug_dump_surface_bmp(ctx, "result.bmp", surf); #endif screen->flush_frontbuffer(screen, surf, window); }
static void draw(struct program *p) { /* set the render target */ cso_set_framebuffer(p->cso, &p->framebuffer); /* clear the render target */ p->pipe->clear(p->pipe, PIPE_CLEAR_COLOR, &p->clear_color, 0, 0); /* set misc state we care about */ cso_set_blend(p->cso, &p->blend); cso_set_depth_stencil_alpha(p->cso, &p->depthstencil); cso_set_rasterizer(p->cso, &p->rasterizer); cso_set_viewport(p->cso, &p->viewport); /* shaders */ cso_set_fragment_shader_handle(p->cso, p->fs); cso_set_vertex_shader_handle(p->cso, p->vs); /* vertex element data */ cso_set_vertex_elements(p->cso, 2, p->velem); util_draw_vertex_buffer(p->pipe, p->cso, p->vbuf, 0, PIPE_PRIM_TRIANGLES, 3, /* verts */ 2); /* attribs/vert */ p->pipe->flush(p->pipe, NULL); debug_dump_surface_bmp(p->pipe, "result.bmp", p->framebuffer.cbufs[0]); }
static void svga_flush( struct pipe_context *pipe, struct pipe_fence_handle **fence, unsigned flags) { struct svga_context *svga = svga_context(pipe); /* Emit buffered drawing commands, and any back copies. */ svga_surfaces_flush( svga ); if (flags & PIPE_FLUSH_FENCE_FD) svga->swc->hints |= SVGA_HINT_FLAG_EXPORT_FENCE_FD; /* Flush command queue. */ svga_context_flush(svga, fence); SVGA_DBG(DEBUG_DMA|DEBUG_PERF, "%s fence_ptr %p\n", __FUNCTION__, fence ? *fence : 0x0); /* Enable to dump BMPs of the color/depth buffers each frame */ if (0) { struct pipe_framebuffer_state *fb = &svga->curr.framebuffer; static unsigned frame_no = 1; char filename[256]; unsigned i; for (i = 0; i < fb->nr_cbufs; i++) { util_snprintf(filename, sizeof(filename), "cbuf%u_%04u.bmp", i, frame_no); debug_dump_surface_bmp(&svga->pipe, filename, fb->cbufs[i]); } if (0 && fb->zsbuf) { util_snprintf(filename, sizeof(filename), "zsbuf_%04u.bmp", frame_no); debug_dump_surface_bmp(&svga->pipe, filename, fb->zsbuf); } ++frame_no; } }
static void draw(struct program *p) { const struct pipe_sampler_state *samplers[] = {&p->sampler}; /* set the render target */ cso_set_framebuffer(p->cso, &p->framebuffer); /* clear the render target */ p->pipe->clear(p->pipe, PIPE_CLEAR_COLOR, &p->clear_color, 0, 0); /* set misc state we care about */ cso_set_blend(p->cso, &p->blend); cso_set_depth_stencil_alpha(p->cso, &p->depthstencil); cso_set_rasterizer(p->cso, &p->rasterizer); cso_set_viewport(p->cso, &p->viewport); /* sampler */ cso_set_samplers(p->cso, PIPE_SHADER_FRAGMENT, 1, samplers); /* texture sampler view */ cso_set_sampler_views(p->cso, PIPE_SHADER_FRAGMENT, 1, &p->view); /* shaders */ cso_set_fragment_shader_handle(p->cso, p->fs); cso_set_vertex_shader_handle(p->cso, p->vs); /* vertex element data */ cso_set_vertex_elements(p->cso, 2, p->velem); util_draw_vertex_buffer(p->pipe, p->cso, p->vbuf, 0, 0, PIPE_PRIM_QUADS, 4, /* verts */ 2); /* attribs/vert */ p->pipe->flush(p->pipe, NULL, 0); debug_dump_surface_bmp(p->pipe, "result.bmp", p->framebuffer.cbufs[0]); }
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; }