From 8e6b925d2a963a2d5a403e106d7d25e3dcca0775 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 10 Sep 2009 11:44:03 +0100 Subject: llvmpipe: Proper control flow builders. New control flow helper functions which keep track of all variables and generate the correct Phi functions. This re-enables skipping the fs execution of quads masked out by the rasterizer, early z testing, and kill opcode. This yields a performance improvement of around 20%. --- src/gallium/drivers/llvmpipe/lp_state_fs.c | 47 ++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 9 deletions(-) (limited to 'src/gallium/drivers/llvmpipe/lp_state_fs.c') diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index 21e675c34e..2e60da60cd 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -197,6 +197,7 @@ generate_fs(struct llvmpipe_context *lp, LLVMValueRef consts_ptr; LLVMValueRef outputs[PIPE_MAX_SHADER_OUTPUTS][NUM_CHANNELS]; LLVMValueRef z = interp->pos[2]; + struct lp_build_flow_context *flow; struct lp_build_mask_context mask; boolean early_depth_test; unsigned attrib; @@ -208,7 +209,33 @@ generate_fs(struct llvmpipe_context *lp, consts_ptr = lp_jit_context_constants(builder, context_ptr); - lp_build_mask_begin(&mask, builder, type, *pmask); + flow = lp_build_flow_create(builder); + + memset(outputs, 0, sizeof outputs); + + lp_build_flow_scope_begin(flow); + + /* Declare the color and z variables */ + for (attrib = 0; attrib < shader->info.num_outputs; ++attrib) { + for(chan = 0; chan < NUM_CHANNELS; ++chan) { + boolean declare = FALSE; + switch (shader->info.output_semantic_name[attrib]) { + case TGSI_SEMANTIC_COLOR: + declare = TRUE; + break; + case TGSI_SEMANTIC_POSITION: + if(chan == 2) + declare = TRUE; + break; + } + if(declare) { + outputs[attrib][chan] = LLVMGetUndef(vec_type); + lp_build_flow_scope_declare(flow, &outputs[attrib][chan]); + } + } + } + + lp_build_mask_begin(&mask, flow, type, *pmask); early_depth_test = key->depth.enabled && @@ -221,12 +248,19 @@ generate_fs(struct llvmpipe_context *lp, type, &mask, z, depth_ptr); - memset(outputs, 0, sizeof outputs); - lp_build_tgsi_soa(builder, tokens, type, &mask, consts_ptr, interp->pos, interp->inputs, outputs, sampler); + if(!early_depth_test) + generate_depth(builder, key, + type, &mask, + z, depth_ptr); + + lp_build_mask_end(&mask); + + lp_build_flow_scope_end(flow); + for (attrib = 0; attrib < shader->info.num_outputs; ++attrib) { for(chan = 0; chan < NUM_CHANNELS; ++chan) { if(outputs[attrib][chan]) { @@ -265,12 +299,7 @@ generate_fs(struct llvmpipe_context *lp, } } - if(!early_depth_test) - generate_depth(builder, key, - type, &mask, - z, depth_ptr); - - lp_build_mask_end(&mask); + lp_build_flow_destroy(flow); *pmask = mask.value; -- cgit v1.2.3