 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
cheriff Regular
Joined: 23 Jun 2004 Posts: 262 Location: Sydney.au
|
Posted: Tue Jul 26, 2005 8:26 pm Post subject: using the .vu elf section |
|
|
on http://www.pcs.uklinux.net/id30.htm, it says | Quote: | | Like all VCL code files, we have a --enter--endenter block, and a --exit--endexit block. These can do handy things for us when we integrate VU microcode into a larger program. However, I don't think there's anything clever they can do for us in this competition, so I'll leave them for now. Just use them to mark the start and end of your code. |
Wich got me thinking.. I currently do things like this:
.vsm --(dvp-as)--> .o --(dvp-objcopy)--> .bin --(bin2c)--> .c --(ee-gcc)--> .o
and link that into my project.
I played around a bit and found that dvd-as's .o will happily link with ee-gcc into the final .elf since everything lives within the .vu section, so that's fine.
My problem is, how do I find this memory when running the elf? I assume it's some .PROVIDE in the linker script which I can then use as extern pointers, but am clueless on how to do that.
Any help? thanks,
-cheriff _________________ Damn, I need a decent signature! |
|
| Back to top |
|
 |
Saotome

Joined: 03 Apr 2004 Posts: 182
|
Posted: Tue Jul 26, 2005 10:22 pm Post subject: |
|
|
That's how I'm doing it:
| Code: |
.global testVu0Code
.global testVu0CodeEnd
.global testVu0Data
.global testVu0DataEnd
.vu
testVu0Code:
nop iand vi15, vi00, vi00
nop lqi.xyzw vf02, (vi15++)
nop lq.xyzw vf03, 0(vi15)
add.xyzw vf01,vf02,vf03 nop
nop sq.xyzw vf01, 0(vi00)
nop[e] nop
nop nop
add[E].xyz vf15,vf15,vf16 nop
add.xyz vf17,vf17,vf18 nop
testVu0CodeEnd:
.data
testVu0Data:
dummydata:
.int 0,0,0,0
.int 0,0,0,0
testVu0DataEnd:
|
Then I'm linking the .o-file from dvp-as to the final .elf.
In the main.c :
| Code: |
extern u8 testVu0Code __attribute__((section(".vudata")));
extern u8 testVu0CodeEnd __attribute__((section(".vudata")));
...
...
//start it with my "vulib"
vu0UploadCode(&testVu0Code, (&testVu0CodeEnd - &testVu0Code), 0, 1);
vu0Start(0);
vu0Wait();
|
here's my code i'm using to upload the vu-code. _________________ infj |
|
| Back to top |
|
 |
cheriff Regular
Joined: 23 Jun 2004 Posts: 262 Location: Sydney.au
|
Posted: Wed Jul 27, 2005 8:56 am Post subject: |
|
|
Ahh, nice. that's exactly what I was looking for. thanks!
Also, it was your vulib that even got me this far in the first place, so thanks!
One Question, though:
I'm using the graph functions from ps2sdk to setup the screen and stuff then my main loop
while(1){
graph_clear_screen(0,0,0);
vu1Start(0);
vu1Wait();
graph_wait_vsync();
}
And it displays fine (just the simple triangle demo) but the loop only happens 2 (sometimes 3) times. After chucking printf's around everything, i found that the vu1wait() never returns.
this also happens with/without various combinations of the clear screen and vsyng functions...
thanks
- cheriff _________________ Damn, I need a decent signature! |
|
| Back to top |
|
 |
Saotome

Joined: 03 Apr 2004 Posts: 182
|
Posted: Wed Jul 27, 2005 10:34 pm Post subject: |
|
|
| cheriff wrote: | | ...Also, it was your vulib that even got me this far in the first place, so thanks! |
always nice to hear that people find it usefull :)
| cheriff wrote: | ...but the loop only happens 2 (sometimes 3) times. After chucking printf's around everything, i found that the vu1wait() never returns.
|
Are you sure that it's not something else (for example the vu program)? I don't know that triangle demo you're talking about, but I have tested some vu1 mpg's and it seems to run fine. One of them was processing some particles and putting them as "points" on the screen. There was no problems with the vu1Wait() (only once with the vu0Wait but I fixed that some months ago).
All vu1Wait() does is doing a loop using the "BC2T" instruction (branches if COP2 conditional signal is TRUE, i.e. VU1 is activated).
here is one working demo with vu1Wait() :
the elf, and the source. _________________ infj |
|
| Back to top |
|
 |
