diff --git a/src/amd/common/ac_formats.c b/src/amd/common/ac_formats.c index 8647cc2ca08..427ab8eb1aa 100644 --- a/src/amd/common/ac_formats.c +++ b/src/amd/common/ac_formats.c @@ -375,6 +375,13 @@ ac_translate_colorswap(enum amd_gfx_level gfx_level, enum pipe_format format, bo return ~0U; } +bool +ac_is_colorbuffer_format_supported(enum amd_gfx_level gfx_level, enum pipe_format format) +{ + return ac_get_cb_format(gfx_level, format) != V_028C70_COLOR_INVALID && + ac_translate_colorswap(gfx_level, format, false) != ~0U; +} + uint32_t ac_colorformat_endian_swap(uint32_t colorformat) { diff --git a/src/amd/common/ac_formats.h b/src/amd/common/ac_formats.h index da033a6ab6c..e11c16a9b7d 100644 --- a/src/amd/common/ac_formats.h +++ b/src/amd/common/ac_formats.h @@ -39,6 +39,10 @@ ac_translate_colorswap(enum amd_gfx_level gfx_level, enum pipe_format format, bool do_endian_swap); +bool +ac_is_colorbuffer_format_supported(enum amd_gfx_level gfx_level, + enum pipe_format format); + uint32_t ac_colorformat_endian_swap(uint32_t colorformat); diff --git a/src/amd/vulkan/radv_formats.c b/src/amd/vulkan/radv_formats.c index 4e9366b4dbf..4a832efc5c5 100644 --- a/src/amd/vulkan/radv_formats.c +++ b/src/amd/vulkan/radv_formats.c @@ -461,10 +461,7 @@ bool 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); - - return color_format != V_028C70_COLOR_INVALID && color_swap != ~0U; + return ac_is_colorbuffer_format_supported(pdev->info.gfx_level, desc->format); } static bool diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c index cbbb2c8ead9..d01a77d97dc 100644 --- a/src/gallium/drivers/radeonsi/si_state.c +++ b/src/gallium/drivers/radeonsi/si_state.c @@ -2456,13 +2456,6 @@ static unsigned si_is_vertex_format_supported(struct pipe_screen *screen, enum p return usage; } -static bool si_is_colorbuffer_format_supported(enum amd_gfx_level gfx_level, - enum pipe_format format) -{ - return ac_get_cb_format(gfx_level, format) != V_028C70_COLOR_INVALID && - ac_translate_colorswap(gfx_level, format, false) != ~0U; -} - static bool si_is_zs_format_supported(enum pipe_format format) { if (format == PIPE_FORMAT_Z16_UNORM_S8_UINT) @@ -2543,7 +2536,7 @@ static bool si_is_format_supported(struct pipe_screen *screen, enum pipe_format if ((usage & (PIPE_BIND_RENDER_TARGET | PIPE_BIND_DISPLAY_TARGET | PIPE_BIND_SCANOUT | PIPE_BIND_SHARED | PIPE_BIND_BLENDABLE)) && - si_is_colorbuffer_format_supported(sscreen->info.gfx_level, format)) { + ac_is_colorbuffer_format_supported(sscreen->info.gfx_level, format)) { retval |= usage & (PIPE_BIND_RENDER_TARGET | PIPE_BIND_DISPLAY_TARGET | PIPE_BIND_SCANOUT | PIPE_BIND_SHARED); if (!util_format_is_pure_integer(format) && !util_format_is_depth_or_stencil(format))