mesa: initial support for ARB_geometry_shader4
[mesa.git] / src / mesa / program / program.h
1 /*
2 * Mesa 3-D graphics library
3 * Version: 6.5.3
4 *
5 * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25 /**
26 * \file program.c
27 * Vertex and fragment program support functions.
28 * \author Brian Paul
29 */
30
31
32 /**
33 * \mainpage Mesa vertex and fragment program module
34 *
35 * This module or directory contains most of the code for vertex and
36 * fragment programs and shaders, including state management, parsers,
37 * and (some) software routines for executing programs
38 */
39
40 #ifndef PROGRAM_H
41 #define PROGRAM_H
42
43 #include "main/mtypes.h"
44
45
46 extern struct gl_program _mesa_DummyProgram;
47
48
49 extern void
50 _mesa_init_program(GLcontext *ctx);
51
52 extern void
53 _mesa_free_program_data(GLcontext *ctx);
54
55 extern void
56 _mesa_update_default_objects_program(GLcontext *ctx);
57
58 extern void
59 _mesa_set_program_error(GLcontext *ctx, GLint pos, const char *string);
60
61 extern const GLubyte *
62 _mesa_find_line_column(const GLubyte *string, const GLubyte *pos,
63 GLint *line, GLint *col);
64
65
66 extern struct gl_program *
67 _mesa_init_vertex_program(GLcontext *ctx,
68 struct gl_vertex_program *prog,
69 GLenum target, GLuint id);
70
71 extern struct gl_program *
72 _mesa_init_fragment_program(GLcontext *ctx,
73 struct gl_fragment_program *prog,
74 GLenum target, GLuint id);
75
76 extern struct gl_program *
77 _mesa_init_geometry_program(GLcontext *ctx,
78 struct gl_geometry_program *prog,
79 GLenum target, GLuint id);
80
81 extern struct gl_program *
82 _mesa_new_program(GLcontext *ctx, GLenum target, GLuint id);
83
84 extern void
85 _mesa_delete_program(GLcontext *ctx, struct gl_program *prog);
86
87 extern struct gl_program *
88 _mesa_lookup_program(GLcontext *ctx, GLuint id);
89
90 extern void
91 _mesa_reference_program(GLcontext *ctx,
92 struct gl_program **ptr,
93 struct gl_program *prog);
94
95 static INLINE void
96 _mesa_reference_vertprog(GLcontext *ctx,
97 struct gl_vertex_program **ptr,
98 struct gl_vertex_program *prog)
99 {
100 _mesa_reference_program(ctx, (struct gl_program **) ptr,
101 (struct gl_program *) prog);
102 }
103
104 static INLINE void
105 _mesa_reference_fragprog(GLcontext *ctx,
106 struct gl_fragment_program **ptr,
107 struct gl_fragment_program *prog)
108 {
109 _mesa_reference_program(ctx, (struct gl_program **) ptr,
110 (struct gl_program *) prog);
111 }
112
113 static INLINE void
114 _mesa_reference_geomprog(GLcontext *ctx,
115 struct gl_geometry_program **ptr,
116 struct gl_geometry_program *prog)
117 {
118 _mesa_reference_program(ctx, (struct gl_program **) ptr,
119 (struct gl_program *) prog);
120 }
121
122 extern struct gl_program *
123 _mesa_clone_program(GLcontext *ctx, const struct gl_program *prog);
124
125 static INLINE struct gl_vertex_program *
126 _mesa_clone_vertex_program(GLcontext *ctx,
127 const struct gl_vertex_program *prog)
128 {
129 return (struct gl_vertex_program *) _mesa_clone_program(ctx, &prog->Base);
130 }
131
132 static INLINE struct gl_geometry_program *
133 _mesa_clone_geometry_program(GLcontext *ctx,
134 const struct gl_geometry_program *prog)
135 {
136 return (struct gl_geometry_program *) _mesa_clone_program(ctx, &prog->Base);
137 }
138
139 static INLINE struct gl_fragment_program *
140 _mesa_clone_fragment_program(GLcontext *ctx,
141 const struct gl_fragment_program *prog)
142 {
143 return (struct gl_fragment_program *) _mesa_clone_program(ctx, &prog->Base);
144 }
145
146
147 extern GLboolean
148 _mesa_insert_instructions(struct gl_program *prog, GLuint start, GLuint count);
149
150 extern GLboolean
151 _mesa_delete_instructions(struct gl_program *prog, GLuint start, GLuint count);
152
153 extern struct gl_program *
154 _mesa_combine_programs(GLcontext *ctx,
155 const struct gl_program *progA,
156 const struct gl_program *progB);
157
158 extern void
159 _mesa_find_used_registers(const struct gl_program *prog,
160 gl_register_file file,
161 GLboolean used[], GLuint usedSize);
162
163 extern GLint
164 _mesa_find_free_register(const GLboolean used[],
165 GLuint maxRegs, GLuint firstReg);
166
167 extern void
168 _mesa_postprocess_program(GLcontext *ctx, struct gl_program *prog);
169
170
171 #endif /* PROGRAM_H */