#define VC4_DIRTY_VTXBUF (1 << 15)
#define VC4_DIRTY_INDEXBUF (1 << 16)
#define VC4_DIRTY_SCISSOR (1 << 17)
+#define VC4_DIRTY_FLAT_SHADE_FLAGS (1 << 18)
#define VC4_SHADER_DIRTY_VP (1 << 0)
#define VC4_SHADER_DIRTY_FP (1 << 1)
struct vc4_shader_uniform_info uniforms[2];
uint32_t coord_shader_offset;
+
+ /** bitmask of which inputs are color inputs, for flat shade handling. */
+ uint32_t color_inputs;
+
uint8_t num_inputs;
};
cl_u16(&vc4->bcl, 16 * vc4->viewport.translate[0]);
cl_u16(&vc4->bcl, 16 * vc4->viewport.translate[1]);
}
+
+ if (vc4->dirty & VC4_DIRTY_FLAT_SHADE_FLAGS) {
+ cl_u8(&vc4->bcl, VC4_PACKET_FLAT_SHADE_FLAGS);
+ cl_u32(&vc4->bcl, vc4->rasterizer->base.flatshade ?
+ vc4->prog.fs->color_inputs : 0);
+ }
}
}
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;
}
}
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);
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),
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;
}
vc4_rasterizer_state_bind(struct pipe_context *pctx, void *hwcso)
{
struct vc4_context *vc4 = vc4_context(pctx);
+ struct vc4_rasterizer_state *rast = hwcso;
+
+ if (vc4->rasterizer && rast &&
+ vc4->rasterizer->base.flatshade != rast->base.flatshade) {
+ vc4->dirty |= VC4_DIRTY_FLAT_SHADE_FLAGS;
+ }
+
vc4->rasterizer = hwcso;
vc4->dirty |= VC4_DIRTY_RASTERIZER;
}