blob: 08fe576afc191ba269adbf6d7a8c120a8921da9c [file] [log] [blame]
Michal Krol2861e732004-03-29 11:09:34 +00001/*
2 * Mesa 3-D graphics library
Brian942ee022007-02-09 15:40:00 -07003 * Version: 6.5.3
Michal Krol2861e732004-03-29 11:09:34 +00004 *
Brian942ee022007-02-09 15:40:00 -07005 * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
Michal Krol2861e732004-03-29 11:09:34 +00006 *
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
Brian Paul253204f2004-09-10 00:45:12 +000032/**
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
Michal Krol2861e732004-03-29 11:09:34 +000040#ifndef PROGRAM_H
41#define PROGRAM_H
42
43#include "mtypes.h"
44
45
Brian Paul122629f2006-07-20 16:49:57 +000046extern struct gl_program _mesa_DummyProgram;
Brian Paul9ca83922004-10-02 15:16:59 +000047
48
Michal Krol2861e732004-03-29 11:09:34 +000049/*
50 * Internal functions
51 */
52
53extern void
54_mesa_init_program(GLcontext *ctx);
55
56extern void
Brian Paul21841f02004-08-14 14:28:11 +000057_mesa_free_program_data(GLcontext *ctx);
58
59extern void
Michal Krol2861e732004-03-29 11:09:34 +000060_mesa_set_program_error(GLcontext *ctx, GLint pos, const char *string);
61
62extern const GLubyte *
63_mesa_find_line_column(const GLubyte *string, const GLubyte *pos,
64 GLint *line, GLint *col);
65
66
Brian Paul122629f2006-07-20 16:49:57 +000067extern struct gl_program *
Brian Paulcdb65412005-01-11 15:56:47 +000068_mesa_init_vertex_program(GLcontext *ctx,
Brian Paul122629f2006-07-20 16:49:57 +000069 struct gl_vertex_program *prog,
Brian Paulcdb65412005-01-11 15:56:47 +000070 GLenum target, GLuint id);
Michal Krol2861e732004-03-29 11:09:34 +000071
Brian Paul122629f2006-07-20 16:49:57 +000072extern struct gl_program *
Brian Paulcdb65412005-01-11 15:56:47 +000073_mesa_init_fragment_program(GLcontext *ctx,
Brian Paul122629f2006-07-20 16:49:57 +000074 struct gl_fragment_program *prog,
Brian Paulcdb65412005-01-11 15:56:47 +000075 GLenum target, GLuint id);
76
Brian Paul122629f2006-07-20 16:49:57 +000077extern struct gl_program *
Michal Krol2861e732004-03-29 11:09:34 +000078_mesa_new_program(GLcontext *ctx, GLenum target, GLuint id);
79
80extern void
Brian Paul122629f2006-07-20 16:49:57 +000081_mesa_delete_program(GLcontext *ctx, struct gl_program *prog);
Michal Krol2861e732004-03-29 11:09:34 +000082
Brian Paul4d12a052006-08-23 23:10:14 +000083extern struct gl_program *
84_mesa_lookup_program(GLcontext *ctx, GLuint id);
Michal Krol2861e732004-03-29 11:09:34 +000085
Brian103ae5d2008-05-06 22:13:06 -060086extern void
87_mesa_reference_program(GLcontext *ctx,
88 struct gl_program **ptr,
89 struct gl_program *prog);
90
91static INLINE void
92_mesa_reference_vertprog(GLcontext *ctx,
93 struct gl_vertex_program **ptr,
94 struct gl_vertex_program *prog)
95{
96 _mesa_reference_program(ctx, (struct gl_program **) ptr,
97 (struct gl_program *) prog);
98}
99
100static INLINE void
101_mesa_reference_fragprog(GLcontext *ctx,
102 struct gl_fragment_program **ptr,
103 struct gl_fragment_program *prog)
104{
105 _mesa_reference_program(ctx, (struct gl_program **) ptr,
106 (struct gl_program *) prog);
107}
Brian Paul3b9b8de2006-08-24 21:57:36 +0000108
Brianb2a3a852006-12-14 13:56:58 -0700109extern struct gl_program *
110_mesa_clone_program(GLcontext *ctx, const struct gl_program *prog);
111
Brian5d1e7302008-04-07 11:16:18 -0600112extern GLboolean
113_mesa_insert_instructions(struct gl_program *prog, GLuint start, GLuint count);
Michal Krol2861e732004-03-29 11:09:34 +0000114
Brian9ffd8892007-10-29 16:35:59 -0600115extern struct gl_program *
116_mesa_combine_programs(GLcontext *ctx,
Brian1203f542007-10-29 16:38:53 -0600117 const struct gl_program *progA,
118 const struct gl_program *progB);
Brian9ffd8892007-10-29 16:35:59 -0600119
120extern GLint
121_mesa_find_free_register(const struct gl_program *prog, GLuint regFile);
122
123
Michal Krol2861e732004-03-29 11:09:34 +0000124/*
Brian Paulfd4395b2005-11-05 03:02:28 +0000125 * API functions common to ARB/NV_vertex/fragment_program
Michal Krol2861e732004-03-29 11:09:34 +0000126 */
127
128extern void GLAPIENTRY
129_mesa_BindProgram(GLenum target, GLuint id);
130
131extern void GLAPIENTRY
132_mesa_DeletePrograms(GLsizei n, const GLuint *ids);
133
134extern void GLAPIENTRY
135_mesa_GenPrograms(GLsizei n, GLuint *ids);
136
Michal Krol2861e732004-03-29 11:09:34 +0000137
138
Michal Krol2861e732004-03-29 11:09:34 +0000139#endif /* PROGRAM_H */