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

wgpu: Update wgpu and naga to 0.19 #14682

Merged
merged 4 commits into from
Jan 21, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
331 changes: 142 additions & 189 deletions Cargo.lock

Large diffs are not rendered by default.

25 changes: 12 additions & 13 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ version = "0.1.0"
[workspace.dependencies]
tracing = "0.1.40"
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
naga = { version = "0.14.2", features = ["validate", "wgsl-out"] }
naga_oil = "0.11.0"
wgpu = "0.18.0"
naga = { version = "0.19.0", features = ["wgsl-out"] }
naga_oil = "0.12.0"
wgpu = "0.19.0"
egui = "0.25.0"

[workspace.lints.rust]
Expand Down Expand Up @@ -95,13 +95,12 @@ inherits = "release"
inherits = "release"

[patch.crates-io]
# 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" }

# https://github.com/emilk/egui/pull/3812
egui = { git = "https://github.com/ruffle-rs/egui", branch = "consume_keys"}
egui_extras = { git = "https://github.com/ruffle-rs/egui", branch = "consume_keys"}
egui-winit = { git = "https://github.com/ruffle-rs/egui", branch = "consume_keys"}
egui-wgpu = { git = "https://github.com/ruffle-rs/egui", branch = "consume_keys"}
# TODO: Replace on new egui update
egui = { git = "https://github.com/emilk/egui", rev = "d319489479c371b15e6419d470551dae5d647396"}
egui_extras = { git = "https://github.com/emilk/egui", rev = "d319489479c371b15e6419d470551dae5d647396"}
egui-winit = { git = "https://github.com/emilk/egui", rev = "d319489479c371b15e6419d470551dae5d647396"}
egui-wgpu = { git = "https://github.com/emilk/egui", rev = "d319489479c371b15e6419d470551dae5d647396"}

