1 /**************************************************************************
3 * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
28 #ifndef I830CONTEXT_INC
29 #define I830CONTEXT_INC
31 #include "intel_context.h"
33 #define I830_FALLBACK_TEXTURE 0x1000
34 #define I830_FALLBACK_COLORMASK 0x2000
35 #define I830_FALLBACK_STENCIL 0x4000
36 #define I830_FALLBACK_STIPPLE 0x8000
37 #define I830_FALLBACK_LOGICOP 0x10000
39 #define I830_UPLOAD_CTX 0x1
40 #define I830_UPLOAD_BUFFERS 0x2
41 #define I830_UPLOAD_STIPPLE 0x4
42 #define I830_UPLOAD_INVARIENT 0x8
43 #define I830_UPLOAD_TEX(i) (0x10<<(i))
44 #define I830_UPLOAD_TEXBLEND(i) (0x100<<(i))
45 #define I830_UPLOAD_TEX_ALL (0x0f0)
46 #define I830_UPLOAD_TEXBLEND_ALL (0xf00)
48 /* State structure offsets - these will probably disappear.
50 #define I830_DESTREG_CBUFADDR0 0
51 #define I830_DESTREG_CBUFADDR1 1
52 #define I830_DESTREG_DBUFADDR0 2
53 #define I830_DESTREG_DBUFADDR1 3
54 #define I830_DESTREG_DV0 4
55 #define I830_DESTREG_DV1 5
56 #define I830_DESTREG_SENABLE 6
57 #define I830_DESTREG_SR0 7
58 #define I830_DESTREG_SR1 8
59 #define I830_DESTREG_SR2 9
60 #define I830_DEST_SETUP_SIZE 10
62 #define I830_CTXREG_STATE1 0
63 #define I830_CTXREG_STATE2 1
64 #define I830_CTXREG_STATE3 2
65 #define I830_CTXREG_STATE4 3
66 #define I830_CTXREG_STATE5 4
67 #define I830_CTXREG_IALPHAB 5
68 #define I830_CTXREG_STENCILTST 6
69 #define I830_CTXREG_ENABLES_1 7
70 #define I830_CTXREG_ENABLES_2 8
71 #define I830_CTXREG_AA 9
72 #define I830_CTXREG_FOGCOLOR 10
73 #define I830_CTXREG_BLENDCOLOR0 11
74 #define I830_CTXREG_BLENDCOLOR1 12
75 #define I830_CTXREG_VF 13
76 #define I830_CTXREG_VF2 14
77 #define I830_CTXREG_MCSB0 15
78 #define I830_CTXREG_MCSB1 16
79 #define I830_CTX_SETUP_SIZE 17
81 #define I830_STPREG_ST0 0
82 #define I830_STPREG_ST1 1
83 #define I830_STP_SETUP_SIZE 2
85 #define I830_TEXREG_TM0LI 0 /* load immediate 2 texture map n */
86 #define I830_TEXREG_TM0S1 1
87 #define I830_TEXREG_TM0S2 2
88 #define I830_TEXREG_TM0S3 3
89 #define I830_TEXREG_TM0S4 4
90 #define I830_TEXREG_MCS 5 /* _3DSTATE_MAP_COORD_SETS */
91 #define I830_TEXREG_CUBE 6 /* _3DSTATE_MAP_SUBE */
92 #define I830_TEX_SETUP_SIZE 7
94 #define I830_TEXBLEND_SIZE 12 /* (4 args + op) * 2 + COLOR_FACTOR */
96 struct i830_texture_object
98 struct intel_texture_object intel
;
99 GLuint Setup
[I830_TEX_SETUP_SIZE
];
102 #define I830_TEX_UNITS 4
106 GLuint Ctx
[I830_CTX_SETUP_SIZE
];
107 GLuint Buffer
[I830_DEST_SETUP_SIZE
];
108 GLuint Stipple
[I830_STP_SETUP_SIZE
];
109 GLuint Tex
[I830_TEX_UNITS
][I830_TEX_SETUP_SIZE
];
110 GLuint TexBlend
[I830_TEX_UNITS
][I830_TEXBLEND_SIZE
];
111 GLuint TexBlendWordsUsed
[I830_TEX_UNITS
];
113 struct intel_region
*draw_region
;
114 struct intel_region
*depth_region
;
116 /* Regions aren't actually that appropriate here as the memory may
117 * be from a PBO or FBO. Will have to do this for draw and depth for
120 dri_bo
*tex_buffer
[I830_TEX_UNITS
];
121 GLuint tex_offset
[I830_TEX_UNITS
];
123 GLuint emitted
; /* I810_UPLOAD_* */
129 struct intel_context intel
;
131 GLuint lodbias_tm0s3
[MAX_TEXTURE_UNITS
];
132 DECLARE_RENDERINPUTS(last_index_bitset
);
134 struct i830_hw_state meta
, initial
, state
, *current
;
140 #define I830_STATECHANGE(i830, flag) \
142 INTEL_FIREVERTICES( &i830->intel ); \
143 i830->state.emitted &= ~flag; \
146 #define I830_ACTIVESTATE(i830, flag, mode) \
148 INTEL_FIREVERTICES( &i830->intel ); \
150 i830->state.active |= flag; \
152 i830->state.active &= ~flag; \
157 extern void i830InitVtbl(struct i830_context
*i830
);
160 i830_state_draw_region(struct intel_context
*intel
,
161 struct i830_hw_state
*state
,
162 struct intel_region
*color_region
,
163 struct intel_region
*depth_region
);
167 i830CreateContext(const __GLcontextModes
* mesaVis
,
168 __DRIcontextPrivate
* driContextPriv
,
169 void *sharedContextPrivate
);
171 /* i830_tex.c, i830_texstate.c
173 extern void i830UpdateTextureState(struct intel_context
*intel
);
175 extern void i830InitTextureFuncs(struct dd_function_table
*functions
);
179 extern GLuint
i830SetTexEnvCombine(struct i830_context
*i830
,
180 const struct gl_tex_env_combine_state
181 *combine
, GLint blendUnit
, GLuint texel_op
,
182 GLuint
* state
, const GLfloat
* factor
);
184 extern void i830EmitTextureBlend(struct i830_context
*i830
);
189 extern void i830InitStateFuncs(struct dd_function_table
*functions
);
191 extern void i830EmitState(struct i830_context
*i830
);
193 extern void i830InitState(struct i830_context
*i830
);
197 extern void i830InitMetaFuncs(struct i830_context
*i830
);
200 i830RotateWindow(struct intel_context
*intel
, __DRIdrawablePrivate
* dPriv
,
203 /*======================================================================
204 * Inline conversion functions. These are better-typed than the
205 * macros used previously:
207 static INLINE
struct i830_context
*
208 i830_context(GLcontext
* ctx
)
210 return (struct i830_context
*) ctx
;