Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added instructions for depth reference and project coordinate image instructions #545

Merged
Merged
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
496 changes: 495 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, 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);
}
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, 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);
}
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, 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);
}
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, 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);
}
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, 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);
}
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, 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);
}
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, 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);
}
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, 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);
}
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, 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);
}