gallium: remove set_sampler_units interface
authorKeith Whitwell <keith@tungstengraphics.com>
Tue, 11 Dec 2007 14:39:37 +0000 (14:39 +0000)
committerKeith Whitwell <keith@tungstengraphics.com>
Tue, 11 Dec 2007 14:39:37 +0000 (14:39 +0000)
The effect of this mapping can be acheived by the state tracker and
setting up the pipe texture state pointers to incorporate its affects.

28 files changed:
src/mesa/pipe/cell/ppu/cell_context.c
src/mesa/pipe/cell/ppu/cell_context.h
src/mesa/pipe/cell/ppu/cell_state.h
src/mesa/pipe/cell/ppu/cell_state_sampler.c
src/mesa/pipe/failover/fo_context.h
src/mesa/pipe/failover/fo_state.c
src/mesa/pipe/failover/fo_state_emit.c
src/mesa/pipe/i915simple/i915_context.h
src/mesa/pipe/i915simple/i915_state.c
src/mesa/pipe/i965simple/brw_state.c
src/mesa/pipe/llvm/gallivm.cpp
src/mesa/pipe/llvm/gallivm.h
src/mesa/pipe/llvm/llvm_base_shader.cpp
src/mesa/pipe/llvm/llvm_entry.c
src/mesa/pipe/p_context.h
src/mesa/pipe/softpipe/sp_context.c
src/mesa/pipe/softpipe/sp_context.h
src/mesa/pipe/softpipe/sp_quad_fs.c
src/mesa/pipe/softpipe/sp_state.h
src/mesa/pipe/softpipe/sp_state_sampler.c
src/mesa/pipe/tgsi/exec/tgsi_exec.c
src/mesa/pipe/tgsi/exec/tgsi_exec.h
src/mesa/state_tracker/st_atom_sampler.c
src/mesa/state_tracker/st_atom_texture.c
src/mesa/state_tracker/st_cb_drawpixels.c
src/mesa/state_tracker/st_cb_texture.c
src/mesa/state_tracker/st_cb_texture.h
src/mesa/state_tracker/st_context.h

index 68543ecf3035e144ca52c2d5041a27023c75136f..5534d82ccfcf018fbe265d4892e3f32d72ce8178 100644 (file)
@@ -217,7 +217,6 @@ cell_create_context(struct pipe_winsys *winsys, struct cell_winsys *cws)
    cell->pipe.set_framebuffer_state = cell_set_framebuffer_state;
 
    cell->pipe.set_polygon_stipple = cell_set_polygon_stipple;
-   cell->pipe.set_sampler_units = cell_set_sampler_units;
    cell->pipe.set_scissor_state = cell_set_scissor_state;
    cell->pipe.set_texture_state = cell_set_texture_state;
    cell->pipe.set_viewport_state = cell_set_viewport_state;
index a64692081d3f9164ff302bff4ca81dee7ae8011a..12073b93a025891ac53e22f9594902c09aebb168 100644 (file)
@@ -58,7 +58,6 @@ struct cell_context
    struct pipe_viewport_state viewport;
    struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX];
    struct pipe_vertex_element vertex_element[PIPE_ATTRIB_MAX];
-   uint sampler_units[PIPE_MAX_SAMPLERS];
    uint dirty;
 
    /** The primitive drawing context */
