2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
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:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
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.
27 * Vertex and fragment program support functions.
33 * \mainpage Mesa vertex and fragment program module
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
43 #include "main/compiler.h"
44 #include "main/mtypes.h"
47 extern struct gl_program _mesa_DummyProgram
;
51 _mesa_init_program(GLcontext
*ctx
);
54 _mesa_free_program_data(GLcontext
*ctx
);
57 _mesa_update_default_objects_program(GLcontext
*ctx
);
60 _mesa_set_program_error(GLcontext
*ctx
, GLint pos
, const char *string
);
62 extern const GLubyte
*
63 _mesa_find_line_column(const GLubyte
*string
, const GLubyte
*pos
,
64 GLint
*line
, GLint
*col
);
67 extern struct gl_program
*
68 _mesa_init_vertex_program(GLcontext
*ctx
,
69 struct gl_vertex_program
*prog
,
70 GLenum target
, GLuint id
);
72 extern struct gl_program
*
73 _mesa_init_fragment_program(GLcontext
*ctx
,
74 struct gl_fragment_program
*prog
,
75 GLenum target
, GLuint id
);
77 extern struct gl_program
*
78 _mesa_init_geometry_program(GLcontext
*ctx
,
79 struct gl_geometry_program
*prog
,
80 GLenum target
, GLuint id
);
82 extern struct gl_program
*
83 _mesa_new_program(GLcontext
*ctx
, GLenum target
, GLuint id
);
86 _mesa_delete_program(GLcontext
*ctx
, struct gl_program
*prog
);
88 extern struct gl_program
*
89 _mesa_lookup_program(GLcontext
*ctx
, GLuint id
);
92 _mesa_reference_program(GLcontext
*ctx
,
93 struct gl_program
**ptr
,
94 struct gl_program
*prog
);
97 _mesa_reference_vertprog(GLcontext
*ctx
,
98 struct gl_vertex_program
**ptr
,
99 struct gl_vertex_program
*prog
)
101 _mesa_reference_program(ctx
, (struct gl_program
**) ptr
,
102 (struct gl_program
*) prog
);
106 _mesa_reference_fragprog(GLcontext
*ctx
,
107 struct gl_fragment_program
**ptr
,
108 struct gl_fragment_program
*prog
)
110 _mesa_reference_program(ctx
, (struct gl_program
**) ptr
,
111 (struct gl_program
*) prog
);
115 _mesa_reference_geomprog(GLcontext
*ctx
,
116 struct gl_geometry_program
**ptr
,
117 struct gl_geometry_program
*prog
)
119 _mesa_reference_program(ctx
, (struct gl_program
**) ptr
,
120 (struct gl_program
*) prog
);
123 extern struct gl_program
*
124 _mesa_clone_program(GLcontext
*ctx
, const struct gl_program
*prog
);
126 static INLINE
struct gl_vertex_program
*
127 _mesa_clone_vertex_program(GLcontext
*ctx
,
128 const struct gl_vertex_program
*prog
)
130 return (struct gl_vertex_program
*) _mesa_clone_program(ctx
, &prog
->Base
);
133 static INLINE
struct gl_geometry_program
*
134 _mesa_clone_geometry_program(GLcontext
*ctx
,
135 const struct gl_geometry_program
*prog
)
137 return (struct gl_geometry_program
*) _mesa_clone_program(ctx
, &prog
->Base
);
140 static INLINE
struct gl_fragment_program
*
141 _mesa_clone_fragment_program(GLcontext
*ctx
,
142 const struct gl_fragment_program
*prog
)
144 return (struct gl_fragment_program
*) _mesa_clone_program(ctx
, &prog
->Base
);
149 _mesa_insert_instructions(struct gl_program
*prog
, GLuint start
, GLuint count
);
152 _mesa_delete_instructions(struct gl_program
*prog
, GLuint start
, GLuint count
);
154 extern struct gl_program
*
155 _mesa_combine_programs(GLcontext
*ctx
,
156 const struct gl_program
*progA
,
157 const struct gl_program
*progB
);
160 _mesa_find_used_registers(const struct gl_program
*prog
,
161 gl_register_file file
,
162 GLboolean used
[], GLuint usedSize
);
165 _mesa_find_free_register(const GLboolean used
[],
166 GLuint maxRegs
, GLuint firstReg
);
169 _mesa_postprocess_program(GLcontext
*ctx
, struct gl_program
*prog
);
171 /* keep these in the same order as TGSI_PROCESSOR_* */
174 _mesa_program_target_to_index(GLenum v
)
178 case GL_VERTEX_PROGRAM_ARB
:
179 return MESA_SHADER_VERTEX
;
180 case GL_FRAGMENT_PROGRAM_ARB
:
181 return MESA_SHADER_FRAGMENT
;
182 case GL_GEOMETRY_PROGRAM_NV
:
183 return MESA_SHADER_GEOMETRY
;
191 _mesa_program_index_to_target(GLuint i
)
193 GLenum enums
[MESA_SHADER_TYPES
] = {
194 GL_VERTEX_PROGRAM_ARB
,
195 GL_FRAGMENT_PROGRAM_ARB
,
196 GL_GEOMETRY_PROGRAM_NV
,
198 if(i
>= MESA_SHADER_TYPES
)
204 #endif /* PROGRAM_H */