- _end_canary
uint _end_canary;
Undocumented in source.
- _start_canary
uint _start_canary;
Undocumented in source.
- images
Image[16] images;
Undocumented in source.
- index_buffer
Buffer index_buffer;
Undocumented in source.
- index_buffer_offset
int index_buffer_offset;
Undocumented in source.
- samplers
Sampler[16] samplers;
Undocumented in source.
- storage_buffers
Buffer[8] storage_buffers;
Undocumented in source.
- vertex_buffer_offsets
int[8] vertex_buffer_offsets;
Undocumented in source.
- vertex_buffers
Buffer[8] vertex_buffers;
Undocumented in source.
sg_bindings
The sg_bindings structure defines the buffers, images and samplers resource bindings for the next draw call.
To update the resource bindings, call sg_apply_bindings() with a pointer to a populated sg_bindings struct. Note that sg_apply_bindings() must be called after sg_apply_pipeline() and that bindings are not preserved across sg_apply_pipeline() calls, even when the new pipeline uses the same 'bindings layout'.
A resource binding struct contains:
- 1..N vertex buffers - 0..N vertex buffer offsets - 0..1 index buffers - 0..1 index buffer offsets - 0..N images - 0..N samplers - 0..N storage buffers
Where 'N' is defined in the following constants:
- SG_MAX_VERTEXBUFFER_BINDSLOTS - SG_MAX_IMAGE_BINDLOTS - SG_MAX_SAMPLER_BINDSLOTS - SG_MAX_STORAGEBUFFER_BINDGLOTS
When using sokol-shdc for shader authoring, the layout(binding=N) annotation in the shader code directly maps to the slot index for that resource type in the bindings struct, for instance the following vertex- and fragment-shader interface for sokol-shdc:
@vs vs layout(binding=0) uniform vs_params { ... }; layout(binding=0) readonly buffer ssbo { ... }; layout(binding=0) uniform texture2D vs_tex; layout(binding=0) uniform sampler vs_smp; ... @end
@fs fs layout(binding=1) uniform fs_params { ... }; layout(binding=1) uniform texture2D fs_tex; layout(binding=1) uniform sampler fs_smp; ... @end
...would map to the following sg_bindings struct:
const sg_bindings bnd = { .vertex_buffers[0] = ..., .images[0] = vs_tex, .images[1] = fs_tex, .samplers[0] = vs_smp, .samplers[1] = fs_smp, .storage_buffers[0] = ssbo, };
...alternatively you can use code-generated slot indices:
const sg_bindings bnd = { .vertex_buffers[0] = ..., .imagesIMG_vs_tex = vs_tex, .imagesIMG_fs_tex = fs_tex, .samplersSMP_vs_smp = vs_smp, .samplersSMP_fs_smp = fs_smp, .storage_buffersSBUF_ssbo = ssbo, };
Resource bindslots for a specific shader/pipeline may have gaps, and an sg_bindings struct may have populated bind slots which are not used by a specific shader. This allows to use the same sg_bindings struct across different shader variants.
When not using sokol-shdc, the bindslot indices in the sg_bindings struct need to match the per-resource reflection info slot indices in the sg_shader_desc struct (for details about that see the sg_shader_desc struct documentation).
The optional buffer offsets can be used to put different unrelated chunks of vertex- and/or index-data into the same buffer objects