diff options
-rw-r--r-- | src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index 5fecad4ea67..0f5b3d9acb7 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -41,6 +41,7 @@ #include "util/u_debug.h" #include "util/u_math.h" #include "util/u_memory.h" +#include "util/u_prim.h" #include "tgsi/tgsi_dump.h" #include "tgsi/tgsi_exec.h" #include "tgsi/tgsi_info.h" @@ -1059,7 +1060,8 @@ emit_mask_scatter(struct lp_build_tgsi_soa_context *bld, static LLVMValueRef get_indirect_index(struct lp_build_tgsi_soa_context *bld, unsigned reg_file, unsigned reg_index, - const struct tgsi_ind_register *indirect_reg) + const struct tgsi_ind_register *indirect_reg, + int index_limit) { LLVMBuilderRef builder = bld->bld_base.base.gallivm->builder; struct lp_build_context *uint_bld = &bld->bld_base.uint_bld; @@ -1106,9 +1108,9 @@ get_indirect_index(struct lp_build_tgsi_soa_context *bld, * larger than the declared size but smaller than the buffer size. */ if (reg_file != TGSI_FILE_CONSTANT) { + assert(index_limit > 0); max_index = lp_build_const_int_vec(bld->bld_base.base.gallivm, - uint_bld->type, - bld->bld_base.info->file_max[reg_file]); + uint_bld->type, index_limit); assert(!uint_bld->type.sign); index = lp_build_min(uint_bld, index, max_index); @@ -1225,7 +1227,8 @@ emit_fetch_constant( indirect_index = get_indirect_index(bld, reg->Register.File, reg->Register.Index, - ®->Indirect); + ®->Indirect, + bld->bld_base.info->file_max[reg->Register.File]); /* All fetches are from the same constant buffer, so * we need to propagate the size to a vector to do a @@ -1364,7 +1367,8 @@ emit_fetch_immediate( indirect_index = get_indirect_index(bld, reg->Register.File, reg->Register.Index, - ®->Indirect); + ®->Indirect, + bld->bld_base.info->file_max[reg->Register.File]); /* * Unlike for other reg classes, adding pixel offsets is unnecessary - * immediates are stored as full vectors (FIXME??? - might be better @@ -1438,7 +1442,8 @@ emit_fetch_input( indirect_index = get_indirect_index(bld, reg->Register.File, reg->Register.Index, - ®->Indirect); + ®->Indirect, + bld->bld_base.info->file_max[reg->Register.File]); index_vec = get_soa_array_offsets(&bld_base->uint_bld, indirect_index, @@ -1524,19 +1529,33 @@ emit_fetch_gs_input( } if (reg->Register.Indirect) { + /* + * XXX: this is possibly not quite the right value, since file_max may be + * larger than the max attrib index, due to it being the max of declared + * inputs AND the max vertices per prim (which is 6 for tri adj). + * It should however be safe to use (since we always allocate + * PIPE_MAX_SHADER_INPUTS (80) for it, which is overallocated quite a bit). + */ + int index_limit = info->file_max[reg->Register.File]; attrib_index = get_indirect_index(bld, reg->Register.File, reg->Register.Index, - ®->Indirect); + ®->Indirect, + index_limit); } else { attrib_index = lp_build_const_int32(gallivm, reg->Register.Index); } if (reg->Dimension.Indirect) { + /* + * A fixed 6 should do as well (which is what we allocate). + */ + int index_limit = u_vertices_per_prim(info->properties[TGSI_PROPERTY_GS_INPUT_PRIM]); vertex_index = get_indirect_index(bld, reg->Register.File, reg->Dimension.Index, - ®->DimIndirect); + ®->DimIndirect, + index_limit); } else { vertex_index = lp_build_const_int32(gallivm, reg->Dimension.Index); } @@ -1591,7 +1610,8 @@ emit_fetch_temporary( indirect_index = get_indirect_index(bld, reg->Register.File, reg->Register.Index, - ®->Indirect); + ®->Indirect, + bld->bld_base.info->file_max[reg->Register.File]); index_vec = get_soa_array_offsets(&bld_base->uint_bld, indirect_index, @@ -1811,7 +1831,8 @@ emit_store_chan( indirect_index = get_indirect_index(bld, reg->Register.File, reg->Register.Index, - ®->Indirect); + ®->Indirect, + bld->bld_base.info->file_max[reg->Register.File]); } else { assert(reg->Register.Index <= bld_base->info->file_max[reg->Register.File]); |