summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2010-03-27 18:56:53 -0700
committerIan Romanick <ian.d.romanick@intel.com>2010-03-27 18:56:53 -0700
commit66faec4895b7bb59a614087a200c05157191b4ae (patch)
tree95b613b0ec2dd9fe54d4a979482b081aebfe9baf
parent19360152f5bd8cff93359dbfe5a50a90b699c118 (diff)
Initial bits to process initializers in variable declarations
As a result, the following tests pass: glslparsertest/array3.frag glslparsertest/CGStandardLibrary.frag glslparsertest/ConstantConversions.frag glslparsertest/constructor1.frag glslparsertest/constructor2.frag glslparsertest/constructor3.V110.frag glslparsertest/dataType4.frag glslparsertest/dataType5.frag glslparsertest/dataType13.frag glslparsertest/dataType19.frag glslparsertest/matrix.V110.frag glslparsertest/parser7.frag glslparsertest/swizzle3.frag The following tests also pass, but it is just by dumb luck. In these cases the shader fails to compile, but it fails for the wrong reason: glslparsertest/array6.frag glslparsertest/comma2.frag glslparsertest/conditional1.frag glslparsertest/conditional2.frag glslparsertest/conditional3.frag glslparsertest/constFunc.frag glslparsertest/ParseTest3.frag glslparsertest/ParseTest4.frag glslparsertest/varying3.frag glslparsertest/parser8.frag (also segfaults) glslparsertest/parser9.frag (also segfaults) The following tests now fail. As far as I can tell, these are all cases where the shader was failing to compile, but it was failing for the wrong reason. glslparsertest/CorrectMatComma.frag glslparsertest/CorrectModule.frag glslparsertest/CorrectSwizzle2.vert glslparsertest/shaders/glsl-fs-bug25902.frag
-rw-r--r--ast_to_hir.cpp39
1 files changed, 25 insertions, 14 deletions
diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp
index c5d60b87b8..ce64794ae2 100644
--- a/ast_to_hir.cpp
+++ b/ast_to_hir.cpp
@@ -980,22 +980,33 @@ ast_declarator_list::hir(exec_list *instructions,
instructions->push_tail(var);
- /* From page 24 (page 30 of the PDF) of the GLSL 1.10 spec:
- *
- * "All uniform variables are read-only and are initialized either
- * directly by an application via API commands, or indirectly by
- * OpenGL."
- */
- if ((state->language_version <= 110)
- && (var->mode == ir_var_uniform)
- && (decl->initializer != NULL)) {
- YYLTYPE loc = decl->initializer->get_location();
+ if (decl->initializer != NULL) {
+ /* From page 24 (page 30 of the PDF) of the GLSL 1.10 spec:
+ *
+ * "All uniform variables are read-only and are initialized either
+ * directly by an application via API commands, or indirectly by
+ * OpenGL."
+ */
+ if ((state->language_version <= 110)
+ && (var->mode == ir_var_uniform)) {
+ YYLTYPE loc = decl->initializer->get_location();
- _mesa_glsl_error(& loc, state, "uniform initializers forbidden in "
- "GLSL 1.10");
- }
+ _mesa_glsl_error(& loc, state, "uniform initializers forbidden in "
+ "GLSL 1.10");
+ }
+
+ ir_dereference *const lhs = new ir_dereference(var);
+ ir_rvalue *const rhs = decl->initializer->hir(instructions, state);
- /* FINISHME: Process the declaration initializer. */
+ /* FINISHME: If the declaration is either 'const' or 'uniform', the
+ * FINISHME: initializer (rhs) must be a constant expression.
+ */
+
+ if (!rhs->type->is_error()) {
+ (void) do_assignment(instructions, state, lhs, rhs,
+ this->get_location());
+ }
+ }
}
/* Variable declarations do not have r-values.