1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
//! Slang shader compiler integration.
//!
//! This module provides Rust bindings to the [Slang](https://shader-slang.org/) shader compiler.
//! Slang is Goldy's sole shader language, supporting compilation to:
//! - SPIR-V (Vulkan)
//! - DXIL (DirectX 12)
//! - MSL (Metal)
//!
//! # Example
//!
//! ```rust,no_run
//! use goldy::slang::{SlangCompiler, ShaderTarget, SlangStage};
//! use goldy::types::OptimizationLevel;
//!
//! let compiler = SlangCompiler::new().unwrap();
//!
//! let source = r#"
//! [shader("vertex")]
//! float4 vs_main(float2 pos : POSITION) : SV_Position {
//! return float4(pos, 0, 1);
//! }
//!
//! [shader("fragment")]
//! float4 fs_main() : SV_Target {
//! return float4(1, 0, 0, 1);
//! }
//! "#;
//!
//! let out = compiler
//! .compile_bindless_with_reflection_and_defines(
//! source,
//! ShaderTarget::Spirv,
//! &[("vs_main", SlangStage::Vertex)],
//! &[],
//! &[],
//! &[],
//! OptimizationLevel::Default,
//! )
//! .unwrap();
//! println!("Compiled {} bytes of SPIR-V", out.shader.data.len());
//! ```
pub use ;
pub use SlangStage;
/// Parse `[numthreads(x, y, z)]` from Slang shader source.
///
/// The input may be the full source string or just the inner content of the
/// `[numthreads(...)]` attribute (e.g. `"numthreads(64, 1, 1)"` or `"64, 1, 1"`).
///
/// Returns `None` if the attribute is absent or cannot be parsed; callers
/// should fall back to a suitable default (e.g. `[64, 1, 1]`).