Re-implement GLSL texture sampler variables.

GLSL sampler variables indicate which texture unit to use for TEX instructions.
Previously, this was baked into the fragment/vertex program and couldn't be
readily changed once set.
Now, SamplerUnits[] array indicates which texture unit is to be used for
each sampler variable.  These values are set with glUniform1i().
This is extra state that must be passed to the fragment/vertex program
executor at runtime.
diff --git a/src/mesa/shader/prog_execute.c b/src/mesa/shader/prog_execute.c
index 28d195d..bd64b57 100644
--- a/src/mesa/shader/prog_execute.c
+++ b/src/mesa/shader/prog_execute.c
@@ -1316,22 +1316,22 @@
              * The rest of the time, just use zero (until we get a more
              * sophisticated way of computing lambda).
              */
+            const GLuint unit = machine->Samplers[inst->TexSrcUnit];
             GLfloat coord[4], color[4], lambda;
 #if 0
             if (inst->SrcReg[0].File == PROGRAM_INPUT &&
-                inst->SrcReg[0].Index == FRAG_ATTRIB_TEX0 + inst->TexSrcUnit)
-               lambda = span->array->lambda[inst->TexSrcUnit][column];
+                inst->SrcReg[0].Index == FRAG_ATTRIB_TEX0 + unit)
+               lambda = span->array->lambda[unit][column];
             else
 #endif
                lambda = 0.0;
             fetch_vector4(&inst->SrcReg[0], machine, coord);
-            machine->FetchTexelLod(ctx, coord, lambda, inst->TexSrcUnit,
-                                   color);
+            machine->FetchTexelLod(ctx, coord, lambda, unit, color);
             if (DEBUG_PROG) {
                printf("TEX (%g, %g, %g, %g) = texture[%d][%g, %g, %g, %g], "
                       "lod %f\n",
                       color[0], color[1], color[2], color[3],
-                      inst->TexSrcUnit,
+                      unit,
                       coord[0], coord[1], coord[2], coord[3], lambda);
             }
             store_vector4(inst, machine, color);
@@ -1375,11 +1375,12 @@
       case OPCODE_TXP:         /* GL_ARB_fragment_program only */
          /* Texture lookup w/ projective divide */
          {
+            const GLuint unit = machine->Samplers[inst->TexSrcUnit];
             GLfloat texcoord[4], color[4], lambda;
 #if 0
             if (inst->SrcReg[0].File == PROGRAM_INPUT &&
                 inst->SrcReg[0].Index == FRAG_ATTRIB_TEX0 + inst->TexSrcUnit)
-               lambda = span->array->lambda[inst->TexSrcUnit][column];
+               lambda = span->array->lambda[unit][column];
             else
 #endif
                lambda = 0.0;
@@ -1393,8 +1394,7 @@
                texcoord[1] /= texcoord[3];
                texcoord[2] /= texcoord[3];
             }
-            machine->FetchTexelLod(ctx, texcoord, lambda,
-                                   inst->TexSrcUnit, color);
+            machine->FetchTexelLod(ctx, texcoord, lambda, unit, color);
             store_vector4(inst, machine, color);
          }
          break;
diff --git a/src/mesa/shader/prog_execute.h b/src/mesa/shader/prog_execute.h
index be29ece..db7bcee 100644
--- a/src/mesa/shader/prog_execute.h
+++ b/src/mesa/shader/prog_execute.h
@@ -62,6 +62,8 @@
    GLuint CondCodes[4];  /**< COND_* value for x/y/z/w */
    GLint AddressReg[MAX_PROGRAM_ADDRESS_REGS][4];
 
+   GLuint *Samplers;  /** Array mapping sampler var to tex unit */
+
    GLuint CallStack[MAX_PROGRAM_CALL_DEPTH]; /**< For CAL/RET instructions */
    GLuint StackDepth; /**< Index/ptr to top of CallStack[] */
 
diff --git a/src/mesa/shader/prog_instruction.c b/src/mesa/shader/prog_instruction.c
index c84c76f..0661290 100644
--- a/src/mesa/shader/prog_instruction.c
+++ b/src/mesa/shader/prog_instruction.c
@@ -246,6 +246,17 @@
 }
 
 
+GLboolean
+_mesa_is_tex_instruction(gl_inst_opcode opcode)
+{
+   return (opcode == OPCODE_TEX ||
+           opcode == OPCODE_TXB ||
+           opcode == OPCODE_TXD ||
+           opcode == OPCODE_TXL ||
+           opcode == OPCODE_TXP);
+}
+
+
 /**
  * Return string name for given program opcode.
  */
diff --git a/src/mesa/shader/prog_instruction.h b/src/mesa/shader/prog_instruction.h
index 643969b..e8a2407 100644
--- a/src/mesa/shader/prog_instruction.h
+++ b/src/mesa/shader/prog_instruction.h
@@ -413,11 +413,13 @@
     */
    GLint BranchTarget;
 
+#if 0
    /**
     * For TEX instructions in shaders, the sampler to use for the
     * texture lookup.
     */
    GLint Sampler;
+#endif
 
    const char *Comment;
 };
@@ -443,6 +445,9 @@
 extern GLuint
 _mesa_num_inst_dst_regs(gl_inst_opcode opcode);
 
+extern GLboolean
+_mesa_is_tex_instruction(gl_inst_opcode opcode);
+
 extern const char *
 _mesa_opcode_string(gl_inst_opcode opcode);
 
diff --git a/src/mesa/shader/prog_parameter.c b/src/mesa/shader/prog_parameter.c
index 9e3d3fe..b4008ab 100644
--- a/src/mesa/shader/prog_parameter.c
+++ b/src/mesa/shader/prog_parameter.c
@@ -283,22 +283,25 @@
  * Add a sampler to the parameter list.
  * \param name  uniform's name
  * \param datatype  GL_SAMPLER_2D, GL_SAMPLER_2D_RECT_ARB, etc.
+ * \param index  the sampler number (as seen in TEX instructions)
  */
 GLint
 _mesa_add_sampler(struct gl_program_parameter_list *paramList,
-                  const char *name, GLenum datatype)
+                  const char *name, GLenum datatype, GLuint index)
 {
    GLint i = _mesa_lookup_parameter_index(paramList, -1, name);
    if (i >= 0 && paramList->Parameters[i].Type == PROGRAM_SAMPLER) {
       ASSERT(paramList->Parameters[i].Size == 1);
       ASSERT(paramList->Parameters[i].DataType == datatype);
+      ASSERT(paramList->ParameterValues[i][0] == index);
       /* already in list */
       return i;
    }
    else {
+      GLfloat indexf = index;
       const GLint size = 1; /* a sampler is basically a texture unit number */
       i = _mesa_add_parameter(paramList, PROGRAM_SAMPLER, name,
-                              size, datatype, NULL, NULL);
+                              size, datatype, &indexf, NULL);
       return i;
    }
 }
