llvmpipe: use 64bit counter for occlusion queries

Some APIs require 64bit and at least for 64bit archs the overhead
should be minimal.

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
This commit is contained in:
Roland Scheidegger 2013-06-19 23:42:28 +02:00
parent dc5dc4fd94
commit 5c9aee111e
3 changed files with 10 additions and 5 deletions

View File

@ -429,7 +429,7 @@ get_s_shift_and_mask(const struct util_format_description *format_desc,
* Test the depth mask. Add the number of channel which has none zero mask
* into the occlusion counter. e.g. maskvalue is {-1, -1, -1, -1}.
* The counter will add 4.
* TODO: could get that out of the loop, and need to use 64bit counter.
* TODO: could get that out of the fs loop.
*
* \param type holds element type of the mask vector.
* \param maskvalue is the depth test mask.
@ -458,6 +458,7 @@ lp_build_occlusion_count(struct gallivm_state *gallivm,
LLVMInt32TypeInContext(context), bits);
count = lp_build_intrinsic_unary(builder, popcntintr,
LLVMInt32TypeInContext(context), bits);
count = LLVMBuildZExt(builder, count, LLVMIntTypeInContext(context, 64), "");
}
else if(util_cpu_caps.has_avx && type.length == 8) {
const char *movmskintr = "llvm.x86.avx.movmsk.ps.256";
@ -468,6 +469,7 @@ lp_build_occlusion_count(struct gallivm_state *gallivm,
LLVMInt32TypeInContext(context), bits);
count = lp_build_intrinsic_unary(builder, popcntintr,
LLVMInt32TypeInContext(context), bits);
count = LLVMBuildZExt(builder, count, LLVMIntTypeInContext(context, 64), "");
}
else {
unsigned i;
@ -510,8 +512,11 @@ lp_build_occlusion_count(struct gallivm_state *gallivm,
}
count = lp_build_intrinsic_unary(builder, popcntintr, counttype, countd);
if (type.length > 4) {
count = LLVMBuildTrunc(builder, count, LLVMIntTypeInContext(context, 32), "");
if (type.length > 8) {
count = LLVMBuildTrunc(builder, count, LLVMIntTypeInContext(context, 64), "");
}
else if (type.length < 8) {
count = LLVMBuildZExt(builder, count, LLVMIntTypeInContext(context, 64), "");
}
}
newcount = LLVMBuildLoad(builder, counter, "origcount");

View File

@ -195,7 +195,7 @@ lp_jit_create_types(struct lp_fragment_shader_variant *lp)
LLVMTypeRef elem_types[LP_JIT_THREAD_DATA_COUNT];
LLVMTypeRef thread_data_type;
elem_types[LP_JIT_THREAD_DATA_COUNTER] = LLVMInt32TypeInContext(lc);
elem_types[LP_JIT_THREAD_DATA_COUNTER] = LLVMInt64TypeInContext(lc);
thread_data_type = LLVMStructTypeInContext(lc, elem_types,
Elements(elem_types), 0);

View File

@ -164,7 +164,7 @@ enum {
struct lp_jit_thread_data
{
uint32_t vis_counter;
uint64_t vis_counter;
};