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"
28 #include "tgsi/tgsi_exec.h"
34 struct r600_bytecode_alu_src
{
45 struct r600_bytecode_alu_dst
{
53 struct r600_bytecode_alu
{
54 struct list_head list
;
55 struct r600_bytecode_alu_src src
[3];
56 struct r600_bytecode_alu_dst dst
;
60 unsigned is_lds_idx_op
;
61 unsigned execute_mask
;
64 unsigned bank_swizzle
;
65 unsigned bank_swizzle_force
;
71 struct r600_bytecode_tex
{
72 struct list_head list
;
85 unsigned coord_type_x
;
86 unsigned coord_type_y
;
87 unsigned coord_type_z
;
88 unsigned coord_type_w
;
97 /* indexed samplers/resources only on evergreen/cayman */
98 unsigned sampler_index_mode
;
99 unsigned resource_index_mode
;
102 struct r600_bytecode_vtx
{
103 struct list_head list
;
109 unsigned mega_fetch_count
;
115 unsigned use_const_fields
;
116 unsigned data_format
;
117 unsigned num_format_all
;
118 unsigned format_comp_all
;
119 unsigned srf_mode_all
;
122 unsigned buffer_index_mode
;
124 // READ_SCRATCH fields
132 unsigned burst_count
;
136 struct r600_bytecode_gds
{
137 struct list_head list
;
151 unsigned uav_index_mode
;
153 unsigned alloc_consume
;
154 unsigned bcast_first_req
;
157 struct r600_bytecode_output
{
171 unsigned burst_count
;
173 unsigned mark
; /* used by MEM_SCRATCH */
176 struct r600_bytecode_rat
{
182 struct r600_bytecode_kcache
{
189 struct r600_bytecode_cf
{
190 struct list_head list
;
199 unsigned cf_addr
; /* control flow addr */
200 struct r600_bytecode_kcache kcache
[4];
201 unsigned r6xx_uses_waterfall
;
202 unsigned eg_alu_extended
;
204 unsigned end_of_program
;
207 struct list_head alu
;
208 struct list_head tex
;
209 struct list_head vtx
;
210 struct list_head gds
;
211 struct r600_bytecode_output output
;
212 struct r600_bytecode_rat rat
;
213 struct r600_bytecode_alu
*curr_bs_head
;
214 struct r600_bytecode_alu
*prev_bs_head
;
215 struct r600_bytecode_alu
*prev2_bs_head
;
223 #define FC_PUSH_VPM 4
224 #define FC_PUSH_WQM 5
226 struct r600_cf_stack_entry
{
228 struct r600_bytecode_cf
*start
;
229 struct r600_bytecode_cf
**mid
; /* used to store the else point */
233 #define SQ_MAX_CALL_DEPTH 0x00000020
235 #define AR_HANDLE_NORMAL 0
236 #define AR_HANDLE_RV6XX 1 /* except RV670 */
238 struct r600_stack_info
{
239 /* current level of non-WQM PUSH operations
240 * (PUSH, PUSH_ELSE, ALU_PUSH_BEFORE) */
242 /* current level of WQM PUSH operations
243 * (PUSH, PUSH_ELSE, PUSH_WQM) */
245 /* current loop level */
250 /* subentries per entry */
254 struct r600_bytecode
{
255 enum chip_class chip_class
;
256 enum radeon_family family
;
257 bool has_compressed_msaa_texturing
;
260 struct r600_bytecode_cf
*cf_last
;
267 unsigned force_add_cf
;
270 struct r600_cf_stack_entry fc_stack
[TGSI_EXEC_MAX_NESTING
];
271 struct r600_stack_info stack
;
275 unsigned ar_handling
;
276 unsigned r6xx_nop_after_rel_dst
;
277 bool index_loaded
[2];
278 unsigned index_reg
[2]; /* indexing register CF_INDEX_[01] */
280 struct r600_isa
* isa
;
281 struct r600_bytecode_output pending_outputs
[5];
282 int n_pending_outputs
;
283 boolean need_wait_ack
; /* emit a pending WAIT_ACK prior to control flow */
288 int eg_bytecode_cf_build(struct r600_bytecode
*bc
, struct r600_bytecode_cf
*cf
);
289 int egcm_load_index_reg(struct r600_bytecode
*bc
, unsigned id
, bool inside_alu_clause
);
290 int eg_bytecode_gds_build(struct r600_bytecode
*bc
, struct r600_bytecode_gds
*gds
, unsigned id
);
291 int eg_bytecode_alu_build(struct r600_bytecode
*bc
,
292 struct r600_bytecode_alu
*alu
, unsigned id
);
294 void r600_bytecode_init(struct r600_bytecode
*bc
,
295 enum chip_class chip_class
,
296 enum radeon_family family
,
297 bool has_compressed_msaa_texturing
);
298 void r600_bytecode_clear(struct r600_bytecode
*bc
);
299 int r600_bytecode_add_alu(struct r600_bytecode
*bc
,
300 const struct r600_bytecode_alu
*alu
);
301 int r600_bytecode_add_vtx(struct r600_bytecode
*bc
,
302 const struct r600_bytecode_vtx
*vtx
);
303 int r600_bytecode_add_vtx_tc(struct r600_bytecode
*bc
,
304 const struct r600_bytecode_vtx
*vtx
);
305 int r600_bytecode_add_tex(struct r600_bytecode
*bc
,
306 const struct r600_bytecode_tex
*tex
);
307 int r600_bytecode_add_gds(struct r600_bytecode
*bc
,
308 const struct r600_bytecode_gds
*gds
);
309 int r600_bytecode_add_output(struct r600_bytecode
*bc
,
310 const struct r600_bytecode_output
*output
);
311 int r600_bytecode_add_pending_output(struct r600_bytecode
*bc
,
312 const struct r600_bytecode_output
*output
);
313 void r600_bytecode_need_wait_ack(struct r600_bytecode
*bc
, boolean needed
);
314 boolean
r600_bytecode_get_need_wait_ack(struct r600_bytecode
*bc
);
315 int r600_bytecode_build(struct r600_bytecode
*bc
);
316 int r600_bytecode_add_cf(struct r600_bytecode
*bc
);
317 int r600_bytecode_add_cfinst(struct r600_bytecode
*bc
,
319 int r600_bytecode_add_alu_type(struct r600_bytecode
*bc
,
320 const struct r600_bytecode_alu
*alu
, unsigned type
);
321 void r600_bytecode_special_constants(uint32_t value
,
322 unsigned *sel
, unsigned *neg
, unsigned abs
);
323 void r600_bytecode_disasm(struct r600_bytecode
*bc
);
324 void r600_bytecode_alu_read(struct r600_bytecode
*bc
,
325 struct r600_bytecode_alu
*alu
, uint32_t word0
, uint32_t word1
);
327 int cm_bytecode_add_cf_end(struct r600_bytecode
*bc
);
329 void *r600_create_vertex_fetch_shader(struct pipe_context
*ctx
,
331 const struct pipe_vertex_element
*elements
);
334 void r700_bytecode_cf_vtx_build(uint32_t *bytecode
,
335 const struct r600_bytecode_cf
*cf
);
336 int r700_bytecode_alu_build(struct r600_bytecode
*bc
,
337 struct r600_bytecode_alu
*alu
, unsigned id
);
338 void r700_bytecode_alu_read(struct r600_bytecode
*bc
,
339 struct r600_bytecode_alu
*alu
, uint32_t word0
, uint32_t word1
);
340 int r700_bytecode_fetch_mem_build(struct r600_bytecode
*bc
,
341 struct r600_bytecode_vtx
*mem
, unsigned id
);
343 void r600_bytecode_export_read(struct r600_bytecode
*bc
,
344 struct r600_bytecode_output
*output
, uint32_t word0
, uint32_t word1
);
345 void eg_bytecode_export_read(struct r600_bytecode
*bc
,
346 struct r600_bytecode_output
*output
, uint32_t word0
, uint32_t word1
);
348 void r600_vertex_data_type(enum pipe_format pformat
, unsigned *format
,
349 unsigned *num_format
, unsigned *format_comp
, unsigned *endian
);
351 static inline int fp64_switch(int i
)