Prevent an invalid texture from being registered in device_create_texture

This commit is contained in:
Kunal Mohan 2020-09-23 00:30:50 +05:30 committed by Dzmitry Malyshau
parent 776f3b6d81
commit 5b073e8dbe

View File

@ -1226,6 +1226,16 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
let device = device_guard
.get(device_id)
.map_err(|_| DeviceError::Invalid)?;
let texture_features = conv::texture_features(desc.format);
if texture_features != wgt::Features::empty() && !device.features.contains(texture_features)
{
return Err(resource::CreateTextureError::MissingFeature(
texture_features,
desc.format,
));
}
let texture = device.create_texture(device_id, desc)?;
let num_levels = texture.full_range.levels.end;
let num_layers = texture.full_range.layers.end;
@ -1240,15 +1250,6 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
None => (),
};
let texture_features = conv::texture_features(desc.format);
if texture_features != wgt::Features::empty() && !device.features.contains(texture_features)
{
return Err(resource::CreateTextureError::MissingFeature(
texture_features,
desc.format,
));
}
device
.trackers
.lock()