r300: Reduce include dependencies
[mesa.git] / src / mesa / drivers / dri / r300 / compiler / radeon_code.h
1 /*
2 * Copyright 2009 Nicolai Hähnle <nhaehnle@gmail.com>
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * on the rights to use, copy, modify, merge, publish, distribute, sub
8 * license, and/or sell copies of the Software, and to permit persons to whom
9 * the Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21 * USE OR OTHER DEALINGS IN THE SOFTWARE. */
22
23 #ifndef RADEON_CODE_H
24 #define RADEON_CODE_H
25
26
27 #define R300_PFS_MAX_ALU_INST 64
28 #define R300_PFS_MAX_TEX_INST 32
29 #define R300_PFS_MAX_TEX_INDIRECT 4
30 #define R300_PFS_NUM_TEMP_REGS 32
31 #define R300_PFS_NUM_CONST_REGS 32
32
33 #define R500_PFS_MAX_INST 512
34 #define R500_PFS_NUM_TEMP_REGS 128
35 #define R500_PFS_NUM_CONST_REGS 256
36
37
38 #define STATE_R300_WINDOW_DIMENSION (STATE_INTERNAL_DRIVER+0)
39 #define STATE_R300_TEXRECT_FACTOR (STATE_INTERNAL_DRIVER+1)
40
41
42 /**
43 * Stores state that influences the compilation of a fragment program.
44 */
45 struct r300_fragment_program_external_state {
46 struct {
47 /**
48 * If the sampler is used as a shadow sampler,
49 * this field is:
50 * 0 - GL_LUMINANCE
51 * 1 - GL_INTENSITY
52 * 2 - GL_ALPHA
53 * depending on the depth texture mode.
54 */
55 GLuint depth_texture_mode : 2;
56
57 /**
58 * If the sampler is used as a shadow sampler,
59 * this field is (texture_compare_func - GL_NEVER).
60 * [e.g. if compare function is GL_LEQUAL, this field is 3]
61 *
62 * Otherwise, this field is 0.
63 */
64 GLuint texture_compare_func : 3;
65 } unit[16];
66 };
67
68
69
70 struct r300_fragment_program_node {
71 int tex_offset; /**< first tex instruction */
72 int tex_end; /**< last tex instruction, relative to tex_offset */
73 int alu_offset; /**< first ALU instruction */
74 int alu_end; /**< last ALU instruction, relative to alu_offset */
75 int flags;
76 };
77
78 /**
79 * Stores an R300 fragment program in its compiled-to-hardware form.
80 */
81 struct r300_fragment_program_code {
82 struct {
83 int length; /**< total # of texture instructions used */
84 GLuint inst[R300_PFS_MAX_TEX_INST];
85 } tex;
86
87 struct {
88 int length; /**< total # of ALU instructions used */
89 struct {
90 GLuint inst0;
91 GLuint inst1;
92 GLuint inst2;
93 GLuint inst3;
94 } inst[R300_PFS_MAX_ALU_INST];
95 } alu;
96
97 struct r300_fragment_program_node node[4];
98 int cur_node;
99 int first_node_has_tex;
100
101 /**
102 * Remember which program register a given hardware constant
103 * belongs to.
104 */
105 struct prog_src_register constant[R300_PFS_NUM_CONST_REGS];
106 int const_nr;
107
108 int max_temp_idx;
109 };
110
111
112 struct r500_fragment_program_code {
113 struct {
114 GLuint inst0;
115 GLuint inst1;
116 GLuint inst2;
117 GLuint inst3;
118 GLuint inst4;
119 GLuint inst5;
120 } inst[R500_PFS_MAX_INST];
121
122 int inst_offset;
123 int inst_end;
124
125 /**
126 * Remember which program register a given hardware constant
127 * belongs to.
128 */
129 struct prog_src_register constant[R500_PFS_NUM_CONST_REGS];
130 int const_nr;
131
132 int max_temp_idx;
133 };
134
135 struct rX00_fragment_program_code {
136 union {
137 struct r300_fragment_program_code r300;
138 struct r500_fragment_program_code r500;
139 } code;
140
141 GLboolean writes_depth;
142
143 /* attribute that we are sending the WPOS in */
144 gl_frag_attrib wpos_attr;
145 /* attribute that we are sending the fog coordinate in */
146 gl_frag_attrib fog_attr;
147 };
148
149
150 #endif /* RADEON_CODE_H */