Fix shader preprocessor include resource check #73975
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #73925
This extra check is needed because both Shader and ShaderInclude implement their resource loader (which gets eventually called by
ResourceLoader::load()
) in a somewhat strange way comapred to many other loaders. Neither loader can never really "fail" and they don't check for any errors, they will always return a valid resource, but with empty text content. In short, previously almost all include paths "worked" even if the file did not even exist and these places simply included an empty string without raising any erros.A more fundamental fix would be to add error checking to both resource loaders, but that would be a high-risk fix as much of the exisiting codebase might not be prepared for these loaders to suddenly start returning null resources.
I can make a separarete PR to add error checking if that sounds like a good idea. It could be tested and merged later when 4.0 is out and there is more room for risky changes.