From 2b9b11632d51d24ae25e6aaccb0dcd86b68f8b20 Mon Sep 17 00:00:00 2001 From: Jinlei Li Date: Mon, 27 Jan 2025 13:55:00 +0800 Subject: [PATCH] Update `app-surface` to v1.5 --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- README.md | 3 ++- code/intermediate/hdr/src/main.rs | 10 +++++----- code/utils/src/load_texture.rs | 2 +- docs/index.md | 3 ++- 6 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1eeafb5cc..29d82236d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -165,9 +165,9 @@ checksum = "c1fd03a028ef38ba2276dce7e33fcd6369c158a1bca17946c4b1b701891c1ff7" [[package]] name = "app-surface" -version = "1.4.2" +version = "1.5.0" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "829670bd5945d3cc9b6affe92395478ecff49dcbc751f60c09b9a8c00b570fd1" +checksum = "c4dab4f7bba0567b69b7749c6bce5945e63cf369f258835b2895d5276247f7ed" dependencies = [ "android_logger", "cfg-if", diff --git a/Cargo.toml b/Cargo.toml index a030402e4..54119d7ca 100755 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,7 @@ version = "0.25" default-features = false [workspace.dependencies] -app-surface = "1.4.2" +app-surface = "1.5.0" # app-surface = { path = "../idroid/wgpu-in-app/app-surface", default-features = false } bytemuck = { version = "1.21", features = ["derive"] } cfg-if = "1" diff --git a/README.md b/README.md index 0ad82ce6a..85baefa0c 100755 --- a/README.md +++ b/README.md @@ -78,6 +78,7 @@ cargo run-wasm --bin tutorial1-window --features webgl Chrome 113+、Microsoft Edge 113+ 及 Arc 浏览器均已默认支持 WebGPU 功能。 ### Safari + Safari 18 (macOS 15) 已经默认开启了 WebGPU 功能。 macOS 14- 系统上,需安装 [Safari Technology Preview 185+](https://www.webkit.org/blog/14879/webgpu-now-available-for-testing-in-safari-technology-preview/),从顶部菜单栏选择 `开发 -> 功能标志` , 搜索并勾选 `WebGPU`: @@ -90,7 +91,7 @@ macOS 14- 系统上,需安装 [Safari Technology Preview 185+](https://www.web ## 关于译者 -我是一名移动端架构师, 有多年使用 OpenGL / WebGL, Metal 的实践经验。2018 年开始接触 WebGPU,目前正积极地参与到 [wgpu 开源项目的开发与完善](/~https://github.com/gfx-rs/wgpu/commits?author=jinleili)之中,并且已于两年前在 AppStore 上架了基于 wgpu 实现的毛笔书法模拟 App [字习 Pro](https://apps.apple.com/cn/app/字习-pro/id1507339788)。 +我是一名移动端架构师, 有多年使用 OpenGL / WebGL, Metal 的实践经验。2018 年开始接触 WebGPU,目前正积极地参与到 [wgpu 开源项目的开发与完善](/~https://github.com/gfx-rs/wgpu/commits?author=jinleili)之中,并且已于 2020 年在 AppStore 上架了基于 wgpu 实现的毛笔书法模拟 App [字习 Pro](https://apps.apple.com/cn/app/字习-pro/id1507339788)。 ## 加入 wgpu 微信学习交流群 diff --git a/code/intermediate/hdr/src/main.rs b/code/intermediate/hdr/src/main.rs index b5afe26ce..f35c3d8e6 100755 --- a/code/intermediate/hdr/src/main.rs +++ b/code/intermediate/hdr/src/main.rs @@ -176,9 +176,9 @@ impl WgpuApp { // 再更新 projection, hdr, depth_texture self.projection.resize(self.size.width, self.size.height); self.hdr - .resize(self.app.device.as_ref(), self.size.width, self.size.height); + .resize(&self.app.device, self.size.width, self.size.height); self.depth_texture = texture::Texture::create_depth_texture( - self.app.device.as_ref(), + &self.app.device, &self.app.config, "depth_texture", ); @@ -260,8 +260,8 @@ impl WgpuAppAction for WgpuApp { let surface_format = app.config.format.remove_srgb_suffix(); app.ctx.update_config_format(surface_format); - let device = app.device.as_ref(); - let queue = app.queue.as_ref(); + let device = &app.device; + let queue = &app.queue; let config = &app.config; let texture_bind_group_layout = @@ -671,7 +671,7 @@ impl WgpuAppAction for WgpuApp { .app .get_current_frame_view(Some(self.app.config.format.add_srgb_suffix())); - let device = self.app.device.as_ref(); + let device = &self.app.device; let mut encoder = device.create_command_encoder(&wgpu::CommandEncoderDescriptor { label: Some("Render Encoder"), }); diff --git a/code/utils/src/load_texture.rs b/code/utils/src/load_texture.rs index ea6850f7c..0554b1ad1 100755 --- a/code/utils/src/load_texture.rs +++ b/code/utils/src/load_texture.rs @@ -92,7 +92,7 @@ pub async fn from_path( format, }; - (any_tex, default_sampler(app.device.as_ref())) + (any_tex, default_sampler(&app.device)) } fn load_from_img( diff --git a/docs/index.md b/docs/index.md index 2c5a7b376..544e1b177 100755 --- a/docs/index.md +++ b/docs/index.md @@ -75,6 +75,7 @@ cargo run-wasm --bin tutorial2-surface --features webgl Chrome 113+、Microsoft Edge 113+ 及 Arc 浏览器均已默认支持 WebGPU 功能。 ### Safari + Safari 18 (macOS 15) 已经默认开启了 WebGPU 功能。 macOS 14- 系统上,需安装 [Safari Technology Preview 185+](https://www.webkit.org/blog/14879/webgpu-now-available-for-testing-in-safari-technology-preview/),从顶部菜单栏选择 `开发 -> 功能标志` , 搜索并勾选 `WebGPU`: @@ -87,7 +88,7 @@ macOS 14- 系统上,需安装 [Safari Technology Preview 185+](https://www.web ## 关于译者 -我是一名移动端架构师,有多年使用 OpenGL / WebGL, Metal 的实践经验。2018 年开始接触 WebGPU,目前正积极地参与到 [wgpu 开源项目的开发与完善](/~https://github.com/gfx-rs/wgpu/commits?author=jinleili)之中,并且已于两年前在 AppStore 上架了基于 wgpu 实现的毛笔书法模拟 App [字习 Pro](https://apps.apple.com/cn/app/字习-pro/id1507339788)。 +我是一名移动端架构师,有多年使用 OpenGL / WebGL, Metal 的实践经验。2018 年开始接触 WebGPU,目前正积极地参与到 [wgpu 开源项目的开发与完善](/~https://github.com/gfx-rs/wgpu/commits?author=jinleili)之中,并且已于 2020 年在 AppStore 上架了基于 wgpu 实现的毛笔书法模拟 App [字习 Pro](https://apps.apple.com/cn/app/字习-pro/id1507339788)。 ## 加入 wgpu 微信学习交流群