lavapipe, nir: Fix wrong array index scaling in nir_collect_src_uniforms

The scaling needs to be ubo * MAX_INLINABLE_UNIFORMS, not
ubo * PIPE_MAX_CONSTANT_BUFFERS, otherwise accesses beyond buffer size
will result for ubo >= 4 (and we'd also access the wrong values later
for other non-zero ubo indices).

Fixes: a7696a4d98 ("lavapipe: Fix bad array index scale factor in lvp_inline_uniforms pass")
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21506>
This commit is contained in:
Roland Scheidegger
2023-02-23 23:08:10 +01:00
committed by Marge Bot
parent b6303d33ec
commit a4fa489002

View File

@@ -148,7 +148,7 @@ nir_collect_src_uniforms(const nir_src *src, int component,
/* Already recorded by other one */
for (int i = 0; i < num_offsets[ubo]; i++) {
if (uni_offsets[ubo * MAX_NUM_BO + i] == offset)
if (uni_offsets[ubo * MAX_INLINABLE_UNIFORMS + i] == offset)
return true;
}
@@ -157,7 +157,7 @@ nir_collect_src_uniforms(const nir_src *src, int component,
return false;
/* Record the uniform offset. */
uni_offsets[ubo * MAX_NUM_BO + num_offsets[ubo]++] = offset;
uni_offsets[ubo * MAX_INLINABLE_UNIFORMS + num_offsets[ubo]++] = offset;
return true;
}
return false;