11591693c7b415e9869157c711fe11263c95d74eDavid Li/*
21591693c7b415e9869157c711fe11263c95d74eDavid Li * Mesa 3-D graphics library
31591693c7b415e9869157c711fe11263c95d74eDavid Li * Version:  7.3
41591693c7b415e9869157c711fe11263c95d74eDavid Li *
51591693c7b415e9869157c711fe11263c95d74eDavid Li * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
61591693c7b415e9869157c711fe11263c95d74eDavid Li *
71591693c7b415e9869157c711fe11263c95d74eDavid Li * Permission is hereby granted, free of charge, to any person obtaining a
81591693c7b415e9869157c711fe11263c95d74eDavid Li * copy of this software and associated documentation files (the "Software"),
91591693c7b415e9869157c711fe11263c95d74eDavid Li * to deal in the Software without restriction, including without limitation
101591693c7b415e9869157c711fe11263c95d74eDavid Li * the rights to use, copy, modify, merge, publish, distribute, sublicense,
111591693c7b415e9869157c711fe11263c95d74eDavid Li * and/or sell copies of the Software, and to permit persons to whom the
121591693c7b415e9869157c711fe11263c95d74eDavid Li * Software is furnished to do so, subject to the following conditions:
131591693c7b415e9869157c711fe11263c95d74eDavid Li *
141591693c7b415e9869157c711fe11263c95d74eDavid Li * The above copyright notice and this permission notice shall be included
151591693c7b415e9869157c711fe11263c95d74eDavid Li * in all copies or substantial portions of the Software.
161591693c7b415e9869157c711fe11263c95d74eDavid Li *
171591693c7b415e9869157c711fe11263c95d74eDavid Li * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
181591693c7b415e9869157c711fe11263c95d74eDavid Li * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
191591693c7b415e9869157c711fe11263c95d74eDavid Li * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
201591693c7b415e9869157c711fe11263c95d74eDavid Li * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
211591693c7b415e9869157c711fe11263c95d74eDavid Li * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
221591693c7b415e9869157c711fe11263c95d74eDavid Li * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
231591693c7b415e9869157c711fe11263c95d74eDavid Li */
241591693c7b415e9869157c711fe11263c95d74eDavid Li
251591693c7b415e9869157c711fe11263c95d74eDavid Li/**
261591693c7b415e9869157c711fe11263c95d74eDavid Li * \file prog_parameter.c
271591693c7b415e9869157c711fe11263c95d74eDavid Li * Program parameter lists and functions.
281591693c7b415e9869157c711fe11263c95d74eDavid Li * \author Brian Paul
291591693c7b415e9869157c711fe11263c95d74eDavid Li */
301591693c7b415e9869157c711fe11263c95d74eDavid Li
311591693c7b415e9869157c711fe11263c95d74eDavid Li#ifndef PROG_PARAMETER_H
321591693c7b415e9869157c711fe11263c95d74eDavid Li#define PROG_PARAMETER_H
331591693c7b415e9869157c711fe11263c95d74eDavid Li
341591693c7b415e9869157c711fe11263c95d74eDavid Li#include "main/mtypes.h"
351591693c7b415e9869157c711fe11263c95d74eDavid Li#include "prog_statevars.h"
361591693c7b415e9869157c711fe11263c95d74eDavid Li
371591693c7b415e9869157c711fe11263c95d74eDavid Li
381591693c7b415e9869157c711fe11263c95d74eDavid Li/**
391591693c7b415e9869157c711fe11263c95d74eDavid Li * Program parameter flags
401591693c7b415e9869157c711fe11263c95d74eDavid Li */
411591693c7b415e9869157c711fe11263c95d74eDavid Li/*@{*/
421591693c7b415e9869157c711fe11263c95d74eDavid Li#define PROG_PARAM_BIT_CENTROID   0x1  /**< for varying vars (GLSL 1.20) */
431591693c7b415e9869157c711fe11263c95d74eDavid Li#define PROG_PARAM_BIT_INVARIANT  0x2  /**< for varying vars (GLSL 1.20) */
441591693c7b415e9869157c711fe11263c95d74eDavid Li#define PROG_PARAM_BIT_FLAT       0x4  /**< for varying vars (GLSL 1.30) */
451591693c7b415e9869157c711fe11263c95d74eDavid Li#define PROG_PARAM_BIT_LINEAR     0x8  /**< for varying vars (GLSL 1.30) */
461591693c7b415e9869157c711fe11263c95d74eDavid Li#define PROG_PARAM_BIT_CYL_WRAP  0x10  /**< XXX gallium debug */
471591693c7b415e9869157c711fe11263c95d74eDavid Li/*@}*/
481591693c7b415e9869157c711fe11263c95d74eDavid Li
491591693c7b415e9869157c711fe11263c95d74eDavid Li
501591693c7b415e9869157c711fe11263c95d74eDavid Li
511591693c7b415e9869157c711fe11263c95d74eDavid Li/**
521591693c7b415e9869157c711fe11263c95d74eDavid Li * Program parameter.
531591693c7b415e9869157c711fe11263c95d74eDavid Li * Used by shaders/programs for uniforms, constants, varying vars, etc.
541591693c7b415e9869157c711fe11263c95d74eDavid Li */
551591693c7b415e9869157c711fe11263c95d74eDavid Listruct gl_program_parameter
561591693c7b415e9869157c711fe11263c95d74eDavid Li{
571591693c7b415e9869157c711fe11263c95d74eDavid Li   const char *Name;        /**< Null-terminated string */
58c0025eb1a3d421c0355a21db9d8ea2bd81278460David Li   //gl_register_file Type;   /**< PROGRAM_NAMED_PARAM, CONSTANT or STATE_VAR */
59c0025eb1a3d421c0355a21db9d8ea2bd81278460David Li   //GLenum DataType;         /**< GL_FLOAT, GL_FLOAT_VEC2, etc */
601591693c7b415e9869157c711fe11263c95d74eDavid Li   /**
611591693c7b415e9869157c711fe11263c95d74eDavid Li    * Number of components (1..4), or more.
621591693c7b415e9869157c711fe11263c95d74eDavid Li    * If the number of components is greater than 4,
631591693c7b415e9869157c711fe11263c95d74eDavid Li    * this parameter is part of a larger uniform like a GLSL matrix or array.
641591693c7b415e9869157c711fe11263c95d74eDavid Li    * The next program parameter's Size will be Size-4 of this parameter.
651591693c7b415e9869157c711fe11263c95d74eDavid Li    */
66c0025eb1a3d421c0355a21db9d8ea2bd81278460David Li   //GLuint Size;
67c0025eb1a3d421c0355a21db9d8ea2bd81278460David Li   GLuint Slots;            /**< how many float[4] slots occupied */
68c0025eb1a3d421c0355a21db9d8ea2bd81278460David Li   // location starts from 0, such that VERT_ATTRIB_GENERIC0 = 0
69c0025eb1a3d421c0355a21db9d8ea2bd81278460David Li   // since there are no predefined vertex attribs in es20
70c0025eb1a3d421c0355a21db9d8ea2bd81278460David Li   // for varyings BindLocation is vertex output location
71c0025eb1a3d421c0355a21db9d8ea2bd81278460David Li   // and Loctation is fragment input location
72c0025eb1a3d421c0355a21db9d8ea2bd81278460David Li   GLint BindLocation;  /**< requested by BindAttribLocation for attributes */
733b02c91d7b1fcc777dbdafeb044e0df61e1ff0d8David Li   GLint Location;          /**< actual location assigned after linking */
74c0025eb1a3d421c0355a21db9d8ea2bd81278460David Li   //GLboolean Initialized;   /**< debug: Has the ParameterValue[] been set? */
75c0025eb1a3d421c0355a21db9d8ea2bd81278460David Li   //GLbitfield Flags;        /**< Bitmask of PROG_PARAM_*_BIT */
761591693c7b415e9869157c711fe11263c95d74eDavid Li   /**
771591693c7b415e9869157c711fe11263c95d74eDavid Li    * A sequence of STATE_* tokens and integers to identify GL state.
781591693c7b415e9869157c711fe11263c95d74eDavid Li    */
79c0025eb1a3d421c0355a21db9d8ea2bd81278460David Li   //gl_state_index StateIndexes[STATE_LENGTH];
801591693c7b415e9869157c711fe11263c95d74eDavid Li};
811591693c7b415e9869157c711fe11263c95d74eDavid Li
821591693c7b415e9869157c711fe11263c95d74eDavid Li
831591693c7b415e9869157c711fe11263c95d74eDavid Li/**
841591693c7b415e9869157c711fe11263c95d74eDavid Li * List of gl_program_parameter instances.
851591693c7b415e9869157c711fe11263c95d74eDavid Li */
861591693c7b415e9869157c711fe11263c95d74eDavid Listruct gl_program_parameter_list
871591693c7b415e9869157c711fe11263c95d74eDavid Li{
881591693c7b415e9869157c711fe11263c95d74eDavid Li   GLuint Size;           /**< allocated size of Parameters, ParameterValues */
891591693c7b415e9869157c711fe11263c95d74eDavid Li   GLuint NumParameters;  /**< number of parameters in arrays */
901591693c7b415e9869157c711fe11263c95d74eDavid Li   struct gl_program_parameter *Parameters; /**< Array [Size] */
91c0025eb1a3d421c0355a21db9d8ea2bd81278460David Li   //GLfloat (*ParameterValues)[4];        /**< Array [Size] of GLfloat[4] */
92c0025eb1a3d421c0355a21db9d8ea2bd81278460David Li   //GLbitfield StateFlags; /**< _NEW_* flags indicating which state changes
93c0025eb1a3d421c0355a21db9d8ea2bd81278460David Li   //                            might invalidate ParameterValues[] */
941591693c7b415e9869157c711fe11263c95d74eDavid Li};
951591693c7b415e9869157c711fe11263c95d74eDavid Li
96c0025eb1a3d421c0355a21db9d8ea2bd81278460David Li#ifdef __cplusplus
97c0025eb1a3d421c0355a21db9d8ea2bd81278460David Liextern "C" {
98c0025eb1a3d421c0355a21db9d8ea2bd81278460David Liclass ir_variable;
99c0025eb1a3d421c0355a21db9d8ea2bd81278460David Li#else
100c0025eb1a3d421c0355a21db9d8ea2bd81278460David Litypedef struct ir_variable ir_variable;
101c0025eb1a3d421c0355a21db9d8ea2bd81278460David Li#endif
102c0025eb1a3d421c0355a21db9d8ea2bd81278460David Li
103c0025eb1a3d421c0355a21db9d8ea2bd81278460David Li// returns index in paramList or -1
104c0025eb1a3d421c0355a21db9d8ea2bd81278460David LiGLint _mesa_add_parameter(struct gl_program_parameter_list * paramList,
105c0025eb1a3d421c0355a21db9d8ea2bd81278460David Li                           const char * name);
106c0025eb1a3d421c0355a21db9d8ea2bd81278460David Li
107c0025eb1a3d421c0355a21db9d8ea2bd81278460David LiGLint _mesa_get_parameter(const struct gl_program_parameter_list * paramList,
108c0025eb1a3d421c0355a21db9d8ea2bd81278460David Li                           const char * name);
109c0025eb1a3d421c0355a21db9d8ea2bd81278460David Li#ifdef __cplusplus
1101591693c7b415e9869157c711fe11263c95d74eDavid Li}
111c0025eb1a3d421c0355a21db9d8ea2bd81278460David Li#endif
1121591693c7b415e9869157c711fe11263c95d74eDavid Li
1131591693c7b415e9869157c711fe11263c95d74eDavid Li#endif /* PROG_PARAMETER_H */
114