radeon/llvm: add support for non-scalar system values
authorMarek Olšák <marek.olsak@amd.com>
Tue, 6 May 2014 11:57:31 +0000 (13:57 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Sat, 10 May 2014 11:58:46 +0000 (13:58 +0200)
The sample position is one of them.

Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c

index 60ade78b5f220d020e32262276ca40471ac01415..f8be0df94cf3fd05c833321721cb172125cc8925 100644 (file)
@@ -218,7 +218,13 @@ static LLVMValueRef fetch_system_value(
        unsigned swizzle)
 {
        struct radeon_llvm_context * ctx = radeon_llvm_context(bld_base);
+       struct gallivm_state *gallivm = bld_base->base.gallivm;
+
        LLVMValueRef cval = ctx->system_values[reg->Register.Index];
+       if (LLVMGetTypeKind(LLVMTypeOf(cval)) == LLVMVectorTypeKind) {
+               cval = LLVMBuildExtractElement(gallivm->builder, cval,
+                                              lp_build_const_int32(gallivm, swizzle), "");
+       }
        return bitcast(bld_base, type, cval);
 }