updated to 0.12

0.12
Ben Hansen 2 years ago
parent 0eed08b713
commit 2073b0fbc1

596
Cargo.lock generated

File diff suppressed because it is too large Load Diff

@ -13,9 +13,9 @@ path = "src/main.rs"
[dependencies]
image = "0.23"
winit = "0.25"
winit = "0.26"
cgmath = "0.18"
env_logger = "0.9"
log = "0.4"
wgpu = "0.11"
wgpu = "0.12"
pollster = "0.2"

@ -8,12 +8,12 @@ edition = "2018"
[dependencies]
image = "0.23"
winit = "0.25"
winit = "0.26"
cgmath = "0.18"
env_logger = "0.9"
log = "0.4"
wgpu = "0.11"
# wgpu = { version = "0.11", features=["trace"]}
wgpu = "0.12"
# wgpu = { version = "0.12", features=["trace"]}
# wgpu = { git = "https://github.com/gfx-rs/wgpu/" }
# wgpu = { git = "https://github.com/gfx-rs/wgpu/", features=["trace"]}
pollster = "0.2"

@ -6,11 +6,11 @@ edition = "2018"
[dependencies]
image = "0.23"
winit = "0.25"
winit = "0.26"
cgmath = "0.18"
env_logger = "0.9"
log = "0.4"
wgpu = "0.11"
wgpu = "0.12"
pollster = "0.2"
# NEW!

@ -94,8 +94,8 @@ impl State {
cull_mode: Some(wgpu::Face::Back),
// Setting this to anything other than Fill requires Features::NON_FILL_POLYGON_MODE
polygon_mode: wgpu::PolygonMode::Fill,
// Requires Features::DEPTH_CLAMPING
clamp_depth: false,
// Requires Features::DEPTH_CLIP_CONTROL
unclipped_depth: false,
// Requires Features::CONSERVATIVE_RASTERIZATION
conservative: false,
},
@ -105,6 +105,9 @@ impl State {
mask: !0,
alpha_to_coverage_enabled: false,
},
// If the pipeline will be used with a multiview render pass, this
// indicates how many array layers the attachments will have.
multiview: None,
});
let shader = device.create_shader_module(&wgpu::ShaderModuleDescriptor {
@ -145,6 +148,9 @@ impl State {
mask: !0,
alpha_to_coverage_enabled: false,
},
// If the pipeline will be used with a multiview render pass, this
// indicates how many array layers the attachments will have.
multiview: None,
});
let use_color = true;