diff --git a/src/mesa/shader/prog_parameter.h b/src/mesa/shader/prog_parameter.h
index 09ff851..40c8c09 100644
--- a/src/mesa/shader/prog_parameter.h
+++ b/src/mesa/shader/prog_parameter.h
@@ -104,7 +104,7 @@
 
 extern GLint
 _mesa_add_sampler(struct gl_program_parameter_list *paramList,
-                  const char *name, GLenum datatype);
+                  const char *name, GLenum datatype, GLuint index);
 
 extern GLint
 _mesa_add_varying(struct gl_program_parameter_list *paramList,
diff --git a/src/mesa/shader/prog_print.c b/src/mesa/shader/prog_print.c
index e92837f..c421b12 100644
--- a/src/mesa/shader/prog_print.c
+++ b/src/mesa/shader/prog_print.c
@@ -719,6 +719,8 @@
 void
 _mesa_print_program_parameters(GLcontext *ctx, const struct gl_program *prog)
 {
+   GLuint i;
+
    _mesa_printf("InputsRead: 0x%x\n", prog->InputsRead);
    _mesa_printf("OutputsWritten: 0x%x\n", prog->OutputsWritten);
    _mesa_printf("NumInstructions=%d\n", prog->NumInstructions);
@@ -726,6 +728,11 @@
    _mesa_printf("NumParameters=%d\n", prog->NumParameters);
    _mesa_printf("NumAttributes=%d\n", prog->NumAttributes);
    _mesa_printf("NumAddressRegs=%d\n", prog->NumAddressRegs);
+   _mesa_printf("Samplers=[ ");
+   for (i = 0; i < MAX_SAMPLERS; i++) {
+      _mesa_printf("%d ", prog->SamplerUnits[i]);
+   }
+   _mesa_printf("]\n");
 	
    _mesa_load_state_parameters(ctx, prog->Parameters);
 			
diff --git a/src/mesa/shader/program.c b/src/mesa/shader/program.c
index 1f22739..cafc0dc 100644
--- a/src/mesa/shader/program.c
+++ b/src/mesa/shader/program.c
@@ -187,12 +187,17 @@
 {
    (void) ctx;
    if (prog) {
+      GLuint i;
       _mesa_bzero(prog, sizeof(*prog));
       prog->Id = id;
       prog->Target = target;
       prog->Resident = GL_TRUE;
       prog->RefCount = 1;
       prog->Format = GL_PROGRAM_FORMAT_ASCII_ARB;
+
+      /* default mapping from samplers to texture units */
+      for (i = 0; i < MAX_SAMPLERS; i++)
+         prog->SamplerUnits[i] = i;
    }
 
    return prog;
diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c
index 9f6c54d..bc5ecda 100644
--- a/src/mesa/shader/shader_api.c
+++ b/src/mesa/shader/shader_api.c
@@ -1045,6 +1045,28 @@
 }
 
 
+
+/**
+ * Update the vertex and fragment program's TexturesUsed arrays.
+ */
+static void
+update_textures_used(struct gl_program *prog)
+{
+   GLuint s;
+
+   memset(prog->TexturesUsed, 0, sizeof(prog->TexturesUsed));
+
+   for (s = 0; s < MAX_SAMPLERS; s++) {
+      if (prog->SamplersUsed & (1 << s)) {
+         GLuint u = prog->SamplerUnits[s];
+         GLuint t = prog->SamplerTargets[s];
+         assert(u < MAX_TEXTURE_IMAGE_UNITS);
+         prog->TexturesUsed[u] |= (1 << t);
+      }
+   }
+}
+
+
 /**
  * Called via ctx->Driver.Uniform().
  */
@@ -1067,26 +1089,6 @@
 
    FLUSH_VERTICES(ctx, _NEW_PROGRAM);
 
-   /*
-    * If we're setting a sampler, we must use glUniformi1()!
-    */
-   if (shProg->Uniforms->Parameters[location].Type == PROGRAM_SAMPLER) {
-      GLint unit;
-      if (type != GL_INT || count != 1) {
-         _mesa_error(ctx, GL_INVALID_OPERATION,
-                     "glUniform(only glUniform1i can be used "
-                     "to set sampler uniforms)");
-         return;
-      }
-      /* check that the sampler (tex unit index) is legal */
-      unit = ((GLint *) values)[0];
-      if (unit >= ctx->Const.MaxTextureImageUnits) {
-         _mesa_error(ctx, GL_INVALID_VALUE,
-                     "glUniform1(invalid sampler/tex unit index)");
-         return;
-      }
-   }
-
    if (count < 0) {
       _mesa_error(ctx, GL_INVALID_VALUE, "glUniform(count < 0)");
       return;
@@ -1119,32 +1121,61 @@
       return;
    }
 
-   for (k = 0; k < count; k++) {
-      GLfloat *uniformVal = shProg->Uniforms->ParameterValues[location + k];
-      if (type == GL_INT ||
-          type == GL_INT_VEC2 ||
-          type == GL_INT_VEC3 ||
-          type == GL_INT_VEC4) {
-         const GLint *iValues = ((const GLint *) values) + k * elems;
-         for (i = 0; i < elems; i++) {
-            uniformVal[i] = (GLfloat) iValues[i];
-         }
-      }
-      else {
-         const GLfloat *fValues = ((const GLfloat *) values) + k * elems;
-         for (i = 0; i < elems; i++) {
-            uniformVal[i] = fValues[i];
-         }
-      }
-   }
-
    if (shProg->Uniforms->Parameters[location].Type == PROGRAM_SAMPLER) {
-      if (shProg->VertexProgram)
-         _slang_resolve_samplers(shProg, &shProg->VertexProgram->Base);
-      if (shProg->FragmentProgram)
-         _slang_resolve_samplers(shProg, &shProg->FragmentProgram->Base);
+      /* This controls which texture unit which is used by a sampler */
+      GLuint texUnit, sampler;
+
+      /* data type for setting samplers must be int */
+      if (type != GL_INT || count != 1) {
+         _mesa_error(ctx, GL_INVALID_OPERATION,
+                     "glUniform(only glUniform1i can be used "
+                     "to set sampler uniforms)");
+         return;
+      }
+
+      sampler = (GLuint) shProg->Uniforms->ParameterValues[location][0];
+      texUnit = ((GLuint *) values)[0];
+
+      /* check that the sampler (tex unit index) is legal */
+      if (texUnit >= ctx->Const.MaxTextureImageUnits) {
+         _mesa_error(ctx, GL_INVALID_VALUE,
+                     "glUniform1(invalid sampler/tex unit index)");
+         return;
+      }
+
+      if (shProg->VertexProgram) {
+         shProg->VertexProgram->Base.SamplerUnits[sampler] = texUnit;
+         update_textures_used(&shProg->VertexProgram->Base);
+      }
+      if (shProg->FragmentProgram) {
+         shProg->FragmentProgram->Base.SamplerUnits[sampler] = texUnit;
+         update_textures_used(&shProg->FragmentProgram->Base);
+      }
+
+
       FLUSH_VERTICES(ctx, _NEW_TEXTURE);
    }
+   else {
+      /* ordinary uniform variable */
+      for (k = 0; k < count; k++) {
+         GLfloat *uniformVal = shProg->Uniforms->ParameterValues[location + k];
+         if (type == GL_INT ||
+             type == GL_INT_VEC2 ||
+             type == GL_INT_VEC3 ||
+             type == GL_INT_VEC4) {
+            const GLint *iValues = ((const GLint *) values) + k * elems;
+            for (i = 0; i < elems; i++) {
+               uniformVal[i] = (GLfloat) iValues[i];
+            }
+         }
+         else {
+            const GLfloat *fValues = ((const GLfloat *) values) + k * elems;
+            for (i = 0; i < elems; i++) {
+               uniformVal[i] = fValues[i];
+            }
+         }
+      }
+   }
 }
 
 
diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c
index fb1f9d5..767ba3f 100644
--- a/src/mesa/shader/slang/slang_codegen.c
+++ b/src/mesa/shader/slang/slang_codegen.c
@@ -2874,14 +2874,23 @@
    const GLint texIndex = sampler_to_texture_index(var->type.specifier.type);
 
    if (texIndex != -1) {
-      /* Texture sampler:
+      /* This is a texture sampler variable...
        * store->File = PROGRAM_SAMPLER
-       * store->Index = sampler uniform location
+       * store->Index = sampler number (0..7, typically)
        * store->Size = texture type index (1D, 2D, 3D, cube, etc)
        */
+#if 0
       GLint samplerUniform
          = _mesa_add_sampler(prog->Parameters, varName, datatype);
-      store = _slang_new_ir_storage(PROGRAM_SAMPLER, samplerUniform, texIndex);
+#elif 0
+      GLint samplerUniform
+         = _mesa_add_sampler(prog->Samplers, varName, datatype);
+      (void) _mesa_add_sampler(prog->Parameters, varName, datatype); /* dummy entry */
+#else
+      const GLint sampNum = A->numSamplers++;
+      _mesa_add_sampler(prog->Parameters, varName, datatype, sampNum);
+#endif
+      store = _slang_new_ir_storage(PROGRAM_SAMPLER, sampNum, texIndex);
       if (dbg) printf("SAMPLER ");
    }
    else if (var->type.qualifier == SLANG_QUAL_UNIFORM) {
diff --git a/src/mesa/shader/slang/slang_compile.c b/src/mesa/shader/slang/slang_compile.c
index 2be89a5..bfb9ca4 100644
--- a/src/mesa/shader/slang/slang_compile.c
+++ b/src/mesa/shader/slang/slang_compile.c
@@ -1618,6 +1618,7 @@
       A.program = O->program;
       A.vartable = O->vartable;
       A.curFuncEndLabel = NULL;
+      A.numSamplers = 0;
       if (!_slang_codegen_global_variable(&A, var, C->type))
          return 0;
    }
@@ -1640,6 +1641,7 @@
          A.space.funcs = O->funs;
          A.space.structs = O->structs;
          A.space.vars = O->vars;
+         A.numSamplers = 0;
          if (!initialize_global(&A, var))
             return 0;
       }
