rt(wgpu): don't use rayon on wasm32
doesn't build on wasm32 because missing glslang but that should be the only snag now
This commit is contained in:
parent
4733831500
commit
11d12730eb
0
librashader-runtime-metal/src/graphics_pipeline.rs
Normal file
0
librashader-runtime-metal/src/graphics_pipeline.rs
Normal file
|
@ -24,10 +24,12 @@ wgpu = { version = "0.19.0", features = ["spirv"] }
|
|||
rustc-hash = "1.1.0"
|
||||
image = "0.24.7"
|
||||
thiserror = "1.0.50"
|
||||
rayon = "1.8.0"
|
||||
bytemuck = { version = "1.14.0", features = ["derive"] }
|
||||
array-concat = "0.5.2"
|
||||
|
||||
[target.'cfg(not(target_arch="wasm32"))'.dependencies]
|
||||
rayon = "1.8.1"
|
||||
|
||||
[dev-dependencies]
|
||||
config = { version = "0.13.4", features = [] }
|
||||
env_logger = "0.10.1"
|
||||
|
|
|
@ -9,6 +9,8 @@ use librashader_runtime::binding::BindingUtil;
|
|||
use librashader_runtime::image::{Image, ImageError, UVDirection};
|
||||
use librashader_runtime::quad::QuadType;
|
||||
use librashader_runtime::uniforms::UniformStorage;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
use rayon::prelude::*;
|
||||
use rustc_hash::FxHashMap;
|
||||
use std::collections::VecDeque;
|
||||
use std::path::Path;
|
||||
|
@ -22,7 +24,6 @@ use librashader_reflect::back::wgsl::WgslCompileOptions;
|
|||
use librashader_runtime::framebuffer::FramebufferInit;
|
||||
use librashader_runtime::render_target::RenderTarget;
|
||||
use librashader_runtime::scaling::ScaleFramebuffer;
|
||||
use rayon::prelude::*;
|
||||
use wgpu::{Device, TextureFormat};
|
||||
|
||||
use crate::error;
|
||||
|
@ -213,8 +214,14 @@ impl FilterChainWgpu {
|
|||
textures: &[TextureConfig],
|
||||
) -> error::Result<FxHashMap<usize, LutTexture>> {
|
||||
let mut luts = FxHashMap::default();
|
||||
let images = textures
|
||||
.par_iter()
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
let images_iter = textures.par_iter();
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
let images_iter = textures.iter();
|
||||
|
||||
let images = images_iter
|
||||
.map(|texture| Image::load(&texture.path, UVDirection::TopLeft))
|
||||
.collect::<Result<Vec<Image>, ImageError>>()?;
|
||||
for (index, (texture, image)) in textures.iter().zip(images).enumerate() {
|
||||
|
@ -251,8 +258,12 @@ impl FilterChainWgpu {
|
|||
passes: Vec<ShaderPassMeta>,
|
||||
semantics: &ShaderSemantics,
|
||||
) -> error::Result<Box<[FilterPass]>> {
|
||||
let filters: Vec<error::Result<FilterPass>> = passes
|
||||
.into_par_iter()
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
let passes_iter = passes.into_par_iter();
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
let passes_iter = passes.into_iter();
|
||||
|
||||
let filters: Vec<error::Result<FilterPass>> = passes_iter
|
||||
.enumerate()
|
||||
.map(|(index, (config, source, mut reflect))| {
|
||||
let reflection = reflect.reflect(index, semantics)?;
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
use std::sync::Arc;
|
||||
use wgpu::Maintain;
|
||||
use winit::{
|
||||
event::*,
|
||||
event_loop::{ControlFlow, EventLoop},
|
||||
window::{Window, WindowBuilder},
|
||||
};
|
||||
|
||||
|
@ -11,7 +9,6 @@ use librashader_presets::ShaderPreset;
|
|||
use librashader_runtime_wgpu::FilterChainWgpu;
|
||||
use wgpu::util::DeviceExt;
|
||||
use winit::event_loop::EventLoopBuilder;
|
||||
use winit::keyboard::{Key, KeyCode, PhysicalKey};
|
||||
use winit::platform::windows::EventLoopBuilderExtWindows;
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
|
@ -107,7 +104,7 @@ impl<'a> State<'a> {
|
|||
let swapchain_capabilities = surface.get_capabilities(&adapter);
|
||||
let swapchain_format = swapchain_capabilities.formats[0];
|
||||
|
||||
let mut config = wgpu::SurfaceConfiguration {
|
||||
let config = wgpu::SurfaceConfiguration {
|
||||
usage: wgpu::TextureUsages::RENDER_ATTACHMENT | wgpu::TextureUsages::COPY_DST,
|
||||
format: swapchain_format,
|
||||
width: size.width,
|
||||
|
@ -212,7 +209,7 @@ impl<'a> State<'a> {
|
|||
self.surface.configure(&self.device, &self.config);
|
||||
}
|
||||
}
|
||||
fn input(&mut self, event: &WindowEvent) -> bool {
|
||||
fn input(&mut self, _event: &WindowEvent) -> bool {
|
||||
false
|
||||
}
|
||||
fn update(&mut self) {}
|
||||
|
|
Loading…
Reference in a new issue