gallium/util: make WRITES_ALL_CBUFS optional in the passthrough fragment shader
authorMarek Olšák <maraeo@gmail.com>
Wed, 29 May 2013 12:11:58 +0000 (14:11 +0200)
committerMarek Olšák <maraeo@gmail.com>
Thu, 13 Jun 2013 01:54:13 +0000 (03:54 +0200)
Reviewed-by: Brian Paul <brianp@vmware.com>
src/gallium/auxiliary/hud/hud_context.c
src/gallium/auxiliary/util/u_simple_shaders.c
src/gallium/auxiliary/util/u_simple_shaders.h
src/gallium/state_trackers/vega/renderer.c
src/gallium/tests/trivial/tri.c
src/mesa/state_tracker/st_atom_shader.c
src/mesa/state_tracker/st_cb_clear.c

index de032b6ba82c923ab11cfbfcdacbda5780e17003..cbd00a9614aa2feccf5f5805a0e3d7edadf2898a 100644 (file)
@@ -959,7 +959,8 @@ hud_create(struct pipe_context *pipe, struct cso_context *cso)
    hud->fs_color =
          util_make_fragment_passthrough_shader(pipe,
                                                TGSI_SEMANTIC_COLOR,
-                                               TGSI_INTERPOLATE_CONSTANT);
+                                               TGSI_INTERPOLATE_CONSTANT,
+                                               TRUE);
 
    {
       /* Read a texture and do .xxxx swizzling. */
index c53c2d024fbe84e4efe6a6ae9941b0c5a0b7e2c9..6ca073dbc46e463c294951b85c5053fb9d36edcb 100644 (file)
@@ -322,11 +322,12 @@ util_make_fragment_tex_shader_writestencil(struct pipe_context *pipe,
 void *
 util_make_fragment_passthrough_shader(struct pipe_context *pipe,
                                       int input_semantic,
-                                      int input_interpolate)
+                                      int input_interpolate,
+                                      boolean write_all_cbufs)
 {
    static const char shader_templ[] =
          "FRAG\n"
-         "PROPERTY FS_COLOR0_WRITES_ALL_CBUFS 1\n"
+         "%s"
          "DCL IN[0], %s[0], %s\n"
          "DCL OUT[0], COLOR[0]\n"
 
@@ -337,7 +338,9 @@ util_make_fragment_passthrough_shader(struct pipe_context *pipe,
    struct tgsi_token tokens[1000];
    struct pipe_shader_state state = {tokens};
 
-   sprintf(text, shader_templ, tgsi_semantic_names[input_semantic],
+   sprintf(text, shader_templ,
+           write_all_cbufs ? "PROPERTY FS_COLOR0_WRITES_ALL_CBUFS 1\n" : "",
+           tgsi_semantic_names[input_semantic],
            tgsi_interpolate_names[input_interpolate]);
 
    if (!tgsi_text_translate(text, tokens, Elements(tokens))) {
index 22b9cee4de655cfa61a0a08aebe3a339c8b4e6f9..06da2490ec7a3f4637626f25ba3aaff95ffbd823 100644 (file)
@@ -89,7 +89,8 @@ util_make_fragment_tex_shader_writestencil(struct pipe_context *pipe,
 extern void *
 util_make_fragment_passthrough_shader(struct pipe_context *pipe,
                                       int input_semantic,
-                                      int input_interpolate);
+                                      int input_interpolate,
+                                      boolean write_all_cbufs);
 
 
 extern void *
index b8232787eba7064a729eeb3234b044a484049f12..35795fc868230ee31248cd95b893d689a639a7b6 100644 (file)
@@ -309,7 +309,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,
-                          TGSI_SEMANTIC_COLOR, TGSI_INTERPOLATE_PERSPECTIVE);
+                          TGSI_SEMANTIC_COLOR, TGSI_INTERPOLATE_PERSPECTIVE,
+                          TRUE);
          break;
       case RENDERER_FS_TEXTURE:
          fs = util_make_fragment_tex_shader(r->pipe,
index 9131bb535db6c78466a2345d2ca492d72483eb75..f93c3f787106ef8c297e6b81f218f5dc1bfac8a9 100644 (file)
@@ -218,7 +218,7 @@ static void init_prog(struct program *p)
 
        /* fragment shader */
        p->fs = util_make_fragment_passthrough_shader(p->pipe,
-                    TGSI_SEMANTIC_COLOR, TGSI_INTERPOLATE_PERSPECTIVE);
+                    TGSI_SEMANTIC_COLOR, TGSI_INTERPOLATE_PERSPECTIVE, TRUE);
 }
 
 static void close_prog(struct program *p)
index c0239e9297c13e9744cefdc3f8ff1d0d2fe3bd25..e22899729a657ccc459d5cf8017a3f35ba6a52b3 100644 (file)
@@ -60,7 +60,8 @@ get_passthrough_fs(struct st_context *st)
    if (!st->passthrough_fs) {
       st->passthrough_fs =
          util_make_fragment_passthrough_shader(st->pipe, TGSI_SEMANTIC_COLOR,
-                                               TGSI_INTERPOLATE_PERSPECTIVE);
+                                               TGSI_INTERPOLATE_PERSPECTIVE,
+                                               TRUE);
    }
 
    return st->passthrough_fs;
index 566f4a76e149892a2f9ccf07f08c79ef7968922c..b8e2fad25d7a8ed35ed4585e9ae57899337fbb65 100644 (file)
@@ -99,7 +99,8 @@ set_fragment_shader(struct st_context *st)
    if (!st->clear.fs)
       st->clear.fs =
          util_make_fragment_passthrough_shader(st->pipe, TGSI_SEMANTIC_GENERIC,
-                                               TGSI_INTERPOLATE_CONSTANT);
+                                               TGSI_INTERPOLATE_CONSTANT,
+                                               TRUE);
 
    cso_set_fragment_shader_handle(st->cso_context, st->clear.fs);
 }