blob: 0db2bcd314ff3ae403944fac0dd2bb9e90edeb65 [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/**
Brian9805e762007-01-05 16:00:57 -070038 * Program parameter.
39 * Used for NV_fragment_program for "DEFINE"d constants and "DECLARE"d
40 * parameters.
41 * Also used by ARB_vertex/fragment_programs for state variables, etc.
42 * Used by shaders for uniforms, constants, varying vars, etc.
Brian00cdc0a2006-12-14 15:01:06 -070043 */
44struct gl_program_parameter
45{
46 const char *Name; /**< Null-terminated string */
47 enum register_file Type; /**< PROGRAM_NAMED_PARAM, CONSTANT or STATE_VAR */
48 GLuint Size; /**< Number of components (1..4) */
49 /**
50 * A sequence of STATE_* tokens and integers to identify GL state.
51 */
52 GLuint StateIndexes[6];
53};
54
55
56/**
Brian9805e762007-01-05 16:00:57 -070057 * List of gl_program_parameter instances.
Brian00cdc0a2006-12-14 15:01:06 -070058 */
59struct gl_program_parameter_list
60{
61 GLuint Size; /**< allocated size of Parameters, ParameterValues */
62 GLuint NumParameters; /**< number of parameters in arrays */
63 struct gl_program_parameter *Parameters; /**< Array [Size] */
64 GLfloat (*ParameterValues)[4]; /**< Array [Size] of GLfloat[4] */
65 GLbitfield StateFlags; /**< _NEW_* flags indicating which state changes
66 might invalidate ParameterValues[] */
67};
68
69
70extern struct gl_program_parameter_list *
71_mesa_new_parameter_list(void);
72
73extern void
74_mesa_free_parameter_list(struct gl_program_parameter_list *paramList);
75
76extern struct gl_program_parameter_list *
77_mesa_clone_parameter_list(const struct gl_program_parameter_list *list);
78
79extern GLint
80_mesa_add_parameter(struct gl_program_parameter_list *paramList,
Brian3a8e2772006-12-20 17:19:16 -070081 const char *name, const GLfloat *values, GLuint size,
Brian00cdc0a2006-12-14 15:01:06 -070082 enum register_file type);
83
84extern GLint
85_mesa_add_named_parameter(struct gl_program_parameter_list *paramList,
86 const char *name, const GLfloat values[4]);
87
88extern GLint
89_mesa_add_named_constant(struct gl_program_parameter_list *paramList,
90 const char *name, const GLfloat values[4],
91 GLuint size);
92
93extern GLint
94_mesa_add_unnamed_constant(struct gl_program_parameter_list *paramList,
95 const GLfloat values[4], GLuint size,
96 GLuint *swizzleOut);
97
98extern GLint
99_mesa_add_uniform(struct gl_program_parameter_list *paramList,
100 const char *name, GLuint size);
101
102extern GLint
Brian9805e762007-01-05 16:00:57 -0700103_mesa_add_sampler(struct gl_program_parameter_list *paramList,
104 const char *name);
105
106extern GLint
Brian00cdc0a2006-12-14 15:01:06 -0700107_mesa_add_varying(struct gl_program_parameter_list *paramList,
108 const char *name, GLuint size);
109
110extern GLint
111_mesa_add_state_reference(struct gl_program_parameter_list *paramList,
112 const GLint *stateTokens);
113
114extern GLfloat *
115_mesa_lookup_parameter_value(const struct gl_program_parameter_list *paramList,
116 GLsizei nameLen, const char *name);
117
118extern GLint
119_mesa_lookup_parameter_index(const struct gl_program_parameter_list *paramList,
120 GLsizei nameLen, const char *name);
121
122extern GLboolean
Brian5b01c5e2006-12-19 18:02:03 -0700123_mesa_lookup_parameter_constant(const struct gl_program_parameter_list *list,
Brian00cdc0a2006-12-14 15:01:06 -0700124 const GLfloat v[], GLsizei vSize,
125 GLint *posOut, GLuint *swizzleOut);
126
Brian5b01c5e2006-12-19 18:02:03 -0700127extern GLuint
128_mesa_parameter_longest_name(const struct gl_program_parameter_list *list);
Brian00cdc0a2006-12-14 15:01:06 -0700129
130#endif /* PROG_PARAMETER_H */