Module: Mesa Branch: main Commit: 9d3dbc6400ed1f049ac9532f9e5b0eb91f751d47 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9d3dbc6400ed1f049ac9532f9e5b0eb91f751d47
Author: Konstantin Seurer <[email protected]> Date: Fri Apr 21 11:43:53 2023 +0200 llvmpipe: Add lp_storage_render_image_format_supported Reviewed-by: Dave Airlie <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23515> --- src/gallium/drivers/llvmpipe/lp_screen.c | 55 +++++++++++++++++++------------- src/gallium/drivers/llvmpipe/lp_screen.h | 4 +++ 2 files changed, 37 insertions(+), 22 deletions(-) diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c index 56b515d3d9b..e0940c36d7a 100644 --- a/src/gallium/drivers/llvmpipe/lp_screen.c +++ b/src/gallium/drivers/llvmpipe/lp_screen.c @@ -672,6 +672,37 @@ llvmpipe_get_compiler_options(struct pipe_screen *screen, } +bool +lp_storage_render_image_format_supported(enum pipe_format format) +{ + const struct util_format_description *format_desc = util_format_description(format); + + if (format_desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB) { + /* this is a lie actually other formats COULD exist where we would fail */ + if (format_desc->nr_channels < 3) + return false; + } else if (format_desc->colorspace != UTIL_FORMAT_COLORSPACE_RGB) { + return false; + } + + if (format_desc->layout != UTIL_FORMAT_LAYOUT_PLAIN && + format != PIPE_FORMAT_R11G11B10_FLOAT) + return false; + + assert(format_desc->block.width == 1); + assert(format_desc->block.height == 1); + + if (format_desc->is_mixed) + return false; + + if (!format_desc->is_array && !format_desc->is_bitmask && + format != PIPE_FORMAT_R11G11B10_FLOAT) + return false; + + return true; +} + + bool lp_storage_image_format_supported(enum pipe_format format) { @@ -754,30 +785,10 @@ llvmpipe_is_format_supported(struct pipe_screen *_screen, if (sample_count != 0 && sample_count != 1 && sample_count != 4) return false; - if (bind & (PIPE_BIND_RENDER_TARGET | PIPE_BIND_SHADER_IMAGE)) { - if (format_desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB) { - /* this is a lie actually other formats COULD exist where we would fail */ - if (format_desc->nr_channels < 3) - return false; - } else if (format_desc->colorspace != UTIL_FORMAT_COLORSPACE_RGB) { - return false; - } - - if (format_desc->layout != UTIL_FORMAT_LAYOUT_PLAIN && - format != PIPE_FORMAT_R11G11B10_FLOAT) - return false; - - assert(format_desc->block.width == 1); - assert(format_desc->block.height == 1); - - if (format_desc->is_mixed) + if (bind & (PIPE_BIND_RENDER_TARGET | PIPE_BIND_SHADER_IMAGE)) + if (!lp_storage_render_image_format_supported(format)) return false; - if (!format_desc->is_array && !format_desc->is_bitmask && - format != PIPE_FORMAT_R11G11B10_FLOAT) - return false; - } - if (bind & PIPE_BIND_SHADER_IMAGE) { if (!lp_storage_image_format_supported(format)) return false; diff --git a/src/gallium/drivers/llvmpipe/lp_screen.h b/src/gallium/drivers/llvmpipe/lp_screen.h index 82aeb3dc5f4..0480dfa816f 100644 --- a/src/gallium/drivers/llvmpipe/lp_screen.h +++ b/src/gallium/drivers/llvmpipe/lp_screen.h @@ -107,6 +107,10 @@ lp_get_constant_buffer_stride(struct pipe_screen *_screen) } +bool +lp_storage_render_image_format_supported(enum pipe_format format); + + bool lp_storage_image_format_supported(enum pipe_format format);
