aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/util/u_simple_shaders.c
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/gallium/auxiliary/util/u_simple_shaders.c
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/gallium/auxiliary/util/u_simple_shaders.c')
-rw-r--r--src/gallium/auxiliary/util/u_simple_shaders.c34
1 files changed, 30 insertions, 4 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);
}