Skip to content

Commit ae25e1a

Browse files
committed
image texel write: change texel write arg from any vector to SampleResult, allows scalars
* breakage: no longer allows any vector, type must match image format * allows texel writes into single-component scalar textures
1 parent 4a75a05 commit ae25e1a

File tree

4 files changed

+9
-38
lines changed

4 files changed

+9
-38
lines changed

crates/spirv-std/src/image.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pub use self::params::{ImageCoordinate, ImageCoordinateSubpassData, ImageSizeQue
44
#[cfg(target_arch = "spirv")]
55
use crate::VectorTruncateInto;
66
pub use crate::macros::Image;
7-
use crate::{Float, Integer, Sampler, Vector};
7+
use crate::{Float, Integer, Sampler};
88
#[cfg(target_arch = "spirv")]
99
use core::arch::asm;
1010
use sample_with::{NoneTy, SampleParams, SomeTy};
@@ -799,10 +799,10 @@ impl<
799799
/// Write a texel to an image without a sampler.
800800
#[crate::macros::gpu_only]
801801
#[doc(alias = "OpImageWrite")]
802-
pub unsafe fn write<I, const N: usize>(
802+
pub unsafe fn write<I>(
803803
&self,
804804
coordinate: impl ImageCoordinate<I, DIM, ARRAYED>,
805-
texels: impl Vector<SampledType, N>,
805+
texels: SampledType::SampleResult,
806806
) where
807807
I: Integer,
808808
{
@@ -873,10 +873,10 @@ impl<
873873
/// Write a texel to an image without a sampler.
874874
#[crate::macros::gpu_only]
875875
#[doc(alias = "OpImageWrite")]
876-
pub unsafe fn write<I, const N: usize>(
876+
pub unsafe fn write<I>(
877877
&self,
878878
coordinate: impl ImageCoordinate<I, DIM, ARRAYED>,
879-
texels: impl Vector<SampledType, N>,
879+
texels: SampledType::SampleResult,
880880
) where
881881
I: Integer,
882882
{

tests/compiletests/ui/image/issue_527.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub fn main_cs(
1616
let p1 = &points_buffer[i + 1];
1717
if p0.x == position.x && p1.y == position.y {
1818
unsafe {
19-
image.write(position, vec2(1.0, 0.0));
19+
image.write(position, vec4(3.0, 2.0, 1.0, 0.0));
2020
};
2121
}
2222
}

tests/compiletests/ui/image/write.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22
// build-pass
33
// compile-flags: -C target-feature=+StorageImageWriteWithoutFormat
44

5+
use spirv_std::glam::*;
56
use spirv_std::spirv;
67
use spirv_std::{Image, arch};
78

89
#[spirv(fragment)]
910
pub fn main(
10-
texels: glam::Vec2,
11+
texels: Vec2,
1112
#[spirv(descriptor_set = 0, binding = 0)] image: &Image!(2D, type=f32, sampled=false),
1213
) {
1314
unsafe {
14-
image.write(glam::UVec2::new(0, 1), texels);
15+
image.write(UVec2::new(0, 1), Vec4::from((texels, 0., 0.)));
1516
}
1617
}

tests/compiletests/ui/image/write_format_scalar.stderr

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)