2 * Mesa 3-D graphics library
4 * Copyright (C) 2013 LunarG, Inc.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
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 NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
25 * Chia-I Wu <olv@lunarg.com>
28 #include "genhw/genhw.h"
29 #include "util/u_pack_color.h"
32 #include "ilo_context.h"
35 #include "ilo_resource.h"
36 #include "ilo_blitter.h"
38 #define MI_FLUSH_DW GEN_MI_CMD(MI_FLUSH_DW)
39 #define MI_LOAD_REGISTER_IMM GEN_MI_CMD(MI_LOAD_REGISTER_IMM)
40 #define COLOR_BLT GEN_BLITTER_CMD(COLOR_BLT)
41 #define XY_COLOR_BLT GEN_BLITTER_CMD(XY_COLOR_BLT)
42 #define SRC_COPY_BLT GEN_BLITTER_CMD(SRC_COPY_BLT)
43 #define XY_SRC_COPY_BLT GEN_BLITTER_CMD(XY_SRC_COPY_BLT)
54 * From the Sandy Bridge PRM, volume 1 part 5, page 7:
56 * "The BLT engine is capable of transferring very large quantities of
57 * graphics data. Any graphics data read from and written to the
58 * destination is permitted to represent a number of pixels that occupies
59 * up to 65,536 scan lines and up to 32,768 bytes per scan line at the
60 * destination. The maximum number of pixels that may be represented per
61 * scan line's worth of graphics data depends on the color depth."
63 static const int gen6_max_bytes_per_scanline
= 32768;
64 static const int gen6_max_scanlines
= 65536;
67 gen6_emit_MI_FLUSH_DW(struct ilo_dev_info
*dev
, struct ilo_cp
*cp
)
69 const uint8_t cmd_len
= 4;
71 ilo_cp_begin(cp
, cmd_len
);
72 ilo_cp_write(cp
, MI_FLUSH_DW
| (cmd_len
- 2));
80 gen6_emit_MI_LOAD_REGISTER_IMM(struct ilo_dev_info
*dev
,
81 uint32_t reg
, uint32_t val
,
84 const uint8_t cmd_len
= 3;
86 ilo_cp_begin(cp
, cmd_len
);
87 ilo_cp_write(cp
, MI_LOAD_REGISTER_IMM
| (cmd_len
- 2));
88 ilo_cp_write(cp
, reg
);
89 ilo_cp_write(cp
, val
);
94 gen6_translate_blt_value_mask(enum gen6_blt_mask value_mask
)
97 case GEN6_BLT_MASK_8
: return GEN6_BLITTER_BR13_FORMAT_8
;
98 case GEN6_BLT_MASK_16
: return GEN6_BLITTER_BR13_FORMAT_565
;
99 default: return GEN6_BLITTER_BR13_FORMAT_8888
;
104 gen6_translate_blt_write_mask(enum gen6_blt_mask write_mask
)
106 switch (write_mask
) {
107 case GEN6_BLT_MASK_32
: return GEN6_BLITTER_BR00_WRITE_RGB
|
108 GEN6_BLITTER_BR00_WRITE_A
;
109 case GEN6_BLT_MASK_32_LO
: return GEN6_BLITTER_BR00_WRITE_RGB
;
110 case GEN6_BLT_MASK_32_HI
: return GEN6_BLITTER_BR00_WRITE_A
;
116 gen6_translate_blt_cpp(enum gen6_blt_mask mask
)
119 case GEN6_BLT_MASK_8
: return 1;
120 case GEN6_BLT_MASK_16
: return 2;
126 gen6_emit_COLOR_BLT(struct ilo_dev_info
*dev
,
127 struct intel_bo
*dst_bo
,
128 int16_t dst_pitch
, uint32_t dst_offset
,
129 uint16_t width
, uint16_t height
,
130 uint32_t pattern
, uint8_t rop
,
131 enum gen6_blt_mask value_mask
,
132 enum gen6_blt_mask write_mask
,
135 const uint8_t cmd_len
= 5;
136 const int cpp
= gen6_translate_blt_cpp(value_mask
);
140 gen6_translate_blt_write_mask(write_mask
) |
143 assert(width
< gen6_max_bytes_per_scanline
);
144 assert(height
< gen6_max_scanlines
);
145 /* offsets are naturally aligned and pitches are dword-aligned */
146 assert(dst_offset
% cpp
== 0 && dst_pitch
% 4 == 0);
148 dw1
= rop
<< GEN6_BLITTER_BR13_ROP__SHIFT
|
149 gen6_translate_blt_value_mask(value_mask
) |
152 ilo_cp_begin(cp
, cmd_len
);
153 ilo_cp_write(cp
, dw0
);
154 ilo_cp_write(cp
, dw1
);
155 ilo_cp_write(cp
, height
<< 16 | width
);
156 ilo_cp_write_bo(cp
, dst_offset
, dst_bo
, INTEL_DOMAIN_RENDER
,
157 INTEL_DOMAIN_RENDER
);
158 ilo_cp_write(cp
, pattern
);
163 gen6_emit_XY_COLOR_BLT(struct ilo_dev_info
*dev
,
164 struct intel_bo
*dst_bo
,
165 enum intel_tiling_mode dst_tiling
,
166 int16_t dst_pitch
, uint32_t dst_offset
,
167 int16_t x1
, int16_t y1
, int16_t x2
, int16_t y2
,
168 uint32_t pattern
, uint8_t rop
,
169 enum gen6_blt_mask value_mask
,
170 enum gen6_blt_mask write_mask
,
173 const uint8_t cmd_len
= 6;
174 const int cpp
= gen6_translate_blt_cpp(value_mask
);
175 int dst_align
, dst_pitch_shift
;
179 gen6_translate_blt_write_mask(write_mask
) |
182 if (dst_tiling
== INTEL_TILING_NONE
) {
187 dw0
|= GEN6_BLITTER_BR00_DST_TILED
;
189 dst_align
= (dst_tiling
== INTEL_TILING_Y
) ? 128 : 512;
190 /* in dwords when tiled */
194 assert((x2
- x1
) * cpp
< gen6_max_bytes_per_scanline
);
195 assert(y2
- y1
< gen6_max_scanlines
);
196 assert(dst_offset
% dst_align
== 0 && dst_pitch
% dst_align
== 0);
198 dw1
= rop
<< GEN6_BLITTER_BR13_ROP__SHIFT
|
199 gen6_translate_blt_value_mask(value_mask
) |
200 dst_pitch
>> dst_pitch_shift
;
202 ilo_cp_begin(cp
, cmd_len
);
203 ilo_cp_write(cp
, dw0
);
204 ilo_cp_write(cp
, dw1
);
205 ilo_cp_write(cp
, y1
<< 16 | x1
);
206 ilo_cp_write(cp
, y2
<< 16 | x2
);
207 ilo_cp_write_bo(cp
, dst_offset
, dst_bo
,
208 INTEL_DOMAIN_RENDER
, INTEL_DOMAIN_RENDER
);
209 ilo_cp_write(cp
, pattern
);
214 gen6_emit_SRC_COPY_BLT(struct ilo_dev_info
*dev
,
215 struct intel_bo
*dst_bo
,
216 int16_t dst_pitch
, uint32_t dst_offset
,
217 uint16_t width
, uint16_t height
,
218 struct intel_bo
*src_bo
,
219 int16_t src_pitch
, uint32_t src_offset
,
220 bool dir_rtl
, uint8_t rop
,
221 enum gen6_blt_mask value_mask
,
222 enum gen6_blt_mask write_mask
,
225 const uint8_t cmd_len
= 6;
226 const int cpp
= gen6_translate_blt_cpp(value_mask
);
230 gen6_translate_blt_write_mask(write_mask
) |
233 assert(width
< gen6_max_bytes_per_scanline
);
234 assert(height
< gen6_max_scanlines
);
235 /* offsets are naturally aligned and pitches are dword-aligned */
236 assert(dst_offset
% cpp
== 0 && dst_pitch
% 4 == 0);
237 assert(src_offset
% cpp
== 0 && src_pitch
% 4 == 0);
239 dw1
= rop
<< GEN6_BLITTER_BR13_ROP__SHIFT
|
240 gen6_translate_blt_value_mask(value_mask
) |
244 dw1
|= GEN6_BLITTER_BR13_DIR_RTL
;
246 ilo_cp_begin(cp
, cmd_len
);
247 ilo_cp_write(cp
, dw0
);
248 ilo_cp_write(cp
, dw1
);
249 ilo_cp_write(cp
, height
<< 16 | width
);
250 ilo_cp_write_bo(cp
, dst_offset
, dst_bo
, INTEL_DOMAIN_RENDER
,
251 INTEL_DOMAIN_RENDER
);
252 ilo_cp_write(cp
, src_pitch
);
253 ilo_cp_write_bo(cp
, src_offset
, src_bo
, INTEL_DOMAIN_RENDER
, 0);
258 gen6_emit_XY_SRC_COPY_BLT(struct ilo_dev_info
*dev
,
259 struct intel_bo
*dst_bo
,
260 enum intel_tiling_mode dst_tiling
,
261 int16_t dst_pitch
, uint32_t dst_offset
,
262 int16_t x1
, int16_t y1
, int16_t x2
, int16_t y2
,
263 struct intel_bo
*src_bo
,
264 enum intel_tiling_mode src_tiling
,
265 int16_t src_pitch
, uint32_t src_offset
,
266 int16_t src_x
, int16_t src_y
, uint8_t rop
,
267 enum gen6_blt_mask value_mask
,
268 enum gen6_blt_mask write_mask
,
271 const uint8_t cmd_len
= 8;
272 const int cpp
= gen6_translate_blt_cpp(value_mask
);
273 int dst_align
, dst_pitch_shift
;
274 int src_align
, src_pitch_shift
;
277 dw0
= XY_SRC_COPY_BLT
|
278 gen6_translate_blt_write_mask(write_mask
) |
281 if (dst_tiling
== INTEL_TILING_NONE
) {
286 dw0
|= GEN6_BLITTER_BR00_DST_TILED
;
288 dst_align
= (dst_tiling
== INTEL_TILING_Y
) ? 128 : 512;
289 /* in dwords when tiled */
293 if (src_tiling
== INTEL_TILING_NONE
) {
298 dw0
|= GEN6_BLITTER_BR00_SRC_TILED
;
300 src_align
= (src_tiling
== INTEL_TILING_Y
) ? 128 : 512;
301 /* in dwords when tiled */
305 assert((x2
- x1
) * cpp
< gen6_max_bytes_per_scanline
);
306 assert(y2
- y1
< gen6_max_scanlines
);
307 assert(dst_offset
% dst_align
== 0 && dst_pitch
% dst_align
== 0);
308 assert(src_offset
% src_align
== 0 && src_pitch
% src_align
== 0);
310 dw1
= rop
<< GEN6_BLITTER_BR13_ROP__SHIFT
|
311 gen6_translate_blt_value_mask(value_mask
) |
312 dst_pitch
>> dst_pitch_shift
;
314 ilo_cp_begin(cp
, cmd_len
);
315 ilo_cp_write(cp
, dw0
);
316 ilo_cp_write(cp
, dw1
);
317 ilo_cp_write(cp
, y1
<< 16 | x1
);
318 ilo_cp_write(cp
, y2
<< 16 | x2
);
319 ilo_cp_write_bo(cp
, dst_offset
, dst_bo
, INTEL_DOMAIN_RENDER
,
320 INTEL_DOMAIN_RENDER
);
321 ilo_cp_write(cp
, src_y
<< 16 | src_x
);
322 ilo_cp_write(cp
, src_pitch
>> src_pitch_shift
);
323 ilo_cp_write_bo(cp
, src_offset
, src_bo
, INTEL_DOMAIN_RENDER
, 0);
328 ilo_blitter_blt_begin(struct ilo_blitter
*blitter
, int max_cmd_size
,
329 struct intel_bo
*dst
, enum intel_tiling_mode dst_tiling
,
330 struct intel_bo
*src
, enum intel_tiling_mode src_tiling
)
332 struct ilo_context
*ilo
= blitter
->ilo
;
333 struct intel_bo
*aper_check
[3];
338 ilo_cp_set_ring(ilo
->cp
, INTEL_RING_BLT
);
339 ilo_cp_set_owner(ilo
->cp
, NULL
, 0);
341 /* check aperture space */
342 aper_check
[0] = ilo
->cp
->bo
;
351 if (!intel_winsys_can_submit_bo(ilo
->winsys
, aper_check
, count
))
352 ilo_cp_flush(ilo
->cp
, "out of aperture");
357 if (dst_tiling
== INTEL_TILING_Y
) {
358 swctrl
|= GEN6_REG_BCS_SWCTRL_DST_TILING_Y
<< 16 |
359 GEN6_REG_BCS_SWCTRL_DST_TILING_Y
;
362 if (src
&& src_tiling
== INTEL_TILING_Y
) {
363 swctrl
|= GEN6_REG_BCS_SWCTRL_SRC_TILING_Y
<< 16 |
364 GEN6_REG_BCS_SWCTRL_SRC_TILING_Y
;
369 * Most clients expect BLT engine to be stateless. If we have to set
370 * BCS_SWCTRL to a non-default value, we have to set it back in the same
373 if (ilo_cp_space(ilo
->cp
) < (4 + 3) * 2 + max_cmd_size
)
374 ilo_cp_flush(ilo
->cp
, "out of space");
376 ilo_cp_assert_no_implicit_flush(ilo
->cp
, true);
379 * From the Ivy Bridge PRM, volume 1 part 4, page 133:
381 * "SW is required to flush the HW before changing the polarity of
382 * this bit (Tile Y Destination/Source)."
384 gen6_emit_MI_FLUSH_DW(ilo
->dev
, ilo
->cp
);
385 gen6_emit_MI_LOAD_REGISTER_IMM(ilo
->dev
,
386 GEN6_REG_BCS_SWCTRL
, swctrl
, ilo
->cp
);
388 swctrl
&= ~(GEN6_REG_BCS_SWCTRL_DST_TILING_Y
|
389 GEN6_REG_BCS_SWCTRL_SRC_TILING_Y
);
396 ilo_blitter_blt_end(struct ilo_blitter
*blitter
, uint32_t swctrl
)
398 struct ilo_context
*ilo
= blitter
->ilo
;
400 /* set BCS_SWCTRL back */
402 gen6_emit_MI_FLUSH_DW(ilo
->dev
, ilo
->cp
);
403 gen6_emit_MI_LOAD_REGISTER_IMM(ilo
->dev
, GEN6_REG_BCS_SWCTRL
, swctrl
, ilo
->cp
);
405 ilo_cp_assert_no_implicit_flush(ilo
->cp
, false);
410 buf_clear_region(struct ilo_blitter
*blitter
,
411 struct ilo_buffer
*dst
,
412 unsigned dst_offset
, unsigned dst_size
,
414 enum gen6_blt_mask value_mask
,
415 enum gen6_blt_mask write_mask
)
417 const uint8_t rop
= 0xf0; /* PATCOPY */
418 const int cpp
= gen6_translate_blt_cpp(value_mask
);
419 struct ilo_context
*ilo
= blitter
->ilo
;
422 if (dst_offset
% cpp
|| dst_size
% cpp
)
425 ilo_blitter_blt_begin(blitter
, 0,
426 dst
->bo
, INTEL_TILING_NONE
, NULL
, INTEL_TILING_NONE
);
429 unsigned width
, height
;
436 if (width
> gen6_max_bytes_per_scanline
) {
437 /* less than INT16_MAX and dword-aligned */
441 height
= dst_size
/ width
;
442 if (height
> gen6_max_scanlines
)
443 height
= gen6_max_scanlines
;
446 gen6_emit_COLOR_BLT(ilo
->dev
, dst
->bo
, pitch
, dst_offset
+ offset
,
447 width
, height
, val
, rop
, value_mask
, write_mask
, ilo
->cp
);
449 offset
+= pitch
* height
;
450 dst_size
-= width
* height
;
453 ilo_blitter_blt_end(blitter
, 0);
459 buf_copy_region(struct ilo_blitter
*blitter
,
460 struct ilo_buffer
*dst
, unsigned dst_offset
,
461 struct ilo_buffer
*src
, unsigned src_offset
,
464 const uint8_t rop
= 0xcc; /* SRCCOPY */
465 struct ilo_context
*ilo
= blitter
->ilo
;
468 ilo_blitter_blt_begin(blitter
, 0,
469 dst
->bo
, INTEL_TILING_NONE
, src
->bo
, INTEL_TILING_NONE
);
472 unsigned width
, height
;
479 if (width
> gen6_max_bytes_per_scanline
) {
480 /* less than INT16_MAX and dword-aligned */
484 height
= size
/ width
;
485 if (height
> gen6_max_scanlines
)
486 height
= gen6_max_scanlines
;
489 gen6_emit_SRC_COPY_BLT(ilo
->dev
,
490 dst
->bo
, pitch
, dst_offset
+ offset
,
492 src
->bo
, pitch
, src_offset
+ offset
,
493 false, rop
, GEN6_BLT_MASK_8
, GEN6_BLT_MASK_8
,
496 offset
+= pitch
* height
;
497 size
-= width
* height
;
500 ilo_blitter_blt_end(blitter
, 0);
506 tex_clear_region(struct ilo_blitter
*blitter
,
507 struct ilo_texture
*dst
, unsigned dst_level
,
508 const struct pipe_box
*dst_box
,
510 enum gen6_blt_mask value_mask
,
511 enum gen6_blt_mask write_mask
)
513 const int cpp
= gen6_translate_blt_cpp(value_mask
);
514 const unsigned max_extent
= 32767; /* INT16_MAX */
515 const uint8_t rop
= 0xf0; /* PATCOPY */
516 struct ilo_context
*ilo
= blitter
->ilo
;
520 /* no W-tiling support */
521 if (dst
->separate_s8
)
524 if (dst
->bo_stride
> max_extent
)
527 swctrl
= ilo_blitter_blt_begin(blitter
, dst_box
->depth
* 6,
528 dst
->bo
, dst
->tiling
, NULL
, INTEL_TILING_NONE
);
530 for (slice
= 0; slice
< dst_box
->depth
; slice
++) {
531 const struct ilo_texture_slice
*dst_slice
=
532 ilo_texture_get_slice(dst
, dst_level
, dst_box
->z
+ slice
);
533 unsigned x1
, y1
, x2
, y2
;
535 x1
= dst_slice
->x
+ dst_box
->x
;
536 y1
= dst_slice
->y
+ dst_box
->y
;
537 x2
= x1
+ dst_box
->width
;
538 y2
= y1
+ dst_box
->height
;
540 if (x2
> max_extent
|| y2
> max_extent
||
541 (x2
- x1
) * cpp
> gen6_max_bytes_per_scanline
)
544 gen6_emit_XY_COLOR_BLT(ilo
->dev
,
545 dst
->bo
, dst
->tiling
, dst
->bo_stride
, 0,
546 x1
, y1
, x2
, y2
, val
, rop
, value_mask
, write_mask
,
550 ilo_blitter_blt_end(blitter
, swctrl
);
552 return (slice
== dst_box
->depth
);
556 tex_copy_region(struct ilo_blitter
*blitter
,
557 struct ilo_texture
*dst
,
559 unsigned dst_x
, unsigned dst_y
, unsigned dst_z
,
560 struct ilo_texture
*src
,
562 const struct pipe_box
*src_box
)
564 const struct util_format_description
*desc
=
565 util_format_description(dst
->bo_format
);
566 const unsigned max_extent
= 32767; /* INT16_MAX */
567 const uint8_t rop
= 0xcc; /* SRCCOPY */
568 struct ilo_context
*ilo
= blitter
->ilo
;
569 enum gen6_blt_mask mask
;
571 int cpp
, xscale
, slice
;
573 /* no W-tiling support */
574 if (dst
->separate_s8
|| src
->separate_s8
)
577 if (dst
->bo_stride
> max_extent
|| src
->bo_stride
> max_extent
)
580 cpp
= desc
->block
.bits
/ 8;
583 /* accommodate for larger cpp */
588 cpp
= (cpp
% 4 == 0) ? 4 : 2;
589 xscale
= (desc
->block
.bits
/ 8) / cpp
;
594 mask
= GEN6_BLT_MASK_8
;
597 mask
= GEN6_BLT_MASK_16
;
600 mask
= GEN6_BLT_MASK_32
;
607 swctrl
= ilo_blitter_blt_begin(blitter
, src_box
->depth
* 8,
608 dst
->bo
, dst
->tiling
, src
->bo
, src
->tiling
);
610 for (slice
= 0; slice
< src_box
->depth
; slice
++) {
611 const struct ilo_texture_slice
*dst_slice
=
612 ilo_texture_get_slice(dst
, dst_level
, dst_z
+ slice
);
613 const struct ilo_texture_slice
*src_slice
=
614 ilo_texture_get_slice(src
, src_level
, src_box
->z
+ slice
);
615 unsigned x1
, y1
, x2
, y2
, src_x
, src_y
;
617 x1
= (dst_slice
->x
+ dst_x
) * xscale
;
618 y1
= dst_slice
->y
+ dst_y
;
619 x2
= (x1
+ src_box
->width
) * xscale
;
620 y2
= y1
+ src_box
->height
;
621 src_x
= (src_slice
->x
+ src_box
->x
) * xscale
;
622 src_y
= src_slice
->y
+ src_box
->y
;
625 x1
/= desc
->block
.width
;
626 y1
/= desc
->block
.height
;
627 x2
= (x2
+ desc
->block
.width
- 1) / desc
->block
.width
;
628 y2
= (y2
+ desc
->block
.height
- 1) / desc
->block
.height
;
629 src_x
/= desc
->block
.width
;
630 src_y
/= desc
->block
.height
;
632 if (x2
> max_extent
|| y2
> max_extent
||
633 src_x
> max_extent
|| src_y
> max_extent
||
634 (x2
- x1
) * cpp
> gen6_max_bytes_per_scanline
)
637 gen6_emit_XY_SRC_COPY_BLT(ilo
->dev
,
638 dst
->bo
, dst
->tiling
, dst
->bo_stride
, 0,
640 src
->bo
, src
->tiling
, src
->bo_stride
, 0,
641 src_x
, src_y
, rop
, mask
, mask
,
645 ilo_blitter_blt_end(blitter
, swctrl
);
647 return (slice
== src_box
->depth
);
651 ilo_blitter_blt_copy_resource(struct ilo_blitter
*blitter
,
652 struct pipe_resource
*dst
, unsigned dst_level
,
653 unsigned dst_x
, unsigned dst_y
, unsigned dst_z
,
654 struct pipe_resource
*src
, unsigned src_level
,
655 const struct pipe_box
*src_box
)
659 ilo_blit_resolve_slices(blitter
->ilo
, src
, src_level
,
660 src_box
->z
, src_box
->depth
, ILO_TEXTURE_BLT_READ
);
661 ilo_blit_resolve_slices(blitter
->ilo
, dst
, dst_level
,
662 dst_z
, src_box
->depth
, ILO_TEXTURE_BLT_WRITE
);
664 if (dst
->target
== PIPE_BUFFER
&& src
->target
== PIPE_BUFFER
) {
665 const unsigned dst_offset
= dst_x
;
666 const unsigned src_offset
= src_box
->x
;
667 const unsigned size
= src_box
->width
;
669 assert(dst_level
== 0 && dst_y
== 0 && dst_z
== 0);
670 assert(src_level
== 0 &&
673 src_box
->height
== 1 &&
674 src_box
->depth
== 1);
676 success
= buf_copy_region(blitter
,
677 ilo_buffer(dst
), dst_offset
, ilo_buffer(src
), src_offset
, size
);
679 else if (dst
->target
!= PIPE_BUFFER
&& src
->target
!= PIPE_BUFFER
) {
680 success
= tex_copy_region(blitter
,
681 ilo_texture(dst
), dst_level
, dst_x
, dst_y
, dst_z
,
682 ilo_texture(src
), src_level
, src_box
);
692 ilo_blitter_blt_clear_rt(struct ilo_blitter
*blitter
,
693 struct pipe_surface
*rt
,
694 const union pipe_color_union
*color
,
695 unsigned x
, unsigned y
,
696 unsigned width
, unsigned height
)
698 const int cpp
= util_format_get_blocksize(rt
->format
);
699 enum gen6_blt_mask mask
;
700 union util_color packed
;
703 if (!ilo_3d_pass_render_condition(blitter
->ilo
))
708 mask
= GEN6_BLT_MASK_8
;
711 mask
= GEN6_BLT_MASK_16
;
714 mask
= GEN6_BLT_MASK_32
;
721 if (util_format_is_pure_integer(rt
->format
) ||
722 util_format_is_compressed(rt
->format
))
725 ilo_blit_resolve_surface(blitter
->ilo
, rt
, ILO_TEXTURE_BLT_WRITE
);
727 util_pack_color(color
->f
, rt
->format
, &packed
);
729 if (rt
->texture
->target
== PIPE_BUFFER
) {
730 unsigned offset
, end
, size
;
732 assert(y
== 0 && height
== 1);
734 offset
= (rt
->u
.buf
.first_element
+ x
) * cpp
;
735 end
= (rt
->u
.buf
.last_element
+ 1) * cpp
;
738 if (offset
+ size
> end
)
741 success
= buf_clear_region(blitter
, ilo_buffer(rt
->texture
),
742 offset
, size
, packed
.ui
, mask
, mask
);
747 u_box_3d(x
, y
, rt
->u
.tex
.first_layer
, width
, height
,
748 rt
->u
.tex
.last_layer
- rt
->u
.tex
.first_layer
+ 1, &box
);
750 success
= tex_clear_region(blitter
, ilo_texture(rt
->texture
),
751 rt
->u
.tex
.level
, &box
, packed
.ui
, mask
, mask
);
758 ilo_blitter_blt_clear_zs(struct ilo_blitter
*blitter
,
759 struct pipe_surface
*zs
,
760 unsigned clear_flags
,
761 double depth
, unsigned stencil
,
762 unsigned x
, unsigned y
,
763 unsigned width
, unsigned height
)
765 enum gen6_blt_mask value_mask
, write_mask
;
769 if (!ilo_3d_pass_render_condition(blitter
->ilo
))
772 switch (zs
->format
) {
773 case PIPE_FORMAT_Z16_UNORM
:
774 if (!(clear_flags
& PIPE_CLEAR_DEPTH
))
777 value_mask
= GEN6_BLT_MASK_16
;
778 write_mask
= GEN6_BLT_MASK_16
;
780 case PIPE_FORMAT_Z32_FLOAT
:
781 if (!(clear_flags
& PIPE_CLEAR_DEPTH
))
784 value_mask
= GEN6_BLT_MASK_32
;
785 write_mask
= GEN6_BLT_MASK_32
;
787 case PIPE_FORMAT_Z24X8_UNORM
:
788 if (!(clear_flags
& PIPE_CLEAR_DEPTH
))
791 value_mask
= GEN6_BLT_MASK_32
;
792 write_mask
= GEN6_BLT_MASK_32_LO
;
794 case PIPE_FORMAT_Z24_UNORM_S8_UINT
:
795 if (!(clear_flags
& PIPE_CLEAR_DEPTHSTENCIL
))
798 value_mask
= GEN6_BLT_MASK_32
;
800 if ((clear_flags
& PIPE_CLEAR_DEPTHSTENCIL
) == PIPE_CLEAR_DEPTHSTENCIL
)
801 write_mask
= GEN6_BLT_MASK_32
;
802 else if (clear_flags
& PIPE_CLEAR_DEPTH
)
803 write_mask
= GEN6_BLT_MASK_32_LO
;
805 write_mask
= GEN6_BLT_MASK_32_HI
;
812 ilo_blit_resolve_surface(blitter
->ilo
, zs
, ILO_TEXTURE_BLT_WRITE
);
814 val
= util_pack_z_stencil(zs
->format
, depth
, stencil
);
816 u_box_3d(x
, y
, zs
->u
.tex
.first_layer
, width
, height
,
817 zs
->u
.tex
.last_layer
- zs
->u
.tex
.first_layer
+ 1, &box
);
819 assert(zs
->texture
->target
!= PIPE_BUFFER
);
821 return tex_clear_region(blitter
, ilo_texture(zs
->texture
),
822 zs
->u
.tex
.level
, &box
, val
, value_mask
, write_mask
);