index 033767d29b882ae7465259225c668832c01199eb..4bad45950ba863e52c737fbb74660d2f88a6b98a 100644 (file)
@@ -93,9 +93,6 @@ void cell_set_constant_buffer(struct pipe_context *pipe,
 void cell_set_polygon_stipple( struct pipe_context *,
                                const struct pipe_poly_stipple * );
 
-void cell_set_sampler_units( struct pipe_context *,
-                             uint numSamplers, const uint *units );
-
 void cell_set_scissor_state( struct pipe_context *,
                              const struct pipe_scissor_state * );
 
index c2a180ed3017ec808d3c2e37e8e02d95cf6901c2..495567b16c28a8a49cdf978e8c1f59e6fbf59d69 100644 (file)
@@ -69,32 +69,22 @@ cell_delete_sampler_state(struct pipe_context *pipe,
 
 
 void
-cell_set_texture_state(struct pipe_context *pipe,
-                           unsigned unit,
-                           struct pipe_texture *texture)
+cell_set_sampler_texture(struct pipe_context *pipe,
+                        unsigned sampler,
+                        struct pipe_texture *texture)
 {
    struct cell_context *cell = cell_context(pipe);
 
    assert(unit < PIPE_MAX_SAMPLERS);
 
 #if 0
-   cell->texture[unit] = cell_texture(texture);  /* ptr, not struct */
-   cell_tile_cache_set_texture(cell->tex_cache[unit], texture);
+   cell->texture[sampler] = cell_texture(texture);  /* ptr, not struct */
+   cell_tile_cache_set_texture(cell->tex_cache[sampler], texture);
 #endif
 
    cell->dirty |= CELL_NEW_TEXTURE;
 }
 
 
-void
-cell_set_sampler_units(struct pipe_context *pipe,
-                           uint num_samplers, const uint *units )
-{
-   struct cell_context *cell = cell_context(pipe);
-   uint i;
-   for (i = 0; i < num_samplers; i++)
-      cell->sampler_units[i] = units[i];
-   cell->dirty |= CELL_NEW_SAMPLER;
-}
 
 
index 2423eb4556596a1f0b68588723c2b856bd5f1f84..f5eaa0b5fa82ff8d9c5e0af315675cdbc5c213b9 100644 (file)
@@ -83,7 +83,6 @@ struct failover_context {
    struct pipe_framebuffer_state framebuffer;
    struct pipe_poly_stipple poly_stipple;
    struct pipe_scissor_state scissor;
-   uint sampler_units[PIPE_MAX_SAMPLERS];
    struct pipe_texture *texture[PIPE_MAX_SAMPLERS];
    struct pipe_viewport_state viewport;
    struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX];
index 689d2fa3c7937a29f01d1aa2f53b2f82417fe15f..6b4f1517ace60090ed8044492f01b074fa577743 100644 (file)
@@ -284,18 +284,6 @@ failover_set_polygon_stipple( struct pipe_context *pipe,
    failover->hw->set_polygon_stipple( failover->hw, stipple );
 }
 
-static void
-failover_set_sampler_units( struct pipe_context *pipe,
-                            uint num_samplers, const uint *units )
-{
-   struct failover_context *failover = failover_context(pipe);
-   uint i;
-
-   for (i = 0; i < num_samplers; i++)
-      failover->sampler_units[i] = units[i];
-   failover->dirty |= FO_NEW_SAMPLER;
-   failover->hw->set_sampler_units(failover->hw, num_samplers, units);
-}
 
 static void *
 failover_create_rasterizer_state(struct pipe_context *pipe,
@@ -390,16 +378,16 @@ failover_delete_sampler_state(struct pipe_context *pipe, void *sampler)
 
 
 static void
-failover_set_texture_state(struct pipe_context *pipe,
-                          unsigned unit,
-                           struct pipe_texture *texture)
+failover_set_sampler_texture(struct pipe_context *pipe,
+                            unsigned unit,
+                            struct pipe_texture *texture)
 {
    struct failover_context *failover = failover_context(pipe);
 
    failover->texture[unit] = texture;
    failover->dirty |= FO_NEW_TEXTURE;
    failover->dirty_texture |= (1<<unit);
-   failover->hw->set_texture_state( failover->hw, unit, texture );
+   failover->hw->set_sampler_texture( failover->hw, unit, texture );
 }
 
 
@@ -472,9 +460,8 @@ failover_init_state_functions( struct failover_context *failover )
    failover->pipe.set_clip_state = failover_set_clip_state;
    failover->pipe.set_framebuffer_state = failover_set_framebuffer_state;
    failover->pipe.set_polygon_stipple = failover_set_polygon_stipple;
-   failover->pipe.set_sampler_units = failover_set_sampler_units;
    failover->pipe.set_scissor_state = failover_set_scissor_state;
-   failover->pipe.set_texture_state = failover_set_texture_state;
+   failover->pipe.set_sampler_texture = failover_set_sampler_texture;
    failover->pipe.set_viewport_state = failover_set_viewport_state;
    failover->pipe.set_vertex_buffer = failover_set_vertex_buffer;
    failover->pipe.set_vertex_element = failover_set_vertex_element;
index 612b0a6ca37eb956328783110db348cf0f361763..c99ecd4f8df8ed5d0776465a67a724cc49844e49 100644 (file)
@@ -109,7 +109,7 @@ failover_state_emit( struct failover_context *failover )
    if (failover->dirty & FO_NEW_TEXTURE) {
       for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
         if (failover->dirty_texture & (1<<i)) {
-           failover->sw->set_texture_state( failover->sw, i, 
+           failover->sw->set_sampler_texture( failover->sw, i, 
                                             failover->texture[i] );
         }
       }
index a239c8f72e45e1e10b9affb4828787e2422283c9..80df7f0fba16212afce03eef02d934bd15744366 100644 (file)
@@ -199,7 +199,6 @@ struct i915_context
    struct pipe_framebuffer_state framebuffer;
    struct pipe_poly_stipple poly_stipple;
    struct pipe_scissor_state scissor;
-   uint sampler_units[PIPE_MAX_SAMPLERS];
    struct i915_texture *texture[PIPE_MAX_SAMPLERS];
    struct pipe_viewport_state viewport;
    struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX];
index a8c6565a54b1f99d6f8f464e723192b0eef7037d..2a9a587a37d7644bb547d244dd22afe9c222f7ee 100644 (file)
@@ -431,14 +431,6 @@ static void i915_set_polygon_stipple( struct pipe_context *pipe,
 {
 }
 
-static void i915_set_sampler_units(struct pipe_context *pipe,
-                                   uint numSamplers, const uint *units)
-{
-   struct i915_context *i915 = i915_context(pipe);
-   uint i;
-   for (i = 0; i < numSamplers; i++)
-      i915->sampler_units[i] = units[i];
-}
 
 static void * i915_create_fs_state(struct pipe_context *pipe,
                                    const struct pipe_shader_state *templ)
@@ -523,13 +515,13 @@ static void i915_set_constant_buffer(struct pipe_context *pipe,
 }
 
 
-static void i915_set_texture_state(struct pipe_context *pipe,
-                                  unsigned unit,
-                                  struct pipe_texture *texture)
+static void i915_set_sampler_texture(struct pipe_context *pipe,
+                                    unsigned sampler,
+                                    struct pipe_texture *texture)
 {
    struct i915_context *i915 = i915_context(pipe);
 
-   i915->texture[unit] = (struct i915_texture*)texture;  /* ptr, not struct */
+   i915->texture[sampler] = (struct i915_texture*)texture;  /* ptr, not struct */
 
    i915->dirty |= I915_NEW_TEXTURE;
 }
@@ -714,9 +706,8 @@ i915_init_state_functions( struct i915_context *i915 )
    i915->pipe.set_framebuffer_state = i915_set_framebuffer_state;
 
    i915->pipe.set_polygon_stipple = i915_set_polygon_stipple;
-   i915->pipe.set_sampler_units = i915_set_sampler_units;
    i915->pipe.set_scissor_state = i915_set_scissor_state;
-   i915->pipe.set_texture_state = i915_set_texture_state;
+   i915->pipe.set_sampler_texture = i915_set_sampler_texture;
    i915->pipe.set_viewport_state = i915_set_viewport_state;
    i915->pipe.set_vertex_buffer = i915_set_vertex_buffer;
    i915->pipe.set_vertex_element = i915_set_vertex_element;
index 7731c2e01fe164aaff4c4c4b33bc9440c986c3a0..ff4ae7999b13f5eb9d2279a39ca0c16d4185edd8 100644 (file)
@@ -110,11 +110,6 @@ static void brw_delete_sampler_state(struct pipe_context *pipe,
 }
 
 
-static void brw_set_sampler_units(struct pipe_context *pipe,
-                                 uint numSamplers, const uint *units)
-{
-}
-
 /************************************************************************
  * Depth stencil 
  */
@@ -349,7 +344,7 @@ static void brw_set_constant_buffer(struct pipe_context *pipe,
  */
 
 
-static void brw_set_texture_state(struct pipe_context *pipe,
+static void brw_set_sampler_texture(struct pipe_context *pipe,
                                   unsigned unit,
                                   struct pipe_texture *texture)
 {
@@ -448,9 +443,8 @@ brw_init_state_functions( struct brw_context *brw )
 //   brw->pipe.set_feedback_buffer = brw_set_feedback_buffer;
 
    brw->pipe.set_polygon_stipple = brw_set_polygon_stipple;
-   brw->pipe.set_sampler_units = brw_set_sampler_units;
    brw->pipe.set_scissor_state = brw_set_scissor_state;
-   brw->pipe.set_texture_state = brw_set_texture_state;
+   brw->pipe.set_sampler_texture = brw_set_sampler_texture;
    brw->pipe.set_viewport_state = brw_set_viewport_state;
    brw->pipe.set_vertex_buffer = brw_set_vertex_buffer;
    brw->pipe.set_vertex_element = brw_set_vertex_element;
index bd8bfac2085057e2f2818c45a0db3ddba088c2b8..a60440022aa8cf254859282fadbb326e3f85113b 100644 (file)
@@ -927,23 +927,21 @@ typedef int (*fragment_shader_runner)(float x, float y,
                                       float (*inputs)[16][4],
                                       int num_attribs,
                                       float (*consts)[4], int num_consts,
-                                      struct tgsi_sampler *samplers,
-                                      unsigned *sampler_units);
+                                      struct tgsi_sampler *samplers);
 
 int gallivm_fragment_shader_exec(struct gallivm_prog *prog,
                                  float fx, float fy,
                                  float (*dests)[16][4],
                                  float (*inputs)[16][4],
                                  float (*consts)[4],
-                                 struct tgsi_sampler *samplers,
-                                 unsigned *sampler_units)
+                                 struct tgsi_sampler *samplers)
 {
    fragment_shader_runner runner = reinterpret_cast<fragment_shader_runner>(prog->function);
    assert(runner);
 
    runner(fx, fy, dests, inputs, prog->num_interp,
           consts, prog->num_consts,
-          samplers, sampler_units);
+          samplers);
 
    return 0;
 }
index 6a05a55db4c15d442e74f35b78a37dfc96dd530a..fd9a11e5b6b8ac2dd221ff37994a9f23c8cfe15c 100644 (file)
@@ -67,8 +67,7 @@ int gallivm_fragment_shader_exec(struct gallivm_prog *prog,
                                  float (*dests)[PIPE_MAX_SHADER_INPUTS][4],
                                  float (*inputs)[PIPE_MAX_SHADER_INPUTS][4],
                                  float (*consts)[4],
-                                 struct tgsi_sampler *samplers,
-                                 unsigned *sampler_units);
+                                 struct tgsi_sampler *samplers);
 void gallivm_prog_inputs_interpolate(struct gallivm_prog *prog,
                                      float (*inputs)[PIPE_MAX_SHADER_INPUTS][4],
                                      const struct tgsi_interp_coef *coefs);
index f141ea2da0c8b5e2a04c6b515100edd569273bb3..a703ba3862533fda30ed72fa1dfbceeae0ca1aab 100644 (file)
@@ -770,8 +770,6 @@ Module* createBaseShader() {
     int32_num_consts_125->setName("num_consts");
     Value* ptr_samplers = args++;
     ptr_samplers->setName("samplers");
-    Value* ptr_sampler_units = args++;
-    ptr_sampler_units->setName("sampler_units");
     
     BasicBlock* label_entry_126 = new BasicBlock("entry",func_run_fragment_shader,0);
     BasicBlock* label_forbody6_i_127 = new BasicBlock("forbody6.i",func_run_fragment_shader,0);
index fe32e7810dc7c6745e1359ab3cbee7ffb63e2d6f..cbe4965ef6347525e536b6ec5beec097075c2e37 100644 (file)
@@ -219,8 +219,7 @@ int run_fragment_shader(float x, float y,
                         int num_inputs,
                         float (*aconsts)[4],
                         int num_consts,
-                        struct tgsi_sampler *samplers,
-                        unsigned *sampler_units)
+                        struct tgsi_sampler *samplers)
 {
    float4  inputs[4][16];
    float4  consts[32];
index 6b97844445012b9503b39ad0aa9223e6c5c0a233..83b4ab07fbfa82d2c98d26228429ee2a3fb26ee2 100644 (file)
@@ -142,15 +142,15 @@ struct pipe_context {
    void (*set_polygon_stipple)( struct pipe_context *,
                                const struct pipe_poly_stipple * );
 
-   void (*set_sampler_units)( struct pipe_context *,
-                              uint num_samplers, const uint *units );
-
    void (*set_scissor_state)( struct pipe_context *,
                               const struct pipe_scissor_state * );
 
-   void (*set_texture_state)( struct pipe_context *,
-                              unsigned unit,
-                              struct pipe_texture * );
+
+   /* Currently a sampler is constrained to sample from a single texture:
+    */
+   void (*set_sampler_texture)( struct pipe_context *,
+                               unsigned sampler,
+                               struct pipe_texture * );
 
    void (*set_viewport_state)( struct pipe_context *,
                                const struct pipe_viewport_state * );
index 43f23dc1e859c3cfe7937a398d6d828902a7a049..7d243aaabb59b58dc437cdcdfb99ff4b64f52ca4 100644 (file)
@@ -307,9 +307,8 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys,
    softpipe->pipe.set_constant_buffer = softpipe_set_constant_buffer;
    softpipe->pipe.set_framebuffer_state = softpipe_set_framebuffer_state;
    softpipe->pipe.set_polygon_stipple = softpipe_set_polygon_stipple;
-   softpipe->pipe.set_sampler_units = softpipe_set_sampler_units;
    softpipe->pipe.set_scissor_state = softpipe_set_scissor_state;
-   softpipe->pipe.set_texture_state = softpipe_set_texture_state;
+   softpipe->pipe.set_sampler_texture = softpipe_set_sampler_texture;
    softpipe->pipe.set_viewport_state = softpipe_set_viewport_state;
 
    softpipe->pipe.set_vertex_buffer = softpipe_set_vertex_buffer;
index 45d15c720e0c4de767c758b228a5bae1ac4a7f1f..afdd0ec88efbd116023dd3b4ce0975cdda3fe9d2 100644 (file)
@@ -91,7 +91,6 @@ struct softpipe_context {
    struct pipe_viewport_state viewport;
    struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX];
    struct pipe_vertex_element vertex_element[PIPE_ATTRIB_MAX];
-   uint sampler_units[PIPE_MAX_SAMPLERS];
    unsigned dirty;
 
    /*
index 75576a9bde817d67e6c80865c31e586c819dd780..9307ed233d062e356ec6c22e76eabe58a8b4ee6f 100644 (file)
@@ -98,7 +98,6 @@ shade_quad(
    /* Consts does not require 16 byte alignment. */
    machine->Consts = softpipe->mapped_constants[PIPE_SHADER_FRAGMENT];
 
-   machine->SamplerUnits = softpipe->sampler_units;
    machine->InterpCoefs = quad->coef;
 
    machine->Inputs[0].xyzw[0].f[0] = fx;
@@ -206,7 +205,7 @@ shade_quad_llvm(struct quad_stage *qs,
    /*quad->mask &=*/
       gallivm_fragment_shader_exec(llvm, fx, fy, dests, inputs,
                                    softpipe->mapped_constants[PIPE_SHADER_FRAGMENT],
-                                   qss->samplers, softpipe->sampler_units);
+                                   qss->samplers);
 #if DLLVM
    printf("OUT LLVM = 1[%f %f %f %f], 2[%f %f %f %f]\n",
           dests[0][0][0], dests[0][0][1], dests[0][0][2], dests[0][0][3], 
index 80a1cba25ad8a546cfe02de13c8d64c5ef19577b..a3bd078a718dd3ca0963dc81177e8096e4a5e2d6 100644 (file)
@@ -111,13 +111,10 @@ void softpipe_delete_vs_state(struct pipe_context *, void *);
 void softpipe_set_polygon_stipple( struct pipe_context *,
                                  const struct pipe_poly_stipple * );
 
-void softpipe_set_sampler_units( struct pipe_context *,
-                                 uint numSamplers, const uint *units );
-
 void softpipe_set_scissor_state( struct pipe_context *,
                                  const struct pipe_scissor_state * );
 
-void softpipe_set_texture_state( struct pipe_context *,
+void softpipe_set_sampler_texture( struct pipe_context *,
                                  unsigned unit,
                                  struct pipe_texture * );
 
index 173901f04e631f9d896faed5c562df170b08d283..3842e71503b64f7beb493c6f930c8dfe74532cfd 100644 (file)
@@ -67,9 +67,9 @@ softpipe_delete_sampler_state(struct pipe_context *pipe,
 
 
 void
-softpipe_set_texture_state(struct pipe_context *pipe,
-                           unsigned unit,
-                           struct pipe_texture *texture)
+softpipe_set_sampler_texture(struct pipe_context *pipe,
+                            unsigned unit,
+                            struct pipe_texture *texture)
 {
    struct softpipe_context *softpipe = softpipe_context(pipe);
 
@@ -82,15 +82,4 @@ softpipe_set_texture_state(struct pipe_context *pipe,
 }
 
 
-void
-softpipe_set_sampler_units(struct pipe_context *pipe,
-                           uint num_samplers, const uint *units )
-{
-   struct softpipe_context *softpipe = softpipe_context(pipe);
-   uint i;
-   for (i = 0; i < num_samplers; i++)
-      softpipe->sampler_units[i] = units[i];
-   softpipe->dirty |= SP_NEW_SAMPLER;
-}
-
 
index ab83f27c1bc067470e8cbdd28ecd099805d2b093..8636271a346e16db90405298636b54a8d7b3f638 100644 (file)
@@ -1217,8 +1217,7 @@ exec_tex(struct tgsi_exec_machine *mach,
          const struct tgsi_full_instruction *inst,
          boolean biasLod)
 {
-   const uint sampler = inst->FullSrcRegisters[1].SrcRegister.Index;
-   const uint unit = mach->SamplerUnits[sampler];
+   const uint unit = inst->FullSrcRegisters[1].SrcRegister.Index;
    union tgsi_exec_channel r[8];
    uint chan_index;
    float lodBias;
index 2c62b30f150fb5760e4316dc24a10ae2153c1c9b..e7952a08e3a7cc1136da295927d4ab8e3e812881 100644 (file)
@@ -162,7 +162,6 @@ struct tgsi_exec_machine
    struct tgsi_exec_vector       *Temps;
    struct tgsi_exec_vector       *Addrs;
 
-   uint                          *SamplerUnits;
    struct tgsi_sampler           *Samplers;
 
    float                         Imms[TGSI_EXEC_NUM_IMMEDIATES][4];
index 67a9159069167868c57c8fc32d514b37ecce4d07..052b6dd144a665b04ac02297521d8df66425ce51 100644 (file)
@@ -172,26 +172,13 @@ update_samplers(struct st_context *st)
          st->pipe->bind_sampler_state(st->pipe, u, cso->data);
       }
    }
-
-
-   /* mapping from sampler vars to texture units */
-   {
-      struct gl_fragment_program *fprog = st->ctx->FragmentProgram._Current;
-      uint sample_units[PIPE_MAX_SAMPLERS];
-      uint s;
-      for (s = 0; s < PIPE_MAX_SAMPLERS; s++) {
-         sample_units[s] = fprog->Base.SamplerUnits[s];
-      }
-
-      st->pipe->set_sampler_units(st->pipe, PIPE_MAX_SAMPLERS, sample_units);
-   }
 }
 
 
 const struct st_tracked_state st_update_sampler = {
    .name = "st_update_sampler",
    .dirty = {
-      .mesa = _NEW_TEXTURE | _NEW_PROGRAM,
+      .mesa = _NEW_TEXTURE,
       .st  = 0,
    },
    .update = update_samplers
index c4e5af02d597678957ac7413579f5d4d79e11f44..fb21d29c409bd69130e84bd5b837fc7c9fd8effe 100644 (file)
 static void 
 update_textures(struct st_context *st)
 {
-   GLuint u;
+   GLuint s;
 
-   for (u = 0; u < st->ctx->Const.MaxTextureImageUnits; u++) {
+   /* ST_NEW_FRAGMENT_PROGRAM
+    */
+   struct gl_fragment_program *fprog = st->ctx->FragmentProgram._Current;
+
+   for (s = 0; s < st->ctx->Const.MaxTextureCoordUnits; s++) {
+      GLuint su = fprog->Base.SamplerUnits[s];
+      
       struct gl_texture_object *texObj
-         = st->ctx->Texture.Unit[u]._Current;
+         = st->ctx->Texture.Unit[su]._Current;
+
       struct pipe_texture *pt;
+
       if (texObj) {
          GLboolean flush, retval;
 
-         retval = st_finalize_texture(st->ctx, st->pipe, u, &flush);
-#if 0
-         printf("finalize_texture returned %d, flush = %d\n",
-                retval, flush);
-#endif
+         retval = st_finalize_texture(st->ctx, st->pipe, texObj, &flush);
 
          pt = st_get_texobj_texture(texObj);
       }
@@ -67,8 +71,14 @@ update_textures(struct st_context *st)
          pt = NULL;
       }
 
-      st->state.texture[u] = pt;
-      st->pipe->set_texture_state(st->pipe, u, pt);
+      /* XXX: need to ensure that textures are unbound/removed from
+       * this table before being deleted, otherwise the pointer
+       * comparison below could fail.
+       */
+      if (st->state.sampler_texture[s] != pt) {
+        st->state.sampler_texture[s] = pt;
+        st->pipe->set_sampler_texture(st->pipe, s, pt);
+      }
    }
 }
 
@@ -77,7 +87,7 @@ const struct st_tracked_state st_update_texture = {
    .name = "st_update_texture",
    .dirty = {
       .mesa = _NEW_TEXTURE,
-      .st  = 0,
+      .st  = ST_NEW_FRAGMENT_PROGRAM,
    },
    .update = update_textures
 };
index 01790003532e5a68f5f1ff568248df6f71cf5d0b..5d4c443c01a5a3012fce1f434223c71f6b0bf989 100644 (file)
@@ -697,7 +697,7 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
 
    /* texture state: */
    {
-      pipe->set_texture_state(pipe, unit, pt);
+      pipe->set_sampler_texture(pipe, unit, pt);
    }
 
    /* Compute window coords (y=0=bottom) with pixel zoom.
@@ -719,7 +719,7 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
    pipe->bind_rasterizer_state(pipe, ctx->st->state.rasterizer->data);
    pipe->bind_fs_state(pipe, ctx->st->state.fs->data);
    pipe->bind_vs_state(pipe, ctx->st->state.vs->data);
-   pipe->set_texture_state(pipe, unit, ctx->st->state.texture[unit]);
+   pipe->set_sampler_texture(pipe, unit, ctx->st->state.sampler_texture[unit]);
    pipe->bind_sampler_state(pipe, unit, ctx->st->state.sampler[unit]->data);
    pipe->set_viewport_state(pipe, &ctx->st->state.viewport);
 }
index 2c93a2f3dd9f5cad4ef0f74d980397633884a608..39dd21dc590e74dca42ecd96c05d8489703d6c07 100644 (file)
@@ -1412,10 +1412,10 @@ copy_image_data_to_texture(struct st_context *st,
  */
 GLboolean
 st_finalize_texture(GLcontext *ctx,
-                   struct pipe_context *pipe, GLuint unit,
+                   struct pipe_context *pipe,
+                   struct gl_texture_object *tObj,
                    GLboolean *needFlush)
 {
-   struct gl_texture_object *tObj = ctx->Texture.Unit[unit]._Current;
    struct st_texture_object *stObj = st_texture_object(tObj);
    int comp_byte = 0;
    int cpp;
index 7f8082b029de2b3f8ac84d980c5113d474e12923..878256ec26c8b0f2cae9520c4d6dcd825038f100 100644 (file)
@@ -8,7 +8,8 @@ st_get_texobj_texture(struct gl_texture_object *texObj);
 
 extern GLboolean
 st_finalize_texture(GLcontext *ctx,
-                   struct pipe_context *pipe, GLuint unit,
+                   struct pipe_context *pipe, 
+                   struct gl_texture_object *tObj,
                    GLboolean *needFlush);
 
 
index 4855961d0997b12338a1a4ea7df8284cd41ce215..87646b3c71341f80d51c176ec977f567e8b072d3 100644 (file)
@@ -106,7 +106,7 @@ struct st_context
       struct pipe_clip_state clip;
       struct pipe_constant_buffer constants[2];
       struct pipe_framebuffer_state framebuffer;
-      struct pipe_texture *texture[PIPE_MAX_SAMPLERS];
+      struct pipe_texture *sampler_texture[PIPE_MAX_SAMPLERS];
       struct pipe_poly_stipple poly_stipple;
       struct pipe_scissor_state scissor;
       struct pipe_viewport_state viewport;