r600g: Silence uninitialized variable warning.
[mesa.git] / src / gallium / drivers / r600 / r600_asm.h
1 /*
2 * Copyright 2010 Jerome Glisse <glisse@freedesktop.org>
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * on the rights to use, copy, modify, merge, publish, distribute, sub
8 * license, and/or sell copies of the Software, and to permit persons to whom
9 * the Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21 * USE OR OTHER DEALINGS IN THE SOFTWARE.
22 */
23 #ifndef R600_ASM_H
24 #define R600_ASM_H
25
26 #include "radeon.h"
27 #include "util/u_double_list.h"
28
29 #define NUM_OF_CYCLES 3
30 #define NUM_OF_COMPONENTS 4
31
32 struct r600_bc_alu_src {
33 unsigned sel;
34 unsigned chan;
35 unsigned neg;
36 unsigned abs;
37 unsigned rel;
38 };
39
40 struct r600_bc_alu_dst {
41 unsigned sel;
42 unsigned chan;
43 unsigned clamp;
44 unsigned write;
45 unsigned rel;
46 };
47
48 struct r600_bc_alu {
49 struct list_head list;
50 struct list_head bs_list; /* bank swizzle list */
51 struct r600_bc_alu_src src[3];
52 struct r600_bc_alu_dst dst;
53 unsigned inst;
54 unsigned last;
55 unsigned is_op3;
56 unsigned predicate;
57 unsigned nliteral;
58 unsigned literal_added;
59 unsigned bank_swizzle;
60 unsigned bank_swizzle_force;
61 u32 value[4];
62 int hw_gpr[NUM_OF_CYCLES][NUM_OF_COMPONENTS];
63 };
64
65 struct r600_bc_tex {
66 struct list_head list;
67 unsigned inst;
68 unsigned resource_id;
69 unsigned src_gpr;
70 unsigned src_rel;
71 unsigned dst_gpr;
72 unsigned dst_rel;
73 unsigned dst_sel_x;
74 unsigned dst_sel_y;
75 unsigned dst_sel_z;
76 unsigned dst_sel_w;
77 unsigned lod_bias;
78 unsigned coord_type_x;
79 unsigned coord_type_y;
80 unsigned coord_type_z;
81 unsigned coord_type_w;
82 unsigned offset_x;
83 unsigned offset_y;
84 unsigned offset_z;
85 unsigned sampler_id;
86 unsigned src_sel_x;
87 unsigned src_sel_y;
88 unsigned src_sel_z;
89 unsigned src_sel_w;
90 };
91
92 struct r600_bc_vtx {
93 struct list_head list;
94 unsigned inst;
95 unsigned fetch_type;
96 unsigned buffer_id;
97 unsigned src_gpr;
98 unsigned src_sel_x;
99 unsigned mega_fetch_count;
100 unsigned dst_gpr;
101 unsigned dst_sel_x;
102 unsigned dst_sel_y;
103 unsigned dst_sel_z;
104 unsigned dst_sel_w;
105 };
106
107 struct r600_bc_output {
108 unsigned array_base;
109 unsigned type;
110 unsigned end_of_program;
111 unsigned inst;
112 unsigned elem_size;
113 unsigned gpr;
114 unsigned swizzle_x;
115 unsigned swizzle_y;
116 unsigned swizzle_z;
117 unsigned swizzle_w;
118 unsigned barrier;
119 };
120
121 struct r600_bc_cf {
122 struct list_head list;
123 unsigned inst;
124 unsigned addr;
125 unsigned ndw;
126 unsigned id;
127 unsigned cond;
128 unsigned pop_count;
129 unsigned cf_addr; /* control flow addr */
130 unsigned kcache0_mode;
131 struct list_head alu;
132 struct list_head tex;
133 struct list_head vtx;
134 struct r600_bc_output output;
135 struct r600_bc_alu *curr_bs_head;
136 };
137
138 #define FC_NONE 0
139 #define FC_IF 1
140 #define FC_LOOP 2
141 #define FC_REP 3
142 #define FC_PUSH_VPM 4
143 #define FC_PUSH_WQM 5
144
145 struct r600_cf_stack_entry {
146 int type;
147 struct r600_bc_cf *start;
148 struct r600_bc_cf **mid; /* used to store the else point */
149 int num_mid;
150 };
151
152 #define SQ_MAX_CALL_DEPTH 0x00000020
153 struct r600_cf_callstack {
154 unsigned fc_sp_before_entry;
155 int sub_desc_index;
156 int current;
157 int max;
158 };
159
160 struct r600_bc {
161 enum radeon_family family;
162 int chiprev; /* 0 - r600, 1 - r700, 2 - evergreen */
163 unsigned use_mem_constant;
164 struct list_head cf;
165 struct r600_bc_cf *cf_last;
166 unsigned ndw;
167 unsigned ncf;
168 unsigned ngpr;
169 unsigned nstack;
170 unsigned nresource;
171 unsigned force_add_cf;
172 u32 *bytecode;
173
174 u32 fc_sp;
175 struct r600_cf_stack_entry fc_stack[32];
176
177 unsigned call_sp;
178 struct r600_cf_callstack callstack[SQ_MAX_CALL_DEPTH];
179 };
180
181 int r600_bc_init(struct r600_bc *bc, enum radeon_family family);
182 int r600_bc_add_alu(struct r600_bc *bc, const struct r600_bc_alu *alu);
183 int r600_bc_add_literal(struct r600_bc *bc, const u32 *value);
184 int r600_bc_add_vtx(struct r600_bc *bc, const struct r600_bc_vtx *vtx);
185 int r600_bc_add_tex(struct r600_bc *bc, const struct r600_bc_tex *tex);
186 int r600_bc_add_output(struct r600_bc *bc, const struct r600_bc_output *output);
187 int r600_bc_build(struct r600_bc *bc);
188 int r600_bc_add_cfinst(struct r600_bc *bc, int inst);
189 int r600_bc_add_alu_type(struct r600_bc *bc, const struct r600_bc_alu *alu, int type);
190 #endif