Add common image type aliases (#662)

This commit is contained in:
Ashley Hauck 2021-06-15 09:19:40 +02:00 committed by GitHub
parent e1a000d408
commit fff2b9bce1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 73 additions and 44 deletions

View File

@ -67,10 +67,10 @@ use quote::ToTokens;
///
/// The grammar for the macro is as follows:
///
/// ```no_compile
/// ```rust,no_compile
/// Image!(
/// <dimensionality>,
/// <type|format>,
/// <type=...|format=...>,
/// [sampled[=<true|false>],]
/// [multisampled[=<true|false>],]
/// [arrayed[=<true|false>],]
@ -78,27 +78,29 @@ use quote::ToTokens;
/// )
/// ```
///
/// `=true` can be omitted as shorthand - e.g. `sampled` is short for `sampled=true`.
///
/// A basic example looks like this:
/// ```no_compile
/// ```rust,no_compile
/// #[spirv(vertex)]
/// fn main(#[spirv(descriptor_set = 0, binding = 0)] image: &Image!(2D, type=f32, sampled)) {}
/// ```
///
/// ## Arguments
///
/// - `dimensionality` — Dimensionality of an image. Accepted values: `1D`,
/// `2D`, `3D`, `rect`, `cube`, `subpass`.
/// - `dimensionality` — Dimensionality of an image.
/// Accepted values: `1D`, `2D`, `3D`, `rect`, `cube`, `subpass`.
/// - `type` — The sampled type of an image, mutually exclusive with `format`,
/// when set the image format is unknown. Accepted values: `f32`, `f64`,
/// `u8`, `u16`, `u32`, `u64`, `i8`, `i16`, `i32`, `i64`.
/// when set the image format is unknown.
/// Accepted values: `f32`, `f64`, `u8`, `u16`, `u32`, `u64`, `i8`, `i16`, `i32`, `i64`.
/// - `format` — The image format of the image, mutually exclusive with `type`.
/// Accepted values: Camel case versions of [`ImageFormat`].
/// - `sampled` — Whether it is known that the image will be used with a sampler
/// at compile time. Accepted values: `true` or `false`. Default: `unknown`.
/// - `multisampled` — Whether the image contains multisampled content. Accepted
/// values: `true` or `false`. Default: `false`.
/// - `arrayed` — Whether the image contains arrayed content. Accepted
/// values: `true` or `false`. Default: `false`.
/// Accepted values: Snake case versions of [`ImageFormat`].
/// - `sampled` — Whether it is known that the image will be used with a sampler.
/// Accepted values: `true` or `false`. Default: `unknown`.
/// - `multisampled` — Whether the image contains multisampled content.
/// Accepted values: `true` or `false`. Default: `false`.
/// - `arrayed` — Whether the image contains arrayed content.
/// Accepted values: `true` or `false`. Default: `false`.
/// - `depth` — Whether it is known that the image is a depth image.
/// Accepted values: `true` or `false`. Default: `unknown`.
///

View File

@ -20,10 +20,37 @@ pub mod __private {
pub use {f32, f64, i16, i32, i64, i8, u16, u32, u64, u8};
}
pub type Image1d = crate::Image!(1D, type=f32, sampled, __crate_root=crate);
pub type Image2d = crate::Image!(2D, type=f32, sampled, __crate_root=crate);
pub type Cubemap = crate::Image!(cube, type=f32, sampled, __crate_root=crate);
pub type Image3d = crate::Image!(3D, type=f32, sampled, __crate_root=crate);
pub type Image1dU = crate::Image!(1D, type=u32, sampled, __crate_root=crate);
pub type Image2dU = crate::Image!(2D, type=u32, sampled, __crate_root=crate);
pub type Image3dU = crate::Image!(3D, type=u32, sampled, __crate_root=crate);
pub type Image1dI = crate::Image!(1D, type=i32, sampled, __crate_root=crate);
pub type Image2dI = crate::Image!(2D, type=i32, sampled, __crate_root=crate);
pub type Image3dI = crate::Image!(3D, type=i32, sampled, __crate_root=crate);
pub type Image1dArray = crate::Image!(1D, type=f32, sampled, arrayed, __crate_root=crate);
pub type Image2dArray = crate::Image!(2D, type=f32, sampled, arrayed, __crate_root=crate);
pub type Image3dArray = crate::Image!(3D, type=f32, sampled, arrayed, __crate_root=crate);
pub type Image1dUArray = crate::Image!(1D, type=u32, sampled, arrayed, __crate_root=crate);
pub type Image2dUArray = crate::Image!(2D, type=u32, sampled, arrayed, __crate_root=crate);
pub type Image3dUArray = crate::Image!(3D, type=u32, sampled, arrayed, __crate_root=crate);
pub type Image1dIArray = crate::Image!(1D, type=i32, sampled, arrayed, __crate_root=crate);
pub type Image2dIArray = crate::Image!(2D, type=i32, sampled, arrayed, __crate_root=crate);
pub type Image3dIArray = crate::Image!(3D, type=i32, sampled, arrayed, __crate_root=crate);
pub type StorageImage1d = crate::Image!(1D, type=f32, sampled=false, __crate_root=crate);
pub type StorageImage2d = crate::Image!(2D, type=f32, sampled=false, __crate_root=crate);
pub type StorageImage3d = crate::Image!(3D, type=f32, sampled=false, __crate_root=crate);
pub type StorageImage1dU = crate::Image!(1D, type=u32, sampled=false, __crate_root=crate);
pub type StorageImage2dU = crate::Image!(2D, type=u32, sampled=false, __crate_root=crate);
pub type StorageImage3dU = crate::Image!(3D, type=u32, sampled=false, __crate_root=crate);
pub type StorageImage1dI = crate::Image!(1D, type=i32, sampled=false, __crate_root=crate);
pub type StorageImage2dI = crate::Image!(2D, type=i32, sampled=false, __crate_root=crate);
pub type StorageImage3dI = crate::Image!(3D, type=i32, sampled=false, __crate_root=crate);
pub type Cubemap = crate::Image!(cube, type=f32, sampled, __crate_root=crate);
/// An opaque image type. Corresponds to `OpTypeImage`.
#[spirv(generic_image_type)]

View File

@ -1,12 +1,12 @@
error: OpImageQueryLevels's image has a dimension of DimRect
--> $SPIRV_STD_SRC/image.rs:733:13
--> $SPIRV_STD_SRC/image.rs:760:13
|
733 | / asm! {
734 | | "%image = OpLoad _ {this}",
735 | | "{result} = OpImageQueryLevels typeof{result} %image",
736 | | this = in(reg) self,
737 | | result = out(reg) result,
738 | | }
760 | / asm! {
761 | | "%image = OpLoad _ {this}",
762 | | "{result} = OpImageQueryLevels typeof{result} %image",
763 | | this = in(reg) self,
764 | | result = out(reg) result,
765 | | }
| |_____________^
|
= note: Allowed dimensions are 1D, 2D, 3D, and Cube

View File

@ -1,13 +1,13 @@
error: OpImageQueryLod's image has a dimension of DimRect
--> $SPIRV_STD_SRC/image.rs:766:13
--> $SPIRV_STD_SRC/image.rs:793:13
|
766 | / asm! {
767 | | "%typeSampledImage = OpTypeSampledImage typeof*{this}",
768 | | "%image = OpLoad _ {this}",
769 | | "%sampler = OpLoad _ {sampler}",
793 | / asm! {
794 | | "%typeSampledImage = OpTypeSampledImage typeof*{this}",
795 | | "%image = OpLoad _ {this}",
796 | | "%sampler = OpLoad _ {sampler}",
... |
777 | | coord = in(reg) &coord
778 | | }
804 | | coord = in(reg) &coord
805 | | }
| |_____________^
|
= note: Allowed dimensions are 1D, 2D, 3D, and Cube

View File

@ -1,13 +1,13 @@
error: OpImageQuerySize is invalid for this image type
--> $SPIRV_STD_SRC/image.rs:795:13
--> $SPIRV_STD_SRC/image.rs:822:13
|
795 | / asm! {
796 | | "%image = OpLoad _ {this}",
797 | | "%result = OpImageQuerySize typeof*{result} %image",
798 | | "OpStore {result} %result",
799 | | this = in(reg) self,
800 | | result = in(reg) &mut result,
801 | | }
822 | / asm! {
823 | | "%image = OpLoad _ {this}",
824 | | "%result = OpImageQuerySize typeof*{result} %image",
825 | | "OpStore {result} %result",
826 | | this = in(reg) self,
827 | | result = in(reg) &mut result,
828 | | }
| |_____________^
|
= note: allowed dimensions are 1D, 2D, 3D, Buffer, Rect, or Cube. if dimension is 1D, 2D, 3D, or Cube, it must have either multisampled be true, *or* sampled of Unknown or No

View File

@ -1,13 +1,13 @@
error: OpImageQuerySizeLod is invalid for this image type
--> $SPIRV_STD_SRC/image.rs:841:13
--> $SPIRV_STD_SRC/image.rs:868:13
|
841 | / asm! {
842 | | "%image = OpLoad _ {this}",
843 | | "%result = OpImageQuerySizeLod typeof*{result} %image {lod}",
844 | | "OpStore {result} %result",
868 | / asm! {
869 | | "%image = OpLoad _ {this}",
870 | | "%result = OpImageQuerySizeLod typeof*{result} %image {lod}",
871 | | "OpStore {result} %result",
... |
847 | | result = in(reg) &mut result,
848 | | }
874 | | result = in(reg) &mut result,
875 | | }
| |_____________^
|
= note: The image's dimension must be 1D, 2D, 3D, or Cube. Multisampled must be false.