Create tangent array if mesh created without tangents #84576
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: #84277
Fixes: #83667
In both cases the issue came from a limitation in the Metal API that we were unaware of. We previously relied on overlapping reads from the normal buffer to pretend that we had tangents. Since we can't do that on Apple devices, we just provide tangent arrays always.
MoltenVK "corrected" our mistake which avoided logical errors on Apple devices, but which led to this subtle bug (https://github.com/KhronosGroup/MoltenVK/blob/bb914faa533a3ed923abf9cce3f9702492bfaef0/MoltenVK/MoltenVK/GPUObjects/MVKPipeline.mm#L1454-L1455)
This greatly simplifies our compression code at the cost of a small amount of bandwidth.
We can now go through our compression code and assume that tangents are always available (and thus remove some now superfluous code). I haven't done so yet as it will be a riskier change. This change is very low risk and is more suitable for a beta fix. I may make a follow up PR to clean the compression code if it makes sense to do so and can be done without compat breakage