ir_to_mesa: Fix mapping of FS texcoord inputs and color output.
authorEric Anholt <eric@anholt.net>
Tue, 1 Jun 2010 23:32:46 +0000 (16:32 -0700)
committerEric Anholt <eric@anholt.net>
Thu, 24 Jun 2010 22:05:21 +0000 (15:05 -0700)
ir_to_mesa.cpp

index 8d3f65ffb207f5520a607b2e55c53aa96102b79a..f121fc88b34089b125fa0e6f95c143033d21e178 100644 (file)
@@ -613,13 +613,14 @@ static const struct {
    /* core_fs */
    {"gl_FragCoord", PROGRAM_INPUT, FRAG_ATTRIB_WPOS},
    {"gl_FrontFacing", PROGRAM_INPUT, FRAG_ATTRIB_FACE},
-   {"gl_FragColor", PROGRAM_INPUT, FRAG_ATTRIB_COL0},
+   {"gl_FragColor", PROGRAM_OUTPUT, FRAG_ATTRIB_COL0},
    {"gl_FragDepth", PROGRAM_UNDEFINED, FRAG_ATTRIB_WPOS}, /* FINISHME: WPOS.z */
 
    /* 110_deprecated_fs */
    {"gl_Color", PROGRAM_INPUT, FRAG_ATTRIB_COL0},
    {"gl_SecondaryColor", PROGRAM_INPUT, FRAG_ATTRIB_COL1},
    {"gl_FogFragCoord", PROGRAM_INPUT, FRAG_ATTRIB_FOGC},
+   {"gl_TexCoord", PROGRAM_INPUT, FRAG_ATTRIB_TEX0}, /* array */
 
    /* 110_deprecated_vs */
    {"gl_Vertex", PROGRAM_INPUT, VERT_ATTRIB_POS},
@@ -669,12 +670,24 @@ ir_to_mesa_visitor::visit(ir_dereference_variable *ir)
 
    if (strncmp(ir->var->name, "gl_", 3) == 0) {
       unsigned int i;
+      bool var_in = (ir->var->mode == ir_var_in ||
+                    ir->var->mode == ir_var_inout);
+
+      tree = this->create_tree(MB_TERM_reference_vec4, ir, NULL, NULL);
 
       for (i = 0; i < ARRAY_SIZE(builtin_var_to_mesa_reg); i++) {
-        if (strcmp(ir->var->name, builtin_var_to_mesa_reg[i].name) == 0)
+        bool in = builtin_var_to_mesa_reg[i].file == PROGRAM_INPUT;
+
+        if (strcmp(ir->var->name, builtin_var_to_mesa_reg[i].name) == 0 &&
+            !(var_in ^ in))
            break;
       }
-      assert(i != ARRAY_SIZE(builtin_var_to_mesa_reg));
+      if (i == ARRAY_SIZE(builtin_var_to_mesa_reg)) {
+        printf("Failed to find builtin for %s variable %s\n",
+               var_in ? "in" : "out",
+               ir->var->name);
+        abort();
+      }
       ir_to_mesa_set_tree_reg(tree, builtin_var_to_mesa_reg[i].file,
                              builtin_var_to_mesa_reg[i].index);
    } else {