Mesa (lp-binning): llvmpipe: Reset the bin when shading a whole tile with an opaque shader.

Jose Fonseca jrfonseca at kemper.freedesktop.org
Wed Jan 13 21:52:01 UTC 2010


Module: Mesa
Branch: lp-binning
Commit: a1acbff299c444913418e65da473745cd901a2db
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a1acbff299c444913418e65da473745cd901a2db

Author: José Fonseca <jfonseca at vmware.com>
Date:   Wed Jan 13 21:51:47 2010 +0000

llvmpipe: Reset the bin when shading a whole tile with an opaque shader.

---

 src/gallium/drivers/llvmpipe/lp_rast.h      |    2 +
 src/gallium/drivers/llvmpipe/lp_scene.c     |   33 ++++++++++++++++----------
 src/gallium/drivers/llvmpipe/lp_scene.h     |    4 +++
 src/gallium/drivers/llvmpipe/lp_setup.c     |    4 ++-
 src/gallium/drivers/llvmpipe/lp_setup.h     |    3 +-
 src/gallium/drivers/llvmpipe/lp_setup_tri.c |    6 +++++
 src/gallium/drivers/llvmpipe/lp_state_fs.c  |   12 +++++++++-
 7 files changed, 48 insertions(+), 16 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_rast.h b/src/gallium/drivers/llvmpipe/lp_rast.h
index 46e22f6..d926adb 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast.h
+++ b/src/gallium/drivers/llvmpipe/lp_rast.h
@@ -68,6 +68,8 @@ struct lp_rast_state {
     * the tile color/z/stencil data somehow:
     */
    lp_jit_frag_func jit_function;
+
+   boolean opaque;
 };
 
 
diff --git a/src/gallium/drivers/llvmpipe/lp_scene.c b/src/gallium/drivers/llvmpipe/lp_scene.c
index 45d5446..967d666 100644
--- a/src/gallium/drivers/llvmpipe/lp_scene.c
+++ b/src/gallium/drivers/llvmpipe/lp_scene.c
@@ -88,6 +88,25 @@ lp_scene_is_empty(struct lp_scene *scene )
 }
 
 
+void
+lp_scene_bin_reset(struct lp_scene *scene, unsigned x, unsigned y)
+{
+   struct cmd_bin *bin = lp_scene_get_bin(scene, x, y);
+   struct cmd_block_list *list = &bin->commands;
+   struct cmd_block *block;
+   struct cmd_block *tmp;
+
+   for (block = list->head; block != list->tail; block = tmp) {
+      tmp = block->next;
+      FREE(block);
+   }
+
+   assert(list->tail->next == NULL);
+   list->head = list->tail;
+   list->head->count = 0;
+}
+
+
 /**
  * Set scene to empty state.
  */
@@ -100,19 +119,7 @@ lp_scene_reset(struct lp_scene *scene )
     */
    for (i = 0; i < scene->tiles_x; i++) {
       for (j = 0; j < scene->tiles_y; j++) {
-         struct cmd_bin *bin = lp_scene_get_bin(scene, i, j);
-         struct cmd_block_list *list = &bin->commands;
-         struct cmd_block *block;
-         struct cmd_block *tmp;
-         
-         for (block = list->head; block != list->tail; block = tmp) {
-            tmp = block->next;
-            FREE(block);
-         }
-         
-         assert(list->tail->next == NULL);
-         list->head = list->tail;
-         list->head->count = 0;
+         lp_scene_bin_reset(scene, i, j);
       }
    }
 
diff --git a/src/gallium/drivers/llvmpipe/lp_scene.h b/src/gallium/drivers/llvmpipe/lp_scene.h
index b59b687..4b6527d 100644
--- a/src/gallium/drivers/llvmpipe/lp_scene.h
+++ b/src/gallium/drivers/llvmpipe/lp_scene.h
@@ -215,6 +215,10 @@ lp_scene_get_bin(struct lp_scene *scene, unsigned x, unsigned y)
 }
 
 
+/** Remove all commands from a bin */
+void
+lp_scene_bin_reset(struct lp_scene *scene, unsigned x, unsigned y);
+
 
 /* Add a command to bin[x][y].
  */
diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c
index 38ea0c6..61b968c 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup.c
@@ -364,12 +364,14 @@ lp_setup_set_fs_inputs( struct setup_context *setup,
 
 void
 lp_setup_set_fs_function( struct setup_context *setup,
-                          lp_jit_frag_func jit_function )
+                          lp_jit_frag_func jit_function,
+                          boolean opaque )
 {
    LP_DBG(DEBUG_SETUP, "%s %p\n", __FUNCTION__, (void *) jit_function);
    /* FIXME: reference count */
 
    setup->fs.current.jit_function = jit_function;
+   setup->fs.current.opaque = opaque;
    setup->dirty |= LP_SETUP_NEW_FS;
 }
 
diff --git a/src/gallium/drivers/llvmpipe/lp_setup.h b/src/gallium/drivers/llvmpipe/lp_setup.h
index bf12cb8..bac7d73 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup.h
+++ b/src/gallium/drivers/llvmpipe/lp_setup.h
@@ -97,7 +97,8 @@ lp_setup_set_fs_inputs( struct setup_context *setup,
 
 void
 lp_setup_set_fs_function( struct setup_context *setup,
-                          lp_jit_frag_func jit_function );
+                          lp_jit_frag_func jit_function,
+                          boolean opaque );
 
 void
 lp_setup_set_fs_constants(struct setup_context *setup,
diff --git a/src/gallium/drivers/llvmpipe/lp_setup_tri.c b/src/gallium/drivers/llvmpipe/lp_setup_tri.c
index 575265b..0f5b25b 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup_tri.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup_tri.c
@@ -459,6 +459,12 @@ do_triangle_ccw(struct setup_context *setup,
 	    {
 	       in = 1;
                /* triangle covers the whole tile- shade whole tile */
+	       if(setup->fs.current.opaque) {
+	          lp_scene_bin_reset( scene, x, y );
+	          lp_scene_bin_command( scene, x, y,
+	                                lp_rast_set_state,
+	                                lp_rast_arg_state(setup->fs.stored) );
+	       }
                lp_scene_bin_command( scene, x, y,
 				     lp_rast_shade_tile,
 				     lp_rast_arg_inputs(&tri->inputs) );
diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c
index c6f5801..1ed9a2f 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_fs.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c
@@ -1005,6 +1005,7 @@ llvmpipe_update_fs(struct llvmpipe_context *lp)
    struct lp_fragment_shader *shader = lp->fs;
    struct lp_fragment_shader_variant_key key;
    struct lp_fragment_shader_variant *variant;
+   boolean opaque;
 
    make_variant_key(lp, shader, &key);
 
@@ -1021,6 +1022,15 @@ llvmpipe_update_fs(struct llvmpipe_context *lp)
 
    shader->current = variant;
 
+   /* TODO: put this in the variant */
+   opaque = !key.blend.logicop_enable &&
+            !key.blend.blend_enable &&
+            !key.alpha.enabled &&
+            !key.depth.enabled &&
+            !shader->info.uses_kill
+            ? TRUE : FALSE;
+
    lp_setup_set_fs_function(lp->setup, 
-                            shader->current->jit_function);
+                            shader->current->jit_function,
+                            opaque);
 }




More information about the mesa-commit mailing list