mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-24 17:30:12 +01:00
nak: make sm available in builders
This is needed for the 'sel' builder method, which should emit different instrs on SM50 versus SM75. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26114>
This commit is contained in:
parent
40127e881f
commit
9af7639e4b
5 changed files with 33 additions and 15 deletions
|
|
@ -8,6 +8,8 @@ use crate::ir::*;
|
|||
pub trait Builder {
|
||||
fn push_instr(&mut self, instr: Box<Instr>) -> &mut Instr;
|
||||
|
||||
fn sm(&self) -> u8;
|
||||
|
||||
fn push_op(&mut self, op: impl Into<Op>) -> &mut Instr {
|
||||
self.push_instr(Instr::new_boxed(op))
|
||||
}
|
||||
|
|
@ -381,12 +383,14 @@ pub trait SSABuilder: Builder {
|
|||
|
||||
pub struct InstrBuilder {
|
||||
instrs: MappedInstrs,
|
||||
sm: u8,
|
||||
}
|
||||
|
||||
impl InstrBuilder {
|
||||
pub fn new() -> Self {
|
||||
pub fn new(sm: u8) -> Self {
|
||||
Self {
|
||||
instrs: MappedInstrs::None,
|
||||
sm,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -408,6 +412,10 @@ impl Builder for InstrBuilder {
|
|||
self.instrs.push(instr);
|
||||
self.instrs.last_mut().unwrap().as_mut()
|
||||
}
|
||||
|
||||
fn sm(&self) -> u8 {
|
||||
self.sm
|
||||
}
|
||||
}
|
||||
|
||||
pub struct SSAInstrBuilder<'a> {
|
||||
|
|
@ -416,9 +424,9 @@ pub struct SSAInstrBuilder<'a> {
|
|||
}
|
||||
|
||||
impl<'a> SSAInstrBuilder<'a> {
|
||||
pub fn new(alloc: &'a mut SSAValueAllocator) -> Self {
|
||||
pub fn new(sm: u8, alloc: &'a mut SSAValueAllocator) -> Self {
|
||||
Self {
|
||||
b: InstrBuilder::new(),
|
||||
b: InstrBuilder::new(sm),
|
||||
alloc: alloc,
|
||||
}
|
||||
}
|
||||
|
|
@ -437,6 +445,10 @@ impl<'a> Builder for SSAInstrBuilder<'a> {
|
|||
fn push_instr(&mut self, instr: Box<Instr>) -> &mut Instr {
|
||||
self.b.push_instr(instr)
|
||||
}
|
||||
|
||||
fn sm(&self) -> u8 {
|
||||
self.b.sm()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> SSABuilder for SSAInstrBuilder<'a> {
|
||||
|
|
@ -457,6 +469,10 @@ impl<'a, T: Builder> Builder for PredicatedBuilder<'a, T> {
|
|||
instr.pred = self.pred;
|
||||
self.b.push_instr(instr)
|
||||
}
|
||||
|
||||
fn sm(&self) -> u8 {
|
||||
self.b.sm()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T: SSABuilder> SSABuilder for PredicatedBuilder<'a, T> {
|
||||
|
|
|
|||
|
|
@ -2579,7 +2579,7 @@ impl<'a> ShaderFromNir<'a> {
|
|||
phi_map: &mut PhiAllocMap<'b>,
|
||||
nb: &nir_block,
|
||||
) {
|
||||
let mut b = SSAInstrBuilder::new(ssa_alloc);
|
||||
let mut b = SSAInstrBuilder::new(self.info.sm, ssa_alloc);
|
||||
|
||||
if nb.index == 0 && self.nir.info.shared_size > 0 {
|
||||
// The blob seems to always do a BSYNC before accessing shared
|
||||
|
|
|
|||
|
|
@ -374,18 +374,17 @@ fn legalize_sm70_instr(
|
|||
}
|
||||
|
||||
fn legalize_instr(
|
||||
sm: u8,
|
||||
b: &mut impl SSABuilder,
|
||||
bl: &impl BlockLiveness,
|
||||
ip: usize,
|
||||
instr: &mut Instr,
|
||||
) {
|
||||
if sm >= 70 {
|
||||
if b.sm() >= 70 {
|
||||
legalize_sm70_instr(b, bl, ip, instr);
|
||||
} else if sm >= 50 {
|
||||
} else if b.sm() >= 50 {
|
||||
legalize_sm50_instr(b, bl, ip, instr);
|
||||
} else {
|
||||
panic!("Unknown shader model SM{sm}");
|
||||
panic!("Unknown shader model SM{}", b.sm());
|
||||
}
|
||||
|
||||
let src_types = instr.src_types();
|
||||
|
|
@ -460,6 +459,7 @@ fn legalize_instr(
|
|||
|
||||
impl Shader {
|
||||
pub fn legalize(&mut self) {
|
||||
let sm = self.info.sm;
|
||||
for f in &mut self.functions {
|
||||
let live = SimpleLiveness::for_function(f);
|
||||
|
||||
|
|
@ -468,8 +468,8 @@ impl Shader {
|
|||
|
||||
let mut instrs = Vec::new();
|
||||
for (ip, mut instr) in b.instrs.drain(..).enumerate() {
|
||||
let mut b = SSAInstrBuilder::new(&mut f.ssa_alloc);
|
||||
legalize_instr(self.info.sm, &mut b, bl, ip, &mut instr);
|
||||
let mut b = SSAInstrBuilder::new(sm, &mut f.ssa_alloc);
|
||||
legalize_instr(&mut b, bl, ip, &mut instr);
|
||||
b.push_instr(instr);
|
||||
instrs.append(&mut b.as_vec());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -174,17 +174,18 @@ impl LowerCopySwap {
|
|||
}
|
||||
|
||||
fn run(&mut self, s: &mut Shader) {
|
||||
let sm = s.info.sm;
|
||||
s.map_instrs(|instr: Box<Instr>, _| -> MappedInstrs {
|
||||
match instr.op {
|
||||
Op::Copy(copy) => {
|
||||
debug_assert!(instr.pred.is_true());
|
||||
let mut b = InstrBuilder::new();
|
||||
let mut b = InstrBuilder::new(sm);
|
||||
self.lower_copy(&mut b, copy);
|
||||
b.as_mapped_instrs()
|
||||
}
|
||||
Op::Swap(swap) => {
|
||||
debug_assert!(instr.pred.is_true());
|
||||
let mut b = InstrBuilder::new();
|
||||
let mut b = InstrBuilder::new(sm);
|
||||
self.lower_swap(&mut b, swap);
|
||||
b.as_mapped_instrs()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ fn cycle_use_swap(pc: &OpParCopy, file: RegFile) -> bool {
|
|||
}
|
||||
}
|
||||
|
||||
fn lower_par_copy(pc: OpParCopy) -> MappedInstrs {
|
||||
fn lower_par_copy(pc: OpParCopy, sm: u8) -> MappedInstrs {
|
||||
let mut graph = CopyGraph::new();
|
||||
let mut vals = Vec::new();
|
||||
let mut reg_to_idx = HashMap::new();
|
||||
|
|
@ -138,7 +138,7 @@ fn lower_par_copy(pc: OpParCopy) -> MappedInstrs {
|
|||
}
|
||||
}
|
||||
|
||||
let mut b = InstrBuilder::new();
|
||||
let mut b = InstrBuilder::new(sm);
|
||||
|
||||
let mut ready = Vec::new();
|
||||
for i in 0..pc.dsts_srcs.len() {
|
||||
|
|
@ -254,11 +254,12 @@ fn lower_par_copy(pc: OpParCopy) -> MappedInstrs {
|
|||
|
||||
impl Shader {
|
||||
pub fn lower_par_copies(&mut self) {
|
||||
let sm = self.info.sm;
|
||||
self.map_instrs(|instr, _| -> MappedInstrs {
|
||||
match instr.op {
|
||||
Op::ParCopy(pc) => {
|
||||
assert!(instr.pred.is_true());
|
||||
lower_par_copy(pc)
|
||||
lower_par_copy(pc, sm)
|
||||
}
|
||||
_ => MappedInstrs::One(instr),
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue