nvk: Emit inactive vertex attributes

VK_KHR_maintenance9 requires that vertex attributes in shaders which map
to vertex attributes that aren't bound at the API return a consistent
value.  In order to do this, we need toemit SET_VERTEX_ATTRIBUTE_A, even
for unused attributes.  The RGBA32F format was chosen to ensure we
return (0, 0, 0, 0) from unbound attributes.

Fixes: 7692d3c0e1 ("nvk: Advertise VK_KHR_maintenance9")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38040>
This commit is contained in:
Faith Ekstrand 2025-10-23 18:27:18 -04:00 committed by Marge Bot
parent e36c277af9
commit d39221cef3

View file

@ -1832,17 +1832,28 @@ nvk_flush_vi_state(struct nvk_cmd_buffer *cmd)
if (BITSET_TEST(dyn->dirty, MESA_VK_DYNAMIC_VI) ||
BITSET_TEST(dyn->dirty, MESA_VK_DYNAMIC_VI_BINDINGS_VALID)) {
u_foreach_bit(a, dyn->vi->attributes_valid) {
const struct nvk_va_format *fmt =
nvk_get_va_format(pdev, dyn->vi->attributes[a].format);
P_MTHD(p, NV9097, SET_VERTEX_ATTRIBUTE_A(0));
for (uint32_t a = 0; a < 32; a++) {
if (dyn->vi->attributes_valid & BITFIELD_BIT(a)) {
const struct nvk_va_format *fmt =
nvk_get_va_format(pdev, dyn->vi->attributes[a].format);
P_IMMD(p, NV9097, SET_VERTEX_ATTRIBUTE_A(a), {
.stream = dyn->vi->attributes[a].binding,
.offset = dyn->vi->attributes[a].offset,
.component_bit_widths = fmt->bit_widths,
.numerical_type = fmt->type,
.swap_r_and_b = fmt->swap_rb,
});
P_NV9097_SET_VERTEX_ATTRIBUTE_A(p, a, {
.stream = dyn->vi->attributes[a].binding,
.source = SOURCE_ACTIVE,
.offset = dyn->vi->attributes[a].offset,
.component_bit_widths = fmt->bit_widths,
.numerical_type = fmt->type,
.swap_r_and_b = fmt->swap_rb,
});
} else {
P_NV9097_SET_VERTEX_ATTRIBUTE_A(p, a, {
.source = SOURCE_INACTIVE,
/* Using RGBA32 gives us (0, 0, 0, 0) for inactive attributes. */
.component_bit_widths = COMPONENT_BIT_WIDTHS_R32_G32_B32_A32,
.numerical_type = NUMERICAL_TYPE_NUM_FLOAT,
});
}
}
u_foreach_bit(b, dyn->vi->bindings_valid) {