Skip to content

Commit

Permalink
render/wgpu: Update wgpu to 0.18.0, naga to 0.14.1, naga_oil to 0.11.…
Browse files Browse the repository at this point in the history
…0, egui to 0.24.1
  • Loading branch information
torokati44 committed Dec 14, 2023
1 parent 4e689c6 commit bf9cf92
Show file tree
Hide file tree
Showing 20 changed files with 180 additions and 124 deletions.
189 changes: 114 additions & 75 deletions Cargo.lock

Large diffs are not rendered by default.

18 changes: 8 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ version = "0.1.0"
# gc-arena = { git = "https://github.com/kyren/gc-arena", rev = "efd89fc683c6bb456af3e226c33763cb822645e9" }
tracing = "0.1.40"
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
naga = { version = "0.13.0", features = ["validate", "wgsl-out"] }
naga_oil = "0.9.0"
wgpu = "0.17.1"
egui = "0.23.0"
naga = { version = "0.14.1", features = ["validate", "wgsl-out"] }
naga_oil = "0.11.0"
wgpu = "0.18.0"
egui = "0.24.1"

# Don't optimize build scripts and macros.
[profile.release.build-override]
Expand Down Expand Up @@ -84,10 +84,8 @@ inherits = "release"
[profile.web-wasm-extensions]
inherits = "release"

# The `v0.17` branch is a single backport commit ahead of the `v0.17.2` release,
# which we need. FIXME: Remove when wgpu `v0.18` is released and we can switch to it.
[patch.crates-io]
wgpu = { git = "https://github.com/gfx-rs/wgpu", branch = "v0.17" }

[patch.'https://github.com/gfx-rs/naga']
naga = "0.13.0"
# These are needed because https://github.com/gfx-rs/wgpu/pull/4778
# is not yet in the latest wgpu release. TODO: Remove when it is.
wgpu = { git = "https://github.com/gfx-rs/wgpu", branch = "v0.18" }
naga = { git = "https://github.com/gfx-rs/wgpu", branch = "v0.18" }
2 changes: 1 addition & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ hashbrown = { version = "0.14.3", features = ["raw"] }
scopeguard = "1.2.0"
fluent-templates = "0.8.0"
egui = { workspace = true, optional = true }
egui_extras = { version = "0.23.0", optional = true }
egui_extras = { version = "0.24.1", optional = true }
png = { version = "0.17.10", optional = true }
flv-rs = { path = "../flv" }
async-channel = "2.1.1"
Expand Down
6 changes: 3 additions & 3 deletions desktop/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ version.workspace = true
clap = { version = "4.4.11", features = ["derive"] }
cpal = "0.15.2"
egui = { workspace = true }
egui_extras = { version = "0.23.0", features = ["image"] }
egui-wgpu = { version = "0.23.0", features = ["winit"] }
egui_extras = { version = "0.24.1", features = ["image"] }
egui-wgpu = { version = "0.24.1", features = ["winit"] }
image = { version = "0.24", features = ["png"] }
egui-winit = "0.23.0"
egui-winit = "0.24.1"
fontdb = "0.16"
ruffle_core = { path = "../core", features = ["audio", "clap", "mp3", "nellymoser", "default_compatibility_rules", "egui", "default_font"] }
ruffle_render = { path = "../render", features = ["clap"] }
Expand Down
24 changes: 15 additions & 9 deletions desktop/src/gui/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::gui::movie::{MovieView, MovieViewRenderer};
use crate::gui::{RuffleGui, MENU_HEIGHT};
use crate::player::{PlayerController, PlayerOptions};
use anyhow::anyhow;
use egui::Context;
use egui::{Context, ViewportId};
use fontdb::{Database, Family, Query, Source};
use ruffle_core::Player;
use ruffle_render_wgpu::backend::{request_adapter_and_device, WgpuRenderBackend};
Expand Down Expand Up @@ -55,7 +55,7 @@ impl GuiController {
}
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
backends: backend,
dx12_shader_compiler: wgpu::Dx12Compiler::default(),
..Default::default()
});
let surface = unsafe { instance.create_surface(window.as_ref()) }?;
let (adapter, device, queue) = futures::executor::block_on(request_adapter_and_device(
Expand Down Expand Up @@ -90,9 +90,9 @@ impl GuiController {
if let Some(Theme::Light) = window.theme() {
egui_ctx.set_visuals(egui::Visuals::light());
}
egui_ctx.set_pixels_per_point(window.scale_factor() as f32);

let mut egui_winit = egui_winit::State::new(event_loop);
egui_winit.set_pixels_per_point(window.scale_factor() as f32);
let mut egui_winit = egui_winit::State::new(ViewportId::ROOT, window.as_ref(), None, None);
egui_winit.set_max_texture_side(descriptors.limits.max_texture_dimension_2d as usize);

let movie_view_renderer = Arc::new(MovieViewRenderer::new(
Expand Down Expand Up @@ -165,7 +165,7 @@ impl GuiController {
self.egui_ctx.set_visuals(visuals);
}

let response = self.egui_winit.on_event(&self.egui_ctx, event);
let response = self.egui_winit.on_window_event(&self.egui_ctx, event);
if response.repaint {
self.window.request_redraw();
}
Expand Down Expand Up @@ -214,7 +214,11 @@ impl GuiController {
},
);
});
self.repaint_after = full_output.repaint_after;
self.repaint_after = full_output
.viewport_output
.get(&ViewportId::ROOT)
.expect("Root viewport must exist")
.repaint_delay;

// If we're not in a UI, tell egui which cursor we prefer to use instead
if !self.egui_ctx.wants_pointer_input() {
Expand All @@ -232,7 +236,9 @@ impl GuiController {
full_output.platform_output,
);

let clipped_primitives = self.egui_ctx.tessellate(full_output.shapes);
let clipped_primitives = self
.egui_ctx
.tessellate(full_output.shapes, full_output.pixels_per_point);

let scale_factor = self.window.scale_factor() as f32;
let screen_descriptor = egui_wgpu::renderer::ScreenDescriptor {
Expand Down Expand Up @@ -283,11 +289,11 @@ impl GuiController {
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(wgpu::Color::BLACK),
store: true,
store: wgpu::StoreOp::Store,
},
})],
depth_stencil_attachment: None,
label: Some("egui_render"),
..Default::default()
});

if let Some(movie_view) = movie_view {
Expand Down
2 changes: 1 addition & 1 deletion exporter/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ fn main() -> Result<()> {
let opt: Opt = Opt::parse();
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
backends: opt.graphics.into(),
dx12_shader_compiler: wgpu::Dx12Compiler::default(),
..Default::default()
});
let (adapter, device, queue) = futures::executor::block_on(request_adapter_and_device(
opt.graphics.into(),
Expand Down
3 changes: 3 additions & 0 deletions render/naga-agal/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,7 @@ impl<'a> NagaBuilder<'a> {
location: 0,
interpolation: None,
sampling: None,
second_blend_source: false,
}),
offset: 0,
}],
Expand All @@ -501,6 +502,7 @@ impl<'a> NagaBuilder<'a> {
location: 0,
interpolation: None,
sampling: None,
second_blend_source: false,
}),
});
}
Expand Down Expand Up @@ -653,6 +655,7 @@ impl<'a> NagaBuilder<'a> {
location: index as u32,
interpolation: None,
sampling: None,
second_blend_source: false,
}),
});

Expand Down
2 changes: 2 additions & 0 deletions render/naga-agal/src/varying.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ impl<'a> NagaBuilder<'a> {
location: index as u32,
interpolation: Some(naga::Interpolation::Perspective),
sampling: None,
second_blend_source: false,
}),
offset: 0,
});
Expand All @@ -85,6 +86,7 @@ impl<'a> NagaBuilder<'a> {
location: index as u32,
interpolation: Some(Interpolation::Perspective),
sampling: None,
second_blend_source: false,
}),
});
let arg_index = self.func.arguments.len() - 1;
Expand Down
2 changes: 2 additions & 0 deletions render/naga-pixelbender/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ impl<'a> ShaderBuilder<'a> {
location: 0,
interpolation: Some(naga::Interpolation::Perspective),
sampling: Some(naga::Sampling::Center),
second_blend_source: false,
}),
});

Expand All @@ -268,6 +269,7 @@ impl<'a> ShaderBuilder<'a> {
location: 0,
interpolation: None,
sampling: None,
second_blend_source: false,
}),
});

Expand Down
8 changes: 4 additions & 4 deletions render/wgpu/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl WgpuRenderBackend<SwapChainTarget> {
pub async fn for_canvas(canvas: web_sys::HtmlCanvasElement) -> Result<Self, Error> {
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
backends: wgpu::Backends::BROWSER_WEBGPU | wgpu::Backends::GL,
dx12_shader_compiler: wgpu::Dx12Compiler::default(),
..Default::default()
});
let surface = instance.create_surface_from_canvas(canvas)?;
let (adapter, device, queue) = request_adapter_and_device(
Expand Down Expand Up @@ -97,7 +97,7 @@ impl WgpuRenderBackend<SwapChainTarget> {
}
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
backends: backend,
dx12_shader_compiler: wgpu::Dx12Compiler::default(),
..Default::default()
});
let surface = unsafe { instance.create_surface(window) }?;
let (adapter, device, queue) = futures::executor::block_on(request_adapter_and_device(
Expand Down Expand Up @@ -144,7 +144,7 @@ impl WgpuRenderBackend<crate::target::TextureTarget> {
}
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
backends: backend,
dx12_shader_compiler: wgpu::Dx12Compiler::default(),
..Default::default()
});
let (adapter, device, queue) = futures::executor::block_on(request_adapter_and_device(
backend,
Expand Down Expand Up @@ -981,7 +981,7 @@ impl<T: RenderTarget + 'static> RenderBackend for WgpuRenderBackend<T> {
resolve_target: None,
ops: wgpu::Operations {
load: wgpu::LoadOp::Clear(wgpu::Color::TRANSPARENT),
store: true,
store: wgpu::StoreOp::Store,
},
}),
1,
Expand Down
7 changes: 4 additions & 3 deletions render/wgpu/src/context3d/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,11 @@ impl WgpuContext3D {
view: depth_view,
depth_ops: Some(wgpu::Operations {
load: depth_load,
store: true,
store: wgpu::StoreOp::Store,
}),
stencil_ops: Some(wgpu::Operations {
load: stencil_load,
store: true,
store: wgpu::StoreOp::Store,
}),
})
} else {
Expand All @@ -283,10 +283,11 @@ impl WgpuContext3D {
resolve_target: self.current_texture_resolve_view.as_deref(),
ops: wgpu::Operations {
load: color_load,
store: true,
store: wgpu::StoreOp::Store,
},
})],
depth_stencil_attachment,
..Default::default()
});
pass.set_bind_group(0, self.bind_group.as_ref().unwrap(), &[]);
pass.set_pipeline(
Expand Down
2 changes: 1 addition & 1 deletion render/wgpu/src/filters/bevel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ impl BevelFilter {
let mut render_pass = draw_encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
label: create_debug_label!("Bevel filter").as_deref(),
color_attachments: &[target.color_attachments()],
depth_stencil_attachment: None,
..Default::default()
});
render_pass.set_pipeline(pipeline);

Expand Down
4 changes: 2 additions & 2 deletions render/wgpu/src/filters/blur.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ impl BlurFilter {
let mut render_pass = draw_encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
label: create_debug_label!("Blur filter").as_deref(),
color_attachments: &[destination.color_attachments()],
depth_stencil_attachment: None,
..Default::default()
});
render_pass.set_pipeline(pipeline);

Expand Down Expand Up @@ -381,7 +381,7 @@ impl BlurFilter {
let mut render_pass = draw_encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
label: create_debug_label!("Blur filter").as_deref(),
color_attachments: &[destination.color_attachments()],
depth_stencil_attachment: None,
..Default::default()
});
render_pass.set_pipeline(pipeline);

