bkaradzic / bgfx

Cross-platform, graphics API agnostic, "Bring Your Own Engine/Framework" style rendering library.
https://bkaradzic.github.io/bgfx/overview.html
BSD 2-Clause "Simplified" License
14.86k stars 1.93k forks source link

global shader variables break uniform detection #1896

Open ProPuke opened 4 years ago

ProPuke commented 4 years ago

If global variables are present in shaders and exist before uniform declarations (like SAMPLER2D()) shaderc will (sometimes?) not include the uniform information in the compiled bin files.

For example:

#include "common.sh" //if this include contains any global variables (which are not optimised away by dce) the uniform below will not be assignable from bgfx

SAMPLER2D(u_albedo, 0);

This isn't mentioned in the docs and likely to cause headaches for others (as it did me).

Occurs when using default shaderc settings (shaderc -f fs_shader.sh -o fs_shader.bin --type f)

OSDVF commented 2 years ago

Headache at 2 am. Certainly.