2 * Copyright 2009 Nicolai Hähnle <nhaehnle@gmail.com>
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:
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
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. */
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
34 #define R500_PFS_MAX_INST 512
35 #define R500_PFS_NUM_TEMP_REGS 128
36 #define R500_PFS_NUM_CONST_REGS 256
39 #define STATE_R300_WINDOW_DIMENSION (STATE_INTERNAL_DRIVER+0)
43 * External constants are constants whose meaning is unknown to this
44 * compiler. For example, a Mesa gl_program's constants are turned
45 * into external constants.
47 RC_CONSTANT_EXTERNAL
= 0,
49 RC_CONSTANT_IMMEDIATE
,
52 * Constant referring to state that is known by this compiler,
53 * see RC_STATE_xxx, i.e. *not* arbitrary Mesa (or other) state.
59 RC_STATE_SHADOW_AMBIENT
= 0,
61 RC_STATE_R300_WINDOW_DIMENSION
,
62 RC_STATE_R300_TEXRECT_FACTOR
66 unsigned Type
:2; /**< RC_CONSTANT_xxx */
76 struct rc_constant_list
{
77 struct rc_constant
* Constants
;
83 void rc_constants_init(struct rc_constant_list
* c
);
84 void rc_constants_copy(struct rc_constant_list
* dst
, struct rc_constant_list
* src
);
85 void rc_constants_destroy(struct rc_constant_list
* c
);
86 unsigned rc_constants_add(struct rc_constant_list
* c
, struct rc_constant
* constant
);
87 unsigned rc_constants_add_state(struct rc_constant_list
* c
, unsigned state1
, unsigned state2
);
88 unsigned rc_constants_add_immediate_vec4(struct rc_constant_list
* c
, const float * data
);
89 unsigned rc_constants_add_immediate_scalar(struct rc_constant_list
* c
, float data
, unsigned * swizzle
);
94 * \note By design, RC_COMPARE_FUNC_xxx + GL_NEVER gives you
95 * the correct GL compare function.
98 RC_COMPARE_FUNC_NEVER
= 0,
100 RC_COMPARE_FUNC_EQUAL
,
101 RC_COMPARE_FUNC_LEQUAL
,
102 RC_COMPARE_FUNC_GREATER
,
103 RC_COMPARE_FUNC_NOTEQUAL
,
104 RC_COMPARE_FUNC_GEQUAL
,
105 RC_COMPARE_FUNC_ALWAYS
109 * Stores state that influences the compilation of a fragment program.
111 struct r300_fragment_program_external_state
{
114 * If the sampler is used as a shadow sampler,
119 * depending on the depth texture mode.
121 unsigned depth_texture_mode
: 2;
124 * If the sampler is used as a shadow sampler,
125 * this field specifies the compare function.
127 * Otherwise, this field is \ref RC_COMPARE_FUNC_NEVER (aka 0).
129 * Otherwise, this field is 0.
130 * \sa rc_compare_func
132 unsigned texture_compare_func
: 3;
138 struct r300_fragment_program_node
{
139 int tex_offset
; /**< first tex instruction */
140 int tex_end
; /**< last tex instruction, relative to tex_offset */
141 int alu_offset
; /**< first ALU instruction */
142 int alu_end
; /**< last ALU instruction, relative to alu_offset */
147 * Stores an R300 fragment program in its compiled-to-hardware form.
149 struct r300_fragment_program_code
{
151 int length
; /**< total # of texture instructions used */
152 uint32_t inst
[R300_PFS_MAX_TEX_INST
];
156 int length
; /**< total # of ALU instructions used */
162 } inst
[R300_PFS_MAX_ALU_INST
];
165 uint32_t config
; /* US_CONFIG */
166 uint32_t pixsize
; /* US_PIXSIZE */
167 uint32_t code_offset
; /* US_CODE_OFFSET */
168 uint32_t code_addr
[4]; /* US_CODE_ADDR */
172 struct r500_fragment_program_code
{
180 } inst
[R500_PFS_MAX_INST
];
182 int inst_end
; /* Number of instructions - 1; also, last instruction to be executed */
189 struct rX00_fragment_program_code
{
191 struct r300_fragment_program_code r300
;
192 struct r500_fragment_program_code r500
;
195 unsigned writes_depth
:1;
197 struct rc_constant_list constants
;
201 #define VSF_MAX_FRAGMENT_LENGTH (255*4)
202 #define VSF_MAX_FRAGMENT_TEMPS (14)
204 #define VSF_MAX_INPUTS 32
205 #define VSF_MAX_OUTPUTS 32
207 struct r300_vertex_program_code
{
210 uint32_t d
[VSF_MAX_FRAGMENT_LENGTH
];
211 float f
[VSF_MAX_FRAGMENT_LENGTH
];
215 int num_temporaries
; /* Number of temp vars used by program */
216 int inputs
[VSF_MAX_INPUTS
];
217 int outputs
[VSF_MAX_OUTPUTS
];
219 struct rc_constant_list constants
;
222 uint32_t OutputsWritten
;
225 void r300_vertex_program_dump(struct r300_vertex_program_code
* vs
);
227 #endif /* RADEON_CODE_H */