2 * Copyright © 2011 Red Hat All Rights Reserved.
4 * Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files (the
6 * "Software"), to deal in the Software without restriction, including
7 * without limitation the rights to use, copy, modify, merge, publish,
8 * distribute, sub license, and/or sell copies of the Software, and to
9 * permit persons to whom the Software is furnished to do so, subject to
10 * the following conditions:
12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
14 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 * NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS
16 * AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
18 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
19 * USE OR OTHER DEALINGS IN THE SOFTWARE.
21 * The above copyright notice and this permission notice (including the
22 * next paragraph) shall be included in all copies or substantial portions
27 * Jérôme Glisse <jglisse@redhat.com>
34 #include <sys/ioctl.h>
37 #include "radeon_drm.h"
38 #include "radeon_surface.h"
40 #define ALIGN(value, alignment) (((value) + alignment - 1) & ~(alignment - 1))
41 #define MAX2(A, B) ((A) > (B) ? (A) : (B))
42 #define MIN2(A, B) ((A) < (B) ? (A) : (B))
44 /* keep this private */
78 typedef int (*hw_init_surface_t)(struct radeon_surface_manager *surf_man,
79 struct radeon_surface *surf);
80 typedef int (*hw_best_surface_t)(struct radeon_surface_manager *surf_man,
81 struct radeon_surface *surf);
83 struct radeon_hw_info {
93 struct radeon_surface_manager {
96 struct radeon_hw_info hw_info;
98 hw_init_surface_t surface_init;
99 hw_best_surface_t surface_best;
103 static int radeon_get_value(int fd, unsigned req, uint32_t *value)
105 struct drm_radeon_info info = {};
110 info.value = (uintptr_t)value;
111 r = drmCommandWriteRead(fd, DRM_RADEON_INFO, &info,
112 sizeof(struct drm_radeon_info));
116 static int radeon_get_family(struct radeon_surface_manager *surf_man)
118 switch (surf_man->device_id) {
119 #define CHIPSET(pci_id, name, fam) case pci_id: surf_man->family = CHIP_##fam; break;
120 #include "r600_pci_ids.h"
128 static unsigned next_power_of_two(unsigned x)
133 return (1 << ((sizeof(unsigned) * 8) - __builtin_clz(x - 1)));
136 static unsigned mip_minify(unsigned size, unsigned level)
140 val = MAX2(1, size >> level);
142 val = next_power_of_two(val);
146 static void surf_minify(struct radeon_surface *surf,
148 uint32_t xalign, uint32_t yalign, uint32_t zalign,
151 surf->level[level].npix_x = mip_minify(surf->npix_x, level);
152 surf->level[level].npix_y = mip_minify(surf->npix_y, level);
153 surf->level[level].npix_z = mip_minify(surf->npix_z, level);
154 surf->level[level].nblk_x = (surf->level[level].npix_x + surf->blk_w - 1) / surf->blk_w;
155 surf->level[level].nblk_y = (surf->level[level].npix_y + surf->blk_h - 1) / surf->blk_h;
156 surf->level[level].nblk_z = (surf->level[level].npix_z + surf->blk_d - 1) / surf->blk_d;
157 if (surf->level[level].mode == RADEON_SURF_MODE_2D) {
158 if (surf->level[level].nblk_x < xalign || surf->level[level].nblk_y < yalign) {
159 surf->level[level].mode = RADEON_SURF_MODE_1D;
163 surf->level[level].nblk_x = ALIGN(surf->level[level].nblk_x, xalign);
164 surf->level[level].nblk_y = ALIGN(surf->level[level].nblk_y, yalign);
165 surf->level[level].nblk_z = ALIGN(surf->level[level].nblk_z, zalign);
167 surf->level[level].offset = offset;
168 surf->level[level].pitch_bytes = surf->level[level].nblk_x * surf->bpe;
169 surf->level[level].slice_size = surf->level[level].pitch_bytes * surf->level[level].nblk_y;
171 surf->bo_size = offset + surf->level[level].slice_size * surf->level[level].nblk_z * surf->array_size;
174 /* ===========================================================================
177 static int r6_init_hw_info(struct radeon_surface_manager *surf_man)
179 uint32_t tiling_config;
180 drmVersionPtr version;
183 r = radeon_get_value(surf_man->fd, RADEON_INFO_TILING_CONFIG,
189 surf_man->hw_info.allow_2d = 0;
190 version = drmGetVersion(surf_man->fd);
191 if (version && version->version_minor >= 14) {
192 surf_man->hw_info.allow_2d = 1;
195 switch ((tiling_config & 0xe) >> 1) {
197 surf_man->hw_info.num_pipes = 1;
200 surf_man->hw_info.num_pipes = 2;
203 surf_man->hw_info.num_pipes = 4;
206 surf_man->hw_info.num_pipes = 8;
212 switch ((tiling_config & 0x30) >> 4) {
214 surf_man->hw_info.num_banks = 4;
217 surf_man->hw_info.num_banks = 8;
223 switch ((tiling_config & 0xc0) >> 6) {
225 surf_man->hw_info.group_bytes = 256;
228 surf_man->hw_info.group_bytes = 512;
236 static int r6_surface_init_linear(struct radeon_surface_manager *surf_man,
237 struct radeon_surface *surf,
238 uint64_t offset, unsigned start_level)
240 uint32_t xalign, yalign, zalign;
243 /* compute alignment */
245 surf->bo_alignment = MAX2(256, surf_man->hw_info.group_bytes);
247 /* the 32 alignment is for scanout, cb or db but to allow texture to be
248 * easily bound as such we force this alignment to all surface
250 xalign = MAX2(1, surf_man->hw_info.group_bytes / surf->bpe);
253 if (surf->flags & RADEON_SURF_SCANOUT) {
254 xalign = MAX2((surf->bpe == 1) ? 64 : 32, xalign);
257 /* build mipmap tree */
258 for (i = start_level; i <= surf->last_level; i++) {
259 surf->level[i].mode = RADEON_SURF_MODE_LINEAR;
260 surf_minify(surf, i, xalign, yalign, zalign, offset);
261 /* level0 and first mipmap need to have alignment */
262 offset = surf->bo_size;
264 offset = ALIGN(offset, surf->bo_alignment);
270 static int r6_surface_init_linear_aligned(struct radeon_surface_manager *surf_man,
271 struct radeon_surface *surf,
272 uint64_t offset, unsigned start_level)
274 uint32_t xalign, yalign, zalign;
277 /* compute alignment */
279 surf->bo_alignment = MAX2(256, surf_man->hw_info.group_bytes);
281 xalign = MAX2(64, surf_man->hw_info.group_bytes / surf->bpe);
285 /* build mipmap tree */
286 for (i = start_level; i <= surf->last_level; i++) {
287 surf->level[i].mode = RADEON_SURF_MODE_LINEAR_ALIGNED;
288 surf_minify(surf, i, xalign, yalign, zalign, offset);
289 /* level0 and first mipmap need to have alignment */
290 offset = surf->bo_size;
292 offset = ALIGN(offset, surf->bo_alignment);
298 static int r6_surface_init_1d(struct radeon_surface_manager *surf_man,
299 struct radeon_surface *surf,
300 uint64_t offset, unsigned start_level)
302 uint32_t xalign, yalign, zalign, tilew;
305 /* compute alignment */
307 xalign = surf_man->hw_info.group_bytes / (tilew * surf->bpe * surf->nsamples);
308 xalign = MAX2(tilew, xalign);
311 if (surf->flags & RADEON_SURF_SCANOUT) {
312 xalign = MAX2((surf->bpe == 1) ? 64 : 32, xalign);
315 surf->bo_alignment = MAX2(256, surf_man->hw_info.group_bytes);
318 /* build mipmap tree */
319 for (i = start_level; i <= surf->last_level; i++) {
320 surf->level[i].mode = RADEON_SURF_MODE_1D;
321 surf_minify(surf, i, xalign, yalign, zalign, offset);
322 /* level0 and first mipmap need to have alignment */
323 offset = surf->bo_size;
325 offset = ALIGN(offset, surf->bo_alignment);
331 static int r6_surface_init_2d(struct radeon_surface_manager *surf_man,
332 struct radeon_surface *surf,
333 uint64_t offset, unsigned start_level)
335 uint32_t xalign, yalign, zalign, tilew;
338 /* compute alignment */
341 xalign = (surf_man->hw_info.group_bytes * surf_man->hw_info.num_banks) /
342 (tilew * surf->bpe * surf->nsamples);
343 xalign = MAX2(tilew * surf_man->hw_info.num_banks, xalign);
344 yalign = tilew * surf_man->hw_info.num_pipes;
345 if (surf->flags & RADEON_SURF_SCANOUT) {
346 xalign = MAX2((surf->bpe == 1) ? 64 : 32, xalign);
350 MAX2(surf_man->hw_info.num_pipes *
351 surf_man->hw_info.num_banks *
353 xalign * yalign * surf->nsamples * surf->bpe);
356 /* build mipmap tree */
357 for (i = start_level; i <= surf->last_level; i++) {
358 surf->level[i].mode = RADEON_SURF_MODE_2D;
359 surf_minify(surf, i, xalign, yalign, zalign, offset);
360 if (surf->level[i].mode == RADEON_SURF_MODE_1D) {
361 return r6_surface_init_1d(surf_man, surf, offset, i);
363 /* level0 and first mipmap need to have alignment */
364 offset = surf->bo_size;
366 offset = ALIGN(offset, surf->bo_alignment);
372 static int r6_surface_init(struct radeon_surface_manager *surf_man,
373 struct radeon_surface *surf)
379 mode = (surf->flags >> RADEON_SURF_MODE_SHIFT) & RADEON_SURF_MODE_MASK;
381 /* force 1d on kernel that can't do 2d */
382 if (!surf_man->hw_info.allow_2d && mode > RADEON_SURF_MODE_1D) {
383 mode = RADEON_SURF_MODE_1D;
384 surf->flags = RADEON_SURF_CLR(surf->flags, MODE);
385 surf->flags |= RADEON_SURF_SET(mode, MODE);
388 /* check surface dimension */
389 if (surf->npix_x > 8192 || surf->npix_y > 8192 || surf->npix_z > 8192) {
393 /* check mipmap last_level */
394 if (surf->last_level > 14) {
398 /* check tiling mode */
400 case RADEON_SURF_MODE_LINEAR:
401 r = r6_surface_init_linear(surf_man, surf, 0, 0);
403 case RADEON_SURF_MODE_LINEAR_ALIGNED:
404 r = r6_surface_init_linear_aligned(surf_man, surf, 0, 0);
406 case RADEON_SURF_MODE_1D:
407 r = r6_surface_init_1d(surf_man, surf, 0, 0);
409 case RADEON_SURF_MODE_2D:
410 r = r6_surface_init_2d(surf_man, surf, 0, 0);
418 static int r6_surface_best(struct radeon_surface_manager *surf_man,
419 struct radeon_surface *surf)
421 /* no value to optimize for r6xx/r7xx */
426 /* ===========================================================================
429 static int eg_init_hw_info(struct radeon_surface_manager *surf_man)
431 uint32_t tiling_config;
432 drmVersionPtr version;
435 r = radeon_get_value(surf_man->fd, RADEON_INFO_TILING_CONFIG,
441 surf_man->hw_info.allow_2d = 0;
442 version = drmGetVersion(surf_man->fd);
443 if (version && version->version_minor >= 14) {
444 surf_man->hw_info.allow_2d = 1;
447 switch (tiling_config & 0xf) {
449 surf_man->hw_info.num_pipes = 1;
452 surf_man->hw_info.num_pipes = 2;
455 surf_man->hw_info.num_pipes = 4;
458 surf_man->hw_info.num_pipes = 8;
464 switch ((tiling_config & 0xf0) >> 4) {
466 surf_man->hw_info.num_banks = 4;
469 surf_man->hw_info.num_banks = 8;
472 surf_man->hw_info.num_banks = 16;
478 switch ((tiling_config & 0xf00) >> 8) {
480 surf_man->hw_info.group_bytes = 256;
483 surf_man->hw_info.group_bytes = 512;
489 switch ((tiling_config & 0xf000) >> 12) {
491 surf_man->hw_info.row_size = 1024;
494 surf_man->hw_info.row_size = 2048;
497 surf_man->hw_info.row_size = 4096;
505 static void eg_surf_minify(struct radeon_surface *surf,
513 unsigned mtile_pr, mtile_ps;
515 surf->level[level].npix_x = mip_minify(surf->npix_x, level);
516 surf->level[level].npix_y = mip_minify(surf->npix_y, level);
517 surf->level[level].npix_z = mip_minify(surf->npix_z, level);
518 surf->level[level].nblk_x = (surf->level[level].npix_x + surf->blk_w - 1) / surf->blk_w;
519 surf->level[level].nblk_y = (surf->level[level].npix_y + surf->blk_h - 1) / surf->blk_h;
520 surf->level[level].nblk_z = (surf->level[level].npix_z + surf->blk_d - 1) / surf->blk_d;
521 if (surf->level[level].mode == RADEON_SURF_MODE_2D) {
522 if (surf->level[level].nblk_x < mtilew || surf->level[level].nblk_y < mtileh) {
523 surf->level[level].mode = RADEON_SURF_MODE_1D;
527 surf->level[level].nblk_x = ALIGN(surf->level[level].nblk_x, mtilew);
528 surf->level[level].nblk_y = ALIGN(surf->level[level].nblk_y, mtileh);
529 surf->level[level].nblk_z = ALIGN(surf->level[level].nblk_z, 1);
531 /* macro tile per row */
532 mtile_pr = surf->level[level].nblk_x / mtilew;
533 /* macro tile per slice */
534 mtile_ps = (mtile_pr * surf->level[level].nblk_y) / mtileh;
536 surf->level[level].offset = offset;
537 surf->level[level].pitch_bytes = surf->level[level].nblk_x * surf->bpe * slice_pt;
538 surf->level[level].slice_size = mtile_ps * mtileb * slice_pt;
540 surf->bo_size = offset + surf->level[level].slice_size * surf->level[level].nblk_z * surf->array_size;
543 static int eg_surface_init_1d(struct radeon_surface_manager *surf_man,
544 struct radeon_surface *surf,
545 uint64_t offset, unsigned start_level)
547 uint32_t xalign, yalign, zalign, tilew;
550 /* compute alignment */
552 xalign = surf_man->hw_info.group_bytes / (tilew * surf->bpe * surf->nsamples);
553 if (surf->flags & RADEON_SURF_SBUFFER) {
554 surf->stencil_offset = 0;
555 surf->stencil_tile_split = 0;
556 xalign = surf_man->hw_info.group_bytes / (tilew * surf->nsamples);
558 xalign = MAX2(tilew, xalign);
561 if (surf->flags & RADEON_SURF_SCANOUT) {
562 xalign = MAX2((surf->bpe == 1) ? 64 : 32, xalign);
565 surf->bo_alignment = MAX2(256, surf_man->hw_info.group_bytes);
568 /* build mipmap tree */
569 for (i = start_level; i <= surf->last_level; i++) {
570 surf->level[i].mode = RADEON_SURF_MODE_1D;
571 surf_minify(surf, i, xalign, yalign, zalign, offset);
572 /* level0 and first mipmap need to have alignment */
573 offset = surf->bo_size;
575 offset = ALIGN(offset, surf->bo_alignment);
579 if (surf->flags & RADEON_SURF_SBUFFER) {
580 surf->stencil_offset = ALIGN(surf->bo_size, surf->bo_alignment);
581 surf->bo_size = surf->stencil_offset + surf->bo_size / 4;
587 static int eg_surface_init_2d(struct radeon_surface_manager *surf_man,
588 struct radeon_surface *surf,
589 uint64_t offset, unsigned start_level)
591 unsigned tilew, tileh, tileb;
592 unsigned mtilew, mtileh, mtileb;
596 surf->stencil_offset = 0;
597 /* compute tile values */
600 tileb = tilew * tileh * surf->bpe * surf->nsamples;
601 /* slices per tile */
603 if (tileb > surf->tile_split) {
604 slice_pt = tileb / surf->tile_split;
606 tileb = tileb / slice_pt;
608 /* macro tile width & height */
609 mtilew = (tilew * surf->bankw * surf_man->hw_info.num_pipes) * surf->mtilea;
610 mtileh = (tileh * surf->bankh * surf_man->hw_info.num_banks) / surf->mtilea;
611 /* macro tile bytes */
612 mtileb = (mtilew / tilew) * (mtileh / tileh) * tileb;
615 surf->bo_alignment = MAX2(256, mtileb);
618 /* build mipmap tree */
619 for (i = start_level; i <= surf->last_level; i++) {
620 surf->level[i].mode = RADEON_SURF_MODE_2D;
621 eg_surf_minify(surf, i, slice_pt, mtilew, mtileh, mtileb, offset);
622 if (surf->level[i].mode == RADEON_SURF_MODE_1D) {
623 return eg_surface_init_1d(surf_man, surf, offset, i);
625 /* level0 and first mipmap need to have alignment */
626 offset = surf->bo_size;
628 offset = ALIGN(offset, surf->bo_alignment);
632 if (surf->flags & RADEON_SURF_SBUFFER) {
633 surf->stencil_offset = ALIGN(surf->bo_size, surf->bo_alignment);
634 surf->bo_size = surf->stencil_offset + surf->bo_size / 4;
640 static int eg_surface_sanity(struct radeon_surface_manager *surf_man,
641 struct radeon_surface *surf,
646 /* check surface dimension */
647 if (surf->npix_x > 16384 || surf->npix_y > 16384 || surf->npix_z > 16384) {
651 /* check mipmap last_level */
652 if (surf->last_level > 15) {
656 /* force 1d on kernel that can't do 2d */
657 if (!surf_man->hw_info.allow_2d && mode > RADEON_SURF_MODE_1D) {
658 mode = RADEON_SURF_MODE_1D;
659 surf->flags = RADEON_SURF_CLR(surf->flags, MODE);
660 surf->flags |= RADEON_SURF_SET(mode, MODE);
663 /* check tile split */
664 if (mode == RADEON_SURF_MODE_2D) {
665 switch (surf->tile_split) {
677 switch (surf->mtilea) {
686 /* check aspect ratio */
687 if (surf_man->hw_info.num_banks < surf->mtilea) {
690 /* check bank width */
691 switch (surf->bankw) {
700 /* check bank height */
701 switch (surf->bankh) {
710 tileb = MIN2(surf->tile_split, 64 * surf->bpe * surf->nsamples);
711 if ((tileb * surf->bankh * surf->bankw) < surf_man->hw_info.group_bytes) {
719 static int eg_surface_init(struct radeon_surface_manager *surf_man,
720 struct radeon_surface *surf)
726 mode = (surf->flags >> RADEON_SURF_MODE_SHIFT) & RADEON_SURF_MODE_MASK;
728 /* for some reason eg need to have room for stencil right after depth */
729 if (surf->flags & RADEON_SURF_ZBUFFER) {
730 surf->flags |= RADEON_SURF_SBUFFER;
733 r = eg_surface_sanity(surf_man, surf, mode);
738 /* check tiling mode */
740 case RADEON_SURF_MODE_LINEAR:
741 r = r6_surface_init_linear(surf_man, surf, 0, 0);
743 case RADEON_SURF_MODE_LINEAR_ALIGNED:
744 r = r6_surface_init_linear_aligned(surf_man, surf, 0, 0);
746 case RADEON_SURF_MODE_1D:
747 r = eg_surface_init_1d(surf_man, surf, 0, 0);
749 case RADEON_SURF_MODE_2D:
750 r = eg_surface_init_2d(surf_man, surf, 0, 0);
758 static unsigned log2_int(unsigned x)
766 if ((unsigned)(1 << l) > x) {
773 /* compute best tile_split, bankw, bankh, mtilea
774 * depending on surface
776 static int eg_surface_best(struct radeon_surface_manager *surf_man,
777 struct radeon_surface *surf)
779 unsigned mode, tileb, h_over_w;
783 mode = (surf->flags >> RADEON_SURF_MODE_SHIFT) & RADEON_SURF_MODE_MASK;
785 /* for some reason eg need to have room for stencil right after depth */
786 if (surf->flags & RADEON_SURF_ZBUFFER) {
787 surf->flags |= RADEON_SURF_SBUFFER;
790 /* set some default value to avoid sanity check choking on them */
791 surf->tile_split = 1024;
794 surf->mtilea = surf_man->hw_info.num_banks;
795 tileb = MIN2(surf->tile_split, 64 * surf->bpe * surf->nsamples);
796 for (; surf->bankh <= 8; surf->bankh *= 2) {
797 if ((tileb * surf->bankh * surf->bankw) >= surf_man->hw_info.group_bytes) {
801 if (surf->mtilea > 8) {
805 r = eg_surface_sanity(surf_man, surf, mode);
810 if (mode != RADEON_SURF_MODE_2D) {
811 /* nothing to do for non 2D tiled surface */
815 /* set tile split to row size, optimize latter for multi-sample surface
816 * tile split >= 256 for render buffer surface. Also depth surface want
817 * smaller value for optimal performances.
819 surf->tile_split = surf_man->hw_info.row_size;
820 surf->stencil_tile_split = surf_man->hw_info.row_size / 2;
822 /* bankw or bankh greater than 1 increase alignment requirement, not
823 * sure if it's worth using smaller bankw & bankh to stick with 2D
824 * tiling on small surface rather than falling back to 1D tiling.
825 * Use recommanded value based on tile size for now.
827 * fmask buffer has different optimal value figure them out once we
830 if (surf->flags & (RADEON_SURF_ZBUFFER | RADEON_SURF_SBUFFER)) {
831 /* assume 1 bytes for stencil, we optimize for stencil as stencil
832 * and depth shares surface values
834 tileb = MIN2(surf->tile_split, 64 * surf->nsamples);
836 tileb = MIN2(surf->tile_split, 64 * surf->bpe * surf->nsamples);
839 /* use bankw of 1 to minimize width alignment, might be interesting to
840 * increase it for large surface
855 /* double check the constraint */
856 for (; surf->bankh <= 8; surf->bankh *= 2) {
857 if ((tileb * surf->bankh * surf->bankw) >= surf_man->hw_info.group_bytes) {
862 h_over_w = (((surf->bankh * surf_man->hw_info.num_banks) << 16) /
863 (surf->bankw * surf_man->hw_info.num_pipes)) >> 16;
864 surf->mtilea = 1 << (log2_int(h_over_w) >> 1);
870 /* ===========================================================================
873 struct radeon_surface_manager *radeon_surface_manager_new(int fd)
875 struct radeon_surface_manager *surf_man;
877 surf_man = calloc(1, sizeof(struct radeon_surface_manager));
878 if (surf_man == NULL) {
882 if (radeon_get_value(fd, RADEON_INFO_DEVICE_ID, &surf_man->device_id)) {
885 if (radeon_get_family(surf_man)) {
889 if (surf_man->family <= CHIP_RV740) {
890 if (r6_init_hw_info(surf_man)) {
893 surf_man->surface_init = &r6_surface_init;
894 surf_man->surface_best = &r6_surface_best;
896 if (eg_init_hw_info(surf_man)) {
899 surf_man->surface_init = &eg_surface_init;
900 surf_man->surface_best = &eg_surface_best;
909 void radeon_surface_manager_free(struct radeon_surface_manager *surf_man)
914 static int radeon_surface_sanity(struct radeon_surface_manager *surf_man,
915 struct radeon_surface *surf,
919 if (surf_man == NULL || surf_man->surface_init == NULL || surf == NULL) {
923 /* all dimension must be at least 1 ! */
924 if (!surf->npix_x || !surf->npix_y || !surf->npix_z) {
927 if (!surf->blk_w || !surf->blk_h || !surf->blk_d) {
930 if (!surf->array_size) {
933 /* array size must be a power of 2 */
934 surf->array_size = next_power_of_two(surf->array_size);
936 switch (surf->nsamples) {
947 case RADEON_SURF_TYPE_1D:
948 if (surf->npix_y > 1) {
951 case RADEON_SURF_TYPE_2D:
952 if (surf->npix_z > 1) {
956 case RADEON_SURF_TYPE_CUBEMAP:
957 if (surf->npix_z > 1) {
960 /* deal with cubemap as they were texture array */
961 if (surf_man->family >= CHIP_RV770) {
962 surf->array_size = 8;
964 surf->array_size = 6;
967 case RADEON_SURF_TYPE_3D:
969 case RADEON_SURF_TYPE_1D_ARRAY:
970 if (surf->npix_y > 1) {
973 case RADEON_SURF_TYPE_2D_ARRAY:
981 int radeon_surface_init(struct radeon_surface_manager *surf_man,
982 struct radeon_surface *surf)
987 type = RADEON_SURF_GET(surf->flags, TYPE);
988 mode = RADEON_SURF_GET(surf->flags, MODE);
990 r = radeon_surface_sanity(surf_man, surf, type, mode);
994 return surf_man->surface_init(surf_man, surf);
997 int radeon_surface_best(struct radeon_surface_manager *surf_man,
998 struct radeon_surface *surf)
1000 unsigned mode, type;
1003 type = RADEON_SURF_GET(surf->flags, TYPE);
1004 mode = RADEON_SURF_GET(surf->flags, MODE);
1006 r = radeon_surface_sanity(surf_man, surf, type, mode);
1010 return surf_man->surface_best(surf_man, surf);