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"
45 /***************************************
46 * Mesa's Driver Functions
47 ***************************************/
49 static const struct dri_extension i915_extensions
[] =
51 { "GL_ARB_depth_texture", NULL
},
52 { "GL_ARB_fragment_program", NULL
},
53 { "GL_ARB_shadow", NULL
},
54 { "GL_ARB_texture_env_crossbar", NULL
},
55 { "GL_EXT_shadow_funcs", NULL
},
56 /* ARB extn won't work if not enabled */
57 { "GL_SGIX_depth_texture", NULL
},
61 /* Override intel default.
63 static void i915InvalidateState( GLcontext
*ctx
, GLuint new_state
)
65 _swrast_InvalidateState( ctx
, new_state
);
66 _swsetup_InvalidateState( ctx
, new_state
);
67 _vbo_InvalidateState( ctx
, new_state
);
68 _tnl_InvalidateState( ctx
, new_state
);
69 _tnl_invalidate_vertex_state( ctx
, new_state
);
70 INTEL_CONTEXT(ctx
)->NewGLState
|= new_state
;
72 /* Todo: gather state values under which tracked parameters become
73 * invalidated, add callbacks for things like
74 * ProgramLocalParameters, etc.
77 struct i915_fragment_program
*p
=
78 (struct i915_fragment_program
*)ctx
->FragmentProgram
._Current
;
79 if (p
&& p
->nr_params
)
80 p
->params_uptodate
= 0;
83 if (new_state
& (_NEW_FOG
|_NEW_HINT
|_NEW_PROGRAM
))
88 static void i915InitDriverFunctions( struct dd_function_table
*functions
)
90 intelInitDriverFunctions( functions
);
91 i915InitStateFunctions( functions
);
92 i915InitTextureFuncs( functions
);
93 i915InitFragProgFuncs( functions
);
94 functions
->UpdateState
= i915InvalidateState
;
99 GLboolean
i915CreateContext( const __GLcontextModes
*mesaVis
,
100 __DRIcontextPrivate
*driContextPriv
,
101 void *sharedContextPrivate
)
103 struct dd_function_table functions
;
104 i915ContextPtr i915
= (i915ContextPtr
) CALLOC_STRUCT(i915_context
);
105 intelContextPtr intel
= &i915
->intel
;
106 GLcontext
*ctx
= &intel
->ctx
;
109 if (!i915
) return GL_FALSE
;
111 i915InitVtbl( i915
);
113 i915InitDriverFunctions( &functions
);
115 if (!intelInitContext( intel
, mesaVis
, driContextPriv
,
116 sharedContextPrivate
, &functions
)) {
121 ctx
->Const
.MaxTextureUnits
= I915_TEX_UNITS
;
122 ctx
->Const
.MaxTextureImageUnits
= I915_TEX_UNITS
;
123 ctx
->Const
.MaxTextureCoordUnits
= I915_TEX_UNITS
;
126 intel
->texture_heaps
[0] =
127 driCreateTextureHeap( 0, intel
,
128 intel
->intelScreen
->tex
.size
,
131 intel
->sarea
->texList
,
132 (unsigned *) & intel
->sarea
->texAge
,
134 sizeof( struct i915_texture_object
),
135 (destroy_texture_object_t
*)intelDestroyTexObj
);
137 /* FIXME: driCalculateMaxTextureLevels assumes that mipmaps are
138 * tightly packed, but they're not in Intel graphics
141 ctx
->Const
.MaxTextureUnits
= I915_TEX_UNITS
;
142 i
= driQueryOptioni( &intel
->optionCache
, "allow_large_textures");
143 driCalculateMaxTextureLevels( intel
->texture_heaps
,
147 11, /* max 2D texture size is 2048x2048 */
149 11, /* cube texture. */
150 11, /* rect texture */
155 /* GL_ARB_fragment_program limits - don't think Mesa actually
156 * validates programs against these, and in any case one ARB
157 * instruction can translate to more than one HW instruction, so
158 * we'll still have to check and fallback each time.
161 ctx
->Const
.FragmentProgram
.MaxNativeTemps
= I915_MAX_TEMPORARY
;
162 ctx
->Const
.FragmentProgram
.MaxNativeAttribs
= 11; /* 8 tex, 2 color, fog */
163 ctx
->Const
.FragmentProgram
.MaxNativeParameters
= I915_MAX_CONSTANT
;
164 ctx
->Const
.FragmentProgram
.MaxNativeAluInstructions
= I915_MAX_ALU_INSN
;
165 ctx
->Const
.FragmentProgram
.MaxNativeTexInstructions
= I915_MAX_TEX_INSN
;
166 ctx
->Const
.FragmentProgram
.MaxNativeInstructions
= (I915_MAX_ALU_INSN
+
168 ctx
->Const
.FragmentProgram
.MaxNativeTexIndirections
= I915_MAX_TEX_INDIRECT
;
169 ctx
->Const
.FragmentProgram
.MaxNativeAddressRegs
= 0; /* I don't think we have one */
170 ctx
->FragmentProgram
._MaintainTexEnvProgram
= GL_TRUE
;
171 ctx
->FragmentProgram
._UseTexEnvProgram
= GL_TRUE
;
174 driInitExtensions( ctx
, i915_extensions
, GL_FALSE
);
177 _tnl_init_vertices( ctx
, ctx
->Const
.MaxArrayLockSize
+ 12,
178 36 * sizeof(GLfloat
) );
180 intel
->verts
= TNL_CONTEXT(ctx
)->clipspace
.vertex_buf
;
182 i915InitState( i915
);