[Mesa-dev] [PATCH 01/15] gallium/util: make WRITES_ALL_CBUFS optional in the passthrough fragment shader

Marek Olšák maraeo at gmail.com
Sat Jun 1 07:29:17 PDT 2013


---
 src/gallium/auxiliary/hud/hud_context.c       |    3 ++-
 src/gallium/auxiliary/util/u_simple_shaders.c |    9 ++++++---
 src/gallium/auxiliary/util/u_simple_shaders.h |    3 ++-
 src/gallium/state_trackers/vega/renderer.c    |    3 ++-
 src/gallium/tests/trivial/tri.c               |    2 +-
 src/mesa/state_tracker/st_atom_shader.c       |    3 ++-
 src/mesa/state_tracker/st_cb_clear.c          |    3 ++-
 7 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/src/gallium/auxiliary/hud/hud_context.c b/src/gallium/auxiliary/hud/hud_context.c
index de032b6..cbd00a9 100644
--- a/src/gallium/auxiliary/hud/hud_context.c
+++ b/src/gallium/auxiliary/hud/hud_context.c
@@ -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. */
diff --git a/src/gallium/auxiliary/util/u_simple_shaders.c b/src/gallium/auxiliary/util/u_simple_shaders.c
index c53c2d0..6ca073d 100644
--- a/src/gallium/auxiliary/util/u_simple_shaders.c
+++ b/src/gallium/auxiliary/util/u_simple_shaders.c
@@ -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))) {
diff --git a/src/gallium/auxiliary/util/u_simple_shaders.h b/src/gallium/auxiliary/util/u_simple_shaders.h
index 22b9cee..06da249 100644
--- a/src/gallium/auxiliary/util/u_simple_shaders.h
+++ b/src/gallium/auxiliary/util/u_simple_shaders.h
@@ -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 *
diff --git a/src/gallium/state_trackers/vega/renderer.c b/src/gallium/state_trackers/vega/renderer.c
index b823278..35795fc 100644
--- a/src/gallium/state_trackers/vega/renderer.c
+++ b/src/gallium/state_trackers/vega/renderer.c
@@ -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,
diff --git a/src/gallium/tests/trivial/tri.c b/src/gallium/tests/trivial/tri.c
index 9131bb5..f93c3f7 100644
--- a/src/gallium/tests/trivial/tri.c
+++ b/src/gallium/tests/trivial/tri.c
@@ -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)
diff --git a/src/mesa/state_tracker/st_atom_shader.c b/src/mesa/state_tracker/st_atom_shader.c
index c0239e9..e228997 100644
--- a/src/mesa/state_tracker/st_atom_shader.c
+++ b/src/mesa/state_tracker/st_atom_shader.c
@@ -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;
diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c
index 566f4a7..b8e2fad 100644
--- a/src/mesa/state_tracker/st_cb_clear.c
+++ b/src/mesa/state_tracker/st_cb_clear.c
@@ -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);
 }
-- 
1.7.10.4



More information about the mesa-dev mailing list