diff options
author | Eric Anholt <[email protected]> | 2014-09-18 12:22:07 -0700 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2014-09-18 17:46:43 -0700 |
commit | 19589147ef660c0bf7fcc52ca82dfbbadf3a9a23 (patch) | |
tree | 6917d74dcc35a26dd07df2b8a3314a6b37ba418a /src/gallium/drivers/vc4/vc4_program.c | |
parent | 6e39854e23d56e70c5ec68fe97ffce4c5a077183 (diff) |
vc4: Add support for stencil operations.
While depth test state is passed through the fragment shader as sideband,
data, the stencil test state has to be set by the fragment shader itself.
Many tests are still failing, but this gets most of hiz/ passing.
Diffstat (limited to 'src/gallium/drivers/vc4/vc4_program.c')
-rw-r--r-- | src/gallium/drivers/vc4/vc4_program.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/gallium/drivers/vc4/vc4_program.c b/src/gallium/drivers/vc4/vc4_program.c index c6603767b5e..1afb587754b 100644 --- a/src/gallium/drivers/vc4/vc4_program.c +++ b/src/gallium/drivers/vc4/vc4_program.c @@ -53,6 +53,9 @@ struct vc4_fs_key { struct vc4_key base; enum pipe_format color_format; bool depth_enabled; + bool stencil_enabled; + bool stencil_twoside; + bool stencil_full_writemasks; bool is_points; bool is_lines; @@ -1253,6 +1256,16 @@ emit_frag_end(struct vc4_compile *c) if (c->discard.file != QFILE_NULL) qir_TLB_DISCARD_SETUP(c, c->discard); + if (c->fs_key->stencil_enabled) { + qir_TLB_STENCIL_SETUP(c, add_uniform(c, QUNIFORM_STENCIL, 0)); + if (c->fs_key->stencil_twoside) { + qir_TLB_STENCIL_SETUP(c, add_uniform(c, QUNIFORM_STENCIL, 1)); + } + if (c->fs_key->stencil_full_writemasks) { + qir_TLB_STENCIL_SETUP(c, add_uniform(c, QUNIFORM_STENCIL, 2)); + } + } + if (c->fs_key->depth_enabled) { struct qreg z; if (c->output_position_index != -1) { @@ -1567,7 +1580,11 @@ vc4_update_compiled_fs(struct vc4_context *vc4, uint8_t prim_mode) if (vc4->framebuffer.cbufs[0]) key->color_format = vc4->framebuffer.cbufs[0]->format; - key->depth_enabled = vc4->zsa->base.depth.enabled; + key->stencil_enabled = vc4->zsa->stencil_uniforms[0] != 0; + key->stencil_twoside = vc4->zsa->stencil_uniforms[1] != 0; + key->stencil_full_writemasks = vc4->zsa->stencil_uniforms[2] != 0; + key->depth_enabled = (vc4->zsa->base.depth.enabled || + key->stencil_enabled); vc4->prog.fs = util_hash_table_get(vc4->fs_cache, key); if (vc4->prog.fs) @@ -1826,6 +1843,14 @@ vc4_write_uniforms(struct vc4_context *vc4, struct vc4_compiled_shader *shader, cl_f(&vc4->uniforms, vc4->blend_color.color[uinfo->data[i]]); break; + + case QUNIFORM_STENCIL: + cl_u32(&vc4->uniforms, + vc4->zsa->stencil_uniforms[uinfo->data[i]] | + (uinfo->data[i] <= 1 ? + (vc4->stencil_ref.ref_value[uinfo->data[i]] << 8) : + 0)); + break; } #if 0 uint32_t written_val = *(uint32_t *)(vc4->uniforms.next - 4); |