mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 09:08:10 +02:00
rusticl/image: take pitches into account when allocating memory for maps
This is more correct than the previous code and the CL CTS relies on edge case behavior here, e.g. for 1Dbuffer images. I think part of that is not actually required by the spec, but whatever. Fixes:7b22bc617b("rusticl/memory: complete rework on how mapping is implemented") Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30528> (cherry picked from commit2484331e82)
This commit is contained in:
parent
d3db644f0d
commit
2fef79767f
2 changed files with 28 additions and 3 deletions
|
|
@ -3634,7 +3634,7 @@
|
|||
"description": "rusticl/image: take pitches into account when allocating memory for maps",
|
||||
"nominated": true,
|
||||
"nomination_type": 1,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": "7b22bc617bf2db4120a438c1ad5e45992f638d82",
|
||||
"notes": null
|
||||
|
|
|
|||
|
|
@ -1329,8 +1329,33 @@ impl Image {
|
|||
*row_pitch = self.image_desc.row_pitch()? as usize;
|
||||
*slice_pitch = self.image_desc.slice_pitch();
|
||||
|
||||
let (offset, size) =
|
||||
CLVec::calc_offset_size(origin, region, [pixel_size, *row_pitch, *slice_pitch]);
|
||||
let offset = CLVec::calc_offset(origin, [pixel_size, *row_pitch, *slice_pitch]);
|
||||
|
||||
// From the CL Spec:
|
||||
//
|
||||
// The pointer returned maps a 1D, 2D or 3D region starting at origin and is at least
|
||||
// region[0] pixels in size for a 1D image, 1D image buffer or 1D image array,
|
||||
// (image_row_pitch × region[1]) pixels in size for a 2D image or 2D image array, and
|
||||
// (image_slice_pitch × region[2]) pixels in size for a 3D image. The result of a memory
|
||||
// access outside this region is undefined.
|
||||
//
|
||||
// It's not guaranteed that the row_pitch is taken into account for 1D images, but the CL
|
||||
// CTS relies on this behavior.
|
||||
//
|
||||
// Also note, that the spec wording is wrong in regards to arrays, which need to take the
|
||||
// image_slice_pitch into account.
|
||||
let size = if self.image_desc.is_array() || self.image_desc.dims() == 3 {
|
||||
debug_assert_ne!(*slice_pitch, 0);
|
||||
// the slice count is in region[1] for 1D array images
|
||||
if self.mem_type == CL_MEM_OBJECT_IMAGE1D_ARRAY {
|
||||
region[1] * *slice_pitch
|
||||
} else {
|
||||
region[2] * *slice_pitch
|
||||
}
|
||||
} else {
|
||||
debug_assert_ne!(*row_pitch, 0);
|
||||
region[1] * *row_pitch
|
||||
};
|
||||
|
||||
let layout;
|
||||
unsafe {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue