cf_apply_vs_storage_buffers¶
Category: graphics
GitHub: cute_graphics.h
Binds storage buffers to the vertex stage of the current graphics pipeline.
| Parameters | Description |
|---|---|
buffers |
The storage buffers to bind, in shader binding order. |
count |
Number of buffers. |
Remarks¶
Call after cf_apply_shader and before cf_draw_elements. The buffers must be
created with graphics_readable (see CF_StorageBufferParams). In the shader,
declare vertex-stage storage buffers at set = 0 with bindings following any
vertex-stage samplers:
Buffer-block tails must be scalars or vectors, so store mat4s as four vec4
columns and reassemble in the shader (see cf_draw3d_set_vs_storage_buffers
for the bone() helper idiom).
This is the tool for data too large or too dynamic for uniforms -- skinning
palettes indexed by a per-instance bone offset, per-instance data pulled by
gl_InstanceIndex (see cf_draw_elements_instanced), or buffers a compute
shader just wrote (compute_writable + graphics_readable composes). On
GLES3/web, read-only storage buffers are emulated through texture fetches
transparently; compute_writable buffers are not available there. The
emulation covers exactly the pattern above -- for web portability keep each
block anonymous, readonly, and a single runtime vec4/uvec4 array (up to
4 per stage), packing scalars and matrices into vec4s.
Related Pages¶
CF_StorageBuffer
cf_make_storage_buffer
cf_apply_fs_storage_buffers
cf_draw_elements_instanced
cf_apply_shader