mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-29 07:20:23 +01:00
Switch NAK to it. Signed-off-by: Christian Gmeiner <cgmeiner@igalia.com> Reviewed-by: M Henning <drawoc@darkrefraction.com> Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31706>
27 lines
671 B
Rust
27 lines
671 B
Rust
// Copyright © 2024 Collabora, Ltd.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
use std::io;
|
|
|
|
use crate::bindings;
|
|
use crate::bindings::nir_instr;
|
|
use crate::memstream::MemStream;
|
|
|
|
/// A memstream that holds the printed NIR instructions.
|
|
pub struct NirInstrPrinter {
|
|
stream: MemStream,
|
|
}
|
|
|
|
impl NirInstrPrinter {
|
|
pub fn new() -> io::Result<Self> {
|
|
Ok(Self {
|
|
stream: MemStream::new()?,
|
|
})
|
|
}
|
|
|
|
/// Prints the given NIR instruction.
|
|
pub fn instr_to_string(&mut self, instr: &nir_instr) -> io::Result<String> {
|
|
unsafe { bindings::nir_print_instr(instr, self.stream.c_file()) };
|
|
self.stream.take_utf8_string_lossy()
|
|
}
|
|
}
|