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"
38 #include "r600_formats.h"
40 extern struct u_resource_vtbl r600_texture_vtbl
;
42 /* Copy from a tiled texture to a detiled one. */
43 static void r600_copy_from_tiled_texture(struct pipe_context
*ctx
, struct r600_transfer
*rtransfer
)
45 struct pipe_transfer
*transfer
= (struct pipe_transfer
*)rtransfer
;
46 struct pipe_resource
*texture
= transfer
->resource
;
47 struct pipe_subresource subdst
;
51 ctx
->resource_copy_region(ctx
, rtransfer
->linear_texture
,
52 subdst
, 0, 0, 0, texture
, transfer
->sr
,
53 transfer
->box
.x
, transfer
->box
.y
, transfer
->box
.z
,
54 transfer
->box
.width
, transfer
->box
.height
);
58 /* Copy from a detiled texture to a tiled one. */
59 static void r600_copy_into_tiled_texture(struct pipe_context
*ctx
, struct r600_transfer
*rtransfer
)
61 struct pipe_transfer
*transfer
= (struct pipe_transfer
*)rtransfer
;
62 struct pipe_resource
*texture
= transfer
->resource
;
63 struct pipe_subresource subsrc
;
67 ctx
->resource_copy_region(ctx
, texture
, transfer
->sr
,
68 transfer
->box
.x
, transfer
->box
.y
, transfer
->box
.z
,
69 rtransfer
->linear_texture
, subsrc
,
71 transfer
->box
.width
, transfer
->box
.height
);
73 ctx
->flush(ctx
, 0, NULL
);
76 static unsigned r600_texture_get_offset(struct r600_resource_texture
*rtex
,
77 unsigned level
, unsigned zslice
,
80 unsigned offset
= rtex
->offset
[level
];
82 switch (rtex
->resource
.base
.b
.target
) {
85 return offset
+ zslice
* rtex
->layer_size
[level
];
86 case PIPE_TEXTURE_CUBE
:
88 return offset
+ face
* rtex
->layer_size
[level
];
90 assert(zslice
== 0 && face
== 0);
95 static unsigned r600_texture_get_stride(struct pipe_screen
*screen
,
96 struct r600_resource_texture
*rtex
,
99 struct pipe_resource
*ptex
= &rtex
->resource
.base
.b
;
100 struct radeon
*radeon
= (struct radeon
*)screen
->winsys
;
101 enum chip_class chipc
= r600_get_family_class(radeon
);
102 unsigned width
, stride
;
104 if (rtex
->pitch_override
)
105 return rtex
->pitch_override
;
107 width
= u_minify(ptex
->width0
, level
);
109 stride
= util_format_get_stride(ptex
->format
, align(width
, 64));
110 if (chipc
== EVERGREEN
)
111 stride
= align(stride
, 512);
113 stride
= align(stride
, 256);
117 static unsigned r600_texture_get_nblocksy(struct pipe_screen
*screen
,
118 struct r600_resource_texture
*rtex
,
121 struct pipe_resource
*ptex
= &rtex
->resource
.base
.b
;
124 height
= u_minify(ptex
->height0
, level
);
125 height
= util_next_power_of_two(height
);
126 return util_format_get_nblocksy(ptex
->format
, height
);
129 /* Get a width in pixels from a stride in bytes. */
130 static unsigned pitch_to_width(enum pipe_format format
,
131 unsigned pitch_in_bytes
)
133 return (pitch_in_bytes
/ util_format_get_blocksize(format
)) *
134 util_format_get_blockwidth(format
);
137 static void r600_setup_miptree(struct pipe_screen
*screen
,
138 struct r600_resource_texture
*rtex
)
140 struct pipe_resource
*ptex
= &rtex
->resource
.base
.b
;
141 struct radeon
*radeon
= (struct radeon
*)screen
->winsys
;
142 enum chip_class chipc
= r600_get_family_class(radeon
);
143 unsigned pitch
, size
, layer_size
, i
, offset
;
146 for (i
= 0, offset
= 0; i
<= ptex
->last_level
; i
++) {
147 pitch
= r600_texture_get_stride(screen
, rtex
, i
);
148 nblocksy
= r600_texture_get_nblocksy(screen
, rtex
, i
);
150 layer_size
= pitch
* nblocksy
;
152 if (ptex
->target
== PIPE_TEXTURE_CUBE
) {
154 size
= layer_size
* 8;
156 size
= layer_size
* 6;
159 size
= layer_size
* u_minify(ptex
->depth0
, i
);
160 rtex
->offset
[i
] = offset
;
161 rtex
->layer_size
[i
] = layer_size
;
162 rtex
->pitch_in_bytes
[i
] = pitch
;
163 rtex
->pitch_in_pixels
[i
] = pitch_to_width(ptex
->format
, pitch
);
169 static struct r600_resource_texture
*
170 r600_texture_create_object(struct pipe_screen
*screen
,
171 const struct pipe_resource
*base
,
173 unsigned pitch_in_bytes_override
,
174 unsigned max_buffer_size
,
177 struct r600_resource_texture
*rtex
;
178 struct r600_resource
*resource
;
179 struct radeon
*radeon
= (struct radeon
*)screen
->winsys
;
181 rtex
= CALLOC_STRUCT(r600_resource_texture
);
185 resource
= &rtex
->resource
;
186 resource
->base
.b
= *base
;
187 resource
->base
.vtbl
= &r600_texture_vtbl
;
188 pipe_reference_init(&resource
->base
.b
.reference
, 1);
189 resource
->base
.b
.screen
= screen
;
191 resource
->domain
= r600_domain_from_usage(resource
->base
.b
.bind
);
192 rtex
->pitch_override
= pitch_in_bytes_override
;
193 rtex
->array_mode
= array_mode
;
197 r600_setup_miptree(screen
, rtex
);
199 resource
->size
= rtex
->size
;
202 resource
->bo
= r600_bo(radeon
, rtex
->size
, 4096, 0);
211 struct pipe_resource
*r600_texture_create(struct pipe_screen
*screen
,
212 const struct pipe_resource
*templ
)
214 unsigned array_mode
= 0;
216 return (struct pipe_resource
*)r600_texture_create_object(screen
, templ
, array_mode
,
221 static void r600_texture_destroy(struct pipe_screen
*screen
,
222 struct pipe_resource
*ptex
)
224 struct r600_resource_texture
*rtex
= (struct r600_resource_texture
*)ptex
;
225 struct r600_resource
*resource
= &rtex
->resource
;
226 struct radeon
*radeon
= (struct radeon
*)screen
->winsys
;
228 if (rtex
->flushed_depth_texture
)
229 pipe_resource_reference((struct pipe_resource
**)&rtex
->flushed_depth_texture
, NULL
);
232 r600_bo_reference(radeon
, &resource
->bo
, NULL
);
237 static struct pipe_surface
*r600_get_tex_surface(struct pipe_screen
*screen
,
238 struct pipe_resource
*texture
,
239 unsigned face
, unsigned level
,
240 unsigned zslice
, unsigned flags
)
242 struct r600_resource_texture
*rtex
= (struct r600_resource_texture
*)texture
;
243 struct pipe_surface
*surface
= CALLOC_STRUCT(pipe_surface
);
248 offset
= r600_texture_get_offset(rtex
, level
, zslice
, face
);
249 pipe_reference_init(&surface
->reference
, 1);
250 pipe_resource_reference(&surface
->texture
, texture
);
251 surface
->format
= texture
->format
;
252 surface
->width
= u_minify(texture
->width0
, level
);
253 surface
->height
= u_minify(texture
->height0
, level
);
254 surface
->offset
= offset
;
255 surface
->usage
= flags
;
256 surface
->zslice
= zslice
;
257 surface
->texture
= texture
;
258 surface
->face
= face
;
259 surface
->level
= level
;
263 static void r600_tex_surface_destroy(struct pipe_surface
*surface
)
265 pipe_resource_reference(&surface
->texture
, NULL
);
270 struct pipe_resource
*r600_texture_from_handle(struct pipe_screen
*screen
,
271 const struct pipe_resource
*templ
,
272 struct winsys_handle
*whandle
)
274 struct radeon
*rw
= (struct radeon
*)screen
->winsys
;
275 struct r600_bo
*bo
= NULL
;
276 unsigned array_mode
= 0;
278 /* Support only 2D textures without mipmaps */
279 if ((templ
->target
!= PIPE_TEXTURE_2D
&& templ
->target
!= PIPE_TEXTURE_RECT
) ||
280 templ
->depth0
!= 1 || templ
->last_level
!= 0)
283 bo
= r600_bo_handle(rw
, whandle
->handle
, &array_mode
);
288 return (struct pipe_resource
*)r600_texture_create_object(screen
, templ
, array_mode
,
294 static unsigned int r600_texture_is_referenced(struct pipe_context
*context
,
295 struct pipe_resource
*texture
,
296 unsigned face
, unsigned level
)
299 return PIPE_REFERENCED_FOR_READ
| PIPE_REFERENCED_FOR_WRITE
;
302 int (*r600_blit_uncompress_depth_ptr
)(struct pipe_context
*ctx
, struct r600_resource_texture
*texture
);
304 int r600_texture_depth_flush(struct pipe_context
*ctx
,
305 struct pipe_resource
*texture
)
307 struct r600_resource_texture
*rtex
= (struct r600_resource_texture
*)texture
;
308 struct pipe_resource resource
;
310 if (rtex
->flushed_depth_texture
)
313 resource
.target
= PIPE_TEXTURE_2D
;
314 resource
.format
= texture
->format
;
315 resource
.width0
= texture
->width0
;
316 resource
.height0
= texture
->height0
;
318 resource
.last_level
= 0;
319 resource
.nr_samples
= 0;
320 resource
.usage
= PIPE_USAGE_DYNAMIC
;
324 resource
.bind
|= PIPE_BIND_DEPTH_STENCIL
;
326 rtex
->flushed_depth_texture
= (struct r600_resource_texture
*)ctx
->screen
->resource_create(ctx
->screen
, &resource
);
327 if (rtex
->flushed_depth_texture
== NULL
) {
328 R600_ERR("failed to create temporary texture to hold untiled copy\n");
333 r600_blit_uncompress_depth_ptr(ctx
, rtex
);
337 struct pipe_transfer
* r600_texture_get_transfer(struct pipe_context
*ctx
,
338 struct pipe_resource
*texture
,
339 struct pipe_subresource sr
,
341 const struct pipe_box
*box
)
343 struct r600_resource_texture
*rtex
= (struct r600_resource_texture
*)texture
;
344 struct pipe_resource resource
;
345 struct r600_transfer
*trans
;
348 trans
= CALLOC_STRUCT(r600_transfer
);
351 pipe_resource_reference(&trans
->transfer
.resource
, texture
);
352 trans
->transfer
.sr
= sr
;
353 trans
->transfer
.usage
= usage
;
354 trans
->transfer
.box
= *box
;
356 r
= r600_texture_depth_flush(ctx
, texture
);
358 R600_ERR("failed to create temporary texture to hold untiled copy\n");
359 pipe_resource_reference(&trans
->transfer
.resource
, NULL
);
363 } else if (rtex
->tiled
) {
364 resource
.target
= PIPE_TEXTURE_2D
;
365 resource
.format
= texture
->format
;
366 resource
.width0
= box
->width
;
367 resource
.height0
= box
->height
;
369 resource
.last_level
= 0;
370 resource
.nr_samples
= 0;
371 resource
.usage
= PIPE_USAGE_DYNAMIC
;
374 /* For texture reading, the temporary (detiled) texture is used as
375 * a render target when blitting from a tiled texture. */
376 if (usage
& PIPE_TRANSFER_READ
) {
377 resource
.bind
|= PIPE_BIND_RENDER_TARGET
;
379 /* For texture writing, the temporary texture is used as a sampler
380 * when blitting into a tiled texture. */
381 if (usage
& PIPE_TRANSFER_WRITE
) {
382 resource
.bind
|= PIPE_BIND_SAMPLER_VIEW
;
384 /* Create the temporary texture. */
385 trans
->linear_texture
= ctx
->screen
->resource_create(ctx
->screen
, &resource
);
386 if (trans
->linear_texture
== NULL
) {
387 R600_ERR("failed to create temporary texture to hold untiled copy\n");
388 pipe_resource_reference(&trans
->transfer
.resource
, NULL
);
393 trans
->transfer
.stride
=
394 ((struct r600_resource_texture
*)trans
->linear_texture
)->pitch_in_bytes
[0];
395 if (usage
& PIPE_TRANSFER_READ
) {
396 /* We cannot map a tiled texture directly because the data is
397 * in a different order, therefore we do detiling using a blit. */
398 r600_copy_from_tiled_texture(ctx
, trans
);
399 /* Always referenced in the blit. */
400 ctx
->flush(ctx
, 0, NULL
);
402 return &trans
->transfer
;
404 trans
->transfer
.stride
= rtex
->pitch_in_bytes
[sr
.level
];
405 trans
->offset
= r600_texture_get_offset(rtex
, sr
.level
, box
->z
, sr
.face
);
406 return &trans
->transfer
;
409 void r600_texture_transfer_destroy(struct pipe_context
*ctx
,
410 struct pipe_transfer
*transfer
)
412 struct r600_transfer
*rtransfer
= (struct r600_transfer
*)transfer
;
413 struct r600_resource_texture
*rtex
= (struct r600_resource_texture
*)transfer
->resource
;
415 if (rtransfer
->linear_texture
) {
416 if (transfer
->usage
& PIPE_TRANSFER_WRITE
) {
417 r600_copy_into_tiled_texture(ctx
, rtransfer
);
419 pipe_resource_reference(&rtransfer
->linear_texture
, NULL
);
421 if (rtex
->flushed_depth_texture
) {
422 pipe_resource_reference((struct pipe_resource
**)&rtex
->flushed_depth_texture
, NULL
);
424 pipe_resource_reference(&transfer
->resource
, NULL
);
428 void* r600_texture_transfer_map(struct pipe_context
*ctx
,
429 struct pipe_transfer
* transfer
)
431 struct r600_transfer
*rtransfer
= (struct r600_transfer
*)transfer
;
433 enum pipe_format format
= transfer
->resource
->format
;
434 struct radeon
*radeon
= (struct radeon
*)ctx
->screen
->winsys
;
438 if (rtransfer
->linear_texture
) {
439 bo
= ((struct r600_resource
*)rtransfer
->linear_texture
)->bo
;
441 struct r600_resource_texture
*rtex
= (struct r600_resource_texture
*)transfer
->resource
;
443 if (rtex
->flushed_depth_texture
)
444 bo
= ((struct r600_resource
*)rtex
->flushed_depth_texture
)->bo
;
446 bo
= ((struct r600_resource
*)transfer
->resource
)->bo
;
448 offset
= rtransfer
->offset
+
449 transfer
->box
.y
/ util_format_get_blockheight(format
) * transfer
->stride
+
450 transfer
->box
.x
/ util_format_get_blockwidth(format
) * util_format_get_blocksize(format
);
452 map
= r600_bo_map(radeon
, bo
, 0, ctx
);
460 void r600_texture_transfer_unmap(struct pipe_context
*ctx
,
461 struct pipe_transfer
* transfer
)
463 struct r600_transfer
*rtransfer
= (struct r600_transfer
*)transfer
;
464 struct radeon
*radeon
= (struct radeon
*)ctx
->screen
->winsys
;
467 if (rtransfer
->linear_texture
) {
468 bo
= ((struct r600_resource
*)rtransfer
->linear_texture
)->bo
;
470 struct r600_resource_texture
*rtex
= (struct r600_resource_texture
*)transfer
->resource
;
472 if (rtex
->flushed_depth_texture
) {
473 bo
= ((struct r600_resource
*)rtex
->flushed_depth_texture
)->bo
;
475 bo
= ((struct r600_resource
*)transfer
->resource
)->bo
;
478 r600_bo_unmap(radeon
, bo
);
481 struct u_resource_vtbl r600_texture_vtbl
=
483 u_default_resource_get_handle
, /* get_handle */
484 r600_texture_destroy
, /* resource_destroy */
485 r600_texture_is_referenced
, /* is_resource_referenced */
486 r600_texture_get_transfer
, /* get_transfer */
487 r600_texture_transfer_destroy
, /* transfer_destroy */
488 r600_texture_transfer_map
, /* transfer_map */
489 u_default_transfer_flush_region
,/* transfer_flush_region */
490 r600_texture_transfer_unmap
, /* transfer_unmap */
491 u_default_transfer_inline_write
/* transfer_inline_write */
494 void r600_init_screen_texture_functions(struct pipe_screen
*screen
)
496 screen
->get_tex_surface
= r600_get_tex_surface
;
497 screen
->tex_surface_destroy
= r600_tex_surface_destroy
;
500 static unsigned r600_get_swizzle_combined(const unsigned char *swizzle_format
,
501 const unsigned char *swizzle_view
)
504 unsigned char swizzle
[4];
506 const uint32_t swizzle_shift
[4] = {
509 const uint32_t swizzle_bit
[4] = {
514 /* Combine two sets of swizzles. */
515 for (i
= 0; i
< 4; i
++) {
516 swizzle
[i
] = swizzle_view
[i
] <= UTIL_FORMAT_SWIZZLE_W
?
517 swizzle_format
[swizzle_view
[i
]] : swizzle_view
[i
];
520 memcpy(swizzle
, swizzle_format
, 4);
524 for (i
= 0; i
< 4; i
++) {
525 switch (swizzle
[i
]) {
526 case UTIL_FORMAT_SWIZZLE_Y
:
527 result
|= swizzle_bit
[1] << swizzle_shift
[i
];
529 case UTIL_FORMAT_SWIZZLE_Z
:
530 result
|= swizzle_bit
[2] << swizzle_shift
[i
];
532 case UTIL_FORMAT_SWIZZLE_W
:
533 result
|= swizzle_bit
[3] << swizzle_shift
[i
];
535 case UTIL_FORMAT_SWIZZLE_0
:
536 result
|= V_038010_SQ_SEL_0
<< swizzle_shift
[i
];
538 case UTIL_FORMAT_SWIZZLE_1
:
539 result
|= V_038010_SQ_SEL_1
<< swizzle_shift
[i
];
541 default: /* UTIL_FORMAT_SWIZZLE_X */
542 result
|= swizzle_bit
[0] << swizzle_shift
[i
];
548 /* texture format translate */
549 uint32_t r600_translate_texformat(enum pipe_format format
,
550 const unsigned char *swizzle_view
,
551 uint32_t *word4_p
, uint32_t *yuv_format_p
)
553 uint32_t result
= 0, word4
= 0, yuv_format
= 0;
554 const struct util_format_description
*desc
;
555 boolean uniform
= TRUE
;
557 const uint32_t sign_bit
[4] = {
558 S_038010_FORMAT_COMP_X(V_038010_SQ_FORMAT_COMP_SIGNED
),
559 S_038010_FORMAT_COMP_Y(V_038010_SQ_FORMAT_COMP_SIGNED
),
560 S_038010_FORMAT_COMP_Z(V_038010_SQ_FORMAT_COMP_SIGNED
),
561 S_038010_FORMAT_COMP_W(V_038010_SQ_FORMAT_COMP_SIGNED
)
563 desc
= util_format_description(format
);
565 word4
|= r600_get_swizzle_combined(desc
->swizzle
, swizzle_view
);
567 /* Colorspace (return non-RGB formats directly). */
568 switch (desc
->colorspace
) {
569 /* Depth stencil formats */
570 case UTIL_FORMAT_COLORSPACE_ZS
:
572 case PIPE_FORMAT_Z16_UNORM
:
575 case PIPE_FORMAT_X24S8_USCALED
:
576 word4
|= S_038010_NUM_FORMAT_ALL(V_038010_SQ_NUM_FORMAT_INT
);
577 case PIPE_FORMAT_Z24X8_UNORM
:
578 case PIPE_FORMAT_Z24_UNORM_S8_USCALED
:
581 case PIPE_FORMAT_S8X24_USCALED
:
582 word4
|= S_038010_NUM_FORMAT_ALL(V_038010_SQ_NUM_FORMAT_INT
);
583 case PIPE_FORMAT_X8Z24_UNORM
:
584 case PIPE_FORMAT_S8_USCALED_Z24_UNORM
:
587 case PIPE_FORMAT_S8_USCALED
:
588 result
= V_0280A0_COLOR_8
;
589 word4
|= S_038010_NUM_FORMAT_ALL(V_038010_SQ_NUM_FORMAT_INT
);
595 case UTIL_FORMAT_COLORSPACE_YUV
:
596 yuv_format
|= (1 << 30);
598 case PIPE_FORMAT_UYVY
:
599 case PIPE_FORMAT_YUYV
:
603 goto out_unknown
; /* TODO */
605 case UTIL_FORMAT_COLORSPACE_SRGB
:
606 word4
|= S_038010_FORCE_DEGAMMA(1);
607 if (format
== PIPE_FORMAT_L8A8_SRGB
|| format
== PIPE_FORMAT_L8_SRGB
)
608 goto out_unknown
; /* fails for some reason - TODO */
615 /* S3TC formats. TODO */
616 if (desc
->layout
== UTIL_FORMAT_LAYOUT_S3TC
) {
621 for (i
= 0; i
< desc
->nr_channels
; i
++) {
622 if (desc
->channel
[i
].type
== UTIL_FORMAT_TYPE_SIGNED
) {
623 word4
|= sign_bit
[i
];
627 /* R8G8Bx_SNORM - TODO CxV8U8 */
631 /* See whether the components are of the same size. */
632 for (i
= 1; i
< desc
->nr_channels
; i
++) {
633 uniform
= uniform
&& desc
->channel
[0].size
== desc
->channel
[i
].size
;
636 /* Non-uniform formats. */
638 switch(desc
->nr_channels
) {
640 if (desc
->channel
[0].size
== 5 &&
641 desc
->channel
[1].size
== 6 &&
642 desc
->channel
[2].size
== 5) {
648 if (desc
->channel
[0].size
== 5 &&
649 desc
->channel
[1].size
== 5 &&
650 desc
->channel
[2].size
== 5 &&
651 desc
->channel
[3].size
== 1) {
652 result
= FMT_1_5_5_5
;
655 if (desc
->channel
[0].size
== 10 &&
656 desc
->channel
[1].size
== 10 &&
657 desc
->channel
[2].size
== 10 &&
658 desc
->channel
[3].size
== 2) {
659 result
= FMT_10_10_10_2
;
667 /* Find the first non-VOID channel. */
668 for (i
= 0; i
< 4; i
++) {
669 if (desc
->channel
[i
].type
!= UTIL_FORMAT_TYPE_VOID
) {
677 /* uniform formats */
678 switch (desc
->channel
[i
].type
) {
679 case UTIL_FORMAT_TYPE_UNSIGNED
:
680 case UTIL_FORMAT_TYPE_SIGNED
:
681 if (!desc
->channel
[i
].normalized
&&
682 desc
->colorspace
!= UTIL_FORMAT_COLORSPACE_SRGB
) {
686 switch (desc
->channel
[i
].size
) {
688 switch (desc
->nr_channels
) {
693 result
= FMT_4_4_4_4
;
698 switch (desc
->nr_channels
) {
706 result
= FMT_8_8_8_8
;
711 switch (desc
->nr_channels
) {
719 result
= FMT_16_16_16_16
;
725 case UTIL_FORMAT_TYPE_FLOAT
:
726 switch (desc
->channel
[i
].size
) {
728 switch (desc
->nr_channels
) {
730 result
= FMT_16_FLOAT
;
733 result
= FMT_16_16_FLOAT
;
736 result
= FMT_16_16_16_16_FLOAT
;
741 switch (desc
->nr_channels
) {
743 result
= FMT_32_FLOAT
;
746 result
= FMT_32_32_FLOAT
;
749 result
= FMT_32_32_32_32_FLOAT
;
759 *yuv_format_p
= yuv_format
;
762 // R600_ERR("Unable to handle texformat %d %s\n", format, util_format_name(format));