nak: Only convert the written portion of the buffer in NirInstrPrinter
Fixes: 02774be708
("nak/sm50: add a memstream abstraction")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29591>
This commit is contained in:

committed by
Marge Bot

parent
70b381e928
commit
944365802f
@@ -32,8 +32,11 @@ impl NirInstrPrinter {
|
||||
unsafe {
|
||||
let stream = self.stream.as_mut().get_unchecked_mut();
|
||||
nak_nir_asprint_instr(stream, instr);
|
||||
let c_str = std::ffi::CStr::from_ptr(stream.buffer);
|
||||
let string = c_str.to_string_lossy().into_owned();
|
||||
let bytes = std::slice::from_raw_parts(
|
||||
stream.buffer as *const u8,
|
||||
stream.written,
|
||||
);
|
||||
let string = String::from_utf8_lossy(bytes).into_owned();
|
||||
nak_clear_memstream(stream);
|
||||
string
|
||||
}
|
||||
|
Reference in New Issue
Block a user