radv: round-up num_records division in radv_flush_vertex_descriptors
authorRhys Perry <pendingchaos02@gmail.com>
Mon, 30 Nov 2020 15:44:08 +0000 (15:44 +0000)
committerRhys Perry <pendingchaos02@gmail.com>
Wed, 3 Feb 2021 09:53:08 +0000 (09:53 +0000)
commit56cd79b63d25ef0d5d795bfa6ab58955b9f96e3b
tree983bb4564a3879282cb4b7930309440679a122b4
parent4cec72c3a9cdea1cd474979c7019c70771c5cd82
radv: round-up num_records division in radv_flush_vertex_descriptors

Vertex attribute bounds checking is supposed to be done per-attribute:
   is_oob = index * stride + attrib_offset + attrib_size > buffer_size
but we were obtaining num_records by dividing the buffer size by the
stride, making it per-vertex:
   is_oob = index * stride + (stride - 1) >= buffer_size

An example from Dead Cells (Wine) is:
attribute bindings: 0, 1, 2
attribute formats: r32g32, r32g32, r32g32b32a32
attribute offsets: 0, 0, 0
binding buffers: all the same buffer
binding offsets: 0, 8, 16
binding sizes: 128, 120, 112
binding strides: 32, 32, 32

Workaround this issue without switching to per-attribute descriptors by
rounding up the division. This is still incorrect, but it should now no
longer consider in-bounds attributes out-of-bounds.

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3796
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4199
Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8835>
.gitlab-ci/deqp-radv-navi10-aco-fails.txt
.gitlab-ci/deqp-radv-navi14-aco-fails.txt
.gitlab-ci/deqp-radv-pitcairn-aco-fails.txt
.gitlab-ci/deqp-radv-raven-aco-fails.txt
.gitlab-ci/deqp-radv-sienna_cichlid-aco-fails.txt
.gitlab-ci/deqp-radv-vega10-aco-fails.txt
src/amd/vulkan/radv_cmd_buffer.c