Skip to content

Commit

Permalink
Fix clippy warning
Browse files Browse the repository at this point in the history
  • Loading branch information
jinleili committed Oct 31, 2024
1 parent 118a070 commit ea48ab8
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 42 deletions.
12 changes: 5 additions & 7 deletions app-surface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,12 @@ async fn create_iasdq_context(
// Caused by:
// Downlevel flags DownlevelFlags(SURFACE_VIEW_FORMATS) are required but not supported on the device.
vec![]
} else if format.is_srgb() {
// HarmonyOS 不支持 view_formats 格式
// format 的值与 view_formats 的值一致时,configure 内部会自动忽略 view_formats 的值
vec![format]
} else {
if format.is_srgb() {
// HarmonyOS 不支持 view_formats 格式
// format 的值与 view_formats 的值一致时,configure 内部会自动忽略 view_formats 的值
vec![format]
} else {
vec![format.add_srgb_suffix()]
}
vec![format.add_srgb_suffix()]
};

let mut config = surface
Expand Down
2 changes: 2 additions & 0 deletions wgpu-in-app/src/desktop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ use winit::{
};

pub fn run() -> Result<(), impl std::error::Error> {
crate::init_logger();

let events_loop = EventLoop::new().unwrap();
let mut app = WgpuApp::default();
events_loop.run_app(&mut app)
Expand Down
13 changes: 0 additions & 13 deletions wgpu-in-app/src/examples/boids.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
use super::Example;
use app_surface::{AppSurface, SurfaceFrame};
use bytemuck::{Pod, Zeroable};
use rand::{
distributions::{Distribution, Uniform},
SeedableRng,
Expand All @@ -16,18 +15,6 @@ const NUM_PARTICLES: u32 = 1500;
// number of single-particle calculations (invocations) in each gpu work group
const PARTICLES_PER_GROUP: u32 = 16;

#[repr(C)]
#[derive(Clone, Copy, Pod, Zeroable)]
struct SimParams {
delta_t: f32,
rule1_distance: f32,
rule2_distance: f32,
rule3_distance: f32,
rule1_scale: f32,
rule2_scale: f32,
rule3_scale: f32,
offset: u32,
}
#[allow(dead_code)]
pub struct Boids {
particle_bind_groups: Vec<wgpu::BindGroup>,
Expand Down
2 changes: 1 addition & 1 deletion wgpu-in-app/src/examples/cube.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
use super::Example;
use app_surface::{AppSurface, SurfaceFrame};
use bytemuck::{Pod, Zeroable};
use std::mem::size_of;
use std::{future::Future, pin::Pin, task};
use wgpu::util::DeviceExt;

#[repr(C)]
#[derive(Clone, Copy, Pod, Zeroable)]
struct Vertex {
Expand Down
22 changes: 1 addition & 21 deletions wgpu-in-app/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,7 @@ pub mod desktop;
// Initialize logging in platform dependant ways.
fn init_logger() {
cfg_if::cfg_if! {
if #[cfg(target_arch = "wasm32")] {
// As we don't have an environment to pull logging level from, we use the query string.
let query_string = web_sys::window().unwrap().location().search().unwrap();
let query_level: Option<log::LevelFilter> = parse_url_query_string(&query_string, "RUST_LOG")
.and_then(|x| x.parse().ok());

// We keep wgpu at Error level, as it's very noisy.
let base_level = query_level.unwrap_or(log::LevelFilter::Info);
let wgpu_level = query_level.unwrap_or(log::LevelFilter::Error);

// On web, we use fern, as console_log doesn't have filtering on a per-module level.
fern::Dispatch::new()
.level(base_level)
.level_for("wgpu_core", wgpu_level)
.level_for("wgpu_hal", wgpu_level)
.level_for("naga", wgpu_level)
.chain(fern::Output::call(console_log::log))
.apply()
.unwrap();
std::panic::set_hook(Box::new(console_error_panic_hook::hook));
} else if #[cfg(target_os = "android")] {
if #[cfg(target_os = "android")] {
// 添加 Android 平台的日志初始化
android_logger::init_once(
android_logger::Config::default()
Expand Down

0 comments on commit ea48ab8

Please sign in to comment.