No results
7
Formats and Types
dxtr edited this page 2026-10-18 16:56:34 +02:00
Formats and Types
Every type below is a deftype exported from cl-gfx, so you can use it in
check-type, typep and declarations. Format names follow WebGPU's: the
channels and their bits, then the numeric kind.
texture-format
| Format | Bytes per texel | Kind | Notes |
|---|---|---|---|
:rgba8-unorm |
4 | colour | |
:rgba8-srgb |
4 | colour, sRGB | |
:bgra8-unorm |
4 | colour | common surface format |
:bgra8-srgb |
4 | colour, sRGB | common surface format |
:r8-unorm |
1 | colour | single channel, such as glyph masks |
:rg8-unorm |
2 | colour | |
:r32-float |
4 | float | |
:rg16-float |
4 | float | |
:rg32-float |
8 | float | |
:rgba16-float |
8 | float | HDR colour |
:rgba32-float |
16 | float | |
:r32-uint |
4 | unsigned integer | |
:rg16-uint |
4 | unsigned integer | |
:rgba8-uint |
4 | unsigned integer | |
:rgba16-uint |
8 | unsigned integer | |
:rgba32-uint |
16 | unsigned integer | |
:r32-sint |
4 | signed integer | |
:depth32-float |
4 | depth | |
:depth24-stencil8 |
4 | depth |
Predicates and helpers:
| Function | Returns |
|---|---|
(texel-size format) |
The size of one texel in bytes. |
(srgb-format-p format) |
True for :rgba8-srgb and :bgra8-srgb. |
(integer-format-p format) |
True for the -uint and -sint formats, which shaders read unfiltered through integer sampler types. |
(depth-format-p format) |
True for :depth32-float and :depth24-stencil8. |
Texel byte order is the format's channel order: :rgba8-unorm is red, green,
blue, alpha; :bgra8-unorm is blue, green, red, alpha. Multi-byte channels
are in the machine's byte order.
vertex-format
| Format | Bytes | Shader type |
|---|---|---|
:float32 |
4 | float |
:float32x2 |
8 | vec2 |
:float32x3 |
12 | vec3 |
:float32x4 |
16 | vec4 |
:float64 |
8 | double, needs :float64 |
:float64x2 |
16 | dvec2, needs :float64 |
:float64x3 |
24 | dvec3, needs :float64 |
:float64x4 |
32 | dvec4, needs :float64 |
:uint32 … :uint32x4 |
4 … 16 | uint … uvec4 |
:sint32 … :sint32x4 |
4 … 16 | int … ivec4 |
:unorm8x4 |
4 | vec4, four bytes mapped to 0 to 1 |
(vertex-format-size format) returns the size in bytes.
Other types
| Type | Values |
|---|---|
index-format |
:uint16, :uint32 |
texture-dimension |
:1d, :1d-array, :2d, :2d-array, :3d, :cube, :cube-array |
sample-count |
1, 2, 4, 8 |
filter |
:nearest, :linear |
address-mode |
:clamp-to-edge, :repeat, :mirror-repeat |
compare-function |
:never, :less, :equal, :less-equal, :greater, :not-equal, :greater-equal, :always |
binding-kind |
:uniform-buffer, :texture, :storage-buffer, :read-only-storage-buffer, :storage-texture, :uniform-texel-buffer, :storage-texel-buffer |
shader-stage |
:vertex, :tessellation-control, :tessellation-evaluation, :geometry, :fragment, :compute |
device-feature |
:geometry-shaders, :tessellation-shaders, :float64, :multisample-storage-textures, :vertex-stores, :rounding-mode-rte-float32, :rounding-mode-rte-float64, :signed-zero-inf-nan-preserve-float32, :signed-zero-inf-nan-preserve-float64 |
validation-check |
:synchronization, :best-practices |
validation-severity |
:error, :warning, :info, :verbose, the most severe first |
buffer-usage |
:vertex, :index, :uniform, :storage, :uniform-texel, :storage-texel, :copy-src, :copy-dst: what create-buffer :usage lists |
texture-usage |
:render-target, :sampled, :storage, :copy-src, :copy-dst: what create-texture :usage lists |
data-vector |
A simple vector of single-float, double-float, (unsigned-byte 8), (unsigned-byte 16) or (unsigned-byte 32): what write-buffer and write-texture take and read-buffer and read-texture return |
data-element-type |
single-float, double-float, (unsigned-byte 8), (unsigned-byte 16), (unsigned-byte 32): the :element-type of read-buffer and read-texture |
bind-group-index |
0 to 3, one less than +max-bind-groups+: what set-bind-group takes |
| Function | Returns |
|---|---|
(array-dimension-p dimension) |
True for :1d-array, :2d-array and :cube-array. |
(cube-dimension-p dimension) |
True for :cube and :cube-array. |
Keyword sets that are not types
| Where | Values |
|---|---|
create-buffer :memory |
:device, :upload |
create-surface :present-mode |
:fifo, :fifo-relaxed, :mailbox, :immediate |
create-render-pipeline :topology |
:triangle-list, :triangle-strip, :line-list, :line-strip, :point-list, :patch-list |
create-render-pipeline :cull-mode |
:none, :front, :back |
create-render-pipeline :front-face |
:counter-clockwise, :clockwise |
create-render-pipeline :blend |
:replace, :alpha, :premultiplied-alpha |
vertex buffer layout :step |
:vertex, :instance |
Constants
| Constant | Value | Meaning |
|---|---|---|
+uniform-offset-alignment+ |
256 | A uniform buffer range in a bind group starts at a multiple of this. |
+storage-offset-alignment+ |
256 | A storage or texel buffer range starts at a multiple of this. |
+max-bind-groups+ |
4 | A pipeline uses at most this many bind groups, numbered from 0, as bind-group-index says. |