2 * Copyright 2009 Joakim Sindholt <opensource@zhasha.com>
3 * Corbin Simpson <MostAwesomeDude@gmail.com>
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * on the rights to use, copy, modify, merge, publish, distribute, sub
9 * license, and/or sell copies of the Software, and to permit persons to whom
10 * the Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
22 * USE OR OTHER DEALINGS IN THE SOFTWARE. */
24 #include "r300_state_invariant.h"
27 struct pipe_viewport_state r300_viewport_identity
= {
28 .scale
= {1.0, 1.0, 1.0, 1.0},
29 .translate
= {0.0, 0.0, 0.0, 0.0},
32 /* Calculate and emit invariant state. This is data that the 3D engine
33 * will probably want at the beginning of every CS, but it's not currently
34 * handled by any CSO setup, and in addition it doesn't really change much.
36 * Note that eventually this should be empty, but it's useful for development
37 * and general unduplication of code. */
38 void r300_emit_invariant_state(struct r300_context
* r300
)
40 struct r300_capabilities
* caps
= r300_screen(r300
->context
.screen
)->caps
;
43 BEGIN_CS(24 + (caps
->has_tcl
? 2: 0));
45 /*** Graphics Backend (GB) ***/
46 /* Various GB enables */
47 OUT_CS_REG(R300_GB_ENABLE
, R300_GB_POINT_STUFF_ENABLE
|
48 R300_GB_LINE_STUFF_ENABLE
|
49 R300_GB_TRIANGLE_STUFF_ENABLE
);
50 /* Subpixel multisampling for AA
51 * These are commented out because glisse's CS checker doesn't like them.
52 * I presume these will be re-enabled later.
53 * OUT_CS_REG(R300_GB_MSPOS0, 0x66666666);
54 * OUT_CS_REG(R300_GB_MSPOS1, 0x6666666);
56 /* Source of fog depth */
57 OUT_CS_REG(R300_GB_SELECT
, R300_GB_FOG_SELECT_1_1_W
);
59 OUT_CS_REG(R300_GB_AA_CONFIG
, 0x0);
62 OUT_CS_REG(R300_FG_FOG_BLEND
, 0x0);
63 OUT_CS_REG(R300_FG_FOG_COLOR_R
, 0x0);
64 OUT_CS_REG(R300_FG_FOG_COLOR_G
, 0x0);
65 OUT_CS_REG(R300_FG_FOG_COLOR_B
, 0x0);
66 OUT_CS_REG(R300_FG_DEPTH_SRC
, 0x0);
67 OUT_CS_REG(R300_US_W_FMT
, 0x0);
70 /* Max and min vertex index clamp. */
71 OUT_CS_REG(R300_VAP_VF_MIN_VTX_INDX
, 0x0);
72 OUT_CS_REG(R300_VAP_VF_MAX_VTX_INDX
, 0xffffff);
73 /* Sign/normalize control */
74 OUT_CS_REG(R300_VAP_PSC_SGN_NORM_CNTL
, R300_SGN_NORM_NO_ZERO
);
77 /* Amount of time to wait for vertex fetches in PVS */
78 OUT_CS_REG(VAP_PVS_VTX_TIMEOUT_REG
, 0xffff);
83 /* XXX unsorted stuff from surface_fill */
84 BEGIN_CS(64 + (caps
->has_tcl
? 5 : 0) + (caps
->is_r500
? 4 : 0));
86 OUT_CS_REG(R300_VAP_PVS_STATE_FLUSH_REG
, 0x0);
88 OUT_CS_REG(R300_SE_VTE_CNTL
, R300_VPORT_X_SCALE_ENA
|
89 R300_VPORT_X_OFFSET_ENA
| R300_VPORT_Y_SCALE_ENA
|
90 R300_VPORT_Y_OFFSET_ENA
| R300_VPORT_Z_SCALE_ENA
|
91 R300_VPORT_Z_OFFSET_ENA
| R300_VTX_W0_FMT
);
93 OUT_CS_REG_SEQ(R300_VAP_GB_VERT_CLIP_ADJ
, 4);
99 /* XXX point tex stuffing */
100 OUT_CS_REG_SEQ(R300_GA_POINT_S0
, 1);
102 OUT_CS_REG_SEQ(R300_GA_POINT_S1
, 1);
104 /* XXX line tex stuffing */
105 OUT_CS_REG_SEQ(R300_GA_LINE_S0
, 1);
107 OUT_CS_REG_SEQ(R300_GA_LINE_S1
, 1);
109 OUT_CS_REG(R300_GA_TRIANGLE_STIPPLE
, 0x5 |
110 (0x5 << R300_GA_TRIANGLE_STIPPLE_Y_SHIFT_SHIFT
));
111 /* XXX this big chunk should be refactored into rs_state */
112 OUT_CS_REG(R300_GA_SOLID_RG
, 0x00000000);
113 OUT_CS_REG(R300_GA_SOLID_BA
, 0x00000000);
114 OUT_CS_REG(R300_GA_POLY_MODE
, 0x00000000);
115 OUT_CS_REG(R300_GA_ROUND_MODE
, 0x00000001);
116 OUT_CS_REG(R300_GA_OFFSET
, 0x00000000);
117 OUT_CS_REG(R300_GA_FOG_SCALE
, 0x3DBF1412);
118 OUT_CS_REG(R300_GA_FOG_OFFSET
, 0x00000000);
119 OUT_CS_REG(R300_SU_TEX_WRAP
, 0x00000000);
120 OUT_CS_REG(R300_SU_DEPTH_SCALE
, 0x4B7FFFFF);
121 OUT_CS_REG(R300_SU_DEPTH_OFFSET
, 0x00000000);
122 OUT_CS_REG(R300_SC_HYPERZ
, 0x0000001C);
123 OUT_CS_REG(R300_SC_EDGERULE
, 0x2DA49525);
124 OUT_CS_REG(R300_RB3D_CCTL
, 0x00000000);
125 OUT_CS_REG(RB3D_COLOR_CHANNEL_MASK
, 0x0000000F);
126 OUT_CS_REG(R300_RB3D_AARESOLVE_CTL
, 0x00000000);
128 OUT_CS_REG(R500_RB3D_DISCARD_SRC_PIXEL_LTE_THRESHOLD
, 0x00000000);
129 OUT_CS_REG(R500_RB3D_DISCARD_SRC_PIXEL_GTE_THRESHOLD
, 0xFFFFFFFF);
131 OUT_CS_REG(R300_ZB_FORMAT
, 0x00000002);
132 OUT_CS_REG(R300_ZB_ZCACHE_CTLSTAT
, 0x00000003);
133 OUT_CS_REG(R300_ZB_BW_CNTL
, 0x00000000);
134 OUT_CS_REG(R300_ZB_DEPTHCLEARVALUE
, 0x00000000);
135 OUT_CS_REG(R300_ZB_HIZ_OFFSET
, 0x00000000);
136 OUT_CS_REG(R300_ZB_HIZ_PITCH
, 0x00000000);
137 OUT_CS_REG(R300_VAP_VTX_STATE_CNTL
, 0x1);
138 OUT_CS_REG(R300_VAP_VSM_VTX_ASSM
, 0x405);
139 OUT_CS_REG(R300_SE_VTE_CNTL
, 0x0000043F);
142 OUT_CS_REG(R300_SC_CLIP_RULE
, 0xaaaa);