diff --git a/crates/spirv-std/src/textures.rs b/crates/spirv-std/src/textures.rs index b6aac362a9..86aa662956 100644 --- a/crates/spirv-std/src/textures.rs +++ b/crates/spirv-std/src/textures.rs @@ -22,6 +22,7 @@ pub struct Image2d { impl Image2d { #[spirv_std_macros::gpu_only] + #[doc(alias = "OpImageSampleImplicitLod")] pub fn sample>( &self, sampler: Sampler, @@ -44,7 +45,9 @@ impl Image2d { result } } + #[spirv_std_macros::gpu_only] + #[doc(alias = "OpImageSampleExplicitLod")] /// Sample the image at a coordinate by a lod pub fn sample_by_lod>( &self, @@ -71,7 +74,9 @@ impl Image2d { } result } + #[spirv_std_macros::gpu_only] + #[doc(alias = "OpImageSampleExplicitLod")] /// Sample the image based on a gradient formed by (dx, dy). Specifically, ([du/dx, dv/dx], [du/dy, dv/dy]) pub fn sample_by_gradient>( &self, @@ -101,8 +106,290 @@ impl Image2d { } result } + + #[spirv_std_macros::gpu_only] + #[doc(alias = "OpImageSampleProjImplicitLod")] + pub fn sample_with_project_coordinate>( + &self, + sampler: Sampler, + project_coordinate: impl Vector, + ) -> V { + unsafe { + let mut result = Default::default(); + asm!( + "%image = OpLoad _ {this}", + "%sampler = OpLoad _ {sampler}", + "%project_coordinate = OpLoad _ {project_coordinate}", + "%sampledImage = OpSampledImage _ %image %sampler", + "%result = OpImageSampleProjImplicitLod _ %sampledImage %project_coordinate", + "OpStore {result} %result", + result = in(reg) &mut result, + this = in(reg) self, + sampler = in(reg) &sampler, + project_coordinate = in(reg) &project_coordinate, + ); + result + } + } + + #[spirv_std_macros::gpu_only] + #[doc(alias = "OpImageSampleProjExplicitLod")] + /// Sample the image with a project coordinate by a lod + pub fn sample_with_project_coordinate_by_lod>( + &self, + sampler: Sampler, + project_coordinate: impl Vector, + lod: f32, + ) -> V { + let mut result = Default::default(); + unsafe { + asm!( + "%image = OpLoad _ {this}", + "%sampler = OpLoad _ {sampler}", + "%project_coordinate = OpLoad _ {project_coordinate}", + "%lod = OpLoad _ {lod}", + "%sampledImage = OpSampledImage _ %image %sampler", + "%result = OpImageSampleProjExplicitLod _ %sampledImage %project_coordinate Lod %lod", + "OpStore {result} %result", + result = in(reg) &mut result, + this = in(reg) self, + sampler = in(reg) &sampler, + project_coordinate = in(reg) &project_coordinate, + lod = in(reg) &lod + ); + } + result + } + + #[spirv_std_macros::gpu_only] + #[doc(alias = "OpImageSampleProjExplicitLod")] + /// Sample the image with a project coordinate based on a gradient formed by (dx, dy). Specifically, ([du/dx, dv/dx], [du/dy, dv/dy]) + pub fn sample_with_project_coordinate_by_gradient>( + &self, + sampler: Sampler, + project_coordinate: impl Vector, + gradient_dx: impl Vector, + gradient_dy: impl Vector, + ) -> V { + let mut result = Default::default(); + unsafe { + asm!( + "%image = OpLoad _ {this}", + "%sampler = OpLoad _ {sampler}", + "%project_coordinate = OpLoad _ {project_coordinate}", + "%gradient_dx = OpLoad _ {gradient_dx}", + "%gradient_dy = OpLoad _ {gradient_dy}", + "%sampledImage = OpSampledImage _ %image %sampler", + "%result = OpImageSampleProjExplicitLod _ %sampledImage %project_coordinate Grad %gradient_dx %gradient_dy", + "OpStore {result} %result", + result = in(reg) &mut result, + this = in(reg) self, + sampler = in(reg) &sampler, + project_coordinate = in(reg) &project_coordinate, + gradient_dx = in(reg) &gradient_dx, + gradient_dy = in(reg) &gradient_dy, + ); + } + result + } + + #[spirv_std_macros::gpu_only] + #[doc(alias = "OpImageSampleDrefImplicitLod")] + /// Sample the image's depth reference + pub fn sample_depth_reference( + &self, + sampler: Sampler, + coordinate: impl Vector, + depth_reference: f32, + ) -> f32 { + let mut result = Default::default(); + unsafe { + asm!( + "%image = OpLoad _ {this}", + "%sampler = OpLoad _ {sampler}", + "%coordinate = OpLoad _ {coordinate}", + "%depth_reference = OpLoad _ {depth_reference}", // not required to do this way, but done for consistency + "%sampledImage = OpSampledImage _ %image %sampler", + "%result = OpImageSampleDrefImplicitLod _ %sampledImage %coordinate %depth_reference", + "OpStore {result} %result", + result = in(reg) &mut result, + this = in(reg) self, + sampler = in(reg) &sampler, + coordinate = in(reg) &coordinate, + depth_reference = in(reg) &depth_reference, + ); + } + result + } + + #[spirv_std_macros::gpu_only] + #[doc(alias = "OpImageSampleDrefExplicitLod")] + /// Sample the image's depth reference based on an explicit lod + pub fn sample_depth_reference_by_lod( + &self, + sampler: Sampler, + coordinate: impl Vector, + depth_reference: f32, + lod: f32, + ) -> f32 { + let mut result = Default::default(); + unsafe { + asm!( + "%image = OpLoad _ {this}", + "%sampler = OpLoad _ {sampler}", + "%coordinate = OpLoad _ {coordinate}", + "%depth_reference = OpLoad _ {depth_reference}", + "%lod = OpLoad _ {lod}", + "%sampledImage = OpSampledImage _ %image %sampler", + "%result = OpImageSampleDrefExplicitLod _ %sampledImage %coordinate %depth_reference Lod %lod", + "OpStore {result} %result", + result = in(reg) &mut result, + this = in(reg) self, + sampler = in(reg) &sampler, + coordinate = in(reg) &coordinate, + depth_reference = in(reg) &depth_reference, + lod = in(reg) &lod, + ) + } + result + } + + #[spirv_std_macros::gpu_only] + #[doc(alias = "OpImageSampleDrefExplicitLod")] + /// Sample the image's depth reference based on a gradient formed by (dx, dy). + /// Specifically, ([du/dx, dv/dx], [du/dy, dv/dy]) + pub fn sample_depth_reference_by_gradient( + &self, + sampler: Sampler, + coordinate: impl Vector, + depth_reference: f32, + gradient_dx: impl Vector, + gradient_dy: impl Vector, + ) -> f32 { + let mut result = Default::default(); + unsafe { + asm!( + "%image = OpLoad _ {this}", + "%sampler = OpLoad _ {sampler}", + "%coordinate = OpLoad _ {coordinate}", + "%depth_reference = OpLoad _ {depth_reference}", + "%gradient_dx = OpLoad _ {gradient_dx}", + "%gradient_dy = OpLoad _ {gradient_dy}", + "%sampledImage = OpSampledImage _ %image %sampler", + "%result = OpImageSampleDrefExplicitLod _ %sampledImage %coordinate %depth_reference Grad %gradient_dx %gradient_dy", + "OpStore {result} %result", + result = in(reg) &mut result, + this = in(reg) self, + sampler = in(reg) &sampler, + coordinate = in(reg) &coordinate, + depth_reference = in(reg) &depth_reference, + gradient_dx = in(reg) &gradient_dx, + gradient_dy = in(reg) &gradient_dy, + ); + } + result + } + + #[spirv_std_macros::gpu_only] + #[doc(alias = "OpImageSampleProjDrefImplicitLod")] + /// Sample the image's depth reference with the project coordinate + pub fn sample_depth_reference_with_project_coordinate( + &self, + sampler: Sampler, + project_coordinate: impl Vector, + depth_reference: f32, + ) -> f32 { + let mut result = Default::default(); + unsafe { + asm!( + "%image = OpLoad _ {this}", + "%sampler = OpLoad _ {sampler}", + "%project_coordinate = OpLoad _ {project_coordinate}", + "%depth_reference = OpLoad _ {depth_reference}", // not required to do this way, but done for consistency + "%sampledImage = OpSampledImage _ %image %sampler", + "%result = OpImageSampleProjDrefImplicitLod _ %sampledImage %project_coordinate %depth_reference", + "OpStore {result} %result", + result = in(reg) &mut result, + this = in(reg) self, + sampler = in(reg) &sampler, + project_coordinate = in(reg) &project_coordinate, + depth_reference = in(reg) &depth_reference, + ); + } + result + } + + #[spirv_std_macros::gpu_only] + #[doc(alias = "OpImageSampleProjDrefExplicitLod")] + /// Sample the image's depth reference with the project coordinate based on an explicit lod + pub fn sample_depth_reference_with_project_coordinate_by_lod( + &self, + sampler: Sampler, + coordinate: impl Vector, + depth_reference: f32, + lod: f32, + ) -> f32 { + let mut result = Default::default(); + unsafe { + asm!( + "%image = OpLoad _ {this}", + "%sampler = OpLoad _ {sampler}", + "%coordinate = OpLoad _ {coordinate}", + "%depth_reference = OpLoad _ {depth_reference}", + "%lod = OpLoad _ {lod}", + "%sampledImage = OpSampledImage _ %image %sampler", + "%result = OpImageSampleProjDrefExplicitLod _ %sampledImage %coordinate %depth_reference Lod %lod", + "OpStore {result} %result", + result = in(reg) &mut result, + this = in(reg) self, + sampler = in(reg) &sampler, + coordinate = in(reg) &coordinate, + depth_reference = in(reg) &depth_reference, + lod = in(reg) &lod, + ) + } + result + } + + #[spirv_std_macros::gpu_only] + #[doc(alias = "OpImageSampleProjDrefExplicitLod")] + /// Sample the image's depth reference with the project coordinate based on a gradient formed by (dx, dy). + /// Specifically, ([du/dx, dv/dx], [du/dy, dv/dy]) + pub fn sample_depth_reference_with_project_coordinate_by_gradient( + &self, + sampler: Sampler, + coordinate: impl Vector, + depth_reference: f32, + gradient_dx: impl Vector, + gradient_dy: impl Vector, + ) -> f32 { + let mut result = Default::default(); + unsafe { + asm!( + "%image = OpLoad _ {this}", + "%sampler = OpLoad _ {sampler}", + "%coordinate = OpLoad _ {coordinate}", + "%depth_reference = OpLoad _ {depth_reference}", + "%gradient_dx = OpLoad _ {gradient_dx}", + "%gradient_dy = OpLoad _ {gradient_dy}", + "%sampledImage = OpSampledImage _ %image %sampler", + "%result = OpImageSampleProjDrefExplicitLod _ %sampledImage %coordinate %depth_reference Grad %gradient_dx %gradient_dy", + "OpStore {result} %result", + result = in(reg) &mut result, + this = in(reg) self, + sampler = in(reg) &sampler, + coordinate = in(reg) &coordinate, + depth_reference = in(reg) &depth_reference, + gradient_dx = in(reg) &gradient_dx, + gradient_dy = in(reg) &gradient_dy, + ); + } + result + } + /// Fetch a single texel with a sampler set at compile time #[spirv_std_macros::gpu_only] + #[doc(alias = "OpImageFetch")] pub fn fetch(&self, coordinate: impl Vector) -> V where V: Vector, @@ -142,6 +429,7 @@ pub struct StorageImage2d { impl StorageImage2d { /// Read a texel from an image without a sampler. #[spirv_std_macros::gpu_only] + #[doc(alias = "OpImageRead")] pub fn read(&self, coordinate: impl Vector) -> V where I: Integer, @@ -166,6 +454,7 @@ impl StorageImage2d { /// Write a texel to an image without a sampler. #[spirv_std_macros::gpu_only] + #[doc(alias = "OpImageWrite")] pub unsafe fn write( &self, coordinate: impl Vector, @@ -201,6 +490,7 @@ pub struct Image2dArray { impl Image2dArray { #[spirv_std_macros::gpu_only] + #[doc(alias = "OpImageSampleImplicitLod")] pub fn sample>( &self, sampler: Sampler, @@ -223,7 +513,9 @@ impl Image2dArray { result } } + #[spirv_std_macros::gpu_only] + #[doc(alias = "OpImageSampleExplicitLod")] /// Sample the image at a coordinate by a lod pub fn sample_by_lod>( &self, @@ -250,7 +542,9 @@ impl Image2dArray { } result } + #[spirv_std_macros::gpu_only] + #[doc(alias = "OpImageSampleExplicitLod")] /// Sample the image based on a gradient formed by (dx, dy). Specifically, ([du/dx, dv/dx], [du/dy, dv/dy]) pub fn sample_by_gradient>( &self, @@ -280,6 +574,103 @@ impl Image2dArray { } result } + + #[spirv_std_macros::gpu_only] + #[doc(alias = "OpImageSampleDrefImplicitLod")] + /// Sample the image's depth reference + pub fn sample_depth_reference( + &self, + sampler: Sampler, + coordinate: impl Vector, + depth_reference: f32, + ) -> f32 { + let mut result = Default::default(); + unsafe { + asm!( + "%image = OpLoad _ {this}", + "%sampler = OpLoad _ {sampler}", + "%coordinate = OpLoad _ {coordinate}", + "%depth_reference = OpLoad _ {depth_reference}", // not required to do this way, but done for consistency + "%sampledImage = OpSampledImage _ %image %sampler", + "%result = OpImageSampleDrefImplicitLod _ %sampledImage %coordinate %depth_reference", + "OpStore {result} %result", + result = in(reg) &mut result, + this = in(reg) self, + sampler = in(reg) &sampler, + coordinate = in(reg) &coordinate, + depth_reference = in(reg) &depth_reference, + ); + } + result + } + + #[spirv_std_macros::gpu_only] + #[doc(alias = "OpImageSampleDrefExplicitLod")] + /// Sample the image's depth reference based on an explicit lod + pub fn sample_depth_reference_by_lod( + &self, + sampler: Sampler, + coordinate: impl Vector, + depth_reference: f32, + lod: f32, + ) -> f32 { + let mut result = Default::default(); + unsafe { + asm!( + "%image = OpLoad _ {this}", + "%sampler = OpLoad _ {sampler}", + "%coordinate = OpLoad _ {coordinate}", + "%depth_reference = OpLoad _ {depth_reference}", + "%lod = OpLoad _ {lod}", + "%sampledImage = OpSampledImage _ %image %sampler", + "%result = OpImageSampleDrefExplicitLod _ %sampledImage %coordinate %depth_reference Lod %lod", + "OpStore {result} %result", + result = in(reg) &mut result, + this = in(reg) self, + sampler = in(reg) &sampler, + coordinate = in(reg) &coordinate, + depth_reference = in(reg) &depth_reference, + lod = in(reg) &lod, + ) + } + result + } + + #[spirv_std_macros::gpu_only] + #[doc(alias = "OpImageSampleDrefExplicitLod")] + /// Sample the image's depth reference based on a gradient formed by (dx, dy). + /// Specifically, ([du/dx, dv/dx], [du/dy, dv/dy]) + pub fn sample_depth_reference_by_gradient( + &self, + sampler: Sampler, + coordinate: impl Vector, + depth_reference: f32, + gradient_dx: impl Vector, + gradient_dy: impl Vector, + ) -> f32 { + let mut result = Default::default(); + unsafe { + asm!( + "%image = OpLoad _ {this}", + "%sampler = OpLoad _ {sampler}", + "%coordinate = OpLoad _ {coordinate}", + "%depth_reference = OpLoad _ {depth_reference}", + "%gradient_dx = OpLoad _ {gradient_dx}", + "%gradient_dy = OpLoad _ {gradient_dy}", + "%sampledImage = OpSampledImage _ %image %sampler", + "%result = OpImageSampleDrefExplicitLod _ %sampledImage %coordinate %depth_reference Grad %gradient_dx %gradient_dy", + "OpStore {result} %result", + result = in(reg) &mut result, + this = in(reg) self, + sampler = in(reg) &sampler, + coordinate = in(reg) &coordinate, + depth_reference = in(reg) &depth_reference, + gradient_dx = in(reg) &gradient_dx, + gradient_dy = in(reg) &gradient_dy, + ); + } + result + } } #[spirv(image_type( @@ -298,6 +689,7 @@ pub struct Cubemap { impl Cubemap { #[spirv_std_macros::gpu_only] + #[doc(alias = "OpSampledImage")] pub fn sample>( &self, sampler: Sampler, @@ -320,7 +712,9 @@ impl Cubemap { result } } + #[spirv_std_macros::gpu_only] + #[doc(alias = "OpImageSampleExplicitLod")] /// Sample the image at a coordinate by a lod pub fn sample_by_lod>( &self, @@ -347,8 +741,10 @@ impl Cubemap { } result } + #[spirv_std_macros::gpu_only] - /// Sample the image based on a gradient formed by (dx, dy). Specifically, ([du/dx, dv/dx], [du/dy, dv/dy]) + #[doc(alias = "OpImageSampleExplicitLod")] + /// Sample the image based on a gradient formed by (dx, dy). Specifically, ([du/dx, dv/dx, dw/dx], [du/dy, dv/dy, dw/dy]) pub fn sample_by_gradient>( &self, sampler: Sampler, @@ -377,6 +773,103 @@ impl Cubemap { } result } + + #[spirv_std_macros::gpu_only] + #[doc(alias = "OpImageSampleDrefImplicitLod")] + /// Sample the image's depth reference + pub fn sample_depth_reference( + &self, + sampler: Sampler, + coordinate: impl Vector, + depth_reference: f32, + ) -> f32 { + let mut result = Default::default(); + unsafe { + asm!( + "%image = OpLoad _ {this}", + "%sampler = OpLoad _ {sampler}", + "%coordinate = OpLoad _ {coordinate}", + "%depth_reference = OpLoad _ {depth_reference}", // not required to do this way, but done for consistency + "%sampledImage = OpSampledImage _ %image %sampler", + "%result = OpImageSampleDrefImplicitLod _ %sampledImage %coordinate %depth_reference", + "OpStore {result} %result", + result = in(reg) &mut result, + this = in(reg) self, + sampler = in(reg) &sampler, + coordinate = in(reg) &coordinate, + depth_reference = in(reg) &depth_reference, + ); + } + result + } + + #[spirv_std_macros::gpu_only] + #[doc(alias = "OpImageSampleDrefExplicitLod")] + /// Sample the image's depth reference based on an explicit lod + pub fn sample_depth_reference_by_lod( + &self, + sampler: Sampler, + coordinate: impl Vector, + depth_reference: f32, + lod: f32, + ) -> f32 { + let mut result = Default::default(); + unsafe { + asm!( + "%image = OpLoad _ {this}", + "%sampler = OpLoad _ {sampler}", + "%coordinate = OpLoad _ {coordinate}", + "%depth_reference = OpLoad _ {depth_reference}", + "%lod = OpLoad _ {lod}", + "%sampledImage = OpSampledImage _ %image %sampler", + "%result = OpImageSampleDrefExplicitLod _ %sampledImage %coordinate %depth_reference Lod %lod", + "OpStore {result} %result", + result = in(reg) &mut result, + this = in(reg) self, + sampler = in(reg) &sampler, + coordinate = in(reg) &coordinate, + depth_reference = in(reg) &depth_reference, + lod = in(reg) &lod, + ) + } + result + } + + #[spirv_std_macros::gpu_only] + #[doc(alias = "OpImageSampleDrefExplicitLod")] + /// Sample the image's depth reference based on a gradient formed by (dx, dy). + /// Specifically, ([du/dx, dv/dx, dw/dx], [du/dy, dv/dy, dw/dy]) + pub fn sample_depth_reference_by_gradient( + &self, + sampler: Sampler, + coordinate: impl Vector, + depth_reference: f32, + gradient_dx: impl Vector, + gradient_dy: impl Vector, + ) -> f32 { + let mut result = Default::default(); + unsafe { + asm!( + "%image = OpLoad _ {this}", + "%sampler = OpLoad _ {sampler}", + "%coordinate = OpLoad _ {coordinate}", + "%depth_reference = OpLoad _ {depth_reference}", + "%gradient_dx = OpLoad _ {gradient_dx}", + "%gradient_dy = OpLoad _ {gradient_dy}", + "%sampledImage = OpSampledImage _ %image %sampler", + "%result = OpImageSampleDrefExplicitLod _ %sampledImage %coordinate %depth_reference Grad %gradient_dx %gradient_dy", + "OpStore {result} %result", + result = in(reg) &mut result, + this = in(reg) self, + sampler = in(reg) &sampler, + coordinate = in(reg) &coordinate, + depth_reference = in(reg) &depth_reference, + gradient_dx = in(reg) &gradient_dx, + gradient_dy = in(reg) &gradient_dy, + ); + } + result + } } #[spirv(sampled_image)] @@ -387,6 +880,7 @@ pub struct SampledImage { impl SampledImage { #[spirv_std_macros::gpu_only] + #[doc(alias = "OpImageSampleImplicitLod")] pub fn sample>(&self, coordinate: impl Vector) -> V { unsafe { let mut result = Default::default(); diff --git a/tests/ui/image/sample_depth_reference/sample.rs b/tests/ui/image/sample_depth_reference/sample.rs new file mode 100644 index 0000000000..9e7bcc3e45 --- /dev/null +++ b/tests/ui/image/sample_depth_reference/sample.rs @@ -0,0 +1,19 @@ +// Test `OpImageSampleDrefImplicitLod` +// build-pass + +use spirv_std::{arch, Cubemap, Image2d, Image2dArray, Sampler}; + +#[spirv(fragment)] +pub fn main( + #[spirv(uniform_constant, descriptor_set = 0, binding = 0)] image: &Image2d, + #[spirv(uniform_constant, descriptor_set = 1, binding = 1)] image_array: &Image2dArray, + #[spirv(uniform_constant, descriptor_set = 2, binding = 2)] cubemap: &Cubemap, + #[spirv(uniform_constant, descriptor_set = 3, binding = 3)] sampler: &Sampler, + output: &mut f32, +) { + let v2 = glam::Vec2::new(0.0, 1.0); + let v3 = glam::Vec3A::new(0.0, 0.0, 1.0); + *output = image.sample_depth_reference(*sampler, v2, 1.0); + *output += image_array.sample_depth_reference(*sampler, v3, 1.0); + *output += cubemap.sample_depth_reference(*sampler, v3, 1.0); +} diff --git a/tests/ui/image/sample_depth_reference/sample_gradient.rs b/tests/ui/image/sample_depth_reference/sample_gradient.rs new file mode 100644 index 0000000000..2ad5301b0b --- /dev/null +++ b/tests/ui/image/sample_depth_reference/sample_gradient.rs @@ -0,0 +1,23 @@ +// Test `OpImageSampleDrefExplicitLod` +// build-pass + +use spirv_std::{arch, Cubemap, Image2d, Image2dArray, Sampler}; + +#[spirv(fragment)] +pub fn main( + #[spirv(uniform_constant, descriptor_set = 0, binding = 0)] image: &Image2d, + #[spirv(uniform_constant, descriptor_set = 1, binding = 1)] image_array: &Image2dArray, + #[spirv(uniform_constant, descriptor_set = 2, binding = 2)] sampler: &Sampler, + #[spirv(uniform_constant, descriptor_set = 3, binding = 3)] cubemap: &Cubemap, + output: &mut f32, +) { + let v2 = glam::Vec2::new(0.0, 1.0); + let v2_dx = glam::Vec2::new(0.0, 1.0); + let v2_dy = glam::Vec2::new(0.0, 1.0); + let v3 = glam::Vec3A::new(0.0, 0.0, 1.0); + let v3_dx = glam::Vec3A::new(0.0, 1.0, 0.5); + let v3_dy = glam::Vec3A::new(0.0, 1.0, 0.5); + *output = image.sample_depth_reference_by_gradient(*sampler, v2, 1.0, v2_dx, v2_dy); + *output += image_array.sample_depth_reference_by_gradient(*sampler, v3, 1.0, v2_dx, v2_dy); + *output += cubemap.sample_depth_reference_by_gradient(*sampler, v3, 1.0, v3_dx, v3_dy); +} diff --git a/tests/ui/image/sample_depth_reference/sample_lod.rs b/tests/ui/image/sample_depth_reference/sample_lod.rs new file mode 100644 index 0000000000..76d3b1e219 --- /dev/null +++ b/tests/ui/image/sample_depth_reference/sample_lod.rs @@ -0,0 +1,19 @@ +// Test `OpImageSampleDrefExplicitLod` +// build-pass + +use spirv_std::{arch, Cubemap, Image2d, Image2dArray, Sampler}; + +#[spirv(fragment)] +pub fn main( + #[spirv(uniform_constant, descriptor_set = 0, binding = 0)] image: &Image2d, + #[spirv(uniform_constant, descriptor_set = 1, binding = 1)] image_array: &Image2dArray, + #[spirv(uniform_constant, descriptor_set = 2, binding = 2)] sampler: &Sampler, + #[spirv(uniform_constant, descriptor_set = 3, binding = 3)] cubemap: &Cubemap, + output: &mut f32, +) { + let v2 = glam::Vec2::new(0.0, 1.0); + let v3 = glam::Vec3A::new(0.0, 0.0, 1.0); + *output = image.sample_depth_reference_by_lod(*sampler, v2, 1.0, 0.0); + *output += image_array.sample_depth_reference_by_lod(*sampler, v3, 1.0, 0.0); + *output += image_array.sample_depth_reference_by_lod(*sampler, v3, 1.0, 0.0); +} diff --git a/tests/ui/image/sample_depth_reference_with_project_coordinate/sample.rs b/tests/ui/image/sample_depth_reference_with_project_coordinate/sample.rs new file mode 100644 index 0000000000..959bc42ba6 --- /dev/null +++ b/tests/ui/image/sample_depth_reference_with_project_coordinate/sample.rs @@ -0,0 +1,14 @@ +// Test `OpImageSampleProjDrefImplicitLod` +// build-pass + +use spirv_std::{arch, Image2d, Sampler}; + +#[spirv(fragment)] +pub fn main( + #[spirv(uniform_constant, descriptor_set = 0, binding = 0)] image: &Image2d, + #[spirv(uniform_constant, descriptor_set = 1, binding = 1)] sampler: &Sampler, + output: &mut f32, +) { + let v3 = glam::Vec3A::new(0.0, 0.0, 1.0); + *output = image.sample_depth_reference_with_project_coordinate(*sampler, v3, 1.0); +} diff --git a/tests/ui/image/sample_depth_reference_with_project_coordinate/sample_gradient.rs b/tests/ui/image/sample_depth_reference_with_project_coordinate/sample_gradient.rs new file mode 100644 index 0000000000..a458b06f11 --- /dev/null +++ b/tests/ui/image/sample_depth_reference_with_project_coordinate/sample_gradient.rs @@ -0,0 +1,16 @@ +// Test `OpImageSampleProjDrefExplicitLod` +// build-pass + +use spirv_std::{arch, Image2d, Sampler}; + +#[spirv(fragment)] +pub fn main( + #[spirv(uniform_constant, descriptor_set = 0, binding = 0)] image: &Image2d, + #[spirv(uniform_constant, descriptor_set = 1, binding = 1)] sampler: &Sampler, + output: &mut f32, +) { + let v2_dx = glam::Vec2::new(0.0, 1.0); + let v2_dy = glam::Vec2::new(0.0, 1.0); + let v3 = glam::Vec3A::new(0.0, 0.0, 1.0); + *output = image.sample_depth_reference_with_project_coordinate_by_gradient(*sampler, v3, 1.0, v2_dx, v2_dy); +} diff --git a/tests/ui/image/sample_depth_reference_with_project_coordinate/sample_lod.rs b/tests/ui/image/sample_depth_reference_with_project_coordinate/sample_lod.rs new file mode 100644 index 0000000000..95e40149b2 --- /dev/null +++ b/tests/ui/image/sample_depth_reference_with_project_coordinate/sample_lod.rs @@ -0,0 +1,14 @@ +// Test `OpImageSampleProjDrefExplicitLod` +// build-pass + +use spirv_std::{arch, Image2d, Sampler}; + +#[spirv(fragment)] +pub fn main( + #[spirv(uniform_constant, descriptor_set = 0, binding = 0)] image: &Image2d, + #[spirv(uniform_constant, descriptor_set = 1, binding = 1)] sampler: &Sampler, + output: &mut f32, +) { + let v3 = glam::Vec3A::new(0.0, 0.0, 1.0); + *output = image.sample_depth_reference_with_project_coordinate_by_lod(*sampler, v3, 1.0, 0.0); +} diff --git a/tests/ui/image/sample_with_project_coordinate/sample.rs b/tests/ui/image/sample_with_project_coordinate/sample.rs new file mode 100644 index 0000000000..dc8c8d0e39 --- /dev/null +++ b/tests/ui/image/sample_with_project_coordinate/sample.rs @@ -0,0 +1,14 @@ +// Test `OpImageSampleProjImplicitLod` +// build-pass + +use spirv_std::{arch, Image2d, Sampler}; + +#[spirv(fragment)] +pub fn main( + #[spirv(uniform_constant, descriptor_set = 0, binding = 0)] image2d: &Image2d, + #[spirv(uniform_constant, descriptor_set = 1, binding = 1)] sampler: &Sampler, + output: &mut glam::Vec4, +) { + let v3 = glam::Vec3::new(0.0, 1.0, 0.5); + *output = image2d.sample_with_project_coordinate(*sampler, v3); +} diff --git a/tests/ui/image/sample_with_project_coordinate/sample_gradient.rs b/tests/ui/image/sample_with_project_coordinate/sample_gradient.rs new file mode 100644 index 0000000000..aa5c8b95cf --- /dev/null +++ b/tests/ui/image/sample_with_project_coordinate/sample_gradient.rs @@ -0,0 +1,15 @@ +// Test `OpImageSampleProjExplicitLod` +// build-pass + +use spirv_std::{arch, Image2d, Sampler}; + +#[spirv(fragment)] +pub fn main( + #[spirv(uniform_constant, descriptor_set = 0, binding = 0)] image2d: &Image2d, + #[spirv(uniform_constant, descriptor_set = 1, binding = 1)] sampler: &Sampler, + output: &mut glam::Vec4, +) { + let v2 = glam::Vec2::new(0.0, 1.0); + let v3 = glam::Vec3::new(0.0, 1.0, 0.5); + *output = image2d.sample_with_project_coordinate_by_gradient(*sampler, v3, v2, v2); +} diff --git a/tests/ui/image/sample_with_project_coordinate/sample_lod.rs b/tests/ui/image/sample_with_project_coordinate/sample_lod.rs new file mode 100644 index 0000000000..3e9e19c182 --- /dev/null +++ b/tests/ui/image/sample_with_project_coordinate/sample_lod.rs @@ -0,0 +1,14 @@ +// Test `OpImageSampleProjExplicitLod` +// build-pass + +use spirv_std::{arch, Image2d, Sampler}; + +#[spirv(fragment)] +pub fn main( + #[spirv(uniform_constant, descriptor_set = 0, binding = 0)] image2d: &Image2d, + #[spirv(uniform_constant, descriptor_set = 1, binding = 1)] sampler: &Sampler, + output: &mut glam::Vec4, +) { + let v3 = glam::Vec3::new(0.0, 1.0, 0.5); + *output = image2d.sample_with_project_coordinate_by_lod(*sampler, v3, 0.0); +}