diff options
author | Eric Anholt <[email protected]> | 2019-01-02 14:50:20 -0800 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2019-01-04 15:59:30 -0800 |
commit | a74f2aeb4fcc8765571b9120a8c8b13cee59de46 (patch) | |
tree | de6a6488bfbc2c9edb8907d38e08f80b841c6a39 /src/compiler/nir | |
parent | 19c608fe43ae7e1578920326690a361ff1be9d88 (diff) |
nir: Allow nir_format_unpack_int/sint to unpack larger values.
For V3D, I want to unpack 4-16-bit packed integers for 8 and 16-bit
integer samplers.
Reviewed-by: Jason Ekstrand <[email protected]>
Diffstat (limited to 'src/compiler/nir')
-rw-r--r-- | src/compiler/nir/nir_format_convert.h | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/compiler/nir/nir_format_convert.h b/src/compiler/nir/nir_format_convert.h index c5d69ba5a37..bf6dc201a18 100644 --- a/src/compiler/nir/nir_format_convert.h +++ b/src/compiler/nir/nir_format_convert.h @@ -90,19 +90,24 @@ nir_format_unpack_int(nir_builder *b, nir_ssa_def *packed, return packed; } + unsigned next_chan = 0; unsigned offset = 0; for (unsigned i = 0; i < num_components; i++) { assert(bits[i] < bit_size); assert(offset + bits[i] <= bit_size); + nir_ssa_def *chan = nir_channel(b, packed, next_chan); nir_ssa_def *lshift = nir_imm_int(b, bit_size - (offset + bits[i])); nir_ssa_def *rshift = nir_imm_int(b, bit_size - bits[i]); if (sign_extend) - comps[i] = nir_ishr(b, nir_ishl(b, packed, lshift), rshift); + comps[i] = nir_ishr(b, nir_ishl(b, chan, lshift), rshift); else - comps[i] = nir_ushr(b, nir_ishl(b, packed, lshift), rshift); + comps[i] = nir_ushr(b, nir_ishl(b, chan, lshift), rshift); offset += bits[i]; + if (offset >= bit_size) { + next_chan++; + offset -= bit_size; + } } - assert(offset <= bit_size); return nir_vec(b, comps, num_components); } |