summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2013-01-14 17:07:58 +0100
committerMarek Olšák <[email protected]>2013-01-15 16:47:18 +0100
commit355d463f73976a5b091371690e5a914511b0b938 (patch)
tree21873711c5ec7f39aee45e7b752388ecbc666969 /src
parent2cd1407d2d376041a5334d79de1ac43a71dcc3cf (diff)
gallium/util: fix glClear with MRT by making the FS write to all cbufs
Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/gallium/auxiliary/util/u_simple_shaders.c34
-rw-r--r--src/gallium/auxiliary/util/u_simple_shaders.h4
-rw-r--r--src/gallium/state_trackers/vega/renderer.c3
-rw-r--r--src/gallium/tests/trivial/tri.c3
-rw-r--r--src/mesa/state_tracker/st_atom_shader.c3
-rw-r--r--src/mesa/state_tracker/st_cb_clear.c4
6 files changed, 42 insertions, 9 deletions
diff --git a/src/gallium/auxiliary/util/u_simple_shaders.c b/src/gallium/auxiliary/util/u_simple_shaders.c
index 5f0134d7014..7e3666122bf 100644
--- a/src/gallium/auxiliary/util/u_simple_shaders.c
+++ b/src/gallium/auxiliary/util/u_simple_shaders.c
@@ -316,13 +316,39 @@ util_make_fragment_tex_shader_writestencil(struct pipe_context *pipe,
/**
- * Make simple fragment color pass-through shader.
+ * Make simple fragment color pass-through shader that replicates OUT[0]
+ * to all bound colorbuffers.
*/
void *
-util_make_fragment_passthrough_shader(struct pipe_context *pipe)
+util_make_fragment_passthrough_shader(struct pipe_context *pipe,
+ int input_semantic,
+ int input_interpolate)
{
- return util_make_fragment_cloneinput_shader(pipe, 1, TGSI_SEMANTIC_COLOR,
- TGSI_INTERPOLATE_PERSPECTIVE);
+ static const char shader_templ[] =
+ "FRAG\n"
+ "PROPERTY FS_COLOR0_WRITES_ALL_CBUFS 1\n"
+ "DCL IN[0], %s[0], %s\n"
+ "DCL OUT[0], COLOR[0]\n"
+
+ "MOV OUT[0], IN[0]\n"
+ "END\n";
+
+ char text[sizeof(shader_templ)+100];
+ struct tgsi_token tokens[1000];
+ struct pipe_shader_state state = {tokens};
+
+ sprintf(text, shader_templ, tgsi_semantic_names[input_semantic],
+ tgsi_interpolate_names[input_interpolate]);
+
+ if (!tgsi_text_translate(text, tokens, Elements(tokens))) {
+ assert(0);
+ return NULL;
+ }
+#if 0
+ tgsi_dump(state.tokens, 0);
+#endif
+
+ return pipe->create_fs_state(pipe, &state);
}
diff --git a/src/gallium/auxiliary/util/u_simple_shaders.h b/src/gallium/auxiliary/util/u_simple_shaders.h
index e4ffde6521e..22b9cee4de6 100644
--- a/src/gallium/auxiliary/util/u_simple_shaders.h
+++ b/src/gallium/auxiliary/util/u_simple_shaders.h
@@ -87,7 +87,9 @@ util_make_fragment_tex_shader_writestencil(struct pipe_context *pipe,
extern void *
-util_make_fragment_passthrough_shader(struct pipe_context *pipe);
+util_make_fragment_passthrough_shader(struct pipe_context *pipe,
+ int input_semantic,
+ int input_interpolate);
extern void *
diff --git a/src/gallium/state_trackers/vega/renderer.c b/src/gallium/state_trackers/vega/renderer.c
index 11d3b5a0779..61e31053234 100644
--- a/src/gallium/state_trackers/vega/renderer.c
+++ b/src/gallium/state_trackers/vega/renderer.c
@@ -308,7 +308,8 @@ static void renderer_set_fs(struct renderer *r, RendererFs id)
switch (id) {
case RENDERER_FS_COLOR:
- fs = util_make_fragment_passthrough_shader(r->pipe);
+ fs = util_make_fragment_passthrough_shader(r->pipe,
+ TGSI_SEMANTIC_COLOR, TGSI_INTERPOLATE_PERSPECTIVE);
break;
case RENDERER_FS_TEXTURE:
fs = util_make_fragment_tex_shader(r->pipe,
diff --git a/src/gallium/tests/trivial/tri.c b/src/gallium/tests/trivial/tri.c
index ad88b869c8d..9acf2e1628a 100644
--- a/src/gallium/tests/trivial/tri.c
+++ b/src/gallium/tests/trivial/tri.c
@@ -216,7 +216,8 @@ static void init_prog(struct program *p)
}
/* fragment shader */
- p->fs = util_make_fragment_passthrough_shader(p->pipe);
+ p->fs = util_make_fragment_passthrough_shader(p->pipe,
+ TGSI_SEMANTIC_COLOR, TGSI_INTERPOLATE_PERSPECTIVE);
}
static void close_prog(struct program *p)
diff --git a/src/mesa/state_tracker/st_atom_shader.c b/src/mesa/state_tracker/st_atom_shader.c
index 45e7a117f5c..c1d7c80bb3a 100644
--- a/src/mesa/state_tracker/st_atom_shader.c
+++ b/src/mesa/state_tracker/st_atom_shader.c
@@ -59,7 +59,8 @@ get_passthrough_fs(struct st_context *st)
{
if (!st->passthrough_fs) {
st->passthrough_fs =
- util_make_fragment_passthrough_shader(st->pipe);
+ util_make_fragment_passthrough_shader(st->pipe, TGSI_SEMANTIC_COLOR,
+ TGSI_INTERPOLATE_PERSPECTIVE);
}
return st->passthrough_fs;
diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c
index 5cf4c07f126..aabea6335ff 100644
--- a/src/mesa/state_tracker/st_cb_clear.c
+++ b/src/mesa/state_tracker/st_cb_clear.c
@@ -96,7 +96,9 @@ static INLINE void
set_fragment_shader(struct st_context *st)
{
if (!st->clear.fs)
- st->clear.fs = util_make_fragment_passthrough_shader(st->pipe);
+ st->clear.fs =
+ util_make_fragment_passthrough_shader(st->pipe, TGSI_SEMANTIC_COLOR,
+ TGSI_INTERPOLATE_CONSTANT);
cso_set_fragment_shader_handle(st->cso_context, st->clear.fs);
}