2 * Copyright © 2014-2017 Broadcom
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 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * 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 NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
27 * Contains the table and accessors for VC5 texture and render target format
30 * The hardware has limited support for texture formats, and extremely limited
31 * support for render target formats. As a result, we emulate other formats
32 * in our shader code, and this stores the table for doing so.
35 #include "util/macros.h"
37 #include "v3d_context.h"
38 #include "v3d_format_table.h"
40 static const struct v3d_format
*
41 get_format(const struct v3d_device_info
*devinfo
, enum pipe_format f
)
43 if (devinfo
->ver
>= 41)
44 return v3d41_get_format_desc(f
);
46 return v3d33_get_format_desc(f
);
50 v3d_rt_format_supported(const struct v3d_device_info
*devinfo
,
53 const struct v3d_format
*vf
= get_format(devinfo
, f
);
58 return vf
->rt_type
!= V3D_OUTPUT_IMAGE_FORMAT_NO
;
62 v3d_get_rt_format(const struct v3d_device_info
*devinfo
, enum pipe_format f
)
64 const struct v3d_format
*vf
= get_format(devinfo
, f
);
73 v3d_tex_format_supported(const struct v3d_device_info
*devinfo
,
76 const struct v3d_format
*vf
= get_format(devinfo
, f
);
82 v3d_get_tex_format(const struct v3d_device_info
*devinfo
, enum pipe_format f
)
84 const struct v3d_format
*vf
= get_format(devinfo
, f
);
93 v3d_get_tex_return_size(const struct v3d_device_info
*devinfo
,
94 enum pipe_format f
, enum pipe_tex_compare compare
)
96 const struct v3d_format
*vf
= get_format(devinfo
, f
);
101 if (compare
== PIPE_TEX_COMPARE_R_TO_TEXTURE
)
104 return vf
->return_size
;
108 v3d_get_tex_return_channels(const struct v3d_device_info
*devinfo
,
111 const struct v3d_format
*vf
= get_format(devinfo
, f
);
116 return vf
->return_channels
;
120 v3d_get_format_swizzle(const struct v3d_device_info
*devinfo
, enum pipe_format f
)
122 const struct v3d_format
*vf
= get_format(devinfo
, f
);
123 static const uint8_t fallback
[] = {0, 1, 2, 3};
132 v3d_get_internal_type_bpp_for_output_format(const struct v3d_device_info
*devinfo
,
137 if (devinfo
->ver
>= 41) {
138 return v3d41_get_internal_type_bpp_for_output_format(format
,
141 return v3d33_get_internal_type_bpp_for_output_format(format
,
147 v3d_tfu_supports_tex_format(const struct v3d_device_info
*devinfo
,
150 if (devinfo
->ver
>= 41) {
151 return v3d41_tfu_supports_tex_format(tex_format
);
153 return v3d33_tfu_supports_tex_format(tex_format
);