mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-09 04:38:03 +02:00
nil: Relax alignment requirements for linear images
Compositors sometime try to import BOs with lower alignments than 128B. This seems particularly common in the case of cursor images but it can also happen on other BOs allocated by the old nouveau GL driver. As long as we avoid rendering to them (which NVK will do), the texture/image hardware is fine as long as they're at least 32B-aligned. Panicing in this case isn't very nice to compositors. Backport-to: 25.0 Reviewed-by: Mel Henning <mhenning@darkrefraction.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33990>
This commit is contained in:
parent
e36f9d6909
commit
3c11da8aea
1 changed files with 13 additions and 5 deletions
|
|
@ -348,10 +348,12 @@ impl Image {
|
|||
|
||||
let row_stride_B = if info.explicit_row_stride_B > 0 {
|
||||
assert!(info.modifier == DRM_FORMAT_MOD_LINEAR);
|
||||
assert!(info.explicit_row_stride_B % 128 == 0);
|
||||
info.explicit_row_stride_B
|
||||
// Texture headers require strides to be 32B-aligned
|
||||
debug_assert!(info.explicit_row_stride_B % 32 == 0);
|
||||
info.explicit_row_stride_B.next_multiple_of(32)
|
||||
} else {
|
||||
// Row stride needs to be aligned to 128B for render to work
|
||||
// If we get to pick the alignment, require 128B so that we
|
||||
// can render to the image without workarounds.
|
||||
lvl_ext_B.width.next_multiple_of(128)
|
||||
};
|
||||
|
||||
|
|
@ -413,8 +415,14 @@ impl Image {
|
|||
image.align_B = std::cmp::max(image.align_B, 1 << 16);
|
||||
}
|
||||
} else {
|
||||
// Linear images need to be aligned to 128B for render to work
|
||||
image.align_B = std::cmp::max(image.align_B, 128);
|
||||
if info.explicit_row_stride_B > 0 {
|
||||
// Linear images need to be aligned to 32B
|
||||
image.align_B = std::cmp::max(image.align_B, 32);
|
||||
} else {
|
||||
// If we get to pick the alignment, require 128B so that we
|
||||
// can render to the image without workarounds.
|
||||
image.align_B = std::cmp::max(image.align_B, 128);
|
||||
}
|
||||
}
|
||||
|
||||
image.size_B = image.size_B.next_multiple_of(image.align_B.into());
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue