Skip to content

Commit 4a75a05

Browse files
committed
image texel write: compiletests with explicit formats, fails for scalar formats
1 parent e97524f commit 4a75a05

File tree

4 files changed

+79
-0
lines changed

4 files changed

+79
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Test `OpImageWrite`
2+
// build-pass
3+
4+
use spirv_std::glam::*;
5+
use spirv_std::spirv;
6+
use spirv_std::{Image, arch};
7+
8+
#[spirv(fragment)]
9+
pub fn main(
10+
texels: f32,
11+
#[spirv(descriptor_set = 0, binding = 0)] image: &Image!(2D, format = r32f, sampled = false),
12+
) {
13+
unsafe {
14+
image.write(UVec2::new(0, 1), texels);
15+
}
16+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
error[E0277]: the trait bound `f32: Vector<f32, _>` is not satisfied
2+
--> $DIR/write_format_scalar.rs:14:39
3+
|
4+
LL | image.write(UVec2::new(0, 1), texels);
5+
| ----- ^^^^^^ the trait `Vector<f32, _>` is not implemented for `f32`
6+
| |
7+
| required by a bound introduced by this call
8+
|
9+
= help: the following other types implement trait `Vector<T, N>`:
10+
`BVec2` implements `Vector<bool, 2>`
11+
`BVec3` implements `Vector<bool, 3>`
12+
`BVec4` implements `Vector<bool, 4>`
13+
`DVec2` implements `Vector<f64, 2>`
14+
`DVec3` implements `Vector<f64, 3>`
15+
`DVec4` implements `Vector<f64, 4>`
16+
`IVec2` implements `Vector<i32, 2>`
17+
`IVec3` implements `Vector<i32, 3>`
18+
and 8 others
19+
note: required by a bound in `Image::<SampledType, DIM, DEPTH, ARRAYED, MULTISAMPLED, spirv_std::::image::{impl#3}::{constant#0}, FORMAT, COMPONENTS>::write`
20+
--> /home/firestar99/workspace/rust-gpu/crates/spirv-std/src/image.rs:805:22
21+
|
22+
LL | pub unsafe fn write<I, const N: usize>(
23+
| ----- required by a bound in this associated function
24+
...
25+
LL | texels: impl Vector<SampledType, N>,
26+
| ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Image::<SampledType, DIM, DEPTH, ARRAYED, MULTISAMPLED, spirv_std::::image::{impl#3}::{constant#0}, FORMAT, COMPONENTS>::write`
27+
28+
error: aborting due to 1 previous error
29+
30+
For more information about this error, try `rustc --explain E0277`.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Test `OpImageWrite`
2+
// build-pass
3+
// compile-flags: -C target-feature=+StorageImageExtendedFormats
4+
5+
use spirv_std::glam::*;
6+
use spirv_std::spirv;
7+
use spirv_std::{Image, arch};
8+
9+
#[spirv(fragment)]
10+
pub fn main(
11+
texels: Vec2,
12+
#[spirv(descriptor_set = 0, binding = 0)] image: &Image!(2D, format = rg32f, sampled = false),
13+
) {
14+
unsafe {
15+
image.write(UVec2::new(0, 1), texels);
16+
}
17+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Test `OpImageWrite`
2+
// build-pass
3+
4+
use spirv_std::glam::*;
5+
use spirv_std::spirv;
6+
use spirv_std::{Image, arch};
7+
8+
#[spirv(fragment)]
9+
pub fn main(
10+
texels: Vec4,
11+
#[spirv(descriptor_set = 0, binding = 0)] image: &Image!(2D, format = rgba32f, sampled = false),
12+
) {
13+
unsafe {
14+
image.write(UVec2::new(0, 1), texels);
15+
}
16+
}

0 commit comments

Comments
 (0)