1bf215546Sopenharmony_ci/*
2bf215546Sopenharmony_ci * Mesa 3-D graphics library
3bf215546Sopenharmony_ci *
4bf215546Sopenharmony_ci * Copyright (C) 1999-2007  Brian Paul   All Rights Reserved.
5bf215546Sopenharmony_ci *
6bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
7bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
8bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation
9bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
11bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
12bf215546Sopenharmony_ci *
13bf215546Sopenharmony_ci * The above copyright notice and this permission notice shall be included
14bf215546Sopenharmony_ci * in all copies or substantial portions of the Software.
15bf215546Sopenharmony_ci *
16bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17bf215546Sopenharmony_ci * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20bf215546Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21bf215546Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22bf215546Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE.
23bf215546Sopenharmony_ci */
24bf215546Sopenharmony_ci
25bf215546Sopenharmony_ci#ifndef PROG_STATEVARS_H
26bf215546Sopenharmony_ci#define PROG_STATEVARS_H
27bf215546Sopenharmony_ci
28bf215546Sopenharmony_ci
29bf215546Sopenharmony_ci#include "main/glheader.h"
30bf215546Sopenharmony_ci#include "compiler/shader_enums.h"
31bf215546Sopenharmony_ci#include <stdint.h>
32bf215546Sopenharmony_ci
33bf215546Sopenharmony_ci
34bf215546Sopenharmony_ci#ifdef __cplusplus
35bf215546Sopenharmony_ciextern "C" {
36bf215546Sopenharmony_ci#endif
37bf215546Sopenharmony_ci
38bf215546Sopenharmony_ci
39bf215546Sopenharmony_cistruct gl_context;
40bf215546Sopenharmony_cistruct gl_constants;
41bf215546Sopenharmony_cistruct gl_program_parameter_list;
42bf215546Sopenharmony_ci
43bf215546Sopenharmony_ci
44bf215546Sopenharmony_ci/**
45bf215546Sopenharmony_ci * Used for describing GL state referenced from inside ARB vertex and
46bf215546Sopenharmony_ci * fragment programs.
47bf215546Sopenharmony_ci * A string such as "state.light[0].ambient" gets translated into a
48bf215546Sopenharmony_ci * sequence of tokens such as [ STATE_LIGHT, 0, STATE_AMBIENT ].
49bf215546Sopenharmony_ci *
50bf215546Sopenharmony_ci * For state that's an array, like STATE_CLIPPLANE, the 2nd token [1] should
51bf215546Sopenharmony_ci * always be the array index.
52bf215546Sopenharmony_ci */
53bf215546Sopenharmony_citypedef enum gl_state_index_ {
54bf215546Sopenharmony_ci   STATE_NOT_STATE_VAR = 0,
55bf215546Sopenharmony_ci
56bf215546Sopenharmony_ci   STATE_MATERIAL,
57bf215546Sopenharmony_ci
58bf215546Sopenharmony_ci   STATE_LIGHT,         /* One gl_light attribute. */
59bf215546Sopenharmony_ci   STATE_LIGHT_ARRAY, /* Multiple gl_light attributes loaded at once. */
60bf215546Sopenharmony_ci   STATE_LIGHT_ATTENUATION_ARRAY,
61bf215546Sopenharmony_ci   STATE_LIGHTMODEL_AMBIENT,
62bf215546Sopenharmony_ci   STATE_LIGHTMODEL_SCENECOLOR,
63bf215546Sopenharmony_ci   STATE_LIGHTPROD,
64bf215546Sopenharmony_ci   STATE_LIGHTPROD_ARRAY_FRONT,   /* multiple lights, only front faces */
65bf215546Sopenharmony_ci   STATE_LIGHTPROD_ARRAY_BACK,    /* multiple lights, only back faces */
66bf215546Sopenharmony_ci   STATE_LIGHTPROD_ARRAY_TWOSIDE, /* multiple lights, both sides */
67bf215546Sopenharmony_ci
68bf215546Sopenharmony_ci   STATE_TEXGEN,
69bf215546Sopenharmony_ci   STATE_TEXENV_COLOR,
70bf215546Sopenharmony_ci
71bf215546Sopenharmony_ci   STATE_FOG_COLOR,
72bf215546Sopenharmony_ci   STATE_FOG_PARAMS,
73bf215546Sopenharmony_ci
74bf215546Sopenharmony_ci   STATE_CLIPPLANE,
75bf215546Sopenharmony_ci
76bf215546Sopenharmony_ci   STATE_POINT_SIZE,
77bf215546Sopenharmony_ci   STATE_POINT_ATTENUATION,
78bf215546Sopenharmony_ci
79bf215546Sopenharmony_ci   STATE_MODELVIEW_MATRIX,
80bf215546Sopenharmony_ci   STATE_MODELVIEW_MATRIX_INVERSE,
81bf215546Sopenharmony_ci   STATE_MODELVIEW_MATRIX_TRANSPOSE,
82bf215546Sopenharmony_ci   STATE_MODELVIEW_MATRIX_INVTRANS,
83bf215546Sopenharmony_ci
84bf215546Sopenharmony_ci   STATE_PROJECTION_MATRIX,
85bf215546Sopenharmony_ci   STATE_PROJECTION_MATRIX_INVERSE,
86bf215546Sopenharmony_ci   STATE_PROJECTION_MATRIX_TRANSPOSE,
87bf215546Sopenharmony_ci   STATE_PROJECTION_MATRIX_INVTRANS,
88bf215546Sopenharmony_ci
89bf215546Sopenharmony_ci   STATE_MVP_MATRIX,
90bf215546Sopenharmony_ci   STATE_MVP_MATRIX_INVERSE,
91bf215546Sopenharmony_ci   STATE_MVP_MATRIX_TRANSPOSE,
92bf215546Sopenharmony_ci   STATE_MVP_MATRIX_INVTRANS,
93bf215546Sopenharmony_ci
94bf215546Sopenharmony_ci   STATE_TEXTURE_MATRIX,
95bf215546Sopenharmony_ci   STATE_TEXTURE_MATRIX_INVERSE,
96bf215546Sopenharmony_ci   STATE_TEXTURE_MATRIX_TRANSPOSE,
97bf215546Sopenharmony_ci   STATE_TEXTURE_MATRIX_INVTRANS,
98bf215546Sopenharmony_ci
99bf215546Sopenharmony_ci   STATE_PROGRAM_MATRIX,
100bf215546Sopenharmony_ci   STATE_PROGRAM_MATRIX_INVERSE,
101bf215546Sopenharmony_ci   STATE_PROGRAM_MATRIX_TRANSPOSE,
102bf215546Sopenharmony_ci   STATE_PROGRAM_MATRIX_INVTRANS,
103bf215546Sopenharmony_ci
104bf215546Sopenharmony_ci   STATE_NUM_SAMPLES,    /* An integer, not a float like the other state vars */
105bf215546Sopenharmony_ci
106bf215546Sopenharmony_ci   STATE_DEPTH_RANGE,
107bf215546Sopenharmony_ci
108bf215546Sopenharmony_ci   STATE_FRAGMENT_PROGRAM_ENV,
109bf215546Sopenharmony_ci   STATE_FRAGMENT_PROGRAM_ENV_ARRAY,
110bf215546Sopenharmony_ci   STATE_FRAGMENT_PROGRAM_LOCAL,
111bf215546Sopenharmony_ci   STATE_FRAGMENT_PROGRAM_LOCAL_ARRAY,
112bf215546Sopenharmony_ci   STATE_VERTEX_PROGRAM_ENV,
113bf215546Sopenharmony_ci   STATE_VERTEX_PROGRAM_ENV_ARRAY,
114bf215546Sopenharmony_ci   STATE_VERTEX_PROGRAM_LOCAL,
115bf215546Sopenharmony_ci   STATE_VERTEX_PROGRAM_LOCAL_ARRAY,
116bf215546Sopenharmony_ci
117bf215546Sopenharmony_ci   STATE_NORMAL_SCALE_EYESPACE,
118bf215546Sopenharmony_ci   STATE_CURRENT_ATTRIB,        /* ctx->Current vertex attrib value */
119bf215546Sopenharmony_ci   STATE_CURRENT_ATTRIB_MAYBE_VP_CLAMPED,        /* ctx->Current vertex attrib value after passthrough vertex processing */
120bf215546Sopenharmony_ci   STATE_NORMAL_SCALE,
121bf215546Sopenharmony_ci   STATE_FOG_PARAMS_OPTIMIZED,  /* for faster fog calc */
122bf215546Sopenharmony_ci   STATE_POINT_SIZE_CLAMPED,    /* includes implementation dependent size clamp */
123bf215546Sopenharmony_ci   STATE_LIGHT_SPOT_DIR_NORMALIZED,   /* pre-normalized spot dir */
124bf215546Sopenharmony_ci   STATE_LIGHT_POSITION,              /* object vs eye space */
125bf215546Sopenharmony_ci   STATE_LIGHT_POSITION_ARRAY,
126bf215546Sopenharmony_ci   STATE_LIGHT_POSITION_NORMALIZED,   /* object vs eye space */
127bf215546Sopenharmony_ci   STATE_LIGHT_POSITION_NORMALIZED_ARRAY,
128bf215546Sopenharmony_ci   STATE_LIGHT_HALF_VECTOR,           /* object vs eye space */
129bf215546Sopenharmony_ci   STATE_PT_SCALE,              /**< Pixel transfer RGBA scale */
130bf215546Sopenharmony_ci   STATE_PT_BIAS,               /**< Pixel transfer RGBA bias */
131bf215546Sopenharmony_ci   STATE_FB_SIZE,               /**< (width-1, height-1, 0, 0) */
132bf215546Sopenharmony_ci   STATE_FB_WPOS_Y_TRANSFORM,   /**< (1, 0, -1, height) if a FBO is bound, (-1, height, 1, 0) otherwise */
133bf215546Sopenharmony_ci   STATE_FB_PNTC_Y_TRANSFORM,   /**< (1, 0, 0, 0) if point origin is upper left, (-1, 1, 0, 0) otherwise */
134bf215546Sopenharmony_ci   STATE_TCS_PATCH_VERTICES_IN, /**< gl_PatchVerticesIn for TCS (integer) */
135bf215546Sopenharmony_ci   STATE_TES_PATCH_VERTICES_IN, /**< gl_PatchVerticesIn for TES (integer) */
136bf215546Sopenharmony_ci   /**
137bf215546Sopenharmony_ci    * A single enum gl_blend_support_qualifier value representing the
138bf215546Sopenharmony_ci    * currently active advanced blending equation, or zero if disabled.
139bf215546Sopenharmony_ci    */
140bf215546Sopenharmony_ci   STATE_ADVANCED_BLENDING_MODE,
141bf215546Sopenharmony_ci   STATE_ALPHA_REF,        /* alpha-test reference value */
142bf215546Sopenharmony_ci   STATE_CLIP_INTERNAL,    /* similar to STATE_CLIPPLANE, but in clip-space */
143bf215546Sopenharmony_ci   STATE_ATOMIC_COUNTER_OFFSET,    /* the byte offset to add to atomic counter bindings */
144bf215546Sopenharmony_ci
145bf215546Sopenharmony_ci   STATE_INTERNAL_DRIVER,	/* first available state index for drivers (must be last) */
146bf215546Sopenharmony_ci
147bf215546Sopenharmony_ci
148bf215546Sopenharmony_ci   /** All enums below don't occur in state[0]. **/
149bf215546Sopenharmony_ci
150bf215546Sopenharmony_ci   /* These 8 enums must be in the same order as the gl_light union members,
151bf215546Sopenharmony_ci    * which should also match the order of gl_LightSource members.
152bf215546Sopenharmony_ci    */
153bf215546Sopenharmony_ci   STATE_AMBIENT,
154bf215546Sopenharmony_ci   STATE_DIFFUSE,
155bf215546Sopenharmony_ci   STATE_SPECULAR,
156bf215546Sopenharmony_ci   STATE_POSITION,       /**< xyzw = position */
157bf215546Sopenharmony_ci   STATE_HALF_VECTOR,
158bf215546Sopenharmony_ci   STATE_SPOT_DIRECTION, /**< xyz = direction, w = cos(cutoff) */
159bf215546Sopenharmony_ci   STATE_ATTENUATION,    /**< xyz = attenuation, w = spot exponent */
160bf215546Sopenharmony_ci   STATE_SPOT_CUTOFF,    /**< x = cutoff, yzw = undefined */
161bf215546Sopenharmony_ci
162bf215546Sopenharmony_ci   STATE_EMISSION,
163bf215546Sopenharmony_ci   STATE_SHININESS,
164bf215546Sopenharmony_ci
165bf215546Sopenharmony_ci   /* These 8 enums must be in the same order as the memory layout of
166bf215546Sopenharmony_ci    * gl_fixedfunc_texture_unit::EyePlane/ObjectPlane.
167bf215546Sopenharmony_ci    */
168bf215546Sopenharmony_ci   STATE_TEXGEN_EYE_S,
169bf215546Sopenharmony_ci   STATE_TEXGEN_EYE_T,
170bf215546Sopenharmony_ci   STATE_TEXGEN_EYE_R,
171bf215546Sopenharmony_ci   STATE_TEXGEN_EYE_Q,
172bf215546Sopenharmony_ci   STATE_TEXGEN_OBJECT_S,
173bf215546Sopenharmony_ci   STATE_TEXGEN_OBJECT_T,
174bf215546Sopenharmony_ci   STATE_TEXGEN_OBJECT_R,
175bf215546Sopenharmony_ci   STATE_TEXGEN_OBJECT_Q,
176bf215546Sopenharmony_ci} gl_state_index;
177bf215546Sopenharmony_ci
178bf215546Sopenharmony_ci
179bf215546Sopenharmony_ciextern void
180bf215546Sopenharmony_ci_mesa_load_state_parameters(struct gl_context *ctx,
181bf215546Sopenharmony_ci                            struct gl_program_parameter_list *paramList);
182bf215546Sopenharmony_ci
183bf215546Sopenharmony_ciextern void
184bf215546Sopenharmony_ci_mesa_upload_state_parameters(struct gl_context *ctx,
185bf215546Sopenharmony_ci                              struct gl_program_parameter_list *paramList,
186bf215546Sopenharmony_ci                              uint32_t *dst);
187bf215546Sopenharmony_ci
188bf215546Sopenharmony_ciextern void
189bf215546Sopenharmony_ci_mesa_optimize_state_parameters(struct gl_constants *consts,
190bf215546Sopenharmony_ci                                struct gl_program_parameter_list *list);
191bf215546Sopenharmony_ci
192bf215546Sopenharmony_ciextern unsigned
193bf215546Sopenharmony_ci_mesa_program_state_value_size(const gl_state_index16 state[STATE_LENGTH]);
194bf215546Sopenharmony_ci
195bf215546Sopenharmony_ciextern GLbitfield
196bf215546Sopenharmony_ci_mesa_program_state_flags(const gl_state_index16 state[STATE_LENGTH]);
197bf215546Sopenharmony_ci
198bf215546Sopenharmony_ci
199bf215546Sopenharmony_ciextern char *
200bf215546Sopenharmony_ci_mesa_program_state_string(const gl_state_index16 state[STATE_LENGTH]);
201bf215546Sopenharmony_ci
202bf215546Sopenharmony_ci
203bf215546Sopenharmony_ci
204bf215546Sopenharmony_ci#ifdef __cplusplus
205bf215546Sopenharmony_ci}
206bf215546Sopenharmony_ci#endif
207bf215546Sopenharmony_ci
208bf215546Sopenharmony_ci#endif /* PROG_STATEVARS_H */
209