~ubuntu-branches/ubuntu/precise/mesa/precise-updates

« back to all changes in this revision

Viewing changes to src/mesa/drivers/dri/r300/compiler/radeon_code.h

  • Committer: Package Import Robot
  • Author(s): Robert Hooker
  • Date: 2012-02-02 12:05:48 UTC
  • mfrom: (1.7.1) (3.3.27 sid)
  • Revision ID: package-import@ubuntu.com-20120202120548-nvkma85jq0h4coix
Tags: 8.0~rc2-0ubuntu4
Drop drisearchdir handling, it is no longer needed with multiarch
and dri-alternates being removed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
#include <stdint.h>
27
 
 
28
 
#define R300_PFS_MAX_ALU_INST     64
29
 
#define R300_PFS_MAX_TEX_INST     32
30
 
#define R300_PFS_MAX_TEX_INDIRECT 4
31
 
#define R300_PFS_NUM_TEMP_REGS    32
32
 
#define R300_PFS_NUM_CONST_REGS   32
33
 
 
34
 
#define R400_PFS_MAX_ALU_INST     512
35
 
#define R400_PFS_MAX_TEX_INST     512
36
 
 
37
 
#define R500_PFS_MAX_INST         512
38
 
#define R500_PFS_NUM_TEMP_REGS    128
39
 
#define R500_PFS_NUM_CONST_REGS   256
40
 
#define R500_PFS_MAX_BRANCH_DEPTH_FULL 32
41
 
#define R500_PFS_MAX_BRANCH_DEPTH_PARTIAL 4
42
 
 
43
 
 
44
 
#define STATE_R300_WINDOW_DIMENSION (STATE_INTERNAL_DRIVER+0)
45
 
 
46
 
enum {
47
 
        /**
48
 
         * External constants are constants whose meaning is unknown to this
49
 
         * compiler. For example, a Mesa gl_program's constants are turned
50
 
         * into external constants.
51
 
         */
52
 
        RC_CONSTANT_EXTERNAL = 0,
53
 
 
54
 
        RC_CONSTANT_IMMEDIATE,
55
 
 
56
 
        /**
57
 
         * Constant referring to state that is known by this compiler,
58
 
         * see RC_STATE_xxx, i.e. *not* arbitrary Mesa (or other) state.
59
 
         */
60
 
        RC_CONSTANT_STATE
61
 
};
62
 
 
63
 
enum {
64
 
        RC_STATE_SHADOW_AMBIENT = 0,
65
 
 
66
 
        RC_STATE_R300_WINDOW_DIMENSION,
67
 
        RC_STATE_R300_TEXRECT_FACTOR,
68
 
        RC_STATE_R300_TEXSCALE_FACTOR,
69
 
        RC_STATE_R300_VIEWPORT_SCALE,
70
 
        RC_STATE_R300_VIEWPORT_OFFSET
71
 
};
72
 
 
73
 
struct rc_constant {
74
 
        unsigned Type:2; /**< RC_CONSTANT_xxx */
75
 
        unsigned Size:3;
76
 
 
77
 
        union {
78
 
                unsigned External;
79
 
                float Immediate[4];
80
 
                unsigned State[2];
81
 
        } u;
82
 
};
83
 
 
84
 
struct rc_constant_list {
85
 
        struct rc_constant * Constants;
86
 
        unsigned Count;
87
 
 
88
 
        unsigned _Reserved;
89
 
};
90
 
 
91
 
void rc_constants_init(struct rc_constant_list * c);
92
 
void rc_constants_copy(struct rc_constant_list * dst, struct rc_constant_list * src);
93
 
void rc_constants_destroy(struct rc_constant_list * c);
94
 
unsigned rc_constants_add(struct rc_constant_list * c, struct rc_constant * constant);
95
 
unsigned rc_constants_add_state(struct rc_constant_list * c, unsigned state1, unsigned state2);
96
 
unsigned rc_constants_add_immediate_vec4(struct rc_constant_list * c, const float * data);
97
 
unsigned rc_constants_add_immediate_scalar(struct rc_constant_list * c, float data, unsigned * swizzle);
98
 
void rc_constants_print(struct rc_constant_list * c);
99
 
 
100
 
/**
101
 
 * Compare functions.
102
 
 *
103
 
 * \note By design, RC_COMPARE_FUNC_xxx + GL_NEVER gives you
104
 
 * the correct GL compare function.
105
 
 */
