panfrost/blend: Fix invalid const values leading to NIR validation errors
authorJessica Clarke <jrtc27@jrtc27.com>
Wed, 30 Nov 2022 00:11:45 +0000 (00:11 +0000)
committerMarge Bot <emma+marge@anholt.net>
Wed, 30 Nov 2022 04:49:17 +0000 (04:49 +0000)
commit750325730bb84981f68d78b205fb0cec1e165100
treea1411fa1d69d41d228899d859849c5180eb680f1
parent6148ccef6372e634ea4875b75419bfdc64e6b219
panfrost/blend: Fix invalid const values leading to NIR validation errors

Using a designated initializer like this leaves padding bits, which form
part of the aliasing u64/f64 member of the union, uninitialised, but a
nir_const_value must always have the unused bits zeroed out. Thus, use
the nir_const_value_for_float helper instead like everywhere else which
will do a memset 0 for us first.

Without this, using the pan_blend shader in a build with validation
enabled fails with:

  NIR validation failed after nir_lower_vars_to_ssa
  ...
            vec4 32 ssa_58 = load_const (0x3f7cfcfd /* 0.988235 */, 0x3f7cfcfd /* 0.988235 */, 0x3f7cfcfd /* 0.988235 */, 0x3f800000 /* 1.000000 */)
  error: memcmp(val, &cmp_val, sizeof(cmp_val)) == 0 (../src/compiler/nir/nir_validate.c:976)

Fixes: 1378c67bcf9e ("panfrost/blend: Inline blend constants")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20071>
src/panfrost/lib/pan_blend.c