r300: Add radeon_program and trivial refactoring of r300_fragprog to use it
[mesa.git] / src / mesa / drivers / dri / r300 / radeon_program.h
1 /*
2 * Copyright (C) 2008 Nicolai Haehnle.
3 *
4 * All Rights Reserved.
5 *
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:
13 *
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.
17 *
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.
25 *
26 */
27
28 #ifndef __RADEON_PROGRAM_H_
29 #define __RADEON_PROGRAM_H_
30
31 #include "glheader.h"
32 #include "macros.h"
33 #include "enums.h"
34 #include "shader/program.h"
35 #include "shader/prog_instruction.h"
36
37
38 enum {
39 CLAUSE_MIXED = 0,
40 CLAUSE_ALU,
41 CLAUSE_TEX
42 };
43
44 /**
45 * A clause is simply a sequence of instructions that are executed
46 * in order.
47 */
48 struct radeon_clause {
49 /**
50 * Type of this clause, one of CLAUSE_XXX.
51 */
52 int Type : 2;
53
54 /**
55 * Pointer to an array of instructions.
56 * The array is terminated by an OPCODE_END instruction.
57 */
58 struct prog_instruction *Instructions;
59
60 /**
61 * Number of instructions in this clause.
62 */
63 int NumInstructions;
64
65 /**
66 * Space reserved for instructions in this clause.
67 */
68 int ReservedInstructions;
69 };
70
71 /**
72 * A compile object, holding the current intermediate state during compilation.
73 */
74 struct radeon_compiler {
75 struct gl_program *Source;
76 GLcontext* Ctx;
77
78 /**
79 * Number of clauses in this program.
80 */
81 int NumClauses;
82
83 /**
84 * Pointer to an array of NumClauses clauses.
85 */
86 struct radeon_clause *Clauses;
87
88 /**
89 * Number of registers in the PROGRAM_TEMPORARIES file.
90 */
91 int NumTemporaries;
92 };
93
94 void radeonCompilerInit(
95 struct radeon_compiler *compiler,
96 GLcontext *ctx,
97 struct gl_program *source);
98 void radeonCompilerCleanup(struct radeon_compiler *compiler);
99 int radeonCompilerAllocateTemporary(struct radeon_compiler *compiler);
100
101 struct radeon_clause *radeonCompilerInsertClause(
102 struct radeon_compiler *compiler,
103 int position,
104 int type);
105 void radeonCompilerEraseClauses(
106 struct radeon_compiler *compiler,
107 int start,
108 int end);
109
110 #endif