Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Image! docs to book #652

Merged
merged 2 commits into from
Jun 9, 2021
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
1 change: 1 addition & 0 deletions docs/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 26 additions & 0 deletions docs/src/image.md
Original file line number Diff line number Diff line change
@@ -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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
type Image2d = Image!(2D, type=f32, sampled);
// In spirv_std::image
pub 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"] }
```