rusticl: cap max alloc size to i32 to avoid overflowing gallium
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run

v2: remove stray comment

Reviewed-by: Karol Herbst <kherbst@redhat.com>
Cc: stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34166>
This commit is contained in:
Seán de Búrca 2025-03-27 10:00:18 -07:00 committed by Marge Bot
parent 5b1088220e
commit ea6c57cfcb

View file

@ -1025,9 +1025,18 @@ impl Device {
self.screen.compute_caps().grid_dimension
}
/// Returns the maximum size in bytes of a memory allocation for this
/// device.
pub fn max_mem_alloc(&self) -> cl_ulong {
// TODO: at the moment gallium doesn't support bigger buffers
min(self.screen.compute_caps().max_mem_alloc_size, 0x80000000)
// The returned value must always be less than or equal to `isize::MAX`,
// as this method may be used for bounds checking on allocations.
// TODO: Add support for larger allocations. gallium doesn't support
// buffers larger than `i32::MAX` due to constraints in the buffer
// mapping API.
min(
self.screen.compute_caps().max_mem_alloc_size,
i32::MAX as cl_ulong,
)
}
pub fn max_samplers(&self) -> cl_uint {