Merge remote-tracking branch 'mesa-public/master' into vulkan
[mesa.git] / src / glsl / ast.h
index ae70b003cfeba94cf5a587f3556a61255fa2e319..eb6d84616711b2a71438ec4afd8a155e7b32ab9c 100644 (file)
@@ -189,6 +189,7 @@ enum ast_operators {
    ast_uint_constant,
    ast_float_constant,
    ast_bool_constant,
+   ast_double_constant,
 
    ast_sequence,
    ast_aggregate
@@ -217,6 +218,13 @@ public:
    virtual ir_rvalue *hir(exec_list *instructions,
                          struct _mesa_glsl_parse_state *state);
 
+   virtual void hir_no_rvalue(exec_list *instructions,
+                              struct _mesa_glsl_parse_state *state);
+
+   ir_rvalue *do_hir(exec_list *instructions,
+                     struct _mesa_glsl_parse_state *state,
+                     bool needs_rvalue);
+
    virtual void print(void) const;
 
    enum ast_operators oper;
@@ -229,6 +237,7 @@ public:
       float float_constant;
       unsigned uint_constant;
       int bool_constant;
+      double double_constant;
    } primary_expression;
 
 
@@ -287,11 +296,24 @@ public:
    virtual ir_rvalue *hir(exec_list *instructions,
                          struct _mesa_glsl_parse_state *state);
 
+   virtual void hir_no_rvalue(exec_list *instructions,
+                              struct _mesa_glsl_parse_state *state);
+
 private:
    /**
     * Is this function call actually a constructor?
     */
    bool cons;
+   ir_rvalue *
+   handle_method(exec_list *instructions,
+                 struct _mesa_glsl_parse_state *state);
+};
+
+class ast_subroutine_list : public ast_node
+{
+public:
+   virtual void print(void) const;
+   exec_list declarations;
 };
 
 class ast_array_specifier : public ast_node {
@@ -359,6 +381,9 @@ public:
 
    virtual ir_rvalue *hir(exec_list *instructions,
                           struct _mesa_glsl_parse_state *state);
+
+   virtual void hir_no_rvalue(exec_list *instructions,
+                              struct _mesa_glsl_parse_state *state);
 };
 
 /**
@@ -411,6 +436,7 @@ struct ast_type_qualifier {
    union {
       struct {
         unsigned invariant:1;
+         unsigned precise:1;
         unsigned constant:1;
         unsigned attribute:1;
         unsigned varying:1;
@@ -418,7 +444,9 @@ struct ast_type_qualifier {
         unsigned out:1;
         unsigned centroid:1;
          unsigned sample:1;
+        unsigned patch:1;
         unsigned uniform:1;
+        unsigned buffer:1;
         unsigned smooth:1;
         unsigned flat:1;
         unsigned noperspective:1;
@@ -495,7 +523,29 @@ struct ast_type_qualifier {
          /** \name Layout qualifiers for GL_ARB_gpu_shader5 */
          /** \{ */
          unsigned invocations:1;
+         unsigned stream:1; /**< Has stream value assigned  */
+         unsigned explicit_stream:1; /**< stream value assigned explicitly by shader code */
          /** \} */
+
+         /** \name Vulkan qualifiers */
+         unsigned vk_set:1;
+
+        /** \name Layout qualifiers for GL_ARB_tessellation_shader */
+        /** \{ */
+        /* tess eval input layout */
+        /* gs prim_type reused for primitive mode */
+        unsigned vertex_spacing:1;
+        unsigned ordering:1;
+        unsigned point_mode:1;
+        /* tess control output layout */
+        unsigned vertices:1;
+        /** \} */
+
+         /** \name Qualifiers for GL_ARB_shader_subroutine */
+        /** \{ */
+         unsigned subroutine:1;  /**< Is this marked 'subroutine' */
+         unsigned subroutine_def:1; /**< Is this marked 'subroutine' with a list of types */
+        /** \} */
       }
       /** \brief Set of flags, accessed by name. */
       q;
