REDRIVER2 icon indicating copy to clipboard operation
REDRIVER2 copied to clipboard

[PsyX] macOS support (Metal)

Open zhmrsk opened this issue 1 month ago • 4 comments

Hello everyone!

I understand that the developers clearly stated that macOS is not considered a target platform. This is due to Apple dropping support for i386 code.

So, my idea was to "port" the 32-bit code to 64-bit. I have no programming experience; the entire code modification was done over a couple of evenings in Antigravity.

The goal was to run Redriver on macOS 26 Tahoe using an Apple Silicon M1 Pro processor.

Since there were issues with OpenGL, I decided to integrate Metal.

I can't say exactly how many changes were made to the code or how radical they are, but I am ready to share the current result:

All the gameplay mechanics work perfectly: collisions and missions. The only thing that still requires attention is the graphics. Right now, I am concerned about the random disappearance (or "popping out") of road, object, and building textures. I attribute this to an incorrect, chaotic texture loading process. Wireframe mode allowed me to see that when textures for nearby objects disappear, objects in the distance are being loaded.

There is also a problem with PGXP. It is clearly broken, as polygon vertices are being stretched chaotically towards the sun (I'm not sure if the anchor point is specifically the sun, though).

I would be happy to contact the mod developers and continue working together. At the very least, it would greatly help me to correctly identify the problem so I can localize it.

I'm attaching screenshots of the game's operation below:

PGXP: OFF Image PGXP: ON Image Wireframe Image Texture drops: Image Image

zhmrsk avatar Nov 22 '25 08:11 zhmrsk

Hi! Compiling to 64 bit targets is already supported both by game and PsyX, Linux builds are already present in my develop-SoapyMan branch. So there should be little to no additional work to make it build and run on ARM64. PGXP graphics artefacts clearly display that there is a problem with PGXP vertex cache lookup as it was tightly integrated with current GL renderer.

How PGXP-Z works: PGXP-Z in PsyX works in the way it generates and caches half-float XY coordinates and float XYZ world coordinates mapped to this XY during GTE transformation. Note that while XY coordinates has are in screen space (has perspective transform), XYZ werent transformed by GTE perspective matrix - it is done later in vertex shader to eliminate texture and vertex warping and also provide correct depth. Then when drawing polygon the renderer will lookup this XY hash and will pass matching XYZ coordinates to the GL renderer and shader will make proper perspective transform. I can see that here might be happening massive PGXP cache misses and second that there would be incorrect perspective matrix passed to shader. Clearly this needs some investigation both in code and through GPU debugging tools.

Other than that, you’re doing a great job despite no programming experience!

SoapyMan avatar Nov 22 '25 12:11 SoapyMan

@SoapyMan Eventually, I abandoned the idea of using Metal. OpenGL is quite viable since I am still encountering a problem where the Skybox renders in front of the 3D world. If I disable the Z-buffer (F6), the image stabilizes.

Another issue bothering me is textures disappearing in specific locations. When I drive to specific points, specific textures vanishю I think is PVS issue. I haven't collected hard data, but based on objective observations, the problem is not random; it is quite consistent. In one implementation, I managed to fix this by disabling texture unloading from memory. Meaning, everything behind the camera remained loaded, but the textures didn't disappear.

Image

Also, on Metal, the background image didn't display during level loading, although the progress bar was moving. On the plus side, there were no rendering artifacts with the map outlines or the damage bar.

I would appreciate the opportunity to reach out to you if necessary. I am contacting you because I’ve exhausted all my theories, and information in open sources is insufficient. Thank you.

zhmrsk avatar Nov 27 '25 14:11 zhmrsk

The PVS bug you observing here was fixed in https://github.com/OpenDriver2/REDRIVER2/commit/f37a4daf0f9efa512b896dad318fa4686743ded1 develop-SoapyMan few days ago

SoapyMan avatar Nov 27 '25 15:11 SoapyMan

You can join us on Driver Madness Discord (https://discord.com/invite/driver), I’m active here and try to help quicker with remaining issues

SoapyMan avatar Nov 27 '25 16:11 SoapyMan