From 77db3e99ddc3ec8870b2a6dcf23fa9459cefa4b6 Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Mon, 30 Jan 2023 20:11:54 -0600 Subject: [PATCH] nil: Add more format support helpers Part-of: --- src/nouveau/nil/nil_format.c | 66 ++++++++++++++++++++++++++++++++++++++++++++ src/nouveau/nil/nil_format.h | 18 ++++++++++++ 2 files changed, 84 insertions(+) diff --git a/src/nouveau/nil/nil_format.c b/src/nouveau/nil/nil_format.c index 529617f..17df593 100644 --- a/src/nouveau/nil/nil_format.c +++ b/src/nouveau/nil/nil_format.c @@ -1,7 +1,10 @@ #include "nil_format.h" +#include "nouveau_device.h" + #include "cl9097.h" #include "cl9097tex.h" +#include "cla297.h" #include "clb097tex.h" enum nil_format_support_flags { @@ -352,6 +355,51 @@ static const struct nil_format_info nil_format_infos[PIPE_FORMAT_COUNT] = }; bool +nil_format_supports_texturing(struct nouveau_ws_device *dev, + enum pipe_format format) +{ + assert(format < PIPE_FORMAT_COUNT); + const struct nil_format_info *fmt = &nil_format_infos[format]; + if (!(fmt->support & NIL_FORMAT_SUPPORTS_TEXTURE_BIT)) + return false; + + const struct util_format_description *desc = util_format_description(format); + if (desc->layout == UTIL_FORMAT_LAYOUT_ETC || + desc->layout == UTIL_FORMAT_LAYOUT_ASTC) { + return dev->device_type == NOUVEAU_WS_DEVICE_TYPE_SOC && + dev->cls_eng3d >= KEPLER_C; + } + + return true; +} + +bool +nil_format_supports_filtering(struct nouveau_ws_device *dev, + enum pipe_format format) +{ + return nil_format_supports_texturing(dev, format) && + !util_format_is_pure_integer(format); +} + +bool +nil_format_supports_buffer(struct nouveau_ws_device *dev, + enum pipe_format format) +{ + assert(format < PIPE_FORMAT_COUNT); + const struct nil_format_info *fmt = &nil_format_infos[format]; + return fmt->support & NIL_FORMAT_SUPPORTS_BUFFER_BIT; +} + +bool +nil_format_supports_storage(struct nouveau_ws_device *dev, + enum pipe_format format) +{ + assert(format < PIPE_FORMAT_COUNT); + const struct nil_format_info *fmt = &nil_format_infos[format]; + return fmt->support & NIL_FORMAT_SUPPORTS_STORAGE_BIT; +} + +bool nil_format_supports_color_targets(struct nouveau_ws_device *dev, enum pipe_format format) { @@ -360,6 +408,24 @@ nil_format_supports_color_targets(struct nouveau_ws_device *dev, return fmt->support & NIL_FORMAT_SUPPORTS_RENDER_BIT; } +bool +nil_format_supports_blending(struct nouveau_ws_device *dev, + enum pipe_format format) +{ + assert(format < PIPE_FORMAT_COUNT); + const struct nil_format_info *fmt = &nil_format_infos[format]; + return fmt->support & NIL_FORMAT_SUPPORTS_BLEND_BIT; +} + +bool +nil_format_supports_depth_stencil(struct nouveau_ws_device *dev, + enum pipe_format format) +{ + assert(format < PIPE_FORMAT_COUNT); + const struct nil_format_info *fmt = &nil_format_infos[format]; + return fmt->support & NIL_FORMAT_SUPPORTS_DEPTH_STENCIL_BIT; +} + uint8_t nil_format_to_color_target(enum pipe_format format) { diff --git a/src/nouveau/nil/nil_format.h b/src/nouveau/nil/nil_format.h index acd6ee0..b4ea355 100644 --- a/src/nouveau/nil/nil_format.h +++ b/src/nouveau/nil/nil_format.h @@ -11,9 +11,27 @@ struct nouveau_ws_device; /* We don't have our own format enum; we use PIPE_FORMAT for everything */ +bool nil_format_supports_texturing(struct nouveau_ws_device *dev, + enum pipe_format format); + +bool nil_format_supports_filtering(struct nouveau_ws_device *dev, + enum pipe_format format); + +bool nil_format_supports_buffer(struct nouveau_ws_device *dev, + enum pipe_format format); + +bool nil_format_supports_storage(struct nouveau_ws_device *dev, + enum pipe_format format); + bool nil_format_supports_color_targets(struct nouveau_ws_device *dev, enum pipe_format format); +bool nil_format_supports_blending(struct nouveau_ws_device *dev, + enum pipe_format format); + +bool nil_format_supports_depth_stencil(struct nouveau_ws_device *dev, + enum pipe_format format); + uint8_t nil_format_to_color_target(enum pipe_format format); uint8_t nil_format_to_depth_stencil(enum pipe_format format); -- 2.7.4