mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-09 06:48:06 +02:00
rusticl/mem: fix image OOB checks
The CL API puts the array layer on the height, where gallium puts it on
the depth. This is taken into account everywhere else, except for API
validation.
Fixes: 8b9a5adf8b ("rusticl/mem: return errors for OOB accesses")
Signed-off-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18852>
This commit is contained in:
parent
1af804d554
commit
df84c89d96
2 changed files with 13 additions and 1 deletions
|
|
@ -510,7 +510,7 @@ fn validate_image_desc(
|
|||
|
||||
fn validate_image_bounds(i: &Mem, origin: CLVec<usize>, region: CLVec<usize>) -> CLResult<()> {
|
||||
let bound = region + origin;
|
||||
if bound > i.image_desc.size() {
|
||||
if bound > i.image_desc.api_size() {
|
||||
return Err(CL_INVALID_VALUE);
|
||||
}
|
||||
Ok(())
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ pub trait CLImageDescInfo {
|
|||
fn row_pitch(&self) -> CLResult<u32>;
|
||||
fn slice_pitch(&self) -> CLResult<u32>;
|
||||
fn size(&self) -> CLVec<usize>;
|
||||
fn api_size(&self) -> CLVec<usize>;
|
||||
|
||||
fn dims(&self) -> u8 {
|
||||
self.type_info().0
|
||||
|
|
@ -124,6 +125,17 @@ impl CLImageDescInfo for cl_image_desc {
|
|||
CLVec::new([self.image_width, height, depth])
|
||||
}
|
||||
|
||||
fn api_size(&self) -> CLVec<usize> {
|
||||
let mut size = self.size();
|
||||
|
||||
if self.is_array() && self.dims() == 1 {
|
||||
size[1] = size[2];
|
||||
size[2] = 1;
|
||||
}
|
||||
|
||||
size
|
||||
}
|
||||
|
||||
fn bx(&self) -> CLResult<pipe_box> {
|
||||
let size = self.size();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue