ekeeke / Genesis-Plus-GX

An enhanced port of Genesis Plus - accurate & portable Sega 8/16 bit emulator
Other
672 stars 193 forks source link

Corrupted .PNG files. Snaps and Savestates. #515

Closed Kingharthacnut closed 11 months ago

Kingharthacnut commented 11 months ago

The .png files that are taken as a Snaps and Savestate cover images have lines of data corruption on them! Is this a GPU problem on my end, is my Wii dying? If you need further info let me know - i'll test other games tommorrow.

Sonic3C IMG_20230715_225755

ekeeke commented 11 months ago

Your Wii is not dying, otherwise it would also happen while playing any game (emulated or not) ;-)

Yes, I noticed long time ago that pixels eventually got corrupted when saving screen to PNG file but it does not happen all the time so retaking another screenshot (or saving over a savestate) would fix it. Back then, I always thought it was some timing issue in my code or bug in libogc functions (I use a GPU hardware feature that copy internal framebuffer to a texture in CPU memory then write this texture to PNG file) but never found out the root cause.

However, looking at my 10 years old code again now, I think I found some potential cache issue that could lead the CPU to read corrupted data from memory when writing the PNG file. Could you give a try to attached test dol and see if it fixes that issue ? You will need to save new PNG files several times (either using snapshot button or making new savestates) to be sure it does not happen anymore.

genplus-gx-test-20230716.zip

Kingharthacnut commented 11 months ago

I used the new .dol and it does not show any corruption - I did multiple save states and checked the background .png and saw nothing out of place. The Shots .png was also fine when checked on my main computer - I could only check one though as the Shots folder only holds one .png per game.

Thank you.

ekeeke commented 11 months ago

Thanks for testing. I will commit the fix later but this confirms these changes fixed this long standing issue.

ekeeke commented 11 months ago

Now officially fixed by https://github.com/ekeeke/Genesis-Plus-GX/commit/a8d61b039189225bf8ab8438a38f758b8868198a