Files
wgpu/wgpu/examples
Wumpf 21f56dc8d2 Do texture init via clear passes when possible (#2307)
* CLEAR_COMMANDS extension is now more of a window into wgpu zero-init
this has mostly implications on the constraints, but also allows a more leaky documentation which makes sense for this non-standard function as there is no other place to look it up

* clear_texture via renderpasses wip

* 3D depth textures are no longer allowed, volumes are always cleared via CPY_DST

* cleanup texture's clear_views

* rename CLEAR_COMMANDS to CLEAR_TEXTURE

* separate clear_texture into reusable & more descriptive parts

* texture clear views are now created ahead of time

* discarded surface fixup goes through new clear_texture method now

* onq ueue texture initialization now goes threw clear_texture
pending inits need to store Stored textures now though, causing more ref count bumping

* texture init on queue_write_texture now also goes through new clear_texture

* transfer functions on commandbuffer use now new texture init route

* merge collect_zero_buffer_copies_for_clear_texture into clear_texture_via_buffer_copies

* clear functions now take TextureInitRange

* Fix clippy lints

* command_encoder_clear_texture no longer takes write lock on texture

* TextureClearMode encodes now is_color

* code cleanup, mostly about `use`

* Handle volume textures in clear_texture_via_render_passes properly

* texture clear no longer requires id::Stored

* init tracking fixes for volumes and init on partial subresource writes

* texture creation enforces COPY_DST only if absolutely necessary

* unrolled functional chain, reduce unsafe scope size

* fix clippy lints

* clear_texture test no longer creates 1D textures

see #2323

* 3D textures are no longer cleared as render target since this isn't supported on Metal

* fix deno building issue, fix formatting

* TextureInner::Surface can now be zero initialized
2021-12-29 09:19:41 -05:00
..
2021-11-19 10:56:48 -05:00
2021-10-07 16:18:09 -04:00
2021-12-17 04:39:48 +00:00
2021-10-07 16:18:09 -04:00
2021-12-15 12:29:37 -05:00
2021-11-19 10:56:48 -05:00
2021-12-15 12:29:37 -05:00
2021-12-15 12:29:37 -05:00
2021-12-15 12:29:37 -05:00
2021-10-07 16:18:09 -04:00
2021-12-17 04:39:48 +00:00

Structure

For the simplest examples without using any helping code (see framework.rs here), check out:

  • hello for printing adapter information
  • hello-triangle for graphics and presentation
  • hello-compute for pure computing

Notably, capture example shows rendering without a surface/window. It reads back the contents and saves them to a file.

All the examples use WGSL shaders unless specified otherwise.

All framework-based examples render to the window and are reftested against the screenshot in the directory.

Feature matrix

Feature boids bunnymark cube mipmap msaa-line shadow skybox texture-arrays water conservative-raster
vertex attributes ⭐ ⭐ ⭐ ⭐ ⭐ ⭐ ⭐
instancing ⭐
lines and points ⭐ ⭐
dynamic buffer offsets ⭐ ⭐
implicit layout ⭐
sampled color textures ⭐ ⭐ ⭐ ⭐ ⭐ ⭐ ⭐ ⭐
storage textures ⭐
binding array ⭐
comparison samplers ⭐
subresource views ⭐ ⭐
cubemaps ⭐
multisampling ⭐
off-screen rendering ⭐ ⭐ ⭐
stencil testing
depth testing ⭐ ⭐ ⭐
depth biasing ⭐
read-only depth ⭐
blending ⭐ ⭐ ⭐
render bundles ⭐ ⭐
compute passes ⭐
error scopes ⭐
optional extensions ⭐
- SPIR-V shaders ⭐
- binding indexing ⭐
- push constants ⭐
- depth clamping ⭐
- compressed textures ⭐
- polygon mode ⭐
- queries ⭐
- conservative rasterization ⭐
integrations
- staging belt
- typed arena
- obj loading ⭐

Hacking

You can record an API trace any of the framework-based examples by starting them as:

mkdir -p trace && WGPU_TRACE=trace cargo run --features trace --example <example-name>