| View previous topic :: View next topic |
| Author |
Message |
mike123mike
Joined: 08 Jul 2008 Posts: 1
|
Posted: Tue Jul 08, 2008 3:34 am Post subject: PS3 Texture Swizzling |
|
|
Hey,
I wondered if anyone has any experience with ps3 texture swizzling. All methods I find which swizzle 16*8 blocks do not work.
Any help would be appreciated
thanks
Mike |
|
| Back to top |
|
 |
IronPeter
Joined: 06 Aug 2007 Posts: 207
|
Posted: Wed Jul 09, 2008 4:06 am Post subject: |
|
|
As far as I know NVidia uses bit-mixing for u, v. So odd bits are taken from u, even from v.
This code ( untested ) must work.
| Code: |
typedef struct Tex
{
uint8_t pixs[128 * 128][4];
};
uint8_t *GetPixel( struct Tex *tex, int i, int j )
{
int address =
( ( i & 1 ) << 0 ) + ( ( j & 1 ) << 1 ) +
( ( i & 2 ) << 1 ) + ( ( j & 2 ) << 2 ) +
( ( i & 4 ) << 2 ) + ( ( j & 4 ) << 3 ) +
( ( i & 8 ) << 3 ) + ( ( j & 8 ) << 4 ) +
( ( i & 16 ) << 4 ) + ( ( j & 16 ) << 5 ) +
( ( i & 32 ) << 5 ) + ( ( j & 32 ) << 6 ) +
( ( i & 64 ) << 6 ) + ( ( j & 64 ) << 7 );
return &tex->pixs[address][0];
}
|
|
|
| Back to top |
|
 |
_protytype_
Joined: 05 Sep 2007 Posts: 3
|
Posted: Thu Jul 17, 2008 8:28 am Post subject: |
|
|
Here is an interesting email exchange between two programmers at insomniac games about swizzling textures on the ps3. They manage to get it done in an insanely low amount of instructions:
http://www.insomniacgames.com/tech/articles/0108/curiouslysmallcode.php
You guys should check regularly on their R&D subsection, they have lots of articles specific to the ps3 and coding on the spus. |
|
| Back to top |
|
 |
|