What happens when you write to GP0 when the GPU is busy?

Graphic based area of development (Graphics Processing Unit), including the Geometry Transform Engine (GTE), TIM, STR (MDEC), etc.
Post Reply
mistershrubber
What is PSXDEV?
What is PSXDEV?
Posts: 4
Joined: August 4th, 2014, 1:41 pm

What happens when you write to GP0 when the GPU is busy?

Post by mistershrubber » August 4th, 2014, 1:44 pm

Hey guys,

I'm working on a PSX project and I was wondering: what happens when you write to GP0 when the GPU is not ready to receive a command weird? Does what you write go to a buffer and gets processed later? What if the buffer is full? Or does it just get discarded?

Thanks in advance!

AmiDog
Active PSXDEV User
Active PSXDEV User
Posts: 53
Joined: September 7th, 2012, 11:51 pm

Re: What happens when you write to GP0 when the GPU is busy?

Post by AmiDog » August 5th, 2014, 6:35 am

First of all, there is a 16-word command buffer, so it's always safe to write 16 values to GP0. The GPU will fetch commands from the buffer until it's empty. However, the GPU is a superscalar design, which make things somewhat more interesting. It seems to be able to fetch and process up to two commands from the buffer at once, so you can usually write two full commands + 16 additional words to GP0 without messing things up. If you perform too many writes, you will end up overwriting the beginning of the buffer.

I'm abusing this in a silly demo I wrote where I write block-fill -> sprite -> block-fill -> lots-of-nops to GP0. The first two commands will be processed, while the second block-fill, which remained in the buffer, will be overwritten by the nops. This produces a sprite on real hardware while all emulators I've tried renders all commands and just give a black screen...

mistershrubber
What is PSXDEV?
What is PSXDEV?
Posts: 4
Joined: August 4th, 2014, 1:41 pm

Re: What happens when you write to GP0 when the GPU is busy?

Post by mistershrubber » August 5th, 2014, 6:49 am

Thank you very much for your answer! That clarified a lot of open questions I had in one go :) Especially the part of the buffer being circular (if I understood correctly that is how you are overwriting the whole buffer with NOPs while the first two commands are being processed) is very interesting.

Thanks again!

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest