nir: add ACCESS_KEEP_SCALAR, preventing vectorization

The comment explains the reason.

Acked-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30208>
This commit is contained in:
Marek Olšák 2024-07-14 19:09:04 -04:00 committed by Marge Bot
parent 3f1c3f04be
commit 1d66acf993
2 changed files with 16 additions and 0 deletions

View file

@ -1066,6 +1066,9 @@ is_strided_vector(const struct glsl_type *type)
static bool
can_vectorize(struct vectorize_ctx *ctx, struct entry *first, struct entry *second)
{
if ((first->access | second->access) & ACCESS_KEEP_SCALAR)
return false;
if (!(get_variable_mode(first) & ctx->options->modes) ||
!(get_variable_mode(second) & ctx->options->modes))
return false;

View file

@ -1145,6 +1145,19 @@ enum gl_access_qualifier
* on AGX, used for some internal shaders.
*/
ACCESS_IN_BOUNDS_AGX = (1 << 14),
/**
* Disallow vectorization.
*
* On some hw (AMD), sparse buffer loads return 0 for all components if
* a sparse load starts on a non-resident page, crosses the page boundary,
* and ends on a resident page. Sometimes we want it to return 0 only for
* the portion of the load that's non-resident, and load values for
* the portion that's resident. The workaround is to scalarize such loads
* and disallow vectorization. This is used by an internal copy_buffer
* shader where the API wants to copy all bytes that are resident.
*/
ACCESS_KEEP_SCALAR = (1 << 15),
};
/**