 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
Shazz

Joined: 31 Aug 2004 Posts: 244 Location: Somewhere over the rainbow
|
Posted: Thu Dec 16, 2004 8:56 pm Post subject: Optimising VIF transfers |
|
|
Hello,
I've got a question about VIF->GIF DMA packets optimisation, currently I'm sending to the VU a bunch of 4 vertices geometry information (ST RGBAQ XYZ2)*4 after the TEX01 texture information
So I was wondering, why only 4 ? As I'm using Triangle strips, why not sending in one paquet 40 vertices and associated data ? I've got 16Kb to fill !
But as I need to fill the NREGS register, it only permits me to send 16 different GIF registers so how can I send 40*3+1 = 121 regs in one packet ? Should I resend a GIF tag/PRIM each 16 regs ?
And is it obvious that this is better to send few large VIF packets after having computing all geometry information than lots of "small" ones but non blocking and doing MIPS computation within dma sends...
Hope I'm clear enough...
| Code: |
*((u64*)p_data)++ = DMA_CNT_TAG( 14 );
// VIF_CODE(CMD,NUM,IMMEDIATE)
*((u32*)p_data)++ = VIF_CODE( VIF_STCYL,0,0x0404 );
*((u32*)p_data)++ = VIF_CODE( VIF_UNPACK_V4_32,14, 4); //14 blocks 4*u32, starting at index 4
// GIF_TAG(NLOOP,EOP,PRE,PRIM,FLG,NREG)
// GS_SETREG_PRIM(prim, iip, tme, fge, abe, aa1, fst, ctxt, fix)
*((u64*)p_data)++ = GIF_TAG( 1, 1, 1, GS_SETREG_PRIM( GS_PRIM_PRIM_TRISTRIP,
1, 1, 0, 0, 0, 0, 0, 0 ), 0, 13 );
*((u64*)p_data)++ = (u64)(0x5125125125126);
// NREGS : XYZ2 RGBAQ ST XYZ2 RGBAQ ST XYZ2 RGBAQ ST XYZ2 RGBAQ ST TEX01 from right to left
...
|
_________________ - TiTAN Art Division -
http://www.titandemo.org |
|
| Back to top |
|
 |
Saotome

Joined: 03 Apr 2004 Posts: 182
|
Posted: Thu Dec 16, 2004 9:52 pm Post subject: |
|
|
the NREG registers in REGS are repeated NLOOP times. so actually you just need to write "XYZ2 RGBAQ ST" once into REGS and set NLOOP to 40 and send your 40(x3) values.
you can find this on page 143 in the EE user's manual ("5.4 REGLIST Mode") _________________ infj |
|
| Back to top |
|
 |
Shazz

Joined: 31 Aug 2004 Posts: 244 Location: Somewhere over the rainbow
|
Posted: Fri Dec 17, 2004 1:54 am Post subject: |
|
|
Yeeeh you're right, how I missed that ?
And for the TEX01 register how can I pass it only one time as it is part of sub PRIM registers ? _________________ - TiTAN Art Division -
http://www.titandemo.org |
|
| Back to top |
|
 |
blackdroid
Joined: 17 Jan 2004 Posts: 564 Location: Sweden
|
Posted: Mon Dec 20, 2004 6:30 pm Post subject: |
|
|
you can send giftags directly to gif via vif, so in your vifstream you could start with VIF[DIRECT] and then the GIF tags you want, then continue with VIF[MPG]/VIF[UNPACK] _________________ Kung VU |
|
| Back to top |
|
 |
emoon

Joined: 18 Jan 2004 Posts: 91 Location: Stockholm, Sweden
|
Posted: Mon Dec 20, 2004 10:11 pm Post subject: |
|
|
This is usually good when you want to set "renderstates".
change alpha/active texture/turn off zbuffer testing/etc
.emoon |
|
| Back to top |
|
 |
Shazz

