blob: 6ce96c79728e3a5164136e968388f7432161535b [file] [log] [blame]
Brian00cdc0a2006-12-14 15:01:06 -07001/*
2 * Mesa 3-D graphics library
3 * Version: 6.5.2
4 *
5 * Copyright (C) 1999-2006 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 prog_parameter.c
27 * Program parameter lists and functions.
28 * \author Brian Paul
29 */
30
31#ifndef PROG_PARAMETER_H
32#define PROG_PARAMETER_H
33
34#include "mtypes.h"
35
36
37/**
38 * Named program parameters
39 * Used for NV_fragment_program "DEFINE"d constants and "DECLARE"d parameters,
40 * and ARB_fragment_program global state references. For the later, Name
41 * might be "state.light[0].diffuse", for example.
42 */
43struct gl_program_parameter
44{
45 const char *Name; /**< Null-terminated string */
46 enum register_file Type; /**< PROGRAM_NAMED_PARAM, CONSTANT or STATE_VAR */
47 GLuint Size; /**< Number of components (1..4) */
48 /**
49 * A sequence of STATE_* tokens and integers to identify GL state.
50 */
51 GLuint StateIndexes[6];
52};
53
54
55/**
56 * A list of the above program_parameter instances.
57 */
58struct gl_program_parameter_list
59{
60 GLuint Size; /**< allocated size of Parameters, ParameterValues */
61 GLuint NumParameters; /**< number of parameters in arrays */
62 struct gl_program_parameter *Parameters; /**< Array [Size] */
63 GLfloat (*ParameterValues)[4]; /**< Array [Size] of GLfloat[4] */
64 GLbitfield StateFlags; /**< _NEW_* flags indicating which state changes
65 might invalidate ParameterValues[] */
66};
67
68
69extern struct gl_program_parameter_list *
70_mesa_new_parameter_list(void);
71
72extern void
73_mesa_free_parameter_list(struct gl_program_parameter_list *paramList);
74
75extern struct gl_program_parameter_list *
76_mesa_clone_parameter_list(const struct gl_program_parameter_list *list);
77
78extern GLint
79_mesa_add_parameter(struct gl_program_parameter_list *paramList,
Brian3a8e2772006-12-20 17:19:16 -070080 const char *name, const GLfloat *values, GLuint size,
Brian00cdc0a2006-12-14 15:01:06 -070081 enum register_file type);
82
83extern GLint
84_mesa_add_named_parameter(struct gl_program_parameter_list *paramList,
85 const char *name, const GLfloat values[4]);
86
87extern GLint
88_mesa_add_named_constant(struct gl_program_parameter_list *paramList,
89 const char *name, const GLfloat values[4],
90 GLuint size);
91
92extern GLint
93_mesa_add_unnamed_constant(struct gl_program_parameter_list *paramList,
94 const GLfloat values[4], GLuint size,
95 GLuint *swizzleOut);
96
97extern GLint
98_mesa_add_uniform(struct gl_program_parameter_list *paramList,
99 const char *name, GLuint size);
100
101extern GLint
102_mesa_add_varying(struct gl_program_parameter_list *paramList,
103 const char *name, GLuint size);
104
105extern GLint
106_mesa_add_state_reference(struct gl_program_parameter_list *paramList,
107 const GLint *stateTokens);
108
109extern GLfloat *
110_mesa_lookup_parameter_value(const struct gl_program_parameter_list *paramList,
111 GLsizei nameLen, const char *name);
112
113extern GLint
114_mesa_lookup_parameter_index(const struct gl_program_parameter_list *paramList,
115 GLsizei nameLen, const char *name);
116
117extern GLboolean
Brian5b01c5e2006-12-19 18:02:03 -0700118_mesa_lookup_parameter_constant(const struct gl_program_parameter_list *list,
Brian00cdc0a2006-12-14 15:01:06 -0700119 const GLfloat v[], GLsizei vSize,
120 GLint *posOut, GLuint *swizzleOut);
121
Brian5b01c5e2006-12-19 18:02:03 -0700122extern GLuint
123_mesa_parameter_longest_name(const struct gl_program_parameter_list *list);
Brian00cdc0a2006-12-14 15:01:06 -0700124
125#endif /* PROG_PARAMETER_H */