162306a36Sopenharmony_ci/*
262306a36Sopenharmony_ci * Copyright 2005 Nicolai Haehnle et al.
362306a36Sopenharmony_ci * Copyright 2008 Advanced Micro Devices, Inc.
462306a36Sopenharmony_ci * Copyright 2009 Jerome Glisse.
562306a36Sopenharmony_ci *
662306a36Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
762306a36Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
862306a36Sopenharmony_ci * to deal in the Software without restriction, including without limitation
962306a36Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
1062306a36Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
1162306a36Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
1262306a36Sopenharmony_ci *
1362306a36Sopenharmony_ci * The above copyright notice and this permission notice shall be included in
1462306a36Sopenharmony_ci * all copies or substantial portions of the Software.
1562306a36Sopenharmony_ci *
1662306a36Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1762306a36Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1862306a36Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
1962306a36Sopenharmony_ci * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
2062306a36Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
2162306a36Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
2262306a36Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE.
2362306a36Sopenharmony_ci *
2462306a36Sopenharmony_ci * Authors: Nicolai Haehnle
2562306a36Sopenharmony_ci *          Jerome Glisse
2662306a36Sopenharmony_ci */
2762306a36Sopenharmony_ci#ifndef _R300_REG_H_
2862306a36Sopenharmony_ci#define _R300_REG_H_
2962306a36Sopenharmony_ci
3062306a36Sopenharmony_ci#define R300_SURF_TILE_MACRO (1<<16)
3162306a36Sopenharmony_ci#define R300_SURF_TILE_MICRO (2<<16)
3262306a36Sopenharmony_ci#define R300_SURF_TILE_BOTH (3<<16)
3362306a36Sopenharmony_ci
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ci#define R300_MC_INIT_MISC_LAT_TIMER	0x180
3662306a36Sopenharmony_ci#	define R300_MC_MISC__MC_CPR_INIT_LAT_SHIFT	0
3762306a36Sopenharmony_ci#	define R300_MC_MISC__MC_VF_INIT_LAT_SHIFT	4
3862306a36Sopenharmony_ci#	define R300_MC_MISC__MC_DISP0R_INIT_LAT_SHIFT	8
3962306a36Sopenharmony_ci#	define R300_MC_MISC__MC_DISP1R_INIT_LAT_SHIFT	12
4062306a36Sopenharmony_ci#	define R300_MC_MISC__MC_FIXED_INIT_LAT_SHIFT	16
4162306a36Sopenharmony_ci#	define R300_MC_MISC__MC_E2R_INIT_LAT_SHIFT	20
4262306a36Sopenharmony_ci#	define R300_MC_MISC__MC_SAME_PAGE_PRIO_SHIFT	24
4362306a36Sopenharmony_ci#	define R300_MC_MISC__MC_GLOBW_INIT_LAT_SHIFT	28
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_ci#define R300_MC_INIT_GFX_LAT_TIMER	0x154
4662306a36Sopenharmony_ci#	define R300_MC_MISC__MC_G3D0R_INIT_LAT_SHIFT	0
4762306a36Sopenharmony_ci#	define R300_MC_MISC__MC_G3D1R_INIT_LAT_SHIFT	4
4862306a36Sopenharmony_ci#	define R300_MC_MISC__MC_G3D2R_INIT_LAT_SHIFT	8
4962306a36Sopenharmony_ci#	define R300_MC_MISC__MC_G3D3R_INIT_LAT_SHIFT	12
5062306a36Sopenharmony_ci#	define R300_MC_MISC__MC_TX0R_INIT_LAT_SHIFT	16
5162306a36Sopenharmony_ci#	define R300_MC_MISC__MC_TX1R_INIT_LAT_SHIFT	20
5262306a36Sopenharmony_ci#	define R300_MC_MISC__MC_GLOBR_INIT_LAT_SHIFT	24
5362306a36Sopenharmony_ci#	define R300_MC_MISC__MC_GLOBW_FULL_LAT_SHIFT	28
5462306a36Sopenharmony_ci
5562306a36Sopenharmony_ci/*
5662306a36Sopenharmony_ci * This file contains registers and constants for the R300. They have been
5762306a36Sopenharmony_ci * found mostly by examining command buffers captured using glxtest, as well
5862306a36Sopenharmony_ci * as by extrapolating some known registers and constants from the R200.
5962306a36Sopenharmony_ci * I am fairly certain that they are correct unless stated otherwise
6062306a36Sopenharmony_ci * in comments.
6162306a36Sopenharmony_ci */
6262306a36Sopenharmony_ci
6362306a36Sopenharmony_ci#define R300_SE_VPORT_XSCALE                0x1D98
6462306a36Sopenharmony_ci#define R300_SE_VPORT_XOFFSET               0x1D9C
6562306a36Sopenharmony_ci#define R300_SE_VPORT_YSCALE                0x1DA0
6662306a36Sopenharmony_ci#define R300_SE_VPORT_YOFFSET               0x1DA4
6762306a36Sopenharmony_ci#define R300_SE_VPORT_ZSCALE                0x1DA8
6862306a36Sopenharmony_ci#define R300_SE_VPORT_ZOFFSET               0x1DAC
6962306a36Sopenharmony_ci
7062306a36Sopenharmony_ci
7162306a36Sopenharmony_ci/*
7262306a36Sopenharmony_ci * Vertex Array Processing (VAP) Control
7362306a36Sopenharmony_ci * Stolen from r200 code from Christoph Brill (It's a guess!)
7462306a36Sopenharmony_ci */
7562306a36Sopenharmony_ci#define R300_VAP_CNTL	0x2080
7662306a36Sopenharmony_ci
7762306a36Sopenharmony_ci/* This register is written directly and also starts data section
7862306a36Sopenharmony_ci * in many 3d CP_PACKET3's
7962306a36Sopenharmony_ci */
8062306a36Sopenharmony_ci#define R300_VAP_VF_CNTL	0x2084
8162306a36Sopenharmony_ci#	define	R300_VAP_VF_CNTL__PRIM_TYPE__SHIFT              0
8262306a36Sopenharmony_ci#	define  R300_VAP_VF_CNTL__PRIM_NONE                     (0<<0)
8362306a36Sopenharmony_ci#	define  R300_VAP_VF_CNTL__PRIM_POINTS                   (1<<0)
8462306a36Sopenharmony_ci#	define  R300_VAP_VF_CNTL__PRIM_LINES                    (2<<0)
8562306a36Sopenharmony_ci#	define  R300_VAP_VF_CNTL__PRIM_LINE_STRIP               (3<<0)
8662306a36Sopenharmony_ci#	define  R300_VAP_VF_CNTL__PRIM_TRIANGLES                (4<<0)
8762306a36Sopenharmony_ci#	define  R300_VAP_VF_CNTL__PRIM_TRIANGLE_FAN             (5<<0)
8862306a36Sopenharmony_ci#	define  R300_VAP_VF_CNTL__PRIM_TRIANGLE_STRIP           (6<<0)
8962306a36Sopenharmony_ci#	define  R300_VAP_VF_CNTL__PRIM_LINE_LOOP                (12<<0)
9062306a36Sopenharmony_ci#	define  R300_VAP_VF_CNTL__PRIM_QUADS                    (13<<0)
9162306a36Sopenharmony_ci#	define  R300_VAP_VF_CNTL__PRIM_QUAD_STRIP               (14<<0)
9262306a36Sopenharmony_ci#	define  R300_VAP_VF_CNTL__PRIM_POLYGON                  (15<<0)
9362306a36Sopenharmony_ci
9462306a36Sopenharmony_ci#	define	R300_VAP_VF_CNTL__PRIM_WALK__SHIFT              4
9562306a36Sopenharmony_ci	/* State based - direct writes to registers trigger vertex
9662306a36Sopenharmony_ci           generation */
9762306a36Sopenharmony_ci#	define	R300_VAP_VF_CNTL__PRIM_WALK_STATE_BASED         (0<<4)
9862306a36Sopenharmony_ci#	define	R300_VAP_VF_CNTL__PRIM_WALK_INDICES             (1<<4)
9962306a36Sopenharmony_ci#	define	R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_LIST         (2<<4)
10062306a36Sopenharmony_ci#	define	R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_EMBEDDED     (3<<4)
10162306a36Sopenharmony_ci
10262306a36Sopenharmony_ci	/* I don't think I saw these three used.. */
10362306a36Sopenharmony_ci#	define	R300_VAP_VF_CNTL__COLOR_ORDER__SHIFT            6
10462306a36Sopenharmony_ci#	define	R300_VAP_VF_CNTL__TCL_OUTPUT_CTL_ENA__SHIFT     9
10562306a36Sopenharmony_ci#	define	R300_VAP_VF_CNTL__PROG_STREAM_ENA__SHIFT        10
10662306a36Sopenharmony_ci
10762306a36Sopenharmony_ci	/* index size - when not set the indices are assumed to be 16 bit */
10862306a36Sopenharmony_ci#	define	R300_VAP_VF_CNTL__INDEX_SIZE_32bit              (1<<11)
10962306a36Sopenharmony_ci	/* number of vertices */
11062306a36Sopenharmony_ci#	define	R300_VAP_VF_CNTL__NUM_VERTICES__SHIFT           16
11162306a36Sopenharmony_ci
11262306a36Sopenharmony_ci/* BEGIN: Wild guesses */
11362306a36Sopenharmony_ci#define R300_VAP_OUTPUT_VTX_FMT_0           0x2090
11462306a36Sopenharmony_ci#       define R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT     (1<<0)
11562306a36Sopenharmony_ci#       define R300_VAP_OUTPUT_VTX_FMT_0__COLOR_PRESENT   (1<<1)
11662306a36Sopenharmony_ci#       define R300_VAP_OUTPUT_VTX_FMT_0__COLOR_1_PRESENT (1<<2)  /* GUESS */
11762306a36Sopenharmony_ci#       define R300_VAP_OUTPUT_VTX_FMT_0__COLOR_2_PRESENT (1<<3)  /* GUESS */
11862306a36Sopenharmony_ci#       define R300_VAP_OUTPUT_VTX_FMT_0__COLOR_3_PRESENT (1<<4)  /* GUESS */
11962306a36Sopenharmony_ci#       define R300_VAP_OUTPUT_VTX_FMT_0__PT_SIZE_PRESENT (1<<16) /* GUESS */
12062306a36Sopenharmony_ci
12162306a36Sopenharmony_ci#define R300_VAP_OUTPUT_VTX_FMT_1           0x2094
12262306a36Sopenharmony_ci	/* each of the following is 3 bits wide, specifies number
12362306a36Sopenharmony_ci	   of components */
12462306a36Sopenharmony_ci#       define R300_VAP_OUTPUT_VTX_FMT_1__TEX_0_COMP_CNT_SHIFT 0
12562306a36Sopenharmony_ci#       define R300_VAP_OUTPUT_VTX_FMT_1__TEX_1_COMP_CNT_SHIFT 3
12662306a36Sopenharmony_ci#       define R300_VAP_OUTPUT_VTX_FMT_1__TEX_2_COMP_CNT_SHIFT 6
12762306a36Sopenharmony_ci#       define R300_VAP_OUTPUT_VTX_FMT_1__TEX_3_COMP_CNT_SHIFT 9
12862306a36Sopenharmony_ci#       define R300_VAP_OUTPUT_VTX_FMT_1__TEX_4_COMP_CNT_SHIFT 12
12962306a36Sopenharmony_ci#       define R300_VAP_OUTPUT_VTX_FMT_1__TEX_5_COMP_CNT_SHIFT 15
13062306a36Sopenharmony_ci#       define R300_VAP_OUTPUT_VTX_FMT_1__TEX_6_COMP_CNT_SHIFT 18
13162306a36Sopenharmony_ci#       define R300_VAP_OUTPUT_VTX_FMT_1__TEX_7_COMP_CNT_SHIFT 21
13262306a36Sopenharmony_ci/* END: Wild guesses */
13362306a36Sopenharmony_ci
13462306a36Sopenharmony_ci#define R300_SE_VTE_CNTL                  0x20b0
13562306a36Sopenharmony_ci#	define     R300_VPORT_X_SCALE_ENA                0x00000001
13662306a36Sopenharmony_ci#	define     R300_VPORT_X_OFFSET_ENA               0x00000002
13762306a36Sopenharmony_ci#	define     R300_VPORT_Y_SCALE_ENA                0x00000004
13862306a36Sopenharmony_ci#	define     R300_VPORT_Y_OFFSET_ENA               0x00000008
13962306a36Sopenharmony_ci#	define     R300_VPORT_Z_SCALE_ENA                0x00000010
14062306a36Sopenharmony_ci#	define     R300_VPORT_Z_OFFSET_ENA               0x00000020
14162306a36Sopenharmony_ci#	define     R300_VTX_XY_FMT                       0x00000100
14262306a36Sopenharmony_ci#	define     R300_VTX_Z_FMT                        0x00000200
14362306a36Sopenharmony_ci#	define     R300_VTX_W0_FMT                       0x00000400
14462306a36Sopenharmony_ci#	define     R300_VTX_W0_NORMALIZE                 0x00000800
14562306a36Sopenharmony_ci#	define     R300_VTX_ST_DENORMALIZED              0x00001000
14662306a36Sopenharmony_ci
14762306a36Sopenharmony_ci/* BEGIN: Vertex data assembly - lots of uncertainties */
14862306a36Sopenharmony_ci
14962306a36Sopenharmony_ci/* gap */
15062306a36Sopenharmony_ci
15162306a36Sopenharmony_ci#define R300_VAP_CNTL_STATUS              0x2140
15262306a36Sopenharmony_ci#	define R300_VC_NO_SWAP                  (0 << 0)
15362306a36Sopenharmony_ci#	define R300_VC_16BIT_SWAP               (1 << 0)
15462306a36Sopenharmony_ci#	define R300_VC_32BIT_SWAP               (2 << 0)
15562306a36Sopenharmony_ci#	define R300_VAP_TCL_BYPASS		(1 << 8)
15662306a36Sopenharmony_ci
15762306a36Sopenharmony_ci/* gap */
15862306a36Sopenharmony_ci
15962306a36Sopenharmony_ci/* Where do we get our vertex data?
16062306a36Sopenharmony_ci *
16162306a36Sopenharmony_ci * Vertex data either comes either from immediate mode registers or from
16262306a36Sopenharmony_ci * vertex arrays.
16362306a36Sopenharmony_ci * There appears to be no mixed mode (though we can force the pitch of
16462306a36Sopenharmony_ci * vertex arrays to 0, effectively reusing the same element over and over
16562306a36Sopenharmony_ci * again).
16662306a36Sopenharmony_ci *
16762306a36Sopenharmony_ci * Immediate mode is controlled by the INPUT_CNTL registers. I am not sure
16862306a36Sopenharmony_ci * if these registers influence vertex array processing.
16962306a36Sopenharmony_ci *
17062306a36Sopenharmony_ci * Vertex arrays are controlled via the 3D_LOAD_VBPNTR packet3.
17162306a36Sopenharmony_ci *
17262306a36Sopenharmony_ci * In both cases, vertex attributes are then passed through INPUT_ROUTE.
17362306a36Sopenharmony_ci *
17462306a36Sopenharmony_ci * Beginning with INPUT_ROUTE_0_0 is a list of WORDs that route vertex data
17562306a36Sopenharmony_ci * into the vertex processor's input registers.
17662306a36Sopenharmony_ci * The first word routes the first input, the second word the second, etc.
17762306a36Sopenharmony_ci * The corresponding input is routed into the register with the given index.
17862306a36Sopenharmony_ci * The list is ended by a word with INPUT_ROUTE_END set.
17962306a36Sopenharmony_ci *
18062306a36Sopenharmony_ci * Always set COMPONENTS_4 in immediate mode.
18162306a36Sopenharmony_ci */
18262306a36Sopenharmony_ci
18362306a36Sopenharmony_ci#define R300_VAP_INPUT_ROUTE_0_0            0x2150
18462306a36Sopenharmony_ci#       define R300_INPUT_ROUTE_COMPONENTS_1     (0 << 0)
18562306a36Sopenharmony_ci#       define R300_INPUT_ROUTE_COMPONENTS_2     (1 << 0)
18662306a36Sopenharmony_ci#       define R300_INPUT_ROUTE_COMPONENTS_3     (2 << 0)
18762306a36Sopenharmony_ci#       define R300_INPUT_ROUTE_COMPONENTS_4     (3 << 0)
18862306a36Sopenharmony_ci#       define R300_INPUT_ROUTE_COMPONENTS_RGBA  (4 << 0) /* GUESS */
18962306a36Sopenharmony_ci#       define R300_VAP_INPUT_ROUTE_IDX_SHIFT    8
19062306a36Sopenharmony_ci#       define R300_VAP_INPUT_ROUTE_IDX_MASK     (31 << 8) /* GUESS */
19162306a36Sopenharmony_ci#       define R300_VAP_INPUT_ROUTE_END          (1 << 13)
19262306a36Sopenharmony_ci#       define R300_INPUT_ROUTE_IMMEDIATE_MODE   (0 << 14) /* GUESS */
19362306a36Sopenharmony_ci#       define R300_INPUT_ROUTE_FLOAT            (1 << 14) /* GUESS */
19462306a36Sopenharmony_ci#       define R300_INPUT_ROUTE_UNSIGNED_BYTE    (2 << 14) /* GUESS */
19562306a36Sopenharmony_ci#       define R300_INPUT_ROUTE_FLOAT_COLOR      (3 << 14) /* GUESS */
19662306a36Sopenharmony_ci#define R300_VAP_INPUT_ROUTE_0_1            0x2154
19762306a36Sopenharmony_ci#define R300_VAP_INPUT_ROUTE_0_2            0x2158
19862306a36Sopenharmony_ci#define R300_VAP_INPUT_ROUTE_0_3            0x215C
19962306a36Sopenharmony_ci#define R300_VAP_INPUT_ROUTE_0_4            0x2160
20062306a36Sopenharmony_ci#define R300_VAP_INPUT_ROUTE_0_5            0x2164
20162306a36Sopenharmony_ci#define R300_VAP_INPUT_ROUTE_0_6            0x2168
20262306a36Sopenharmony_ci#define R300_VAP_INPUT_ROUTE_0_7            0x216C
20362306a36Sopenharmony_ci
20462306a36Sopenharmony_ci/* gap */
20562306a36Sopenharmony_ci
20662306a36Sopenharmony_ci/* Notes:
20762306a36Sopenharmony_ci *  - always set up to produce at least two attributes:
20862306a36Sopenharmony_ci *    if vertex program uses only position, fglrx will set normal, too
20962306a36Sopenharmony_ci *  - INPUT_CNTL_0_COLOR and INPUT_CNTL_COLOR bits are always equal.
21062306a36Sopenharmony_ci */
21162306a36Sopenharmony_ci#define R300_VAP_INPUT_CNTL_0               0x2180
21262306a36Sopenharmony_ci#       define R300_INPUT_CNTL_0_COLOR           0x00000001
21362306a36Sopenharmony_ci#define R300_VAP_INPUT_CNTL_1               0x2184
21462306a36Sopenharmony_ci#       define R300_INPUT_CNTL_POS               0x00000001
21562306a36Sopenharmony_ci#       define R300_INPUT_CNTL_NORMAL            0x00000002
21662306a36Sopenharmony_ci#       define R300_INPUT_CNTL_COLOR             0x00000004
21762306a36Sopenharmony_ci#       define R300_INPUT_CNTL_TC0               0x00000400
21862306a36Sopenharmony_ci#       define R300_INPUT_CNTL_TC1               0x00000800
21962306a36Sopenharmony_ci#       define R300_INPUT_CNTL_TC2               0x00001000 /* GUESS */
22062306a36Sopenharmony_ci#       define R300_INPUT_CNTL_TC3               0x00002000 /* GUESS */
22162306a36Sopenharmony_ci#       define R300_INPUT_CNTL_TC4               0x00004000 /* GUESS */
22262306a36Sopenharmony_ci#       define R300_INPUT_CNTL_TC5               0x00008000 /* GUESS */
22362306a36Sopenharmony_ci#       define R300_INPUT_CNTL_TC6               0x00010000 /* GUESS */
22462306a36Sopenharmony_ci#       define R300_INPUT_CNTL_TC7               0x00020000 /* GUESS */
22562306a36Sopenharmony_ci
22662306a36Sopenharmony_ci/* gap */
22762306a36Sopenharmony_ci
22862306a36Sopenharmony_ci/* Words parallel to INPUT_ROUTE_0; All words that are active in INPUT_ROUTE_0
22962306a36Sopenharmony_ci * are set to a swizzling bit pattern, other words are 0.
23062306a36Sopenharmony_ci *
23162306a36Sopenharmony_ci * In immediate mode, the pattern is always set to xyzw. In vertex array
23262306a36Sopenharmony_ci * mode, the swizzling pattern is e.g. used to set zw components in texture
23362306a36Sopenharmony_ci * coordinates with only tweo components.
23462306a36Sopenharmony_ci */
23562306a36Sopenharmony_ci#define R300_VAP_INPUT_ROUTE_1_0            0x21E0
23662306a36Sopenharmony_ci#       define R300_INPUT_ROUTE_SELECT_X    0
23762306a36Sopenharmony_ci#       define R300_INPUT_ROUTE_SELECT_Y    1
23862306a36Sopenharmony_ci#       define R300_INPUT_ROUTE_SELECT_Z    2
23962306a36Sopenharmony_ci#       define R300_INPUT_ROUTE_SELECT_W    3
24062306a36Sopenharmony_ci#       define R300_INPUT_ROUTE_SELECT_ZERO 4
24162306a36Sopenharmony_ci#       define R300_INPUT_ROUTE_SELECT_ONE  5
24262306a36Sopenharmony_ci#       define R300_INPUT_ROUTE_SELECT_MASK 7
24362306a36Sopenharmony_ci#       define R300_INPUT_ROUTE_X_SHIFT     0
24462306a36Sopenharmony_ci#       define R300_INPUT_ROUTE_Y_SHIFT     3
24562306a36Sopenharmony_ci#       define R300_INPUT_ROUTE_Z_SHIFT     6
24662306a36Sopenharmony_ci#       define R300_INPUT_ROUTE_W_SHIFT     9
24762306a36Sopenharmony_ci#       define R300_INPUT_ROUTE_ENABLE      (15 << 12)
24862306a36Sopenharmony_ci#define R300_VAP_INPUT_ROUTE_1_1            0x21E4
24962306a36Sopenharmony_ci#define R300_VAP_INPUT_ROUTE_1_2            0x21E8
25062306a36Sopenharmony_ci#define R300_VAP_INPUT_ROUTE_1_3            0x21EC
25162306a36Sopenharmony_ci#define R300_VAP_INPUT_ROUTE_1_4            0x21F0
25262306a36Sopenharmony_ci#define R300_VAP_INPUT_ROUTE_1_5            0x21F4
25362306a36Sopenharmony_ci#define R300_VAP_INPUT_ROUTE_1_6            0x21F8
25462306a36Sopenharmony_ci#define R300_VAP_INPUT_ROUTE_1_7            0x21FC
25562306a36Sopenharmony_ci
25662306a36Sopenharmony_ci/* END: Vertex data assembly */
25762306a36Sopenharmony_ci
25862306a36Sopenharmony_ci/* gap */
25962306a36Sopenharmony_ci
26062306a36Sopenharmony_ci/* BEGIN: Upload vertex program and data */
26162306a36Sopenharmony_ci
26262306a36Sopenharmony_ci/*
26362306a36Sopenharmony_ci * The programmable vertex shader unit has a memory bank of unknown size
26462306a36Sopenharmony_ci * that can be written to in 16 byte units by writing the address into
26562306a36Sopenharmony_ci * UPLOAD_ADDRESS, followed by data in UPLOAD_DATA (multiples of 4 DWORDs).
26662306a36Sopenharmony_ci *
26762306a36Sopenharmony_ci * Pointers into the memory bank are always in multiples of 16 bytes.
26862306a36Sopenharmony_ci *
26962306a36Sopenharmony_ci * The memory bank is divided into areas with fixed meaning.
27062306a36Sopenharmony_ci *
27162306a36Sopenharmony_ci * Starting at address UPLOAD_PROGRAM: Vertex program instructions.
27262306a36Sopenharmony_ci * Native limits reported by drivers from ATI suggest size 256 (i.e. 4KB),
27362306a36Sopenharmony_ci * whereas the difference between known addresses suggests size 512.
27462306a36Sopenharmony_ci *
27562306a36Sopenharmony_ci * Starting at address UPLOAD_PARAMETERS: Vertex program parameters.
27662306a36Sopenharmony_ci * Native reported limits and the VPI layout suggest size 256, whereas
27762306a36Sopenharmony_ci * difference between known addresses suggests size 512.
27862306a36Sopenharmony_ci *
27962306a36Sopenharmony_ci * At address UPLOAD_POINTSIZE is a vector (0, 0, ps, 0), where ps is the
28062306a36Sopenharmony_ci * floating point pointsize. The exact purpose of this state is uncertain,
28162306a36Sopenharmony_ci * as there is also the R300_RE_POINTSIZE register.
28262306a36Sopenharmony_ci *
28362306a36Sopenharmony_ci * Multiple vertex programs and parameter sets can be loaded at once,
28462306a36Sopenharmony_ci * which could explain the size discrepancy.
28562306a36Sopenharmony_ci */
28662306a36Sopenharmony_ci#define R300_VAP_PVS_UPLOAD_ADDRESS         0x2200
28762306a36Sopenharmony_ci#       define R300_PVS_UPLOAD_PROGRAM           0x00000000
28862306a36Sopenharmony_ci#       define R300_PVS_UPLOAD_PARAMETERS        0x00000200
28962306a36Sopenharmony_ci#       define R300_PVS_UPLOAD_POINTSIZE         0x00000406
29062306a36Sopenharmony_ci
29162306a36Sopenharmony_ci/* gap */
29262306a36Sopenharmony_ci
29362306a36Sopenharmony_ci#define R300_VAP_PVS_UPLOAD_DATA            0x2208
29462306a36Sopenharmony_ci
29562306a36Sopenharmony_ci/* END: Upload vertex program and data */
29662306a36Sopenharmony_ci
29762306a36Sopenharmony_ci/* gap */
29862306a36Sopenharmony_ci
29962306a36Sopenharmony_ci/* I do not know the purpose of this register. However, I do know that
30062306a36Sopenharmony_ci * it is set to 221C_CLEAR for clear operations and to 221C_NORMAL
30162306a36Sopenharmony_ci * for normal rendering.
30262306a36Sopenharmony_ci */
30362306a36Sopenharmony_ci#define R300_VAP_UNKNOWN_221C               0x221C
30462306a36Sopenharmony_ci#       define R300_221C_NORMAL                  0x00000000
30562306a36Sopenharmony_ci#       define R300_221C_CLEAR                   0x0001C000
30662306a36Sopenharmony_ci
30762306a36Sopenharmony_ci/* These seem to be per-pixel and per-vertex X and Y clipping planes. The first
30862306a36Sopenharmony_ci * plane is per-pixel and the second plane is per-vertex.
30962306a36Sopenharmony_ci *
31062306a36Sopenharmony_ci * This was determined by experimentation alone but I believe it is correct.
31162306a36Sopenharmony_ci *
31262306a36Sopenharmony_ci * These registers are called X_QUAD0_1_FL to X_QUAD0_4_FL by glxtest.
31362306a36Sopenharmony_ci */
31462306a36Sopenharmony_ci#define R300_VAP_CLIP_X_0                   0x2220
31562306a36Sopenharmony_ci#define R300_VAP_CLIP_X_1                   0x2224
31662306a36Sopenharmony_ci#define R300_VAP_CLIP_Y_0                   0x2228
31762306a36Sopenharmony_ci#define R300_VAP_CLIP_Y_1                   0x2230
31862306a36Sopenharmony_ci
31962306a36Sopenharmony_ci/* gap */
32062306a36Sopenharmony_ci
32162306a36Sopenharmony_ci/* Sometimes, END_OF_PKT and 0x2284=0 are the only commands sent between
32262306a36Sopenharmony_ci * rendering commands and overwriting vertex program parameters.
32362306a36Sopenharmony_ci * Therefore, I suspect writing zero to 0x2284 synchronizes the engine and
32462306a36Sopenharmony_ci * avoids bugs caused by still running shaders reading bad data from memory.
32562306a36Sopenharmony_ci */
32662306a36Sopenharmony_ci#define R300_VAP_PVS_STATE_FLUSH_REG        0x2284
32762306a36Sopenharmony_ci
32862306a36Sopenharmony_ci/* Absolutely no clue what this register is about. */
32962306a36Sopenharmony_ci#define R300_VAP_UNKNOWN_2288               0x2288
33062306a36Sopenharmony_ci#       define R300_2288_R300                    0x00750000 /* -- nh */
33162306a36Sopenharmony_ci#       define R300_2288_RV350                   0x0000FFFF /* -- Vladimir */
33262306a36Sopenharmony_ci
33362306a36Sopenharmony_ci/* gap */
33462306a36Sopenharmony_ci
33562306a36Sopenharmony_ci/* Addresses are relative to the vertex program instruction area of the
33662306a36Sopenharmony_ci * memory bank. PROGRAM_END points to the last instruction of the active
33762306a36Sopenharmony_ci * program
33862306a36Sopenharmony_ci *
33962306a36Sopenharmony_ci * The meaning of the two UNKNOWN fields is obviously not known. However,
34062306a36Sopenharmony_ci * experiments so far have shown that both *must* point to an instruction
34162306a36Sopenharmony_ci * inside the vertex program, otherwise the GPU locks up.
34262306a36Sopenharmony_ci *
34362306a36Sopenharmony_ci * fglrx usually sets CNTL_3_UNKNOWN to the end of the program and
34462306a36Sopenharmony_ci * R300_PVS_CNTL_1_POS_END_SHIFT points to instruction where last write to
34562306a36Sopenharmony_ci * position takes place.
34662306a36Sopenharmony_ci *
34762306a36Sopenharmony_ci * Most likely this is used to ignore rest of the program in cases
34862306a36Sopenharmony_ci * where group of verts arent visible. For some reason this "section"
34962306a36Sopenharmony_ci * is sometimes accepted other instruction that have no relationship with
35062306a36Sopenharmony_ci * position calculations.
35162306a36Sopenharmony_ci */
35262306a36Sopenharmony_ci#define R300_VAP_PVS_CNTL_1                 0x22D0
35362306a36Sopenharmony_ci#       define R300_PVS_CNTL_1_PROGRAM_START_SHIFT   0
35462306a36Sopenharmony_ci#       define R300_PVS_CNTL_1_POS_END_SHIFT         10
35562306a36Sopenharmony_ci#       define R300_PVS_CNTL_1_PROGRAM_END_SHIFT     20
35662306a36Sopenharmony_ci/* Addresses are relative the vertex program parameters area. */
35762306a36Sopenharmony_ci#define R300_VAP_PVS_CNTL_2                 0x22D4
35862306a36Sopenharmony_ci#       define R300_PVS_CNTL_2_PARAM_OFFSET_SHIFT 0
35962306a36Sopenharmony_ci#       define R300_PVS_CNTL_2_PARAM_COUNT_SHIFT  16
36062306a36Sopenharmony_ci#define R300_VAP_PVS_CNTL_3	           0x22D8
36162306a36Sopenharmony_ci#       define R300_PVS_CNTL_3_PROGRAM_UNKNOWN_SHIFT 10
36262306a36Sopenharmony_ci#       define R300_PVS_CNTL_3_PROGRAM_UNKNOWN2_SHIFT 0
36362306a36Sopenharmony_ci
36462306a36Sopenharmony_ci/* The entire range from 0x2300 to 0x2AC inclusive seems to be used for
36562306a36Sopenharmony_ci * immediate vertices
36662306a36Sopenharmony_ci */
36762306a36Sopenharmony_ci#define R300_VAP_VTX_COLOR_R                0x2464
36862306a36Sopenharmony_ci#define R300_VAP_VTX_COLOR_G                0x2468
36962306a36Sopenharmony_ci#define R300_VAP_VTX_COLOR_B                0x246C
37062306a36Sopenharmony_ci#define R300_VAP_VTX_POS_0_X_1              0x2490 /* used for glVertex2*() */
37162306a36Sopenharmony_ci#define R300_VAP_VTX_POS_0_Y_1              0x2494
37262306a36Sopenharmony_ci#define R300_VAP_VTX_COLOR_PKD              0x249C /* RGBA */
37362306a36Sopenharmony_ci#define R300_VAP_VTX_POS_0_X_2              0x24A0 /* used for glVertex3*() */
37462306a36Sopenharmony_ci#define R300_VAP_VTX_POS_0_Y_2              0x24A4
37562306a36Sopenharmony_ci#define R300_VAP_VTX_POS_0_Z_2              0x24A8
37662306a36Sopenharmony_ci/* write 0 to indicate end of packet? */
37762306a36Sopenharmony_ci#define R300_VAP_VTX_END_OF_PKT             0x24AC
37862306a36Sopenharmony_ci
37962306a36Sopenharmony_ci/* gap */
38062306a36Sopenharmony_ci
38162306a36Sopenharmony_ci/* These are values from r300_reg/r300_reg.h - they are known to be correct
38262306a36Sopenharmony_ci * and are here so we can use one register file instead of several
38362306a36Sopenharmony_ci * - Vladimir
38462306a36Sopenharmony_ci */
38562306a36Sopenharmony_ci#define R300_GB_VAP_RASTER_VTX_FMT_0	0x4000
38662306a36Sopenharmony_ci#	define R300_GB_VAP_RASTER_VTX_FMT_0__POS_PRESENT	(1<<0)
38762306a36Sopenharmony_ci#	define R300_GB_VAP_RASTER_VTX_FMT_0__COLOR_0_PRESENT	(1<<1)
38862306a36Sopenharmony_ci#	define R300_GB_VAP_RASTER_VTX_FMT_0__COLOR_1_PRESENT	(1<<2)
38962306a36Sopenharmony_ci#	define R300_GB_VAP_RASTER_VTX_FMT_0__COLOR_2_PRESENT	(1<<3)
39062306a36Sopenharmony_ci#	define R300_GB_VAP_RASTER_VTX_FMT_0__COLOR_3_PRESENT	(1<<4)
39162306a36Sopenharmony_ci#	define R300_GB_VAP_RASTER_VTX_FMT_0__COLOR_SPACE	(0xf<<5)
39262306a36Sopenharmony_ci#	define R300_GB_VAP_RASTER_VTX_FMT_0__PT_SIZE_PRESENT	(0x1<<16)
39362306a36Sopenharmony_ci
39462306a36Sopenharmony_ci#define R300_GB_VAP_RASTER_VTX_FMT_1	0x4004
39562306a36Sopenharmony_ci	/* each of the following is 3 bits wide, specifies number
39662306a36Sopenharmony_ci	   of components */
39762306a36Sopenharmony_ci#	define R300_GB_VAP_RASTER_VTX_FMT_1__TEX_0_COMP_CNT_SHIFT	0
39862306a36Sopenharmony_ci#	define R300_GB_VAP_RASTER_VTX_FMT_1__TEX_1_COMP_CNT_SHIFT	3
39962306a36Sopenharmony_ci#	define R300_GB_VAP_RASTER_VTX_FMT_1__TEX_2_COMP_CNT_SHIFT	6
40062306a36Sopenharmony_ci#	define R300_GB_VAP_RASTER_VTX_FMT_1__TEX_3_COMP_CNT_SHIFT	9
40162306a36Sopenharmony_ci#	define R300_GB_VAP_RASTER_VTX_FMT_1__TEX_4_COMP_CNT_SHIFT	12
40262306a36Sopenharmony_ci#	define R300_GB_VAP_RASTER_VTX_FMT_1__TEX_5_COMP_CNT_SHIFT	15
40362306a36Sopenharmony_ci#	define R300_GB_VAP_RASTER_VTX_FMT_1__TEX_6_COMP_CNT_SHIFT	18
40462306a36Sopenharmony_ci#	define R300_GB_VAP_RASTER_VTX_FMT_1__TEX_7_COMP_CNT_SHIFT	21
40562306a36Sopenharmony_ci
40662306a36Sopenharmony_ci/* UNK30 seems to enables point to quad transformation on textures
40762306a36Sopenharmony_ci * (or something closely related to that).
40862306a36Sopenharmony_ci * This bit is rather fatal at the time being due to lackings at pixel
40962306a36Sopenharmony_ci * shader side
41062306a36Sopenharmony_ci */
41162306a36Sopenharmony_ci#define R300_GB_ENABLE	0x4008
41262306a36Sopenharmony_ci#	define R300_GB_POINT_STUFF_ENABLE	(1<<0)
41362306a36Sopenharmony_ci#	define R300_GB_LINE_STUFF_ENABLE	(1<<1)
41462306a36Sopenharmony_ci#	define R300_GB_TRIANGLE_STUFF_ENABLE	(1<<2)
41562306a36Sopenharmony_ci#	define R300_GB_STENCIL_AUTO_ENABLE	(1<<4)
41662306a36Sopenharmony_ci#	define R300_GB_UNK31			(1<<31)
41762306a36Sopenharmony_ci	/* each of the following is 2 bits wide */
41862306a36Sopenharmony_ci#define R300_GB_TEX_REPLICATE	0
41962306a36Sopenharmony_ci#define R300_GB_TEX_ST		1
42062306a36Sopenharmony_ci#define R300_GB_TEX_STR		2
42162306a36Sopenharmony_ci#	define R300_GB_TEX0_SOURCE_SHIFT	16
42262306a36Sopenharmony_ci#	define R300_GB_TEX1_SOURCE_SHIFT	18
42362306a36Sopenharmony_ci#	define R300_GB_TEX2_SOURCE_SHIFT	20
42462306a36Sopenharmony_ci#	define R300_GB_TEX3_SOURCE_SHIFT	22
42562306a36Sopenharmony_ci#	define R300_GB_TEX4_SOURCE_SHIFT	24
42662306a36Sopenharmony_ci#	define R300_GB_TEX5_SOURCE_SHIFT	26
42762306a36Sopenharmony_ci#	define R300_GB_TEX6_SOURCE_SHIFT	28
42862306a36Sopenharmony_ci#	define R300_GB_TEX7_SOURCE_SHIFT	30
42962306a36Sopenharmony_ci
43062306a36Sopenharmony_ci/* MSPOS - positions for multisample antialiasing (?) */
43162306a36Sopenharmony_ci#define R300_GB_MSPOS0	0x4010
43262306a36Sopenharmony_ci	/* shifts - each of the fields is 4 bits */
43362306a36Sopenharmony_ci#	define R300_GB_MSPOS0__MS_X0_SHIFT	0
43462306a36Sopenharmony_ci#	define R300_GB_MSPOS0__MS_Y0_SHIFT	4
43562306a36Sopenharmony_ci#	define R300_GB_MSPOS0__MS_X1_SHIFT	8
43662306a36Sopenharmony_ci#	define R300_GB_MSPOS0__MS_Y1_SHIFT	12
43762306a36Sopenharmony_ci#	define R300_GB_MSPOS0__MS_X2_SHIFT	16
43862306a36Sopenharmony_ci#	define R300_GB_MSPOS0__MS_Y2_SHIFT	20
43962306a36Sopenharmony_ci#	define R300_GB_MSPOS0__MSBD0_Y		24
44062306a36Sopenharmony_ci#	define R300_GB_MSPOS0__MSBD0_X		28
44162306a36Sopenharmony_ci
44262306a36Sopenharmony_ci#define R300_GB_MSPOS1	0x4014
44362306a36Sopenharmony_ci#	define R300_GB_MSPOS1__MS_X3_SHIFT	0
44462306a36Sopenharmony_ci#	define R300_GB_MSPOS1__MS_Y3_SHIFT	4
44562306a36Sopenharmony_ci#	define R300_GB_MSPOS1__MS_X4_SHIFT	8
44662306a36Sopenharmony_ci#	define R300_GB_MSPOS1__MS_Y4_SHIFT	12
44762306a36Sopenharmony_ci#	define R300_GB_MSPOS1__MS_X5_SHIFT	16
44862306a36Sopenharmony_ci#	define R300_GB_MSPOS1__MS_Y5_SHIFT	20
44962306a36Sopenharmony_ci#	define R300_GB_MSPOS1__MSBD1		24
45062306a36Sopenharmony_ci
45162306a36Sopenharmony_ci
45262306a36Sopenharmony_ci#define R300_GB_TILE_CONFIG	0x4018
45362306a36Sopenharmony_ci#	define R300_GB_TILE_ENABLE	(1<<0)
45462306a36Sopenharmony_ci#	define R300_GB_TILE_PIPE_COUNT_RV300	0
45562306a36Sopenharmony_ci#	define R300_GB_TILE_PIPE_COUNT_R300	(3<<1)
45662306a36Sopenharmony_ci#	define R300_GB_TILE_PIPE_COUNT_R420	(7<<1)
45762306a36Sopenharmony_ci#	define R300_GB_TILE_PIPE_COUNT_RV410	(3<<1)
45862306a36Sopenharmony_ci#	define R300_GB_TILE_SIZE_8		0
45962306a36Sopenharmony_ci#	define R300_GB_TILE_SIZE_16		(1<<4)
46062306a36Sopenharmony_ci#	define R300_GB_TILE_SIZE_32		(2<<4)
46162306a36Sopenharmony_ci#	define R300_GB_SUPER_SIZE_1		(0<<6)
46262306a36Sopenharmony_ci#	define R300_GB_SUPER_SIZE_2		(1<<6)
46362306a36Sopenharmony_ci#	define R300_GB_SUPER_SIZE_4		(2<<6)
46462306a36Sopenharmony_ci#	define R300_GB_SUPER_SIZE_8		(3<<6)
46562306a36Sopenharmony_ci#	define R300_GB_SUPER_SIZE_16		(4<<6)
46662306a36Sopenharmony_ci#	define R300_GB_SUPER_SIZE_32		(5<<6)
46762306a36Sopenharmony_ci#	define R300_GB_SUPER_SIZE_64		(6<<6)
46862306a36Sopenharmony_ci#	define R300_GB_SUPER_SIZE_128		(7<<6)
46962306a36Sopenharmony_ci#	define R300_GB_SUPER_X_SHIFT		9	/* 3 bits wide */
47062306a36Sopenharmony_ci#	define R300_GB_SUPER_Y_SHIFT		12	/* 3 bits wide */
47162306a36Sopenharmony_ci#	define R300_GB_SUPER_TILE_A		0
47262306a36Sopenharmony_ci#	define R300_GB_SUPER_TILE_B		(1<<15)
47362306a36Sopenharmony_ci#	define R300_GB_SUBPIXEL_1_12		0
47462306a36Sopenharmony_ci#	define R300_GB_SUBPIXEL_1_16		(1<<16)
47562306a36Sopenharmony_ci
47662306a36Sopenharmony_ci#define R300_GB_FIFO_SIZE	0x4024
47762306a36Sopenharmony_ci	/* each of the following is 2 bits wide */
47862306a36Sopenharmony_ci#define R300_GB_FIFO_SIZE_32	0
47962306a36Sopenharmony_ci#define R300_GB_FIFO_SIZE_64	1
48062306a36Sopenharmony_ci#define R300_GB_FIFO_SIZE_128	2
48162306a36Sopenharmony_ci#define R300_GB_FIFO_SIZE_256	3
48262306a36Sopenharmony_ci#	define R300_SC_IFIFO_SIZE_SHIFT	0
48362306a36Sopenharmony_ci#	define R300_SC_TZFIFO_SIZE_SHIFT	2
48462306a36Sopenharmony_ci#	define R300_SC_BFIFO_SIZE_SHIFT	4
48562306a36Sopenharmony_ci
48662306a36Sopenharmony_ci#	define R300_US_OFIFO_SIZE_SHIFT	12
48762306a36Sopenharmony_ci#	define R300_US_WFIFO_SIZE_SHIFT	14
48862306a36Sopenharmony_ci	/* the following use the same constants as above, but meaning is
48962306a36Sopenharmony_ci	   is times 2 (i.e. instead of 32 words it means 64 */
49062306a36Sopenharmony_ci#	define R300_RS_TFIFO_SIZE_SHIFT	6
49162306a36Sopenharmony_ci#	define R300_RS_CFIFO_SIZE_SHIFT	8
49262306a36Sopenharmony_ci#	define R300_US_RAM_SIZE_SHIFT		10
49362306a36Sopenharmony_ci	/* watermarks, 3 bits wide */
49462306a36Sopenharmony_ci#	define R300_RS_HIGHWATER_COL_SHIFT	16
49562306a36Sopenharmony_ci#	define R300_RS_HIGHWATER_TEX_SHIFT	19
49662306a36Sopenharmony_ci#	define R300_OFIFO_HIGHWATER_SHIFT	22	/* two bits only */
49762306a36Sopenharmony_ci#	define R300_CUBE_FIFO_HIGHWATER_COL_SHIFT	24
49862306a36Sopenharmony_ci
49962306a36Sopenharmony_ci#define R300_GB_SELECT	0x401C
50062306a36Sopenharmony_ci#	define R300_GB_FOG_SELECT_C0A		0
50162306a36Sopenharmony_ci#	define R300_GB_FOG_SELECT_C1A		1
50262306a36Sopenharmony_ci#	define R300_GB_FOG_SELECT_C2A		2
50362306a36Sopenharmony_ci#	define R300_GB_FOG_SELECT_C3A		3
50462306a36Sopenharmony_ci#	define R300_GB_FOG_SELECT_1_1_W	4
50562306a36Sopenharmony_ci#	define R300_GB_FOG_SELECT_Z		5
50662306a36Sopenharmony_ci#	define R300_GB_DEPTH_SELECT_Z		0
50762306a36Sopenharmony_ci#	define R300_GB_DEPTH_SELECT_1_1_W	(1<<3)
50862306a36Sopenharmony_ci#	define R300_GB_W_SELECT_1_W		0
50962306a36Sopenharmony_ci#	define R300_GB_W_SELECT_1		(1<<4)
51062306a36Sopenharmony_ci
51162306a36Sopenharmony_ci#define R300_GB_AA_CONFIG		0x4020
51262306a36Sopenharmony_ci#	define R300_AA_DISABLE			0x00
51362306a36Sopenharmony_ci#	define R300_AA_ENABLE			0x01
51462306a36Sopenharmony_ci#	define R300_AA_SUBSAMPLES_2		0
51562306a36Sopenharmony_ci#	define R300_AA_SUBSAMPLES_3		(1<<1)
51662306a36Sopenharmony_ci#	define R300_AA_SUBSAMPLES_4		(2<<1)
51762306a36Sopenharmony_ci#	define R300_AA_SUBSAMPLES_6		(3<<1)
51862306a36Sopenharmony_ci
51962306a36Sopenharmony_ci/* gap */
52062306a36Sopenharmony_ci
52162306a36Sopenharmony_ci/* Zero to flush caches. */
52262306a36Sopenharmony_ci#define R300_TX_INVALTAGS                   0x4100
52362306a36Sopenharmony_ci#define R300_TX_FLUSH                       0x0
52462306a36Sopenharmony_ci
52562306a36Sopenharmony_ci/* The upper enable bits are guessed, based on fglrx reported limits. */
52662306a36Sopenharmony_ci#define R300_TX_ENABLE                      0x4104
52762306a36Sopenharmony_ci#       define R300_TX_ENABLE_0                  (1 << 0)
52862306a36Sopenharmony_ci#       define R300_TX_ENABLE_1                  (1 << 1)
52962306a36Sopenharmony_ci#       define R300_TX_ENABLE_2                  (1 << 2)
53062306a36Sopenharmony_ci#       define R300_TX_ENABLE_3                  (1 << 3)
53162306a36Sopenharmony_ci#       define R300_TX_ENABLE_4                  (1 << 4)
53262306a36Sopenharmony_ci#       define R300_TX_ENABLE_5                  (1 << 5)
53362306a36Sopenharmony_ci#       define R300_TX_ENABLE_6                  (1 << 6)
53462306a36Sopenharmony_ci#       define R300_TX_ENABLE_7                  (1 << 7)
53562306a36Sopenharmony_ci#       define R300_TX_ENABLE_8                  (1 << 8)
53662306a36Sopenharmony_ci#       define R300_TX_ENABLE_9                  (1 << 9)
53762306a36Sopenharmony_ci#       define R300_TX_ENABLE_10                 (1 << 10)
53862306a36Sopenharmony_ci#       define R300_TX_ENABLE_11                 (1 << 11)
53962306a36Sopenharmony_ci#       define R300_TX_ENABLE_12                 (1 << 12)
54062306a36Sopenharmony_ci#       define R300_TX_ENABLE_13                 (1 << 13)
54162306a36Sopenharmony_ci#       define R300_TX_ENABLE_14                 (1 << 14)
54262306a36Sopenharmony_ci#       define R300_TX_ENABLE_15                 (1 << 15)
54362306a36Sopenharmony_ci
54462306a36Sopenharmony_ci/* The pointsize is given in multiples of 6. The pointsize can be
54562306a36Sopenharmony_ci * enormous: Clear() renders a single point that fills the entire
54662306a36Sopenharmony_ci * framebuffer.
54762306a36Sopenharmony_ci */
54862306a36Sopenharmony_ci#define R300_RE_POINTSIZE                   0x421C
54962306a36Sopenharmony_ci#       define R300_POINTSIZE_Y_SHIFT            0
55062306a36Sopenharmony_ci#       define R300_POINTSIZE_Y_MASK             (0xFFFF << 0) /* GUESS */
55162306a36Sopenharmony_ci#       define R300_POINTSIZE_X_SHIFT            16
55262306a36Sopenharmony_ci#       define R300_POINTSIZE_X_MASK             (0xFFFF << 16) /* GUESS */
55362306a36Sopenharmony_ci#       define R300_POINTSIZE_MAX             (R300_POINTSIZE_Y_MASK / 6)
55462306a36Sopenharmony_ci
55562306a36Sopenharmony_ci/* The line width is given in multiples of 6.
55662306a36Sopenharmony_ci * In default mode lines are classified as vertical lines.
55762306a36Sopenharmony_ci * HO: horizontal
55862306a36Sopenharmony_ci * VE: vertical or horizontal
55962306a36Sopenharmony_ci * HO & VE: no classification
56062306a36Sopenharmony_ci */
56162306a36Sopenharmony_ci#define R300_RE_LINE_CNT                      0x4234
56262306a36Sopenharmony_ci#       define R300_LINESIZE_SHIFT            0
56362306a36Sopenharmony_ci#       define R300_LINESIZE_MASK             (0xFFFF << 0) /* GUESS */
56462306a36Sopenharmony_ci#       define R300_LINESIZE_MAX             (R300_LINESIZE_MASK / 6)
56562306a36Sopenharmony_ci#       define R300_LINE_CNT_HO               (1 << 16)
56662306a36Sopenharmony_ci#       define R300_LINE_CNT_VE               (1 << 17)
56762306a36Sopenharmony_ci
56862306a36Sopenharmony_ci/* Some sort of scale or clamp value for texcoordless textures. */
56962306a36Sopenharmony_ci#define R300_RE_UNK4238                       0x4238
57062306a36Sopenharmony_ci
57162306a36Sopenharmony_ci/* Something shade related */
57262306a36Sopenharmony_ci#define R300_RE_SHADE                         0x4274
57362306a36Sopenharmony_ci
57462306a36Sopenharmony_ci#define R300_RE_SHADE_MODEL                   0x4278
57562306a36Sopenharmony_ci#	define R300_RE_SHADE_MODEL_SMOOTH     0x3aaaa
57662306a36Sopenharmony_ci#	define R300_RE_SHADE_MODEL_FLAT       0x39595
57762306a36Sopenharmony_ci
57862306a36Sopenharmony_ci/* Dangerous */
57962306a36Sopenharmony_ci#define R300_RE_POLYGON_MODE                  0x4288
58062306a36Sopenharmony_ci#	define R300_PM_ENABLED                (1 << 0)
58162306a36Sopenharmony_ci#	define R300_PM_FRONT_POINT            (0 << 0)
58262306a36Sopenharmony_ci#	define R300_PM_BACK_POINT             (0 << 0)
58362306a36Sopenharmony_ci#	define R300_PM_FRONT_LINE             (1 << 4)
58462306a36Sopenharmony_ci#	define R300_PM_FRONT_FILL             (1 << 5)
58562306a36Sopenharmony_ci#	define R300_PM_BACK_LINE              (1 << 7)
58662306a36Sopenharmony_ci#	define R300_PM_BACK_FILL              (1 << 8)
58762306a36Sopenharmony_ci
58862306a36Sopenharmony_ci/* Fog parameters */
58962306a36Sopenharmony_ci#define R300_RE_FOG_SCALE                     0x4294
59062306a36Sopenharmony_ci#define R300_RE_FOG_START                     0x4298
59162306a36Sopenharmony_ci
59262306a36Sopenharmony_ci/* Not sure why there are duplicate of factor and constant values.
59362306a36Sopenharmony_ci * My best guess so far is that there are separate zbiases for test and write.
59462306a36Sopenharmony_ci * Ordering might be wrong.
59562306a36Sopenharmony_ci * Some of the tests indicate that fgl has a fallback implementation of zbias
59662306a36Sopenharmony_ci * via pixel shaders.
59762306a36Sopenharmony_ci */
59862306a36Sopenharmony_ci#define R300_RE_ZBIAS_CNTL                    0x42A0 /* GUESS */
59962306a36Sopenharmony_ci#define R300_RE_ZBIAS_T_FACTOR                0x42A4
60062306a36Sopenharmony_ci#define R300_RE_ZBIAS_T_CONSTANT              0x42A8
60162306a36Sopenharmony_ci#define R300_RE_ZBIAS_W_FACTOR                0x42AC
60262306a36Sopenharmony_ci#define R300_RE_ZBIAS_W_CONSTANT              0x42B0
60362306a36Sopenharmony_ci
60462306a36Sopenharmony_ci/* This register needs to be set to (1<<1) for RV350 to correctly
60562306a36Sopenharmony_ci * perform depth test (see --vb-triangles in r300_demo)
60662306a36Sopenharmony_ci * Don't know about other chips. - Vladimir
60762306a36Sopenharmony_ci * This is set to 3 when GL_POLYGON_OFFSET_FILL is on.
60862306a36Sopenharmony_ci * My guess is that there are two bits for each zbias primitive
60962306a36Sopenharmony_ci * (FILL, LINE, POINT).
61062306a36Sopenharmony_ci *  One to enable depth test and one for depth write.
61162306a36Sopenharmony_ci * Yet this doesn't explain why depth writes work ...
61262306a36Sopenharmony_ci */
61362306a36Sopenharmony_ci#define R300_RE_OCCLUSION_CNTL		    0x42B4
61462306a36Sopenharmony_ci#	define R300_OCCLUSION_ON		(1<<1)
61562306a36Sopenharmony_ci
61662306a36Sopenharmony_ci#define R300_RE_CULL_CNTL                   0x42B8
61762306a36Sopenharmony_ci#       define R300_CULL_FRONT                   (1 << 0)
61862306a36Sopenharmony_ci#       define R300_CULL_BACK                    (1 << 1)
61962306a36Sopenharmony_ci#       define R300_FRONT_FACE_CCW               (0 << 2)
62062306a36Sopenharmony_ci#       define R300_FRONT_FACE_CW                (1 << 2)
62162306a36Sopenharmony_ci
62262306a36Sopenharmony_ci
62362306a36Sopenharmony_ci/* BEGIN: Rasterization / Interpolators - many guesses */
62462306a36Sopenharmony_ci
62562306a36Sopenharmony_ci/* 0_UNKNOWN_18 has always been set except for clear operations.
62662306a36Sopenharmony_ci * TC_CNT is the number of incoming texture coordinate sets (i.e. it depends
62762306a36Sopenharmony_ci * on the vertex program, *not* the fragment program)
62862306a36Sopenharmony_ci */
62962306a36Sopenharmony_ci#define R300_RS_CNTL_0                      0x4300
63062306a36Sopenharmony_ci#       define R300_RS_CNTL_TC_CNT_SHIFT         2
63162306a36Sopenharmony_ci#       define R300_RS_CNTL_TC_CNT_MASK          (7 << 2)
63262306a36Sopenharmony_ci	/* number of color interpolators used */
63362306a36Sopenharmony_ci#	define R300_RS_CNTL_CI_CNT_SHIFT         7
63462306a36Sopenharmony_ci#       define R300_RS_CNTL_0_UNKNOWN_18         (1 << 18)
63562306a36Sopenharmony_ci	/* Guess: RS_CNTL_1 holds the index of the highest used RS_ROUTE_n
63662306a36Sopenharmony_ci	   register. */
63762306a36Sopenharmony_ci#define R300_RS_CNTL_1                      0x4304
63862306a36Sopenharmony_ci
63962306a36Sopenharmony_ci/* gap */
64062306a36Sopenharmony_ci
64162306a36Sopenharmony_ci/* Only used for texture coordinates.
64262306a36Sopenharmony_ci * Use the source field to route texture coordinate input from the
64362306a36Sopenharmony_ci * vertex program to the desired interpolator. Note that the source
64462306a36Sopenharmony_ci * field is relative to the outputs the vertex program *actually*
64562306a36Sopenharmony_ci * writes. If a vertex program only writes texcoord[1], this will
64662306a36Sopenharmony_ci * be source index 0.
64762306a36Sopenharmony_ci * Set INTERP_USED on all interpolators that produce data used by
64862306a36Sopenharmony_ci * the fragment program. INTERP_USED looks like a swizzling mask,
64962306a36Sopenharmony_ci * but I haven't seen it used that way.
65062306a36Sopenharmony_ci *
65162306a36Sopenharmony_ci * Note: The _UNKNOWN constants are always set in their respective
65262306a36Sopenharmony_ci * register. I don't know if this is necessary.
65362306a36Sopenharmony_ci */
65462306a36Sopenharmony_ci#define R300_RS_INTERP_0                    0x4310
65562306a36Sopenharmony_ci#define R300_RS_INTERP_1                    0x4314
65662306a36Sopenharmony_ci#       define R300_RS_INTERP_1_UNKNOWN          0x40
65762306a36Sopenharmony_ci#define R300_RS_INTERP_2                    0x4318
65862306a36Sopenharmony_ci#       define R300_RS_INTERP_2_UNKNOWN          0x80
65962306a36Sopenharmony_ci#define R300_RS_INTERP_3                    0x431C
66062306a36Sopenharmony_ci#       define R300_RS_INTERP_3_UNKNOWN          0xC0
66162306a36Sopenharmony_ci#define R300_RS_INTERP_4                    0x4320
66262306a36Sopenharmony_ci#define R300_RS_INTERP_5                    0x4324
66362306a36Sopenharmony_ci#define R300_RS_INTERP_6                    0x4328
66462306a36Sopenharmony_ci#define R300_RS_INTERP_7                    0x432C
66562306a36Sopenharmony_ci#       define R300_RS_INTERP_SRC_SHIFT          2
66662306a36Sopenharmony_ci#       define R300_RS_INTERP_SRC_MASK           (7 << 2)
66762306a36Sopenharmony_ci#       define R300_RS_INTERP_USED               0x00D10000
66862306a36Sopenharmony_ci
66962306a36Sopenharmony_ci/* These DWORDs control how vertex data is routed into fragment program
67062306a36Sopenharmony_ci * registers, after interpolators.
67162306a36Sopenharmony_ci */
67262306a36Sopenharmony_ci#define R300_RS_ROUTE_0                     0x4330
67362306a36Sopenharmony_ci#define R300_RS_ROUTE_1                     0x4334
67462306a36Sopenharmony_ci#define R300_RS_ROUTE_2                     0x4338
67562306a36Sopenharmony_ci#define R300_RS_ROUTE_3                     0x433C /* GUESS */
67662306a36Sopenharmony_ci#define R300_RS_ROUTE_4                     0x4340 /* GUESS */
67762306a36Sopenharmony_ci#define R300_RS_ROUTE_5                     0x4344 /* GUESS */
67862306a36Sopenharmony_ci#define R300_RS_ROUTE_6                     0x4348 /* GUESS */
67962306a36Sopenharmony_ci#define R300_RS_ROUTE_7                     0x434C /* GUESS */
68062306a36Sopenharmony_ci#       define R300_RS_ROUTE_SOURCE_INTERP_0     0
68162306a36Sopenharmony_ci#       define R300_RS_ROUTE_SOURCE_INTERP_1     1
68262306a36Sopenharmony_ci#       define R300_RS_ROUTE_SOURCE_INTERP_2     2
68362306a36Sopenharmony_ci#       define R300_RS_ROUTE_SOURCE_INTERP_3     3
68462306a36Sopenharmony_ci#       define R300_RS_ROUTE_SOURCE_INTERP_4     4
68562306a36Sopenharmony_ci#       define R300_RS_ROUTE_SOURCE_INTERP_5     5 /* GUESS */
68662306a36Sopenharmony_ci#       define R300_RS_ROUTE_SOURCE_INTERP_6     6 /* GUESS */
68762306a36Sopenharmony_ci#       define R300_RS_ROUTE_SOURCE_INTERP_7     7 /* GUESS */
68862306a36Sopenharmony_ci#       define R300_RS_ROUTE_ENABLE              (1 << 3) /* GUESS */
68962306a36Sopenharmony_ci#       define R300_RS_ROUTE_DEST_SHIFT          6
69062306a36Sopenharmony_ci#       define R300_RS_ROUTE_DEST_MASK           (31 << 6) /* GUESS */
69162306a36Sopenharmony_ci
69262306a36Sopenharmony_ci/* Special handling for color: When the fragment program uses color,
69362306a36Sopenharmony_ci * the ROUTE_0_COLOR bit is set and ROUTE_0_COLOR_DEST contains the
69462306a36Sopenharmony_ci * color register index.
69562306a36Sopenharmony_ci *
69662306a36Sopenharmony_ci * Apperently you may set the R300_RS_ROUTE_0_COLOR bit, but not provide any
69762306a36Sopenharmony_ci * R300_RS_ROUTE_0_COLOR_DEST value; this setup is used for clearing the state.
69862306a36Sopenharmony_ci * See r300_ioctl.c:r300EmitClearState. I'm not sure if this setup is strictly
69962306a36Sopenharmony_ci * correct or not. - Oliver.
70062306a36Sopenharmony_ci */
70162306a36Sopenharmony_ci#       define R300_RS_ROUTE_0_COLOR             (1 << 14)
70262306a36Sopenharmony_ci#       define R300_RS_ROUTE_0_COLOR_DEST_SHIFT  17
70362306a36Sopenharmony_ci#       define R300_RS_ROUTE_0_COLOR_DEST_MASK   (31 << 17) /* GUESS */
70462306a36Sopenharmony_ci/* As above, but for secondary color */
70562306a36Sopenharmony_ci#		define R300_RS_ROUTE_1_COLOR1            (1 << 14)
70662306a36Sopenharmony_ci#		define R300_RS_ROUTE_1_COLOR1_DEST_SHIFT 17
70762306a36Sopenharmony_ci#		define R300_RS_ROUTE_1_COLOR1_DEST_MASK  (31 << 17)
70862306a36Sopenharmony_ci#		define R300_RS_ROUTE_1_UNKNOWN11         (1 << 11)
70962306a36Sopenharmony_ci/* END: Rasterization / Interpolators - many guesses */
71062306a36Sopenharmony_ci
71162306a36Sopenharmony_ci/* Hierarchical Z Enable */
71262306a36Sopenharmony_ci#define R300_SC_HYPERZ                   0x43a4
71362306a36Sopenharmony_ci#	define R300_SC_HYPERZ_DISABLE     (0 << 0)
71462306a36Sopenharmony_ci#	define R300_SC_HYPERZ_ENABLE      (1 << 0)
71562306a36Sopenharmony_ci#	define R300_SC_HYPERZ_MIN         (0 << 1)
71662306a36Sopenharmony_ci#	define R300_SC_HYPERZ_MAX         (1 << 1)
71762306a36Sopenharmony_ci#	define R300_SC_HYPERZ_ADJ_256     (0 << 2)
71862306a36Sopenharmony_ci#	define R300_SC_HYPERZ_ADJ_128     (1 << 2)
71962306a36Sopenharmony_ci#	define R300_SC_HYPERZ_ADJ_64      (2 << 2)
72062306a36Sopenharmony_ci#	define R300_SC_HYPERZ_ADJ_32      (3 << 2)
72162306a36Sopenharmony_ci#	define R300_SC_HYPERZ_ADJ_16      (4 << 2)
72262306a36Sopenharmony_ci#	define R300_SC_HYPERZ_ADJ_8       (5 << 2)
72362306a36Sopenharmony_ci#	define R300_SC_HYPERZ_ADJ_4       (6 << 2)
72462306a36Sopenharmony_ci#	define R300_SC_HYPERZ_ADJ_2       (7 << 2)
72562306a36Sopenharmony_ci#	define R300_SC_HYPERZ_HZ_Z0MIN_NO (0 << 5)
72662306a36Sopenharmony_ci#	define R300_SC_HYPERZ_HZ_Z0MIN    (1 << 5)
72762306a36Sopenharmony_ci#	define R300_SC_HYPERZ_HZ_Z0MAX_NO (0 << 6)
72862306a36Sopenharmony_ci#	define R300_SC_HYPERZ_HZ_Z0MAX    (1 << 6)
72962306a36Sopenharmony_ci
73062306a36Sopenharmony_ci#define R300_SC_EDGERULE                 0x43a8
73162306a36Sopenharmony_ci
73262306a36Sopenharmony_ci/* BEGIN: Scissors and cliprects */
73362306a36Sopenharmony_ci
73462306a36Sopenharmony_ci/* There are four clipping rectangles. Their corner coordinates are inclusive.
73562306a36Sopenharmony_ci * Every pixel is assigned a number from 0 and 15 by setting bits 0-3 depending
73662306a36Sopenharmony_ci * on whether the pixel is inside cliprects 0-3, respectively. For example,
73762306a36Sopenharmony_ci * if a pixel is inside cliprects 0 and 1, but outside 2 and 3, it is assigned
73862306a36Sopenharmony_ci * the number 3 (binary 0011).
73962306a36Sopenharmony_ci * Iff the bit corresponding to the pixel's number in RE_CLIPRECT_CNTL is set,
74062306a36Sopenharmony_ci * the pixel is rasterized.
74162306a36Sopenharmony_ci *
74262306a36Sopenharmony_ci * In addition to this, there is a scissors rectangle. Only pixels inside the
74362306a36Sopenharmony_ci * scissors rectangle are drawn. (coordinates are inclusive)
74462306a36Sopenharmony_ci *
74562306a36Sopenharmony_ci * For some reason, the top-left corner of the framebuffer is at (1440, 1440)
74662306a36Sopenharmony_ci * for the purpose of clipping and scissors.
74762306a36Sopenharmony_ci */
74862306a36Sopenharmony_ci#define R300_RE_CLIPRECT_TL_0               0x43B0
74962306a36Sopenharmony_ci#define R300_RE_CLIPRECT_BR_0               0x43B4
75062306a36Sopenharmony_ci#define R300_RE_CLIPRECT_TL_1               0x43B8
75162306a36Sopenharmony_ci#define R300_RE_CLIPRECT_BR_1               0x43BC
75262306a36Sopenharmony_ci#define R300_RE_CLIPRECT_TL_2               0x43C0
75362306a36Sopenharmony_ci#define R300_RE_CLIPRECT_BR_2               0x43C4
75462306a36Sopenharmony_ci#define R300_RE_CLIPRECT_TL_3               0x43C8
75562306a36Sopenharmony_ci#define R300_RE_CLIPRECT_BR_3               0x43CC
75662306a36Sopenharmony_ci#       define R300_CLIPRECT_OFFSET              1440
75762306a36Sopenharmony_ci#       define R300_CLIPRECT_MASK                0x1FFF
75862306a36Sopenharmony_ci#       define R300_CLIPRECT_X_SHIFT             0
75962306a36Sopenharmony_ci#       define R300_CLIPRECT_X_MASK              (0x1FFF << 0)
76062306a36Sopenharmony_ci#       define R300_CLIPRECT_Y_SHIFT             13
76162306a36Sopenharmony_ci#       define R300_CLIPRECT_Y_MASK              (0x1FFF << 13)
76262306a36Sopenharmony_ci#define R300_RE_CLIPRECT_CNTL               0x43D0
76362306a36Sopenharmony_ci#       define R300_CLIP_OUT                     (1 << 0)
76462306a36Sopenharmony_ci#       define R300_CLIP_0                       (1 << 1)
76562306a36Sopenharmony_ci#       define R300_CLIP_1                       (1 << 2)
76662306a36Sopenharmony_ci#       define R300_CLIP_10                      (1 << 3)
76762306a36Sopenharmony_ci#       define R300_CLIP_2                       (1 << 4)
76862306a36Sopenharmony_ci#       define R300_CLIP_20                      (1 << 5)
76962306a36Sopenharmony_ci#       define R300_CLIP_21                      (1 << 6)
77062306a36Sopenharmony_ci#       define R300_CLIP_210                     (1 << 7)
77162306a36Sopenharmony_ci#       define R300_CLIP_3                       (1 << 8)
77262306a36Sopenharmony_ci#       define R300_CLIP_30                      (1 << 9)
77362306a36Sopenharmony_ci#       define R300_CLIP_31                      (1 << 10)
77462306a36Sopenharmony_ci#       define R300_CLIP_310                     (1 << 11)
77562306a36Sopenharmony_ci#       define R300_CLIP_32                      (1 << 12)
77662306a36Sopenharmony_ci#       define R300_CLIP_320                     (1 << 13)
77762306a36Sopenharmony_ci#       define R300_CLIP_321                     (1 << 14)
77862306a36Sopenharmony_ci#       define R300_CLIP_3210                    (1 << 15)
77962306a36Sopenharmony_ci
78062306a36Sopenharmony_ci/* gap */
78162306a36Sopenharmony_ci
78262306a36Sopenharmony_ci#define R300_RE_SCISSORS_TL                 0x43E0
78362306a36Sopenharmony_ci#define R300_RE_SCISSORS_BR                 0x43E4
78462306a36Sopenharmony_ci#       define R300_SCISSORS_OFFSET              1440
78562306a36Sopenharmony_ci#       define R300_SCISSORS_X_SHIFT             0
78662306a36Sopenharmony_ci#       define R300_SCISSORS_X_MASK              (0x1FFF << 0)
78762306a36Sopenharmony_ci#       define R300_SCISSORS_Y_SHIFT             13
78862306a36Sopenharmony_ci#       define R300_SCISSORS_Y_MASK              (0x1FFF << 13)
78962306a36Sopenharmony_ci/* END: Scissors and cliprects */
79062306a36Sopenharmony_ci
79162306a36Sopenharmony_ci/* BEGIN: Texture specification */
79262306a36Sopenharmony_ci
79362306a36Sopenharmony_ci/*
79462306a36Sopenharmony_ci * The texture specification dwords are grouped by meaning and not by texture
79562306a36Sopenharmony_ci * unit. This means that e.g. the offset for texture image unit N is found in
79662306a36Sopenharmony_ci * register TX_OFFSET_0 + (4*N)
79762306a36Sopenharmony_ci */
79862306a36Sopenharmony_ci#define R300_TX_FILTER_0                    0x4400
79962306a36Sopenharmony_ci#       define R300_TX_REPEAT                    0
80062306a36Sopenharmony_ci#       define R300_TX_MIRRORED                  1
80162306a36Sopenharmony_ci#       define R300_TX_CLAMP                     4
80262306a36Sopenharmony_ci#       define R300_TX_CLAMP_TO_EDGE             2
80362306a36Sopenharmony_ci#       define R300_TX_CLAMP_TO_BORDER           6
80462306a36Sopenharmony_ci#       define R300_TX_WRAP_S_SHIFT              0
80562306a36Sopenharmony_ci#       define R300_TX_WRAP_S_MASK               (7 << 0)
80662306a36Sopenharmony_ci#       define R300_TX_WRAP_T_SHIFT              3
80762306a36Sopenharmony_ci#       define R300_TX_WRAP_T_MASK               (7 << 3)
80862306a36Sopenharmony_ci#       define R300_TX_WRAP_Q_SHIFT              6
80962306a36Sopenharmony_ci#       define R300_TX_WRAP_Q_MASK               (7 << 6)
81062306a36Sopenharmony_ci#       define R300_TX_MAG_FILTER_NEAREST        (1 << 9)
81162306a36Sopenharmony_ci#       define R300_TX_MAG_FILTER_LINEAR         (2 << 9)
81262306a36Sopenharmony_ci#       define R300_TX_MAG_FILTER_MASK           (3 << 9)
81362306a36Sopenharmony_ci#       define R300_TX_MIN_FILTER_NEAREST        (1 << 11)
81462306a36Sopenharmony_ci#       define R300_TX_MIN_FILTER_LINEAR         (2 << 11)
81562306a36Sopenharmony_ci#	define R300_TX_MIN_FILTER_NEAREST_MIP_NEAREST       (5  <<  11)
81662306a36Sopenharmony_ci#	define R300_TX_MIN_FILTER_NEAREST_MIP_LINEAR        (9  <<  11)
81762306a36Sopenharmony_ci#	define R300_TX_MIN_FILTER_LINEAR_MIP_NEAREST        (6  <<  11)
81862306a36Sopenharmony_ci#	define R300_TX_MIN_FILTER_LINEAR_MIP_LINEAR         (10 <<  11)
81962306a36Sopenharmony_ci
82062306a36Sopenharmony_ci/* NOTE: NEAREST doesn't seem to exist.
82162306a36Sopenharmony_ci * Im not seting MAG_FILTER_MASK and (3 << 11) on for all
82262306a36Sopenharmony_ci * anisotropy modes because that would void selected mag filter
82362306a36Sopenharmony_ci */
82462306a36Sopenharmony_ci#	define R300_TX_MIN_FILTER_ANISO_NEAREST             (0 << 13)
82562306a36Sopenharmony_ci#	define R300_TX_MIN_FILTER_ANISO_LINEAR              (0 << 13)
82662306a36Sopenharmony_ci#	define R300_TX_MIN_FILTER_ANISO_NEAREST_MIP_NEAREST (1 << 13)
82762306a36Sopenharmony_ci#	define R300_TX_MIN_FILTER_ANISO_NEAREST_MIP_LINEAR  (2 << 13)
82862306a36Sopenharmony_ci#       define R300_TX_MIN_FILTER_MASK   ( (15 << 11) | (3 << 13) )
82962306a36Sopenharmony_ci#	define R300_TX_MAX_ANISO_1_TO_1  (0 << 21)
83062306a36Sopenharmony_ci#	define R300_TX_MAX_ANISO_2_TO_1  (2 << 21)
83162306a36Sopenharmony_ci#	define R300_TX_MAX_ANISO_4_TO_1  (4 << 21)
83262306a36Sopenharmony_ci#	define R300_TX_MAX_ANISO_8_TO_1  (6 << 21)
83362306a36Sopenharmony_ci#	define R300_TX_MAX_ANISO_16_TO_1 (8 << 21)
83462306a36Sopenharmony_ci#	define R300_TX_MAX_ANISO_MASK    (14 << 21)
83562306a36Sopenharmony_ci
83662306a36Sopenharmony_ci#define R300_TX_FILTER1_0                      0x4440
83762306a36Sopenharmony_ci#	define R300_CHROMA_KEY_MODE_DISABLE    0
83862306a36Sopenharmony_ci#	define R300_CHROMA_KEY_FORCE	       1
83962306a36Sopenharmony_ci#	define R300_CHROMA_KEY_BLEND           2
84062306a36Sopenharmony_ci#	define R300_MC_ROUND_NORMAL            (0<<2)
84162306a36Sopenharmony_ci#	define R300_MC_ROUND_MPEG4             (1<<2)
84262306a36Sopenharmony_ci#	define R300_LOD_BIAS_MASK	    0x1fff
84362306a36Sopenharmony_ci#	define R300_EDGE_ANISO_EDGE_DIAG       (0<<13)
84462306a36Sopenharmony_ci#	define R300_EDGE_ANISO_EDGE_ONLY       (1<<13)
84562306a36Sopenharmony_ci#	define R300_MC_COORD_TRUNCATE_DISABLE  (0<<14)
84662306a36Sopenharmony_ci#	define R300_MC_COORD_TRUNCATE_MPEG     (1<<14)
84762306a36Sopenharmony_ci#	define R300_TX_TRI_PERF_0_8            (0<<15)
84862306a36Sopenharmony_ci#	define R300_TX_TRI_PERF_1_8            (1<<15)
84962306a36Sopenharmony_ci#	define R300_TX_TRI_PERF_1_4            (2<<15)
85062306a36Sopenharmony_ci#	define R300_TX_TRI_PERF_3_8            (3<<15)
85162306a36Sopenharmony_ci#	define R300_ANISO_THRESHOLD_MASK       (7<<17)
85262306a36Sopenharmony_ci
85362306a36Sopenharmony_ci#define R300_TX_SIZE_0                      0x4480
85462306a36Sopenharmony_ci#       define R300_TX_WIDTHMASK_SHIFT           0
85562306a36Sopenharmony_ci#       define R300_TX_WIDTHMASK_MASK            (2047 << 0)
85662306a36Sopenharmony_ci#       define R300_TX_HEIGHTMASK_SHIFT          11
85762306a36Sopenharmony_ci#       define R300_TX_HEIGHTMASK_MASK           (2047 << 11)
85862306a36Sopenharmony_ci#       define R300_TX_UNK23                     (1 << 23)
85962306a36Sopenharmony_ci#       define R300_TX_MAX_MIP_LEVEL_SHIFT       26
86062306a36Sopenharmony_ci#       define R300_TX_MAX_MIP_LEVEL_MASK        (0xf << 26)
86162306a36Sopenharmony_ci#       define R300_TX_SIZE_PROJECTED            (1<<30)
86262306a36Sopenharmony_ci#       define R300_TX_SIZE_TXPITCH_EN           (1<<31)
86362306a36Sopenharmony_ci#define R300_TX_FORMAT_0                    0x44C0
86462306a36Sopenharmony_ci	/* The interpretation of the format word by Wladimir van der Laan */
86562306a36Sopenharmony_ci	/* The X, Y, Z and W refer to the layout of the components.
86662306a36Sopenharmony_ci	   They are given meanings as R, G, B and Alpha by the swizzle
86762306a36Sopenharmony_ci	   specification */
86862306a36Sopenharmony_ci#	define R300_TX_FORMAT_X8		    0x0
86962306a36Sopenharmony_ci#	define R300_TX_FORMAT_X16		    0x1
87062306a36Sopenharmony_ci#	define R300_TX_FORMAT_Y4X4		    0x2
87162306a36Sopenharmony_ci#	define R300_TX_FORMAT_Y8X8		    0x3
87262306a36Sopenharmony_ci#	define R300_TX_FORMAT_Y16X16		    0x4
87362306a36Sopenharmony_ci#	define R300_TX_FORMAT_Z3Y3X2		    0x5
87462306a36Sopenharmony_ci#	define R300_TX_FORMAT_Z5Y6X5		    0x6
87562306a36Sopenharmony_ci#	define R300_TX_FORMAT_Z6Y5X5		    0x7
87662306a36Sopenharmony_ci#	define R300_TX_FORMAT_Z11Y11X10		    0x8
87762306a36Sopenharmony_ci#	define R300_TX_FORMAT_Z10Y11X11		    0x9
87862306a36Sopenharmony_ci#	define R300_TX_FORMAT_W4Z4Y4X4		    0xA
87962306a36Sopenharmony_ci#	define R300_TX_FORMAT_W1Z5Y5X5		    0xB
88062306a36Sopenharmony_ci#	define R300_TX_FORMAT_W8Z8Y8X8		    0xC
88162306a36Sopenharmony_ci#	define R300_TX_FORMAT_W2Z10Y10X10	    0xD
88262306a36Sopenharmony_ci#	define R300_TX_FORMAT_W16Z16Y16X16	    0xE
88362306a36Sopenharmony_ci#	define R300_TX_FORMAT_DXT1		    0xF
88462306a36Sopenharmony_ci#	define R300_TX_FORMAT_DXT3		    0x10
88562306a36Sopenharmony_ci#	define R300_TX_FORMAT_DXT5		    0x11
88662306a36Sopenharmony_ci#	define R300_TX_FORMAT_D3DMFT_CxV8U8	    0x12     /* no swizzle */
88762306a36Sopenharmony_ci#	define R300_TX_FORMAT_A8R8G8B8		    0x13     /* no swizzle */
88862306a36Sopenharmony_ci#	define R300_TX_FORMAT_B8G8_B8G8		    0x14     /* no swizzle */
88962306a36Sopenharmony_ci#	define R300_TX_FORMAT_G8R8_G8B8		    0x15     /* no swizzle */
89062306a36Sopenharmony_ci	/* 0x16 - some 16 bit green format.. ?? */
89162306a36Sopenharmony_ci#	define R300_TX_FORMAT_UNK25		   (1 << 25) /* no swizzle */
89262306a36Sopenharmony_ci#	define R300_TX_FORMAT_CUBIC_MAP		   (1 << 26)
89362306a36Sopenharmony_ci
89462306a36Sopenharmony_ci	/* gap */
89562306a36Sopenharmony_ci	/* Floating point formats */
89662306a36Sopenharmony_ci	/* Note - hardware supports both 16 and 32 bit floating point */
89762306a36Sopenharmony_ci#	define R300_TX_FORMAT_FL_I16		    0x18
89862306a36Sopenharmony_ci#	define R300_TX_FORMAT_FL_I16A16		    0x19
89962306a36Sopenharmony_ci#	define R300_TX_FORMAT_FL_R16G16B16A16	    0x1A
90062306a36Sopenharmony_ci#	define R300_TX_FORMAT_FL_I32		    0x1B
90162306a36Sopenharmony_ci#	define R300_TX_FORMAT_FL_I32A32		    0x1C
90262306a36Sopenharmony_ci#	define R300_TX_FORMAT_FL_R32G32B32A32	    0x1D
90362306a36Sopenharmony_ci#	define R300_TX_FORMAT_ATI2N		    0x1F
90462306a36Sopenharmony_ci	/* alpha modes, convenience mostly */
90562306a36Sopenharmony_ci	/* if you have alpha, pick constant appropriate to the
90662306a36Sopenharmony_ci	   number of channels (1 for I8, 2 for I8A8, 4 for R8G8B8A8, etc */
90762306a36Sopenharmony_ci#	define R300_TX_FORMAT_ALPHA_1CH		    0x000
90862306a36Sopenharmony_ci#	define R300_TX_FORMAT_ALPHA_2CH		    0x200
90962306a36Sopenharmony_ci#	define R300_TX_FORMAT_ALPHA_4CH		    0x600
91062306a36Sopenharmony_ci#	define R300_TX_FORMAT_ALPHA_NONE	    0xA00
91162306a36Sopenharmony_ci	/* Swizzling */
91262306a36Sopenharmony_ci	/* constants */
91362306a36Sopenharmony_ci#	define R300_TX_FORMAT_X		0
91462306a36Sopenharmony_ci#	define R300_TX_FORMAT_Y		1
91562306a36Sopenharmony_ci#	define R300_TX_FORMAT_Z		2
91662306a36Sopenharmony_ci#	define R300_TX_FORMAT_W		3
91762306a36Sopenharmony_ci#	define R300_TX_FORMAT_ZERO	4
91862306a36Sopenharmony_ci#	define R300_TX_FORMAT_ONE	5
91962306a36Sopenharmony_ci	/* 2.0*Z, everything above 1.0 is set to 0.0 */
92062306a36Sopenharmony_ci#	define R300_TX_FORMAT_CUT_Z	6
92162306a36Sopenharmony_ci	/* 2.0*W, everything above 1.0 is set to 0.0 */
92262306a36Sopenharmony_ci#	define R300_TX_FORMAT_CUT_W	7
92362306a36Sopenharmony_ci
92462306a36Sopenharmony_ci#	define R300_TX_FORMAT_B_SHIFT	18
92562306a36Sopenharmony_ci#	define R300_TX_FORMAT_G_SHIFT	15
92662306a36Sopenharmony_ci#	define R300_TX_FORMAT_R_SHIFT	12
92762306a36Sopenharmony_ci#	define R300_TX_FORMAT_A_SHIFT	9
92862306a36Sopenharmony_ci	/* Convenience macro to take care of layout and swizzling */
92962306a36Sopenharmony_ci#	define R300_EASY_TX_FORMAT(B, G, R, A, FMT)	(		\
93062306a36Sopenharmony_ci		((R300_TX_FORMAT_##B)<<R300_TX_FORMAT_B_SHIFT)		\
93162306a36Sopenharmony_ci		| ((R300_TX_FORMAT_##G)<<R300_TX_FORMAT_G_SHIFT)	\
93262306a36Sopenharmony_ci		| ((R300_TX_FORMAT_##R)<<R300_TX_FORMAT_R_SHIFT)	\
93362306a36Sopenharmony_ci		| ((R300_TX_FORMAT_##A)<<R300_TX_FORMAT_A_SHIFT)	\
93462306a36Sopenharmony_ci		| (R300_TX_FORMAT_##FMT)				\
93562306a36Sopenharmony_ci		)
93662306a36Sopenharmony_ci	/* These can be ORed with result of R300_EASY_TX_FORMAT()
93762306a36Sopenharmony_ci	   We don't really know what they do. Take values from a
93862306a36Sopenharmony_ci           constant color ? */
93962306a36Sopenharmony_ci#	define R300_TX_FORMAT_CONST_X		(1<<5)
94062306a36Sopenharmony_ci#	define R300_TX_FORMAT_CONST_Y		(2<<5)
94162306a36Sopenharmony_ci#	define R300_TX_FORMAT_CONST_Z		(4<<5)
94262306a36Sopenharmony_ci#	define R300_TX_FORMAT_CONST_W		(8<<5)
94362306a36Sopenharmony_ci
94462306a36Sopenharmony_ci#	define R300_TX_FORMAT_YUV_MODE		0x00800000
94562306a36Sopenharmony_ci
94662306a36Sopenharmony_ci#define R300_TX_PITCH_0			    0x4500 /* obvious missing in gap */
94762306a36Sopenharmony_ci#define R300_TX_OFFSET_0                    0x4540
94862306a36Sopenharmony_ci	/* BEGIN: Guess from R200 */
94962306a36Sopenharmony_ci#       define R300_TXO_ENDIAN_NO_SWAP           (0 << 0)
95062306a36Sopenharmony_ci#       define R300_TXO_ENDIAN_BYTE_SWAP         (1 << 0)
95162306a36Sopenharmony_ci#       define R300_TXO_ENDIAN_WORD_SWAP         (2 << 0)
95262306a36Sopenharmony_ci#       define R300_TXO_ENDIAN_HALFDW_SWAP       (3 << 0)
95362306a36Sopenharmony_ci#       define R300_TXO_MACRO_TILE               (1 << 2)
95462306a36Sopenharmony_ci#       define R300_TXO_MICRO_TILE               (1 << 3)
95562306a36Sopenharmony_ci#       define R300_TXO_MICRO_TILE_SQUARE        (2 << 3)
95662306a36Sopenharmony_ci#       define R300_TXO_OFFSET_MASK              0xffffffe0
95762306a36Sopenharmony_ci#       define R300_TXO_OFFSET_SHIFT             5
95862306a36Sopenharmony_ci	/* END: Guess from R200 */
95962306a36Sopenharmony_ci
96062306a36Sopenharmony_ci/* 32 bit chroma key */
96162306a36Sopenharmony_ci#define R300_TX_CHROMA_KEY_0                      0x4580
96262306a36Sopenharmony_ci/* ff00ff00 == { 0, 1.0, 0, 1.0 } */
96362306a36Sopenharmony_ci#define R300_TX_BORDER_COLOR_0              0x45C0
96462306a36Sopenharmony_ci
96562306a36Sopenharmony_ci/* END: Texture specification */
96662306a36Sopenharmony_ci
96762306a36Sopenharmony_ci/* BEGIN: Fragment program instruction set */
96862306a36Sopenharmony_ci
96962306a36Sopenharmony_ci/* Fragment programs are written directly into register space.
97062306a36Sopenharmony_ci * There are separate instruction streams for texture instructions and ALU
97162306a36Sopenharmony_ci * instructions.
97262306a36Sopenharmony_ci * In order to synchronize these streams, the program is divided into up
97362306a36Sopenharmony_ci * to 4 nodes. Each node begins with a number of TEX operations, followed
97462306a36Sopenharmony_ci * by a number of ALU operations.
97562306a36Sopenharmony_ci * The first node can have zero TEX ops, all subsequent nodes must have at
97662306a36Sopenharmony_ci * least
97762306a36Sopenharmony_ci * one TEX ops.
97862306a36Sopenharmony_ci * All nodes must have at least one ALU op.
97962306a36Sopenharmony_ci *
98062306a36Sopenharmony_ci * The index of the last node is stored in PFS_CNTL_0: A value of 0 means
98162306a36Sopenharmony_ci * 1 node, a value of 3 means 4 nodes.
98262306a36Sopenharmony_ci * The total amount of instructions is defined in PFS_CNTL_2. The offsets are
98362306a36Sopenharmony_ci * offsets into the respective instruction streams, while *_END points to the
98462306a36Sopenharmony_ci * last instruction relative to this offset.
98562306a36Sopenharmony_ci */
98662306a36Sopenharmony_ci#define R300_PFS_CNTL_0                     0x4600
98762306a36Sopenharmony_ci#       define R300_PFS_CNTL_LAST_NODES_SHIFT    0
98862306a36Sopenharmony_ci#       define R300_PFS_CNTL_LAST_NODES_MASK     (3 << 0)
98962306a36Sopenharmony_ci#       define R300_PFS_CNTL_FIRST_NODE_HAS_TEX  (1 << 3)
99062306a36Sopenharmony_ci#define R300_PFS_CNTL_1                     0x4604
99162306a36Sopenharmony_ci/* There is an unshifted value here which has so far always been equal to the
99262306a36Sopenharmony_ci * index of the highest used temporary register.
99362306a36Sopenharmony_ci */
99462306a36Sopenharmony_ci#define R300_PFS_CNTL_2                     0x4608
99562306a36Sopenharmony_ci#       define R300_PFS_CNTL_ALU_OFFSET_SHIFT    0
99662306a36Sopenharmony_ci#       define R300_PFS_CNTL_ALU_OFFSET_MASK     (63 << 0)
99762306a36Sopenharmony_ci#       define R300_PFS_CNTL_ALU_END_SHIFT       6
99862306a36Sopenharmony_ci#       define R300_PFS_CNTL_ALU_END_MASK        (63 << 6)
99962306a36Sopenharmony_ci#       define R300_PFS_CNTL_TEX_OFFSET_SHIFT    12
100062306a36Sopenharmony_ci#       define R300_PFS_CNTL_TEX_OFFSET_MASK     (31 << 12) /* GUESS */
100162306a36Sopenharmony_ci#       define R300_PFS_CNTL_TEX_END_SHIFT       18
100262306a36Sopenharmony_ci#       define R300_PFS_CNTL_TEX_END_MASK        (31 << 18) /* GUESS */
100362306a36Sopenharmony_ci
100462306a36Sopenharmony_ci/* gap */
100562306a36Sopenharmony_ci
100662306a36Sopenharmony_ci/* Nodes are stored backwards. The last active node is always stored in
100762306a36Sopenharmony_ci * PFS_NODE_3.
100862306a36Sopenharmony_ci * Example: In a 2-node program, NODE_0 and NODE_1 are set to 0. The
100962306a36Sopenharmony_ci * first node is stored in NODE_2, the second node is stored in NODE_3.
101062306a36Sopenharmony_ci *
101162306a36Sopenharmony_ci * Offsets are relative to the master offset from PFS_CNTL_2.
101262306a36Sopenharmony_ci */
101362306a36Sopenharmony_ci#define R300_PFS_NODE_0                     0x4610
101462306a36Sopenharmony_ci#define R300_PFS_NODE_1                     0x4614
101562306a36Sopenharmony_ci#define R300_PFS_NODE_2                     0x4618
101662306a36Sopenharmony_ci#define R300_PFS_NODE_3                     0x461C
101762306a36Sopenharmony_ci#       define R300_PFS_NODE_ALU_OFFSET_SHIFT    0
101862306a36Sopenharmony_ci#       define R300_PFS_NODE_ALU_OFFSET_MASK     (63 << 0)
101962306a36Sopenharmony_ci#       define R300_PFS_NODE_ALU_END_SHIFT       6
102062306a36Sopenharmony_ci#       define R300_PFS_NODE_ALU_END_MASK        (63 << 6)
102162306a36Sopenharmony_ci#       define R300_PFS_NODE_TEX_OFFSET_SHIFT    12
102262306a36Sopenharmony_ci#       define R300_PFS_NODE_TEX_OFFSET_MASK     (31 << 12)
102362306a36Sopenharmony_ci#       define R300_PFS_NODE_TEX_END_SHIFT       17
102462306a36Sopenharmony_ci#       define R300_PFS_NODE_TEX_END_MASK        (31 << 17)
102562306a36Sopenharmony_ci#		define R300_PFS_NODE_OUTPUT_COLOR        (1 << 22)
102662306a36Sopenharmony_ci#		define R300_PFS_NODE_OUTPUT_DEPTH        (1 << 23)
102762306a36Sopenharmony_ci
102862306a36Sopenharmony_ci/* TEX
102962306a36Sopenharmony_ci * As far as I can tell, texture instructions cannot write into output
103062306a36Sopenharmony_ci * registers directly. A subsequent ALU instruction is always necessary,
103162306a36Sopenharmony_ci * even if it's just MAD o0, r0, 1, 0
103262306a36Sopenharmony_ci */
103362306a36Sopenharmony_ci#define R300_PFS_TEXI_0                     0x4620
103462306a36Sopenharmony_ci#	define R300_FPITX_SRC_SHIFT              0
103562306a36Sopenharmony_ci#	define R300_FPITX_SRC_MASK               (31 << 0)
103662306a36Sopenharmony_ci	/* GUESS */
103762306a36Sopenharmony_ci#	define R300_FPITX_SRC_CONST              (1 << 5)
103862306a36Sopenharmony_ci#	define R300_FPITX_DST_SHIFT              6
103962306a36Sopenharmony_ci#	define R300_FPITX_DST_MASK               (31 << 6)
104062306a36Sopenharmony_ci#	define R300_FPITX_IMAGE_SHIFT            11
104162306a36Sopenharmony_ci	/* GUESS based on layout and native limits */
104262306a36Sopenharmony_ci#       define R300_FPITX_IMAGE_MASK             (15 << 11)
104362306a36Sopenharmony_ci/* Unsure if these are opcodes, or some kind of bitfield, but this is how
104462306a36Sopenharmony_ci * they were set when I checked
104562306a36Sopenharmony_ci */
104662306a36Sopenharmony_ci#	define R300_FPITX_OPCODE_SHIFT		15
104762306a36Sopenharmony_ci#		define R300_FPITX_OP_TEX	1
104862306a36Sopenharmony_ci#		define R300_FPITX_OP_KIL	2
104962306a36Sopenharmony_ci#		define R300_FPITX_OP_TXP	3
105062306a36Sopenharmony_ci#		define R300_FPITX_OP_TXB	4
105162306a36Sopenharmony_ci#	define R300_FPITX_OPCODE_MASK           (7 << 15)
105262306a36Sopenharmony_ci
105362306a36Sopenharmony_ci/* ALU
105462306a36Sopenharmony_ci * The ALU instructions register blocks are enumerated according to the order
105562306a36Sopenharmony_ci * in which fglrx. I assume there is space for 64 instructions, since
105662306a36Sopenharmony_ci * each block has space for a maximum of 64 DWORDs, and this matches reported
105762306a36Sopenharmony_ci * native limits.
105862306a36Sopenharmony_ci *
105962306a36Sopenharmony_ci * The basic functional block seems to be one MAD for each color and alpha,
106062306a36Sopenharmony_ci * and an adder that adds all components after the MUL.
106162306a36Sopenharmony_ci *  - ADD, MUL, MAD etc.: use MAD with appropriate neutral operands
106262306a36Sopenharmony_ci *  - DP4: Use OUTC_DP4, OUTA_DP4
106362306a36Sopenharmony_ci *  - DP3: Use OUTC_DP3, OUTA_DP4, appropriate alpha operands
106462306a36Sopenharmony_ci *  - DPH: Use OUTC_DP4, OUTA_DP4, appropriate alpha operands
106562306a36Sopenharmony_ci *  - CMPH: If ARG2 > 0.5, return ARG0, else return ARG1
106662306a36Sopenharmony_ci *  - CMP: If ARG2 < 0, return ARG1, else return ARG0
106762306a36Sopenharmony_ci *  - FLR: use FRC+MAD
106862306a36Sopenharmony_ci *  - XPD: use MAD+MAD
106962306a36Sopenharmony_ci *  - SGE, SLT: use MAD+CMP
107062306a36Sopenharmony_ci *  - RSQ: use ABS modifier for argument
107162306a36Sopenharmony_ci *  - Use OUTC_REPL_ALPHA to write results of an alpha-only operation
107262306a36Sopenharmony_ci *    (e.g. RCP) into color register
107362306a36Sopenharmony_ci *  - apparently, there's no quick DST operation
107462306a36Sopenharmony_ci *  - fglrx set FPI2_UNKNOWN_31 on a "MAD fragment.color, tmp0, tmp1, tmp2"
107562306a36Sopenharmony_ci *  - fglrx set FPI2_UNKNOWN_31 on a "MAX r2, r1, c0"
107662306a36Sopenharmony_ci *  - fglrx once set FPI0_UNKNOWN_31 on a "FRC r1, r1"
107762306a36Sopenharmony_ci *
107862306a36Sopenharmony_ci * Operand selection
107962306a36Sopenharmony_ci * First stage selects three sources from the available registers and
108062306a36Sopenharmony_ci * constant parameters. This is defined in INSTR1 (color) and INSTR3 (alpha).
108162306a36Sopenharmony_ci * fglrx sorts the three source fields: Registers before constants,
108262306a36Sopenharmony_ci * lower indices before higher indices; I do not know whether this is
108362306a36Sopenharmony_ci * necessary.
108462306a36Sopenharmony_ci *
108562306a36Sopenharmony_ci * fglrx fills unused sources with "read constant 0"
108662306a36Sopenharmony_ci * According to specs, you cannot select more than two different constants.
108762306a36Sopenharmony_ci *
108862306a36Sopenharmony_ci * Second stage selects the operands from the sources. This is defined in
108962306a36Sopenharmony_ci * INSTR0 (color) and INSTR2 (alpha). You can also select the special constants
109062306a36Sopenharmony_ci * zero and one.
109162306a36Sopenharmony_ci * Swizzling and negation happens in this stage, as well.
109262306a36Sopenharmony_ci *
109362306a36Sopenharmony_ci * Important: Color and alpha seem to be mostly separate, i.e. their sources
109462306a36Sopenharmony_ci * selection appears to be fully independent (the register storage is probably
109562306a36Sopenharmony_ci * physically split into a color and an alpha section).
109662306a36Sopenharmony_ci * However (because of the apparent physical split), there is some interaction
109762306a36Sopenharmony_ci * WRT swizzling. If, for example, you want to load an R component into an
109862306a36Sopenharmony_ci * Alpha operand, this R component is taken from a *color* source, not from
109962306a36Sopenharmony_ci * an alpha source. The corresponding register doesn't even have to appear in
110062306a36Sopenharmony_ci * the alpha sources list. (I hope this all makes sense to you)
110162306a36Sopenharmony_ci *
110262306a36Sopenharmony_ci * Destination selection
110362306a36Sopenharmony_ci * The destination register index is in FPI1 (color) and FPI3 (alpha)
110462306a36Sopenharmony_ci * together with enable bits.
110562306a36Sopenharmony_ci * There are separate enable bits for writing into temporary registers
110662306a36Sopenharmony_ci * (DSTC_REG_* /DSTA_REG) and program output registers (DSTC_OUTPUT_*
110762306a36Sopenharmony_ci * /DSTA_OUTPUT). You can write to both at once, or not write at all (the
110862306a36Sopenharmony_ci * same index must be used for both).
110962306a36Sopenharmony_ci *
111062306a36Sopenharmony_ci * Note: There is a special form for LRP
111162306a36Sopenharmony_ci *  - Argument order is the same as in ARB_fragment_program.
111262306a36Sopenharmony_ci *  - Operation is MAD
111362306a36Sopenharmony_ci *  - ARG1 is set to ARGC_SRC1C_LRP/ARGC_SRC1A_LRP
111462306a36Sopenharmony_ci *  - Set FPI0/FPI2_SPECIAL_LRP
111562306a36Sopenharmony_ci * Arbitrary LRP (including support for swizzling) requires vanilla MAD+MAD
111662306a36Sopenharmony_ci */
111762306a36Sopenharmony_ci#define R300_PFS_INSTR1_0                   0x46C0
111862306a36Sopenharmony_ci#       define R300_FPI1_SRC0C_SHIFT             0
111962306a36Sopenharmony_ci#       define R300_FPI1_SRC0C_MASK              (31 << 0)
112062306a36Sopenharmony_ci#       define R300_FPI1_SRC0C_CONST             (1 << 5)
112162306a36Sopenharmony_ci#       define R300_FPI1_SRC1C_SHIFT             6
112262306a36Sopenharmony_ci#       define R300_FPI1_SRC1C_MASK              (31 << 6)
112362306a36Sopenharmony_ci#       define R300_FPI1_SRC1C_CONST             (1 << 11)
112462306a36Sopenharmony_ci#       define R300_FPI1_SRC2C_SHIFT             12
112562306a36Sopenharmony_ci#       define R300_FPI1_SRC2C_MASK              (31 << 12)
112662306a36Sopenharmony_ci#       define R300_FPI1_SRC2C_CONST             (1 << 17)
112762306a36Sopenharmony_ci#       define R300_FPI1_SRC_MASK                0x0003ffff
112862306a36Sopenharmony_ci#       define R300_FPI1_DSTC_SHIFT              18
112962306a36Sopenharmony_ci#       define R300_FPI1_DSTC_MASK               (31 << 18)
113062306a36Sopenharmony_ci#		define R300_FPI1_DSTC_REG_MASK_SHIFT     23
113162306a36Sopenharmony_ci#       define R300_FPI1_DSTC_REG_X              (1 << 23)
113262306a36Sopenharmony_ci#       define R300_FPI1_DSTC_REG_Y              (1 << 24)
113362306a36Sopenharmony_ci#       define R300_FPI1_DSTC_REG_Z              (1 << 25)
113462306a36Sopenharmony_ci#		define R300_FPI1_DSTC_OUTPUT_MASK_SHIFT  26
113562306a36Sopenharmony_ci#       define R300_FPI1_DSTC_OUTPUT_X           (1 << 26)
113662306a36Sopenharmony_ci#       define R300_FPI1_DSTC_OUTPUT_Y           (1 << 27)
113762306a36Sopenharmony_ci#       define R300_FPI1_DSTC_OUTPUT_Z           (1 << 28)
113862306a36Sopenharmony_ci
113962306a36Sopenharmony_ci#define R300_PFS_INSTR3_0                   0x47C0
114062306a36Sopenharmony_ci#       define R300_FPI3_SRC0A_SHIFT             0
114162306a36Sopenharmony_ci#       define R300_FPI3_SRC0A_MASK              (31 << 0)
114262306a36Sopenharmony_ci#       define R300_FPI3_SRC0A_CONST             (1 << 5)
114362306a36Sopenharmony_ci#       define R300_FPI3_SRC1A_SHIFT             6
114462306a36Sopenharmony_ci#       define R300_FPI3_SRC1A_MASK              (31 << 6)
114562306a36Sopenharmony_ci#       define R300_FPI3_SRC1A_CONST             (1 << 11)
114662306a36Sopenharmony_ci#       define R300_FPI3_SRC2A_SHIFT             12
114762306a36Sopenharmony_ci#       define R300_FPI3_SRC2A_MASK              (31 << 12)
114862306a36Sopenharmony_ci#       define R300_FPI3_SRC2A_CONST             (1 << 17)
114962306a36Sopenharmony_ci#       define R300_FPI3_SRC_MASK                0x0003ffff
115062306a36Sopenharmony_ci#       define R300_FPI3_DSTA_SHIFT              18
115162306a36Sopenharmony_ci#       define R300_FPI3_DSTA_MASK               (31 << 18)
115262306a36Sopenharmony_ci#       define R300_FPI3_DSTA_REG                (1 << 23)
115362306a36Sopenharmony_ci#       define R300_FPI3_DSTA_OUTPUT             (1 << 24)
115462306a36Sopenharmony_ci#		define R300_FPI3_DSTA_DEPTH              (1 << 27)
115562306a36Sopenharmony_ci
115662306a36Sopenharmony_ci#define R300_PFS_INSTR0_0                   0x48C0
115762306a36Sopenharmony_ci#       define R300_FPI0_ARGC_SRC0C_XYZ          0
115862306a36Sopenharmony_ci#       define R300_FPI0_ARGC_SRC0C_XXX          1
115962306a36Sopenharmony_ci#       define R300_FPI0_ARGC_SRC0C_YYY          2
116062306a36Sopenharmony_ci#       define R300_FPI0_ARGC_SRC0C_ZZZ          3
116162306a36Sopenharmony_ci#       define R300_FPI0_ARGC_SRC1C_XYZ          4
116262306a36Sopenharmony_ci#       define R300_FPI0_ARGC_SRC1C_XXX          5
116362306a36Sopenharmony_ci#       define R300_FPI0_ARGC_SRC1C_YYY          6
116462306a36Sopenharmony_ci#       define R300_FPI0_ARGC_SRC1C_ZZZ          7
116562306a36Sopenharmony_ci#       define R300_FPI0_ARGC_SRC2C_XYZ          8
116662306a36Sopenharmony_ci#       define R300_FPI0_ARGC_SRC2C_XXX          9
116762306a36Sopenharmony_ci#       define R300_FPI0_ARGC_SRC2C_YYY          10
116862306a36Sopenharmony_ci#       define R300_FPI0_ARGC_SRC2C_ZZZ          11
116962306a36Sopenharmony_ci#       define R300_FPI0_ARGC_SRC0A              12
117062306a36Sopenharmony_ci#       define R300_FPI0_ARGC_SRC1A              13
117162306a36Sopenharmony_ci#       define R300_FPI0_ARGC_SRC2A              14
117262306a36Sopenharmony_ci#       define R300_FPI0_ARGC_SRC1C_LRP          15
117362306a36Sopenharmony_ci#       define R300_FPI0_ARGC_ZERO               20
117462306a36Sopenharmony_ci#       define R300_FPI0_ARGC_ONE                21
117562306a36Sopenharmony_ci	/* GUESS */
117662306a36Sopenharmony_ci#       define R300_FPI0_ARGC_HALF               22
117762306a36Sopenharmony_ci#       define R300_FPI0_ARGC_SRC0C_YZX          23
117862306a36Sopenharmony_ci#       define R300_FPI0_ARGC_SRC1C_YZX          24
117962306a36Sopenharmony_ci#       define R300_FPI0_ARGC_SRC2C_YZX          25
118062306a36Sopenharmony_ci#       define R300_FPI0_ARGC_SRC0C_ZXY          26
118162306a36Sopenharmony_ci#       define R300_FPI0_ARGC_SRC1C_ZXY          27
118262306a36Sopenharmony_ci#       define R300_FPI0_ARGC_SRC2C_ZXY          28
118362306a36Sopenharmony_ci#       define R300_FPI0_ARGC_SRC0CA_WZY         29
118462306a36Sopenharmony_ci#       define R300_FPI0_ARGC_SRC1CA_WZY         30
118562306a36Sopenharmony_ci#       define R300_FPI0_ARGC_SRC2CA_WZY         31
118662306a36Sopenharmony_ci
118762306a36Sopenharmony_ci#       define R300_FPI0_ARG0C_SHIFT             0
118862306a36Sopenharmony_ci#       define R300_FPI0_ARG0C_MASK              (31 << 0)
118962306a36Sopenharmony_ci#       define R300_FPI0_ARG0C_NEG               (1 << 5)
119062306a36Sopenharmony_ci#       define R300_FPI0_ARG0C_ABS               (1 << 6)
119162306a36Sopenharmony_ci#       define R300_FPI0_ARG1C_SHIFT             7
119262306a36Sopenharmony_ci#       define R300_FPI0_ARG1C_MASK              (31 << 7)
119362306a36Sopenharmony_ci#       define R300_FPI0_ARG1C_NEG               (1 << 12)
119462306a36Sopenharmony_ci#       define R300_FPI0_ARG1C_ABS               (1 << 13)
119562306a36Sopenharmony_ci#       define R300_FPI0_ARG2C_SHIFT             14
119662306a36Sopenharmony_ci#       define R300_FPI0_ARG2C_MASK              (31 << 14)
119762306a36Sopenharmony_ci#       define R300_FPI0_ARG2C_NEG               (1 << 19)
119862306a36Sopenharmony_ci#       define R300_FPI0_ARG2C_ABS               (1 << 20)
119962306a36Sopenharmony_ci#       define R300_FPI0_SPECIAL_LRP             (1 << 21)
120062306a36Sopenharmony_ci#       define R300_FPI0_OUTC_MAD                (0 << 23)
120162306a36Sopenharmony_ci#       define R300_FPI0_OUTC_DP3                (1 << 23)
120262306a36Sopenharmony_ci#       define R300_FPI0_OUTC_DP4                (2 << 23)
120362306a36Sopenharmony_ci#       define R300_FPI0_OUTC_MIN                (4 << 23)
120462306a36Sopenharmony_ci#       define R300_FPI0_OUTC_MAX                (5 << 23)
120562306a36Sopenharmony_ci#       define R300_FPI0_OUTC_CMPH               (7 << 23)
120662306a36Sopenharmony_ci#       define R300_FPI0_OUTC_CMP                (8 << 23)
120762306a36Sopenharmony_ci#       define R300_FPI0_OUTC_FRC                (9 << 23)
120862306a36Sopenharmony_ci#       define R300_FPI0_OUTC_REPL_ALPHA         (10 << 23)
120962306a36Sopenharmony_ci#       define R300_FPI0_OUTC_SAT                (1 << 30)
121062306a36Sopenharmony_ci#       define R300_FPI0_INSERT_NOP              (1 << 31)
121162306a36Sopenharmony_ci
121262306a36Sopenharmony_ci#define R300_PFS_INSTR2_0                   0x49C0
121362306a36Sopenharmony_ci#       define R300_FPI2_ARGA_SRC0C_X            0
121462306a36Sopenharmony_ci#       define R300_FPI2_ARGA_SRC0C_Y            1
121562306a36Sopenharmony_ci#       define R300_FPI2_ARGA_SRC0C_Z            2
121662306a36Sopenharmony_ci#       define R300_FPI2_ARGA_SRC1C_X            3
121762306a36Sopenharmony_ci#       define R300_FPI2_ARGA_SRC1C_Y            4
121862306a36Sopenharmony_ci#       define R300_FPI2_ARGA_SRC1C_Z            5
121962306a36Sopenharmony_ci#       define R300_FPI2_ARGA_SRC2C_X            6
122062306a36Sopenharmony_ci#       define R300_FPI2_ARGA_SRC2C_Y            7
122162306a36Sopenharmony_ci#       define R300_FPI2_ARGA_SRC2C_Z            8
122262306a36Sopenharmony_ci#       define R300_FPI2_ARGA_SRC0A              9
122362306a36Sopenharmony_ci#       define R300_FPI2_ARGA_SRC1A              10
122462306a36Sopenharmony_ci#       define R300_FPI2_ARGA_SRC2A              11
122562306a36Sopenharmony_ci#       define R300_FPI2_ARGA_SRC1A_LRP          15
122662306a36Sopenharmony_ci#       define R300_FPI2_ARGA_ZERO               16
122762306a36Sopenharmony_ci#       define R300_FPI2_ARGA_ONE                17
122862306a36Sopenharmony_ci	/* GUESS */
122962306a36Sopenharmony_ci#       define R300_FPI2_ARGA_HALF               18
123062306a36Sopenharmony_ci#       define R300_FPI2_ARG0A_SHIFT             0
123162306a36Sopenharmony_ci#       define R300_FPI2_ARG0A_MASK              (31 << 0)
123262306a36Sopenharmony_ci#       define R300_FPI2_ARG0A_NEG               (1 << 5)
123362306a36Sopenharmony_ci	/* GUESS */
123462306a36Sopenharmony_ci#	define R300_FPI2_ARG0A_ABS		 (1 << 6)
123562306a36Sopenharmony_ci#       define R300_FPI2_ARG1A_SHIFT             7
123662306a36Sopenharmony_ci#       define R300_FPI2_ARG1A_MASK              (31 << 7)
123762306a36Sopenharmony_ci#       define R300_FPI2_ARG1A_NEG               (1 << 12)
123862306a36Sopenharmony_ci	/* GUESS */
123962306a36Sopenharmony_ci#	define R300_FPI2_ARG1A_ABS		 (1 << 13)
124062306a36Sopenharmony_ci#       define R300_FPI2_ARG2A_SHIFT             14
124162306a36Sopenharmony_ci#       define R300_FPI2_ARG2A_MASK              (31 << 14)
124262306a36Sopenharmony_ci#       define R300_FPI2_ARG2A_NEG               (1 << 19)
124362306a36Sopenharmony_ci	/* GUESS */
124462306a36Sopenharmony_ci#	define R300_FPI2_ARG2A_ABS		 (1 << 20)
124562306a36Sopenharmony_ci#       define R300_FPI2_SPECIAL_LRP             (1 << 21)
124662306a36Sopenharmony_ci#       define R300_FPI2_OUTA_MAD                (0 << 23)
124762306a36Sopenharmony_ci#       define R300_FPI2_OUTA_DP4                (1 << 23)
124862306a36Sopenharmony_ci#       define R300_FPI2_OUTA_MIN                (2 << 23)
124962306a36Sopenharmony_ci#       define R300_FPI2_OUTA_MAX                (3 << 23)
125062306a36Sopenharmony_ci#       define R300_FPI2_OUTA_CMP                (6 << 23)
125162306a36Sopenharmony_ci#       define R300_FPI2_OUTA_FRC                (7 << 23)
125262306a36Sopenharmony_ci#       define R300_FPI2_OUTA_EX2                (8 << 23)
125362306a36Sopenharmony_ci#       define R300_FPI2_OUTA_LG2                (9 << 23)
125462306a36Sopenharmony_ci#       define R300_FPI2_OUTA_RCP                (10 << 23)
125562306a36Sopenharmony_ci#       define R300_FPI2_OUTA_RSQ                (11 << 23)
125662306a36Sopenharmony_ci#       define R300_FPI2_OUTA_SAT                (1 << 30)
125762306a36Sopenharmony_ci#       define R300_FPI2_UNKNOWN_31              (1 << 31)
125862306a36Sopenharmony_ci/* END: Fragment program instruction set */
125962306a36Sopenharmony_ci
126062306a36Sopenharmony_ci/* Fog state and color */
126162306a36Sopenharmony_ci#define R300_RE_FOG_STATE                   0x4BC0
126262306a36Sopenharmony_ci#       define R300_FOG_ENABLE                   (1 << 0)
126362306a36Sopenharmony_ci#	define R300_FOG_MODE_LINEAR              (0 << 1)
126462306a36Sopenharmony_ci#	define R300_FOG_MODE_EXP                 (1 << 1)
126562306a36Sopenharmony_ci#	define R300_FOG_MODE_EXP2                (2 << 1)
126662306a36Sopenharmony_ci#	define R300_FOG_MODE_MASK                (3 << 1)
126762306a36Sopenharmony_ci#define R300_FOG_COLOR_R                    0x4BC8
126862306a36Sopenharmony_ci#define R300_FOG_COLOR_G                    0x4BCC
126962306a36Sopenharmony_ci#define R300_FOG_COLOR_B                    0x4BD0
127062306a36Sopenharmony_ci
127162306a36Sopenharmony_ci#define R300_PP_ALPHA_TEST                  0x4BD4
127262306a36Sopenharmony_ci#       define R300_REF_ALPHA_MASK               0x000000ff
127362306a36Sopenharmony_ci#       define R300_ALPHA_TEST_FAIL              (0 << 8)
127462306a36Sopenharmony_ci#       define R300_ALPHA_TEST_LESS              (1 << 8)
127562306a36Sopenharmony_ci#       define R300_ALPHA_TEST_LEQUAL            (3 << 8)
127662306a36Sopenharmony_ci#       define R300_ALPHA_TEST_EQUAL             (2 << 8)
127762306a36Sopenharmony_ci#       define R300_ALPHA_TEST_GEQUAL            (6 << 8)
127862306a36Sopenharmony_ci#       define R300_ALPHA_TEST_GREATER           (4 << 8)
127962306a36Sopenharmony_ci#       define R300_ALPHA_TEST_NEQUAL            (5 << 8)
128062306a36Sopenharmony_ci#       define R300_ALPHA_TEST_PASS              (7 << 8)
128162306a36Sopenharmony_ci#       define R300_ALPHA_TEST_OP_MASK           (7 << 8)
128262306a36Sopenharmony_ci#       define R300_ALPHA_TEST_ENABLE            (1 << 11)
128362306a36Sopenharmony_ci
128462306a36Sopenharmony_ci/* gap */
128562306a36Sopenharmony_ci
128662306a36Sopenharmony_ci/* Fragment program parameters in 7.16 floating point */
128762306a36Sopenharmony_ci#define R300_PFS_PARAM_0_X                  0x4C00
128862306a36Sopenharmony_ci#define R300_PFS_PARAM_0_Y                  0x4C04
128962306a36Sopenharmony_ci#define R300_PFS_PARAM_0_Z                  0x4C08
129062306a36Sopenharmony_ci#define R300_PFS_PARAM_0_W                  0x4C0C
129162306a36Sopenharmony_ci/* GUESS: PARAM_31 is last, based on native limits reported by fglrx */
129262306a36Sopenharmony_ci#define R300_PFS_PARAM_31_X                 0x4DF0
129362306a36Sopenharmony_ci#define R300_PFS_PARAM_31_Y                 0x4DF4
129462306a36Sopenharmony_ci#define R300_PFS_PARAM_31_Z                 0x4DF8
129562306a36Sopenharmony_ci#define R300_PFS_PARAM_31_W                 0x4DFC
129662306a36Sopenharmony_ci
129762306a36Sopenharmony_ci/* Notes:
129862306a36Sopenharmony_ci * - AFAIK fglrx always sets BLEND_UNKNOWN when blending is used in
129962306a36Sopenharmony_ci *   the application
130062306a36Sopenharmony_ci * - AFAIK fglrx always sets BLEND_NO_SEPARATE when CBLEND and ABLEND
130162306a36Sopenharmony_ci *    are set to the same
130262306a36Sopenharmony_ci *   function (both registers are always set up completely in any case)
130362306a36Sopenharmony_ci * - Most blend flags are simply copied from R200 and not tested yet
130462306a36Sopenharmony_ci */
130562306a36Sopenharmony_ci#define R300_RB3D_CBLEND                    0x4E04
130662306a36Sopenharmony_ci#define R300_RB3D_ABLEND                    0x4E08
130762306a36Sopenharmony_ci/* the following only appear in CBLEND */
130862306a36Sopenharmony_ci#       define R300_BLEND_ENABLE                     (1 << 0)
130962306a36Sopenharmony_ci#       define R300_BLEND_UNKNOWN                    (3 << 1)
131062306a36Sopenharmony_ci#       define R300_BLEND_NO_SEPARATE                (1 << 3)
131162306a36Sopenharmony_ci/* the following are shared between CBLEND and ABLEND */
131262306a36Sopenharmony_ci#       define R300_FCN_MASK                         (3  << 12)
131362306a36Sopenharmony_ci#       define R300_COMB_FCN_ADD_CLAMP               (0  << 12)
131462306a36Sopenharmony_ci#       define R300_COMB_FCN_ADD_NOCLAMP             (1  << 12)
131562306a36Sopenharmony_ci#       define R300_COMB_FCN_SUB_CLAMP               (2  << 12)
131662306a36Sopenharmony_ci#       define R300_COMB_FCN_SUB_NOCLAMP             (3  << 12)
131762306a36Sopenharmony_ci#       define R300_COMB_FCN_MIN                     (4  << 12)
131862306a36Sopenharmony_ci#       define R300_COMB_FCN_MAX                     (5  << 12)
131962306a36Sopenharmony_ci#       define R300_COMB_FCN_RSUB_CLAMP              (6  << 12)
132062306a36Sopenharmony_ci#       define R300_COMB_FCN_RSUB_NOCLAMP            (7  << 12)
132162306a36Sopenharmony_ci#       define R300_BLEND_GL_ZERO                    (32)
132262306a36Sopenharmony_ci#       define R300_BLEND_GL_ONE                     (33)
132362306a36Sopenharmony_ci#       define R300_BLEND_GL_SRC_COLOR               (34)
132462306a36Sopenharmony_ci#       define R300_BLEND_GL_ONE_MINUS_SRC_COLOR     (35)
132562306a36Sopenharmony_ci#       define R300_BLEND_GL_DST_COLOR               (36)
132662306a36Sopenharmony_ci#       define R300_BLEND_GL_ONE_MINUS_DST_COLOR     (37)
132762306a36Sopenharmony_ci#       define R300_BLEND_GL_SRC_ALPHA               (38)
132862306a36Sopenharmony_ci#       define R300_BLEND_GL_ONE_MINUS_SRC_ALPHA     (39)
132962306a36Sopenharmony_ci#       define R300_BLEND_GL_DST_ALPHA               (40)
133062306a36Sopenharmony_ci#       define R300_BLEND_GL_ONE_MINUS_DST_ALPHA     (41)
133162306a36Sopenharmony_ci#       define R300_BLEND_GL_SRC_ALPHA_SATURATE      (42)
133262306a36Sopenharmony_ci#       define R300_BLEND_GL_CONST_COLOR             (43)
133362306a36Sopenharmony_ci#       define R300_BLEND_GL_ONE_MINUS_CONST_COLOR   (44)
133462306a36Sopenharmony_ci#       define R300_BLEND_GL_CONST_ALPHA             (45)
133562306a36Sopenharmony_ci#       define R300_BLEND_GL_ONE_MINUS_CONST_ALPHA   (46)
133662306a36Sopenharmony_ci#       define R300_BLEND_MASK                       (63)
133762306a36Sopenharmony_ci#       define R300_SRC_BLEND_SHIFT                  (16)
133862306a36Sopenharmony_ci#       define R300_DST_BLEND_SHIFT                  (24)
133962306a36Sopenharmony_ci#define R300_RB3D_BLEND_COLOR               0x4E10
134062306a36Sopenharmony_ci#define R300_RB3D_COLORMASK                 0x4E0C
134162306a36Sopenharmony_ci#       define R300_COLORMASK0_B                 (1<<0)
134262306a36Sopenharmony_ci#       define R300_COLORMASK0_G                 (1<<1)
134362306a36Sopenharmony_ci#       define R300_COLORMASK0_R                 (1<<2)
134462306a36Sopenharmony_ci#       define R300_COLORMASK0_A                 (1<<3)
134562306a36Sopenharmony_ci
134662306a36Sopenharmony_ci/* gap */
134762306a36Sopenharmony_ci
134862306a36Sopenharmony_ci#define R300_RB3D_COLOROFFSET0              0x4E28
134962306a36Sopenharmony_ci#       define R300_COLOROFFSET_MASK             0xFFFFFFF0 /* GUESS */
135062306a36Sopenharmony_ci#define R300_RB3D_COLOROFFSET1              0x4E2C /* GUESS */
135162306a36Sopenharmony_ci#define R300_RB3D_COLOROFFSET2              0x4E30 /* GUESS */
135262306a36Sopenharmony_ci#define R300_RB3D_COLOROFFSET3              0x4E34 /* GUESS */
135362306a36Sopenharmony_ci
135462306a36Sopenharmony_ci/* gap */
135562306a36Sopenharmony_ci
135662306a36Sopenharmony_ci/* Bit 16: Larger tiles
135762306a36Sopenharmony_ci * Bit 17: 4x2 tiles
135862306a36Sopenharmony_ci * Bit 18: Extremely weird tile like, but some pixels duplicated?
135962306a36Sopenharmony_ci */
136062306a36Sopenharmony_ci#define R300_RB3D_COLORPITCH0               0x4E38
136162306a36Sopenharmony_ci#       define R300_COLORPITCH_MASK              0x00001FF8 /* GUESS */
136262306a36Sopenharmony_ci#       define R300_COLOR_TILE_ENABLE            (1 << 16) /* GUESS */
136362306a36Sopenharmony_ci#       define R300_COLOR_MICROTILE_ENABLE       (1 << 17) /* GUESS */
136462306a36Sopenharmony_ci#       define R300_COLOR_MICROTILE_SQUARE_ENABLE (2 << 17)
136562306a36Sopenharmony_ci#       define R300_COLOR_ENDIAN_NO_SWAP         (0 << 18) /* GUESS */
136662306a36Sopenharmony_ci#       define R300_COLOR_ENDIAN_WORD_SWAP       (1 << 18) /* GUESS */
136762306a36Sopenharmony_ci#       define R300_COLOR_ENDIAN_DWORD_SWAP      (2 << 18) /* GUESS */
136862306a36Sopenharmony_ci#       define R300_COLOR_FORMAT_RGB565          (2 << 22)
136962306a36Sopenharmony_ci#       define R300_COLOR_FORMAT_ARGB8888        (3 << 22)
137062306a36Sopenharmony_ci#define R300_RB3D_COLORPITCH1               0x4E3C /* GUESS */
137162306a36Sopenharmony_ci#define R300_RB3D_COLORPITCH2               0x4E40 /* GUESS */
137262306a36Sopenharmony_ci#define R300_RB3D_COLORPITCH3               0x4E44 /* GUESS */
137362306a36Sopenharmony_ci
137462306a36Sopenharmony_ci#define R300_RB3D_AARESOLVE_OFFSET          0x4E80
137562306a36Sopenharmony_ci#define R300_RB3D_AARESOLVE_PITCH           0x4E84
137662306a36Sopenharmony_ci#define R300_RB3D_AARESOLVE_CTL             0x4E88
137762306a36Sopenharmony_ci/* gap */
137862306a36Sopenharmony_ci
137962306a36Sopenharmony_ci/* Guess by Vladimir.
138062306a36Sopenharmony_ci * Set to 0A before 3D operations, set to 02 afterwards.
138162306a36Sopenharmony_ci */
138262306a36Sopenharmony_ci/*#define R300_RB3D_DSTCACHE_CTLSTAT          0x4E4C*/
138362306a36Sopenharmony_ci#       define R300_RB3D_DSTCACHE_UNKNOWN_02             0x00000002
138462306a36Sopenharmony_ci#       define R300_RB3D_DSTCACHE_UNKNOWN_0A             0x0000000A
138562306a36Sopenharmony_ci
138662306a36Sopenharmony_ci/* gap */
138762306a36Sopenharmony_ci/* There seems to be no "write only" setting, so use Z-test = ALWAYS
138862306a36Sopenharmony_ci * for this.
138962306a36Sopenharmony_ci * Bit (1<<8) is the "test" bit. so plain write is 6  - vd
139062306a36Sopenharmony_ci */
139162306a36Sopenharmony_ci#define R300_ZB_CNTL                             0x4F00
139262306a36Sopenharmony_ci#	define R300_STENCIL_ENABLE		 (1 << 0)
139362306a36Sopenharmony_ci#	define R300_Z_ENABLE		         (1 << 1)
139462306a36Sopenharmony_ci#	define R300_Z_WRITE_ENABLE		 (1 << 2)
139562306a36Sopenharmony_ci#	define R300_Z_SIGNED_COMPARE		 (1 << 3)
139662306a36Sopenharmony_ci#	define R300_STENCIL_FRONT_BACK		 (1 << 4)
139762306a36Sopenharmony_ci
139862306a36Sopenharmony_ci#define R300_ZB_ZSTENCILCNTL                   0x4f04
139962306a36Sopenharmony_ci	/* functions */
140062306a36Sopenharmony_ci#	define R300_ZS_NEVER			0
140162306a36Sopenharmony_ci#	define R300_ZS_LESS			1
140262306a36Sopenharmony_ci#	define R300_ZS_LEQUAL			2
140362306a36Sopenharmony_ci#	define R300_ZS_EQUAL			3
140462306a36Sopenharmony_ci#	define R300_ZS_GEQUAL			4
140562306a36Sopenharmony_ci#	define R300_ZS_GREATER			5
140662306a36Sopenharmony_ci#	define R300_ZS_NOTEQUAL			6
140762306a36Sopenharmony_ci#	define R300_ZS_ALWAYS			7
140862306a36Sopenharmony_ci#       define R300_ZS_MASK                     7
140962306a36Sopenharmony_ci	/* operations */
141062306a36Sopenharmony_ci#	define R300_ZS_KEEP			0
141162306a36Sopenharmony_ci#	define R300_ZS_ZERO			1
141262306a36Sopenharmony_ci#	define R300_ZS_REPLACE			2
141362306a36Sopenharmony_ci#	define R300_ZS_INCR			3
141462306a36Sopenharmony_ci#	define R300_ZS_DECR			4
141562306a36Sopenharmony_ci#	define R300_ZS_INVERT			5
141662306a36Sopenharmony_ci#	define R300_ZS_INCR_WRAP		6
141762306a36Sopenharmony_ci#	define R300_ZS_DECR_WRAP		7
141862306a36Sopenharmony_ci#	define R300_Z_FUNC_SHIFT		0
141962306a36Sopenharmony_ci	/* front and back refer to operations done for front
142062306a36Sopenharmony_ci	   and back faces, i.e. separate stencil function support */
142162306a36Sopenharmony_ci#	define R300_S_FRONT_FUNC_SHIFT	        3
142262306a36Sopenharmony_ci#	define R300_S_FRONT_SFAIL_OP_SHIFT	6
142362306a36Sopenharmony_ci#	define R300_S_FRONT_ZPASS_OP_SHIFT	9
142462306a36Sopenharmony_ci#	define R300_S_FRONT_ZFAIL_OP_SHIFT      12
142562306a36Sopenharmony_ci#	define R300_S_BACK_FUNC_SHIFT           15
142662306a36Sopenharmony_ci#	define R300_S_BACK_SFAIL_OP_SHIFT       18
142762306a36Sopenharmony_ci#	define R300_S_BACK_ZPASS_OP_SHIFT       21
142862306a36Sopenharmony_ci#	define R300_S_BACK_ZFAIL_OP_SHIFT       24
142962306a36Sopenharmony_ci
143062306a36Sopenharmony_ci#define R300_ZB_STENCILREFMASK                        0x4f08
143162306a36Sopenharmony_ci#	define R300_STENCILREF_SHIFT       0
143262306a36Sopenharmony_ci#	define R300_STENCILREF_MASK        0x000000ff
143362306a36Sopenharmony_ci#	define R300_STENCILMASK_SHIFT      8
143462306a36Sopenharmony_ci#	define R300_STENCILMASK_MASK       0x0000ff00
143562306a36Sopenharmony_ci#	define R300_STENCILWRITEMASK_SHIFT 16
143662306a36Sopenharmony_ci#	define R300_STENCILWRITEMASK_MASK  0x00ff0000
143762306a36Sopenharmony_ci
143862306a36Sopenharmony_ci/* gap */
143962306a36Sopenharmony_ci
144062306a36Sopenharmony_ci#define R300_ZB_FORMAT                             0x4f10
144162306a36Sopenharmony_ci#	define R300_DEPTHFORMAT_16BIT_INT_Z   (0 << 0)
144262306a36Sopenharmony_ci#	define R300_DEPTHFORMAT_16BIT_13E3    (1 << 0)
144362306a36Sopenharmony_ci#	define R300_DEPTHFORMAT_24BIT_INT_Z_8BIT_STENCIL   (2 << 0)
144462306a36Sopenharmony_ci/* reserved up to (15 << 0) */
144562306a36Sopenharmony_ci#	define R300_INVERT_13E3_LEADING_ONES  (0 << 4)
144662306a36Sopenharmony_ci#	define R300_INVERT_13E3_LEADING_ZEROS (1 << 4)
144762306a36Sopenharmony_ci
144862306a36Sopenharmony_ci#define R300_ZB_ZTOP                             0x4F14
144962306a36Sopenharmony_ci#	define R300_ZTOP_DISABLE                 (0 << 0)
145062306a36Sopenharmony_ci#	define R300_ZTOP_ENABLE                  (1 << 0)
145162306a36Sopenharmony_ci
145262306a36Sopenharmony_ci/* gap */
145362306a36Sopenharmony_ci
145462306a36Sopenharmony_ci#define R300_ZB_ZCACHE_CTLSTAT            0x4f18
145562306a36Sopenharmony_ci#       define R300_ZB_ZCACHE_CTLSTAT_ZC_FLUSH_NO_EFFECT      (0 << 0)
145662306a36Sopenharmony_ci#       define R300_ZB_ZCACHE_CTLSTAT_ZC_FLUSH_FLUSH_AND_FREE (1 << 0)
145762306a36Sopenharmony_ci#       define R300_ZB_ZCACHE_CTLSTAT_ZC_FREE_NO_EFFECT       (0 << 1)
145862306a36Sopenharmony_ci#       define R300_ZB_ZCACHE_CTLSTAT_ZC_FREE_FREE            (1 << 1)
145962306a36Sopenharmony_ci#       define R300_ZB_ZCACHE_CTLSTAT_ZC_BUSY_IDLE            (0 << 31)
146062306a36Sopenharmony_ci#       define R300_ZB_ZCACHE_CTLSTAT_ZC_BUSY_BUSY            (1 << 31)
146162306a36Sopenharmony_ci
146262306a36Sopenharmony_ci#define R300_ZB_BW_CNTL                     0x4f1c
146362306a36Sopenharmony_ci#	define R300_HIZ_DISABLE                              (0 << 0)
146462306a36Sopenharmony_ci#	define R300_HIZ_ENABLE                               (1 << 0)
146562306a36Sopenharmony_ci#	define R300_HIZ_MIN                                  (0 << 1)
146662306a36Sopenharmony_ci#	define R300_HIZ_MAX                                  (1 << 1)
146762306a36Sopenharmony_ci#	define R300_FAST_FILL_DISABLE                        (0 << 2)
146862306a36Sopenharmony_ci#	define R300_FAST_FILL_ENABLE                         (1 << 2)
146962306a36Sopenharmony_ci#	define R300_RD_COMP_DISABLE                          (0 << 3)
147062306a36Sopenharmony_ci#	define R300_RD_COMP_ENABLE                           (1 << 3)
147162306a36Sopenharmony_ci#	define R300_WR_COMP_DISABLE                          (0 << 4)
147262306a36Sopenharmony_ci#	define R300_WR_COMP_ENABLE                           (1 << 4)
147362306a36Sopenharmony_ci#	define R300_ZB_CB_CLEAR_RMW                          (0 << 5)
147462306a36Sopenharmony_ci#	define R300_ZB_CB_CLEAR_CACHE_LINEAR                 (1 << 5)
147562306a36Sopenharmony_ci#	define R300_FORCE_COMPRESSED_STENCIL_VALUE_DISABLE   (0 << 6)
147662306a36Sopenharmony_ci#	define R300_FORCE_COMPRESSED_STENCIL_VALUE_ENABLE    (1 << 6)
147762306a36Sopenharmony_ci
147862306a36Sopenharmony_ci#	define R500_ZEQUAL_OPTIMIZE_ENABLE                   (0 << 7)
147962306a36Sopenharmony_ci#	define R500_ZEQUAL_OPTIMIZE_DISABLE                  (1 << 7)
148062306a36Sopenharmony_ci#	define R500_SEQUAL_OPTIMIZE_ENABLE                   (0 << 8)
148162306a36Sopenharmony_ci#	define R500_SEQUAL_OPTIMIZE_DISABLE                  (1 << 8)
148262306a36Sopenharmony_ci
148362306a36Sopenharmony_ci#	define R500_BMASK_ENABLE                             (0 << 10)
148462306a36Sopenharmony_ci#	define R500_BMASK_DISABLE                            (1 << 10)
148562306a36Sopenharmony_ci#	define R500_HIZ_EQUAL_REJECT_DISABLE                 (0 << 11)
148662306a36Sopenharmony_ci#	define R500_HIZ_EQUAL_REJECT_ENABLE                  (1 << 11)
148762306a36Sopenharmony_ci#	define R500_HIZ_FP_EXP_BITS_DISABLE                  (0 << 12)
148862306a36Sopenharmony_ci#	define R500_HIZ_FP_EXP_BITS_1                        (1 << 12)
148962306a36Sopenharmony_ci#	define R500_HIZ_FP_EXP_BITS_2                        (2 << 12)
149062306a36Sopenharmony_ci#	define R500_HIZ_FP_EXP_BITS_3                        (3 << 12)
149162306a36Sopenharmony_ci#	define R500_HIZ_FP_EXP_BITS_4                        (4 << 12)
149262306a36Sopenharmony_ci#	define R500_HIZ_FP_EXP_BITS_5                        (5 << 12)
149362306a36Sopenharmony_ci#	define R500_HIZ_FP_INVERT_LEADING_ONES               (0 << 15)
149462306a36Sopenharmony_ci#	define R500_HIZ_FP_INVERT_LEADING_ZEROS              (1 << 15)
149562306a36Sopenharmony_ci#	define R500_TILE_OVERWRITE_RECOMPRESSION_ENABLE      (0 << 16)
149662306a36Sopenharmony_ci#	define R500_TILE_OVERWRITE_RECOMPRESSION_DISABLE     (1 << 16)
149762306a36Sopenharmony_ci#	define R500_CONTIGUOUS_6XAA_SAMPLES_ENABLE           (0 << 17)
149862306a36Sopenharmony_ci#	define R500_CONTIGUOUS_6XAA_SAMPLES_DISABLE          (1 << 17)
149962306a36Sopenharmony_ci#	define R500_PEQ_PACKING_DISABLE                      (0 << 18)
150062306a36Sopenharmony_ci#	define R500_PEQ_PACKING_ENABLE                       (1 << 18)
150162306a36Sopenharmony_ci#	define R500_COVERED_PTR_MASKING_DISABLE              (0 << 18)
150262306a36Sopenharmony_ci#	define R500_COVERED_PTR_MASKING_ENABLE               (1 << 18)
150362306a36Sopenharmony_ci
150462306a36Sopenharmony_ci
150562306a36Sopenharmony_ci/* gap */
150662306a36Sopenharmony_ci
150762306a36Sopenharmony_ci/* Z Buffer Address Offset.
150862306a36Sopenharmony_ci * Bits 31 to 5 are used for aligned Z buffer address offset for macro tiles.
150962306a36Sopenharmony_ci */
151062306a36Sopenharmony_ci#define R300_ZB_DEPTHOFFSET               0x4f20
151162306a36Sopenharmony_ci
151262306a36Sopenharmony_ci/* Z Buffer Pitch and Endian Control */
151362306a36Sopenharmony_ci#define R300_ZB_DEPTHPITCH                0x4f24
151462306a36Sopenharmony_ci#       define R300_DEPTHPITCH_MASK              0x00003FFC
151562306a36Sopenharmony_ci#       define R300_DEPTHMACROTILE_DISABLE      (0 << 16)
151662306a36Sopenharmony_ci#       define R300_DEPTHMACROTILE_ENABLE       (1 << 16)
151762306a36Sopenharmony_ci#       define R300_DEPTHMICROTILE_LINEAR       (0 << 17)
151862306a36Sopenharmony_ci#       define R300_DEPTHMICROTILE_TILED        (1 << 17)
151962306a36Sopenharmony_ci#       define R300_DEPTHMICROTILE_TILED_SQUARE (2 << 17)
152062306a36Sopenharmony_ci#       define R300_DEPTHENDIAN_NO_SWAP         (0 << 18)
152162306a36Sopenharmony_ci#       define R300_DEPTHENDIAN_WORD_SWAP       (1 << 18)
152262306a36Sopenharmony_ci#       define R300_DEPTHENDIAN_DWORD_SWAP      (2 << 18)
152362306a36Sopenharmony_ci#       define R300_DEPTHENDIAN_HALF_DWORD_SWAP (3 << 18)
152462306a36Sopenharmony_ci
152562306a36Sopenharmony_ci/* Z Buffer Clear Value */
152662306a36Sopenharmony_ci#define R300_ZB_DEPTHCLEARVALUE                  0x4f28
152762306a36Sopenharmony_ci
152862306a36Sopenharmony_ci#define R300_ZB_ZMASK_OFFSET			 0x4f30
152962306a36Sopenharmony_ci#define R300_ZB_ZMASK_PITCH			 0x4f34
153062306a36Sopenharmony_ci#define R300_ZB_ZMASK_WRINDEX			 0x4f38
153162306a36Sopenharmony_ci#define R300_ZB_ZMASK_DWORD			 0x4f3c
153262306a36Sopenharmony_ci#define R300_ZB_ZMASK_RDINDEX			 0x4f40
153362306a36Sopenharmony_ci
153462306a36Sopenharmony_ci/* Hierarchical Z Memory Offset */
153562306a36Sopenharmony_ci#define R300_ZB_HIZ_OFFSET                       0x4f44
153662306a36Sopenharmony_ci
153762306a36Sopenharmony_ci/* Hierarchical Z Write Index */
153862306a36Sopenharmony_ci#define R300_ZB_HIZ_WRINDEX                      0x4f48
153962306a36Sopenharmony_ci
154062306a36Sopenharmony_ci/* Hierarchical Z Data */
154162306a36Sopenharmony_ci#define R300_ZB_HIZ_DWORD                        0x4f4c
154262306a36Sopenharmony_ci
154362306a36Sopenharmony_ci/* Hierarchical Z Read Index */
154462306a36Sopenharmony_ci#define R300_ZB_HIZ_RDINDEX                      0x4f50
154562306a36Sopenharmony_ci
154662306a36Sopenharmony_ci/* Hierarchical Z Pitch */
154762306a36Sopenharmony_ci#define R300_ZB_HIZ_PITCH                        0x4f54
154862306a36Sopenharmony_ci
154962306a36Sopenharmony_ci/* Z Buffer Z Pass Counter Data */
155062306a36Sopenharmony_ci#define R300_ZB_ZPASS_DATA                       0x4f58
155162306a36Sopenharmony_ci
155262306a36Sopenharmony_ci/* Z Buffer Z Pass Counter Address */
155362306a36Sopenharmony_ci#define R300_ZB_ZPASS_ADDR                       0x4f5c
155462306a36Sopenharmony_ci
155562306a36Sopenharmony_ci/* Depth buffer X and Y coordinate offset */
155662306a36Sopenharmony_ci#define R300_ZB_DEPTHXY_OFFSET                   0x4f60
155762306a36Sopenharmony_ci#	define R300_DEPTHX_OFFSET_SHIFT  1
155862306a36Sopenharmony_ci#	define R300_DEPTHX_OFFSET_MASK   0x000007FE
155962306a36Sopenharmony_ci#	define R300_DEPTHY_OFFSET_SHIFT  17
156062306a36Sopenharmony_ci#	define R300_DEPTHY_OFFSET_MASK   0x07FE0000
156162306a36Sopenharmony_ci
156262306a36Sopenharmony_ci/* Sets the fifo sizes */
156362306a36Sopenharmony_ci#define R500_ZB_FIFO_SIZE                        0x4fd0
156462306a36Sopenharmony_ci#	define R500_OP_FIFO_SIZE_FULL   (0 << 0)
156562306a36Sopenharmony_ci#	define R500_OP_FIFO_SIZE_HALF   (1 << 0)
156662306a36Sopenharmony_ci#	define R500_OP_FIFO_SIZE_QUATER (2 << 0)
156762306a36Sopenharmony_ci#	define R500_OP_FIFO_SIZE_EIGTHS (4 << 0)
156862306a36Sopenharmony_ci
156962306a36Sopenharmony_ci/* Stencil Reference Value and Mask for backfacing quads */
157062306a36Sopenharmony_ci/* R300_ZB_STENCILREFMASK handles front face */
157162306a36Sopenharmony_ci#define R500_ZB_STENCILREFMASK_BF                0x4fd4
157262306a36Sopenharmony_ci#	define R500_STENCILREF_SHIFT       0
157362306a36Sopenharmony_ci#	define R500_STENCILREF_MASK        0x000000ff
157462306a36Sopenharmony_ci#	define R500_STENCILMASK_SHIFT      8
157562306a36Sopenharmony_ci#	define R500_STENCILMASK_MASK       0x0000ff00
157662306a36Sopenharmony_ci#	define R500_STENCILWRITEMASK_SHIFT 16
157762306a36Sopenharmony_ci#	define R500_STENCILWRITEMASK_MASK  0x00ff0000
157862306a36Sopenharmony_ci
157962306a36Sopenharmony_ci/* BEGIN: Vertex program instruction set */
158062306a36Sopenharmony_ci
158162306a36Sopenharmony_ci/* Every instruction is four dwords long:
158262306a36Sopenharmony_ci *  DWORD 0: output and opcode
158362306a36Sopenharmony_ci *  DWORD 1: first argument
158462306a36Sopenharmony_ci *  DWORD 2: second argument
158562306a36Sopenharmony_ci *  DWORD 3: third argument
158662306a36Sopenharmony_ci *
158762306a36Sopenharmony_ci * Notes:
158862306a36Sopenharmony_ci *  - ABS r, a is implemented as MAX r, a, -a
158962306a36Sopenharmony_ci *  - MOV is implemented as ADD to zero
159062306a36Sopenharmony_ci *  - XPD is implemented as MUL + MAD
159162306a36Sopenharmony_ci *  - FLR is implemented as FRC + ADD
159262306a36Sopenharmony_ci *  - apparently, fglrx tries to schedule instructions so that there is at
159362306a36Sopenharmony_ci *    least one instruction between the write to a temporary and the first
159462306a36Sopenharmony_ci *    read from said temporary; however, violations of this scheduling are
159562306a36Sopenharmony_ci *    allowed
159662306a36Sopenharmony_ci *  - register indices seem to be unrelated with OpenGL aliasing to
159762306a36Sopenharmony_ci *    conventional state
159862306a36Sopenharmony_ci *  - only one attribute and one parameter can be loaded at a time; however,
159962306a36Sopenharmony_ci *    the same attribute/parameter can be used for more than one argument
160062306a36Sopenharmony_ci *  - the second software argument for POW is the third hardware argument
160162306a36Sopenharmony_ci *    (no idea why)
160262306a36Sopenharmony_ci *  - MAD with only temporaries as input seems to use VPI_OUT_SELECT_MAD_2
160362306a36Sopenharmony_ci *
160462306a36Sopenharmony_ci * There is some magic surrounding LIT:
160562306a36Sopenharmony_ci *   The single argument is replicated across all three inputs, but swizzled:
160662306a36Sopenharmony_ci *     First argument: xyzy
160762306a36Sopenharmony_ci *     Second argument: xyzx
160862306a36Sopenharmony_ci *     Third argument: xyzw
160962306a36Sopenharmony_ci *   Whenever the result is used later in the fragment program, fglrx forces
161062306a36Sopenharmony_ci *   x and w to be 1.0 in the input selection; I don't know whether this is
161162306a36Sopenharmony_ci *   strictly necessary
161262306a36Sopenharmony_ci */
161362306a36Sopenharmony_ci#define R300_VPI_OUT_OP_DOT                     (1 << 0)
161462306a36Sopenharmony_ci#define R300_VPI_OUT_OP_MUL                     (2 << 0)
161562306a36Sopenharmony_ci#define R300_VPI_OUT_OP_ADD                     (3 << 0)
161662306a36Sopenharmony_ci#define R300_VPI_OUT_OP_MAD                     (4 << 0)
161762306a36Sopenharmony_ci#define R300_VPI_OUT_OP_DST                     (5 << 0)
161862306a36Sopenharmony_ci#define R300_VPI_OUT_OP_FRC                     (6 << 0)
161962306a36Sopenharmony_ci#define R300_VPI_OUT_OP_MAX                     (7 << 0)
162062306a36Sopenharmony_ci#define R300_VPI_OUT_OP_MIN                     (8 << 0)
162162306a36Sopenharmony_ci#define R300_VPI_OUT_OP_SGE                     (9 << 0)
162262306a36Sopenharmony_ci#define R300_VPI_OUT_OP_SLT                     (10 << 0)
162362306a36Sopenharmony_ci	/* Used in GL_POINT_DISTANCE_ATTENUATION_ARB, vector(scalar, vector) */
162462306a36Sopenharmony_ci#define R300_VPI_OUT_OP_UNK12                   (12 << 0)
162562306a36Sopenharmony_ci#define R300_VPI_OUT_OP_ARL                     (13 << 0)
162662306a36Sopenharmony_ci#define R300_VPI_OUT_OP_EXP                     (65 << 0)
162762306a36Sopenharmony_ci#define R300_VPI_OUT_OP_LOG                     (66 << 0)
162862306a36Sopenharmony_ci	/* Used in fog computations, scalar(scalar) */
162962306a36Sopenharmony_ci#define R300_VPI_OUT_OP_UNK67                   (67 << 0)
163062306a36Sopenharmony_ci#define R300_VPI_OUT_OP_LIT                     (68 << 0)
163162306a36Sopenharmony_ci#define R300_VPI_OUT_OP_POW                     (69 << 0)
163262306a36Sopenharmony_ci#define R300_VPI_OUT_OP_RCP                     (70 << 0)
163362306a36Sopenharmony_ci#define R300_VPI_OUT_OP_RSQ                     (72 << 0)
163462306a36Sopenharmony_ci	/* Used in GL_POINT_DISTANCE_ATTENUATION_ARB, scalar(scalar) */
163562306a36Sopenharmony_ci#define R300_VPI_OUT_OP_UNK73                   (73 << 0)
163662306a36Sopenharmony_ci#define R300_VPI_OUT_OP_EX2                     (75 << 0)
163762306a36Sopenharmony_ci#define R300_VPI_OUT_OP_LG2                     (76 << 0)
163862306a36Sopenharmony_ci#define R300_VPI_OUT_OP_MAD_2                   (128 << 0)
163962306a36Sopenharmony_ci	/* all temps, vector(scalar, vector, vector) */
164062306a36Sopenharmony_ci#define R300_VPI_OUT_OP_UNK129                  (129 << 0)
164162306a36Sopenharmony_ci
164262306a36Sopenharmony_ci#define R300_VPI_OUT_REG_CLASS_TEMPORARY        (0 << 8)
164362306a36Sopenharmony_ci#define R300_VPI_OUT_REG_CLASS_ADDR             (1 << 8)
164462306a36Sopenharmony_ci#define R300_VPI_OUT_REG_CLASS_RESULT           (2 << 8)
164562306a36Sopenharmony_ci#define R300_VPI_OUT_REG_CLASS_MASK             (31 << 8)
164662306a36Sopenharmony_ci
164762306a36Sopenharmony_ci#define R300_VPI_OUT_REG_INDEX_SHIFT            13
164862306a36Sopenharmony_ci	/* GUESS based on fglrx native limits */
164962306a36Sopenharmony_ci#define R300_VPI_OUT_REG_INDEX_MASK             (31 << 13)
165062306a36Sopenharmony_ci
165162306a36Sopenharmony_ci#define R300_VPI_OUT_WRITE_X                    (1 << 20)
165262306a36Sopenharmony_ci#define R300_VPI_OUT_WRITE_Y                    (1 << 21)
165362306a36Sopenharmony_ci#define R300_VPI_OUT_WRITE_Z                    (1 << 22)
165462306a36Sopenharmony_ci#define R300_VPI_OUT_WRITE_W                    (1 << 23)
165562306a36Sopenharmony_ci
165662306a36Sopenharmony_ci#define R300_VPI_IN_REG_CLASS_TEMPORARY         (0 << 0)
165762306a36Sopenharmony_ci#define R300_VPI_IN_REG_CLASS_ATTRIBUTE         (1 << 0)
165862306a36Sopenharmony_ci#define R300_VPI_IN_REG_CLASS_PARAMETER         (2 << 0)
165962306a36Sopenharmony_ci#define R300_VPI_IN_REG_CLASS_NONE              (9 << 0)
166062306a36Sopenharmony_ci#define R300_VPI_IN_REG_CLASS_MASK              (31 << 0)
166162306a36Sopenharmony_ci
166262306a36Sopenharmony_ci#define R300_VPI_IN_REG_INDEX_SHIFT             5
166362306a36Sopenharmony_ci	/* GUESS based on fglrx native limits */
166462306a36Sopenharmony_ci#define R300_VPI_IN_REG_INDEX_MASK              (255 << 5)
166562306a36Sopenharmony_ci
166662306a36Sopenharmony_ci/* The R300 can select components from the input register arbitrarily.
166762306a36Sopenharmony_ci * Use the following constants, shifted by the component shift you
166862306a36Sopenharmony_ci * want to select
166962306a36Sopenharmony_ci */
167062306a36Sopenharmony_ci#define R300_VPI_IN_SELECT_X    0
167162306a36Sopenharmony_ci#define R300_VPI_IN_SELECT_Y    1
167262306a36Sopenharmony_ci#define R300_VPI_IN_SELECT_Z    2
167362306a36Sopenharmony_ci#define R300_VPI_IN_SELECT_W    3
167462306a36Sopenharmony_ci#define R300_VPI_IN_SELECT_ZERO 4
167562306a36Sopenharmony_ci#define R300_VPI_IN_SELECT_ONE  5
167662306a36Sopenharmony_ci#define R300_VPI_IN_SELECT_MASK 7
167762306a36Sopenharmony_ci
167862306a36Sopenharmony_ci#define R300_VPI_IN_X_SHIFT                     13
167962306a36Sopenharmony_ci#define R300_VPI_IN_Y_SHIFT                     16
168062306a36Sopenharmony_ci#define R300_VPI_IN_Z_SHIFT                     19
168162306a36Sopenharmony_ci#define R300_VPI_IN_W_SHIFT                     22
168262306a36Sopenharmony_ci
168362306a36Sopenharmony_ci#define R300_VPI_IN_NEG_X                       (1 << 25)
168462306a36Sopenharmony_ci#define R300_VPI_IN_NEG_Y                       (1 << 26)
168562306a36Sopenharmony_ci#define R300_VPI_IN_NEG_Z                       (1 << 27)
168662306a36Sopenharmony_ci#define R300_VPI_IN_NEG_W                       (1 << 28)
168762306a36Sopenharmony_ci/* END: Vertex program instruction set */
168862306a36Sopenharmony_ci
168962306a36Sopenharmony_ci/* BEGIN: Packet 3 commands */
169062306a36Sopenharmony_ci
169162306a36Sopenharmony_ci/* A primitive emission dword. */
169262306a36Sopenharmony_ci#define R300_PRIM_TYPE_NONE                     (0 << 0)
169362306a36Sopenharmony_ci#define R300_PRIM_TYPE_POINT                    (1 << 0)
169462306a36Sopenharmony_ci#define R300_PRIM_TYPE_LINE                     (2 << 0)
169562306a36Sopenharmony_ci#define R300_PRIM_TYPE_LINE_STRIP               (3 << 0)
169662306a36Sopenharmony_ci#define R300_PRIM_TYPE_TRI_LIST                 (4 << 0)
169762306a36Sopenharmony_ci#define R300_PRIM_TYPE_TRI_FAN                  (5 << 0)
169862306a36Sopenharmony_ci#define R300_PRIM_TYPE_TRI_STRIP                (6 << 0)
169962306a36Sopenharmony_ci#define R300_PRIM_TYPE_TRI_TYPE2                (7 << 0)
170062306a36Sopenharmony_ci#define R300_PRIM_TYPE_RECT_LIST                (8 << 0)
170162306a36Sopenharmony_ci#define R300_PRIM_TYPE_3VRT_POINT_LIST          (9 << 0)
170262306a36Sopenharmony_ci#define R300_PRIM_TYPE_3VRT_LINE_LIST           (10 << 0)
170362306a36Sopenharmony_ci	/* GUESS (based on r200) */
170462306a36Sopenharmony_ci#define R300_PRIM_TYPE_POINT_SPRITES            (11 << 0)
170562306a36Sopenharmony_ci#define R300_PRIM_TYPE_LINE_LOOP                (12 << 0)
170662306a36Sopenharmony_ci#define R300_PRIM_TYPE_QUADS                    (13 << 0)
170762306a36Sopenharmony_ci#define R300_PRIM_TYPE_QUAD_STRIP               (14 << 0)
170862306a36Sopenharmony_ci#define R300_PRIM_TYPE_POLYGON                  (15 << 0)
170962306a36Sopenharmony_ci#define R300_PRIM_TYPE_MASK                     0xF
171062306a36Sopenharmony_ci#define R300_PRIM_WALK_IND                      (1 << 4)
171162306a36Sopenharmony_ci#define R300_PRIM_WALK_LIST                     (2 << 4)
171262306a36Sopenharmony_ci#define R300_PRIM_WALK_RING                     (3 << 4)
171362306a36Sopenharmony_ci#define R300_PRIM_WALK_MASK                     (3 << 4)
171462306a36Sopenharmony_ci	/* GUESS (based on r200) */
171562306a36Sopenharmony_ci#define R300_PRIM_COLOR_ORDER_BGRA              (0 << 6)
171662306a36Sopenharmony_ci#define R300_PRIM_COLOR_ORDER_RGBA              (1 << 6)
171762306a36Sopenharmony_ci#define R300_PRIM_NUM_VERTICES_SHIFT            16
171862306a36Sopenharmony_ci#define R300_PRIM_NUM_VERTICES_MASK             0xffff
171962306a36Sopenharmony_ci
172062306a36Sopenharmony_ci/* Draw a primitive from vertex data in arrays loaded via 3D_LOAD_VBPNTR.
172162306a36Sopenharmony_ci * Two parameter dwords:
172262306a36Sopenharmony_ci * 0. The first parameter appears to be always 0
172362306a36Sopenharmony_ci * 1. The second parameter is a standard primitive emission dword.
172462306a36Sopenharmony_ci */
172562306a36Sopenharmony_ci#define R300_PACKET3_3D_DRAW_VBUF           0x00002800
172662306a36Sopenharmony_ci
172762306a36Sopenharmony_ci/* Specify the full set of vertex arrays as (address, stride).
172862306a36Sopenharmony_ci * The first parameter is the number of vertex arrays specified.
172962306a36Sopenharmony_ci * The rest of the command is a variable length list of blocks, where
173062306a36Sopenharmony_ci * each block is three dwords long and specifies two arrays.
173162306a36Sopenharmony_ci * The first dword of a block is split into two words, the lower significant
173262306a36Sopenharmony_ci * word refers to the first array, the more significant word to the second
173362306a36Sopenharmony_ci * array in the block.
173462306a36Sopenharmony_ci * The low byte of each word contains the size of an array entry in dwords,
173562306a36Sopenharmony_ci * the high byte contains the stride of the array.
173662306a36Sopenharmony_ci * The second dword of a block contains the pointer to the first array,
173762306a36Sopenharmony_ci * the third dword of a block contains the pointer to the second array.
173862306a36Sopenharmony_ci * Note that if the total number of arrays is odd, the third dword of
173962306a36Sopenharmony_ci * the last block is omitted.
174062306a36Sopenharmony_ci */
174162306a36Sopenharmony_ci#define R300_PACKET3_3D_LOAD_VBPNTR         0x00002F00
174262306a36Sopenharmony_ci
174362306a36Sopenharmony_ci#define R300_PACKET3_INDX_BUFFER            0x00003300
174462306a36Sopenharmony_ci#    define R300_EB_UNK1_SHIFT                      24
174562306a36Sopenharmony_ci#    define R300_EB_UNK1                    (0x80<<24)
174662306a36Sopenharmony_ci#    define R300_EB_UNK2                        0x0810
174762306a36Sopenharmony_ci#define R300_PACKET3_3D_DRAW_VBUF_2         0x00003400
174862306a36Sopenharmony_ci#define R300_PACKET3_3D_DRAW_INDX_2         0x00003600
174962306a36Sopenharmony_ci
175062306a36Sopenharmony_ci/* END: Packet 3 commands */
175162306a36Sopenharmony_ci
175262306a36Sopenharmony_ci
175362306a36Sopenharmony_ci/* Color formats for 2d packets
175462306a36Sopenharmony_ci */
175562306a36Sopenharmony_ci#define R300_CP_COLOR_FORMAT_CI8	2
175662306a36Sopenharmony_ci#define R300_CP_COLOR_FORMAT_ARGB1555	3
175762306a36Sopenharmony_ci#define R300_CP_COLOR_FORMAT_RGB565	4
175862306a36Sopenharmony_ci#define R300_CP_COLOR_FORMAT_ARGB8888	6
175962306a36Sopenharmony_ci#define R300_CP_COLOR_FORMAT_RGB332	7
176062306a36Sopenharmony_ci#define R300_CP_COLOR_FORMAT_RGB8	9
176162306a36Sopenharmony_ci#define R300_CP_COLOR_FORMAT_ARGB4444	15
176262306a36Sopenharmony_ci
176362306a36Sopenharmony_ci/*
176462306a36Sopenharmony_ci * CP type-3 packets
176562306a36Sopenharmony_ci */
176662306a36Sopenharmony_ci#define R300_CP_CMD_BITBLT_MULTI	0xC0009B00
176762306a36Sopenharmony_ci
176862306a36Sopenharmony_ci#define R500_VAP_INDEX_OFFSET		0x208c
176962306a36Sopenharmony_ci
177062306a36Sopenharmony_ci#define R500_GA_US_VECTOR_INDEX         0x4250
177162306a36Sopenharmony_ci#define R500_GA_US_VECTOR_DATA          0x4254
177262306a36Sopenharmony_ci
177362306a36Sopenharmony_ci#define R500_RS_IP_0                    0x4074
177462306a36Sopenharmony_ci#define R500_RS_INST_0                  0x4320
177562306a36Sopenharmony_ci
177662306a36Sopenharmony_ci#define R500_US_CONFIG                  0x4600
177762306a36Sopenharmony_ci
177862306a36Sopenharmony_ci#define R500_US_FC_CTRL			0x4624
177962306a36Sopenharmony_ci#define R500_US_CODE_ADDR		0x4630
178062306a36Sopenharmony_ci
178162306a36Sopenharmony_ci#define R500_RB3D_COLOR_CLEAR_VALUE_AR  0x46c0
178262306a36Sopenharmony_ci#define R500_RB3D_CONSTANT_COLOR_AR     0x4ef8
178362306a36Sopenharmony_ci
178462306a36Sopenharmony_ci#define R300_SU_REG_DEST                0x42c8
178562306a36Sopenharmony_ci#define RV530_FG_ZBREG_DEST             0x4be8
178662306a36Sopenharmony_ci#define R300_ZB_ZPASS_DATA              0x4f58
178762306a36Sopenharmony_ci#define R300_ZB_ZPASS_ADDR              0x4f5c
178862306a36Sopenharmony_ci
178962306a36Sopenharmony_ci#endif /* _R300_REG_H */
1790