diff options
author | Michal Krol <[email protected]> | 2007-11-18 18:20:20 +0000 |
---|---|---|
committer | Michal Krol <[email protected]> | 2007-11-18 18:20:20 +0000 |
commit | 7f718f047676e88b660618784f256a96f7e8ed58 (patch) | |
tree | 0e7c6676b64df5394eb0d09073a934cc4bbaa408 /src/mesa/pipe/softpipe/sp_quad.c | |
parent | ca7f68a7cf25a51f382bba8c42d8c6ab7db57b5d (diff) |
Implement early depth test.
Early depth test is enabled when depth test is enabled and
alpha test is disabled and fragment shader does not write
depth.
The early-z is implemented by moving the depth test stage
just before the fragment shader stage and prepending it
with an earlyz stage, introduced with this commit.
The earlyz stage prepares the quad->outputs.depth for
the following depth test stage by interpolating Z position,
just as the fragment shader would do.
Diffstat (limited to 'src/mesa/pipe/softpipe/sp_quad.c')
-rw-r--r-- | src/mesa/pipe/softpipe/sp_quad.c | 70 |
1 files changed, 45 insertions, 25 deletions
diff --git a/src/mesa/pipe/softpipe/sp_quad.c b/src/mesa/pipe/softpipe/sp_quad.c index 429497e9b26..5a0df6de9d3 100644 --- a/src/mesa/pipe/softpipe/sp_quad.c +++ b/src/mesa/pipe/softpipe/sp_quad.c @@ -28,24 +28,52 @@ #include "sp_context.h" +#include "sp_state.h" +#include "pipe/tgsi/exec/tgsi_token.h" +static void +sp_push_quad_first( + struct softpipe_context *sp, + struct quad_stage *quad ) +{ + quad->next = sp->quad.first; + sp->quad.first = quad; +} + +static void +sp_build_depth_stencil( + struct softpipe_context *sp ) +{ + if (sp->depth_stencil->stencil.front_enabled || + sp->depth_stencil->stencil.back_enabled) { + sp_push_quad_first( sp, sp->quad.stencil_test ); + } + else if (sp->depth_stencil->depth.enabled && + sp->framebuffer.zbuf) { + sp_push_quad_first( sp, sp->quad.depth_test ); + } +} void sp_build_quad_pipeline(struct softpipe_context *sp) { + boolean early_depth_test = + sp->depth_stencil->depth.enabled && + sp->framebuffer.zbuf && + !sp->alpha_test->enabled && + sp->fs->shader.output_semantic_name[0] != TGSI_SEMANTIC_POSITION; + /* build up the pipeline in reverse order... */ sp->quad.first = sp->quad.output; if (sp->blend->colormask != 0xf) { - sp->quad.colormask->next = sp->quad.first; - sp->quad.first = sp->quad.colormask; + sp_push_quad_first( sp, sp->quad.colormask ); } if (sp->blend->blend_enable || sp->blend->logicop_enable) { - sp->quad.blend->next = sp->quad.first; - sp->quad.first = sp->quad.blend; + sp_push_quad_first( sp, sp->quad.blend ); } if (sp->framebuffer.num_cbufs == 1) { @@ -54,46 +82,38 @@ sp_build_quad_pipeline(struct softpipe_context *sp) } else { /* insert bufloop stage */ - sp->quad.bufloop->next = sp->quad.first; - sp->quad.first = sp->quad.bufloop; + sp_push_quad_first( sp, sp->quad.bufloop ); } if (sp->depth_stencil->depth.occlusion_count) { - sp->quad.occlusion->next = sp->quad.first; - sp->quad.first = sp->quad.occlusion; + sp_push_quad_first( sp, sp->quad.occlusion ); } if (sp->rasterizer->poly_smooth || sp->rasterizer->line_smooth || sp->rasterizer->point_smooth) { - sp->quad.coverage->next = sp->quad.first; - sp->quad.first = sp->quad.coverage; + sp_push_quad_first( sp, sp->quad.coverage ); } - if ( sp->depth_stencil->stencil.front_enabled - || sp->depth_stencil->stencil.back_enabled) { - sp->quad.stencil_test->next = sp->quad.first; - sp->quad.first = sp->quad.stencil_test; - } - else if (sp->depth_stencil->depth.enabled && - sp->framebuffer.zbuf) { - sp->quad.depth_test->next = sp->quad.first; - sp->quad.first = sp->quad.depth_test; + if (!early_depth_test) { + sp_build_depth_stencil( sp ); } if (sp->alpha_test->enabled) { - sp->quad.alpha_test->next = sp->quad.first; - sp->quad.first = sp->quad.alpha_test; + sp_push_quad_first( sp, sp->quad.alpha_test ); } /* XXX always enable shader? */ if (1) { - sp->quad.shade->next = sp->quad.first; - sp->quad.first = sp->quad.shade; + sp_push_quad_first( sp, sp->quad.shade ); + } + + if (early_depth_test) { + sp_build_depth_stencil( sp ); + sp_push_quad_first( sp, sp->quad.earlyz ); } if (sp->rasterizer->poly_stipple_enable) { - sp->quad.polygon_stipple->next = sp->quad.first; - sp->quad.first = sp->quad.polygon_stipple; + sp_push_quad_first( sp, sp->quad.polygon_stipple ); } } |