gallium: Set all state via cso_context in blit/gen_mipmap utils.
authorJosé Fonseca <jrfonseca@tungstengraphics.com>
Mon, 21 Apr 2008 13:26:33 +0000 (22:26 +0900)
committerJosé Fonseca <jrfonseca@tungstengraphics.com>
Mon, 21 Apr 2008 13:26:33 +0000 (22:26 +0900)
cso_restore_* functions are implemented on top of cso_set_*, therefore
they require full knowledge of the current pipe state to work correctly.
Directly calling pipe's set_*_state functions will lead to undefined state.

Also save and restore shaders.

src/gallium/auxiliary/util/u_blit.c
src/gallium/auxiliary/util/u_gen_mipmap.c

index eec5e60..be5e83e 100644 (file)
@@ -300,6 +300,8 @@ util_blit_pixels(struct blit_state *ctx,
    cso_save_samplers(ctx->cso);
    cso_save_sampler_textures(ctx->cso);
    cso_save_framebuffer(ctx->cso);
+   cso_save_fragment_shader(ctx->cso);
+   cso_save_vertex_shader(ctx->cso);
 
    /* set misc state we care about */
    cso_set_blend(ctx->cso, &ctx->blend);
@@ -313,11 +315,11 @@ util_blit_pixels(struct blit_state *ctx,
    cso_single_sampler_done(ctx->cso);
 
    /* texture */
-   pipe->set_sampler_textures(pipe, 1, &tex);
+   cso_set_sampler_textures(ctx->cso, 1, &tex);
 
    /* shaders */
-   pipe->bind_fs_state(pipe, ctx->fs);
-   pipe->bind_vs_state(pipe, ctx->vs);
+   cso_set_fragment_shader(ctx->cso, ctx->fs);
+   cso_set_vertex_shader(ctx->cso, ctx->vs);
 
    /* drawing dest */
    memset(&fb, 0, sizeof(fb));
@@ -344,6 +346,8 @@ util_blit_pixels(struct blit_state *ctx,
    cso_restore_samplers(ctx->cso);
    cso_restore_sampler_textures(ctx->cso);
    cso_restore_framebuffer(ctx->cso);
+   cso_restore_fragment_shader(ctx->cso);
+   cso_restore_vertex_shader(ctx->cso);
 
    /* free the texture */
    pipe_surface_reference(&texSurf, NULL);
index 2fd214d..f0c4063 100644 (file)
@@ -880,16 +880,18 @@ util_gen_mipmap(struct gen_mipmap_state *ctx,
    cso_save_samplers(ctx->cso);
    cso_save_sampler_textures(ctx->cso);
    cso_save_framebuffer(ctx->cso);
+   cso_save_fragment_shader(ctx->cso);
+   cso_save_vertex_shader(ctx->cso);
 
    /* bind our state */
    cso_set_blend(ctx->cso, &ctx->blend);
    cso_set_depth_stencil_alpha(ctx->cso, &ctx->depthstencil);
    cso_set_rasterizer(ctx->cso, &ctx->rasterizer);
 
-   pipe->bind_vs_state(pipe, ctx->vs);
-   pipe->bind_fs_state(pipe, ctx->fs);
+   cso_set_fragment_shader(ctx->cso, ctx->fs);
+   cso_set_vertex_shader(ctx->cso, ctx->vs);
 #if 0
-   pipe->set_viewport_state(pipe, &ctx->viewport);
+   cso_set_viewport(ctx->cso, &ctx->viewport);
 #endif
 
    /* init framebuffer state */
@@ -930,7 +932,7 @@ util_gen_mipmap(struct gen_mipmap_state *ctx,
       simple_viewport(pipe, pt->width[dstLevel], pt->height[dstLevel]);
 #endif
 
-      pipe->set_sampler_textures(pipe, 1, &pt);
+      cso_set_sampler_textures(ctx->cso, 1, &pt);
 
       /* quad coords in window coords (bypassing clipping, viewport mapping) */
       set_vertex_data(ctx,
@@ -954,4 +956,6 @@ util_gen_mipmap(struct gen_mipmap_state *ctx,
    cso_restore_samplers(ctx->cso);
    cso_restore_sampler_textures(ctx->cso);
    cso_restore_framebuffer(ctx->cso);
+   cso_restore_fragment_shader(ctx->cso);
+   cso_restore_vertex_shader(ctx->cso);
 }