@@ -528,7 +578,13 @@ struct ast_type_qualifier {
    /** Maximum output vertices in GLSL 1.50 geometry shaders. */
    int max_vertices;
 
-   /** Input or output primitive type in GLSL 1.50 geometry shaders */
+   /** Stream in GLSL 1.50 geometry shaders. */
+   unsigned stream;
+
+   /**
+    * Input or output primitive type in GLSL 1.50 geometry shaders
+    * and tessellation shaders.
+    */
    GLenum prim_type;
 
    /**
@@ -555,6 +611,18 @@ struct ast_type_qualifier {
     */
    int local_size[3];
 
+   /** Tessellation evaluation shader: vertex spacing (equal, fractional even/odd) */
+   GLenum vertex_spacing;
+
+   /** Tessellation evaluation shader: vertex ordering (CW or CCW) */
+   GLenum ordering;
+
+   /** Tessellation evaluation shader: point mode */
+   bool point_mode;
+
+   /** Tessellation control shader: number of output vertices */
+   int vertices;
+
    /**
     * Image format specified with an ARB_shader_image_load_store
     * layout qualifier.
@@ -574,6 +642,11 @@ struct ast_type_qualifier {
     */
    glsl_base_type image_base_type;
 
+   /**
+    * Vulkan descriptor set
+    */
+   int set;
+
    /**
     * Return true if and only if an interpolation qualifier is present.
     */
@@ -610,30 +683,23 @@ struct ast_type_qualifier {
                        _mesa_glsl_parse_state *state,
                        ast_type_qualifier q);
 
+   bool merge_out_qualifier(YYLTYPE *loc,
+                           _mesa_glsl_parse_state *state,
+                           ast_type_qualifier q,
+                           ast_node* &node);
+
    bool merge_in_qualifier(YYLTYPE *loc,
                            _mesa_glsl_parse_state *state,
                            ast_type_qualifier q,
                            ast_node* &node);
 
+   ast_subroutine_list *subroutine_list;
 };
 
 class ast_declarator_list;
 
 class ast_struct_specifier : public ast_node {
 public:
-   /**
-    * \brief Make a shallow copy of an ast_struct_specifier.
-    *
-    * Use only if the objects are allocated from the same context and will not
-    * be modified. Zeros the inherited ast_node's fields.
-    */
-   ast_struct_specifier(const ast_struct_specifier& that):
-      ast_node(), name(that.name), declarations(that.declarations),
-      is_declaration(that.is_declaration)
-   {
-      /* empty */
-   }
-
    ast_struct_specifier(const char *identifier,
                        ast_declarator_list *declarator_list);
    virtual void print(void) const;
@@ -651,22 +717,6 @@ public:
 
 class ast_type_specifier : public ast_node {
 public:
-   /**
-    * \brief Make a shallow copy of an ast_type_specifier, specifying array
-    *        fields.
-    *
-    * Use only if the objects are allocated from the same context and will not
-    * be modified. Zeros the inherited ast_node's fields.
-    */
-   ast_type_specifier(const ast_type_specifier *that,
-                      ast_array_specifier *array_specifier)
-      : ast_node(), type_name(that->type_name), structure(that->structure),
-        array_specifier(array_specifier),
-        default_precision(that->default_precision)
-   {
-      /* empty */
-   }
-
    /** Construct a type specifier from a type name */
    ast_type_specifier(const char *name) 
       : type_name(name), structure(NULL), array_specifier(NULL),
@@ -732,13 +782,11 @@ public:
    exec_list declarations;
 
    /**
-    * Special flag for vertex shader "invariant" declarations.
-    *
-    * Vertex shaders can contain "invariant" variable redeclarations that do
-    * not include a type.  For example, "invariant gl_Position;".  This flag
-    * is used to note these cases when no type is specified.
+    * Flags for redeclarations. In these cases, no type is specified, to
+    * `type` is allowed to be NULL. In all other cases, this would be an error.
     */
-   int invariant;
+   int invariant;     /** < `invariant` redeclaration */
+   int precise;       /** < `precise` redeclaration */
 };
 
 
@@ -1040,6 +1088,27 @@ public:
 };
 
 
+/**
+ * AST node representing a declaration of the output layout for tessellation
+ * control shaders.
+ */
+class ast_tcs_output_layout : public ast_node
+{
+public:
+   ast_tcs_output_layout(const struct YYLTYPE &locp, int vertices)
+      : vertices(vertices)
+   {
+      set_location(locp);
+   }
+
+   virtual ir_rvalue *hir(exec_list *instructions,
+                          struct _mesa_glsl_parse_state *state);
+
+private:
+   const int vertices;
+};
+
+
 /**
  * AST node representing a declaration of the input layout for geometry
  * shaders.