[Mesa-dev] [PATCH 02/16] draw: move tgsi-related state into a tgsi sub-struct

Brian Paul brianp at vmware.com
Thu Aug 9 20:11:01 PDT 2012


To better organize things a bit.
---
 src/gallium/auxiliary/draw/draw_context.c |   10 +++++-----
 src/gallium/auxiliary/draw/draw_gs.c      |   22 +++++++++++-----------
 src/gallium/auxiliary/draw/draw_private.h |   21 +++++++++++++--------
 src/gallium/auxiliary/draw/draw_vs.c      |    6 +++---
 src/gallium/auxiliary/draw/draw_vs_exec.c |    6 +++---
 5 files changed, 35 insertions(+), 30 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c
index dd4698b..3c9c7f1 100644
--- a/src/gallium/auxiliary/draw/draw_context.c
+++ b/src/gallium/auxiliary/draw/draw_context.c
@@ -576,7 +576,7 @@ draw_num_shader_outputs(const struct draw_context *draw)
 
 /**
  * Provide TGSI sampler objects for vertex/geometry shaders that use
- * texture fetches.
+ * texture fetches.  This state only needs to be set once per context.
  * This might only be used by software drivers for the time being.
  */
 void
@@ -586,12 +586,12 @@ draw_texture_samplers(struct draw_context *draw,
                       struct tgsi_sampler **samplers)
 {
    if (shader == PIPE_SHADER_VERTEX) {
-      draw->vs.num_samplers = num_samplers;
-      draw->vs.samplers = samplers;
+      draw->vs.tgsi.num_samplers = num_samplers;
+      draw->vs.tgsi.samplers = samplers;
    } else {
       debug_assert(shader == PIPE_SHADER_GEOMETRY);
-      draw->gs.num_samplers = num_samplers;
-      draw->gs.samplers = samplers;
+      draw->gs.tgsi.num_samplers = num_samplers;
+      draw->gs.tgsi.samplers = samplers;
    }
 }
 
