} tgsi;
struct tgsi_exec_machine *fs_machine;
+ /** whether early depth testing is enabled */
+ bool early_depth;
/** The primitive drawing context */
struct draw_context *draw;
static unsigned
exec_run( const struct sp_fragment_shader_variant *var,
struct tgsi_exec_machine *machine,
- struct quad_header *quad )
+ struct quad_header *quad,
+ bool early_depth_test )
{
/* Compute X, Y, Z, W vals for this quad */
setup_pos_vector(quad->posCoef,
{
uint j;
- for (j = 0; j < 4; j++)
- quad->output.depth[j] = machine->Outputs[i].xyzw[2].f[j];
+ if (!early_depth_test) {
+ for (j = 0; j < 4; j++)
+ quad->output.depth[j] = machine->Outputs[i].xyzw[2].f[j];
+ }
}
break;
case TGSI_SEMANTIC_STENCIL:
{
uint j;
-
- for (j = 0; j < 4; j++)
- quad->output.stencil[j] = (unsigned)machine->Outputs[i].xyzw[1].u[j];
+ if (!early_depth_test) {
+ for (j = 0; j < 4; j++)
+ quad->output.stencil[j] = (unsigned)machine->Outputs[i].xyzw[1].u[j];
+ }
}
break;
}
{
unsigned i, pass = 0;
const struct tgsi_shader_info *fsInfo = &qs->softpipe->fs_variant->info;
- boolean interp_depth = !fsInfo->writes_z;
+ boolean interp_depth = !fsInfo->writes_z || qs->softpipe->early_depth;
boolean shader_stencil_ref = fsInfo->writes_stencil;
struct depth_data data;
unsigned vp_idx = quads[0]->input.viewport_index;
{
const struct tgsi_shader_info *fsInfo = &qs->softpipe->fs_variant->info;
- boolean interp_depth = !fsInfo->writes_z;
+ boolean interp_depth = !fsInfo->writes_z || qs->softpipe->early_depth;
boolean alpha = qs->softpipe->depth_stencil->alpha.enabled;
/* run shader */
machine->flatshade_color = softpipe->rasterizer->flatshade ? TRUE : FALSE;
- return softpipe->fs_variant->run( softpipe->fs_variant, machine, quad );
+ return softpipe->fs_variant->run( softpipe->fs_variant, machine, quad, softpipe->early_depth );
}
sp_build_quad_pipeline(struct softpipe_context *sp)
{
boolean early_depth_test =
- sp->depth_stencil->depth.enabled &&
+ (sp->depth_stencil->depth.enabled &&
sp->framebuffer.zsbuf &&
!sp->depth_stencil->alpha.enabled &&
!sp->fs_variant->info.uses_kill &&
!sp->fs_variant->info.writes_z &&
- !sp->fs_variant->info.writes_stencil;
+ !sp->fs_variant->info.writes_stencil) ||
+ sp->fs_variant->info.properties[TGSI_PROPERTY_FS_EARLY_DEPTH_STENCIL];
sp->quad.first = sp->quad.blend;
+ sp->early_depth = early_depth_test;
if (early_depth_test) {
insert_stage_at_head( sp, sp->quad.shade );
insert_stage_at_head( sp, sp->quad.depth_test );
unsigned (*run)(const struct sp_fragment_shader_variant *shader,
struct tgsi_exec_machine *machine,
- struct quad_header *quad);
+ struct quad_header *quad,
+ bool early_depth_test);
/* Deletes this instance of the object */
void (*delete)(struct sp_fragment_shader_variant *shader,