backends/drm: replace manual IN_FORMATS parsing with libdrm functions

!2819 reminded me that it's time to replace this mess with libdrm functions

Upstream MR: https://gitlab.freedesktop.org/mesa/drm/-/merge_requests/146
This commit is contained in:
Xaver Hugl 2022-08-30 08:30:01 +00:00 committed by Vlad Zahorodnii
parent 71b53ca5b0
commit c4b9626117
2 changed files with 4 additions and 20 deletions

View file

@ -247,7 +247,7 @@ set_package_properties(UDev PROPERTIES
PURPOSE "Required for input handling on Wayland."
)
find_package(Libdrm 2.4.62)
find_package(Libdrm 2.4.108)
set_package_properties(Libdrm PROPERTIES TYPE REQUIRED PURPOSE "Required for drm output on Wayland.")
find_package(gbm)

View file

@ -68,25 +68,9 @@ bool DrmPlane::init()
// read formats from blob if available and if modifiers are supported, and from the plane object if not
if (const auto formatProp = getProp(PropertyIndex::In_Formats); formatProp && formatProp->immutableBlob() && gpu()->addFB2ModifiersSupported()) {
auto blob = static_cast<drm_format_modifier_blob *>(formatProp->immutableBlob()->data);
auto modifiers = reinterpret_cast<drm_format_modifier *>(reinterpret_cast<uint8_t *>(blob) + blob->modifiers_offset);
uint32_t *formatarr = reinterpret_cast<uint32_t *>(reinterpret_cast<uint8_t *>(blob) + blob->formats_offset);
for (uint32_t f = 0; f < blob->count_formats; f++) {
auto format = formatarr[f];
QVector<uint64_t> mods;
for (uint32_t m = 0; m < blob->count_modifiers; m++) {
auto modifier = &modifiers[m];
// The modifier advertisement blob is partitioned into groups of 64 formats
if (m < modifier->offset || m > modifier->offset + 63) {
continue;
}
if (!(modifier->formats & (1 << (f - modifier->offset)))) {
continue;
}
mods << modifier->modifier;
}
m_supportedFormats.insert(format, mods);
drmModeFormatModifierIterator iterator{};
while (drmModeFormatModifierBlobIterNext(formatProp->immutableBlob(), &iterator)) {
m_supportedFormats[iterator.fmt].push_back(iterator.mod);
}
} else {
for (uint32_t i = 0; i < p->count_formats; i++) {