2 #include "cell/common.h"
3 #include "pipe/p_shader_tokens.h"
4 #include "pipe/p_debug.h"
5 #include "tgsi/tgsi_parse.h"
6 //#include "tgsi_build.h"
7 #include "tgsi/tgsi_util.h"
10 tgsi_util_get_src_register_swizzle(
11 const struct tgsi_src_register
*reg
,
30 tgsi_util_get_src_register_extswizzle(
31 const struct tgsi_src_register_ext_swz
*reg
,
36 return reg
->ExtSwizzleX
;
38 return reg
->ExtSwizzleY
;
40 return reg
->ExtSwizzleZ
;
42 return reg
->ExtSwizzleW
;
50 tgsi_util_get_full_src_register_extswizzle(
51 const struct tgsi_full_src_register
*reg
,
57 * First, calculate the extended swizzle for a given channel. This will give
58 * us either a channel index into the simple swizzle or a constant 1 or 0.
60 swizzle
= tgsi_util_get_src_register_extswizzle(
61 ®
->SrcRegisterExtSwz
,
64 ASSERT (TGSI_SWIZZLE_X
== TGSI_EXTSWIZZLE_X
);
65 ASSERT (TGSI_SWIZZLE_Y
== TGSI_EXTSWIZZLE_Y
);
66 ASSERT (TGSI_SWIZZLE_Z
== TGSI_EXTSWIZZLE_Z
);
67 ASSERT (TGSI_SWIZZLE_W
== TGSI_EXTSWIZZLE_W
);
68 ASSERT (TGSI_EXTSWIZZLE_ZERO
> TGSI_SWIZZLE_W
);
69 ASSERT (TGSI_EXTSWIZZLE_ONE
> TGSI_SWIZZLE_W
);
72 * Second, calculate the simple swizzle for the unswizzled channel index.
73 * Leave the constants intact, they are not affected by the simple swizzle.
75 if( swizzle
<= TGSI_SWIZZLE_W
) {
76 swizzle
= tgsi_util_get_src_register_swizzle(
85 tgsi_util_get_src_register_extnegate(
86 const struct tgsi_src_register_ext_swz
*reg
,
105 tgsi_util_set_src_register_extnegate(
106 struct tgsi_src_register_ext_swz
*reg
,
110 switch( component
) {
112 reg
->NegateX
= negate
;
115 reg
->NegateY
= negate
;
118 reg
->NegateZ
= negate
;
121 reg
->NegateW
= negate
;
129 tgsi_util_get_full_src_register_sign_mode(
130 const struct tgsi_full_src_register
*reg
,
135 if( reg
->SrcRegisterExtMod
.Absolute
) {
136 /* Consider only the post-abs negation. */
138 if( reg
->SrcRegisterExtMod
.Negate
) {
139 sign_mode
= TGSI_UTIL_SIGN_SET
;
142 sign_mode
= TGSI_UTIL_SIGN_CLEAR
;
146 /* Accumulate the three negations. */
150 negate
= reg
->SrcRegister
.Negate
;
151 if( tgsi_util_get_src_register_extnegate( ®
->SrcRegisterExtSwz
, component
) ) {
154 if( reg
->SrcRegisterExtMod
.Negate
) {
159 sign_mode
= TGSI_UTIL_SIGN_TOGGLE
;
162 sign_mode
= TGSI_UTIL_SIGN_KEEP
;