Disabling some fallbacks as they cause misc programs not to start and adding some...
[mesa.git] / src / mesa / drivers / dri / r300 / pixel_shader.h
1 #ifndef __PIXEL_SHADER_H__
2 #define __PIXEL_SHADER_H__
3
4 #include "r300_reg.h"
5
6
7 /* INSTR 0 */
8
9 #define PFS_OP_MAD 0
10 #define PFS_OP_DP3 1
11 #define PFS_OP_DP4 2
12 #define PFS_OP_MIN 4
13 #define PFS_OP_MAX 5
14 #define PFS_OP_CMP 8
15 #define PFS_OP_FRC 9
16 #define PFS_OP_OUTC_REPL_ALPHA 10
17
18 /* "or" these with arg0 value to negate or take absolute value of an argument */
19 #define PFS_ARG_NEG (1<<5)
20 #define PFS_ARG_ABS (1<<6)
21
22 #define MAKE_PFS_INSTR0(op, arg0, arg1, arg2, flags) \
23 ( ((op)<<23) \
24 | ((arg0)<<R300_FPI0_ARG0C_SHIFT) \
25 | ((arg1)<<R300_FPI0_ARG1C_SHIFT) \
26 | ((arg2)<<R300_FPI0_ARG2C_SHIFT) \
27 | (flags) \
28 )
29
30 #define PFS_FLAG_X 1
31 #define PFS_FLAG_Y 2
32 #define PFS_FLAG_XY 3
33 #define PFS_FLAG_Z 4
34 #define PFS_FLAG_XZ 5
35 #define PFS_FLAG_YZ 6
36 #define PFS_FLAG_ALL 7
37 #define PFS_FLAG_NONE 0
38
39 #define EASY_PFS_INSTR0(op, arg0, arg1, arg2) \
40 MAKE_PFS_INSTR0(PFS_OP_##op, \
41 R300_FPI0_ARGC_##arg0, \
42 R300_FPI0_ARGC_##arg1, \
43 R300_FPI0_ARGC_##arg2, \
44 0)
45
46 /* INSTR 1 */
47
48 #define PFS_FLAG_CONST (1<<5)
49
50 #define MAKE_PFS_INSTR1(dstc, src0, src1, src2, reg, output) \
51 ((src0) | ((src1) << R300_FPI1_SRC1C_SHIFT) \
52 | ((src2)<<R300_FPI1_SRC2C_SHIFT) \
53 | ((dstc) << R300_FPI1_DSTC_SHIFT) \
54 | ((reg) << 23) | ((output)<<26))
55
56 #define EASY_PFS_INSTR1(dstc, src0, src1, src2, reg, output) \
57 MAKE_PFS_INSTR1(dstc, src0, src1, src2, PFS_FLAG_##reg, PFS_FLAG_##output)
58
59 /* INSTR 2 */
60
61 /* you can "or" PFS_ARG_NEG with these values to negate them */
62
63 #define MAKE_PFS_INSTR2(op, arg0, arg1, arg2, flags) \
64 (((op) << 23) | \
65 ((arg0)<<R300_FPI2_ARG0A_SHIFT) | \
66 ((arg1)<<R300_FPI2_ARG1A_SHIFT) | \
67 ((arg2)<<R300_FPI2_ARG2A_SHIFT) | \
68 (flags))
69
70 #define EASY_PFS_INSTR2(op, arg0, arg1, arg2) \
71 MAKE_PFS_INSTR2(R300_FPI2_OUTA_##op, \
72 R300_FPI2_ARGA_##arg0, \
73 R300_FPI2_ARGA_##arg1, \
74 R300_FPI2_ARGA_##arg2, \
75 0)
76
77
78 /* INSTR 3 */
79
80 #define PFS_FLAG_NONE 0
81 #define PFS_FLAG_REG 1
82 #define PFS_FLAG_OUTPUT 2
83 #define PFS_FLAG_BOTH 3
84
85 #define MAKE_PFS_INSTR3(dstc, src0, src1, src2, flags) \
86 ((src0) | ((src1) << R300_FPI1_SRC1C_SHIFT) \
87 | ((src2)<<R300_FPI1_SRC2C_SHIFT) \
88 | ((dstc) << R300_FPI1_DSTC_SHIFT) \
89 | ((flags) << 23))
90
91 #define EASY_PFS_INSTR3(dstc, src0, src1, src2, flag) \
92 MAKE_PFS_INSTR3(dstc, src0, src1, src2, PFS_FLAG_##flag)
93
94 /* What are 0's ORed with flags ? They are register numbers that
95 just happen to be 0 */
96 #define PFS_NOP { \
97 EASY_PFS_INSTR0(MAD, SRC0C_XYZ, ONE, ZERO), \
98 EASY_PFS_INSTR1(0, 0, 0 | PFS_FLAG_CONST, 0 | PFS_FLAG_CONST, NONE, ALL), \
99 EASY_PFS_INSTR2(MAD, SRC0A, ONE, ZERO), \
100 EASY_PFS_INSTR3(0, 0, 0 | PFS_FLAG_CONST, 0 | PFS_FLAG_CONST, OUTPUT) \
101 }
102
103 #endif