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

Misshitsu no Sacrifice and Macross series needs mipmap interpolation for smooth animation. #6357

Closed
RadarNyan opened this issue Jun 17, 2014 · 26 comments
Labels
GE emulation Backend-independent GPU issues Mipmaps Mipmapping related issues
Milestone

Comments

@RadarNyan
Copy link

RadarNyan commented Jun 17, 2014

DEMO: NPJH90092 PRODUCT: ULJS00251
(This game required 6.10 PSP update)

No vocal
All vocals are silent in game as reported in #2436 but BGM now works fine.

In debug log:

01:24:128 BGM thread   E[ME]: HLE\sceAtrac.cpp:939 sceAtracGetSecondBufferInfo(0, 0bfafa54, 0bfafa58)
01:24:128 BGM thread   D[ME]: HLE\sceAtrac.cpp:1353 sceAtracSetLoopNum(0, -1)
01:24:128 BGM thread   D[ME]: HLE\sceAtrac.cpp:919 sceAtracGetRemainFrame(0, 0bfafa50)
01:24:128 BGM thread   D[IO]: HLE\sceUmd.cpp:316 0x32=sceUmdGetDriveStat()
01:24:129 BGM thread   E[ME]: HLE\sceAtrac.cpp:632 WARNING: Remaining data in packet - we currently only decode one frame/packet
01:24:129 BGM thread   D[ME]: HLE\sceAtrac.cpp:702 00000000=sceAtracDecodeData(0, 08986a00, 0bfafa24[00000800], 0bfafaf8[00000000], 0bfafa1c[232])

Intro background video lagging

(Check next comment for animation)

Nothing wrong in log console, OP movie plays pretty fine and smooth though.

Edit:
Just a list of titles that are affected by this with gameID's in case it'll ever need a hack:

  • Misshitsu no Sacrifice(ULJS-00251, NPJH-50224),
  • Misshitsu no Sacrifice Jitka: Aru Heisa Shisetsu kara no Dasshutsu (NPJH-00065),
  • Misshitsu no Sacrifice: Miki High Tension Night (NPJH-00077),
  • Macross Ace Frontier (ULJS-00158, ULJS-19029),
  • Macross Ultimate Frontier (ULJS-00231, ULJS-00223),
  • Macross Triangle Frontier (ULJS-00321, ULJS-00369, ULJS-19072).

Macross series uses it for(AFAIK) water animation only, Misshitsu series uses it for pretty much all animations, including animated UI.

Also to note since things are easily forgotten, mipmap interpolation is already supported in software renderer.

@RadarNyan
Copy link
Author

Intro background video lagging

sidebyside

side by side gif animation showing this bug in action (up: real PSP, down: PPSSPP)
as you can see PPSSPP is also running in full speed (check the arrow, it animates fine)
GE debugger shows these textures have two levels, L1 is different from L0 but the same (in shape) as the next changed textures L0 but lighter (in brightness).

JPCSP also has this problem.

@RadarNyan RadarNyan changed the title Misshitsu no Sacrifice: No vocal, Intro background video lagging. Misshitsu no Sacrifice: Intro background "video" lagging (with 60/60 FPS) Jun 24, 2014
@RadarNyan RadarNyan changed the title Misshitsu no Sacrifice: Intro background "video" lagging (with 60/60 FPS) Misshitsu no Sacrifice: Intro background "video" lagging (with 60/60 FPS), No vocal Jun 24, 2014
@unknownbrackets
Copy link
Collaborator

Has this improved or changed at all? If not, a log might help - wondering if it uses sceMpeg or scePsmf.

-[Unknown]

@RadarNyan
Copy link
Author

Tried latest git build (v0.9.9.1-1582-g08eaa6e) nothing changed.
Which log level & log channels should I choose for the log?

Here's the official download link of trial version (NPJH90092) if you want to debug yourself:
http://www.d3p.co.jp/sacrifice/ms_trial.zip
This scene is at the very beginning of the game (right after you start the game from title screen)

@LunaMoo
Copy link
Collaborator

LunaMoo commented Jan 21, 2015

The problem might be completely unrelated, but the animation of what should it look like vs how it looks reminds me of water in macross games, so just for reference to check another if one of those get's fixed - #5559

@unknownbrackets
Copy link
Collaborator

Interestingly, it draws this using bezier patches. I'm not sure, at first I thought it was using bezier to "tween" between keyframes, but afaict it uses the same control points for every single frame.

The bezier patch is a single patch and, afaict, it's always the same. We generate pretty basic UVs for it, in a 0, 0.25, 0.5, 0.75, 1.0 pattern. I'm guessing that part is all correct. It uses UV scaling to just draw the right portion of the texture.

Importantly: it uses 2 texture levels. The two levels appear to be slightly different frames. level/bias is set to 0x050001 and slope is 0. While displaying a single frame, this bias (the 5) goes from 0x0 - 0xf, so this is probably what drives the tweening affect?

But, it only ever has 2 texture levels. Our current code seems to think that texlevel >> 16 should peg a specific mip level?

-[Unknown]

@hrydgard
Copy link
Owner

Are the two levels set to different sizes or the same size? Really interesting use of the mipmapping hardware and mipmap bias if the latter, and one that we simply can't replicate using OpenGL, without writing some rather specialized shader code for this case...

@unknownbrackets
Copy link
Collaborator

Same size, sorry should've mentioned that.

I mean, I guess we could fetch from both levels and interpolate ourselves if we did it in the shader. Seems messy... probably better to bind as separate textures?

I looked at the code again, we divide by 16. So basically, it goes from 0.0 to 0.9375 of the next keyframe using mipmapping. I still wonder if this is what that water does as well in the Macross game.

-[Unknown]

@hrydgard
Copy link
Owner

So - if the first two mip levels are the same size, we create them as separate textures (or as a WxHx2 3D texture where available, that is, OpenGL 3 and ES 3+) and either blend in the shader or sample the 3D texture with a Z coordinate equal to the mip bias. Yet more shader flags and combinations, sigh...

@hrydgard
Copy link
Owner

Actually I think this is rare enough that we can just ignore it for OpenGL ES 2.0 and go ahead and only do the 3D texture solution. Doesn't seem worth the trouble to go all out with workarounds when this will be comparatively easy to do...

@unknownbrackets
Copy link
Collaborator

For voices (probably ought to be a separate bug though), it seems like an timing problem related to IO. It calls sceIoClose on a file, then starts a thread and that thread tries to access the file. It's possible we're doing async wrong and that can somehow work...

-[Unknown]

@unknownbrackets
Copy link
Collaborator

So, what's happening here with the voices is that even after closing a file, you're supposed to be able to read a stale result from the file - it seems. Basically the game does this:

thread1:
sceIoOpen
sceIoReadAsync
sceIoClose
create thread2

thread2:
sceIoWaitAsync

It seems like sceIoClose is meant to wait for the pending operation to complete, and then close it. The result would then be available for thread2, and the memory would've been written.

-[Unknown]

@daniel229
Copy link
Collaborator

JPCSP fixed the voices in jpcsp/jpcsp@61ecddc

@hrydgard
Copy link
Owner

hrydgard commented Feb 3, 2017

Just for the record, I believe #8868 should have fixed the voices here. Mipmapping ("video lag") issue is, as mentioned, the same as #5350 .

@RadarNyan
Copy link
Author

Yes, I can confirm that voices playback is working.
Can't test the code in for mipmapping though as I'm currently not cappable to make a custom build.

@hrydgard hrydgard added this to the v1.5.0 milestone Feb 4, 2017
@LunaMoo
Copy link
Collaborator

LunaMoo commented Feb 12, 2017

Just to note this fake mipmap problem isn't limited to the talking goo animation shown above, possibly all animations in this game use it, from the start of the demo I noticed it on ui elements(althrough not as bad with those just cuts fps by half) and all animated water(looks pretty much as choppy as in Macross series).

@hrydgard
Copy link
Owner

Both problems seem to be fixed since a long time, closing.

@LunaMoo
Copy link
Collaborator

LunaMoo commented Nov 14, 2017

Those problems were fixed, but for now only in softGPU.

@LunaMoo LunaMoo added D3D11 Direct3D 11 D3D9 Direct3D 9 OpenGL labels Nov 14, 2017
@hrydgard hrydgard modified the milestones: v1.10.0, Future May 24, 2020
@LunaMoo LunaMoo added GE emulation Backend-independent GPU issues and removed D3D11 Direct3D 11 D3D9 Direct3D 9 OpenGL Vulkan labels Aug 29, 2020
@hrydgard hrydgard added the Mipmaps Mipmapping related issues label Nov 11, 2020
@LunaMoo
Copy link
Collaborator

LunaMoo commented Jul 25, 2022

Would implementing this still be that bothersome in for example Vulkan backend? It's nowadays decently supported even on mobiles.

@hrydgard hrydgard modified the milestones: Future, Future-Prio Jul 25, 2022
@hrydgard
Copy link
Owner

Not difficult, just a little architecturally awkward, and since it doesn't affect playability it's kinda fallen down the list of priorities. It will get implemented though (for VK/D3D11, possibly also GL 3+)

@LunaMoo
Copy link
Collaborator

LunaMoo commented Jul 25, 2022

I'd say it does affect playability of at least Misshitsu series since all animations in the game use it and currently run like they're on heavy frameskipping^_^;, then again there were always people willing to play in single digit fps if the alternative would be not playing at all.

@hrydgard
Copy link
Owner

I hacked up something Vulkan-only that needs testing. Some GE dumps would be great, preferably in the middle between two animation frames. Both for Misshitu and Macross water, ideally.

@unknownbrackets
Copy link
Collaborator

There's actually a free demo up above. It does it pretty early on.

-[Unknown]

@hrydgard
Copy link
Owner

Oh right, I think I have that sitting around somewhere - unfortunately, the link 404s.

hrydgard added a commit that referenced this issue Jul 25, 2022
…6357)

Vulkan-only currently, though all the other backends except ES 2.0
without GL_OES_texture_3d can support it with some work.
hrydgard added a commit that referenced this issue Jul 30, 2022
…6357)

Vulkan-only currently, though all the other backends except ES 2.0
without GL_OES_texture_3d can support it with some work.
hrydgard added a commit that referenced this issue Jul 30, 2022
…6357)

Vulkan-only currently, though all the other backends except ES 2.0
without GL_OES_texture_3d can support it with some work.
hrydgard added a commit that referenced this issue Jul 30, 2022
…6357)

Vulkan-only currently, though all the other backends except ES 2.0
without GL_OES_texture_3d can support it with some work.
hrydgard added a commit that referenced this issue Jul 31, 2022
…6357)

Vulkan-only currently, though all the other backends except ES 2.0
without GL_OES_texture_3d can support it with some work.
@Panderner
Copy link
Contributor

Misshitsu no Sacrifice's intro background video runs smoothly on latest build.
ezgif com-gif-maker

@hrydgard
Copy link
Owner

hrydgard commented Aug 1, 2022

Closing, finally :) That was not easy, heh.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GE emulation Backend-independent GPU issues Mipmaps Mipmapping related issues
Projects
None yet
Development

No branches or pull requests

6 participants