Skip to content

Commit d26259d

Browse files
authored
Update wgpu 0.29 (#9)
* Update wgpu 0.29 * Allow collapsible match
1 parent cb4b396 commit d26259d

File tree

18 files changed

+123
-137
lines changed

18 files changed

+123
-137
lines changed

Cargo.toml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "glass"
3-
version = "0.4.0"
3+
version = "0.5.0"
44
edition = "2021"
55

66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@@ -14,18 +14,18 @@ indexmap = "2.9"
1414
pollster = "0.4"
1515
image = "0.25"
1616
bytemuck = { version = "1.20", features = ["derive"] }
17-
wgpu = { version = "27.0", features = ["naga-ir"] }
17+
wgpu = { version = "29.0", features = ["naga-ir"] }
1818
winit = { version = "0.30" }
1919

2020
[dev-dependencies]
21-
egui = { version = "0.33" }
22-
egui-wgpu = { version = "0.33" }
23-
egui-winit = { version = "0.33" }
24-
egui_extras = { version = "0.33" }
25-
egui_demo_lib = { version = "0.33" }
21+
egui = { version = "0.34" }
22+
egui-wgpu = { version = "0.34" }
23+
egui-winit = { version = "0.34" }
24+
egui_extras = { version = "0.34" }
25+
egui_demo_lib = { version = "0.34" }
2626
rapier2d = { version = "0.31.0", features = ["default", "debug-render"] }
27-
rand = "0.9"
28-
glam = "0.30"
27+
rand = "0.10"
28+
glam = "0.32"
2929

3030
[lints.clippy]
3131
blocks_in_conditions = "allow"
@@ -34,6 +34,7 @@ self_named_constructors = "allow"
3434
too_long_first_doc_paragraph = "allow"
3535
uninlined_format_args = "allow"
3636
default_constructed_unit_structs = "allow"
37+
collapsible_match = "allow"
3738

3839
[profile.dev]
3940
opt-level = 3

examples/egui_gui.rs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use glass::{
66
window::{GlassWindow, RenderData, WindowConfig},
77
Glass, GlassApp, GlassConfig, GlassContext, GlassError,
88
};
9-
use wgpu::{CommandBuffer, Device, Queue, StoreOp};
9+
use wgpu::{CommandBuffer, StoreOp};
1010
use winit::{event::WindowEvent, event_loop::ActiveEventLoop, window::WindowId};
1111

1212
fn main() -> Result<(), GlassError> {
@@ -39,13 +39,9 @@ impl GlassApp for GuiApp {
3939
}
4040

4141
fn update(&mut self, context: &mut GlassContext) {
42-
let device = context.device();
43-
let queue = context.queue();
4442
context
45-
.primary_render_window()
46-
.render_default(device, queue, self, |app, render_data| {
47-
render_egui(app, device, queue, render_data)
48-
});
43+
.primary_render_window_mut()
44+
.render_default(self, render_egui);
4945
}
5046
}
5147

@@ -112,13 +108,10 @@ fn update_egui_with_winit_event(
112108
}
113109
}
114110

