Prevent an invalid texture from being registered in device_create_texture

This commit is contained in:
Kunal Mohan authored and Dzmitry Malyshau committed 2020-10-05 14:47:32 -04:00
1 parent 776f3b6d81
commit 5b073e8dbe
1 file changed
+10 -9
+10 -9
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()