Skip to content
This repository was archived by the owner on Jun 18, 2021. It is now read-only.

Fix generic bounds on buffer mapping #126

Merged
merged 1 commit into from
Nov 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ version = "0.4"
git = "https://github.com/gfx-rs/wgpu"
rev = "73b33ea76e2f91b3114aa7640b1d60518d39f915"

[dependencies.core]
[dependencies.wgc]
package = "wgpu-core"
version = "0.1"
git = "https://github.com/gfx-rs/wgpu"
Expand Down
3 changes: 2 additions & 1 deletion examples/cube/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#[path = "../framework.rs"]
mod framework;

#[derive(Clone, Copy)]
#[repr(C)]
#[derive(Clone, Copy, zerocopy::AsBytes, zerocopy::FromBytes)]
struct Vertex {
_pos: [f32; 4],
_tex_coord: [f32; 2],
Expand Down
3 changes: 2 additions & 1 deletion examples/mipmap/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ mod framework;

const TEXTURE_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Rgba8UnormSrgb;

#[derive(Clone, Copy)]
#[repr(C)]
#[derive(Clone, Copy, zerocopy::AsBytes, zerocopy::FromBytes)]
struct Vertex {
#[allow(dead_code)]
pos: [f32; 4],
Expand Down
3 changes: 2 additions & 1 deletion examples/msaa-line/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
#[path = "../framework.rs"]
mod framework;

#[derive(Clone, Copy)]
#[repr(C)]
#[derive(Clone, Copy, zerocopy::AsBytes, zerocopy::FromBytes)]
struct Vertex {
_pos: [f32; 2],
_color: [f32; 4],
Expand Down
14 changes: 8 additions & 6 deletions examples/shadow/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ use std::{mem, ops::Range, rc::Rc};
#[path = "../framework.rs"]
mod framework;

#[derive(Clone, Copy)]
#[repr(C)]
#[derive(Clone, Copy, zerocopy::AsBytes, zerocopy::FromBytes)]

struct Vertex {
_pos: [i8; 4],
_normal: [i8; 4],
Expand Down Expand Up @@ -95,7 +97,7 @@ struct Light {
}

#[repr(C)]
#[derive(Clone, Copy)]
#[derive(Clone, Copy, zerocopy::AsBytes, zerocopy::FromBytes)]
struct LightRaw {
proj: [[f32; 4]; 4],
pos: [f32; 4],
Expand Down Expand Up @@ -124,16 +126,16 @@ impl Light {
}

#[repr(C)]
#[derive(Clone, Copy)]
#[derive(Clone, Copy, zerocopy::AsBytes, zerocopy::FromBytes)]
struct ForwardUniforms {
proj: [[f32; 4]; 4],
num_lights: [u32; 4],
}

#[repr(C)]
#[derive(Clone, Copy)]
#[derive(Clone, Copy, zerocopy::AsBytes, zerocopy::FromBytes)]
struct EntityUniforms {
model: cgmath::Matrix4<f32>,
model: [[f32; 4]; 4],
color: [f32; 4],
}

Expand Down Expand Up @@ -700,7 +702,7 @@ impl framework::Example for Example {
entity.mx_world = entity.mx_world * rotation;
}
temp_buf_data.data[i] = EntityUniforms {
model: entity.mx_world.clone(),
model: entity.mx_world.into(),
color: [
entity.color.r as f32,
entity.color.g as f32,
Expand Down
17 changes: 13 additions & 4 deletions examples/skybox/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,14 @@ impl framework::Example for Skybox {
let aspect = sc_desc.width as f32 / sc_desc.height as f32;
let uniforms = Self::generate_uniforms(aspect);
let uniform_buf = device
.create_buffer_mapped(
.create_buffer_mapped::<[[f32; 4]; 4]>(
uniforms.len(),
wgpu::BufferUsage::UNIFORM | wgpu::BufferUsage::COPY_DST,
)
.fill_from_slice(&uniforms);
.fill_from_slice(&[
uniforms[0].into(),
uniforms[1].into(),
]);
let uniform_buf_size = std::mem::size_of::<Uniforms>();

let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
Expand Down Expand Up @@ -276,8 +279,14 @@ impl framework::Example for Skybox {
self.uniforms[1] = self.uniforms[1] * rotation;
let uniform_buf_size = std::mem::size_of::<Uniforms>();
let temp_buf = device
.create_buffer_mapped(2, wgpu::BufferUsage::COPY_SRC)
.fill_from_slice(&self.uniforms);
.create_buffer_mapped::<[[f32; 4]; 4]>(
self.uniforms.len(),
wgpu::BufferUsage::COPY_SRC,
)
.fill_from_slice(&[
self.uniforms[0].into(),
self.uniforms[1].into(),
]);

init_encoder.copy_buffer_to_buffer(
&temp_buf,
Expand Down
Loading