r600_shader.h revision b7e1c893
1b7e1c893Smrg/*
2b7e1c893Smrg * RadeonHD R6xx, R7xx DRI driver
3b7e1c893Smrg *
4b7e1c893Smrg * Copyright (C) 2008-2009  Alexander Deucher
5b7e1c893Smrg * Copyright (C) 2008-2009  Matthias Hopf
6b7e1c893Smrg *
7b7e1c893Smrg * Permission is hereby granted, free of charge, to any person obtaining a
8b7e1c893Smrg * copy of this software and associated documentation files (the "Software"),
9b7e1c893Smrg * to deal in the Software without restriction, including without limitation
10b7e1c893Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11b7e1c893Smrg * and/or sell copies of the Software, and to permit persons to whom the
12b7e1c893Smrg * Software is furnished to do so, subject to the following conditions:
13b7e1c893Smrg *
14b7e1c893Smrg * The above copyright notice and this permission notice shall be included
15b7e1c893Smrg * in all copies or substantial portions of the Software.
16b7e1c893Smrg *
17b7e1c893Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18b7e1c893Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19b7e1c893Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
20b7e1c893Smrg * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21b7e1c893Smrg * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22b7e1c893Smrg * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23b7e1c893Smrg */
24b7e1c893Smrg
25b7e1c893Smrg/*
26b7e1c893Smrg * Shader macros
27b7e1c893Smrg */
28b7e1c893Smrg
29b7e1c893Smrg#ifndef __SHADER_H__
30b7e1c893Smrg#define __SHADER_H__
31b7e1c893Smrg
32b7e1c893Smrg#include "radeon.h"
33b7e1c893Smrg
34b7e1c893Smrg/* Restrictions of ALU instructions
35b7e1c893Smrg * order of scalar ops is always x,y,z,w,t(rans), last to be indicated by last==1.
36b7e1c893Smrg * max of 3 different src GPRs per instr.
37b7e1c893Smrg * max of 4 different cfile constant components per instr.
38b7e1c893Smrg * max of 2 (different) constants (any type) for t.
39b7e1c893Smrg * bank swizzle (see below).
40b7e1c893Smrg * GPR write stalls read of same register. Auto-replaced by PV/PS, NOP needed if registers are relative to
41b7e1c893Smrg * different indices (gpr,loop,nothing).
42b7e1c893Smrg * may use constant registers or constant cache, but not both.
43b7e1c893Smrg */
44b7e1c893Smrg
45b7e1c893Smrg/* Bank_swizzle: (pp. 297ff)
46b7e1c893Smrg * Only one of each x,y,z,w GPR component can be loaded per cycle (3 cycles per instr, called 0-2).
47b7e1c893Smrg * per scalar instruction bank_swizzle can select which cycle each operand comes from. e.g.:
48b7e1c893Smrg *   SRC0 SRC1 SRC2  SWIZZLE  cycle0 cycle1 cycle2
49b7e1c893Smrg *   1.x  2.x          012     1.x    2.x     -
50b7e1c893Smrg *   3.x  1.y          201     1.y     -     3.x
51b7e1c893Smrg *   2.x  1.y          102    (1.y)  (2.x)    -
52b7e1c893Smrg * If data is read in a cycle, multiple scalar instructions can reference it.
53b7e1c893Smrg * Special case: square() - i.e. same component in src0+src1 doesn't need read port -> ignores swizzle for src1.
54b7e1c893Smrg * No restrictions for constants or PV/PS.
55b7e1c893Smrg * t can load multiple components in a single cycle slot, but has to share cycles with xyzw.
56b7e1c893Smrg * t with single constant may not load GPRs or PV/PS in cycle 0 (carefull with ALU_TRANS_210).
57b7e1c893Smrg * t with two constants may only load GPRs or PV/PS in cycle 2.
58b7e1c893Smrg */
59b7e1c893Smrg
60b7e1c893Smrg
61b7e1c893Smrg/* Oder of instructions: All CF, All ALU, All Tex/Vtx fetches */
62b7e1c893Smrg
63b7e1c893Smrg
64b7e1c893Smrg// CF insts
65b7e1c893Smrg// addr
66b7e1c893Smrg#define ADDR(x)  (x)
67b7e1c893Smrg// pc
68b7e1c893Smrg#define POP_COUNT(x)      (x)
69b7e1c893Smrg// const
70b7e1c893Smrg#define CF_CONST(x)       (x)
71b7e1c893Smrg// cond
72b7e1c893Smrg#define COND(x)        (x)		// SQ_COND_*
73b7e1c893Smrg// count
74b7e1c893Smrg#define I_COUNT(x)        ((x) ? ((x) - 1) : 0)
75b7e1c893Smrg//r7xx
76b7e1c893Smrg#define COUNT_3(x)        (x)
77b7e1c893Smrg// call count
78b7e1c893Smrg#define CALL_COUNT(x)     (x)
79b7e1c893Smrg// eop
80b7e1c893Smrg#define END_OF_PROGRAM(x)   (x)
81b7e1c893Smrg// vpm
82b7e1c893Smrg#define VALID_PIXEL_MODE(x) (x)
83b7e1c893Smrg// cf inst
84b7e1c893Smrg#define CF_INST(x)        (x)		// SQ_CF_INST_*
85b7e1c893Smrg
86b7e1c893Smrg// wqm
87b7e1c893Smrg#define WHOLE_QUAD_MODE(x)  (x)
88b7e1c893Smrg// barrier
89b7e1c893Smrg#define BARRIER(x)          (x)
90b7e1c893Smrg//kb0
91b7e1c893Smrg#define KCACHE_BANK0(x)          (x)
92b7e1c893Smrg//kb1
93b7e1c893Smrg#define KCACHE_BANK1(x)          (x)
94b7e1c893Smrg// km0/1
95b7e1c893Smrg#define KCACHE_MODE0(x)          (x)
96b7e1c893Smrg#define KCACHE_MODE1(x)          (x)	// SQ_CF_KCACHE_*
97b7e1c893Smrg//
98b7e1c893Smrg#define KCACHE_ADDR0(x)          (x)
99b7e1c893Smrg#define KCACHE_ADDR1(x)          (x)
100b7e1c893Smrg// uw
101b7e1c893Smrg#define USES_WATERFALL(x)        (x)
102b7e1c893Smrg
103b7e1c893Smrg#define ARRAY_BASE(x)        (x)
104b7e1c893Smrg// export pixel
105b7e1c893Smrg#define CF_PIXEL_MRT0         0
106b7e1c893Smrg#define CF_PIXEL_MRT1         1
107b7e1c893Smrg#define CF_PIXEL_MRT2         2
108b7e1c893Smrg#define CF_PIXEL_MRT3         3
109b7e1c893Smrg#define CF_PIXEL_MRT4         4
110b7e1c893Smrg#define CF_PIXEL_MRT5         5
111b7e1c893Smrg#define CF_PIXEL_MRT6         6
112b7e1c893Smrg#define CF_PIXEL_MRT7         7
113b7e1c893Smrg// *_FOG: r6xx only
114b7e1c893Smrg#define CF_PIXEL_MRT0_FOG     16
115b7e1c893Smrg#define CF_PIXEL_MRT1_FOG     17
116b7e1c893Smrg#define CF_PIXEL_MRT2_FOG     18
117b7e1c893Smrg#define CF_PIXEL_MRT3_FOG     19
118b7e1c893Smrg#define CF_PIXEL_MRT4_FOG     20
119b7e1c893Smrg#define CF_PIXEL_MRT5_FOG     21
120b7e1c893Smrg#define CF_PIXEL_MRT6_FOG     22
121b7e1c893Smrg#define CF_PIXEL_MRT7_FOG     23
122b7e1c893Smrg#define CF_PIXEL_Z            61
123b7e1c893Smrg// export pos
124b7e1c893Smrg#define CF_POS0               60
125b7e1c893Smrg#define CF_POS1               61
126b7e1c893Smrg#define CF_POS2               62
127b7e1c893Smrg#define CF_POS3               63
128b7e1c893Smrg// export param
129b7e1c893Smrg// 0...31
130b7e1c893Smrg#define TYPE(x)              (x)	// SQ_EXPORT_*
131b7e1c893Smrg#if 0
132b7e1c893Smrg// type export
133b7e1c893Smrg#define SQ_EXPORT_PIXEL              0
134b7e1c893Smrg#define SQ_EXPORT_POS                1
135b7e1c893Smrg#define SQ_EXPORT_PARAM              2
136b7e1c893Smrg// reserved 3
137b7e1c893Smrg// type mem
138b7e1c893Smrg#define SQ_EXPORT_WRITE              0
139b7e1c893Smrg#define SQ_EXPORT_WRITE_IND          1
140b7e1c893Smrg#define SQ_EXPORT_WRITE_ACK          2
141b7e1c893Smrg#define SQ_EXPORT_WRITE_IND_ACK      3
142b7e1c893Smrg#endif
143b7e1c893Smrg
144b7e1c893Smrg#define RW_GPR(x)            (x)
145b7e1c893Smrg#define RW_REL(x)            (x)
146b7e1c893Smrg#define ABSOLUTE                  0
147b7e1c893Smrg#define RELATIVE                  1
148b7e1c893Smrg#define INDEX_GPR(x)            (x)
149b7e1c893Smrg#define ELEM_SIZE(x)            (x ? (x - 1) : 0)
150b7e1c893Smrg#define COMP_MASK(x)            (x)
151b7e1c893Smrg#define R6xx_ELEM_LOOP(x)            (x)
152b7e1c893Smrg#define BURST_COUNT(x)          (x ? (x - 1) : 0)
153b7e1c893Smrg
154b7e1c893Smrg// swiz
155b7e1c893Smrg#define SRC_SEL_X(x)    (x)		// SQ_SEL_* each
156b7e1c893Smrg#define SRC_SEL_Y(x)    (x)
157b7e1c893Smrg#define SRC_SEL_Z(x)    (x)
158b7e1c893Smrg#define SRC_SEL_W(x)    (x)
159b7e1c893Smrg
160b7e1c893Smrg#define CF_DWORD0(addr) (addr)
161b7e1c893Smrg// R7xx has another entry (COUNT3), but that is only used for adding a bit to count.
162b7e1c893Smrg// We allow one more bit for count in the argument of the macro on R7xx instead.
163b7e1c893Smrg// R6xx: [0,7]  R7xx: [1,16]
164b7e1c893Smrg#define CF_DWORD1(pc, cf_const, cond, count, call_count, eop, vpm, cf_inst, wqm, b) \
165b7e1c893Smrg        (((pc) << 0) | ((cf_const) << 3) | ((cond) << 8) | (((count) & 7) << 10) | (((count) >> 3) << 19) | \
166b7e1c893Smrg         ((call_count) << 13) | ((eop) << 21) | ((vpm) << 22) | ((cf_inst) << 23) | ((wqm) << 30) | ((b) << 31))
167b7e1c893Smrg
168b7e1c893Smrg#define CF_ALU_DWORD0(addr, kb0, kb1, km0) (((addr) << 0) | ((kb0) << 22) | ((kb1) << 26) | ((km0) << 30))
169b7e1c893Smrg#define CF_ALU_DWORD1(km1, kcache_addr0, kcache_addr1, count, uw, cf_inst, wqm, b) \
170b7e1c893Smrg        (((km1) << 0) | ((kcache_addr0) << 2) | ((kcache_addr1) << 10) | \
171b7e1c893Smrg	 ((count) << 18) | ((uw) << 25) | ((cf_inst) << 26) | ((wqm) << 30) | ((b) << 31))
172b7e1c893Smrg
173b7e1c893Smrg#define CF_ALLOC_IMP_EXP_DWORD0(array_base, type, rw_gpr, rr, index_gpr, es) \
174b7e1c893Smrg	 (((array_base) << 0) | ((type) << 13) | ((rw_gpr) << 15) | ((rr) << 22) | ((index_gpr) << 23) | \
175b7e1c893Smrg          ((es) << 30))
176b7e1c893Smrg// R7xx apparently doesn't have the ELEM_LOOP entry any more
177b7e1c893Smrg// We still expose it, but ELEM_LOOP is explicitely R6xx now.
178b7e1c893Smrg// TODO: is this just forgotten in the docs, or really not available any more?
179b7e1c893Smrg#define CF_ALLOC_IMP_EXP_DWORD1_BUF(array_size, comp_mask, el, bc, eop, vpm, cf_inst, wqm, b) \
180b7e1c893Smrg        (((array_size) << 0) | ((comp_mask) << 12) | ((el) << 16) | ((bc) << 17) | \
181b7e1c893Smrg	 ((eop) << 21) | ((vpm) << 22) | ((cf_inst) << 23) | ((wqm) << 30) | ((b) << 31))
182b7e1c893Smrg#define CF_ALLOC_IMP_EXP_DWORD1_SWIZ(sel_x, sel_y, sel_z, sel_w, el, bc, eop, vpm, cf_inst, wqm, b) \
183b7e1c893Smrg        (((sel_x) << 0) | ((sel_y) << 3) | ((sel_z) << 6) | ((sel_w) << 9) | ((el) << 16) | \
184b7e1c893Smrg	 ((bc) << 17) | ((eop) << 21) | ((vpm) << 22) | ((cf_inst) << 23) | \
185b7e1c893Smrg	 ((wqm) << 30) | ((b) << 31))
186b7e1c893Smrg
187b7e1c893Smrg// ALU clause insts
188b7e1c893Smrg#define SRC0_SEL(x)        (x)
189b7e1c893Smrg#define SRC1_SEL(x)        (x)
190b7e1c893Smrg#define SRC2_SEL(x)        (x)
191b7e1c893Smrg// src[0-2]_sel
192b7e1c893Smrg//   0-127 GPR
193b7e1c893Smrg// 128-159 kcache constants bank 0
194b7e1c893Smrg// 160-191 kcache constants bank 1
195b7e1c893Smrg// 248-255 special SQ_ALU_SRC_* (0, 1, etc.)
196b7e1c893Smrg
197b7e1c893Smrg#define SRC0_REL(x)        (x)
198b7e1c893Smrg#define SRC1_REL(x)        (x)
199b7e1c893Smrg#define SRC2_REL(x)        (x)
200b7e1c893Smrg// elem
201b7e1c893Smrg#define SRC0_ELEM(x)        (x)
202b7e1c893Smrg#define SRC1_ELEM(x)        (x)
203b7e1c893Smrg#define SRC2_ELEM(x)        (x)
204b7e1c893Smrg#define ELEM_X        0
205b7e1c893Smrg#define ELEM_Y        1
206b7e1c893Smrg#define ELEM_Z        2
207b7e1c893Smrg#define ELEM_W        3
208b7e1c893Smrg// neg
209b7e1c893Smrg#define SRC0_NEG(x)        (x)
210b7e1c893Smrg#define SRC1_NEG(x)        (x)
211b7e1c893Smrg#define SRC2_NEG(x)        (x)
212b7e1c893Smrg// im
213b7e1c893Smrg#define INDEX_MODE(x)    (x)		// SQ_INDEX_*
214b7e1c893Smrg// ps
215b7e1c893Smrg#define PRED_SEL(x)      (x)		// SQ_PRED_SEL_*
216b7e1c893Smrg// last
217b7e1c893Smrg#define LAST(x)          (x)
218b7e1c893Smrg// abs
219b7e1c893Smrg#define SRC0_ABS(x)       (x)
220b7e1c893Smrg#define SRC1_ABS(x)       (x)
221b7e1c893Smrg// uem
222b7e1c893Smrg#define UPDATE_EXECUTE_MASK(x) (x)
223b7e1c893Smrg// up
224b7e1c893Smrg#define UPDATE_PRED(x)      (x)
225b7e1c893Smrg// wm
226b7e1c893Smrg#define WRITE_MASK(x)   (x)
227b7e1c893Smrg// fm
228b7e1c893Smrg#define FOG_MERGE(x)    (x)
229b7e1c893Smrg// omod
230b7e1c893Smrg#define OMOD(x)        (x)		// SQ_ALU_OMOD_*
231b7e1c893Smrg// alu inst
232b7e1c893Smrg#define ALU_INST(x)        (x)		// SQ_ALU_INST_*
233b7e1c893Smrg//bs
234b7e1c893Smrg#define BANK_SWIZZLE(x)        (x)	// SQ_ALU_VEC_*
235b7e1c893Smrg#define DST_GPR(x)        (x)
236b7e1c893Smrg#define DST_REL(x)        (x)
237b7e1c893Smrg#define DST_ELEM(x)       (x)
238b7e1c893Smrg#define CLAMP(x)          (x)
239b7e1c893Smrg
240b7e1c893Smrg#define ALU_DWORD0(src0_sel, s0r, s0e, s0n, src1_sel, s1r, s1e, s1n, im, ps, last) \
241b7e1c893Smrg        (((src0_sel) << 0) | ((s0r) << 9) | ((s0e) << 10) | ((s0n) << 12) | \
242b7e1c893Smrg         ((src1_sel) << 13) | ((s1r) << 22) | ((s1e) << 23) | ((s1n) << 25) | \
243b7e1c893Smrg	 ((im) << 26) | ((ps) << 29) | ((last) << 31))
244b7e1c893Smrg// R7xx has alu_inst at a different slot, and no fog merge any more (no fix function fog any more)
245b7e1c893Smrg#define R6xx_ALU_DWORD1_OP2(s0a, s1a, uem, up, wm, fm, omod, alu_inst, bs, dst_gpr, dr, de, clamp) \
246b7e1c893Smrg        (((s0a) << 0) | ((s1a) << 1) | ((uem) << 2) | ((up) << 3) | ((wm) << 4) | \
247b7e1c893Smrg         ((fm) << 5) | ((omod) << 6) | ((alu_inst) << 8) | ((bs) << 18) | ((dst_gpr) << 21) | \
248b7e1c893Smrg	 ((dr) << 28) | ((de) << 29) | ((clamp) << 31))
249b7e1c893Smrg#define R7xx_ALU_DWORD1_OP2(s0a, s1a, uem, up, wm, omod, alu_inst, bs, dst_gpr, dr, de, clamp) \
250b7e1c893Smrg        (((s0a) << 0) | ((s1a) << 1) | ((uem) << 2) | ((up) << 3) | ((wm) << 4) | \
251b7e1c893Smrg         ((omod) << 5) | ((alu_inst) << 7) | ((bs) << 18) | ((dst_gpr) << 21) | \
252b7e1c893Smrg	 ((dr) << 28) | ((de) << 29) | ((clamp) << 31))
253b7e1c893Smrg// This is a general chipset macro, but due to selection by chipid typically not usable in static arrays
254b7e1c893Smrg// Fog is NOT USED on R7xx, even if specified.
255b7e1c893Smrg#define ALU_DWORD1_OP2(chipfamily, s0a, s1a, uem, up, wm, fm, omod, alu_inst, bs, dst_gpr, dr, de, clamp) \
256b7e1c893Smrg    ((chipfamily) < CHIP_FAMILY_RV770 ? \
257b7e1c893Smrg     R6xx_ALU_DWORD1_OP2(s0a, s1a, uem, up, wm, fm, omod, alu_inst, bs, dst_gpr, dr, de, clamp) : \
258b7e1c893Smrg     R7xx_ALU_DWORD1_OP2(s0a, s1a, uem, up, wm, omod, alu_inst, bs, dst_gpr, dr, de, clamp))
259b7e1c893Smrg#define ALU_DWORD1_OP3(src2_sel, s2r, s2e, s2n, alu_inst, bs, dst_gpr, dr, de, clamp) \
260b7e1c893Smrg        (((src2_sel) << 0) | ((s2r) << 9) | ((s2e) << 10) | ((s2n) << 12) | \
261b7e1c893Smrg         ((alu_inst) << 13) | ((bs) << 18) | ((dst_gpr) << 21) | ((dr) << 28) | \
262b7e1c893Smrg	 ((de) << 29) | ((clamp) << 31))
263b7e1c893Smrg
264b7e1c893Smrg// VTX clause insts
265b7e1c893Smrg// vxt insts
266b7e1c893Smrg#define VTX_INST(x)        (x)		// SQ_VTX_INST_*
267b7e1c893Smrg
268b7e1c893Smrg// fetch type
269b7e1c893Smrg#define FETCH_TYPE(x)        (x)	// SQ_VTX_FETCH_*
270b7e1c893Smrg
271b7e1c893Smrg#define FETCH_WHOLE_QUAD(x)        (x)
272b7e1c893Smrg#define BUFFER_ID(x)        (x)
273b7e1c893Smrg#define SRC_GPR(x)          (x)
274b7e1c893Smrg#define SRC_REL(x)          (x)
275b7e1c893Smrg#define MEGA_FETCH_COUNT(x)        ((x) ? ((x) - 1) : 0)
276b7e1c893Smrg
277b7e1c893Smrg#define SEMANTIC_ID(x)        (x)
278b7e1c893Smrg#define DST_SEL_X(x)          (x)
279b7e1c893Smrg#define DST_SEL_Y(x)          (x)
280b7e1c893Smrg#define DST_SEL_Z(x)          (x)
281b7e1c893Smrg#define DST_SEL_W(x)          (x)
282b7e1c893Smrg#define USE_CONST_FIELDS(x)   (x)
283b7e1c893Smrg#define DATA_FORMAT(x)        (x)
284b7e1c893Smrg// num format
285b7e1c893Smrg#define NUM_FORMAT_ALL(x)     (x)	// SQ_NUM_FORMAT_*
286b7e1c893Smrg// format comp
287b7e1c893Smrg#define FORMAT_COMP_ALL(x)     (x)	// SQ_FORMAT_COMP_*
288b7e1c893Smrg// sma
289b7e1c893Smrg#define SRF_MODE_ALL(x)     (x)
290b7e1c893Smrg#define SRF_MODE_ZERO_CLAMP_MINUS_ONE      0
291b7e1c893Smrg#define SRF_MODE_NO_ZERO                   1
292b7e1c893Smrg#define OFFSET(x)     (x)
293b7e1c893Smrg// endian swap
294b7e1c893Smrg#define ENDIAN_SWAP(x)     (x)		// SQ_ENDIAN_*
295b7e1c893Smrg#define CONST_BUF_NO_STRIDE(x)     (x)
296b7e1c893Smrg// mf
297b7e1c893Smrg#define MEGA_FETCH(x)     (x)
298b7e1c893Smrg
299b7e1c893Smrg#define VTX_DWORD0(vtx_inst, ft, fwq, buffer_id, src_gpr, sr, ssx, mfc) \
300b7e1c893Smrg        (((vtx_inst) << 0) | ((ft) << 5) | ((fwq) << 7) | ((buffer_id) << 8) | \
301b7e1c893Smrg	 ((src_gpr) << 16) | ((sr) << 23) | ((ssx) << 24) | ((mfc) << 26))
302b7e1c893Smrg#define VTX_DWORD1_SEM(semantic_id, dsx, dsy, dsz, dsw, ucf, data_format, nfa, fca, sma) \
303b7e1c893Smrg        (((semantic_id) << 0) | ((dsx) << 9) | ((dsy) << 12) | ((dsz) << 15) | ((dsw) << 18) | \
304b7e1c893Smrg	 ((ucf) << 21) | ((data_format) << 22) | ((nfa) << 28) | ((fca) << 30) | ((sma) << 31))
305b7e1c893Smrg#define VTX_DWORD1_GPR(dst_gpr, dr, dsx, dsy, dsz, dsw, ucf, data_format, nfa, fca, sma) \
306b7e1c893Smrg        (((dst_gpr) << 0) | ((dr) << 7) | ((dsx) << 9) | ((dsy) << 12) | ((dsz) << 15) | ((dsw) << 18) | \
307b7e1c893Smrg	 ((ucf) << 21) | ((data_format) << 22) | ((nfa) << 28) | ((fca) << 30) | ((sma) << 31))
308b7e1c893Smrg#define VTX_DWORD2(offset, es, cbns, mf) \
309b7e1c893Smrg	 (((offset) << 0) | ((es) << 16) | ((cbns) << 18) | ((mf) << 19))
310b7e1c893Smrg#define VTX_DWORD_PAD 0x00000000
311b7e1c893Smrg
312b7e1c893Smrg// TEX clause insts
313b7e1c893Smrg// tex insts
314b7e1c893Smrg#define TEX_INST(x)     (x)		// SQ_TEX_INST_*
315b7e1c893Smrg
316b7e1c893Smrg#define BC_FRAC_MODE(x)         (x)
317b7e1c893Smrg#define FETCH_WHOLE_QUAD(x)     (x)
318b7e1c893Smrg#define RESOURCE_ID(x)          (x)
319b7e1c893Smrg#define R7xx_ALT_CONST(x)            (x)
320b7e1c893Smrg
321b7e1c893Smrg#define LOD_BIAS(x)     (x)
322b7e1c893Smrg//ct
323b7e1c893Smrg#define COORD_TYPE_X(x)     (x)
324b7e1c893Smrg#define COORD_TYPE_Y(x)     (x)
325b7e1c893Smrg#define COORD_TYPE_Z(x)     (x)
326b7e1c893Smrg#define COORD_TYPE_W(x)     (x)
327b7e1c893Smrg#define TEX_UNNORMALIZED                0
328b7e1c893Smrg#define TEX_NORMALIZED                  1
329b7e1c893Smrg#define OFFSET_X(x) (((int)(x) * 2) & 0x1f) /* 4:1-bits 2's-complement fixed-point: [-8.0..7.5] */
330b7e1c893Smrg#define OFFSET_Y(x) (((int)(x) * 2) & 0x1f)
331b7e1c893Smrg#define OFFSET_Z(x) (((int)(x) * 2) & 0x1f)
332b7e1c893Smrg#define SAMPLER_ID(x)     (x)
333b7e1c893Smrg
334b7e1c893Smrg// R7xx has an additional parameter ALT_CONST. We always expose it, but ALT_CONST is R7xx only
335b7e1c893Smrg#define TEX_DWORD0(tex_inst, bfm, fwq, resource_id, src_gpr, sr, ac) \
336b7e1c893Smrg	 (((tex_inst) << 0) | ((bfm) << 5) | ((fwq) << 7) | ((resource_id) << 8) | \
337b7e1c893Smrg          ((src_gpr) << 16) | ((sr) << 23) | ((ac) << 24))
338b7e1c893Smrg#define TEX_DWORD1(dst_gpr, dr, dsx, dsy, dsz, dsw, lod_bias, ctx, cty, ctz, ctw) \
339b7e1c893Smrg        (((dst_gpr) << 0) | ((dr) << 7) | ((dsx) << 9) | ((dsy) << 12) | ((dsz) << 15) | ((dsw) << 18) | \
340b7e1c893Smrg	 ((lod_bias) << 21) | ((ctx) << 28) | ((cty) << 29) | ((ctz) << 30) | ((ctw) << 31))
341b7e1c893Smrg#define TEX_DWORD2(offset_x, offset_y, offset_z, sampler_id, ssx, ssy, ssz, ssw) \
342b7e1c893Smrg        (((offset_x) << 0) | ((offset_y) << 5) | ((offset_z) << 10) | ((sampler_id) << 15) | \
343b7e1c893Smrg	 ((ssx) << 20) | ((ssy) << 23) | ((ssz) << 26) | ((ssw) << 29))
344b7e1c893Smrg#define TEX_DWORD_PAD 0x00000000
345b7e1c893Smrg
346b7e1c893Smrgextern int R600_solid_vs(RADEONChipFamily ChipSet, uint32_t* vs);
347b7e1c893Smrgextern int R600_solid_ps(RADEONChipFamily ChipSet, uint32_t* ps);
348b7e1c893Smrg
349b7e1c893Smrgextern int R600_copy_vs(RADEONChipFamily ChipSet, uint32_t* vs);
350b7e1c893Smrgextern int R600_copy_ps(RADEONChipFamily ChipSet, uint32_t* ps);
351b7e1c893Smrg
352b7e1c893Smrgextern int R600_xv_vs(RADEONChipFamily ChipSet, uint32_t* shader);
353b7e1c893Smrgextern int R600_xv_ps(RADEONChipFamily ChipSet, uint32_t* shader);
354b7e1c893Smrg
355b7e1c893Smrgextern int R600_comp_vs(RADEONChipFamily ChipSet, uint32_t* vs);
356b7e1c893Smrgextern int R600_comp_mask_ps(RADEONChipFamily ChipSet, uint32_t* ps);
357b7e1c893Smrgextern int R600_comp_ps(RADEONChipFamily ChipSet, uint32_t* ps);
358b7e1c893Smrg
359b7e1c893Smrg#endif
360