@@ -1773,6 +1775,7 @@
       A.program = O->program;
       A.vartable = O->vartable;
       A.log = C->L;
+      A.numSamplers = 0;
 
       _slang_codegen_function(&A, *parsed_func_ret);
    }
@@ -2152,6 +2155,9 @@
       shader->Programs[0]->Parameters = _mesa_new_parameter_list();
       shader->Programs[0]->Varying = _mesa_new_parameter_list();
       shader->Programs[0]->Attributes = _mesa_new_parameter_list();
+#if 0
+      shader->Programs[0]->Samplers = _mesa_new_parameter_list();
+#endif
    }
 
    slang_info_log_construct(&info_log);
diff --git a/src/mesa/shader/slang/slang_emit.c b/src/mesa/shader/slang/slang_emit.c
index fe13f28..2b08e70 100644
--- a/src/mesa/shader/slang/slang_emit.c
+++ b/src/mesa/shader/slang/slang_emit.c
@@ -906,11 +906,15 @@
    assert(n->Children[0]->Store->Size >= TEXTURE_1D_INDEX);
    assert(n->Children[0]->Store->Size <= TEXTURE_RECT_INDEX);
 
-   inst->Sampler = n->Children[0]->Store->Index; /* i.e. uniform's index */
    inst->TexSrcTarget = n->Children[0]->Store->Size;
