summaryrefslogtreecommitdiff
path: root/src/mesa
diff options
context:
space:
mode:
authorJakob Bornecrantz <wallbraker@gmail.com>2011-03-05 13:27:00 +0100
committerJakob Bornecrantz <wallbraker@gmail.com>2011-03-12 19:39:45 +0100
commit1a79064da12a8be71dca7656e5eebc4b85d2b35f (patch)
treec171bb2f0988a3889579f5d02773585694b89aa6 /src/mesa
parent7339915a4bfb563c5986d139e83aa7664f346e89 (diff)
gallium: Delay the creation of simple helper shaders
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/state_tracker/st_cb_clear.c54
1 files changed, 38 insertions, 16 deletions
diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c
index 0e0c4326ed..1eb748e0d5 100644
--- a/src/mesa/state_tracker/st_cb_clear.c
+++ b/src/mesa/state_tracker/st_cb_clear.c
@@ -63,26 +63,12 @@
void
st_init_clear(struct st_context *st)
{
- struct pipe_context *pipe = st->pipe;
struct pipe_screen *pscreen = st->pipe->screen;
memset(&st->clear, 0, sizeof(st->clear));
st->clear.raster.gl_rasterization_rules = 1;
st->clear.enable_ds_separate = pscreen->get_param(pscreen, PIPE_CAP_DEPTHSTENCIL_CLEAR_SEPARATE);
-
- /* fragment shader state: color pass-through program */
- st->clear.fs = util_make_fragment_passthrough_shader(pipe);
-
- /* vertex shader state: color/position pass-through */
- {
- const uint semantic_names[] = { TGSI_SEMANTIC_POSITION,
- TGSI_SEMANTIC_COLOR };
- const uint semantic_indexes[] = { 0, 0 };
- st->clear.vs = util_make_vertex_passthrough_shader(pipe, 2,
- semantic_names,
- semantic_indexes);
- }
}
@@ -108,6 +94,42 @@ st_destroy_clear(struct st_context *st)
/**
+ * Helper function to set the fragment shaders.
+ */
+static INLINE void
+set_fragment_shader(struct st_context *st)
+{
+ if (!st->clear.fs)
+ st->clear.fs = util_make_fragment_passthrough_shader(st->pipe);
+
+ cso_set_fragment_shader_handle(st->cso_context, st->clear.fs);
+}
+
+
+/**
+ * Helper function to set the vertex shader.
+ */
+static INLINE void
+set_vertex_shader(struct st_context *st)
+{
+ /* vertex shader - still required to provide the linkage between
+ * fragment shader input semantics and vertex_element/buffers.
+ */
+ if (!st->clear.vs)
+ {
+ const uint semantic_names[] = { TGSI_SEMANTIC_POSITION,
+ TGSI_SEMANTIC_COLOR };
+ const uint semantic_indexes[] = { 0, 0 };
+ st->clear.vs = util_make_vertex_passthrough_shader(st->pipe, 2,
+ semantic_names,
+ semantic_indexes);
+ }
+
+ cso_set_vertex_shader_handle(st->cso_context, st->clear.vs);
+}
+
+
+/**
* Draw a screen-aligned quadrilateral.
* Coords are clip coords with y=0=bottom.
*/
@@ -297,8 +319,8 @@ clear_with_quad(struct gl_context *ctx,
}
cso_set_clip(st->cso_context, &st->clear.clip);
- cso_set_fragment_shader_handle(st->cso_context, st->clear.fs);
- cso_set_vertex_shader_handle(st->cso_context, st->clear.vs);
+ set_fragment_shader(st);
+ set_vertex_shader(st);
if (ctx->DrawBuffer->_ColorDrawBuffers[0]) {
st_translate_color(ctx->Color.ClearColor,