mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-22 06:44:14 +00:00
Prevent an invalid texture from being registered in device_create_texture
This commit is contained in:
parent
776f3b6d81
commit
5b073e8dbe
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user