-
Notifications
You must be signed in to change notification settings - Fork 15
/
glsl.rs
44 lines (38 loc) · 1.46 KB
/
glsl.rs
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
use {
screen_13::prelude::*,
screen_13_hot::prelude::*,
screen_13_window::{Window, WindowError},
std::path::PathBuf,
};
/// This program draws a noise signal to the swapchain - make changes to fill_image.comp or the
/// noise.glsl file it includes to see those changes update while the program is still running.
///
/// Run with RUST_LOG=info to get notification of shader compilations.
fn main() -> Result<(), WindowError> {
pretty_env_logger::init();
let window = Window::new()?;
// Create a compute pipeline - the same as normal except for "Hot" prefixes and we provide the
// shader source code path instead of the shader source code bytes
let cargo_manifest_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
let mut pipeline = HotComputePipeline::create(
&window.device,
ComputePipelineInfo::default(),
HotShader::new_compute(cargo_manifest_dir.join("examples/res/fill_image.comp")),
)?;
let mut frame_index: u32 = 0;
window.run(|frame| {
frame
.render_graph
.begin_pass("make some noise")
.bind_pipeline(pipeline.hot())
.write_descriptor(0, frame.swapchain_image)
.record_compute(move |compute, _| {
compute.push_constants(&frame_index.to_ne_bytes()).dispatch(
frame.width,
frame.height,
1,
);
});
frame_index += 1;
})
}