16d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane/**************************************************************************
26d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane *
3877128505431adaf817dc8069172ebe4a1cdf5d8José Fonseca * Copyright 2003 VMware, Inc.
46d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane * All Rights Reserved.
56d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane *
66d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane * Permission is hereby granted, free of charge, to any person obtaining a
76d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane * copy of this software and associated documentation files (the
86d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane * "Software"), to deal in the Software without restriction, including
96d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane * without limitation the rights to use, copy, modify, merge, publish,
106d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane * distribute, sub license, and/or sell copies of the Software, and to
116d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane * permit persons to whom the Software is furnished to do so, subject to
126d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane * the following conditions:
136d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane *
146d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane * The above copyright notice and this permission notice (including the
156d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane * next paragraph) shall be included in all copies or substantial portions
166d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane * of the Software.
176d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane *
186d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
196d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
206d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21877128505431adaf817dc8069172ebe4a1cdf5d8José Fonseca * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
226d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
236d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
246d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
256d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane *
266d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane **************************************************************************/
276d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane
286d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane#include "i915_context.h"
294bea4cb9fd55cdb267003a6e6e16f7e903e00940Jordan Justen#include "main/api_exec.h"
30ecadb51bbcb972a79f3ed79e65a7986b9396e757Brian Paul#include "main/imports.h"
31c2ef10803d6c30e13f8f762cc874e3bccc8a2881Eric Anholt#include "main/macros.h"
324bea4cb9fd55cdb267003a6e6e16f7e903e00940Jordan Justen#include "main/version.h"
334bea4cb9fd55cdb267003a6e6e16f7e903e00940Jordan Justen#include "main/vtxfmt.h"
343c231b863160d82cd6cc85724c53e5bcb4ca03e1Eric Anholt#include "intel_chipset.h"
356d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane#include "intel_tris.h"
366d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane#include "tnl/t_context.h"
376d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane#include "tnl/t_pipeline.h"
386d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane#include "tnl/t_vertex.h"
396d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane
406d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane#include "swrast/swrast.h"
416d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane#include "swrast_setup/swrast_setup.h"
426d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane#include "tnl/tnl.h"
431e0da6233be6e5fb0143615d5e3d3642ddb7964fKenneth Graunke#include "util/ralloc.h"
446d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane
456d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane#include "i915_reg.h"
4661b512c47c9888f3ff117faf3aceccfb52d59c3aEric Anholt#include "i915_program.h"
476d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane
486d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane/***************************************
496d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane * Mesa's Driver Functions
506d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane ***************************************/
516d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane
526d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane/* Override intel default.
536d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane */
546d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihanestatic void
55f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergi915InvalidateState(struct gl_context * ctx, GLuint new_state)
566d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane{
576d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane   _swrast_InvalidateState(ctx, new_state);
586d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane   _swsetup_InvalidateState(ctx, new_state);
596a3fdc3a1ea6c306d9543791bf172dd1052d7382Keith Whitwell   _vbo_InvalidateState(ctx, new_state);
606d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane   _tnl_InvalidateState(ctx, new_state);
616d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane   _tnl_invalidate_vertex_state(ctx, new_state);
626d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane   intel_context(ctx)->NewGLState |= new_state;
636d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane
646d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane   /* Todo: gather state values under which tracked parameters become
656d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane    * invalidated, add callbacks for things like
666d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane    * ProgramLocalParameters, etc.
676d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane    */
686d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane   {
696d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane      struct i915_fragment_program *p =
706d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane         (struct i915_fragment_program *) ctx->FragmentProgram._Current;
716d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane      if (p && p->nr_params)
726d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane         p->params_uptodate = 0;
736d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane   }
746d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane
75246729162ccc7e2672aa6cc957053ce3a8975a2cEric Anholt   if (new_state & (_NEW_STENCIL | _NEW_BUFFERS | _NEW_POLYGON))
76246729162ccc7e2672aa6cc957053ce3a8975a2cEric Anholt      i915_update_stencil(ctx);
77de80eeea0eebf00ee678b1a0fbd5fe67b00a8636Eric Anholt   if (new_state & (_NEW_LIGHT))
78de80eeea0eebf00ee678b1a0fbd5fe67b00a8636Eric Anholt       i915_update_provoking_vertex(ctx);
7961b512c47c9888f3ff117faf3aceccfb52d59c3aEric Anholt   if (new_state & (_NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS))
8061b512c47c9888f3ff117faf3aceccfb52d59c3aEric Anholt       i915_update_program(ctx);
81c6532875493ffe7de9c37924c70ebf6d0472e23dYuanhan Liu   if (new_state & (_NEW_PROGRAM | _NEW_POINT))
82c6532875493ffe7de9c37924c70ebf6d0472e23dYuanhan Liu       i915_update_sprite_point_enable(ctx);
836d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane}
846d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane
856d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane
866d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihanestatic void
876d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihanei915InitDriverFunctions(struct dd_function_table *functions)
886d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane{
896d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane   intelInitDriverFunctions(functions);
906d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane   i915InitStateFunctions(functions);
916d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane   i915InitFragProgFuncs(functions);
926d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane   functions->UpdateState = i915InvalidateState;
936d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane}
946d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane
9527505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt/* Note: this is shared with i830. */
9627505a105a4bf8b7329b87d29e1625e545508e4eEric Anholtvoid
9727505a105a4bf8b7329b87d29e1625e545508e4eEric Anholtintel_init_texture_formats(struct gl_context *ctx)
9827505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt{
9927505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt   struct intel_context *intel = intel_context(ctx);
10027505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt   struct intel_screen *intel_screen = intel->intelScreen;
10127505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt
102ef145ba4ded6aafb28e3bda02fb348e6b8bff12aMark Mueller   ctx->TextureFormatSupported[MESA_FORMAT_B8G8R8A8_UNORM] = true;
10327505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt   if (intel_screen->deviceID != PCI_CHIP_I830_M &&
10427505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt       intel_screen->deviceID != PCI_CHIP_845_G)
105ef145ba4ded6aafb28e3bda02fb348e6b8bff12aMark Mueller      ctx->TextureFormatSupported[MESA_FORMAT_B8G8R8X8_UNORM] = true;
1064df1b986d3e44dc035227054000a1d0e1846ef07Eric Anholt   if (intel->gen == 3)
107eeed49f5f290793870c60b5b635b977a732a1eb4Mark Mueller      ctx->TextureFormatSupported[MESA_FORMAT_B8G8R8A8_SRGB] = true;
108eeed49f5f290793870c60b5b635b977a732a1eb4Mark Mueller   ctx->TextureFormatSupported[MESA_FORMAT_B4G4R4A4_UNORM] = true;
109eeed49f5f290793870c60b5b635b977a732a1eb4Mark Mueller   ctx->TextureFormatSupported[MESA_FORMAT_B5G5R5A1_UNORM] = true;
110eeed49f5f290793870c60b5b635b977a732a1eb4Mark Mueller   ctx->TextureFormatSupported[MESA_FORMAT_B5G6R5_UNORM] = true;
11150a01d2acafb2a937e62b24258e2e777c0cd1489Mark Mueller   ctx->TextureFormatSupported[MESA_FORMAT_L_UNORM8] = true;
11240a08e0d6a57cc79ee72a62aeedec20cae774ed5Ville Syrjälä   if (intel->gen == 3)
11340a08e0d6a57cc79ee72a62aeedec20cae774ed5Ville Syrjälä      ctx->TextureFormatSupported[MESA_FORMAT_A_UNORM8] = true;
11450a01d2acafb2a937e62b24258e2e777c0cd1489Mark Mueller   ctx->TextureFormatSupported[MESA_FORMAT_I_UNORM8] = true;
115eeed49f5f290793870c60b5b635b977a732a1eb4Mark Mueller   ctx->TextureFormatSupported[MESA_FORMAT_L8A8_UNORM] = true;
11627505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt
11727505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt   /* Depth and stencil */
118c1d4d4999303f9167b20f4e0674b9436e6295cf7Ville Syrjälä   if (intel->gen == 3) {
119c1d4d4999303f9167b20f4e0674b9436e6295cf7Ville Syrjälä      ctx->TextureFormatSupported[MESA_FORMAT_Z24_UNORM_S8_UINT] = true;
120c1d4d4999303f9167b20f4e0674b9436e6295cf7Ville Syrjälä      ctx->TextureFormatSupported[MESA_FORMAT_Z24_UNORM_X8_UINT] = true;
12127505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt
122c1d4d4999303f9167b20f4e0674b9436e6295cf7Ville Syrjälä      /*
123c1d4d4999303f9167b20f4e0674b9436e6295cf7Ville Syrjälä       * This was disabled in initial FBO enabling to avoid combinations
124c1d4d4999303f9167b20f4e0674b9436e6295cf7Ville Syrjälä       * of depth+stencil that wouldn't work together.  We since decided
125c1d4d4999303f9167b20f4e0674b9436e6295cf7Ville Syrjälä       * that it was OK, since it's up to the app to come up with the
126c1d4d4999303f9167b20f4e0674b9436e6295cf7Ville Syrjälä       * combo that actually works, so this can probably be re-enabled.
127c1d4d4999303f9167b20f4e0674b9436e6295cf7Ville Syrjälä       */
128c1d4d4999303f9167b20f4e0674b9436e6295cf7Ville Syrjälä      /*
129c1d4d4999303f9167b20f4e0674b9436e6295cf7Ville Syrjälä      ctx->TextureFormatSupported[MESA_FORMAT_Z_UNORM16] = true;
130c1d4d4999303f9167b20f4e0674b9436e6295cf7Ville Syrjälä      ctx->TextureFormatSupported[MESA_FORMAT_Z24] = true;
131c1d4d4999303f9167b20f4e0674b9436e6295cf7Ville Syrjälä      */
132c1d4d4999303f9167b20f4e0674b9436e6295cf7Ville Syrjälä   }
13327505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt
13427505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt   /* ctx->Extensions.MESA_ycbcr_texture */
13527505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt   ctx->TextureFormatSupported[MESA_FORMAT_YCBCR] = true;
13627505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt   ctx->TextureFormatSupported[MESA_FORMAT_YCBCR_REV] = true;
13727505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt
13827505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt   /* GL_3DFX_texture_compression_FXT1 */
13927505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt   ctx->TextureFormatSupported[MESA_FORMAT_RGB_FXT1] = true;
14027505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt   ctx->TextureFormatSupported[MESA_FORMAT_RGBA_FXT1] = true;
14127505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt
14227505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt   /* GL_EXT_texture_compression_s3tc */
14327505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt   ctx->TextureFormatSupported[MESA_FORMAT_RGB_DXT1] = true;
14427505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt   ctx->TextureFormatSupported[MESA_FORMAT_RGBA_DXT1] = true;
14527505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt   ctx->TextureFormatSupported[MESA_FORMAT_RGBA_DXT3] = true;
14627505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt   ctx->TextureFormatSupported[MESA_FORMAT_RGBA_DXT5] = true;
14727505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt}
1486d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane
149dd1d66fc4ab5d7064113a2017a431c3461598b91Kristian Høgsbergextern const struct tnl_pipeline_stage *intel_pipeline[];
1506d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane
1512e5a1a254ed81b1d3efa6064f48183eefac784d0Kenneth Graunkebool
1524b69100bdcf26dbb5be4d600b7ca5f5cdf6e8f20Kristian Høgsbergi915CreateContext(int api,
153d3491e775fb07f891463b2185d74bbad62f3ed24Kristian Høgsberg		  const struct gl_config * mesaVis,
154d61f07318c8678901b948fdaa8ccdf37aa3203e9Kristian Høgsberg                  __DRIcontext * driContextPriv,
155db273724c9484d513f5caa34729475d2873d9f7bIan Romanick                  unsigned major_version,
156db273724c9484d513f5caa34729475d2873d9f7bIan Romanick                  unsigned minor_version,
15738366c0c6e715314367b15680702e382d5c46a4aKristian Høgsberg                  uint32_t flags,
158db273724c9484d513f5caa34729475d2873d9f7bIan Romanick                  unsigned *error,
1596d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane                  void *sharedContextPrivate)
1606d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane{
1616d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane   struct dd_function_table functions;
16235d5d5df72a2747262e00e521e650c8974d6c64dEric Anholt   struct i915_context *i915 = rzalloc(NULL, struct i915_context);
1636d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane   struct intel_context *intel = &i915->intel;
164f9995b30756140724f41daf963fa06167912be7fKristian Høgsberg   struct gl_context *ctx = &intel->ctx;
1656d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane
166db273724c9484d513f5caa34729475d2873d9f7bIan Romanick   if (!i915) {
167db273724c9484d513f5caa34729475d2873d9f7bIan Romanick      *error = __DRI_CTX_ERROR_NO_MEMORY;
1682e5a1a254ed81b1d3efa6064f48183eefac784d0Kenneth Graunke      return false;
169db273724c9484d513f5caa34729475d2873d9f7bIan Romanick   }
1706d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane
1716d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane   i915InitVtbl(i915);
1726d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane
1736d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane   i915InitDriverFunctions(&functions);
1746d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane
17538366c0c6e715314367b15680702e382d5c46a4aKristian Høgsberg   if (!intelInitContext(intel, api, major_version, minor_version, flags,
176a11fe62058ad9d44170be9346111e3f6630a3327Chad Versace                         mesaVis, driContextPriv,
177a11fe62058ad9d44170be9346111e3f6630a3327Chad Versace                         sharedContextPrivate, &functions,
178a11fe62058ad9d44170be9346111e3f6630a3327Chad Versace                         error)) {
179a11fe62058ad9d44170be9346111e3f6630a3327Chad Versace      ralloc_free(i915);
1802e5a1a254ed81b1d3efa6064f48183eefac784d0Kenneth Graunke      return false;
1816d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane   }
1826d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane
1838d15268a61fe400668495e6cb42c4d15e8b17cbbEric Anholt   intel_init_texture_formats(ctx);
1848d15268a61fe400668495e6cb42c4d15e8b17cbbEric Anholt
18560953059ea2319eae4d737831824dbce08ee1725Eric Anholt   _math_matrix_ctr(&intel->ViewportMatrix);
18660953059ea2319eae4d737831824dbce08ee1725Eric Anholt
187dd1d66fc4ab5d7064113a2017a431c3461598b91Kristian Høgsberg   /* Initialize swrast, tnl driver tables: */
188dd1d66fc4ab5d7064113a2017a431c3461598b91Kristian Høgsberg   intelInitTriFuncs(ctx);
189dd1d66fc4ab5d7064113a2017a431c3461598b91Kristian Høgsberg
190dd1d66fc4ab5d7064113a2017a431c3461598b91Kristian Høgsberg   /* Install the customized pipeline: */
191dd1d66fc4ab5d7064113a2017a431c3461598b91Kristian Høgsberg   _tnl_destroy_pipeline(ctx);
192dd1d66fc4ab5d7064113a2017a431c3461598b91Kristian Høgsberg   _tnl_install_pipeline(ctx, intel_pipeline);
193dd1d66fc4ab5d7064113a2017a431c3461598b91Kristian Høgsberg
194f75843a517bd188639e6866db2a7b04de3524e16Dave Airlie   if (intel->no_rast)
195f75843a517bd188639e6866db2a7b04de3524e16Dave Airlie      FALLBACK(intel, INTEL_FALLBACK_USER, 1);
196f75843a517bd188639e6866db2a7b04de3524e16Dave Airlie
1976d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane   ctx->Const.MaxTextureUnits = I915_TEX_UNITS;
19884732a982c3eeaca2e2809532c8422dc5f7045c1Paul Berry   ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits = I915_TEX_UNITS;
1998ba157006fe98bca96b79bea1394b0c33ddf4ad3Ian Romanick   ctx->Const.Program[MESA_SHADER_VERTEX].MaxTextureImageUnits = I915_TEX_UNITS;
2006d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane   ctx->Const.MaxTextureCoordUnits = I915_TEX_UNITS;
201f9f31b25740887373806cb489e5480dc9b261805Eric Anholt   ctx->Const.MaxVarying = I915_TEX_UNITS;
20284732a982c3eeaca2e2809532c8422dc5f7045c1Paul Berry   ctx->Const.Program[MESA_SHADER_VERTEX].MaxOutputComponents =
20384732a982c3eeaca2e2809532c8422dc5f7045c1Paul Berry      ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxInputComponents = ctx->Const.MaxVarying * 4;
20451e945ec9c0b803f5e998f87449fb02a7c39ae65Eric Anholt   ctx->Const.MaxCombinedTextureImageUnits =
20584732a982c3eeaca2e2809532c8422dc5f7045c1Paul Berry      ctx->Const.Program[MESA_SHADER_VERTEX].MaxTextureImageUnits +
20684732a982c3eeaca2e2809532c8422dc5f7045c1Paul Berry      ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits;
2076d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane
2086d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane   /* Advertise the full hardware capabilities.  The new memory
2096d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane    * manager should cope much better with overload situations:
2106d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane    */
2116d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane   ctx->Const.MaxTextureLevels = 12;
2126d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane   ctx->Const.Max3DTextureLevels = 9;
2136d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane   ctx->Const.MaxCubeTextureLevels = 12;
2146d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane   ctx->Const.MaxTextureRectSize = (1 << 11);
2156d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane   ctx->Const.MaxTextureUnits = I915_TEX_UNITS;
2166d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane
21750853be894aa3edd1e9271f7d625f319209e340fRoland Scheidegger   ctx->Const.MaxTextureMaxAnisotropy = 4.0;
21850853be894aa3edd1e9271f7d625f319209e340fRoland Scheidegger
2196d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane   /* GL_ARB_fragment_program limits - don't think Mesa actually
2206d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane    * validates programs against these, and in any case one ARB
2216d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane    * instruction can translate to more than one HW instruction, so
2226d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane    * we'll still have to check and fallback each time.
2236d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane    */
22484732a982c3eeaca2e2809532c8422dc5f7045c1Paul Berry   ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxNativeTemps = I915_MAX_TEMPORARY;
22584732a982c3eeaca2e2809532c8422dc5f7045c1Paul Berry   ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxNativeAttribs = 11;    /* 8 tex, 2 color, fog */
22684732a982c3eeaca2e2809532c8422dc5f7045c1Paul Berry   ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxNativeParameters = I915_MAX_CONSTANT;
22784732a982c3eeaca2e2809532c8422dc5f7045c1Paul Berry   ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxNativeAluInstructions = I915_MAX_ALU_INSN;
22884732a982c3eeaca2e2809532c8422dc5f7045c1Paul Berry   ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxNativeTexInstructions = I915_MAX_TEX_INSN;
22984732a982c3eeaca2e2809532c8422dc5f7045c1Paul Berry   ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxNativeInstructions = (I915_MAX_ALU_INSN +
2306d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane                                                       I915_MAX_TEX_INSN);
23184732a982c3eeaca2e2809532c8422dc5f7045c1Paul Berry   ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxNativeTexIndirections =
2326d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane      I915_MAX_TEX_INDIRECT;
23384732a982c3eeaca2e2809532c8422dc5f7045c1Paul Berry   ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxNativeAddressRegs = 0; /* I don't think we have one */
23484732a982c3eeaca2e2809532c8422dc5f7045c1Paul Berry   ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxEnvParams =
23584732a982c3eeaca2e2809532c8422dc5f7045c1Paul Berry      MIN2(ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxNativeParameters,
23684732a982c3eeaca2e2809532c8422dc5f7045c1Paul Berry	   ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxEnvParams);
2376d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane
238790ff232e2607a83e6207d06900a5e3de613d161Ian Romanick   /* i915 stores all values in single-precision floats.  Values aren't set
239790ff232e2607a83e6207d06900a5e3de613d161Ian Romanick    * for other program targets because software is used for those targets.
240790ff232e2607a83e6207d06900a5e3de613d161Ian Romanick    */
24184732a982c3eeaca2e2809532c8422dc5f7045c1Paul Berry   ctx->Const.Program[MESA_SHADER_FRAGMENT].MediumFloat.RangeMin = 127;
24284732a982c3eeaca2e2809532c8422dc5f7045c1Paul Berry   ctx->Const.Program[MESA_SHADER_FRAGMENT].MediumFloat.RangeMax = 127;
24384732a982c3eeaca2e2809532c8422dc5f7045c1Paul Berry   ctx->Const.Program[MESA_SHADER_FRAGMENT].MediumFloat.Precision = 23;
24484732a982c3eeaca2e2809532c8422dc5f7045c1Paul Berry   ctx->Const.Program[MESA_SHADER_FRAGMENT].LowFloat = ctx->Const.Program[MESA_SHADER_FRAGMENT].HighFloat =
24584732a982c3eeaca2e2809532c8422dc5f7045c1Paul Berry      ctx->Const.Program[MESA_SHADER_FRAGMENT].MediumFloat;
24684732a982c3eeaca2e2809532c8422dc5f7045c1Paul Berry   ctx->Const.Program[MESA_SHADER_FRAGMENT].MediumInt.RangeMin = 24;
24784732a982c3eeaca2e2809532c8422dc5f7045c1Paul Berry   ctx->Const.Program[MESA_SHADER_FRAGMENT].MediumInt.RangeMax = 24;
24884732a982c3eeaca2e2809532c8422dc5f7045c1Paul Berry   ctx->Const.Program[MESA_SHADER_FRAGMENT].MediumInt.Precision = 0;
24984732a982c3eeaca2e2809532c8422dc5f7045c1Paul Berry   ctx->Const.Program[MESA_SHADER_FRAGMENT].LowInt = ctx->Const.Program[MESA_SHADER_FRAGMENT].HighInt =
25084732a982c3eeaca2e2809532c8422dc5f7045c1Paul Berry      ctx->Const.Program[MESA_SHADER_FRAGMENT].MediumInt;
251790ff232e2607a83e6207d06900a5e3de613d161Ian Romanick
2522e5a1a254ed81b1d3efa6064f48183eefac784d0Kenneth Graunke   ctx->FragmentProgram._MaintainTexEnvProgram = true;
2536d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane
2546d3a2c97f4a78e85545286e0e126cd3a27bd1cbdLuca Barbieri   /* FINISHME: Are there other options that should be enabled for software
2556d3a2c97f4a78e85545286e0e126cd3a27bd1cbdLuca Barbieri    * FINISHME: vertex shaders?
2566d3a2c97f4a78e85545286e0e126cd3a27bd1cbdLuca Barbieri    */
2572dc2b12ed15abb84c7e2b3c2726dcc1b735abcdaTapani Pälli   ctx->Const.ShaderCompilerOptions[MESA_SHADER_VERTEX].EmitNoIndirectSampler =
2582dc2b12ed15abb84c7e2b3c2726dcc1b735abcdaTapani Pälli      true;
2594c1dc1c4d772b06578567f14419fdd4f27843825Ian Romanick
2604c1dc1c4d772b06578567f14419fdd4f27843825Ian Romanick   struct gl_shader_compiler_options *const fs_options =
261002211f9eea258acc253528024ee104aa1fcd90dMarek Olšák      & ctx->Const.ShaderCompilerOptions[MESA_SHADER_FRAGMENT];
262488fe51cf823ccd137c667f1e92dd86f8323b723Bryan Cain   fs_options->MaxIfDepth = 0;
2632e5a1a254ed81b1d3efa6064f48183eefac784d0Kenneth Graunke   fs_options->EmitNoPow = true;
2642e5a1a254ed81b1d3efa6064f48183eefac784d0Kenneth Graunke   fs_options->EmitNoMainReturn = true;
2652e5a1a254ed81b1d3efa6064f48183eefac784d0Kenneth Graunke   fs_options->EmitNoIndirectInput = true;
2662e5a1a254ed81b1d3efa6064f48183eefac784d0Kenneth Graunke   fs_options->EmitNoIndirectOutput = true;
2672e5a1a254ed81b1d3efa6064f48183eefac784d0Kenneth Graunke   fs_options->EmitNoIndirectUniform = true;
2682e5a1a254ed81b1d3efa6064f48183eefac784d0Kenneth Graunke   fs_options->EmitNoIndirectTemp = true;
2692dc2b12ed15abb84c7e2b3c2726dcc1b735abcdaTapani Pälli   fs_options->EmitNoIndirectSampler = true;
27095c08920ea3d040360e5cc51d8a852d21a0329eeEric Anholt
2718aa209c766b79144db499063dd1c8482562b07bfIan Romanick   ctx->Const.MaxDrawBuffers = 1;
272eb062ab07f0bea3c7ce83274ed64ce9b5197c667Eric Anholt   ctx->Const.QueryCounterBits.SamplesPassed = 0;
2738aa209c766b79144db499063dd1c8482562b07bfIan Romanick
2746d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane   _tnl_init_vertices(ctx, ctx->Const.MaxArrayLockSize + 12,
2756d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane                      36 * sizeof(GLfloat));
2766d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane
2776d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane   intel->verts = TNL_CONTEXT(ctx)->clipspace.vertex_buf;
2786d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane
2796d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane   i915InitState(i915);
2806d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane
281d439491a77cf9f25ea7a7f9c2309d2542d87f83eIan Romanick   /* Always enable pixel fog.  Vertex fog using fog coord will conflict
282d439491a77cf9f25ea7a7f9c2309d2542d87f83eIan Romanick    * with fog code appended onto fragment program.
283d439491a77cf9f25ea7a7f9c2309d2542d87f83eIan Romanick    */
284d439491a77cf9f25ea7a7f9c2309d2542d87f83eIan Romanick   _tnl_allow_vertex_fog(ctx, 0);
285d439491a77cf9f25ea7a7f9c2309d2542d87f83eIan Romanick   _tnl_allow_pixel_fog(ctx, 1);
286d439491a77cf9f25ea7a7f9c2309d2542d87f83eIan Romanick
2874bea4cb9fd55cdb267003a6e6e16f7e903e00940Jordan Justen   _mesa_compute_version(ctx);
2884bea4cb9fd55cdb267003a6e6e16f7e903e00940Jordan Justen
289be4b1664fbc98b0b1d66bb91850ecada52b36b91Eric Anholt   _mesa_initialize_dispatch_tables(ctx);
2904bea4cb9fd55cdb267003a6e6e16f7e903e00940Jordan Justen   _mesa_initialize_vbo_vtxfmt(ctx);
2914bea4cb9fd55cdb267003a6e6e16f7e903e00940Jordan Justen
2922e5a1a254ed81b1d3efa6064f48183eefac784d0Kenneth Graunke   return true;
2936d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane}
294