#include "util/u_math.h"
#include "pipe/p_defines.h"
+#include "pipe/p_screen.h"
boolean
return format;
}
}
+
+bool
+util_format_planar_is_supported(struct pipe_screen *screen,
+ enum pipe_format format,
+ enum pipe_texture_target target,
+ unsigned sample_count,
+ unsigned storage_sample_count,
+ unsigned bind)
+{
+ unsigned num_planes = util_format_get_num_planes(format);
+ assert(num_planes >= 2);
+
+ for (unsigned i = 0; i < num_planes; i++) {
+ if (!screen->is_format_supported(screen,
+ util_format_get_plane_format(format, i),
+ target, sample_count,
+ storage_sample_count, bind))
+ return false;
+ }
+
+ return true;
+}
# A.k.a. D3DDECLTYPE_DEC3N
PIPE_FORMAT_R10G10B10X2_SNORM , plain, 1, 1, 1, sn10, sn10, sn10 , x2 , xyz1, rgb, x2 , sn10, sn10, sn10, wzy1
-PIPE_FORMAT_YV12 , other, 1, 1, 1, x8 , x8 , x8 , x8 , xyzw, yuv
-PIPE_FORMAT_YV16 , other, 1, 1, 1, x8 , x8 , x8 , x8 , xyzw, yuv
-PIPE_FORMAT_IYUV , other, 1, 1, 1, x8 , x8 , x8 , x8 , xyzw, yuv
-PIPE_FORMAT_NV12 , other, 1, 1, 1, x8 , x8 , x8 , x8 , xyzw, yuv
-PIPE_FORMAT_NV21 , other, 1, 1, 1, x8 , x8 , x8 , x8 , xyzw, yuv
+PIPE_FORMAT_YV12 , planar3, 1, 1, 1, , , , , xyzw, yuv
+PIPE_FORMAT_YV16 , planar3, 1, 1, 1, , , , , xyzw, yuv
+PIPE_FORMAT_IYUV , planar3, 1, 1, 1, , , , , xyzw, yuv
+PIPE_FORMAT_NV12 , planar2, 1, 1, 1, , , , , xyzw, yuv
+PIPE_FORMAT_NV21 , planar2, 1, 1, 1, , , , , xyzw, yuv
-PIPE_FORMAT_P016 , other, 1, 1, 1, x16 , x16 , , , xyzw, yuv
+PIPE_FORMAT_P016 , planar2, 1, 1, 1, , , , , xyzw, yuv
# Usually used to implement IA44 and AI44 formats in video decoding
PIPE_FORMAT_A4R4_UNORM , plain, 1, 1, 1, un4 , un4 , , , y00x, rgb, un4, un4 , , , x00y
#include "util/u_debug.h"
union pipe_color_union;
+struct pipe_screen;
#ifdef __cplusplus
UTIL_FORMAT_LAYOUT_ATC,
+ /** Formats with 2 or more planes. */
+ UTIL_FORMAT_LAYOUT_PLANAR2,
+ UTIL_FORMAT_LAYOUT_PLANAR3,
+
/**
* Everything else that doesn't fit in any of the above layouts.
*/
}
}
+static inline unsigned
+util_format_get_num_planes(enum pipe_format format)
+{
+ switch (util_format_description(format)->layout) {
+ case UTIL_FORMAT_LAYOUT_PLANAR3:
+ return 3;
+ case UTIL_FORMAT_LAYOUT_PLANAR2:
+ return 2;
+ default:
+ return 1;
+ }
+}
+
+static inline enum pipe_format
+util_format_get_plane_format(enum pipe_format format, unsigned plane)
+{
+ switch (format) {
+ case PIPE_FORMAT_YV12:
+ case PIPE_FORMAT_YV16:
+ case PIPE_FORMAT_IYUV:
+ return PIPE_FORMAT_R8_UNORM;
+ case PIPE_FORMAT_NV12:
+ return !plane ? PIPE_FORMAT_R8_UNORM : PIPE_FORMAT_RG88_UNORM;
+ case PIPE_FORMAT_NV21:
+ return !plane ? PIPE_FORMAT_R8_UNORM : PIPE_FORMAT_GR88_UNORM;
+ case PIPE_FORMAT_P016:
+ return !plane ? PIPE_FORMAT_R16_UNORM : PIPE_FORMAT_R16G16_UNORM;
+ default:
+ return format;
+ }
+}
+
+static inline unsigned
+util_format_get_plane_width(enum pipe_format format, unsigned plane,
+ unsigned width)
+{
+ switch (format) {
+ case PIPE_FORMAT_YV12:
+ case PIPE_FORMAT_YV16:
+ case PIPE_FORMAT_IYUV:
+ case PIPE_FORMAT_NV12:
+ case PIPE_FORMAT_NV21:
+ case PIPE_FORMAT_P016:
+ return !plane ? width : (width + 1) / 2;
+ default:
+ return width;
+ }
+}
+
+static inline unsigned
+util_format_get_plane_height(enum pipe_format format, unsigned plane,
+ unsigned height)
+{
+ switch (format) {
+ case PIPE_FORMAT_YV12:
+ case PIPE_FORMAT_IYUV:
+ case PIPE_FORMAT_NV12:
+ case PIPE_FORMAT_NV21:
+ case PIPE_FORMAT_P016:
+ return !plane ? height : (height + 1) / 2;
+ case PIPE_FORMAT_YV16:
+ default:
+ return height;
+ }
+}
+
+bool util_format_planar_is_supported(struct pipe_screen *screen,
+ enum pipe_format format,
+ enum pipe_texture_target target,
+ unsigned sample_count,
+ unsigned storage_sample_count,
+ unsigned bind);
+
/**
* Return the number of components stored.
* Formats with block size != 1x1 will always have 1 component (the block).