blob: 879623b127ae261fcd85c3266a4446954de868e7 [file] [log] [blame]
Brian00cdc0a2006-12-14 15:01:06 -07001/*
2 * Mesa 3-D graphics library
Brianb7978af2007-01-09 19:17:17 -07003 * Version: 6.5.3
Brian00cdc0a2006-12-14 15:01:06 -07004 *
Brianb7978af2007-01-09 19:17:17 -07005 * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
Brian00cdc0a2006-12-14 15:01:06 -07006 *
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"
Brianb7978af2007-01-09 19:17:17 -070035#include "prog_statevars.h"
Brian00cdc0a2006-12-14 15:01:06 -070036
37
38/**
Brian9805e762007-01-05 16:00:57 -070039 * Program parameter.
40 * Used for NV_fragment_program for "DEFINE"d constants and "DECLARE"d
41 * parameters.
42 * Also used by ARB_vertex/fragment_programs for state variables, etc.
43 * Used by shaders for uniforms, constants, varying vars, etc.
Brian00cdc0a2006-12-14 15:01:06 -070044 */
45struct gl_program_parameter
46{
47 const char *Name; /**< Null-terminated string */
48 enum register_file Type; /**< PROGRAM_NAMED_PARAM, CONSTANT or STATE_VAR */
49 GLuint Size; /**< Number of components (1..4) */
50 /**
51 * A sequence of STATE_* tokens and integers to identify GL state.
52 */
Brianaa9d22a2007-02-23 11:21:03 -070053 gl_state_index StateIndexes[STATE_LENGTH];
Brian00cdc0a2006-12-14 15:01:06 -070054};
55
56
57/**
Brian9805e762007-01-05 16:00:57 -070058 * List of gl_program_parameter instances.
Brian00cdc0a2006-12-14 15:01:06 -070059 */
60struct gl_program_parameter_list
61{
62 GLuint Size; /**< allocated size of Parameters, ParameterValues */
63 GLuint NumParameters; /**< number of parameters in arrays */
64 struct gl_program_parameter *Parameters; /**< Array [Size] */
65 GLfloat (*ParameterValues)[4]; /**< Array [Size] of GLfloat[4] */
66 GLbitfield StateFlags; /**< _NEW_* flags indicating which state changes
67 might invalidate ParameterValues[] */
68};
69
70
71extern struct gl_program_parameter_list *
72_mesa_new_parameter_list(void);
73
74extern void
75_mesa_free_parameter_list(struct gl_program_parameter_list *paramList);
76
77extern struct gl_program_parameter_list *
78_mesa_clone_parameter_list(const struct gl_program_parameter_list *list);
79
80extern GLint
81_mesa_add_parameter(struct gl_program_parameter_list *paramList,
Brianb7978af2007-01-09 19:17:17 -070082 enum register_file type, const char *name,
83 GLuint size, const GLfloat *values,
84 const gl_state_index state[STATE_LENGTH]);
Brian00cdc0a2006-12-14 15:01:06 -070085
86extern GLint
87_mesa_add_named_parameter(struct gl_program_parameter_list *paramList,
88 const char *name, const GLfloat values[4]);
89
90extern GLint
91_mesa_add_named_constant(struct gl_program_parameter_list *paramList,
92 const char *name, const GLfloat values[4],
93 GLuint size);
94
95extern GLint
96_mesa_add_unnamed_constant(struct gl_program_parameter_list *paramList,
97 const GLfloat values[4], GLuint size,
98 GLuint *swizzleOut);
99
100extern GLint
101_mesa_add_uniform(struct gl_program_parameter_list *paramList,
102 const char *name, GLuint size);
103
104extern GLint
Brian9805e762007-01-05 16:00:57 -0700105_mesa_add_sampler(struct gl_program_parameter_list *paramList,
106 const char *name);
107
108extern GLint
Brian00cdc0a2006-12-14 15:01:06 -0700109_mesa_add_varying(struct gl_program_parameter_list *paramList,
110 const char *name, GLuint size);
111
112extern GLint
Brian3209c3e2007-01-09 17:49:24 -0700113_mesa_add_attribute(struct gl_program_parameter_list *paramList,
Brianb7978af2007-01-09 19:17:17 -0700114 const char *name, GLint size, GLint attrib);
Brian3209c3e2007-01-09 17:49:24 -0700115
116extern GLint
Brian00cdc0a2006-12-14 15:01:06 -0700117_mesa_add_state_reference(struct gl_program_parameter_list *paramList,
Brianaa9d22a2007-02-23 11:21:03 -0700118 const gl_state_index stateTokens[STATE_LENGTH]);
Brian00cdc0a2006-12-14 15:01:06 -0700119
120extern GLfloat *
121_mesa_lookup_parameter_value(const struct gl_program_parameter_list *paramList,
122 GLsizei nameLen, const char *name);
123
124extern GLint
125_mesa_lookup_parameter_index(const struct gl_program_parameter_list *paramList,
126 GLsizei nameLen, const char *name);
127
128extern GLboolean
Brian5b01c5e2006-12-19 18:02:03 -0700129_mesa_lookup_parameter_constant(const struct gl_program_parameter_list *list,
Brian223d7cb2007-01-23 16:37:51 -0700130 const GLfloat v[], GLuint vSize,
Brian00cdc0a2006-12-14 15:01:06 -0700131 GLint *posOut, GLuint *swizzleOut);
132
Brian5b01c5e2006-12-19 18:02:03 -0700133extern GLuint
Brian6d3d9c12007-04-18 14:19:17 -0600134_mesa_longest_parameter_name(const struct gl_program_parameter_list *list,
135 enum register_file type);
136
Brian00cdc0a2006-12-14 15:01:06 -0700137
138#endif /* PROG_PARAMETER_H */