cheriff Regular
Joined: 23 Jun 2004 Posts: 262 Location: Sydney.au
|
Posted: Fri Jul 29, 2005 1:46 am Post subject: |
|
|
Yes, my vu code/data combo is stuffed somewhere...
| Code: | ; =================================================
; flowMon::Emit() vcl 1.4beta7 produced this code:
.vu
.align 4
START:
; _LNOPT_w=[ normal2 ] 4 [2 0] 4 [START]
NOP iaddiu VI01,VI00,0
NOP xgkick VI01
NOP[E] NOP
NOP NOP
.align 4
; iCount=4
; register stats:
; 2 VU User integer
; 0 VU User floating point
|
and | Code: | u64 myVudata[10];
int i = 0;
// qword 0
myVudata[i++] = GIF_SET_TAG( 2, /* NLOOP */
0, /* EOP */
1, /* PRE */
GIF_SET_PRIM(6, 1, 0, 0, 0, 0, 0, 0, 0),
GIF_TAG_PACKED,
2); /* NREGS*/
myVudata[i++] = 0x51 ; /* RGBAQ and XYZ2 */
// qword 1
myVudata[i++] = 255;
myVudata[i++] = 0; /* RED */
// qword 2
myVudata[i++] = ((x-100)<<4) | (u64)((y)<<4) << 32;
myVudata[i++] = 0x0400;
// qword 3
myVudata[i++] = 0;
myVudata[i++] = 255; /* BLUE */
// qword 4
myVudata[i++] = ((x+100)<<4) | (u64)((y+20)<<4) << 32;
myVudata[i++] = 0x0400; |
It does draw a blue rectangle for me (the red is leftover from when this was a coloured triangle)
But both times around, it hangs after only 2 frames. (but in your code i cant even see the sprite) _________________ Damn, I need a decent signature! |
|
| Back to top |
|
 |
Saotome

Joined: 03 Apr 2004 Posts: 182
|
Posted: Fri Jul 29, 2005 4:24 am Post subject: |
|
|
| cheriff wrote: | | ...but in your code i cant even see the sprite |
You mean you can't see anything when you start it? Hmm, did you try the already compiled elf? It runs fine on my PS2. It's a PAL, don't know if this could be a problem (?), it should detect and set everything to ntsc automaticaly. Ok, it's my own gs-lib and didn't test it on NTSC so... ;P
But back to your sample/problem:
Shouldn't you set the EOP flag in the GIF tag?
I guess the second xgkick might be stalled (so the VU1-MPG doesn't return), because the first transfer is not finished correctly (because of the EOP). EOP=0 means after the first GIF tag and data comes another GIF tag, but you're just sending one GIF tag + data. I'm not realy sure, but give it a try ;) _________________ infj |
|
| Back to top |
|
 |
cheriff Regular
Joined: 23 Jun 2004 Posts: 262 Location: Sydney.au
|
Posted: Fri Jul 29, 2005 10:41 am Post subject: |
|
|
Sorry, I meant that your elf and compiled source runs perfect (very nice, btw!) but when i splice in my vu data/code it craps out, same as mine... Am gonna try EOF in the tag now... stay tuned!
EDIT (2 mins later): woo-hoo! that did it. How annoying that simply flipping one bit, and it look me 3 days to figure out :)
Well thanks for all your help, and sample code too! Now it's time to see if maybe I can't get something a little more prettier outta this thing..
cheers,
cheriff _________________ Damn, I need a decent signature! |
|
| Back to top |
|
 |
Saotome

Joined: 03 Apr 2004 Posts: 182
|
Posted: Fri Jul 29, 2005 11:04 pm Post subject: |
|
|
Nice to hear, that it finally works :) _________________ infj |
|
| Back to top |
|
 |
valar2006
Joined: 22 Jul 2005 Posts: 1
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|