diff options
author | Marek Olšák <[email protected]> | 2012-11-29 02:55:01 +0100 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2012-11-29 20:31:41 +0100 |
commit | 3e163a137be7f9a80ec720903c4bda028de5681f (patch) | |
tree | f227c113227d2440d700d66bb6fc9dc27d98b9b1 /src/gallium/auxiliary/postprocess/pp_run.c | |
parent | 135fe907a016ec20b6779f6b3a657563e89c1081 (diff) |
gallium/postprocess: share pipe_context and cso_context with the state tracker
Using one context instead of two is more efficient and
we can skip another context flush.
Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary/postprocess/pp_run.c')
-rw-r--r-- | src/gallium/auxiliary/postprocess/pp_run.c | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/src/gallium/auxiliary/postprocess/pp_run.c b/src/gallium/auxiliary/postprocess/pp_run.c index 4e6d6750f0b..6f063246562 100644 --- a/src/gallium/auxiliary/postprocess/pp_run.c +++ b/src/gallium/auxiliary/postprocess/pp_run.c @@ -44,6 +44,7 @@ pp_run(struct pp_queue_t *ppq, struct pipe_resource *in, { struct pipe_resource *refin = NULL, *refout = NULL; unsigned int i; + struct cso_context *cso = ppq->p->cso; if (in->width0 != ppq->p->framebuffer.width || in->height0 != ppq->p->framebuffer.height) { @@ -65,6 +66,28 @@ pp_run(struct pp_queue_t *ppq, struct pipe_resource *in, in = ppq->tmp[0]; } + /* save state (restored below) */ + cso_save_blend(cso); + cso_save_depth_stencil_alpha(cso); + cso_save_fragment_shader(cso); + cso_save_framebuffer(cso); + cso_save_geometry_shader(cso); + cso_save_rasterizer(cso); + cso_save_sample_mask(cso); + cso_save_samplers(cso, PIPE_SHADER_FRAGMENT); + cso_save_sampler_views(cso, PIPE_SHADER_FRAGMENT); + cso_save_stencil_ref(cso); + cso_save_stream_outputs(cso); + cso_save_vertex_elements(cso); + cso_save_vertex_shader(cso); + cso_save_viewport(cso); + cso_save_aux_vertex_buffer_slot(cso); + + /* set default state */ + cso_set_sample_mask(cso, ~0); + cso_set_stream_outputs(cso, 0, NULL, 0); + cso_set_geometry_shader_handle(cso, NULL); + // Kept only for this frame. pipe_resource_reference(&ppq->depth, indepth); pipe_resource_reference(&refin, in); @@ -100,6 +123,23 @@ pp_run(struct pp_queue_t *ppq, struct pipe_resource *in, break; } + /* restore state we changed */ + cso_restore_blend(cso); + cso_restore_depth_stencil_alpha(cso); + cso_restore_fragment_shader(cso); + cso_restore_framebuffer(cso); + cso_restore_geometry_shader(cso); + cso_restore_rasterizer(cso); + cso_restore_sample_mask(cso); + cso_restore_samplers(cso, PIPE_SHADER_FRAGMENT); + cso_restore_sampler_views(cso, PIPE_SHADER_FRAGMENT); + cso_restore_stencil_ref(cso); + cso_restore_stream_outputs(cso); + cso_restore_vertex_elements(cso); + cso_restore_vertex_shader(cso); + cso_restore_viewport(cso); + cso_restore_aux_vertex_buffer_slot(cso); + pipe_resource_reference(&ppq->depth, NULL); pipe_resource_reference(&refin, NULL); pipe_resource_reference(&refout, NULL); @@ -180,7 +220,6 @@ pp_filter_draw(struct program *p) { util_draw_vertex_buffer(p->pipe, p->cso, p->vbuf, 0, 0, PIPE_PRIM_QUADS, 4, 2); - p->pipe->flush(p->pipe, NULL); } /** Set the framebuffer as active. */ |