| View previous topic :: View next topic |
| Author |
Message |
ps2devman
Joined: 09 Oct 2006 Posts: 271
|
Posted: Mon Oct 29, 2007 12:51 pm Post subject: |
|
|
| Grats! |
|
| Back to top |
|
 |
IronPeter
Joined: 06 Aug 2007 Posts: 207
|
Posted: Mon Oct 29, 2007 5:04 pm Post subject: my plans. |
|
|
I would like to wait few days. Probably, I'll describe 3D initialization on wiki.
After that ( and getting stable cvn hosting ) I want to port some parts of mesa-nouveau ( fragment shader compiler, states setup, textures, buffers ). I want to write some kind of small gl library. Do not want to write memory and resource managers, this library will work in the exclusive mode. I want fragment shader compiler and DXT texture compressor to be standalone utils, not the core of the library. |
|
| Back to top |
|
 |
IronPeter
Joined: 06 Aug 2007 Posts: 207
|
Posted: Tue Oct 30, 2007 4:52 am Post subject: |
|
|
| I edited Wiki, please check grammar. |
|
| Back to top |
|
 |
IronPeter
Joined: 06 Aug 2007 Posts: 207
|
Posted: Tue Oct 30, 2007 6:08 pm Post subject: black rendering issue |
|
|
I was reported about only black rendering on PS3 ( also nouveau has the same issue on PPC, probably, endianness ).
Will try to fix that. It is stopper bug, of course. |
|
| Back to top |
|
 |
IronPeter
Joined: 06 Aug 2007 Posts: 207
|
Posted: Wed Oct 31, 2007 7:30 am Post subject: |
|
|
It is very funny bug, I tame it a bit.
using this shader ( gray output )
static nv_pshader_t nv30_fp = {
.num_regs = 2,
.size = (2*4),
.data = {
/* MOV R0, ( 0.5f, 0.5f, 0.5f, 0.5f ) */
0x01403e81, 0x1c9dc802, 0x0001c800, 0x3fe1c800,
0x3f000000, 0x3f000000, 0x3f000000, 0x3f000000,
}
};
and with endiannes of 3D class setted to 0x0 I was able to get non-black ( gray, as aspected ) rendering. Check svn repo.
The problem is RGBA is converting visually as ABGR on the screen ( probably there is some workaround with that ). Very funny bug. |
|
| Back to top |
|
 |
ralferoo
Joined: 03 Mar 2007 Posts: 122
|
Posted: Wed Oct 31, 2007 6:06 pm Post subject: |
|
|
| IronPeter wrote: | | The problem is RGBA is converting visually as ABGR on the screen ( probably there is some workaround with that ). Very funny bug. |
From reading on the web it seems that most nVidia cards can be driven as either little or big endian. A random dump I found by googling for endianness on nVidia cards seems to suggest that endianness can be specified on a per-object basis for any object that has ENGINE=GRAPHICS in the context: http://people.freedesktop.org/~kmeyer/renouveau_dumps/nv40-00f9/test-nvramht_output.txt.gz
Perhaps the context the hypervisor has created is little endian for some reason? |
|
| Back to top |
|
 |
IronPeter
Joined: 06 Aug 2007 Posts: 207
|
Posted: Wed Oct 31, 2007 6:37 pm Post subject: |
|
|
>Perhaps the context the hypervisor has created is little endian for some reason?
Context objects are big endian ( native for PPC ). For example, screen data blitted by the GPU is big endian.
And as usual, edit Wiki after me, please :). |
|
| Back to top |
|
 |
IronPeter
Joined: 06 Aug 2007 Posts: 207
|
Posted: Thu Nov 01, 2007 3:48 am Post subject: endian issue resolved |
|
|
| check svn repo and Wiki page. |
|
| Back to top |
|
 |
ps2devman
Joined: 09 Oct 2006 Posts: 271
|
Posted: Thu Nov 01, 2007 4:29 am Post subject: |
|
|
| Thx for finding the solution. Keep on the good work! |
|
| Back to top |
|
 |
