nil: Add more format support helpers

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
This commit is contained in:
Faith Ekstrand 2023-01-30 20:11:54 -06:00 committed by Marge Bot
parent 0af169b86b
commit 77db3e99dd
2 changed files with 84 additions and 0 deletions

View file

@ -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 {
@ -351,6 +354,51 @@ static const struct nil_format_info nil_format_infos[PIPE_FORMAT_COUNT] =
SF(A, R5SG5SB6U_NORM, 0, R, G, B, ONE_FLOAT, SNORM, SNORM, UNORM, UNORM, B6G5R5, T),
};
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)
{

View file

@ -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);