From 45b104e0a228595142ed4bc62bbc8948100b9325 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 23 Sep 2014 15:27:55 -0700 Subject: vc4: Add support for flat shading. This is just the GL 1.1 flat shading of colors -- we don't need to support TGSI constant interpolation bits, because we don't do GLSL 1.30. Fixes 7 piglit tests. --- src/gallium/drivers/vc4/vc4_program.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/gallium/drivers/vc4/vc4_program.c') diff --git a/src/gallium/drivers/vc4/vc4_program.c b/src/gallium/drivers/vc4/vc4_program.c index 587831f231d..38e80dd5ba9 100644 --- a/src/gallium/drivers/vc4/vc4_program.c +++ b/src/gallium/drivers/vc4/vc4_program.c @@ -877,12 +877,17 @@ emit_fragment_varying(struct vc4_compile *c, int index) } static void -emit_fragment_input(struct vc4_compile *c, int attr) +emit_fragment_input(struct vc4_compile *c, int attr, + struct tgsi_full_declaration *decl) { for (int i = 0; i < 4; i++) { c->inputs[attr * 4 + i] = emit_fragment_varying(c, attr * 4 + i); c->num_inputs++; + + if (decl->Semantic.Name == TGSI_SEMANTIC_COLOR || + decl->Semantic.Name == TGSI_SEMANTIC_BCOLOR) + c->color_inputs |= 1 << i; } } @@ -908,7 +913,7 @@ emit_tgsi_declaration(struct vc4_compile *c, TGSI_SEMANTIC_POSITION) { emit_fragcoord_input(c, i); } else { - emit_fragment_input(c, i); + emit_fragment_input(c, i, decl); } } else { emit_vertex_input(c, i); @@ -1527,6 +1532,7 @@ vc4_fs_compile(struct vc4_context *vc4, struct vc4_compiled_shader *shader, QSTAGE_FRAG, &key->base); shader->num_inputs = c->num_inputs; + shader->color_inputs = c->color_inputs; copy_uniform_state_to_shader(shader, 0, c); shader->bo = vc4_bo_alloc_mem(vc4->screen, c->qpu_insts, c->qpu_inst_count * sizeof(uint64_t), @@ -1620,6 +1626,12 @@ vc4_update_compiled_fs(struct vc4_context *vc4, uint8_t prim_mode) vc4_fs_compile(vc4, shader, key); util_hash_table_set(vc4->fs_cache, key, shader); + if (vc4->rasterizer->base.flatshade && + vc4->prog.fs && + vc4->prog.fs->color_inputs != shader->color_inputs) { + vc4->dirty |= VC4_DIRTY_FLAT_SHADE_FLAGS; + } + vc4->prog.fs = shader; } -- cgit v1.2.3