cypherpunks
Joined: 22 Oct 2007 Posts: 4
|
Posted: Thu Nov 01, 2007 5:14 am Post subject: |
|
|
I made some grammar edits to the wiki. There were some pieces that were unclear to me however, and could use some clarification:
IronPeter, did you create a 3d class from scratch? This is what I understand from this thread and the source code. However the way it is worded on the wiki leads me to believe you found an existing 3d object, or modified an existing object to be a 3d object. Which statement is correct?
Also, the wiki says the Hypervisor makes objects in RAMIN. Is it possible to make objects anywhere other than RAMIN, or is this just a convention of the Hypervisor? I admit ignorance here as to how NVIDIA cards work.
Finally, in the FIFO workaround section where it says "So the hack consists in either patching the last operation with a NOP, or changing the FIFO write pointer to stop earlier." -- shouldn't it be changed to "changing the FIFO write pointer to stop later" since you'll (presumably) be adding commands to the end of the FIFO?
Thanks for all the hard work! I hope to contribute soon as well (once I get ps3toolchain to compile under cygwin.. grrr..) |
|
| Back to top |
|
 |
IronPeter
Joined: 06 Aug 2007 Posts: 207
|
Posted: Thu Nov 01, 2007 5:51 am Post subject: |
|
|
>IronPeter, did you create a 3d class from scratch
Yes, I created 3d class instance from scratch. There is no 3d class instance registered by HV in RAMHT. Probably, there is some HV's call doing that. We did not find that call.
> Is it possible to make objects anywhere other than RAMIN, or is this just a convention of the Hypervisor?
RAMIN is acronym for "the place there graphics objects are stored". This memory has strict format. This format seems to be independent from environment ( HV environment on PS3 or video driver on PC ). |
|
| Back to top |
|
 |
IronPeter
Joined: 06 Aug 2007 Posts: 207
|
Posted: Thu Nov 01, 2007 5:58 am Post subject: |
|
|
>I hope to contribute soon as well
I hope I'll setup OpenRSX project soon. Here, on ps2dev svn. Everybody wellcome to contribute.
Want Glaurung to contribute textures and blend modes :). |
|
| Back to top |
|
 |
ralferoo
Joined: 03 Mar 2007 Posts: 122
|
Posted: Thu Nov 01, 2007 8:56 am Post subject: |
|
|
| cypherpunks wrote: | | Finally, in the FIFO workaround section where it says "So the hack consists in either patching the last operation with a NOP, or changing the FIFO write pointer to stop earlier." -- shouldn't it be changed to "changing the FIFO write pointer to stop later" since you'll (presumably) be adding commands to the end of the FIFO? | No, it is correct as is.
Think of it as:
| Code: |
rptr: opA
opB
opC
x: END //stop processing, wait for hypervisor to restart GPU
eptr:
|
The GPU processes instructions sequentially from rptr (think PC in a CPU) from an instruction queue. Unlike a CPU, when rptr==eptr it waits until eptr changes so that more instructions can be added to the end of a list of instructions. The benefit of this is that it decouples the GPU execution flow from the rate of instruction generation on the CPU. With a conventional CPU, you'd need to create blocks of instructions with an END and only once the entire block had been created could you let the GPU execute it. That method would require the CPU to keep polling the GPU to figure out what it's up to, this approach allows the CPU to create instructions and assume they will get done soon.
So, now you understand that, the hack is the prevent execution of the END instruction, because restarting the GPU is a privileged hypervisor operation. Either of the two techniques have the same effect (either setting wptr to x or replacing the END with a NOP) - the GPU never executes the END instruction and so continues to wait for the wptr to change again before it continues reading instructions. By never ending the list of instructions, the GPU is always waiting for us and so we never need the hypervisor to kick start the process again.
To add our own instructions to the command queue, we formulate a block of instructions, writing them to the next available position in the queue. Then, we update wptr to point to the next instruction after the last one. This means the GPU notices it can continue processing and executes up to the last one.
The next question is that what happens when we get to the end of this buffer. After all, it's only 64k long. The answer is that the GPU has a JMP/branch instruction just like a CPU. So, when we're close to running out of space, we jump back to the start of the FIFO buffer and repeat the process. There are GPU pre-fetch bugs that mean you need to target the jump into a block of NOPs, but this isn't a major problem.
Hope that helps you make sense of this! |
|
| Back to top |
|
 |
