fix up radeon span functions using latest r200 code from Brian,
[mesa.git] / src / mesa / drivers / dri / i915 / i830_context.c
1 /**************************************************************************
2 *
3 * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
4 * All Rights Reserved.
5 *
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:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
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.
25 *
26 **************************************************************************/
27
28 #include "i830_context.h"
29 #include "imports.h"
30 #include "texmem.h"
31 #include "intel_tex.h"
32 #include "tnl/tnl.h"
33 #include "tnl/t_vertex.h"
34 #include "tnl/t_context.h"
35 #include "utils.h"
36
37 /***************************************
38 * Mesa's Driver Functions
39 ***************************************/
40
41 static const struct dri_extension i830_extensions[] =
42 {
43 { "GL_ARB_texture_env_crossbar", NULL },
44 { NULL, NULL }
45 };
46
47
48 static void i830InitDriverFunctions( struct dd_function_table *functions )
49 {
50 intelInitDriverFunctions( functions );
51 i830InitStateFuncs( functions );
52 i830InitTextureFuncs( functions );
53 }
54
55
56 GLboolean i830CreateContext( const __GLcontextModes *mesaVis,
57 __DRIcontextPrivate *driContextPriv,
58 void *sharedContextPrivate)
59 {
60 struct dd_function_table functions;
61 i830ContextPtr i830 = (i830ContextPtr) CALLOC_STRUCT(i830_context);
62 intelContextPtr intel = &i830->intel;
63 GLcontext *ctx = &intel->ctx;
64 if (!i830) return GL_FALSE;
65
66 i830InitVtbl( i830 );
67 i830InitDriverFunctions( &functions );
68
69 if (!intelInitContext( intel, mesaVis, driContextPriv,
70 sharedContextPrivate, &functions )) {
71 FREE(i830);
72 return GL_FALSE;
73 }
74
75 intel->ctx.Const.MaxTextureUnits = I830_TEX_UNITS;
76 intel->ctx.Const.MaxTextureImageUnits = I830_TEX_UNITS;
77 intel->ctx.Const.MaxTextureCoordUnits = I830_TEX_UNITS;
78
79 intel->nr_heaps = 1;
80 intel->texture_heaps[0] =
81 driCreateTextureHeap( 0, intel,
82 intel->intelScreen->tex.size,
83 12,
84 I830_NR_TEX_REGIONS,
85 intel->sarea->texList,
86 & intel->sarea->texAge,
87 & intel->swapped,
88 sizeof( struct i830_texture_object ),
89 (destroy_texture_object_t *)intelDestroyTexObj );
90
91 /* FIXME: driCalculateMaxTextureLevels assumes that mipmaps are tightly
92 * FIXME: packed, but they're not in Intel graphics hardware.
93 */
94 intel->ctx.Const.MaxTextureUnits = 1;
95 driCalculateMaxTextureLevels( intel->texture_heaps,
96 intel->nr_heaps,
97 &intel->ctx.Const,
98 4,
99 11, /* max 2D texture size is 2048x2048 */
100 8, /* max 3D texture size is 256^3 */
101 10, /* max CUBE texture size is 1024x1024 */
102 11, /* max RECT. supported */
103 12,
104 GL_FALSE );
105 intel->ctx.Const.MaxTextureUnits = I830_TEX_UNITS;
106
107 _tnl_init_vertices( ctx, ctx->Const.MaxArrayLockSize + 12,
108 18 * sizeof(GLfloat) );
109
110 intel->verts = TNL_CONTEXT(ctx)->clipspace.vertex_buf;
111
112 driInitExtensions( ctx, i830_extensions, GL_FALSE );
113
114 i830InitState( i830 );
115
116
117 _tnl_allow_vertex_fog( ctx, 1 );
118 _tnl_allow_pixel_fog( ctx, 0 );
119
120 return GL_TRUE;
121 }
122