webgpu: Implement ShaderCompilationInfo (#32642)

* ShaderCompilationInfo

* expectations

* Handle CompilationInfo promise in GPUShaderModule

* Fix my english
This commit is contained in:
Samson 2024-07-02 15:39:06 +02:00 committed by GitHub
parent bd0a5eb4b7
commit c0105de82b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 22103 additions and 682 deletions

View file

@ -4,6 +4,7 @@
//! Data and main loop of WebGPU thread.
use std::borrow::Cow;
use std::collections::HashMap;
use std::slice;
use std::sync::{Arc, Mutex};
@ -437,17 +438,24 @@ impl WGPU {
program_id,
program,
label,
sender,
} => {
let global = &self.global;
let source = wgpu_core::pipeline::ShaderModuleSource::Wgsl(
crate::Cow::Owned(program),
);
let source =
wgpu_core::pipeline::ShaderModuleSource::Wgsl(Cow::Borrowed(&program));
let desc = ShaderModuleDescriptor {
label: label.map(|s| s.into()),
shader_bound_checks: wgt::ShaderBoundChecks::default(),
};
let (_, error) = gfx_select!(program_id =>
global.device_create_shader_module(device_id, &desc, source, Some(program_id)));
if let Err(e) = sender.send(Some(Ok(WebGPUResponse::CompilationInfo(
error
.as_ref()
.map(|e| crate::ShaderCompilationInfo::from(e, &program)),
)))) {
warn!("Failed to send WebGPUResponse::CompilationInfo {e:?}");
}
self.maybe_dispatch_wgpu_error(device_id, error);
},
WebGPURequest::CreateSwapChain {