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. */
23 #ifndef RADEON_COMPILER_H
24 #define RADEON_COMPILER_H
26 #include "main/mtypes.h"
27 #include "shader/prog_instruction.h"
29 #define R300_PFS_MAX_ALU_INST 64
30 #define R300_PFS_MAX_TEX_INST 32
31 #define R300_PFS_MAX_TEX_INDIRECT 4
32 #define R300_PFS_NUM_TEMP_REGS 32
33 #define R300_PFS_NUM_CONST_REGS 32
35 #define R500_PFS_MAX_INST 512
36 #define R500_PFS_NUM_TEMP_REGS 128
37 #define R500_PFS_NUM_CONST_REGS 256
40 #define STATE_R300_WINDOW_DIMENSION (STATE_INTERNAL_DRIVER+0)
41 #define STATE_R300_TEXRECT_FACTOR (STATE_INTERNAL_DRIVER+1)
45 * Stores state that influences the compilation of a fragment program.
47 struct r300_fragment_program_external_state
{
50 * If the sampler is used as a shadow sampler,
55 * depending on the depth texture mode.
57 GLuint depth_texture_mode
: 2;
60 * If the sampler is used as a shadow sampler,
61 * this field is (texture_compare_func - GL_NEVER).
62 * [e.g. if compare function is GL_LEQUAL, this field is 3]
64 * Otherwise, this field is 0.
66 GLuint texture_compare_func
: 3;
72 struct r300_fragment_program_node
{
73 int tex_offset
; /**< first tex instruction */
74 int tex_end
; /**< last tex instruction, relative to tex_offset */
75 int alu_offset
; /**< first ALU instruction */
76 int alu_end
; /**< last ALU instruction, relative to alu_offset */
81 * Stores an R300 fragment program in its compiled-to-hardware form.
83 struct r300_fragment_program_code
{
85 int length
; /**< total # of texture instructions used */
86 GLuint inst
[R300_PFS_MAX_TEX_INST
];
90 int length
; /**< total # of ALU instructions used */
96 } inst
[R300_PFS_MAX_ALU_INST
];
99 struct r300_fragment_program_node node
[4];
101 int first_node_has_tex
;
104 * Remember which program register a given hardware constant
107 struct prog_src_register constant
[R300_PFS_NUM_CONST_REGS
];
114 struct r500_fragment_program_code
{
122 } inst
[R500_PFS_MAX_INST
];
128 * Remember which program register a given hardware constant
131 struct prog_src_register constant
[R500_PFS_NUM_CONST_REGS
];
137 struct rX00_fragment_program_code
{
139 struct r300_fragment_program_code r300
;
140 struct r500_fragment_program_code r500
;
143 GLboolean writes_depth
;
145 /* attribute that we are sending the WPOS in */
146 gl_frag_attrib wpos_attr
;
147 /* attribute that we are sending the fog coordinate in */
148 gl_frag_attrib fog_attr
;
151 struct r300_fragment_program_compiler
{
153 struct rX00_fragment_program_code
*code
;
154 struct gl_program
*program
;
155 struct r300_fragment_program_external_state state
;
160 GLboolean
r3xx_compile_fragment_program(struct r300_fragment_program_compiler
* c
);
162 #endif /* RADEON_COMPILER_H */