softgpu_core/
executable.rs1use softgpu_amd_code_object::{load_agent_image, LaunchAbi, LoadableKernel};
4use std::collections::HashMap;
5
6#[derive(Debug, Clone)]
8pub struct CodeObjectReader {
9 pub bytes: Vec<u8>,
10}
11
12#[derive(Debug, Clone)]
14pub struct ExecutableSymbol {
15 pub name: String,
16 pub symbol: String,
17 pub kernel_object: u64,
18 pub kernarg_segment_size: u32,
19 pub kernarg_segment_align: u32,
20 pub group_segment_size: u32,
21 pub private_segment_size: u32,
22 pub launch_abi: LaunchAbi,
23}
24
25#[derive(Debug, Clone)]
27pub struct SoftGpuExecutable {
28 pub frozen: bool,
29 pub symbols: Vec<ExecutableSymbol>,
30}
31
32pub fn parse_agent_kernels(bytes: &[u8]) -> Result<Vec<LoadableKernel>, String> {
34 let img = load_agent_image(bytes).map_err(|e| e.to_string())?;
35 Ok(img.kernels)
36}
37
38pub fn index_symbols(symbols: &[ExecutableSymbol]) -> HashMap<String, usize> {
40 let mut map = HashMap::new();
41 for (i, s) in symbols.iter().enumerate() {
42 map.insert(s.name.clone(), i);
43 map.insert(s.symbol.clone(), i);
44 if let Some(stripped) = s.symbol.strip_suffix(".kd") {
46 map.insert(stripped.to_string(), i);
47 }
48 }
49 map
50}