mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 00:58:05 +02:00
rusticl/compiler: Add NirPrintfInfo
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23898>
This commit is contained in:
parent
e3169f624d
commit
11729e8311
1 changed files with 55 additions and 0 deletions
|
|
@ -40,6 +40,33 @@ impl<'a, T: 'a> Iterator for ExecListIter<'a, T> {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct NirPrintfInfo {
|
||||
count: usize,
|
||||
printf_info: *mut u_printf_info,
|
||||
}
|
||||
|
||||
impl NirPrintfInfo {
|
||||
pub fn u_printf(&self, buf: &[u8]) {
|
||||
unsafe {
|
||||
u_printf(
|
||||
stdout_ptr(),
|
||||
buf.as_ptr().cast(),
|
||||
buf.len(),
|
||||
self.printf_info.cast(),
|
||||
self.count as u32,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for NirPrintfInfo {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
ralloc_free(self.printf_info.cast());
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
pub struct NirShader {
|
||||
nir: NonNull<nir_shader>,
|
||||
}
|
||||
|
|
@ -266,6 +293,34 @@ impl NirShader {
|
|||
&[]
|
||||
}
|
||||
}
|
||||
pub fn take_printf_info(&mut self) -> Option<NirPrintfInfo> {
|
||||
let nir = unsafe { self.nir.as_mut() };
|
||||
|
||||
let info = nir.printf_info;
|
||||
if info.is_null() {
|
||||
return None;
|
||||
}
|
||||
let count = nir.printf_info_count as usize;
|
||||
|
||||
unsafe {
|
||||
ralloc_steal(ptr::null(), info.cast());
|
||||
|
||||
for i in 0..count {
|
||||
ralloc_steal(info.cast(), (*info.add(i)).arg_sizes.cast());
|
||||
ralloc_steal(info.cast(), (*info.add(i)).strings.cast());
|
||||
}
|
||||
};
|
||||
|
||||
let result = Some(NirPrintfInfo {
|
||||
count: count,
|
||||
printf_info: info,
|
||||
});
|
||||
|
||||
nir.printf_info_count = 0;
|
||||
nir.printf_info = ptr::null_mut();
|
||||
|
||||
result
|
||||
}
|
||||
|
||||
pub fn get_constant_buffer(&self) -> &[u8] {
|
||||
unsafe {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue