2 * Copyright (C) 2008 Nicolai Haehnle.
6 * Permission is hereby granted, free of charge, to any person obtaining
7 * a copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sublicense, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial
16 * portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21 * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
22 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 #ifndef __RADEON_PROGRAM_H_
29 #define __RADEON_PROGRAM_H_
34 #include "shader/program.h"
35 #include "shader/prog_instruction.h"
45 PROGRAM_BUILTIN
= PROGRAM_FILE_MAX
/**< not a real register, but a special swizzle constant */
48 #define SWIZZLE_0000 MAKE_SWIZZLE4(SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ZERO)
49 #define SWIZZLE_1111 MAKE_SWIZZLE4(SWIZZLE_ONE, SWIZZLE_ONE, SWIZZLE_ONE, SWIZZLE_ONE)
52 * A clause is simply a sequence of instructions that are executed
55 struct radeon_clause
{
57 * Type of this clause, one of CLAUSE_XXX.
62 * Pointer to an array of instructions.
63 * The array is terminated by an OPCODE_END instruction.
65 struct prog_instruction
*Instructions
;
68 * Number of instructions in this clause.
73 * Space reserved for instructions in this clause.
75 int ReservedInstructions
;
79 * A compile object, holding the current intermediate state during compilation.
81 struct radeon_compiler
{
82 struct gl_program
*Source
;
86 * Number of clauses in this program.
91 * Pointer to an array of NumClauses clauses.
93 struct radeon_clause
*Clauses
;
96 * Number of registers in the PROGRAM_TEMPORARIES file.
101 void radeonCompilerInit(
102 struct radeon_compiler
*compiler
,
104 struct gl_program
*source
);
105 void radeonCompilerCleanup(struct radeon_compiler
*compiler
);
106 int radeonCompilerAllocateTemporary(struct radeon_compiler
*compiler
);
108 struct radeon_clause
*radeonCompilerInsertClause(
109 struct radeon_compiler
*compiler
,
112 void radeonCompilerEraseClauses(
113 struct radeon_compiler
*compiler
,
117 struct prog_instruction
* radeonClauseInsertInstructions(
118 struct radeon_compiler
*compiler
,
119 struct radeon_clause
*clause
,
120 int position
, int count
);
125 struct radeon_program_transform_context
{
126 struct radeon_compiler
*compiler
;
129 * Destination clause where new instructions must be written.
131 struct radeon_clause
*dest
;
134 * Original clause that is currently being transformed.
136 struct radeon_clause
*src
;
140 * A transformation that can be passed to \ref radeonClauseLinearTransform.
142 * The function will be called once for each instruction.
143 * It has to either emit the appropriate transformed code for the instruction
144 * and return GL_TRUE, or return GL_FALSE if it doesn't understand the
147 * The function gets passed the userData as last parameter.
149 struct radeon_program_transformation
{
150 GLboolean (*function
)(
151 struct radeon_program_transform_context
*,
152 struct prog_instruction
*,
157 void radeonClauseLocalTransform(
158 struct radeon_compiler
*compiler
,
159 struct radeon_clause
*clause
,
160 int num_transformations
,
161 struct radeon_program_transformation
* transformations
);