diff options
author | Nicolai Hähnle <[email protected]> | 2016-10-09 22:28:30 +0200 |
---|---|---|
committer | Nicolai Hähnle <[email protected]> | 2016-10-13 15:41:11 +0200 |
commit | b234e377650c8280d56060ff38c55af9d7772ee4 (patch) | |
tree | 91218a72d00b2c0ca0b0f3ec3f88b408ea70f88e /src | |
parent | 76a940893de634a50b9149a5f3f37c33fbf4f484 (diff) |
st/glsl_to_tgsi: simplify translate_tex_offset
This fixes a bug with offsets from uniforms which seems to have only been
noticed as a crash in piglit's
arb_gpu_shader5/compiler/builtin-functions/fs-gatherOffset-uniform-offset.frag
on radeonsi.
Cc: [email protected]
Reviewed-by: Ilia Mirkin <[email protected]>
Reviewed-by: Marek Olšák <[email protected]>
Reviewed-by: Dave Airlie <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 64 |
1 files changed, 14 insertions, 50 deletions
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index f721506a160..33c1f877b69 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -5668,60 +5668,24 @@ translate_src(struct st_translate *t, const st_src_reg *src_reg) static struct tgsi_texture_offset translate_tex_offset(struct st_translate *t, - const st_src_reg *in_offset, int idx) + const st_src_reg *in_offset) { struct tgsi_texture_offset offset; - struct ureg_src imm_src; - struct ureg_dst dst; - int array; + struct ureg_src src = translate_src(t, in_offset); - switch (in_offset->file) { - case PROGRAM_IMMEDIATE: - assert(in_offset->index >= 0 && in_offset->index < t->num_immediates); - imm_src = t->immediates[in_offset->index]; - - offset.File = imm_src.File; - offset.Index = imm_src.Index; - offset.SwizzleX = imm_src.SwizzleX; - offset.SwizzleY = imm_src.SwizzleY; - offset.SwizzleZ = imm_src.SwizzleZ; - offset.Padding = 0; - break; - case PROGRAM_INPUT: - imm_src = t->inputs[t->inputMapping[in_offset->index]]; - offset.File = imm_src.File; - offset.Index = imm_src.Index; - offset.SwizzleX = GET_SWZ(in_offset->swizzle, 0); - offset.SwizzleY = GET_SWZ(in_offset->swizzle, 1); - offset.SwizzleZ = GET_SWZ(in_offset->swizzle, 2); - offset.Padding = 0; - break; - case PROGRAM_TEMPORARY: - imm_src = ureg_src(t->temps[in_offset->index]); - offset.File = imm_src.File; - offset.Index = imm_src.Index; - offset.SwizzleX = GET_SWZ(in_offset->swizzle, 0); - offset.SwizzleY = GET_SWZ(in_offset->swizzle, 1); - offset.SwizzleZ = GET_SWZ(in_offset->swizzle, 2); - offset.Padding = 0; - break; - case PROGRAM_ARRAY: - array = in_offset->index >> 16; + offset.File = src.File; + offset.Index = src.Index; + offset.SwizzleX = src.SwizzleX; + offset.SwizzleY = src.SwizzleY; + offset.SwizzleZ = src.SwizzleZ; + offset.Padding = 0; - assert(array >= 0); - assert(array < (int)t->num_temp_arrays); + assert(!src.Indirect); + assert(!src.DimIndirect); + assert(!src.Dimension); + assert(!src.Absolute); /* those shouldn't be used with integers anyway */ + assert(!src.Negate); - dst = t->arrays[array]; - offset.File = dst.File; - offset.Index = dst.Index + (in_offset->index & 0xFFFF) - 0x8000; - offset.SwizzleX = GET_SWZ(in_offset->swizzle, 0); - offset.SwizzleY = GET_SWZ(in_offset->swizzle, 1); - offset.SwizzleZ = GET_SWZ(in_offset->swizzle, 2); - offset.Padding = 0; - break; - default: - break; - } return offset; } @@ -5785,7 +5749,7 @@ compile_tgsi_instruction(struct st_translate *t, ureg_src_indirect(src[num_src], ureg_src(t->address[2])); num_src++; for (i = 0; i < (int)inst->tex_offset_num_offset; i++) { - texoffsets[i] = translate_tex_offset(t, &inst->tex_offsets[i], i); + texoffsets[i] = translate_tex_offset(t, &inst->tex_offsets[i]); } tex_target = st_translate_texture_target(inst->tex_target, inst->tex_shadow); |