draw/gs: make sure geometry shaders don't overflow
[mesa.git] / src / glsl / hir_field_selection.cpp
index db1e06932f4596f15bc0e1e2a37164ce562d8116..0035a5f81fd972aec13c75aecdce70ca4f11054d 100644 (file)
  */
 
 #include "ir.h"
-#include "main/imports.h"
-#include "symbol_table.h"
+#include "program/symbol_table.h"
 #include "glsl_parser_extras.h"
 #include "ast.h"
 #include "glsl_types.h"
 
-struct ir_rvalue *
+ir_rvalue *
 _mesa_ast_field_selection_to_hir(const ast_expression *expr,
                                 exec_list *instructions,
                                 struct _mesa_glsl_parse_state *state)
@@ -62,7 +61,8 @@ _mesa_ast_field_selection_to_hir(const ast_expression *expr,
         _mesa_glsl_error(& loc, state, "Invalid swizzle / mask `%s'",
                          expr->primary_expression.identifier);
       }
-   } else if (op->type->base_type == GLSL_TYPE_STRUCT) {
+   } else if (op->type->base_type == GLSL_TYPE_STRUCT
+              || op->type->base_type == GLSL_TYPE_INTERFACE) {
       result = new(ctx) ir_dereference_record(op,
                                              expr->primary_expression.identifier);
 
@@ -73,8 +73,7 @@ _mesa_ast_field_selection_to_hir(const ast_expression *expr,
       }
    } else if (expr->subexpressions[1] != NULL) {
       /* Handle "method calls" in GLSL 1.20 - namely, array.length() */
-      if (state->language_version < 120)
-        _mesa_glsl_error(&loc, state, "Methods not supported in GLSL 1.10.");
+      state->check_version(120, 300, &loc, "Methods not supported");
 
       ast_expression *call = expr->subexpressions[1];
       assert(call->oper == ast_function_call);
@@ -99,5 +98,5 @@ _mesa_ast_field_selection_to_hir(const ast_expression *expr,
                       expr->primary_expression.identifier);
    }
 
-   return result ? result : ir_call::get_error_instruction(ctx);
+   return result ? result : ir_rvalue::error_value(ctx);
 }