2 Copyright (C) Intel Corp. 2006. All Rights Reserved.
3 Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
4 develop this 3D driver.
6 Permission is hereby granted, free of charge, to any person obtaining
7 a copy of this software and associated documentation files (the
8 "Software"), to deal in the Software without restriction, including
9 without limitation the rights to use, copy, modify, merge, publish,
10 distribute, sublicense, and/or sell copies of the Software, and to
11 permit persons to whom the Software is furnished to do so, subject to
12 the following conditions:
14 The above copyright notice and this permission notice (including the
15 next paragraph) shall be included in all copies or substantial
16 portions of the Software.
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21 IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
22 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **********************************************************************/
29 * Keith Whitwell <keith@tungstengraphics.com>
33 #include "brw_context.h"
36 #include "shader/arbprogparse.h"
37 #include "shader/program_instruction.h"
39 static const char *fp_opcode_string
[] = {
40 "ABS", /* ARB_f_p only */
42 "CMP", /* ARB_f_p only */
44 "DDX", /* NV_f_p only */
45 "DDY", /* NV_f_p only */
48 "DPH", /* ARB_f_p only */
50 "END", /* private opcode */
54 "KIL", /* ARB_f_p only */
55 "KIL_NV", /* NV_f_p only */
64 "PK2H", /* NV_f_p only */
65 "PK2US", /* NV_f_p only */
66 "PK4B", /* NV_f_p only */
67 "PK4UB", /* NV_f_p only */
69 "PRINT", /* Mesa only */
71 "RFL", /* NV_f_p only */
73 "SCS", /* ARB_f_p only */
74 "SEQ", /* NV_f_p only */
75 "SFL", /* NV_f_p only */
76 "SGE", /* NV_f_p only */
77 "SGT", /* NV_f_p only */
79 "SLE", /* NV_f_p only */
81 "SNE", /* NV_f_p only */
82 "STR", /* NV_f_p only */
84 "SWZ", /* ARB_f_p only */
86 "TXB", /* ARB_f_p only */
87 "TXD", /* NV_f_p only */
88 "TXP", /* ARB_f_p only */
89 "TXP_NV", /* NV_f_p only */
90 "UP2H", /* NV_f_p only */
91 "UP2US", /* NV_f_p only */
92 "UP4B", /* NV_f_p only */
93 "UP4UB", /* NV_f_p only */
94 "X2D", /* NV_f_p only - 2d mat mul */
95 "XPD", /* ARB_f_p only - cross product */
100 void brw_wm_print_value( struct brw_wm_compile
*c
,
101 struct brw_wm_value
*value
)
104 if (c
->state
>= PASS2_DONE
)
105 brw_print_reg(value
->hw_reg
);
106 else if( value
== &c
->undef_value
)
107 _mesa_printf("undef");
108 else if( value
- c
->vreg
>= 0 &&
109 value
- c
->vreg
< BRW_WM_MAX_VREG
)
110 _mesa_printf("r%d", value
- c
->vreg
);
111 else if (value
- c
->creg
>= 0 &&
112 value
- c
->creg
< BRW_WM_MAX_PARAM
)
113 _mesa_printf("c%d", value
- c
->creg
);
114 else if (value
- c
->payload
.input_interp
>= 0 &&
115 value
- c
->payload
.input_interp
< FRAG_ATTRIB_MAX
)
116 _mesa_printf("i%d", value
- c
->payload
.input_interp
);
117 else if (value
- c
->payload
.depth
>= 0 &&
118 value
- c
->payload
.depth
< FRAG_ATTRIB_MAX
)
119 _mesa_printf("d%d", value
- c
->payload
.depth
);
124 void brw_wm_print_ref( struct brw_wm_compile
*c
,
125 struct brw_wm_ref
*ref
)
127 struct brw_reg hw_reg
= ref
->hw_reg
;
129 if (ref
->unspill_reg
)
130 _mesa_printf("UNSPILL(%x)/", ref
->value
->spill_slot
);
132 if (c
->state
>= PASS2_DONE
)
133 brw_print_reg(ref
->hw_reg
);
135 _mesa_printf("%s", hw_reg
.negate
? "-" : "");
136 _mesa_printf("%s", hw_reg
.abs
? "abs/" : "");
137 brw_wm_print_value(c
, ref
->value
);
138 if ((hw_reg
.nr
&1) || hw_reg
.subnr
) {
139 _mesa_printf("->%d.%d", (hw_reg
.nr
&1), hw_reg
.subnr
);
144 void brw_wm_print_insn( struct brw_wm_compile
*c
,
145 struct brw_wm_instruction
*inst
)
148 GLuint nr_args
= brw_wm_nr_args(inst
->opcode
);
151 for (i
= 0; i
< 4; i
++) {
153 brw_wm_print_value(c
, inst
->dst
[i
]);
154 if (inst
->dst
[i
]->spill_slot
)
155 _mesa_printf("/SPILL(%x)",inst
->dst
[i
]->spill_slot
);
164 if (inst
->writemask
!= WRITEMASK_XYZW
)
165 _mesa_printf(".%s%s%s%s",
166 GET_BIT(inst
->writemask
, 0) ? "x" : "",
167 GET_BIT(inst
->writemask
, 1) ? "y" : "",
168 GET_BIT(inst
->writemask
, 2) ? "z" : "",
169 GET_BIT(inst
->writemask
, 3) ? "w" : "");
171 switch (inst
->opcode
) {
173 _mesa_printf(" = PIXELXY");
176 _mesa_printf(" = DELTAXY");
179 _mesa_printf(" = PIXELW");
182 _mesa_printf(" = WPOSXY");
185 _mesa_printf(" = PINTERP");
188 _mesa_printf(" = LINTERP");
191 _mesa_printf(" = CINTERP");
194 _mesa_printf(" = FB_WRITE");
197 _mesa_printf(" = %s", fp_opcode_string
[inst
->opcode
]);
202 _mesa_printf("_SAT");
204 for (arg
= 0; arg
< nr_args
; arg
++) {
208 for (i
= 0; i
< 4; i
++) {
209 if (inst
->src
[arg
][i
]) {
210 brw_wm_print_ref(c
, inst
->src
[arg
][i
]);
224 void brw_wm_print_program( struct brw_wm_compile
*c
,
229 _mesa_printf("\n\n\n%s:\n", stage
);
230 for (insn
= 0; insn
< c
->nr_insns
; insn
++)
231 brw_wm_print_insn(c
, &c
->instruction
[insn
]);
232 _mesa_printf("\n\n\n");