Prevent an invalid texture from being registered in device_create_texture
@@ -1262,6 +1262,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;
@@ -1276,15 +1286,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()
