diff options
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_jit.c | 19 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_jit.h | 18 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_rast.c | 8 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_rast_priv.h | 6 | ||||
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_state_fs.c | 25 |
5 files changed, 56 insertions, 20 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_jit.c b/src/gallium/drivers/llvmpipe/lp_jit.c index d0a791671e6..f517b67fff6 100644 --- a/src/gallium/drivers/llvmpipe/lp_jit.c +++ b/src/gallium/drivers/llvmpipe/lp_jit.c @@ -190,6 +190,25 @@ lp_jit_create_types(struct lp_fragment_shader_variant *lp) lp->jit_context_ptr_type = LLVMPointerType(context_type, 0); } + /* struct lp_jit_thread_data */ + { + LLVMTypeRef elem_types[LP_JIT_THREAD_DATA_COUNT]; + LLVMTypeRef thread_data_type; + + elem_types[LP_JIT_THREAD_DATA_COUNTER] = LLVMInt32TypeInContext(lc); + + thread_data_type = LLVMStructTypeInContext(lc, elem_types, + Elements(elem_types), 0); + +#if HAVE_LLVM < 0x0300 + LLVMInvalidateStructLayout(gallivm->target, thread_data_type); + + LLVMAddTypeName(gallivm->module, "thread_data", thread_data_type); +#endif + + lp->jit_thread_data_ptr_type = LLVMPointerType(thread_data_type, 0); + } + if (gallivm_debug & GALLIVM_DEBUG_IR) { LLVMDumpModule(gallivm->module); } diff --git a/src/gallium/drivers/llvmpipe/lp_jit.h b/src/gallium/drivers/llvmpipe/lp_jit.h index 3057c0dc2b0..472d3911e71 100644 --- a/src/gallium/drivers/llvmpipe/lp_jit.h +++ b/src/gallium/drivers/llvmpipe/lp_jit.h @@ -162,6 +162,22 @@ enum { lp_build_struct_get_ptr(_gallivm, _ptr, LP_JIT_CTX_SAMPLERS, "samplers") +struct lp_jit_thread_data +{ + uint32_t vis_counter; +}; + + +enum { + LP_JIT_THREAD_DATA_COUNTER = 0, + LP_JIT_THREAD_DATA_COUNT +}; + + +#define lp_jit_thread_data_counter(_gallivm, _ptr) \ + lp_build_struct_get_ptr(_gallivm, _ptr, LP_JIT_THREAD_DATA_COUNTER, "counter") + + /** * typedef for fragment shader function * @@ -189,7 +205,7 @@ typedef void uint8_t **color, void *depth, uint32_t mask, - uint32_t *counter, + struct lp_jit_thread_data *thread_data, unsigned *stride); diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c b/src/gallium/drivers/llvmpipe/lp_rast.c index 2daf2fefa26..09c578769bc 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast.c +++ b/src/gallium/drivers/llvmpipe/lp_rast.c @@ -386,7 +386,7 @@ lp_rast_shade_tile(struct lp_rasterizer_task *task, color, depth, 0xffff, - &task->vis_counter, + &task->thread_data, stride); END_JIT_CALL(); } @@ -469,7 +469,7 @@ lp_rast_shade_quads_mask(struct lp_rasterizer_task *task, color, depth, mask, - &task->vis_counter, + &task->thread_data, stride); END_JIT_CALL(); } @@ -491,7 +491,7 @@ lp_rast_begin_query(struct lp_rasterizer_task *task, switch (pq->type) { case PIPE_QUERY_OCCLUSION_COUNTER: - task->vis_counter = 0; + task->thread_data.vis_counter = 0; break; case PIPE_QUERY_PRIMITIVES_GENERATED: case PIPE_QUERY_PRIMITIVES_EMITTED: @@ -519,7 +519,7 @@ lp_rast_end_query(struct lp_rasterizer_task *task, switch (pq->type) { case PIPE_QUERY_OCCLUSION_COUNTER: - pq->count[task->thread_index] += task->vis_counter; + pq->count[task->thread_index] += task->thread_data.vis_counter; break; case PIPE_QUERY_TIMESTAMP: pq->count[task->thread_index] = os_time_get_nano(); diff --git a/src/gallium/drivers/llvmpipe/lp_rast_priv.h b/src/gallium/drivers/llvmpipe/lp_rast_priv.h index afcf33382f4..5db8fcd19b2 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast_priv.h +++ b/src/gallium/drivers/llvmpipe/lp_rast_priv.h @@ -94,8 +94,8 @@ struct lp_rasterizer_task /** "my" index */ unsigned thread_index; - /* occlude counter for visiable pixels */ - uint32_t vis_counter; + /* occlude counter for visible pixels */ + struct lp_jit_thread_data thread_data; uint64_t query_start; struct llvmpipe_query *query[PIPE_QUERY_TYPES]; @@ -276,7 +276,7 @@ lp_rast_shade_quads_all( struct lp_rasterizer_task *task, color, depth, 0xffff, - &task->vis_counter, + &task->thread_data, stride ); END_JIT_CALL(); } diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index 00f3b6990e3..90a67e62b85 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -233,7 +233,7 @@ generate_fs(struct gallivm_state *gallivm, LLVMValueRef facing, unsigned partial_mask, LLVMValueRef mask_input, - LLVMValueRef counter) + LLVMValueRef thread_data_ptr) { const struct util_format_description *zs_format_desc = NULL; const struct tgsi_token *tokens = shader->base.tokens; @@ -431,9 +431,12 @@ generate_fs(struct gallivm_state *gallivm, } } - if (counter) + if (key->occlusion_count) { + LLVMValueRef counter = lp_jit_thread_data_counter(gallivm, thread_data_ptr); + lp_build_name(counter, "counter"); lp_build_occlusion_count(gallivm, type, lp_build_mask_value(&mask), counter); + } *pmask = lp_build_mask_end(&mask); } @@ -457,7 +460,7 @@ generate_fs_loop(struct gallivm_state *gallivm, LLVMValueRef depth_ptr, unsigned depth_bits, LLVMValueRef facing, - LLVMValueRef counter) + LLVMValueRef thread_data_ptr) { const struct util_format_description *zs_format_desc = NULL; const struct tgsi_token *tokens = shader->base.tokens; @@ -674,6 +677,7 @@ generate_fs_loop(struct gallivm_state *gallivm, } if (key->occlusion_count) { + LLVMValueRef counter = lp_jit_thread_data_counter(gallivm, thread_data_ptr); lp_build_name(counter, "counter"); lp_build_occlusion_count(gallivm, type, lp_build_mask_value(&mask), counter); @@ -1767,7 +1771,7 @@ generate_fragment(struct llvmpipe_context *lp, LLVMValueRef stride_ptr; LLVMValueRef depth_ptr; LLVMValueRef mask_input; - LLVMValueRef counter = NULL; + LLVMValueRef thread_data_ptr; LLVMBasicBlockRef block; LLVMBuilderRef builder; struct lp_build_sampler_soa *sampler; @@ -1848,7 +1852,7 @@ generate_fragment(struct llvmpipe_context *lp, arg_types[7] = LLVMPointerType(LLVMPointerType(blend_vec_type, 0), 0); /* color */ arg_types[8] = LLVMPointerType(int8_type, 0); /* depth */ arg_types[9] = int32_type; /* mask_input */ - arg_types[10] = LLVMPointerType(int32_type, 0); /* counter */ + arg_types[10] = variant->jit_thread_data_ptr_type; /* per thread data */ arg_types[11] = LLVMPointerType(int32_type, 0); /* stride */ func_type = LLVMFunctionType(LLVMVoidTypeInContext(gallivm->context), @@ -1876,6 +1880,7 @@ generate_fragment(struct llvmpipe_context *lp, color_ptr_ptr = LLVMGetParam(function, 7); depth_ptr = LLVMGetParam(function, 8); mask_input = LLVMGetParam(function, 9); + thread_data_ptr = LLVMGetParam(function, 10); stride_ptr = LLVMGetParam(function, 11); lp_build_name(context_ptr, "context"); @@ -1886,14 +1891,10 @@ generate_fragment(struct llvmpipe_context *lp, lp_build_name(dady_ptr, "dady"); lp_build_name(color_ptr_ptr, "color_ptr_ptr"); lp_build_name(depth_ptr, "depth"); + lp_build_name(thread_data_ptr, "thread_data"); lp_build_name(mask_input, "mask_input"); lp_build_name(stride_ptr, "stride_ptr"); - if (key->occlusion_count) { - counter = LLVMGetParam(function, 10); - lp_build_name(counter, "counter"); - } - /* * Function body */ @@ -1947,7 +1948,7 @@ generate_fragment(struct llvmpipe_context *lp, facing, partial_mask, mask_input, - counter); + thread_data_ptr); for (cbuf = 0; cbuf < key->nr_cbufs; cbuf++) for (chan = 0; chan < TGSI_NUM_CHANNELS; ++chan) @@ -2006,7 +2007,7 @@ generate_fragment(struct llvmpipe_context *lp, depth_ptr, depth_bits, facing, - counter); + thread_data_ptr); for (i = 0; i < num_fs; i++) { LLVMValueRef indexi = lp_build_const_int32(gallivm, i); |