Compare commits

...

2 Commits

Author SHA1 Message Date
molive a3f57ad681 try passthrough 2026-10-08 19:52:16 +01:00
molive a1054477d0 minor fixes 2026-10-08 19:51:11 +01:00
+48 -10
View File
@@ -1,3 +1,5 @@
const CREATE_SPV_PIPELINE: bool = false;
fn main() { fn main() {
env_logger::init(); env_logger::init();
@@ -24,8 +26,13 @@ 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
required_limits: wgpu::Limits::downlevel_defaults(), | wgpu::Features::PASSTHROUGH_SHADERS,
required_limits: wgpu::Limits {
max_binding_array_elements_per_shader_stage: 1000,
max_compute_invocations_per_workgroup: 512,
..wgpu::Limits::downlevel_defaults()
},
experimental_features: wgpu::ExperimentalFeatures::disabled(), experimental_features: wgpu::ExperimentalFeatures::disabled(),
memory_hints: wgpu::MemoryHints::MemoryUsage, memory_hints: wgpu::MemoryHints::MemoryUsage,
trace: wgpu::Trace::Off, trace: wgpu::Trace::Off,
@@ -36,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 {
@@ -83,19 +99,41 @@ fn main() {
}); });
log::logger().flush(); log::logger().flush();
log::info!("Creating SPV module..."); 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::logger().flush();
log::info!("WGSL module: {wgsl_module:?}"); log::info!("Creating SPV pipeline...");
log::info!("SPV module: {spv_module:?}"); let spv_pipeline = if CREATE_SPV_PIPELINE {
log::info!("WGSL pipeline: {wgsl_pipeline:?}"); Some(
log::info!("SPV pipeline: {spv_pipeline:?}"); 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 {}
} }