Warren
Joined: 24 Jan 2004 Posts: 175 Location: San Diego, CA
|
Posted: Thu Nov 01, 2007 10:05 am Post subject: |
|
|
| Great post ralferoo! Thanks for the overview. |
|
| Back to top |
|
 |
ps2devman
Joined: 09 Oct 2006 Posts: 271
|
Posted: Thu Nov 01, 2007 6:43 pm Post subject: |
|
|
There is, technically, a way to branch to sub fifo buffers (of any size).
But that implies to know what services the interrupt handler associated to the GPU interrupt can do. Once again, I will describe what happens with nv2A on xbox 1.
In the main fifo sequence you just put a fire interrupt command with a data code that says "please remember this address+n (return address)".
Then you put a jump command after that, to the sub fifo buffer (usually already filled with pre-calculated insanely long commands to achieve top speed). At the end of the sub fifo buffers (let's consider it as a kind of subprogram or procedure), you put a fire interupt command with a data code that says "return" followed by a jump (which address will be updated). So the interrupt handler has 2 data code that allows to remember the return address or to setup up the jump adress with the remembered return address (in order to effectively do the "return").
Plenty of magnificent tricks (like the "fences" mechanism, a kind of sync between CPU and GPU for many specific purposes) can be done once you know (or better, can edit) the interrupt handler. Not the case on PS3 of course... But maybe someday, someone will be able to just "read" the HV code and will tell us what services already offers the current interrupt handler. Useless to say it's also very useful to be able to understand error reports made by GPU (reported through the same interrupt handler) when you make a mistake when you write a wrong sequence of command somewhere in fifo buffer (better than a black screen saying nothing). |
|
| Back to top |
|
 |
IronPeter
Joined: 06 Aug 2007 Posts: 207
|
Posted: Fri Nov 02, 2007 5:47 am Post subject: small update |
|
|
| textured triangle in the repo. Just 10 minutes work. |
|
| Back to top |
|
 |
cypherpunks
Joined: 22 Oct 2007 Posts: 4
|
Posted: Fri Nov 02, 2007 6:07 am Post subject: |
|
|
Thanks for the detailed explanation ralferoo! It makes perfect sense now. If you don't mind, later today I'll expand that section in the wiki to include parts of this discussion, and maybe an example FIFO queue to illustrate it.
PS: IronPeter, that's great news! |
|
| Back to top |
|
 |
IronPeter
Joined: 06 Aug 2007 Posts: 207
|
Posted: Fri Nov 02, 2007 6:34 am Post subject: |
|
|
cypherpunks, resolution ot the endian issue was great ( nouveau did not handle big endianness ).
Proper texturing is just an expected behavior. |
|
| Back to top |
|
 |
IronPeter
Joined: 06 Aug 2007 Posts: 207
|
Posted: Fri Nov 02, 2007 7:06 am Post subject: another small feature |
|
|
| Setup of depth buffer. Just for fun this buffer is mapped into visual screen area. |
|
| Back to top |
|
 |
ps2devman
Joined: 09 Oct 2006 Posts: 271
|
Posted: Sat Nov 03, 2007 1:03 am Post subject: |
|
|
Fantastic! You did it! Shaders running on PS3!!! Thx IronPeter!
Time to adapt this for other os demo... (come here free time!)
PS3 owners who love coding will have wonderful Xmas holidays!
(beware to next firmware upgrade though...) |
|
| Back to top |
|
 |
IronPeter
Joined: 06 Aug 2007 Posts: 207
|
Posted: Sat Nov 03, 2007 4:04 am Post subject: |
|
|
ps2devman, thanks a lot.
>Shaders running on PS3!!!
also there are textures and working depth test :). I've updated demo, now it shows 3 Z-overlapping triangles.
So at this moment we have
1.) working shaders, both pixel and vertex
2.) working textures
3.) working Z test.
We need
1.) Renderstates like blend, different Z modes, alpha test. - easy
2.) Index and vertex buffers. - a bit more harder.
3.) Texture support with differenet formats, mips, swizzling. - more harder
4.) Some shader compiler ( microcode is very hard to maintain ). - hard.
I want to setup ps2rsx project soon. Probably, this week-end, |
|
| Back to top |
|
 |
