extsrc/mesa/src/mesa/drivers/dri/i965/brw_fs.cpp
/* Our support for uniforms is piggy-backed on the struct
 * gl_fragment_program, because that's where the values actually
 * get stored, rather than in some global gl_shader_program uniform
 * store.
 */
Our support for uniforms is piggy-backed on the struct
gl_fragment_program, because that's where the values actually
get stored, rather than in some global gl_shader_program uniform
store.
Our support for uniforms is piggy - backed on the struct gl_fragment_program because that ' s where the values actually get stored rather than in some global gl_shader_program uniform store .
int
fs_visitor::setup_uniform_values(int loc, const glsl_type *type)
{
   unsigned int offset = 0;
   if (type->is_matrix()) {
      const glsl_type *column = glsl_type::get_instance(GLSL_TYPE_FLOAT,
							type->vector_elements,
							1);
      for (unsigned int i = 0; i < type->matrix_columns; i++) {
	 offset += setup_uniform_values(loc + offset, column);
      }
      return offset;
   }
   switch (type->base_type) {
   case GLSL_TYPE_FLOAT:
   case GLSL_TYPE_UINT:
   case GLSL_TYPE_INT:
   case GLSL_TYPE_BOOL:
      for (unsigned int i = 0; i < type->vector_elements; i++) {
	 unsigned int param = c->prog_data.nr_params++;
	 assert(param < ARRAY_SIZE(c->prog_data.param));
	 if (ctx->Const.NativeIntegers) {
	    c->prog_data.param_convert[param] = PARAM_NO_CONVERT;
	 } else {
	    switch (type->base_type) {
	    case GLSL_TYPE_FLOAT:
	       c->prog_data.param_convert[param] = PARAM_NO_CONVERT;
	       break;
	    case GLSL_TYPE_UINT:
	       c->prog_data.param_convert[param] = PARAM_CONVERT_F2U;
	       break;
	    case GLSL_TYPE_INT:
	       c->prog_data.param_convert[param] = PARAM_CONVERT_F2I;
	       break;
	    case GLSL_TYPE_BOOL:
	       c->prog_data.param_convert[param] = PARAM_CONVERT_F2B;
	       break;
	    default:
	       assert(!"not reached");
	       c->prog_data.param_convert[param] = PARAM_NO_CONVERT;
	       break;
	    }
	 }
	 this->param_index[param] = loc;
	 this->param_offset[param] = i;
      }
      return 1;
   case GLSL_TYPE_STRUCT:
      for (unsigned int i = 0; i < type->length; i++) {
	 offset += setup_uniform_values(loc + offset,
					type->fields.structure[i].type);
      }
      return offset;
   case GLSL_TYPE_ARRAY:
      for (unsigned int i = 0; i < type->length; i++) {
	 offset += setup_uniform_values(loc + offset, type->fields.array);
      }
      return offset;
   case GLSL_TYPE_SAMPLER:
      return 1;
   default:
      assert(!"not reached");
      return 0;
   }
}
int fs_visitor :: setup_uniform_values ( int loc , const glsl_type * type ) { unsigned int offset = 0 ; if ( type -> is_matrix ( ) ) { const glsl_type * column = glsl_type :: get_instance ( GLSL_TYPE_FLOAT , type -> vector_elements , 1 ) ; for ( unsigned int i = 0 ; i < type -> matrix_columns ; i ++ ) { offset += setup_uniform_values ( loc + offset , column ) ; } return offset ; } switch ( type -> base_type ) { case GLSL_TYPE_FLOAT : case GLSL_TYPE_UINT : case GLSL_TYPE_INT : case GLSL_TYPE_BOOL : for ( unsigned int i = 0 ; i < type -> vector_elements ; i ++ ) { unsigned int param = c -> prog_data . nr_params ++ ; assert ( param < ARRAY_SIZE ( c -> prog_data . param ) ) ; if ( ctx -> Const . NativeIntegers ) { c -> prog_data . param_convert [ param ] = PARAM_NO_CONVERT ; } else { switch ( type -> base_type ) { case GLSL_TYPE_FLOAT : c -> prog_data . param_convert [ param ] = PARAM_NO_CONVERT ; break ; case GLSL_TYPE_UINT : c -> prog_data . param_convert [ param ] = PARAM_CONVERT_F2U ; break ; case GLSL_TYPE_INT : c -> prog_data . param_convert [ param ] = PARAM_CONVERT_F2I ; break ; case GLSL_TYPE_BOOL : c -> prog_data . param_convert [ param ] = PARAM_CONVERT_F2B ; break ; default : assert ( ! " " ) ; c -> prog_data . param_convert [ param ] = PARAM_NO_CONVERT ; break ; } } this -> param_index [ param ] = loc ; this -> param_offset [ param ] = i ; } return 1 ; case GLSL_TYPE_STRUCT : for ( unsigned int i = 0 ; i < type -> length ; i ++ ) { offset += setup_uniform_values ( loc + offset , type -> fields . structure [ i ] . type ) ; } return offset ; case GLSL_TYPE_ARRAY : for ( unsigned int i = 0 ; i < type -> length ; i ++ ) { offset += setup_uniform_values ( loc + offset , type -> fields . array ) ; } return offset ; case GLSL_TYPE_SAMPLER : return 1 ; default : assert ( ! " " ) ; return 0 ; } }
Our support for uniforms is piggy-backed on the struct
 gl_fragment_program, because that's where the values actually
 get stored, rather than in some global gl_shader_program uniform
 store.
Our support for uniforms is piggy - backed on the struct gl_fragment_program because that ' s where the values actually get stored rather than in some global gl_shader_program uniform store .
/* The sampler takes up a slot, but we don't use any values from it. */