GS: UV rounding method to grab enough of texture #12131
Closed
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.
EDIT: This is still broken except in special cases
Description of Changes
This is in response to the issue #12100. The problem was that for certain draws, not enough of a texture was being read from memory, because the edge texels for bilinear filter was not being accounted for properly (which can be +/-1 more than for without the bilinear filter). To fix the issue, the code calculates the UV coordinates at the minimum/maximum pixel centers in the draw's bounding box, then computes the UV coordinates for the bilinear filter, then uses these to specify the area of the texture that needs to be read. I believe this is most useful when the draw is something that looks like a flat rectangle (either a sprite or triangles shaped like a rectangle, with constant depth). I'm not sure what would happen for 3d polys.
Rationale behind Changes
The previous method for determining the proper bounds of the texture to read from memory used a heuristic that depended on ratio that the texture was being expanded/shrunk from texel space to pixel space. However, there are cases where this code cannot properly detect the bound of the texture being used when doing bilinear filtering.
Suggested Testing Steps
I would recommend running the GS dump in the thread #12100 and running the game itself. If there are other games that have similar issues, it would be good to check those too.
PS. Any feedback/suggestions from devs/testers with more experience on these issues or help testing this is much appreciated. Currently the code is still rough, though I would plan to clean it up if it was accepted.