ac/nir: support lowering of sub-dword push constants
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com> Reviewed-by: Marek Olšák <marek.olsak@amd.com> Reviewed-by: Daniel Schürmann <daniel@schuermann.dev> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29480>
This commit is contained in:
@@ -52,6 +52,10 @@ lower_subdword_loads(nir_builder *b, nir_instr *instr, void *data)
|
||||
if (!(modes & nir_var_mem_global))
|
||||
return false;
|
||||
break;
|
||||
case nir_intrinsic_load_push_constant:
|
||||
if (!(modes & nir_var_mem_push_const))
|
||||
return false;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@@ -93,6 +97,13 @@ lower_subdword_loads(nir_builder *b, nir_instr *instr, void *data)
|
||||
return true;
|
||||
}
|
||||
|
||||
b->cursor = nir_before_instr(instr);
|
||||
|
||||
if (nir_intrinsic_has_base(intr)) {
|
||||
offset = nir_iadd_imm(b, offset, nir_intrinsic_base(intr));
|
||||
nir_intrinsic_set_base(intr, 0);
|
||||
}
|
||||
|
||||
/* Multi-component unaligned loads may straddle the dword boundary.
|
||||
* E.g. for 2 components, we need to load an extra dword, and so on.
|
||||
*/
|
||||
@@ -114,7 +125,6 @@ lower_subdword_loads(nir_builder *b, nir_instr *instr, void *data)
|
||||
/* There is a good probability that the offset is "iadd" adding
|
||||
* align_offset. Subtracting align_offset should eliminate it.
|
||||
*/
|
||||
b->cursor = nir_before_instr(instr);
|
||||
nir_src_rewrite(src_offset, nir_iadd_imm(b, offset, -align_offset));
|
||||
|
||||
b->cursor = nir_after_instr(instr);
|
||||
@@ -132,7 +142,6 @@ lower_subdword_loads(nir_builder *b, nir_instr *instr, void *data)
|
||||
assert(align_mul <= 2 && align_offset <= 3);
|
||||
|
||||
/* Round down by masking out the bits. */
|
||||
b->cursor = nir_before_instr(instr);
|
||||
nir_src_rewrite(src_offset, nir_iand_imm(b, offset, ~0x3));
|
||||
|
||||
/* We need to shift bits in the loaded vector by this number. */
|
||||
|
Reference in New Issue
Block a user