Restore dirty list for BaseMaterial3D but don't use it on resource loader. #99716
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 #99576.
Visual updates for Material3D broke in general as I added the ability for materials and shaders to defer the updates according to what @reduz outlined for pipeline pre-compilation.
The dirty list is a bit of a hacky solution to make sure the updates reach in time to the materials on the scene, but we don't have a much better way to do it for architectural reasons. There's sadly no way for these minor material modifications to properly notify the scene geometry that it should request an update again by querying the RID of the Material or the shader.
For the sake of keeping the improvement I added for deferring the shader updates, as it's a huge improvement that allows shaders to be compiled by the resource loader, I used a change that Pedro recently did where it'll skip on adding the material to the dirty list if it's found to be within a resource loader.
While the logic might seem similar at first glance, the big difference is that it does not defer the call using the deferred mechanism but rather it allows the thread that requires the material to load it when necessary.
Requesting a review from @RandomShaper just to make sure this change makes sense.
We should make sure this doesn't break any existing logic with background loaders (demo projects that use background threads on loading screens) and that it still works as intended.