Avoid error spam when shaders fail to compile by freeing shader_data version when compilation fails #100128
+32
−8
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: #99263
#99263 is a regression from #90400
Previously the ShaderData class would set its member valid to false when about to compile and then set it to true if compilation was successful (both shader compilation and setting up pipelines). IIRC we removed that since we needed to shift around how the shader was compiled run asynchronously.
Then, when setting up geometry for drawing we checked if the shader_data of a material was valid, if not, we could fall back to the default material.
Now instead of checking if !shader_data->valid, we check if the
shader_data->version.is_valid()
. Theversion
is allocated the first time the shader succeeds at compiling. After that,shader_data.is_valid()
will always return true. Accordingly, a way to fix this is to free theversion
if it exists already and the compilation fails.