diff options
author | Brian Paul <[email protected]> | 2013-06-21 16:24:55 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2013-06-22 08:49:09 -0600 |
commit | cba7939790caeb22dde451d9d334054c522ca5ce (patch) | |
tree | c87d74e0a398a48825f0c8c418922ad99ef6cc0f /src | |
parent | b03f3945080971004f2ba0952ea13d7be4bf3c43 (diff) |
svga: minor cleanups, comments in svga_tgsi_insn.c
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/drivers/svga/svga_tgsi_insn.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/src/gallium/drivers/svga/svga_tgsi_insn.c b/src/gallium/drivers/svga/svga_tgsi_insn.c index 92ee444a0db..3add4c03d09 100644 --- a/src/gallium/drivers/svga/svga_tgsi_insn.c +++ b/src/gallium/drivers/svga/svga_tgsi_insn.c @@ -117,28 +117,39 @@ translate_dst_register( struct svga_shader_emitter *emit, } +/** + * Apply a swizzle to a src_register, returning a new src_register + * Ex: swizzle(SRC.ZZYY, SWIZZLE_Z, SWIZZLE_W, SWIZZLE_X, SWIZZLE_Y) + * would return SRC.YYZZ + */ static struct src_register -swizzle( struct src_register src, - int x, - int y, - int z, - int w ) +swizzle(struct src_register src, + unsigned x, unsigned y, unsigned z, unsigned w) { + assert(x < 4); + assert(y < 4); + assert(z < 4); + assert(w < 4); x = (src.base.swizzle >> (x * 2)) & 0x3; y = (src.base.swizzle >> (y * 2)) & 0x3; z = (src.base.swizzle >> (z * 2)) & 0x3; w = (src.base.swizzle >> (w * 2)) & 0x3; - src.base.swizzle = TRANSLATE_SWIZZLE(x,y,z,w); + src.base.swizzle = TRANSLATE_SWIZZLE(x, y, z, w); return src; } +/** + * Apply a "scalar" swizzle to a src_register returning a new + * src_register where all the swizzle terms are the same. + * Ex: scalar(SRC.WZYX, SWIZZLE_Y) would return SRC.ZZZZ + */ static struct src_register -scalar( struct src_register src, - int comp ) +scalar(struct src_register src, unsigned comp) { + assert(comp < 4); return swizzle( src, comp, comp, comp, comp ); } |