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