ps2devman
Joined: 09 Oct 2006 Posts: 271
|
Posted: Sat Nov 03, 2007 8:11 pm Post subject: |
|
|
I will try to give a hand with 4).
The idea is to do something similar to function pcode2mcode in pbkit.
It translates standard shaders written in pseudo code into native code.
That way public compiler Cg.exe could be used and you just include the binary (pseudo code) result in your code, then function pcode2mcode does all the translation work automatically.
Dunno if Cg.exe is good enough for the level of shader models we need.
Also need to look again all the files of Nouveau project... They surely ran into this trouble already and they may have found best solution already. |
|
| Back to top |
|
 |
ps2devman
Joined: 09 Oct 2006 Posts: 271
|
Posted: Sat Nov 03, 2007 9:52 pm Post subject: |
|
|
I would like to talk about performance (because we talk about shaders).
There are persistent rumours that claim that the 360 Xenos is faster than RSX. Of course, now, we are getting closer to the answer, since we will be able to count the number of vertex per frame we can enqueue (when vertex buffer mechanism will work).
Thanks to tmbinc, we could see that, currently, homebrew on 360 can expect, at least, 3.900.000 v/f at 60 fps with minimal shader (no lighting, just simple texture projection) and 3.100.000 v/f at 60 fps with gouraud lighting (1 source). The same kind of performance loss has been seen with other gpu's even if they are slower (xb1 -330.000-, ps2 -250.000-).
I think the goal, would be to have higher performance on PS3, since the machine costs more. If RSX alone is slower, then we have to use SPU's to get a smart solution. Actually the clue, I think, are the shaders. The more sophisticated they are, the more we lose performance.
So, since we are to think about compiling shaders, here is a paradox :
Maybe we shouldn't spend too much time working on sophisticated shaders. What we may try to do is to have SPU's do the preliminary calculation work and data flow towards shaders, in order to have minimal and fastest shaders running on the RSX... It's certainly unusual strategy (but remembers me vu1 working for GS on ps2). |
|
| Back to top |
|
 |
rapso
Joined: 28 Mar 2005 Posts: 148
|
Posted: Sat Nov 03, 2007 10:05 pm Post subject: |
|
|
As long as you don't really know the performance charasteristics, it's no good to already make assumption on ways to improve performance. what if the basic performance on PS3 is bad, but it loses less performance on more sophisticated shader?
I think that even with homebrew going on it will take quite a long time to figure out how the performance really is and why. |
|
| Back to top |
|
 |
IronPeter
Joined: 06 Aug 2007 Posts: 207
|
Posted: Sun Nov 04, 2007 12:21 am Post subject: |
|
|
There is official geometry proccessing tool Edge from Sony. You can google for Edge specs ( it is open info ).
This tool does vertex processing on SPU. Skeletal animation, even back face culling. I tried to write some back face culling code. Pretty fast on the single SPU. One single SPU can provide RSX with geometry. Two SPUs can flood the graphic chip.
RSX has two memory channels - DDR and XDR. XDR memory contains push buffer and is good for dynamic spu-generated geometry. DDR memory is for render targets and textures.
The main perfomance ( just perfomance, not the core functionality ) issue, as for me, is TILE and ZCOMP setup. You can refer pbkit ( thanks to ps2devman ) or nouveau project for details.
I do not know the way to setup it from FIFO interface. pbkit and Nouveau do this setup via mmio regs. I have no ideas how can we access global GPU mmio regs. |
|
| Back to top |
|
 |
