From 788ae5891ab4fc797775eaff827e88e566d2b1ec Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Fri, 6 May 2022 18:30:19 +0200 Subject: [PATCH] backends/drm: zero metadata for unused planes The kernel may fail requests if data for unused planes is non-zero. --- src/backends/drm/drm_buffer_gbm.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/backends/drm/drm_buffer_gbm.cpp b/src/backends/drm/drm_buffer_gbm.cpp index 138496b681..a4bd5d3fbb 100644 --- a/src/backends/drm/drm_buffer_gbm.cpp +++ b/src/backends/drm/drm_buffer_gbm.cpp @@ -32,27 +32,39 @@ namespace KWin static std::array getHandles(gbm_bo *bo) { std::array ret; - for (int i = 0; i < gbm_bo_get_plane_count(bo); i++) { + int i = 0; + for (; i < gbm_bo_get_plane_count(bo); i++) { ret[i] = gbm_bo_get_handle(bo).u32; } + for (; i < 4; i++) { + ret[i] = 0; + } return ret; } static std::array getStrides(gbm_bo *bo) { std::array ret; - for (int i = 0; i < gbm_bo_get_plane_count(bo); i++) { + int i = 0; + for (; i < gbm_bo_get_plane_count(bo); i++) { ret[i] = gbm_bo_get_stride_for_plane(bo, i); } + for (; i < 4; i++) { + ret[i] = 0; + } return ret; } static std::array getOffsets(gbm_bo *bo) { std::array ret; - for (int i = 0; i < gbm_bo_get_plane_count(bo); i++) { + int i = 0; + for (; i < gbm_bo_get_plane_count(bo); i++) { ret[i] = gbm_bo_get_offset(bo, i); } + for (; i < 4; i++) { + ret[i] = 0; + } return ret; }