gallivm: fix conversion for pure integer formats
[mesa.git] / src / gallium / auxiliary / postprocess / pp_run.c
index 9d0bfdf81ffd2dea147e8df10d04916df1a9b115..0bed547bd445ac327ce88b8b4a065197bb3875e2 100644 (file)
@@ -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) {
@@ -60,11 +61,35 @@ pp_run(struct pp_queue_t *ppq, struct pipe_resource *in,
       util_blit_pixels(ppq->p->blitctx, in, 0, 0, 0,
                        w, h, 0, ppq->tmps[0],
                        0, 0, w, h, 0, PIPE_TEX_MIPFILTER_NEAREST,
-                       TGSI_WRITEMASK_XYZW);
+                       TGSI_WRITEMASK_XYZW, 0);
 
       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);
+   cso_save_render_condition(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);
+   cso_set_render_condition(cso, NULL, 0);
+
    // Kept only for this frame.
    pipe_resource_reference(&ppq->depth, indepth);
    pipe_resource_reference(&refin, in);
@@ -100,6 +125,24 @@ 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);
+   cso_restore_render_condition(cso);
+
    pipe_resource_reference(&ppq->depth, NULL);
    pipe_resource_reference(&refin, NULL);
    pipe_resource_reference(&refout, NULL);
@@ -123,7 +166,6 @@ void
 pp_filter_setup_out(struct program *p, struct pipe_resource *out)
 {
    p->surf.format = out->format;
-   p->surf.usage = PIPE_BIND_RENDER_TARGET;
 
    p->framebuffer.cbufs[0] = p->pipe->create_surface(p->pipe, out, &p->surf);
 }
@@ -178,9 +220,8 @@ pp_filter_misc_state(struct program *p)
 void
 pp_filter_draw(struct program *p)
 {
-   util_draw_vertex_buffer(p->pipe, p->cso, p->vbuf, 0,
+   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. */