diff --git a/crates/spirv-builder/src/test/basic.rs b/crates/spirv-builder/src/test/basic.rs index 11abab3588..b37bb147b2 100644 --- a/crates/spirv-builder/src/test/basic.rs +++ b/crates/spirv-builder/src/test/basic.rs @@ -613,7 +613,9 @@ fn image_write() { #[spirv(fragment)] pub fn main(input: Input, image: UniformConstant) { let texels = *input; - image.write(glam::UVec2::new(0, 1), texels); + unsafe { + image.write(glam::UVec2::new(0, 1), texels); + } } "#); } diff --git a/crates/spirv-std/src/textures.rs b/crates/spirv-std/src/textures.rs index 14624c6835..80c518d86e 100644 --- a/crates/spirv-std/src/textures.rs +++ b/crates/spirv-std/src/textures.rs @@ -89,22 +89,20 @@ impl StorageImage2d { /// Write a texel to an image without a sampler. #[spirv_std_macros::gpu_only] - pub fn write(&self, coordinate: V, texels: V2) + pub unsafe fn write(&self, coordinate: V, texels: V2) where I: Integer, V: Vector, V2: Vector, { - unsafe { - asm! { - "%image = OpLoad _ {this}", - "%coordinate = OpLoad _ {coordinate}", - "%texels = OpLoad _ {texels}", - "OpImageWrite %image %coordinate %texels", - this = in(reg) self, - coordinate = in(reg) &coordinate, - texels = in(reg) &texels, - } + asm! { + "%image = OpLoad _ {this}", + "%coordinate = OpLoad _ {coordinate}", + "%texels = OpLoad _ {texels}", + "OpImageWrite %image %coordinate %texels", + this = in(reg) self, + coordinate = in(reg) &coordinate, + texels = in(reg) &texels, } } }