From a3f57ad681b407001078d6bf9b36ed19ecd4309f Mon Sep 17 00:00:00 2001 From: Molive Date: Thu, 8 Oct 2026 19:50:40 +0100 Subject: [PATCH] try passthrough --- src/main.rs | 52 +++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 43 insertions(+), 9 deletions(-) diff --git a/src/main.rs b/src/main.rs index 0552c4c..1c48f97 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,5 @@ +const CREATE_SPV_PIPELINE: bool = false; + fn main() { env_logger::init(); @@ -24,7 +26,8 @@ fn main() { | wgpu::Features::STORAGE_RESOURCE_BINDING_ARRAY | wgpu::Features::SAMPLED_TEXTURE_AND_STORAGE_BUFFER_ARRAY_NON_UNIFORM_INDEXING | wgpu::Features::STORAGE_TEXTURE_ARRAY_NON_UNIFORM_INDEXING - | wgpu::Features::PARTIALLY_BOUND_BINDING_ARRAY, + | wgpu::Features::PARTIALLY_BOUND_BINDING_ARRAY + | wgpu::Features::PASSTHROUGH_SHADERS, required_limits: wgpu::Limits { max_binding_array_elements_per_shader_stage: 1000, max_compute_invocations_per_workgroup: 512, @@ -40,8 +43,17 @@ fn main() { let wgsl_module = device.create_shader_module(wgpu::include_wgsl!("shader.wgsl")); log::logger().flush(); + log::info!("Creating SPV passthrough module..."); + let spv_ps_module = + unsafe { device.create_shader_module_passthrough(wgpu::include_spirv_raw!("shader.spv")) }; + log::logger().flush(); + log::info!("Creating SPV module..."); - let spv_module = device.create_shader_module(wgpu::include_spirv!("shader.spv")); + let spv_module = if CREATE_SPV_PIPELINE { + Some(device.create_shader_module(wgpu::include_spirv!("shader.spv"))) + } else { + None + }; log::logger().flush(); let bind_group_layout = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor { @@ -87,19 +99,41 @@ fn main() { }); log::logger().flush(); - log::info!("Creating SPV pipeline..."); - let spv_pipeline = device.create_compute_pipeline(&wgpu::ComputePipelineDescriptor { + log::info!("Creating SPV Passthrough pipeline..."); + let spv_ps_pipeline = device.create_compute_pipeline(&wgpu::ComputePipelineDescriptor { label: None, layout: Some(&pipeline_layout), - module: &spv_module, + module: &spv_ps_module, entry_point: Some("main"), compilation_options: wgpu::PipelineCompilationOptions::default(), cache: None, }); + log::logger().flush(); - log::info!("WGSL module: {wgsl_module:?}"); - log::info!("SPV module: {spv_module:?}"); - log::info!("WGSL pipeline: {wgsl_pipeline:?}"); - log::info!("SPV pipeline: {spv_pipeline:?}"); + log::info!("Creating SPV pipeline..."); + let spv_pipeline = if CREATE_SPV_PIPELINE { + Some( + device.create_compute_pipeline(&wgpu::ComputePipelineDescriptor { + label: None, + layout: Some(&pipeline_layout), + module: spv_module.as_ref().unwrap(), + entry_point: Some("main"), + compilation_options: wgpu::PipelineCompilationOptions::default(), + cache: None, + }), + ) + } else { + None + }; + log::logger().flush(); + + log::info!("WGSL module: {wgsl_module:?}"); + log::info!("SPV module: {spv_module:?}"); + log::info!("SPV ps module: {spv_ps_module:?}"); + log::info!("WGSL pipeline: {wgsl_pipeline:?}"); + log::info!("SPV pipeline: {spv_pipeline:?}"); + log::info!("SPV ps pipeline: {spv_ps_pipeline:?}"); + + loop {} }