Skip to content
modkitv0.2

Hello compute — a compute shader writes a texture, a draw displays it

← All examples31_compute_texture

The simplest "why compute": one invocation per pixel computes a color and stores it into a R/W storage image; a fullscreen draw then samples that image. The loop, all on the spine: 1. mk_texture_create_storage() -> a compute-writable, sampleable image 2. mk_shader_load_compute_multi() -> the compute program (cs_plasma) 3. mk_dispatch(&mk_dispatch_desc{}) -> run the compute (writes the image) 4. mk_fullscreen_blit(...) -> present the image (bufferless triangle) Compute and the display run in two passes (two ascending views) so bgfx inserts the compute->graphics barrier automatically.

Hello compute — a compute shader writes a texture, a draw displays it
Number
31
Tags
shaderstexturepost
Source
examples/31_compute_texture/main.c

Build and run

./scripts/build-linux.sh release --target=31_compute_texture --run