13464ebd5Sriastradh/*
23464ebd5Sriastradh * Mesa 3-D graphics library
33464ebd5Sriastradh *
43464ebd5Sriastradh * Copyright (C) 1999-2007  Brian Paul   All Rights Reserved.
53464ebd5Sriastradh *
63464ebd5Sriastradh * Permission is hereby granted, free of charge, to any person obtaining a
73464ebd5Sriastradh * copy of this software and associated documentation files (the "Software"),
83464ebd5Sriastradh * to deal in the Software without restriction, including without limitation
93464ebd5Sriastradh * the rights to use, copy, modify, merge, publish, distribute, sublicense,
103464ebd5Sriastradh * and/or sell copies of the Software, and to permit persons to whom the
113464ebd5Sriastradh * Software is furnished to do so, subject to the following conditions:
123464ebd5Sriastradh *
133464ebd5Sriastradh * The above copyright notice and this permission notice shall be included
143464ebd5Sriastradh * in all copies or substantial portions of the Software.
153464ebd5Sriastradh *
163464ebd5Sriastradh * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
173464ebd5Sriastradh * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
183464ebd5Sriastradh * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19af69d88dSmrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20af69d88dSmrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21af69d88dSmrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22af69d88dSmrg * OTHER DEALINGS IN THE SOFTWARE.
233464ebd5Sriastradh */
243464ebd5Sriastradh
253464ebd5Sriastradh#ifndef PROG_STATEVARS_H
263464ebd5Sriastradh#define PROG_STATEVARS_H
273464ebd5Sriastradh
28af69d88dSmrg
293464ebd5Sriastradh#include "main/glheader.h"
3001e04c3fSmrg#include "compiler/shader_enums.h"
317ec681f3Smrg#include <stdint.h>
323464ebd5Sriastradh
33af69d88dSmrg
34af69d88dSmrg#ifdef __cplusplus
35af69d88dSmrgextern "C" {
36af69d88dSmrg#endif
37af69d88dSmrg
38af69d88dSmrg
393464ebd5Sriastradhstruct gl_context;
407ec681f3Smrgstruct gl_constants;
413464ebd5Sriastradhstruct gl_program_parameter_list;
423464ebd5Sriastradh
433464ebd5Sriastradh
443464ebd5Sriastradh/**
453464ebd5Sriastradh * Used for describing GL state referenced from inside ARB vertex and
463464ebd5Sriastradh * fragment programs.
473464ebd5Sriastradh * A string such as "state.light[0].ambient" gets translated into a
483464ebd5Sriastradh * sequence of tokens such as [ STATE_LIGHT, 0, STATE_AMBIENT ].
493464ebd5Sriastradh *
503464ebd5Sriastradh * For state that's an array, like STATE_CLIPPLANE, the 2nd token [1] should
513464ebd5Sriastradh * always be the array index.
523464ebd5Sriastradh */
533464ebd5Sriastradhtypedef enum gl_state_index_ {
547ec681f3Smrg   STATE_NOT_STATE_VAR = 0,
553464ebd5Sriastradh
567ec681f3Smrg   STATE_MATERIAL,
577ec681f3Smrg
587ec681f3Smrg   STATE_LIGHT,         /* One gl_light attribute. */
597ec681f3Smrg   STATE_LIGHT_ARRAY, /* Multiple gl_light attributes loaded at once. */
607ec681f3Smrg   STATE_LIGHT_ATTENUATION_ARRAY,
613464ebd5Sriastradh   STATE_LIGHTMODEL_AMBIENT,
623464ebd5Sriastradh   STATE_LIGHTMODEL_SCENECOLOR,
633464ebd5Sriastradh   STATE_LIGHTPROD,
647ec681f3Smrg   STATE_LIGHTPROD_ARRAY_FRONT,   /* multiple lights, only front faces */
657ec681f3Smrg   STATE_LIGHTPROD_ARRAY_BACK,    /* multiple lights, only back faces */
667ec681f3Smrg   STATE_LIGHTPROD_ARRAY_TWOSIDE, /* multiple lights, both sides */
673464ebd5Sriastradh
683464ebd5Sriastradh   STATE_TEXGEN,
697ec681f3Smrg   STATE_TEXENV_COLOR,
703464ebd5Sriastradh
713464ebd5Sriastradh   STATE_FOG_COLOR,
723464ebd5Sriastradh   STATE_FOG_PARAMS,
733464ebd5Sriastradh
743464ebd5Sriastradh   STATE_CLIPPLANE,
753464ebd5Sriastradh
763464ebd5Sriastradh   STATE_POINT_SIZE,
773464ebd5Sriastradh   STATE_POINT_ATTENUATION,
783464ebd5Sriastradh
793464ebd5Sriastradh   STATE_MODELVIEW_MATRIX,
807ec681f3Smrg   STATE_MODELVIEW_MATRIX_INVERSE,
817ec681f3Smrg   STATE_MODELVIEW_MATRIX_TRANSPOSE,
827ec681f3Smrg   STATE_MODELVIEW_MATRIX_INVTRANS,
833464ebd5Sriastradh
847ec681f3Smrg   STATE_PROJECTION_MATRIX,
857ec681f3Smrg   STATE_PROJECTION_MATRIX_INVERSE,
867ec681f3Smrg   STATE_PROJECTION_MATRIX_TRANSPOSE,
877ec681f3Smrg   STATE_PROJECTION_MATRIX_INVTRANS,
883464ebd5Sriastradh
897ec681f3Smrg   STATE_MVP_MATRIX,
907ec681f3Smrg   STATE_MVP_MATRIX_INVERSE,
917ec681f3Smrg   STATE_MVP_MATRIX_TRANSPOSE,
927ec681f3Smrg   STATE_MVP_MATRIX_INVTRANS,
933464ebd5Sriastradh
947ec681f3Smrg   STATE_TEXTURE_MATRIX,
957ec681f3Smrg   STATE_TEXTURE_MATRIX_INVERSE,
967ec681f3Smrg   STATE_TEXTURE_MATRIX_TRANSPOSE,
977ec681f3Smrg   STATE_TEXTURE_MATRIX_INVTRANS,
983464ebd5Sriastradh
997ec681f3Smrg   STATE_PROGRAM_MATRIX,
1007ec681f3Smrg   STATE_PROGRAM_MATRIX_INVERSE,
1017ec681f3Smrg   STATE_PROGRAM_MATRIX_TRANSPOSE,
1027ec681f3Smrg   STATE_PROGRAM_MATRIX_INVTRANS,
1033464ebd5Sriastradh
104af69d88dSmrg   STATE_NUM_SAMPLES,    /* An integer, not a float like the other state vars */
105af69d88dSmrg
1063464ebd5Sriastradh   STATE_DEPTH_RANGE,
1073464ebd5Sriastradh
1087ec681f3Smrg   STATE_FRAGMENT_PROGRAM_ENV,
1097ec681f3Smrg   STATE_FRAGMENT_PROGRAM_ENV_ARRAY,
1107ec681f3Smrg   STATE_FRAGMENT_PROGRAM_LOCAL,
1117ec681f3Smrg   STATE_FRAGMENT_PROGRAM_LOCAL_ARRAY,
1127ec681f3Smrg   STATE_VERTEX_PROGRAM_ENV,
1137ec681f3Smrg   STATE_VERTEX_PROGRAM_ENV_ARRAY,
1147ec681f3Smrg   STATE_VERTEX_PROGRAM_LOCAL,
1157ec681f3Smrg   STATE_VERTEX_PROGRAM_LOCAL_ARRAY,
1163464ebd5Sriastradh
1177ec681f3Smrg   STATE_NORMAL_SCALE_EYESPACE,
1183464ebd5Sriastradh   STATE_CURRENT_ATTRIB,        /* ctx->Current vertex attrib value */
1193464ebd5Sriastradh   STATE_CURRENT_ATTRIB_MAYBE_VP_CLAMPED,        /* ctx->Current vertex attrib value after passthrough vertex processing */
1203464ebd5Sriastradh   STATE_NORMAL_SCALE,
1213464ebd5Sriastradh   STATE_FOG_PARAMS_OPTIMIZED,  /* for faster fog calc */
1223464ebd5Sriastradh   STATE_POINT_SIZE_CLAMPED,    /* includes implementation dependent size clamp */
1233464ebd5Sriastradh   STATE_LIGHT_SPOT_DIR_NORMALIZED,   /* pre-normalized spot dir */
1243464ebd5Sriastradh   STATE_LIGHT_POSITION,              /* object vs eye space */
1257ec681f3Smrg   STATE_LIGHT_POSITION_ARRAY,
1263464ebd5Sriastradh   STATE_LIGHT_POSITION_NORMALIZED,   /* object vs eye space */
1277ec681f3Smrg   STATE_LIGHT_POSITION_NORMALIZED_ARRAY,
1283464ebd5Sriastradh   STATE_LIGHT_HALF_VECTOR,           /* object vs eye space */
1293464ebd5Sriastradh   STATE_PT_SCALE,              /**< Pixel transfer RGBA scale */
1303464ebd5Sriastradh   STATE_PT_BIAS,               /**< Pixel transfer RGBA bias */
1313464ebd5Sriastradh   STATE_FB_SIZE,               /**< (width-1, height-1, 0, 0) */
1323464ebd5Sriastradh   STATE_FB_WPOS_Y_TRANSFORM,   /**< (1, 0, -1, height) if a FBO is bound, (-1, height, 1, 0) otherwise */
1337ec681f3Smrg   STATE_FB_PNTC_Y_TRANSFORM,   /**< (1, 0, 0, 0) if point origin is upper left, (-1, 1, 0, 0) otherwise */
13401e04c3fSmrg   STATE_TCS_PATCH_VERTICES_IN, /**< gl_PatchVerticesIn for TCS (integer) */
13501e04c3fSmrg   STATE_TES_PATCH_VERTICES_IN, /**< gl_PatchVerticesIn for TES (integer) */
13601e04c3fSmrg   /**
13701e04c3fSmrg    * A single enum gl_blend_support_qualifier value representing the
13801e04c3fSmrg    * currently active advanced blending equation, or zero if disabled.
13901e04c3fSmrg    */
14001e04c3fSmrg   STATE_ADVANCED_BLENDING_MODE,
1417ec681f3Smrg   STATE_ALPHA_REF,        /* alpha-test reference value */
1427ec681f3Smrg   STATE_CLIP_INTERNAL,    /* similar to STATE_CLIPPLANE, but in clip-space */
1437ec681f3Smrg
1447ec681f3Smrg   STATE_INTERNAL_DRIVER,	/* first available state index for drivers (must be last) */
1457ec681f3Smrg
1467ec681f3Smrg
1477ec681f3Smrg   /** All enums below don't occur in state[0]. **/
1487ec681f3Smrg
1497ec681f3Smrg   /* These 8 enums must be in the same order as the gl_light union members,
1507ec681f3Smrg    * which should also match the order of gl_LightSource members.
1517ec681f3Smrg    */
1527ec681f3Smrg   STATE_AMBIENT,
1537ec681f3Smrg   STATE_DIFFUSE,
1547ec681f3Smrg   STATE_SPECULAR,
1557ec681f3Smrg   STATE_POSITION,       /**< xyzw = position */
1567ec681f3Smrg   STATE_HALF_VECTOR,
1577ec681f3Smrg   STATE_SPOT_DIRECTION, /**< xyz = direction, w = cos(cutoff) */
1587ec681f3Smrg   STATE_ATTENUATION,    /**< xyz = attenuation, w = spot exponent */
1597ec681f3Smrg   STATE_SPOT_CUTOFF,    /**< x = cutoff, yzw = undefined */
1607ec681f3Smrg
1617ec681f3Smrg   STATE_EMISSION,
1627ec681f3Smrg   STATE_SHININESS,
1637ec681f3Smrg
1647ec681f3Smrg   /* These 8 enums must be in the same order as the memory layout of
1657ec681f3Smrg    * gl_fixedfunc_texture_unit::EyePlane/ObjectPlane.
1667ec681f3Smrg    */
1677ec681f3Smrg   STATE_TEXGEN_EYE_S,
1687ec681f3Smrg   STATE_TEXGEN_EYE_T,
1697ec681f3Smrg   STATE_TEXGEN_EYE_R,
1707ec681f3Smrg   STATE_TEXGEN_EYE_Q,
1717ec681f3Smrg   STATE_TEXGEN_OBJECT_S,
1727ec681f3Smrg   STATE_TEXGEN_OBJECT_T,
1737ec681f3Smrg   STATE_TEXGEN_OBJECT_R,
1747ec681f3Smrg   STATE_TEXGEN_OBJECT_Q,
1753464ebd5Sriastradh} gl_state_index;
1763464ebd5Sriastradh
1773464ebd5Sriastradh
1783464ebd5Sriastradhextern void
1793464ebd5Sriastradh_mesa_load_state_parameters(struct gl_context *ctx,
1803464ebd5Sriastradh                            struct gl_program_parameter_list *paramList);
1813464ebd5Sriastradh
1827ec681f3Smrgextern void
1837ec681f3Smrg_mesa_upload_state_parameters(struct gl_context *ctx,
1847ec681f3Smrg                              struct gl_program_parameter_list *paramList,
1857ec681f3Smrg                              uint32_t *dst);
1867ec681f3Smrg
1877ec681f3Smrgextern void
1887ec681f3Smrg_mesa_optimize_state_parameters(struct gl_constants *consts,
1897ec681f3Smrg                                struct gl_program_parameter_list *list);
1907ec681f3Smrg
1917ec681f3Smrgextern unsigned
1927ec681f3Smrg_mesa_program_state_value_size(const gl_state_index16 state[STATE_LENGTH]);
1933464ebd5Sriastradh
1943464ebd5Sriastradhextern GLbitfield
19501e04c3fSmrg_mesa_program_state_flags(const gl_state_index16 state[STATE_LENGTH]);
1963464ebd5Sriastradh
1973464ebd5Sriastradh
1983464ebd5Sriastradhextern char *
19901e04c3fSmrg_mesa_program_state_string(const gl_state_index16 state[STATE_LENGTH]);
2003464ebd5Sriastradh
2013464ebd5Sriastradh
2023464ebd5Sriastradh
203af69d88dSmrg#ifdef __cplusplus
204af69d88dSmrg}
205af69d88dSmrg#endif
2063464ebd5Sriastradh
2073464ebd5Sriastradh#endif /* PROG_STATEVARS_H */
208