1 /*
2 * Copyright 2010 Jerome Glisse <glisse@freedesktop.org>
3 * SPDX-License-Identifier: MIT
4 */
5
6 #include "r600_pipe.h"
7 #include "compute_memory_pool.h"
8 #include "evergreen_compute.h"
9 #include "util/u_surface.h"
10 #include "util/format/u_format.h"
11 #include "evergreend.h"
12
13 enum r600_blitter_op /* bitmask */
14 {
15 R600_SAVE_FRAGMENT_STATE = 1,
16 R600_SAVE_TEXTURES = 2,
17 R600_SAVE_FRAMEBUFFER = 4,
18 R600_DISABLE_RENDER_COND = 8,
19 R600_SAVE_CONST_BUF0 = 16,
20
21 R600_CLEAR = R600_SAVE_FRAGMENT_STATE | R600_SAVE_CONST_BUF0,
22
23 R600_CLEAR_SURFACE = R600_SAVE_FRAGMENT_STATE | R600_SAVE_FRAMEBUFFER,
24
25 R600_COPY_BUFFER = R600_DISABLE_RENDER_COND,
26
27 R600_COPY_TEXTURE = R600_SAVE_FRAGMENT_STATE | R600_SAVE_FRAMEBUFFER | R600_SAVE_TEXTURES |
28 R600_DISABLE_RENDER_COND,
29
30 R600_BLIT = R600_SAVE_FRAGMENT_STATE | R600_SAVE_FRAMEBUFFER | R600_SAVE_TEXTURES,
31
32 R600_DECOMPRESS = R600_SAVE_FRAGMENT_STATE | R600_SAVE_FRAMEBUFFER | R600_DISABLE_RENDER_COND,
33
34 R600_COLOR_RESOLVE = R600_SAVE_FRAGMENT_STATE | R600_SAVE_FRAMEBUFFER
35 };
36
r600_blitter_begin(struct pipe_context * ctx,enum r600_blitter_op op)37 static void r600_blitter_begin(struct pipe_context *ctx, enum r600_blitter_op op)
38 {
39 struct r600_context *rctx = (struct r600_context *)ctx;
40
41 if (rctx->cmd_buf_is_compute) {
42 rctx->b.gfx.flush(rctx, PIPE_FLUSH_ASYNC, NULL);
43 rctx->cmd_buf_is_compute = false;
44 }
45
46 util_blitter_save_vertex_buffers(rctx->blitter, rctx->vertex_buffer_state.vb,
47 util_last_bit(rctx->vertex_buffer_state.enabled_mask));
48 util_blitter_save_vertex_elements(rctx->blitter, rctx->vertex_fetch_shader.cso);
49 util_blitter_save_vertex_shader(rctx->blitter, rctx->vs_shader);
50 util_blitter_save_geometry_shader(rctx->blitter, rctx->gs_shader);
51 util_blitter_save_tessctrl_shader(rctx->blitter, rctx->tcs_shader);
52 util_blitter_save_tesseval_shader(rctx->blitter, rctx->tes_shader);
53 util_blitter_save_so_targets(rctx->blitter, rctx->b.streamout.num_targets,
54 (struct pipe_stream_output_target**)rctx->b.streamout.targets,
55 MESA_PRIM_UNKNOWN);
56 util_blitter_save_rasterizer(rctx->blitter, rctx->rasterizer_state.cso);
57
58 if (op & R600_SAVE_FRAGMENT_STATE) {
59 util_blitter_save_viewport(rctx->blitter, &rctx->b.viewports.states[0]);
60 util_blitter_save_scissor(rctx->blitter, &rctx->b.scissors.states[0]);
61 util_blitter_save_fragment_shader(rctx->blitter, rctx->ps_shader);
62 util_blitter_save_blend(rctx->blitter, rctx->blend_state.cso);
63 util_blitter_save_depth_stencil_alpha(rctx->blitter, rctx->dsa_state.cso);
64 util_blitter_save_stencil_ref(rctx->blitter, &rctx->stencil_ref.pipe_state);
65 util_blitter_save_sample_mask(rctx->blitter, rctx->sample_mask.sample_mask, rctx->ps_iter_samples);
66 }
67
68 if (op & R600_SAVE_CONST_BUF0) {
69 util_blitter_save_fragment_constant_buffer_slot(rctx->blitter,
70 &rctx->constbuf_state[PIPE_SHADER_FRAGMENT].cb[0]);
71 }
72
73 if (op & R600_SAVE_FRAMEBUFFER)
74 util_blitter_save_framebuffer(rctx->blitter, &rctx->framebuffer.state);
75
76 if (op & R600_SAVE_TEXTURES) {
77 util_blitter_save_fragment_sampler_states(
78 rctx->blitter, util_last_bit(rctx->samplers[PIPE_SHADER_FRAGMENT].states.enabled_mask),
79 (void**)rctx->samplers[PIPE_SHADER_FRAGMENT].states.states);
80
81 util_blitter_save_fragment_sampler_views(
82 rctx->blitter, util_last_bit(rctx->samplers[PIPE_SHADER_FRAGMENT].views.enabled_mask),
83 (struct pipe_sampler_view**)rctx->samplers[PIPE_SHADER_FRAGMENT].views.views);
84 }
85
86 if (op & R600_DISABLE_RENDER_COND)
87 rctx->b.render_cond_force_off = true;
88 }
89
r600_blitter_end(struct pipe_context * ctx)90 static void r600_blitter_end(struct pipe_context *ctx)
91 {
92 struct r600_context *rctx = (struct r600_context *)ctx;
93
94 rctx->b.render_cond_force_off = false;
95 }
96
u_max_sample(struct pipe_resource * r)97 static unsigned u_max_sample(struct pipe_resource *r)
98 {
99 return r->nr_samples ? r->nr_samples - 1 : 0;
100 }
101
r600_blit_decompress_depth(struct pipe_context * ctx,struct r600_texture * texture,struct r600_texture * staging,unsigned first_level,unsigned last_level,unsigned first_layer,unsigned last_layer,unsigned first_sample,unsigned last_sample)102 static void r600_blit_decompress_depth(struct pipe_context *ctx,
103 struct r600_texture *texture,
104 struct r600_texture *staging,
105 unsigned first_level, unsigned last_level,
106 unsigned first_layer, unsigned last_layer,
107 unsigned first_sample, unsigned last_sample)
108 {
109 struct r600_context *rctx = (struct r600_context *)ctx;
110 unsigned layer, level, sample, checked_last_layer, max_layer, max_sample;
111 struct r600_texture *flushed_depth_texture = staging ?
112 staging : texture->flushed_depth_texture;
113 const struct util_format_description *desc =
114 util_format_description(texture->resource.b.b.format);
115 float depth;
116
117 if (!staging && !texture->dirty_level_mask)
118 return;
119
120 max_sample = u_max_sample(&texture->resource.b.b);
121
122 /* XXX Decompressing MSAA depth textures is broken on R6xx.
123 * There is also a hardlock if CMASK and FMASK are not present.
124 * Just skip this until we find out how to fix it. */
125 if (rctx->b.gfx_level == R600 && max_sample > 0) {
126 texture->dirty_level_mask = 0;
127 return;
128 }
129
130 if (rctx->b.family == CHIP_RV610 || rctx->b.family == CHIP_RV630 ||
131 rctx->b.family == CHIP_RV620 || rctx->b.family == CHIP_RV635)
132 depth = 0.0f;
133 else
134 depth = 1.0f;
135
136 /* Enable decompression in DB_RENDER_CONTROL */
137 rctx->db_misc_state.flush_depthstencil_through_cb = true;
138 rctx->db_misc_state.copy_depth = util_format_has_depth(desc);
139 rctx->db_misc_state.copy_stencil = util_format_has_stencil(desc);
140 rctx->db_misc_state.copy_sample = first_sample;
141 r600_mark_atom_dirty(rctx, &rctx->db_misc_state.atom);
142
143 for (level = first_level; level <= last_level; level++) {
144 if (!staging && !(texture->dirty_level_mask & (1 << level)))
145 continue;
146
147 /* The smaller the mipmap level, the less layers there are
148 * as far as 3D textures are concerned. */
149 max_layer = util_max_layer(&texture->resource.b.b, level);
150 checked_last_layer = last_layer < max_layer ? last_layer : max_layer;
151
152 for (layer = first_layer; layer <= checked_last_layer; layer++) {
153 for (sample = first_sample; sample <= last_sample; sample++) {
154 struct pipe_surface *zsurf, *cbsurf, surf_tmpl;
155
156 if (sample != rctx->db_misc_state.copy_sample) {
157 rctx->db_misc_state.copy_sample = sample;
158 r600_mark_atom_dirty(rctx, &rctx->db_misc_state.atom);
159 }
160
161 surf_tmpl.format = texture->resource.b.b.format;
162 surf_tmpl.u.tex.level = level;
163 surf_tmpl.u.tex.first_layer = layer;
164 surf_tmpl.u.tex.last_layer = layer;
165
166 zsurf = ctx->create_surface(ctx, &texture->resource.b.b, &surf_tmpl);
167
168 surf_tmpl.format = flushed_depth_texture->resource.b.b.format;
169 cbsurf = ctx->create_surface(ctx,
170 &flushed_depth_texture->resource.b.b, &surf_tmpl);
171
172 r600_blitter_begin(ctx, R600_DECOMPRESS);
173 util_blitter_custom_depth_stencil(rctx->blitter, zsurf, cbsurf, 1 << sample,
174 rctx->custom_dsa_flush, depth);
175 r600_blitter_end(ctx);
176
177 pipe_surface_reference(&zsurf, NULL);
178 pipe_surface_reference(&cbsurf, NULL);
179 }
180 }
181
182 /* The texture will always be dirty if some layers or samples aren't flushed.
183 * I don't think this case occurs often though. */
184 if (!staging &&
185 first_layer == 0 && last_layer == max_layer &&
186 first_sample == 0 && last_sample == max_sample) {
187 texture->dirty_level_mask &= ~(1 << level);
188 }
189 }
190
191 /* re-enable compression in DB_RENDER_CONTROL */
192 rctx->db_misc_state.flush_depthstencil_through_cb = false;
193 r600_mark_atom_dirty(rctx, &rctx->db_misc_state.atom);
194 }
195
r600_blit_decompress_depth_in_place(struct r600_context * rctx,struct r600_texture * texture,bool is_stencil_sampler,unsigned first_level,unsigned last_level,unsigned first_layer,unsigned last_layer)196 static void r600_blit_decompress_depth_in_place(struct r600_context *rctx,
197 struct r600_texture *texture,
198 bool is_stencil_sampler,
199 unsigned first_level, unsigned last_level,
200 unsigned first_layer, unsigned last_layer)
201 {
202 struct pipe_surface *zsurf, surf_tmpl = {{0}};
203 unsigned layer, max_layer, checked_last_layer, level;
204 unsigned *dirty_level_mask;
205
206 /* Enable decompression in DB_RENDER_CONTROL */
207 if (is_stencil_sampler) {
208 rctx->db_misc_state.flush_stencil_inplace = true;
209 dirty_level_mask = &texture->stencil_dirty_level_mask;
210 } else {
211 rctx->db_misc_state.flush_depth_inplace = true;
212 dirty_level_mask = &texture->dirty_level_mask;
213 }
214 r600_mark_atom_dirty(rctx, &rctx->db_misc_state.atom);
215
216 surf_tmpl.format = texture->resource.b.b.format;
217
218 for (level = first_level; level <= last_level; level++) {
219 if (!(*dirty_level_mask & (1 << level)))
220 continue;
221
222 surf_tmpl.u.tex.level = level;
223
224 /* The smaller the mipmap level, the less layers there are
225 * as far as 3D textures are concerned. */
226 max_layer = util_max_layer(&texture->resource.b.b, level);
227 checked_last_layer = last_layer < max_layer ? last_layer : max_layer;
228
229 for (layer = first_layer; layer <= checked_last_layer; layer++) {
230 surf_tmpl.u.tex.first_layer = layer;
231 surf_tmpl.u.tex.last_layer = layer;
232
233 zsurf = rctx->b.b.create_surface(&rctx->b.b, &texture->resource.b.b, &surf_tmpl);
234
235 r600_blitter_begin(&rctx->b.b, R600_DECOMPRESS);
236 util_blitter_custom_depth_stencil(rctx->blitter, zsurf, NULL, ~0,
237 rctx->custom_dsa_flush, 1.0f);
238 r600_blitter_end(&rctx->b.b);
239
240 pipe_surface_reference(&zsurf, NULL);
241 }
242
243 /* The texture will always be dirty if some layers or samples aren't flushed.
244 * I don't think this case occurs often though. */
245 if (first_layer == 0 && last_layer == max_layer) {
246 *dirty_level_mask &= ~(1 << level);
247 }
248 }
249
250 /* Disable decompression in DB_RENDER_CONTROL */
251 rctx->db_misc_state.flush_depth_inplace = false;
252 rctx->db_misc_state.flush_stencil_inplace = false;
253 r600_mark_atom_dirty(rctx, &rctx->db_misc_state.atom);
254 }
255
r600_decompress_depth_textures(struct r600_context * rctx,struct r600_samplerview_state * textures)256 void r600_decompress_depth_textures(struct r600_context *rctx,
257 struct r600_samplerview_state *textures)
258 {
259 unsigned i;
260 unsigned depth_texture_mask = textures->compressed_depthtex_mask;
261
262 while (depth_texture_mask) {
263 struct pipe_sampler_view *view;
264 struct r600_pipe_sampler_view *rview;
265 struct r600_texture *tex;
266
267 i = u_bit_scan(&depth_texture_mask);
268
269 view = &textures->views[i]->base;
270 assert(view);
271 rview = (struct r600_pipe_sampler_view*)view;
272
273 tex = (struct r600_texture *)view->texture;
274 assert(tex->db_compatible);
275
276 if (r600_can_sample_zs(tex, rview->is_stencil_sampler)) {
277 r600_blit_decompress_depth_in_place(rctx, tex,
278 rview->is_stencil_sampler,
279 view->u.tex.first_level, view->u.tex.last_level,
280 0, util_max_layer(&tex->resource.b.b, view->u.tex.first_level));
281 } else {
282 r600_blit_decompress_depth(&rctx->b.b, tex, NULL,
283 view->u.tex.first_level, view->u.tex.last_level,
284 0, util_max_layer(&tex->resource.b.b, view->u.tex.first_level),
285 0, u_max_sample(&tex->resource.b.b));
286 }
287 }
288 }
289
r600_decompress_depth_images(struct r600_context * rctx,struct r600_image_state * images)290 void r600_decompress_depth_images(struct r600_context *rctx,
291 struct r600_image_state *images)
292 {
293 unsigned i;
294 unsigned depth_texture_mask = images->compressed_depthtex_mask;
295
296 while (depth_texture_mask) {
297 struct r600_image_view *view;
298 struct r600_texture *tex;
299
300 i = u_bit_scan(&depth_texture_mask);
301
302 view = &images->views[i];
303 assert(view);
304
305 tex = (struct r600_texture *)view->base.resource;
306 assert(tex->db_compatible);
307
308 if (r600_can_sample_zs(tex, false)) {
309 r600_blit_decompress_depth_in_place(rctx, tex,
310 false,
311 view->base.u.tex.level,
312 view->base.u.tex.level,
313 0, util_max_layer(&tex->resource.b.b, view->base.u.tex.level));
314 } else {
315 r600_blit_decompress_depth(&rctx->b.b, tex, NULL,
316 view->base.u.tex.level,
317 view->base.u.tex.level,
318 0, util_max_layer(&tex->resource.b.b, view->base.u.tex.level),
319 0, u_max_sample(&tex->resource.b.b));
320 }
321 }
322 }
323
r600_blit_decompress_color(struct pipe_context * ctx,struct r600_texture * rtex,unsigned first_level,unsigned last_level,unsigned first_layer,unsigned last_layer)324 static void r600_blit_decompress_color(struct pipe_context *ctx,
325 struct r600_texture *rtex,
326 unsigned first_level, unsigned last_level,
327 unsigned first_layer, unsigned last_layer)
328 {
329 struct r600_context *rctx = (struct r600_context *)ctx;
330 unsigned layer, level, checked_last_layer, max_layer;
331
332 if (!rtex->dirty_level_mask)
333 return;
334
335 for (level = first_level; level <= last_level; level++) {
336 if (!(rtex->dirty_level_mask & (1 << level)))
337 continue;
338
339 /* The smaller the mipmap level, the less layers there are
340 * as far as 3D textures are concerned. */
341 max_layer = util_max_layer(&rtex->resource.b.b, level);
342 checked_last_layer = last_layer < max_layer ? last_layer : max_layer;
343
344 for (layer = first_layer; layer <= checked_last_layer; layer++) {
345 struct pipe_surface *cbsurf, surf_tmpl;
346
347 surf_tmpl.format = rtex->resource.b.b.format;
348 surf_tmpl.u.tex.level = level;
349 surf_tmpl.u.tex.first_layer = layer;
350 surf_tmpl.u.tex.last_layer = layer;
351 cbsurf = ctx->create_surface(ctx, &rtex->resource.b.b, &surf_tmpl);
352
353 r600_blitter_begin(ctx, R600_DECOMPRESS);
354 util_blitter_custom_color(rctx->blitter, cbsurf,
355 rtex->fmask.size ? rctx->custom_blend_decompress : rctx->custom_blend_fastclear);
356 r600_blitter_end(ctx);
357
358 pipe_surface_reference(&cbsurf, NULL);
359 }
360
361 /* The texture will always be dirty if some layers aren't flushed.
362 * I don't think this case occurs often though. */
363 if (first_layer == 0 && last_layer == max_layer) {
364 rtex->dirty_level_mask &= ~(1 << level);
365 }
366 }
367 }
368
r600_decompress_color_textures(struct r600_context * rctx,struct r600_samplerview_state * textures)369 void r600_decompress_color_textures(struct r600_context *rctx,
370 struct r600_samplerview_state *textures)
371 {
372 unsigned i;
373 unsigned mask = textures->compressed_colortex_mask;
374
375 while (mask) {
376 struct pipe_sampler_view *view;
377 struct r600_texture *tex;
378
379 i = u_bit_scan(&mask);
380
381 view = &textures->views[i]->base;
382 assert(view);
383
384 tex = (struct r600_texture *)view->texture;
385 assert(tex->cmask.size);
386
387 r600_blit_decompress_color(&rctx->b.b, tex,
388 view->u.tex.first_level, view->u.tex.last_level,
389 0, util_max_layer(&tex->resource.b.b, view->u.tex.first_level));
390 }
391 }
392
r600_decompress_color_images(struct r600_context * rctx,struct r600_image_state * images)393 void r600_decompress_color_images(struct r600_context *rctx,
394 struct r600_image_state *images)
395 {
396 unsigned i;
397 unsigned mask = images->compressed_colortex_mask;
398
399 while (mask) {
400 struct r600_image_view *view;
401 struct r600_texture *tex;
402
403 i = u_bit_scan(&mask);
404
405 view = &images->views[i];
406 assert(view);
407
408 tex = (struct r600_texture *)view->base.resource;
409 assert(tex->cmask.size);
410
411 r600_blit_decompress_color(&rctx->b.b, tex,
412 view->base.u.tex.level, view->base.u.tex.level,
413 view->base.u.tex.first_layer,
414 view->base.u.tex.last_layer);
415 }
416 }
417
418 /* Helper for decompressing a portion of a color or depth resource before
419 * blitting if any decompression is needed.
420 * The driver doesn't decompress resources automatically while u_blitter is
421 * rendering. */
r600_decompress_subresource(struct pipe_context * ctx,struct pipe_resource * tex,unsigned level,unsigned first_layer,unsigned last_layer)422 static bool r600_decompress_subresource(struct pipe_context *ctx,
423 struct pipe_resource *tex,
424 unsigned level,
425 unsigned first_layer, unsigned last_layer)
426 {
427 struct r600_context *rctx = (struct r600_context *)ctx;
428 struct r600_texture *rtex = (struct r600_texture*)tex;
429
430 if (rtex->db_compatible) {
431 if (r600_can_sample_zs(rtex, false)) {
432 r600_blit_decompress_depth_in_place(rctx, rtex, false,
433 level, level,
434 first_layer, last_layer);
435 if (rtex->surface.has_stencil) {
436 r600_blit_decompress_depth_in_place(rctx, rtex, true,
437 level, level,
438 first_layer, last_layer);
439 }
440 } else {
441 if (!r600_init_flushed_depth_texture(ctx, tex, NULL))
442 return false; /* error */
443
444 r600_blit_decompress_depth(ctx, rtex, NULL,
445 level, level,
446 first_layer, last_layer,
447 0, u_max_sample(tex));
448 }
449 } else if (rtex->cmask.size) {
450 r600_blit_decompress_color(ctx, rtex, level, level,
451 first_layer, last_layer);
452 }
453 return true;
454 }
455
r600_clear(struct pipe_context * ctx,unsigned buffers,const struct pipe_scissor_state * scissor_state,const union pipe_color_union * color,double depth,unsigned stencil)456 static void r600_clear(struct pipe_context *ctx, unsigned buffers,
457 const struct pipe_scissor_state *scissor_state,
458 const union pipe_color_union *color,
459 double depth, unsigned stencil)
460 {
461 struct r600_context *rctx = (struct r600_context *)ctx;
462 struct pipe_framebuffer_state *fb = &rctx->framebuffer.state;
463
464 if (buffers & PIPE_CLEAR_COLOR && rctx->b.gfx_level >= EVERGREEN) {
465 evergreen_do_fast_color_clear(&rctx->b, fb, &rctx->framebuffer.atom,
466 &buffers, NULL, color);
467 if (!buffers)
468 return; /* all buffers have been fast cleared */
469 }
470
471 if (buffers & PIPE_CLEAR_COLOR) {
472 int i;
473
474 /* These buffers cannot use fast clear, make sure to disable expansion. */
475 for (i = 0; i < fb->nr_cbufs; i++) {
476 struct r600_texture *tex;
477
478 /* If not clearing this buffer, skip. */
479 if (!(buffers & (PIPE_CLEAR_COLOR0 << i)))
480 continue;
481
482 if (!fb->cbufs[i])
483 continue;
484
485 tex = (struct r600_texture *)fb->cbufs[i]->texture;
486 if (tex->fmask.size == 0)
487 tex->dirty_level_mask &= ~(1 << fb->cbufs[i]->u.tex.level);
488 }
489 }
490
491 /* if hyperz enabled just clear hyperz */
492 if (fb->zsbuf && (buffers & PIPE_CLEAR_DEPTH)) {
493 struct r600_texture *rtex;
494 unsigned level = fb->zsbuf->u.tex.level;
495
496 rtex = (struct r600_texture*)fb->zsbuf->texture;
497
498 /* We can't use hyperz fast clear if each slice of a texture
499 * array are clear to different value. To simplify code just
500 * disable fast clear for texture array.
501 */
502 if (r600_htile_enabled(rtex, level) &&
503 fb->zsbuf->u.tex.first_layer == 0 &&
504 fb->zsbuf->u.tex.last_layer == util_max_layer(&rtex->resource.b.b, level)) {
505 if (rtex->depth_clear_value != depth) {
506 rtex->depth_clear_value = depth;
507 r600_mark_atom_dirty(rctx, &rctx->db_state.atom);
508 }
509 rctx->db_misc_state.htile_clear = true;
510 r600_mark_atom_dirty(rctx, &rctx->db_misc_state.atom);
511 }
512 }
513
514 r600_blitter_begin(ctx, R600_CLEAR);
515 util_blitter_clear(rctx->blitter, fb->width, fb->height,
516 util_framebuffer_get_num_layers(fb),
517 buffers, color, depth, stencil,
518 util_framebuffer_get_num_samples(fb) > 1);
519 r600_blitter_end(ctx);
520
521 /* disable fast clear */
522 if (rctx->db_misc_state.htile_clear) {
523 rctx->db_misc_state.htile_clear = false;
524 r600_mark_atom_dirty(rctx, &rctx->db_misc_state.atom);
525 }
526 }
527
r600_clear_render_target(struct pipe_context * ctx,struct pipe_surface * dst,const union pipe_color_union * color,unsigned dstx,unsigned dsty,unsigned width,unsigned height,bool render_condition_enabled)528 static void r600_clear_render_target(struct pipe_context *ctx,
529 struct pipe_surface *dst,
530 const union pipe_color_union *color,
531 unsigned dstx, unsigned dsty,
532 unsigned width, unsigned height,
533 bool render_condition_enabled)
534 {
535 struct r600_context *rctx = (struct r600_context *)ctx;
536
537 r600_blitter_begin(ctx, R600_CLEAR_SURFACE |
538 (render_condition_enabled ? 0 : R600_DISABLE_RENDER_COND));
539 util_blitter_clear_render_target(rctx->blitter, dst, color,
540 dstx, dsty, width, height);
541 r600_blitter_end(ctx);
542 }
543
r600_clear_depth_stencil(struct pipe_context * ctx,struct pipe_surface * dst,unsigned clear_flags,double depth,unsigned stencil,unsigned dstx,unsigned dsty,unsigned width,unsigned height,bool render_condition_enabled)544 static void r600_clear_depth_stencil(struct pipe_context *ctx,
545 struct pipe_surface *dst,
546 unsigned clear_flags,
547 double depth,
548 unsigned stencil,
549 unsigned dstx, unsigned dsty,
550 unsigned width, unsigned height,
551 bool render_condition_enabled)
552 {
553 struct r600_context *rctx = (struct r600_context *)ctx;
554
555 r600_blitter_begin(ctx, R600_CLEAR_SURFACE |
556 (render_condition_enabled ? 0 : R600_DISABLE_RENDER_COND));
557 util_blitter_clear_depth_stencil(rctx->blitter, dst, clear_flags, depth, stencil,
558 dstx, dsty, width, height);
559 r600_blitter_end(ctx);
560 }
561
r600_copy_buffer(struct pipe_context * ctx,struct pipe_resource * dst,unsigned dstx,struct pipe_resource * src,const struct pipe_box * src_box)562 static void r600_copy_buffer(struct pipe_context *ctx, struct pipe_resource *dst, unsigned dstx,
563 struct pipe_resource *src, const struct pipe_box *src_box)
564 {
565 struct r600_context *rctx = (struct r600_context*)ctx;
566
567 if (rctx->screen->b.has_cp_dma)
568 r600_cp_dma_copy_buffer(rctx, dst, dstx, src, src_box->x, src_box->width);
569 else
570 util_resource_copy_region(ctx, dst, 0, dstx, 0, 0, src, 0, src_box);
571 }
572
573 /**
574 * Global buffers are not really resources, they are are actually offsets
575 * into a single global resource (r600_screen::global_pool). The means
576 * they don't have their own buf handle, so they cannot be passed
577 * to r600_copy_buffer() and must be handled separately.
578 */
r600_copy_global_buffer(struct pipe_context * ctx,struct pipe_resource * dst,unsigned dstx,struct pipe_resource * src,const struct pipe_box * src_box)579 static void r600_copy_global_buffer(struct pipe_context *ctx,
580 struct pipe_resource *dst, unsigned
581 dstx, struct pipe_resource *src,
582 const struct pipe_box *src_box)
583 {
584 struct r600_context *rctx = (struct r600_context*)ctx;
585 struct compute_memory_pool *pool = rctx->screen->global_pool;
586 struct pipe_box new_src_box = *src_box;
587
588 if (src->bind & PIPE_BIND_GLOBAL) {
589 struct r600_resource_global *rsrc =
590 (struct r600_resource_global *)src;
591 struct compute_memory_item *item = rsrc->chunk;
592
593 if (is_item_in_pool(item)) {
594 new_src_box.x += 4 * item->start_in_dw;
595 src = (struct pipe_resource *)pool->bo;
596 } else {
597 if (item->real_buffer == NULL) {
598 item->real_buffer =
599 r600_compute_buffer_alloc_vram(pool->screen,
600 item->size_in_dw * 4);
601 }
602 src = (struct pipe_resource*)item->real_buffer;
603 }
604 }
605 if (dst->bind & PIPE_BIND_GLOBAL) {
606 struct r600_resource_global *rdst =
607 (struct r600_resource_global *)dst;
608 struct compute_memory_item *item = rdst->chunk;
609
610 if (is_item_in_pool(item)) {
611 dstx += 4 * item->start_in_dw;
612 dst = (struct pipe_resource *)pool->bo;
613 } else {
614 if (item->real_buffer == NULL) {
615 item->real_buffer =
616 r600_compute_buffer_alloc_vram(pool->screen,
617 item->size_in_dw * 4);
618 }
619 dst = (struct pipe_resource*)item->real_buffer;
620 }
621 }
622
623 r600_copy_buffer(ctx, dst, dstx, src, &new_src_box);
624 }
625
r600_clear_buffer(struct pipe_context * ctx,struct pipe_resource * dst,uint64_t offset,uint64_t size,unsigned value,enum r600_coherency coher)626 static void r600_clear_buffer(struct pipe_context *ctx, struct pipe_resource *dst,
627 uint64_t offset, uint64_t size, unsigned value,
628 enum r600_coherency coher)
629 {
630 struct r600_context *rctx = (struct r600_context*)ctx;
631
632 if (rctx->screen->b.has_cp_dma &&
633 rctx->b.gfx_level >= EVERGREEN &&
634 offset % 4 == 0 && size % 4 == 0) {
635 evergreen_cp_dma_clear_buffer(rctx, dst, offset, size, value, coher);
636 } else if (rctx->screen->b.has_streamout && offset % 4 == 0 && size % 4 == 0) {
637 union pipe_color_union clear_value;
638 clear_value.ui[0] = value;
639
640 r600_blitter_begin(ctx, R600_DISABLE_RENDER_COND);
641 util_blitter_clear_buffer(rctx->blitter, dst, offset, size,
642 1, &clear_value);
643 r600_blitter_end(ctx);
644 } else {
645 uint32_t *map = r600_buffer_map_sync_with_rings(&rctx->b, r600_resource(dst),
646 PIPE_MAP_WRITE);
647 map += offset / 4;
648 size /= 4;
649 for (unsigned i = 0; i < size; i++)
650 *map++ = value;
651 }
652 }
653
r600_resource_copy_region(struct pipe_context * ctx,struct pipe_resource * dst,unsigned dst_level,unsigned dstx,unsigned dsty,unsigned dstz,struct pipe_resource * src,unsigned src_level,const struct pipe_box * src_box)654 void r600_resource_copy_region(struct pipe_context *ctx,
655 struct pipe_resource *dst,
656 unsigned dst_level,
657 unsigned dstx, unsigned dsty, unsigned dstz,
658 struct pipe_resource *src,
659 unsigned src_level,
660 const struct pipe_box *src_box)
661 {
662 struct r600_context *rctx = (struct r600_context *)ctx;
663 struct pipe_surface *dst_view, dst_templ;
664 struct pipe_sampler_view src_templ, *src_view;
665 unsigned dst_width, dst_height, src_width0, src_height0, src_widthFL, src_heightFL;
666 unsigned src_force_level = 0;
667 struct pipe_box sbox, dstbox;
668
669 /* Handle buffers first. */
670 if (dst->target == PIPE_BUFFER && src->target == PIPE_BUFFER) {
671 if ((src->bind & PIPE_BIND_GLOBAL) ||
672 (dst->bind & PIPE_BIND_GLOBAL)) {
673 r600_copy_global_buffer(ctx, dst, dstx, src, src_box);
674 } else {
675 r600_copy_buffer(ctx, dst, dstx, src, src_box);
676 }
677 return;
678 }
679
680 assert(u_max_sample(dst) == u_max_sample(src));
681
682 /* The driver doesn't decompress resources automatically while
683 * u_blitter is rendering. */
684 if (!r600_decompress_subresource(ctx, src, src_level,
685 src_box->z, src_box->z + src_box->depth - 1)) {
686 return; /* error */
687 }
688
689 dst_width = u_minify(dst->width0, dst_level);
690 dst_height = u_minify(dst->height0, dst_level);
691 src_width0 = src->width0;
692 src_height0 = src->height0;
693 src_widthFL = u_minify(src->width0, src_level);
694 src_heightFL = u_minify(src->height0, src_level);
695
696 util_blitter_default_dst_texture(&dst_templ, dst, dst_level, dstz);
697 util_blitter_default_src_texture(rctx->blitter, &src_templ, src, src_level);
698
699 if (util_format_is_compressed(src->format) ||
700 util_format_is_compressed(dst->format)) {
701 unsigned blocksize = util_format_get_blocksize(src->format);
702
703 if (blocksize == 8)
704 src_templ.format = PIPE_FORMAT_R16G16B16A16_UINT; /* 64-bit block */
705 else
706 src_templ.format = PIPE_FORMAT_R32G32B32A32_UINT; /* 128-bit block */
707 dst_templ.format = src_templ.format;
708
709 dst_width = util_format_get_nblocksx(dst->format, dst_width);
710 dst_height = util_format_get_nblocksy(dst->format, dst_height);
711 src_width0 = util_format_get_nblocksx(src->format, src_width0);
712 src_height0 = util_format_get_nblocksy(src->format, src_height0);
713 src_widthFL = util_format_get_nblocksx(src->format, src_widthFL);
714 src_heightFL = util_format_get_nblocksy(src->format, src_heightFL);
715
716 dstx = util_format_get_nblocksx(dst->format, dstx);
717 dsty = util_format_get_nblocksy(dst->format, dsty);
718
719 sbox.x = util_format_get_nblocksx(src->format, src_box->x);
720 sbox.y = util_format_get_nblocksy(src->format, src_box->y);
721 sbox.z = src_box->z;
722 sbox.width = util_format_get_nblocksx(src->format, src_box->width);
723 sbox.height = util_format_get_nblocksy(src->format, src_box->height);
724 sbox.depth = src_box->depth;
725 src_box = &sbox;
726
727 src_force_level = src_level;
728 } else if (!util_blitter_is_copy_supported(rctx->blitter, dst, src)) {
729 if (util_format_is_subsampled_422(src->format)) {
730
731 src_templ.format = PIPE_FORMAT_R8G8B8A8_UINT;
732 dst_templ.format = PIPE_FORMAT_R8G8B8A8_UINT;
733
734 dst_width = util_format_get_nblocksx(dst->format, dst_width);
735 src_width0 = util_format_get_nblocksx(src->format, src_width0);
736 src_widthFL = util_format_get_nblocksx(src->format, src_widthFL);
737
738 dstx = util_format_get_nblocksx(dst->format, dstx);
739
740 sbox = *src_box;
741 sbox.x = util_format_get_nblocksx(src->format, src_box->x);
742 sbox.width = util_format_get_nblocksx(src->format, src_box->width);
743 src_box = &sbox;
744 } else {
745 unsigned blocksize = util_format_get_blocksize(src->format);
746
747 switch (blocksize) {
748 case 1:
749 dst_templ.format = PIPE_FORMAT_R8_UNORM;
750 src_templ.format = PIPE_FORMAT_R8_UNORM;
751 break;
752 case 2:
753 dst_templ.format = PIPE_FORMAT_R8G8_UNORM;
754 src_templ.format = PIPE_FORMAT_R8G8_UNORM;
755 break;
756 case 4:
757 dst_templ.format = PIPE_FORMAT_R8G8B8A8_UNORM;
758 src_templ.format = PIPE_FORMAT_R8G8B8A8_UNORM;
759 break;
760 case 8:
761 dst_templ.format = PIPE_FORMAT_R16G16B16A16_UINT;
762 src_templ.format = PIPE_FORMAT_R16G16B16A16_UINT;
763 break;
764 case 16:
765 dst_templ.format = PIPE_FORMAT_R32G32B32A32_UINT;
766 src_templ.format = PIPE_FORMAT_R32G32B32A32_UINT;
767 break;
768 default:
769 fprintf(stderr, "Unhandled format %s with blocksize %u\n",
770 util_format_short_name(src->format), blocksize);
771 assert(0);
772 }
773 }
774 }
775
776 dst_view = r600_create_surface_custom(ctx, dst, &dst_templ,
777 /* we don't care about these two for r600g */
778 dst->width0, dst->height0,
779 dst_width, dst_height);
780
781 if (rctx->b.gfx_level >= EVERGREEN) {
782 src_view = evergreen_create_sampler_view_custom(ctx, src, &src_templ,
783 src_width0, src_height0,
784 src_force_level);
785 } else {
786 src_view = r600_create_sampler_view_custom(ctx, src, &src_templ,
787 src_widthFL, src_heightFL);
788 }
789
790 u_box_3d(dstx, dsty, dstz, abs(src_box->width), abs(src_box->height),
791 abs(src_box->depth), &dstbox);
792
793 /* Copy. */
794 r600_blitter_begin(ctx, R600_COPY_TEXTURE);
795 util_blitter_blit_generic(rctx->blitter, dst_view, &dstbox,
796 src_view, src_box, src_width0, src_height0,
797 PIPE_MASK_RGBAZS, PIPE_TEX_FILTER_NEAREST, NULL,
798 false, false, 0, NULL);
799 r600_blitter_end(ctx);
800
801 pipe_surface_reference(&dst_view, NULL);
802 pipe_sampler_view_reference(&src_view, NULL);
803 }
804
do_hardware_msaa_resolve(struct pipe_context * ctx,const struct pipe_blit_info * info)805 static bool do_hardware_msaa_resolve(struct pipe_context *ctx,
806 const struct pipe_blit_info *info)
807 {
808 struct r600_context *rctx = (struct r600_context*)ctx;
809 struct r600_texture *dst = (struct r600_texture*)info->dst.resource;
810 unsigned dst_width = u_minify(info->dst.resource->width0, info->dst.level);
811 unsigned dst_height = u_minify(info->dst.resource->height0, info->dst.level);
812 enum pipe_format format = info->src.format;
813 unsigned sample_mask =
814 rctx->b.gfx_level == CAYMAN ? ~0 :
815 ((1ull << MAX2(1, info->src.resource->nr_samples)) - 1);
816 struct pipe_resource *tmp, templ;
817 struct pipe_blit_info blit;
818
819 /* Check basic requirements for hw resolve. */
820 if (!(info->src.resource->nr_samples > 1 &&
821 info->dst.resource->nr_samples <= 1 &&
822 !util_format_is_pure_integer(format) &&
823 !util_format_is_depth_or_stencil(format) &&
824 util_max_layer(info->src.resource, 0) == 0))
825 return false;
826
827 /* Check the remaining requirements for hw resolve. */
828 if (util_max_layer(info->dst.resource, info->dst.level) == 0 &&
829 util_is_format_compatible(util_format_description(info->src.format),
830 util_format_description(info->dst.format)) &&
831 !info->scissor_enable &&
832 !info->swizzle_enable &&
833 (info->mask & PIPE_MASK_RGBA) == PIPE_MASK_RGBA &&
834 dst_width == info->src.resource->width0 &&
835 dst_height == info->src.resource->height0 &&
836 info->dst.box.x == 0 &&
837 info->dst.box.y == 0 &&
838 info->dst.box.width == dst_width &&
839 info->dst.box.height == dst_height &&
840 info->dst.box.depth == 1 &&
841 info->src.box.x == 0 &&
842 info->src.box.y == 0 &&
843 info->src.box.width == dst_width &&
844 info->src.box.height == dst_height &&
845 info->src.box.depth == 1 &&
846 dst->surface.u.legacy.level[info->dst.level].mode >= RADEON_SURF_MODE_1D &&
847 (!dst->cmask.size || !dst->dirty_level_mask) /* dst cannot be fast-cleared */) {
848 r600_blitter_begin(ctx, R600_COLOR_RESOLVE |
849 (info->render_condition_enable ? 0 : R600_DISABLE_RENDER_COND));
850 util_blitter_custom_resolve_color(rctx->blitter,
851 info->dst.resource, info->dst.level,
852 info->dst.box.z,
853 info->src.resource, info->src.box.z,
854 sample_mask, rctx->custom_blend_resolve,
855 format);
856 r600_blitter_end(ctx);
857 return true;
858 }
859
860 /* Shader-based resolve is VERY SLOW. Instead, resolve into
861 * a temporary texture and blit.
862 */
863 memset(&templ, 0, sizeof(templ));
864 templ.target = PIPE_TEXTURE_2D;
865 templ.format = info->src.resource->format;
866 templ.width0 = info->src.resource->width0;
867 templ.height0 = info->src.resource->height0;
868 templ.depth0 = 1;
869 templ.array_size = 1;
870 templ.usage = PIPE_USAGE_DEFAULT;
871 templ.flags = R600_RESOURCE_FLAG_FORCE_TILING;
872
873 tmp = ctx->screen->resource_create(ctx->screen, &templ);
874 if (!tmp)
875 return false;
876
877 /* resolve */
878 r600_blitter_begin(ctx, R600_COLOR_RESOLVE |
879 (info->render_condition_enable ? 0 : R600_DISABLE_RENDER_COND));
880 util_blitter_custom_resolve_color(rctx->blitter, tmp, 0, 0,
881 info->src.resource, info->src.box.z,
882 sample_mask, rctx->custom_blend_resolve,
883 format);
884 r600_blitter_end(ctx);
885
886 /* blit */
887 blit = *info;
888 blit.src.resource = tmp;
889 blit.src.box.z = 0;
890
891 r600_blitter_begin(ctx, R600_BLIT |
892 (info->render_condition_enable ? 0 : R600_DISABLE_RENDER_COND));
893 util_blitter_blit(rctx->blitter, &blit, NULL);
894 r600_blitter_end(ctx);
895
896 pipe_resource_reference(&tmp, NULL);
897 return true;
898 }
899
r600_stencil_z24unorms8_to_z24unorms8uint(struct pipe_context * ctx,struct pipe_resource * dst,struct pipe_resource * src,const struct pipe_box * box_dst,const struct pipe_box * box_src,const unsigned dst_level,const unsigned src_level)900 static void r600_stencil_z24unorms8_to_z24unorms8uint(struct pipe_context *ctx,
901 struct pipe_resource *dst, struct pipe_resource *src,
902 const struct pipe_box *box_dst, const struct pipe_box *box_src,
903 const unsigned dst_level, const unsigned src_level)
904 {
905 struct pipe_transfer *tsrc;
906 uint8_t *slice_src = pipe_texture_map_3d(ctx, src, src_level, PIPE_MAP_READ,
907 box_src->x, box_src->y, box_src->z,
908 box_src->width, box_src->height, box_src->depth, &tsrc);
909 if (slice_src) {
910 struct pipe_transfer *tdst;
911 uint8_t *slice_dst = pipe_texture_map_3d(ctx, dst, dst_level, PIPE_MAP_READ_WRITE,
912 box_dst->x, box_dst->y, box_dst->z,
913 box_src->width, box_src->height, box_src->depth, &tdst);
914 if (slice_dst) {
915 for (unsigned slice = 0; slice < box_src->depth; slice++)
916 for (unsigned row = 0; row < box_src->height; row++) {
917 for (unsigned k = 0; k < box_src->width; k++) {
918 slice_dst[k * 4 + 3] = slice_src[k * 4 + 3];
919 }
920 slice_src += tsrc->stride / sizeof(*slice_src);
921 slice_dst += tdst->stride / sizeof(*slice_dst);
922 }
923 pipe_texture_unmap(ctx, tdst);
924 }
925 pipe_texture_unmap(ctx, tsrc);
926 }
927 }
928
r600_stencil_z32floats8x24_to_z24unorms8(struct pipe_context * ctx,struct pipe_resource * dst,struct pipe_resource * src,const struct pipe_box * box_dst,const struct pipe_box * box_src,const unsigned dst_level,const unsigned src_level)929 static void r600_stencil_z32floats8x24_to_z24unorms8(struct pipe_context *ctx,
930 struct pipe_resource *dst, struct pipe_resource *src,
931 const struct pipe_box *box_dst, const struct pipe_box *box_src,
932 const unsigned dst_level, const unsigned src_level)
933 {
934 struct pipe_transfer *tsrc;
935 uint8_t *slice_src = pipe_texture_map_3d(ctx, src, src_level, PIPE_MAP_READ,
936 box_src->x, box_src->y, box_src->z,
937 box_src->width, box_src->height, box_src->depth, &tsrc);
938 if (slice_src) {
939 struct pipe_transfer *tdst;
940 uint8_t *slice_dst = pipe_texture_map_3d(ctx, dst, dst_level, PIPE_MAP_READ_WRITE,
941 box_dst->x, box_dst->y, box_dst->z,
942 box_src->width, box_src->height, box_src->depth, &tdst);
943 if (slice_dst) {
944 for (unsigned slice = 0; slice < box_src->depth; slice++)
945 for (unsigned row = 0; row < box_src->height; row++) {
946 for (unsigned k = 0; k < box_src->width; k++) {
947 slice_dst[k * 4 + 3] = slice_src[k * 8 + 4];
948 }
949 slice_src += tsrc->stride / sizeof(*slice_src);
950 slice_dst += tdst->stride / sizeof(*slice_dst);
951 }
952 pipe_texture_unmap(ctx, tdst);
953 }
954 pipe_texture_unmap(ctx, tsrc);
955 }
956 }
957
r600_blit(struct pipe_context * ctx,const struct pipe_blit_info * info)958 static void r600_blit(struct pipe_context *ctx,
959 const struct pipe_blit_info *info)
960 {
961 struct r600_context *rctx = (struct r600_context*)ctx;
962 struct r600_texture *rdst = (struct r600_texture *)info->dst.resource;
963
964 if (do_hardware_msaa_resolve(ctx, info)) {
965 return;
966 }
967
968 /* Using SDMA for copying to a linear texture in GTT is much faster.
969 * This improves DRI PRIME performance.
970 *
971 * resource_copy_region can't do this yet, because dma_copy calls it
972 * on failure (recursion).
973 */
974 if (rdst->surface.u.legacy.level[info->dst.level].mode ==
975 RADEON_SURF_MODE_LINEAR_ALIGNED &&
976 rctx->b.dma_copy &&
977 util_can_blit_via_copy_region(info, false, rctx->b.render_cond != NULL)) {
978 rctx->b.dma_copy(ctx, info->dst.resource, info->dst.level,
979 info->dst.box.x, info->dst.box.y,
980 info->dst.box.z,
981 info->src.resource, info->src.level,
982 &info->src.box);
983 return;
984 }
985
986 assert(util_blitter_is_blit_supported(rctx->blitter, info));
987
988 /* The driver doesn't decompress resources automatically while
989 * u_blitter is rendering. */
990 if (!r600_decompress_subresource(ctx, info->src.resource, info->src.level,
991 info->src.box.z,
992 info->src.box.z + info->src.box.depth - 1)) {
993 return; /* error */
994 }
995
996 if (rctx->screen->b.debug_flags & DBG_FORCE_DMA &&
997 util_try_blit_via_copy_region(ctx, info, rctx->b.render_cond != NULL))
998 return;
999
1000 {
1001 const bool blit_box_same_size = info->src.box.width == info->dst.box.width &&
1002 info->src.box.height == info->dst.box.height &&
1003 info->src.box.depth == info->dst.box.depth;
1004 const bool blit_stencil = (info->mask & PIPE_MASK_S) != 0;
1005 const bool src_is_ZS = info->src.format == PIPE_FORMAT_Z24_UNORM_S8_UINT ||
1006 info->src.format == PIPE_FORMAT_Z32_FLOAT_S8X24_UINT;
1007
1008 if (unlikely(rctx->b.gfx_level >= EVERGREEN &&
1009 blit_stencil && blit_box_same_size && src_is_ZS &&
1010 info->dst.format == PIPE_FORMAT_Z24_UNORM_S8_UINT &&
1011 info->src.resource->last_level &&
1012 !info->dst.resource->last_level &&
1013 info->src.box.width >= 16 && info->src.box.width < 32)) {
1014 if (info->mask & ~PIPE_MASK_S) {
1015 struct pipe_blit_info blit;
1016 memcpy(&blit, info, sizeof(blit));
1017 blit.mask = info->mask & ~PIPE_MASK_S;
1018 r600_blitter_begin(ctx, R600_BLIT |
1019 (info->render_condition_enable ? 0 : R600_DISABLE_RENDER_COND));
1020 util_blitter_blit(rctx->blitter, &blit, NULL);
1021 r600_blitter_end(ctx);
1022 }
1023
1024 assert(util_format_get_blocksize(PIPE_FORMAT_Z24_UNORM_S8_UINT) == 4);
1025 assert(util_format_get_blocksize(PIPE_FORMAT_Z32_FLOAT_S8X24_UINT) == 8);
1026
1027 if (info->src.format == info->dst.format)
1028 r600_stencil_z24unorms8_to_z24unorms8uint(ctx,
1029 info->dst.resource, info->src.resource,
1030 &info->dst.box, &info->src.box,
1031 info->dst.level, info->src.level);
1032 else
1033 r600_stencil_z32floats8x24_to_z24unorms8(ctx,
1034 info->dst.resource, info->src.resource,
1035 &info->dst.box, &info->src.box,
1036 info->dst.level, info->src.level);
1037
1038 return;
1039 }
1040 }
1041
1042 r600_blitter_begin(ctx, R600_BLIT |
1043 (info->render_condition_enable ? 0 : R600_DISABLE_RENDER_COND));
1044 util_blitter_blit(rctx->blitter, info, NULL);
1045 r600_blitter_end(ctx);
1046 }
1047
r600_flush_resource(struct pipe_context * ctx,struct pipe_resource * res)1048 static void r600_flush_resource(struct pipe_context *ctx,
1049 struct pipe_resource *res)
1050 {
1051 struct r600_texture *rtex = (struct r600_texture*)res;
1052
1053 assert(res->target != PIPE_BUFFER);
1054
1055 if (!rtex->is_depth && rtex->cmask.size) {
1056 r600_blit_decompress_color(ctx, rtex, 0, res->last_level,
1057 0, util_max_layer(res, 0));
1058 }
1059 }
1060
r600_init_blit_functions(struct r600_context * rctx)1061 void r600_init_blit_functions(struct r600_context *rctx)
1062 {
1063 rctx->b.b.clear = r600_clear;
1064 rctx->b.b.clear_render_target = r600_clear_render_target;
1065 rctx->b.b.clear_depth_stencil = r600_clear_depth_stencil;
1066 rctx->b.b.resource_copy_region = r600_resource_copy_region;
1067 rctx->b.b.blit = r600_blit;
1068 rctx->b.b.flush_resource = r600_flush_resource;
1069 rctx->b.clear_buffer = r600_clear_buffer;
1070 rctx->b.blit_decompress_depth = r600_blit_decompress_depth;
1071 }
1072