2 * Copyright 2010 Jerome Glisse <glisse@freedesktop.org>
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * on the rights to use, copy, modify, merge, publish, distribute, sub
8 * license, and/or sell copies of the Software, and to permit persons to whom
9 * the Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21 * USE OR OTHER DEALINGS IN THE SOFTWARE.
28 #include <pipe/p_screen.h>
29 #include <util/u_format.h>
30 #include <util/u_math.h>
31 #include <util/u_inlines.h>
32 #include <util/u_memory.h>
33 #include "state_tracker/drm_driver.h"
34 #include "r600_pipe.h"
35 #include "r600_resource.h"
36 #include "r600_state_inlines.h"
39 extern struct u_resource_vtbl r600_texture_vtbl
;
41 /* Copy from a tiled texture to a detiled one. */
42 static void r600_copy_from_tiled_texture(struct pipe_context
*ctx
, struct r600_transfer
*rtransfer
)
44 struct pipe_transfer
*transfer
= (struct pipe_transfer
*)rtransfer
;
45 struct pipe_resource
*texture
= transfer
->resource
;
46 struct pipe_subresource subdst
;
50 ctx
->resource_copy_region(ctx
, rtransfer
->linear_texture
,
51 subdst
, 0, 0, 0, texture
, transfer
->sr
,
52 transfer
->box
.x
, transfer
->box
.y
, transfer
->box
.z
,
53 transfer
->box
.width
, transfer
->box
.height
);
57 /* Copy from a detiled texture to a tiled one. */
58 static void r600_copy_into_tiled_texture(struct pipe_context
*ctx
, struct r600_transfer
*rtransfer
)
60 struct pipe_transfer
*transfer
= (struct pipe_transfer
*)rtransfer
;
61 struct pipe_resource
*texture
= transfer
->resource
;
62 struct pipe_subresource subsrc
;
66 ctx
->resource_copy_region(ctx
, texture
, transfer
->sr
,
67 transfer
->box
.x
, transfer
->box
.y
, transfer
->box
.z
,
68 rtransfer
->linear_texture
, subsrc
,
70 transfer
->box
.width
, transfer
->box
.height
);
72 ctx
->flush(ctx
, 0, NULL
);
75 static unsigned r600_texture_get_offset(struct r600_resource_texture
*rtex
,
76 unsigned level
, unsigned zslice
,
79 unsigned offset
= rtex
->offset
[level
];
81 switch (rtex
->resource
.base
.b
.target
) {
84 return offset
+ zslice
* rtex
->layer_size
[level
];
85 case PIPE_TEXTURE_CUBE
:
87 return offset
+ face
* rtex
->layer_size
[level
];
89 assert(zslice
== 0 && face
== 0);
94 static unsigned r600_texture_get_stride(struct pipe_screen
*screen
,
95 struct r600_resource_texture
*rtex
,
98 struct pipe_resource
*ptex
= &rtex
->resource
.base
.b
;
99 struct radeon
*radeon
= (struct radeon
*)screen
->winsys
;
100 enum chip_class chipc
= r600_get_family_class(radeon
);
101 unsigned width
, stride
;
103 if (rtex
->pitch_override
)
104 return rtex
->pitch_override
;
106 width
= u_minify(ptex
->width0
, level
);
108 stride
= util_format_get_stride(ptex
->format
, align(width
, 64));
109 if (chipc
== EVERGREEN
)
110 stride
= align(stride
, 512);
112 stride
= align(stride
, 256);
116 static unsigned r600_texture_get_nblocksy(struct pipe_screen
*screen
,
117 struct r600_resource_texture
*rtex
,
120 struct pipe_resource
*ptex
= &rtex
->resource
.base
.b
;
123 height
= u_minify(ptex
->height0
, level
);
124 height
= util_next_power_of_two(height
);
125 return util_format_get_nblocksy(ptex
->format
, height
);
128 /* Get a width in pixels from a stride in bytes. */
129 static unsigned pitch_to_width(enum pipe_format format
,
130 unsigned pitch_in_bytes
)
132 return (pitch_in_bytes
/ util_format_get_blocksize(format
)) *
133 util_format_get_blockwidth(format
);
136 static void r600_setup_miptree(struct pipe_screen
*screen
,
137 struct r600_resource_texture
*rtex
)
139 struct pipe_resource
*ptex
= &rtex
->resource
.base
.b
;
140 struct radeon
*radeon
= (struct radeon
*)screen
->winsys
;
141 enum chip_class chipc
= r600_get_family_class(radeon
);
142 unsigned pitch
, size
, layer_size
, i
, offset
;
145 for (i
= 0, offset
= 0; i
<= ptex
->last_level
; i
++) {
146 pitch
= r600_texture_get_stride(screen
, rtex
, i
);
147 nblocksy
= r600_texture_get_nblocksy(screen
, rtex
, i
);
149 layer_size
= pitch
* nblocksy
;
151 if (ptex
->target
== PIPE_TEXTURE_CUBE
) {
153 size
= layer_size
* 8;
155 size
= layer_size
* 6;
158 size
= layer_size
* u_minify(ptex
->depth0
, i
);
159 rtex
->offset
[i
] = offset
;
160 rtex
->layer_size
[i
] = layer_size
;
161 rtex
->pitch_in_bytes
[i
] = pitch
;
162 rtex
->pitch_in_pixels
[i
] = pitch_to_width(ptex
->format
, pitch
);
168 static struct r600_resource_texture
*
169 r600_texture_create_object(struct pipe_screen
*screen
,
170 const struct pipe_resource
*base
,
172 unsigned pitch_in_bytes_override
,
173 unsigned max_buffer_size
,
176 struct r600_resource_texture
*rtex
;
177 struct r600_resource
*resource
;
178 struct radeon
*radeon
= (struct radeon
*)screen
->winsys
;
180 rtex
= CALLOC_STRUCT(r600_resource_texture
);
184 resource
= &rtex
->resource
;
185 resource
->base
.b
= *base
;
186 resource
->base
.vtbl
= &r600_texture_vtbl
;
187 pipe_reference_init(&resource
->base
.b
.reference
, 1);
188 resource
->base
.b
.screen
= screen
;
190 resource
->domain
= r600_domain_from_usage(resource
->base
.b
.bind
);
191 rtex
->pitch_override
= pitch_in_bytes_override
;
192 rtex
->array_mode
= array_mode
;
194 r600_setup_miptree(screen
, rtex
);
196 resource
->size
= rtex
->size
;
199 resource
->bo
= r600_bo(radeon
, rtex
->size
, 4096, 0);
208 struct pipe_resource
*r600_texture_create(struct pipe_screen
*screen
,
209 const struct pipe_resource
*templ
)
211 unsigned array_mode
= 0;
213 return (struct pipe_resource
*)r600_texture_create_object(screen
, templ
, array_mode
,
218 static void r600_texture_destroy(struct pipe_screen
*screen
,
219 struct pipe_resource
*ptex
)
221 struct r600_resource_texture
*rtex
= (struct r600_resource_texture
*)ptex
;
222 struct r600_resource
*resource
= &rtex
->resource
;
223 struct radeon
*radeon
= (struct radeon
*)screen
->winsys
;
225 if (rtex
->flushed_depth_texture
)
226 pipe_resource_reference((struct pipe_resource
**)&rtex
->flushed_depth_texture
, NULL
);
229 r600_bo_reference(radeon
, &resource
->bo
, NULL
);
234 static struct pipe_surface
*r600_get_tex_surface(struct pipe_screen
*screen
,
235 struct pipe_resource
*texture
,
236 unsigned face
, unsigned level
,
237 unsigned zslice
, unsigned flags
)
239 struct r600_resource_texture
*rtex
= (struct r600_resource_texture
*)texture
;
240 struct pipe_surface
*surface
= CALLOC_STRUCT(pipe_surface
);
245 offset
= r600_texture_get_offset(rtex
, level
, zslice
, face
);
246 pipe_reference_init(&surface
->reference
, 1);
247 pipe_resource_reference(&surface
->texture
, texture
);
248 surface
->format
= texture
->format
;
249 surface
->width
= u_minify(texture
->width0
, level
);
250 surface
->height
= u_minify(texture
->height0
, level
);
251 surface
->offset
= offset
;
252 surface
->usage
= flags
;
253 surface
->zslice
= zslice
;
254 surface
->texture
= texture
;
255 surface
->face
= face
;
256 surface
->level
= level
;
260 static void r600_tex_surface_destroy(struct pipe_surface
*surface
)
262 pipe_resource_reference(&surface
->texture
, NULL
);
267 struct pipe_resource
*r600_texture_from_handle(struct pipe_screen
*screen
,
268 const struct pipe_resource
*templ
,
269 struct winsys_handle
*whandle
)
271 struct radeon
*rw
= (struct radeon
*)screen
->winsys
;
272 struct r600_bo
*bo
= NULL
;
274 /* Support only 2D textures without mipmaps */
275 if ((templ
->target
!= PIPE_TEXTURE_2D
&& templ
->target
!= PIPE_TEXTURE_RECT
) ||
276 templ
->depth0
!= 1 || templ
->last_level
!= 0)
279 bo
= r600_bo_handle(rw
, whandle
->handle
);
284 return (struct pipe_resource
*)r600_texture_create_object(screen
, templ
, 0,
290 static unsigned int r600_texture_is_referenced(struct pipe_context
*context
,
291 struct pipe_resource
*texture
,
292 unsigned face
, unsigned level
)
295 return PIPE_REFERENCED_FOR_READ
| PIPE_REFERENCED_FOR_WRITE
;
298 int (*r600_blit_uncompress_depth_ptr
)(struct pipe_context
*ctx
, struct r600_resource_texture
*texture
);
300 int r600_texture_depth_flush(struct pipe_context
*ctx
,
301 struct pipe_resource
*texture
)
303 struct r600_resource_texture
*rtex
= (struct r600_resource_texture
*)texture
;
304 struct pipe_resource resource
;
306 if (rtex
->flushed_depth_texture
)
309 resource
.target
= PIPE_TEXTURE_2D
;
310 resource
.format
= texture
->format
;
311 resource
.width0
= texture
->width0
;
312 resource
.height0
= texture
->height0
;
314 resource
.last_level
= 0;
315 resource
.nr_samples
= 0;
316 resource
.usage
= PIPE_USAGE_DYNAMIC
;
320 resource
.bind
|= PIPE_BIND_RENDER_TARGET
;
322 rtex
->flushed_depth_texture
= (struct r600_resource_texture
*)ctx
->screen
->resource_create(ctx
->screen
, &resource
);
323 if (rtex
->flushed_depth_texture
== NULL
) {
324 R600_ERR("failed to create temporary texture to hold untiled copy\n");
329 r600_blit_uncompress_depth_ptr(ctx
, rtex
);
333 struct pipe_transfer
* r600_texture_get_transfer(struct pipe_context
*ctx
,
334 struct pipe_resource
*texture
,
335 struct pipe_subresource sr
,
337 const struct pipe_box
*box
)
339 struct r600_resource_texture
*rtex
= (struct r600_resource_texture
*)texture
;
340 struct pipe_resource resource
;
341 struct r600_transfer
*trans
;
344 trans
= CALLOC_STRUCT(r600_transfer
);
347 pipe_resource_reference(&trans
->transfer
.resource
, texture
);
348 trans
->transfer
.sr
= sr
;
349 trans
->transfer
.usage
= usage
;
350 trans
->transfer
.box
= *box
;
351 trans
->transfer
.stride
= rtex
->pitch_in_bytes
[sr
.level
];
352 trans
->offset
= r600_texture_get_offset(rtex
, sr
.level
, box
->z
, sr
.face
);
354 r
= r600_texture_depth_flush(ctx
, texture
);
356 R600_ERR("failed to create temporary texture to hold untiled copy\n");
357 pipe_resource_reference(&trans
->transfer
.resource
, NULL
);
361 } else if (rtex
->tiled
) {
362 resource
.target
= PIPE_TEXTURE_2D
;
363 resource
.format
= texture
->format
;
364 resource
.width0
= box
->width
;
365 resource
.height0
= box
->height
;
367 resource
.last_level
= 0;
368 resource
.nr_samples
= 0;
369 resource
.usage
= PIPE_USAGE_DYNAMIC
;
372 /* For texture reading, the temporary (detiled) texture is used as
373 * a render target when blitting from a tiled texture. */
374 if (usage
& PIPE_TRANSFER_READ
) {
375 resource
.bind
|= PIPE_BIND_RENDER_TARGET
;
377 /* For texture writing, the temporary texture is used as a sampler
378 * when blitting into a tiled texture. */
379 if (usage
& PIPE_TRANSFER_WRITE
) {
380 resource
.bind
|= PIPE_BIND_SAMPLER_VIEW
;
382 /* Create the temporary texture. */
383 trans
->linear_texture
= ctx
->screen
->resource_create(ctx
->screen
, &resource
);
384 if (trans
->linear_texture
== NULL
) {
385 R600_ERR("failed to create temporary texture to hold untiled copy\n");
386 pipe_resource_reference(&trans
->transfer
.resource
, NULL
);
391 trans
->transfer
.stride
=
392 ((struct r600_resource_texture
*)trans
->linear_texture
)->pitch_in_bytes
[0];
393 if (usage
& PIPE_TRANSFER_READ
) {
394 /* We cannot map a tiled texture directly because the data is
395 * in a different order, therefore we do detiling using a blit. */
396 r600_copy_from_tiled_texture(ctx
, trans
);
397 /* Always referenced in the blit. */
398 ctx
->flush(ctx
, 0, NULL
);
401 return &trans
->transfer
;
404 void r600_texture_transfer_destroy(struct pipe_context
*ctx
,
405 struct pipe_transfer
*transfer
)
407 struct r600_transfer
*rtransfer
= (struct r600_transfer
*)transfer
;
408 struct r600_resource_texture
*rtex
= (struct r600_resource_texture
*)transfer
->resource
;
410 if (rtransfer
->linear_texture
) {
411 if (transfer
->usage
& PIPE_TRANSFER_WRITE
) {
412 r600_copy_into_tiled_texture(ctx
, rtransfer
);
414 pipe_resource_reference(&rtransfer
->linear_texture
, NULL
);
416 if (rtex
->flushed_depth_texture
) {
417 pipe_resource_reference((struct pipe_resource
**)&rtex
->flushed_depth_texture
, NULL
);
419 pipe_resource_reference(&transfer
->resource
, NULL
);
423 void* r600_texture_transfer_map(struct pipe_context
*ctx
,
424 struct pipe_transfer
* transfer
)
426 struct r600_transfer
*rtransfer
= (struct r600_transfer
*)transfer
;
428 enum pipe_format format
= transfer
->resource
->format
;
429 struct radeon
*radeon
= (struct radeon
*)ctx
->screen
->winsys
;
433 if (rtransfer
->linear_texture
) {
434 bo
= ((struct r600_resource
*)rtransfer
->linear_texture
)->bo
;
436 struct r600_resource_texture
*rtex
= (struct r600_resource_texture
*)transfer
->resource
;
438 if (rtex
->flushed_depth_texture
)
439 bo
= ((struct r600_resource
*)rtex
->flushed_depth_texture
)->bo
;
441 bo
= ((struct r600_resource
*)transfer
->resource
)->bo
;
443 offset
= rtransfer
->offset
+
444 transfer
->box
.y
/ util_format_get_blockheight(format
) * transfer
->stride
+
445 transfer
->box
.x
/ util_format_get_blockwidth(format
) * util_format_get_blocksize(format
);
447 map
= r600_bo_map(radeon
, bo
, 0, ctx
);
455 void r600_texture_transfer_unmap(struct pipe_context
*ctx
,
456 struct pipe_transfer
* transfer
)
458 struct r600_transfer
*rtransfer
= (struct r600_transfer
*)transfer
;
459 struct radeon
*radeon
= (struct radeon
*)ctx
->screen
->winsys
;
462 if (rtransfer
->linear_texture
) {
463 bo
= ((struct r600_resource
*)rtransfer
->linear_texture
)->bo
;
465 struct r600_resource_texture
*rtex
= (struct r600_resource_texture
*)transfer
->resource
;
467 if (rtex
->flushed_depth_texture
) {
468 bo
= ((struct r600_resource
*)rtex
->flushed_depth_texture
)->bo
;
470 bo
= ((struct r600_resource
*)transfer
->resource
)->bo
;
473 r600_bo_unmap(radeon
, bo
);
476 struct u_resource_vtbl r600_texture_vtbl
=
478 u_default_resource_get_handle
, /* get_handle */
479 r600_texture_destroy
, /* resource_destroy */
480 r600_texture_is_referenced
, /* is_resource_referenced */
481 r600_texture_get_transfer
, /* get_transfer */
482 r600_texture_transfer_destroy
, /* transfer_destroy */
483 r600_texture_transfer_map
, /* transfer_map */
484 u_default_transfer_flush_region
,/* transfer_flush_region */
485 r600_texture_transfer_unmap
, /* transfer_unmap */
486 u_default_transfer_inline_write
/* transfer_inline_write */
489 void r600_init_screen_texture_functions(struct pipe_screen
*screen
)
491 screen
->get_tex_surface
= r600_get_tex_surface
;
492 screen
->tex_surface_destroy
= r600_tex_surface_destroy
;
495 static unsigned r600_get_swizzle_combined(const unsigned char *swizzle_format
,
496 const unsigned char *swizzle_view
)
499 unsigned char swizzle
[4];
501 const uint32_t swizzle_shift
[4] = {
504 const uint32_t swizzle_bit
[4] = {
509 /* Combine two sets of swizzles. */
510 for (i
= 0; i
< 4; i
++) {
511 swizzle
[i
] = swizzle_view
[i
] <= UTIL_FORMAT_SWIZZLE_W
?
512 swizzle_format
[swizzle_view
[i
]] : swizzle_view
[i
];
515 memcpy(swizzle
, swizzle_format
, 4);
519 for (i
= 0; i
< 4; i
++) {
520 switch (swizzle
[i
]) {
521 case UTIL_FORMAT_SWIZZLE_Y
:
522 result
|= swizzle_bit
[1] << swizzle_shift
[i
];
524 case UTIL_FORMAT_SWIZZLE_Z
:
525 result
|= swizzle_bit
[2] << swizzle_shift
[i
];
527 case UTIL_FORMAT_SWIZZLE_W
:
528 result
|= swizzle_bit
[3] << swizzle_shift
[i
];
530 case UTIL_FORMAT_SWIZZLE_0
:
531 result
|= V_038010_SQ_SEL_0
<< swizzle_shift
[i
];
533 case UTIL_FORMAT_SWIZZLE_1
:
534 result
|= V_038010_SQ_SEL_1
<< swizzle_shift
[i
];
536 default: /* UTIL_FORMAT_SWIZZLE_X */
537 result
|= swizzle_bit
[0] << swizzle_shift
[i
];
543 /* texture format translate */
544 uint32_t r600_translate_texformat(enum pipe_format format
,
545 const unsigned char *swizzle_view
,
546 uint32_t *word4_p
, uint32_t *yuv_format_p
)
548 uint32_t result
= 0, word4
= 0, yuv_format
= 0;
549 const struct util_format_description
*desc
;
550 boolean uniform
= TRUE
;
552 const uint32_t sign_bit
[4] = {
553 S_038010_FORMAT_COMP_X(V_038010_SQ_FORMAT_COMP_SIGNED
),
554 S_038010_FORMAT_COMP_Y(V_038010_SQ_FORMAT_COMP_SIGNED
),
555 S_038010_FORMAT_COMP_Z(V_038010_SQ_FORMAT_COMP_SIGNED
),
556 S_038010_FORMAT_COMP_W(V_038010_SQ_FORMAT_COMP_SIGNED
)
558 desc
= util_format_description(format
);
560 word4
|= r600_get_swizzle_combined(desc
->swizzle
, swizzle_view
);
562 /* Colorspace (return non-RGB formats directly). */
563 switch (desc
->colorspace
) {
564 /* Depth stencil formats */
565 case UTIL_FORMAT_COLORSPACE_ZS
:
567 case PIPE_FORMAT_Z16_UNORM
:
568 result
= V_0280A0_COLOR_16
;
570 case PIPE_FORMAT_X24S8_USCALED
:
571 word4
|= S_038010_NUM_FORMAT_ALL(V_038010_SQ_NUM_FORMAT_INT
);
572 case PIPE_FORMAT_Z24X8_UNORM
:
573 case PIPE_FORMAT_Z24_UNORM_S8_USCALED
:
574 result
= V_0280A0_COLOR_8_24
;
576 case PIPE_FORMAT_S8X24_USCALED
:
577 word4
|= S_038010_NUM_FORMAT_ALL(V_038010_SQ_NUM_FORMAT_INT
);
578 case PIPE_FORMAT_X8Z24_UNORM
:
579 case PIPE_FORMAT_S8_USCALED_Z24_UNORM
:
580 result
= V_0280A0_COLOR_24_8
;
582 case PIPE_FORMAT_S8_USCALED
:
583 result
= V_0280A0_COLOR_8
;
584 word4
|= S_038010_NUM_FORMAT_ALL(V_038010_SQ_NUM_FORMAT_INT
);
590 case UTIL_FORMAT_COLORSPACE_YUV
:
591 yuv_format
|= (1 << 30);
593 case PIPE_FORMAT_UYVY
:
594 case PIPE_FORMAT_YUYV
:
598 goto out_unknown
; /* TODO */
600 case UTIL_FORMAT_COLORSPACE_SRGB
:
601 word4
|= S_038010_FORCE_DEGAMMA(1);
602 if (format
== PIPE_FORMAT_L8A8_SRGB
|| format
== PIPE_FORMAT_L8_SRGB
)
603 goto out_unknown
; /* fails for some reason - TODO */
610 /* S3TC formats. TODO */
611 if (desc
->layout
== UTIL_FORMAT_LAYOUT_S3TC
) {
616 for (i
= 0; i
< desc
->nr_channels
; i
++) {
617 if (desc
->channel
[i
].type
== UTIL_FORMAT_TYPE_SIGNED
) {
618 word4
|= sign_bit
[i
];
622 /* R8G8Bx_SNORM - TODO CxV8U8 */
626 /* See whether the components are of the same size. */
627 for (i
= 1; i
< desc
->nr_channels
; i
++) {
628 uniform
= uniform
&& desc
->channel
[0].size
== desc
->channel
[i
].size
;
631 /* Non-uniform formats. */
633 switch(desc
->nr_channels
) {
635 if (desc
->channel
[0].size
== 5 &&
636 desc
->channel
[1].size
== 6 &&
637 desc
->channel
[2].size
== 5) {
638 result
= V_0280A0_COLOR_5_6_5
;
643 if (desc
->channel
[0].size
== 5 &&
644 desc
->channel
[1].size
== 5 &&
645 desc
->channel
[2].size
== 5 &&
646 desc
->channel
[3].size
== 1) {
647 result
= V_0280A0_COLOR_1_5_5_5
;
650 if (desc
->channel
[0].size
== 10 &&
651 desc
->channel
[1].size
== 10 &&
652 desc
->channel
[2].size
== 10 &&
653 desc
->channel
[3].size
== 2) {
654 result
= V_0280A0_COLOR_10_10_10_2
;
662 /* Find the first non-VOID channel. */
663 for (i
= 0; i
< 4; i
++) {
664 if (desc
->channel
[i
].type
!= UTIL_FORMAT_TYPE_VOID
) {
672 /* uniform formats */
673 switch (desc
->channel
[i
].type
) {
674 case UTIL_FORMAT_TYPE_UNSIGNED
:
675 case UTIL_FORMAT_TYPE_SIGNED
:
676 if (!desc
->channel
[i
].normalized
&&
677 desc
->colorspace
!= UTIL_FORMAT_COLORSPACE_SRGB
) {
681 switch (desc
->channel
[i
].size
) {
683 switch (desc
->nr_channels
) {
685 result
= V_0280A0_COLOR_4_4
;
688 result
= V_0280A0_COLOR_4_4_4_4
;
693 switch (desc
->nr_channels
) {
695 result
= V_0280A0_COLOR_8
;
698 result
= V_0280A0_COLOR_8_8
;
701 result
= V_0280A0_COLOR_8_8_8_8
;
706 switch (desc
->nr_channels
) {
708 result
= V_0280A0_COLOR_16
;
711 result
= V_0280A0_COLOR_16_16
;
714 result
= V_0280A0_COLOR_16_16_16_16
;
720 case UTIL_FORMAT_TYPE_FLOAT
:
721 switch (desc
->channel
[i
].size
) {
723 switch (desc
->nr_channels
) {
725 result
= V_0280A0_COLOR_16_FLOAT
;
728 result
= V_0280A0_COLOR_16_16_FLOAT
;
731 result
= V_0280A0_COLOR_16_16_16_16_FLOAT
;
736 switch (desc
->nr_channels
) {
738 result
= V_0280A0_COLOR_32_FLOAT
;
741 result
= V_0280A0_COLOR_32_32_FLOAT
;
744 result
= V_0280A0_COLOR_32_32_32_32_FLOAT
;
754 *yuv_format_p
= yuv_format
;
757 // R600_ERR("Unable to handle texformat %d %s\n", format, util_format_name(format));