mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-06-21 01:38:23 +02:00
kraid: Add a Model::op_is_supported() query
Most of the other queries assert or return a default value if the op itself is unsupported. This gives a clear answer to whether that op is supported at all, which is useful to know as a sanity check, if nothing else. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/42200>
This commit is contained in:
parent
166cea24fb
commit
0f8ad63283
2 changed files with 19 additions and 3 deletions
|
|
@ -805,8 +805,8 @@ impl V9Instr for OpStore {
|
|||
}
|
||||
}
|
||||
|
||||
macro_rules! v9_op_match {
|
||||
($op: expr, |$x: ident| $y: expr) => {
|
||||
macro_rules! v9_op_match_else {
|
||||
($op: expr, |$x: ident| $y: expr, $z: expr) => {
|
||||
match $op {
|
||||
Op::Branch($x) => $y,
|
||||
Op::CSel($x) => $y,
|
||||
|
|
@ -823,15 +823,25 @@ macro_rules! v9_op_match {
|
|||
Op::Nop($x) => $y,
|
||||
Op::ShiftLop($x) => $y,
|
||||
Op::Store($x) => $y,
|
||||
_ => panic!("Unsupported op: {}", $op),
|
||||
_ => $z,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! v9_op_match {
|
||||
($op: expr, |$x: ident| $y: expr) => {
|
||||
v9_op_match_else!($op, |$x| $y, panic!("Unsupported op: {}", $op))
|
||||
};
|
||||
}
|
||||
|
||||
fn v9_op_info(op: &Op, arch: u8) -> Option<&InstructionInfo> {
|
||||
v9_op_match!(op, |op| op.get_info(arch))
|
||||
}
|
||||
|
||||
pub fn v9_op_is_supported(op: &Op, arch: u8) -> bool {
|
||||
v9_op_match_else!(op, |op| op.get_info(arch).is_some(), false)
|
||||
}
|
||||
|
||||
pub fn v9_op_is_message(op: &Op, arch: u8) -> bool {
|
||||
v9_op_info(op, arch).is_some_and(|info| info.is_message)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ pub trait Model {
|
|||
|
||||
fn encode_shader(&self, s: &Shader<'_>) -> Vec<u32>;
|
||||
|
||||
fn op_is_supported(&self, op: &Op) -> bool;
|
||||
|
||||
fn op_is_message(&self, op: &Op) -> bool;
|
||||
|
||||
fn op_src_supports_imm32(&self, op: &Op, src: &Src) -> bool;
|
||||
|
|
@ -39,6 +41,10 @@ impl Model for ValhallModel {
|
|||
encode_v9(s, self.arch)
|
||||
}
|
||||
|
||||
fn op_is_supported(&self, op: &Op) -> bool {
|
||||
op.as_virtual().is_some() || v9_op_is_supported(op, self.arch)
|
||||
}
|
||||
|
||||
fn op_is_message(&self, op: &Op) -> bool {
|
||||
if let Some(vop) = op.as_virtual() {
|
||||
vop.is_message()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue