Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
16 changes: 16 additions & 0 deletions crates/spirv-std/src/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,22 @@ impl<
}
result.truncate_into()
}

/// Fetch a single texel at a mipmap `lod` with a sampler set at compile time
///
/// `lod` is also known as `level` in WGSL's `textureLoad`
#[crate::macros::gpu_only]
#[doc(alias = "OpImageFetch")]
pub fn fetch_with_lod<I>(
&self,
coordinate: impl ImageCoordinate<I, DIM, ARRAYED>,
lod: u32,
) -> SampledType::SampleResult
where
I: Integer,
{
self.fetch_with(coordinate, sample_with::lod(lod))
}
}

impl<
Expand Down
13 changes: 13 additions & 0 deletions tests/compiletests/ui/image/fetch_with_lod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// build-pass

use spirv_std::spirv;
use spirv_std::{Image, arch};

#[spirv(fragment)]
pub fn main(
#[spirv(descriptor_set = 0, binding = 0)] image: &Image!(2D, type=f32, sampled),
output: &mut glam::Vec4,
) {
let texel = image.fetch_with_lod(glam::IVec2::new(0, 1), 0);
*output = texel;
}
Loading