radeonsi: stop big offsets from hanging the GPU v2
authorChristian König <deathsimple@vodafone.de>
Wed, 29 Aug 2012 08:48:01 +0000 (10:48 +0200)
committerChristian König <deathsimple@vodafone.de>
Tue, 4 Sep 2012 08:51:32 +0000 (10:51 +0200)
v2: rebased of radeon/llvm fix.

Signed-off-by: Christian König <deathsimple@vodafone.de>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
src/gallium/drivers/radeonsi/radeonsi_shader.c

index 9734ab3ad0d134ac5c1793db9d5cb19ba245c360..8c9214933ffee94821468e6e39c63ffd5e34e8a7 100644 (file)
@@ -357,6 +357,7 @@ static LLVMValueRef fetch_constant(
        unsigned swizzle)
 {
        struct lp_build_context * base = &bld_base->base;
+       unsigned idx;
 
        LLVMValueRef const_ptr;
        LLVMValueRef offset;
@@ -376,8 +377,14 @@ static LLVMValueRef fetch_constant(
        /* XXX: This assumes that the constant buffer is not packed, so
         * CONST[0].x will have an offset of 0 and CONST[1].x will have an
         * offset of 4. */
-       offset = lp_build_const_int32(base->gallivm,
-                                       (reg->Register.Index * 4) + swizzle);
+       idx = (reg->Register.Index * 4) + swizzle;
+
+       /* index loads above 255 are currently not supported */
+       if (idx > 255) {
+               assert(0);
+               idx = 0;
+       }
+       offset = lp_build_const_int32(base->gallivm, idx);
 
        load = build_indexed_load(base->gallivm, const_ptr, offset);
        return bitcast(bld_base, type, load);