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#ifndef I915CONTEXT_INC
296b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define I915CONTEXT_INC
306b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
316b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#include "intel_context.h"
326b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
336b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define I915_FALLBACK_TEXTURE		 0x1000
346b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define I915_FALLBACK_COLORMASK		 0x2000
356b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define I915_FALLBACK_STENCIL		 0x4000
366b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define I915_FALLBACK_STIPPLE		 0x8000
376b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define I915_FALLBACK_PROGRAM		 0x10000
386b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define I915_FALLBACK_LOGICOP		 0x20000
396b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define I915_FALLBACK_POLYGON_SMOOTH	 0x40000
406b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define I915_FALLBACK_POINT_SMOOTH	 0x80000
41533b7660073f2c1cd1a19105d4989ec11bfdcd87Ian Romanick#define I915_FALLBACK_POINT_SPRITE_COORD_ORIGIN	 0x100000
42b87406e55f029d29594ae76a4b39a4fe1007fe4fEric Anholt#define I915_FALLBACK_DRAW_OFFSET	 0x200000
43c6532875493ffe7de9c37924c70ebf6d0472e23dYuanhan Liu#define I915_FALLBACK_COORD_REPLACE	 0x400000
446b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
456b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define I915_UPLOAD_CTX              0x1
466b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define I915_UPLOAD_BUFFERS          0x2
476b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define I915_UPLOAD_STIPPLE          0x4
486b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define I915_UPLOAD_PROGRAM          0x8
496b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define I915_UPLOAD_CONSTANTS        0x10
506b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define I915_UPLOAD_INVARIENT        0x40
516b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define I915_UPLOAD_DEFAULTS         0x80
52de80eeea0eebf00ee678b1a0fbd5fe67b00a8636Eric Anholt#define I915_UPLOAD_RASTER_RULES     0x100
537c97e288fb6a105ea60c377aef4472cc33ca01bcChris Wilson#define I915_UPLOAD_BLEND            0x200
546b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define I915_UPLOAD_TEX(i)           (0x00010000<<(i))
556b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define I915_UPLOAD_TEX_ALL          (0x00ff0000)
566b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define I915_UPLOAD_TEX_0_SHIFT      16
576b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
586b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
596b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell/* State structure offsets - these will probably disappear.
606b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell */
616b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define I915_DESTREG_CBUFADDR0 0
626b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define I915_DESTREG_CBUFADDR1 1
636b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define I915_DESTREG_DBUFADDR0 3
646b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define I915_DESTREG_DBUFADDR1 4
656b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define I915_DESTREG_DV0 6
666b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define I915_DESTREG_DV1 7
676b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define I915_DESTREG_SENABLE 8
686b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define I915_DESTREG_SR0 9
696b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define I915_DESTREG_SR1 10
706b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define I915_DESTREG_SR2 11
710cade4de4f74f6b0e86fb6622e2fc370c73fd840Eric Anholt#define I915_DESTREG_DRAWRECT0 12
720cade4de4f74f6b0e86fb6622e2fc370c73fd840Eric Anholt#define I915_DESTREG_DRAWRECT1 13
730cade4de4f74f6b0e86fb6622e2fc370c73fd840Eric Anholt#define I915_DESTREG_DRAWRECT2 14
740cade4de4f74f6b0e86fb6622e2fc370c73fd840Eric Anholt#define I915_DESTREG_DRAWRECT3 15
750cade4de4f74f6b0e86fb6622e2fc370c73fd840Eric Anholt#define I915_DESTREG_DRAWRECT4 16
760cade4de4f74f6b0e86fb6622e2fc370c73fd840Eric Anholt#define I915_DESTREG_DRAWRECT5 17
770cade4de4f74f6b0e86fb6622e2fc370c73fd840Eric Anholt#define I915_DEST_SETUP_SIZE 18
786b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
796b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define I915_CTXREG_STATE4		0
807c97e288fb6a105ea60c377aef4472cc33ca01bcChris Wilson#define I915_CTXREG_LI			1
817c97e288fb6a105ea60c377aef4472cc33ca01bcChris Wilson#define I915_CTXREG_LIS2		2
827c97e288fb6a105ea60c377aef4472cc33ca01bcChris Wilson#define I915_CTXREG_LIS4		3
837c97e288fb6a105ea60c377aef4472cc33ca01bcChris Wilson#define I915_CTXREG_LIS5		4
847c97e288fb6a105ea60c377aef4472cc33ca01bcChris Wilson#define I915_CTXREG_LIS6		5
857c97e288fb6a105ea60c377aef4472cc33ca01bcChris Wilson#define I915_CTXREG_BF_STENCIL_OPS	6
867c97e288fb6a105ea60c377aef4472cc33ca01bcChris Wilson#define I915_CTXREG_BF_STENCIL_MASKS	7
877c97e288fb6a105ea60c377aef4472cc33ca01bcChris Wilson#define I915_CTX_SETUP_SIZE		8
887c97e288fb6a105ea60c377aef4472cc33ca01bcChris Wilson
897c97e288fb6a105ea60c377aef4472cc33ca01bcChris Wilson#define I915_BLENDREG_IAB		0
907c97e288fb6a105ea60c377aef4472cc33ca01bcChris Wilson#define I915_BLENDREG_BLENDCOLOR0	1
917c97e288fb6a105ea60c377aef4472cc33ca01bcChris Wilson#define I915_BLENDREG_BLENDCOLOR1	2
927c97e288fb6a105ea60c377aef4472cc33ca01bcChris Wilson#define I915_BLEND_SETUP_SIZE		3
936b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
946b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define I915_STPREG_ST0        0
956b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define I915_STPREG_ST1        1
966b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define I915_STP_SETUP_SIZE    2
976b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
986b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define I915_TEXREG_MS3        1
996b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define I915_TEXREG_MS4        2
1006b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define I915_TEXREG_SS2        3
1016b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define I915_TEXREG_SS3        4
1026b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define I915_TEXREG_SS4        5
1036b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define I915_TEX_SETUP_SIZE    6
1046b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
1056b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define I915_DEFREG_C0    0
1066b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define I915_DEFREG_C1    1
1076b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define I915_DEFREG_S0    2
1086b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define I915_DEFREG_S1    3
1096b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define I915_DEFREG_Z0    4
1106b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define I915_DEFREG_Z1    5
1116b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define I915_DEF_SETUP_SIZE    6
1126b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
113de80eeea0eebf00ee678b1a0fbd5fe67b00a8636Eric Anholtenum {
114de80eeea0eebf00ee678b1a0fbd5fe67b00a8636Eric Anholt   I915_RASTER_RULES,
115de80eeea0eebf00ee678b1a0fbd5fe67b00a8636Eric Anholt   I915_RASTER_RULES_SETUP_SIZE,
116de80eeea0eebf00ee678b1a0fbd5fe67b00a8636Eric Anholt};
1176b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
1186b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define I915_MAX_CONSTANT      32
1196b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define I915_CONSTANT_SIZE     (2+(4*I915_MAX_CONSTANT))
1206b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
1212c6793fb6bc89df16c23f727bcb072a157ab8d10Chris Wilson#define I915_MAX_TEX_INDIRECT 4
1222c6793fb6bc89df16c23f727bcb072a157ab8d10Chris Wilson#define I915_MAX_TEX_INSN     32
1232c6793fb6bc89df16c23f727bcb072a157ab8d10Chris Wilson#define I915_MAX_ALU_INSN     64
1242c6793fb6bc89df16c23f727bcb072a157ab8d10Chris Wilson#define I915_MAX_DECL_INSN    27
1252c6793fb6bc89df16c23f727bcb072a157ab8d10Chris Wilson#define I915_MAX_TEMPORARY    16
1262c6793fb6bc89df16c23f727bcb072a157ab8d10Chris Wilson
12796a3c69d48bb7c021181e061d010cca08198ae4cEric Anholt#define I915_MAX_INSN          (I915_MAX_DECL_INSN + \
12896a3c69d48bb7c021181e061d010cca08198ae4cEric Anholt				I915_MAX_TEX_INSN + \
12996a3c69d48bb7c021181e061d010cca08198ae4cEric Anholt				I915_MAX_ALU_INSN)
1306b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
13196a3c69d48bb7c021181e061d010cca08198ae4cEric Anholt/* Maximum size of the program packet, which matches the limits on
13296a3c69d48bb7c021181e061d010cca08198ae4cEric Anholt * decl, tex, and ALU instructions.
13396a3c69d48bb7c021181e061d010cca08198ae4cEric Anholt */
13496a3c69d48bb7c021181e061d010cca08198ae4cEric Anholt#define I915_PROGRAM_SIZE      (I915_MAX_INSN * 3 + 1)
1356b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
1366b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell/* Hardware version of a parsed fragment program.  "Derived" from the
1376b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * mesa fragment_program struct.
1386b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell */
1396b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellstruct i915_fragment_program
1406b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell{
1416b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   struct gl_fragment_program FragProg;
1426b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
1432e5a1a254ed81b1d3efa6064f48183eefac784d0Kenneth Graunke   bool translated;
1442e5a1a254ed81b1d3efa6064f48183eefac784d0Kenneth Graunke   bool params_uptodate;
1452e5a1a254ed81b1d3efa6064f48183eefac784d0Kenneth Graunke   bool on_hardware;
1462e5a1a254ed81b1d3efa6064f48183eefac784d0Kenneth Graunke   bool error;             /* If program is malformed for any reason. */
1476b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
14891d0020eecb78ef2984fd0afafc5d555c0e957d8Eric Anholt   /** Record of which phases R registers were last written in. */
14991d0020eecb78ef2984fd0afafc5d555c0e957d8Eric Anholt   GLuint register_phases[16];
15091d0020eecb78ef2984fd0afafc5d555c0e957d8Eric Anholt   GLuint indirections;
1516b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   GLuint nr_tex_indirect;
1526b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   GLuint nr_tex_insn;
1536b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   GLuint nr_alu_insn;
1546b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   GLuint nr_decl_insn;
1556b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
1566b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
1576b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
1586b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
1596b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   /* TODO: split between the stored representation of a program and
1606b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell    * the state used to build that representation.
1616b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell    */
162f9995b30756140724f41daf963fa06167912be7fKristian Høgsberg   struct gl_context *ctx;
1636b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
16496a3c69d48bb7c021181e061d010cca08198ae4cEric Anholt   /* declarations contains the packet header. */
16596a3c69d48bb7c021181e061d010cca08198ae4cEric Anholt   GLuint declarations[I915_MAX_DECL_INSN * 3 + 1];
16696a3c69d48bb7c021181e061d010cca08198ae4cEric Anholt   GLuint program[(I915_MAX_TEX_INSN + I915_MAX_ALU_INSN) * 3];
1676b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
1686b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   GLfloat constant[I915_MAX_CONSTANT][4];
1696b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   GLuint constant_flags[I915_MAX_CONSTANT];
1706b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   GLuint nr_constants;
1716b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
1726b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   GLuint *csr;                 /* Cursor, points into program.
1736b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                 */
1746b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
1756b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   GLuint *decl;                /* Cursor, points into declarations.
1766b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                 */
1776b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
1786b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   GLuint decl_s;               /* flags for which s regs need to be decl'd */
1796b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   GLuint decl_t;               /* flags for which t regs need to be decl'd */
1806b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
1816b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   GLuint temp_flag;            /* Tracks temporary regs which are in
1826b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                 * use.
1836b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                 */
1846b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
1856b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   GLuint utemp_flag;           /* Tracks TYPE_U temporary regs which are in
1866b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                 * use.
1876b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                                 */
1886b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
1896b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
1903369cd9a6f943365242d7832e69788d4aede9a8fXiang, Haihao   /* Track which R registers are "live" for each instruction.
1913369cd9a6f943365242d7832e69788d4aede9a8fXiang, Haihao    * A register is live between the time it's written to and the last time
1923369cd9a6f943365242d7832e69788d4aede9a8fXiang, Haihao    * it's read. */
1933369cd9a6f943365242d7832e69788d4aede9a8fXiang, Haihao   GLuint usedRegs[I915_MAX_INSN];
1946b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
1956b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   /* Helpers for i915_fragprog.c:
1966b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell    */
1976b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   GLuint wpos_tex;
1982e5a1a254ed81b1d3efa6064f48183eefac784d0Kenneth Graunke   bool depth_written;
1996b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
2006b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   struct
2016b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   {
2026b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      GLuint reg;               /* Hardware constant idx */
2036b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      const GLfloat *values;    /* Pointer to tracked values */
2046b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   } param[I915_MAX_CONSTANT];
2056b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   GLuint nr_params;
2066b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell};
2076b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
2086b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
2096b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
2106b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
2116b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
2126b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
2136b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
2146b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define I915_TEX_UNITS 8
2156b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
2166b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
2176b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellstruct i915_hw_state
2186b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell{
2196b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   GLuint Ctx[I915_CTX_SETUP_SIZE];
2207c97e288fb6a105ea60c377aef4472cc33ca01bcChris Wilson   GLuint Blend[I915_BLEND_SETUP_SIZE];
2216b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   GLuint Buffer[I915_DEST_SETUP_SIZE];
2226b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   GLuint Stipple[I915_STP_SETUP_SIZE];
2236b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   GLuint Defaults[I915_DEF_SETUP_SIZE];
224de80eeea0eebf00ee678b1a0fbd5fe67b00a8636Eric Anholt   GLuint RasterRules[I915_RASTER_RULES_SETUP_SIZE];
2256b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   GLuint Tex[I915_TEX_UNITS][I915_TEX_SETUP_SIZE];
2266b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   GLuint Constant[I915_CONSTANT_SIZE];
2276b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   GLuint ConstantSize;
2286b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   GLuint Program[I915_PROGRAM_SIZE];
2296b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   GLuint ProgramSize;
2306b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
2316b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   /* Region pointers for relocation:
2326b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell    */
2336b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   struct intel_region *draw_region;
2346b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   struct intel_region *depth_region;
2356b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell/*    struct intel_region *tex_region[I915_TEX_UNITS]; */
2366b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
2376b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   /* Regions aren't actually that appropriate here as the memory may
238cfc21190af1038f204d38ab4764a9c731b0323a5Eric Anholt    * be from a PBO or FBO.  Will have to do this for draw and depth for
239cfc21190af1038f204d38ab4764a9c731b0323a5Eric Anholt    * FBO's...
2406b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell    */
24134474fa4119378ef9fbb9fb557cc19c0a1ca1f7eEric Anholt   drm_intel_bo *tex_buffer[I915_TEX_UNITS];
2426b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   GLuint tex_offset[I915_TEX_UNITS];
2436b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
2446b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
2456b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   GLuint active;               /* I915_UPLOAD_* */
2466b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   GLuint emitted;              /* I915_UPLOAD_* */
2476b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell};
2486b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
2496b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellstruct i915_context
2506b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell{
2516b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   struct intel_context intel;
2526b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
2536b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   GLuint last_ReallyEnabled;
2546b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   GLuint lodbias_ss2[MAX_TEXTURE_UNITS];
2556b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
2566b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
2576b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   struct i915_fragment_program *current_program;
2586b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
2592c6793fb6bc89df16c23f727bcb072a157ab8d10Chris Wilson   drm_intel_bo *current_vb_bo;
2602c6793fb6bc89df16c23f727bcb072a157ab8d10Chris Wilson   unsigned int current_vertex_size;
2612c6793fb6bc89df16c23f727bcb072a157ab8d10Chris Wilson
262c9886d535e4ac5ae108b1015a9682f4ddd297536Eric Anholt   struct i915_hw_state state;
2636d741627b00677d269537ad36e5f2ecd31fd98b5Chris Wilson   uint32_t last_draw_offset;
2640b0cad38c57fbe59710cb4058866b2e68f6d471aChris Wilson   GLuint last_sampler;
2656b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell};
2666b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
2676b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
2686b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define I915_STATECHANGE(i915, flag)					\
2696b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwelldo {									\
2706b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   INTEL_FIREVERTICES( &(i915)->intel );					\
2716b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   (i915)->state.emitted &= ~(flag);					\
2726b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell} while (0)
2736b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
2746b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define I915_ACTIVESTATE(i915, flag, mode)			\
2756b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwelldo {								\
2766b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   INTEL_FIREVERTICES( &(i915)->intel );				\
2776b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   if (mode)							\
2786b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      (i915)->state.active |= (flag);				\
2796b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   else								\
2806b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell      (i915)->state.active &= ~(flag);				\
2816b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell} while (0)
2826b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
2836b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
2846b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell/*======================================================================
2856b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * i915_vtbl.c
2866b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell */
2876b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellextern void i915InitVtbl(struct i915_context *i915);
2886b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
2896b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellextern void
2906b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwelli915_state_draw_region(struct intel_context *intel,
2916b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                       struct i915_hw_state *state,
2926b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                       struct intel_region *color_region,
2936b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell                       struct intel_region *depth_region);
2946b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
2956b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
2966b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
2976b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define SZ_TO_HW(sz)  ((sz-2)&0x3)
2986b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define EMIT_SZ(sz)   (EMIT_1F + (sz) - 1)
2996b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define EMIT_ATTR( ATTR, STYLE, S4, SZ )				\
3006b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwelldo {									\
3016b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   intel->vertex_attrs[intel->vertex_attr_count].attrib = (ATTR);	\
3026b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   intel->vertex_attrs[intel->vertex_attr_count].format = (STYLE);	\
3036b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   s4 |= S4;								\
3046b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   intel->vertex_attr_count++;						\
3056b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   offset += (SZ);							\
3066b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell} while (0)
3076b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
3086b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define EMIT_PAD( N )							\
3096b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwelldo {									\
3106b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   intel->vertex_attrs[intel->vertex_attr_count].attrib = 0;		\
3116b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   intel->vertex_attrs[intel->vertex_attr_count].format = EMIT_PAD;	\
3126b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   intel->vertex_attrs[intel->vertex_attr_count].offset = (N);		\
3136b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   intel->vertex_attr_count++;						\
3146b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   offset += (N);							\
3156b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell} while (0)
3166b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
3176b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
3186b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
3196b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell/*======================================================================
3206b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * i915_context.c
3216b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell */
3222e5a1a254ed81b1d3efa6064f48183eefac784d0Kenneth Graunkeextern bool i915CreateContext(int api,
3232e5a1a254ed81b1d3efa6064f48183eefac784d0Kenneth Graunke			      const struct gl_config * mesaVis,
3242e5a1a254ed81b1d3efa6064f48183eefac784d0Kenneth Graunke			      __DRIcontext * driContextPriv,
325db273724c9484d513f5caa34729475d2873d9f7bIan Romanick                              unsigned major_version,
326db273724c9484d513f5caa34729475d2873d9f7bIan Romanick                              unsigned minor_version,
327db273724c9484d513f5caa34729475d2873d9f7bIan Romanick                              unsigned *error,
3282e5a1a254ed81b1d3efa6064f48183eefac784d0Kenneth Graunke			      void *sharedContextPrivate);
3296b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
3306b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
3316b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell/*======================================================================
3326b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * i915_debug.c
3336b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell */
3346b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellextern void i915_disassemble_program(const GLuint * program, GLuint sz);
3356b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellextern void i915_print_ureg(const char *msg, GLuint ureg);
3366b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
3376b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
3386b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell/*======================================================================
3396b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * i915_state.c
3406b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell */
3416b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellextern void i915InitStateFunctions(struct dd_function_table *functions);
3426b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellextern void i915InitState(struct i915_context *i915);
343f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergextern void i915_update_stencil(struct gl_context * ctx);
344f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergextern void i915_update_provoking_vertex(struct gl_context *ctx);
345c6532875493ffe7de9c37924c70ebf6d0472e23dYuanhan Liuextern void i915_update_sprite_point_enable(struct gl_context *ctx);
3466b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
3476b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
3486b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell/*======================================================================
3496b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * i915_tex.c
3506b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell */
3516b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellextern void i915UpdateTextureState(struct intel_context *intel);
3526b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellextern void i915InitTextureFuncs(struct dd_function_table *functions);
3536b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
3546b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell/*======================================================================
3556b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * i915_fragprog.c
3566b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell */
3576b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellextern void i915ValidateFragmentProgram(struct i915_context *i915);
3586b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellextern void i915InitFragProgFuncs(struct dd_function_table *functions);
3596b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
3606b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell/*======================================================================
3616b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * Inline conversion functions.  These are better-typed than the
3626b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell * macros used previously:
3636b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell */
3646b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwellstatic INLINE struct i915_context *
365f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergi915_context(struct gl_context * ctx)
3666b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell{
3676b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell   return (struct i915_context *) ctx;
3686b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell}
3696b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
3706b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
3716b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
3726b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#define I915_CONTEXT(ctx)	i915_context(ctx)
3736b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
3746b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
3756b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell
3766b9e31f3eb3dbe20cbc8493b963bbc6530e392c6Keith Whitwell#endif
377