gonetz / GLideN64

A new generation, open-source graphics plugin for N64 emulators.
Other
771 stars 179 forks source link

S2DEX fixes. Feedback. #1971

Closed gonetz closed 5 years ago

gonetz commented 5 years ago

Current HLE implementation for backgrounds commands is too high level. Actual commands are very complex. The microcode is documented, but the documentation does not cover some tiny details in internal mechanics. Thus, existing implementation does not always work right. olivieryuyu decided to not rely on documentation and decode the microcode itself. The goal of that new decoding project was to implement commands in HLE as close as possible to LLE and obtain the result, which is as good as with LLE or better.

It was very long and hard project, which took circa six months. It is not finished yet, but we are close. Both background commands implemented and they produce exactly the same result as in LLE mode on all games we tested.

You may run current versions of the plugin in LLE mode and find numerous graphics glitches in 2D games. Some of glitches caused by errors in texture loading code. Backgrounds commands do texture loading in quite weird manner, which "normal" game code never uses. I fixed several hard issues in plugin's texturing subsystem during development of that project. However, many glitches remained after these fixes. These glitches can be called "the curse of hardware rendering". There are two main groups of such glitches:

So, new implementation has issues, but most of them appears only in non-native resolutions. GLideN64 already has tool to eliminate issues with 2D graphics in high resolutions. You may enable "Render 2D elements in native resolution" option to activate it. I adopted that tool to work with new background commands. StarCraft backgrounds have glitches in high-res, but "Render 2D elements in native resolution" eliminates them. However, the tool is not bug-free by itself and in some games its use may cause disappearance of part of graphics. Besides, sometimes it is slow.

As you may guess from my explanations above, it is in rather alpha state. We tested it a lot, but with only two of us we could miss some regressions. Please test and leave bug reports. Sources reside in s2dex_fixes branch. I suggest to start with "Render 2D elements in native resolution" disabled and enable it only when you see aforementioned glitches. If use of "Render 2D elements in native resolution" causes new glitches, please report about it. Also, if you see glitches, please switch to LLE mode and compare. It is important for us to know about cases where LLE is still better.

gonetz commented 5 years ago

Related open issues:

1896

1897

1870

1869

1695

1619

936

1518

315 (is it ucode issue though?)

329

133

Kidboy17 commented 5 years ago

Ok just did some testing. I am using the latest development build of Project 64.

1695 Kirby 64: The outlines appear unless you have Render 2D enabled or use Original N64 Res option. Game runs fine from what I have seen with Render 2D enabled.

1896 Pokemon Puzzle League: The background is fixed now. Works with and without Render 2D enabled. Played a few rounds, game seems fine if people want Render 2D on.

Kidboy17 commented 5 years ago

Found a minor issue with Mario Kart 64. This happens in both LLE and HLE mode when not using Original N64 Res option. Render 2D does nothing to it. mariokart

Edit Also Killer Instinct still has alignment issues in LLE and HLE mode even using Original N64 Res. killerinstinct

gonetz commented 5 years ago

@Kidboy17 MarioKart and Killer Instinct do not use S2DEX. I know, that there are plenty of various 2D issues. This task is to find issues in HLE implementation of S2DEX ucode and only such issues. If the same issue reproduced in LLE mode, it need not be reported here. We need to know only about HLE issues.

List of games, which use S2DEX ucode (thanks to theboy181):

CallistoNTG commented 5 years ago

Resident Evil 2 glitchy backgrounds seem to be improved. Problem seen here https://github.com/gonetz/GLideN64/issues/1869 The hallway background renders correctly, and options menu only has some faint vertical lines on the text instead of heavily glitched lines. I'd post screenshots but Github isn't allowing it right now for some reason.

gonetz commented 5 years ago

Resident Evil 2 glitchy backgrounds seem to be improved.

This is strange. New background code is currently incompatible with RE2, thus old code is used. So, if something is improved in this game, it is because of some general fixes in texturing, which I've done in that branch.

olivieryuyu commented 5 years ago

a new bug here (must be very recent)

gliden64_gt64_000

weinerschnitzel commented 5 years ago

It looks like there are also alignment issues in the mini map

The last 0 on the speedometer also looks like there is an extra column of black pixels on the right. (Just before the k in km)

gonetz commented 5 years ago

Regression in GT 64 speedometer is fixed with f0b9f02e0. Mini map looks a bit different in HLE and LLE.

theboy181 commented 5 years ago

image 1080 has a regression with the background using this WIP Not sure why its not an SDEX title.

gonetz commented 5 years ago

I made several corrections in general texturing code, so any game can be affected. I'll check, may be this regression caused by these corrections.

OtavioRaposo commented 5 years ago

Indiana Jones first level sky is looking strange. untitled

theboy181 commented 5 years ago

Same issue in 1080 Snowboarding.

theboy181 commented 5 years ago

I think and I can’t double check right now that there is 2d regressions in Mario Golf again too.

gizmo98 commented 5 years ago

After upgrading to ubuntu 18.04 and getting everything running again i had some time to test s2dex_fixes branch. Everything looks fine. I experience significant slowdown in Bakuretsu Muteki Bangaioh compared to an old branch from november 18.

theboy181 commented 5 years ago

So none of the bugs reported ? @gizmo98

gizmo98 commented 5 years ago

@theboy181 Ok. I just tested s2dex games. I will check the posted issues.

gonetz commented 5 years ago

I reverted commit, which causes issues reported by theboy181 and OtavioRaposo. Thanks for help! Link on updated build is in WIP builds 3

Nerrel commented 5 years ago

The Neon Genesis commit that was just reverted seemed to solve several problems in Majora's Mask. This glitched ground seam in north clock town was fixed by the initial S2DEX merge and is now broken again in the new WIP build: image of ground

Also, before the S2DEX merge objects that combined a larger grayscale texture with a smaller color texture had required that the new custom color texture be offset from the grayscale one by a few pixels diagonally to align correctly, otherwise this blurred/ doubled effect would be created: image of blurred ground image of misaligned trees

After the S2DEX merge this offsetting was no longer necessary and the new HD color and grayscale textures aligned perfectly right from the start. This seems like the correct behavior, since it's also how the same custom textures load in Dolphin. The new build once again requires the textures to be offset.

One last thing is that some custom textures aren't loading consistently after the S2DEX merge, and this is true in the latest WIP build as well. The skybox textures flicker on and off suddenly; the entire skybox is dumping new textures with different filenames, but the old textures still seem to load intermittently. Here's a brief video of the problem: https://youtu.be/PJ5gT6binCA

gonetz commented 5 years ago

@Nerrel It's a bad news :( Everything related to N64 texturing emulation is so complex and fragile. My current goal is to fix all regressions and make new release. Than I'm going to rewrite GLideN64 texturing to make it more friendly to HD textures.

Nerrel commented 5 years ago

Right, I don't expect custom texture fixes until that rewrite, but the mapping/positioning of many of the default textures was also improved by that commit. The ground seam in that first photo also occurs with the original textures, for instance. I just wanted to make a note of that build's fixes in case it wasn't known that it improved Zelda as well.

Will the texture rewrite change the way the way the default textures are handled as well as custom textures?

gonetz commented 5 years ago

for instance. I just wanted to make a note of that build's fixes in case it wasn't known that it improved Zelda as well.

I did not notice that, thanks

Will the texture rewrite change the way the way the default textures are handled as well as custom textures?

Yes. As I understand, the main source of issues with HD textures is the way plugin handles texture wrapping and mirroring. In some cases, plugin does software texture mirroring for tiles loaded from TMEM. Texture loading is full of legacy code, I'm not sure why it was made this way. May be it is a heritage of dark times, when npot textures were not supported by mainstream hardware. I'm going to revise these parts of code.

gonetz commented 5 years ago

@IceLancerSR I'll check, what is wrong with txPath. Please open new task for it. This one is about S2DEX fixes, so I may just forget about your request as it has no separate open task for it.

olivieryuyu commented 5 years ago

can it be closed?

gonetz commented 5 years ago

I think it can