(options: &Options, compiled_shader_modules: CompiledShaderModules)
| 12 | } |
| 13 | |
| 14 | async fn start_internal(options: &Options, compiled_shader_modules: CompiledShaderModules) { |
| 15 | let backends = wgpu::util::backend_bits_from_env().unwrap_or(wgpu::Backends::PRIMARY); |
| 16 | let instance = wgpu::Instance::new(wgpu::InstanceDescriptor { |
| 17 | backends, |
| 18 | dx12_shader_compiler: wgpu::util::dx12_shader_compiler_from_env().unwrap_or_default(), |
| 19 | }); |
| 20 | let adapter = wgpu::util::initialize_adapter_from_env_or_default(&instance, backends, None) |
| 21 | .await |
| 22 | .expect("Failed to find an appropriate adapter"); |
| 23 | |
| 24 | let mut features = |
| 25 | wgpu::Features::TIMESTAMP_QUERY | wgpu::Features::TIMESTAMP_QUERY_INSIDE_PASSES; |
| 26 | if options.force_spirv_passthru { |
| 27 | features |= wgpu::Features::SPIRV_SHADER_PASSTHROUGH; |
| 28 | } |
| 29 | |
| 30 | let (device, queue) = adapter |
| 31 | .request_device( |
| 32 | &wgpu::DeviceDescriptor { |
| 33 | label: None, |
| 34 | features, |
| 35 | limits: wgpu::Limits::default(), |
| 36 | }, |
| 37 | None, |
| 38 | ) |
| 39 | .await |
| 40 | .expect("Failed to create device"); |
| 41 | drop(instance); |
| 42 | drop(adapter); |
| 43 | |
| 44 | let timestamp_period = queue.get_timestamp_period(); |
| 45 | |
| 46 | let entry_point = "main_cs"; |
| 47 | |
| 48 | // FIXME(eddyb) automate this decision by default. |
| 49 | let module = compiled_shader_modules.spv_module_for_entry_point(entry_point); |
| 50 | let module = if options.force_spirv_passthru { |
| 51 | unsafe { device.create_shader_module_spirv(&module) } |
| 52 | } else { |
| 53 | let wgpu::ShaderModuleDescriptorSpirV { label, source } = module; |
| 54 | device.create_shader_module(wgpu::ShaderModuleDescriptor { |
| 55 | label, |
| 56 | source: wgpu::ShaderSource::SpirV(source), |
| 57 | }) |
| 58 | }; |
| 59 | |
| 60 | let top = 2u32.pow(20); |
| 61 | let src_range = 1..top; |
| 62 | |
| 63 | let src = src_range |
| 64 | .clone() |
| 65 | .flat_map(u32::to_ne_bytes) |
| 66 | .collect::<Vec<_>>(); |
| 67 | |
| 68 | let bind_group_layout = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor { |
| 69 | label: None, |
| 70 | entries: &[wgpu::BindGroupLayoutEntry { |
| 71 | binding: 0, |
no test coverage detected