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 #include "i915_context.h"
30 #include "intel_tex.h"
31 #include "intel_tris.h"
32 #include "tnl/t_context.h"
33 #include "tnl/t_pipeline.h"
34 #include "tnl/t_vertex.h"
36 #include "swrast/swrast.h"
37 #include "swrast_setup/swrast_setup.h"
39 #include "array_cache/acache.h"
44 /***************************************
45 * Mesa's Driver Functions
46 ***************************************/
48 static const char * const card_extensions
[] =
50 "GL_ARB_fragment_program",
54 /* Override intel default.
56 static void i915InvalidateState( GLcontext
*ctx
, GLuint new_state
)
58 _swrast_InvalidateState( ctx
, new_state
);
59 _swsetup_InvalidateState( ctx
, new_state
);
60 _ac_InvalidateState( ctx
, new_state
);
61 _tnl_InvalidateState( ctx
, new_state
);
62 _tnl_invalidate_vertex_state( ctx
, new_state
);
63 INTEL_CONTEXT(ctx
)->NewGLState
|= new_state
;
65 /* Todo: gather state values under which tracked parameters become
66 * invalidated, add callbacks for things like
67 * ProgramLocalParameters, etc.
70 struct i915_fragment_program
*p
=
71 (struct i915_fragment_program
*)ctx
->FragmentProgram
.Current
;
73 p
->params_uptodate
= 0;
78 /* This is the extension list explicitly enabled by the client and
79 * excludes functionality available in Mesa and also excludes legacy
80 * extensions. It is recognized that in an open source driver, those
81 * extensions will probably be re-enabled.
83 static const GLubyte
*i915GetString( GLcontext
*ctx
, GLenum name
)
85 if (name
== GL_EXTENSIONS
)
87 "GL_ARB_fragment_program "
88 "GL_ARB_multitexture "
89 "GL_ARB_point_parameters "
90 "GL_ARB_texture_border_clamp "
91 "GL_ARB_texture_compression "
92 "GL_ARB_texture_cube_map "
93 "GL_ARB_texture_env_add "
94 "GL_ARB_texture_env_combine "
95 "GL_ARB_texture_env_dot3 "
96 "GL_ARB_texture_mirrored_repeat "
97 "GL_ARB_transpose_matrix "
98 "GL_ARB_vertex_buffer_object "
99 "GL_ARB_vertex_program "
103 "GL_EXT_blend_color "
104 "GL_EXT_blend_func_separate "
105 "GL_EXT_blend_minmax "
106 "GL_EXT_blend_subtract "
107 "GL_EXT_clip_volume_hint "
108 "GL_EXT_compiled_vertex_array "
109 "GL_EXT_draw_range_elements "
111 "GL_EXT_multi_draw_arrays "
112 "GL_EXT_packed_pixels "
113 "GL_EXT_rescale_normal "
114 "GL_EXT_secondary_color "
115 "GL_EXT_separate_specular_color "
116 "GL_EXT_stencil_wrap "
118 "GL_EXT_texture_env_add "
119 "GL_EXT_texture_env_combine "
120 "GL_EXT_texture_filter_anisotropic "
121 "GL_IBM_texture_mirrored_repeat "
122 "GL_MESA_ycbcr_texture "
123 "GL_MESA_window_pos "
124 "GL_NV_texgen_reflection "
125 "GL_SGIS_generate_mipmap";
127 return intelGetString( ctx
, name
);
131 static void i915InitDriverFunctions( struct dd_function_table
*functions
)
133 intelInitDriverFunctions( functions
);
134 i915InitStateFunctions( functions
);
135 i915InitTextureFuncs( functions
);
136 i915InitFragProgFuncs( functions
);
137 functions
->UpdateState
= i915InvalidateState
;
138 functions
->GetString
= i915GetString
;
143 GLboolean
i915CreateContext( const __GLcontextModes
*mesaVis
,
144 __DRIcontextPrivate
*driContextPriv
,
145 void *sharedContextPrivate
)
147 struct dd_function_table functions
;
148 i915ContextPtr i915
= (i915ContextPtr
) CALLOC_STRUCT(i915_context
);
149 intelContextPtr intel
= &i915
->intel
;
150 GLcontext
*ctx
= &intel
->ctx
;
152 if (!i915
) return GL_FALSE
;
154 i915InitVtbl( i915
);
156 i915InitDriverFunctions( &functions
);
158 if (!intelInitContext( intel
, mesaVis
, driContextPriv
,
159 sharedContextPrivate
, &functions
)) {
164 ctx
->Const
.MaxTextureUnits
= I915_TEX_UNITS
;
165 ctx
->Const
.MaxTextureImageUnits
= I915_TEX_UNITS
;
166 ctx
->Const
.MaxTextureCoordUnits
= I915_TEX_UNITS
;
169 intel
->texture_heaps
[0] =
170 driCreateTextureHeap( 0, intel
,
171 intel
->intelScreen
->textureSize
,
174 intel
->sarea
->texList
,
175 & intel
->sarea
->texAge
,
177 sizeof( struct i915_texture_object
),
178 (destroy_texture_object_t
*)intelDestroyTexObj
);
180 /* FIXME: driCalculateMaxTextureLevels assumes that mipmaps are tightly
181 * FIXME: packed, but they're not in Intel graphics hardware.
183 ctx
->Const
.MaxTextureUnits
= 1;
184 driCalculateMaxTextureLevels( intel
->texture_heaps
,
188 11, /* max 2D texture size is 2048x2048 */
190 11, /* cube texture. */
191 11, /* rect texture */
194 ctx
->Const
.MaxTextureUnits
= I915_TEX_UNITS
;
196 /* GL_ARB_fragment_program limits - don't think Mesa actually
197 * validates programs against these, and in any case one ARB
198 * instruction can translate to more than one HW instruction, so
199 * we'll still have to check and fallback each time.
202 ctx
->Const
.MaxFragmentProgramTemps
= I915_MAX_TEMPORARY
;
203 ctx
->Const
.MaxFragmentProgramAttribs
= 11; /* 8 tex, 2 color, fog */
204 ctx
->Const
.MaxFragmentProgramLocalParams
= I915_MAX_CONSTANT
;
205 ctx
->Const
.MaxFragmentProgramEnvParams
= I915_MAX_CONSTANT
;
206 ctx
->Const
.MaxFragmentProgramAluInstructions
= I915_MAX_ALU_INSN
;
207 ctx
->Const
.MaxFragmentProgramTexInstructions
= I915_MAX_TEX_INSN
;
208 ctx
->Const
.MaxFragmentProgramInstructions
= (I915_MAX_ALU_INSN
+
210 ctx
->Const
.MaxFragmentProgramTexIndirections
= I915_MAX_TEX_INDIRECT
;
211 ctx
->Const
.MaxFragmentProgramAddressRegs
= 0; /* I don't think we have one */
214 driInitExtensions( ctx
, card_extensions
, GL_FALSE
);
217 _tnl_init_vertices( ctx
, ctx
->Const
.MaxArrayLockSize
+ 12,
218 36 * sizeof(GLfloat
) );
220 intel
->verts
= TNL_CONTEXT(ctx
)->clipspace
.vertex_buf
;
222 i915InitState( i915
);