Merge pull request #133 from rmsc/master

Fix typo in beginner tutorial 4
This commit is contained in:
sotrh 2021-01-18 00:33:49 -07:00 committed by GitHub
commit 6416357063
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 17 additions and 18 deletions

View File

@ -66,8 +66,8 @@ struct State {
queue: wgpu::Queue,
sc_desc: wgpu::SwapChainDescriptor,
swap_chain: wgpu::SwapChain,
render_pipeline: wgpu::RenderPipeline,
size: winit::dpi::PhysicalSize<u32>,
render_pipeline: wgpu::RenderPipeline,
// NEW!
vertex_buffer: wgpu::Buffer,
index_buffer: wgpu::Buffer,
@ -175,11 +175,11 @@ impl State {
queue,
sc_desc,
swap_chain,
size,
render_pipeline,
vertex_buffer,
index_buffer,
num_indices,
size,
}
}

View File

@ -69,8 +69,8 @@ struct State {
queue: wgpu::Queue,
sc_desc: wgpu::SwapChainDescriptor,
swap_chain: wgpu::SwapChain,
render_pipeline: wgpu::RenderPipeline,
size: winit::dpi::PhysicalSize<u32>,
render_pipeline: wgpu::RenderPipeline,
vertex_buffer: wgpu::Buffer,
index_buffer: wgpu::Buffer,
num_indices: u32,
@ -222,13 +222,13 @@ impl State {
queue,
sc_desc,
swap_chain,
size,
render_pipeline,
vertex_buffer,
index_buffer,
num_indices,
diffuse_texture,
diffuse_bind_group,
size,
}
}

View File

@ -214,8 +214,8 @@ struct State {
queue: wgpu::Queue,
sc_desc: wgpu::SwapChainDescriptor,
swap_chain: wgpu::SwapChain,
render_pipeline: wgpu::RenderPipeline,
size: winit::dpi::PhysicalSize<u32>,
render_pipeline: wgpu::RenderPipeline,
vertex_buffer: wgpu::Buffer,
index_buffer: wgpu::Buffer,
num_indices: u32,
@ -415,6 +415,7 @@ impl State {
queue,
sc_desc,
swap_chain,
size,
render_pipeline,
vertex_buffer,
index_buffer,
@ -426,7 +427,6 @@ impl State {
uniform_buffer,
uniform_bind_group,
uniforms,
size,
}
}

View File

@ -512,6 +512,7 @@ impl State {
queue,
sc_desc,
swap_chain,
size,
render_pipeline,
vertex_buffer,
index_buffer,
@ -523,7 +524,6 @@ impl State {
uniform_buffer,
uniform_bind_group,
uniforms,
size,
// NEW!
instances,
instance_buffer,

View File

@ -529,6 +529,7 @@ impl State {
queue,
sc_desc,
swap_chain,
size,
render_pipeline,
vertex_buffer,
index_buffer,
@ -540,7 +541,6 @@ impl State {
uniform_buffer,
uniform_bind_group,
uniforms,
size,
instances,
instance_buffer,
depth_texture,

View File

@ -225,6 +225,7 @@ struct State {
queue: wgpu::Queue,
sc_desc: wgpu::SwapChainDescriptor,
swap_chain: wgpu::SwapChain,
size: winit::dpi::PhysicalSize<u32>,
render_pipeline: wgpu::RenderPipeline,
obj_model: model::Model,
camera: Camera,
@ -236,7 +237,6 @@ struct State {
#[allow(dead_code)]
instance_buffer: wgpu::Buffer,
depth_texture: texture::Texture,
size: winit::dpi::PhysicalSize<u32>,
}
impl State {
@ -444,6 +444,7 @@ impl State {
queue,
sc_desc,
swap_chain,
size,
render_pipeline,
obj_model,
camera,
@ -454,7 +455,6 @@ impl State {
instances,
instance_buffer,
depth_texture,
size,
}
}

View File

@ -209,9 +209,9 @@ Self {
surface,
device,
queue,
size,
sc_desc,
swap_chain,
size,
// NEW!
render_pipeline,
}

View File

@ -89,7 +89,7 @@ struct Vertex {
<div class="note">
If you're struct includes types that don't implement `Pod` and `Zeroable`, you'll need to implement these traits manually. These traits don't require us to implement any methods, so we just need to use the following to get our code to work.
If your struct includes types that don't implement `Pod` and `Zeroable`, you'll need to implement these traits manually. These traits don't require us to implement any methods, so we just need to use the following to get our code to work.
```rust
unsafe impl bytemuck::Pod for Vertex {}
@ -107,9 +107,9 @@ Self {
queue,
sc_desc,
swap_chain,
size,
render_pipeline,
vertex_buffer,
size,
}
```
@ -138,8 +138,8 @@ wgpu::VertexBufferDescriptor {
```
1. The `stride` defines how wide a vertex is. When the shader goes to read the next vertex, it will skip over `stride` number of bytes. In our case, stride will probably be 24 bytes.
2. `step_mode` tells the pipeline how often it should move to the next vertex. This seems redundant in our case, but we can specify `wgpu::InputStepMode::Instance` if we only want the change vertices when we start drawing a new instance. We'll cover instancing in a later tutorial.
3. Vertex attributes describe the individual parts of the vertex. Generally this is a 1:1 mapping with a structs fields which it is in our case.
2. `step_mode` tells the pipeline how often it should move to the next vertex. This seems redundant in our case, but we can specify `wgpu::InputStepMode::Instance` if we only want to change vertices when we start drawing a new instance. We'll cover instancing in a later tutorial.
3. Vertex attributes describe the individual parts of the vertex. Generally this is a 1:1 mapping with a struct's fields, which it is in our case.
4. This defines the `offset` in bytes that this attribute starts. The first attribute is usually zero, and any future attributes are the collective `size_of` the previous attributes data.
5. This tells the shader what location to store this attribute at. For example `layout(location=0) in vec3 x` in the vertex shader would correspond to the position field of the struct, while `layout(location=1) in vec3 x` would be the color field.
6. `format` tells the shader the shape of the attribute. `Float3` corresponds to `vec3` in shader code. The max value we can store in an attribute is `Float4` (`Uint4`, and `Int4` work as well). We'll keep this in mind for when we have to store things that are bigger than `Float4`.
@ -176,7 +176,7 @@ impl Vertex {
<div class="note">
Specifying the attributes as we are now is quite verbose. We could use the `vertex_attr_array` macro provided by wgpu to clean things up a bit. With it our `VertexBufferDescriptor` becomes
Specifying the attributes as we did now is quite verbose. We could use the `vertex_attr_array` macro provided by wgpu to clean things up a bit. With it our `VertexBufferDescriptor` becomes
```rust
wgpu::VertexBufferDescriptor {
@ -388,8 +388,8 @@ Self {
queue,
sc_desc,
swap_chain,
render_pipeline,
size,
render_pipeline,
vertex_buffer,
// NEW!
index_buffer,

View File

@ -225,7 +225,6 @@ struct State {
sc_desc: wgpu::SwapChainDescriptor,
swap_chain: wgpu::SwapChain,
size: winit::dpi::PhysicalSize<u32>,
colour: wgpu::Color,
render_pipeline: wgpu::RenderPipeline,
vertex_buffer: wgpu::Buffer,
index_buffer: wgpu::Buffer,