Mesa (gallium-0.1): ureg: make sampler decl take an explicit index

Keith Whitwell keithw at kemper.freedesktop.org
Fri Aug 28 14:01:22 UTC 2009


Module: Mesa
Branch: gallium-0.1
Commit: b86f64cbb9c9aa4531b633c0ebb068f0e5c048eb
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=b86f64cbb9c9aa4531b633c0ebb068f0e5c048eb

Author: Keith Whitwell <keithw at vmware.com>
Date:   Thu Aug 27 15:36:21 2009 +0100

ureg: make sampler decl take an explicit index

---

 src/gallium/auxiliary/tgsi/tgsi_ureg.c |   27 ++++++++++++++++++++++-----
 src/gallium/auxiliary/tgsi/tgsi_ureg.h |    8 +++++++-
 2 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
index e7e592c..cd10c50 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
@@ -99,11 +99,13 @@ struct ureg_program
    } immediate[UREG_MAX_IMMEDIATE];
    unsigned nr_immediates;
 
+   struct ureg_src sampler[PIPE_MAX_SAMPLERS];
+   unsigned nr_samplers;
+
    unsigned temps_active[UREG_MAX_TEMP / 32];
    unsigned nr_temps;
 
    unsigned nr_constants;
-   unsigned nr_samplers;
    unsigned nr_instructions;
 
    struct ureg_tokens domain[2];
@@ -350,9 +352,23 @@ void ureg_release_temporary( struct ureg_program *ureg,
 
 /* Allocate a new sampler.
  */
-struct ureg_src ureg_DECL_sampler( struct ureg_program *ureg )
+struct ureg_src ureg_DECL_sampler( struct ureg_program *ureg,
+                                   unsigned nr )
 {
-   return ureg_src_register( TGSI_FILE_SAMPLER, ureg->nr_samplers++ );
+   unsigned i;
+
+   for (i = 0; i < ureg->nr_samplers; i++)
+      if (ureg->sampler[i].Index == nr)
+         return ureg->sampler[i];
+   
+   if (i < PIPE_MAX_SAMPLERS) {
+      ureg->sampler[i] = ureg_src_register( TGSI_FILE_SAMPLER, nr );
+      ureg->nr_samplers++;
+      return ureg->sampler[i];
+   }
+
+   assert( 0 );
+   return ureg->sampler[0];
 }
 
 
@@ -715,10 +731,11 @@ static void emit_decls( struct ureg_program *ureg )
                  TGSI_INTERPOLATE_CONSTANT );
    }
 
-   if (ureg->nr_samplers) {
+   for (i = 0; i < ureg->nr_samplers; i++) {
       emit_decl_range( ureg, 
                        TGSI_FILE_SAMPLER,
-                       0, ureg->nr_samplers );
+                       ureg->sampler[i].Index, 
+                       ureg->sampler[i].Index );
    }
 
    if (ureg->nr_constants) {
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.h b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
index 2cebbeb..07ee47a 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
@@ -136,8 +136,14 @@ void
 ureg_release_temporary( struct ureg_program *ureg,
                         struct ureg_dst tmp );
 
+/* Supply an index to the sampler declaration as this is the hook to
+ * the external pipe_sampler state.  Users of this function probably
+ * don't want just any sampler, but a specific one which they've set
+ * up state for in the context.
+ */
 struct ureg_src
-ureg_DECL_sampler( struct ureg_program * );
+ureg_DECL_sampler( struct ureg_program *,
+                   unsigned index );
 
 
 static INLINE struct ureg_src




More information about the mesa-commit mailing list