From 224f712950494730c76b48864f2ca19acde1c8cf Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 1 Jun 2010 16:32:46 -0700 Subject: ir_to_mesa: Fix mapping of FS texcoord inputs and color output. --- ir_to_mesa.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/ir_to_mesa.cpp b/ir_to_mesa.cpp index 8d3f65ffb20..f121fc88b34 100644 --- a/ir_to_mesa.cpp +++ b/ir_to_mesa.cpp @@ -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 { -- cgit v1.2.3