106
 
typedef enum {
107
 
        RC_COMPARE_FUNC_NEVER = 0,
108
 
        RC_COMPARE_FUNC_LESS,
109
 
        RC_COMPARE_FUNC_EQUAL,
110
 
        RC_COMPARE_FUNC_LEQUAL,
111
 
        RC_COMPARE_FUNC_GREATER,
112
 
        RC_COMPARE_FUNC_NOTEQUAL,
113
 
        RC_COMPARE_FUNC_GEQUAL,
114
 
        RC_COMPARE_FUNC_ALWAYS
115
 
} rc_compare_func;
116
 
 
117
 
/**
118
 
 * Coordinate wrapping modes.
119
 
 *
120
 
 * These are not quite the same as their GL counterparts yet.
121
 
 */
122
 
typedef enum {
123
 
        RC_WRAP_NONE = 0,
124
 
        RC_WRAP_REPEAT,
125
 
        RC_WRAP_MIRRORED_REPEAT,
126
 
        RC_WRAP_MIRRORED_CLAMP
127
 
} rc_wrap_mode;
128
 
 
129
 
/**
130
 
 * Stores state that influences the compilation of a fragment program.
131
 
 */
132
 
struct r300_fragment_program_external_state {
133
 
        struct {
134
 
                /**
135
 
                 * This field contains swizzle for some lowering passes
136
 
                 * (shadow comparison, unorm->snorm conversion)
137
 
                 */
138
 
                unsigned texture_swizzle:12;
139
 
 
140
 
                /**
141
 
                 * If the sampler is used as a shadow sampler,
142
 
                 * this field specifies the compare function.
143
 
                 *
144
 
                 * Otherwise, this field is \ref RC_COMPARE_FUNC_NEVER (aka 0).
145
 
                 * \sa rc_compare_func
146
 
                 */
147
 
                unsigned texture_compare_func : 3;
148
 
 
149
 
                /**
150
 
                 * No matter what the sampler type is,
151
 
                 * this field turns it into a shadow sampler.
152
 
                 */
153
 
                unsigned compare_mode_enabled : 1;
154
 
 
155
 
                /**
156
 
                 * If the sampler will receive non-normalized coords,
157
 
                 * this field is set. The scaling factor is given by
158
 
                 * RC_STATE_R300_TEXRECT_FACTOR.
159
 
                 */
160
 
                unsigned non_normalized_coords : 1;
161
 
 
162
 
                /**
163
 
                 * This field specifies wrapping modes for the sampler.
164
 
                 *
165
 
                 * If this field is \ref RC_WRAP_NONE (aka 0), no wrapping maths
166
 
                 * will be performed on the coordinates.
167
 
                 */
168
 
                unsigned wrap_mode : 3;
169
 
 
170
 
                /**
171
 
                 * The coords are scaled after applying the wrap mode emulation
172
 
                 * and right before texture fetch. The scaling factor is given by
173
 
                 * RC_STATE_R300_TEXSCALE_FACTOR. */
174
 
                unsigned clamp_and_scale_before_fetch : 1;
175
 
 
176
 
                /**
177
 
                 * Fetch RGTC1_SNORM or LATC1_SNORM as UNORM and convert UNORM -> SNORM
178
 
                 * in the shader.
179
 
                 */
180
 
                unsigned convert_unorm_to_snorm:1;
181
 
        } unit[16];
182
 
 
183
 
        unsigned frag_clamp:1;
184
 
};
185
 
 
186
 
 
187
 
 
188
 
struct r300_fragment_program_node {
189
 
        int tex_offset; /**< first tex instruction */
190
 
        int tex_end; /**< last tex instruction, relative to tex_offset */
191
 
        int alu_offset; /**< first ALU instruction */
192
 
        int alu_end; /**< last ALU instruction, relative to alu_offset */
193
 
        int flags;
194
 
};
195
 
 
196
 
/**
197
 
 * Stores an R300 fragment program in its compiled-to-hardware form.
198
 
 */
199
 
struct r300_fragment_program_code {
200
 
        struct {
201
 
                unsigned int length; /**< total # of texture instructions used */
202
 
                uint32_t inst[R400_PFS_MAX_TEX_INST];
203
 
        } tex;
204
 
 
205
 
        struct {
206
 
                unsigned int length; /**< total # of ALU instructions used */
207
 
