forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

PS3 Texture Swizzling

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PS3 Development
View previous topic :: View next topic  
Author Message
mike123mike



Joined: 08 Jul 2008
Posts: 1

PostPosted: Tue Jul 08, 2008 3:34 am    Post subject: PS3 Texture Swizzling Reply with quote

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
View user's profile Send private message
IronPeter



Joined: 06 Aug 2007
Posts: 207

PostPosted: Wed Jul 09, 2008 4:06 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
_protytype_



Joined: 05 Sep 2007
Posts: 3

PostPosted: Thu Jul 17, 2008 8:28 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PS3 Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
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