glsl: Modify strategy for accumulating conditions when lowering if-statements
[mesa.git] / src / glsl / glsl_types.h
index eb9d501858a64d4fe17d1e6292f16ee68fd08717..048696693be7fe18b27bf2ae4456de9d532aa0a4 100644 (file)
@@ -165,21 +165,6 @@ struct glsl_type {
    static const glsl_type *const mat4x3_type;
    static const glsl_type *const mat4_type;
    /*@}*/
-   
-   /**
-    * Get the built-in instance of the vec4 type for a specific base type
-    */
-   static const glsl_type *get_vec4_type(glsl_base_type base_type)
-   {
-      if (base_type == GLSL_TYPE_FLOAT)
-         return vec4_type;
-      else if (base_type == GLSL_TYPE_INT)
-         return ivec4_type;
-      else if (base_type == GLSL_TYPE_UINT)
-         return uvec4_type;
-      else
-         return NULL;
-   }
 
 
    /**
@@ -239,6 +224,41 @@ struct glsl_type {
     */
    unsigned component_slots() const;
 
+   /**
+    * \brief Can this type be implicitly converted to another?
+    *
+    * \return True if the types are identical or if this type can be converted
+    *         to \c desired according to Section 4.1.10 of the GLSL spec.
+    *
+    * \verbatim
+    * From page 25 (31 of the pdf) of the GLSL 1.50 spec, Section 4.1.10
+    * Implicit Conversions:
+    *
+    *     In some situations, an expression and its type will be implicitly
+    *     converted to a different type. The following table shows all allowed
+    *     implicit conversions:
+    *
+    *     Type of expression | Can be implicitly converted to
+    *     --------------------------------------------------
+    *     int                  float
+    *     uint
+    *
+    *     ivec2                vec2
+    *     uvec2
+    *
+    *     ivec3                vec3
+    *     uvec3
+    *
+    *     ivec4                vec4
+    *     uvec4
+    *
+    *     There are no implicit array or structure conversions. For example,
+    *     an array of int cannot be implicitly converted to an array of float.
+    *     There are no implicit conversions between signed and unsigned
+    *     integers.
+    * \endverbatim
+    */
+   bool can_implicitly_convert_to(const glsl_type *desired) const;
 
    /**
     * Query whether or not a type is a scalar (non-vector and non-matrix).
@@ -310,6 +330,12 @@ struct glsl_type {
       return base_type == GLSL_TYPE_SAMPLER;
    }
 
+   /**
+    * Query whether or not type is a sampler, or for struct and array
+    * types, contains a sampler.
+    */
+   bool contains_sampler() const;
+
    /**
     * Query whether or not a type is an array
     */