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

PS2 Optimisations #18

Open
TheMrIron2 opened this issue Dec 15, 2017 · 8 comments
Open

PS2 Optimisations #18

TheMrIron2 opened this issue Dec 15, 2017 · 8 comments

Comments

@TheMrIron2
Copy link
Contributor

Some future ideas for more optimal circumstances on PS2:

  • The PS2 GPU memory is fast enough to flush and refill textures multiple times per frame, according to the developers of Metal Gear Solid 2 - who had up to 10MB of textures on-screen at times inside the 4MB VRAM (total, not including memory used for buffers). It may be possible to use similar techniques to achieve better results in this demo.
  • I feel better looking textures could be used with the above method and storing these in the main 32MB RAM and sending them to the GPU as needed - the PS2 has a 3.6GB/s memory bus so the potential is undoubtedly there.
  • Using recent gsKit tools available on github may also give the code some cleaner syntax and possibly expand the available libraries?
  • Different video modes; I would say that a 640x448i mode and a 640x480p mode would be optimal, however 640x540 at 1080i would also be very interesting - a few games used this for a 1080i mode, and this could look great on HDTVs possibly with antialiasing.

Keep this project up, though. It's nice to see demos like this arise on the PS2. I recommend you check out the gsKit "hi-res" sample code for an idea of what you might be able to do - this seems like a relatively simple scene, and one programmer was able to get a rotating 3D teapot running at native 1920x1080, a 1920x1080 background texture and all with antialiasing at 60FPS. Would be cool to see some improvements here from code like that.

@TheMrIron2
Copy link
Contributor Author

Oh and a footnote; the emulator statistics are telling me that GPU is below 10% for the majority of the time, sometimes spiking to just under 15%, and the CPU load is in the 50% region for most of the time (~25% at lowest, ~60% at highest). The vector units are completely unused (perhaps you could use these for on-the-fly decompression or geometry?). Just thought I would mention the statistics in case it helps.

@kosua20
Copy link
Owner

kosua20 commented Dec 27, 2017

This was my first PS2 homebrew tentative, so I have surely missed some best practices and more complex techniques :-). I discovered the PS2 hardware during this project, so I didn't feel confident enough to immediately use the VUs and juggle with RAM/VRAM per-frame. I've stayed close to the basic examples available w/ gsKit and other resources on the web, there is clearly room for many improvements!
Thank you for all these details and suggestions, and for your pull requests!

@TheMrIron2
Copy link
Contributor Author

TheMrIron2 commented Dec 27, 2017

No problem. I've been trying to get this demo running at a close to HD resolution (960x720 or 720x1080) single buffered but I haven't had the time to finish it. I'll submit another pull once I've done so!

@TheMrIron2
Copy link
Contributor Author

In the meantime, a note; by lowering the bit depth of images (textures etc.) and the framebuffer itself (ie. to 16-bit) you save a significant amount of memory. For example:
640x448x24 (24-bit): 6881280
640x448x16 (16-bit): 4587520

You can see you could probably get away with nicer textures and higher resolution by finding a sweet spot with colour/bit depth.

@kosua20
Copy link
Owner

kosua20 commented Dec 31, 2017

Thank you, that's great! I won't have the time to come back to this demo in the next few weeks, but I will try to see how I can better use the freed RAM/VRAM in order to improve the quality of the textures and the rendering resolution.

@TheMrIron2
Copy link
Contributor Author

No problem. I haven't had time to compile this and I think some of the code expects certain bit depths for different textures, so I think it'll require a bit of trial and error with a working ps2sdk to get it working correctly.

@TheMrIron2
Copy link
Contributor Author

TheMrIron2 commented Mar 9, 2018

Something I forgot to mention months ago and remembered when I saw this on my homepage; here's a fundamental thing about PS2 hardware design - the VRAM is not meant to be used for storing textures. The VRAM is purely for pixel data (eg. framebuffers). The 32MB of main RAM is main RAM, but the bus between it and the GPU is specifically designed to be able to zip textures from RAM to the GPU. So essentially, you could have many more textures at a higher resolution than what you could fit in 4MB. When/if you get the time I'd recommend looking into that so you could use stupidly large textures at high resolutions.

Dumb of me to overlook such a thing, but I digress 😅

@Fewnity
Copy link

Fewnity commented Feb 20, 2024

A VU1 sample would be awesome! We need more VU1 sample in the ps2 scene

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

No branches or pull requests

3 participants