mirror of
https://github.com/EmbarkStudios/rust-gpu.git
synced 2024-11-21 22:34:34 +00:00
Add common image type aliases (#662)
This commit is contained in:
parent
e1a000d408
commit
fff2b9bce1
@ -67,10 +67,10 @@ use quote::ToTokens;
|
|||||||
///
|
///
|
||||||
/// The grammar for the macro is as follows:
|
/// The grammar for the macro is as follows:
|
||||||
///
|
///
|
||||||
/// ```no_compile
|
/// ```rust,no_compile
|
||||||
/// Image!(
|
/// Image!(
|
||||||
/// <dimensionality>,
|
/// <dimensionality>,
|
||||||
/// <type|format>,
|
/// <type=...|format=...>,
|
||||||
/// [sampled[=<true|false>],]
|
/// [sampled[=<true|false>],]
|
||||||
/// [multisampled[=<true|false>],]
|
/// [multisampled[=<true|false>],]
|
||||||
/// [arrayed[=<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:
|
/// A basic example looks like this:
|
||||||
/// ```no_compile
|
/// ```rust,no_compile
|
||||||
/// #[spirv(vertex)]
|
/// #[spirv(vertex)]
|
||||||
/// fn main(#[spirv(descriptor_set = 0, binding = 0)] image: &Image!(2D, type=f32, sampled)) {}
|
/// fn main(#[spirv(descriptor_set = 0, binding = 0)] image: &Image!(2D, type=f32, sampled)) {}
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// ## Arguments
|
/// ## Arguments
|
||||||
///
|
///
|
||||||
/// - `dimensionality` — Dimensionality of an image. Accepted values: `1D`,
|
/// - `dimensionality` — Dimensionality of an image.
|
||||||
/// `2D`, `3D`, `rect`, `cube`, `subpass`.
|
/// Accepted values: `1D`, `2D`, `3D`, `rect`, `cube`, `subpass`.
|
||||||
/// - `type` — The sampled type of an image, mutually exclusive with `format`,
|
/// - `type` — The sampled type of an image, mutually exclusive with `format`,
|
||||||
/// when set the image format is unknown. Accepted values: `f32`, `f64`,
|
/// when set the image format is unknown.
|
||||||
/// `u8`, `u16`, `u32`, `u64`, `i8`, `i16`, `i32`, `i64`.
|
/// Accepted values: `f32`, `f64`, `u8`, `u16`, `u32`, `u64`, `i8`, `i16`, `i32`, `i64`.
|
||||||
/// - `format` — The image format of the image, mutually exclusive with `type`.
|
/// - `format` — The image format of the image, mutually exclusive with `type`.
|
||||||
/// Accepted values: Camel case versions of [`ImageFormat`].
|
/// Accepted values: Snake case versions of [`ImageFormat`].
|
||||||
/// - `sampled` — Whether it is known that the image will be used with a sampler
|
/// - `sampled` — Whether it is known that the image will be used with a sampler.
|
||||||
/// at compile time. Accepted values: `true` or `false`. Default: `unknown`.
|
/// Accepted values: `true` or `false`. Default: `unknown`.
|
||||||
/// - `multisampled` — Whether the image contains multisampled content. Accepted
|
/// - `multisampled` — Whether the image contains multisampled content.
|
||||||
/// values: `true` or `false`. Default: `false`.
|
/// Accepted values: `true` or `false`. Default: `false`.
|
||||||
/// - `arrayed` — Whether the image contains arrayed content. Accepted
|
/// - `arrayed` — Whether the image contains arrayed content.
|
||||||
/// values: `true` or `false`. Default: `false`.
|
/// Accepted values: `true` or `false`. Default: `false`.
|
||||||
/// - `depth` — Whether it is known that the image is a depth image.
|
/// - `depth` — Whether it is known that the image is a depth image.
|
||||||
/// Accepted values: `true` or `false`. Default: `unknown`.
|
/// Accepted values: `true` or `false`. Default: `unknown`.
|
||||||
///
|
///
|
||||||
|
@ -20,10 +20,37 @@ pub mod __private {
|
|||||||
pub use {f32, f64, i16, i32, i64, i8, u16, u32, u64, u8};
|
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 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 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 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`.
|
/// An opaque image type. Corresponds to `OpTypeImage`.
|
||||||
#[spirv(generic_image_type)]
|
#[spirv(generic_image_type)]
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
error: OpImageQueryLevels's image has a dimension of DimRect
|
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! {
|
760 | / asm! {
|
||||||
734 | | "%image = OpLoad _ {this}",
|
761 | | "%image = OpLoad _ {this}",
|
||||||
735 | | "{result} = OpImageQueryLevels typeof{result} %image",
|
762 | | "{result} = OpImageQueryLevels typeof{result} %image",
|
||||||
736 | | this = in(reg) self,
|
763 | | this = in(reg) self,
|
||||||
737 | | result = out(reg) result,
|
764 | | result = out(reg) result,
|
||||||
738 | | }
|
765 | | }
|
||||||
| |_____________^
|
| |_____________^
|
||||||
|
|
|
|
||||||
= note: Allowed dimensions are 1D, 2D, 3D, and Cube
|
= note: Allowed dimensions are 1D, 2D, 3D, and Cube
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
error: OpImageQueryLod's image has a dimension of DimRect
|
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! {
|
793 | / asm! {
|
||||||
767 | | "%typeSampledImage = OpTypeSampledImage typeof*{this}",
|
794 | | "%typeSampledImage = OpTypeSampledImage typeof*{this}",
|
||||||
768 | | "%image = OpLoad _ {this}",
|
795 | | "%image = OpLoad _ {this}",
|
||||||
769 | | "%sampler = OpLoad _ {sampler}",
|
796 | | "%sampler = OpLoad _ {sampler}",
|
||||||
... |
|
... |
|
||||||
777 | | coord = in(reg) &coord
|
804 | | coord = in(reg) &coord
|
||||||
778 | | }
|
805 | | }
|
||||||
| |_____________^
|
| |_____________^
|
||||||
|
|
|
|
||||||
= note: Allowed dimensions are 1D, 2D, 3D, and Cube
|
= note: Allowed dimensions are 1D, 2D, 3D, and Cube
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
error: OpImageQuerySize is invalid for this image type
|
error: OpImageQuerySize is invalid for this image type
|
||||||
--> $SPIRV_STD_SRC/image.rs:795:13
|
--> $SPIRV_STD_SRC/image.rs:822:13
|
||||||
|
|
|
|
||||||
795 | / asm! {
|
822 | / asm! {
|
||||||
796 | | "%image = OpLoad _ {this}",
|
823 | | "%image = OpLoad _ {this}",
|
||||||
797 | | "%result = OpImageQuerySize typeof*{result} %image",
|
824 | | "%result = OpImageQuerySize typeof*{result} %image",
|
||||||
798 | | "OpStore {result} %result",
|
825 | | "OpStore {result} %result",
|
||||||
799 | | this = in(reg) self,
|
826 | | this = in(reg) self,
|
||||||
800 | | result = in(reg) &mut result,
|
827 | | result = in(reg) &mut result,
|
||||||
801 | | }
|
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
|
= 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
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
error: OpImageQuerySizeLod is invalid for this image type
|
error: OpImageQuerySizeLod is invalid for this image type
|
||||||
--> $SPIRV_STD_SRC/image.rs:841:13
|
--> $SPIRV_STD_SRC/image.rs:868:13
|
||||||
|
|
|
|
||||||
841 | / asm! {
|
868 | / asm! {
|
||||||
842 | | "%image = OpLoad _ {this}",
|
869 | | "%image = OpLoad _ {this}",
|
||||||
843 | | "%result = OpImageQuerySizeLod typeof*{result} %image {lod}",
|
870 | | "%result = OpImageQuerySizeLod typeof*{result} %image {lod}",
|
||||||
844 | | "OpStore {result} %result",
|
871 | | "OpStore {result} %result",
|
||||||
... |
|
... |
|
||||||
847 | | result = in(reg) &mut result,
|
874 | | result = in(reg) &mut result,
|
||||||
848 | | }
|
875 | | }
|
||||||
| |_____________^
|
| |_____________^
|
||||||
|
|
|
|
||||||
= note: The image's dimension must be 1D, 2D, 3D, or Cube. Multisampled must be false.
|
= note: The image's dimension must be 1D, 2D, 3D, or Cube. Multisampled must be false.
|
||||||
|
Loading…
Reference in New Issue
Block a user