mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 00:58:05 +02:00
rusticl: add new CL_INVALID_BUFFER_SIZE condition for clCreateBuffer
Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29776>
(cherry picked from commit 1ff86021a7)
This commit is contained in:
parent
a063c0503e
commit
865c926a36
2 changed files with 15 additions and 2 deletions
|
|
@ -4,7 +4,7 @@
|
|||
"description": "rusticl: add new CL_INVALID_BUFFER_SIZE condition for clCreateBuffer",
|
||||
"nominated": true,
|
||||
"nomination_type": 0,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": null,
|
||||
"notes": null
|
||||
|
|
|
|||
|
|
@ -275,13 +275,26 @@ fn create_buffer_with_properties(
|
|||
return Err(CL_INVALID_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
// ... or if size is greater than CL_DEVICE_MAX_MEM_ALLOC_SIZE for all devices in context.
|
||||
// ... or if size is greater than CL_DEVICE_MAX_MEM_ALLOC_SIZE for all devices in context,
|
||||
if checked_compare(size, Ordering::Greater, c.max_mem_alloc()) {
|
||||
return Err(CL_INVALID_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
validate_host_ptr(host_ptr, flags)?;
|
||||
|
||||
// or if CL_MEM_USE_HOST_PTR is set in flags and host_ptr is a pointer returned by clSVMAlloc
|
||||
// and size is greater than the size passed to clSVMAlloc.
|
||||
if let Some((svm_ptr, svm_layout)) = c.find_svm_alloc(host_ptr as usize) {
|
||||
// SAFETY: they are part of the same allocation, and because host_ptr >= svm_ptr we can cast
|
||||
// to usize.
|
||||
let diff = unsafe { host_ptr.offset_from(svm_ptr) } as usize;
|
||||
|
||||
// technically we don't have to account for the offset, but it's almost for free.
|
||||
if size > svm_layout.size() - diff {
|
||||
return Err(CL_INVALID_BUFFER_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
let props = Properties::from_ptr_raw(properties);
|
||||
// CL_INVALID_PROPERTY if a property name in properties is not a supported property name, if
|
||||
// the value specified for a supported property name is not valid, or if the same property name
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue