nak: gather instr count explicitly
This isn't as simple as dividing so we want a real shader info property for nvk to consume. Plumb one through. Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Reviewed-by: M Henning <drawoc@darkrefraction.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30136>
This commit is contained in:
committed by
Marge Bot
parent
67e3b3fbfd
commit
4030447dab
@@ -103,6 +103,9 @@ struct nak_shader_info {
|
||||
|
||||
uint8_t _pad0;
|
||||
|
||||
/** Number of instructions used */
|
||||
uint32_t num_instrs;
|
||||
|
||||
/** Size of shader local (scratch) memory */
|
||||
uint32_t slm_size;
|
||||
|
||||
|
||||
@@ -330,7 +330,7 @@ pub extern "C" fn nak_compile_shader(
|
||||
eprintln!("NAK IR:\n{}", &s);
|
||||
}
|
||||
|
||||
s.gather_global_mem_usage();
|
||||
s.gather_info();
|
||||
|
||||
let info = nak_shader_info {
|
||||
stage: nir.info.stage(),
|
||||
@@ -342,6 +342,7 @@ pub extern "C" fn nak_compile_shader(
|
||||
},
|
||||
num_barriers: s.info.num_barriers,
|
||||
_pad0: Default::default(),
|
||||
num_instrs: s.info.num_instrs,
|
||||
slm_size: s.info.slm_size,
|
||||
__bindgen_anon_1: match &s.info.stage {
|
||||
ShaderStageInfo::Compute(cs_info) => {
|
||||
@@ -457,16 +458,9 @@ pub extern "C" fn nak_compile_shader(
|
||||
let c_name = _mesa_shader_stage_to_string(info.stage as u32);
|
||||
CStr::from_ptr(c_name).to_str().expect("Invalid UTF-8")
|
||||
};
|
||||
let instruction_count = if nak.sm >= 70 {
|
||||
code.len() / 4
|
||||
} else if nak.sm >= 50 {
|
||||
(code.len() / 8) * 3
|
||||
} else {
|
||||
unreachable!()
|
||||
};
|
||||
|
||||
eprintln!("Stage: {}", stage_name);
|
||||
eprintln!("Instruction count: {}", instruction_count);
|
||||
eprintln!("Instruction count: {}", info.num_instrs);
|
||||
eprintln!("Num GPRs: {}", info.num_gprs);
|
||||
eprintln!("SLM size: {}", info.slm_size);
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ use std::ops::Index;
|
||||
fn init_info_from_nir(nir: &nir_shader) -> ShaderInfo {
|
||||
ShaderInfo {
|
||||
num_gprs: 0,
|
||||
num_instrs: 0,
|
||||
num_barriers: 0,
|
||||
slm_size: nir.scratch_size,
|
||||
uses_global_mem: false,
|
||||
|
||||
@@ -6239,6 +6239,7 @@ pub enum ShaderIoInfo {
|
||||
pub struct ShaderInfo {
|
||||
pub num_gprs: u8,
|
||||
pub num_barriers: u8,
|
||||
pub num_instrs: u32,
|
||||
pub slm_size: u32,
|
||||
pub uses_global_mem: bool,
|
||||
pub writes_global_mem: bool,
|
||||
@@ -6294,15 +6295,14 @@ impl Shader<'_> {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn gather_global_mem_usage(&mut self) {
|
||||
if let ShaderStageInfo::Compute(_) = self.info.stage {
|
||||
return;
|
||||
}
|
||||
|
||||
pub fn gather_info(&mut self) {
|
||||
let mut num_instrs = 0;
|
||||
let mut uses_global_mem = false;
|
||||
let mut writes_global_mem = false;
|
||||
|
||||
self.for_each_instr(&mut |instr| {
|
||||
num_instrs += 1;
|
||||
|
||||
if !uses_global_mem {
|
||||
uses_global_mem = instr.uses_global_mem();
|
||||
}
|
||||
@@ -6312,6 +6312,7 @@ impl Shader<'_> {
|
||||
}
|
||||
});
|
||||
|
||||
self.info.num_instrs = num_instrs;
|
||||
self.info.uses_global_mem = uses_global_mem;
|
||||
self.info.writes_global_mem = writes_global_mem;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user