Castlevania : Yami no Juin - Improve the speed and add memory card support
Posted on 2006-07-17 00:00:00
After doing some more tests today, I figured out that the multi-threaded thing isn't that much of a good idea... At least, not for the moment.

In Castlevania, the VIF produces way more data than the GIF/GS can handle during an interval of time and the main emulation thread becomes stuck waiting for more space to be available to store more commands. So, unless we make the GIF/GS processing faster, the multi-threaded approach won't give any speed increase.

I did some quick profiling to see where most of the time was spend during the emulation, and 80%~90% of the emulation time is spent in the GIF/GS subfunctions, while the VIF1 uses at most 5% and the EE 10% : another argument that says that the GIF/GS is the big problem here.

The thing that makes the GIF/GS very slow is all those calls to glTexImage2D in the OpenGL GS handler. If we remove any texture processing, we can get around 10~15 frames per second which is 10~15 times faster than what we got right now. If we disable texture cache invalidation, we get the same speed as if we had disabled any OpenGL texture uploading, without visible problems.

So the solution might lie there... If the textures the game uploads end up being the same as the ones we already have in RAM, there is no point in invalidating the cached textures. So, tomorrow I'm going to try adding a check for changes in the GS RAM when we're transfering a texture and invalidate the cache only if there was a change.