floooh / sokol

minimal cross-platform standalone C headers
https://floooh.github.io/sokol-html5
zlib License
6.53k stars 468 forks source link

Planning: Resource binding cleanup #1037

Open floooh opened 2 months ago

floooh commented 2 months ago

This would make sense after the storage-buffer update:

General idea is to allow more flexibility when mapping the sokol-gfx 'bind slot convention' to the backend API bind slots.

typedef struct sg_bindings {
    uint32_t _start_canary;
    sg_buffer vertex_buffers[SG_MAX_VERTEXBUFFER_BINDINGS];
    int vertex_buffer_offsets[SG_MAX_VERTEXBUFFER_BINDINGS];
    sg_buffer index_buffer;
    int index_buffer_offset;
    sg_image images[SG_MAX_IMAGE_BINDINGS];
    sg_sampler samplers[SG_MAX_SAMPLER_BINDINGS];
    sg_buffer storage_buffers[SG_MAX_STORAGEBUFFER_BINDINGS];
    uint32_t _end_canary;
} sg_bindings;

The sg_shader_desc needs to provide a mapping from those unified "sokol-gfx bindslots" to shader stages and (probably backend-API specific) concrete bind slots (typically generated by sokol-shdc).