kraid: Add a very dumb message slot assignment pass

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41841>
This commit is contained in:
Faith Ekstrand 2026-05-27 16:02:54 -04:00 committed by Marge Bot
parent 60c3690165
commit d771ba7908
3 changed files with 31 additions and 0 deletions

View file

@ -81,6 +81,10 @@ pub extern "C" fn kraid_compile_nir(
dump_shader(&s, "after register assignment");
s.validate();
s.assign_message_slots();
dump_shader(&s, "after message slot assignment");
s.validate();
let bin = model.encode_shader(&s);
dynarray_append_vec(binary, bin);
}

View file

@ -9,6 +9,7 @@ mod encode_v9;
mod flow;
mod ir;
mod isa;
mod message_slots;
mod model;
mod nir;
mod ops;

View file

@ -0,0 +1,26 @@
// Copyright © 2026 Collabora, Ltd.
// SPDX-License-Identifier: MIT
use crate::flow::FlowWaitBit;
use crate::ir::*;
fn op_is_message(op: &Op) -> bool {
// TODO: Make this real
matches!(
op,
Op::LdPka(_) | Op::LeaPka(_) | Op::Load(_) | Op::Store(_)
)
}
impl Shader<'_> {
pub fn assign_message_slots(&mut self) {
for b in self.blocks.iter_mut() {
for i in b.instrs.iter_mut() {
if op_is_message(&i.op) {
i.flow.set_msg_slot_idx(0);
i.flow.set_wait_bit(FlowWaitBit::Slot0);
}
}
}
}
}