Skip to content
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
378 changes: 190 additions & 188 deletions Cargo.lock

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions crates/spirv-std/src/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ impl<
/// Fetch a single texel with a sampler set at compile time
#[crate::macros::gpu_only]
#[doc(alias = "OpImageFetch")]
#[inline]
pub fn fetch<I>(
&self,
coordinate: impl ImageCoordinate<I, DIM, ARRAYED>,
Expand Down Expand Up @@ -165,6 +166,7 @@ impl<
/// `lod` is also known as `level` in WGSL's `textureLoad`
#[crate::macros::gpu_only]
#[doc(alias = "OpImageFetch")]
#[inline]
pub fn fetch_with_lod<I>(
&self,
coordinate: impl ImageCoordinate<I, DIM, ARRAYED>,
Expand Down Expand Up @@ -238,6 +240,7 @@ impl<

/// Sample texels at `coord` from the image using `sampler`.
#[crate::macros::gpu_only]
#[inline]
pub fn sample<F>(
&self,
sampler: Sampler,
Expand Down Expand Up @@ -272,6 +275,7 @@ impl<
/// Sample texels at `coord` from the image using `sampler`, after adding the input bias to the
/// implicit level of detail.
#[crate::macros::gpu_only]
#[inline]
pub fn sample_bias<F>(
&self,
sampler: Sampler,
Expand Down Expand Up @@ -310,6 +314,7 @@ impl<
#[crate::macros::gpu_only]
#[doc(alias = "OpImageSampleExplicitLod")]
/// Sample the image at a coordinate by a lod
#[inline]
pub fn sample_by_lod<F>(
&self,
sampler: Sampler,
Expand Down Expand Up @@ -346,6 +351,7 @@ impl<
#[crate::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])
#[inline]
pub fn sample_by_gradient<F>(
&self,
sampler: Sampler,
Expand Down Expand Up @@ -385,6 +391,7 @@ impl<
#[crate::macros::gpu_only]
#[doc(alias = "OpImageSampleDrefImplicitLod")]
/// Sample the image's depth reference
#[inline]
pub fn sample_depth_reference<F>(
&self,
sampler: Sampler,
Expand Down Expand Up @@ -421,6 +428,7 @@ impl<
#[crate::macros::gpu_only]
#[doc(alias = "OpImageSampleDrefExplicitLod")]
/// Sample the image's depth reference based on an explicit lod
#[inline]
pub fn sample_depth_reference_by_lod<F>(
&self,
sampler: Sampler,
Expand Down Expand Up @@ -461,6 +469,7 @@ impl<
#[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])
#[inline]
pub fn sample_depth_reference_by_gradient<F>(
&self,
sampler: Sampler,
Expand Down Expand Up @@ -523,6 +532,7 @@ impl<
/// Sample the image with a project coordinate
#[crate::macros::gpu_only]
#[doc(alias = "OpImageSampleProjImplicitLod")]
#[inline]
pub fn sample_with_project_coordinate<F>(
&self,
sampler: Sampler,
Expand Down Expand Up @@ -556,6 +566,7 @@ impl<
#[crate::macros::gpu_only]
#[doc(alias = "OpImageSampleProjExplicitLod")]
/// Sample the image with a project coordinate by a lod
#[inline]
pub fn sample_with_project_coordinate_by_lod<F>(
&self,
sampler: Sampler,
Expand Down Expand Up @@ -592,6 +603,7 @@ impl<
#[crate::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])
#[inline]
pub fn sample_with_project_coordinate_by_gradient<F>(
&self,
sampler: Sampler,
Expand Down Expand Up @@ -631,6 +643,7 @@ impl<
#[crate::macros::gpu_only]
#[doc(alias = "OpImageSampleProjDrefImplicitLod")]
/// Sample the image's depth reference with the project coordinate
#[inline]
pub fn sample_depth_reference_with_project_coordinate<F>(
&self,
sampler: Sampler,
Expand Down Expand Up @@ -667,6 +680,7 @@ impl<
#[crate::macros::gpu_only]
#[doc(alias = "OpImageSampleProjDrefExplicitLod")]
/// Sample the image's depth reference with the project coordinate based on an explicit lod
#[inline]
pub fn sample_depth_reference_with_project_coordinate_by_lod<F>(
&self,
sampler: Sampler,
Expand Down Expand Up @@ -707,6 +721,7 @@ impl<
#[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])
#[inline]
pub fn sample_depth_reference_with_project_coordinate_by_gradient<F>(
&self,
sampler: Sampler,
Expand Down Expand Up @@ -770,6 +785,7 @@ impl<
/// Read a texel from an image without a sampler.
#[crate::macros::gpu_only]
#[doc(alias = "OpImageRead")]
#[inline]
pub fn read<I>(
&self,
coordinate: impl ImageCoordinate<I, DIM, ARRAYED>,
Expand Down Expand Up @@ -799,6 +815,7 @@ impl<
/// Write a texel to an image without a sampler.
#[crate::macros::gpu_only]
#[doc(alias = "OpImageWrite")]
#[inline]
pub unsafe fn write<I>(
&self,
coordinate: impl ImageCoordinate<I, DIM, ARRAYED>,
Expand Down Expand Up @@ -844,6 +861,7 @@ impl<
/// Read a texel from an image without a sampler.
#[crate::macros::gpu_only]
#[doc(alias = "OpImageRead")]
#[inline]
pub fn read<I>(
&self,
coordinate: impl ImageCoordinate<I, DIM, ARRAYED>,
Expand Down Expand Up @@ -873,6 +891,7 @@ impl<
/// Write a texel to an image without a sampler.
#[crate::macros::gpu_only]
#[doc(alias = "OpImageWrite")]
#[inline]
pub unsafe fn write<I>(
&self,
coordinate: impl ImageCoordinate<I, DIM, ARRAYED>,
Expand Down Expand Up @@ -918,6 +937,7 @@ impl<
/// Note: Vulkan only allows the read if the first two components of the coordinate are zero.
#[crate::macros::gpu_only]
#[doc(alias = "OpImageRead")]
#[inline]
pub fn read_subpass<I>(
&self,
coordinate: impl ImageCoordinateSubpassData<I, ARRAYED>,
Expand Down Expand Up @@ -959,6 +979,7 @@ impl<
/// Query the number of mipmap levels.
#[crate::macros::gpu_only]
#[doc(alias = "OpImageQueryLevels")]
#[inline]
pub fn query_levels(&self) -> u32
where
Self: HasQueryLevels,
Expand All @@ -984,6 +1005,7 @@ impl<
/// detail relative to the base level.
#[crate::macros::gpu_only]
#[doc(alias = "OpImageQueryLod")]
#[inline]
pub fn query_lod(
&self,
sampler: Sampler,
Expand Down Expand Up @@ -1023,6 +1045,7 @@ impl<
/// Query the dimensions of Image, with no level of detail.
#[crate::macros::gpu_only]
#[doc(alias = "OpImageQuerySize")]
#[inline]
pub fn query_size<Size: ImageSizeQuery<u32, DIM, ARRAYED> + Default>(&self) -> Size
where
Self: HasQuerySize,
Expand Down Expand Up @@ -1066,6 +1089,7 @@ impl<
/// Query the dimensions of Image at a specific level of detail.
#[crate::macros::gpu_only]
#[doc(alias = "OpImageQuerySizeLod")]
#[inline]
pub fn query_size_lod<Size: ImageSizeQuery<u32, DIM, ARRAYED> + Default>(
&self,
lod: u32,
Expand Down Expand Up @@ -1112,6 +1136,7 @@ impl<
/// Query the number of samples available per texel fetch in a multisample image.
#[crate::macros::gpu_only]
#[doc(alias = "OpImageQuerySamples")]
#[inline]
pub fn query_samples(&self) -> u32 {
let mut result = Default::default();
unsafe {
Expand Down Expand Up @@ -1166,6 +1191,7 @@ impl<
{
/// Sample texels at `coord` from the sampled image with an implicit lod.
#[crate::macros::gpu_only]
#[inline]
pub fn sample<F>(
&self,
coord: impl ImageCoordinate<F, DIM, ARRAYED>,
Expand All @@ -1192,6 +1218,7 @@ impl<

/// Sample texels at `coord` from the sampled image with an explicit lod.
#[crate::macros::gpu_only]
#[inline]
pub fn sample_by_lod<F>(
&self,
coord: impl ImageCoordinate<F, DIM, ARRAYED>,
Expand Down Expand Up @@ -1222,6 +1249,7 @@ impl<
/// Query the dimensions of the image at the specified level of detail.
#[crate::macros::gpu_only]
#[doc(alias = "OpImageQuerySizeLod")]
#[inline]
pub fn query_size_lod<Size: ImageSizeQuery<u32, DIM, ARRAYED> + Default>(
&self,
lod: u32,
Expand Down Expand Up @@ -1280,6 +1308,7 @@ impl<
/// Available only for multisampled images.
#[crate::macros::gpu_only]
#[doc(alias = "OpImageQuerySize")]
#[inline]
pub fn query_size<Size: ImageSizeQuery<u32, DIM, ARRAYED> + Default>(&self) -> Size
where
Image<
Expand Down Expand Up @@ -1416,6 +1445,7 @@ impl<
{
#[crate::macros::gpu_only]
#[doc(alias = "OpImageFetch")]
#[inline]
fn fetch_with<I>(
&self,
coordinate: impl ImageCoordinate<I, DIM, ARRAYED>,
Expand Down Expand Up @@ -1482,6 +1512,7 @@ impl<

/// Sample texels at `coord` from the image using `sampler`.
#[crate::macros::gpu_only]
#[inline]
fn sample_with<F>(
&self,
sampler: Sampler,
Expand Down Expand Up @@ -1517,6 +1548,7 @@ impl<
/// Sample the image's depth reference
#[crate::macros::gpu_only]
#[doc(alias = "OpImageSampleDrefImplicitLod")]
#[inline]
fn sample_depth_reference_with<F>(
&self,
sampler: Sampler,
Expand Down Expand Up @@ -1554,6 +1586,7 @@ impl<
/// Sample the image with a project coordinate
#[crate::macros::gpu_only]
#[doc(alias = "OpImageSampleProjImplicitLod")]
#[inline]
fn sample_with_project_coordinate_with<F>(
&self,
sampler: Sampler,
Expand Down Expand Up @@ -1588,6 +1621,7 @@ impl<
/// Sample the image's depth reference with the project coordinate
#[crate::macros::gpu_only]
#[doc(alias = "OpImageSampleProjDrefImplicitLod")]
#[inline]
fn sample_depth_reference_with_project_coordinate_with<F>(
&self,
sampler: Sampler,
Expand Down
8 changes: 8 additions & 0 deletions crates/spirv-std/src/image/sample_with.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ pub struct SampleParams<B: OptionTy, L: OptionTy, G: OptionTy, S: OptionTy> {
}

/// Sets the 'Bias' image operand
#[inline]
pub fn bias<B>(bias: B) -> SampleParams<SomeTy<B>, NoneTy, NoneTy, NoneTy> {
SampleParams {
bias: SomeTy(bias),
Expand All @@ -47,6 +48,7 @@ pub fn bias<B>(bias: B) -> SampleParams<SomeTy<B>, NoneTy, NoneTy, NoneTy> {
}

/// Sets the 'Lod' image operand
#[inline]
pub fn lod<L>(lod: L) -> SampleParams<NoneTy, SomeTy<L>, NoneTy, NoneTy> {
SampleParams {
bias: NoneTy,
Expand All @@ -57,6 +59,7 @@ pub fn lod<L>(lod: L) -> SampleParams<NoneTy, SomeTy<L>, NoneTy, NoneTy> {
}

/// Sets the 'Grad' image operand
#[inline]
pub fn grad<T>(grad_x: T, grad_y: T) -> SampleParams<NoneTy, NoneTy, SomeTy<(T, T)>, NoneTy> {
SampleParams {
bias: NoneTy,
Expand All @@ -67,6 +70,7 @@ pub fn grad<T>(grad_x: T, grad_y: T) -> SampleParams<NoneTy, NoneTy, SomeTy<(T,
}

/// Sets the 'Sample' image operand
#[inline]
pub fn sample_index<S>(sample_index: S) -> SampleParams<NoneTy, NoneTy, NoneTy, SomeTy<S>> {
SampleParams {
bias: NoneTy,
Expand All @@ -78,6 +82,7 @@ pub fn sample_index<S>(sample_index: S) -> SampleParams<NoneTy, NoneTy, NoneTy,

impl<L: OptionTy, G: OptionTy, S: OptionTy> SampleParams<NoneTy, L, G, S> {
/// Sets the 'Bias' image operand
#[inline]
pub fn bias<B>(self, bias: B) -> SampleParams<SomeTy<B>, L, G, S> {
SampleParams {
bias: SomeTy(bias),
Expand All @@ -90,6 +95,7 @@ impl<L: OptionTy, G: OptionTy, S: OptionTy> SampleParams<NoneTy, L, G, S> {

impl<B: OptionTy, G: OptionTy, S: OptionTy> SampleParams<B, NoneTy, G, S> {
/// Sets the 'Lod' image operand
#[inline]
pub fn lod<L>(self, lod: L) -> SampleParams<B, SomeTy<L>, G, S> {
SampleParams {
bias: self.bias,
Expand All @@ -102,6 +108,7 @@ impl<B: OptionTy, G: OptionTy, S: OptionTy> SampleParams<B, NoneTy, G, S> {

impl<B: OptionTy, L: OptionTy, S: OptionTy> SampleParams<B, L, NoneTy, S> {
/// Sets the 'Lod' image operand
#[inline]
pub fn grad<T>(self, grad_x: T, grad_y: T) -> SampleParams<B, L, SomeTy<(T, T)>, S> {
SampleParams {
bias: self.bias,
Expand All @@ -114,6 +121,7 @@ impl<B: OptionTy, L: OptionTy, S: OptionTy> SampleParams<B, L, NoneTy, S> {

impl<B: OptionTy, L: OptionTy, G: OptionTy> SampleParams<B, L, G, NoneTy> {
/// Sets the 'Sample' image operand
#[inline]
pub fn sample_index<S>(self, sample_index: S) -> SampleParams<B, L, G, SomeTy<S>> {
SampleParams {
bias: self.bias,
Expand Down
4 changes: 2 additions & 2 deletions tests/compiletests/ui/image/gather_err.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ LL | let r1: glam::Vec4 = image1d.gather(*sampler, 0.0f32, 0);
Image<SampledType, 3, DEPTH, ARRAYED, 0, SAMPLED, FORMAT, COMPONENTS>
Image<SampledType, 4, DEPTH, ARRAYED, 0, SAMPLED, FORMAT, COMPONENTS>
note: required by a bound in `Image::<SampledType, DIM, DEPTH, ARRAYED, spirv_std::::image::{impl#1}::{constant#0}, SAMPLED, FORMAT, COMPONENTS>::gather`
--> $SPIRV_STD_SRC/image.rs:212:15
--> $SPIRV_STD_SRC/image.rs:214:15
|
LL | pub fn gather<F>(
| ------ required by a bound in this associated function
Expand All @@ -28,7 +28,7 @@ LL | let r2: glam::Vec4 = image3d.gather(*sampler, v3, 0);
Image<SampledType, 3, DEPTH, ARRAYED, 0, SAMPLED, FORMAT, COMPONENTS>
Image<SampledType, 4, DEPTH, ARRAYED, 0, SAMPLED, FORMAT, COMPONENTS>
note: required by a bound in `Image::<SampledType, DIM, DEPTH, ARRAYED, spirv_std::::image::{impl#1}::{constant#0}, SAMPLED, FORMAT, COMPONENTS>::gather`
--> $SPIRV_STD_SRC/image.rs:212:15
--> $SPIRV_STD_SRC/image.rs:214:15
|
LL | pub fn gather<F>(
| ------ required by a bound in this associated function
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ LL | *output = image.query_levels();
Image<SampledType, 2, DEPTH, ARRAYED, MULTISAMPLED, SAMPLED, FORMAT, COMPONENTS>
Image<SampledType, 3, DEPTH, ARRAYED, MULTISAMPLED, SAMPLED, FORMAT, COMPONENTS>
note: required by a bound in `Image::<SampledType, DIM, DEPTH, ARRAYED, MULTISAMPLED, SAMPLED, FORMAT, COMPONENTS>::query_levels`
--> $SPIRV_STD_SRC/image.rs:964:15
--> $SPIRV_STD_SRC/image.rs:985:15
|
LL | pub fn query_levels(&self) -> u32
| ------------ required by a bound in this associated function
Expand Down
2 changes: 1 addition & 1 deletion tests/compiletests/ui/image/query/query_lod_err.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ LL | *output = image.query_lod(*sampler, glam::Vec2::new(0.0, 1.0));
Image<SampledType, 2, DEPTH, ARRAYED, MULTISAMPLED, SAMPLED, FORMAT, COMPONENTS>
Image<SampledType, 3, DEPTH, ARRAYED, MULTISAMPLED, SAMPLED, FORMAT, COMPONENTS>
note: required by a bound in `Image::<SampledType, DIM, DEPTH, ARRAYED, MULTISAMPLED, SAMPLED, FORMAT, COMPONENTS>::query_lod`
--> $SPIRV_STD_SRC/image.rs:993:15
--> $SPIRV_STD_SRC/image.rs:1015:15
|
LL | pub fn query_lod(
| --------- required by a bound in this associated function
Expand Down
2 changes: 1 addition & 1 deletion tests/compiletests/ui/image/query/query_size_err.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ LL | *output = image.query_size();
Image<SampledType, 2, DEPTH, ARRAYED, 0, 2, FORMAT, COMPONENTS>
and 6 others
note: required by a bound in `Image::<SampledType, DIM, DEPTH, ARRAYED, MULTISAMPLED, SAMPLED, FORMAT, COMPONENTS>::query_size`
--> $SPIRV_STD_SRC/image.rs:1028:15
--> $SPIRV_STD_SRC/image.rs:1051:15
|
LL | pub fn query_size<Size: ImageSizeQuery<u32, DIM, ARRAYED> + Default>(&self) -> Size
| ---------- required by a bound in this associated function
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ LL | *output = image.query_size_lod(0);
Image<SampledType, 2, DEPTH, ARRAYED, 0, SAMPLED, FORMAT, COMPONENTS>
Image<SampledType, 3, DEPTH, ARRAYED, 0, SAMPLED, FORMAT, COMPONENTS>
note: required by a bound in `Image::<SampledType, DIM, DEPTH, ARRAYED, spirv_std::::image::{impl#7}::{constant#0}, SAMPLED, FORMAT, COMPONENTS>::query_size_lod`
--> $SPIRV_STD_SRC/image.rs:1074:15
--> $SPIRV_STD_SRC/image.rs:1098:15
|
LL | pub fn query_size_lod<Size: ImageSizeQuery<u32, DIM, ARRAYED> + Default>(
| -------------- required by a bound in this associated function
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ LL | *output = rect_sampled.query_size_lod(0);
Image<SampledType, 2, DEPTH, ARRAYED, 0, SAMPLED, FORMAT, COMPONENTS>
Image<SampledType, 3, DEPTH, ARRAYED, 0, SAMPLED, FORMAT, COMPONENTS>
note: required by a bound in `SampledImage::<Image<SampledType, DIM, DEPTH, ARRAYED, spirv_std::::image::{impl#9}::{constant#0}, SAMPLED, FORMAT, COMPONENTS>>::query_size_lod`
--> /image.rs:1239:12
--> /image.rs:1267:12
|
LL | pub fn query_size_lod<Size: ImageSizeQuery<u32, DIM, ARRAYED> + Default>(
| -------------- required by a bound in this associated function
Expand Down
Loading
Loading