Browse Source

gallium: disable early Z test if fragment shader contains KIL instruction.

Use tgsi_scan_shader() to determine if the fragment shader uses KIL or
writes fragment.z
tags/mesa_20090313
Brian 17 years ago
parent
commit
012391357f

+ 3
- 2
src/gallium/drivers/softpipe/sp_quad.c View File

void void
sp_build_quad_pipeline(struct softpipe_context *sp) sp_build_quad_pipeline(struct softpipe_context *sp)
{ {
boolean early_depth_test =
boolean early_depth_test =
sp->depth_stencil->depth.enabled && sp->depth_stencil->depth.enabled &&
sp->framebuffer.zsbuf && sp->framebuffer.zsbuf &&
!sp->depth_stencil->alpha.enabled && !sp->depth_stencil->alpha.enabled &&
sp->fs->shader.output_semantic_name[0] != TGSI_SEMANTIC_POSITION;
!sp->fs->uses_kill &&
!sp->fs->writes_z;


/* build up the pipeline in reverse order... */ /* build up the pipeline in reverse order... */



+ 3
- 0
src/gallium/drivers/softpipe/sp_state.h View File

struct sp_fragment_shader { struct sp_fragment_shader {
struct pipe_shader_state shader; struct pipe_shader_state shader;


boolean uses_kill;
boolean writes_z;

void (*prepare)( const struct sp_fragment_shader *shader, void (*prepare)( const struct sp_fragment_shader *shader,
struct tgsi_exec_machine *machine, struct tgsi_exec_machine *machine,
struct tgsi_sampler *samplers); struct tgsi_sampler *samplers);

+ 13
- 9
src/gallium/drivers/softpipe/sp_state_fs.c View File

#include "pipe/p_shader_tokens.h" #include "pipe/p_shader_tokens.h"
#include "draw/draw_context.h" #include "draw/draw_context.h"
#include "tgsi/util/tgsi_dump.h" #include "tgsi/util/tgsi_dump.h"
#include "tgsi/util/tgsi_scan.h"




void * void *
{ {
struct softpipe_context *softpipe = softpipe_context(pipe); struct softpipe_context *softpipe = softpipe_context(pipe);
struct sp_fragment_shader *state; struct sp_fragment_shader *state;
struct tgsi_shader_info info;

tgsi_scan_shader(templ->tokens, &info);


if (softpipe->dump_fs) if (softpipe->dump_fs)
tgsi_dump(templ->tokens, 0); tgsi_dump(templ->tokens, 0);


state = softpipe_create_fs_llvm( softpipe, templ ); state = softpipe_create_fs_llvm( softpipe, templ );
if (state)
return state;
state = softpipe_create_fs_sse( softpipe, templ );
if (state)
return state;

state = softpipe_create_fs_exec( softpipe, templ );

if (!state) {
state = softpipe_create_fs_sse( softpipe, templ );
if (!state) {
state = softpipe_create_fs_exec( softpipe, templ );
}
}
assert(state); assert(state);
state->uses_kill = (info.opcode_count[TGSI_OPCODE_KIL] ||
info.opcode_count[TGSI_OPCODE_KILP]);
state->writes_z = info.writes_z;
return state; return state;
} }



Loading…
Cancel
Save