freedreno/a6xx: Allow suboptimal sampling formats when requested

We prefer PoT block sizes for various reasons, but if we are asked to
import 12/24/48b formats for sampling we can do so.

Signed-off-by: Rob Clark <rob.clark@oss.qualcomm.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35982>
This commit is contained in:
Rob Clark
2025-06-27 07:21:14 -07:00
committed by Marge Bot
parent 63b33eb4d9
commit 70fe77f61b
2 changed files with 12 additions and 5 deletions
@@ -22,8 +22,12 @@
#include "ir3/ir3_compiler.h"
static bool
valid_sample_count(unsigned sample_count)
valid_sample_count(unsigned sample_count, bool is_suboptimal)
{
/* NPoT formats do not support MSAA: */
if (is_suboptimal && (sample_count > 1))
return false;
switch (sample_count) {
case 0:
case 1:
@@ -47,10 +51,14 @@ fd6_screen_is_format_supported(struct pipe_screen *pscreen,
unsigned storage_sample_count, unsigned usage)
{
struct fd_screen *screen = fd_screen(pscreen);
bool allow_suboptimal = usage & PIPE_BIND_SAMPLER_VIEW_SUBOPTIMAL;
bool is_suboptimal = !util_is_power_of_two_or_zero(util_format_get_blocksize(format));
unsigned retval = 0;
usage &= ~PIPE_BIND_SAMPLER_VIEW_SUBOPTIMAL;
if ((target >= PIPE_MAX_TEXTURE_TYPES) ||
!valid_sample_count(sample_count)) {
!valid_sample_count(sample_count, is_suboptimal)) {
DBG("not supported: format=%s, target=%d, sample_count=%d, usage=%x",
util_format_name(format), target, sample_count, usage);
return false;
@@ -69,8 +77,7 @@ fd6_screen_is_format_supported(struct pipe_screen *pscreen,
if ((usage & (PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_SHADER_IMAGE)) &&
has_tex &&
(target == PIPE_BUFFER ||
util_is_power_of_two_or_zero(util_format_get_blocksize(format)))) {
(target == PIPE_BUFFER || allow_suboptimal || !is_suboptimal)) {
retval |= usage & (PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_SHADER_IMAGE);
}
@@ -1192,7 +1192,7 @@ fd_resource_layout_init(struct pipe_resource *prsc)
layout->cpp = util_format_get_blocksize(prsc->format);
layout->cpp *= fd_resource_nr_samples(prsc);
layout->cpp_shift = ffs(layout->cpp) - 1;
layout->cpp_shift = ffs(util_next_power_of_two(layout->cpp)) - 1;
}
static struct fd_resource *