diff --git a/code/showcase/compute/Cargo.toml b/code/showcase/compute/Cargo.toml index c60bc4a5..22ad127b 100644 --- a/code/showcase/compute/Cargo.toml +++ b/code/showcase/compute/Cargo.toml @@ -14,7 +14,7 @@ image = "0.23" log = "0.4" rayon = "1.4" tobj = "2.0" -wgpu = { version = "0.8", features = ["trace"] } +wgpu = { version = "0.8", features = ["trace", "cross"] } winit = "0.24" [build-dependencies] diff --git a/code/showcase/compute/src/model.rs b/code/showcase/compute/src/model.rs index 7789bcc7..fb4ebe3e 100644 --- a/code/showcase/compute/src/model.rs +++ b/code/showcase/compute/src/model.rs @@ -19,6 +19,7 @@ pub struct ModelVertex { normal: [f32; 3], tangent: [f32; 3], bitangent: [f32; 3], + padding: [u32; 2], } impl Vertex for ModelVertex { @@ -294,20 +295,18 @@ impl ModelLoader { m.mesh.positions[i * 3], m.mesh.positions[i * 3 + 1], m.mesh.positions[i * 3 + 2], - ] - .into(), + ], // tex_coords: [m.mesh.texcoords[i * 2], m.mesh.texcoords[i * 2 + 1], 0.0] - tex_coords: [m.mesh.texcoords[i * 2], m.mesh.texcoords[i * 2 + 1]] - .into(), + tex_coords: [m.mesh.texcoords[i * 2], m.mesh.texcoords[i * 2 + 1]], normal: [ m.mesh.normals[i * 3], m.mesh.normals[i * 3 + 1], m.mesh.normals[i * 3 + 2], - ] - .into(), + ], // We'll calculate these later - tangent: [0.0; 3].into(), - bitangent: [0.0; 3].into(), + tangent: [0.0; 3], + bitangent: [0.0; 3], + padding: [0; 2], } }) .collect::>(); diff --git a/code/showcase/compute/src/model_load.comp b/code/showcase/compute/src/model_load.comp index 717d2b8f..0bc57101 100644 --- a/code/showcase/compute/src/model_load.comp +++ b/code/showcase/compute/src/model_load.comp @@ -8,6 +8,7 @@ struct ModelVertex { float nx; float ny; float nz; float tx; float ty; float tz; float bx; float by; float bz; + uint pad0; uint pad1; }; layout(std430, set=0, binding=0) buffer SrcVertexBuffer { diff --git a/code/showcase/compute/src/model_load.comp.spv b/code/showcase/compute/src/model_load.comp.spv index 9593e9b6..97dbb23e 100644 Binary files a/code/showcase/compute/src/model_load.comp.spv and b/code/showcase/compute/src/model_load.comp.spv differ diff --git a/code/showcase/compute/src/pipeline.rs b/code/showcase/compute/src/pipeline.rs index ed71a5aa..685d69df 100644 --- a/code/showcase/compute/src/pipeline.rs +++ b/code/showcase/compute/src/pipeline.rs @@ -40,9 +40,11 @@ pub fn create_render_pipeline( color_format: wgpu::TextureFormat, depth_format: Option, vertex_layouts: &[wgpu::VertexBufferLayout], - vs_src: wgpu::ShaderModuleDescriptor, - fs_src: wgpu::ShaderModuleDescriptor, + mut vs_src: wgpu::ShaderModuleDescriptor, + mut fs_src: wgpu::ShaderModuleDescriptor, ) -> wgpu::RenderPipeline { + vs_src.flags &= wgpu::ShaderFlags::VALIDATION; + fs_src.flags &= wgpu::ShaderFlags::VALIDATION; let vs_module = device.create_shader_module(&vs_src); let fs_module = device.create_shader_module(&fs_src); diff --git a/docs/news/README.md b/docs/news/README.md index 6f5eb898..f1ea526a 100644 --- a/docs/news/README.md +++ b/docs/news/README.md @@ -6,6 +6,16 @@ Originally I wanted to wait until the WGSL spec fully stabilized, but due to some issues with the GLSL code, I've decided to switch over the code now. Why'll GLSL is supported by WebGPU, it's currently secondary to WGSL. I'll keep an example of how to use GLSL (and maybe add HLSL and Metal as well), but I'm going to use WGSL from now on. +### Shaderc has been removed + +I've been thinking about doing this for a while now. Because shaderc is a c library, it often has to be redownloaded during builds. This has been slowing down my ability to add new content and maintain old content. I had been considering switching to naga earlier, but some of my shaders (notably the lighting ones) weren't compiling with naga as I was using features not available for compatibility reasons (`inverse` is not available in all languages targeting spirv). + +Since I needed to make a bunch of changes to the code base to make the glsl, and because I wanted to switch the tutorial to WGSL anyways, I decided to bite the bullet and recode everything in WGSL and remove shaderc from the tutorials. + +### Some of the showcase examples are broken + +The `wgpu_glyph`, and `imgui-wgpu` crates currently depend on `wgpu` 0.7, which is causing the `pong` and `imgui-demo` to not compile. I decided to excluded them from the workspace until the underlying crates update to using `wgpu` 0.8. (Feel free to submit a issue or even PR when that happens!) + ### Various API changes * The `depth` field is now `depth_or_array_layers` diff --git a/docs/showcase/imgui-demo/README.md b/docs/showcase/imgui-demo/README.md index 7c9305ff..d52f0893 100644 --- a/docs/showcase/imgui-demo/README.md +++ b/docs/showcase/imgui-demo/README.md @@ -1,5 +1,11 @@ # Basic Imgui Demo +
+ +This example is currently broken for 0.8. Some of the dependecies used are still on wgpu 0.7 which causes some dependency conflicts. Once the `imgui-wgpu` crate has been updated to use wgpu 0.8 I'll update the dependencies and remove this warning. + +
+ This is not an in depth guid on how to use Imgui. But here are some of the basics you'll need to get started. We'll need to import [imgui-rs](https://docs.rs/imgui), [imgui-wgpu](https://docs.rs/imgui-wgpu), and [imgui-winit-support](https://docs.rs/imgui-winit-support). ```toml diff --git a/docs/showcase/pong/README.md b/docs/showcase/pong/README.md index b54c0325..2531237b 100644 --- a/docs/showcase/pong/README.md +++ b/docs/showcase/pong/README.md @@ -1,5 +1,11 @@ # Pong +
+ +This example is currently broken for 0.8. Some of the dependecies used are still on wgpu 0.7 which causes some dependency conflicts. Once the `imgui-wgpu` crate has been updated to use wgpu 0.8 I'll update the dependencies and remove this warning. + +
+ ![](./pong.png) Practically the "Hello World!" of games. Pong has been remade thousands of times. I know Pong. You know Pong. We all know Pong. That being said, this time I wanted to put a little more effort than most people do. This showcase has a basic menu system, sounds, and different game states.