diff --git a/src/gallium/auxiliary/draw/draw_gs.c b/src/gallium/auxiliary/draw/draw_gs.c
index 50a03ac..b2b4087 100644
--- a/src/gallium/auxiliary/draw/draw_gs.c
+++ b/src/gallium/auxiliary/draw/draw_gs.c
@@ -45,15 +45,15 @@
 boolean
 draw_gs_init( struct draw_context *draw )
 {
-   draw->gs.machine = tgsi_exec_machine_create();
-   if (!draw->gs.machine)
+   draw->gs.tgsi.machine = tgsi_exec_machine_create();
+   if (!draw->gs.tgsi.machine)
       return FALSE;
 
-   draw->gs.machine->Primitives = align_malloc(
+   draw->gs.tgsi.machine->Primitives = align_malloc(
       MAX_PRIMITIVES * sizeof(struct tgsi_exec_vector), 16);
-   if (!draw->gs.machine->Primitives)
+   if (!draw->gs.tgsi.machine->Primitives)
       return FALSE;
-   memset(draw->gs.machine->Primitives, 0,
+   memset(draw->gs.tgsi.machine->Primitives, 0,
           MAX_PRIMITIVES * sizeof(struct tgsi_exec_vector));
 
    return TRUE;
@@ -61,12 +61,12 @@ draw_gs_init( struct draw_context *draw )
 
 void draw_gs_destroy( struct draw_context *draw )
 {
-   if (!draw->gs.machine)
+   if (!draw->gs.tgsi.machine)
       return;
 
-   align_free(draw->gs.machine->Primitives);
+   align_free(draw->gs.tgsi.machine->Primitives);
 
-   tgsi_exec_machine_destroy(draw->gs.machine);
+   tgsi_exec_machine_destroy(draw->gs.tgsi.machine);
 }
 
 void
@@ -121,7 +121,7 @@ draw_create_geometry_shader(struct draw_context *draw,
          gs->max_output_vertices = gs->info.properties[i].data[0];
    }
 
-   gs->machine = draw->gs.machine;
+   gs->machine = draw->gs.tgsi.machine;
 
    if (gs)
    {
@@ -483,7 +483,7 @@ void draw_geometry_shader_prepare(struct draw_geometry_shader *shader,
    if (shader && shader->machine->Tokens != shader->state.tokens) {
       tgsi_exec_machine_bind_shader(shader->machine,
                                     shader->state.tokens,
-                                    draw->gs.num_samplers,
-                                    draw->gs.samplers);
+                                    draw->gs.tgsi.num_samplers,
+                                    draw->gs.tgsi.samplers);
    }
 }
diff --git a/src/gallium/auxiliary/draw/draw_private.h b/src/gallium/auxiliary/draw/draw_private.h
index 9cede21..6a085be 100644
--- a/src/gallium/auxiliary/draw/draw_private.h
+++ b/src/gallium/auxiliary/draw/draw_private.h
@@ -240,12 +240,14 @@ struct draw_context
       uint edgeflag_output;
       uint clipvertex_output;
       uint clipdistance_output[2];
-      /** TGSI program interpreter runtime state */
-      struct tgsi_exec_machine *machine;
 
-      uint num_samplers;
-      struct tgsi_sampler **samplers;
+      /** Fields for TGSI interpreter / execution */
+      struct {
+         struct tgsi_exec_machine *machine;
 
+         struct tgsi_sampler **samplers;
+         uint num_samplers;
+      } tgsi;
 
       const void *aligned_constants[PIPE_MAX_CONSTANT_BUFFERS];
 
@@ -265,11 +267,14 @@ struct draw_context
       uint num_gs_outputs;  /**< convenience, from geometry_shader */
       uint position_output;
 
-      /** TGSI program interpreter runtime state */
-      struct tgsi_exec_machine *machine;
+      /** Fields for TGSI interpreter / execution */
+      struct {
+         struct tgsi_exec_machine *machine;
+
+         struct tgsi_sampler **samplers;
+         uint num_samplers;
+      } tgsi;
 
-      uint num_samplers;
-      struct tgsi_sampler **samplers;
    } gs;
 
    /** Fragment shader state */
diff --git a/src/gallium/auxiliary/draw/draw_vs.c b/src/gallium/auxiliary/draw/draw_vs.c
index 56c4f88..0aea2f2 100644
--- a/src/gallium/auxiliary/draw/draw_vs.c
+++ b/src/gallium/auxiliary/draw/draw_vs.c
@@ -193,8 +193,8 @@ draw_vs_init( struct draw_context *draw )
 {
    draw->dump_vs = debug_get_option_gallium_dump_vs();
 
-   draw->vs.machine = tgsi_exec_machine_create();
-   if (!draw->vs.machine)
+   draw->vs.tgsi.machine = tgsi_exec_machine_create();
+   if (!draw->vs.tgsi.machine)
       return FALSE;
 
    draw->vs.emit_cache = translate_cache_create();
@@ -225,7 +225,7 @@ draw_vs_destroy( struct draw_context *draw )
       }
    }
 
-   tgsi_exec_machine_destroy(draw->vs.machine);
+   tgsi_exec_machine_destroy(draw->vs.tgsi.machine);
 }
 
 
diff --git a/src/gallium/auxiliary/draw/draw_vs_exec.c b/src/gallium/auxiliary/draw/draw_vs_exec.c
index 84ce8c1..828a155 100644
--- a/src/gallium/auxiliary/draw/draw_vs_exec.c
+++ b/src/gallium/auxiliary/draw/draw_vs_exec.c
@@ -69,8 +69,8 @@ vs_exec_prepare( struct draw_vertex_shader *shader,
    if (evs->machine->Tokens != shader->state.tokens) {
       tgsi_exec_machine_bind_shader(evs->machine,
                                     shader->state.tokens,
-                                    draw->vs.num_samplers,
-                                    draw->vs.samplers);
+                                    draw->vs.tgsi.num_samplers,
+                                    draw->vs.tgsi.samplers);
    }
 }
 
@@ -235,7 +235,7 @@ draw_create_vs_exec(struct draw_context *draw,
    vs->base.run_linear = vs_exec_run_linear;
    vs->base.delete = vs_exec_delete;
    vs->base.create_variant = draw_vs_create_variant_generic;
-   vs->machine = draw->vs.machine;
+   vs->machine = draw->vs.tgsi.machine;
 
    return &vs->base;
 }
-- 
1.7.3.4



More information about the mesa-dev mailing list