-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Allow delayed loading of texture replacements #15025
Conversation
Cool idea, fails to load replacements for me:
anything special that needs to be done for it? Used vulkan and just tried to run my stuttery test texture pack I have on ramdisk. |
78abd18
to
be3c1f5
Compare
Blarg. I got myself worried about the width changing and crashing from out of bounds and forgot to validate PNGs after changing, I seem to be forgetting to retest after minor changes more often these days... I thought I did. Darn it. Anyhow, fixed, just needed the -[Unknown] |
Ah, sorry, D3D11 was still trying to use the texture. Cleaned that up and centralized a bit. -[Unknown] |
Thanks:), |
https://youtu.be/58avCsikNqo a short clip showing how it pops while still stuttering. |
If any individual load takes more than a frame, it'll currently still hitch (would be solved using a thread), but the multiple freezes should be smaller than the original freeze would've been. That seemed pretty stuttery though, seems worse than I'd expect the sum... maybe I made a mistake somewhere... -[Unknown] |
That stuttery screen with dialog animation is actually much worse than without this feature, kind of looks like it invalidates the texture each frame as without the feature it just quickly loads and disappears without any delays. edit: I guess the black screen definitely is shorter with this feature, so it's where all the loading happens, I had to check, but this small dialog actually loads 16 textures, 11 of which are 512x512 font textures.;o |
Combined ZIM + pop in is enought to have it practically stutter free:). |
732f25c
to
0036c87
Compare
So sounds like it'd be useful for me to add the threaded decoding here. -[Unknown] |
If I understand correctly, threaded decoding would make it no longer require to fit within frame budget, so assuming no other bottlenecks, would make it silky smooth and just make it pop in later depending on hardware performance? If soo that'll be great, definitely a better choice for gameplay than freezes/stutter through an option to disable delay might still be nice to have for people that doesn't care about gameplay experience and just want to record video with built-in recorder. |
Not actually decoding into the cache, just setup.
And make sure we don't change our minds about using a replacement during a draw.
0036c87
to
09f0578
Compare
I think there's some kind of issue with the new commit, didn't notice much of a change so I restarted the game(via ctrl+B) and after a few seconds, before even reaching the stuttery part it simply hang, it didn't crashed or anything, the window is still active and not frozen either, it just stays there on black screen forever and while it logs input, it doesn't react to it, so can't even leave to menu. Edit: now it hangs like that every time the moment it hits the stuttery moment, even through I did close it through task manager completely. |
I probably need to test with a more varied texture pack... If you comment out If that does prevent the hang, what about making -[Unknown] |
Both prevent the hang, however the first one prevents it completely, the latter despite glitches still makes it hang when restarting the game. Edit: maybe I should word that differently, as in the latter doesn't prevent the hang, just slightly changes how the hang can be reproduced. Either way the key to hang with and without this test change is restarting the game as if something wasn't cleared/restarted properly. The only differences is it will work once after re-running PPSSPP, while previously it was hanging every time after first game restart even when PPSSPP was fully closed and reopened and also previously it continued to hang after few boot screens, with the last change it crashes instantly when restarting the game via ctrl+B. |
If the texture is being loaded and we stop or reset, make sure it stops to avoid any crash or hang.
Hm, I'm not reproducing that currently. I did find things would go badly if you reset emulation while a texture was still busy loading, though. Should be improved now. -[Unknown] |
Unfortunately still starts hanging after first game restart, then it continues to hang during first run as if something in the system would continue affecting it until I restart windows even if I manually close all PPSSPP instances through task manager. I don't use any 3rd party overlay software nor driver hacks, it's pretty bare bone win 10, chrome and Visual Studio running, tries to change backends and settings as well to see if anything affects it, but doesn't seem like it's the case. One weird thing just happened, I ran PPSSPP which was already hanging through DebugLog.bat and it somehow passed the hang moment and continued to replace textures further, until start menu. Maybe --log affected some timing, because every single time it hanged at earlier spot in previous tries.:o I was writing that it possibly avoided the issue completely then I got back into the game and tried to continue and it still hanged. Not sure if this helps, but here's the log. The PPSSPP doesn't crash during the hang, but stops logging doing anything except input, so the hang had to start near the end of this log. |
Still haven't reproduced the problems, I'm mainly testing using Persona 3 Portable and its texture pack that was posted on the forum - tried multiple backends, at 4x. That said, I realized maybe running a parallel loop from a task could cause problems, maybe that's the issue? -[Unknown] |
Yup, that appear to fix the problem:). |
The texture pop-in at least in case of AI-upscaled textures which are faithful to original isn't that noticeable and PNG texture pack works just as smoothly as the ZIM one with this maybe with just slightly longer texture load:). Unfortunately both formats still suffer from ocassional stutter, not sure what's causing it, I get it doesn't matter if I have the texture pack on hdd, ssd or ramdisk, not sure what bottleneck causes that. |
Hm, I wanted to let there be some time to avoid pop in for faster loading textures. There's two possibilities for the stuttering:
We could validate if it's 2 pretty simply, by changing -[Unknown] |
Setting it to -1.0 just stopped replacing textures, I tried to instead divide it again by 10000.0, this felt less noticeable in-game, but maybe it's just a placebo as ocassionally it still stuttered. |
Ah, sorry, I fixed it to allow Watching the log with the pack, I do sometimes still drop a frame here and there, which I do think is from the time uploading the texture. Still, it does seem like much reduced lag. -[Unknown] |
Yeah even with 0 it still has it's moments, still even if not perfect, it's a huge improvement.(Edit: by huge improvement I mean this PR, not the 0 change ~ still not sure if it really has an impact) Even with this it's worth converting textures to ZIM format as the stutter while in same moments is a bit shorter with ZIM's(I mostly get it by sound by now as there's no freezes whatsoever with this PR). |
I think this looks fine overall, was slightly afraid that it would interfere with the texture loading rework that's slowly starting to take shape in my head, but it doesn't. I've been swamped lately so haven't had time to really test this, but I'm happy to get this in, and if needed we can improve it further later. |
Made a short video that includes gameplay to show the delay with this PR as it is now, but with ZIM textures it's hard to notice, max few frames in the heaviest places like savedata dialog after boot screens(11 font 512x512 textures + 5 smaller ones all upscaled x4) that otherwise would just freeze and load with a delay: The water in-game is glitchy, but that's cause missing mipmap interpolation, has nothing to do with the feature. |
Wow, it fixed stuttering issue I encountered in my texture pack. here comparison video. |
Let's get it in. |
This has completely fixed the stuttering in the games I've made texture packs for! The only downside is that re-loading from a save state or toggling texture replacement off and on no longer causes the textures to be re-loaded from disk, which is an important feature for authoring textures, since it lets you rapidly iterate and test in-game. It would be useful to be able to disable this feature, or flush the texture cache and re-load replaced textures from disk if the user toggles texture replacement off and on, |
You can disable this using -[Unknown] |
Just tested; setting A hotkey to reload replaced textures from disk, would be very useful! |
Please check #15740 when it's done building (Artifacts on the Checks tab.) This should make disabling and re-enabling clear cache and reload them. -[Unknown] |
Works perfectly, thanks! |
Delayed loading (pop in) is not really ideal, especially if replacements aren't just higher detail but have some differences (I think for more simplistic games, they can even be used to translate a game.) But hitching is really annoying, so arguably the replaced images "hitching" in without affecting gameplay is also bad, but less bad.
This takes a very simple step and uses a frame budget to decode texture level data into RAM but avoid significant hitching. It keeps this decoded data cached for a while, so it can skip decoding if the texture is needed again in a couple minutes.
It might be nice for this to be configurable (both whether you would allow popping, and maybe some way to balance RAM usage), but wanted to open this to allow people to experiment and see how this impacts hitching.
This doesn't move texture decoding to threads, but that wouldn't be much harder to do. A more advanced technique (loading texture in thread until queue runner, and dynamically selecting texture and maybe shader at that point) is somewhat complex, but ultimately would probably result in some hitching or pop-in too, so this is an experiment to see how bad pop-in is.
Feedback on builds under Artifacts on the Checks tab appreciated.
-[Unknown]