# TODO: Replace on new wgpu update
wgpu = { git = "https://github.com/gfx-rs/wgpu", rev = "e128d6c2613c7f8aecd25539c6fbc914bfda04f7"}
naga = { git = "https://github.com/gfx-rs/wgpu", rev = "e128d6c2613c7f8aecd25539c6fbc914bfda04f7"}
3 changes: 3 additions & 0 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,7 @@ unknown-git = "deny"
github = [
"ruffle-rs",
"gfx-rs",

# TODO: Remove when egui update is released
"emilk",
]
8 changes: 6 additions & 2 deletions desktop/src/gui/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub struct GuiController {
window: Rc<Window>,
last_update: Instant,
repaint_after: Duration,
surface: wgpu::Surface,
surface: wgpu::Surface<'static>,
surface_format: wgpu::TextureFormat,
movie_view_renderer: Arc<MovieViewRenderer>,
// Note that `window.get_inner_size` can change at any point on x11, even between two lines of code.
Expand Down Expand Up @@ -57,7 +57,9 @@ impl GuiController {
backends: backend,
..Default::default()
});
let surface = unsafe { instance.create_surface(window.as_ref()) }?;
let surface = unsafe {
instance.create_surface_unsafe(wgpu::SurfaceTargetUnsafe::from_window(window.as_ref())?)
}?;
let (adapter, device, queue) = futures::executor::block_on(request_adapter_and_device(
backend,
&instance,
Expand All @@ -81,6 +83,7 @@ impl GuiController {
width: size.width,
height: size.height,
present_mode: Default::default(),
desired_maximum_frame_latency: 2,
alpha_mode: Default::default(),
view_formats: Default::default(),
},
Expand Down Expand Up @@ -143,6 +146,7 @@ impl GuiController {
width: size.width,
height: size.height,
present_mode: Default::default(),
desired_maximum_frame_latency: 2,
alpha_mode: Default::default(),
view_formats: Default::default(),
},
Expand Down
14 changes: 8 additions & 6 deletions desktop/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,9 @@ pub fn plot_stats_in_tracy(instance: &wgpu::Instance) {
const TEXTURE_VIEWS: PlotName = plot_name!("Texture Views");

let tracy = Client::running().expect("tracy client must be running");
let report = instance.generate_report();
let report = instance
.generate_report()
.expect("reports should be available on desktop");

#[allow(unused_mut)]
let mut backend = None;
Expand All @@ -258,18 +260,18 @@ pub fn plot_stats_in_tracy(instance: &wgpu::Instance) {
}
#[cfg(windows)]
{
backend = backend.or(report.dx12).or(report.dx11);
backend = backend.or(report.dx12);
}
#[cfg(any(target_os = "macos", target_os = "ios"))]
{
backend = backend.or(report.metal);
}

if let Some(stats) = backend {
tracy.plot(BIND_GROUPS, stats.bind_groups.num_occupied as f64);
tracy.plot(BUFFERS, stats.buffers.num_occupied as f64);
tracy.plot(TEXTURES, stats.textures.num_occupied as f64);
tracy.plot(TEXTURE_VIEWS, stats.texture_views.num_occupied as f64);
tracy.plot(BIND_GROUPS, stats.bind_groups.num_allocated as f64);
tracy.plot(BUFFERS, stats.buffers.num_allocated as f64);
tracy.plot(TEXTURES, stats.textures.num_allocated as f64);
tracy.plot(TEXTURE_VIEWS, stats.texture_views.num_allocated as f64);
}

tracy.frame_mark();
Expand Down
2 changes: 1 addition & 1 deletion render/naga-agal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ num-traits = "0.2.17"

[dev-dependencies]
insta = "1.34.0"
naga = { workspace = true, features = ["wgsl-out", "validate"] }
naga = { workspace = true, features = ["wgsl-out"] }
40 changes: 14 additions & 26 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, ShaderStage, StructMember, SwizzleComponent, UnaryOperator,
Override, ResourceBinding, Scalar, ShaderStage, StructMember, SwizzleComponent, UnaryOperator,
};
use naga::{BinaryOperator, MathFunction};
use naga::{
Expand Down Expand Up @@ -129,28 +129,25 @@ impl VertexAttributeFormat {
return module.types.insert(
Type {
name: None,
inner: TypeInner::Scalar {
kind: ScalarKind::Float,
width: 4,
},
inner: TypeInner::Scalar(Scalar::F32),
},
Span::UNDEFINED,
);
}
let (size, width, kind) = match self {
let (size, scalar) = match self {
VertexAttributeFormat::Float1 => unreachable!(),
VertexAttributeFormat::Float2 => (VectorSize::Bi, 4, ScalarKind::Float),
VertexAttributeFormat::Float3 => (VectorSize::Tri, 4, ScalarKind::Float),
VertexAttributeFormat::Float4 => (VectorSize::Quad, 4, ScalarKind::Float),
VertexAttributeFormat::Float2 => (VectorSize::Bi, Scalar::F32),
VertexAttributeFormat::Float3 => (VectorSize::Tri, Scalar::F32),
VertexAttributeFormat::Float4 => (VectorSize::Quad, Scalar::F32),
// The conversion is done by wgpu, since we specify
// `wgpu::VertexFormat::Unorm8x4` in `CurrentPipeline::rebuild_pipeline`
VertexAttributeFormat::Bytes4 => (VectorSize::Quad, 4, ScalarKind::Float),
VertexAttributeFormat::Bytes4 => (VectorSize::Quad, Scalar::F32),
};

module.types.insert(
Type {
name: None,
inner: TypeInner::Vector { size, kind, width },
inner: TypeInner::Vector { size, scalar },
},
Span::UNDEFINED,
)
Expand Down Expand Up @@ -412,7 +409,7 @@ impl<'a> NagaBuilder<'a> {
inner: TypeInner::Matrix {
columns: VectorSize::Tri,
rows: VectorSize::Tri,
width: 4,
scalar: Scalar::F32,
},
},
Span::UNDEFINED,
Expand All @@ -424,7 +421,7 @@ impl<'a> NagaBuilder<'a> {
inner: TypeInner::Matrix {
columns: VectorSize::Tri,
rows: VectorSize::Quad,
width: 4,
scalar: Scalar::F32,
},
},
Span::UNDEFINED,
Expand All @@ -436,7 +433,7 @@ impl<'a> NagaBuilder<'a> {
inner: TypeInner::Matrix {
columns: VectorSize::Quad,
rows: VectorSize::Quad,
width: 4,
scalar: Scalar::F32,
},
},
Span::UNDEFINED,
Expand Down Expand Up @@ -475,21 +472,15 @@ impl<'a> NagaBuilder<'a> {
let f32_type = module.types.insert(
Type {
name: None,
inner: TypeInner::Scalar {
kind: ScalarKind::Float,
width: 4,
},
inner: TypeInner::Scalar(Scalar::F32),
},
Span::UNDEFINED,
);

let u32_type = module.types.insert(
Type {
name: None,
inner: TypeInner::Scalar {
kind: ScalarKind::Uint,
width: 4,
},
inner: TypeInner::Scalar(Scalar::U32),
},
Span::UNDEFINED,
);
Expand Down Expand Up @@ -1651,10 +1642,7 @@ impl<'a> NagaBuilder<'a> {
&mut self.return_type,
Type {
name: None,
inner: TypeInner::Scalar {
kind: ScalarKind::Float,
width: 0,
},
inner: TypeInner::Scalar(Scalar::F32),
},
);

Expand Down
4 changes: 2 additions & 2 deletions render/naga-agal/tests/snapshots/wgsl__complex_fractal.snap
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ fn main(@location(0) param: vec2<f32>, @location(1) param_1: vec2<f32>) -> Verte
var dest_temp: vec4<f32>;
var varying_0_: vec4<f32>;

dest_temp = vec4<f32>(param.x, param.y, 0.0, 1.0);
dest_temp = vec4<f32>(param.x, param.y, 0f, 1f);
let _e10: vec4<f32> = constant_registers[1u];
let _e13: vec4<f32> = constant_registers[2u];
let _e16: vec4<f32> = constant_registers[3u];
let _e19: vec4<f32> = constant_registers[4u];
varying_0_ = (transpose(mat4x4<f32>(_e10, _e13, _e16, _e19)) * vec4<f32>(param_1.x, param_1.y, 0.0, 1.0));
varying_0_ = (transpose(mat4x4<f32>(_e10, _e13, _e16, _e19)) * vec4<f32>(param_1.x, param_1.y, 0f, 1f));
let _e32: vec4<f32> = constant_registers[0u];
let _e33: vec4<f32> = _e32.zwww;
varying_0_.z = _e33.z;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ fn main(@location(0) param: vec4<f32>) -> FragmentOutput {
let _e149: vec4<f32> = constant_registers[16u];
let _e151: vec4<f32> = temporary3_;
let _e153: vec3<f32> = cross(_e149.xyx, _e151.xyz);
let _e158: vec4<f32> = vec4<f32>(_e153.x, _e153.y, _e153.z, 1.0);
let _e158: vec4<f32> = vec4<f32>(_e153.x, _e153.y, _e153.z, 1f);
temporary5_.x = _e158.x;
temporary5_.y = _e158.y;
temporary5_.z = _e158.z;
Expand All @@ -109,7 +109,7 @@ fn main(@location(0) param: vec4<f32>) -> FragmentOutput {
let _e176: vec4<f32> = temporary3_;
let _e178: vec4<f32> = temporary6_;
let _e180: vec3<f32> = cross(_e176.xyz, _e178.xyz);
let _e185: vec4<f32> = vec4<f32>(_e180.x, _e180.y, _e180.z, 1.0);
let _e185: vec4<f32> = vec4<f32>(_e180.x, _e180.y, _e180.z, 1f);
temporary5_.x = _e185.x;
temporary5_.y = _e185.y;
temporary5_.z = _e185.z;
Expand Down
2 changes: 1 addition & 1 deletion render/naga-agal/tests/snapshots/wgsl__misc_opcodes-2.snap
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fn main(@location(0) param: vec4<f32>) -> FragmentOutput {
let _e6: vec4<f32> = dpdy(_e5);
temporary1_ = _e6;
let _e8: vec4<f32> = temporary1_;
if (_e8.xxxx.x < 0.0) {
if (_e8.xxxx.x < 0f) {
discard;
}
let _e13: vec4<f32> = temporary0_;
Expand Down
4 changes: 2 additions & 2 deletions render/naga-agal/tests/snapshots/wgsl__misc_opcodes.snap
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ fn main(@location(0) param: vec4<f32>) -> VertexOutput {
let _e21: vec4<f32> = temporary5_;
let _e27: vec4<f32> = constant_registers[0u];
let _e29: vec3<f32> = (transpose(mat3x3<f32>(_e15.xyz, _e18.xyz, _e21.xyz)) * _e27.xyz);
temporary4_ = vec4<f32>(_e29.x, _e29.y, _e29.z, 1.0);
temporary4_ = vec4<f32>(_e29.x, _e29.y, _e29.z, 1f);
let _e35: vec4<f32> = temporary3_;
let _e36: vec4<f32> = temporary4_;
let _e37: vec4<f32> = temporary5_;
let _e42: vec4<f32> = constant_registers[2u];
let _e43: vec3<f32> = (transpose(mat3x4<f32>(_e35, _e36, _e37)) * _e42);
temporary5_ = vec4<f32>(_e43.x, _e43.y, _e43.z, 1.0);
temporary5_ = vec4<f32>(_e43.x, _e43.y, _e43.z, 1f);
let _e49: vec4<f32> = temporary5_;
let _e50: vec4<f32> = temporary4_;
temporary6_ = min(_e49, _e50);
Expand Down
4 changes: 2 additions & 2 deletions render/naga-agal/tests/snapshots/wgsl__shaders.snap
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ fn main(@location(0) param: vec3<f32>, @location(1) param_1: vec3<f32>) -> Verte
let _e7: vec4<f32> = constant_registers[1u];
let _e10: vec4<f32> = constant_registers[2u];
let _e13: vec4<f32> = constant_registers[3u];
dest_temp = (transpose(mat4x4<f32>(_e4, _e7, _e10, _e13)) * vec4<f32>(param.x, param.y, param.z, 1.0));
varying_0_ = vec4<f32>(param_1.x, param_1.y, param_1.z, 1.0);
dest_temp = (transpose(mat4x4<f32>(_e4, _e7, _e10, _e13)) * vec4<f32>(param.x, param.y, param.z, 1f));
varying_0_ = vec4<f32>(param_1.x, param_1.y, param_1.z, 1f);
let _e30: vec4<f32> = dest_temp;
let _e31: vec4<f32> = varying_0_;
return VertexOutput(_e30, _e31);
Expand Down
16 changes: 7 additions & 9 deletions render/naga-pixelbender/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,7 @@ impl<'a> ShaderBuilder<'a> {
name: None,
inner: TypeInner::Vector {
size: naga::VectorSize::Bi,
kind: ScalarKind::Float,
width: 4,
scalar: naga::Scalar::F32,
},
},
Span::UNDEFINED,
Expand All @@ -166,8 +165,8 @@ impl<'a> ShaderBuilder<'a> {
name: None,
inner: TypeInner::Vector {
size: naga::VectorSize::Quad,
kind: ScalarKind::Float,
width: 4,

scalar: naga::Scalar::F32,
},
},
Span::UNDEFINED,
Expand All @@ -178,8 +177,7 @@ impl<'a> ShaderBuilder<'a> {
name: None,
inner: TypeInner::Vector {
size: naga::VectorSize::Quad,
kind: ScalarKind::Sint,
width: 4,
scalar: naga::Scalar::I32,
},
},
Span::UNDEFINED,
Expand All @@ -191,7 +189,7 @@ impl<'a> ShaderBuilder<'a> {
inner: TypeInner::Matrix {
columns: naga::VectorSize::Bi,
rows: naga::VectorSize::Bi,
width: 4,
scalar: naga::Scalar::F32,
},
},
Span::UNDEFINED,
Expand All @@ -203,7 +201,7 @@ impl<'a> ShaderBuilder<'a> {
inner: TypeInner::Matrix {
columns: naga::VectorSize::Tri,
rows: naga::VectorSize::Tri,
width: 4,
scalar: naga::Scalar::F32,
},
},
Span::UNDEFINED,
Expand All @@ -215,7 +213,7 @@ impl<'a> ShaderBuilder<'a> {
inner: TypeInner::Matrix {
columns: naga::VectorSize::Quad,
rows: naga::VectorSize::Quad,
width: 4,
scalar: naga::Scalar::F32,
},
},
Span::UNDEFINED,
Expand Down
4 changes: 2 additions & 2 deletions render/wgpu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ version.workspace = true
workspace = true

[dependencies]
wgpu = { workspace = true, features = ["naga"] }
wgpu = { workspace = true, features = ["naga-ir"] }
tracing = { workspace = true }
ruffle_render = { path = "..", features = ["tessellator", "wgpu"] }
bytemuck = { version = "1.14.0", features = ["derive"] }
raw-window-handle = "0.5.2"
raw-window-handle = "0.6.0"
clap = { version = "4.4.17", features = ["derive"], optional = true }
enum-map = "2.7.3"
fnv = "1.0.7"
Expand Down
Loading