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
PS3 Texture Swizzling
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.
This code ( untested ) must work.
Code: Select all
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];
}
-
- Posts: 3
- Joined: Wed Sep 05, 2007 11:33 am
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/arti ... llcode.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.
http://www.insomniacgames.com/tech/arti ... llcode.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.