mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
webgpu: Move supported context format to content timeline (#34028)
* Move supported context format to content timeline https://github.com/gpuweb/gpuweb/pull/4911 Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * Update expectations Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> --------- Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
parent
10aa485c0c
commit
a01d66df53
4 changed files with 42 additions and 169 deletions
|
@ -39,6 +39,17 @@ impl MallocSizeOf for WebGPUContextId {
|
|||
}
|
||||
}
|
||||
|
||||
impl ContextConfiguration {
|
||||
fn format(&self) -> ImageFormat {
|
||||
match self.format {
|
||||
wgt::TextureFormat::Rgba8Unorm => ImageFormat::RGBA8,
|
||||
wgt::TextureFormat::Bgra8Unorm => ImageFormat::BGRA8,
|
||||
// TODO: wgt::TextureFormat::Rgba16Float
|
||||
_ => unreachable!("Unsupported canvas context format in configuration"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub type WGPUImageMap = Arc<Mutex<HashMap<WebGPUContextId, ContextData>>>;
|
||||
|
||||
/// Presentation id encodes current configuration and current image
|
||||
|
@ -383,17 +394,11 @@ impl crate::WGPU {
|
|||
let presentation_id = context_data.next_presentation_id();
|
||||
context_data.check_and_update_presentation_id(presentation_id);
|
||||
|
||||
// If configuration is not provided or presentation format is not valid
|
||||
// the context will be dummy until recreation
|
||||
let format = config.as_ref().and_then(|config| match config.format {
|
||||
wgt::TextureFormat::Rgba8Unorm => Some(ImageFormat::RGBA8),
|
||||
wgt::TextureFormat::Bgra8Unorm => Some(ImageFormat::BGRA8),
|
||||
_ => None,
|
||||
});
|
||||
|
||||
let needs_image_update = if let Some(format) = format {
|
||||
let config = config.expect("Config should exist when valid format is available");
|
||||
let new_image_desc = WebGPUImageDescriptor::new(format, size, config.is_opaque);
|
||||
// If configuration is not provided
|
||||
// the context will be dummy/empty until recreation
|
||||
let needs_image_update = if let Some(config) = config {
|
||||
let new_image_desc =
|
||||
WebGPUImageDescriptor::new(config.format(), size, config.is_opaque);
|
||||
let needs_swapchain_rebuild = context_data.swap_chain.is_none() ||
|
||||
new_image_desc.buffer_size() != context_data.image_desc.buffer_size();
|
||||
if needs_swapchain_rebuild {
|
||||
|
|
|
@ -551,21 +551,7 @@ impl WGPU {
|
|||
{
|
||||
warn!("Unable to send FreeTexture({:?}) ({:?})", texture_id, e);
|
||||
};
|
||||
if let Some(error) = error {
|
||||
self.dispatch_error(device_id, Error::from_error(error));
|
||||
continue;
|
||||
}
|
||||
// Supported context formats
|
||||
// TODO: wgt::TextureFormat::Rgba16Float, when wr supports HDR
|
||||
if !matches!(
|
||||
descriptor.format,
|
||||
wgt::TextureFormat::Bgra8Unorm | wgt::TextureFormat::Rgba8Unorm
|
||||
) {
|
||||
self.dispatch_error(
|
||||
device_id,
|
||||
Error::Validation("Unsupported context format".to_string()),
|
||||
);
|
||||
}
|
||||
self.maybe_dispatch_wgpu_error(device_id, error);
|
||||
},
|
||||
WebGPURequest::DestroyContext { context_id } => {
|
||||
self.destroy_context(context_id);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue