mesa: fix MSVC signed/unsigned warnings in transformfeedback.c
[mesa.git] / src / mesa / main / ff_fragment_shader.cpp
index 0233f38025716c3de7ffd3605851d5c84b6b2234..3a80ab7f3b737d5b663634fc8197ad2ed263b565 100644 (file)
@@ -33,6 +33,7 @@ extern "C" {
 #include "mtypes.h"
 #include "main/uniforms.h"
 #include "main/macros.h"
+#include "main/samplerobj.h"
 #include "program/program.h"
 #include "program/prog_parameter.h"
 #include "program/prog_cache.h"
@@ -428,11 +429,13 @@ static GLuint make_state_key( struct gl_context *ctx,  struct state_key *key )
       const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i];
       const struct gl_texture_object *texObj = texUnit->_Current;
       const struct gl_tex_env_combine_state *comb = texUnit->_CurrentCombine;
+      const struct gl_sampler_object *samp;
       GLenum format;
 
       if (!texUnit->_ReallyEnabled || !texUnit->Enabled)
          continue;
 
+      samp = _mesa_get_samplerobj(ctx, i);
       format = texObj->Image[0][texObj->BaseLevel]->_BaseFormat;
 
       key->unit[i].enabled = 1;
@@ -444,7 +447,7 @@ static GLuint make_state_key( struct gl_context *ctx,  struct state_key *key )
          translate_tex_src_bit(texUnit->_ReallyEnabled);
 
       key->unit[i].shadow =
-         ((texObj->Sampler.CompareMode == GL_COMPARE_R_TO_TEXTURE) &&
+         ((samp->CompareMode == GL_COMPARE_R_TO_TEXTURE) &&
           ((format == GL_DEPTH_COMPONENT) || 
            (format == GL_DEPTH_STENCIL_EXT)));
 
@@ -536,7 +539,7 @@ public:
 };
 
 static ir_rvalue *
-get_current_attrib(struct texenv_fragment_program *p, GLuint attrib)
+get_current_attrib(texenv_fragment_program *p, GLuint attrib)
 {
    ir_variable *current;
    ir_rvalue *val;
@@ -549,7 +552,7 @@ get_current_attrib(struct texenv_fragment_program *p, GLuint attrib)
 }
 
 static ir_rvalue *