@ -93,8 +93,8 @@ impl State {
cull_mode: Some(wgpu::Face::Back),
// Setting this to anything other than Fill requires Features::NON_FILL_POLYGON_MODE
polygon_mode: wgpu::PolygonMode::Fill,
// Requires Features::DEPTH_CLAMPING
clamp_depth: false,
// Requires Features::DEPTH_CLIP_CONTROL
unclipped_depth: false,
// Requires Features::CONSERVATIVE_RASTERIZATION
conservative: false,
},
@ -104,6 +104,9 @@ impl State {
mask: !0,
alpha_to_coverage_enabled: false,
},
// If the pipeline will be used with a multiview render pass, this
// indicates how many array layers the attachments will have.
multiview: None,
});
Self {

@ -8,8 +8,8 @@ edition = "2018"
[dependencies]
image = "0.23"
cgmath = "0.18"
winit = "0.25"
wgpu = "0.11"
winit = "0.26"
wgpu = "0.12"
env_logger = "0.9"
log = "0.4"
pollster = "0.2"

@ -157,8 +157,8 @@ impl State {
cull_mode: Some(wgpu::Face::Back),
// Setting this to anything other than Fill requires Features::NON_FILL_POLYGON_MODE
polygon_mode: wgpu::PolygonMode::Fill,
// Requires Features::DEPTH_CLAMPING
clamp_depth: false,
// Requires Features::DEPTH_CLIP_CONTROL
unclipped_depth: false,
// Requires Features::CONSERVATIVE_RASTERIZATION
conservative: false,
},
@ -168,6 +168,9 @@ impl State {
mask: !0,
alpha_to_coverage_enabled: false,
},
// If the pipeline will be used with a multiview render pass, this
// indicates how many array layers the attachments will have.
multiview: None,
});
let vertex_buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {

@ -150,8 +150,8 @@ impl State {
cull_mode: Some(wgpu::Face::Back),
// Setting this to anything other than Fill requires Features::NON_FILL_POLYGON_MODE
polygon_mode: wgpu::PolygonMode::Fill,
// Requires Features::DEPTH_CLAMPING
clamp_depth: false,
// Requires Features::DEPTH_CLIP_CONTROL
unclipped_depth: false,
// Requires Features::CONSERVATIVE_RASTERIZATION
conservative: false,
},
@ -161,6 +161,9 @@ impl State {
mask: !0,
alpha_to_coverage_enabled: false,
},
// If the pipeline will be used with a multiview render pass, this
// indicates how many array layers the attachments will have.
multiview: None,
});
let vertex_buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {

@ -14,8 +14,8 @@ env_logger = "0.9"
log = "0.4"
pollster = "0.2"
image = "0.23"
wgpu = "0.11"
winit = "0.25"
wgpu = "0.12"
winit = "0.26"
[build-dependencies]
anyhow = "1.0"

@ -135,10 +135,7 @@ impl State {
wgpu::BindGroupLayoutEntry {
binding: 1,
visibility: wgpu::ShaderStages::FRAGMENT,
ty: wgpu::BindingType::Sampler {
comparison: false,
filtering: true,
},
ty: wgpu::BindingType::Sampler(wgpu::SamplerBindingType::Filtering),
count: None,
},
],
@ -223,8 +220,8 @@ impl State {
cull_mode: Some(wgpu::Face::Back),
// Setting this to anything other than Fill requires Features::NON_FILL_POLYGON_MODE
polygon_mode: wgpu::PolygonMode::Fill,
// Requires Features::DEPTH_CLAMPING
clamp_depth: false,
// Requires Features::DEPTH_CLIP_CONTROL
unclipped_depth: false,
// Requires Features::CONSERVATIVE_RASTERIZATION
conservative: false,
},
@ -234,6 +231,9 @@ impl State {
mask: !0,
alpha_to_coverage_enabled: false,
},
// If the pipeline will be used with a multiview render pass, this
// indicates how many array layers the attachments will have.
multiview: None,
});
let vertex_buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {

@ -136,10 +136,7 @@ impl State {
wgpu::BindGroupLayoutEntry {
binding: 1,
visibility: wgpu::ShaderStages::FRAGMENT,
ty: wgpu::BindingType::Sampler {
comparison: false,
filtering: true,
},
ty: wgpu::BindingType::Sampler(wgpu::SamplerBindingType::Filtering),
count: None,
},
],
@ -200,8 +197,8 @@ impl State {
cull_mode: Some(wgpu::Face::Back),
// Setting this to anything other than Fill requires Features::NON_FILL_POLYGON_MODE
polygon_mode: wgpu::PolygonMode::Fill,
// Requires Features::DEPTH_CLAMPING
clamp_depth: false,
// Requires Features::DEPTH_CLIP_CONTROL
unclipped_depth: false,
// Requires Features::CONSERVATIVE_RASTERIZATION
conservative: false,
},
@ -211,6 +208,9 @@ impl State {
mask: !0,
alpha_to_coverage_enabled: false,
},
// If the pipeline will be used with a multiview render pass, this
// indicates how many array layers the attachments will have.
multiview: None,
});
let vertex_buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {

@ -12,8 +12,8 @@ env_logger = "0.9"
log = "0.4"
pollster = "0.2"
image = "0.23"
wgpu = "0.11"
winit = "0.25"
wgpu = "0.12"
winit = "0.26"
[build-dependencies]
anyhow = "1.0"

@ -301,10 +301,7 @@ impl State {
wgpu::BindGroupLayoutEntry {
binding: 1,
visibility: wgpu::ShaderStages::FRAGMENT,
ty: wgpu::BindingType::Sampler {
comparison: false,
filtering: true,
},
ty: wgpu::BindingType::Sampler(wgpu::SamplerBindingType::Filtering),
count: None,
},
],
@ -410,8 +407,8 @@ impl State {
cull_mode: Some(wgpu::Face::Back),
// Setting this to anything other than Fill requires Features::NON_FILL_POLYGON_MODE
polygon_mode: wgpu::PolygonMode::Fill,
// Requires Features::DEPTH_CLAMPING
clamp_depth: false,
// Requires Features::DEPTH_CLIP_CONTROL
unclipped_depth: false,
// Requires Features::CONSERVATIVE_RASTERIZATION
conservative: false,
},
@ -421,6 +418,9 @@ impl State {
mask: !0,
alpha_to_coverage_enabled: false,
},
// If the pipeline will be used with a multiview render pass, this
// indicates how many array layers the attachments will have.
multiview: None,
});
let vertex_buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {

@ -286,10 +286,7 @@ impl State {
wgpu::BindGroupLayoutEntry {
binding: 1,
visibility: wgpu::ShaderStages::FRAGMENT,
ty: wgpu::BindingType::Sampler {
comparison: false,
filtering: true,
},
ty: wgpu::BindingType::Sampler(wgpu::SamplerBindingType::Filtering),
count: None,
},
],
@ -394,8 +391,8 @@ impl State {
cull_mode: Some(wgpu::Face::Back),
// Setting this to anything other than Fill requires Features::NON_FILL_POLYGON_MODE
polygon_mode: wgpu::PolygonMode::Fill,
// Requires Features::DEPTH_CLAMPING
clamp_depth: false,
// Requires Features::DEPTH_CLIP_CONTROL
unclipped_depth: false,
// Requires Features::CONSERVATIVE_RASTERIZATION
conservative: false,
},
@ -405,6 +402,9 @@ impl State {
mask: !0,
alpha_to_coverage_enabled: false,
},
// If the pipeline will be used with a multiview render pass, this
// indicates how many array layers the attachments will have.
multiview: None,
});
let vertex_buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {

@ -12,8 +12,8 @@ env_logger = "0.9"
log = "0.4"
pollster = "0.2"
image = "0.23"
wgpu = "0.11"
winit = "0.25"
wgpu = "0.12"
winit = "0.26"
[build-dependencies]
anyhow = "1.0"

@ -383,10 +383,7 @@ impl State {
wgpu::BindGroupLayoutEntry {
binding: 1,
visibility: wgpu::ShaderStages::FRAGMENT,
ty: wgpu::BindingType::Sampler {
comparison: false,
filtering: true,
},
ty: wgpu::BindingType::Sampler(wgpu::SamplerBindingType::Filtering),
count: None,
},
],
@ -523,8 +520,8 @@ impl State {
cull_mode: Some(wgpu::Face::Back),
// Setting this to anything other than Fill requires Features::NON_FILL_POLYGON_MODE
polygon_mode: wgpu::PolygonMode::Fill,
// Requires Features::DEPTH_CLAMPING
clamp_depth: false,
// Requires Features::DEPTH_CLIP_CONTROL
unclipped_depth: false,
// Requires Features::CONSERVATIVE_RASTERIZATION
conservative: false,
},
@ -534,6 +531,9 @@ impl State {
mask: !0,
alpha_to_coverage_enabled: false,
},
// If the pipeline will be used with a multiview render pass, this
// indicates how many array layers the attachments will have.
multiview: None,
});
let vertex_buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {

@ -347,10 +347,7 @@ impl State {
wgpu::BindGroupLayoutEntry {
binding: 1,
visibility: wgpu::ShaderStages::FRAGMENT,
ty: wgpu::BindingType::Sampler {
comparison: false,
filtering: true,
},
ty: wgpu::BindingType::Sampler(wgpu::SamplerBindingType::Filtering),
count: None,
},
],
@ -487,8 +484,8 @@ impl State {
cull_mode: Some(wgpu::Face::Back),
// Setting this to anything other than Fill requires Features::NON_FILL_POLYGON_MODE
polygon_mode: wgpu::PolygonMode::Fill,
// Requires Features::DEPTH_CLAMPING
clamp_depth: false,
// Requires Features::DEPTH_CLIP_CONTROL
unclipped_depth: false,
// Requires Features::CONSERVATIVE_RASTERIZATION
conservative: false,
},
@ -498,6 +495,9 @@ impl State {
mask: !0,
alpha_to_coverage_enabled: false,
},
// If the pipeline will be used with a multiview render pass, this
// indicates how many array layers the attachments will have.
multiview: None,
});
let vertex_buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {

@ -12,8 +12,8 @@ env_logger = "0.9"
pollster = "0.2"
image = "0.23"
log = "0.4"
wgpu = "0.11"
winit = "0.25"
wgpu = "0.12"
winit = "0.26"
[build-dependencies]
anyhow = "1.0"

@ -327,10 +327,7 @@ impl DepthPass {
wgpu::BindGroupLayoutEntry {
binding: 1,
count: None,
ty: wgpu::BindingType::Sampler {
comparison: true,
filtering: true,
},
ty: wgpu::BindingType::Sampler(wgpu::SamplerBindingType::Comparison),
visibility: wgpu::ShaderStages::FRAGMENT,
},
],
@ -400,8 +397,8 @@ impl DepthPass {
cull_mode: Some(wgpu::Face::Back),
// Setting this to anything other than Fill requires Features::NON_FILL_POLYGON_MODE
polygon_mode: wgpu::PolygonMode::Fill,
// Requires Features::DEPTH_CLAMPING
clamp_depth: false,
// Requires Features::DEPTH_CLIP_CONTROL
unclipped_depth: false,
// Requires Features::CONSERVATIVE_RASTERIZATION
conservative: false,
},
@ -411,6 +408,9 @@ impl DepthPass {
mask: !0,
alpha_to_coverage_enabled: false,
},
// If the pipeline will be used with a multiview render pass, this
// indicates how many array layers the attachments will have.
multiview: None,
});
Self {
@ -544,10 +544,7 @@ impl State {
wgpu::BindGroupLayoutEntry {
binding: 1,
visibility: wgpu::ShaderStages::FRAGMENT,
ty: wgpu::BindingType::Sampler {
comparison: false,
filtering: true,
},
ty: wgpu::BindingType::Sampler(wgpu::SamplerBindingType::Filtering),
count: None,
},
],
@ -684,8 +681,8 @@ impl State {
cull_mode: Some(wgpu::Face::Back),
// Setting this to anything other than Fill requires Features::NON_FILL_POLYGON_MODE
polygon_mode: wgpu::PolygonMode::Fill,
// Requires Features::DEPTH_CLAMPING
clamp_depth: false,
// Requires Features::DEPTH_CLIP_CONTROL
unclipped_depth: false,
// Requires Features::CONSERVATIVE_RASTERIZATION
conservative: false,
},
@ -705,6 +702,9 @@ impl State {
mask: !0,
alpha_to_coverage_enabled: false,
},
// If the pipeline will be used with a multiview render pass, this
// indicates how many array layers the attachments will have.
multiview: None,
});
let vertex_buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {

@ -357,10 +357,7 @@ impl State {
wgpu::BindGroupLayoutEntry {
binding: 1,
visibility: wgpu::ShaderStages::FRAGMENT,
ty: wgpu::BindingType::Sampler {
comparison: false,
filtering: true,
},
ty: wgpu::BindingType::Sampler(wgpu::SamplerBindingType::Filtering),
count: None,
},
],
@ -500,8 +497,8 @@ impl State {
cull_mode: Some(wgpu::Face::Back),
// Setting this to anything other than Fill requires Features::NON_FILL_POLYGON_MODE
polygon_mode: wgpu::PolygonMode::Fill,
// Requires Features::DEPTH_CLAMPING
clamp_depth: false,
// Requires Features::DEPTH_CLIP_CONTROL
unclipped_depth: false,
// Requires Features::CONSERVATIVE_RASTERIZATION
conservative: false,
},
@ -517,6 +514,9 @@ impl State {
mask: !0,
alpha_to_coverage_enabled: false,
},
// If the pipeline will be used with a multiview render pass, this
// indicates how many array layers the attachments will have.
multiview: None,
});
let vertex_buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {

@ -13,8 +13,8 @@ pollster = "0.2"
image = "0.23"
log = "0.4"
tobj = "3.0"
wgpu = "0.11"
winit = "0.25"
wgpu = "0.12"
winit = "0.26"
[build-dependencies]
anyhow = "1.0"

@ -293,10 +293,7 @@ impl State {
wgpu::BindGroupLayoutEntry {
binding: 1,
visibility: wgpu::ShaderStages::FRAGMENT,
ty: wgpu::BindingType::Sampler {
comparison: false,
filtering: true,
},
ty: wgpu::BindingType::Sampler(wgpu::SamplerBindingType::Filtering),
count: None,
},
],
@ -428,8 +425,8 @@ impl State {
cull_mode: Some(wgpu::Face::Back),
// Setting this to anything other than Fill requires Features::NON_FILL_POLYGON_MODE
polygon_mode: wgpu::PolygonMode::Fill,
// Requires Features::DEPTH_CLAMPING
clamp_depth: false,
// Requires Features::DEPTH_CLIP_CONTROL
unclipped_depth: false,
// Requires Features::CONSERVATIVE_RASTERIZATION
conservative: false,
},
@ -445,6 +442,9 @@ impl State {
mask: !0,
alpha_to_coverage_enabled: false,
},
// If the pipeline will be used with a multiview render pass, this
// indicates how many array layers the attachments will have.
multiview: None,
});
Self {

@ -13,8 +13,8 @@ pollster = "0.2"
image = "0.23"
log = "0.4"
tobj = "3.0"
wgpu = "0.11"
winit = "0.25"
wgpu = "0.12"
winit = "0.26"
[build-dependencies]
anyhow = "1.0"

@ -309,8 +309,8 @@ fn create_render_pipeline(
cull_mode: Some(wgpu::Face::Back),
// Setting this to anything other than Fill requires Features::NON_FILL_POLYGON_MODE
polygon_mode: wgpu::PolygonMode::Fill,
// Requires Features::DEPTH_CLAMPING
clamp_depth: false,
// Requires Features::DEPTH_CLIP_CONTROL
unclipped_depth: false,
// Requires Features::CONSERVATIVE_RASTERIZATION
conservative: false,
},
@ -326,6 +326,9 @@ fn create_render_pipeline(
mask: !0,
alpha_to_coverage_enabled: false,
},
// If the pipeline will be used with a multiview render pass, this
// indicates how many array layers the attachments will have.
multiview: None,
})
}
@ -383,10 +386,7 @@ impl State {
wgpu::BindGroupLayoutEntry {
binding: 1,
visibility: wgpu::ShaderStages::FRAGMENT,
ty: wgpu::BindingType::Sampler {
comparison: false,
filtering: true,
},
ty: wgpu::BindingType::Sampler(wgpu::SamplerBindingType::Filtering),
count: None,
},
],

