PS3 Texture Swizzling

Technical discussion on the newly released and hard to find PS3.

Moderators: cheriff, emoon

Post Reply
mike123mike
Posts: 1
Joined: Tue Jul 08, 2008 3:31 am

PS3 Texture Swizzling

Post by mike123mike »

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
IronPeter
Posts: 207
Joined: Mon Aug 06, 2007 12:46 am
Contact:

Post by IronPeter »

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: Select all


typedef struct Tex
{
    uint8_t pixs[128 * 128][4];    
};

uint8_t *GetPixel( struct Tex *tex, int i, int j )
{
    int address = 
    
    &#40; &#40; i & 1 &#41; << 0 &#41; + &#40; &#40; j & 1 &#41; << 1 &#41; +
    &#40; &#40; i & 2 &#41; << 1 &#41; + &#40; &#40; j & 2 &#41; << 2 &#41; +
    &#40; &#40; i & 4 &#41; << 2 &#41; + &#40; &#40; j & 4 &#41; << 3 &#41; +
    &#40; &#40; i & 8 &#41; << 3 &#41; + &#40; &#40; j & 8 &#41; << 4 &#41; +
    &#40; &#40; i & 16 &#41; << 4 &#41; + &#40; &#40; j & 16 &#41; << 5 &#41; +
    &#40; &#40; i & 32 &#41; << 5 &#41; + &#40; &#40; j & 32 &#41; << 6 &#41; +
    &#40; &#40; i & 64 &#41; << 6 &#41; + &#40; &#40; j & 64 &#41; << 7 &#41;;
    
    return &tex->pixs&#91;address&#93;&#91;0&#93;;
&#125;

_protytype_
Posts: 3
Joined: Wed Sep 05, 2007 11:33 am

Post by _protytype_ »

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.
Post Reply