blob: ee85c4a1fc084082c89db1799a2a87affd768d96 [file] [log] [blame]
Dave Airlie551ebd82009-09-01 15:25:57 +10001
2#define R100_TRACK_MAX_TEXTURE 3
3#define R200_TRACK_MAX_TEXTURE 6
4#define R300_TRACK_MAX_TEXTURE 16
5
6#define R100_MAX_CB 1
7#define R300_MAX_CB 4
8
9/*
10 * CS functions
11 */
12struct r100_cs_track_cb {
Jerome Glisse4c788672009-11-20 14:29:23 +010013 struct radeon_bo *robj;
Dave Airlie551ebd82009-09-01 15:25:57 +100014 unsigned pitch;
15 unsigned cpp;
16 unsigned offset;
17};
18
19struct r100_cs_track_array {
Jerome Glisse4c788672009-11-20 14:29:23 +010020 struct radeon_bo *robj;
Dave Airlie551ebd82009-09-01 15:25:57 +100021 unsigned esize;
22};
23
24struct r100_cs_cube_info {
Jerome Glisse4c788672009-11-20 14:29:23 +010025 struct radeon_bo *robj;
26 unsigned offset;
Dave Airlie551ebd82009-09-01 15:25:57 +100027 unsigned width;
28 unsigned height;
29};
30
Dave Airlied785d782009-12-07 13:16:06 +100031#define R100_TRACK_COMP_NONE 0
32#define R100_TRACK_COMP_DXT1 1
33#define R100_TRACK_COMP_DXT35 2
34
Dave Airlie551ebd82009-09-01 15:25:57 +100035struct r100_cs_track_texture {
Jerome Glisse4c788672009-11-20 14:29:23 +010036 struct radeon_bo *robj;
Dave Airlie551ebd82009-09-01 15:25:57 +100037 struct r100_cs_cube_info cube_info[5]; /* info for 5 non-primary faces */
38 unsigned pitch;
39 unsigned width;
40 unsigned height;
41 unsigned num_levels;
42 unsigned cpp;
43 unsigned tex_coord_type;
44 unsigned txdepth;
45 unsigned width_11;
46 unsigned height_11;
47 bool use_pitch;
48 bool enabled;
Alex Deucher43b93fb2010-10-27 01:02:35 -040049 bool lookup_disable;
Dave Airlie551ebd82009-09-01 15:25:57 +100050 bool roundup_w;
51 bool roundup_h;
Dave Airlied785d782009-12-07 13:16:06 +100052 unsigned compress_format;
Dave Airlie551ebd82009-09-01 15:25:57 +100053};
54
Dave Airlie551ebd82009-09-01 15:25:57 +100055struct r100_cs_track {
Dave Airlie551ebd82009-09-01 15:25:57 +100056 unsigned num_cb;
57 unsigned num_texture;
58 unsigned maxy;
59 unsigned vtx_size;
60 unsigned vap_vf_cntl;
Marek Olšákcae94b02010-02-21 21:24:15 +010061 unsigned vap_alt_nverts;
Dave Airlie551ebd82009-09-01 15:25:57 +100062 unsigned immd_dwords;
63 unsigned num_arrays;
64 unsigned max_indx;
Marek Olšák46c64d42009-12-17 06:02:28 +010065 unsigned color_channel_mask;
Dave Airlie551ebd82009-09-01 15:25:57 +100066 struct r100_cs_track_array arrays[11];
67 struct r100_cs_track_cb cb[R300_MAX_CB];
68 struct r100_cs_track_cb zb;
69 struct r100_cs_track_texture textures[R300_TRACK_MAX_TEXTURE];
70 bool z_enabled;
71 bool separate_cube;
Marek Olšák797fd5b2010-04-13 02:33:36 +020072 bool zb_cb_clear;
Marek Olšák46c64d42009-12-17 06:02:28 +010073 bool blend_read_enable;
Marek Olšák40b4a752011-02-12 19:21:35 +010074
75 bool cb_dirty;
76 bool zb_dirty;
77 bool tex_dirty;
Dave Airlie551ebd82009-09-01 15:25:57 +100078};
79
80int r100_cs_track_check(struct radeon_device *rdev, struct r100_cs_track *track);
81void r100_cs_track_clear(struct radeon_device *rdev, struct r100_cs_track *track);
82int r100_cs_packet_next_reloc(struct radeon_cs_parser *p,
83 struct radeon_cs_reloc **cs_reloc);
84void r100_cs_dump_packet(struct radeon_cs_parser *p,
85 struct radeon_cs_packet *pkt);
86
87int r100_cs_packet_parse_vline(struct radeon_cs_parser *p);
88
89int r200_packet0_check(struct radeon_cs_parser *p,
90 struct radeon_cs_packet *pkt,
91 unsigned idx, unsigned reg);
92
Dave Airlie513bcb42009-09-23 16:56:27 +100093
94
Dave Airlie551ebd82009-09-01 15:25:57 +100095static inline int r100_reloc_pitch_offset(struct radeon_cs_parser *p,
96 struct radeon_cs_packet *pkt,
97 unsigned idx,
98 unsigned reg)
99{
100 int r;
101 u32 tile_flags = 0;
102 u32 tmp;
103 struct radeon_cs_reloc *reloc;
Dave Airlie513bcb42009-09-23 16:56:27 +1000104 u32 value;
Dave Airlie551ebd82009-09-01 15:25:57 +1000105
106 r = r100_cs_packet_next_reloc(p, &reloc);
107 if (r) {
108 DRM_ERROR("No reloc for ib[%d]=0x%04X\n",
109 idx, reg);
110 r100_cs_dump_packet(p, pkt);
111 return r;
112 }
Dave Airlie513bcb42009-09-23 16:56:27 +1000113 value = radeon_get_ib_value(p, idx);
114 tmp = value & 0x003fffff;
Dave Airlie551ebd82009-09-01 15:25:57 +1000115 tmp += (((u32)reloc->lobj.gpu_offset) >> 10);
116
117 if (reloc->lobj.tiling_flags & RADEON_TILING_MACRO)
118 tile_flags |= RADEON_DST_TILE_MACRO;
119 if (reloc->lobj.tiling_flags & RADEON_TILING_MICRO) {
120 if (reg == RADEON_SRC_PITCH_OFFSET) {
121 DRM_ERROR("Cannot src blit from microtiled surface\n");
122 r100_cs_dump_packet(p, pkt);
123 return -EINVAL;
124 }
125 tile_flags |= RADEON_DST_TILE_MICRO;
126 }
127
128 tmp |= tile_flags;
Dave Airlie513bcb42009-09-23 16:56:27 +1000129 p->ib->ptr[idx] = (value & 0x3fc00000) | tmp;
Dave Airlie551ebd82009-09-01 15:25:57 +1000130 return 0;
131}
Dave Airlie513bcb42009-09-23 16:56:27 +1000132
133static inline int r100_packet3_load_vbpntr(struct radeon_cs_parser *p,
134 struct radeon_cs_packet *pkt,
135 int idx)
136{
137 unsigned c, i;
138 struct radeon_cs_reloc *reloc;
139 struct r100_cs_track *track;
140 int r = 0;
141 volatile uint32_t *ib;
142 u32 idx_value;
143
144 ib = p->ib->ptr;
145 track = (struct r100_cs_track *)p->track;
146 c = radeon_get_ib_value(p, idx++) & 0x1F;
147 track->num_arrays = c;
148 for (i = 0; i < (c - 1); i+=2, idx+=3) {
149 r = r100_cs_packet_next_reloc(p, &reloc);
150 if (r) {
151 DRM_ERROR("No reloc for packet3 %d\n",
152 pkt->opcode);
153 r100_cs_dump_packet(p, pkt);
154 return r;
155 }
156 idx_value = radeon_get_ib_value(p, idx);
157 ib[idx+1] = radeon_get_ib_value(p, idx + 1) + ((u32)reloc->lobj.gpu_offset);
158
159 track->arrays[i + 0].esize = idx_value >> 8;
160 track->arrays[i + 0].robj = reloc->robj;
161 track->arrays[i + 0].esize &= 0x7F;
162 r = r100_cs_packet_next_reloc(p, &reloc);
163 if (r) {
164 DRM_ERROR("No reloc for packet3 %d\n",
165 pkt->opcode);
166 r100_cs_dump_packet(p, pkt);
167 return r;
168 }
169 ib[idx+2] = radeon_get_ib_value(p, idx + 2) + ((u32)reloc->lobj.gpu_offset);
170 track->arrays[i + 1].robj = reloc->robj;
171 track->arrays[i + 1].esize = idx_value >> 24;
172 track->arrays[i + 1].esize &= 0x7F;
173 }
174 if (c & 1) {
175 r = r100_cs_packet_next_reloc(p, &reloc);
176 if (r) {
177 DRM_ERROR("No reloc for packet3 %d\n",
178 pkt->opcode);
179 r100_cs_dump_packet(p, pkt);
180 return r;
181 }
182 idx_value = radeon_get_ib_value(p, idx);
183 ib[idx+1] = radeon_get_ib_value(p, idx + 1) + ((u32)reloc->lobj.gpu_offset);
184 track->arrays[i + 0].robj = reloc->robj;
185 track->arrays[i + 0].esize = idx_value >> 8;
186 track->arrays[i + 0].esize &= 0x7F;
187 }
188 return r;
189}