-
Notifications
You must be signed in to change notification settings - Fork 132
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
libpacket2 with VU support #149
Conversation
Very nice! |
Very good job! |
Great, well done! |
Congratulations on your achievement. The VU's make the PS2 one of the most interesting platforms of it's time, but also one of the most difficult to program. However, the code you're proposing is in it's current state not suitable for incusion in ps2sdk. It's a good 'proof-of-concept' or 'hello world', but for inclusion in ps2sdk I think it's not suitable. I'll try to give my thoughts as to why: The heart of the PS2 is the DMA controller. Creating DMA packets is essential, and I think it's an area where the current ps2sdk lacks the most. The "libpacket" library in ee/packet should be a very important library. A part of this PR should probably try to improve libpacket, or create a new super-libpacket, so that it's more easy to manage multiple packets, link them together and send them (using libdma) to the vu1/gs/etc...
Allows for only 1 "dyn_list" at a time. A more "C" object oriented approach would be to have the user manage multiple packets like so:
These could all be in libpacket and libdma I think? There's a lot more packet libraries for the ps2 though. Like in gsKit, it's managing it's own double buffered packets, just like what you've created. But a far more powerfull implementation (in C++ by sony!) is this one: Something like this in "C" would be a perfect "libpacket" for ps2sdk I think. I know this is asking a lot, but I'd rather have the current crappy packet library in ps2sdk, than lots of packet libraries all serving their own purpose. 2 years ago I tried porting libstuff and libgl to ps2sdk. They where both created by sony and are very efficient. They allow the application to use the OpenGL 1.2 interface, and the library takes care of the rest. It has multiple VU1 programs, each one highly optimized for a specific purpose. Sony originally developed this library for their own SDK, and for ps2linux. Becouse of ps2linux it was release opensource. It's tripple-A-game-grade code, so take a good look ;). Would it be an idea to try to fix these 2 libraries and add them as separate git repositories to ps2dev? The OpenGL 1.2 interface would be a lot more easy and full of features for Tyra and others to implement, and you would probably get awesome performance ;) |
Hi Rick. Thank you for your response. Right, your answer allowed me to better understand the current situation. I will try to create a second version of libpacket based on the code you sent me. Be warned that this may take a while - I need to study the EE / DMA documentation thoroughly. |
And on the third day Rick said "remove this vu1.c.., just create better libpacket!", and .... here it is "libpacket2" Hi guys!
I will be greateful for any tips! Everything was tested on emulator&hardware. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work in such a short time!
With some minor changes I'd love to merge this into ps2sdk.
Ok, thats all :) |
Amazing! I've tried to summarize the libraries and API's you're adding:
Instead of
Great!
Great!
I guess this is my mistake, sorry. All these functions have
Change this into somthing like:
Again, only adding data to packet2_t. Then have the user create and transfer the packet. This also removes the dependency to libdma. So as a user of the library I can create a chained packet that first transfers the code, and then transfers the data. All in a single chained packet with a single dma transfer. |
Done :)
|
Great!
These 2 functions don't belong to the "packet2_*" family of functions, becouse they don't do anything with the If there's no comments/reviews/objections from others I'll squash-merge this PR tomorrow. |
I've been experimenting with libpacket2 to see what the library would be like from a user point of view. There's some things missing or not working as easy as I was hoping. I've created this "pseudo code" as an example of how I think the inner loop of the example should be able to work:
NOTE1: I have not used the "vu" part of the library, as I feel constraint in possibilities and efficiency when using it. What do you think? The library is already usefull as it is, but I think it can be made more simple and powerfull. Should I pull it and you/I/we change things later with PR's when needed? One other thing: the |
Hi Rick. I played a little with _vu, and changed it into _utils to emphasize that this is just an addition. So necessary functions, like "upload_micro_program()" was moved out. vu_add() functions was removed. On the client side, packets can be merged via memcpy() (packet2_add()) and reference. Below is the example of that. To be honest, I don't want to make sample too complex. I refactored sample to make 1 dma send per cube, but did it with packet2_add(). Also added print_qws(), print_data() which can be helpful (and was!) with debugging. I think, that is good idea, to add new features in next PRs. This is the big one! :P Thanks! |
The reason that vu1.c had send_matrix() in separate dma packet is the real world scenario. In real world, game is not rendering cube with several vertices, but meshes with 10-20k vertices. In Tyra I'm sending view/proj matrix once per mesh, and after it I'm splitting big 3D mesh into many small packets and sending 2-3 of them at once. Sony recommended about 60 verts at once/buffer, because of VU mem limit. But of course, view/proj matrix can be attached to first small packet of 3D mesh, it is faster. |
Gracias hijo.. |
Hi guys.
After tons of hours that I've spent on PS2, I'm ready to present for you VU1 rendering support in PS2SDK which is the most optimal way to 3D rendering on PS2, which has been used in most games.
Video:
https://www.youtube.com/watch?v=oupamAeUvHs
It was tested on PCSX2 and hardware (ps2link).
I'm not a experienced C/C++ developer, so I will be very grateful for any suggestions and must-do, that can be make.
Features:
Thanks!