floooh / sokol

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

Misleading error message VALIDATE_ABND_FS_EXPECTED_IMAGE_BINDING #918

Closed danielchasehooper closed 9 months ago

danielchasehooper commented 9 months ago

This error message can be confusing when you did assign to the slot, but the sg_image.id is zero: sg_apply_bindings: missing image binding on fragment stage

    sg_apply_bindings(&(sg_bindings){
        .vertex_buffers[0] = g_square_vertex_buffer,
        .fs.images[SLOT_tex] = src, // look the image binding is right here!
        .fs.samplers[SLOT_smp] = linear_sampler, 
    });

I think it'd be helpful if the message were updated to make it clear that either the bound image is zero or you didn't even specify the binding

floooh commented 9 months ago

Hmm good point, but unfortunately in that case sokol-gfx cannot differentiate between the bind slot being assigned an invalid handle (SG_INVALID_ID), and the slot not being set in the first place. In both cases there's a zero in .fs.images[SLOT_tex].id

The actual test in the validation layer is bindings->fs.images[i].id != SG_INVALID_ID (where SG_INVALID_ID is defined as zero).

Any ideas for a better error message in that case? (e.g. the bind slot is either not set, or the image handle is invalid).

danielchasehooper commented 9 months ago

Maybe sg_apply_bindings: image binding is either missing or set to a sg_image with id 0? sg_apply_bindings: image binding is either missing or set to an uninitialized sg_image?

floooh commented 9 months ago

Ok fixed, the new message is:

sg_apply_bindings: image binding on vertex stage is missing or the image handle is invalid

(same format for samplers)