-get_gl_Color(struct texenv_fragment_program *p)
+get_gl_Color(texenv_fragment_program *p)
 {
    if (p->state->inputs_available & FRAG_BIT_COL0) {
       ir_variable *var = p->shader->symbols->get_variable("gl_Color");
@@ -561,7 +564,7 @@ get_gl_Color(struct texenv_fragment_program *p)
 }
 
 static ir_rvalue *
-get_source(struct texenv_fragment_program *p,
+get_source(texenv_fragment_program *p,
           GLuint src, GLuint unit)
 {
    ir_variable *var;
@@ -612,7 +615,7 @@ get_source(struct texenv_fragment_program *p,
 }
 
 static ir_rvalue *
-emit_combine_source(struct texenv_fragment_program *p,
+emit_combine_source(texenv_fragment_program *p,
                    GLuint unit,
                    GLuint source,
                    GLuint operand)
@@ -687,7 +690,7 @@ static GLboolean args_match( const struct state_key *key, GLuint unit )
 }
 
 static ir_rvalue *
-smear(struct texenv_fragment_program *p, ir_rvalue *val)
+smear(texenv_fragment_program *p, ir_rvalue *val)
 {
    if (!val->type->is_scalar())
       return val;
@@ -696,7 +699,7 @@ smear(struct texenv_fragment_program *p, ir_rvalue *val)
 }
 
 static ir_rvalue *
-emit_combine(struct texenv_fragment_program *p,
+emit_combine(texenv_fragment_program *p,
             GLuint unit,
             GLuint nr,
             GLuint mode,
@@ -777,7 +780,7 @@ emit_combine(struct texenv_fragment_program *p,
  * Generate instructions for one texture unit's env/combiner mode.
  */
 static ir_rvalue *
-emit_texenv(struct texenv_fragment_program *p, GLuint unit)
+emit_texenv(texenv_fragment_program *p, GLuint unit)
 {
    const struct state_key *key = p->state;
    GLboolean rgb_saturate, alpha_saturate;
@@ -887,10 +890,10 @@ emit_texenv(struct texenv_fragment_program *p, GLuint unit)
       }
       else {
         float const_data[4] = {
-           1 << rgb_shift,
-           1 << rgb_shift,
-           1 << rgb_shift,
-           1 << alpha_shift
+           float(1 << rgb_shift),
+           float(1 << rgb_shift),
+           float(1 << rgb_shift),
+           float(1 << alpha_shift)
         };
         shift = new(p->mem_ctx) ir_constant(glsl_type::vec4_type,
                                             (ir_constant_data *)const_data);
@@ -906,7 +909,7 @@ emit_texenv(struct texenv_fragment_program *p, GLuint unit)
 /**
  * Generate instruction for getting a texture source term.
  */
-static void load_texture( struct texenv_fragment_program *p, GLuint unit )
+static void load_texture( texenv_fragment_program *p, GLuint unit )
 {
    ir_dereference *deref;
 
@@ -1036,7 +1039,7 @@ static void load_texture( struct texenv_fragment_program *p, GLuint unit )
 }
 
 static void
-load_texenv_source(struct texenv_fragment_program *p,
+load_texenv_source(texenv_fragment_program *p,
                   GLuint src, GLuint unit)
 {
    switch (src) {
@@ -1066,7 +1069,7 @@ load_texenv_source(struct texenv_fragment_program *p,
  * Generate instructions for loading all texture source terms.
  */
 static GLboolean
-load_texunit_sources( struct texenv_fragment_program *p, GLuint unit )
+load_texunit_sources( texenv_fragment_program *p, GLuint unit )
 {
    const struct state_key *key = p->state;
    GLuint i;
@@ -1086,7 +1089,7 @@ load_texunit_sources( struct texenv_fragment_program *p, GLuint unit )
  * Generate instructions for loading bump map textures.
  */
 static void
-load_texunit_bumpmap( struct texenv_fragment_program *p, GLuint unit )
+load_texunit_bumpmap( texenv_fragment_program *p, GLuint unit )
 {
    const struct state_key *key = p->state;
    GLuint bumpedUnitNr = key->unit[unit].OptRGB[1].Source - SRC_TEXTURE0;
@@ -1138,7 +1141,7 @@ load_texunit_bumpmap( struct texenv_fragment_program *p, GLuint unit )
  * GL_FOG_COORDINATE_EXT is set to GL_FRAGMENT_DEPTH_EXT.
  */
 static ir_rvalue *
-emit_fog_instructions(struct texenv_fragment_program *p,
+emit_fog_instructions(texenv_fragment_program *p,
                      ir_rvalue *fragcolor)
 {
    struct state_key *key = p->state;
@@ -1211,7 +1214,7 @@ emit_fog_instructions(struct texenv_fragment_program *p,
 }
 
 static void
-emit_instructions(struct texenv_fragment_program *p)
+emit_instructions(texenv_fragment_program *p)
 {
    struct state_key *key = p->state;
    GLuint unit;
@@ -1360,7 +1363,8 @@ create_new_program(struct gl_context *ctx, struct state_key *key)
    _mesa_associate_uniform_storage(ctx, p.shader_program, fp->Parameters);
 
    _mesa_update_shader_textures_used(p.shader_program, fp);
-   (void) ctx->Driver.ProgramStringNotify(ctx, fp->Target, fp);
+   if (ctx->Driver.SamplerUniformChange)
+      ctx->Driver.SamplerUniformChange(ctx, fp->Target, fp);
 
    if (!p.shader_program->LinkStatus)
       _mesa_problem(ctx, "Failed to link fixed function fragment shader: %s\n",