Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Final Fantasy 4 rendering issues with DIRTY_CULLRANGE #11850

Closed
Salz opened this issue Feb 26, 2019 · 11 comments
Closed

Final Fantasy 4 rendering issues with DIRTY_CULLRANGE #11850

Salz opened this issue Feb 26, 2019 · 11 comments
Labels
D3D9 Direct3D 9 OpenGL
Milestone

Comments

@Salz
Copy link

Salz commented Feb 26, 2019

What happens?

Final Fantasy 4 is missing some digits/text at the end of some lines. This happenes on 1.7.5 and current master branch (commit 593c313). Digits at the end of numbers are missing at least in the bestiary, the time and gil display and the number of items already owned in shops. Letters at the end of long lines are missing in the story description of The After Years, and on some in game dialogue, too. See attached pictures for examples.

I bisected this to commit 6705849 - reverting it fixes the output on both 1.7 and master branch.

What hardware, operating system, and PPSSPP version? On desktop, GPU matters for graphical issues.

I'm running the Qt:Linux build on Intel(R) Haswell Graphics (CPU G3450).

bug1
bug2

@hrydgard
Copy link
Owner

That commit by itself should be safe, it must be hiding some other bug....

@hrydgard
Copy link
Owner

@hrydgard hrydgard added this to the v1.8.0 milestone Feb 26, 2019
@Salz
Copy link
Author

Salz commented Feb 26, 2019

Zipfile contains the ppdumps for both Images of the original bugreport running on the v1.7.5 version.

ppdmp.zip

@hrydgard
Copy link
Owner

Thanks, that will help investigation.

@hrydgard
Copy link
Owner

hrydgard commented Feb 27, 2019

Interesting, this seems to only affect the D3D 9 and OpenGL backends, Vulkan and D3D11 are fine.

The missing letters seem to get hit by vertex range culling, they get NaN in W. What's going on...

@hrydgard hrydgard added D3D9 Direct3D 9 OpenGL labels Feb 27, 2019
@hrydgard
Copy link
Owner

hrydgard commented Feb 27, 2019

The affected characters are drawn with a small-ish rectangular viewport including the bounding box of the letter and the bottom-right corner of the screen, while the working characters are drawn within a full screen viewport (their shadows with a 1px offset). This can be seen with careful poking around in RenderDoc. Most likely we compute the wrong horizontal/vertical culling region for these.

@hrydgard
Copy link
Owner

hrydgard commented Feb 27, 2019

In one example (a tall and thin viewport touching the right edge of the screen), CalcCullRange computes a minX of -592 and a maxX of -236. Not easy for vertices with final clip space positions within approximately the -1...1 range to make it through that.. Something is wrong with the math.

Plus, it's very curious that Vulkan/D3D11 aren't affected. I wonder if these are viewports we've clipped against the right/bottom edges.. (answer yes, see below)

Added this to the bottom of CalcCullRange and it only hits in D3D9/OpenGL:

	if (minValues[0] < 0.0 && maxValues[0] < 0.0) {
		__debugbreak();
	}

Yeah so this is definitely related to GPU_SUPPORTS_LARGE_VIEWPORTS, which is set by D3D11 and Vulkan only. This only fails when we clip the viewports and modify the proj matrix to match.

@hrydgard
Copy link
Owner

@unknownbrackets I know you said you don't have time this week, but you're the viewport master :) I'm planning to release 1.8.0 around March 12 or so, if you have sec before then it would be great. If not, I'll dig into it myself. But this is definitely caused by CalcCullRange going wrong with viewports that we clip manually on platforms that don't support large ones.

@hrydgard
Copy link
Owner

hrydgard commented Mar 2, 2019

This should now be fixed! Thanks unknown.

@hrydgard
Copy link
Owner

hrydgard commented Mar 2, 2019

Oh, and thanks @Salz for the great bisection!

@Salz
Copy link
Author

Salz commented Mar 4, 2019

Thanks, I can confirm this issue is fixed in the current master branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
D3D9 Direct3D 9 OpenGL
Projects
None yet
Development

No branches or pull requests

2 participants