v3dv: don't allocate MAX_PUSH_CONSTANTS_SIZE bytes for the push constants UBO
authorIago Toral Quiroga <itoral@igalia.com>
Thu, 14 Jul 2022 06:58:06 +0000 (08:58 +0200)
committerMarge Bot <emma+marge@anholt.net>
Tue, 19 Jul 2022 05:46:04 +0000 (05:46 +0000)
commit45b8dc667a45bd01d9de93da4eafc1774e7cb19a
treece98e895eb8206561e8ea6e39bd0740e26509724
parent51a45f93150630d2974de0221cdc8ef238d85c74
v3dv: don't allocate MAX_PUSH_CONSTANTS_SIZE bytes for the push constants UBO

We have code in there to allocate various segments of MAX_PUSH_CONSTANTS_SIZE
to handle the case of various draw calls in the same command buffer requiring
different push constants, so we are implicitly expecting it to be larger than
this. In fact, this only works now because when we allocate a BO we are always
at least allocating a full page, so the least we ever allocate is 4096 bytes,
so be explicit about it to avoid confusion.

Also, since we were always mapping MAX_PUSH_CONSTANTS_SIZE and the mapping
always starts at the beginning of the BO, it looks like after the first copy
when the resource offset is not zero, we would be writing outside the mapped
range. Always map the full size of the BO instead to ensure this doesn't
happen.

Reviewed-by: Alejandro PiƱeiro <apinheiro@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17536>
src/broadcom/vulkan/v3dv_uniforms.c