2 Copyright (C) Intel Corp. 2006. All Rights Reserved.
3 Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
4 develop this 3D driver.
6 Permission is hereby granted, free of charge, to any person obtaining
7 a 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, sublicense, 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
16 portions of the Software.
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21 IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
22 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **********************************************************************/
29 * Keith Whitwell <keith@tungstengraphics.com>
33 #include "main/imports.h"
34 #include "main/api_noop.h"
35 #include "main/macros.h"
36 #include "main/vtxfmt.h"
37 #include "main/simple_list.h"
38 #include "shader/shader_api.h"
40 #include "brw_context.h"
41 #include "brw_defines.h"
43 #include "brw_state.h"
45 #include "intel_tex.h"
46 #include "intel_blit.h"
47 #include "intel_batchbuffer.h"
48 #include "intel_pixel.h"
49 #include "intel_span.h"
50 #include "tnl/t_pipeline.h"
55 /***************************************
56 * Mesa's Driver Functions
57 ***************************************/
59 static void brwUseProgram(GLcontext
*ctx
, GLuint program
)
61 _mesa_use_program(ctx
, program
);
64 static void brwInitProgFuncs( struct dd_function_table
*functions
)
66 functions
->UseProgram
= brwUseProgram
;
68 static void brwInitDriverFunctions( struct dd_function_table
*functions
)
70 intelInitDriverFunctions( functions
);
72 brwInitFragProgFuncs( functions
);
73 brwInitProgFuncs( functions
);
74 brw_init_queryobj_functions(functions
);
76 functions
->Viewport
= intel_viewport
;
80 static void brw_init_attribs( struct brw_context
*brw
)
82 GLcontext
*ctx
= &brw
->intel
.ctx
;
84 brw
->attribs
.Color
= &ctx
->Color
;
85 brw
->attribs
.Depth
= &ctx
->Depth
;
86 brw
->attribs
.Fog
= &ctx
->Fog
;
87 brw
->attribs
.Hint
= &ctx
->Hint
;
88 brw
->attribs
.Light
= &ctx
->Light
;
89 brw
->attribs
.Line
= &ctx
->Line
;
90 brw
->attribs
.Point
= &ctx
->Point
;
91 brw
->attribs
.Polygon
= &ctx
->Polygon
;
92 brw
->attribs
.Scissor
= &ctx
->Scissor
;
93 brw
->attribs
.Stencil
= &ctx
->Stencil
;
94 brw
->attribs
.Texture
= &ctx
->Texture
;
95 brw
->attribs
.Transform
= &ctx
->Transform
;
96 brw
->attribs
.Viewport
= &ctx
->Viewport
;
97 brw
->attribs
.VertexProgram
= &ctx
->VertexProgram
;
98 brw
->attribs
.FragmentProgram
= &ctx
->FragmentProgram
;
99 brw
->attribs
.PolygonStipple
= &ctx
->PolygonStipple
[0];
103 GLboolean
brwCreateContext( const __GLcontextModes
*mesaVis
,
104 __DRIcontextPrivate
*driContextPriv
,
105 void *sharedContextPrivate
)
107 struct dd_function_table functions
;
108 struct brw_context
*brw
= (struct brw_context
*) CALLOC_STRUCT(brw_context
);
109 struct intel_context
*intel
= &brw
->intel
;
110 GLcontext
*ctx
= &intel
->ctx
;
113 _mesa_printf("%s: failed to alloc context\n", __FUNCTION__
);
118 brwInitDriverFunctions( &functions
);
120 if (!intelInitContext( intel
, mesaVis
, driContextPriv
,
121 sharedContextPrivate
, &functions
)) {
122 _mesa_printf("%s: failed to init intel context\n", __FUNCTION__
);
127 /* Initialize swrast, tnl driver tables: */
128 intelInitSpanFuncs(ctx
);
130 TNL_CONTEXT(ctx
)->Driver
.RunPipeline
= _tnl_run_pipeline
;
132 ctx
->Const
.MaxTextureImageUnits
= BRW_MAX_TEX_UNIT
;
133 ctx
->Const
.MaxTextureCoordUnits
= 8; /* Mesa limit */
134 ctx
->Const
.MaxTextureUnits
= MIN2(ctx
->Const
.MaxTextureCoordUnits
,
135 ctx
->Const
.MaxTextureImageUnits
);
136 ctx
->Const
.MaxVertexTextureImageUnits
= 0; /* no vertex shader textures */
138 /* Advertise the full hardware capabilities. The new memory
139 * manager should cope much better with overload situations:
141 ctx
->Const
.MaxTextureLevels
= 12;
142 ctx
->Const
.Max3DTextureLevels
= 9;
143 ctx
->Const
.MaxCubeTextureLevels
= 12;
144 ctx
->Const
.MaxTextureRectSize
= (1<<11);
146 /* if conformance mode is set, swrast can handle any size AA point */
147 ctx
->Const
.MaxPointSizeAA
= 255.0;
149 /* ctx->Const.MaxNativeVertexProgramTemps = 32; */
151 brw_init_attribs( brw
);
152 brw_init_metaops( brw
);
153 brw_init_state( brw
);
155 brw
->state
.dirty
.mesa
= ~0;
156 brw
->state
.dirty
.brw
= ~0;
158 brw
->emit_state_always
= 0;
160 ctx
->VertexProgram
._MaintainTnlProgram
= GL_TRUE
;
161 ctx
->FragmentProgram
._MaintainTexEnvProgram
= GL_TRUE
;
163 make_empty_list(&brw
->query
.active_head
);
165 brw_draw_init( brw
);