diff options
author | Hui Qi Tay <tayhuiqithq@gmail.com> | 2010-09-28 17:52:14 +0100 |
---|---|---|
committer | Keith Whitwell <keithw@vmware.com> | 2010-09-29 10:11:59 +0100 |
commit | 3744d1c7d30543520cede8a6c580f26985978953 (patch) | |
tree | fc73d4e5ca0d83c9998fde9e1511253386c2ea0e | |
parent | 94f65d095a1365b69a041302b473e40c6ccae3c3 (diff) |
draw: added viewport and cliptest flags
Corrections in store_clip to store clip coordinates in AoS form.
Viewport & cliptest flag options based on variant key.
Put back draw_pt_post_vs and now 2 paths based on whether clipping
occurs or not.
-rw-r--r-- | src/gallium/auxiliary/draw/draw_llvm.c | 130 | ||||
-rw-r--r-- | src/gallium/auxiliary/draw/draw_llvm.h | 6 | ||||
-rw-r--r-- | src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c | 12 |
3 files changed, 98 insertions, 50 deletions
diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c index 36254d359c..940b2d7ae5 100644 --- a/src/gallium/auxiliary/draw/draw_llvm.c +++ b/src/gallium/auxiliary/draw/draw_llvm.c @@ -736,10 +736,10 @@ store_clip(LLVMBuilderRef builder, indices[0] = LLVMConstInt(LLVMInt32Type(), 0, 0); indices[1] = LLVMConstInt(LLVMInt32Type(), 0, 0); - out[0] = LLVMBuildLoad(builder, outputs[0][0], ""); /*x0 y0 z0 w0*/ - out[1] = LLVMBuildLoad(builder, outputs[0][1], ""); /*x1 y1 z1 w1*/ - out[2] = LLVMBuildLoad(builder, outputs[0][2], ""); /*x2 y2 z2 w2*/ - out[3] = LLVMBuildLoad(builder, outputs[0][3], ""); /*x3 y3 z3 w3*/ + out[0] = LLVMBuildLoad(builder, outputs[0][0], ""); /*x0 x1 x2 x3*/ + out[1] = LLVMBuildLoad(builder, outputs[0][1], ""); /*y0 y1 y2 y3*/ + out[2] = LLVMBuildLoad(builder, outputs[0][2], ""); /*z0 z1 z2 z3*/ + out[3] = LLVMBuildLoad(builder, outputs[0][3], ""); /*w0 w1 w2 w3*/ io0_ptr = LLVMBuildGEP(builder, io_ptr, &ind0, 1, ""); io1_ptr = LLVMBuildGEP(builder, io_ptr, &ind1, 1, ""); @@ -753,22 +753,22 @@ store_clip(LLVMBuilderRef builder, for (int i = 0; i<4; i++){ clip0_ptr = LLVMBuildGEP(builder, clip_ptr0, - indices, 2, ""); //x1 + indices, 2, ""); //x0 clip1_ptr = LLVMBuildGEP(builder, clip_ptr1, - indices, 2, ""); //y1 + indices, 2, ""); //x1 clip2_ptr = LLVMBuildGEP(builder, clip_ptr2, - indices, 2, ""); //z1 + indices, 2, ""); //x2 clip3_ptr = LLVMBuildGEP(builder, clip_ptr3, - indices, 2, ""); //w1 - - out0elem = LLVMBuildExtractElement(builder, out[0], - indices[1], ""); //x1 - out1elem = LLVMBuildExtractElement(builder, out[1], - indices[1], ""); //y1 - out2elem = LLVMBuildExtractElement(builder, out[2], - indices[1], ""); //z1 - out3elem = LLVMBuildExtractElement(builder, out[3], - indices[1], ""); //w1 + indices, 2, ""); //x3 + + out0elem = LLVMBuildExtractElement(builder, out[i], + ind0, ""); //x0 + out1elem = LLVMBuildExtractElement(builder, out[i], + ind1, ""); //x1 + out2elem = LLVMBuildExtractElement(builder, out[i], + ind2, ""); //x2 + out3elem = LLVMBuildExtractElement(builder, out[i], + ind3, ""); //x3 LLVMBuildStore(builder, out0elem, clip0_ptr); LLVMBuildStore(builder, out1elem, clip1_ptr); @@ -822,7 +822,9 @@ generate_viewport(struct draw_llvm *llvm, */ static LLVMValueRef generate_clipmask(LLVMBuilderRef builder, - LLVMValueRef (*outputs)[NUM_CHANNELS]) + LLVMValueRef (*outputs)[NUM_CHANNELS], + boolean disable_zclipping, + boolean enable_d3dclipping) { LLVMValueRef mask; /* stores the <4xi32> clipmasks */ LLVMValueRef test, temp; @@ -866,22 +868,31 @@ generate_clipmask(LLVMBuilderRef builder, temp = LLVMBuildShl(builder, temp, shift, ""); test = LLVMBuildAnd(builder, test, temp, ""); mask = LLVMBuildOr(builder, mask, test, ""); - - /* plane 5 */ - test = LLVMBuildFAdd(builder, pos_z, pos_w, ""); - test = lp_build_compare(builder, f32_type, PIPE_FUNC_GREATER, zero, test); - temp = LLVMBuildShl(builder, temp, shift, ""); - test = LLVMBuildAnd(builder, test, temp, ""); - mask = LLVMBuildOr(builder, mask, test, ""); - - /* plane 6 */ - test = lp_build_compare(builder, f32_type, PIPE_FUNC_GREATER, pos_z, pos_w); - temp = LLVMBuildShl(builder, temp, shift, ""); - test = LLVMBuildAnd(builder, test, temp, ""); - mask = LLVMBuildOr(builder, mask, test, ""); - + + if (!disable_zclipping){ + if (enable_d3dclipping){ + /* plane 5 */ + test = lp_build_compare(builder, f32_type, PIPE_FUNC_GREATER, zero, pos_z); + temp = LLVMBuildShl(builder, temp, shift, ""); + test = LLVMBuildAnd(builder, test, temp, ""); + mask = LLVMBuildOr(builder, mask, test, ""); + } + else{ + /* plane 5 */ + test = LLVMBuildFAdd(builder, pos_z, pos_w, ""); + test = lp_build_compare(builder, f32_type, PIPE_FUNC_GREATER, zero, test); + temp = LLVMBuildShl(builder, temp, shift, ""); + test = LLVMBuildAnd(builder, test, temp, ""); + mask = LLVMBuildOr(builder, mask, test, ""); + } + /* plane 6 */ + test = lp_build_compare(builder, f32_type, PIPE_FUNC_GREATER, pos_z, pos_w); + temp = LLVMBuildShl(builder, temp, shift, ""); + test = LLVMBuildAnd(builder, test, temp, ""); + mask = LLVMBuildOr(builder, mask, test, ""); + } + return mask; - } /* @@ -930,8 +941,9 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant) LLVMValueRef outputs[PIPE_MAX_SHADER_OUTPUTS][NUM_CHANNELS]; void *code; struct lp_build_sampler_soa *sampler = 0; - LLVMValueRef ret, ret_ptr; + boolean disable_cliptest = variant->key.disable_cliptest; + boolean disable_viewport = variant->key.disable_viewport; arg_types[0] = llvm->context_ptr_type; /* context */ arg_types[1] = llvm->vertex_header_ptr_type; /* vertex_header */ @@ -1040,13 +1052,23 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant) /* store original positions in clip before further manipulation */ store_clip(builder, io, outputs); - /* allocate clipmask, assign it integer type */ - clipmask = generate_clipmask(builder, outputs); - clipmask_bool(builder, clipmask, ret_ptr); + /* do cliptest */ + if (!disable_cliptest){ + /* allocate clipmask, assign it integer type */ + clipmask = generate_clipmask(builder, outputs, + variant->key.disable_zclipping, variant->key.enable_d3dclipping); + /* return clipping boolean value for function */ + clipmask_bool(builder, clipmask, ret_ptr); + } + else{ + clipmask = lp_build_const_int_vec(lp_type_int_vec(32), 0); + } /* do viewport mapping */ - generate_viewport(llvm, builder, outputs); - + if (!disable_viewport){ + generate_viewport(llvm, builder, outputs); + } + /* store clipmask in vertex header and positions in data */ convert_to_aos(builder, io, outputs, clipmask, draw->vs.vertex_shader->info.num_outputs, @@ -1115,6 +1137,8 @@ draw_llvm_generate_elts(struct draw_llvm *llvm, struct draw_llvm_variant *varian void *code; struct lp_build_sampler_soa *sampler = 0; LLVMValueRef ret, ret_ptr; + boolean disable_cliptest = variant->key.disable_cliptest; + boolean disable_viewport = variant->key.disable_viewport; arg_types[0] = llvm->context_ptr_type; /* context */ arg_types[1] = llvm->vertex_header_ptr_type; /* vertex_header */ @@ -1232,13 +1256,23 @@ draw_llvm_generate_elts(struct draw_llvm *llvm, struct draw_llvm_variant *varian /* store original positions in clip before further manipulation */ store_clip(builder, io, outputs); - /* allocate clipmask, assign it integer type */ - clipmask = generate_clipmask(builder, outputs); - clipmask_bool(builder, clipmask, ret_ptr); - - /* do viewport mapping */ - generate_viewport(llvm, builder, outputs); + /* do cliptest */ + if (!disable_cliptest){ + /* allocate clipmask, assign it integer type */ + clipmask = generate_clipmask(builder, outputs, + variant->key.disable_zclipping, variant->key.enable_d3dclipping); + /* return clipping boolean value for function */ + clipmask_bool(builder, clipmask, ret_ptr); + } + else{ + clipmask = lp_build_const_int_vec(lp_type_int_vec(32), 0); + } + /* do viewport mapping */ + if (!disable_viewport){ + generate_viewport(llvm, builder, outputs); + } + /* store clipmask in vertex header, * original positions in clip * and transformed positions in data @@ -1303,6 +1337,12 @@ draw_llvm_make_variant_key(struct draw_llvm *llvm, char *store) */ key->nr_vertex_elements = llvm->draw->pt.nr_vertex_elements; + /* will have to rig this up properly later */ + key->disable_cliptest = 0; + key->disable_viewport = 0; + key->disable_zclipping = 0; + key->enable_d3dclipping = 0; + /* All variants of this shader will have the same value for * nr_samplers. Not yet trying to compact away holes in the * sampler array. diff --git a/src/gallium/auxiliary/draw/draw_llvm.h b/src/gallium/auxiliary/draw/draw_llvm.h index 1142ea51cf..8ff366956c 100644 --- a/src/gallium/auxiliary/draw/draw_llvm.h +++ b/src/gallium/auxiliary/draw/draw_llvm.h @@ -160,7 +160,11 @@ typedef int struct draw_llvm_variant_key { unsigned nr_vertex_elements:16; - unsigned nr_samplers:16; + unsigned nr_samplers:12; + unsigned disable_cliptest:1; + unsigned disable_viewport:1; + unsigned disable_zclipping:1; + unsigned enable_d3dclipping:1; /* Variable number of vertex elements: */ diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c index 77291e304e..dc138b980d 100644 --- a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c +++ b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c @@ -217,6 +217,7 @@ llvm_pipeline_generic( struct draw_pt_middle_end *middle, struct draw_vertex_info gs_vert_info; struct draw_vertex_info *vert_info; unsigned opt = fpme->opt; + unsigned clipped = 0; llvm_vert_info.count = fetch_info->count; llvm_vert_info.vertex_size = fpme->vertex_size; @@ -230,7 +231,7 @@ llvm_pipeline_generic( struct draw_pt_middle_end *middle, } if (fetch_info->linear) - fpme->current_variant->jit_func( &fpme->llvm->jit_context, + clipped = fpme->current_variant->jit_func( &fpme->llvm->jit_context, llvm_vert_info.verts, (const char **)draw->pt.user.vbuffer, fetch_info->start, @@ -239,7 +240,7 @@ llvm_pipeline_generic( struct draw_pt_middle_end *middle, draw->pt.vertex_buffer, draw->instance_id); else - fpme->current_variant->jit_func_elts( &fpme->llvm->jit_context, + clipped = fpme->current_variant->jit_func_elts( &fpme->llvm->jit_context, llvm_vert_info.verts, (const char **)draw->pt.user.vbuffer, fetch_info->elts, @@ -266,6 +267,9 @@ llvm_pipeline_generic( struct draw_pt_middle_end *middle, FREE(vert_info->verts); vert_info = &gs_vert_info; prim_info = &gs_prim_info; + + clipped = draw_pt_post_vs_run( fpme->post_vs, vert_info ); + } /* stream output needs to be done before clipping */ @@ -273,11 +277,11 @@ llvm_pipeline_generic( struct draw_pt_middle_end *middle, vert_info, prim_info ); - if (draw_pt_post_vs_run( fpme->post_vs, vert_info )) { + if (clipped) { opt |= PT_PIPELINE; } - /* Do we need to run the pipeline? + /* Do we need to run the pipeline? Now will come here if clipped */ if (opt & PT_PIPELINE) { pipeline( fpme, |