Joined: 31 Aug 2004 Posts: 244 Location: Somewhere over the rainbow
|
Posted: Tue Mar 01, 2005 10:41 pm Post subject: |
|
|
Eh eh during the Iradium party last weekend I have decided to write a 64K based on my former VU code...
Speaking about that I had some issues with the PBDemolib, especially with the TextureUpload. I had to rewrite mien as if you use the TextureUpload for example at each frame to make a kind of 2D effect (modifying a bitmap buffer and send it as a texture) it was freezing (probably a pb of memory allocation, I wrote a textureupload using the same buffer and not doing sprAlloc each time... ) so emoon, I'd like to have your feedback...
But thinking about it, I saw that raizor, emoon, jar were using the renderTargets to code some kind of blur and radial effects but I really did not understand anything of how it is working....
Can anybody explain me how it works and the things behind ???
Thanks _________________ - TiTAN Art Division -
http://www.titandemo.org |
|
| Back to top |
|
 |
blackdroid
Joined: 17 Jan 2004 Posts: 564 Location: Sweden
|
Posted: Thu Mar 03, 2005 1:12 am Post subject: |
|
|
you render to some offplace in vram by setting the fbp, then you change the fbp to your "normal" frame buffer and use the rendered offplace as texture and draw it.
or maybe you are really wondering about the builtin frame blur in the pcrtc ? _________________ Kung VU |
|
| Back to top |
|
 |
Shazz

Joined: 31 Aug 2004 Posts: 244 Location: Somewhere over the rainbow
|
Posted: Sat Mar 26, 2005 1:50 am Post subject: |
|
|
hum, coming back to the DIRECT vif code... I've got a problem with it :
| Code: |
///////////////////////////////////////////////////////////////////////////
// send DIRECT giftag using path 2 with texture settings
*((u64*)p_data)++ = DMA_CNT_TAG( 2 );
// VIF_CODE(CMD,NUM,IMMEDIATE)
*((u32*)pChain)++ = VIF_CODE( VIF_NOP, 0, 0 );
*((u32*)p_data)++ = VIF_CODE( VIF_DIRECT, 0, 2);
*((u64*)p_data)++ = GIF_TAG( 1, 1, 0, 0, 0, 1 );
*((u64*)p_data)++ = 0x6;
*((u64*)p_data)++ = PbTextureGetTex0( p_texture );
*((u64*)p_data)++ = 0; // 0 : only lower is significant
///////////////////////////////////////////////////////////////////////////
// Build the data we need to send to the vu1
*((u64*)p_data)++ = DMA_REF_TAG( (u32)&final_matrix, 4 );
*((u32*)p_data)++ = VIF_CODE( VIF_STCYL,0,0x0404 );
*((u32*)p_data)++ = VIF_CODE( VIF_UNPACK_V4_32, 4,0 );
///////////////////////////////////////////////////////////////////////////
// Add giftag and vertex data
*((u64*)p_data)++ = DMA_CNT_TAG( 1+(10*LOOPSIZE) );
*((u32*)p_data)++ = VIF_CODE( VIF_STCYL,0,0x0404 );
*((u32*)p_data)++ = VIF_CODE( VIF_UNPACK_V4_32, 1+(10*LOOPSIZE), 4 );
*((u64*)p_data)++ = GIF_TAG( LOOPSIZE, 1, 1, GS_SETREG_PRIM( GS_PRIM_PRIM_TRIANGLE,
1, 1, 0, 0, 0, 0, 0, 0 ), 0, 10 );
*((u64*)p_data)++ = (u64)(0x5125125126);
...
|
The first block using the DIRECT VIF code makes the screen to freeze... what's wrong ? _________________ - TiTAN Art Division -
http://www.titandemo.org |
|
| Back to top |
|
 |
Saotome

Joined: 03 Apr 2004 Posts: 182
|
Posted: Sat Mar 26, 2005 2:39 am Post subject: |
|
|
maybe a typo?
| Code: |
*((u32*)pChain)++ = VIF_CODE( VIF_NOP, 0, 0 );
*((u32*)p_data)++ = VIF_CODE( VIF_DIRECT, 0, 2);
|
shouldn't the "pChain" be a "p_data"? _________________ infj |
|
| Back to top |
|
 |
Shazz

Joined: 31 Aug 2004 Posts: 244 Location: Somewhere over the rainbow
|
Posted: Sat Mar 26, 2005 3:27 am Post subject: |
|
|
Copy/paste will kill me...
But why the hell this NOP is needed ? to have data aligned on qw ?)
NOP.... nop nop nop...
but it works now :D thanks.. _________________ - TiTAN Art Division -
http://www.titandemo.org |
|
| 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
|