Currently planes are rendered in creation order. This is not an issue, but
with the introduction of new zpos configuration, it is required to
properly render planes.

Signed-off-by: Louis Chauvet <[email protected]>
---
 drivers/gpu/drm/vkms/vkms_crtc.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c
index bac0790c6577..0524c47460fb 100644
--- a/drivers/gpu/drm/vkms/vkms_crtc.c
+++ b/drivers/gpu/drm/vkms/vkms_crtc.c
@@ -4,6 +4,7 @@
 
 #include <drm/drm_atomic.h>
 #include <drm/drm_atomic_helper.h>
+#include <drm/drm_blend.h>
 #include <drm/drm_managed.h>
 #include <drm/drm_probe_helper.h>
 #include <drm/drm_vblank.h>
@@ -141,14 +142,20 @@ static int vkms_crtc_atomic_check(struct drm_crtc *crtc,
                return -ENOMEM;
        vkms_state->num_active_planes = i;
 
-       i = 0;
+       ret = drm_atomic_normalize_zpos(crtc->dev, state);
+       if (ret)
+               return ret;
+
        drm_for_each_plane_mask(plane, crtc->dev, crtc_state->plane_mask) {
                plane_state = drm_atomic_get_new_plane_state(crtc_state->state, 
plane);
 
                if (!plane_state->visible)
                        continue;
 
-               vkms_state->active_planes[i++] =
+               // Order planes according to their normalized_zpos
+               // After drm_atomic_normalize_zpos, the possible values are 
0..n_planes-1
+               // so store them using this index
+               vkms_state->active_planes[plane_state->normalized_zpos] =
                        to_vkms_plane_state(plane_state);
        }
 

-- 
2.51.0

Reply via email to