Compare commits
No commits in common. "dcaba617e105ae420bd4d5442f36d41b7603b20e" and "24bcc55e74857b3c72a6f68c26747ee66eeda98f" have entirely different histories.
dcaba617e1
...
24bcc55e74
|
@ -1,20 +0,0 @@
|
||||||
use cyborg::shader::{parse_wgsl, generate_wgsl, add_includes};
|
|
||||||
use cyborg::logger::Timer;
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let comp_timer = Timer::start("Shader compilation");
|
|
||||||
|
|
||||||
// Generate a shader and preprocess it
|
|
||||||
let mut source = std::fs::read_to_string("src/shader.wgsl").unwrap();
|
|
||||||
source = add_includes(&source);
|
|
||||||
|
|
||||||
// Parse the WGSL into a usable module
|
|
||||||
let module = parse_wgsl(&source);
|
|
||||||
|
|
||||||
// Generate a valid WGSL string from the module
|
|
||||||
let gen_wgsl = generate_wgsl(&module);
|
|
||||||
|
|
||||||
println!("Generated WGSL:\n\n{}", gen_wgsl);
|
|
||||||
|
|
||||||
comp_timer.print_status();
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
use std::fs::read_to_string;
|
|
||||||
use cyborg::shader::{parse_wgsl, generate_wgsl, add_includes};
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
// Generate a shader and preprocess it
|
|
||||||
let mut source = read_to_string("src/shader.wgsl").unwrap();
|
|
||||||
source = add_includes(&source);
|
|
||||||
|
|
||||||
// Parse the WGSL into a usable module
|
|
||||||
let module = parse_wgsl(&source);
|
|
||||||
|
|
||||||
// Generate a valid WGSL string from the module
|
|
||||||
let gen_wgsl = generate_wgsl(&module);
|
|
||||||
|
|
||||||
println!("{:?}", module);
|
|
||||||
}
|
|
|
@ -1,2 +0,0 @@
|
||||||
pub mod logger;
|
|
||||||
pub mod shader;
|
|
|
@ -1,19 +0,0 @@
|
||||||
use std::time::{Instant};
|
|
||||||
|
|
||||||
pub struct Timer<'a> {
|
|
||||||
name: &'a str,
|
|
||||||
start_time: Instant
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> Timer<'a> {
|
|
||||||
pub fn start(name: &'a str) -> Timer {
|
|
||||||
Timer {
|
|
||||||
name: name,
|
|
||||||
start_time: Instant::now()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn print_status(&self) {
|
|
||||||
println!("{}: {}ms", self.name, Instant::now().duration_since(self.start_time).as_nanos() as f32 / 1_000_000.0)
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -7,7 +7,7 @@ use super::shader::{parse_wgsl, generate_wgsl, add_includes};
|
||||||
use crate::handle::*;
|
use crate::handle::*;
|
||||||
use crate::model::OnLoad;
|
use crate::model::OnLoad;
|
||||||
use wgpu::util::DeviceExt;
|
use wgpu::util::DeviceExt;
|
||||||
use std::fs::read_to_string;
|
use std::fs::{File, read_to_string};
|
||||||
|
|
||||||
pub struct Renderer {
|
pub struct Renderer {
|
||||||
pub device: wgpu::Device,
|
pub device: wgpu::Device,
|
||||||
|
|
|
@ -67,22 +67,4 @@ pub fn add_includes(source: &String) -> String {
|
||||||
}
|
}
|
||||||
|
|
||||||
combined
|
combined
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn preprocess_file() {
|
|
||||||
// Generate a shader and preprocess it
|
|
||||||
let mut source = read_to_string("src/shader.wgsl").unwrap();
|
|
||||||
source = add_includes(&source);
|
|
||||||
|
|
||||||
// Parse the WGSL into a usable module
|
|
||||||
let module = parse_wgsl(&source);
|
|
||||||
|
|
||||||
// Generate a valid WGSL string from the module
|
|
||||||
let gen_wgsl = generate_wgsl(&module);
|
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue