1 /**************************************************************************
3 * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
29 #include <GL/internal/dri_interface.h>
31 #include "intel_batchbuffer.h"
32 #include "intel_chipset.h"
33 #include "intel_context.h"
34 #include "intel_mipmap_tree.h"
35 #include "intel_regions.h"
36 #include "intel_tex_layout.h"
37 #include "intel_tex.h"
38 #include "intel_blit.h"
40 #include "main/enums.h"
41 #include "main/formats.h"
42 #include "main/glformats.h"
43 #include "main/teximage.h"
45 #define FILE_DEBUG_FLAG DEBUG_MIPTREE
48 target_to_target(GLenum target
)
51 case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB
:
52 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB
:
53 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB
:
54 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB
:
55 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB
:
56 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB
:
57 return GL_TEXTURE_CUBE_MAP_ARB
;
64 * @param for_bo Indicates that the caller is
65 * intel_miptree_create_for_bo(). If true, then do not create
68 struct intel_mipmap_tree
*
69 intel_miptree_create_layout(struct intel_context
*intel
,
79 struct intel_mipmap_tree
*mt
= calloc(sizeof(*mt
), 1);
83 DBG("%s target %s format %s level %d..%d <-- %p\n", __FUNCTION__
,
84 _mesa_lookup_enum_by_nr(target
),
85 _mesa_get_format_name(format
),
86 first_level
, last_level
, mt
);
88 mt
->target
= target_to_target(target
);
90 mt
->first_level
= first_level
;
91 mt
->last_level
= last_level
;
92 mt
->logical_width0
= width0
;
93 mt
->logical_height0
= height0
;
94 mt
->logical_depth0
= depth0
;
96 /* The cpp is bytes per (1, blockheight)-sized block for compressed
97 * textures. This is why you'll see divides by blockheight all over
100 _mesa_get_format_block_size(format
, &bw
, &bh
);
101 assert(_mesa_get_format_bytes(mt
->format
) % bw
== 0);
102 mt
->cpp
= _mesa_get_format_bytes(mt
->format
) / bw
;
104 mt
->compressed
= _mesa_is_format_compressed(format
);
107 if (target
== GL_TEXTURE_CUBE_MAP
) {
112 mt
->physical_width0
= width0
;
113 mt
->physical_height0
= height0
;
114 mt
->physical_depth0
= depth0
;
116 intel_get_texture_alignment_unit(intel
, mt
->format
,
117 &mt
->align_w
, &mt
->align_h
);
121 i945_miptree_layout(mt
);
123 i915_miptree_layout(mt
);
129 * \brief Helper function for intel_miptree_create().
132 intel_miptree_choose_tiling(struct intel_context
*intel
,
135 enum intel_miptree_tiling_mode requested
,
136 struct intel_mipmap_tree
*mt
)
138 /* Some usages may want only one type of tiling, like depth miptrees (Y
139 * tiled), or temporary BOs for uploading data once (linear).
142 case INTEL_MIPTREE_TILING_ANY
:
144 case INTEL_MIPTREE_TILING_Y
:
145 return I915_TILING_Y
;
146 case INTEL_MIPTREE_TILING_NONE
:
147 return I915_TILING_NONE
;
150 int minimum_pitch
= mt
->total_width
* mt
->cpp
;
152 /* If the width is much smaller than a tile, don't bother tiling. */
153 if (minimum_pitch
< 64)
154 return I915_TILING_NONE
;
156 if (ALIGN(minimum_pitch
, 512) >= 32768) {
157 perf_debug("%dx%d miptree too large to blit, falling back to untiled",
158 mt
->total_width
, mt
->total_height
);
159 return I915_TILING_NONE
;
162 /* We don't have BLORP to handle Y-tiled blits, so use X-tiling. */
163 return I915_TILING_X
;
166 struct intel_mipmap_tree
*
167 intel_miptree_create(struct intel_context
*intel
,
175 bool expect_accelerated_upload
,
176 enum intel_miptree_tiling_mode requested_tiling
)
178 struct intel_mipmap_tree
*mt
;
179 GLuint total_width
, total_height
;
182 mt
= intel_miptree_create_layout(intel
, target
, format
,
183 first_level
, last_level
, width0
,
187 * pitch == 0 || height == 0 indicates the null texture
189 if (!mt
|| !mt
->total_width
|| !mt
->total_height
) {
190 intel_miptree_release(&mt
);
194 total_width
= mt
->total_width
;
195 total_height
= mt
->total_height
;
197 uint32_t tiling
= intel_miptree_choose_tiling(intel
, format
, width0
,
200 bool y_or_x
= tiling
== (I915_TILING_Y
| I915_TILING_X
);
202 mt
->region
= intel_region_alloc(intel
->intelScreen
,
203 y_or_x
? I915_TILING_Y
: tiling
,
207 expect_accelerated_upload
);
209 /* If the region is too large to fit in the aperture, we need to use the
210 * BLT engine to support it. The BLT paths can't currently handle Y-tiling,
211 * so we need to fall back to X.
213 if (y_or_x
&& mt
->region
->bo
->size
>= intel
->max_gtt_map_object_size
) {
214 perf_debug("%dx%d miptree larger than aperture; falling back to X-tiled\n",
215 mt
->total_width
, mt
->total_height
);
216 intel_region_release(&mt
->region
);
218 mt
->region
= intel_region_alloc(intel
->intelScreen
,
223 expect_accelerated_upload
);
229 intel_miptree_release(&mt
);
236 struct intel_mipmap_tree
*
237 intel_miptree_create_for_bo(struct intel_context
*intel
,
246 struct intel_mipmap_tree
*mt
;
248 struct intel_region
*region
= calloc(1, sizeof(*region
));
252 /* Nothing will be able to use this miptree with the BO if the offset isn't
255 if (tiling
!= I915_TILING_NONE
)
256 assert(offset
% 4096 == 0);
258 /* miptrees can't handle negative pitch. If you need flipping of images,
259 * that's outside of the scope of the mt.
263 mt
= intel_miptree_create_layout(intel
, GL_TEXTURE_2D
, format
,
272 region
->cpp
= mt
->cpp
;
273 region
->width
= width
;
274 region
->height
= height
;
275 region
->pitch
= pitch
;
276 region
->refcount
= 1;
277 drm_intel_bo_reference(bo
);
279 region
->tiling
= tiling
;
289 * For a singlesample DRI2 buffer, this simply wraps the given region with a miptree.
291 * For a multisample DRI2 buffer, this wraps the given region with
292 * a singlesample miptree, then creates a multisample miptree into which the
293 * singlesample miptree is embedded as a child.
295 struct intel_mipmap_tree
*
296 intel_miptree_create_for_dri2_buffer(struct intel_context
*intel
,
297 unsigned dri_attachment
,
299 struct intel_region
*region
)
301 struct intel_mipmap_tree
*mt
= NULL
;
303 /* Only the front and back buffers, which are color buffers, are shared
306 assert(dri_attachment
== __DRI_BUFFER_BACK_LEFT
||
307 dri_attachment
== __DRI_BUFFER_FRONT_LEFT
||
308 dri_attachment
== __DRI_BUFFER_FAKE_FRONT_LEFT
);
309 assert(_mesa_get_format_base_format(format
) == GL_RGB
||
310 _mesa_get_format_base_format(format
) == GL_RGBA
);
312 mt
= intel_miptree_create_for_bo(intel
,
322 mt
->region
->name
= region
->name
;
328 * For a singlesample image buffer, this simply wraps the given region with a miptree.
330 * For a multisample image buffer, this wraps the given region with
331 * a singlesample miptree, then creates a multisample miptree into which the
332 * singlesample miptree is embedded as a child.
334 struct intel_mipmap_tree
*
335 intel_miptree_create_for_image_buffer(struct intel_context
*intel
,
336 enum __DRIimageBufferMask buffer_type
,
338 uint32_t num_samples
,
339 struct intel_region
*region
)
341 struct intel_mipmap_tree
*mt
= NULL
;
343 /* Only the front and back buffers, which are color buffers, are allocated
344 * through the image loader.
346 assert(_mesa_get_format_base_format(format
) == GL_RGB
||
347 _mesa_get_format_base_format(format
) == GL_RGBA
);
349 mt
= intel_miptree_create_for_bo(intel
,
360 struct intel_mipmap_tree
*
361 intel_miptree_create_for_renderbuffer(struct intel_context
*intel
,
368 return intel_miptree_create(intel
, GL_TEXTURE_2D
, format
, 0, 0,
369 width
, height
, depth
, true,
370 INTEL_MIPTREE_TILING_ANY
);
374 intel_miptree_reference(struct intel_mipmap_tree
**dst
,
375 struct intel_mipmap_tree
*src
)
380 intel_miptree_release(dst
);
384 DBG("%s %p refcount now %d\n", __FUNCTION__
, src
, src
->refcount
);
392 intel_miptree_release(struct intel_mipmap_tree
**mt
)
397 DBG("%s %p refcount will be %d\n", __FUNCTION__
, *mt
, (*mt
)->refcount
- 1);
398 if (--(*mt
)->refcount
<= 0) {
401 DBG("%s deleting %p\n", __FUNCTION__
, *mt
);
403 intel_region_release(&((*mt
)->region
));
405 for (i
= 0; i
< MAX_TEXTURE_LEVELS
; i
++) {
406 free((*mt
)->level
[i
].slice
);
415 intel_miptree_get_dimensions_for_image(struct gl_texture_image
*image
,
416 int *width
, int *height
, int *depth
)
418 switch (image
->TexObject
->Target
) {
419 case GL_TEXTURE_1D_ARRAY
:
420 *width
= image
->Width
;
422 *depth
= image
->Height
;
425 *width
= image
->Width
;
426 *height
= image
->Height
;
427 *depth
= image
->Depth
;
433 * Can the image be pulled into a unified mipmap tree? This mirrors
434 * the completeness test in a lot of ways.
436 * Not sure whether I want to pass gl_texture_image here.
439 intel_miptree_match_image(struct intel_mipmap_tree
*mt
,
440 struct gl_texture_image
*image
)
442 struct intel_texture_image
*intelImage
= intel_texture_image(image
);
443 GLuint level
= intelImage
->base
.Base
.Level
;
444 int width
, height
, depth
;
446 /* glTexImage* choose the texture object based on the target passed in, and
447 * objects can't change targets over their lifetimes, so this should be
450 assert(target_to_target(image
->TexObject
->Target
) == mt
->target
);
452 gl_format mt_format
= mt
->format
;
454 if (image
->TexFormat
!= mt_format
)
457 intel_miptree_get_dimensions_for_image(image
, &width
, &height
, &depth
);
459 if (mt
->target
== GL_TEXTURE_CUBE_MAP
)
462 /* Test image dimensions against the base level image adjusted for
463 * minification. This will also catch images not present in the
464 * tree, changed targets, etc.
466 if (mt
->target
== GL_TEXTURE_2D_MULTISAMPLE
||
467 mt
->target
== GL_TEXTURE_2D_MULTISAMPLE_ARRAY
) {
468 /* nonzero level here is always bogus */
471 if (width
!= mt
->logical_width0
||
472 height
!= mt
->logical_height0
||
473 depth
!= mt
->logical_depth0
) {
478 /* all normal textures, renderbuffers, etc */
479 if (width
!= mt
->level
[level
].width
||
480 height
!= mt
->level
[level
].height
||
481 depth
!= mt
->level
[level
].depth
) {
491 intel_miptree_set_level_info(struct intel_mipmap_tree
*mt
,
494 GLuint w
, GLuint h
, GLuint d
)
496 mt
->level
[level
].width
= w
;
497 mt
->level
[level
].height
= h
;
498 mt
->level
[level
].depth
= d
;
499 mt
->level
[level
].level_x
= x
;
500 mt
->level
[level
].level_y
= y
;
502 DBG("%s level %d size: %d,%d,%d offset %d,%d\n", __FUNCTION__
,
503 level
, w
, h
, d
, x
, y
);
505 assert(mt
->level
[level
].slice
== NULL
);
507 mt
->level
[level
].slice
= calloc(d
, sizeof(*mt
->level
[0].slice
));
508 mt
->level
[level
].slice
[0].x_offset
= mt
->level
[level
].level_x
;
509 mt
->level
[level
].slice
[0].y_offset
= mt
->level
[level
].level_y
;
514 intel_miptree_set_image_offset(struct intel_mipmap_tree
*mt
,
515 GLuint level
, GLuint img
,
518 if (img
== 0 && level
== 0)
519 assert(x
== 0 && y
== 0);
521 assert(img
< mt
->level
[level
].depth
);
523 mt
->level
[level
].slice
[img
].x_offset
= mt
->level
[level
].level_x
+ x
;
524 mt
->level
[level
].slice
[img
].y_offset
= mt
->level
[level
].level_y
+ y
;
526 DBG("%s level %d img %d pos %d,%d\n",
527 __FUNCTION__
, level
, img
,
528 mt
->level
[level
].slice
[img
].x_offset
,
529 mt
->level
[level
].slice
[img
].y_offset
);
533 intel_miptree_get_image_offset(struct intel_mipmap_tree
*mt
,
534 GLuint level
, GLuint slice
,
535 GLuint
*x
, GLuint
*y
)
537 assert(slice
< mt
->level
[level
].depth
);
539 *x
= mt
->level
[level
].slice
[slice
].x_offset
;
540 *y
= mt
->level
[level
].slice
[slice
].y_offset
;
544 * Rendering with tiled buffers requires that the base address of the buffer
545 * be aligned to a page boundary. For renderbuffers, and sometimes with
546 * textures, we may want the surface to point at a texture image level that
547 * isn't at a page boundary.
549 * This function returns an appropriately-aligned base offset
550 * according to the tiling restrictions, plus any required x/y offset
554 intel_miptree_get_tile_offsets(struct intel_mipmap_tree
*mt
,
555 GLuint level
, GLuint slice
,
559 struct intel_region
*region
= mt
->region
;
561 uint32_t mask_x
, mask_y
;
563 intel_region_get_tile_masks(region
, &mask_x
, &mask_y
, false);
564 intel_miptree_get_image_offset(mt
, level
, slice
, &x
, &y
);
566 *tile_x
= x
& mask_x
;
567 *tile_y
= y
& mask_y
;
569 return intel_region_get_aligned_offset(region
, x
& ~mask_x
, y
& ~mask_y
,
574 intel_miptree_copy_slice_sw(struct intel_context
*intel
,
575 struct intel_mipmap_tree
*dst_mt
,
576 struct intel_mipmap_tree
*src_mt
,
583 int src_stride
, dst_stride
;
584 int cpp
= dst_mt
->cpp
;
586 intel_miptree_map(intel
, src_mt
,
593 intel_miptree_map(intel
, dst_mt
,
597 GL_MAP_WRITE_BIT
| GL_MAP_INVALIDATE_RANGE_BIT
,
600 DBG("sw blit %s mt %p %p/%d -> %s mt %p %p/%d (%dx%d)\n",
601 _mesa_get_format_name(src_mt
->format
),
602 src_mt
, src
, src_stride
,
603 _mesa_get_format_name(dst_mt
->format
),
604 dst_mt
, dst
, dst_stride
,
607 int row_size
= cpp
* width
;
608 if (src_stride
== row_size
&&
609 dst_stride
== row_size
) {
610 memcpy(dst
, src
, row_size
* height
);
612 for (int i
= 0; i
< height
; i
++) {
613 memcpy(dst
, src
, row_size
);
619 intel_miptree_unmap(intel
, dst_mt
, level
, slice
);
620 intel_miptree_unmap(intel
, src_mt
, level
, slice
);
624 intel_miptree_copy_slice(struct intel_context
*intel
,
625 struct intel_mipmap_tree
*dst_mt
,
626 struct intel_mipmap_tree
*src_mt
,
632 gl_format format
= src_mt
->format
;
633 uint32_t width
= src_mt
->level
[level
].width
;
634 uint32_t height
= src_mt
->level
[level
].height
;
642 assert(depth
< src_mt
->level
[level
].depth
);
643 assert(src_mt
->format
== dst_mt
->format
);
645 if (dst_mt
->compressed
) {
646 height
= ALIGN(height
, dst_mt
->align_h
) / dst_mt
->align_h
;
647 width
= ALIGN(width
, dst_mt
->align_w
);
650 uint32_t dst_x
, dst_y
, src_x
, src_y
;
651 intel_miptree_get_image_offset(dst_mt
, level
, slice
, &dst_x
, &dst_y
);
652 intel_miptree_get_image_offset(src_mt
, level
, slice
, &src_x
, &src_y
);
654 DBG("validate blit mt %s %p %d,%d/%d -> mt %s %p %d,%d/%d (%dx%d)\n",
655 _mesa_get_format_name(src_mt
->format
),
656 src_mt
, src_x
, src_y
, src_mt
->region
->pitch
,
657 _mesa_get_format_name(dst_mt
->format
),
658 dst_mt
, dst_x
, dst_y
, dst_mt
->region
->pitch
,
661 if (!intel_miptree_blit(intel
,
662 src_mt
, level
, slice
, 0, 0, false,
663 dst_mt
, level
, slice
, 0, 0, false,
664 width
, height
, GL_COPY
)) {
665 perf_debug("miptree validate blit for %s failed\n",
666 _mesa_get_format_name(format
));
668 intel_miptree_copy_slice_sw(intel
, dst_mt
, src_mt
, level
, slice
,
674 * Copies the image's current data to the given miptree, and associates that
675 * miptree with the image.
677 * If \c invalidate is true, then the actual image data does not need to be
678 * copied, but the image still needs to be associated to the new miptree (this
679 * is set to true if we're about to clear the image).
682 intel_miptree_copy_teximage(struct intel_context
*intel
,
683 struct intel_texture_image
*intelImage
,
684 struct intel_mipmap_tree
*dst_mt
,
687 struct intel_mipmap_tree
*src_mt
= intelImage
->mt
;
688 struct intel_texture_object
*intel_obj
=
689 intel_texture_object(intelImage
->base
.Base
.TexObject
);
690 int level
= intelImage
->base
.Base
.Level
;
691 int face
= intelImage
->base
.Base
.Face
;
692 GLuint depth
= intelImage
->base
.Base
.Depth
;
695 for (int slice
= 0; slice
< depth
; slice
++) {
696 intel_miptree_copy_slice(intel
, dst_mt
, src_mt
, level
, face
, slice
);
700 intel_miptree_reference(&intelImage
->mt
, dst_mt
);
701 intel_obj
->needs_validate
= true;
705 intel_miptree_map_raw(struct intel_context
*intel
, struct intel_mipmap_tree
*mt
)
707 drm_intel_bo
*bo
= mt
->region
->bo
;
709 if (unlikely(INTEL_DEBUG
& DEBUG_PERF
)) {
710 if (drm_intel_bo_busy(bo
)) {
711 perf_debug("Mapping a busy BO, causing a stall on the GPU.\n");
715 intel_flush(&intel
->ctx
);
717 if (mt
->region
->tiling
!= I915_TILING_NONE
)
718 drm_intel_gem_bo_map_gtt(bo
);
720 drm_intel_bo_map(bo
, true);
726 intel_miptree_unmap_raw(struct intel_context
*intel
,
727 struct intel_mipmap_tree
*mt
)
729 drm_intel_bo_unmap(mt
->region
->bo
);
733 intel_miptree_map_gtt(struct intel_context
*intel
,
734 struct intel_mipmap_tree
*mt
,
735 struct intel_miptree_map
*map
,
736 unsigned int level
, unsigned int slice
)
740 unsigned int image_x
, image_y
;
744 /* For compressed formats, the stride is the number of bytes per
745 * row of blocks. intel_miptree_get_image_offset() already does
748 _mesa_get_format_block_size(mt
->format
, &bw
, &bh
);
752 base
= intel_miptree_map_raw(intel
, mt
) + mt
->offset
;
757 /* Note that in the case of cube maps, the caller must have passed the
758 * slice number referencing the face.
760 intel_miptree_get_image_offset(mt
, level
, slice
, &image_x
, &image_y
);
764 map
->stride
= mt
->region
->pitch
;
765 map
->ptr
= base
+ y
* map
->stride
+ x
* mt
->cpp
;
768 DBG("%s: %d,%d %dx%d from mt %p (%s) %d,%d = %p/%d\n", __FUNCTION__
,
769 map
->x
, map
->y
, map
->w
, map
->h
,
770 mt
, _mesa_get_format_name(mt
->format
),
771 x
, y
, map
->ptr
, map
->stride
);
775 intel_miptree_unmap_gtt(struct intel_context
*intel
,
776 struct intel_mipmap_tree
*mt
,
777 struct intel_miptree_map
*map
,
781 intel_miptree_unmap_raw(intel
, mt
);
785 intel_miptree_map_blit(struct intel_context
*intel
,
786 struct intel_mipmap_tree
*mt
,
787 struct intel_miptree_map
*map
,
788 unsigned int level
, unsigned int slice
)
790 map
->mt
= intel_miptree_create(intel
, GL_TEXTURE_2D
, mt
->format
,
794 INTEL_MIPTREE_TILING_NONE
);
796 fprintf(stderr
, "Failed to allocate blit temporary\n");
799 map
->stride
= map
->mt
->region
->pitch
;
801 if (!intel_miptree_blit(intel
,
803 map
->x
, map
->y
, false,
806 map
->w
, map
->h
, GL_COPY
)) {
807 fprintf(stderr
, "Failed to blit\n");
811 intel_batchbuffer_flush(intel
);
812 map
->ptr
= intel_miptree_map_raw(intel
, map
->mt
);
814 DBG("%s: %d,%d %dx%d from mt %p (%s) %d,%d = %p/%d\n", __FUNCTION__
,
815 map
->x
, map
->y
, map
->w
, map
->h
,
816 mt
, _mesa_get_format_name(mt
->format
),
817 level
, slice
, map
->ptr
, map
->stride
);
822 intel_miptree_release(&map
->mt
);
828 intel_miptree_unmap_blit(struct intel_context
*intel
,
829 struct intel_mipmap_tree
*mt
,
830 struct intel_miptree_map
*map
,
834 struct gl_context
*ctx
= &intel
->ctx
;
836 intel_miptree_unmap_raw(intel
, map
->mt
);
838 if (map
->mode
& GL_MAP_WRITE_BIT
) {
839 bool ok
= intel_miptree_blit(intel
,
843 map
->x
, map
->y
, false,
844 map
->w
, map
->h
, GL_COPY
);
845 WARN_ONCE(!ok
, "Failed to blit from linear temporary mapping");
848 intel_miptree_release(&map
->mt
);
852 * Create and attach a map to the miptree at (level, slice). Return the
855 static struct intel_miptree_map
*
856 intel_miptree_attach_map(struct intel_mipmap_tree
*mt
,
865 struct intel_miptree_map
*map
= calloc(1, sizeof(*map
));
870 assert(mt
->level
[level
].slice
[slice
].map
== NULL
);
871 mt
->level
[level
].slice
[slice
].map
= map
;
883 * Release the map at (level, slice).
886 intel_miptree_release_map(struct intel_mipmap_tree
*mt
,
890 struct intel_miptree_map
**map
;
892 map
= &mt
->level
[level
].slice
[slice
].map
;
898 intel_miptree_map(struct intel_context
*intel
,
899 struct intel_mipmap_tree
*mt
,
910 struct intel_miptree_map
*map
;
912 map
= intel_miptree_attach_map(mt
, level
, slice
, x
, y
, w
, h
, mode
);
919 /* See intel_miptree_blit() for details on the 32k pitch limit. */
920 if (mt
->region
->tiling
!= I915_TILING_NONE
&&
921 mt
->region
->bo
->size
>= intel
->max_gtt_map_object_size
) {
922 assert(mt
->region
->pitch
< 32768);
923 intel_miptree_map_blit(intel
, mt
, map
, level
, slice
);
925 intel_miptree_map_gtt(intel
, mt
, map
, level
, slice
);
929 *out_stride
= map
->stride
;
931 if (map
->ptr
== NULL
)
932 intel_miptree_release_map(mt
, level
, slice
);
936 intel_miptree_unmap(struct intel_context
*intel
,
937 struct intel_mipmap_tree
*mt
,
941 struct intel_miptree_map
*map
= mt
->level
[level
].slice
[slice
].map
;
946 DBG("%s: mt %p (%s) level %d slice %d\n", __FUNCTION__
,
947 mt
, _mesa_get_format_name(mt
->format
), level
, slice
);
950 intel_miptree_unmap_blit(intel
, mt
, map
, level
, slice
);
952 intel_miptree_unmap_gtt(intel
, mt
, map
, level
, slice
);
955 intel_miptree_release_map(mt
, level
, slice
);