115-
fn render_egui(
116-
app: &mut GuiApp,
117-
device: &Device,
118-
queue: &Queue,
119-
render_data: RenderData,
120-
) -> Option<Vec<CommandBuffer>> {
111+
fn render_egui(app: &mut GuiApp, render_data: RenderData) -> Option<Vec<CommandBuffer>> {
121112
let window = render_data.window;
113+
let device = window.device_context().device();
114+
let queue = window.device_context().queue();
122115
let view = render_data
123116
.frame
124117
.texture
@@ -136,7 +129,7 @@ fn render_egui(
136129
textures_delta,
137130
pixels_per_point,
138131
..
139-
} = egui_ctx.run(raw_input, |egui_ctx| {
132+
} = egui_ctx.run_ui(raw_input, |egui_ctx| {
140133
// Ui content
141134
ui_app.ui(egui_ctx);
142135
});
@@ -183,6 +176,7 @@ fn render_egui(
183176
depth_stencil_attachment: None,
184177
timestamp_writes: None,
185178
occlusion_query_set: None,
179+
multiview_mask: None,
186180
});
187181
// Here you would render your scene
188182
// Render Egui

examples/game_of_life/draw.wgsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ struct PushConstants {
33
draw_end: vec2<f32>,
44
draw_radius: f32,
55
}
6-
var<push_constant> pc: PushConstants;
6+
var<immediate> pc: PushConstants;
77

88
@group(0) @binding(0)
99
var data_in: texture_storage_2d<rgba16float, read_write>;

examples/game_of_life/game_of_life.wgsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ struct PushConstants {
33
draw_end: vec2<f32>,
44
draw_radius: f32,
55
}
6-
var<push_constant> pc: PushConstants;
6+
var<immediate> pc: PushConstants;
77

88
@group(0) @binding(0)
99
var image: texture_storage_2d<rgba16float, read_write>;

examples/game_of_life/main.rs

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ use glass::{
1212
use wgpu::{
1313
Backends, BindGroup, BindGroupDescriptor, CommandBuffer, CommandEncoder, ComputePassDescriptor,
1414
ComputePipeline, ComputePipelineDescriptor, Extent3d, InstanceFlags, Limits, MemoryHints,
15-
PowerPreference, PresentMode, PushConstantRange, ShaderStages, StorageTextureAccess, StoreOp,
16-
TextureFormat, TextureUsages,
15+
PowerPreference, PresentMode, StorageTextureAccess, StoreOp, TextureFormat, TextureUsages,
1716
};
1817
use winit::{
1918
event::{ElementState, MouseButton, WindowEvent},
@@ -37,10 +36,10 @@ fn config() -> GlassConfig {
3736
device_config: DeviceConfig {
3837
power_preference: PowerPreference::HighPerformance,
3938
memory_hints: MemoryHints::Performance,
40-
features: wgpu::Features::PUSH_CONSTANTS
39+
features: wgpu::Features::IMMEDIATES
4140
| wgpu::Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES,
4241
limits: Limits {
43-
max_push_constant_size: 128,
42+
max_immediate_size: 128,
4443
..Limits::default()
4544
},
4645
backends: Backends::all(),
@@ -107,12 +106,9 @@ impl GlassApp for GameOfLifeApp {
107106
fn update(&mut self, context: &mut GlassContext) {
108107
run_update(self, context);
109108

110-
context.primary_render_window().render_default(
111-
context.device(),
112-
context.queue(),
113-
self,
114-
render,
115-
);
109+
context
110+
.primary_render_window_mut()
111+
.render_default(self, render);
116112
}
117113
}
118114

@@ -240,6 +236,7 @@ fn render(app: &mut GameOfLifeApp, render_data: RenderData) -> Option<Vec<Comman
240236
depth_stencil_attachment: None,
241237
timestamp_writes: None,
242238
occlusion_query_set: None,
239+
multiview_mask: None,
243240
});
244241
quad_pipeline.draw(
245242
&mut rpass,
@@ -297,7 +294,7 @@ fn draw_game_of_life(
297294
let pc = GameOfLifePushConstants::new(start, end, 10.0);
298295
cpass.set_pipeline(draw_pipeline);
299296
cpass.set_bind_group(0, &data.draw_bind_group, &[]);
300-
cpass.set_push_constants(0, bytemuck::cast_slice(&[pc]));
297+
cpass.set_immediates(0, bytemuck::cast_slice(&[pc]));
301298
cpass.dispatch_workgroups(WIDTH / 8, HEIGHT / 8, 1);
302299
}
303300

@@ -339,7 +336,7 @@ fn update_game_of_life(
339336
let pc = GameOfLifePushConstants::new(Vec2::ZERO, Vec2::ZERO, 0.0);
340337
cpass.set_pipeline(game_of_life_pipeline);
341338
cpass.set_bind_group(0, &update_bind_group, &[]);
342-
cpass.set_push_constants(0, bytemuck::cast_slice(&[pc]));
339+
cpass.set_immediates(0, bytemuck::cast_slice(&[pc]));
343340
cpass.dispatch_workgroups(WIDTH / 8, HEIGHT / 8, 1);
344341

345342
app.count += 1;
@@ -366,7 +363,7 @@ fn init_game_of_life(app: &mut GameOfLifeApp, context: &GlassContext) {
366363
});
367364
cpass.set_pipeline(init_pipeline);
368365
cpass.set_bind_group(0, &data.init_bind_group, &[]);
369-
cpass.set_push_constants(
366+
cpass.set_immediates(
370367
0,
371368
bytemuck::cast_slice(&[GameOfLifePushConstants::new(Vec2::ZERO, Vec2::ZERO, 0.0)]),
372369
);
@@ -535,11 +532,8 @@ fn create_game_of_life_pipeline(
535532
.device()
536533
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
537534
label: Some("Game of Life Init Layout"),
538-
bind_group_layouts: &[&bg_layout],
539-
push_constant_ranges: &[PushConstantRange {
540-
stages: ShaderStages::COMPUTE,
541-
range: 0..std::mem::size_of::<GameOfLifePushConstants>() as u32,
542-
}],
535+
bind_group_layouts: &[Some(&bg_layout)],
536+
immediate_size: size_of::<GameOfLifePushConstants>() as u32,
543537
});
544538
let init_pipeline = context
545539
.device()
@@ -557,11 +551,8 @@ fn create_game_of_life_pipeline(
557551
.device()
558552
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
559553
label: Some("Game of Life Layout"),
560-
bind_group_layouts: &[&bg_layout],
561-
push_constant_ranges: &[PushConstantRange {
562-
stages: ShaderStages::COMPUTE,
563-
range: 0..std::mem::size_of::<GameOfLifePushConstants>() as u32,
564-
}],
554+
bind_group_layouts: &[Some(&bg_layout)],
555+
immediate_size: size_of::<GameOfLifePushConstants>() as u32,
565556
});
566557
let update_pipeline = context
567558
.device()
@@ -578,11 +569,8 @@ fn create_game_of_life_pipeline(
578569
.device()
579570
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
580571
label: Some("Draw Layout"),
581-
bind_group_layouts: &[&dr_layout],
582-
push_constant_ranges: &[PushConstantRange {
583-
stages: ShaderStages::COMPUTE,
584-
range: 0..std::mem::size_of::<GameOfLifePushConstants>() as u32,
585-
}],
572+
bind_group_layouts: &[Some(&dr_layout)],
573+
immediate_size: size_of::<GameOfLifePushConstants>() as u32,
586574
});
587575
let draw_pipeline = context
588576
.device()

examples/hello_world.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,8 @@ struct HelloWorld;
1616

1717
impl GlassApp for HelloWorld {
1818
fn update(&mut self, _context: &mut GlassContext) {
19-
_context.primary_render_window().render_default(
20-
_context.device(),
21-
_context.queue(),
22-
self,
23-
|_, _| None,
24-
);
19+
_context
20+
.primary_render_window_mut()
21+
.render_default(self, |_, _| None);
2522
}
2623
}

examples/lines.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ fn config() -> GlassConfig {
1919
GlassConfig {
2020
device_config: DeviceConfig {
2121
limits: Limits {
22-
max_push_constant_size: 128,
22+
max_immediate_size: 128,
2323
..Default::default()
2424
},
2525
features: Features::POLYGON_MODE_LINE,
@@ -223,13 +223,8 @@ impl GlassApp for LineApp {
223223
narrow_phase,
224224
);
225225

226-
let window = _context.primary_render_window();
227-
window.render_default(
228-
_context.device(),
229-
_context.queue(),
230-
self,
231-
add_render_commands,
232-
);
226+
let window = _context.primary_render_window_mut();
227+
window.render_default(self, add_render_commands);
233228
}
234229
}
235230

@@ -263,6 +258,7 @@ fn add_render_commands(app: &mut LineApp, render_data: RenderData) -> Option<Vec
263258
depth_stencil_attachment: None,
264259
timestamp_writes: None,
265260
occlusion_query_set: None,
261+
multiview_mask: None,
266262
});
267263
for line in lines.lines.iter() {
268264
line_pipeline.draw(&mut rpass, view_proj.to_cols_array_2d(), *line);

examples/multiple_windows/main.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,8 @@ impl GlassApp for MultiWindowApp {
6969
}
7070

7171
fn update(&mut self, context: &mut GlassContext) {
72-
let device = context.device_arc();
73-
let queue = context.queue_arc();
74-
for (_, window) in context.windows().iter() {
75-
window.render_default(&device, &queue, self, render);
72+
for (_, window) in context.windows().iter_mut() {
73+
window.render_default(self, render);
7674
}
7775
}
7876
}
@@ -104,6 +102,7 @@ fn render(_app: &mut MultiWindowApp, render_data: RenderData) -> Option<Vec<Comm
104102
depth_stencil_attachment: None,
105103
timestamp_writes: None,
106104
occlusion_query_set: None,
105+
multiview_mask: None,
107106
});
108107
}
109108
None

