Merge branch 'mesa_7_5_branch' into mesa_7_6_branch
[mesa.git] / src / mesa / drivers / dri / r300 / compiler / radeon_program_pair.h
1 /*
2 * Copyright (C) 2008 Nicolai Haehnle.
3 *
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining
7 * a copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sublicense, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial
16 * portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21 * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
22 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 */
27
28 #ifndef __RADEON_PROGRAM_PAIR_H_
29 #define __RADEON_PROGRAM_PAIR_H_
30
31 #include "radeon_program.h"
32
33 struct r300_fragment_program_compiler;
34
35
36 /**
37 * Represents a paired instruction, as found in R300 and R500
38 * fragment programs.
39 */
40 struct radeon_pair_instruction_source {
41 GLuint Index:8;
42 GLuint Constant:1;
43 GLuint Used:1;
44 };
45
46 struct radeon_pair_instruction_rgb {
47 GLuint Opcode:8;
48 GLuint DestIndex:8;
49 GLuint WriteMask:3;
50 GLuint OutputWriteMask:3;
51 GLuint Saturate:1;
52
53 struct radeon_pair_instruction_source Src[3];
54
55 struct {
56 GLuint Source:2;
57 GLuint Swizzle:9;
58 GLuint Abs:1;
59 GLuint Negate:1;
60 } Arg[3];
61 };
62
63 struct radeon_pair_instruction_alpha {
64 GLuint Opcode:8;
65 GLuint DestIndex:8;
66 GLuint WriteMask:1;
67 GLuint OutputWriteMask:1;
68 GLuint DepthWriteMask:1;
69 GLuint Saturate:1;
70
71 struct radeon_pair_instruction_source Src[3];
72
73 struct {
74 GLuint Source:2;
75 GLuint Swizzle:3;
76 GLuint Abs:1;
77 GLuint Negate:1;
78 } Arg[3];
79 };
80
81 struct radeon_pair_instruction {
82 struct radeon_pair_instruction_rgb RGB;
83 struct radeon_pair_instruction_alpha Alpha;
84 };
85
86
87 enum {
88 RADEON_OPCODE_TEX = 0,
89 RADEON_OPCODE_TXB,
90 RADEON_OPCODE_TXP,
91 RADEON_OPCODE_KIL
92 };
93
94 struct radeon_pair_texture_instruction {
95 GLuint Opcode:2; /**< one of RADEON_OPCODE_xxx */
96
97 GLuint DestIndex:8;
98 GLuint WriteMask:4;
99
100 GLuint TexSrcUnit:5;
101 GLuint TexSrcTarget:3;
102
103 GLuint SrcIndex:8;
104 GLuint SrcSwizzle:12;
105 };
106
107
108 /**
109 *
110 */
111 struct radeon_pair_handler {
112 /**
113 * Write a paired instruction to the hardware.
114 *
115 * @return GL_FALSE on error.
116 */
117 GLboolean (*EmitPaired)(void*, struct radeon_pair_instruction*);
118
119 /**
120 * Write a texture instruction to the hardware.
121 * Register indices have already been rewritten to the allocated
122 * hardware register numbers.
123 *
124 * @return GL_FALSE on error.
125 */
126 GLboolean (*EmitTex)(void*, struct radeon_pair_texture_instruction*);
127
128 /**
129 * Called before a block of contiguous, independent texture
130 * instructions is emitted.
131 */
132 GLboolean (*BeginTexBlock)(void*);
133
134 unsigned MaxHwTemps;
135 };
136
137 void radeonPairProgram(
138 struct r300_fragment_program_compiler * compiler,
139 const struct radeon_pair_handler*, void *userdata);
140
141 void radeonPrintPairInstruction(struct radeon_pair_instruction *inst);
142
143 #endif /* __RADEON_PROGRAM_PAIR_H_ */