16d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane/************************************************************************** 26d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane * 36d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. 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. 216d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane * IN NO EVENT SHALL TUNGSTEN GRAPHICS 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" 29ecadb51bbcb972a79f3ed79e65a7986b9396e757Brian Paul#include "main/imports.h" 30c2ef10803d6c30e13f8f762cc874e3bccc8a2881Eric Anholt#include "main/macros.h" 316d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane#include "intel_tris.h" 326d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane#include "tnl/t_context.h" 336d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane#include "tnl/t_pipeline.h" 346d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane#include "tnl/t_vertex.h" 356d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane 366d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane#include "swrast/swrast.h" 376d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane#include "swrast_setup/swrast_setup.h" 386d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane#include "tnl/tnl.h" 3935d5d5df72a2747262e00e521e650c8974d6c64dEric Anholt#include "../glsl/ralloc.h" 406d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane 416d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane#include "i915_reg.h" 4261b512c47c9888f3ff117faf3aceccfb52d59c3aEric Anholt#include "i915_program.h" 436d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane 44dd1d66fc4ab5d7064113a2017a431c3461598b91Kristian Høgsberg#include "intel_span.h" 456d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane 466d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane/*************************************** 476d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane * Mesa's Driver Functions 486d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane ***************************************/ 496d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane 506d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane/* Override intel default. 516d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane */ 526d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihanestatic void 53f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergi915InvalidateState(struct gl_context * ctx, GLuint new_state) 546d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane{ 556d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane _swrast_InvalidateState(ctx, new_state); 566d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane _swsetup_InvalidateState(ctx, new_state); 576a3fdc3a1ea6c306d9543791bf172dd1052d7382Keith Whitwell _vbo_InvalidateState(ctx, new_state); 586d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane _tnl_InvalidateState(ctx, new_state); 596d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane _tnl_invalidate_vertex_state(ctx, new_state); 606d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane intel_context(ctx)->NewGLState |= new_state; 616d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane 626d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane /* Todo: gather state values under which tracked parameters become 636d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane * invalidated, add callbacks for things like 646d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane * ProgramLocalParameters, etc. 656d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane */ 666d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane { 676d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane struct i915_fragment_program *p = 686d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane (struct i915_fragment_program *) ctx->FragmentProgram._Current; 696d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane if (p && p->nr_params) 706d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane p->params_uptodate = 0; 716d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane } 726d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane 73246729162ccc7e2672aa6cc957053ce3a8975a2cEric Anholt if (new_state & (_NEW_STENCIL | _NEW_BUFFERS | _NEW_POLYGON)) 74246729162ccc7e2672aa6cc957053ce3a8975a2cEric Anholt i915_update_stencil(ctx); 75de80eeea0eebf00ee678b1a0fbd5fe67b00a8636Eric Anholt if (new_state & (_NEW_LIGHT)) 76de80eeea0eebf00ee678b1a0fbd5fe67b00a8636Eric Anholt i915_update_provoking_vertex(ctx); 7761b512c47c9888f3ff117faf3aceccfb52d59c3aEric Anholt if (new_state & (_NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS)) 7861b512c47c9888f3ff117faf3aceccfb52d59c3aEric Anholt i915_update_program(ctx); 79c6532875493ffe7de9c37924c70ebf6d0472e23dYuanhan Liu if (new_state & (_NEW_PROGRAM | _NEW_POINT)) 80c6532875493ffe7de9c37924c70ebf6d0472e23dYuanhan Liu i915_update_sprite_point_enable(ctx); 816d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane} 826d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane 836d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane 846d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihanestatic void 856d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihanei915InitDriverFunctions(struct dd_function_table *functions) 866d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane{ 876d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane intelInitDriverFunctions(functions); 886d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane i915InitStateFunctions(functions); 896d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane i915InitFragProgFuncs(functions); 906d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane functions->UpdateState = i915InvalidateState; 916d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane} 926d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane 9327505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt/* Note: this is shared with i830. */ 9427505a105a4bf8b7329b87d29e1625e545508e4eEric Anholtvoid 9527505a105a4bf8b7329b87d29e1625e545508e4eEric Anholtintel_init_texture_formats(struct gl_context *ctx) 9627505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt{ 9727505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt struct intel_context *intel = intel_context(ctx); 9827505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt struct intel_screen *intel_screen = intel->intelScreen; 9927505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt 10027505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt ctx->TextureFormatSupported[MESA_FORMAT_ARGB8888] = true; 10127505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt if (intel_screen->deviceID != PCI_CHIP_I830_M && 10227505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt intel_screen->deviceID != PCI_CHIP_845_G) 10327505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt ctx->TextureFormatSupported[MESA_FORMAT_XRGB8888] = true; 10427505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt ctx->TextureFormatSupported[MESA_FORMAT_ARGB4444] = true; 10527505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt ctx->TextureFormatSupported[MESA_FORMAT_ARGB1555] = true; 10627505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt ctx->TextureFormatSupported[MESA_FORMAT_RGB565] = true; 10727505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt ctx->TextureFormatSupported[MESA_FORMAT_L8] = true; 10827505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt ctx->TextureFormatSupported[MESA_FORMAT_A8] = true; 10927505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt ctx->TextureFormatSupported[MESA_FORMAT_I8] = true; 11027505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt ctx->TextureFormatSupported[MESA_FORMAT_AL88] = true; 11127505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt 11227505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt /* Depth and stencil */ 11327505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt ctx->TextureFormatSupported[MESA_FORMAT_S8_Z24] = true; 11427505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt ctx->TextureFormatSupported[MESA_FORMAT_X8_Z24] = true; 11527505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt ctx->TextureFormatSupported[MESA_FORMAT_S8] = intel->has_separate_stencil; 11627505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt 11727505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt /* 11827505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt * This was disabled in initial FBO enabling to avoid combinations 11927505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt * of depth+stencil that wouldn't work together. We since decided 12027505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt * that it was OK, since it's up to the app to come up with the 12127505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt * combo that actually works, so this can probably be re-enabled. 12227505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt */ 12327505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt /* 12427505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt ctx->TextureFormatSupported[MESA_FORMAT_Z16] = true; 12527505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt ctx->TextureFormatSupported[MESA_FORMAT_Z24] = true; 12627505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt */ 12727505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt 12827505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt /* ctx->Extensions.MESA_ycbcr_texture */ 12927505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt ctx->TextureFormatSupported[MESA_FORMAT_YCBCR] = true; 13027505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt ctx->TextureFormatSupported[MESA_FORMAT_YCBCR_REV] = true; 13127505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt 13227505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt /* GL_3DFX_texture_compression_FXT1 */ 13327505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt ctx->TextureFormatSupported[MESA_FORMAT_RGB_FXT1] = true; 13427505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt ctx->TextureFormatSupported[MESA_FORMAT_RGBA_FXT1] = true; 13527505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt 13627505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt /* GL_EXT_texture_compression_s3tc */ 13727505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt ctx->TextureFormatSupported[MESA_FORMAT_RGB_DXT1] = true; 13827505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt ctx->TextureFormatSupported[MESA_FORMAT_RGBA_DXT1] = true; 13927505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt ctx->TextureFormatSupported[MESA_FORMAT_RGBA_DXT3] = true; 14027505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt ctx->TextureFormatSupported[MESA_FORMAT_RGBA_DXT5] = true; 14127505a105a4bf8b7329b87d29e1625e545508e4eEric Anholt} 1426d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane 143dd1d66fc4ab5d7064113a2017a431c3461598b91Kristian Høgsbergextern const struct tnl_pipeline_stage *intel_pipeline[]; 1446d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane 1452e5a1a254ed81b1d3efa6064f48183eefac784d0Kenneth Graunkebool 1464b69100bdcf26dbb5be4d600b7ca5f5cdf6e8f20Kristian Høgsbergi915CreateContext(int api, 147d3491e775fb07f891463b2185d74bbad62f3ed24Kristian Høgsberg const struct gl_config * mesaVis, 148d61f07318c8678901b948fdaa8ccdf37aa3203e9Kristian Høgsberg __DRIcontext * driContextPriv, 149db273724c9484d513f5caa34729475d2873d9f7bIan Romanick unsigned major_version, 150db273724c9484d513f5caa34729475d2873d9f7bIan Romanick unsigned minor_version, 151db273724c9484d513f5caa34729475d2873d9f7bIan Romanick unsigned *error, 1526d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane void *sharedContextPrivate) 1536d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane{ 1546d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane struct dd_function_table functions; 15535d5d5df72a2747262e00e521e650c8974d6c64dEric Anholt struct i915_context *i915 = rzalloc(NULL, struct i915_context); 1566d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane struct intel_context *intel = &i915->intel; 157f9995b30756140724f41daf963fa06167912be7fKristian Høgsberg struct gl_context *ctx = &intel->ctx; 1586d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane 159db273724c9484d513f5caa34729475d2873d9f7bIan Romanick if (!i915) { 160db273724c9484d513f5caa34729475d2873d9f7bIan Romanick *error = __DRI_CTX_ERROR_NO_MEMORY; 1612e5a1a254ed81b1d3efa6064f48183eefac784d0Kenneth Graunke return false; 162db273724c9484d513f5caa34729475d2873d9f7bIan Romanick } 1636d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane 1646d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane i915InitVtbl(i915); 1656d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane 1666d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane i915InitDriverFunctions(&functions); 1676d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane 1684b69100bdcf26dbb5be4d600b7ca5f5cdf6e8f20Kristian Høgsberg if (!intelInitContext(intel, api, mesaVis, driContextPriv, 1696d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane sharedContextPrivate, &functions)) { 170db273724c9484d513f5caa34729475d2873d9f7bIan Romanick *error = __DRI_CTX_ERROR_NO_MEMORY; 171db273724c9484d513f5caa34729475d2873d9f7bIan Romanick return false; 172db273724c9484d513f5caa34729475d2873d9f7bIan Romanick } 173db273724c9484d513f5caa34729475d2873d9f7bIan Romanick 174db273724c9484d513f5caa34729475d2873d9f7bIan Romanick /* Now that the extension bits are known, filter against the requested API 175db273724c9484d513f5caa34729475d2873d9f7bIan Romanick * and version. 176db273724c9484d513f5caa34729475d2873d9f7bIan Romanick */ 177db273724c9484d513f5caa34729475d2873d9f7bIan Romanick switch (api) { 178db273724c9484d513f5caa34729475d2873d9f7bIan Romanick case API_OPENGL: { 179db273724c9484d513f5caa34729475d2873d9f7bIan Romanick const unsigned max_version = 180db273724c9484d513f5caa34729475d2873d9f7bIan Romanick (ctx->Extensions.ARB_fragment_shader && 181db273724c9484d513f5caa34729475d2873d9f7bIan Romanick ctx->Extensions.ARB_occlusion_query) ? 20 : 15; 182db273724c9484d513f5caa34729475d2873d9f7bIan Romanick const unsigned req_version = major_version * 10 + minor_version; 183db273724c9484d513f5caa34729475d2873d9f7bIan Romanick 184db273724c9484d513f5caa34729475d2873d9f7bIan Romanick if (req_version > max_version) { 185db273724c9484d513f5caa34729475d2873d9f7bIan Romanick *error = __DRI_CTX_ERROR_BAD_VERSION; 186db273724c9484d513f5caa34729475d2873d9f7bIan Romanick return false; 187db273724c9484d513f5caa34729475d2873d9f7bIan Romanick } 188db273724c9484d513f5caa34729475d2873d9f7bIan Romanick break; 189db273724c9484d513f5caa34729475d2873d9f7bIan Romanick } 190db273724c9484d513f5caa34729475d2873d9f7bIan Romanick case API_OPENGLES: 191db273724c9484d513f5caa34729475d2873d9f7bIan Romanick case API_OPENGLES2: 192db273724c9484d513f5caa34729475d2873d9f7bIan Romanick break; 193db273724c9484d513f5caa34729475d2873d9f7bIan Romanick default: 194db273724c9484d513f5caa34729475d2873d9f7bIan Romanick *error = __DRI_CTX_ERROR_BAD_API; 1952e5a1a254ed81b1d3efa6064f48183eefac784d0Kenneth Graunke return false; 1966d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane } 1976d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane 1988d15268a61fe400668495e6cb42c4d15e8b17cbbEric Anholt intel_init_texture_formats(ctx); 1998d15268a61fe400668495e6cb42c4d15e8b17cbbEric Anholt 20060953059ea2319eae4d737831824dbce08ee1725Eric Anholt _math_matrix_ctr(&intel->ViewportMatrix); 20160953059ea2319eae4d737831824dbce08ee1725Eric Anholt 202dd1d66fc4ab5d7064113a2017a431c3461598b91Kristian Høgsberg /* Initialize swrast, tnl driver tables: */ 203dd1d66fc4ab5d7064113a2017a431c3461598b91Kristian Høgsberg intelInitSpanFuncs(ctx); 204dd1d66fc4ab5d7064113a2017a431c3461598b91Kristian Høgsberg intelInitTriFuncs(ctx); 205dd1d66fc4ab5d7064113a2017a431c3461598b91Kristian Høgsberg 206dd1d66fc4ab5d7064113a2017a431c3461598b91Kristian Høgsberg /* Install the customized pipeline: */ 207dd1d66fc4ab5d7064113a2017a431c3461598b91Kristian Høgsberg _tnl_destroy_pipeline(ctx); 208dd1d66fc4ab5d7064113a2017a431c3461598b91Kristian Høgsberg _tnl_install_pipeline(ctx, intel_pipeline); 209dd1d66fc4ab5d7064113a2017a431c3461598b91Kristian Høgsberg 210f75843a517bd188639e6866db2a7b04de3524e16Dave Airlie if (intel->no_rast) 211f75843a517bd188639e6866db2a7b04de3524e16Dave Airlie FALLBACK(intel, INTEL_FALLBACK_USER, 1); 212f75843a517bd188639e6866db2a7b04de3524e16Dave Airlie 2136d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane ctx->Const.MaxTextureUnits = I915_TEX_UNITS; 2146d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane ctx->Const.MaxTextureImageUnits = I915_TEX_UNITS; 2156d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane ctx->Const.MaxTextureCoordUnits = I915_TEX_UNITS; 216f9f31b25740887373806cb489e5480dc9b261805Eric Anholt ctx->Const.MaxVarying = I915_TEX_UNITS; 21751e945ec9c0b803f5e998f87449fb02a7c39ae65Eric Anholt ctx->Const.MaxCombinedTextureImageUnits = 21851e945ec9c0b803f5e998f87449fb02a7c39ae65Eric Anholt ctx->Const.MaxVertexTextureImageUnits + 21951e945ec9c0b803f5e998f87449fb02a7c39ae65Eric Anholt ctx->Const.MaxTextureImageUnits; 2206d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane 2216d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane /* Advertise the full hardware capabilities. The new memory 2226d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane * manager should cope much better with overload situations: 2236d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane */ 2246d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane ctx->Const.MaxTextureLevels = 12; 2256d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane ctx->Const.Max3DTextureLevels = 9; 2266d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane ctx->Const.MaxCubeTextureLevels = 12; 2276d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane ctx->Const.MaxTextureRectSize = (1 << 11); 2286d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane ctx->Const.MaxTextureUnits = I915_TEX_UNITS; 2296d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane 23050853be894aa3edd1e9271f7d625f319209e340fRoland Scheidegger ctx->Const.MaxTextureMaxAnisotropy = 4.0; 23150853be894aa3edd1e9271f7d625f319209e340fRoland Scheidegger 2326d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane /* GL_ARB_fragment_program limits - don't think Mesa actually 2336d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane * validates programs against these, and in any case one ARB 2346d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane * instruction can translate to more than one HW instruction, so 2356d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane * we'll still have to check and fallback each time. 2366d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane */ 2376d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane ctx->Const.FragmentProgram.MaxNativeTemps = I915_MAX_TEMPORARY; 2386d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane ctx->Const.FragmentProgram.MaxNativeAttribs = 11; /* 8 tex, 2 color, fog */ 2396d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane ctx->Const.FragmentProgram.MaxNativeParameters = I915_MAX_CONSTANT; 2406d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane ctx->Const.FragmentProgram.MaxNativeAluInstructions = I915_MAX_ALU_INSN; 2416d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane ctx->Const.FragmentProgram.MaxNativeTexInstructions = I915_MAX_TEX_INSN; 2426d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane ctx->Const.FragmentProgram.MaxNativeInstructions = (I915_MAX_ALU_INSN + 2436d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane I915_MAX_TEX_INSN); 2446d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane ctx->Const.FragmentProgram.MaxNativeTexIndirections = 2456d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane I915_MAX_TEX_INDIRECT; 2466d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane ctx->Const.FragmentProgram.MaxNativeAddressRegs = 0; /* I don't think we have one */ 247eabe12df44a41e97fb5736959e8864ddbd01be14Ian Romanick ctx->Const.FragmentProgram.MaxEnvParams = 248eabe12df44a41e97fb5736959e8864ddbd01be14Ian Romanick MIN2(ctx->Const.FragmentProgram.MaxNativeParameters, 249eabe12df44a41e97fb5736959e8864ddbd01be14Ian Romanick ctx->Const.FragmentProgram.MaxEnvParams); 2506d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane 251790ff232e2607a83e6207d06900a5e3de613d161Ian Romanick /* i915 stores all values in single-precision floats. Values aren't set 252790ff232e2607a83e6207d06900a5e3de613d161Ian Romanick * for other program targets because software is used for those targets. 253790ff232e2607a83e6207d06900a5e3de613d161Ian Romanick */ 2542fb0aebd4a248d2a0725099cd5646253c30c1dc3Ian Romanick ctx->Const.FragmentProgram.MediumFloat.RangeMin = 127; 2552fb0aebd4a248d2a0725099cd5646253c30c1dc3Ian Romanick ctx->Const.FragmentProgram.MediumFloat.RangeMax = 127; 2562fb0aebd4a248d2a0725099cd5646253c30c1dc3Ian Romanick ctx->Const.FragmentProgram.MediumFloat.Precision = 23; 2572fb0aebd4a248d2a0725099cd5646253c30c1dc3Ian Romanick ctx->Const.FragmentProgram.LowFloat = ctx->Const.FragmentProgram.HighFloat = 2582fb0aebd4a248d2a0725099cd5646253c30c1dc3Ian Romanick ctx->Const.FragmentProgram.MediumFloat; 2592fb0aebd4a248d2a0725099cd5646253c30c1dc3Ian Romanick ctx->Const.FragmentProgram.MediumInt.RangeMin = 24; 2602fb0aebd4a248d2a0725099cd5646253c30c1dc3Ian Romanick ctx->Const.FragmentProgram.MediumInt.RangeMax = 24; 2612fb0aebd4a248d2a0725099cd5646253c30c1dc3Ian Romanick ctx->Const.FragmentProgram.MediumInt.Precision = 0; 2622fb0aebd4a248d2a0725099cd5646253c30c1dc3Ian Romanick ctx->Const.FragmentProgram.LowInt = ctx->Const.FragmentProgram.HighInt = 2632fb0aebd4a248d2a0725099cd5646253c30c1dc3Ian Romanick ctx->Const.FragmentProgram.MediumInt; 264790ff232e2607a83e6207d06900a5e3de613d161Ian Romanick 2652e5a1a254ed81b1d3efa6064f48183eefac784d0Kenneth Graunke ctx->FragmentProgram._MaintainTexEnvProgram = true; 2666d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane 2676d3a2c97f4a78e85545286e0e126cd3a27bd1cbdLuca Barbieri /* FINISHME: Are there other options that should be enabled for software 2686d3a2c97f4a78e85545286e0e126cd3a27bd1cbdLuca Barbieri * FINISHME: vertex shaders? 2696d3a2c97f4a78e85545286e0e126cd3a27bd1cbdLuca Barbieri */ 2702e5a1a254ed81b1d3efa6064f48183eefac784d0Kenneth Graunke ctx->ShaderCompilerOptions[MESA_SHADER_VERTEX].EmitCondCodes = true; 2714c1dc1c4d772b06578567f14419fdd4f27843825Ian Romanick 2724c1dc1c4d772b06578567f14419fdd4f27843825Ian Romanick struct gl_shader_compiler_options *const fs_options = 2734c1dc1c4d772b06578567f14419fdd4f27843825Ian Romanick & ctx->ShaderCompilerOptions[MESA_SHADER_FRAGMENT]; 274488fe51cf823ccd137c667f1e92dd86f8323b723Bryan Cain fs_options->MaxIfDepth = 0; 2752e5a1a254ed81b1d3efa6064f48183eefac784d0Kenneth Graunke fs_options->EmitNoNoise = true; 2762e5a1a254ed81b1d3efa6064f48183eefac784d0Kenneth Graunke fs_options->EmitNoPow = true; 2772e5a1a254ed81b1d3efa6064f48183eefac784d0Kenneth Graunke fs_options->EmitNoMainReturn = true; 2782e5a1a254ed81b1d3efa6064f48183eefac784d0Kenneth Graunke fs_options->EmitNoIndirectInput = true; 2792e5a1a254ed81b1d3efa6064f48183eefac784d0Kenneth Graunke fs_options->EmitNoIndirectOutput = true; 2802e5a1a254ed81b1d3efa6064f48183eefac784d0Kenneth Graunke fs_options->EmitNoIndirectUniform = true; 2812e5a1a254ed81b1d3efa6064f48183eefac784d0Kenneth Graunke fs_options->EmitNoIndirectTemp = true; 28295c08920ea3d040360e5cc51d8a852d21a0329eeEric Anholt 2838aa209c766b79144db499063dd1c8482562b07bfIan Romanick ctx->Const.MaxDrawBuffers = 1; 2848aa209c766b79144db499063dd1c8482562b07bfIan Romanick 2856d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane _tnl_init_vertices(ctx, ctx->Const.MaxArrayLockSize + 12, 2866d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane 36 * sizeof(GLfloat)); 2876d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane 2886d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane intel->verts = TNL_CONTEXT(ctx)->clipspace.vertex_buf; 2896d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane 2906d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane i915InitState(i915); 2916d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane 292d439491a77cf9f25ea7a7f9c2309d2542d87f83eIan Romanick /* Always enable pixel fog. Vertex fog using fog coord will conflict 293d439491a77cf9f25ea7a7f9c2309d2542d87f83eIan Romanick * with fog code appended onto fragment program. 294d439491a77cf9f25ea7a7f9c2309d2542d87f83eIan Romanick */ 295d439491a77cf9f25ea7a7f9c2309d2542d87f83eIan Romanick _tnl_allow_vertex_fog(ctx, 0); 296d439491a77cf9f25ea7a7f9c2309d2542d87f83eIan Romanick _tnl_allow_pixel_fog(ctx, 1); 297d439491a77cf9f25ea7a7f9c2309d2542d87f83eIan Romanick 2982e5a1a254ed81b1d3efa6064f48183eefac784d0Kenneth Graunke return true; 2996d104cb932080c5c0d951fbc0ec6d30fb7ebef45Alan Hourihane} 300