Expand Down
2 changes: 1 addition & 1 deletion render/wgpu/src/filters/color_matrix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ impl ColorMatrixFilter {
let mut render_pass = draw_encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
label: create_debug_label!("Color matrix filter").as_deref(),
color_attachments: &[target.color_attachments()],
depth_stencil_attachment: None,
..Default::default()
});
render_pass.set_pipeline(pipeline);

Expand Down
2 changes: 1 addition & 1 deletion render/wgpu/src/filters/displacement_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ impl DisplacementMapFilter {
let mut render_pass = draw_encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
label: create_debug_label!("Displacement map filter").as_deref(),
color_attachments: &[target.color_attachments()],
depth_stencil_attachment: None,
..Default::default()
});
render_pass.set_pipeline(pipeline);

Expand Down
2 changes: 1 addition & 1 deletion render/wgpu/src/filters/glow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ impl GlowFilter {
let mut render_pass = draw_encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
label: create_debug_label!("Glow filter").as_deref(),
color_attachments: &[target.color_attachments()],
depth_stencil_attachment: None,
..Default::default()
});
render_pass.set_pipeline(pipeline);

Expand Down
9 changes: 3 additions & 6 deletions render/wgpu/src/pixel_bender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use ruffle_render::{
use wgpu::util::StagingBelt;
use wgpu::{
BindGroupEntry, BindingResource, BlendComponent, BufferDescriptor, BufferUsages,
ColorTargetState, ColorWrites, CommandEncoder, FrontFace, ImageCopyTexture, PipelineLayout,
ColorTargetState, ColorWrites, CommandEncoder, ImageCopyTexture, PipelineLayout,
RenderPipeline, RenderPipelineDescriptor, SamplerBindingType, ShaderModuleDescriptor,
TextureDescriptor, TextureFormat, TextureView, VertexState,
};
Expand Down Expand Up @@ -71,11 +71,7 @@ impl PixelBenderWgpuShader {
write_mask: ColorWrites::all(),
})],
}),
primitive: wgpu::PrimitiveState {
front_face: FrontFace::Ccw,
cull_mode: None,
..Default::default()
},
primitive: Default::default(),
depth_stencil: None,
multisample: wgpu::MultisampleState {
count: samples,
Expand Down Expand Up @@ -558,6 +554,7 @@ pub(super) fn run_pixelbender_shader_impl(
label: Some("PixelBender render pass"),
color_attachments: &[color_attachment],
depth_stencil_attachment: None,
..Default::default()
});
render_pass.set_bind_group(0, &bind_group, &[]);
render_pass.set_pipeline(pipeline);
Expand Down
2 changes: 2 additions & 0 deletions render/wgpu/src/surface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ impl Surface {
} else {
None
},
..Default::default()
});
render_pass.set_bind_group(0, target.globals().bind_group(), &[]);
let mut renderer = CommandRenderer::new(
Expand Down Expand Up @@ -298,6 +299,7 @@ impl Surface {
} else {
None
},
..Default::default()
});
render_pass.set_bind_group(0, target.globals().bind_group(), &[]);

Expand Down
9 changes: 6 additions & 3 deletions render/wgpu/src/surface/target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ impl CommandTarget {
encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
label: create_debug_label!("Clearing command target").as_deref(),
color_attachments: &[self.color_attachments()],
depth_stencil_attachment: None,
..Default::default()
});
}
}
Expand Down Expand Up @@ -367,7 +367,10 @@ impl CommandTarget {
Some(wgpu::RenderPassColorAttachment {
view: self.frame_buffer.view(),
resolve_target: self.resolve_buffer.as_ref().map(|b| b.view()),
ops: wgpu::Operations { load, store: true },
ops: wgpu::Operations {
load,
store: wgpu::StoreOp::Store,
},
})
}

Expand All @@ -393,7 +396,7 @@ impl CommandTarget {
} else {
wgpu::LoadOp::Load
},
store: true,
store: wgpu::StoreOp::Store,
}),
})
}
Expand Down
Loading

0 comments on commit bf9cf92

Please sign in to comment.