glsl: Track in each ir_variable whether it was ever assigned.
[mesa.git] / src / glsl / ir.h
index 054e2acaadb432e441fbd12f212f0c97bcb1b102..ddfaf3614aed3287467e8d62cc6e9d8c96402030 100644 (file)
@@ -88,7 +88,6 @@ enum ir_node_type {
 class ir_instruction : public exec_node {
 public:
    enum ir_node_type ir_type;
-   const struct glsl_type *type;
 
    /** ir_print_visitor helper for debugging. */
    void print(void) const;
@@ -127,7 +126,6 @@ protected:
    ir_instruction()
    {
       ir_type = ir_type_unset;
-      type = NULL;
    }
 };
 
@@ -137,6 +135,8 @@ protected:
  */
 class ir_rvalue : public ir_instruction {
 public:
+   const struct glsl_type *type;
+
    virtual ir_rvalue *clone(void *mem_ctx, struct hash_table *) const;
 
    virtual void accept(ir_visitor *v)
@@ -320,6 +320,11 @@ public:
     */
    glsl_interp_qualifier determine_interpolation_mode(bool flat_shade);
 
+   /**
+    * Declared type of the variable
+    */
+   const struct glsl_type *type;
+
    /**
     * Delcared name of the variable
     */
@@ -348,9 +353,22 @@ public:
     * Several GLSL semantic checks require knowledge of whether or not a
     * variable has been used.  For example, it is an error to redeclare a
     * variable as invariant after it has been used.
+    *
+    * This is only maintained in the ast_to_hir.cpp path, not in
+    * Mesa's fixed function or ARB program paths.
     */
    unsigned used:1;
 
+   /**
+    * Has this variable been statically assigned?
+    *
+    * This answers whether the variable was assigned in any path of
+    * the shader during ast_to_hir.  This doesn't answer whether it is
+    * still written after dead code removal, nor is it maintained in
+    * non-ast_to_hir.cpp (GLSL parsing) paths.
+    */
+   unsigned assigned:1;
+
    /**
     * Storage class of the variable.
     *
@@ -381,6 +399,7 @@ public:
     * no effect).
     */
    unsigned explicit_location:1;
+   unsigned explicit_index:1;
 
    /**
     * Does this variable have an initializer?
@@ -415,6 +434,11 @@ public:
     */
    int location;
 
+   /**
+    * output index for dual source blending.
+    */
+   int index;
+
    /**
     * Built-in state that backs this uniform
     *
@@ -1071,19 +1095,6 @@ public:
       return callee->function_name();
    }
 
-   /**
-    * Get the function signature bound to this function call
-    */
-   ir_function_signature *get_callee()
-   {
-      return callee;
-   }
-
-   /**
-    * Set the function call target
-    */
-   void set_callee(ir_function_signature *sig);
-
    /**
     * Generates an inline version of the function before @ir,
     * storing the return value in return_deref.
@@ -1096,14 +1107,16 @@ public:
     */
    ir_dereference_variable *return_deref;
 
+   /**
+    * The specific function signature being called.
+    */
+   ir_function_signature *callee;
+
    /* List of ir_rvalue of paramaters passed in this call. */
    exec_list actual_parameters;
 
    /** Should this call only bind to a built-in function? */
    bool use_builtin;
-
-private:
-   ir_function_signature *callee;
 };