Formats: reject multisampled linear texture layouts
(cherry picked from commit 350f91c23a9402b2a556a84c208a80030910ae3f)
This commit is contained in:
1 parent
886afce1e3
commit
379f4e733d
1 file changed
+22
-1
@@ -274,7 +274,8 @@ impl Layout {
|
||||
&& matches!(d.block, 1 | 4)
|
||||
&& d.samples.is_power_of_two()
|
||||
&& d.samples <= 8
|
||||
&& (d.samples == 1 || (d.dimension == Dimension::Tex2d && d.mips == 1))
|
||||
&& (d.samples == 1
|
||||
|| (d.dimension == Dimension::Tex2d && d.mips == 1 && d.swizzle != Swizzle::LINEAR))
|
||||
&& (d.dimension != Dimension::Tex1d || d.height == 1)
|
||||
&& (d.dimension != Dimension::Tex3d
|
||||
|| matches!(d.swizzle.0, 0 | 5 | 9 | 17 | 21 | 24..=27));
|
||||
@@ -902,6 +903,26 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn linear_layouts_require_one_sample() {
|
||||
let linear = desc(256, 256, 1, 4, Swizzle::LINEAR);
|
||||
let single = Layout::new(&linear).unwrap();
|
||||
assert!(single.addressable());
|
||||
assert_eq!(single.size, 256 * 256 * 4);
|
||||
|
||||
for samples in [2, 4, 8] {
|
||||
let multisampled = Desc { samples, ..linear };
|
||||
assert_eq!(Layout::new(&multisampled), Err(Error::Invalid));
|
||||
|
||||
let tiled = Layout::new(&Desc {
|
||||
swizzle: Swizzle::SW_64KB_R_X,
|
||||
..multisampled
|
||||
})
|
||||
.unwrap();
|
||||
assert_eq!(tiled.size, single.size * u64::from(samples));
|
||||
}
|
||||
}
|
||||
|
||||
/// Sizes past the hardware's 16384 texels per side are refused instead
|
||||
/// of overflowing the size arithmetic (found by random-input testing).
|
||||
#[test]
|
||||
|
||||
Reference in new issue
Block a user