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 struct dri_extension i915_extensions
[] =
50 { "GL_ARB_depth_texture", NULL
},
51 { "GL_ARB_fragment_program", NULL
},
52 { "GL_ARB_shadow", NULL
},
53 { "GL_EXT_shadow_funcs", NULL
},
54 /* ARB extn won't work if not enabled */
55 { "GL_SGIX_depth_texture", NULL
},
59 /* Override intel default.
61 static void i915InvalidateState( GLcontext
*ctx
, GLuint new_state
)
63 _swrast_InvalidateState( ctx
, new_state
);
64 _swsetup_InvalidateState( ctx
, new_state
);
65 _ac_InvalidateState( ctx
, new_state
);
66 _tnl_InvalidateState( ctx
, new_state
);
67 _tnl_invalidate_vertex_state( ctx
, new_state
);
68 INTEL_CONTEXT(ctx
)->NewGLState
|= new_state
;
70 /* Todo: gather state values under which tracked parameters become
71 * invalidated, add callbacks for things like
72 * ProgramLocalParameters, etc.
75 struct i915_fragment_program
*p
=
76 (struct i915_fragment_program
*)ctx
->FragmentProgram
._Current
;
77 if (p
&& p
->nr_params
)
78 p
->params_uptodate
= 0;
81 if (new_state
& (_NEW_FOG
|_NEW_HINT
|_NEW_PROGRAM
))
86 static void i915InitDriverFunctions( struct dd_function_table
*functions
)
88 intelInitDriverFunctions( functions
);
89 i915InitStateFunctions( functions
);
90 i915InitTextureFuncs( functions
);
91 i915InitFragProgFuncs( functions
);
92 functions
->UpdateState
= i915InvalidateState
;
97 GLboolean
i915CreateContext( const __GLcontextModes
*mesaVis
,
98 __DRIcontextPrivate
*driContextPriv
,
99 void *sharedContextPrivate
)
101 struct dd_function_table functions
;
102 i915ContextPtr i915
= (i915ContextPtr
) CALLOC_STRUCT(i915_context
);
103 intelContextPtr intel
= &i915
->intel
;
104 GLcontext
*ctx
= &intel
->ctx
;
106 if (!i915
) return GL_FALSE
;
108 i915InitVtbl( i915
);
110 i915InitDriverFunctions( &functions
);
112 if (!intelInitContext( intel
, mesaVis
, driContextPriv
,
113 sharedContextPrivate
, &functions
)) {
118 ctx
->Const
.MaxTextureUnits
= I915_TEX_UNITS
;
119 ctx
->Const
.MaxTextureImageUnits
= I915_TEX_UNITS
;
120 ctx
->Const
.MaxTextureCoordUnits
= I915_TEX_UNITS
;
123 intel
->texture_heaps
[0] =
124 driCreateTextureHeap( 0, intel
,
125 intel
->intelScreen
->tex
.size
,
128 intel
->sarea
->texList
,
129 & intel
->sarea
->texAge
,
131 sizeof( struct i915_texture_object
),
132 (destroy_texture_object_t
*)intelDestroyTexObj
);
134 /* FIXME: driCalculateMaxTextureLevels assumes that mipmaps are
135 * tightly packed, but they're not in Intel graphics
138 ctx
->Const
.MaxTextureUnits
= 1;
139 driCalculateMaxTextureLevels( intel
->texture_heaps
,
143 11, /* max 2D texture size is 2048x2048 */
145 11, /* cube texture. */
146 11, /* rect texture */
149 ctx
->Const
.MaxTextureUnits
= I915_TEX_UNITS
;
151 /* GL_ARB_fragment_program limits - don't think Mesa actually
152 * validates programs against these, and in any case one ARB
153 * instruction can translate to more than one HW instruction, so
154 * we'll still have to check and fallback each time.
157 ctx
->Const
.MaxFragmentProgramTemps
= I915_MAX_TEMPORARY
;
158 ctx
->Const
.MaxFragmentProgramAttribs
= 11; /* 8 tex, 2 color, fog */
159 ctx
->Const
.MaxFragmentProgramLocalParams
= I915_MAX_CONSTANT
;
160 ctx
->Const
.MaxFragmentProgramEnvParams
= I915_MAX_CONSTANT
;
161 ctx
->Const
.MaxFragmentProgramAluInstructions
= I915_MAX_ALU_INSN
;
162 ctx
->Const
.MaxFragmentProgramTexInstructions
= I915_MAX_TEX_INSN
;
163 ctx
->Const
.MaxFragmentProgramInstructions
= (I915_MAX_ALU_INSN
+
165 ctx
->Const
.MaxFragmentProgramTexIndirections
= I915_MAX_TEX_INDIRECT
;
166 ctx
->Const
.MaxFragmentProgramAddressRegs
= 0; /* I don't think we have one */
169 driInitExtensions( ctx
, i915_extensions
, GL_FALSE
);
172 _tnl_init_vertices( ctx
, ctx
->Const
.MaxArrayLockSize
+ 12,
173 36 * sizeof(GLfloat
) );
175 intel
->verts
= TNL_CONTEXT(ctx
)->clipspace
.vertex_buf
;
177 i915InitState( i915
);