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);
}
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
*
uint8_t **color,
void *depth,
uint32_t mask,
- uint32_t *counter,
+ struct lp_jit_thread_data *thread_data,
unsigned *stride);
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;
}
}
- 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);
}
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;
}
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);
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;
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),
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");
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
*/
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)
depth_ptr,
depth_bits,
facing,
- counter);
+ thread_data_ptr);
for (i = 0; i < num_fs; i++) {
LLVMValueRef indexi = lp_build_const_int32(gallivm, i);