Closed terrybrash closed 12 months ago
Hmm this looks indeed wrong (the first output also isn't great because it has a duplicate image/sampler pair). Looks like I'm currently missing a test shader which has two identical samplers.
Thanks for the code snippet, I'll try to investigate tomorrow.
Ah ok, the culprit is definitely this new code which ignores image/sampler pairs with dummy samplers (SPIRVCross seems to generate such a dummy sampler for the textureSize()
call).
Don't know yet though why this wasn't a problem before.
Looks like I'm currently missing a test shader which has two identical samplers.
Is there any way to avoid creating two identical samplers? I tried to assign them to a local variable in the shader but that didn't work because sampler2D
is limited in where it can be called (which I don't really understand why 😅).
I think I found a solution that's more robust then before and also avoids the duplicate image/sampler pair which was present before. E.g. in the test shader it now looks like this:
desc.fs.images[0].used = true;
desc.fs.images[0].multisampled = false;
desc.fs.images[0].image_type = SG_IMAGETYPE_2D;
desc.fs.images[0].sample_type = SG_IMAGESAMPLETYPE_FLOAT;
desc.fs.images[1].used = true;
desc.fs.images[1].multisampled = false;
desc.fs.images[1].image_type = SG_IMAGETYPE_2D;
desc.fs.images[1].sample_type = SG_IMAGESAMPLETYPE_FLOAT;
desc.fs.samplers[0].used = true;
desc.fs.samplers[0].sampler_type = SG_SAMPLERTYPE_FILTERING;
desc.fs.image_sampler_pairs[0].used = true;
desc.fs.image_sampler_pairs[0].image_slot = 0;
desc.fs.image_sampler_pairs[0].sampler_slot = 0;
desc.fs.image_sampler_pairs[1].used = true;
desc.fs.image_sampler_pairs[1].image_slot = 1;
desc.fs.image_sampler_pairs[1].sampler_slot = 0;
I'll need to do a bit more testing though...
didn't work because sampler2D is limited in where it can be called (which I don't really understand why 😅)
Yeah, that's some weird GLSL limitation. Apparently it's not possible to store a GLSL combined image-sampler in a variable. The actual problem was the textureSize() call, which required to let SPIRVCross create dummy samplers for HLSL, MSL and WGSL output. I've solved that problem differently now by using a separate SPIRVCross GLSL output for parsing the reflection data.
Pull request: https://github.com/floooh/sokol-tools/pull/110
Ok fix is merged. The new executables will be available when this GH Action has finished: https://github.com/floooh/sokol-tools/actions/runs/6684866701
Please let me know if this works for you!
Works perfectly! Thanks again @floooh! 😁
It seems that Sokol SHDC is generating a sparse array of
image_sampler_pairs
on the latest version, from this shader:Previous Sokol SHDC Rust output:
Current Sokol SHDC Rust output:
Which fails validation on the most recent version of Sokol: