i915_vtbl.c revision c9886d535e4ac5ae108b1015a9682f4ddd297536
16b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell/************************************************************************** 26b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * 36b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. 46b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * All Rights Reserved. 56b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * 66b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * Permission is hereby granted, free of charge, to any person obtaining a 76b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * copy of this software and associated documentation files (the 86b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * "Software"), to deal in the Software without restriction, including 96b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * without limitation the rights to use, copy, modify, merge, publish, 106b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * distribute, sub license, and/or sell copies of the Software, and to 116b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * permit persons to whom the Software is furnished to do so, subject to 126b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * the following conditions: 136b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * 146b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * The above copyright notice and this permission notice (including the 156b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * next paragraph) shall be included in all copies or substantial portions 166b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * of the Software. 176b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * 186b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 196b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 206b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 216b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR 226b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 236b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 246b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 256b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * 266b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell **************************************************************************/ 276b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 286b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 296b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 30ecadb51bbcb972a79f3ed79e65a7986b9396e757Brian Paul#include "main/glheader.h" 31ecadb51bbcb972a79f3ed79e65a7986b9396e757Brian Paul#include "main/mtypes.h" 32ecadb51bbcb972a79f3ed79e65a7986b9396e757Brian Paul#include "main/imports.h" 33ecadb51bbcb972a79f3ed79e65a7986b9396e757Brian Paul#include "main/macros.h" 34ecadb51bbcb972a79f3ed79e65a7986b9396e757Brian Paul#include "main/colormac.h" 356b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 366b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#include "tnl/t_context.h" 376b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#include "tnl/t_vertex.h" 386b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 396b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#include "intel_batchbuffer.h" 406b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#include "intel_regions.h" 41f75843a517bd188639e6866db2a7b04de3524e16Dave Airlie#include "intel_tris.h" 422c30fd84dfa052949a117c78d932b58c1f88b446Eric Anholt#include "intel_fbo.h" 43b30dc2c66aeaad6661eef515a08a3da89aa07cb2Eric Anholt#include "intel_chipset.h" 446b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 456b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#include "i915_reg.h" 466b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#include "i915_context.h" 476b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 486b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellstatic void 49a188ba4bf9364df24842d8727f4c7ddb2f894a2cRoland Scheideggeri915_render_prevalidate(struct intel_context *intel) 506b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell{ 516b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell struct i915_context *i915 = i915_context(&intel->ctx); 526b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 53d6fbf87575a59e24c5d47b8b6b8700ee4583709bEric Anholt i915ValidateFragmentProgram(i915); 546b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell} 556b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 56a188ba4bf9364df24842d8727f4c7ddb2f894a2cRoland Scheideggerstatic void 57a188ba4bf9364df24842d8727f4c7ddb2f894a2cRoland Scheideggeri915_render_start(struct intel_context *intel) 58a188ba4bf9364df24842d8727f4c7ddb2f894a2cRoland Scheidegger{ 59a188ba4bf9364df24842d8727f4c7ddb2f894a2cRoland Scheidegger} 60a188ba4bf9364df24842d8727f4c7ddb2f894a2cRoland Scheidegger 616b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 626b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellstatic void 636b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwelli915_reduced_primitive_state(struct intel_context *intel, GLenum rprim) 646b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell{ 656b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell struct i915_context *i915 = i915_context(&intel->ctx); 666b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell GLuint st1 = i915->state.Stipple[I915_STPREG_ST1]; 676b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 686b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell st1 &= ~ST1_ENABLE; 696b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 706b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell switch (rprim) { 710bf2479aef5def4d01bfc55b08992f41664f1431Brian Paul case GL_QUADS: /* from RASTERIZE(GL_QUADS) in t_dd_tritemp.h */ 726b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell case GL_TRIANGLES: 736b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell if (intel->ctx.Polygon.StippleFlag && intel->hw_stipple) 746b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell st1 |= ST1_ENABLE; 756b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell break; 766b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell case GL_LINES: 776b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell case GL_POINTS: 786b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell default: 796b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell break; 806b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell } 816b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 826b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell i915->intel.reduced_primitive = rprim; 836b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 846b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell if (st1 != i915->state.Stipple[I915_STPREG_ST1]) { 856b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell INTEL_FIREVERTICES(intel); 866b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 876b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell I915_STATECHANGE(i915, I915_UPLOAD_STIPPLE); 886b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell i915->state.Stipple[I915_STPREG_ST1] = st1; 896b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell } 906b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell} 916b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 926b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 936b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell/* Pull apart the vertex format registers and figure out how large a 946b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * vertex is supposed to be. 956b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell */ 966b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellstatic GLboolean 976b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwelli915_check_vertex_size(struct intel_context *intel, GLuint expected) 986b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell{ 996b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell struct i915_context *i915 = i915_context(&intel->ctx); 100c9886d535e4ac5ae108b1015a9682f4ddd297536Eric Anholt int lis2 = i915->state.Ctx[I915_CTXREG_LIS2]; 101c9886d535e4ac5ae108b1015a9682f4ddd297536Eric Anholt int lis4 = i915->state.Ctx[I915_CTXREG_LIS4]; 1026b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell int i, sz = 0; 1036b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 1046b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell switch (lis4 & S4_VFMT_XYZW_MASK) { 1056b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell case S4_VFMT_XY: 1066b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell sz = 2; 1076b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell break; 1086b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell case S4_VFMT_XYZ: 1096b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell sz = 3; 1106b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell break; 1116b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell case S4_VFMT_XYW: 1126b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell sz = 3; 1136b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell break; 1146b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell case S4_VFMT_XYZW: 1156b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell sz = 4; 1166b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell break; 1176b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell default: 1186b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell fprintf(stderr, "no xyzw specified\n"); 1196b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell return 0; 1206b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell } 1216b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 1226b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell if (lis4 & S4_VFMT_SPEC_FOG) 1236b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell sz++; 1246b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell if (lis4 & S4_VFMT_COLOR) 1256b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell sz++; 1266b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell if (lis4 & S4_VFMT_DEPTH_OFFSET) 1276b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell sz++; 1286b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell if (lis4 & S4_VFMT_POINT_WIDTH) 1296b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell sz++; 1306b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell if (lis4 & S4_VFMT_FOG_PARAM) 1316b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell sz++; 1326b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 1336b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell for (i = 0; i < 8; i++) { 1346b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell switch (lis2 & S2_TEXCOORD_FMT0_MASK) { 1356b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell case TEXCOORDFMT_2D: 1366b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell sz += 2; 1376b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell break; 1386b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell case TEXCOORDFMT_3D: 1396b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell sz += 3; 1406b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell break; 1416b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell case TEXCOORDFMT_4D: 1426b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell sz += 4; 1436b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell break; 1446b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell case TEXCOORDFMT_1D: 1456b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell sz += 1; 1466b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell break; 1476b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell case TEXCOORDFMT_2D_16: 1486b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell sz += 1; 1496b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell break; 1506b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell case TEXCOORDFMT_4D_16: 1516b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell sz += 2; 1526b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell break; 1536b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell case TEXCOORDFMT_NOT_PRESENT: 1546b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell break; 1556b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell default: 1566b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell fprintf(stderr, "bad texcoord fmt %d\n", i); 1576b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell return GL_FALSE; 1586b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell } 1596b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell lis2 >>= S2_TEXCOORD_FMT1_SHIFT; 1606b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell } 1616b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 1626b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell if (sz != expected) 1636b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell fprintf(stderr, "vertex size mismatch %d/%d\n", sz, expected); 1646b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 1656b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell return sz == expected; 1666b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell} 1676b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 1686b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 1696b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellstatic void 1706b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwelli915_emit_invarient_state(struct intel_context *intel) 1716b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell{ 1726b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell BATCH_LOCALS; 1736b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 1745203b7227ccb6b618fa42f08434d4a3cf123dca2Kristian Høgsberg BEGIN_BATCH(17); 1756b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 1766b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell OUT_BATCH(_3DSTATE_AA_CMD | 1776b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell AA_LINE_ECAAR_WIDTH_ENABLE | 1786b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell AA_LINE_ECAAR_WIDTH_1_0 | 1796b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell AA_LINE_REGION_WIDTH_ENABLE | AA_LINE_REGION_WIDTH_1_0); 1806b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 1816b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell OUT_BATCH(_3DSTATE_DFLT_DIFFUSE_CMD); 1826b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell OUT_BATCH(0); 1836b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 1846b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell OUT_BATCH(_3DSTATE_DFLT_SPEC_CMD); 1856b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell OUT_BATCH(0); 1866b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 1876b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell OUT_BATCH(_3DSTATE_DFLT_Z_CMD); 1886b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell OUT_BATCH(0); 1896b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 1906b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell /* Don't support texture crossbar yet */ 1916b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell OUT_BATCH(_3DSTATE_COORD_SET_BINDINGS | 1926b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell CSB_TCB(0, 0) | 1936b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell CSB_TCB(1, 1) | 1946b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell CSB_TCB(2, 2) | 1956b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell CSB_TCB(3, 3) | 1966b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell CSB_TCB(4, 4) | CSB_TCB(5, 5) | CSB_TCB(6, 6) | CSB_TCB(7, 7)); 1976b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 1986b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell /* Need to initialize this to zero. 1996b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell */ 2004a789e408dbba7891f1436b2f42e7c0824e5ba7aKeith Whitwell OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | I1_LOAD_S(3) | (0)); 2016b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell OUT_BATCH(0); 2026b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 2036b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell /* XXX: Use this */ 2046b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell OUT_BATCH(_3DSTATE_SCISSOR_ENABLE_CMD | DISABLE_SCISSOR_RECT); 2056b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 2066b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell OUT_BATCH(_3DSTATE_SCISSOR_RECT_0_CMD); 2076b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell OUT_BATCH(0); 2086b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell OUT_BATCH(0); 2096b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 2106b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell OUT_BATCH(_3DSTATE_DEPTH_SUBRECT_DISABLE); 2116b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 2126b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell OUT_BATCH(_3DSTATE_LOAD_INDIRECT | 0); /* disable indirect state */ 2136b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell OUT_BATCH(0); 2146b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 2156b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell ADVANCE_BATCH(); 2166b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell} 2176b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 2186b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 2196b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define emit(intel, state, size ) \ 2205203b7227ccb6b618fa42f08434d4a3cf123dca2Kristian Høgsberg intel_batchbuffer_data(intel->batch, state, size) 2216b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 2226b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellstatic GLuint 2236b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellget_dirty(struct i915_hw_state *state) 2246b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell{ 2256b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell GLuint dirty; 2266b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 2276b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell /* Workaround the multitex hang - if one texture unit state is 2286b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * modified, emit all texture units. 2296b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell */ 2306b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell dirty = state->active & ~state->emitted; 2316b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell if (dirty & I915_UPLOAD_TEX_ALL) 2326b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell state->emitted &= ~I915_UPLOAD_TEX_ALL; 2336b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell dirty = state->active & ~state->emitted; 2346b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell return dirty; 2356b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell} 2366b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 2376b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 2386b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellstatic GLuint 2396b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellget_state_size(struct i915_hw_state *state) 2406b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell{ 2416b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell GLuint dirty = get_dirty(state); 2426b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell GLuint i; 2436b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell GLuint sz = 0; 2446b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 2454a789e408dbba7891f1436b2f42e7c0824e5ba7aKeith Whitwell if (dirty & I915_UPLOAD_INVARIENT) 2464a789e408dbba7891f1436b2f42e7c0824e5ba7aKeith Whitwell sz += 30 * 4; 2474a789e408dbba7891f1436b2f42e7c0824e5ba7aKeith Whitwell 248de80eeea0eebf00ee678b1a0fbd5fe67b00a8636Eric Anholt if (dirty & I915_UPLOAD_RASTER_RULES) 249de80eeea0eebf00ee678b1a0fbd5fe67b00a8636Eric Anholt sz += sizeof(state->RasterRules); 250de80eeea0eebf00ee678b1a0fbd5fe67b00a8636Eric Anholt 2516b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell if (dirty & I915_UPLOAD_CTX) 2526b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell sz += sizeof(state->Ctx); 2536b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 2546b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell if (dirty & I915_UPLOAD_BUFFERS) 2556b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell sz += sizeof(state->Buffer); 2566b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 2576b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell if (dirty & I915_UPLOAD_STIPPLE) 2586b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell sz += sizeof(state->Stipple); 2596b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 2606b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell if (dirty & I915_UPLOAD_FOG) 2616b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell sz += sizeof(state->Fog); 2626b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 2636b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell if (dirty & I915_UPLOAD_TEX_ALL) { 2646b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell int nr = 0; 2656b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell for (i = 0; i < I915_TEX_UNITS; i++) 2666b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell if (dirty & I915_UPLOAD_TEX(i)) 2676b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell nr++; 2686b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 2696b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell sz += (2 + nr * 3) * sizeof(GLuint) * 2; 2706b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell } 2716b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 2726b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell if (dirty & I915_UPLOAD_CONSTANTS) 2736b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell sz += state->ConstantSize * sizeof(GLuint); 2746b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 2756b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell if (dirty & I915_UPLOAD_PROGRAM) 2766b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell sz += state->ProgramSize * sizeof(GLuint); 2776b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 2786b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell return sz; 2796b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell} 2806b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 2816b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell/* Push the state into the sarea and/or texture memory. 2826b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell */ 2836b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellstatic void 2848517079cbcbbf31291b05420f3b776df712dfd47Eric Anholti915_emit_state(struct intel_context *intel) 2856b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell{ 2866b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell struct i915_context *i915 = i915_context(&intel->ctx); 287c9886d535e4ac5ae108b1015a9682f4ddd297536Eric Anholt struct i915_hw_state *state = &i915->state; 288f75843a517bd188639e6866db2a7b04de3524e16Dave Airlie int i, count, aper_count; 2896b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell GLuint dirty; 290f75843a517bd188639e6866db2a7b04de3524e16Dave Airlie dri_bo *aper_array[3 + I915_TEX_UNITS]; 29196338dd1470bb088cbbe50d629cd30175245a784Dave Airlie GET_CURRENT_CONTEXT(ctx); 2926b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell BATCH_LOCALS; 2936b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 2946b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell /* We don't hold the lock at this point, so want to make sure that 2958517079cbcbbf31291b05420f3b776df712dfd47Eric Anholt * there won't be a buffer wrap between the state emits and the primitive 2968517079cbcbbf31291b05420f3b776df712dfd47Eric Anholt * emit header. 2976b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * 2986b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * It might be better to talk about explicit places where 2996b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * scheduling is allowed, rather than assume that it is whenever a 3006b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * batchbuffer fills up. 301a8fee3a498c8c4966d57a5273408477f3aa3ce73Keith Whitwell */ 302f75843a517bd188639e6866db2a7b04de3524e16Dave Airlie intel_batchbuffer_require_space(intel->batch, 3035203b7227ccb6b618fa42f08434d4a3cf123dca2Kristian Høgsberg get_state_size(state) + INTEL_PRIM_EMIT_SIZE); 3047cc7ff7051d427ff45b4d7d3664e2eecd13d0e13Dave Airlie count = 0; 3057cc7ff7051d427ff45b4d7d3664e2eecd13d0e13Dave Airlie again: 306f75843a517bd188639e6866db2a7b04de3524e16Dave Airlie aper_count = 0; 3077cc7ff7051d427ff45b4d7d3664e2eecd13d0e13Dave Airlie dirty = get_dirty(state); 3087cc7ff7051d427ff45b4d7d3664e2eecd13d0e13Dave Airlie 309f75843a517bd188639e6866db2a7b04de3524e16Dave Airlie aper_array[aper_count++] = intel->batch->buf; 3107cc7ff7051d427ff45b4d7d3664e2eecd13d0e13Dave Airlie if (dirty & I915_UPLOAD_BUFFERS) { 311f75843a517bd188639e6866db2a7b04de3524e16Dave Airlie aper_array[aper_count++] = state->draw_region->buffer; 312f75843a517bd188639e6866db2a7b04de3524e16Dave Airlie if (state->depth_region) 313f75843a517bd188639e6866db2a7b04de3524e16Dave Airlie aper_array[aper_count++] = state->depth_region->buffer; 3147cc7ff7051d427ff45b4d7d3664e2eecd13d0e13Dave Airlie } 3157cc7ff7051d427ff45b4d7d3664e2eecd13d0e13Dave Airlie 3167cc7ff7051d427ff45b4d7d3664e2eecd13d0e13Dave Airlie if (dirty & I915_UPLOAD_TEX_ALL) { 317f75843a517bd188639e6866db2a7b04de3524e16Dave Airlie for (i = 0; i < I915_TEX_UNITS; i++) { 318f75843a517bd188639e6866db2a7b04de3524e16Dave Airlie if (dirty & I915_UPLOAD_TEX(i)) { 319f75843a517bd188639e6866db2a7b04de3524e16Dave Airlie if (state->tex_buffer[i]) { 320f75843a517bd188639e6866db2a7b04de3524e16Dave Airlie aper_array[aper_count++] = state->tex_buffer[i]; 321f75843a517bd188639e6866db2a7b04de3524e16Dave Airlie } 322f75843a517bd188639e6866db2a7b04de3524e16Dave Airlie } 323f75843a517bd188639e6866db2a7b04de3524e16Dave Airlie } 3247cc7ff7051d427ff45b4d7d3664e2eecd13d0e13Dave Airlie } 325f75843a517bd188639e6866db2a7b04de3524e16Dave Airlie 326f75843a517bd188639e6866db2a7b04de3524e16Dave Airlie if (dri_bufmgr_check_aperture_space(aper_array, aper_count)) { 3277cc7ff7051d427ff45b4d7d3664e2eecd13d0e13Dave Airlie if (count == 0) { 3287cc7ff7051d427ff45b4d7d3664e2eecd13d0e13Dave Airlie count++; 3297cc7ff7051d427ff45b4d7d3664e2eecd13d0e13Dave Airlie intel_batchbuffer_flush(intel->batch); 3307cc7ff7051d427ff45b4d7d3664e2eecd13d0e13Dave Airlie goto again; 3317cc7ff7051d427ff45b4d7d3664e2eecd13d0e13Dave Airlie } else { 3327cc7ff7051d427ff45b4d7d3664e2eecd13d0e13Dave Airlie _mesa_error(ctx, GL_OUT_OF_MEMORY, "i915 emit state"); 3337cc7ff7051d427ff45b4d7d3664e2eecd13d0e13Dave Airlie assert(0); 3347cc7ff7051d427ff45b4d7d3664e2eecd13d0e13Dave Airlie } 3357cc7ff7051d427ff45b4d7d3664e2eecd13d0e13Dave Airlie } 336a8fee3a498c8c4966d57a5273408477f3aa3ce73Keith Whitwell 3377cc7ff7051d427ff45b4d7d3664e2eecd13d0e13Dave Airlie /* work out list of buffers to emit */ 3387cc7ff7051d427ff45b4d7d3664e2eecd13d0e13Dave Airlie 3396b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell /* Do this here as we may have flushed the batchbuffer above, 3406b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * causing more state to be dirty! 3416b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell */ 3426b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell dirty = get_dirty(state); 3434a789e408dbba7891f1436b2f42e7c0824e5ba7aKeith Whitwell state->emitted |= dirty; 344a8fee3a498c8c4966d57a5273408477f3aa3ce73Keith Whitwell assert(get_dirty(state) == 0); 345a8fee3a498c8c4966d57a5273408477f3aa3ce73Keith Whitwell 3466b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell if (INTEL_DEBUG & DEBUG_STATE) 3476b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell fprintf(stderr, "%s dirty: %x\n", __FUNCTION__, dirty); 3486b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 3496b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell if (dirty & I915_UPLOAD_INVARIENT) { 3506b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell if (INTEL_DEBUG & DEBUG_STATE) 3516b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell fprintf(stderr, "I915_UPLOAD_INVARIENT:\n"); 3526b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell i915_emit_invarient_state(intel); 3536b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell } 3546b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 355de80eeea0eebf00ee678b1a0fbd5fe67b00a8636Eric Anholt if (dirty & I915_UPLOAD_RASTER_RULES) { 356de80eeea0eebf00ee678b1a0fbd5fe67b00a8636Eric Anholt if (INTEL_DEBUG & DEBUG_STATE) 357de80eeea0eebf00ee678b1a0fbd5fe67b00a8636Eric Anholt fprintf(stderr, "I915_UPLOAD_RASTER_RULES:\n"); 358de80eeea0eebf00ee678b1a0fbd5fe67b00a8636Eric Anholt emit(intel, state->RasterRules, sizeof(state->RasterRules)); 359de80eeea0eebf00ee678b1a0fbd5fe67b00a8636Eric Anholt } 360de80eeea0eebf00ee678b1a0fbd5fe67b00a8636Eric Anholt 3616b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell if (dirty & I915_UPLOAD_CTX) { 3626b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell if (INTEL_DEBUG & DEBUG_STATE) 3636b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell fprintf(stderr, "I915_UPLOAD_CTX:\n"); 3647a9c7c1133d5cf17d032c8568e8f040a7c171a72Brian Paul 3656b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell emit(intel, state->Ctx, sizeof(state->Ctx)); 3666b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell } 3676b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 3686b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell if (dirty & I915_UPLOAD_BUFFERS) { 3692861d9200be15cc44e8825387d3bd79086523c67Kristian Høgsberg GLuint count = 15; 370df73363ed1aa34cc0dc5feefb3933309591fa015Xiang, Haihao 3716b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell if (INTEL_DEBUG & DEBUG_STATE) 3726b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell fprintf(stderr, "I915_UPLOAD_BUFFERS:\n"); 373df73363ed1aa34cc0dc5feefb3933309591fa015Xiang, Haihao 374df73363ed1aa34cc0dc5feefb3933309591fa015Xiang, Haihao if (state->depth_region) 375df73363ed1aa34cc0dc5feefb3933309591fa015Xiang, Haihao count += 3; 376df73363ed1aa34cc0dc5feefb3933309591fa015Xiang, Haihao 3775203b7227ccb6b618fa42f08434d4a3cf123dca2Kristian Høgsberg BEGIN_BATCH(count); 3786b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell OUT_BATCH(state->Buffer[I915_DESTREG_CBUFADDR0]); 3796b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell OUT_BATCH(state->Buffer[I915_DESTREG_CBUFADDR1]); 3806b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell OUT_RELOC(state->draw_region->buffer, 381f75843a517bd188639e6866db2a7b04de3524e16Dave Airlie I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER, 3826b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell state->draw_region->draw_offset); 3836b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 3846b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell if (state->depth_region) { 3856b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell OUT_BATCH(state->Buffer[I915_DESTREG_DBUFADDR0]); 3866b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell OUT_BATCH(state->Buffer[I915_DESTREG_DBUFADDR1]); 3876b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell OUT_RELOC(state->depth_region->buffer, 388f75843a517bd188639e6866db2a7b04de3524e16Dave Airlie I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER, 3896b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell state->depth_region->draw_offset); 3906b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell } 3916b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 3926b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell OUT_BATCH(state->Buffer[I915_DESTREG_DV0]); 3936b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell OUT_BATCH(state->Buffer[I915_DESTREG_DV1]); 3946b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell OUT_BATCH(state->Buffer[I915_DESTREG_SENABLE]); 3956b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell OUT_BATCH(state->Buffer[I915_DESTREG_SR0]); 3966b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell OUT_BATCH(state->Buffer[I915_DESTREG_SR1]); 3976b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell OUT_BATCH(state->Buffer[I915_DESTREG_SR2]); 3980cade4de4f74f6b0e86fb6622e2fc370c73fd840Eric Anholt 3992861d9200be15cc44e8825387d3bd79086523c67Kristian Høgsberg assert(state->Buffer[I915_DESTREG_DRAWRECT0] != MI_NOOP); 4002861d9200be15cc44e8825387d3bd79086523c67Kristian Høgsberg OUT_BATCH(state->Buffer[I915_DESTREG_DRAWRECT0]); 4012861d9200be15cc44e8825387d3bd79086523c67Kristian Høgsberg OUT_BATCH(state->Buffer[I915_DESTREG_DRAWRECT1]); 4022861d9200be15cc44e8825387d3bd79086523c67Kristian Høgsberg OUT_BATCH(state->Buffer[I915_DESTREG_DRAWRECT2]); 4032861d9200be15cc44e8825387d3bd79086523c67Kristian Høgsberg OUT_BATCH(state->Buffer[I915_DESTREG_DRAWRECT3]); 4042861d9200be15cc44e8825387d3bd79086523c67Kristian Høgsberg OUT_BATCH(state->Buffer[I915_DESTREG_DRAWRECT4]); 4052861d9200be15cc44e8825387d3bd79086523c67Kristian Høgsberg OUT_BATCH(state->Buffer[I915_DESTREG_DRAWRECT5]); 4060cade4de4f74f6b0e86fb6622e2fc370c73fd840Eric Anholt 4076b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell ADVANCE_BATCH(); 4086b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell } 4096b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 4106b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell if (dirty & I915_UPLOAD_STIPPLE) { 4116b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell if (INTEL_DEBUG & DEBUG_STATE) 4126b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell fprintf(stderr, "I915_UPLOAD_STIPPLE:\n"); 4136b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell emit(intel, state->Stipple, sizeof(state->Stipple)); 4146b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell } 4156b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 4166b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell if (dirty & I915_UPLOAD_FOG) { 4176b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell if (INTEL_DEBUG & DEBUG_STATE) 4186b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell fprintf(stderr, "I915_UPLOAD_FOG:\n"); 4196b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell emit(intel, state->Fog, sizeof(state->Fog)); 4206b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell } 4216b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 4226b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell /* Combine all the dirty texture state into a single command to 4236b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * avoid lockups on I915 hardware. 4246b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell */ 4256b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell if (dirty & I915_UPLOAD_TEX_ALL) { 4266b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell int nr = 0; 4276b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 4286b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell for (i = 0; i < I915_TEX_UNITS; i++) 4296b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell if (dirty & I915_UPLOAD_TEX(i)) 4306b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell nr++; 4316b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 4325203b7227ccb6b618fa42f08434d4a3cf123dca2Kristian Høgsberg BEGIN_BATCH(2 + nr * 3); 4336b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell OUT_BATCH(_3DSTATE_MAP_STATE | (3 * nr)); 4346b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell OUT_BATCH((dirty & I915_UPLOAD_TEX_ALL) >> I915_UPLOAD_TEX_0_SHIFT); 4356b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell for (i = 0; i < I915_TEX_UNITS; i++) 4366b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell if (dirty & I915_UPLOAD_TEX(i)) { 4376b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 4386b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell if (state->tex_buffer[i]) { 4396b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell OUT_RELOC(state->tex_buffer[i], 440f75843a517bd188639e6866db2a7b04de3524e16Dave Airlie I915_GEM_DOMAIN_SAMPLER, 0, 4416b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell state->tex_offset[i]); 4426b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell } 443e0885b84a0e10d6a3c976c8dc52a5fdc175635bbMichel Dänzer else { 444e0885b84a0e10d6a3c976c8dc52a5fdc175635bbMichel Dänzer OUT_BATCH(state->tex_offset[i]); 445e0885b84a0e10d6a3c976c8dc52a5fdc175635bbMichel Dänzer } 4466b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 4476b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell OUT_BATCH(state->Tex[i][I915_TEXREG_MS3]); 4486b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell OUT_BATCH(state->Tex[i][I915_TEXREG_MS4]); 4496b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell } 4506b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell ADVANCE_BATCH(); 4516b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 4525203b7227ccb6b618fa42f08434d4a3cf123dca2Kristian Høgsberg BEGIN_BATCH(2 + nr * 3); 4536b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell OUT_BATCH(_3DSTATE_SAMPLER_STATE | (3 * nr)); 4546b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell OUT_BATCH((dirty & I915_UPLOAD_TEX_ALL) >> I915_UPLOAD_TEX_0_SHIFT); 4556b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell for (i = 0; i < I915_TEX_UNITS; i++) 4566b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell if (dirty & I915_UPLOAD_TEX(i)) { 4576b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell OUT_BATCH(state->Tex[i][I915_TEXREG_SS2]); 4586b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell OUT_BATCH(state->Tex[i][I915_TEXREG_SS3]); 4596b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell OUT_BATCH(state->Tex[i][I915_TEXREG_SS4]); 4606b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell } 4616b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell ADVANCE_BATCH(); 4626b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell } 4636b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 4646b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell if (dirty & I915_UPLOAD_CONSTANTS) { 4656b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell if (INTEL_DEBUG & DEBUG_STATE) 4666b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell fprintf(stderr, "I915_UPLOAD_CONSTANTS:\n"); 4676b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell emit(intel, state->Constant, state->ConstantSize * sizeof(GLuint)); 4686b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell } 4696b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 4706b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell if (dirty & I915_UPLOAD_PROGRAM) { 471e2ca788ae700aae75bf8d024c1374c38cc5574f9Xiang, Haihao if (state->ProgramSize) { 472c1a3ac0e45d6b69d5567f80b76815b2e6997128dXiang, Haihao if (INTEL_DEBUG & DEBUG_STATE) 473c1a3ac0e45d6b69d5567f80b76815b2e6997128dXiang, Haihao fprintf(stderr, "I915_UPLOAD_PROGRAM:\n"); 4746b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 475c1a3ac0e45d6b69d5567f80b76815b2e6997128dXiang, Haihao assert((state->Program[0] & 0x1ff) + 2 == state->ProgramSize); 4766b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 477c1a3ac0e45d6b69d5567f80b76815b2e6997128dXiang, Haihao emit(intel, state->Program, state->ProgramSize * sizeof(GLuint)); 478c1a3ac0e45d6b69d5567f80b76815b2e6997128dXiang, Haihao if (INTEL_DEBUG & DEBUG_STATE) 479c1a3ac0e45d6b69d5567f80b76815b2e6997128dXiang, Haihao i915_disassemble_program(state->Program, state->ProgramSize); 480c1a3ac0e45d6b69d5567f80b76815b2e6997128dXiang, Haihao } 4816b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell } 4826b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 483a8fee3a498c8c4966d57a5273408477f3aa3ce73Keith Whitwell intel->batch->dirty_state &= ~dirty; 4844a789e408dbba7891f1436b2f42e7c0824e5ba7aKeith Whitwell assert(get_dirty(state) == 0); 485a8fee3a498c8c4966d57a5273408477f3aa3ce73Keith Whitwell assert((intel->batch->dirty_state & (1<<1)) == 0); 486a8fee3a498c8c4966d57a5273408477f3aa3ce73Keith Whitwell} 487a8fee3a498c8c4966d57a5273408477f3aa3ce73Keith Whitwell 488a8fee3a498c8c4966d57a5273408477f3aa3ce73Keith Whitwellstatic void 4896b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwelli915_destroy_context(struct intel_context *intel) 4906b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell{ 4912193c4de83acfc3268ccca7b54b00543307e0baaMichel Dänzer GLuint i; 4922193c4de83acfc3268ccca7b54b00543307e0baaMichel Dänzer struct i915_context *i915 = i915_context(&intel->ctx); 4932193c4de83acfc3268ccca7b54b00543307e0baaMichel Dänzer 4947d99ddcb2bb09f1f54d91e6e20e42d217a5bccdfEric Anholt intel_region_release(&i915->state.draw_region); 4957d99ddcb2bb09f1f54d91e6e20e42d217a5bccdfEric Anholt intel_region_release(&i915->state.depth_region); 4967d99ddcb2bb09f1f54d91e6e20e42d217a5bccdfEric Anholt 4972193c4de83acfc3268ccca7b54b00543307e0baaMichel Dänzer for (i = 0; i < I915_TEX_UNITS; i++) { 4982193c4de83acfc3268ccca7b54b00543307e0baaMichel Dänzer if (i915->state.tex_buffer[i] != NULL) { 4994f1c9f7e510122b32c82ee9adbdb4987dae27afeEric Anholt dri_bo_unreference(i915->state.tex_buffer[i]); 5002193c4de83acfc3268ccca7b54b00543307e0baaMichel Dänzer i915->state.tex_buffer[i] = NULL; 5012193c4de83acfc3268ccca7b54b00543307e0baaMichel Dänzer } 5022193c4de83acfc3268ccca7b54b00543307e0baaMichel Dänzer } 5032193c4de83acfc3268ccca7b54b00543307e0baaMichel Dänzer 5046b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell _tnl_free_vertices(&intel->ctx); 5056b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell} 5066b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 507165ae5e2fb57bdb64b4cf01271b4effeb811f675Eric Anholtvoid 508165ae5e2fb57bdb64b4cf01271b4effeb811f675Eric Anholti915_set_buf_info_for_region(uint32_t *state, struct intel_region *region, 509165ae5e2fb57bdb64b4cf01271b4effeb811f675Eric Anholt uint32_t buffer_id) 510165ae5e2fb57bdb64b4cf01271b4effeb811f675Eric Anholt{ 511165ae5e2fb57bdb64b4cf01271b4effeb811f675Eric Anholt state[0] = _3DSTATE_BUF_INFO_CMD; 512165ae5e2fb57bdb64b4cf01271b4effeb811f675Eric Anholt state[1] = buffer_id; 513165ae5e2fb57bdb64b4cf01271b4effeb811f675Eric Anholt 514165ae5e2fb57bdb64b4cf01271b4effeb811f675Eric Anholt if (region != NULL) { 515165ae5e2fb57bdb64b4cf01271b4effeb811f675Eric Anholt state[1] |= BUF_3D_PITCH(region->pitch * region->cpp); 516165ae5e2fb57bdb64b4cf01271b4effeb811f675Eric Anholt 517165ae5e2fb57bdb64b4cf01271b4effeb811f675Eric Anholt if (region->tiling != I915_TILING_NONE) { 518165ae5e2fb57bdb64b4cf01271b4effeb811f675Eric Anholt state[1] |= BUF_3D_TILED_SURFACE; 519165ae5e2fb57bdb64b4cf01271b4effeb811f675Eric Anholt if (region->tiling == I915_TILING_Y) 520165ae5e2fb57bdb64b4cf01271b4effeb811f675Eric Anholt state[1] |= BUF_3D_TILE_WALK_Y; 521165ae5e2fb57bdb64b4cf01271b4effeb811f675Eric Anholt } 522165ae5e2fb57bdb64b4cf01271b4effeb811f675Eric Anholt } 523165ae5e2fb57bdb64b4cf01271b4effeb811f675Eric Anholt} 5246b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 525f9439e4a4696b8bc5fcdf3ac664f5e8d446f6621Eric Anholtstatic void 526f9439e4a4696b8bc5fcdf3ac664f5e8d446f6621Eric Anholti915_set_draw_region(struct intel_context *intel, 527f9439e4a4696b8bc5fcdf3ac664f5e8d446f6621Eric Anholt struct intel_region *color_regions[], 528f9439e4a4696b8bc5fcdf3ac664f5e8d446f6621Eric Anholt struct intel_region *depth_region, 529f9439e4a4696b8bc5fcdf3ac664f5e8d446f6621Eric Anholt GLuint num_regions) 5306b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell{ 5316b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell struct i915_context *i915 = i915_context(&intel->ctx); 5320cade4de4f74f6b0e86fb6622e2fc370c73fd840Eric Anholt GLcontext *ctx = &intel->ctx; 5332c30fd84dfa052949a117c78d932b58c1f88b446Eric Anholt struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0]; 5342c30fd84dfa052949a117c78d932b58c1f88b446Eric Anholt struct intel_renderbuffer *irb = intel_renderbuffer(rb); 5356b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell GLuint value; 536f9439e4a4696b8bc5fcdf3ac664f5e8d446f6621Eric Anholt struct i915_hw_state *state = &i915->state; 5376b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 538f9439e4a4696b8bc5fcdf3ac664f5e8d446f6621Eric Anholt if (state->draw_region != color_regions[0]) { 5396b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell intel_region_release(&state->draw_region); 540f9439e4a4696b8bc5fcdf3ac664f5e8d446f6621Eric Anholt intel_region_reference(&state->draw_region, color_regions[0]); 5416b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell } 5426b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell if (state->depth_region != depth_region) { 5436b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell intel_region_release(&state->depth_region); 5446b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell intel_region_reference(&state->depth_region, depth_region); 5456b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell } 5466b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 5476b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell /* 5486b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * Set stride/cpp values 5496b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell */ 550165ae5e2fb57bdb64b4cf01271b4effeb811f675Eric Anholt i915_set_buf_info_for_region(&state->Buffer[I915_DESTREG_CBUFADDR0], 551f9439e4a4696b8bc5fcdf3ac664f5e8d446f6621Eric Anholt color_regions[0], BUF_3D_ID_COLOR_BACK); 5526b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 553165ae5e2fb57bdb64b4cf01271b4effeb811f675Eric Anholt i915_set_buf_info_for_region(&state->Buffer[I915_DESTREG_DBUFADDR0], 554165ae5e2fb57bdb64b4cf01271b4effeb811f675Eric Anholt depth_region, BUF_3D_ID_DEPTH); 5556b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 5566b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell /* 5576b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * Compute/set I915_DESTREG_DV1 value 5586b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell */ 5596b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell value = (DSTORG_HORT_BIAS(0x8) | /* .5 */ 5606b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell DSTORG_VERT_BIAS(0x8) | /* .5 */ 5616b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell LOD_PRECLAMP_OGL | TEX_DEFAULT_COLOR_OGL); 5622c30fd84dfa052949a117c78d932b58c1f88b446Eric Anholt if (irb != NULL) { 5633078bd136d6ee1d9ad16b4c834cad23b005304a4Ian Romanick switch (irb->Base.Format) { 5642c30fd84dfa052949a117c78d932b58c1f88b446Eric Anholt case MESA_FORMAT_ARGB8888: 5654a253431abf43a0638afb43605b44a8742b72a60Brian Paul case MESA_FORMAT_XRGB8888: 5662c30fd84dfa052949a117c78d932b58c1f88b446Eric Anholt value |= DV_PF_8888; 5672c30fd84dfa052949a117c78d932b58c1f88b446Eric Anholt break; 5682c30fd84dfa052949a117c78d932b58c1f88b446Eric Anholt case MESA_FORMAT_RGB565: 5692c30fd84dfa052949a117c78d932b58c1f88b446Eric Anholt value |= DV_PF_565 | DITHER_FULL_ALWAYS; 5702c30fd84dfa052949a117c78d932b58c1f88b446Eric Anholt break; 5712c30fd84dfa052949a117c78d932b58c1f88b446Eric Anholt case MESA_FORMAT_ARGB1555: 5722c30fd84dfa052949a117c78d932b58c1f88b446Eric Anholt value |= DV_PF_1555 | DITHER_FULL_ALWAYS; 5732c30fd84dfa052949a117c78d932b58c1f88b446Eric Anholt break; 5742c30fd84dfa052949a117c78d932b58c1f88b446Eric Anholt case MESA_FORMAT_ARGB4444: 5752c30fd84dfa052949a117c78d932b58c1f88b446Eric Anholt value |= DV_PF_4444 | DITHER_FULL_ALWAYS; 5762c30fd84dfa052949a117c78d932b58c1f88b446Eric Anholt break; 5772c30fd84dfa052949a117c78d932b58c1f88b446Eric Anholt default: 5782c30fd84dfa052949a117c78d932b58c1f88b446Eric Anholt _mesa_problem(ctx, "Bad renderbuffer format: %d\n", 5793078bd136d6ee1d9ad16b4c834cad23b005304a4Ian Romanick irb->Base.Format); 5802c30fd84dfa052949a117c78d932b58c1f88b446Eric Anholt } 5816b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell } 5822c30fd84dfa052949a117c78d932b58c1f88b446Eric Anholt 583b30dc2c66aeaad6661eef515a08a3da89aa07cb2Eric Anholt /* This isn't quite safe, thus being hidden behind an option. When changing 584b30dc2c66aeaad6661eef515a08a3da89aa07cb2Eric Anholt * the value of this bit, the pipeline needs to be MI_FLUSHed. And it 585b30dc2c66aeaad6661eef515a08a3da89aa07cb2Eric Anholt * can only be set when a depth buffer is already defined. 586b30dc2c66aeaad6661eef515a08a3da89aa07cb2Eric Anholt */ 587f67748038935e609aa85450b20d550b4813c9429Eric Anholt if (intel->is_945 && intel->use_early_z && 588b30dc2c66aeaad6661eef515a08a3da89aa07cb2Eric Anholt depth_region->tiling != I915_TILING_NONE) 589b30dc2c66aeaad6661eef515a08a3da89aa07cb2Eric Anholt value |= CLASSIC_EARLY_DEPTH; 590b30dc2c66aeaad6661eef515a08a3da89aa07cb2Eric Anholt 5916b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell if (depth_region && depth_region->cpp == 4) { 5926b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell value |= DEPTH_FRMT_24_FIXED_8_OTHER; 5936b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell } 5946b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell else { 5956b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell value |= DEPTH_FRMT_16_FIXED; 5966b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell } 5976b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell state->Buffer[I915_DESTREG_DV1] = value; 5986b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 5992861d9200be15cc44e8825387d3bd79086523c67Kristian Høgsberg state->Buffer[I915_DESTREG_DRAWRECT0] = _3DSTATE_DRAWRECT_INFO; 6002861d9200be15cc44e8825387d3bd79086523c67Kristian Høgsberg state->Buffer[I915_DESTREG_DRAWRECT1] = 0; 6012861d9200be15cc44e8825387d3bd79086523c67Kristian Høgsberg state->Buffer[I915_DESTREG_DRAWRECT2] = 0; /* xmin, ymin */ 6022861d9200be15cc44e8825387d3bd79086523c67Kristian Høgsberg state->Buffer[I915_DESTREG_DRAWRECT3] = 6032861d9200be15cc44e8825387d3bd79086523c67Kristian Høgsberg (ctx->DrawBuffer->Width & 0xffff) | 6042861d9200be15cc44e8825387d3bd79086523c67Kristian Høgsberg (ctx->DrawBuffer->Height << 16); 6052861d9200be15cc44e8825387d3bd79086523c67Kristian Høgsberg state->Buffer[I915_DESTREG_DRAWRECT4] = 0; /* xoff, yoff */ 6062861d9200be15cc44e8825387d3bd79086523c67Kristian Høgsberg state->Buffer[I915_DESTREG_DRAWRECT5] = 0; 6070cade4de4f74f6b0e86fb6622e2fc370c73fd840Eric Anholt 6086b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell I915_STATECHANGE(i915, I915_UPLOAD_BUFFERS); 6096b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell} 6106b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 6116b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 6126b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 6136b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellstatic void 6145f86ae057a645c03dc1e0c51c2fb1b2628a50e0aEric Anholti915_new_batch(struct intel_context *intel) 6156b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell{ 6166b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell struct i915_context *i915 = i915_context(&intel->ctx); 6175f86ae057a645c03dc1e0c51c2fb1b2628a50e0aEric Anholt 6185f86ae057a645c03dc1e0c51c2fb1b2628a50e0aEric Anholt /* Mark all state as needing to be emitted when starting a new batchbuffer. 6195f86ae057a645c03dc1e0c51c2fb1b2628a50e0aEric Anholt * Using hardware contexts would be an alternative, but they have some 6205f86ae057a645c03dc1e0c51c2fb1b2628a50e0aEric Anholt * difficulties associated with them (physical address requirements). 6215f86ae057a645c03dc1e0c51c2fb1b2628a50e0aEric Anholt */ 6226b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell i915->state.emitted = 0; 6236b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell} 6246b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 6256b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellstatic void 6266b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwelli915_assert_not_dirty( struct intel_context *intel ) 6276b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell{ 6286b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell struct i915_context *i915 = i915_context(&intel->ctx); 629c9886d535e4ac5ae108b1015a9682f4ddd297536Eric Anholt GLuint dirty = get_dirty(&i915->state); 6306b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell assert(!dirty); 6316b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell} 6326b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell 6336b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellvoid 6346b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwelli915InitVtbl(struct i915_context *i915) 6356b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell{ 6366b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell i915->intel.vtbl.check_vertex_size = i915_check_vertex_size; 6376b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell i915->intel.vtbl.destroy = i915_destroy_context; 6386b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell i915->intel.vtbl.emit_state = i915_emit_state; 6395f86ae057a645c03dc1e0c51c2fb1b2628a50e0aEric Anholt i915->intel.vtbl.new_batch = i915_new_batch; 6406b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell i915->intel.vtbl.reduced_primitive_state = i915_reduced_primitive_state; 6416b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell i915->intel.vtbl.render_start = i915_render_start; 642a188ba4bf9364df24842d8727f4c7ddb2f894a2cRoland Scheidegger i915->intel.vtbl.render_prevalidate = i915_render_prevalidate; 6436b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell i915->intel.vtbl.set_draw_region = i915_set_draw_region; 6446b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell i915->intel.vtbl.update_texture_state = i915UpdateTextureState; 6456b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell i915->intel.vtbl.assert_not_dirty = i915_assert_not_dirty; 646f75843a517bd188639e6866db2a7b04de3524e16Dave Airlie i915->intel.vtbl.finish_batch = intel_finish_vb; 6476b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell} 648