r600g: cleanup includes
[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 "r600.h"
27
28 struct r600_vertex_element;
29 struct r600_context;
30
31 struct r600_bytecode_alu_src {
32 unsigned sel;
33 unsigned chan;
34 unsigned neg;
35 unsigned abs;
36 unsigned rel;
37 unsigned kc_bank;
38 uint32_t value;
39 };
40
41 struct r600_bytecode_alu_dst {
42 unsigned sel;
43 unsigned chan;
44 unsigned clamp;
45 unsigned write;
46 unsigned rel;
47 };
48
49 struct r600_bytecode_alu {
50 struct list_head list;
51 struct r600_bytecode_alu_src src[3];
52 struct r600_bytecode_alu_dst dst;
53 unsigned inst;
54 unsigned last;
55 unsigned is_op3;
56 unsigned predicate;
57 unsigned bank_swizzle;
58 unsigned bank_swizzle_force;
59 unsigned omod;
60 unsigned index_mode;
61 };
62
63 struct r600_bytecode_tex {
64 struct list_head list;
65 unsigned inst;
66 unsigned resource_id;
67 unsigned src_gpr;
68 unsigned src_rel;
69 unsigned dst_gpr;
70 unsigned dst_rel;
71 unsigned dst_sel_x;
72 unsigned dst_sel_y;
73 unsigned dst_sel_z;
74 unsigned dst_sel_w;
75 unsigned lod_bias;
76 unsigned coord_type_x;
77 unsigned coord_type_y;
78 unsigned coord_type_z;
79 unsigned coord_type_w;
80 unsigned offset_x;
81 unsigned offset_y;
82 unsigned offset_z;
83 unsigned sampler_id;
84 unsigned src_sel_x;
85 unsigned src_sel_y;
86 unsigned src_sel_z;
87 unsigned src_sel_w;
88 };
89
90 struct r600_bytecode_vtx {
91 struct list_head list;
92 unsigned inst;
93 unsigned fetch_type;
94 unsigned buffer_id;
95 unsigned src_gpr;
96 unsigned src_sel_x;
97 unsigned mega_fetch_count;
98 unsigned dst_gpr;
99 unsigned dst_sel_x;
100 unsigned dst_sel_y;
101 unsigned dst_sel_z;
102 unsigned dst_sel_w;
103 unsigned use_const_fields;
104 unsigned data_format;
105 unsigned num_format_all;
106 unsigned format_comp_all;
107 unsigned srf_mode_all;
108 unsigned offset;
109 unsigned endian;
110 };
111
112 struct r600_bytecode_output {
113 unsigned array_base;
114 unsigned array_size;
115 unsigned comp_mask;
116 unsigned type;
117 unsigned end_of_program;
118
119 /* CF_INST. This is already bit-shifted and only needs to be or'd for bytecode. */
120 unsigned inst;
121
122 unsigned elem_size;
123 unsigned gpr;
124 unsigned swizzle_x;
125 unsigned swizzle_y;
126 unsigned swizzle_z;
127 unsigned swizzle_w;
128 unsigned burst_count;
129 unsigned barrier;
130 };
131
132 struct r600_bytecode_kcache {
133 unsigned bank;
134 unsigned mode;
135 unsigned addr;
136 };
137
138 struct r600_bytecode_cf {
139 struct list_head list;
140
141 /* CF_INST. This is already bit-shifted and only needs to be or'd for bytecode. */
142 unsigned inst;
143
144 unsigned addr;
145 unsigned ndw;
146 unsigned id;
147 unsigned cond;
148 unsigned pop_count;
149 unsigned cf_addr; /* control flow addr */
150 struct r600_bytecode_kcache kcache[4];
151 unsigned r6xx_uses_waterfall;
152 unsigned eg_alu_extended;
153 struct list_head alu;
154 struct list_head tex;
155 struct list_head vtx;
156 struct r600_bytecode_output output;
157 struct r600_bytecode_alu *curr_bs_head;
158 struct r600_bytecode_alu *prev_bs_head;
159 struct r600_bytecode_alu *prev2_bs_head;
160 };
161
162 #define FC_NONE 0
163 #define FC_IF 1
164 #define FC_LOOP 2
165 #define FC_REP 3
166 #define FC_PUSH_VPM 4
167 #define FC_PUSH_WQM 5
168
169 struct r600_cf_stack_entry {
170 int type;
171 struct r600_bytecode_cf *start;
172 struct r600_bytecode_cf **mid; /* used to store the else point */
173 int num_mid;
174 };
175
176 #define SQ_MAX_CALL_DEPTH 0x00000020
177 struct r600_cf_callstack {
178 unsigned fc_sp_before_entry;
179 int sub_desc_index;
180 int current;
181 int max;
182 };
183
184 #define AR_HANDLE_NORMAL 0
185 #define AR_HANDLE_RV6XX 1 /* except RV670 */
186
187
188 struct r600_bytecode {
189 enum chip_class chip_class;
190 int type;
191 struct list_head cf;
192 struct r600_bytecode_cf *cf_last;
193 unsigned ndw;
194 unsigned ncf;
195 unsigned ngpr;
196 unsigned nstack;
197 unsigned nresource;
198 unsigned force_add_cf;
199 uint32_t *bytecode;
200 uint32_t fc_sp;
201 struct r600_cf_stack_entry fc_stack[32];
202 unsigned call_sp;
203 struct r600_cf_callstack callstack[SQ_MAX_CALL_DEPTH];
204 unsigned ar_loaded;
205 unsigned ar_reg;
206 unsigned ar_handling;
207 unsigned r6xx_nop_after_rel_dst;
208 };
209
210 /* eg_asm.c */
211 int eg_bytecode_cf_build(struct r600_bytecode *bc, struct r600_bytecode_cf *cf);
212
213 /* r600_asm.c */
214 void r600_bytecode_init(struct r600_bytecode *bc, enum chip_class chip_class, enum radeon_family family);
215 void r600_bytecode_clear(struct r600_bytecode *bc);
216 int r600_bytecode_add_alu(struct r600_bytecode *bc, const struct r600_bytecode_alu *alu);
217 int r600_bytecode_add_vtx(struct r600_bytecode *bc, const struct r600_bytecode_vtx *vtx);
218 int r600_bytecode_add_tex(struct r600_bytecode *bc, const struct r600_bytecode_tex *tex);
219 int r600_bytecode_add_output(struct r600_bytecode *bc, const struct r600_bytecode_output *output);
220 int r600_bytecode_build(struct r600_bytecode *bc);
221 int r600_bytecode_add_cfinst(struct r600_bytecode *bc, int inst);
222 int r600_bytecode_add_alu_type(struct r600_bytecode *bc, const struct r600_bytecode_alu *alu, int type);
223 void r600_bytecode_special_constants(uint32_t value, unsigned *sel, unsigned *neg);
224 void r600_bytecode_dump(struct r600_bytecode *bc);
225
226 int cm_bytecode_add_cf_end(struct r600_bytecode *bc);
227
228 int r600_vertex_elements_build_fetch_shader(struct r600_context *rctx, struct r600_vertex_element *ve);
229
230 /* r700_asm.c */
231 void r700_bytecode_cf_vtx_build(uint32_t *bytecode, const struct r600_bytecode_cf *cf);
232 int r700_bytecode_alu_build(struct r600_bytecode *bc, struct r600_bytecode_alu *alu, unsigned id);
233
234 #endif