asahi: Do not overread user index buffers
We need to align the extent to 4 for the GPU, but we can't copy more than the original size out of the user buffer. Always alloc the exact size we need. This does mean the GPU gets an IB extent that could include some other stuff later in the pool, if not aligned. This is probably safe? Given the base alignment, it should never cross a page boundary and fault or anything like that. Signed-off-by: Asahi Lina <lina@asahilina.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21686>
This commit is contained in:
@@ -2389,8 +2389,9 @@ agx_index_buffer_direct_ptr(struct agx_batch *batch,
|
||||
} else {
|
||||
*extent = ALIGN_POT(draw->count * info->index_size, 4);
|
||||
|
||||
return agx_pool_upload_aligned(
|
||||
&batch->pool, ((uint8_t *)info->index.user) + offset, *extent, 64);
|
||||
return agx_pool_upload_aligned(&batch->pool,
|
||||
((uint8_t *)info->index.user) + offset,
|
||||
draw->count * info->index_size, 64);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user