Experimental wgpu WebGL backend support

- Added missing `draw_cache_align_4x4` call for `brush_glyph` on wasm32 target
- Added WebGL support to `integratio_wgpu` example
- Fixed test.yml CI workflow
- Removed spir-v shader in `integration_wgpu`; Fixed formatting
- Removed redundant `BoxStream` typedef
This commit is contained in:
Vladyslav Nikonov 2021-10-21 22:42:14 +03:00 committed by Héctor Ramón Jiménez
parent c75ed37148
commit bdca20fc4a
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
21 changed files with 414 additions and 86 deletions

View file

@ -6,8 +6,11 @@ pub struct Scene {
}
impl Scene {
pub fn new(device: &wgpu::Device) -> Scene {
let pipeline = build_pipeline(device);
pub fn new(
device: &wgpu::Device,
texture_format: wgpu::TextureFormat,
) -> Scene {
let pipeline = build_pipeline(device, texture_format);
Scene { pipeline }
}
@ -47,12 +50,14 @@ impl Scene {
}
}
fn build_pipeline(device: &wgpu::Device) -> wgpu::RenderPipeline {
let vs_module =
device.create_shader_module(&wgpu::include_spirv!("shader/vert.spv"));
let fs_module =
device.create_shader_module(&wgpu::include_spirv!("shader/frag.spv"));
fn build_pipeline(
device: &wgpu::Device,
texture_format: wgpu::TextureFormat,
) -> wgpu::RenderPipeline {
let (vs_module, fs_module) = (
device.create_shader_module(&wgpu::include_wgsl!("shader/vert.wgsl")),
device.create_shader_module(&wgpu::include_wgsl!("shader/frag.wgsl")),
);
let pipeline_layout =
device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
@ -74,7 +79,7 @@ fn build_pipeline(device: &wgpu::Device) -> wgpu::RenderPipeline {
module: &fs_module,
entry_point: "main",
targets: &[wgpu::ColorTargetState {
format: wgpu::TextureFormat::Bgra8UnormSrgb,
format: texture_format,
blend: Some(wgpu::BlendState {
color: wgpu::BlendComponent::REPLACE,
alpha: wgpu::BlendComponent::REPLACE,