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

render,desktop: Port to wgpu v0.20.0, switch to egui master #16168

Merged
merged 2 commits into from
May 16, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
140 changes: 46 additions & 94 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ version = "0.1.0"
[workspace.dependencies]
tracing = "0.1.40"
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
naga = { version = "0.19.2", features = ["wgsl-out"] }
wgpu = "0.19.4"
egui = "0.27.2"
naga = { version = "0.20.0", features = ["wgsl-out"] }
wgpu = "0.20.0"
egui = { git = "https://github.com/emilk/egui.git", rev = "738ea75453567c5f17a543e68aec8c48097cae7b" }
clap = { version = "4.5.4", features = ["derive"] }
anyhow = "1.0"
slotmap = "1.0.7"
Expand Down
2 changes: 1 addition & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ hashbrown = { version = "0.14.5", features = ["raw"] }
scopeguard = "1.2.0"
fluent-templates = "0.9.4"
egui = { workspace = true, optional = true }
egui_extras = { version = "0.27.2", optional = true }
egui_extras = { git = "https://github.com/emilk/egui.git", rev = "738ea75453567c5f17a543e68aec8c48097cae7b", optional = true }
png = { version = "0.17.13", optional = true }
flv-rs = { path = "../flv" }
async-channel = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion core/src/debug_ui/avm1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl Avm1ObjectWindow {
Window::new(object_name(object))
.id(Id::new(object.as_ptr()))
.open(&mut keep_open)
.scroll2([true, true])
.scroll([true, true])
.show(egui_ctx, |ui| {
Grid::new(ui.id().with("properties"))
.num_columns(2)
Expand Down
2 changes: 1 addition & 1 deletion core/src/debug_ui/avm2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl Avm2ObjectWindow {
Window::new(object_name(activation.context.gc_context, object))
.id(Id::new(object.as_ptr()))
.open(&mut keep_open)
.scroll2([true, true])
.scroll([true, true])
.show(egui_ctx, |ui| {
ui.horizontal(|ui| {
ui.selectable_value(&mut self.open_panel, Panel::Information, "Information");
Expand Down
2 changes: 1 addition & 1 deletion core/src/debug_ui/display_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ impl DisplayObjectWindow {
Window::new(summary_name(object))
.id(Id::new(object.as_ptr()))
.open(&mut keep_open)
.scroll2([true, true])
.scroll([true, true])
.show(egui_ctx, |ui| {
ui.horizontal(|ui| {
ui.selectable_value(&mut self.open_panel, Panel::Position, "Position");
Expand Down
2 changes: 1 addition & 1 deletion core/src/debug_ui/display_object/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl DisplayObjectSearchWindow {

Window::new("Display Object Picker")
.open(&mut keep_open)
.scroll2([true, true])
.scroll([true, true])
.show(egui_ctx, |ui| {
ui.horizontal(|ui| {
ui.checkbox(&mut self.include_hidden, "Include Hidden");
Expand Down
4 changes: 2 additions & 2 deletions core/src/debug_ui/movie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl MovieListWindow {

Window::new("Known Movie List")
.open(&mut keep_open)
.scroll2([true, true])
.scroll([true, true])
.show(egui_ctx, |ui| {
let movies = context.library.known_movies();

Expand Down Expand Up @@ -81,7 +81,7 @@ impl MovieWindow {
Window::new(movie_name(&movie))
.id(Id::new(Arc::as_ptr(&movie)))
.open(&mut keep_open)
.scroll2([true, true])
.scroll([true, true])
.show(egui_ctx, |ui| {
ui.horizontal(|ui| {
ui.selectable_value(&mut self.open_panel, Panel::Information, "Information");
Expand Down
14 changes: 11 additions & 3 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,14 @@ license-files = [
# Lint level for when multiple versions of the same crate are detected
multiple-versions = "warn"

# We are manually pinning `tracing-tracy` to match the version used by
# `profiling`, but this can get stale easily.
deny = [{ name = "tracy-client", deny-multiple-versions = true }]
deny = [
# We are manually pinning `tracing-tracy` to match the version used by
# `profiling`, but this can get stale easily.
{ name = "tracy-client", deny-multiple-versions = true },
# Having multiple versions of this can silently cause images (such as
# the logo in the about dialog) in egui to not appear.
{ name = "image", deny-multiple-versions = true },
]

[sources]
# Lint level for what to happen when a crate from a crate registry that is not
Expand All @@ -72,6 +77,9 @@ unknown-git = "deny"
# github.com organizations to allow git sources for
github = [
"ruffle-rs",
# TODO: Remove once egui is updated to the first release
# with https://github.com/emilk/egui/pull/4160 in it.
"emilk",
]

[advisories]
Expand Down
6 changes: 3 additions & 3 deletions desktop/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ workspace = true
clap = { workspace = true }
cpal = "0.15.3"
egui = { workspace = true }
egui_extras = { version = "0.27.2", features = ["image"] }
egui-wgpu = { version = "0.27.2", features = ["winit"] }
egui_extras = { git = "https://github.com/emilk/egui.git", rev = "738ea75453567c5f17a543e68aec8c48097cae7b", features = ["image"] }
egui-wgpu = { git = "https://github.com/emilk/egui.git", rev = "738ea75453567c5f17a543e68aec8c48097cae7b", features = ["winit"] }
image = { workspace = true, features = ["png"] }
egui-winit = "0.27.2"
egui-winit = { git = "https://github.com/emilk/egui.git", rev = "738ea75453567c5f17a543e68aec8c48097cae7b" }
fontdb = "0.17"
ruffle_core = { path = "../core", features = ["audio", "clap", "mp3", "nellymoser", "default_compatibility_rules", "egui"] }
ruffle_render = { path = "../render", features = ["clap"] }
Expand Down
2 changes: 2 additions & 0 deletions desktop/src/gui/movie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ impl MovieViewRenderer {
// 1: vec2 texture coordinates
attributes: &wgpu::vertex_attr_array![0 => Float32x2, 1 => Float32x2],
}],
compilation_options: Default::default(),
},
primitive: wgpu::PrimitiveState {
topology: wgpu::PrimitiveTopology::TriangleList,
Expand Down Expand Up @@ -116,6 +117,7 @@ impl MovieViewRenderer {
blend: Some(wgpu::BlendState::REPLACE),
write_mask: wgpu::ColorWrites::ALL,
})],
compilation_options: Default::default(),
}),
multiview: None,
});
Expand Down
17 changes: 6 additions & 11 deletions render/naga-agal/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::num::NonZeroU32;
use naga::{
AddressSpace, ArraySize, Block, BuiltIn, Constant, DerivativeControl, EntryPoint,
FunctionArgument, FunctionResult, GlobalVariable, ImageClass, ImageDimension, Literal,
Override, ResourceBinding, Scalar, ShaderStage, StructMember, SwizzleComponent, UnaryOperator,
ResourceBinding, Scalar, ShaderStage, StructMember, SwizzleComponent, UnaryOperator,
};
use naga::{BinaryOperator, MathFunction};
use naga::{
Expand Down Expand Up @@ -185,13 +185,12 @@ impl VertexAttributeFormat {

let const_expr_f32_zero = builder
.module
.const_expressions
.global_expressions
.append(Expression::Literal(Literal::F32(0.0)), Span::UNDEFINED);

let constant_zero = builder.module.constants.append(
Constant {
name: None,
r#override: Override::None,
ty: builder.f32_type,
init: const_expr_f32_zero,
},
Expand All @@ -209,13 +208,12 @@ impl VertexAttributeFormat {

let const_expr_f32_1 = builder
.module
.const_expressions
.global_expressions
.append(Expression::Literal(Literal::F32(1.0)), Span::UNDEFINED);

let constant_one = builder.module.constants.append(
Constant {
name: None,
r#override: Override::None,
ty: builder.f32_type,
init: const_expr_f32_1,
},
Expand Down Expand Up @@ -683,14 +681,13 @@ impl<'a> NagaBuilder<'a> {
}

fn emit_const_register_load(&mut self, index: usize) -> Result<Handle<Expression>> {
let const_value_expr = self.module.const_expressions.append(
let const_value_expr = self.module.global_expressions.append(
Expression::Literal(Literal::U32(index as u32)),
Span::UNDEFINED,
);
let index_const = self.module.constants.append(
Constant {
name: None,
r#override: Override::None,
ty: self.u32_type,
init: const_value_expr,
},
Expand Down Expand Up @@ -859,15 +856,14 @@ impl<'a> NagaBuilder<'a> {
convert: Some(4),
});

let const_indirect_offset = self.module.const_expressions.append(
let const_indirect_offset = self.module.global_expressions.append(
Expression::Literal(Literal::U32(source.indirect_offset as u32)),
Span::UNDEFINED,
);

let offset_constant = self.module.constants.append(
Constant {
name: None,
r#override: Override::None,
ty: self.u32_type,
init: const_indirect_offset,
},
Expand Down Expand Up @@ -1602,14 +1598,13 @@ impl<'a> NagaBuilder<'a> {

let constant_f32_zero = self
.module
.const_expressions
.global_expressions
.append(Expression::Literal(Literal::F32(0.0)), Span::UNDEFINED);

// Check `source < 0.0`.
let constant_zero = self.module.constants.append(
Constant {
name: None,
r#override: Override::None,
ty: self.f32_type,
init: constant_f32_zero,
},
Expand Down
2 changes: 2 additions & 0 deletions render/wgpu/src/context3d/current_pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@ impl CurrentPipeline {
module: &compiled_shaders.vertex_module,
entry_point: naga_agal::SHADER_ENTRY_POINT,
buffers: &wgpu_vertex_buffers,
compilation_options: Default::default(),
},
fragment: Some(wgpu::FragmentState {
module: &compiled_shaders.fragment_module,
Expand All @@ -520,6 +521,7 @@ impl CurrentPipeline {
}),
write_mask: self.color_mask,
})],
compilation_options: Default::default(),
}),
primitive: wgpu::PrimitiveState {
// Stage3d appears to use clockwise winding:
Expand Down
4 changes: 4 additions & 0 deletions render/wgpu/src/descriptors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ impl Descriptors {
module: &self.shaders.copy_srgb_shader,
entry_point: "main_vertex",
buffers: &VERTEX_BUFFERS_DESCRIPTION_POS,
compilation_options: Default::default(),
},
fragment: Some(wgpu::FragmentState {
module: &self.shaders.copy_srgb_shader,
Expand All @@ -107,6 +108,7 @@ impl Descriptors {
blend: Some(wgpu::BlendState::REPLACE),
write_mask: Default::default(),
})],
compilation_options: Default::default(),
}),
primitive: wgpu::PrimitiveState {
topology: wgpu::PrimitiveTopology::TriangleList,
Expand Down Expand Up @@ -163,6 +165,7 @@ impl Descriptors {
module: &self.shaders.copy_shader,
entry_point: "main_vertex",
buffers: &VERTEX_BUFFERS_DESCRIPTION_POS,
compilation_options: Default::default(),
},
fragment: Some(wgpu::FragmentState {
module: &self.shaders.copy_shader,
Expand All @@ -174,6 +177,7 @@ impl Descriptors {
blend: Some(wgpu::BlendState::REPLACE),
write_mask: Default::default(),
})],
compilation_options: Default::default(),
}),
primitive: wgpu::PrimitiveState {
topology: wgpu::PrimitiveTopology::TriangleList,
Expand Down
2 changes: 2 additions & 0 deletions render/wgpu/src/filters/bevel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ impl BevelFilter {
module: &descriptors.shaders.bevel_filter,
entry_point: "main_vertex",
buffers: &VERTEX_BUFFERS_DESCRIPTION_FILTERS_WITH_DOUBLE_BLUR,
compilation_options: Default::default(),
},
primitive: wgpu::PrimitiveState {
topology: wgpu::PrimitiveTopology::TriangleList,
Expand All @@ -142,6 +143,7 @@ impl BevelFilter {
module: &descriptors.shaders.bevel_filter,
entry_point: "main_fragment",
targets: &[Some(wgpu::TextureFormat::Rgba8Unorm.into())],
compilation_options: Default::default(),
}),
multiview: None,
})
Expand Down
2 changes: 2 additions & 0 deletions render/wgpu/src/filters/blur.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ impl BlurFilter {
module: &descriptors.shaders.blur_filter,
entry_point: "main_vertex",
buffers: &VERTEX_BUFFERS_DESCRIPTION_FILTERS,
compilation_options: Default::default(),
},
primitive: wgpu::PrimitiveState {
topology: wgpu::PrimitiveTopology::TriangleList,
Expand All @@ -137,6 +138,7 @@ impl BlurFilter {
module: &descriptors.shaders.blur_filter,
entry_point: "main_fragment",
targets: &[Some(wgpu::TextureFormat::Rgba8Unorm.into())],
compilation_options: Default::default(),
}),
multiview: None,
})
Expand Down
2 changes: 2 additions & 0 deletions render/wgpu/src/filters/color_matrix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ impl ColorMatrixFilter {
module: &descriptors.shaders.color_matrix_filter,
entry_point: "main_vertex",
buffers: &VERTEX_BUFFERS_DESCRIPTION_FILTERS,
compilation_options: Default::default(),
},
primitive: wgpu::PrimitiveState {
topology: wgpu::PrimitiveTopology::TriangleList,
Expand All @@ -118,6 +119,7 @@ impl ColorMatrixFilter {
module: &descriptors.shaders.color_matrix_filter,
entry_point: "main_fragment",
targets: &[Some(wgpu::TextureFormat::Rgba8Unorm.into())],
compilation_options: Default::default(),
}),
multiview: None,
})
Expand Down
2 changes: 2 additions & 0 deletions render/wgpu/src/filters/displacement_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ impl DisplacementMapFilter {
module: &descriptors.shaders.displacement_map_filter,
entry_point: "main_vertex",
buffers: &VERTEX_BUFFERS_DESCRIPTION_FILTERS,
compilation_options: Default::default(),
},
primitive: wgpu::PrimitiveState {
topology: wgpu::PrimitiveTopology::TriangleList,
Expand All @@ -155,6 +156,7 @@ impl DisplacementMapFilter {
module: &descriptors.shaders.displacement_map_filter,
entry_point: "main_fragment",
targets: &[Some(wgpu::TextureFormat::Rgba8Unorm.into())],
compilation_options: Default::default(),
}),
multiview: None,
})
Expand Down
2 changes: 2 additions & 0 deletions render/wgpu/src/filters/glow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ impl GlowFilter {
module: &descriptors.shaders.glow_filter,
entry_point: "main_vertex",
buffers: &VERTEX_BUFFERS_DESCRIPTION_FILTERS_WITH_BLUR,
compilation_options: Default::default(),
},
primitive: wgpu::PrimitiveState {
topology: wgpu::PrimitiveTopology::TriangleList,
Expand All @@ -141,6 +142,7 @@ impl GlowFilter {
module: &descriptors.shaders.glow_filter,
entry_point: "main_fragment",
targets: &[Some(wgpu::TextureFormat::Rgba8Unorm.into())],
compilation_options: Default::default(),
}),
multiview: None,
})
Expand Down
2 changes: 2 additions & 0 deletions render/wgpu/src/pipelines.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,13 @@ fn create_pipeline_descriptor<'a>(
module: vertex_shader,
entry_point: "main_vertex",
buffers: vertex_buffer_layout,
compilation_options: Default::default(),
},
fragment: Some(wgpu::FragmentState {
module: fragment_shader,
entry_point: "main_fragment",
targets: color_target_state,
compilation_options: Default::default(),
}),
primitive: wgpu::PrimitiveState {
topology: wgpu::PrimitiveTopology::TriangleList,
Expand Down
2 changes: 2 additions & 0 deletions render/wgpu/src/pixel_bender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ impl PixelBenderWgpuShader {
module: &self.vertex_shader,
entry_point: naga_pixelbender::VERTEX_SHADER_ENTRYPOINT,
buffers: &VERTEX_BUFFERS_DESCRIPTION_FILTERS,
compilation_options: Default::default(),
},
fragment: Some(wgpu::FragmentState {
module: &self.fragment_shader,
Expand All @@ -78,6 +79,7 @@ impl PixelBenderWgpuShader {
}),
write_mask: ColorWrites::all(),
})],
compilation_options: Default::default(),
}),
primitive: Default::default(),
depth_stencil: None,
Expand Down