summaryrefslogtreecommitdiffstats
path: root/examples/integration_wgpu/src/scene.rs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/integration_wgpu/src/scene.rs')
-rw-r--r--examples/integration_wgpu/src/scene.rs23
1 files changed, 14 insertions, 9 deletions
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,