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

VU1 sample syncronization problem #495

Open
Fewnity opened this issue Jan 5, 2024 · 3 comments
Open

VU1 sample syncronization problem #495

Fewnity opened this issue Jan 5, 2024 · 3 comments

Comments

@Fewnity
Copy link

Fewnity commented Jan 5, 2024

I'm currently trying to draw a more detailed 3D model in the VU1 sample. And for this we have to make more packets every frame to render the scene. But this will cause flickering/missing models on real hardware. (we can get the same problem just by adding more cubes to render in the scene).

According to several people, it's a syncronization problem with the VU1. Like I'm sending data while the VU1 is still rendering.
I tried to add a flush to wait for the VU1 but without success. I'm desperate not to find a solution.

Fixing this problem will help people to create a more complexe project by using the sample as a base so I think it's interesting to fix this.
I planned to add PS2 support in a game engine.

PS2 vs PCSX2
image

@F0bes
Copy link
Contributor

F0bes commented Feb 29, 2024

Can you provide minimum reproducible code for this issue? If the issue is what you say it is, you might just need a FLUSHE in your VIFCode (or a bc2t instruction loop).

@Fewnity
Copy link
Author

Fewnity commented Mar 4, 2024

vu1.zip
@F0bes Here is the vu1 sample (the normal one) but with just more cubes. On emulator you can see few cubes blicking and on real hardware a big amount of cubes are not rendered correctly. I tried many fix, I hope someone can figure out how to fix it :/

@F0bes
Copy link
Contributor

F0bes commented Mar 6, 2024

You'll need to optimize, a vblank interval is happening during your drawing because it's too slow.

Here is how I can prove this:

You're doing 1224 cubes.
I used cop0 count and determined that draw_cube call is taking around 5186 cycles on pcsx2. ~9000 on my PS2!

I'll use the PCSX2 number for the math below.

So that's 6,347,664 cycles / frame.
The EE is ~300 Mhz optimistically so that'll take around 0.021 seconds, or 20 miliseconds per frame. (Divide the total cycle count by 300,000,000)
The time per frame (1/60) for 60fps is 16 miliseconds per frame. Faster that what you can render currently.

You can test this yourself, make z only have 12 iterations. This will give you around 14 miliseconds / frame. If you try it on PCSX2, there will be no flickering :)

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

2 participants