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"
47 * From the Sandy Bridge PRM, volume 1 part 5, page 7:
49 * "The BLT engine is capable of transferring very large quantities of
50 * graphics data. Any graphics data read from and written to the
51 * destination is permitted to represent a number of pixels that occupies
52 * up to 65,536 scan lines and up to 32,768 bytes per scan line at the
53 * destination. The maximum number of pixels that may be represented per
54 * scan line's worth of graphics data depends on the color depth."
56 static const int gen6_max_bytes_per_scanline
= 32768;
57 static const int gen6_max_scanlines
= 65536;
60 gen6_MI_FLUSH_DW(struct ilo_builder
*builder
)
62 const uint8_t cmd_len
= 4;
63 const uint32_t dw0
= GEN6_MI_CMD(MI_FLUSH_DW
) | (cmd_len
- 2);
66 ilo_builder_batch_pointer(builder
, cmd_len
, &dw
);
74 gen6_MI_LOAD_REGISTER_IMM(struct ilo_builder
*builder
,
75 uint32_t reg
, uint32_t val
)
77 const uint8_t cmd_len
= 3;
78 const uint32_t dw0
= GEN6_MI_CMD(MI_LOAD_REGISTER_IMM
) | (cmd_len
- 2);
81 ilo_builder_batch_pointer(builder
, cmd_len
, &dw
);
88 gen6_translate_blt_value_mask(enum gen6_blt_mask value_mask
)
91 case GEN6_BLT_MASK_8
: return GEN6_BLITTER_BR13_FORMAT_8
;
92 case GEN6_BLT_MASK_16
: return GEN6_BLITTER_BR13_FORMAT_565
;
93 default: return GEN6_BLITTER_BR13_FORMAT_8888
;
98 gen6_translate_blt_write_mask(enum gen6_blt_mask write_mask
)
100 switch (write_mask
) {
101 case GEN6_BLT_MASK_32
: return GEN6_BLITTER_BR00_WRITE_RGB
|
102 GEN6_BLITTER_BR00_WRITE_A
;
103 case GEN6_BLT_MASK_32_LO
: return GEN6_BLITTER_BR00_WRITE_RGB
;
104 case GEN6_BLT_MASK_32_HI
: return GEN6_BLITTER_BR00_WRITE_A
;
110 gen6_translate_blt_cpp(enum gen6_blt_mask mask
)
113 case GEN6_BLT_MASK_8
: return 1;
114 case GEN6_BLT_MASK_16
: return 2;
120 gen6_COLOR_BLT(struct ilo_builder
*builder
,
121 struct intel_bo
*dst_bo
,
122 int16_t dst_pitch
, uint32_t dst_offset
,
123 uint16_t width
, uint16_t height
,
124 uint32_t pattern
, uint8_t rop
,
125 enum gen6_blt_mask value_mask
,
126 enum gen6_blt_mask write_mask
)
128 const uint8_t cmd_len
= 5;
129 const int cpp
= gen6_translate_blt_cpp(value_mask
);
130 uint32_t dw0
, dw1
, *dw
;
133 dw0
= GEN6_BLITTER_CMD(COLOR_BLT
) |
134 gen6_translate_blt_write_mask(write_mask
) |
137 assert(width
< gen6_max_bytes_per_scanline
);
138 assert(height
< gen6_max_scanlines
);
139 /* offsets are naturally aligned and pitches are dword-aligned */
140 assert(dst_offset
% cpp
== 0 && dst_pitch
% 4 == 0);
142 dw1
= rop
<< GEN6_BLITTER_BR13_ROP__SHIFT
|
143 gen6_translate_blt_value_mask(value_mask
) |
146 pos
= ilo_builder_batch_pointer(builder
, cmd_len
, &dw
);
149 dw
[2] = height
<< 16 | width
;
152 ilo_builder_batch_reloc(builder
, pos
+ 3,
153 dst_bo
, dst_offset
, INTEL_RELOC_WRITE
);
157 gen6_XY_COLOR_BLT(struct ilo_builder
*builder
,
158 struct intel_bo
*dst_bo
,
159 enum intel_tiling_mode dst_tiling
,
160 int16_t dst_pitch
, uint32_t dst_offset
,
161 int16_t x1
, int16_t y1
, int16_t x2
, int16_t y2
,
162 uint32_t pattern
, uint8_t rop
,
163 enum gen6_blt_mask value_mask
,
164 enum gen6_blt_mask write_mask
)
166 const uint8_t cmd_len
= 6;
167 const int cpp
= gen6_translate_blt_cpp(value_mask
);
168 int dst_align
, dst_pitch_shift
;
169 uint32_t dw0
, dw1
, *dw
;
172 dw0
= GEN6_BLITTER_CMD(XY_COLOR_BLT
) |
173 gen6_translate_blt_write_mask(write_mask
) |
176 if (dst_tiling
== INTEL_TILING_NONE
) {
181 dw0
|= GEN6_BLITTER_BR00_DST_TILED
;
183 dst_align
= (dst_tiling
== INTEL_TILING_Y
) ? 128 : 512;
184 /* in dwords when tiled */
188 assert((x2
- x1
) * cpp
< gen6_max_bytes_per_scanline
);
189 assert(y2
- y1
< gen6_max_scanlines
);
190 assert(dst_offset
% dst_align
== 0 && dst_pitch
% dst_align
== 0);
192 dw1
= rop
<< GEN6_BLITTER_BR13_ROP__SHIFT
|
193 gen6_translate_blt_value_mask(value_mask
) |
194 dst_pitch
>> dst_pitch_shift
;
196 pos
= ilo_builder_batch_pointer(builder
, cmd_len
, &dw
);
199 dw
[2] = y1
<< 16 | x1
;
200 dw
[3] = y2
<< 16 | x2
;
203 ilo_builder_batch_reloc(builder
, pos
+ 4,
204 dst_bo
, dst_offset
, INTEL_RELOC_WRITE
);
208 gen6_SRC_COPY_BLT(struct ilo_builder
*builder
,
209 struct intel_bo
*dst_bo
,
210 int16_t dst_pitch
, uint32_t dst_offset
,
211 uint16_t width
, uint16_t height
,
212 struct intel_bo
*src_bo
,
213 int16_t src_pitch
, uint32_t src_offset
,
214 bool dir_rtl
, uint8_t rop
,
215 enum gen6_blt_mask value_mask
,
216 enum gen6_blt_mask write_mask
)
218 const uint8_t cmd_len
= 6;
219 const int cpp
= gen6_translate_blt_cpp(value_mask
);
220 uint32_t dw0
, dw1
, *dw
;
223 dw0
= GEN6_BLITTER_CMD(SRC_COPY_BLT
) |
224 gen6_translate_blt_write_mask(write_mask
) |
227 assert(width
< gen6_max_bytes_per_scanline
);
228 assert(height
< gen6_max_scanlines
);
229 /* offsets are naturally aligned and pitches are dword-aligned */
230 assert(dst_offset
% cpp
== 0 && dst_pitch
% 4 == 0);
231 assert(src_offset
% cpp
== 0 && src_pitch
% 4 == 0);
233 dw1
= rop
<< GEN6_BLITTER_BR13_ROP__SHIFT
|
234 gen6_translate_blt_value_mask(value_mask
) |
238 dw1
|= GEN6_BLITTER_BR13_DIR_RTL
;
240 pos
= ilo_builder_batch_pointer(builder
, cmd_len
, &dw
);
243 dw
[2] = height
<< 16 | width
;
246 ilo_builder_batch_reloc(builder
, pos
+ 3,
247 dst_bo
, dst_offset
, INTEL_RELOC_WRITE
);
248 ilo_builder_batch_reloc(builder
, pos
+ 5,
249 src_bo
, src_offset
, 0);
253 gen6_XY_SRC_COPY_BLT(struct ilo_builder
*builder
,
254 struct intel_bo
*dst_bo
,
255 enum intel_tiling_mode dst_tiling
,
256 int16_t dst_pitch
, uint32_t dst_offset
,
257 int16_t x1
, int16_t y1
, int16_t x2
, int16_t y2
,
258 struct intel_bo
*src_bo
,
259 enum intel_tiling_mode src_tiling
,
260 int16_t src_pitch
, uint32_t src_offset
,
261 int16_t src_x
, int16_t src_y
, uint8_t rop
,
262 enum gen6_blt_mask value_mask
,
263 enum gen6_blt_mask write_mask
)
265 const uint8_t cmd_len
= 8;
266 const int cpp
= gen6_translate_blt_cpp(value_mask
);
267 int dst_align
, dst_pitch_shift
;
268 int src_align
, src_pitch_shift
;
269 uint32_t dw0
, dw1
, *dw
;
272 dw0
= GEN6_BLITTER_CMD(XY_SRC_COPY_BLT
) |
273 gen6_translate_blt_write_mask(write_mask
) |
276 if (dst_tiling
== INTEL_TILING_NONE
) {
281 dw0
|= GEN6_BLITTER_BR00_DST_TILED
;
283 dst_align
= (dst_tiling
== INTEL_TILING_Y
) ? 128 : 512;
284 /* in dwords when tiled */
288 if (src_tiling
== INTEL_TILING_NONE
) {
293 dw0
|= GEN6_BLITTER_BR00_SRC_TILED
;
295 src_align
= (src_tiling
== INTEL_TILING_Y
) ? 128 : 512;
296 /* in dwords when tiled */
300 assert((x2
- x1
) * cpp
< gen6_max_bytes_per_scanline
);
301 assert(y2
- y1
< gen6_max_scanlines
);
302 assert(dst_offset
% dst_align
== 0 && dst_pitch
% dst_align
== 0);
303 assert(src_offset
% src_align
== 0 && src_pitch
% src_align
== 0);
305 dw1
= rop
<< GEN6_BLITTER_BR13_ROP__SHIFT
|
306 gen6_translate_blt_value_mask(value_mask
) |
307 dst_pitch
>> dst_pitch_shift
;
309 pos
= ilo_builder_batch_pointer(builder
, cmd_len
, &dw
);
312 dw
[2] = y1
<< 16 | x1
;
313 dw
[3] = y2
<< 16 | x2
;
314 dw
[5] = src_y
<< 16 | src_x
;
315 dw
[6] = src_pitch
>> src_pitch_shift
;
317 ilo_builder_batch_reloc(builder
, pos
+ 4,
318 dst_bo
, dst_offset
, INTEL_RELOC_WRITE
);
319 ilo_builder_batch_reloc(builder
, pos
+ 7,
320 src_bo
, src_offset
, 0);
324 ilo_blitter_blt_begin(struct ilo_blitter
*blitter
, int max_cmd_size
,
325 struct intel_bo
*dst
, enum intel_tiling_mode dst_tiling
,
326 struct intel_bo
*src
, enum intel_tiling_mode src_tiling
)
328 struct ilo_context
*ilo
= blitter
->ilo
;
329 struct intel_bo
*aper_check
[2];
334 ilo_cp_set_ring(ilo
->cp
, INTEL_RING_BLT
);
335 ilo_cp_set_owner(ilo
->cp
, NULL
, 0);
337 /* check aperture space */
346 if (!ilo_builder_validate(&ilo
->cp
->builder
, count
, aper_check
))
347 ilo_cp_flush(ilo
->cp
, "out of aperture");
352 if (dst_tiling
== INTEL_TILING_Y
) {
353 swctrl
|= GEN6_REG_BCS_SWCTRL_DST_TILING_Y
<< 16 |
354 GEN6_REG_BCS_SWCTRL_DST_TILING_Y
;
357 if (src
&& src_tiling
== INTEL_TILING_Y
) {
358 swctrl
|= GEN6_REG_BCS_SWCTRL_SRC_TILING_Y
<< 16 |
359 GEN6_REG_BCS_SWCTRL_SRC_TILING_Y
;
363 * Most clients expect BLT engine to be stateless. If we have to set
364 * BCS_SWCTRL to a non-default value, we have to set it back in the same
368 max_cmd_size
+= (4 + 3) * 2;
370 if (ilo_cp_space(ilo
->cp
) < max_cmd_size
) {
371 ilo_cp_flush(ilo
->cp
, "out of space");
372 assert(ilo_cp_space(ilo
->cp
) >= max_cmd_size
);
377 * From the Ivy Bridge PRM, volume 1 part 4, page 133:
379 * "SW is required to flush the HW before changing the polarity of
380 * this bit (Tile Y Destination/Source)."
382 gen6_MI_FLUSH_DW(&ilo
->cp
->builder
);
383 gen6_MI_LOAD_REGISTER_IMM(&ilo
->cp
->builder
,
384 GEN6_REG_BCS_SWCTRL
, swctrl
);
386 swctrl
&= ~(GEN6_REG_BCS_SWCTRL_DST_TILING_Y
|
387 GEN6_REG_BCS_SWCTRL_SRC_TILING_Y
);
394 ilo_blitter_blt_end(struct ilo_blitter
*blitter
, uint32_t swctrl
)
396 struct ilo_context
*ilo
= blitter
->ilo
;
398 /* set BCS_SWCTRL back */
400 gen6_MI_FLUSH_DW(&ilo
->cp
->builder
);
401 gen6_MI_LOAD_REGISTER_IMM(&ilo
->cp
->builder
, GEN6_REG_BCS_SWCTRL
, swctrl
);
406 buf_clear_region(struct ilo_blitter
*blitter
,
407 struct ilo_buffer
*dst
,
408 unsigned dst_offset
, unsigned dst_size
,
410 enum gen6_blt_mask value_mask
,
411 enum gen6_blt_mask write_mask
)
413 const uint8_t rop
= 0xf0; /* PATCOPY */
414 const int cpp
= gen6_translate_blt_cpp(value_mask
);
415 struct ilo_context
*ilo
= blitter
->ilo
;
418 if (dst_offset
% cpp
|| dst_size
% cpp
)
421 ilo_blitter_blt_begin(blitter
, 0,
422 dst
->bo
, INTEL_TILING_NONE
, NULL
, INTEL_TILING_NONE
);
425 unsigned width
, height
;
432 if (width
> gen6_max_bytes_per_scanline
) {
433 /* less than INT16_MAX and dword-aligned */
437 height
= dst_size
/ width
;
438 if (height
> gen6_max_scanlines
)
439 height
= gen6_max_scanlines
;
442 gen6_COLOR_BLT(&ilo
->cp
->builder
, dst
->bo
, pitch
, dst_offset
+ offset
,
443 width
, height
, val
, rop
, value_mask
, write_mask
);
445 offset
+= pitch
* height
;
446 dst_size
-= width
* height
;
449 ilo_blitter_blt_end(blitter
, 0);
455 buf_copy_region(struct ilo_blitter
*blitter
,
456 struct ilo_buffer
*dst
, unsigned dst_offset
,
457 struct ilo_buffer
*src
, unsigned src_offset
,
460 const uint8_t rop
= 0xcc; /* SRCCOPY */
461 struct ilo_context
*ilo
= blitter
->ilo
;
464 ilo_blitter_blt_begin(blitter
, 0,
465 dst
->bo
, INTEL_TILING_NONE
, src
->bo
, INTEL_TILING_NONE
);
468 unsigned width
, height
;
475 if (width
> gen6_max_bytes_per_scanline
) {
476 /* less than INT16_MAX and dword-aligned */
480 height
= size
/ width
;
481 if (height
> gen6_max_scanlines
)
482 height
= gen6_max_scanlines
;
485 gen6_SRC_COPY_BLT(&ilo
->cp
->builder
,
486 dst
->bo
, pitch
, dst_offset
+ offset
,
488 src
->bo
, pitch
, src_offset
+ offset
,
489 false, rop
, GEN6_BLT_MASK_8
, GEN6_BLT_MASK_8
);
491 offset
+= pitch
* height
;
492 size
-= width
* height
;
495 ilo_blitter_blt_end(blitter
, 0);
501 tex_clear_region(struct ilo_blitter
*blitter
,
502 struct ilo_texture
*dst
, unsigned dst_level
,
503 const struct pipe_box
*dst_box
,
505 enum gen6_blt_mask value_mask
,
506 enum gen6_blt_mask write_mask
)
508 const int cpp
= gen6_translate_blt_cpp(value_mask
);
509 const unsigned max_extent
= 32767; /* INT16_MAX */
510 const uint8_t rop
= 0xf0; /* PATCOPY */
511 struct ilo_context
*ilo
= blitter
->ilo
;
515 /* no W-tiling support */
516 if (dst
->separate_s8
)
519 if (dst
->layout
.bo_stride
> max_extent
)
522 swctrl
= ilo_blitter_blt_begin(blitter
, dst_box
->depth
* 6,
523 dst
->bo
, dst
->layout
.tiling
, NULL
, INTEL_TILING_NONE
);
525 for (slice
= 0; slice
< dst_box
->depth
; slice
++) {
526 unsigned x1
, y1
, x2
, y2
;
528 ilo_layout_get_slice_pos(&dst
->layout
,
529 dst_level
, dst_box
->z
+ slice
, &x1
, &y1
);
533 x2
= x1
+ dst_box
->width
;
534 y2
= y1
+ dst_box
->height
;
536 if (x2
> max_extent
|| y2
> max_extent
||
537 (x2
- x1
) * cpp
> gen6_max_bytes_per_scanline
)
540 gen6_XY_COLOR_BLT(&ilo
->cp
->builder
,
541 dst
->bo
, dst
->layout
.tiling
, dst
->layout
.bo_stride
, 0,
542 x1
, y1
, x2
, y2
, val
, rop
, value_mask
, write_mask
);
545 ilo_blitter_blt_end(blitter
, swctrl
);
547 return (slice
== dst_box
->depth
);
551 tex_copy_region(struct ilo_blitter
*blitter
,
552 struct ilo_texture
*dst
,
554 unsigned dst_x
, unsigned dst_y
, unsigned dst_z
,
555 struct ilo_texture
*src
,
557 const struct pipe_box
*src_box
)
559 const struct util_format_description
*desc
=
560 util_format_description(dst
->layout
.format
);
561 const unsigned max_extent
= 32767; /* INT16_MAX */
562 const uint8_t rop
= 0xcc; /* SRCCOPY */
563 struct ilo_context
*ilo
= blitter
->ilo
;
564 enum gen6_blt_mask mask
;
566 int cpp
, xscale
, slice
;
568 /* no W-tiling support */
569 if (dst
->separate_s8
|| src
->separate_s8
)
572 if (dst
->layout
.bo_stride
> max_extent
||
573 src
->layout
.bo_stride
> max_extent
)
576 cpp
= desc
->block
.bits
/ 8;
579 /* accommodate for larger cpp */
584 cpp
= (cpp
% 4 == 0) ? 4 : 2;
585 xscale
= (desc
->block
.bits
/ 8) / cpp
;
590 mask
= GEN6_BLT_MASK_8
;
593 mask
= GEN6_BLT_MASK_16
;
596 mask
= GEN6_BLT_MASK_32
;
603 swctrl
= ilo_blitter_blt_begin(blitter
, src_box
->depth
* 8,
604 dst
->bo
, dst
->layout
.tiling
, src
->bo
, src
->layout
.tiling
);
606 for (slice
= 0; slice
< src_box
->depth
; slice
++) {
607 unsigned x1
, y1
, x2
, y2
, src_x
, src_y
;
609 ilo_layout_get_slice_pos(&dst
->layout
,
610 dst_level
, dst_z
+ slice
, &x1
, &y1
);
611 x1
= (x1
+ dst_x
) * xscale
;
613 x2
= (x1
+ src_box
->width
) * xscale
;
614 y2
= y1
+ src_box
->height
;
616 ilo_layout_get_slice_pos(&src
->layout
,
617 src_level
, src_box
->z
+ slice
, &src_x
, &src_y
);
619 src_x
= (src_x
+ src_box
->x
) * xscale
;
623 x1
/= desc
->block
.width
;
624 y1
/= desc
->block
.height
;
625 x2
= (x2
+ desc
->block
.width
- 1) / desc
->block
.width
;
626 y2
= (y2
+ desc
->block
.height
- 1) / desc
->block
.height
;
627 src_x
/= desc
->block
.width
;
628 src_y
/= desc
->block
.height
;
630 if (x2
> max_extent
|| y2
> max_extent
||
631 src_x
> max_extent
|| src_y
> max_extent
||
632 (x2
- x1
) * cpp
> gen6_max_bytes_per_scanline
)
635 gen6_XY_SRC_COPY_BLT(&ilo
->cp
->builder
,
636 dst
->bo
, dst
->layout
.tiling
, dst
->layout
.bo_stride
, 0,
638 src
->bo
, src
->layout
.tiling
, src
->layout
.bo_stride
, 0,
639 src_x
, src_y
, rop
, mask
, mask
);
642 ilo_blitter_blt_end(blitter
, swctrl
);
644 return (slice
== src_box
->depth
);
648 ilo_blitter_blt_copy_resource(struct ilo_blitter
*blitter
,
649 struct pipe_resource
*dst
, unsigned dst_level
,
650 unsigned dst_x
, unsigned dst_y
, unsigned dst_z
,
651 struct pipe_resource
*src
, unsigned src_level
,
652 const struct pipe_box
*src_box
)
656 ilo_blit_resolve_slices(blitter
->ilo
, src
, src_level
,
657 src_box
->z
, src_box
->depth
, ILO_TEXTURE_BLT_READ
);
658 ilo_blit_resolve_slices(blitter
->ilo
, dst
, dst_level
,
659 dst_z
, src_box
->depth
, ILO_TEXTURE_BLT_WRITE
);
661 if (dst
->target
== PIPE_BUFFER
&& src
->target
== PIPE_BUFFER
) {
662 const unsigned dst_offset
= dst_x
;
663 const unsigned src_offset
= src_box
->x
;
664 const unsigned size
= src_box
->width
;
666 assert(dst_level
== 0 && dst_y
== 0 && dst_z
== 0);
667 assert(src_level
== 0 &&
670 src_box
->height
== 1 &&
671 src_box
->depth
== 1);
673 success
= buf_copy_region(blitter
,
674 ilo_buffer(dst
), dst_offset
, ilo_buffer(src
), src_offset
, size
);
676 else if (dst
->target
!= PIPE_BUFFER
&& src
->target
!= PIPE_BUFFER
) {
677 success
= tex_copy_region(blitter
,
678 ilo_texture(dst
), dst_level
, dst_x
, dst_y
, dst_z
,
679 ilo_texture(src
), src_level
, src_box
);
689 ilo_blitter_blt_clear_rt(struct ilo_blitter
*blitter
,
690 struct pipe_surface
*rt
,
691 const union pipe_color_union
*color
,
692 unsigned x
, unsigned y
,
693 unsigned width
, unsigned height
)
695 const int cpp
= util_format_get_blocksize(rt
->format
);
696 enum gen6_blt_mask mask
;
697 union util_color packed
;
700 if (!ilo_3d_pass_render_condition(blitter
->ilo
))
705 mask
= GEN6_BLT_MASK_8
;
708 mask
= GEN6_BLT_MASK_16
;
711 mask
= GEN6_BLT_MASK_32
;
718 if (util_format_is_pure_integer(rt
->format
) ||
719 util_format_is_compressed(rt
->format
))
722 ilo_blit_resolve_surface(blitter
->ilo
, rt
, ILO_TEXTURE_BLT_WRITE
);
724 util_pack_color(color
->f
, rt
->format
, &packed
);
726 if (rt
->texture
->target
== PIPE_BUFFER
) {
727 unsigned offset
, end
, size
;
729 assert(y
== 0 && height
== 1);
731 offset
= (rt
->u
.buf
.first_element
+ x
) * cpp
;
732 end
= (rt
->u
.buf
.last_element
+ 1) * cpp
;
735 if (offset
+ size
> end
)
738 success
= buf_clear_region(blitter
, ilo_buffer(rt
->texture
),
739 offset
, size
, packed
.ui
[0], mask
, mask
);
744 u_box_3d(x
, y
, rt
->u
.tex
.first_layer
, width
, height
,
745 rt
->u
.tex
.last_layer
- rt
->u
.tex
.first_layer
+ 1, &box
);
747 success
= tex_clear_region(blitter
, ilo_texture(rt
->texture
),
748 rt
->u
.tex
.level
, &box
, packed
.ui
[0], mask
, mask
);
755 ilo_blitter_blt_clear_zs(struct ilo_blitter
*blitter
,
756 struct pipe_surface
*zs
,
757 unsigned clear_flags
,
758 double depth
, unsigned stencil
,
759 unsigned x
, unsigned y
,
760 unsigned width
, unsigned height
)
762 enum gen6_blt_mask value_mask
, write_mask
;
766 if (!ilo_3d_pass_render_condition(blitter
->ilo
))
769 switch (zs
->format
) {
770 case PIPE_FORMAT_Z16_UNORM
:
771 if (!(clear_flags
& PIPE_CLEAR_DEPTH
))
774 value_mask
= GEN6_BLT_MASK_16
;
775 write_mask
= GEN6_BLT_MASK_16
;
777 case PIPE_FORMAT_Z32_FLOAT
:
778 if (!(clear_flags
& PIPE_CLEAR_DEPTH
))
781 value_mask
= GEN6_BLT_MASK_32
;
782 write_mask
= GEN6_BLT_MASK_32
;
784 case PIPE_FORMAT_Z24X8_UNORM
:
785 if (!(clear_flags
& PIPE_CLEAR_DEPTH
))
788 value_mask
= GEN6_BLT_MASK_32
;
789 write_mask
= GEN6_BLT_MASK_32_LO
;
791 case PIPE_FORMAT_Z24_UNORM_S8_UINT
:
792 if (!(clear_flags
& PIPE_CLEAR_DEPTHSTENCIL
))
795 value_mask
= GEN6_BLT_MASK_32
;
797 if ((clear_flags
& PIPE_CLEAR_DEPTHSTENCIL
) == PIPE_CLEAR_DEPTHSTENCIL
)
798 write_mask
= GEN6_BLT_MASK_32
;
799 else if (clear_flags
& PIPE_CLEAR_DEPTH
)
800 write_mask
= GEN6_BLT_MASK_32_LO
;
802 write_mask
= GEN6_BLT_MASK_32_HI
;
809 ilo_blit_resolve_surface(blitter
->ilo
, zs
, ILO_TEXTURE_BLT_WRITE
);
811 val
= util_pack_z_stencil(zs
->format
, depth
, stencil
);
813 u_box_3d(x
, y
, zs
->u
.tex
.first_layer
, width
, height
,
814 zs
->u
.tex
.last_layer
- zs
->u
.tex
.first_layer
+ 1, &box
);
816 assert(zs
->texture
->target
!= PIPE_BUFFER
);
818 return tex_clear_region(blitter
, ilo_texture(zs
->texture
),
819 zs
->u
.tex
.level
, &box
, val
, value_mask
, write_mask
);