mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-02 07:20:16 +01:00
v3d: Add V3D_TFU_READAHEAD padding for allocated resources
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36159>
This commit is contained in:
parent
310aa198f4
commit
4e033ffb27
1 changed files with 11 additions and 10 deletions
|
|
@ -102,17 +102,18 @@ v3d_resource_bo_alloc(struct v3d_resource *rsc)
|
|||
struct pipe_screen *pscreen = prsc->screen;
|
||||
struct v3d_bo *bo;
|
||||
|
||||
/* Buffers may be read using ldunifa, which prefetches the next
|
||||
* 4 bytes after a read. If the buffer's size is exactly a multiple
|
||||
* of a page size and the shader reads the last 4 bytes with ldunifa
|
||||
* the prefetching would read out of bounds and cause an MMU error,
|
||||
* so we allocate extra space to avoid kernel error spamming.
|
||||
/* Buffers may be read using ldunifa, which prefetches the next 4
|
||||
* bytes after a read. If the buffer's size is exactly a multiple of a
|
||||
* page size and the shader reads the last 4 bytes with ldunifa the
|
||||
* prefetching would read out of bounds and cause an MMU error, so we
|
||||
* allocate extra space to avoid kernel error spamming. We also need
|
||||
* to add a V3D_TFU_READAHEAD padding to avoid invalid reads done by
|
||||
* the TFU unit after the end of the last page allocated.
|
||||
*/
|
||||
uint32_t size = rsc->size;
|
||||
if (rsc->base.target == PIPE_BUFFER && (size % 4096 == 0))
|
||||
size += 4;
|
||||
|
||||
bo = v3d_bo_alloc(v3d_screen(pscreen), size, "resource");
|
||||
uint32_t padding =
|
||||
rsc->base.target == PIPE_BUFFER ? 4 : V3D_TFU_READAHEAD_SIZE;
|
||||
bo = v3d_bo_alloc(v3d_screen(pscreen), rsc->size + padding,
|
||||
"resource");
|
||||
if (bo) {
|
||||
v3d_bo_unreference(&rsc->bo);
|
||||
rsc->bo = bo;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue