Compare commits

1 Commits

Author SHA1 Message Date
molive a3f57ad681 try passthrough 2026-10-08 19:52:16 +01:00
+39 -5
View File
@@ -1,3 +1,5 @@
const CREATE_SPV_PIPELINE: bool = false;
fn main() { fn main() {
env_logger::init(); env_logger::init();
@@ -24,7 +26,8 @@ fn main() {
| wgpu::Features::STORAGE_RESOURCE_BINDING_ARRAY | wgpu::Features::STORAGE_RESOURCE_BINDING_ARRAY
| wgpu::Features::SAMPLED_TEXTURE_AND_STORAGE_BUFFER_ARRAY_NON_UNIFORM_INDEXING | wgpu::Features::SAMPLED_TEXTURE_AND_STORAGE_BUFFER_ARRAY_NON_UNIFORM_INDEXING
| wgpu::Features::STORAGE_TEXTURE_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 { required_limits: wgpu::Limits {
max_binding_array_elements_per_shader_stage: 1000, max_binding_array_elements_per_shader_stage: 1000,
max_compute_invocations_per_workgroup: 512, max_compute_invocations_per_workgroup: 512,
@@ -40,8 +43,17 @@ fn main() {
let wgsl_module = device.create_shader_module(wgpu::include_wgsl!("shader.wgsl")); let wgsl_module = device.create_shader_module(wgpu::include_wgsl!("shader.wgsl"));
log::logger().flush(); 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..."); 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(); log::logger().flush();
let bind_group_layout = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor { let bind_group_layout = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
@@ -87,19 +99,41 @@ fn main() {
}); });
log::logger().flush(); log::logger().flush();
log::info!("Creating SPV pipeline..."); log::info!("Creating SPV Passthrough pipeline...");
let spv_pipeline = device.create_compute_pipeline(&wgpu::ComputePipelineDescriptor { let spv_ps_pipeline = device.create_compute_pipeline(&wgpu::ComputePipelineDescriptor {
label: None, label: None,
layout: Some(&pipeline_layout), layout: Some(&pipeline_layout),
module: &spv_module, module: &spv_ps_module,
entry_point: Some("main"), entry_point: Some("main"),
compilation_options: wgpu::PipelineCompilationOptions::default(), compilation_options: wgpu::PipelineCompilationOptions::default(),
cache: None, cache: None,
}); });
log::logger().flush();
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::logger().flush();
log::info!("WGSL module: {wgsl_module:?}"); log::info!("WGSL module: {wgsl_module:?}");
log::info!("SPV module: {spv_module:?}"); log::info!("SPV module: {spv_module:?}");
log::info!("SPV ps module: {spv_ps_module:?}");
log::info!("WGSL pipeline: {wgsl_pipeline:?}"); log::info!("WGSL pipeline: {wgsl_pipeline:?}");
log::info!("SPV pipeline: {spv_pipeline:?}"); log::info!("SPV pipeline: {spv_pipeline:?}");
log::info!("SPV ps pipeline: {spv_ps_pipeline:?}");
loop {}
} }