nir: Add is_null_constant to nir_constant

Indicates that the values contained within are 0s, regardless of
type. Enables some optimizations.

Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23173>
This commit is contained in:
Jesse Natalie
2023-05-18 10:31:50 -07:00
committed by Marge Bot
parent 009d2de88f
commit 4edfb67fd4
7 changed files with 54 additions and 26 deletions
+5
View File
@@ -2530,6 +2530,11 @@ static void
write_constant(void *dst, size_t dst_size,
const nir_constant *c, const struct glsl_type *type)
{
if (c->is_null_constant) {
memset(dst, 0, dst_size);
return;
}
if (glsl_type_is_vector_or_scalar(type)) {
const unsigned num_components = glsl_get_vector_elements(type);
const unsigned bit_size = glsl_get_bit_size(type);