mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 00:49:04 +02:00
radv: add radv_is_colorbuffer_format_blendable()
This will allow us to add a common helper to know if a format is supported by CB. Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29291>
This commit is contained in:
parent
8f39e3a0f3
commit
473559001f
4 changed files with 22 additions and 18 deletions
|
|
@ -2086,9 +2086,8 @@ radv_cmd_clear_image(struct radv_cmd_buffer *cmd_buffer, struct radv_image *imag
|
|||
bool disable_compression = false;
|
||||
|
||||
if (format == VK_FORMAT_E5B9G9R9_UFLOAT_PACK32) {
|
||||
bool blendable;
|
||||
if (cs ? !radv_is_storage_image_format_supported(pdev, format)
|
||||
: !radv_is_colorbuffer_format_supported(pdev, format, &blendable)) {
|
||||
: !radv_is_colorbuffer_format_supported(pdev, format)) {
|
||||
format = VK_FORMAT_R32_UINT;
|
||||
internal_clear_value.color.uint32[0] = float3_to_rgb9e5(clear_value->color.float32);
|
||||
|
||||
|
|
|
|||
|
|
@ -441,20 +441,28 @@ radv_is_buffer_format_supported(VkFormat format, bool *scaled)
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
radv_is_colorbuffer_format_blendable(const struct radv_physical_device *pdev, VkFormat format)
|
||||
{
|
||||
const struct util_format_description *desc = vk_format_description(format);
|
||||
const uint32_t color_format = ac_get_cb_format(pdev->info.gfx_level, desc->format);
|
||||
const uint32_t color_num_format = ac_get_cb_number_type(desc->format);
|
||||
|
||||
assert(color_format != V_028C70_COLOR_INVALID);
|
||||
if (color_num_format == V_028C70_NUMBER_UINT || color_num_format == V_028C70_NUMBER_SINT ||
|
||||
color_format == V_028C70_COLOR_8_24 || color_format == V_028C70_COLOR_24_8 ||
|
||||
color_format == V_028C70_COLOR_X24_8_32_FLOAT)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
radv_is_colorbuffer_format_supported(const struct radv_physical_device *pdev, VkFormat format, bool *blendable)
|
||||
radv_is_colorbuffer_format_supported(const struct radv_physical_device *pdev, VkFormat format)
|
||||
{
|
||||
const struct util_format_description *desc = vk_format_description(format);
|
||||
uint32_t color_format = ac_get_cb_format(pdev->info.gfx_level, desc->format);
|
||||
uint32_t color_swap = ac_translate_colorswap(pdev->info.gfx_level, desc->format, false);
|
||||
uint32_t color_num_format = ac_get_cb_number_type(desc->format);
|
||||
|
||||
if (color_num_format == V_028C70_NUMBER_UINT || color_num_format == V_028C70_NUMBER_SINT ||
|
||||
color_format == V_028C70_COLOR_8_24 || color_format == V_028C70_COLOR_24_8 ||
|
||||
color_format == V_028C70_COLOR_X24_8_32_FLOAT) {
|
||||
*blendable = false;
|
||||
} else
|
||||
*blendable = true;
|
||||
|
||||
return color_format != V_028C70_COLOR_INVALID && color_swap != ~0U;
|
||||
}
|
||||
|
|
@ -578,7 +586,6 @@ radv_physical_device_get_format_properties(struct radv_physical_device *pdev, Vk
|
|||
const struct radv_instance *instance = radv_physical_device_instance(pdev);
|
||||
VkFormatFeatureFlags2 linear = 0, tiled = 0, buffer = 0;
|
||||
const struct util_format_description *desc = vk_format_description(format);
|
||||
bool blendable;
|
||||
bool scaled = false;
|
||||
/* TODO: implement some software emulation of SUBSAMPLED formats. */
|
||||
if (desc->format == PIPE_FORMAT_NONE || desc->layout == UTIL_FORMAT_LAYOUT_SUBSAMPLED) {
|
||||
|
|
@ -706,10 +713,10 @@ radv_physical_device_get_format_properties(struct radv_physical_device *pdev, Vk
|
|||
linear &= ~VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_FILTER_MINMAX_BIT;
|
||||
}
|
||||
}
|
||||
if (radv_is_colorbuffer_format_supported(pdev, format, &blendable) && desc->channel[0].size != 64) {
|
||||
if (radv_is_colorbuffer_format_supported(pdev, format) && desc->channel[0].size != 64) {
|
||||
linear |= VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BIT | VK_FORMAT_FEATURE_2_BLIT_DST_BIT;
|
||||
tiled |= VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BIT | VK_FORMAT_FEATURE_2_BLIT_DST_BIT;
|
||||
if (blendable) {
|
||||
if (radv_is_colorbuffer_format_blendable(pdev, format)) {
|
||||
linear |= VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BLEND_BIT;
|
||||
tiled |= VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BLEND_BIT;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@ bool radv_is_storage_image_format_supported(const struct radv_physical_device *d
|
|||
|
||||
bool radv_is_buffer_format_supported(VkFormat format, bool *scaled);
|
||||
|
||||
bool radv_is_colorbuffer_format_supported(const struct radv_physical_device *pdev, VkFormat format, bool *blendable);
|
||||
bool radv_is_colorbuffer_format_supported(const struct radv_physical_device *pdev, VkFormat format);
|
||||
|
||||
bool radv_is_format_emulated(const struct radv_physical_device *pdev, VkFormat format);
|
||||
|
||||
|
|
|
|||
|
|
@ -178,9 +178,7 @@ bool
|
|||
radv_are_formats_dcc_compatible(const struct radv_physical_device *pdev, const void *pNext, VkFormat format,
|
||||
VkImageCreateFlags flags, bool *sign_reinterpret)
|
||||
{
|
||||
bool blendable;
|
||||
|
||||
if (!radv_is_colorbuffer_format_supported(pdev, format, &blendable))
|
||||
if (!radv_is_colorbuffer_format_supported(pdev, format))
|
||||
return false;
|
||||
|
||||
if (sign_reinterpret != NULL)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue