Skip to content

Commit

Permalink
[WIP] Update wgpu to 0.8
Browse files Browse the repository at this point in the history
- Also update other dependencies
- TODO: imgui-wgpu is blocking this. See: Yatekii/imgui-wgpu-rs#54
  • Loading branch information
parasyte committed May 5, 2021
1 parent 316400e commit 6975914
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 25 deletions.
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ include = [
pollster = "0.2"
raw-window-handle = "0.3"
thiserror = "1.0"
ultraviolet = "0.7"
wgpu = "0.7"
ultraviolet = "0.8"
wgpu = "0.8"

[dev-dependencies]
pixels-mocks = { path = "internals/pixels-mocks" }
winit = "0.24"

[workspace]
resolver = "2"
members = [
"examples/*",
"internals/*",
Expand Down
2 changes: 1 addition & 1 deletion examples/custom-shader/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ fn create_noise_renderer(pixels: &Pixels) -> (wgpu::TextureView, NoiseRenderer)
size: pixels::wgpu::Extent3d {
width: WIDTH,
height: HEIGHT,
depth: 1,
depth_or_array_layers: 1,
},
mip_level_count: 1,
sample_count: 1,
Expand Down
14 changes: 8 additions & 6 deletions examples/custom-shader/src/renderers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ impl NoiseRenderer {
},
wgpu::BindGroupEntry {
binding: 2,
resource: wgpu::BindingResource::Buffer {
resource: wgpu::BindingResource::Buffer(wgpu::BufferBinding {
buffer: &time_buffer,
offset: 0,
size: None,
},
}),
},
],
});
Expand All @@ -114,8 +114,10 @@ impl NoiseRenderer {
entry_point: "main",
targets: &[wgpu::ColorTargetState {
format: wgpu::TextureFormat::Bgra8UnormSrgb,
color_blend: wgpu::BlendState::REPLACE,
alpha_blend: wgpu::BlendState::REPLACE,
blend: Some(wgpu::BlendState {
color: wgpu::BlendComponent::REPLACE,
alpha: wgpu::BlendComponent::REPLACE,
}),
write_mask: wgpu::ColorWrite::ALL,
}],
}),
Expand All @@ -139,8 +141,8 @@ impl NoiseRenderer {
) {
let mut rpass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
label: Some("NoiseRenderer render pass"),
color_attachments: &[wgpu::RenderPassColorAttachmentDescriptor {
attachment: render_target,
color_attachments: &[wgpu::RenderPassColorAttachment {
view: render_target,
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(wgpu::Color::BLACK),
Expand Down
6 changes: 3 additions & 3 deletions examples/egui-winit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ optimize = ["log/release_max_level_warn"]
default = ["optimize"]

[dependencies]
egui = "0.10"
egui_wgpu_backend = { git = "https://github.com/hasenbanck/egui_wgpu_backend.git", rev = "9d03ad345d15d1e44165849b242d3562fdf3e859" }
egui_winit_platform = { git = "https://github.com/hasenbanck/egui_winit_platform.git", rev = "17298250e9721e8bf2c1d4a17b3e22777f8cb2e8" }
egui = "0.11"
egui_wgpu_backend = "0.7"
egui_winit_platform = "0.6"
env_logger = "0.8"
log = "0.4"
pixels = { path = "../.." }
Expand Down
3 changes: 2 additions & 1 deletion examples/egui-winit/src/gui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ impl Gui {

ui.separator();

ui.horizontal_for_text(egui::TextStyle::Body, |ui| {
ui.horizontal(|ui| {
ui.spacing_mut().item_spacing.x /= 2.0;
ui.label("Learn more about egui at");
ui.hyperlink("https://docs.rs/egui");
});
Expand Down
2 changes: 1 addition & 1 deletion examples/minimal-fltk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ optimize = ["log/release_max_level_warn"]
default = ["optimize"]

[dependencies]
fltk = { version = "0.15", features = ["no-pango"] }
fltk = { version = "1.0", features = ["no-images", "no-pango"] }
env_logger = "0.8"
log = "0.4"
pixels = { path = "../.." }
2 changes: 1 addition & 1 deletion src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ pub(crate) fn create_backing_texture(
let texture_extent = wgpu::Extent3d {
width,
height,
depth: 1,
depth_or_array_layers: 1,
};

let texture = device.create_texture(&wgpu::TextureDescriptor {
Expand Down
9 changes: 5 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
pub use crate::builder::PixelsBuilder;
pub use crate::renderers::ScalingRenderer;
pub use raw_window_handle;
use std::num::NonZeroU32;
pub use wgpu;

use raw_window_handle::HasRawWindowHandle;
Expand Down Expand Up @@ -359,16 +360,16 @@ impl Pixels {
let bytes_per_row =
(self.context.texture_extent.width as f32 * self.context.texture_format_size) as u32;
self.context.queue.write_texture(
wgpu::TextureCopyView {
wgpu::ImageCopyTexture {
texture: &self.context.texture,
mip_level: 0,
origin: wgpu::Origin3d { x: 0, y: 0, z: 0 },
},
&self.pixels,
wgpu::TextureDataLayout {
wgpu::ImageDataLayout {
offset: 0,
bytes_per_row,
rows_per_image: self.context.texture_extent.height,
bytes_per_row: NonZeroU32::new(bytes_per_row),
rows_per_image: NonZeroU32::new(self.context.texture_extent.height),
},
self.context.texture_extent,
);
Expand Down
14 changes: 8 additions & 6 deletions src/renderers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ impl ScalingRenderer {
},
wgpu::BindGroupEntry {
binding: 2,
resource: wgpu::BindingResource::Buffer {
resource: wgpu::BindingResource::Buffer(wgpu::BufferBinding {
buffer: &uniform_buffer,
offset: 0,
size: None,
},
}),
},
],
});
Expand All @@ -132,8 +132,10 @@ impl ScalingRenderer {
entry_point: "main",
targets: &[wgpu::ColorTargetState {
format: render_texture_format,
color_blend: wgpu::BlendState::REPLACE,
alpha_blend: wgpu::BlendState::REPLACE,
blend: Some(wgpu::BlendState {
color: wgpu::BlendComponent::REPLACE,
alpha: wgpu::BlendComponent::REPLACE,
}),
write_mask: wgpu::ColorWrite::ALL,
}],
}),
Expand All @@ -153,8 +155,8 @@ impl ScalingRenderer {
// Draw the updated texture to the render target
let mut rpass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
label: Some("pixels_scaling_renderer_render_pass"),
color_attachments: &[wgpu::RenderPassColorAttachmentDescriptor {
attachment: render_target,
color_attachments: &[wgpu::RenderPassColorAttachment {
view: render_target,
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(wgpu::Color::BLACK),
Expand Down

0 comments on commit 6975914

Please sign in to comment.