glsl2: Add support for redeclaring layout of gl_FragCoord for ARB_fcc.
authorEric Anholt <eric@anholt.net>
Wed, 28 Jul 2010 21:41:51 +0000 (14:41 -0700)
committerEric Anholt <eric@anholt.net>
Wed, 28 Jul 2010 22:00:09 +0000 (15:00 -0700)
Fixes:
glsl-arb-fragment-coord-conventions

src/glsl/ast_to_hir.cpp
src/glsl/ir.h
src/glsl/ir_clone.cpp
src/mesa/program/ir_to_mesa.cpp

index d82cf333895a9ca079ee6f99aa03e91de864fc0a..8e8690c628ff41ad3346409c40f488e94173d606 100644 (file)
@@ -50,6 +50,7 @@
  */
 
 #include "main/imports.h"
+#include "main/extensions.h"
 #include "glsl_symbol_table.h"
 #include "glsl_parser_extras.h"
 #include "ast.h"
@@ -1542,8 +1543,8 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual,
    else
       var->interpolation = ir_var_smooth;
 
-   /* FINISHME: Apply the fragment coord convetion layout qualifiers.
-    */
+   var->pixel_center_integer = qual->pixel_center_integer;
+   var->origin_upper_left = qual->origin_upper_left;
    if ((qual->origin_upper_left || qual->pixel_center_integer)
        && (strcmp(var->name, "gl_FragCoord") != 0)) {
       const char *const qual_string = (qual->origin_upper_left)
@@ -1932,6 +1933,16 @@ ast_declarator_list::hir(exec_list *instructions,
            earlier->type = var->type;
            delete var;
            var = NULL;
+        } else if (state->extensions->ARB_fragment_coord_conventions &&
+                   (earlier != NULL) &&
+                   (strcmp(var->name, "gl_FragCoord") == 0) &&
+                   earlier->type == var->type &&
+                   earlier->mode == var->mode) {
+           /* Allow redeclaration of gl_FragCoord for ARB_fcc layout
+            * qualifiers.
+            */
+           earlier->origin_upper_left = var->origin_upper_left;
+           earlier->pixel_center_integer = var->pixel_center_integer;
         } else {
            YYLTYPE loc = this->get_location();
 
index 7e8363106da76ff165a8d50942cb9dc0ce169080..202685d145a113b745f1eab93e30b1e14c050b39 100644 (file)
@@ -238,6 +238,10 @@ public:
     */
    unsigned array_lvalue:1;
 
+   /* ARB_fragment_coord_conventions */
+   unsigned origin_upper_left:1;
+   unsigned pixel_center_integer:1;
+
    /**
     * Storage location of the base of this variable
     *
index c49a7324818c1dc2281d38e6d7a5bf57c3a3b3c7..f97080d2056ce8ba01ba3aa97e7358cf3ccf3a7a 100644 (file)
@@ -52,6 +52,8 @@ ir_variable::clone(struct hash_table *ht) const
    var->array_lvalue = this->array_lvalue;
    var->location = this->location;
    var->warn_extension = this->warn_extension;
+   var->origin_upper_left = this->origin_upper_left;
+   var->pixel_center_integer = this->pixel_center_integer;
 
    if (this->constant_value)
       var->constant_value = this->constant_value->clone(ht);
index c53381e29d9d344314ed7d69c35a036d03142dee..a3019cc650af4565065e9d8e640ec6e5e66b053d 100644 (file)
@@ -557,7 +557,12 @@ ir_to_mesa_visitor::find_variable_storage(ir_variable *var)
 void
 ir_to_mesa_visitor::visit(ir_variable *ir)
 {
-   (void)ir;
+   if (strcmp(ir->name, "gl_FragCoord") == 0) {
+      struct gl_fragment_program *fp = (struct gl_fragment_program *)this->prog;
+
+      fp->OriginUpperLeft = ir->origin_upper_left;
+      fp->PixelCenterInteger = ir->pixel_center_integer;
+   }
 }
 
 void