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

Gsdx black fmv #1222

Merged
merged 8 commits into from
Apr 21, 2016
Merged

Gsdx black fmv #1222

merged 8 commits into from
Apr 21, 2016

Conversation

gregory38
Copy link
Contributor

Commits fix rules of roses and I hope various black screen FMV

Performance impact must be tested, and I'm afraid of strange texture cache behavior.

@ssakash
Copy link
Member

ssakash commented Mar 6, 2016

Your third commit causes some graphical issues on Bomber man Kart and also random crashes at few instances.

Compiled without third commit:
fine

compiled with third commit:
not so fine

@ssakash
Copy link
Member

ssakash commented Mar 6, 2016

Third commit also causes random crashes on Ben 10 : Protector of earth. though without any graphical glitches. The issue isn't reproducible with the first two commits.

@gregory38 gregory38 force-pushed the gsdx-black-fmv branch 2 times, most recently from 4df3439 to 21a1c4d Compare March 6, 2016 17:33
@gregory38
Copy link
Contributor Author

Only the latest commit impact the rendering.

I updated the code to support 16 bits format. And to check the size of the upload. I'm not sure it will fix the crashes but it won't be worst.

@ssakash
Copy link
Member

ssakash commented Mar 6, 2016

the new commit seems to fix to all the regressions, I'll try doing an indepth test later.

@gregory38
Copy link
Contributor Author

Oh great. Today is my ludky day. Texture blocks are 2 time smaller in 16 bits, so I guess it was overflown.

By the way, it must be tested without the "Switch to GSdx SW when an FMV plays" gamefix. Hopefully it will become useless.

@MrCK1
Copy link
Member

MrCK1 commented Mar 7, 2016

I'll test GT4 later; just hope it will get past the copyright screen :(

@refractionpcsx2
Copy link
Member

I doubt this will fix GT4, that doesn't even work in software mode, the video doesn't even actually play as far as I'm aware.

@ssakash
Copy link
Member

ssakash commented Mar 7, 2016

I doubt this will fix GT4, that doesn't even work in software mode

I assume it's a core issue ?

Edit: I did further testing on the build for regression at some more games and it seems to be fine. I didn't test any games with broken FMV's though, I don't have any such games.

@FlatOutPS2
Copy link
Contributor

This commit hasn't fixed any software mode-only video's I've tried. I still needed to f9 to software mode to see the video's.

@bositman
Copy link
Member

bositman commented Mar 7, 2016

@FlatOutPS2 Please explicitly state games so we don't test the same games again...

@gregory38
Copy link
Contributor Author

@FlatOutPS2
Please send me a gs dump for a game. I put very strict condition on the texture cache. Maybe I need to relax them a bit. Or maybe I miss somethings in the texture cache.

@FlatOutPS2
Copy link
Contributor

Here are two video GS dumps that only play in software mode:
http://forums.pcsx2.net/attachment.php?aid=59318

@gregory38
Copy link
Contributor Author

Thanks you. I can reproduce the bug on my side. Now remains to understand the issue and to fix it.

@gregory38
Copy link
Contributor Author

Hum, trailer seems to work with the preload hack (at least on the dump)

@gregory38
Copy link
Contributor Author

On the other dump (spy hunter), it is very interesting. @ssakash will love it.

So the game uses an internal resolution of 640x512, very standard. But it draws the texture on the rectangle (0 , 992 ) x (640, 1232). In native resolution the FB is 1280x1024... So you can understand that texture is drawn in the void....

Currently the source texture is located at 0x1400 and the FB at 0x0 (FBW == 10). The pixel (0) x (992) is therefore located at (992/32) == 31th height page. A page row is 320 blocks. So we are around 0x26C0 which mean in the source texture. In others word, the game overflow the frame buffer to draw into the texture. It copies (blits) data from the top of the texture to a lower part...

Now I can search a rope to hang myself :p I dunno how to fix it. Let's try a bigger FB to see if it "fixes" the bug. Good new the bottom part is correctly drawn in the FB. Bad new the texture isn't invalidated so there is a texture cache bug too.

@gregory38
Copy link
Contributor Author

Ok I understand the texture cache bug.
What happen after the draw
1/ invalidate the texture
2/ upload the data from the GS memory (CPU) to GPU texture

What ought to be the correct version
1/ invalidate the texture
2/ transfer the rendering from the VRAM to the RAM (aka GS memory)
3/ upload the data from the GS memory to GPU texture

@gregory38
Copy link
Contributor Author

FWIW, I added a check on FB size. And it seems that the "trailer.gs" also draw outside of the FB, namely between 1024th line and 1280th line. I give it a closer look and it seems a similar pattern as above.

I really don't know how to fix it. So far, it seems FMV rendering is done after the line 1024, so maybe I can try to detect the pattern and completely invalidate the RT target. It won't be fast, but it could be enough for a couple of FMV. Boys, it is time to find game that suffers of this issue, so I can polish my idea.

@gregory38
Copy link
Contributor Author

I pushed a tentative fix for native resolution. Please test some games @ramapcsx2, @FlatOutPS2

@FlatOutPS2
Copy link
Contributor

It doesn't fix it. It did show some vertical lines dancing on the screen at times, but it's stil black most of the time. This happened with all the games I tested.

Edit: The vertical lines appear when the entire screen is used by a video. Most video's have black borders to give a "cinematic" feel, and with those the screen is just black, so it only sees either the very bottom or the top of a video and stretches it accross the screen as vertical lines.

@gregory38
Copy link
Contributor Author

Just to sure, you're in native mode.

@FlatOutPS2
Copy link
Contributor

Yes, it's completely black at higher resolutions.

@gregory38
Copy link
Contributor Author

Ok. The issue is the texture cache management. I suspect I fix the bug in the middle of the flow, it means that if the texture cache is correct at instant T of the video, the next frame will be correct. However I suspect a bug remains in the start of the video. First frame is likely wrong, and it is likely reused. I would need a bigger gs dump, one that start before the FMV so cache is polluted with wrong data.

@FlatOutPS2
Copy link
Contributor

Is this enough?
http://forums.pcsx2.net/attachment.php?aid=59329

@gregory38
Copy link
Contributor Author

Did you try with the preload hack?

@FlatOutPS2
Copy link
Contributor

Yes, same result.

@gregory38
Copy link
Contributor Author

Hum I slowed down the rendering, and I spot a couple of glitches. However I'm far from a black screen.
screenshot - 03122016 - 10 23 59 am

Could you tell me the complete name of the game? I will try to find it in my local resellers.

@gregory38
Copy link
Contributor Author

I have a trail. Here a texture cache lookup of the frame.

Message:TC: Lookup Frame 1280x1280, close hit: 21 (0x800, took 0x0 -> 0x2800)
Message:TC: Lookup Frame 1280x1280, perfect hit: 1 (0x800 -> 0x1000)

We try to load data from pointer 0x800. I can you see there are 2 valid buffers. One that ranges from 0 to 0x2800 and the others one that ranges from 0x800 -> 0x1000. The texture cache take the 2nd one. But I think it mustn't exists, because it is a subpart of the first buffer. Indeed if I check the texture, the small buffer is fully black.

@gregory38
Copy link
Contributor Author

Thanks for your report. I will revert my change for the auto-detection of the height. It requires 2 frames to stabilize, and just fill the texture cache with junk.

The hint is based on the rendering
It often happens the game try to upload the FMV directly which typically
gave a black screen.

Commit fix rules of roses and I hope various black screen FMV

Performance impact must be tested, and I'm afraid of strange texture cache behavior.

V2: check the size of the transfer too
V3: add support of 16 bits format
V4: avoid division by 0
It will be used in the following commit
It will be used in next commit. However, it might not be the best solution
The long story:
Game blits FMV far aways of the RT which is actually the input of the RO texture...
Currently GSdx suffers of 2 bugs.
1/ RT is too small
2/ texture isn't properly updated with the rendered value. Texture is invalidated
but it reads back the pixels from the GS memory whereas the correct
value is located on the GPU.

This commit will replace the standard draw by a manual blit. Therefore it avoid
size issue and bad upscaling issue.

v2:
* Use various copy to be more compatible with dx api
* Move all part of the hack info the BlitFMV function

v3: add log message
Try to avoid random black screen frame

v2: don't force the preload hack on the frame
It creates a ghost image over FMV

v3: support offset within a frame
So let's increase the height. It will increase the memory requirement on some games

v2: try to do it automatically
(not sure it will useful as most game will requires it)
v3: let's back to an hardcoded 1280 size. It generates too much issue
@gregory38
Copy link
Contributor Author

I reverted my auto detection code.

On 007, I don't have the flickering on the dump. And the gap is normal. The game renders the FMV as line. FF DoC uses points. Hack is possible (by replacement of the line by some sprite with the CPU or a Geometry Shader)

@gregory38 gregory38 closed this Apr 4, 2016
@gregory38 gregory38 reopened this Apr 4, 2016
@Aced14
Copy link
Contributor

Aced14 commented Apr 5, 2016

Here's another game that's still suffering from FMV flickering (as of 8943a9d)...

Monster Attack

@gregory38
Copy link
Contributor Author

@Aced14 I think your dump is too small. I can't reproduce the issue on my side.

@Aced14
Copy link
Contributor

Aced14 commented Apr 9, 2016

@gregory38 Here's a multi-frame GS dump of Monster Attack:
Monster Attack: Multi-frame GS GS dump (OpenGL hardware)

Just to provide more information, when this game starts up, it checks for memory card data, then proceeds to show company logos. The first logo is a static image for "agetec" (fades in/out and works fine in all GSdx modes and renderers). The second logo is for "D3 PUBLISHER", which uses an FMV. In GSdx hardware (both OGL and DX11), that particular FMV flickers heavily between black and its "real" video frames. It doesn't flicker in GSdx's software modes.

@gregory38
Copy link
Contributor Author

@Aced14 could you provide me a short iso dump? Try to search on forum how to generate it, I don't remember which plugin can create it. I didn't manage to reproduce the issue with the GS dump.

Otherwise I think I will merge the PR. So far it seems to solve more bug than to introduce new one ;)

@gregory38 gregory38 merged commit 59ef668 into master Apr 21, 2016
@Aced14
Copy link
Contributor

Aced14 commented Apr 22, 2016

@gregory38 Monster Attack: Block dump.

From what I researched, it seems that only the Linuz ISO CDVD plugin can read/write block dumps. But it's not included in modern PCSX2 builds. I copied it out of a summer 2014 build and used it within this PR's latest AppVeyor build.

@tabnk
Copy link

tabnk commented Apr 26, 2016

Finally the rules of rose FMV can be render in hardware mode.

@gregory38 gregory38 deleted the gsdx-black-fmv branch April 28, 2016 21:31
@baptiste0602
Copy link

This PR introduces half-screen issue with Splinter Cell Chaos Theory : half bottom is black.
Tested with (E) version. I will try later if it's happening in (U).

Should I add it to #1339 ?

@refractionpcsx2
Copy link
Member

This PR introduces half-screen issue with Splinter Cell Chaos Theory : half bottom is black.
Tested with (E) version. I will try later if it's happening in (U).

Should I add it to #1339 ?

Thanks :) I have added it for you to the "Extra" list as it has a link to here.

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

Successfully merging this pull request may close these issues.