                struct {
208
 
                        uint32_t rgb_inst;
209
 
                        uint32_t rgb_addr;
210
 
                        uint32_t alpha_inst;
211
 
                        uint32_t alpha_addr;
212
 
                        uint32_t r400_ext_addr;
213
 
                } inst[R400_PFS_MAX_ALU_INST];
214
 
        } alu;
215
 
 
216
 
        uint32_t config; /* US_CONFIG */
217
 
        uint32_t pixsize; /* US_PIXSIZE */
218
 
        uint32_t code_offset; /* US_CODE_OFFSET */
219
 
        uint32_t r400_code_offset_ext; /* US_CODE_EXT */
220
 
        uint32_t code_addr[4]; /* US_CODE_ADDR */
221
 
        /*US_CODE_BANK.R390_MODE: Enables 512 instructions and 64 temporaries
222
 
         * for r400 cards */
223
 
        unsigned int r390_mode:1;
224
 
};
225
 
 
226
 
 
227
 
struct r500_fragment_program_code {
228
 
        struct {
229
 
                uint32_t inst0;
230
 
                uint32_t inst1;
231
 
                uint32_t inst2;
232
 
                uint32_t inst3;
233
 
                uint32_t inst4;
234
 
                uint32_t inst5;
235
 
        } inst[R500_PFS_MAX_INST];
236
 
 
237
 
        int inst_end; /* Number of instructions - 1; also, last instruction to be executed */
238
 
 
239
 
        int max_temp_idx;
240
 
 
241
 
        uint32_t us_fc_ctrl;
242
 
 
243
 
        uint32_t int_constants[32];
244
 
        uint32_t int_constant_count;
245
 
};
246
 
 
247
 
struct rX00_fragment_program_code {
248
 
        union {
249
 
                struct r300_fragment_program_code r300;
250
 
                struct r500_fragment_program_code r500;
251
 
        } code;
252
 
 
253
 
        unsigned writes_depth:1;
254
 
 
255
 
        struct rc_constant_list constants;
256
 
        unsigned *constants_remap_table;
257
 
};
258
 
 
259
 
 
260
 
#define R300_VS_MAX_ALU         256
261
 
#define R300_VS_MAX_ALU_DWORDS  (R300_VS_MAX_ALU * 4)
262
 
#define R500_VS_MAX_ALU         1024
263
 
#define R500_VS_MAX_ALU_DWORDS  (R500_VS_MAX_ALU * 4)
264
 
#define R300_VS_MAX_TEMPS       32
265
 
/* This is the max for all chipsets (r300-r500) */
266
 
#define R300_VS_MAX_FC_OPS 16
267
 
/* The r500 maximum depth is not just for loops, but any combination of loops
268
 
 * and subroutine jumps. */
269
 
#define R500_VS_MAX_FC_DEPTH 8
270
 
#define R300_VS_MAX_LOOP_DEPTH 1
271
 
 
272
 
#define VSF_MAX_INPUTS 32
273
 
#define VSF_MAX_OUTPUTS 32
274
 
 
275
 
struct r300_vertex_program_code {
276
 
        int length;
277
 
        union {
278
 
                uint32_t d[R500_VS_MAX_ALU_DWORDS];
279
 
                float f[R500_VS_MAX_ALU_DWORDS];
280
 
        } body;
281
 
 
282
 
        int pos_end;
283
 
        int num_temporaries;    /* Number of temp vars used by program */
284
 
        int inputs[VSF_MAX_INPUTS];
285
 
        int outputs[VSF_MAX_OUTPUTS];
286
 
 
287
 
        struct rc_constant_list constants;
288
 
        unsigned *constants_remap_table;
289
 
 
290
 
        uint32_t InputsRead;
291
 
        uint32_t OutputsWritten;
292
 
 
293
 
        unsigned int num_fc_ops;
294
 
        uint32_t fc_ops;
295
 
        union {
296
 
                uint32_t r300[R300_VS_MAX_FC_OPS];
297
 
                struct {
298
 
                        uint32_t lw;
299
 
                        uint32_t uw;
300
 
                } r500[R300_VS_MAX_FC_OPS];
301
 
        } fc_op_addrs;
302
 
        int32_t fc_loop_index[R300_VS_MAX_FC_OPS];
303
 
};
304
 
 
305
 
#endif /* RADEON_CODE_H */
306