kraid: Use instruction info to implement op_is_message()

This was a lot of plumbing but now we know for sure 100% of the time.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41841>
This commit is contained in:
Faith Ekstrand 2026-05-28 16:43:40 -04:00 committed by Marge Bot
parent e644edab7a
commit 2d849e184c
3 changed files with 15 additions and 9 deletions

View file

@ -840,6 +840,14 @@ macro_rules! v9_op_match {
};
}
fn v9_op_info(op: &Op, arch: u8) -> Option<&InstructionInfo> {
v9_op_match!(op, |op| op.get_info(arch))
}
pub fn v9_op_is_message(op: &Op, arch: u8) -> bool {
v9_op_info(op, arch).is_some_and(|info| info.is_message)
}
fn encode_instr(
ip: i64,
instr: &Instr,

View file

@ -4,19 +4,11 @@
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) {
if self.model.op_is_message(&i.op) {
i.flow.set_msg_slot_idx(0);
i.flow.set_wait_bit(FlowWaitBit::Slot0);
}

View file

@ -10,6 +10,8 @@ pub trait Model {
fn encode_shader(&self, s: &Shader<'_>) -> Vec<u32>;
fn op_is_message(&self, op: &Op) -> bool;
fn small_constants(&self) -> &[SmallConstant];
}
@ -35,6 +37,10 @@ impl Model for ValhallModel {
encode_v9(s, self.arch)
}
fn op_is_message(&self, op: &Op) -> bool {
v9_op_is_message(op, self.arch)
}
fn small_constants(&self) -> &[SmallConstant] {
&self.sc_table
}