Skip to content

Commit e1ce96d

Browse files
authored
Merge pull request #82 from zkmopro/feat/dynamic-chunk-size
Refactor Metal MSM with ShaderManager and Improved Buffer Management
2 parents ed387f5 + 9c4a161 commit e1ce96d

27 files changed

Lines changed: 842 additions & 376 deletions

mopro-msm/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,6 @@ proptest-regressions
2222
# Metal shader intermediate files and libraries
2323
src/msm/metal_msm/shader/**/*.ir
2424
src/msm/metal_msm/shader/**/*.lib
25+
26+
# Ignore constants.metal
27+
src/msm/metal_msm/shader/constants.metal

mopro-msm/src/msm/metal_msm/host/shader.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,39 @@ macro_rules! write_constant_array {
3636
};
3737
}
3838

39+
/// Get the shader directory path using CARGO_MANIFEST_DIR for proper OS file location
40+
/// This function provides robust path resolution that works across different build environments
41+
pub fn get_shader_dir() -> PathBuf {
42+
let manifest_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
43+
let shader_path = manifest_dir
44+
.join("src")
45+
.join("msm")
46+
.join("metal_msm")
47+
.join("shader");
48+
49+
// Verify the path exists, if not try alternative locations
50+
if shader_path.exists() {
51+
shader_path
52+
} else {
53+
// Fallback: try relative path from workspace root
54+
let workspace_shader_path = manifest_dir
55+
.parent() // go up one level from mopro-msm to workspace root
56+
.unwrap_or(&manifest_dir)
57+
.join("mopro-msm")
58+
.join("src")
59+
.join("msm")
60+
.join("metal_msm")
61+
.join("shader");
62+
63+
if workspace_shader_path.exists() {
64+
workspace_shader_path
65+
} else {
66+
// Final fallback: use the original path and let error handling take care of it
67+
shader_path
68+
}
69+
}
70+
}
71+
3972
pub fn compile_metal(path_from_cargo_manifest_dir: &str, input_filename: &str) -> String {
4073
let input_path = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
4174
.join(path_from_cargo_manifest_dir)

0 commit comments

Comments
 (0)