a6c93bd3607e7e96f737d78801baf72645ddc781
[mesa.git] / src / mesa / drivers / dri / r300 / r300_fragprog.h
1 #ifndef __R300_FRAGPROG_H_
2 #define __R300_FRAGPROG_H_
3
4 #include "glheader.h"
5 #include "macros.h"
6 #include "enums.h"
7
8 #include "program.h"
9 #include "r300_context.h"
10 #include "program_instruction.h"
11
12 /* representation of a register for emit_arith/swizzle */
13 typedef struct _pfs_reg_t {
14 enum {
15 REG_TYPE_INPUT,
16 REG_TYPE_OUTPUT,
17 REG_TYPE_TEMP,
18 REG_TYPE_CONST
19 } type:2;
20 GLuint index:6;
21 GLuint v_swz:5;
22 GLuint s_swz:5;
23 GLuint negate_v:1;
24 GLuint negate_s:1;
25 GLuint absolute:1;
26 GLboolean no_use:1;
27 GLboolean valid:1;
28 } pfs_reg_t;
29
30 typedef struct r300_fragment_program_swizzle {
31 GLuint length;
32 GLuint src[4];
33 GLuint inst[8];
34 } r300_fragment_program_swizzle_t;
35
36 /* supported hw opcodes */
37 #define PFS_OP_MAD 0
38 #define PFS_OP_DP3 1
39 #define PFS_OP_DP4 2
40 #define PFS_OP_MIN 3
41 #define PFS_OP_MAX 4
42 #define PFS_OP_CMP 5
43 #define PFS_OP_FRC 6
44 #define PFS_OP_EX2 7
45 #define PFS_OP_LG2 8
46 #define PFS_OP_RCP 9
47 #define PFS_OP_RSQ 10
48 #define PFS_OP_REPL_ALPHA 11
49 #define MAX_PFS_OP 11
50
51 #define PFS_FLAG_SAT (1 << 0)
52 #define PFS_FLAG_ABS (1 << 1)
53
54 #define ARG_NEG (1 << 5)
55 #define ARG_ABS (1 << 6)
56 #define ARG_MASK (127 << 0)
57 #define ARG_STRIDE 7
58 #define SRC_CONST (1 << 5)
59 #define SRC_MASK (63 << 0)
60 #define SRC_STRIDE 6
61
62 #define NOP_INST0 ( \
63 (R300_FPI0_OUTC_MAD) | \
64 (R300_FPI0_ARGC_ZERO << R300_FPI0_ARG0C_SHIFT) | \
65 (R300_FPI0_ARGC_ZERO << R300_FPI0_ARG1C_SHIFT) | \
66 (R300_FPI0_ARGC_ZERO << R300_FPI0_ARG2C_SHIFT))
67 #define NOP_INST1 ( \
68 ((0 | SRC_CONST) << R300_FPI1_SRC0C_SHIFT) | \
69 ((0 | SRC_CONST) << R300_FPI1_SRC1C_SHIFT) | \
70 ((0 | SRC_CONST) << R300_FPI1_SRC2C_SHIFT))
71 #define NOP_INST2 ( \
72 (R300_FPI2_OUTA_MAD) | \
73 (R300_FPI2_ARGA_ZERO << R300_FPI2_ARG0A_SHIFT) | \
74 (R300_FPI2_ARGA_ZERO << R300_FPI2_ARG1A_SHIFT) | \
75 (R300_FPI2_ARGA_ZERO << R300_FPI2_ARG2A_SHIFT))
76 #define NOP_INST3 ( \
77 ((0 | SRC_CONST) << R300_FPI3_SRC0A_SHIFT) | \
78 ((0 | SRC_CONST) << R300_FPI3_SRC1A_SHIFT) | \
79 ((0 | SRC_CONST) << R300_FPI3_SRC2A_SHIFT))
80
81 #include "r300_context.h"
82
83 struct r300_fragment_program;
84
85 extern void r300_translate_fragment_shader(struct r300_fragment_program *rp);
86
87 #endif
88