Add Image! docs to book (#652)

This commit is contained in:
Ashley Hauck 2021-06-09 12:18:05 +02:00 committed by GitHub
parent 0b23a4282f
commit 64380d609a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 0 deletions

View File

@ -10,5 +10,6 @@
- [Features]()
- [Attribute syntax](./attributes.md)
- [Inline Assembly](./inline-asm.md)
- [Image type syntax](./image.md)
- [RFCs]()
- [001. Resource Binding Syntax](./rfcs/001-resource-binding-syntax.md)

26
docs/src/image.md Normal file
View File

@ -0,0 +1,26 @@
# Image type syntax
There are a huge number of combinations of image types in SPIR-V. They are represented by a const
generic type called `spirv_std::image::Image`, however, specifying the generic parameters of this
type is incredibly tedious, so a wrapper macro, `spirv_std::Image!` can be used to write the type
instead.
The specific syntax and meaning of the arguments to the `Image!` macro can be found in
[rustdoc](https://embarkstudios.github.io/rust-gpu/api/spirv_std/macro.Image.html).
Some type aliases for common image formats can be found in the
[`spirv_std::image`](https://embarkstudios.github.io/rust-gpu/api/spirv_std/image/index.html)
module. For example, `Image2d` is a very commonly used type, corresponding to `texture2D` in GLSL,
and is likely what you want if you want a regular old sampled texture.
```rust,no_run
type Image2d = Image!(2D, type=f32, sampled);
```
Note that the `const-generics` cargo feature in spirv-std must be enabled to use the `Image!` macro
at the moment. This will likely change in the near future.
```toml
[dependencies]
spirv-std = { ..., features = ["const-generics"] }
```