Frontory

Open code, practice, and notes →

Download source with English comments · for reading

WGSL · 23 Storage Texture Output

Series contents · Technology map

Stage: Numeric Verification and Kernel Design · Editable example · Storage ID: wgsl-step-23

Goals and learning outcomes

Prerequisites

Continue using the output and records from Unit 22. Before experimenting with Storage Texture Output, preserve the previous inputs and reference outputs.

Key concepts and explanations

Output Format

The format in a storage texture declaration must match the host texture format. The format also determines the range and precision of stored values.

Connecting Passes

A texture written by compute can be read in the next render pass. Avoid conflicting uses in the same operation and set resource usage accordingly.

Practice setup

First check the execution scope guidance on the example screen. The following describes the environment needed to extend the assignment in a separate project. This document-guided exercise requires your own implementation in a separate localhost or HTTPS project. Check the secure context, navigator.gpu, and adapter request result, and provide an unsupported-environment message. Retain device.lost handling and resource cleanup.

The linked example is a starting point. It does not implement every task below. Complete work beyond its supported scope in a separate project.

Practice tasks

  1. In image.wgsl, declare a write storage texture with rgba8unorm format.
  2. Convert global id x/y into colors and write them using textureStore.
  3. On the host, create a texture with STORAGE_BINDING|TEXTURE_BINDING and display it in the next render pass.

Variables to observe

VariableBaselineChangeExpected change / hypothesis
Output colorRange 0..1Some components above 1The unorm format is expected to reveal its storage range limits.

Predictions in this table are not measured results. Change one condition at a time and record why the actual result differs.

Completion criteria

Self-check

  1. Are f32 computation results stored unchanged as f32 in the texture?
  2. Which result structures suit a storage texture or a storage buffer?

Official references

Linked example and execution scope

Example source · Runtime environments and limits

Runs actual WebGPU/WGSL. Requires HTTPS/localhost and a supported adapter; unsupported environments display a reason, and CPU results are not presented as GPU results.

Source code and records are not overwritten automatically. Resetting an existing example also preserves your notes.

Next learning

Previous: Stage Constraints on Texture Functions · Next: Numeric Stability and Special Inputs

Open code, practice, and notes →