diff options
author | José Fonseca <jfonseca@vmware.com> | 2009-09-10 12:14:53 +0100 |
---|---|---|
committer | José Fonseca <jfonseca@vmware.com> | 2009-09-10 12:14:53 +0100 |
commit | 48f19c0bcdc56d33ef2873eeabe635380764e968 (patch) | |
tree | 8b62e65e045150a9a85bc6e14175a1a04c343820 /src/gallium/drivers/llvmpipe/lp_bld_format_soa.c | |
parent | c3c80c5c22f9ce7fabba90daa5d5142e5fb1c012 (diff) |
llvmpipe: Fix sampling from depth textures. Respect texture compare func.
Fixes Mesa shadowtex sample.
Diffstat (limited to 'src/gallium/drivers/llvmpipe/lp_bld_format_soa.c')
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_bld_format_soa.c | 53 |
1 files changed, 34 insertions, 19 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_format_soa.c b/src/gallium/drivers/llvmpipe/lp_bld_format_soa.c index 36bac06d2e..569e8d10a3 100644 --- a/src/gallium/drivers/llvmpipe/lp_bld_format_soa.c +++ b/src/gallium/drivers/llvmpipe/lp_bld_format_soa.c @@ -83,6 +83,30 @@ lp_build_gather(LLVMBuilderRef builder, } +static LLVMValueRef +lp_build_format_swizzle(union lp_type type, + const LLVMValueRef *inputs, + enum util_format_swizzle swizzle) +{ + switch (swizzle) { + case UTIL_FORMAT_SWIZZLE_X: + case UTIL_FORMAT_SWIZZLE_Y: + case UTIL_FORMAT_SWIZZLE_Z: + case UTIL_FORMAT_SWIZZLE_W: + return inputs[swizzle]; + case UTIL_FORMAT_SWIZZLE_0: + return lp_build_zero(type); + case UTIL_FORMAT_SWIZZLE_1: + return lp_build_one(type); + case UTIL_FORMAT_SWIZZLE_NONE: + return lp_build_undef(type); + default: + assert(0); + return lp_build_undef(type); + } +} + + void lp_build_unpack_rgba_soa(LLVMBuilderRef builder, const struct util_format_description *format_desc, @@ -146,25 +170,16 @@ lp_build_unpack_rgba_soa(LLVMBuilderRef builder, start = stop; } - for (chan = 0; chan < 4; ++chan) { - enum util_format_swizzle swizzle = format_desc->swizzle[chan]; - - switch (swizzle) { - case UTIL_FORMAT_SWIZZLE_X: - case UTIL_FORMAT_SWIZZLE_Y: - case UTIL_FORMAT_SWIZZLE_Z: - case UTIL_FORMAT_SWIZZLE_W: - rgba[chan] = inputs[swizzle]; - break; - case UTIL_FORMAT_SWIZZLE_0: - rgba[chan] = lp_build_zero(type); - break; - case UTIL_FORMAT_SWIZZLE_1: - rgba[chan] = lp_build_one(type); - break; - case UTIL_FORMAT_SWIZZLE_NONE: - rgba[chan] = lp_build_undef(type); - break; + if(format_desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS) { + enum util_format_swizzle swizzle = format_desc->swizzle[0]; + LLVMValueRef depth = lp_build_format_swizzle(type, inputs, swizzle); + rgba[2] = rgba[1] = rgba[0] = depth; + rgba[3] = lp_build_one(type); + } + else { + for (chan = 0; chan < 4; ++chan) { + enum util_format_swizzle swizzle = format_desc->swizzle[chan]; + rgba[chan] = lp_build_format_swizzle(type, inputs, swizzle); } } } |