svgadump: Dump the new depth format names.
[mesa.git] / src / glsl / glsl_types.cpp
index 76b4f3e4cb0e20008413ccf5524d39440d935205..c94aec0d2da8352772aecc284b9d308eab3b5174 100644 (file)
@@ -111,6 +111,22 @@ add_types_to_symbol_table(glsl_symbol_table *symtab,
    }
 }
 
+bool
+glsl_type::contains_sampler() const
+{
+   if (this->is_array()) {
+      return this->fields.array->contains_sampler();
+   } else if (this->is_record()) {
+      for (unsigned int i = 0; i < this->length; i++) {
+        if (this->fields.structure[i].type->contains_sampler())
+           return true;
+      }
+      return false;
+   } else {
+      return this->is_sampler();
+   }
+}
+
 void
 glsl_type::generate_100ES_types(glsl_symbol_table *symtab)
 {
@@ -131,6 +147,7 @@ glsl_type::generate_110_types(glsl_symbol_table *symtab)
    add_types_to_symbol_table(symtab, builtin_110_types,
                             Elements(builtin_110_types),
                             false);
+   add_types_to_symbol_table(symtab, &_sampler3D_type, 1, false);
    add_types_to_symbol_table(symtab, builtin_110_deprecated_structure_types,
                             Elements(builtin_110_deprecated_structure_types),
                             false);
@@ -178,6 +195,13 @@ glsl_type::generate_EXT_texture_array_types(glsl_symbol_table *symtab,
 }
 
 
+void
+glsl_type::generate_OES_texture_3D_types(glsl_symbol_table *symtab, bool warn)
+{
+   add_types_to_symbol_table(symtab, &_sampler3D_type, 1, warn);
+}
+
+
 void
 _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state)
 {
@@ -204,6 +228,10 @@ _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state)
       glsl_type::generate_ARB_texture_rectangle_types(state->symbols,
                                           state->ARB_texture_rectangle_warn);
    }
+   if (state->OES_texture_3D_enable && state->language_version == 100) {
+      glsl_type::generate_OES_texture_3D_types(state->symbols,
+                                              state->OES_texture_3D_warn);
+   }
 
    if (state->EXT_texture_array_enable && state->language_version < 130) {
       // These are already included in 130; don't create twice.
@@ -495,3 +523,19 @@ glsl_type::component_slots() const
       return 0;
    }
 }
+
+bool
+glsl_type::can_implicitly_convert_to(const glsl_type *desired) const
+{
+   if (this == desired)
+      return true;
+
+   /* There is no conversion among matrix types. */
+   if (this->matrix_columns > 1 || desired->matrix_columns > 1)
+      return false;
+
+   /* int and uint can be converted to float. */
+   return desired->is_float()
+          && this->is_integer()
+          && this->vector_elements == desired->vector_elements;
+}