From bdca20fc4a3e8f6bd8ffb59de75e6ca0f8a94b6a Mon Sep 17 00:00:00 2001 From: Vladyslav Nikonov Date: Thu, 21 Oct 2021 22:42:14 +0300 Subject: 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 --- examples/integration_wgpu/src/scene.rs | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'examples/integration_wgpu/src/scene.rs') diff --git a/examples/integration_wgpu/src/scene.rs b/examples/integration_wgpu/src/scene.rs index 910d8d8c..fbda1326 100644 --- a/examples/integration_wgpu/src/scene.rs +++ b/examples/integration_wgpu/src/scene.rs @@ -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, -- cgit