Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions crates/spirv-std/src/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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<I, const N: usize>(
pub unsafe fn write<I>(
&self,
coordinate: impl ImageCoordinate<I, DIM, ARRAYED>,
texels: impl Vector<SampledType, N>,
texels: SampledType::SampleResult,
) where
I: Integer,
{
Expand Down Expand Up @@ -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<I, const N: usize>(
pub unsafe fn write<I>(
&self,
coordinate: impl ImageCoordinate<I, DIM, ARRAYED>,
texels: impl Vector<SampledType, N>,
texels: SampledType::SampleResult,
) where
I: Integer,
{
Expand Down
2 changes: 1 addition & 1 deletion tests/compiletests/ui/image/issue_527.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
};
}
}
Expand Down
5 changes: 3 additions & 2 deletions tests/compiletests/ui/image/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.)));
}
}
16 changes: 16 additions & 0 deletions tests/compiletests/ui/image/write_format_scalar.rs
Original file line number Diff line number Diff line change
@@ -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);
}
}
17 changes: 17 additions & 0 deletions tests/compiletests/ui/image/write_format_vec2.rs
Original file line number Diff line number Diff line change
@@ -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);
}
}
16 changes: 16 additions & 0 deletions tests/compiletests/ui/image/write_format_vec4.rs
Original file line number Diff line number Diff line change
@@ -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);
}
}