Commit 55c54eed authored by Kristian H. Kristensen's avatar Kristian H. Kristensen Committed by Commit Bot

exo: Set the gfx::NativePixmapHandle modifier

This will forward the modifier all the way to the eventual EGLImage or
gbm bo import such that GLES or KMS will properly understand the
buffer layout.

BUG=b:145579089, b:79682290
TEST=wayland_rects_client --use-drm=msm and verify modifiers get passed

Change-Id: Ia422c3713f1a9384aa737c3d1cccb1dd76709e18
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2314984
Commit-Queue: Kristian H. Kristensen <hoegsberg@chromium.org>
Reviewed-by: default avatarDaniele Castagna <dcastagna@chromium.org>
Reviewed-by: default avatarFritz Koenig <frkoenig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#793405}
parent 134db883
......@@ -51,6 +51,7 @@ struct LinuxBufferParams {
base::ScopedFD fd;
uint32_t stride;
uint32_t offset;
uint64_t modifier;
};
explicit LinuxBufferParams(Display* display) : display(display) {}
......@@ -74,7 +75,8 @@ void linux_buffer_params_add(wl_client* client,
LinuxBufferParams* linux_buffer_params =
GetUserDataAs<LinuxBufferParams>(resource);
LinuxBufferParams::Plane plane{base::ScopedFD(fd), stride, offset};
const uint64_t modifier = (static_cast<uint64_t>(modifier_hi) << 32) | modifier_lo;
LinuxBufferParams::Plane plane{base::ScopedFD(fd), stride, offset, modifier};
const auto& inserted = linux_buffer_params->planes.insert(
std::pair<uint32_t, LinuxBufferParams::Plane>(plane_idx,
......@@ -106,8 +108,16 @@ bool ValidateLinuxBufferParams(wl_resource* resource,
LinuxBufferParams* linux_buffer_params =
GetUserDataAs<LinuxBufferParams>(resource);
size_t num_planes = gfx::NumberOfPlanesForLinearBufferFormat(format);
size_t num_planes = linux_buffer_params->planes.size();
if (num_planes == 0) {
wl_resource_post_error(resource,
ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INCOMPLETE,
"no planes given");
return false;
}
// Validate that we have planes 0..num_planes-1
for (uint32_t i = 0; i < num_planes; ++i) {
auto plane_it = linux_buffer_params->planes.find(i);
if (plane_it == linux_buffer_params->planes.end()) {
......@@ -118,7 +128,24 @@ bool ValidateLinuxBufferParams(wl_resource* resource,
}
}
if (linux_buffer_params->planes.size() != num_planes) {
// All planes must have the same modifier.
uint64_t modifier = linux_buffer_params->planes[0].modifier;
for (uint32_t i = 0; i < num_planes; ++i) {
if (linux_buffer_params->planes[i].modifier != modifier) {
wl_resource_post_error(resource,
ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INVALID_FORMAT,
"all planes must have same modifier");
return false;
}
}
// For linear layouts we know how many planes to expect, so check
// that. Otherwise, we have to trust that the client gave us the
// right number and fail later when importing the EGLImage if that's
// wrong.
if (modifier == DRM_FORMAT_MOD_LINEAR &&
linux_buffer_params->planes.size() !=
gfx::NumberOfPlanesForLinearBufferFormat(format)) {
wl_resource_post_error(resource, ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_PLANE_IDX,
"plane idx out of bounds");
return false;
......@@ -153,14 +180,12 @@ wl_resource* create_buffer(wl_client* client,
LinuxBufferParams* linux_buffer_params =
GetUserDataAs<LinuxBufferParams>(resource);
size_t num_planes =
gfx::NumberOfPlanesForLinearBufferFormat(supported_format->buffer_format);
gfx::NativePixmapHandle handle;
for (uint32_t i = 0; i < num_planes; ++i) {
auto plane_it = linux_buffer_params->planes.find(i);
LinuxBufferParams::Plane& plane = plane_it->second;
handle.modifier = linux_buffer_params->planes[0].modifier;
for (uint32_t i = 0; i < linux_buffer_params->planes.size(); ++i) {
auto& plane = linux_buffer_params->planes[i];
handle.planes.emplace_back(plane.stride, plane.offset, 0,
std::move(plane.fd));
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment