mirror of
https://github.com/EmbarkStudios/rust-gpu.git
synced 2024-11-25 00:04:11 +00:00
Clarify and fix up some image documentation (#678)
This commit is contained in:
parent
8c05636f53
commit
22e4bf4022
@ -263,6 +263,7 @@ impl Parse for ImageType {
|
||||
| ImageFormat::Rg8Snorm
|
||||
| ImageFormat::R16Snorm
|
||||
| ImageFormat::R8Snorm => SampledType::F32,
|
||||
|
||||
ImageFormat::Rgba32i
|
||||
| ImageFormat::Rgba16i
|
||||
| ImageFormat::Rgba8i
|
||||
@ -285,6 +286,7 @@ impl Parse for ImageType {
|
||||
| ImageFormat::R8ui => SampledType::U32,
|
||||
|
||||
ImageFormat::R64ui => SampledType::U64,
|
||||
|
||||
ImageFormat::R64i => SampledType::I64,
|
||||
|
||||
ImageFormat::Unknown => unreachable!(),
|
||||
|
@ -80,7 +80,8 @@ use syn::{punctuated::Punctuated, spanned::Spanned, ItemFn, Token};
|
||||
|
||||
use quote::ToTokens;
|
||||
|
||||
/// A macro for creating SPIR-V `OpTypeImage` types.
|
||||
/// A macro for creating SPIR-V `OpTypeImage` types. Always produces a
|
||||
/// `spirv_std::image::Image<...>` type.
|
||||
///
|
||||
/// The grammar for the macro is as follows:
|
||||
///
|
||||
@ -122,6 +123,11 @@ use quote::ToTokens;
|
||||
/// Accepted values: `true` or `false`. Default: `unknown`.
|
||||
///
|
||||
/// [`ImageFormat`]: spirv_types::image_params::ImageFormat
|
||||
///
|
||||
/// Keep in mind that `sampled` here is a different concept than the `SampledImage` type:
|
||||
/// `sampled=true` means that this image requires a sampler to be able to access, while the
|
||||
/// `SampledImage` type bundles that sampler together with the image into a single type (e.g.
|
||||
/// `sampler2D` in GLSL, vs. `texture2D`).
|
||||
#[proc_macro]
|
||||
// The `Image` is supposed to be used in the type position, which
|
||||
// uses `PascalCase`.
|
||||
|
@ -153,92 +153,89 @@ impl From<bool> for Sampled {
|
||||
pub enum ImageFormat {
|
||||
/// Representation not known at compile time.
|
||||
Unknown,
|
||||
/// RGBA channels, 32 bit floating point integer.
|
||||
/// RGBA channels, 32 bit floating point per channel.
|
||||
Rgba32f,
|
||||
/// RGBA channels, 16 bit floating point integer.
|
||||
/// RGBA channels, 16 bit floating point per channel.
|
||||
Rgba16f,
|
||||
/// RGBA channels, 16 bit floating point integer.
|
||||
/// Single red channel, 32 bit floating point.
|
||||
R32f,
|
||||
/// RGBA channels, 8 bit floating point integer.
|
||||
/// RGBA channels, 8 bit unsigned normalized integer per channel.
|
||||
Rgba8,
|
||||
/// RGBA channels, 8 bit signed normalized integer.
|
||||
/// RGBA channels, 8 bit signed normalized integer per channel.
|
||||
Rgba8Snorm,
|
||||
/// Red+Green channels, 32 bit floating point integer.
|
||||
/// Red+Green channels, 32 bit floating point per channel.
|
||||
Rg32f,
|
||||
/// Red+Green channels, 16 bit floating point integer.
|
||||
/// Red+Green channels, 16 bit floating point per channel.
|
||||
Rg16f,
|
||||
/// 32 bit unsigned integer containing two 11 bit floating point integers
|
||||
/// for the Red and Green channels, and a 10 bit floating point integer for
|
||||
/// the Blue channel.
|
||||
/// 32 bits containing two 11 bit floating point numbers for the Red and Green
|
||||
/// channels, and a 10 bit floating point number for the Blue channel.
|
||||
R11fG11fB10f,
|
||||
/// Red channel, 16 bit floating point.
|
||||
/// Single red channel, 16 bit floating point.
|
||||
R16f,
|
||||
/// RGBA channel, 16 bit floating point.
|
||||
/// RGBA channels, 16 bit unsigned normalized integer per channel.
|
||||
Rgba16,
|
||||
/// 32 bit unsigned integer containing three 10 bit unsigned normalized
|
||||
/// integers for the Red, Green, and Blue channels; with a 2 unsigned
|
||||
/// normalized integer for the Alpha channel.
|
||||
/// 32 bits containing three 10 bit unsigned normalized integers for the Red, Green, and Blue
|
||||
/// channels, and a 2 bit unsigned normalized integer for the Alpha channel.
|
||||
Rgb10A2,
|
||||
/// Red+Green channels, 16 bit floating point integer.
|
||||
/// Red+Green channels, 16 bit unsigned normalized integer per channel.
|
||||
Rg16,
|
||||
/// Red+Green channels, 8 bit floating point integer.
|
||||
/// Red+Green channels, 8 bit unsigned normalized integer per channel.
|
||||
Rg8,
|
||||
/// Red+Green channels, 16 bit floating point integer.
|
||||
/// Single red channel, 16 bit unsigned normalized integer.
|
||||
R16,
|
||||
/// Red channel, 8 bit floating point integer.
|
||||
/// Single red channel, 8 bit unsigned normalized integer.
|
||||
R8,
|
||||
/// RGBA channels, 16 bit signed normalized integer.
|
||||
/// RGBA channels, 16 bit signed normalized integer per channel.
|
||||
Rgba16Snorm,
|
||||
/// RGB channels, 16 bit signed normalized integer.
|
||||
/// Red+Green channels, 16 bit signed normalized integer per channel.
|
||||
Rg16Snorm,
|
||||
/// Red+Green channels, 8 bit signed normalized integer.
|
||||
/// Red+Green channels, 8 bit signed normalized integer per channel.
|
||||
Rg8Snorm,
|
||||
/// Red channel, 16 bit signed normalized integer.
|
||||
/// Single red channel, 16 bit signed normalized integer.
|
||||
R16Snorm,
|
||||
/// Red channel, 16 bit signed normalized integer.
|
||||
/// Single red channel, 8 bit signed normalized integer.
|
||||
R8Snorm,
|
||||
/// RGBA channels, 32 bit signed integer.
|
||||
/// RGBA channels, 32 bit signed integer per channel (not normalized).
|
||||
Rgba32i,
|
||||
/// RGBA channels, 16 bit signed integer.
|
||||
/// RGBA channels, 16 bit signed integer per channel (not normalized).
|
||||
Rgba16i,
|
||||
/// RGBA channels, 8 bit signed integer.
|
||||
/// RGBA channels, 8 bit signed integer per channel (not normalized).
|
||||
Rgba8i,
|
||||
/// Red channel, 32 bit signed integer.
|
||||
/// Single red channel, 32 bit signed integer (not normalized).
|
||||
R32i,
|
||||
/// Red+Green channels, 32 bit signed integer.
|
||||
/// Red+Green channels, 32 bit signed integer per channel (not normalized).
|
||||
Rg32i,
|
||||
/// Red+Green channels, 16 bit signed integer.
|
||||
/// Red+Green channels, 16 bit signed integer per channel (not normalized).
|
||||
Rg16i,
|
||||
/// Red+Green channels, 8 bit signed integer.
|
||||
/// Red+Green channels, 8 bit signed integer per channel (not normalized).
|
||||
Rg8i,
|
||||
/// Red channel, 16 bit signed integer.
|
||||
/// Single red channel, 16 bit signed integer (not normalized).
|
||||
R16i,
|
||||
/// Red channel, 8 bit signed integer.
|
||||
/// Single red channel, 8 bit signed integer (not normalized).
|
||||
R8i,
|
||||
/// RGBA channels, 32 bit unsigned integer.
|
||||
/// RGBA channels, 32 bit unsigned integer per channel (not normalized).
|
||||
Rgba32ui,
|
||||
/// RGBA channels, 16 bit unsigned integer.
|
||||
/// RGBA channels, 16 bit unsigned integer per channel (not normalized).
|
||||
Rgba16ui,
|
||||
/// RGBA channels, 8 bit unsigned integer.
|
||||
/// RGBA channels, 8 bit unsigned integer per channel (not normalized).
|
||||
Rgba8ui,
|
||||
/// Red channel, 32 bit unsigned integer.
|
||||
/// Single red channel, 32 bit unsigned integer (not normalized).
|
||||
R32ui,
|
||||
/// 32 bit unsigned integer containing three 10 bit unsigned integers for
|
||||
/// the Red, Green, and Blue channels, and a 2 bit unsigned integer for the
|
||||
/// Alpha channel.
|
||||
/// 32 bits containing three 10 bit unsigned integers for the Red, Green, and Blue channels,
|
||||
/// and a 2 bit unsigned integer for the Alpha channel.
|
||||
Rgb10A2ui,
|
||||
/// Red+Green channels, 32 bit unsigned integer.
|
||||
/// Red+Green channels, 32 bit unsigned integer per channel (not normalized).
|
||||
Rg32ui,
|
||||
/// Red+Green channels, 16 bit unsigned integer.
|
||||
/// Red+Green channels, 16 bit unsigned integer per channel (not normalized).
|
||||
Rg16ui,
|
||||
/// Red+Green channels, 8 bit unsigned integer.
|
||||
/// Red+Green channels, 8 bit unsigned integer per channel (not normalized).
|
||||
Rg8ui,
|
||||
/// Red channel, 16 bit unsigned integer.
|
||||
/// Single red channel, 16 bit unsigned integer (not normalized).
|
||||
R16ui,
|
||||
/// Red channel, 8 bit unsigned integer.
|
||||
/// Single red channel, 8 bit unsigned integer (not normalized).
|
||||
R8ui,
|
||||
/// Red channel, 64 bit unsigned integer.
|
||||
/// Single red channel, 64 bit unsigned integer (not normalized).
|
||||
R64ui,
|
||||
/// Red channel, 64 bit signed integer.
|
||||
/// Single red channel, 64 bit signed integer (not normalized).
|
||||
R64i,
|
||||
}
|
||||
|
@ -53,6 +53,9 @@ pub type StorageImage3dI = crate::Image!(3D, type=i32, sampled=false, __crate_ro
|
||||
pub type Cubemap = crate::Image!(cube, type=f32, sampled, __crate_root=crate);
|
||||
|
||||
/// An opaque image type. Corresponds to `OpTypeImage`.
|
||||
///
|
||||
/// You likely want to write this type using the [`crate::Image!`] macro helper, as the generic
|
||||
/// arguments here can get extremely verbose.
|
||||
#[spirv(generic_image_type)]
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct Image<
|
||||
@ -914,8 +917,11 @@ impl<
|
||||
}
|
||||
}
|
||||
|
||||
/// An image combined with a sampler, enabling filtered accesses of the
|
||||
/// image’s contents.
|
||||
/// An image combined with a sampler in a single value, enabling filtered accesses of the image's
|
||||
/// contents. Corresponds to `OpTypeSampledImage`.
|
||||
///
|
||||
/// The generic type parameter is the underlying image type, written like
|
||||
/// `SampledImage<Image!(...)>`.
|
||||
#[spirv(sampled_image)]
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct SampledImage<I> {
|
||||
|
@ -1,12 +1,12 @@
|
||||
error: OpImageQueryLevels's image has a dimension of DimRect
|
||||
--> $SPIRV_STD_SRC/image.rs:760:13
|
||||
--> $SPIRV_STD_SRC/image.rs:763:13
|
||||
|
|
||||
760 | / asm! {
|
||||
761 | | "%image = OpLoad _ {this}",
|
||||
762 | | "{result} = OpImageQueryLevels typeof{result} %image",
|
||||
763 | | this = in(reg) self,
|
||||
764 | | result = out(reg) result,
|
||||
765 | | }
|
||||
763 | / asm! {
|
||||
764 | | "%image = OpLoad _ {this}",
|
||||
765 | | "{result} = OpImageQueryLevels typeof{result} %image",
|
||||
766 | | this = in(reg) self,
|
||||
767 | | result = out(reg) result,
|
||||
768 | | }
|
||||
| |_____________^
|
||||
|
|
||||
= note: Allowed dimensions are 1D, 2D, 3D, and Cube
|
||||
|
@ -1,13 +1,13 @@
|
||||
error: OpImageQueryLod's image has a dimension of DimRect
|
||||
--> $SPIRV_STD_SRC/image.rs:793:13
|
||||
--> $SPIRV_STD_SRC/image.rs:796:13
|
||||
|
|
||||
793 | / asm! {
|
||||
794 | | "%typeSampledImage = OpTypeSampledImage typeof*{this}",
|
||||
795 | | "%image = OpLoad _ {this}",
|
||||
796 | | "%sampler = OpLoad _ {sampler}",
|
||||
796 | / asm! {
|
||||
797 | | "%typeSampledImage = OpTypeSampledImage typeof*{this}",
|
||||
798 | | "%image = OpLoad _ {this}",
|
||||
799 | | "%sampler = OpLoad _ {sampler}",
|
||||
... |
|
||||
804 | | coord = in(reg) &coord
|
||||
805 | | }
|
||||
807 | | coord = in(reg) &coord
|
||||
808 | | }
|
||||
| |_____________^
|
||||
|
|
||||
= note: Allowed dimensions are 1D, 2D, 3D, and Cube
|
||||
|
@ -1,13 +1,13 @@
|
||||
error: OpImageQuerySize is invalid for this image type
|
||||
--> $SPIRV_STD_SRC/image.rs:822:13
|
||||
--> $SPIRV_STD_SRC/image.rs:825:13
|
||||
|
|
||||
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 | | }
|
||||
825 | / asm! {
|
||||
826 | | "%image = OpLoad _ {this}",
|
||||
827 | | "%result = OpImageQuerySize typeof*{result} %image",
|
||||
828 | | "OpStore {result} %result",
|
||||
829 | | this = in(reg) self,
|
||||
830 | | result = in(reg) &mut result,
|
||||
831 | | }
|
||||
| |_____________^
|
||||
|
|
||||
= 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
|
||||
--> $SPIRV_STD_SRC/image.rs:868:13
|
||||
--> $SPIRV_STD_SRC/image.rs:871:13
|
||||
|
|
||||
868 | / asm! {
|
||||
869 | | "%image = OpLoad _ {this}",
|
||||
870 | | "%result = OpImageQuerySizeLod typeof*{result} %image {lod}",
|
||||
871 | | "OpStore {result} %result",
|
||||
871 | / asm! {
|
||||
872 | | "%image = OpLoad _ {this}",
|
||||
873 | | "%result = OpImageQuerySizeLod typeof*{result} %image {lod}",
|
||||
874 | | "OpStore {result} %result",
|
||||
... |
|
||||
874 | | result = in(reg) &mut result,
|
||||
875 | | }
|
||||
877 | | result = in(reg) &mut result,
|
||||
878 | | }
|
||||
| |_____________^
|
||||
|
|
||||
= note: The image's dimension must be 1D, 2D, 3D, or Cube. Multisampled must be false.
|
||||
|
Loading…
Reference in New Issue
Block a user