2 * Copyright 2010 Jerome Glisse <glisse@freedesktop.org>
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:
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
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.
26 #include "r600_pipe.h"
29 struct r600_bytecode_alu_src
{
40 struct r600_bytecode_alu_dst
{
48 struct r600_bytecode_alu
{
49 struct list_head list
;
50 struct r600_bytecode_alu_src src
[3];
51 struct r600_bytecode_alu_dst dst
;
55 unsigned execute_mask
;
58 unsigned bank_swizzle
;
59 unsigned bank_swizzle_force
;
64 struct r600_bytecode_tex
{
65 struct list_head list
;
78 unsigned coord_type_x
;
79 unsigned coord_type_y
;
80 unsigned coord_type_z
;
81 unsigned coord_type_w
;
90 /* indexed samplers/resources only on evergreen/cayman */
91 unsigned sampler_index_mode
;
92 unsigned resource_index_mode
;
95 struct r600_bytecode_vtx
{
96 struct list_head list
;
102 unsigned mega_fetch_count
;
108 unsigned use_const_fields
;
109 unsigned data_format
;
110 unsigned num_format_all
;
111 unsigned format_comp_all
;
112 unsigned srf_mode_all
;
115 unsigned buffer_index_mode
;
118 struct r600_bytecode_output
{
132 unsigned burst_count
;
136 struct r600_bytecode_kcache
{
143 struct r600_bytecode_cf
{
144 struct list_head list
;
153 unsigned cf_addr
; /* control flow addr */
154 struct r600_bytecode_kcache kcache
[4];
155 unsigned r6xx_uses_waterfall
;
156 unsigned eg_alu_extended
;
158 unsigned end_of_program
;
159 struct list_head alu
;
160 struct list_head tex
;
161 struct list_head vtx
;
162 struct r600_bytecode_output output
;
163 struct r600_bytecode_alu
*curr_bs_head
;
164 struct r600_bytecode_alu
*prev_bs_head
;
165 struct r600_bytecode_alu
*prev2_bs_head
;
173 #define FC_PUSH_VPM 4
174 #define FC_PUSH_WQM 5
176 struct r600_cf_stack_entry
{
178 struct r600_bytecode_cf
*start
;
179 struct r600_bytecode_cf
**mid
; /* used to store the else point */
183 #define SQ_MAX_CALL_DEPTH 0x00000020
185 #define AR_HANDLE_NORMAL 0
186 #define AR_HANDLE_RV6XX 1 /* except RV670 */
188 struct r600_stack_info
{
189 /* current level of non-WQM PUSH operations
190 * (PUSH, PUSH_ELSE, ALU_PUSH_BEFORE) */
192 /* current level of WQM PUSH operations
193 * (PUSH, PUSH_ELSE, PUSH_WQM) */
195 /* current loop level */
200 /* subentries per entry */
204 struct r600_bytecode
{
205 enum chip_class chip_class
;
206 enum radeon_family family
;
207 bool has_compressed_msaa_texturing
;
210 struct r600_bytecode_cf
*cf_last
;
217 unsigned force_add_cf
;
220 struct r600_cf_stack_entry fc_stack
[32];
221 struct r600_stack_info stack
;
225 unsigned ar_handling
;
226 unsigned r6xx_nop_after_rel_dst
;
227 bool index_loaded
[2];
228 unsigned index_reg
[2]; /* indexing register CF_INDEX_[01] */
230 struct r600_isa
* isa
;
234 int eg_bytecode_cf_build(struct r600_bytecode
*bc
, struct r600_bytecode_cf
*cf
);
235 int egcm_load_index_reg(struct r600_bytecode
*bc
, unsigned id
, bool inside_alu_clause
);
238 void r600_bytecode_init(struct r600_bytecode
*bc
,
239 enum chip_class chip_class
,
240 enum radeon_family family
,
241 bool has_compressed_msaa_texturing
);
242 void r600_bytecode_clear(struct r600_bytecode
*bc
);
243 int r600_bytecode_add_alu(struct r600_bytecode
*bc
,
244 const struct r600_bytecode_alu
*alu
);
245 int r600_bytecode_add_vtx(struct r600_bytecode
*bc
,
246 const struct r600_bytecode_vtx
*vtx
);
247 int r600_bytecode_add_tex(struct r600_bytecode
*bc
,
248 const struct r600_bytecode_tex
*tex
);
249 int r600_bytecode_add_output(struct r600_bytecode
*bc
,
250 const struct r600_bytecode_output
*output
);
251 int r600_bytecode_build(struct r600_bytecode
*bc
);
252 int r600_bytecode_add_cf(struct r600_bytecode
*bc
);
253 int r600_bytecode_add_cfinst(struct r600_bytecode
*bc
,
255 int r600_bytecode_add_alu_type(struct r600_bytecode
*bc
,
256 const struct r600_bytecode_alu
*alu
, unsigned type
);
257 void r600_bytecode_special_constants(uint32_t value
,
258 unsigned *sel
, unsigned *neg
, unsigned abs
);
259 void r600_bytecode_disasm(struct r600_bytecode
*bc
);
260 void r600_bytecode_alu_read(struct r600_bytecode
*bc
,
261 struct r600_bytecode_alu
*alu
, uint32_t word0
, uint32_t word1
);
263 int cm_bytecode_add_cf_end(struct r600_bytecode
*bc
);
265 void *r600_create_vertex_fetch_shader(struct pipe_context
*ctx
,
267 const struct pipe_vertex_element
*elements
);
270 void r700_bytecode_cf_vtx_build(uint32_t *bytecode
,
271 const struct r600_bytecode_cf
*cf
);
272 int r700_bytecode_alu_build(struct r600_bytecode
*bc
,
273 struct r600_bytecode_alu
*alu
, unsigned id
);
274 void r700_bytecode_alu_read(struct r600_bytecode
*bc
,
275 struct r600_bytecode_alu
*alu
, uint32_t word0
, uint32_t word1
);
276 void r600_bytecode_export_read(struct r600_bytecode
*bc
,
277 struct r600_bytecode_output
*output
, uint32_t word0
, uint32_t word1
);
278 void eg_bytecode_export_read(struct r600_bytecode
*bc
,
279 struct r600_bytecode_output
*output
, uint32_t word0
, uint32_t word1
);
281 void r600_vertex_data_type(enum pipe_format pformat
, unsigned *format
,
282 unsigned *num_format
, unsigned *format_comp
, unsigned *endian
);
284 static inline int fp64_switch(int i
)