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. */
26 #define R300_PFS_MAX_ALU_INST 64
27 #define R300_PFS_MAX_TEX_INST 32
28 #define R300_PFS_MAX_TEX_INDIRECT 4
29 #define R300_PFS_NUM_TEMP_REGS 32
30 #define R300_PFS_NUM_CONST_REGS 32
32 #define R500_PFS_MAX_INST 512
33 #define R500_PFS_NUM_TEMP_REGS 128
34 #define R500_PFS_NUM_CONST_REGS 256
37 #define STATE_R300_WINDOW_DIMENSION (STATE_INTERNAL_DRIVER+0)
41 * External constants are constants whose meaning is unknown to this
42 * compiler. For example, a Mesa gl_program's constants are turned
43 * into external constants.
45 RC_CONSTANT_EXTERNAL
= 0,
47 RC_CONSTANT_IMMEDIATE
,
50 * Constant referring to state that is known by this compiler,
51 * see RC_STATE_xxx, i.e. *not* arbitrary Mesa (or other) state.
57 RC_STATE_SHADOW_AMBIENT
= 0,
59 RC_STATE_R300_WINDOW_DIMENSION
,
60 RC_STATE_R300_TEXRECT_FACTOR
64 unsigned Type
:2; /**< RC_CONSTANT_xxx */
74 struct rc_constant_list
{
75 struct rc_constant
* Constants
;
81 void rc_constants_init(struct rc_constant_list
* c
);
82 void rc_constants_copy(struct rc_constant_list
* dst
, struct rc_constant_list
* src
);
83 void rc_constants_destroy(struct rc_constant_list
* c
);
84 unsigned rc_constants_add(struct rc_constant_list
* c
, struct rc_constant
* constant
);
85 unsigned rc_constants_add_state(struct rc_constant_list
* c
, unsigned state1
, unsigned state2
);
86 unsigned rc_constants_add_immediate_vec4(struct rc_constant_list
* c
, const float * data
);
87 unsigned rc_constants_add_immediate_scalar(struct rc_constant_list
* c
, float data
, unsigned * swizzle
);
90 * Stores state that influences the compilation of a fragment program.
92 struct r300_fragment_program_external_state
{
95 * If the sampler is used as a shadow sampler,
100 * depending on the depth texture mode.
102 GLuint depth_texture_mode
: 2;
105 * If the sampler is used as a shadow sampler,
106 * this field is (texture_compare_func - GL_NEVER).
107 * [e.g. if compare function is GL_LEQUAL, this field is 3]
109 * Otherwise, this field is 0.
111 GLuint texture_compare_func
: 3;
117 struct r300_fragment_program_node
{
118 int tex_offset
; /**< first tex instruction */
119 int tex_end
; /**< last tex instruction, relative to tex_offset */
120 int alu_offset
; /**< first ALU instruction */
121 int alu_end
; /**< last ALU instruction, relative to alu_offset */
126 * Stores an R300 fragment program in its compiled-to-hardware form.
128 struct r300_fragment_program_code
{
130 int length
; /**< total # of texture instructions used */
131 GLuint inst
[R300_PFS_MAX_TEX_INST
];
135 int length
; /**< total # of ALU instructions used */
141 } inst
[R300_PFS_MAX_ALU_INST
];
144 struct r300_fragment_program_node node
[4];
146 int first_node_has_tex
;
152 struct r500_fragment_program_code
{
160 } inst
[R500_PFS_MAX_INST
];
168 struct rX00_fragment_program_code
{
170 struct r300_fragment_program_code r300
;
171 struct r500_fragment_program_code r500
;
174 GLboolean writes_depth
;
176 struct rc_constant_list constants
;
180 #define VSF_MAX_FRAGMENT_LENGTH (255*4)
181 #define VSF_MAX_FRAGMENT_TEMPS (14)
183 struct r300_vertex_program_code
{
186 GLuint d
[VSF_MAX_FRAGMENT_LENGTH
];
187 float f
[VSF_MAX_FRAGMENT_LENGTH
];
191 int num_temporaries
; /* Number of temp vars used by program */
192 int inputs
[VERT_ATTRIB_MAX
];
193 int outputs
[VERT_RESULT_MAX
];
195 struct rc_constant_list constants
;
197 GLbitfield InputsRead
;
198 GLbitfield OutputsWritten
;
201 #endif /* RADEON_CODE_H */