Page 1 of 1
using the .vu elf section
Posted: Tue Jul 26, 2005 8:26 pm
by cheriff
on
http://www.pcs.uklinux.net/id30.htm, it says
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
Posted: Tue Jul 26, 2005 10:22 pm
by Saotome
That's how I'm doing it:
Code: Select all
.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: Select all
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.
Posted: Wed Jul 27, 2005 8:56 am
by cheriff
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
Posted: Wed Jul 27, 2005 10:34 pm
by Saotome
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.
Posted: Fri Jul 29, 2005 1:46 am
by cheriff
Yes, my vu code/data combo is stuffed somewhere...
Code: Select all
; =================================================
; 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: Select all
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)
Posted: Fri Jul 29, 2005 4:24 am
by Saotome
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 ;)
Posted: Fri Jul 29, 2005 10:41 am
by cheriff
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
Posted: Fri Jul 29, 2005 11:04 pm
by Saotome
Nice to hear, that it finally works :)
Posted: Tue Aug 23, 2005 10:00 am
by valar2006