1 /*
2  * Mesa 3-D graphics library
3  *
4  * Copyright (C) 1999-2007  Brian Paul   All Rights Reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the "Software"),
8  * to deal in the Software without restriction, including without limitation
9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the
11  * Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included
14  * in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22  * OTHER DEALINGS IN THE SOFTWARE.
23  */
24 
25 #ifndef PROG_STATEVARS_H
26 #define PROG_STATEVARS_H
27 
28 
29 #include "main/glheader.h"
30 #include "compiler/shader_enums.h"
31 
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 
38 struct gl_context;
39 struct gl_program_parameter_list;
40 
41 
42 /**
43  * Used for describing GL state referenced from inside ARB vertex and
44  * fragment programs.
45  * A string such as "state.light[0].ambient" gets translated into a
46  * sequence of tokens such as [ STATE_LIGHT, 0, STATE_AMBIENT ].
47  *
48  * For state that's an array, like STATE_CLIPPLANE, the 2nd token [1] should
49  * always be the array index.
50  */
51 typedef enum gl_state_index_ {
52    STATE_MATERIAL = 100,  /* start at 100 so small ints are seen as ints */
53 
54    STATE_LIGHT,
55    STATE_LIGHTMODEL_AMBIENT,
56    STATE_LIGHTMODEL_SCENECOLOR,
57    STATE_LIGHTPROD,
58 
59    STATE_TEXGEN,
60 
61    STATE_FOG_COLOR,
62    STATE_FOG_PARAMS,
63 
64    STATE_CLIPPLANE,
65 
66    STATE_POINT_SIZE,
67    STATE_POINT_ATTENUATION,
68 
69    STATE_MODELVIEW_MATRIX,
70    STATE_PROJECTION_MATRIX,
71    STATE_MVP_MATRIX,
72    STATE_TEXTURE_MATRIX,
73    STATE_PROGRAM_MATRIX,
74    STATE_MATRIX_INVERSE,
75    STATE_MATRIX_TRANSPOSE,
76    STATE_MATRIX_INVTRANS,
77 
78    STATE_AMBIENT,
79    STATE_DIFFUSE,
80    STATE_SPECULAR,
81    STATE_EMISSION,
82    STATE_SHININESS,
83    STATE_HALF_VECTOR,
84 
85    STATE_POSITION,       /**< xyzw = position */
86    STATE_ATTENUATION,    /**< xyz = attenuation, w = spot exponent */
87    STATE_SPOT_DIRECTION, /**< xyz = direction, w = cos(cutoff) */
88    STATE_SPOT_CUTOFF,    /**< x = cutoff, yzw = undefined */
89 
90    STATE_TEXGEN_EYE_S,
91    STATE_TEXGEN_EYE_T,
92    STATE_TEXGEN_EYE_R,
93    STATE_TEXGEN_EYE_Q,
94    STATE_TEXGEN_OBJECT_S,
95    STATE_TEXGEN_OBJECT_T,
96    STATE_TEXGEN_OBJECT_R,
97    STATE_TEXGEN_OBJECT_Q,
98 
99    STATE_TEXENV_COLOR,
100 
101    STATE_NUM_SAMPLES,    /* An integer, not a float like the other state vars */
102 
103    STATE_DEPTH_RANGE,
104 
105    STATE_VERTEX_PROGRAM,
106    STATE_FRAGMENT_PROGRAM,
107 
108    STATE_ENV,
109    STATE_LOCAL,
110 
111    STATE_INTERNAL,		/* Mesa additions */
112    STATE_CURRENT_ATTRIB,        /* ctx->Current vertex attrib value */
113    STATE_CURRENT_ATTRIB_MAYBE_VP_CLAMPED,        /* ctx->Current vertex attrib value after passthrough vertex processing */
114    STATE_NORMAL_SCALE,
115    STATE_FOG_PARAMS_OPTIMIZED,  /* for faster fog calc */
116    STATE_POINT_SIZE_CLAMPED,    /* includes implementation dependent size clamp */
117    STATE_LIGHT_SPOT_DIR_NORMALIZED,   /* pre-normalized spot dir */
118    STATE_LIGHT_POSITION,              /* object vs eye space */
119    STATE_LIGHT_POSITION_NORMALIZED,   /* object vs eye space */
120    STATE_LIGHT_HALF_VECTOR,           /* object vs eye space */
121    STATE_PT_SCALE,              /**< Pixel transfer RGBA scale */
122    STATE_PT_BIAS,               /**< Pixel transfer RGBA bias */
123    STATE_FB_SIZE,               /**< (width-1, height-1, 0, 0) */
124    STATE_FB_WPOS_Y_TRANSFORM,   /**< (1, 0, -1, height) if a FBO is bound, (-1, height, 1, 0) otherwise */
125    STATE_FB_PNTC_Y_TRANSFORM,   /**< (1, 0, 0, 0) if point origin is upper left, (-1, 1, 0, 0) otherwise */
126    STATE_TCS_PATCH_VERTICES_IN, /**< gl_PatchVerticesIn for TCS (integer) */
127    STATE_TES_PATCH_VERTICES_IN, /**< gl_PatchVerticesIn for TES (integer) */
128    /**
129     * A single enum gl_blend_support_qualifier value representing the
130     * currently active advanced blending equation, or zero if disabled.
131     */
132    STATE_ADVANCED_BLENDING_MODE,
133    STATE_ALPHA_REF,        /* alpha-test reference value */
134    STATE_CLIP_INTERNAL,    /* similar to STATE_CLIPPLANE, but in clip-space */
135    STATE_INTERNAL_DRIVER	/* first available state index for drivers (must be last) */
136 } gl_state_index;
137 
138 
139 extern void
140 _mesa_load_state_parameters(struct gl_context *ctx,
141                             struct gl_program_parameter_list *paramList);
142 
143 extern unsigned
144 _mesa_program_state_value_size(const gl_state_index16 state[STATE_LENGTH]);
145 
146 extern GLbitfield
147 _mesa_program_state_flags(const gl_state_index16 state[STATE_LENGTH]);
148 
149 
150 extern char *
151 _mesa_program_state_string(const gl_state_index16 state[STATE_LENGTH]);
152 
153 
154 
155 #ifdef __cplusplus
156 }
157 #endif
158 
159 #endif /* PROG_STATEVARS_H */
160