diff --git a/crates/spirv-std/src/image.rs b/crates/spirv-std/src/image.rs index 9fa844d087..f1f72f676e 100644 --- a/crates/spirv-std/src/image.rs +++ b/crates/spirv-std/src/image.rs @@ -4,7 +4,7 @@ pub use self::params::{ImageCoordinate, ImageCoordinateSubpassData, ImageSizeQue #[cfg(target_arch = "spirv")] use crate::VectorTruncateInto; pub use crate::macros::Image; -use crate::{Float, Integer, Sampler, Vector}; +use crate::{Float, Integer, Sampler}; #[cfg(target_arch = "spirv")] use core::arch::asm; use sample_with::{NoneTy, SampleParams, SomeTy}; @@ -799,10 +799,10 @@ impl< /// Write a texel to an image without a sampler. #[crate::macros::gpu_only] #[doc(alias = "OpImageWrite")] - pub unsafe fn write( + pub unsafe fn write( &self, coordinate: impl ImageCoordinate, - texels: impl Vector, + texels: SampledType::SampleResult, ) where I: Integer, { @@ -873,10 +873,10 @@ impl< /// Write a texel to an image without a sampler. #[crate::macros::gpu_only] #[doc(alias = "OpImageWrite")] - pub unsafe fn write( + pub unsafe fn write( &self, coordinate: impl ImageCoordinate, - texels: impl Vector, + texels: SampledType::SampleResult, ) where I: Integer, { diff --git a/tests/compiletests/ui/image/issue_527.rs b/tests/compiletests/ui/image/issue_527.rs index 1e81023671..41d4b85863 100644 --- a/tests/compiletests/ui/image/issue_527.rs +++ b/tests/compiletests/ui/image/issue_527.rs @@ -16,7 +16,7 @@ pub fn main_cs( let p1 = &points_buffer[i + 1]; if p0.x == position.x && p1.y == position.y { unsafe { - image.write(position, vec2(1.0, 0.0)); + image.write(position, vec4(3.0, 2.0, 1.0, 0.0)); }; } } diff --git a/tests/compiletests/ui/image/write.rs b/tests/compiletests/ui/image/write.rs index 34dfae1350..9f24373cc8 100644 --- a/tests/compiletests/ui/image/write.rs +++ b/tests/compiletests/ui/image/write.rs @@ -2,15 +2,16 @@ // build-pass // compile-flags: -C target-feature=+StorageImageWriteWithoutFormat +use spirv_std::glam::*; use spirv_std::spirv; use spirv_std::{Image, arch}; #[spirv(fragment)] pub fn main( - texels: glam::Vec2, + texels: Vec2, #[spirv(descriptor_set = 0, binding = 0)] image: &Image!(2D, type=f32, sampled=false), ) { unsafe { - image.write(glam::UVec2::new(0, 1), texels); + image.write(UVec2::new(0, 1), Vec4::from((texels, 0., 0.))); } } diff --git a/tests/compiletests/ui/image/write_format_scalar.rs b/tests/compiletests/ui/image/write_format_scalar.rs new file mode 100644 index 0000000000..2bf227358c --- /dev/null +++ b/tests/compiletests/ui/image/write_format_scalar.rs @@ -0,0 +1,16 @@ +// Test `OpImageWrite` +// build-pass + +use spirv_std::glam::*; +use spirv_std::spirv; +use spirv_std::{Image, arch}; + +#[spirv(fragment)] +pub fn main( + texels: f32, + #[spirv(descriptor_set = 0, binding = 0)] image: &Image!(2D, format = r32f, sampled = false), +) { + unsafe { + image.write(UVec2::new(0, 1), texels); + } +} diff --git a/tests/compiletests/ui/image/write_format_vec2.rs b/tests/compiletests/ui/image/write_format_vec2.rs new file mode 100644 index 0000000000..8de4821a6a --- /dev/null +++ b/tests/compiletests/ui/image/write_format_vec2.rs @@ -0,0 +1,17 @@ +// Test `OpImageWrite` +// build-pass +// compile-flags: -C target-feature=+StorageImageExtendedFormats + +use spirv_std::glam::*; +use spirv_std::spirv; +use spirv_std::{Image, arch}; + +#[spirv(fragment)] +pub fn main( + texels: Vec2, + #[spirv(descriptor_set = 0, binding = 0)] image: &Image!(2D, format = rg32f, sampled = false), +) { + unsafe { + image.write(UVec2::new(0, 1), texels); + } +} diff --git a/tests/compiletests/ui/image/write_format_vec4.rs b/tests/compiletests/ui/image/write_format_vec4.rs new file mode 100644 index 0000000000..8ae9df41ea --- /dev/null +++ b/tests/compiletests/ui/image/write_format_vec4.rs @@ -0,0 +1,16 @@ +// Test `OpImageWrite` +// build-pass + +use spirv_std::glam::*; +use spirv_std::spirv; +use spirv_std::{Image, arch}; + +#[spirv(fragment)] +pub fn main( + texels: Vec4, + #[spirv(descriptor_set = 0, binding = 0)] image: &Image!(2D, format = rgba32f, sampled = false), +) { + unsafe { + image.write(UVec2::new(0, 1), texels); + } +}