Skip to content

Commit

Permalink
feat: Added instructions for depth reference and project coordinate i…
Browse files Browse the repository at this point in the history
…mage instructions
  • Loading branch information
DeanBDean committed Mar 29, 2021
1 parent 182bbca commit ff85f68
Show file tree
Hide file tree
Showing 10 changed files with 615 additions and 1 deletion.
468 changes: 467 additions & 1 deletion crates/spirv-std/src/textures.rs

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions tests/ui/image/sample_depth_reference/sample.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Test `OpImageSampleDrefImplicitLod`
// build-pass

use spirv_std::{arch, Cubemap, Image2d, Image2dArray, Sampler};

#[spirv(fragment)]
pub fn main(
#[spirv(uniform_constant)] image: &Image2d,
#[spirv(uniform_constant)] image_array: &Image2dArray,
#[spirv(uniform_constant)] cubemap: &Cubemap,
#[spirv(uniform_constant)] 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);
}
23 changes: 23 additions & 0 deletions tests/ui/image/sample_depth_reference/sample_gradient.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Test `OpImageSampleDrefExplicitLod`
// build-pass

use spirv_std::{arch, Cubemap, Image2d, Image2dArray, Sampler};

#[spirv(fragment)]
pub fn main(
#[spirv(uniform_constant)] image: &Image2d,
#[spirv(uniform_constant)] image_array: &Image2dArray,
#[spirv(uniform_constant)] sampler: &Sampler,
#[spirv(uniform_constant)] 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);
}
19 changes: 19 additions & 0 deletions tests/ui/image/sample_depth_reference/sample_lod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Test `OpImageSampleDrefExplicitLod`
// build-pass

use spirv_std::{arch, Cubemap, Image2d, Image2dArray, Sampler};

#[spirv(fragment)]
pub fn main(
#[spirv(uniform_constant)] image: &Image2d,
#[spirv(uniform_constant)] image_array: &Image2dArray,
#[spirv(uniform_constant)] sampler: &Sampler,
#[spirv(uniform_constant)] 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);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Test `OpImageSampleProjDrefImplicitLod`
// build-pass

use spirv_std::{arch, Image2d, Sampler};

#[spirv(fragment)]
pub fn main(
#[spirv(uniform_constant)] image: &Image2d,
#[spirv(uniform_constant)] 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);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Test `OpImageSampleProjDrefExplicitLod`
// build-pass

use spirv_std::{arch, Image2d, Sampler};

#[spirv(fragment)]
pub fn main(
#[spirv(uniform_constant)] image: &Image2d,
#[spirv(uniform_constant)] 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);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Test `OpImageSampleProjDrefExplicitLod`
// build-pass

use spirv_std::{arch, Image2d, Sampler};

#[spirv(fragment)]
pub fn main(
#[spirv(uniform_constant)] image: &Image2d,
#[spirv(uniform_constant)] 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);
}
14 changes: 14 additions & 0 deletions tests/ui/image/sample_with_project_coordinate/sample.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Test `OpImageSampleProjImplicitLod`
// build-pass

use spirv_std::{arch, Image2d, Sampler};

#[spirv(fragment)]
pub fn main(
#[spirv(uniform_constant)] image2d: &Image2d,
#[spirv(uniform_constant)] 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);
}
15 changes: 15 additions & 0 deletions tests/ui/image/sample_with_project_coordinate/sample_gradient.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Test `OpImageSampleProjExplicitLod`
// build-pass

use spirv_std::{arch, Image2d, Sampler};

#[spirv(fragment)]
pub fn main(
#[spirv(uniform_constant)] image2d: &Image2d,
#[spirv(uniform_constant)] 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);
}
14 changes: 14 additions & 0 deletions tests/ui/image/sample_with_project_coordinate/sample_lod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Test `OpImageSampleProjExplicitLod`
// build-pass

use spirv_std::{arch, Image2d, Sampler};

#[spirv(fragment)]
pub fn main(
#[spirv(uniform_constant)] image2d: &Image2d,
#[spirv(uniform_constant)] 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);
}

0 comments on commit ff85f68

Please sign in to comment.