llvmpipe: misc fixes for sparse binding
This change:
1. Move size validation within sparse binding, but not escape to
non-sparse code path.
2. Error out if sparse is requested on unsupported platforms.
Fixes: d747c4a874 ("lavapipe: Implement sparse buffers and images")
Reviewed-by: Christian Gmeiner <cgmeiner@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38074>
This commit is contained in:
@@ -1598,9 +1598,13 @@ llvmpipe_resource_bind_backing(struct pipe_screen *pscreen,
|
||||
if (!lpr->backable)
|
||||
return false;
|
||||
|
||||
if ((lpr->base.flags & PIPE_RESOURCE_FLAG_SPARSE) && offset < lpr->size_required) {
|
||||
if (lpr->base.flags & PIPE_RESOURCE_FLAG_SPARSE) {
|
||||
#if DETECT_OS_LINUX
|
||||
struct llvmpipe_memory_allocation *mem = (struct llvmpipe_memory_allocation *)pmem;
|
||||
|
||||
if (offset >= lpr->size_required)
|
||||
return false;
|
||||
|
||||
if (mem) {
|
||||
if (llvmpipe_resource_is_texture(&lpr->base)) {
|
||||
mmap((char *)lpr->tex_data + offset, size, PROT_READ|PROT_WRITE,
|
||||
@@ -1620,9 +1624,11 @@ llvmpipe_resource_bind_backing(struct pipe_screen *pscreen,
|
||||
MAP_SHARED|MAP_FIXED|MAP_ANONYMOUS, -1, 0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
addr = llvmpipe_map_memory(pscreen, pmem);
|
||||
|
||||
Reference in New Issue
Block a user