Skip to content
This repository was archived by the owner on Oct 31, 2025. It is now read-only.

Commit f513a61

Browse files
committed
feat: Added instructions for depth reference and project coordinate image instructions
1 parent 182bbca commit f513a61

File tree

10 files changed

+593
-1
lines changed

10 files changed

+593
-1
lines changed

crates/spirv-std/src/textures.rs

Lines changed: 445 additions & 1 deletion
Large diffs are not rendered by default.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Test `OpImageSampleDrefImplicitLod`
2+
// build-pass
3+
4+
use spirv_std::{arch, Cubemap, Image2d, Image2dArray, Sampler};
5+
6+
#[spirv(fragment)]
7+
pub fn main(
8+
#[spirv(uniform_constant)] image: &Image2d,
9+
#[spirv(uniform_constant)] image_array: &Image2dArray,
10+
#[spirv(uniform_constant)] cubemap: &Cubemap,
11+
#[spirv(uniform_constant)] sampler: &Sampler,
12+
output: &mut f32,
13+
) {
14+
let v2 = glam::Vec2::new(0.0, 1.0);
15+
let v3 = glam::Vec3A::new(0.0, 0.0, 1.0);
16+
*output = image.sample_depth_reference(*sampler, v2, 1.0);
17+
*output += image_array.sample_depth_reference(*sampler, v3, 1.0);
18+
*output += cubemap.sample_depth_reference(*sampler, v3, 1.0);
19+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Test `OpImageSampleDrefExplicitLod`
2+
// build-pass
3+
4+
use spirv_std::{arch, Cubemap, Image2d, Image2dArray, Sampler};
5+
6+
#[spirv(fragment)]
7+
pub fn main(
8+
#[spirv(uniform_constant)] image: &Image2d,
9+
#[spirv(uniform_constant)] image_array: &Image2dArray,
10+
#[spirv(uniform_constant)] sampler: &Sampler,
11+
#[spirv(uniform_constant)] cubemap: &Cubemap,
12+
output: &mut f32,
13+
) {
14+
let v2 = glam::Vec2::new(0.0, 1.0);
15+
let v2_dx = glam::Vec2::new(0.0, 1.0);
16+
let v2_dy = glam::Vec2::new(0.0, 1.0);
17+
let v3 = glam::Vec3A::new(0.0, 0.0, 1.0);
18+
let v3_dx = glam::Vec3A::new(0.0, 1.0, 0.5);
19+
let v3_dy = glam::Vec3A::new(0.0, 1.0, 0.5);
20+
*output = image.sample_depth_reference_by_gradient(*sampler, v2, 1.0, v2_dx, v2_dy);
21+
*output += image_array.sample_depth_reference_by_gradient(*sampler, v3, 1.0, v2_dx, v2_dy);
22+
*output += cubemap.sample_depth_reference_by_gradient(*sampler, v3, 1.0, v3_dx, v3_dy);
23+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Test `OpImageSampleDrefExplicitLod`
2+
// build-pass
3+
4+
use spirv_std::{arch, Cubemap, Image2d, Image2dArray, Sampler};
5+
6+
#[spirv(fragment)]
7+
pub fn main(
8+
#[spirv(uniform_constant)] image: &Image2d,
9+
#[spirv(uniform_constant)] image_array: &Image2dArray,
10+
#[spirv(uniform_constant)] sampler: &Sampler,
11+
#[spirv(uniform_constant)] cubemap: &Cubemap,
12+
output: &mut f32,
13+
) {
14+
let v2 = glam::Vec2::new(0.0, 1.0);
15+
let v3 = glam::Vec3A::new(0.0, 0.0, 1.0);
16+
*output = image.sample_depth_reference_by_lod(*sampler, v2, 1.0, 0.0);
17+
*output += image_array.sample_depth_reference_by_lod(*sampler, v3, 1.0, 0.0);
18+
*output += image_array.sample_depth_reference_by_lod(*sampler, v3, 1.0, 0.0);
19+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Test `OpImageSampleProjDrefImplicitLod`
2+
// build-pass
3+
4+
use spirv_std::{arch, Image2d, Sampler};
5+
6+
#[spirv(fragment)]
7+
pub fn main(
8+
#[spirv(uniform_constant)] image: &Image2d,
9+
#[spirv(uniform_constant)] sampler: &Sampler,
10+
output: &mut f32,
11+
) {
12+
let v3 = glam::Vec3A::new(0.0, 0.0, 1.0);
13+
*output = image.sample_depth_reference_with_project_coordinate(*sampler, v3, 1.0);
14+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Test `OpImageSampleProjDrefExplicitLod`
2+
// build-pass
3+
4+
use spirv_std::{arch, Image2d, Sampler};
5+
6+
#[spirv(fragment)]
7+
pub fn main(
8+
#[spirv(uniform_constant)] image: &Image2d,
9+
#[spirv(uniform_constant)] sampler: &Sampler,
10+
output: &mut f32,
11+
) {
12+
let v2_dx = glam::Vec2::new(0.0, 1.0);
13+
let v2_dy = glam::Vec2::new(0.0, 1.0);
14+
let v3 = glam::Vec3A::new(0.0, 0.0, 1.0);
15+
*output = image.sample_depth_reference_with_project_coordinate_by_gradient(*sampler, v3, 1.0, v2_dx, v2_dy);
16+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Test `OpImageSampleProjDrefExplicitLod`
2+
// build-pass
3+
4+
use spirv_std::{arch, Image2d, Sampler};
5+
6+
#[spirv(fragment)]
7+
pub fn main(
8+
#[spirv(uniform_constant)] image: &Image2d,
9+
#[spirv(uniform_constant)] sampler: &Sampler,
10+
output: &mut f32,
11+
) {
12+
let v3 = glam::Vec3A::new(0.0, 0.0, 1.0);
13+
*output = image.sample_depth_reference_with_project_coordinate_by_lod(*sampler, v3, 1.0, 0.0);
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Test `OpImageSampleProjImplicitLod`
2+
// build-pass
3+
4+
use spirv_std::{arch, Image2d, Sampler};
5+
6+
#[spirv(fragment)]
7+
pub fn main(
8+
#[spirv(uniform_constant)] image2d: &Image2d,
9+
#[spirv(uniform_constant)] sampler: &Sampler,
10+
output: &mut glam::Vec4,
11+
) {
12+
let v3 = glam::Vec3::new(0.0, 1.0, 0.5);
13+
*output = image2d.sample_with_project_coordinate(*sampler, v3);
14+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Test `OpImageSampleProjExplicitLod`
2+
// build-pass
3+
4+
use spirv_std::{arch, Image2d, Sampler};
5+
6+
#[spirv(fragment)]
7+
pub fn main(
8+
#[spirv(uniform_constant)] image2d: &Image2d,
9+
#[spirv(uniform_constant)] sampler: &Sampler,
10+
output: &mut glam::Vec4,
11+
) {
12+
let v2 = glam::Vec2::new(0.0, 1.0);
13+
let v3 = glam::Vec3::new(0.0, 1.0, 0.5);
14+
*output = image2d.sample_with_project_coordinate_by_gradient(*sampler, v3, v2, v2);
15+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Test `OpImageSampleProjExplicitLod`
2+
// build-pass
3+
4+
use spirv_std::{arch, Image2d, Sampler};
5+
6+
#[spirv(fragment)]
7+
pub fn main(
8+
#[spirv(uniform_constant)] image2d: &Image2d,
9+
#[spirv(uniform_constant)] sampler: &Sampler,
10+
output: &mut glam::Vec4,
11+
) {
12+
let v3 = glam::Vec3::new(0.0, 1.0, 0.5);
13+
*output = image2d.sample_with_project_coordinate_by_lod(*sampler, v3, 0.0);
14+
}

0 commit comments

Comments
 (0)