diff options
author | Eric Anholt <[email protected]> | 2014-09-16 12:55:16 -0700 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2014-09-16 13:03:41 -0700 |
commit | 2264925f85f349f57773d46114806a148eae6394 (patch) | |
tree | 9b059661ae394b6e68c4dd164c356be920efc5df | |
parent | aae4223fbd2d94f922339baa11ffefdb88896770 (diff) |
vc4: Add support for computed depth writes.
Fixes piglit glsl-1.10-fragdepth and early-z.
-rw-r--r-- | src/gallium/drivers/vc4/vc4_program.c | 23 | ||||
-rw-r--r-- | src/gallium/drivers/vc4/vc4_qir.c | 3 | ||||
-rw-r--r-- | src/gallium/drivers/vc4/vc4_qir.h | 2 |
3 files changed, 26 insertions, 2 deletions
diff --git a/src/gallium/drivers/vc4/vc4_program.c b/src/gallium/drivers/vc4/vc4_program.c index 8a83913bbe5..a662dc2ce54 100644 --- a/src/gallium/drivers/vc4/vc4_program.c +++ b/src/gallium/drivers/vc4/vc4_program.c @@ -891,6 +891,16 @@ emit_tgsi_declaration(struct vc4_compile *c, case TGSI_FILE_OUTPUT: resize_qreg_array(c, &c->outputs, &c->outputs_array_size, (decl->Range.Last + 1) * 4); + + switch (decl->Semantic.Name) { + case TGSI_SEMANTIC_POSITION: + c->output_position_index = decl->Range.First * 4; + break; + case TGSI_SEMANTIC_COLOR: + c->output_color_index = decl->Range.First * 4; + break; + } + break; } } @@ -1206,7 +1216,9 @@ emit_frag_end(struct vc4_compile *c) c->undef, c->undef, c->undef, c->undef }; vc4_blend(c, blend_color, dst_color, - c->outputs ? c->outputs : undef_array); + (c->output_color_index != -1 ? + c->outputs + c->output_color_index : + undef_array)); /* If the bit isn't set in the color mask, then just return the * original dst color, instead. @@ -1238,7 +1250,14 @@ emit_frag_end(struct vc4_compile *c) qir_TLB_DISCARD_SETUP(c, c->discard); if (c->fs_key->depth_enabled) { - qir_TLB_Z_WRITE(c, qir_FRAG_Z(c)); + struct qreg z; + if (c->output_position_index != -1) { + z = qir_FTOI(c, qir_FMUL(c, c->outputs[c->output_position_index + 2], + qir_uniform_f(c, 0xffffff))); + } else { + z = qir_FRAG_Z(c); + } + qir_TLB_Z_WRITE(c, z); } bool color_written = false; diff --git a/src/gallium/drivers/vc4/vc4_qir.c b/src/gallium/drivers/vc4/vc4_qir.c index 640589d23c0..216abb37828 100644 --- a/src/gallium/drivers/vc4/vc4_qir.c +++ b/src/gallium/drivers/vc4/vc4_qir.c @@ -279,6 +279,9 @@ qir_compile_init(void) make_empty_list(&c->instructions); + c->output_position_index = -1; + c->output_color_index = -1; + return c; } diff --git a/src/gallium/drivers/vc4/vc4_qir.h b/src/gallium/drivers/vc4/vc4_qir.h index f26f8963f34..f3dad5ed67c 100644 --- a/src/gallium/drivers/vc4/vc4_qir.h +++ b/src/gallium/drivers/vc4/vc4_qir.h @@ -227,6 +227,8 @@ struct vc4_compile { uint32_t num_uniforms; uint32_t num_outputs; uint32_t num_texture_samples; + uint32_t output_position_index; + uint32_t output_color_index; struct qreg undef; enum qstage stage; |