+#if 0
    inst->TexSrcUnit = 27; /* Dummy value; the TexSrcUnit will be computed at
                            * link time, using the sampler uniform's value.
                            */
+   inst->Sampler = n->Children[0]->Store->Index; /* i.e. uniform's index */
+#else
+   inst->TexSrcUnit = n->Children[0]->Store->Index; /* i.e. uniform's index */
+#endif
    return inst;
 }
 
diff --git a/src/mesa/shader/slang/slang_link.c b/src/mesa/shader/slang/slang_link.c
index eaa29ba..32f7168 100644
--- a/src/mesa/shader/slang/slang_link.c
+++ b/src/mesa/shader/slang/slang_link.c
@@ -144,10 +144,14 @@
 }
 
 
+static GLuint shProg_NumSamplers = 0; /** XXX temporary */
+
+
 static GLboolean
 link_uniform_vars(struct gl_shader_program *shProg, struct gl_program *prog)
 {
    GLuint *map, i;
+   GLuint samplerMap[MAX_SAMPLERS];
 
 #if 0
    printf("================ pre link uniforms ===============\n");
@@ -168,10 +172,13 @@
       /* sanity check */
       assert(is_uniform(p->Type));
 
+      /* See if this uniform is already in the linked program's list */
       if (p->Name) {
+         /* this is a named uniform */
          j = _mesa_lookup_parameter_index(shProg->Uniforms, -1, p->Name);
       }
       else {
+         /* this is an unnamed constant */
          /*GLuint swizzle;*/
          ASSERT(p->Type == PROGRAM_CONSTANT);
          if (_mesa_lookup_parameter_constant(shProg->Uniforms, pVals,
@@ -184,7 +191,8 @@
       }
 
       if (j >= 0) {
-         /* already in list, check size XXX check this */
+         /* already in linked program's list */
+         /* check size XXX check this */
 #if 0
          assert(p->Size == shProg->Uniforms->Parameters[j].Size);
 #endif
@@ -205,7 +213,15 @@
             j = _mesa_add_uniform(shProg->Uniforms, p->Name, p->Size, p->DataType);
             break;
          case PROGRAM_SAMPLER:
-            j = _mesa_add_sampler(shProg->Uniforms, p->Name, p->DataType);
+            {
+               GLuint sampNum = shProg_NumSamplers++;
+               GLuint oldSampNum;
+               j = _mesa_add_sampler(shProg->Uniforms, p->Name,
+                                     p->DataType, sampNum);
+               oldSampNum = (GLuint) prog->Parameters->ParameterValues[i][0];
+               assert(oldSampNum < MAX_SAMPLERS);
+               samplerMap[oldSampNum] = sampNum;
+            }
             break;
          default:
             _mesa_problem(NULL, "bad parameter type in link_uniform_vars()");
@@ -243,6 +259,7 @@
    /* OK, now scan the program/shader instructions looking for uniform vars,
     * replacing the old index with the new index.
     */
+   prog->SamplersUsed = 0x0;
    for (i = 0; i < prog->NumInstructions; i++) {
       struct prog_instruction *inst = prog->Instructions + i;
       GLuint j;
@@ -257,14 +274,15 @@
          }
       }
 
-      if (inst->Opcode == OPCODE_TEX ||
-          inst->Opcode == OPCODE_TXB ||
-          inst->Opcode == OPCODE_TXP) {
+      if (_mesa_is_tex_instruction(inst->Opcode)) {
          /*
          printf("====== remap sampler from %d to %d\n",
                 inst->Sampler, map[ inst->Sampler ]);
          */
-         inst->Sampler = map[ inst->Sampler ];
+         /* here, texUnit is really samplerUnit */
+         inst->TexSrcUnit = samplerMap[inst->TexSrcUnit];
+         prog->SamplerTargets[inst->TexSrcUnit] = inst->TexSrcTarget;
+         prog->SamplersUsed |= (1 << inst->TexSrcUnit);
       }
    }
 
@@ -404,36 +422,6 @@
 
 
 
-/**
- * Scan program for texture instructions, lookup sampler/uniform's value
- * to determine which texture unit to use.
- * Also, update the program's TexturesUsed[] array.
- */
-void
-_slang_resolve_samplers(struct gl_shader_program *shProg,
-                        struct gl_program *prog)
-{
-   GLuint i;
-
-   for (i = 0; i < MAX_TEXTURE_IMAGE_UNITS; i++)
-      prog->TexturesUsed[i] = 0;
-
-   for (i = 0; i < prog->NumInstructions; i++) {
-      struct prog_instruction *inst = prog->Instructions + i;
-      if (inst->Opcode == OPCODE_TEX ||
-          inst->Opcode == OPCODE_TXB ||
-          inst->Opcode == OPCODE_TXP) {
-         GLint sampleUnit = (GLint) shProg->Uniforms->ParameterValues[inst->Sampler][0];
-         assert(sampleUnit < MAX_TEXTURE_IMAGE_UNITS);
-         inst->TexSrcUnit = sampleUnit;
-
-         prog->TexturesUsed[inst->TexSrcUnit] |= (1 << inst->TexSrcTarget);
-      }
-   }
-}
-
-
-
 /** cast wrapper */
 static struct gl_vertex_program *
 vertex_program(struct gl_program *prog)
@@ -490,6 +478,8 @@
    const struct gl_fragment_program *fragProg;
    GLuint i;
 
+   shProg_NumSamplers = 0; /** XXX temporary */
+
    _mesa_clear_shader_program_data(ctx, shProg);
 
    shProg->Uniforms = _mesa_new_parameter_list();
@@ -550,13 +540,6 @@
    }
 
    if (shProg->VertexProgram) {
-      _slang_resolve_samplers(shProg, &shProg->VertexProgram->Base);
-   }
-   if (shProg->FragmentProgram) {
-      _slang_resolve_samplers(shProg, &shProg->FragmentProgram->Base);
-   }
-
-   if (shProg->VertexProgram) {
       if (!_slang_resolve_attributes(shProg, &shProg->VertexProgram->Base)) {
          /*goto cleanup;*/
          _mesa_problem(ctx, "_slang_resolve_attributes() failed");
@@ -601,7 +584,7 @@
       _mesa_print_program(&fragProg->Base);
       _mesa_print_program_parameters(ctx, &fragProg->Base);
 #endif
-#if 0
+#if 01
       printf("************** linked fragment prog\n");
       _mesa_print_program(&shProg->FragmentProgram->Base);
       _mesa_print_program_parameters(ctx, &shProg->FragmentProgram->Base);
diff --git a/src/mesa/shader/slang/slang_link.h b/src/mesa/shader/slang/slang_link.h
index 606b9e4..8ef8a6b 100644
--- a/src/mesa/shader/slang/slang_link.h
+++ b/src/mesa/shader/slang/slang_link.h
@@ -33,10 +33,6 @@
             struct gl_shader_program *shProg);
 
 extern void
-_slang_resolve_samplers(struct gl_shader_program *shProg,
-                        struct gl_program *prog);
-
-extern void
 _slang_remap_attribute(struct gl_program *prog, GLuint oldAttrib,
                        GLuint newAttrib);
 
diff --git a/src/mesa/shader/slang/slang_typeinfo.h b/src/mesa/shader/slang/slang_typeinfo.h
index 587331e..ad5aa3e 100644
--- a/src/mesa/shader/slang/slang_typeinfo.h
+++ b/src/mesa/shader/slang/slang_typeinfo.h
@@ -65,6 +65,7 @@
    struct slang_label_ *curFuncEndLabel;
    struct slang_ir_node_ *CurLoop;
    struct slang_function_ *CurFunction;
+   GLuint numSamplers;
 } slang_assemble_ctx;