examples/quad/main.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ fn config() -> GlassConfig {
3636
device_config: DeviceConfig {
3737
limits: Limits {
3838
// Needed for push constants
39-
max_push_constant_size: 128,
39+
max_immediate_size: 128,
4040
..Default::default()
4141
},
4242
..DeviceConfig::performance()
@@ -66,12 +66,9 @@ impl GlassApp for TreeApp {
6666
}
6767

6868
fn update(&mut self, context: &mut GlassContext) {
69-
context.primary_render_window().render_default(
70-
context.device(),
71-
context.queue(),
72-
self,
73-
render,
74-
);
69+
context
70+
.primary_render_window_mut()
71+
.render_default(self, render);
7572
}
7673
}
7774

@@ -116,6 +113,7 @@ fn render(app: &mut TreeApp, render_data: RenderData) -> Option<Vec<CommandBuffe
116113
depth_stencil_attachment: None,
117114
timestamp_writes: None,
118115
occlusion_query_set: None,
116+
multiview_mask: None,
119117
});
120118
quad_pipeline.draw(
121119
&mut rpass,

examples/sand/main.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,9 @@ impl GlassApp for SandSim {
142142
self.grid.simulate();
143143
self.grid.update_texture(context.queue());
144144

145-
context.primary_render_window().render_default(
146-
context.device(),
147-
context.queue(),
148-
self,
149-
render,
150-
);
145+
context
146+
.primary_render_window_mut()
147+
.render_default(self, render);
151148

152149
self.timer.update();
153150
if let Some(w) = context.primary_render_window_maybe() {
@@ -194,6 +191,7 @@ fn render(app: &mut SandSim, render_data: RenderData) -> Option<Vec<CommandBuffe
194191
depth_stencil_attachment: None,
195192
timestamp_writes: None,
196193
occlusion_query_set: None,
194+
multiview_mask: None,
197195
});
198196
quad_pipeline.draw(
199197
&mut rpass,
@@ -242,7 +240,7 @@ fn config() -> GlassConfig {
242240
device_config: DeviceConfig {
243241
limits: Limits {
244242
// Needed for push constants
245-
max_push_constant_size: 128,
243+
max_immediate_size: 128,
246244
..Default::default()
247245
},
248246
..DeviceConfig::default()

0 commit comments

Comments
 (0)