r300: Added the PVS_OP_DST_OPERAND documentation from AMD.
[mesa.git] / src / mesa / drivers / dri / r300 / r300_vertprog.h
1 #ifndef __R300_VERTPROG_H_
2 #define __R300_VERTPROG_H_
3
4 #include "r300_reg.h"
5
6 #define R300_VPI_IN_REG_INDEX_SHIFT 5
7 /* GUESS based on fglrx native limits */
8 #define R300_VPI_IN_REG_INDEX_MASK (255 << 5)
9
10 #define R300_VPI_IN_X_SHIFT 13
11 #define R300_VPI_IN_Y_SHIFT 16
12 #define R300_VPI_IN_Z_SHIFT 19
13 #define R300_VPI_IN_W_SHIFT 22
14
15 #define R300_VPI_IN_NEG_X (1 << 25)
16 #define R300_VPI_IN_NEG_Y (1 << 26)
17 #define R300_VPI_IN_NEG_Z (1 << 27)
18 #define R300_VPI_IN_NEG_W (1 << 28)
19
20 #define PVS_VECTOR_OPCODE(opcode, reg_index, reg_writemask, reg_class) \
21 (((opcode & PVS_DST_OPCODE_MASK) << PVS_DST_OPCODE_SHIFT) \
22 | ((reg_index & PVS_DST_OFFSET_MASK) << PVS_DST_OFFSET_SHIFT) \
23 | ((reg_writemask & 0xf) << PVS_DST_WE_X_SHIFT) /* X Y Z W */ \
24 | ((reg_class & PVS_DST_REG_TYPE_MASK) << PVS_DST_REG_TYPE_SHIFT))
25
26 #define PVS_MATH_OPCODE(opcode, reg_index, reg_writemask, reg_class) \
27 (((opcode & PVS_DST_OPCODE_MASK) << PVS_DST_OPCODE_SHIFT) \
28 | ((1 & PVS_DST_MATH_INST_MASK) << PVS_DST_MATH_INST_SHIFT) \
29 | ((reg_index & PVS_DST_OFFSET_MASK) << PVS_DST_OFFSET_SHIFT) \
30 | ((reg_writemask & 0xf) << PVS_DST_WE_X_SHIFT) /* X Y Z W */ \
31 | ((reg_class & PVS_DST_REG_TYPE_MASK) << PVS_DST_REG_TYPE_SHIFT))
32
33
34 #define PVS_SOURCE_OPCODE(in_reg_index, comp_x, comp_y, comp_z, comp_w, reg_class, negate) \
35 (((in_reg_index) << R300_VPI_IN_REG_INDEX_SHIFT) \
36 | ((comp_x) << R300_VPI_IN_X_SHIFT) \
37 | ((comp_y) << R300_VPI_IN_Y_SHIFT) \
38 | ((comp_z) << R300_VPI_IN_Z_SHIFT) \
39 | ((comp_w) << R300_VPI_IN_W_SHIFT) \
40 | ((negate) << 25) \
41 | ((reg_class)))
42
43 #if 1
44
45 #define VSF_FLAG_X 1
46 #define VSF_FLAG_Y 2
47 #define VSF_FLAG_Z 4
48 #define VSF_FLAG_W 8
49 #define VSF_FLAG_XYZ (VSF_FLAG_X | VSF_FLAG_Y | VSF_FLAG_Z)
50 #define VSF_FLAG_ALL 0xf
51 #define VSF_FLAG_NONE 0
52
53 #define R300_VPI_OUT_WRITE_X (1 << 20)
54 #define R300_VPI_OUT_WRITE_Y (1 << 21)
55 #define R300_VPI_OUT_WRITE_Z (1 << 22)
56 #define R300_VPI_OUT_WRITE_W (1 << 23)
57
58 #define VP_OUTMASK_X R300_VPI_OUT_WRITE_X
59 #define VP_OUTMASK_Y R300_VPI_OUT_WRITE_Y
60 #define VP_OUTMASK_Z R300_VPI_OUT_WRITE_Z
61 #define VP_OUTMASK_W R300_VPI_OUT_WRITE_W
62 #define VP_OUTMASK_XY (VP_OUTMASK_X|VP_OUTMASK_Y)
63 #define VP_OUTMASK_XZ (VP_OUTMASK_X|VP_OUTMASK_Z)
64 #define VP_OUTMASK_XW (VP_OUTMASK_X|VP_OUTMASK_W)
65 #define VP_OUTMASK_XYZ (VP_OUTMASK_XY|VP_OUTMASK_Z)
66 #define VP_OUTMASK_XYW (VP_OUTMASK_XY|VP_OUTMASK_W)
67 #define VP_OUTMASK_XZW (VP_OUTMASK_XZ|VP_OUTMASK_W)
68 #define VP_OUTMASK_XYZW (VP_OUTMASK_XYZ|VP_OUTMASK_W)
69 #define VP_OUTMASK_YZ (VP_OUTMASK_Y|VP_OUTMASK_Z)
70 #define VP_OUTMASK_YW (VP_OUTMASK_Y|VP_OUTMASK_W)
71 #define VP_OUTMASK_YZW (VP_OUTMASK_YZ|VP_OUTMASK_W)
72 #define VP_OUTMASK_ZW (VP_OUTMASK_Z|VP_OUTMASK_W)
73
74 #define VP_OUT(instr,outclass,outidx,outmask) \
75 (VE_##instr | \
76 ((outidx & PVS_DST_OFFSET_MASK) << PVS_DST_OFFSET_SHIFT) | \
77 ((PVS_DST_REG_##outclass & PVS_DST_REG_TYPE_MASK) << PVS_DST_REG_TYPE_SHIFT) | \
78 VP_OUTMASK_##outmask)
79
80 #define VP_IN(inclass,inidx) \
81 (((inidx) << R300_VPI_IN_REG_INDEX_SHIFT) | \
82 (PVS_SRC_REG_##inclass << 0) | \
83 (PVS_SRC_SELECT_X << R300_VPI_IN_X_SHIFT) | \
84 (PVS_SRC_SELECT_Y << R300_VPI_IN_Y_SHIFT) | \
85 (PVS_SRC_SELECT_Z << R300_VPI_IN_Z_SHIFT) | \
86 (PVS_SRC_SELECT_W << R300_VPI_IN_W_SHIFT))
87 #define VP_ZERO() \
88 ((PVS_SRC_SELECT_FORCE_0 << R300_VPI_IN_X_SHIFT) | \
89 (PVS_SRC_SELECT_FORCE_0 << R300_VPI_IN_Y_SHIFT) | \
90 (PVS_SRC_SELECT_FORCE_0 << R300_VPI_IN_Z_SHIFT) | \
91 (PVS_SRC_SELECT_FORCE_0 << R300_VPI_IN_W_SHIFT))
92 #define VP_ONE() \
93 ((PVS_SRC_SELECT_FORCE_1 << R300_VPI_IN_X_SHIFT) | \
94 (PVS_SRC_SELECT_FORCE_1 << R300_VPI_IN_Y_SHIFT) | \
95 (PVS_SRC_SELECT_FORCE_1 << R300_VPI_IN_Z_SHIFT) | \
96 (PVS_SRC_SELECT_FORCE_1 << R300_VPI_IN_W_SHIFT))
97
98 #define VP_NEG(in,comp) ((in) ^ (R300_VPI_IN_NEG_##comp))
99 #define VP_NEGALL(in,comp) VP_NEG(VP_NEG(VP_NEG(VP_NEG((in),X),Y),Z),W)
100
101 #endif
102
103 #endif