Fix DMA linear texture copy fast path #3496
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.
FindTexture
tries to find an existing texture that matches the copy parameters, if found we try to write the data into the texture directly which is more efficient. However,FindTexture
was also matching textures that have a height higher than the copy height. This causes problems because linear strided -> linear conversion expects data to be at least as large as the texture itself, and in this case it won't be causing an exception.The fix here is making
FindTexture
only match linear textures with exactly the copy height. In addition to that, I removed theRegionY
parameter because it is not used for linear copies, only block linear ones (that's an incorrect assumption that was made in the past and corrected, but I missed that code). Since after this only two fields fromDmaTexture
were accessed, I decided to stop passing the whole struct and just pass those 2 parameters to the function, which is more efficient.Fixes crash in SD Gundam Battle Alliance Demo with the following exception:
For the record, at that time it was trying to write 256x25 data into a 64x29 RGBA8Srgb texture. With this fix, it tries to write it into a 64x25 texture.