From c4c9bfdebd86dce4ce91e1b9a57435871d35c827 Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Thu, 18 Jul 2024 11:11:50 -0500 Subject: [PATCH] nak: Drop the nvfuzz binary A much better version now exists as part of https://gitlab.freedesktop.org/gfxstrand/nv-shader-tools Part-of: --- .gitlab-ci/test/gitlab-ci.yml | 1 - src/nouveau/compiler/meson.build | 10 --- src/nouveau/compiler/nvfuzz/main.rs | 107 ---------------------------- 3 files changed, 118 deletions(-) delete mode 100644 src/nouveau/compiler/nvfuzz/main.rs diff --git a/.gitlab-ci/test/gitlab-ci.yml b/.gitlab-ci/test/gitlab-ci.yml index f2fa4760428..8816abf0c50 100644 --- a/.gitlab-ci/test/gitlab-ci.yml +++ b/.gitlab-ci/test/gitlab-ci.yml @@ -41,7 +41,6 @@ rustfmt: - shopt -s globstar - rustfmt --version - rustfmt --verbose src/**/lib.rs - - rustfmt --verbose src/**/main.rs python-test: # Cancel job if a newer commit is pushed to the same branch diff --git a/src/nouveau/compiler/meson.build b/src/nouveau/compiler/meson.build index a049cb526b7..a9fbb15656f 100644 --- a/src/nouveau/compiler/meson.build +++ b/src/nouveau/compiler/meson.build @@ -172,16 +172,6 @@ _libnak = static_library( gnu_symbol_visibility : 'hidden', ) -if with_tools.contains('nouveau') - executable( - 'nvfuzz', - files('nvfuzz/main.rs'), - rust_crate_type : 'bin', - link_with: [_libbitview_rs], - install : true - ) -endif - idep_nak = declare_dependency( include_directories : include_directories('.'), link_with : _libnak, diff --git a/src/nouveau/compiler/nvfuzz/main.rs b/src/nouveau/compiler/nvfuzz/main.rs deleted file mode 100644 index c8e73d84cfd..00000000000 --- a/src/nouveau/compiler/nvfuzz/main.rs +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright © 2022 Collabora, Ltd. - * SPDX-License-Identifier: MIT - */ - -extern crate bitview; - -use crate::bitview::*; - -use std::fs; -use std::io::Write; -use std::ops::Range; -use std::path::PathBuf; -use std::process::Command; - -const TMP_FILE: &str = "/tmp/nvfuzz"; - -fn find_cuda() -> std::io::Result { - let paths = fs::read_dir("/usr/local")?; - - for path in paths { - let mut path = path?.path(); - let Some(fname) = path.file_name() else { - continue; - }; - - let Some(fname) = fname.to_str() else { - continue; - }; - - if !fname.starts_with("cuda-") { - continue; - } - - path.push("bin"); - path.push("nvdisasm"); - if path.exists() { - return Ok(path); - } - } - - Err(std::io::Error::new( - std::io::ErrorKind::NotFound, - "Failed to find nvdisasm", - )) -} - -//fn write_tmpfile(data: &[u32]) -> std::io::Result<()> { -// let mut file = std::fs::File::create(TMP_FILE)?; -// for dw in data { -// file.write(dw.to_le_bytes())?; -// } -//} - -fn main() { - let args: Vec = std::env::args().collect(); - let sm: u8 = { - let sm_str = &args[1]; - assert!(sm_str.starts_with("SM")); - sm_str[2..].parse().unwrap() - }; - let range: Vec<&str> = args[2].split("..").collect(); - let range: Range = Range { - start: range[0].parse().unwrap(), - end: range[1].parse().unwrap(), - }; - - let dw_count = if sm >= 70 { - 4 - } else if sm >= 50 { - 8 - } else { - panic!("Unknown shader model"); - }; - - let mut instr = Vec::new(); - for i in 0..dw_count { - instr.push(u32::from_str_radix(&args[3 + i], 16).unwrap()); - } - - let cuda_path = find_cuda().expect("Failed to find CUDA"); - - for bits in 0..(1_u64 << range.len()) { - BitMutView::new(&mut instr[..]).set_field(range.clone(), bits); - - print!("With {:#x} in {}..{}:", bits, range.start, range.end); - for dw in &instr { - print!(" {:#x}", dw); - } - print!("\n"); - - let mut data = Vec::new(); - for dw in &instr { - data.extend(dw.to_le_bytes()); - } - std::fs::write(TMP_FILE, data).expect("Failed to write file"); - - let out = Command::new(cuda_path.as_path()) - .arg("-b") - .arg(format!("SM{sm}")) - .arg(TMP_FILE) - .output() - .expect("failed to execute process"); - std::io::stderr().write_all(&out.stderr).expect("IO error"); - std::io::stdout().write_all(&out.stdout).expect("IO error"); - } -}