diff options
author | Eric Anholt <[email protected]> | 2010-07-28 14:41:51 -0700 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2010-07-28 15:00:09 -0700 |
commit | 4a962170d7cf4243d6ae156fca20a6167388925d (patch) | |
tree | 4d779c860f351ce01c1e03b4fae06d4a312463dd /src | |
parent | 8d8469eb2ade4fd48188403351a38f740987fb80 (diff) |
glsl2: Add support for redeclaring layout of gl_FragCoord for ARB_fcc.
Fixes:
glsl-arb-fragment-coord-conventions
Diffstat (limited to 'src')
-rw-r--r-- | src/glsl/ast_to_hir.cpp | 15 | ||||
-rw-r--r-- | src/glsl/ir.h | 4 | ||||
-rw-r--r-- | src/glsl/ir_clone.cpp | 2 | ||||
-rw-r--r-- | src/mesa/program/ir_to_mesa.cpp | 7 |
4 files changed, 25 insertions, 3 deletions
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index d82cf333895..8e8690c628f 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -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(); diff --git a/src/glsl/ir.h b/src/glsl/ir.h index 7e8363106da..202685d145a 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -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 * diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp index c49a7324818..f97080d2056 100644 --- a/src/glsl/ir_clone.cpp +++ b/src/glsl/ir_clone.cpp @@ -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); diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index c53381e29d9..a3019cc650a 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -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 |