As I mentioned in my other post, I am working on recreating as much of the PSX as possible in Verilog to put down on an FPGA. I am currently working on the GPU and need some help. After searching around, I have found that the internals of the GPU as still largely a mystery, and so I have implemented it such that it follows the "ISA" of the original GPU; while my internals are probably very different.
Some pieces are missing and I could use some help with them:
1. The functions used to mix colors (example; texture blending and shading). I have a color from the texture map (in 24-bits RGB (8-bits per channel)) and I now need to scale it appropriately using the RGB arguments given. I have completed the interpolation to get the values of any arbitrary RGB; but I dont know what I now need to do to properly scale (average them?).
2. 24-bit vs 16-bit color mode does not make a whole lot of sense to me. Well, this is more of an addressing problem to be honest. All commands give addresses into VRAM as XY coordinate pairs. If I am in different color modes, does the meaning of XY change? Or are the XY addresses constant such that VRAM is always 16-bit addressed via a unique XY (Well, the PSX's VRAM is actually a 32-bit RAM; so youd cut off the LSB to get the 32-bit address). Simply put, I need a better understanding of how VRAM is addressed.
3. For VRAM to CPU transfers (GP0:0xC0), does the data in GPUREAD update every read or how is the data acknowledged?
I'm sure I'll come up with more as I continue the design. Thanks!
PSX Some of the Operations/How it works
-
- Interested PSXDEV User
- Posts: 5
- Joined: Sep 09, 2013
1. The PSX does modulate with a fixed color scale of 2, that is, rather than the usual (color * color) / 256 it does (color * color) / 128. Just do ((texel_r << 3) * (color_r)) >> 7, possibly add dithering, and then saturate the color. As for blending, the 4 blending modes are (d+s)/2, (d+s), (d-s) and (d+(s/4)).
2. The PSX can only render in 16-bit mode and always address the VRAM in 16-bit pixel coordinates. That is, the display offset address is calculated the same way no matter if the GPU currently display the VRAM as 16-bit or 24-bit color.
3. Yes, it updates every read.
2. The PSX can only render in 16-bit mode and always address the VRAM in 16-bit pixel coordinates. That is, the display offset address is calculated the same way no matter if the GPU currently display the VRAM as 16-bit or 24-bit color.
3. Yes, it updates every read.
-
- Interested PSXDEV User
- Posts: 5
- Joined: Sep 09, 2013
Thanks AmiDog,
I still am a bit confused about some of the commands and how they operate; mostly surrounding textures and shading.
First off, it seems Flat shaping isn't really a thing, its just a shape thats monochrome while a "shaded" polygon or line is always gauraud shaded. Is this correct?
Second, you mentioned blending modes. When you apply a blended texture, do you mix the texture color with the monochrome color according to the semi-transparency mode? (ie GPU_status[6:5])
I still am a bit confused about some of the commands and how they operate; mostly surrounding textures and shading.
First off, it seems Flat shaping isn't really a thing, its just a shape thats monochrome while a "shaded" polygon or line is always gauraud shaded. Is this correct?
Second, you mentioned blending modes. When you apply a blended texture, do you mix the texture color with the monochrome color according to the semi-transparency mode? (ie GPU_status[6:5])
Yes, you can have a single color for the entire polygon (flat) or you specify a color for each vertex (gouraud).
When dealing with a texture, you modulate the texel color with the polygon color, unless the no modulate bit is set. That is, you take the color from the texture and multiply it with the color from the polygon, which may be the same color for all pixels (flat) or interpolated between corners (gouraud). The product is then divided by 128 before applying dithering and saturation. (Se point 1 in my reply above.)
Blending is done as the last step, when writing the pixel to VRAM, that is, after any modulate, gouraud interpolation etc. I.e. you blend the pixel already in VRAM with the final pixel from the polygon.
When dealing with a texture, you modulate the texel color with the polygon color, unless the no modulate bit is set. That is, you take the color from the texture and multiply it with the color from the polygon, which may be the same color for all pixels (flat) or interpolated between corners (gouraud). The product is then divided by 128 before applying dithering and saturation. (Se point 1 in my reply above.)
Blending is done as the last step, when writing the pixel to VRAM, that is, after any modulate, gouraud interpolation etc. I.e. you blend the pixel already in VRAM with the final pixel from the polygon.
Who is online
Users browsing this forum: No registered users and 2 guests