Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to wgpu 0.12, egui 0.18 #861

Closed
wants to merge 6 commits into from
Closed
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 examples/ui/egui/circle_packing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ fn view(app: &App, model: &Model, frame: Frame) {

draw.to_frame(app, &frame).unwrap();

model.egui.draw_to_frame(&frame).unwrap();
model.egui.draw_to_frame(&frame);
}

fn intersects(circle: &Circle, circles: &Vec<Circle>) -> bool {
Expand Down
2 changes: 1 addition & 1 deletion examples/ui/egui/tune_color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ fn view(app: &App, model: &Model, frame: Frame) {
draw.to_frame(app, &frame).unwrap();

// Do this as the last operation on your frame.
model.egui.draw_to_frame(&frame).unwrap();
model.egui.draw_to_frame(&frame);
}

fn edit_hsv(ui: &mut egui::Ui, color: &mut Hsv) {
Expand Down
2 changes: 1 addition & 1 deletion nannou/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ serde_json = "1"
toml = "0.5"
walkdir = "2"
web-sys = { version = "0.3.55", optional = true }
wgpu_upstream = { version = "0.11.1", package = "wgpu" }
wgpu_upstream = { version = "0.12.0", package = "wgpu" }
winit = "0.26"

[features]
Expand Down
29 changes: 19 additions & 10 deletions nannou/src/draw/renderer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ pub struct Renderer {
glyph_cache_texture: wgpu::Texture,
depth_texture: wgpu::Texture,
depth_texture_view: wgpu::TextureView,
default_texture: wgpu::Texture,
_default_texture: wgpu::Texture,
default_texture_view: wgpu::TextureView,
uniform_bind_group_layout: wgpu::BindGroupLayout,
uniform_bind_group: wgpu::BindGroup,
Expand Down Expand Up @@ -393,6 +393,7 @@ impl Renderer {
// Create the glyph cache texture.
let text_sampler_desc = wgpu::SamplerBuilder::new().into_descriptor();
let text_sampler_filtering = wgpu::sampler_filtering(&text_sampler_desc);
let text_sampler_binding_ty = sampler_binding_type(text_sampler_filtering);
let text_sampler = device.create_sampler(&text_sampler_desc);
let glyph_cache_texture = wgpu::TextureBuilder::new()
.size(glyph_cache_size)
Expand Down Expand Up @@ -430,7 +431,7 @@ impl Renderer {
create_uniform_bind_group(device, &uniform_bind_group_layout, &uniform_buffer);

// Bind group for text.
let text_bind_group_layout = create_text_bind_group_layout(device, text_sampler_filtering);
let text_bind_group_layout = create_text_bind_group_layout(device, text_sampler_binding_ty);
let text_bind_group = create_text_bind_group(
device,
&text_bind_group_layout,
Expand Down Expand Up @@ -462,7 +463,7 @@ impl Renderer {
glyph_cache_texture,
depth_texture,
depth_texture_view,
default_texture,
_default_texture: default_texture,
default_texture_view,
uniform_bind_group_layout,
uniform_bind_group,
Expand Down Expand Up @@ -647,9 +648,10 @@ impl Renderer {
let color_blend = curr_ctxt.blend.color.clone();
let alpha_blend = curr_ctxt.blend.alpha.clone();
let sampler_filtering = wgpu::sampler_filtering(&curr_ctxt.sampler);
let sampler_binding_ty = sampler_binding_type(sampler_filtering);
new_pipeline_ids.insert(
new_pipeline_id,
(color_blend, alpha_blend, sampler_filtering),
(color_blend, alpha_blend, sampler_binding_ty),
);
let cmd = RenderCommand::SetPipeline(new_pipeline_id);
self.render_commands.push(cmd);
Expand Down Expand Up @@ -707,14 +709,14 @@ impl Renderer {
// Clear new combos that we already have.
new_pipeline_ids.retain(|id, _| !self.pipelines.contains_key(id));
// Create new render pipelines as necessary.
for (new_id, (color_blend, alpha_blend, sampler_filtering)) in new_pipeline_ids {
for (new_id, (color_blend, alpha_blend, sampler_binding_ty)) in new_pipeline_ids {
let bind_group_layout = self
.texture_bind_group_layouts
.entry(new_id.texture_sample_type)
.or_insert_with(|| {
create_texture_bind_group_layout(
device,
sampler_filtering,
sampler_binding_ty,
new_id.texture_sample_type,
)
});
Expand Down Expand Up @@ -1045,9 +1047,9 @@ fn create_uniform_bind_group_layout(device: &wgpu::Device) -> wgpu::BindGroupLay
.build(device)
}

fn create_text_bind_group_layout(device: &wgpu::Device, filtering: bool) -> wgpu::BindGroupLayout {
fn create_text_bind_group_layout(device: &wgpu::Device, sampler_ty: wgpu::SamplerBindingType) -> wgpu::BindGroupLayout {
wgpu::BindGroupLayoutBuilder::new()
.sampler(wgpu::ShaderStages::FRAGMENT, filtering)
.sampler(wgpu::ShaderStages::FRAGMENT, sampler_ty)
.texture(
wgpu::ShaderStages::FRAGMENT,
false,
Expand All @@ -1057,13 +1059,20 @@ fn create_text_bind_group_layout(device: &wgpu::Device, filtering: bool) -> wgpu
.build(device)
}

fn sampler_binding_type(filtering: bool) -> wgpu::SamplerBindingType {
match filtering {
true => wgpu::SamplerBindingType::Filtering,
false => wgpu::SamplerBindingType::NonFiltering,
}
}

fn create_texture_bind_group_layout(
device: &wgpu::Device,
filtering: bool,
sampler_binding_ty: wgpu::SamplerBindingType,
texture_sample_type: wgpu::TextureSampleType,
) -> wgpu::BindGroupLayout {
wgpu::BindGroupLayoutBuilder::new()
.sampler(wgpu::ShaderStages::FRAGMENT, filtering)
.sampler(wgpu::ShaderStages::FRAGMENT, sampler_binding_ty)
.texture(
wgpu::ShaderStages::FRAGMENT,
false,
Expand Down
1 change: 0 additions & 1 deletion nannou/src/draw/renderer/shaders/vs.wgsl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[[block]]
struct Data {
proj: mat4x4<f32>;
};
Expand Down
4 changes: 2 additions & 2 deletions nannou_egui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ repository = "https://github.com/AlexEne/nannou_egui"
readme = "../README.md"

[dependencies]
egui_wgpu_backend = "0.14"
egui = "0.15.0"
egui-wgpu = "0.18"
egui = "0.18"
winit = "0.26"
nannou = { version = "0.18.1", path = "../nannou" }
Loading