c0e418a936eb75cb8402ffff504a1a8c690dfaf7
[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 VSF_FLAG_X 1
7 #define VSF_FLAG_Y 2
8 #define VSF_FLAG_Z 4
9 #define VSF_FLAG_W 8
10 #define VSF_FLAG_XYZ (VSF_FLAG_X | VSF_FLAG_Y | VSF_FLAG_Z)
11 #define VSF_FLAG_ALL 0xf
12 #define VSF_FLAG_NONE 0
13
14 /* first DWORD of an instruction */
15
16 #define PVS_VECTOR_OPCODE(op, out_reg_index, out_reg_fields, class) \
17 ((op) \
18 | ((out_reg_index) << R300_VPI_OUT_REG_INDEX_SHIFT) \
19 | ((out_reg_fields) << 20) \
20 | ( (class) << 8 ) )
21
22 #define PVS_DST_MATH_INST (1 << 6)
23
24 #define PVS_MATH_OPCODE(op, out_reg_index, out_reg_fields, class) \
25 ((op) \
26 | PVS_DST_MATH_INST \
27 | ((out_reg_index) << R300_VPI_OUT_REG_INDEX_SHIFT) \
28 | ((out_reg_fields) << 20) \
29 | ( (class) << 8 ) )
30
31 /* according to Nikolai, the subsequent 3 DWORDs are sources, use same define for each */
32
33 #define VSF_IN_COMPONENT_X 0
34 #define VSF_IN_COMPONENT_Y 1
35 #define VSF_IN_COMPONENT_Z 2
36 #define VSF_IN_COMPONENT_W 3
37 #define VSF_IN_COMPONENT_ZERO 4
38 #define VSF_IN_COMPONENT_ONE 5
39
40 #define PVS_SOURCE_OPCODE(in_reg_index, comp_x, comp_y, comp_z, comp_w, class, negate) \
41 ( ((in_reg_index)<<R300_VPI_IN_REG_INDEX_SHIFT) \
42 | ((comp_x)<<R300_VPI_IN_X_SHIFT) \
43 | ((comp_y)<<R300_VPI_IN_Y_SHIFT) \
44 | ((comp_z)<<R300_VPI_IN_Z_SHIFT) \
45 | ((comp_w)<<R300_VPI_IN_W_SHIFT) \
46 | ((negate)<<25) | ((class)))
47
48 #if 1
49
50 /**
51 * Vertex program helper macros
52 */
53
54 #define VP_OUTMASK_X R300_VPI_OUT_WRITE_X
55 #define VP_OUTMASK_Y R300_VPI_OUT_WRITE_Y
56 #define VP_OUTMASK_Z R300_VPI_OUT_WRITE_Z
57 #define VP_OUTMASK_W R300_VPI_OUT_WRITE_W
58 #define VP_OUTMASK_XY (VP_OUTMASK_X|VP_OUTMASK_Y)
59 #define VP_OUTMASK_XZ (VP_OUTMASK_X|VP_OUTMASK_Z)
60 #define VP_OUTMASK_XW (VP_OUTMASK_X|VP_OUTMASK_W)
61 #define VP_OUTMASK_XYZ (VP_OUTMASK_XY|VP_OUTMASK_Z)
62 #define VP_OUTMASK_XYW (VP_OUTMASK_XY|VP_OUTMASK_W)
63 #define VP_OUTMASK_XZW (VP_OUTMASK_XZ|VP_OUTMASK_W)
64 #define VP_OUTMASK_XYZW (VP_OUTMASK_XYZ|VP_OUTMASK_W)
65 #define VP_OUTMASK_YZ (VP_OUTMASK_Y|VP_OUTMASK_Z)
66 #define VP_OUTMASK_YW (VP_OUTMASK_Y|VP_OUTMASK_W)
67 #define VP_OUTMASK_YZW (VP_OUTMASK_YZ|VP_OUTMASK_W)
68 #define VP_OUTMASK_ZW (VP_OUTMASK_Z|VP_OUTMASK_W)
69
70 #define VP_OUT(instr,outclass,outidx,outmask) \
71 (VE_##instr | \
72 ((outidx) << R300_VPI_OUT_REG_INDEX_SHIFT) | \
73 (PVS_DST_REG_##outclass << 8) | \
74 VP_OUTMASK_##outmask)
75
76 #define VP_IN(class,idx) \
77 (((idx) << R300_VPI_IN_REG_INDEX_SHIFT) | \
78 (PVS_SRC_REG_##class << 0) | \
79 (PVS_SRC_SELECT_X << R300_VPI_IN_X_SHIFT) | \
80 (PVS_SRC_SELECT_Y << R300_VPI_IN_Y_SHIFT) | \
81 (PVS_SRC_SELECT_Z << R300_VPI_IN_Z_SHIFT) | \
82 (PVS_SRC_SELECT_W << R300_VPI_IN_W_SHIFT))
83 #define VP_ZERO() \
84 ((PVS_SRC_SELECT_FORCE_0 << R300_VPI_IN_X_SHIFT) | \
85 (PVS_SRC_SELECT_FORCE_0 << R300_VPI_IN_Y_SHIFT) | \
86 (PVS_SRC_SELECT_FORCE_0 << R300_VPI_IN_Z_SHIFT) | \
87 (PVS_SRC_SELECT_FORCE_0 << R300_VPI_IN_W_SHIFT))
88 #define VP_ONE() \
89 ((PVS_SRC_SELECT_FORCE_1 << R300_VPI_IN_X_SHIFT) | \
90 (PVS_SRC_SELECT_FORCE_1 << R300_VPI_IN_Y_SHIFT) | \
91 (PVS_SRC_SELECT_FORCE_1 << R300_VPI_IN_Z_SHIFT) | \
92 (PVS_SRC_SELECT_FORCE_1 << R300_VPI_IN_W_SHIFT))
93
94 #define VP_NEG(in,comp) ((in) ^ (R300_VPI_IN_NEG_##comp))
95 #define VP_NEGALL(in,comp) VP_NEG(VP_NEG(VP_NEG(VP_NEG((in),X),Y),Z),W)
96
97 #endif
98
99 #endif