llvmpipe: asst. clean-up in lp_bld_depth.c
Signed-off-by: Brian Paul <brianp@vmware.com> Reviewed-by: Dave Airlie <airlied@redhat.com> Reviewed-by: Roland Scheidegger <sroland@vmware.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17561>
This commit is contained in:
parent
3b595bf50f
commit
aba7554f39
|
@ -268,14 +268,19 @@ lp_build_stencil_op(struct lp_build_context *bld,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stencil[0].writemask != 0xff ||
|
if (stencil[0].writemask != 0xff ||
|
||||||
(stencil[1].enabled && front_facing != NULL && stencil[1].writemask != 0xff)) {
|
(stencil[1].enabled && front_facing != NULL &&
|
||||||
|
stencil[1].writemask != 0xff)) {
|
||||||
/* mask &= stencil[0].writemask */
|
/* mask &= stencil[0].writemask */
|
||||||
LLVMValueRef writemask = lp_build_const_int_vec(bld->gallivm, bld->type,
|
LLVMValueRef writemask = lp_build_const_int_vec(bld->gallivm, bld->type,
|
||||||
stencil[0].writemask);
|
stencil[0].writemask);
|
||||||
if (stencil[1].enabled && stencil[1].writemask != stencil[0].writemask && front_facing != NULL) {
|
if (stencil[1].enabled &&
|
||||||
LLVMValueRef back_writemask = lp_build_const_int_vec(bld->gallivm, bld->type,
|
stencil[1].writemask != stencil[0].writemask &&
|
||||||
stencil[1].writemask);
|
front_facing != NULL) {
|
||||||
writemask = lp_build_select(bld, front_facing, writemask, back_writemask);
|
LLVMValueRef back_writemask =
|
||||||
|
lp_build_const_int_vec(bld->gallivm, bld->type,
|
||||||
|
stencil[1].writemask);
|
||||||
|
writemask = lp_build_select(bld, front_facing,
|
||||||
|
writemask, back_writemask);
|
||||||
}
|
}
|
||||||
|
|
||||||
mask = LLVMBuildAnd(builder, mask, writemask, "");
|
mask = LLVMBuildAnd(builder, mask, writemask, "");
|
||||||
|
@ -316,7 +321,7 @@ lp_depth_type(const struct util_format_description *format_desc,
|
||||||
assert(z_swizzle == 0);
|
assert(z_swizzle == 0);
|
||||||
assert(format_desc->channel[z_swizzle].size == 32);
|
assert(format_desc->channel[z_swizzle].size == 32);
|
||||||
}
|
}
|
||||||
else if(format_desc->channel[z_swizzle].type == UTIL_FORMAT_TYPE_UNSIGNED) {
|
else if (format_desc->channel[z_swizzle].type == UTIL_FORMAT_TYPE_UNSIGNED) {
|
||||||
assert(format_desc->block.bits <= 32);
|
assert(format_desc->block.bits <= 32);
|
||||||
assert(format_desc->channel[z_swizzle].normalized);
|
assert(format_desc->channel[z_swizzle].normalized);
|
||||||
if (format_desc->channel[z_swizzle].size < format_desc->block.bits) {
|
if (format_desc->channel[z_swizzle].size < format_desc->block.bits) {
|
||||||
|
@ -386,10 +391,7 @@ static boolean
|
||||||
get_s_shift_and_mask(const struct util_format_description *format_desc,
|
get_s_shift_and_mask(const struct util_format_description *format_desc,
|
||||||
unsigned *shift, unsigned *mask)
|
unsigned *shift, unsigned *mask)
|
||||||
{
|
{
|
||||||
unsigned s_swizzle;
|
const unsigned s_swizzle = format_desc->swizzle[1];
|
||||||
unsigned sz;
|
|
||||||
|
|
||||||
s_swizzle = format_desc->swizzle[1];
|
|
||||||
|
|
||||||
if (s_swizzle == PIPE_SWIZZLE_NONE)
|
if (s_swizzle == PIPE_SWIZZLE_NONE)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -404,7 +406,7 @@ get_s_shift_and_mask(const struct util_format_description *format_desc,
|
||||||
}
|
}
|
||||||
|
|
||||||
*shift = format_desc->channel[s_swizzle].shift;
|
*shift = format_desc->channel[s_swizzle].shift;
|
||||||
sz = format_desc->channel[s_swizzle].size;
|
const unsigned sz = format_desc->channel[s_swizzle].size;
|
||||||
*mask = (1U << sz) - 1U;
|
*mask = (1U << sz) - 1U;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -436,7 +438,7 @@ lp_build_occlusion_count(struct gallivm_state *gallivm,
|
||||||
assert(type.length <= 16);
|
assert(type.length <= 16);
|
||||||
assert(type.floating);
|
assert(type.floating);
|
||||||
|
|
||||||
if(util_get_cpu_caps()->has_sse && type.length == 4) {
|
if (util_get_cpu_caps()->has_sse && type.length == 4) {
|
||||||
const char *movmskintr = "llvm.x86.sse.movmsk.ps";
|
const char *movmskintr = "llvm.x86.sse.movmsk.ps";
|
||||||
const char *popcntintr = "llvm.ctpop.i32";
|
const char *popcntintr = "llvm.ctpop.i32";
|
||||||
LLVMValueRef bits = LLVMBuildBitCast(builder, maskvalue,
|
LLVMValueRef bits = LLVMBuildBitCast(builder, maskvalue,
|
||||||
|
@ -447,7 +449,7 @@ lp_build_occlusion_count(struct gallivm_state *gallivm,
|
||||||
LLVMInt32TypeInContext(context), bits);
|
LLVMInt32TypeInContext(context), bits);
|
||||||
count = LLVMBuildZExt(builder, count, LLVMIntTypeInContext(context, 64), "");
|
count = LLVMBuildZExt(builder, count, LLVMIntTypeInContext(context, 64), "");
|
||||||
}
|
}
|
||||||
else if(util_get_cpu_caps()->has_avx && type.length == 8) {
|
else if (util_get_cpu_caps()->has_avx && type.length == 8) {
|
||||||
const char *movmskintr = "llvm.x86.avx.movmsk.ps.256";
|
const char *movmskintr = "llvm.x86.avx.movmsk.ps.256";
|
||||||
const char *popcntintr = "llvm.ctpop.i32";
|
const char *popcntintr = "llvm.ctpop.i32";
|
||||||
LLVMValueRef bits = LLVMBuildBitCast(builder, maskvalue,
|
LLVMValueRef bits = LLVMBuildBitCast(builder, maskvalue,
|
||||||
|
@ -459,7 +461,6 @@ lp_build_occlusion_count(struct gallivm_state *gallivm,
|
||||||
count = LLVMBuildZExt(builder, count, LLVMIntTypeInContext(context, 64), "");
|
count = LLVMBuildZExt(builder, count, LLVMIntTypeInContext(context, 64), "");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
unsigned i;
|
|
||||||
LLVMValueRef countv = LLVMBuildAnd(builder, maskvalue, countmask, "countv");
|
LLVMValueRef countv = LLVMBuildAnd(builder, maskvalue, countmask, "countv");
|
||||||
LLVMTypeRef counttype = LLVMIntTypeInContext(context, type.length * 8);
|
LLVMTypeRef counttype = LLVMIntTypeInContext(context, type.length * 8);
|
||||||
LLVMTypeRef i8vntype = LLVMVectorType(LLVMInt8TypeInContext(context), type.length * 4);
|
LLVMTypeRef i8vntype = LLVMVectorType(LLVMInt8TypeInContext(context), type.length * 4);
|
||||||
|
@ -469,7 +470,7 @@ lp_build_occlusion_count(struct gallivm_state *gallivm,
|
||||||
|
|
||||||
countv = LLVMBuildBitCast(builder, countv, i8vntype, "");
|
countv = LLVMBuildBitCast(builder, countv, i8vntype, "");
|
||||||
|
|
||||||
for (i = 0; i < type.length; i++) {
|
for (unsigned i = 0; i < type.length; i++) {
|
||||||
#if UTIL_ARCH_LITTLE_ENDIAN
|
#if UTIL_ARCH_LITTLE_ENDIAN
|
||||||
shuffles[i] = lp_build_const_int32(gallivm, 4*i);
|
shuffles[i] = lp_build_const_int32(gallivm, 4*i);
|
||||||
#else
|
#else
|
||||||
|
@ -542,20 +543,16 @@ lp_build_depth_stencil_load_swizzled(struct gallivm_state *gallivm,
|
||||||
{
|
{
|
||||||
LLVMBuilderRef builder = gallivm->builder;
|
LLVMBuilderRef builder = gallivm->builder;
|
||||||
LLVMValueRef shuffles[LP_MAX_VECTOR_LENGTH / 4];
|
LLVMValueRef shuffles[LP_MAX_VECTOR_LENGTH / 4];
|
||||||
LLVMValueRef zs_dst1, zs_dst2;
|
|
||||||
LLVMValueRef zs_dst_ptr;
|
|
||||||
LLVMValueRef depth_offset1, depth_offset2;
|
LLVMValueRef depth_offset1, depth_offset2;
|
||||||
LLVMTypeRef load_ptr_type;
|
const unsigned depth_bytes = format_desc->block.bits / 8;
|
||||||
unsigned depth_bytes = format_desc->block.bits / 8;
|
|
||||||
struct lp_type zs_type = lp_depth_type(format_desc, z_src_type.length);
|
struct lp_type zs_type = lp_depth_type(format_desc, z_src_type.length);
|
||||||
struct lp_type zs_load_type = zs_type;
|
|
||||||
|
|
||||||
|
struct lp_type zs_load_type = zs_type;
|
||||||
zs_load_type.length = zs_load_type.length / 2;
|
zs_load_type.length = zs_load_type.length / 2;
|
||||||
|
|
||||||
LLVMTypeRef zs_dst_type = lp_build_vec_type(gallivm, zs_load_type);
|
LLVMTypeRef zs_dst_type = lp_build_vec_type(gallivm, zs_load_type);
|
||||||
load_ptr_type = LLVMPointerType(zs_dst_type, 0);
|
|
||||||
|
|
||||||
if (z_src_type.length == 4) {
|
if (z_src_type.length == 4) {
|
||||||
unsigned i;
|
|
||||||
LLVMValueRef looplsb = LLVMBuildAnd(builder, loop_counter,
|
LLVMValueRef looplsb = LLVMBuildAnd(builder, loop_counter,
|
||||||
lp_build_const_int32(gallivm, 1), "");
|
lp_build_const_int32(gallivm, 1), "");
|
||||||
LLVMValueRef loopmsb = LLVMBuildAnd(builder, loop_counter,
|
LLVMValueRef loopmsb = LLVMBuildAnd(builder, loop_counter,
|
||||||
|
@ -567,7 +564,7 @@ lp_build_depth_stencil_load_swizzled(struct gallivm_state *gallivm,
|
||||||
depth_offset1 = LLVMBuildAdd(builder, depth_offset1, offset2, "");
|
depth_offset1 = LLVMBuildAdd(builder, depth_offset1, offset2, "");
|
||||||
|
|
||||||
/* just concatenate the loaded 2x2 values into 4-wide vector */
|
/* just concatenate the loaded 2x2 values into 4-wide vector */
|
||||||
for (i = 0; i < 4; i++) {
|
for (unsigned i = 0; i < 4; i++) {
|
||||||
shuffles[i] = lp_build_const_int32(gallivm, i);
|
shuffles[i] = lp_build_const_int32(gallivm, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -589,9 +586,12 @@ lp_build_depth_stencil_load_swizzled(struct gallivm_state *gallivm,
|
||||||
depth_offset2 = LLVMBuildAdd(builder, depth_offset1, depth_stride, "");
|
depth_offset2 = LLVMBuildAdd(builder, depth_offset1, depth_stride, "");
|
||||||
|
|
||||||
/* Load current z/stencil values from z/stencil buffer */
|
/* Load current z/stencil values from z/stencil buffer */
|
||||||
zs_dst_ptr = LLVMBuildGEP(builder, depth_ptr, &depth_offset1, 1, "");
|
LLVMTypeRef load_ptr_type = LLVMPointerType(zs_dst_type, 0);
|
||||||
|
LLVMValueRef zs_dst_ptr =
|
||||||
|
LLVMBuildGEP(builder, depth_ptr, &depth_offset1, 1, "");
|
||||||
zs_dst_ptr = LLVMBuildBitCast(builder, zs_dst_ptr, load_ptr_type, "");
|
zs_dst_ptr = LLVMBuildBitCast(builder, zs_dst_ptr, load_ptr_type, "");
|
||||||
zs_dst1 = LLVMBuildLoad2(builder, zs_dst_type, zs_dst_ptr, "");
|
LLVMValueRef zs_dst1 = LLVMBuildLoad2(builder, zs_dst_type, zs_dst_ptr, "");
|
||||||
|
LLVMValueRef zs_dst2;
|
||||||
if (is_1d) {
|
if (is_1d) {
|
||||||
zs_dst2 = lp_build_undef(gallivm, zs_load_type);
|
zs_dst2 = lp_build_undef(gallivm, zs_load_type);
|
||||||
}
|
}
|
||||||
|
@ -619,7 +619,6 @@ lp_build_depth_stencil_load_swizzled(struct gallivm_state *gallivm,
|
||||||
|
|
||||||
else if (format_desc->block.bits > 32) {
|
else if (format_desc->block.bits > 32) {
|
||||||
/* rely on llvm to handle too wide vector we have here nicely */
|
/* rely on llvm to handle too wide vector we have here nicely */
|
||||||
unsigned i;
|
|
||||||
struct lp_type typex2 = zs_type;
|
struct lp_type typex2 = zs_type;
|
||||||
struct lp_type s_type = zs_type;
|
struct lp_type s_type = zs_type;
|
||||||
LLVMValueRef shuffles1[LP_MAX_VECTOR_LENGTH / 4];
|
LLVMValueRef shuffles1[LP_MAX_VECTOR_LENGTH / 4];
|
||||||
|
@ -634,7 +633,7 @@ lp_build_depth_stencil_load_swizzled(struct gallivm_state *gallivm,
|
||||||
tmp = LLVMBuildBitCast(builder, *z_fb,
|
tmp = LLVMBuildBitCast(builder, *z_fb,
|
||||||
lp_build_vec_type(gallivm, typex2), "");
|
lp_build_vec_type(gallivm, typex2), "");
|
||||||
|
|
||||||
for (i = 0; i < zs_type.length; i++) {
|
for (unsigned i = 0; i < zs_type.length; i++) {
|
||||||
shuffles1[i] = lp_build_const_int32(gallivm, i * 2);
|
shuffles1[i] = lp_build_const_int32(gallivm, i * 2);
|
||||||
shuffles2[i] = lp_build_const_int32(gallivm, i * 2 + 1);
|
shuffles2[i] = lp_build_const_int32(gallivm, i * 2 + 1);
|
||||||
}
|
}
|
||||||
|
@ -652,6 +651,7 @@ lp_build_depth_stencil_load_swizzled(struct gallivm_state *gallivm,
|
||||||
lp_build_name(*z_fb, "z_dst");
|
lp_build_name(*z_fb, "z_dst");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Store depth/stencil values.
|
* Store depth/stencil values.
|
||||||
* Incoming values are swizzled (typically n 2x2 quads), stored linear.
|
* Incoming values are swizzled (typically n 2x2 quads), stored linear.
|
||||||
|
@ -718,7 +718,6 @@ lp_build_depth_stencil_write_swizzled(struct gallivm_state *gallivm,
|
||||||
depth_offset1 = LLVMBuildAdd(builder, depth_offset1, offset2, "");
|
depth_offset1 = LLVMBuildAdd(builder, depth_offset1, offset2, "");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
unsigned i;
|
|
||||||
LLVMValueRef loopx2 = LLVMBuildShl(builder, loop_counter,
|
LLVMValueRef loopx2 = LLVMBuildShl(builder, loop_counter,
|
||||||
lp_build_const_int32(gallivm, 1), "");
|
lp_build_const_int32(gallivm, 1), "");
|
||||||
assert(z_src_type.length == 8);
|
assert(z_src_type.length == 8);
|
||||||
|
@ -727,7 +726,7 @@ lp_build_depth_stencil_write_swizzled(struct gallivm_state *gallivm,
|
||||||
* We load 2x4 values, and need to swizzle them (order
|
* We load 2x4 values, and need to swizzle them (order
|
||||||
* 0,1,4,5,2,3,6,7) - not so hot with avx unfortunately.
|
* 0,1,4,5,2,3,6,7) - not so hot with avx unfortunately.
|
||||||
*/
|
*/
|
||||||
for (i = 0; i < 8; i++) {
|
for (unsigned i = 0; i < 8; i++) {
|
||||||
shuffles[i] = lp_build_const_int32(gallivm, (i&1) + (i&2) * 2 + (i&4) / 2);
|
shuffles[i] = lp_build_const_int32(gallivm, (i&1) + (i&2) * 2 + (i&4) / 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -780,10 +779,9 @@ lp_build_depth_stencil_write_swizzled(struct gallivm_state *gallivm,
|
||||||
z_value, s_value, 1);
|
z_value, s_value, 1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
unsigned i;
|
|
||||||
LLVMValueRef shuffles[LP_MAX_VECTOR_LENGTH / 2];
|
LLVMValueRef shuffles[LP_MAX_VECTOR_LENGTH / 2];
|
||||||
assert(z_src_type.length == 8);
|
assert(z_src_type.length == 8);
|
||||||
for (i = 0; i < 8; i++) {
|
for (unsigned i = 0; i < 8; i++) {
|
||||||
shuffles[i*2] = lp_build_const_int32(gallivm, (i&1) + (i&2) * 2 + (i&4) / 2);
|
shuffles[i*2] = lp_build_const_int32(gallivm, (i&1) + (i&2) * 2 + (i&4) / 2);
|
||||||
shuffles[i*2+1] = lp_build_const_int32(gallivm, (i&1) + (i&2) * 2 + (i&4) / 2 +
|
shuffles[i*2+1] = lp_build_const_int32(gallivm, (i&1) + (i&2) * 2 + (i&4) / 2 +
|
||||||
z_src_type.length);
|
z_src_type.length);
|
||||||
|
@ -807,6 +805,7 @@ lp_build_depth_stencil_write_swizzled(struct gallivm_state *gallivm,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate code for performing depth and/or stencil tests.
|
* Generate code for performing depth and/or stencil tests.
|
||||||
* We operate on a vector of values (typically n 2x2 quads).
|
* We operate on a vector of values (typically n 2x2 quads).
|
||||||
|
@ -858,7 +857,7 @@ lp_build_depth_stencil_test(struct gallivm_state *gallivm,
|
||||||
* floats. Setting these bits here will ensure that the lp_build_conv() call
|
* floats. Setting these bits here will ensure that the lp_build_conv() call
|
||||||
* below won't try to unnecessarily clamp the incoming values.
|
* below won't try to unnecessarily clamp the incoming values.
|
||||||
*/
|
*/
|
||||||
if(z_src_type.floating) {
|
if (z_src_type.floating) {
|
||||||
z_src_type.sign = FALSE;
|
z_src_type.sign = FALSE;
|
||||||
z_src_type.norm = TRUE;
|
z_src_type.norm = TRUE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue