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 #include "intel_regions.h"
45 #include "intel_batchbuffer.h"
47 /***************************************
48 * Mesa's Driver Functions
49 ***************************************/
51 static const struct dri_extension i915_extensions
[] = {
52 {"GL_ARB_depth_texture", NULL
},
53 {"GL_ARB_fragment_program", NULL
},
54 {"GL_ARB_shadow", NULL
},
55 {"GL_ARB_texture_env_crossbar", NULL
},
56 {"GL_ARB_texture_non_power_of_two", NULL
},
57 {"GL_EXT_shadow_funcs", NULL
},
58 /* ARB extn won't work if not enabled */
59 {"GL_SGIX_depth_texture", NULL
},
63 /* Override intel default.
66 i915InvalidateState(GLcontext
* ctx
, GLuint new_state
)
68 _swrast_InvalidateState(ctx
, new_state
);
69 _swsetup_InvalidateState(ctx
, new_state
);
70 _ac_InvalidateState(ctx
, new_state
);
71 _tnl_InvalidateState(ctx
, new_state
);
72 _tnl_invalidate_vertex_state(ctx
, new_state
);
73 intel_context(ctx
)->NewGLState
|= new_state
;
75 /* Todo: gather state values under which tracked parameters become
76 * invalidated, add callbacks for things like
77 * ProgramLocalParameters, etc.
80 struct i915_fragment_program
*p
=
81 (struct i915_fragment_program
*) ctx
->FragmentProgram
._Current
;
82 if (p
&& p
->nr_params
)
83 p
->params_uptodate
= 0;
86 if (new_state
& (_NEW_FOG
| _NEW_HINT
| _NEW_PROGRAM
))
92 i915InitDriverFunctions(struct dd_function_table
*functions
)
94 intelInitDriverFunctions(functions
);
95 i915InitStateFunctions(functions
);
96 i915InitTextureFuncs(functions
);
97 i915InitFragProgFuncs(functions
);
98 functions
->UpdateState
= i915InvalidateState
;
104 i915CreateContext(const __GLcontextModes
* mesaVis
,
105 __DRIcontextPrivate
* driContextPriv
,
106 void *sharedContextPrivate
)
108 struct dd_function_table functions
;
109 struct i915_context
*i915
=
110 (struct i915_context
*) CALLOC_STRUCT(i915_context
);
111 struct intel_context
*intel
= &i915
->intel
;
112 GLcontext
*ctx
= &intel
->ctx
;
118 _mesa_printf("\ntexmem-0-3 branch\n\n");
121 i915InitMetaFuncs(i915
);
123 i915InitDriverFunctions(&functions
);
125 if (!intelInitContext(intel
, mesaVis
, driContextPriv
,
126 sharedContextPrivate
, &functions
)) {
131 ctx
->Const
.MaxTextureUnits
= I915_TEX_UNITS
;
132 ctx
->Const
.MaxTextureImageUnits
= I915_TEX_UNITS
;
133 ctx
->Const
.MaxTextureCoordUnits
= I915_TEX_UNITS
;
136 /* Advertise the full hardware capabilities. The new memory
137 * manager should cope much better with overload situations:
139 ctx
->Const
.MaxTextureLevels
= 12;
140 ctx
->Const
.Max3DTextureLevels
= 9;
141 ctx
->Const
.MaxCubeTextureLevels
= 12;
142 ctx
->Const
.MaxTextureRectSize
= (1 << 11);
143 ctx
->Const
.MaxTextureUnits
= I915_TEX_UNITS
;
145 /* GL_ARB_fragment_program limits - don't think Mesa actually
146 * validates programs against these, and in any case one ARB
147 * instruction can translate to more than one HW instruction, so
148 * we'll still have to check and fallback each time.
150 ctx
->Const
.FragmentProgram
.MaxNativeTemps
= I915_MAX_TEMPORARY
;
151 ctx
->Const
.FragmentProgram
.MaxNativeAttribs
= 11; /* 8 tex, 2 color, fog */
152 ctx
->Const
.FragmentProgram
.MaxNativeParameters
= I915_MAX_CONSTANT
;
153 ctx
->Const
.FragmentProgram
.MaxNativeAluInstructions
= I915_MAX_ALU_INSN
;
154 ctx
->Const
.FragmentProgram
.MaxNativeTexInstructions
= I915_MAX_TEX_INSN
;
155 ctx
->Const
.FragmentProgram
.MaxNativeInstructions
= (I915_MAX_ALU_INSN
+
157 ctx
->Const
.FragmentProgram
.MaxNativeTexIndirections
=
158 I915_MAX_TEX_INDIRECT
;
159 ctx
->Const
.FragmentProgram
.MaxNativeAddressRegs
= 0; /* I don't think we have one */
161 ctx
->_MaintainTexEnvProgram
= 1;
162 ctx
->_UseTexEnvProgram
= 1;
164 driInitExtensions(ctx
, i915_extensions
, GL_FALSE
);
167 _tnl_init_vertices(ctx
, ctx
->Const
.MaxArrayLockSize
+ 12,
168 36 * sizeof(GLfloat
));
170 intel
->verts
= TNL_CONTEXT(ctx
)->clipspace
.vertex_buf
;