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"
29 #include "main/imports.h"
30 #include "main/macros.h"
31 #include "intel_tex.h"
32 #include "intel_tris.h"
33 #include "tnl/t_context.h"
34 #include "tnl/t_pipeline.h"
35 #include "tnl/t_vertex.h"
37 #include "swrast/swrast.h"
38 #include "swrast_setup/swrast_setup.h"
44 #include "intel_regions.h"
45 #include "intel_batchbuffer.h"
46 #include "intel_tris.h"
47 #include "intel_span.h"
48 #include "intel_pixel.h"
50 /***************************************
51 * Mesa's Driver Functions
52 ***************************************/
54 /* Override intel default.
57 i915InvalidateState(GLcontext
* ctx
, GLuint new_state
)
59 _swrast_InvalidateState(ctx
, new_state
);
60 _swsetup_InvalidateState(ctx
, new_state
);
61 _vbo_InvalidateState(ctx
, new_state
);
62 _tnl_InvalidateState(ctx
, new_state
);
63 _tnl_invalidate_vertex_state(ctx
, new_state
);
64 intel_context(ctx
)->NewGLState
|= new_state
;
66 /* Todo: gather state values under which tracked parameters become
67 * invalidated, add callbacks for things like
68 * ProgramLocalParameters, etc.
71 struct i915_fragment_program
*p
=
72 (struct i915_fragment_program
*) ctx
->FragmentProgram
._Current
;
73 if (p
&& p
->nr_params
)
74 p
->params_uptodate
= 0;
77 if (new_state
& (_NEW_FOG
| _NEW_HINT
| _NEW_PROGRAM
| _NEW_PROGRAM_CONSTANTS
))
79 if (new_state
& (_NEW_STENCIL
| _NEW_BUFFERS
| _NEW_POLYGON
))
80 i915_update_stencil(ctx
);
81 if (new_state
& (_NEW_LIGHT
))
82 i915_update_provoking_vertex(ctx
);
87 i915InitDriverFunctions(struct dd_function_table
*functions
)
89 intelInitDriverFunctions(functions
);
90 i915InitStateFunctions(functions
);
91 i915InitFragProgFuncs(functions
);
92 functions
->UpdateState
= i915InvalidateState
;
96 extern const struct tnl_pipeline_stage
*intel_pipeline
[];
99 i915CreateContext(const __GLcontextModes
* mesaVis
,
100 __DRIcontextPrivate
* driContextPriv
,
101 void *sharedContextPrivate
)
103 struct dd_function_table functions
;
104 struct i915_context
*i915
=
105 (struct i915_context
*) CALLOC_STRUCT(i915_context
);
106 struct intel_context
*intel
= &i915
->intel
;
107 GLcontext
*ctx
= &intel
->ctx
;
113 _mesa_printf("\ntexmem-0-3 branch\n\n");
116 i915InitMetaFuncs(i915
);
118 i915InitDriverFunctions(&functions
);
120 if (!intelInitContext(intel
, mesaVis
, driContextPriv
,
121 sharedContextPrivate
, &functions
)) {
126 _math_matrix_ctr(&intel
->ViewportMatrix
);
128 /* Initialize swrast, tnl driver tables: */
129 intelInitSpanFuncs(ctx
);
130 intelInitTriFuncs(ctx
);
132 /* Install the customized pipeline: */
133 _tnl_destroy_pipeline(ctx
);
134 _tnl_install_pipeline(ctx
, intel_pipeline
);
137 FALLBACK(intel
, INTEL_FALLBACK_USER
, 1);
139 ctx
->Const
.MaxTextureUnits
= I915_TEX_UNITS
;
140 ctx
->Const
.MaxTextureImageUnits
= I915_TEX_UNITS
;
141 ctx
->Const
.MaxTextureCoordUnits
= I915_TEX_UNITS
;
144 /* Advertise the full hardware capabilities. The new memory
145 * manager should cope much better with overload situations:
147 ctx
->Const
.MaxTextureLevels
= 12;
148 ctx
->Const
.Max3DTextureLevels
= 9;
149 ctx
->Const
.MaxCubeTextureLevels
= 12;
150 ctx
->Const
.MaxTextureRectSize
= (1 << 11);
151 ctx
->Const
.MaxTextureUnits
= I915_TEX_UNITS
;
153 ctx
->Const
.MaxTextureMaxAnisotropy
= 4.0;
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.
160 ctx
->Const
.FragmentProgram
.MaxNativeTemps
= I915_MAX_TEMPORARY
;
161 ctx
->Const
.FragmentProgram
.MaxNativeAttribs
= 11; /* 8 tex, 2 color, fog */
162 ctx
->Const
.FragmentProgram
.MaxNativeParameters
= I915_MAX_CONSTANT
;
163 ctx
->Const
.FragmentProgram
.MaxNativeAluInstructions
= I915_MAX_ALU_INSN
;
164 ctx
->Const
.FragmentProgram
.MaxNativeTexInstructions
= I915_MAX_TEX_INSN
;
165 ctx
->Const
.FragmentProgram
.MaxNativeInstructions
= (I915_MAX_ALU_INSN
+
167 ctx
->Const
.FragmentProgram
.MaxNativeTexIndirections
=
168 I915_MAX_TEX_INDIRECT
;
169 ctx
->Const
.FragmentProgram
.MaxNativeAddressRegs
= 0; /* I don't think we have one */
170 ctx
->Const
.FragmentProgram
.MaxEnvParams
=
171 MIN2(ctx
->Const
.FragmentProgram
.MaxNativeParameters
,
172 ctx
->Const
.FragmentProgram
.MaxEnvParams
);
174 ctx
->FragmentProgram
._MaintainTexEnvProgram
= GL_TRUE
;
176 ctx
->Const
.MaxDrawBuffers
= 1;
178 _tnl_init_vertices(ctx
, ctx
->Const
.MaxArrayLockSize
+ 12,
179 36 * sizeof(GLfloat
));
181 intel
->verts
= TNL_CONTEXT(ctx
)->clipspace
.vertex_buf
;