Fix a couple issues found by ASan/UBSan in the Metal backend#1844
Open
fabioarnold wants to merge 4 commits intocemu-project:mainfrom
Open
Fix a couple issues found by ASan/UBSan in the Metal backend#1844fabioarnold wants to merge 4 commits intocemu-project:mainfrom
fabioarnold wants to merge 4 commits intocemu-project:mainfrom
Conversation
`m_uniformBufferOffsets` is sized to `METAL_GENERAL_SHADER_TYPE_TOTAL`
Otherwise `cemu_assert_debug(s_cache == nullptr);` fails in MetalPipelineCache.cpp: 294
std::map::operator[] inserts a default-constructed (null) value when the key is absent. In GetSwizzledView, m_fallbackViewCache[key] would insert a null entry, but if a free slot existed in m_viewCache the texture was stored there instead, leaving the null entry in m_fallbackViewCache. The destructor then iterated the map and called ->release() on that null pointer.
13caea1 to
5554699
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Applied after #1842 attempts to fix graphical glitches I encountered while playing Twilight Princess HD due to memory corruption.
MetalPipelineCacheto 0.MetalRenderer()by using the correct bound.Another issue I couldn't test but was discovered by Claude:
The old code tried to convert a triangle fan into a triangle strip because Metal doesn't support fans. It's in
LatteIndices_unpackTriangleFanAndConvert:It's clever, trying to connect indices from both ends. However, it doesn't work in the case of a non-convex polygon like a star. You can convert to a triangle strip matching the topology of the original fan. But every other triangle needs to be degenerate. It's a bit more complicated and uses 2 indices per triangle.
In this change I implemented it the easy way and used a triangle list instead with 3 indices per triangle.