Skip to content

broadcom/compiler: fix robust buffer access

Iago Toral requested to merge itoral/mesa:v3dv_robust_fixes into main

Our implemention was bogus, it was only putting a cap on the offset based on the aligned buffer size and this doesn't ensure the access to the buffer happens within its valid range.

I think the only reason we have been passing the tests is that we align all buffers sizes to 256B and the tests create buffers with a size that is smaller than that (like 64B). When get the size of the buffer from the shader, we get the actual bound range (so 64B in this case) and by capping to that we don't ensure the access will stay within that range, but we ensure it will stay within the underlying memory bound to the buffer (256B), and this is fine by the spec, however, I think if the actual buffer range was the same as the underlying allocation we would fail the tests.

A valid behavior for robust buffer access on an out-of-bounds access is to return any valid bytes within the buffer, so we can just make that offset 0.

Also, this feature doesn't apply to shared memory, so we drop that. Still, I decided to keep the implementation around (disabled by default) should prove useful in the future for debugging.

Merge request reports