gallium: Use CSO cache for shaders.

This commit is contained in:
Michel Dänzer
2008-04-21 17:51:39 +01:00
parent 0824fb1d6a
commit 65efe807b9
6 changed files with 20 additions and 30 deletions

View File

@@ -273,8 +273,8 @@ update_linkage( struct st_context *st )
st->vp = stvp;
st->fp = stfp;
st->pipe->bind_vs_state(st->pipe, stvp->driver_shader);
st->pipe->bind_fs_state(st->pipe, stfp->driver_shader);
cso_set_vertex_shader(st->cso_context, stvp->driver_shader);
cso_set_fragment_shader(st->cso_context, stfp->driver_shader);
st->vertex_result_to_slot = xvp->output_to_slot;
}

View File

@@ -438,16 +438,18 @@ draw_bitmap_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
cso_save_samplers(cso);
cso_save_sampler_textures(cso);
cso_save_viewport(cso);
cso_save_fragment_shader(cso);
cso_save_vertex_shader(cso);
/* rasterizer state: just scissor */
st->bitmap.rasterizer.scissor = ctx->Scissor.Enabled;
cso_set_rasterizer(cso, &st->bitmap.rasterizer);
/* fragment shader state: TEX lookup program */
pipe->bind_fs_state(pipe, stfp->driver_shader);
cso_set_fragment_shader(cso, stfp->driver_shader);
/* vertex shader state: position + texcoord pass-through */
pipe->bind_vs_state(pipe, st->bitmap.vs);
cso_set_vertex_shader(cso, st->bitmap.vs);
/* sampler / texture state */
cso_single_sampler(cso, 0, &st->bitmap.sampler);
@@ -488,9 +490,8 @@ draw_bitmap_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
cso_restore_samplers(cso);
cso_restore_sampler_textures(cso);
cso_restore_viewport(cso);
/* shaders don't go through cso yet */
pipe->bind_fs_state(pipe, st->fp->driver_shader);
pipe->bind_vs_state(pipe, st->vp->driver_shader);
cso_save_fragment_shader(cso);
cso_save_vertex_shader(cso);
}

View File

@@ -71,7 +71,6 @@ st_BlitFramebuffer(GLcontext *ctx,
GLbitfield mask, GLenum filter)
{
struct st_context *st = ctx->st;
struct pipe_context *pipe = st->pipe;
const uint pFilter = ((filter == GL_NEAREST)
? PIPE_TEX_MIPFILTER_NEAREST
@@ -100,10 +99,6 @@ st_BlitFramebuffer(GLcontext *ctx,
0.0, pFilter);
}
/* shaders don't go through CSO yet */
pipe->bind_fs_state(pipe, st->fp->driver_shader);
pipe->bind_vs_state(pipe, st->vp->driver_shader);
}

View File

@@ -195,7 +195,6 @@ clear_with_quad(GLcontext *ctx,
GLboolean color, GLboolean depth, GLboolean stencil)
{
struct st_context *st = ctx->st;
struct pipe_context *pipe = st->pipe;
const GLfloat x0 = ctx->DrawBuffer->_Xmin;
const GLfloat x1 = ctx->DrawBuffer->_Xmax;
GLfloat y0, y1;
@@ -222,6 +221,8 @@ clear_with_quad(GLcontext *ctx,
cso_save_depth_stencil_alpha(st->cso_context);
cso_save_rasterizer(st->cso_context);
cso_save_viewport(st->cso_context);
cso_save_fragment_shader(st->cso_context);
cso_save_vertex_shader(st->cso_context);
/* blend state: RGBA masking */
{
@@ -273,8 +274,8 @@ clear_with_quad(GLcontext *ctx,
cso_set_rasterizer(st->cso_context, &st->clear.raster);
cso_set_viewport(st->cso_context, &st->clear.viewport);
pipe->bind_fs_state(pipe, st->clear.fs);
pipe->bind_vs_state(pipe, st->clear.vs);
cso_set_fragment_shader(st->cso_context, st->clear.fs);
cso_set_vertex_shader(st->cso_context, st->clear.vs);
/* draw quad matching scissor rect (XXX verify coord round-off) */
draw_quad(ctx, x0, y0, x1, y1, ctx->Depth.Clear, ctx->Color.ClearColor);
@@ -284,9 +285,8 @@ clear_with_quad(GLcontext *ctx,
cso_restore_depth_stencil_alpha(st->cso_context);
cso_restore_rasterizer(st->cso_context);
cso_restore_viewport(st->cso_context);
/* these don't go through cso yet */
pipe->bind_fs_state(pipe, st->fp->driver_shader);
pipe->bind_vs_state(pipe, st->vp->driver_shader);
cso_restore_fragment_shader(st->cso_context);
cso_restore_vertex_shader(st->cso_context);
}

View File

@@ -532,6 +532,8 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
cso_save_viewport(cso);
cso_save_samplers(cso);
cso_save_sampler_textures(cso);
cso_save_fragment_shader(cso);
cso_save_vertex_shader(cso);
/* rasterizer state: just scissor */
{
@@ -543,10 +545,10 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
}
/* fragment shader state: TEX lookup program */
pipe->bind_fs_state(pipe, stfp->driver_shader);
cso_set_fragment_shader(cso, stfp->driver_shader);
/* vertex shader state: position + texcoord pass-through */
pipe->bind_vs_state(pipe, stvp->driver_shader);
cso_set_vertex_shader(cso, stvp->driver_shader);
/* texture sampling state: */
@@ -615,10 +617,8 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
cso_restore_viewport(cso);
cso_restore_samplers(cso);
cso_restore_sampler_textures(cso);
/* shaders don't go through cso yet */
pipe->bind_fs_state(pipe, st->fp->driver_shader);
pipe->bind_vs_state(pipe, st->vp->driver_shader);
cso_restore_fragment_shader(cso);
cso_restore_vertex_shader(cso);
}

View File

@@ -95,12 +95,6 @@ st_render_mipmap(struct st_context *st,
util_gen_mipmap(st->gen_mipmap, pt, face, baseLevel, lastLevel,
PIPE_TEX_FILTER_LINEAR);
/* shaders don't go through CSO yet */
if (st->fp)
pipe->bind_fs_state(pipe, st->fp->driver_shader);
if (st->vp)
pipe->bind_vs_state(pipe, st->vp->driver_shader);
return TRUE;
}