diff options
author | Tom Stellard <[email protected]> | 2011-06-15 08:00:13 -0700 |
---|---|---|
committer | Tom Stellard <[email protected]> | 2011-09-16 17:19:56 -0700 |
commit | 1e5aaaa138d87a3e3bc53f6e4c18b1842b752dea (patch) | |
tree | 306a48b89719c85ca5eb97465e4e8c0ceccf3a1f /src/gallium/drivers/r300/compiler/radeon_compiler_util.c | |
parent | 96620d2275894d1e021d403c0e40007c61269563 (diff) |
r300/compiler: Move some helper functions to radeon_compiler_util.c
Diffstat (limited to 'src/gallium/drivers/r300/compiler/radeon_compiler_util.c')
-rw-r--r-- | src/gallium/drivers/r300/compiler/radeon_compiler_util.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/gallium/drivers/r300/compiler/radeon_compiler_util.c b/src/gallium/drivers/r300/compiler/radeon_compiler_util.c index 2742721f800..33dbe0e86e9 100644 --- a/src/gallium/drivers/r300/compiler/radeon_compiler_util.c +++ b/src/gallium/drivers/r300/compiler/radeon_compiler_util.c @@ -699,3 +699,38 @@ unsigned int rc_make_conversion_swizzle( } return conversion_swizzle; } + +/** + * @return 1 if the register contains an immediate value, 0 otherwise. + */ +unsigned int rc_src_reg_is_immediate( + struct radeon_compiler * c, + unsigned int file, + unsigned int index) +{ + return file == RC_FILE_CONSTANT && + c->Program.Constants.Constants[index].Type == RC_CONSTANT_IMMEDIATE; +} + +/** + * @return The immediate value in the specified register. + */ +float rc_get_constant_value( + struct radeon_compiler * c, + unsigned int index, + unsigned int swizzle, + unsigned int negate, + unsigned int chan) +{ + float base = 1.0f; + int swz = GET_SWZ(swizzle, chan); + if(swz >= 4 || index >= c->Program.Constants.Count ){ + rc_error(c, "get_constant_value: Can't find a value.\n"); + return 0.0f; + } + if(GET_BIT(negate, chan)){ + base = -1.0f; + } + return base * + c->Program.Constants.Constants[index].u.Immediate[swz]; +} |