Merge remote branch 'origin/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_code.h"
32 #include "radeon_opcodes.h"
33 #include "radeon_program_constants.h"
34
35 struct r300_fragment_program_compiler;
36
37
38 /**
39 * \file
40 * Represents a paired ALU instruction, as found in R300 and R500
41 * fragment programs.
42 *
43 * Note that this representation is taking some liberties as far
44 * as register files are concerned, to allow separate register
45 * allocation.
46 *
47 * Also note that there are some subtleties in that the semantics
48 * of certain opcodes are implicitly changed in this representation;
49 * see \ref rc_pair_translate
50 */
51
52
53 struct radeon_pair_instruction_source {
54 unsigned int Used:1;
55 rc_register_file File:3;
56 unsigned int Index:RC_REGISTER_INDEX_BITS;
57 };
58
59 struct radeon_pair_instruction_rgb {
60 rc_opcode Opcode:8;
61 unsigned int DestIndex:RC_REGISTER_INDEX_BITS;
62 unsigned int WriteMask:3;
63 unsigned int OutputWriteMask:3;
64 unsigned int Saturate:1;
65
66 struct radeon_pair_instruction_source Src[3];
67
68 struct {
69 unsigned int Source:2;
70 unsigned int Swizzle:9;
71 unsigned int Abs:1;
72 unsigned int Negate:1;
73 } Arg[3];
74 };
75
76 struct radeon_pair_instruction_alpha {
77 rc_opcode Opcode:8;
78 unsigned int DestIndex:RC_REGISTER_INDEX_BITS;
79 unsigned int WriteMask:1;
80 unsigned int OutputWriteMask:1;
81 unsigned int DepthWriteMask:1;
82 unsigned int Saturate:1;
83
84 struct radeon_pair_instruction_source Src[3];
85
86 struct {
87 unsigned int Source:2;
88 unsigned int Swizzle:3;
89 unsigned int Abs:1;
90 unsigned int Negate:1;
91 } Arg[3];
92 };
93
94 struct rc_pair_instruction {
95 struct radeon_pair_instruction_rgb RGB;
96 struct radeon_pair_instruction_alpha Alpha;
97
98 rc_write_aluresult WriteALUResult:2;
99 rc_compare_func ALUResultCompare:3;
100 };
101
102
103 /**
104 * General helper functions for dealing with the paired instruction format.
105 */
106 /*@{*/
107 int rc_pair_alloc_source(struct rc_pair_instruction *pair,
108 unsigned int rgb, unsigned int alpha,
109 rc_register_file file, unsigned int index);
110 /*@}*/
111
112
113 /**
114 * Compiler passes that operate with the paired format.
115 */
116 /*@{*/
117 struct radeon_pair_handler;
118
119 void rc_pair_translate(struct r300_fragment_program_compiler *c);
120 void rc_pair_schedule(struct r300_fragment_program_compiler *c);
121 void rc_pair_regalloc(struct r300_fragment_program_compiler *c, unsigned maxtemps);
122 /*@}*/
123
124 #endif /* __RADEON_PROGRAM_PAIR_H_ */