summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/r300/pixel_shader.h
blob: 07c844973402130611c507fe03a7eab60c8cdf61 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#ifndef __PIXEL_SHADER_H__
#define __PIXEL_SHADER_H__

#include "r300_reg.h"


/* INSTR 0 */

#define PFS_OP_MAD	0
#define PFS_OP_DP3	1
#define PFS_OP_DP4	2
#define PFS_OP_MIN	4
#define PFS_OP_MAX	5
#define PFS_OP_CMP	8
#define PFS_OP_FRC	9
#define PFS_OP_OUTC_REPL_ALPHA	10

/* "or" these with arg0 value to negate or take absolute value of an argument */
#define PFS_ARG_NEG  (1<<5)
#define PFS_ARG_ABS  (1<<6)

#define MAKE_PFS_INSTR0(op, arg0, arg1, arg2, flags) \
	( ((op)<<23) \
	  | ((arg0)<<R300_FPI0_ARG0C_SHIFT) \
	  | ((arg1)<<R300_FPI0_ARG1C_SHIFT) \
	  | ((arg2)<<R300_FPI0_ARG2C_SHIFT) \
	  | (flags) \
	)

#define PFS_FLAG_X	1
#define PFS_FLAG_Y	2
#define PFS_FLAG_XY	3
#define PFS_FLAG_Z	4
#define PFS_FLAG_XZ	5
#define PFS_FLAG_YZ	6
#define PFS_FLAG_ALL	7
#define PFS_FLAG_NONE	0

#define EASY_PFS_INSTR0(op, arg0, arg1, arg2) \
	MAKE_PFS_INSTR0(PFS_OP_##op, \
		R300_FPI0_ARGC_##arg0, \
		R300_FPI0_ARGC_##arg1, \
		R300_FPI0_ARGC_##arg2, \
		0)

/* INSTR 1 */

#define PFS_FLAG_CONST (1<<5)

#define MAKE_PFS_INSTR1(dstc, src0, src1, src2, reg, output) \
	((src0) | ((src1) << R300_FPI1_SRC1C_SHIFT) \
	  | ((src2)<<R300_FPI1_SRC2C_SHIFT) \
	  | ((dstc) << R300_FPI1_DSTC_SHIFT) \
	  | ((reg) << 23) | ((output)<<26))

#define EASY_PFS_INSTR1(dstc, src0, src1, src2, reg, output) \
	MAKE_PFS_INSTR1(dstc, src0, src1, src2, PFS_FLAG_##reg, PFS_FLAG_##output)

/* INSTR 2 */

/* you can "or" PFS_ARG_NEG with these values to negate them */

#define MAKE_PFS_INSTR2(op, arg0, arg1, arg2, flags) \
	(((op) << 23) | \
	  ((arg0)<<R300_FPI2_ARG0A_SHIFT) | \
	  ((arg1)<<R300_FPI2_ARG1A_SHIFT) | \
	  ((arg2)<<R300_FPI2_ARG2A_SHIFT) | \
	  (flags))

#define EASY_PFS_INSTR2(op, arg0, arg1, arg2) \
	MAKE_PFS_INSTR2(R300_FPI2_OUTA_##op, \
		R300_FPI2_ARGA_##arg0, \
		R300_FPI2_ARGA_##arg1, \
		R300_FPI2_ARGA_##arg2, \
		0)


/* INSTR 3 */

#define PFS_FLAG_NONE	0
#define PFS_FLAG_REG	1
#define PFS_FLAG_OUTPUT	2
#define PFS_FLAG_BOTH	3

#define MAKE_PFS_INSTR3(dstc, src0, src1, src2, flags) \
	((src0) | ((src1) << R300_FPI1_SRC1C_SHIFT) \
	  | ((src2)<<R300_FPI1_SRC2C_SHIFT) \
	  | ((dstc) << R300_FPI1_DSTC_SHIFT) \
	  | ((flags) << 23))

#define EASY_PFS_INSTR3(dstc, src0, src1, src2, flag) \
	MAKE_PFS_INSTR3(dstc, src0, src1, src2, PFS_FLAG_##flag)

#endif