@ -13,8 +13,8 @@ pollster = "0.2"
image = "0.23"
log = "0.4"
tobj = "3.0"
wgpu = "0.11"
winit = "0.25"
wgpu = "0.12"
winit = "0.26"
[build-dependencies]
anyhow = "1.0"

@ -310,8 +310,8 @@ fn create_render_pipeline(
cull_mode: Some(wgpu::Face::Back),
// Setting this to anything other than Fill requires Features::NON_FILL_POLYGON_MODE
polygon_mode: wgpu::PolygonMode::Fill,
// Requires Features::DEPTH_CLAMPING
clamp_depth: false,
// Requires Features::DEPTH_CLIP_CONTROL
unclipped_depth: false,
// Requires Features::CONSERVATIVE_RASTERIZATION
conservative: false,
},
@ -327,6 +327,9 @@ fn create_render_pipeline(
mask: !0,
alpha_to_coverage_enabled: false,
},
// If the pipeline will be used with a multiview render pass, this
// indicates how many array layers the attachments will have.
multiview: None,
})
}
@ -384,10 +387,7 @@ impl State {
wgpu::BindGroupLayoutEntry {
binding: 1,
visibility: wgpu::ShaderStages::FRAGMENT,
ty: wgpu::BindingType::Sampler {
comparison: false,
filtering: true,
},
ty: wgpu::BindingType::Sampler(wgpu::SamplerBindingType::Filtering),
count: None,
},
// normal map
@ -404,10 +404,7 @@ impl State {
wgpu::BindGroupLayoutEntry {
binding: 3,
visibility: wgpu::ShaderStages::FRAGMENT,
ty: wgpu::BindingType::Sampler {
comparison: false,
filtering: true,
},
ty: wgpu::BindingType::Sampler(wgpu::SamplerBindingType::Filtering),
count: None,
},
],

@ -13,8 +13,8 @@ pollster = "0.2"
image = "0.23"
log = "0.4"
tobj = "3.0"
wgpu = "0.11"
winit = "0.25"
wgpu = "0.12"
winit = "0.26"
[build-dependencies]
anyhow = "1.0"

@ -190,8 +190,8 @@ fn create_render_pipeline(
cull_mode: Some(wgpu::Face::Back),
// Setting this to anything other than Fill requires Features::NON_FILL_POLYGON_MODE
polygon_mode: wgpu::PolygonMode::Fill,
// Requires Features::DEPTH_CLAMPING
clamp_depth: false,
// Requires Features::DEPTH_CLIP_CONTROL
unclipped_depth: false,
// Requires Features::CONSERVATIVE_RASTERIZATION
conservative: false,
},
@ -207,6 +207,9 @@ fn create_render_pipeline(
mask: !0,
alpha_to_coverage_enabled: false,
},
// If the pipeline will be used with a multiview render pass, this
// indicates how many array layers the attachments will have.
multiview: None,
})
}
@ -264,10 +267,7 @@ impl State {
wgpu::BindGroupLayoutEntry {
binding: 1,
visibility: wgpu::ShaderStages::FRAGMENT,
ty: wgpu::BindingType::Sampler {
comparison: false,
filtering: true,
},
ty: wgpu::BindingType::Sampler(wgpu::SamplerBindingType::Filtering),
count: None,
},
// normal map
@ -284,10 +284,7 @@ impl State {
wgpu::BindGroupLayoutEntry {
binding: 3,
visibility: wgpu::ShaderStages::FRAGMENT,
ty: wgpu::BindingType::Sampler {
comparison: false,
filtering: true,
},
ty: wgpu::BindingType::Sampler(wgpu::SamplerBindingType::Filtering),
count: None,
},
],

@ -14,8 +14,8 @@ image = "0.23"
log = "0.4"
rayon = "1.4" # NEW!
tobj = "3.0"
wgpu = "0.11"
winit = "0.25"
wgpu = "0.12"
winit = "0.26"
[build-dependencies]
anyhow = "1.0"

@ -189,8 +189,8 @@ fn create_render_pipeline(
cull_mode: Some(wgpu::Face::Back),
// Setting this to anything other than Fill requires Features::NON_FILL_POLYGON_MODE
polygon_mode: wgpu::PolygonMode::Fill,
// Requires Features::DEPTH_CLAMPING
clamp_depth: false,
// Requires Features::DEPTH_CLIP_CONTROL
unclipped_depth: false,
// Requires Features::CONSERVATIVE_RASTERIZATION
conservative: false,
},
@ -206,6 +206,9 @@ fn create_render_pipeline(
mask: !0,
alpha_to_coverage_enabled: false,
},
// If the pipeline will be used with a multiview render pass, this
// indicates how many array layers the attachments will have.
multiview: None,
})
}
@ -263,10 +266,7 @@ impl State {
wgpu::BindGroupLayoutEntry {
binding: 1,
visibility: wgpu::ShaderStages::FRAGMENT,
ty: wgpu::BindingType::Sampler {
comparison: false,
filtering: true,
},
ty: wgpu::BindingType::Sampler(wgpu::SamplerBindingType::Filtering),
count: None,
},
// normal map
@ -283,10 +283,7 @@ impl State {
wgpu::BindGroupLayoutEntry {
binding: 3,
visibility: wgpu::ShaderStages::FRAGMENT,
ty: wgpu::BindingType::Sampler {
comparison: false,
filtering: true,
},
ty: wgpu::BindingType::Sampler(wgpu::SamplerBindingType::Filtering),
count: None,
},
],

@ -14,8 +14,8 @@ image = "0.23"
log = "0.4"
rayon = "1.4"
tobj = "2.0"
wgpu = { version = "0.11", features = ["trace", "spirv"] }
winit = "0.25"
wgpu = { version = "0.12", features = ["trace", "spirv"] }
winit = "0.26"
[build-dependencies]
anyhow = "1.0"

@ -8,6 +8,7 @@ use naga::front::glsl::Parser;
use rayon::prelude::*;
use std::env;
use std::{fs::read_to_string, path::PathBuf};
use std::result::Result::Ok;
pub fn load_shader(src_path: PathBuf) -> Result<()> {
let extension = src_path

@ -2,19 +2,19 @@ struct FragmentOutput {
[[location(0)]] f_color: vec4<f32>;
};
var<private> v_color1: vec3<f32>;
var<private> v_color_1: vec3<f32>;
var<private> f_color: vec4<f32>;
fn main1() {
let e2: vec3<f32> = v_color1;
fn main_1() {
let e2: vec3<f32> = v_color_1;
f_color = vec4<f32>(e2, 1.0);
return;
}
[[stage(fragment)]]
fn main([[location(0)]] v_color: vec3<f32>) -> FragmentOutput {
v_color1 = v_color;
main1();
v_color_1 = v_color;
main_1();
let e7: vec4<f32> = f_color;
return FragmentOutput(e7);
}

@ -15,34 +15,34 @@ struct VertexOutput {
[[builtin(position)]] member: vec4<f32>;
};
var<private> a_position1: vec3<f32>;
var<private> a_position_1: vec3<f32>;
var<private> v_color: vec3<f32>;
[[group(0), binding(0)]]
var<uniform> global: Camera;
[[group(1), binding(0)]]
var<uniform> global1: Light;
var<uniform> global_1: Light;
var<private> scale: f32 = 0.25;
var<private> gl_Position: vec4<f32>;
fn main1() {
fn main_1() {
var v_position: vec3<f32>;
let e11: vec3<f32> = a_position1;
let e11: vec3<f32> = a_position_1;
let e12: f32 = scale;
let e14: vec3<f32> = global1.u_position;
let e14: vec3<f32> = global_1.u_position;
v_position = ((e11 * e12) + e14);
let e18: mat4x4<f32> = global.u_view_proj;
let e19: vec3<f32> = v_position;
gl_Position = (e18 * vec4<f32>(e19, f32(1)));
let e24: vec3<f32> = global1.u_color;
let e24: vec3<f32> = global_1.u_color;
v_color = e24;
return;
}
[[stage(vertex)]]
fn main([[location(0)]] a_position: vec3<f32>) -> VertexOutput {
a_position1 = a_position;
main1();
a_position_1 = a_position;
main_1();
let e18: vec3<f32> = v_color;
let e20: vec4<f32> = gl_Position;
return VertexOutput(e18, e20);

@ -211,10 +211,7 @@ impl State {
wgpu::BindGroupLayoutEntry {
binding: 1,
visibility: wgpu::ShaderStages::FRAGMENT,
ty: wgpu::BindingType::Sampler {
comparison: false,
filtering: true,
},
ty: wgpu::BindingType::Sampler(wgpu::SamplerBindingType::Filtering),
count: None,
},
// normal map
@ -231,10 +228,7 @@ impl State {
wgpu::BindGroupLayoutEntry {
binding: 3,
visibility: wgpu::ShaderStages::FRAGMENT,
ty: wgpu::BindingType::Sampler {
comparison: false,
filtering: true,
},
ty: wgpu::BindingType::Sampler(wgpu::SamplerBindingType::Filtering),
count: None,
},
],

@ -41,45 +41,45 @@ struct ComputeInfo {
[[group(0), binding(0)]]
var<storage> global: SrcVertexBuffer;
[[group(0), binding(1)]]
var<storage, read_write> global1: DstVertexBuffer;
var<storage, read_write> global_1: DstVertexBuffer;
[[group(0), binding(2)]]
var<storage> global2: IndexBuffer;
var<storage> global_2: IndexBuffer;
[[group(0), binding(3)]]
var<uniform> global3: ComputeInfo;
var<uniform> global_3: ComputeInfo;
var<private> gl_GlobalInvocationID: vec3<u32>;
fn getPos(v: ModelVertex) -> vec3<f32> {
var v1: ModelVertex;
var v_1: ModelVertex;
v1 = v;
let e12: ModelVertex = v1;
let e14: ModelVertex = v1;
let e16: ModelVertex = v1;
v_1 = v;
let e12: ModelVertex = v_1;
let e14: ModelVertex = v_1;
let e16: ModelVertex = v_1;
return vec3<f32>(e12.x, e14.y, e16.z);
}
fn getUV(v2: ModelVertex) -> vec2<f32> {
var v3: ModelVertex;
fn getUV(v_2: ModelVertex) -> vec2<f32> {
var v_3: ModelVertex;
v3 = v2;
let e12: ModelVertex = v3;
let e14: ModelVertex = v3;
v_3 = v_2;
let e12: ModelVertex = v_3;
let e14: ModelVertex = v_3;
return vec2<f32>(e12.uv, e14.uw);
}
fn getNormal(v4: ModelVertex) -> vec3<f32> {
var v5: ModelVertex;
fn getNormal(v_4: ModelVertex) -> vec3<f32> {
var v_5: ModelVertex;
v5 = v4;
let e12: ModelVertex = v5;
let e14: ModelVertex = v5;
let e16: ModelVertex = v5;
v_5 = v_4;
let e12: ModelVertex = v_5;
let e14: ModelVertex = v_5;
let e16: ModelVertex = v_5;
return vec3<f32>(e12.nx, e14.ny, e16.nz);
}
fn calcTangentBitangent(vertexIndex: u32) -> ModelVertex {
var vertexIndex1: u32;
var v6: ModelVertex;
var vertexIndex_1: u32;
var v_6: ModelVertex;
var tangent: vec3<f32> = vec3<f32>(0.0, 0.0, 0.0);
var bitangent: vec3<f32> = vec3<f32>(0.0, 0.0, 0.0);
var trianglesIncluded: u32 = 0u;
@ -102,32 +102,32 @@ fn calcTangentBitangent(vertexIndex: u32) -> ModelVertex {
var delta_uv2_: vec2<f32>;
var r: f32;
vertexIndex1 = vertexIndex;
let e12: u32 = vertexIndex1;
vertexIndex_1 = vertexIndex;
let e12: u32 = vertexIndex_1;
let e14: ModelVertex = global.srcVertices[e12];
v6 = e14;
v_6 = e14;
loop {
let e30: u32 = i;
let e31: u32 = global3.numIndices;
let e31: u32 = global_3.numIndices;
if (!((e30 < e31))) {
break;
}
{
let e38: u32 = i;
let e40: u32 = global2.indices[e38];
let e40: u32 = global_2.indices[e38];
index0_ = e40;
let e42: u32 = i;
let e47: u32 = global2.indices[(e42 + u32(1))];
let e47: u32 = global_2.indices[(e42 + u32(1))];
index1_ = e47;
let e49: u32 = i;
let e54: u32 = global2.indices[(e49 + u32(2))];
let e54: u32 = global_2.indices[(e49 + u32(2))];
index2_ = e54;
let e56: u32 = index0_;
let e57: u32 = vertexIndex1;
let e57: u32 = vertexIndex_1;
let e59: u32 = index1_;
let e60: u32 = vertexIndex1;
let e60: u32 = vertexIndex_1;
let e63: u32 = index2_;
let e64: u32 = vertexIndex1;
let e64: u32 = vertexIndex_1;
if ((((e56 == e57) || (e59 == e60)) || (e63 == e64))) {
{
let e67: u32 = index0_;
@ -214,39 +214,39 @@ fn calcTangentBitangent(vertexIndex: u32) -> ModelVertex {
}
}
let e184: vec3<f32> = tangent;
v6.tx = e184.x;
v_6.tx = e184.x;
let e187: vec3<f32> = tangent;
v6.ty = e187.y;
v_6.ty = e187.y;
let e190: vec3<f32> = tangent;
v6.tz = e190.z;
v_6.tz = e190.z;
let e193: vec3<f32> = bitangent;
v6.bx = e193.x;
v_6.bx = e193.x;
let e196: vec3<f32> = bitangent;
v6.by = e196.y;
v_6.by = e196.y;
let e199: vec3<f32> = bitangent;
v6.bz = e199.z;
let e201: ModelVertex = v6;
v_6.bz = e199.z;
let e201: ModelVertex = v_6;
return e201;
}
fn main1() {
var vertexIndex2: u32;
fn main_1() {
var vertexIndex_2: u32;
var result: ModelVertex;
let e11: vec3<u32> = gl_GlobalInvocationID;
vertexIndex2 = e11.x;
let e15: u32 = vertexIndex2;
vertexIndex_2 = e11.x;
let e15: u32 = vertexIndex_2;
let e16: ModelVertex = calcTangentBitangent(e15);
result = e16;
let e18: u32 = vertexIndex2;
let e18: u32 = vertexIndex_2;
let e20: ModelVertex = result;
global1.dstVertices[e18] = e20;
global_1.dstVertices[e18] = e20;
return;
}
[[stage(compute), workgroup_size(64, 1, 1)]]
fn main([[builtin(global_invocation_id)]] param: vec3<u32>) {
gl_GlobalInvocationID = param;
main1();
main_1();
return;
}

@ -72,7 +72,7 @@ pub fn create_render_pipeline(
cull_mode: Some(wgpu::Face::Back),
// Setting this to anything other than Fill requires Features::NON_FILL_POLYGON_MODE
polygon_mode: wgpu::PolygonMode::Fill,
clamp_depth: false,
unclipped_depth: false,
conservative: false,
},
depth_stencil: depth_format.map(|format| wgpu::DepthStencilState {
@ -87,6 +87,9 @@ pub fn create_render_pipeline(
mask: !0,
alpha_to_coverage_enabled: false,
},
// If the pipeline will be used with a multiview render pass, this
// indicates how many array layers the attachments will have.
multiview: None,
})
}

@ -8,10 +8,10 @@ struct FragmentOutput {
[[location(0)]] f_color: vec4<f32>;
};
var<private> v_tex_coords1: vec2<f32>;
var<private> v_position1: vec3<f32>;
var<private> v_light_position1: vec3<f32>;
var<private> v_view_position1: vec3<f32>;
var<private> v_tex_coords_1: vec2<f32>;
var<private> v_position_1: vec3<f32>;
var<private> v_light_position_1: vec3<f32>;
var<private> v_view_position_1: vec3<f32>;
var<private> f_color: vec4<f32>;
[[group(0), binding(0)]]
var t_diffuse: texture_2d<f32>;
@ -24,7 +24,7 @@ var s_normal: sampler;
[[group(2), binding(0)]]
var<uniform> global: Light;
fn main1() {
fn main_1() {
var object_color: vec4<f32>;
var object_normal: vec4<f32>;
var ambient_strength: f32 = 0.10000000149011612;
@ -39,10 +39,10 @@ fn main1() {
var specular_color: vec3<f32>;
var result: vec3<f32>;
let e14: vec2<f32> = v_tex_coords1;
let e14: vec2<f32> = v_tex_coords_1;
let e15: vec4<f32> = textureSample(t_diffuse, s_diffuse, e14);
object_color = e15;
let e18: vec2<f32> = v_tex_coords1;
let e18: vec2<f32> = v_tex_coords_1;
let e19: vec4<f32> = textureSample(t_normal, s_normal, e18);
object_normal = e19;
let e23: vec3<f32> = global.light_color;
@ -51,10 +51,10 @@ fn main1() {
let e27: vec4<f32> = object_normal;
let e34: vec4<f32> = object_normal;
normal = normalize(((e34.xyz * 2.0) - vec3<f32>(1.0)));
let e43: vec3<f32> = v_light_position1;
let e44: vec3<f32> = v_position1;
let e46: vec3<f32> = v_light_position1;
let e47: vec3<f32> = v_position1;
let e43: vec3<f32> = v_light_position_1;
let e44: vec3<f32> = v_position_1;
let e46: vec3<f32> = v_light_position_1;
let e47: vec3<f32> = v_position_1;
light_dir = normalize((e46 - e47));
let e53: vec3<f32> = normal;
let e54: vec3<f32> = light_dir;
@ -64,10 +64,10 @@ fn main1() {
let e65: vec3<f32> = global.light_color;
let e66: f32 = diffuse_strength;
diffuse_color = (e65 * e66);
let e69: vec3<f32> = v_view_position1;
let e70: vec3<f32> = v_position1;
let e72: vec3<f32> = v_view_position1;
let e73: vec3<f32> = v_position1;
let e69: vec3<f32> = v_view_position_1;
let e70: vec3<f32> = v_position_1;
let e72: vec3<f32> = v_view_position_1;
let e73: vec3<f32> = v_position_1;
view_dir = normalize((e72 - e73));
let e77: vec3<f32> = view_dir;
let e78: vec3<f32> = light_dir;
@ -99,11 +99,11 @@ fn main1() {
[[stage(fragment)]]
fn main([[location(0)]] v_tex_coords: vec2<f32>, [[location(1)]] v_position: vec3<f32>, [[location(2)]] v_light_position: vec3<f32>, [[location(3)]] v_view_position: vec3<f32>) -> FragmentOutput {
v_tex_coords1 = v_tex_coords;
v_position1 = v_position;
v_light_position1 = v_light_position;
v_view_position1 = v_view_position;
main1();
v_tex_coords_1 = v_tex_coords;
v_position_1 = v_position;
v_light_position_1 = v_light_position;
v_view_position_1 = v_view_position;
main_1();
let e31: vec4<f32> = f_color;
return FragmentOutput(e31);
}

@ -18,11 +18,11 @@ struct VertexOutput {
[[builtin(position)]] member: vec4<f32>;
};
var<private> a_position1: vec3<f32>;
var<private> a_tex_coords1: vec2<f32>;
var<private> a_normal1: vec3<f32>;
var<private> a_tangent1: vec3<f32>;
var<private> a_bitangent1: vec3<f32>;
var<private> a_position_1: vec3<f32>;
var<private> a_tex_coords_1: vec2<f32>;
var<private> a_normal_1: vec3<f32>;
var<private> a_tangent_1: vec3<f32>;
var<private> a_bitangent_1: vec3<f32>;
var<private> v_tex_coords: vec2<f32>;
var<private> v_position: vec3<f32>;
var<private> v_light_position: vec3<f32>;
@ -37,10 +37,10 @@ var<private> normal_matrix_0_1: vec3<f32>;
var<private> normal_matrix_1_1: vec3<f32>;
var<private> normal_matrix_2_1: vec3<f32>;
[[group(2), binding(0)]]
var<uniform> global1: Light;
var<uniform> global_1: Light;
var<private> gl_Position: vec4<f32>;
fn main1() {
fn main_1() {
var model_matrix: mat4x4<f32>;
var normal_matrix: mat3x3<f32>;
var normal: vec3<f32>;
@ -54,26 +54,26 @@ fn main1() {
let e26: vec4<f32> = model_matrix_2_1;
let e27: vec4<f32> = model_matrix_3_1;
model_matrix = mat4x4<f32>(vec4<f32>(e24.x, e24.y, e24.z, e24.w), vec4<f32>(e25.x, e25.y, e25.z, e25.w), vec4<f32>(e26.x, e26.y, e26.z, e26.w), vec4<f32>(e27.x, e27.y, e27.z, e27.w));
let e50: vec2<f32> = a_tex_coords1;
let e50: vec2<f32> = a_tex_coords_1;
v_tex_coords = e50;
let e51: vec3<f32> = normal_matrix_0_1;
let e52: vec3<f32> = normal_matrix_1_1;
let e53: vec3<f32> = normal_matrix_2_1;
normal_matrix = mat3x3<f32>(vec3<f32>(e51.x, e51.y, e51.z), vec3<f32>(e52.x, e52.y, e52.z), vec3<f32>(e53.x, e53.y, e53.z));
let e68: mat3x3<f32> = normal_matrix;
let e69: vec3<f32> = a_normal1;
let e69: vec3<f32> = a_normal_1;
let e71: mat3x3<f32> = normal_matrix;
let e72: vec3<f32> = a_normal1;
let e72: vec3<f32> = a_normal_1;
normal = normalize((e71 * e72));
let e76: mat3x3<f32> = normal_matrix;
let e77: vec3<f32> = a_tangent1;
let e77: vec3<f32> = a_tangent_1;
let e79: mat3x3<f32> = normal_matrix;
let e80: vec3<f32> = a_tangent1;
let e80: vec3<f32> = a_tangent_1;
tangent = normalize((e79 * e80));
let e84: mat3x3<f32> = normal_matrix;
let e85: vec3<f32> = a_bitangent1;
let e85: vec3<f32> = a_bitangent_1;
let e87: mat3x3<f32> = normal_matrix;
let e88: vec3<f32> = a_bitangent1;
let e88: vec3<f32> = a_bitangent_1;
bitangent = normalize((e87 * e88));
let e92: vec3<f32> = tangent;
let e93: vec3<f32> = bitangent;
@ -83,13 +83,13 @@ fn main1() {
let e110: vec3<f32> = normal;
tangent_matrix = transpose(mat3x3<f32>(vec3<f32>(e108.x, e108.y, e108.z), vec3<f32>(e109.x, e109.y, e109.z), vec3<f32>(e110.x, e110.y, e110.z)));
let e126: mat4x4<f32> = model_matrix;
let e127: vec3<f32> = a_position1;
let e127: vec3<f32> = a_position_1;
model_space = (e126 * vec4<f32>(e127, 1.0));
let e132: mat3x3<f32> = tangent_matrix;
let e133: vec4<f32> = model_space;
v_position = (e132 * e133.xyz);
let e136: mat3x3<f32> = tangent_matrix;
let e137: vec3<f32> = global1.light_position;
let e137: vec3<f32> = global_1.light_position;
v_light_position = (e136 * e137);
let e139: mat3x3<f32> = tangent_matrix;
let e140: vec3<f32> = global.u_view_position;
@ -102,11 +102,11 @@ fn main1() {
[[stage(vertex)]]
fn main([[location(0)]] a_position: vec3<f32>, [[location(1)]] a_tex_coords: vec2<f32>, [[location(2)]] a_normal: vec3<f32>, [[location(3)]] a_tangent: vec3<f32>, [[location(4)]] a_bitangent: vec3<f32>, [[location(5)]] model_matrix_0_: vec4<f32>, [[location(6)]] model_matrix_1_: vec4<f32>, [[location(7)]] model_matrix_2_: vec4<f32>, [[location(8)]] model_matrix_3_: vec4<f32>, [[location(9)]] normal_matrix_0_: vec3<f32>, [[location(10)]] normal_matrix_1_: vec3<f32>, [[location(11)]] normal_matrix_2_: vec3<f32>) -> VertexOutput {
a_position1 = a_position;
a_tex_coords1 = a_tex_coords;
a_normal1 = a_normal;
a_tangent1 = a_tangent;
a_bitangent1 = a_bitangent;
a_position_1 = a_position;
a_tex_coords_1 = a_tex_coords;
a_normal_1 = a_normal;
a_tangent_1 = a_tangent;
a_bitangent_1 = a_bitangent;
model_matrix_0_1 = model_matrix_0_;
model_matrix_1_1 = model_matrix_1_;
model_matrix_2_1 = model_matrix_2_;
@ -114,7 +114,7 @@ fn main([[location(0)]] a_position: vec3<f32>, [[location(1)]] a_tex_coords: vec
normal_matrix_0_1 = normal_matrix_0_;
normal_matrix_1_1 = normal_matrix_1_;
normal_matrix_2_1 = normal_matrix_2_;
main1();
main_1();
let e65: vec2<f32> = v_tex_coords;
let e67: vec3<f32> = v_position;
let e69: vec3<f32> = v_light_position;

@ -14,13 +14,13 @@ pollster = "0.2"
image = "0.23"
log = "0.4"
tobj = "2.0"
wgpu = "0.11"
wgpu = "0.12"
wgpu-subscriber = "0.1"
winit = "0.25"
winit = "0.26"
[build-dependencies]
anyhow = "1.0"
fs_extra = "1.2"
glob = "0.3"
shaderc = "0.7"
naga = { version = "0.8", features = ["glsl-in", "spv-out", "wgsl-out"]}
rayon = "1.5"

@ -1,90 +1,93 @@
use anyhow::*;
// use fs_extra::copy_items;
// use fs_extra::dir::CopyOptions;
use glob::glob;
use naga::back::wgsl;
use naga::front::glsl::Options;
use naga::front::glsl::Parser;
use rayon::prelude::*;
// use std::env;
use std::fs::{read_to_string, write};
use std::path::PathBuf;
use std::{fs::read_to_string, path::PathBuf};
use anyhow::Context;
struct ShaderData {
src: String,
src_path: PathBuf,
spv_path: PathBuf,
kind: shaderc::ShaderKind,
}
pub fn load_shader(src_path: PathBuf) -> anyhow::Result<()> {
let extension = src_path
.extension()
.context("File has no extension")?
.to_str()
.context("Extension cannot be converted to &str")?;
let kind = match extension {
"vert" => naga::ShaderStage::Vertex,
"frag" => naga::ShaderStage::Fragment,
"comp" => naga::ShaderStage::Compute,
_ => anyhow::bail!("Unsupported shader: {}", src_path.display()),
};
let src = read_to_string(src_path.clone())?;
// let spv_path = src_path.with_extension(format!("{}.spv", extension));
let wgsl_path = src_path.with_extension(format!("{}.wgsl", extension));
impl ShaderData {
pub fn load(src_path: PathBuf) -> Result<Self> {
let extension = src_path
.extension()
.context("File has no extension")?
.to_str()
.context("Extension cannot be converted to &str")?;
let kind = match extension {
"vert" => shaderc::ShaderKind::Vertex,
"frag" => shaderc::ShaderKind::Fragment,
"comp" => shaderc::ShaderKind::Compute,
_ => bail!("Unsupported shader: {}", src_path.display()),
};
let mut parser = Parser::default();
let options = Options::from(kind);
let module = match parser.parse(&options, &src) {
Ok(it) => it,
Err(errors) => {
anyhow::bail!(
"Failed to compile shader: {}\nErrors:\n{:#?}",
src_path.display(),
errors
);
}
};
let src = read_to_string(src_path.clone())?;
let spv_path = src_path.with_extension(format!("{}.spv", extension));
let info = naga::valid::Validator::new(
naga::valid::ValidationFlags::all(),
naga::valid::Capabilities::empty(),
)
.validate(&module)?;
let flags = wgsl::WriterFlags::empty();
std::fs::write(wgsl_path, wgsl::write_string(&module, &info, flags)?)?;
Ok(Self {
src,
src_path,
spv_path,
kind,
})
}
// let flags = spv::WriterFlags::DEBUG | spv::WriterFlags::ADJUST_COORDINATE_SPACE;
// let options = spv::Options {
// flags,
// ..Default::default()
// };
// let spv = spv::write_vec(&module, &info, &options)?;
// let dis = rspirv::dr::load_words(spv)
// .expect("Unable to disassemble shader")
// .disassemble();
// std::fs::write(spv_path, &spv)?;
Ok(())
}
fn main() -> Result<()> {
fn main() -> anyhow::Result<()> {
// This tells cargo to rerun this script if something in /src/ changes.
println!("cargo:rerun-if-changed=src/*");
// Collect all shaders recursively within /src/
// UDPATED!
let mut shader_paths = Vec::new();
shader_paths.extend(glob("./src/**/*.vert")?);
shader_paths.extend(glob("./src/**/*.frag")?);
shader_paths.extend(glob("./src/**/*.comp")?);
let shader_paths = {
let mut data = Vec::new();
data.extend(glob("./src/**/*.vert")?);
data.extend(glob("./src/**/*.frag")?);
data.extend(glob("./src/**/*.comp")?);
data
};
// UPDATED!
// This is parallelized
let shaders = shader_paths
shader_paths
.into_par_iter()
.map(|glob_result| ShaderData::load(glob_result?))
.collect::<Vec<Result<_>>>()
.map(|glob_result| load_shader(glob_result?))
.collect::<Vec<anyhow::Result<_>>>()
.into_iter()
.collect::<Result<Vec<_>>>();
let mut compiler = shaderc::Compiler::new().context("Unable to create shader compiler")?;
// This can't be parallelized. The [shaderc::Compiler] is not
// thread safe. Also, it creates a lot of resources. You could
// spawn multiple processes to handle this, but it would probably
// be better just to only compile shaders that have been changed
// recently.
for shader in shaders? {
let compiled = compiler.compile_into_spirv(
&shader.src,
shader.kind,
shader.src_path.to_str().unwrap(),
"main",
None,
)?;
write(shader.spv_path, compiled.as_binary_u8())?;
}
.collect::<anyhow::Result<Vec<_>>>()?;
// This tells cargo to rerun this script if something in /res/ changes.
// println!("cargo:rerun-if-changed=res/*");
// let out_dir = env::var("OUT_DIR")?;
// let mut copy_options = CopyOptions::new();
// copy_options.overwrite = true;
// let mut paths_to_copy = Vec::new();
// copy_options.overwrite = true;
// paths_to_copy.push("res/");
// copy_items(&paths_to_copy, out_dir, &copy_options)?;

@ -1,3 +1,5 @@
use std::num::NonZeroU32;
use crate::model::Vertex;
use anyhow::*;
@ -18,6 +20,7 @@ pub struct RenderPipelineBuilder<'a> {
sample_count: u32,
sample_mask: u64,
alpha_to_coverage_enabled: bool,
multiview: Option<NonZeroU32>,
}
impl<'a> RenderPipelineBuilder<'a> {
@ -39,6 +42,7 @@ impl<'a> RenderPipelineBuilder<'a> {
sample_count: 1,
sample_mask: !0,
alpha_to_coverage_enabled: false,
multiview: None,
}
}
@ -167,6 +171,11 @@ impl<'a> RenderPipelineBuilder<'a> {
self
}
pub fn multiview(&mut self, value: Option<NonZeroU32>) -> &mut Self {
self.multiview = value;
self
}
pub fn build(&mut self, device: &wgpu::Device) -> Result<wgpu::RenderPipeline> {
// We need a layout
if self.layout.is_none() {
@ -229,6 +238,7 @@ impl<'a> RenderPipelineBuilder<'a> {
mask: self.sample_mask,
alpha_to_coverage_enabled: self.alpha_to_coverage_enabled,
},
multiview: self.multiview,
});
Ok(pipeline)
}

@ -0,0 +1,43 @@
struct SimulationData {
clear_color: vec4<f32>;
canvas_size: vec2<f32>;
mouse_pos: vec2<f32>;
time: vec2<f32>;
};
struct FragmentOutput {
[[location(0)]] frag_color: vec4<f32>;
};
var<private> clip_coords_1: vec3<f32>;
var<private> frag_color: vec4<f32>;
[[group(0), binding(0)]]
var<uniform> global: SimulationData;
fn main_1() {
var t: f32;
var uv: vec3<f32>;
var col: vec4<f32>;
let _e10 = global.time;
t = _e10.x;
let _e13 = clip_coords_1;
uv = ((_e13 * 0.5) + vec3<f32>(0.5));
let _e20 = uv;
let _e28 = t;
let _e30 = uv;
let _e36 = global.clear_color;
let _e38 = t;
col = mix(vec4<f32>(_e30.x, _e30.y, _e30.z, 1.0), _e36, vec4<f32>(sin(_e38)));
let _e43 = col;
frag_color = _e43;
return;
}
[[stage(fragment)]]
fn main([[location(0)]] clip_coords: vec3<f32>) -> FragmentOutput {
clip_coords_1 = clip_coords;
main_1();
let _e15 = frag_color;
return FragmentOutput(_e15);
}

@ -107,13 +107,14 @@ pub struct ShaderCanvasBuilder<'a> {
impl<'a> ShaderCanvasBuilder<'a> {
pub fn new() -> Self {
Self {
canvas_size: [256.0; 2],
clear_color: [0.0, 0.0, 0.0, 1.0],
label: None,
display_format: None,
frag_code: Some(wgpu::include_spirv!("shader_canvas.frag.spv")),
vert_code: Some(wgpu::include_spirv!("shader_canvas.vert.spv")),
frag_code: Some(wgpu::include_wgsl!("shader_canvas.frag.wgsl")),
vert_code: Some(wgpu::include_wgsl!("shader_canvas.vert.wgsl")),
}
}
@ -229,8 +230,8 @@ impl<'a> ShaderCanvasBuilder<'a> {
cull_mode: Some(wgpu::Face::Back),
// Setting this to anything other than Fill requires Features::NON_FILL_POLYGON_MODE
polygon_mode: wgpu::PolygonMode::Fill,
// Requires Features::DEPTH_CLAMPING
clamp_depth: false,
// Requires Features::DEPTH_CLIP_CONTROL
unclipped_depth: false,
// Requires Features::CONSERVATIVE_RASTERIZATION
conservative: false,
},
@ -240,6 +241,9 @@ impl<'a> ShaderCanvasBuilder<'a> {
mask: !0,
alpha_to_coverage_enabled: false,
},
// If the pipeline will be used with a multiview render pass, this
// indicates how many array layers the attachments will have.
multiview: None,
});
Ok(ShaderCanvas {

@ -2,19 +2,23 @@
layout(location=0) out vec3 clip_coords;
const vec3 positions[6] = vec3[6](
// Bottom left triangle
vec3(-1.0, 1.0, 0.0),
vec3(-1.0, -1.0, 0.0),
vec3(1.0, -1.0, 0.0),
// const vec3 positions[6] = vec3[6](
// // Bottom left triangle
// vec3(-1.0, 1.0, 0.0),
// vec3(-1.0, -1.0, 0.0),
// vec3(1.0, -1.0, 0.0),
// Top right triangle
vec3(-1.0, 1.0, 0.0),
vec3(1.0, -1.0, 0.0),
vec3(1.0, 1.0, 0.0)
);
// // Top right triangle
// vec3(-1.0, 1.0, 0.0),
// vec3(1.0, -1.0, 0.0),
// vec3(1.0, 1.0, 0.0)
// );
void main() {
gl_Position = vec4(positions[gl_VertexIndex], 1.0);
float x = float(((uint(gl_VertexIndex) + 2u) / 3u)%2u);
float y = float(((uint(gl_VertexIndex) + 1u) / 3u)%2u);
gl_Position = vec4(-1.0f + x*2.0f, -1.0f+y*2.0f, 0.0f, 1.0f);
// gl_Position = vec4(positions[gl_VertexIndex], 1.0);
clip_coords = gl_Position.xyz;
}

@ -0,0 +1,33 @@
struct VertexOutput {
[[location(0)]] clip_coords: vec3<f32>;
[[builtin(position)]] member: vec4<f32>;
};
var<private> clip_coords: vec3<f32>;
var<private> gl_VertexIndex: u32;
var<private> gl_Position: vec4<f32>;
fn main_1() {
var x: f32;
var y: f32;
let _e2 = gl_VertexIndex;
x = f32((((u32(_e2) + 2u) / 3u) % 2u));
let _e12 = gl_VertexIndex;
y = f32((((u32(_e12) + 1u) / 3u) % 2u));
let _e25 = x;
let _e31 = y;
gl_Position = vec4<f32>((-(1.0) + (_e25 * 2.0)), (-(1.0) + (_e31 * 2.0)), 0.0, 1.0);
let _e38 = gl_Position;
clip_coords = _e38.xyz;
return;
}
[[stage(vertex)]]
fn main([[builtin(vertex_index)]] param: u32) -> VertexOutput {
gl_VertexIndex = param;
main_1();
let _e5 = clip_coords;
let _e7 = gl_Position;
return VertexOutput(_e5, _e7);
}

@ -14,8 +14,8 @@ pollster = "0.2"
image = "0.23"
log = "0.4"
tobj = "3.1"
wgpu = "0.11"
winit = "0.25"
wgpu = "0.12"
winit = "0.26"
gif = "0.10.3"
framework = { version = "0.1.0", path = "../framework" }

@ -80,18 +80,5 @@ fn main() -> Result<()> {
write(shader.spv_path, compiled.as_binary_u8())?;
}
// This tells cargo to rerun this script if something in /res/ changes.
println!("cargo:rerun-if-changed=res/*");
let out_dir = env::var("OUT_DIR")?;
let mut copy_options = CopyOptions::new();
copy_options.overwrite = true;
let mut paths_to_copy = Vec::new();
paths_to_copy.push("res/");
match copy_items(&paths_to_copy, out_dir, &copy_options) {
Ok(_) => {}
Err(e) => eprintln!("{}", e),
}
Ok(())
}

@ -1,6 +1,6 @@
extern crate framework;
use anyhow::*;
// use anyhow::*;
use std::{iter, mem, num::NonZeroU32};
async fn run() {
@ -148,7 +148,7 @@ async fn run() {
save_gif("output.gif", &mut frames, 10, texture_size as u16).unwrap();
}
fn save_gif(path: &str, frames: &mut Vec<Vec<u8>>, speed: i32, size: u16) -> Result<()> {
fn save_gif(path: &str, frames: &mut Vec<Vec<u8>>, speed: i32, size: u16) -> anyhow::Result<()> {
use gif::{Encoder, Frame, Repeat, SetParameter};
let mut image = std::fs::File::create(path)?;
@ -201,8 +201,8 @@ fn create_render_pipeline(
cull_mode: Some(wgpu::Face::Back),
// Setting this to anything other than Fill requires Features::NON_FILL_POLYGON_MODE
polygon_mode: wgpu::PolygonMode::Fill,
// Requires Features::DEPTH_CLAMPING
clamp_depth: false,
// Requires Features::DEPTH_CLIP_CONTROL
unclipped_depth: false,
// Requires Features::CONSERVATIVE_RASTERIZATION
conservative: false,
},
@ -212,6 +212,9 @@ fn create_render_pipeline(
mask: !0,
alpha_to_coverage_enabled: false,
},
// If the pipeline will be used with a multiview render pass, this
// indicates how many array layers the attachments will have.
multiview: None,
});
render_pipeline

@ -8,7 +8,7 @@ edition = "2018"
[dependencies]
anyhow = "1.0"
wgpu = "0.11"
wgpu = "0.12"
pollster = "0.2"
imgui = "0.7"
imgui-wgpu = "0.17"

@ -10,13 +10,13 @@ crate-type = ["cdylib", "rlib"]
[dependencies]
cfg-if = "1"
env_logger = "0.9"
winit = "0.25"
winit = "0.26"
anyhow = "1.0"
bytemuck = { version = "1.4", features = [ "derive" ] }
cgmath = "0.18"
pollster = "0.2"
wgpu = { version = "0.11", features = ["spirv"]}
wgpu_glyph = "0.15"
wgpu = { version = "0.12", features = ["spirv"]}
wgpu_glyph = "0.16"
rand = "0.8"
rodio = { version = "0.14", default-features = false, features = ["wav"] }
log = "0.4"
@ -34,8 +34,8 @@ web-sys = { version = "0.3.53", features = [
"Window",
"Element",
]}
winit = { version = "0.25", features = ["web-sys"] }
wgpu = { version = "0.11", features = ["spirv", "webgl"]}
# winit = { version = "0.26", features = ["web-sys"] }
wgpu = { version = "0.12", features = ["spirv", "webgl"]}
[build-dependencies]
anyhow = "1.0"

@ -8,8 +8,9 @@ use naga::front::glsl::Parser;
use rayon::prelude::*;
use std::env;
use std::{fs::read_to_string, path::PathBuf};
use std::result::Result::Ok;
pub fn load_shader(src_path: PathBuf) -> Result<()> {
pub fn load_shader(src_path: PathBuf) -> anyhow::Result<()> {
let extension = src_path
.extension()
.context("File has no extension")?

@ -4,14 +4,14 @@ struct FragmentOutput {
var<private> fColor: vec4<f32>;
fn main1() {
fn main_1() {
fColor = vec4<f32>(f32(1));
return;
}
[[stage(fragment)]]
fn main() -> FragmentOutput {
main1();
main_1();
let e3: vec4<f32> = fColor;
return FragmentOutput(e3);
}

@ -2,19 +2,19 @@ struct VertexOutput {
[[builtin(position)]] member: vec4<f32>;
};
var<private> aPosition1: vec2<f32>;
var<private> aPosition_1: vec2<f32>;
var<private> gl_Position: vec4<f32>;
fn main1() {
let e2: vec2<f32> = aPosition1;
fn main_1() {
let e2: vec2<f32> = aPosition_1;
gl_Position = vec4<f32>(e2, f32(0), f32(1));
return;
}
[[stage(vertex)]]
fn main([[location(0)]] aPosition: vec2<f32>) -> VertexOutput {
aPosition1 = aPosition;
main1();
aPosition_1 = aPosition;
main_1();
let e5: vec4<f32> = gl_Position;
return VertexOutput(e5);
}

@ -275,8 +275,8 @@ fn create_render_pipeline(
cull_mode: Some(wgpu::Face::Back),
// Setting this to anything other than Fill requires Features::NON_FILL_POLYGON_MODE
polygon_mode: wgpu::PolygonMode::Fill,
// Requires Features::DEPTH_CLAMPING
clamp_depth: false,
// Requires Features::DEPTH_CLIP_CONTROL
unclipped_depth: false,
// Requires Features::CONSERVATIVE_RASTERIZATION
conservative: false,
},
@ -286,5 +286,8 @@ fn create_render_pipeline(
mask: !0,
alpha_to_coverage_enabled: false,
},
// If the pipeline will be used with a multiview render pass, this
// indicates how many array layers the attachments will have.
multiview: None,
})
}

@ -0,0 +1,10 @@
[package]
name = "snow"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
anyhow = "1.0"
framework = { version = "0.1", path = "../framework"}

@ -0,0 +1,33 @@
use anyhow::*;
struct Snow {
}
impl framework::Demo for Snow {
fn init(display: &framework::Display) -> Result<Self, Error> {
Ok(Self {
})
}
fn process_mouse(&mut self, dx: f64, dy: f64) {
}
fn resize(&mut self, display: &framework::Display) {
}
fn update(&mut self, display: &framework::Display, dt: std::time::Duration) {
}
fn render(&mut self, display: &mut framework::Display) {
}
}
fn main() {
framework::run::<Snow>();
}

@ -9,10 +9,10 @@ edition = "2018"
[dependencies]
image = "0.23"
raw-window-handle = "0.3"
winit = "0.25"
winit = "0.26"
shaderc = "0.7"
cgmath = "0.18"
wgpu = "0.11"
wgpu = "0.12"
pollster = "0.2"
[[bin]]

@ -111,8 +111,8 @@ async fn run() {
cull_mode: Some(wgpu::Face::Back),
// Setting this to anything other than Fill requires Features::NON_FILL_POLYGON_MODE
polygon_mode: wgpu::PolygonMode::Fill,
// Requires Features::DEPTH_CLAMPING
clamp_depth: false,
// Requires Features::DEPTH_CLIP_CONTROL
unclipped_depth: false,
// Requires Features::CONSERVATIVE_RASTERIZATION
conservative: false,
},
@ -122,6 +122,9 @@ async fn run() {
mask: !0,
alpha_to_coverage_enabled: false,
},
// If the pipeline will be used with a multiview render pass, this
// indicates how many array layers the attachments will have.
multiview: None,
});
let mut encoder =

@ -67,6 +67,6 @@ export default {
<style>
#wasm-example canvas {
background-color: black;
background-color: #abcdef;
}
</style>

@ -9,11 +9,11 @@ For the beginner stuff, we're going to keep things very simple, we'll add things
```toml
[dependencies]
image = "0.23"
winit = "0.25"
winit = "0.26"
cgmath = "0.18"
env_logger = "0.9"
log = "0.4"
wgpu = "0.11"
wgpu = "0.12"
pollster = "0.2"
```

@ -194,8 +194,8 @@ Two things to note here:
cull_mode: Some(wgpu::Face::Back),
// Setting this to anything other than Fill requires Features::NON_FILL_POLYGON_MODE
polygon_mode: wgpu::PolygonMode::Fill,
// Requires Features::DEPTH_CLAMPING
clamp_depth: false,
// Requires Features::DEPTH_CLIP_CONTROL
unclipped_depth: false,
// Requires Features::CONSERVATIVE_RASTERIZATION
conservative: false,
},

@ -156,7 +156,7 @@ There are 2 options:
Mipmaps are a complex topic, and will require [their own section in the future](/todo). For now, we can say that `mipmap_filter` functions similar to `(mag/min)_filter` as it tells the sampler how to blend between mipmaps.
I'm using some defaults for the other fields. If you want to see what they are, check [the wgpu docs](https://docs.rs/wgpu/0.11.0/wgpu/struct.SamplerDescriptor.html).
I'm using some defaults for the other fields. If you want to see what they are, check [the wgpu docs](https://docs.rs/wgpu/0.12.0/wgpu/struct.SamplerDescriptor.html).
All these different resources are nice and all, but they don't do us much good if we can't plug them in anywhere. This is where `BindGroup`s and `PipelineLayout`s come in.
@ -429,11 +429,11 @@ For convenience sake, let's pull our texture code into its module. We'll first n
[dependencies]
image = "0.23"
cgmath = "0.18"
winit = "0.25"
winit = "0.26"
env_logger = "0.9"
log = "0.4"
pollster = "0.2"
wgpu = "0.11"
wgpu = "0.12"
bytemuck = { version = "1.4", features = [ "derive" ] }
anyhow = "1.0" // NEW!
```

@ -6,7 +6,7 @@ Instancing allows us to draw the same object multiple times with different prope
We don't want to use this method for performance reasons. Updating the uniform buffer for each instance would require multiple buffer copies each frame. On top of that, our method to update the uniform buffer currently requires use to create a new buffer to store the updated data. That's a lot of time wasted between draw calls.
If we look at the parameters for the `draw_indexed` function [in the wgpu docs](https://docs.rs/wgpu/0.11.0/wgpu/struct.RenderPass.html#method.draw_indexed), we can see a solution to our problem.
If we look at the parameters for the `draw_indexed` function [in the wgpu docs](https://docs.rs/wgpu/0.12.0/wgpu/struct.RenderPass.html#method.draw_indexed), we can see a solution to our problem.
```rust
pub fn draw_indexed(

@ -148,8 +148,8 @@ fn create_render_pipeline(
cull_mode: Some(wgpu::Face::Back),
// Setting this to anything other than Fill requires Features::NON_FILL_POLYGON_MODE
polygon_mode: wgpu::PolygonMode::Fill,
// Requires Features::DEPTH_CLAMPING
clamp_depth: false,
// Requires Features::DEPTH_CLIP_CONTROL
unclipped_depth: false,
// Requires Features::CONSERVATIVE_RASTERIZATION
conservative: false,
},

@ -8,7 +8,7 @@ I would have released this sooner, but I wanted to add support for touch so that
If you want to check out the demo, just head over to [the write up](../showcase/pong/#wasm-support)
## 0.11 further changes to Surface
## 0.12 further changes to Surface
`SwapchainFrame` is no longer a thing. Instead `get_current_texture` will return a `SurfaceTexture` directly. This means that getting a frame to draw to looks somethings like this:

@ -264,12 +264,12 @@ In order for wasm-pack to work properly I first needed to add some dependencies:
[dependencies]
cfg-if = "1"
env_logger = "0.9"
winit = "0.25"
winit = "0.26"
anyhow = "1.0"
bytemuck = { version = "1.4", features = [ "derive" ] }
cgmath = "0.18"
pollster = "0.2"
wgpu = { version = "0.11", features = ["spirv"]}
wgpu = { version = "0.12", features = ["spirv"]}
wgpu_glyph = "0.15"
rand = "0.8"
rodio = { version = "0.14", default-features = false, features = ["wav"] }
@ -289,7 +289,7 @@ web-sys = { version = "0.3.53", features = [
"Element",
]}
winit = { version = "0.25", features = ["web-sys"] }
wgpu = { version = "0.11", features = ["spirv", "webgl"]}
wgpu = { version = "0.12", features = ["spirv", "webgl"]}
```
I'll highlight a few of these:

Loading…
Cancel
Save