Archived

This topic is now archived and is closed to further replies.

ProgramMax

What is swizzling?

Recommended Posts

A buddy was talking about a clever idea he had for culling objects from a scene. He said it was based on swizzling. I did a bit of research and haven''t quite grasped what swizzling is exactly. Could anyone help me out? Thanks!

Share this post


Link to post
Share on other sites
The other meaning of "swizzling" is converting stored offsets and references to direct memory addresses. Sort of like what you''d do when loading a binary tree structure from a file into memory.


How appropriate. You fight like a cow.

Share this post


Link to post
Share on other sites
quote:
Original post by Sneftel
The other meaning of "swizzling" is converting stored offsets and references to direct memory addresses. Sort of like what you''d do when loading a binary tree structure from a file into memory.



I''ve always called this "indexing".
Well, live and learn

-Nik

Share this post


Link to post
Share on other sites
Can also mean "reorganising data for more optimal access"

For example say you have a set of 4 component vectors in memory:
xyzw,xyzw,xyzw,...,xyzw

For some algorithms implemented with SIMD CPU instructions (MMX, SSE, 3DNow!), if the data is "swizzled" into a form such as:
xxxx,yyyy,zzzz,...,xxxx

Then the implementation can often use less or faster instructions.


Another common type of "swizzle" (reorganisation of data) is for textures on graphics cards - many reorganise the layout of texels in memory to allow better texel/texture cache use (assuming the app uses textures in a "usual" way).


AFAIK it comes from "swizzle stick" which is a nick name for a drink stirrer (i.e. "mix up" the drink).

--
Simon O''Connor
3D Game Programmer &
Microsoft DirectX MVP

Share this post


Link to post
Share on other sites
The SIMD and cache example makes a lot of sense to me.

The buddy I was talking about is programming his own database driver for his project. The objects which could be potentially culled are in this database. Given this situation, the comment about swizzling being memory access instead of offsets and references makes sense.

Anyway, this sounds really great. I like the SIMD stuff a lot. Are there any pages that you guys can think of which are kinda a tutorial for swizzling being used in gaming?

Thanks again!

Share this post


Link to post
Share on other sites