nir/drawpixels: handle load_color0, load_input, load_interpolated_input
[mesa.git] / src / compiler / glsl / ast_to_hir.cpp
index 61351341703c6ecd20fa68d41fff70ba38faa768..214412bc30a73954d2f20b40f40b9a9010510b81 100644 (file)
@@ -6015,6 +6015,19 @@ ast_function::hir(exec_list *instructions,
                        name);
    }
 
+   /* Get the precision for the return type */
+   unsigned return_precision;
+
+   if (state->es_shader) {
+      YYLTYPE loc = this->get_location();
+      return_precision =
+         select_gles_precision(this->return_type->qualifier.precision,
+                               return_type,
+                               state,
+                               &loc);
+   } else {
+      return_precision = GLSL_PRECISION_NONE;
+   }
 
    /* Create an ir_function if one doesn't already exist. */
    f = state->symbols->get_function(name);
@@ -6043,7 +6056,6 @@ ast_function::hir(exec_list *instructions,
     */
    if (state->es_shader) {
       /* Local shader has no exact candidates; check the built-ins. */
-      _mesa_glsl_initialize_builtin_functions();
       if (state->language_version >= 300 &&
           _mesa_glsl_has_builtin_function(state, name)) {
          YYLTYPE loc = this->get_location();
@@ -6086,6 +6098,13 @@ ast_function::hir(exec_list *instructions,
                              "match prototype", name);
          }
 
+         if (sig->return_precision != return_precision) {
+            YYLTYPE loc = this->get_location();
+
+            _mesa_glsl_error(&loc, state, "function `%s' return type precision "
+                             "doesn't match prototype", name);
+         }
+
          if (sig->is_defined) {
             if (is_definition) {
                YYLTYPE loc = this->get_location();
@@ -6130,6 +6149,7 @@ ast_function::hir(exec_list *instructions,
     */
    if (sig == NULL) {
       sig = new(ctx) ir_function_signature(return_type);
+      sig->return_precision = return_precision;
       f->add_signature(sig);
    }
 
@@ -6444,6 +6464,25 @@ ast_jump_statement::hir(exec_list *instructions,
 }
 
 
+ir_rvalue *
+ast_demote_statement::hir(exec_list *instructions,
+                          struct _mesa_glsl_parse_state *state)
+{
+   void *ctx = state;
+
+   if (state->stage != MESA_SHADER_FRAGMENT) {
+      YYLTYPE loc = this->get_location();
+
+      _mesa_glsl_error(& loc, state,
+                       "`demote' may only appear in a fragment shader");
+   }
+
+   instructions->push_tail(new(ctx) ir_demote);
+
+   return NULL;
+}
+
+
 ir_rvalue *
 ast_selection_statement::hir(exec_list *instructions,
                              struct _mesa_glsl_parse_state *state)