ps2devman
Joined: 09 Oct 2006 Posts: 271
|
Posted: Sun Nov 04, 2007 1:49 am Post subject: |
|
|
Don't worry we will find a way, even if it takes months to find it.
If we can have vertex buffers running, that will be already heaven.
I have the feeling the interrupt handler is the key. Since it's used to report gpu errors, I don't think it doesn't exist in HV, and I'm pretty sure, Sony engineers were lazy to strip unused/dangerous services from it.
We can try to observe existing shaders for any unusual command that would be an access request to mmio from fifo. On nv2A (xb1) it's used to disable/enable the noise flag for compressed texture, for example, right from within the command sequence in the fifo (push buffer). |
|
| Back to top |
|
 |
IronPeter
Joined: 06 Aug 2007 Posts: 207
|
Posted: Sun Nov 04, 2007 5:20 am Post subject: |
|
|
ps2devman, yes. The TILE and ZCOMP setup is not critical task for us.
I have working vertex buffers. With some issues.
The problem is index buffer. I was unable to find any info about index buffer in the nouveau docs. I have not PC with NV40 and linux installed to make fifo dump with gl
DrawElements call :(.
It is great if somebody can do that dump.
Edit: Vertex buffer works fine, both in XDR or DDR memory, issues were resolved. |
|
| Back to top |
|
 |
ps2devman
Joined: 09 Oct 2006 Posts: 271
|
Posted: Sun Nov 04, 2007 4:41 pm Post subject: |
|
|
I'm speechless... It's heaven. Thanks a lot IronPeter!
For index buffer, I don't know well enough nv40 yet, but you can see how it is done in nv20 by looking at pbkit Demo 04. There are constants in the source to define in order to have rendering by index buffer instead of vertex buffer. Also by looking at the name of the nv20 constant, you may discover how will be named the nv40 constant that does the same.
However, for me, it's heaven... Since I plan to have same homebrew game sources compile for ps3, 360, xb1 and ps2. Since ps2 doesn't support at all index buffers, I planned to use vertex buffers only anyway.
Anyway, I will send an e-mail to Nouveau project leader, to be sure he knows what point you reached. He should be able to give us nice infos.
(And Nouveau project members often have nv40 card and Linux dumper) |
|
| Back to top |
|
 |
IronPeter
Joined: 06 Aug 2007 Posts: 207
|
Posted: Mon Nov 05, 2007 1:21 am Post subject: SVN repo on ps2dev |
|
|
I've created ps3rsx project. Excuse some delay.
For now there is only one project inside this repo - a bit modified example with 3 triangles. z buffering, textures, vertex and pixel processing, vertex buffers.
I want to have full-scale 3D library. src folder is empty for now :).
project will have MIT license.
SVN repo:
http://svn.ps2dev.org/listing.php?repname=ps3ware&path=%2Ftrunk%2Flibps3rsx%2F&rev=0&sc=0
fill free to commit. |
|
| Back to top |
|
 |
ngharo
Joined: 26 Oct 2007 Posts: 4
|
Posted: Mon Nov 05, 2007 2:49 am Post subject: |
|
|
| IronPeter wrote: | The problem is index buffer. I was unable to find any info about index buffer in the nouveau docs. I have not PC with NV40 and linux installed to make fifo dump with gl
DrawElements call :(.
It is great if somebody can do that dump. |
I have a friend with a GeForce 6800 that I could borrow to complete a FIFO dump. Only, I don't know how :( Let me know if I can help. |
|
| Back to top |
|
 |
|