Skip to content

Commit

Permalink
Set VIEW_FORMATS downlevel_flag for test
Browse files Browse the repository at this point in the history
  • Loading branch information
jinleili committed Dec 1, 2022
1 parent 3d37a31 commit 9e485bd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
14 changes: 9 additions & 5 deletions wgpu-core/src/device/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1092,11 +1092,15 @@ impl<A: HalApi> Device<A> {
extent.depth_or_array_layers = view_layer_count;
}
let format = desc.format.unwrap_or(texture.desc.format);
if format != texture.desc.format && !texture.desc.view_formats.contains(&format) {
return Err(resource::CreateTextureViewError::FormatReinterpretation {
texture: texture.desc.format,
view: format,
});
if format != texture.desc.format {
if texture.desc.view_formats.contains(&format) {
self.require_downlevel_flags(wgt::DownlevelFlags::VIEW_FORMATS)?;
} else {
return Err(resource::CreateTextureViewError::FormatReinterpretation {
texture: texture.desc.format,
view: format,
});
}
}

// filter the usages based on the other criteria
Expand Down
2 changes: 2 additions & 0 deletions wgpu-core/src/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,8 @@ pub enum CreateTextureViewError {
texture: wgt::TextureFormat,
view: wgt::TextureFormat,
},
#[error(transparent)]
MissingDownlevelFlags(#[from] MissingDownlevelFlags),
}

#[derive(Clone, Debug, Error)]
Expand Down
7 changes: 5 additions & 2 deletions wgpu/tests/shader_view_format/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
use crate::common::{image::calc_difference, initialize_test, TestParameters, TestingContext};
use std::num::NonZeroU32;
use wgpu::{util::DeviceExt, TextureFormat};
use wgpu::{util::DeviceExt, DownlevelFlags, Limits, TextureFormat};

#[test]
fn reinterpret_srgb_ness() {
let parameters = TestParameters::default();
let parameters = TestParameters::default()
.downlevel_flags(DownlevelFlags::VIEW_FORMATS)
.limits(Limits::downlevel_defaults())
.specific_failure(Some(wgpu::Backends::GL), None, None, true);
initialize_test(parameters, |ctx| {
let unorm_data: [[u8; 4]; 4] = [
[180, 0, 0, 255],
Expand Down

0 comments on commit 9e485bd

Please sign in to comment.