@@ -351,6 +351,7 @@ static int rendertarget_gbm_present(
351
351
struct rendertarget_gbm * gbm_target ;
352
352
struct gbm_bo * next_front_bo ;
353
353
uint32_t next_front_fb_id ;
354
+ bool supported ;
354
355
int ok ;
355
356
356
357
gbm_target = & target -> gbm ;
@@ -368,8 +369,41 @@ static int rendertarget_gbm_present(
368
369
drmdev_atomic_req_put_plane_property (atomic_req , drm_plane_id , "CRTC_Y" , 0 );
369
370
drmdev_atomic_req_put_plane_property (atomic_req , drm_plane_id , "CRTC_W" , flutterpi .display .width );
370
371
drmdev_atomic_req_put_plane_property (atomic_req , drm_plane_id , "CRTC_H" , flutterpi .display .height );
371
- drmdev_atomic_req_put_plane_property (atomic_req , drm_plane_id , "rotation" , DRM_MODE_ROTATE_0 );
372
- drmdev_atomic_req_put_plane_property (atomic_req , drm_plane_id , "zpos" , zpos );
372
+
373
+ ok = drmdev_plane_supports_setting_rotation_value (atomic_req -> drmdev , drm_plane_id , DRM_MODE_ROTATE_0 , & supported );
374
+ if (ok != 0 ) return ok ;
375
+
376
+ if (supported ) {
377
+ drmdev_atomic_req_put_plane_property (atomic_req , drm_plane_id , "rotation" , DRM_MODE_ROTATE_0 );
378
+ } else {
379
+ static bool printed = false;
380
+
381
+ if (!printed ) {
382
+ fprintf (stderr ,
383
+ "[compositor] GPU does not support reflecting the screen in Y-direction.\n"
384
+ " This is required for rendering into hardware overlay planes though.\n"
385
+ " Any UI that is drawn in overlay planes will look upside down.\n"
386
+ );
387
+ printed = true;
388
+ }
389
+ }
390
+
391
+ ok = drmdev_plane_supports_setting_zpos_value (atomic_req -> drmdev , drm_plane_id , zpos , & supported );
392
+ if (ok != 0 ) return ok ;
393
+
394
+ if (supported ) {
395
+ drmdev_atomic_req_put_plane_property (atomic_req , drm_plane_id , "zpos" , zpos );
396
+ } else {
397
+ static bool printed = false;
398
+
399
+ if (!printed ) {
400
+ fprintf (stderr ,
401
+ "[compositor] GPU does not supported the desired HW plane order.\n"
402
+ " Some UI layers may be invisible.\n"
403
+ );
404
+ printed = true;
405
+ }
406
+ }
373
407
374
408
// TODO: move this to the page flip handler.
375
409
// We can only be sure the buffer can be released when the buffer swap
@@ -438,6 +472,7 @@ static int rendertarget_nogbm_present(
438
472
int zpos
439
473
) {
440
474
struct rendertarget_nogbm * nogbm_target ;
475
+ bool supported ;
441
476
int ok ;
442
477
443
478
nogbm_target = & target -> nogbm ;
@@ -456,8 +491,41 @@ static int rendertarget_nogbm_present(
456
491
drmdev_atomic_req_put_plane_property (req , drm_plane_id , "CRTC_Y" , 0 );
457
492
drmdev_atomic_req_put_plane_property (req , drm_plane_id , "CRTC_W" , flutterpi .display .width );
458
493
drmdev_atomic_req_put_plane_property (req , drm_plane_id , "CRTC_H" , flutterpi .display .height );
459
- drmdev_atomic_req_put_plane_property (req , drm_plane_id , "rotation" , DRM_MODE_ROTATE_0 | DRM_MODE_REFLECT_Y );
460
- drmdev_atomic_req_put_plane_property (req , drm_plane_id , "zpos" , zpos );
494
+
495
+ ok = drmdev_plane_supports_setting_rotation_value (req -> drmdev , drm_plane_id , DRM_MODE_ROTATE_0 | DRM_MODE_REFLECT_Y , & supported );
496
+ if (ok != 0 ) return ok ;
497
+
498
+ if (supported ) {
499
+ drmdev_atomic_req_put_plane_property (req , drm_plane_id , "rotation" , DRM_MODE_ROTATE_0 | DRM_MODE_REFLECT_Y );
500
+ } else {
501
+ static bool printed = false;
502
+
503
+ if (!printed ) {
504
+ fprintf (stderr ,
505
+ "[compositor] GPU does not support reflecting the screen in Y-direction.\n"
506
+ " This is required for rendering into hardware overlay planes though.\n"
507
+ " Any UI that is drawn in overlay planes will look upside down.\n"
508
+ );
509
+ printed = true;
510
+ }
511
+ }
512
+
513
+ ok = drmdev_plane_supports_setting_zpos_value (req -> drmdev , drm_plane_id , zpos , & supported );
514
+ if (ok != 0 ) return ok ;
515
+
516
+ if (supported ) {
517
+ drmdev_atomic_req_put_plane_property (req , drm_plane_id , "zpos" , zpos );
518
+ } else {
519
+ static bool printed = false;
520
+
521
+ if (!printed ) {
522
+ fprintf (stderr ,
523
+ "[compositor] GPU does not supported the desired HW plane order.\n"
524
+ " Some UI layers may be invisible.\n"
525
+ );
526
+ printed = true;
527
+ }
528
+ }
461
529
462
530
return 0 ;
463
531
}
@@ -709,10 +777,32 @@ static bool on_present_layers(
709
777
ok = drmdev_atomic_req_put_modeset_props (req , & req_flags );
710
778
if (ok != 0 ) return false;
711
779
780
+ int64_t max_zpos = 0 ;
781
+
712
782
for_each_unreserved_plane_in_atomic_req (req , plane ) {
713
783
if (plane -> type == DRM_PLANE_TYPE_CURSOR ) {
714
784
// make sure the cursor is in front of everything
715
- drmdev_atomic_req_put_plane_property (req , plane -> plane -> plane_id , "zpos" , 2 );
785
+ int64_t max_zpos ;
786
+ bool supported ;
787
+
788
+ ok = drmdev_plane_get_max_zpos_value (req -> drmdev , plane -> plane -> plane_id , & max_zpos );
789
+ if (ok != 0 ) {
790
+ printf ("[compositor] Could not move cursor to front. Mouse cursor may be invisible. drmdev_plane_get_max_zpos_value: %s\n" , strerror (ok ));
791
+ continue ;
792
+ }
793
+
794
+ ok = drmdev_plane_supports_setting_zpos_value (req -> drmdev , plane -> plane -> plane_id , max_zpos , & supported );
795
+ if (ok != 0 ) {
796
+ printf ("[compositor] Could not move cursor to front. Mouse cursor may be invisible. drmdev_plane_supports_setting_zpos_value: %s\n" , strerror (ok ));
797
+ continue ;
798
+ }
799
+
800
+ if (supported ) {
801
+ drmdev_atomic_req_put_plane_property (req , plane -> plane -> plane_id , "zpos" , max_zpos );
802
+ } else {
803
+ printf ("[compositor] Could not move cursor to front. Mouse cursor may be invisible. drmdev_plane_supports_setting_zpos_value: %s\n" , strerror (ok ));
804
+ continue ;
805
+ }
716
806
}
717
807
}
718
808
@@ -865,6 +955,17 @@ static bool on_present_layers(
865
955
}
866
956
}
867
957
}
958
+
959
+ int64_t min_zpos ;
960
+ for_each_unreserved_plane_in_atomic_req (req , plane ) {
961
+ if (plane -> type == DRM_PLANE_TYPE_PRIMARY ) {
962
+ ok = drmdev_plane_get_min_zpos_value (req -> drmdev , plane -> plane -> plane_id , & min_zpos );
963
+ if (ok != 0 ) {
964
+ min_zpos = 0 ;
965
+ }
966
+ break ;
967
+ }
968
+ }
868
969
869
970
for (int i = 0 ; i < layers_count ; i ++ ) {
870
971
if (layers [i ]-> type == kFlutterLayerContentTypeBackingStore ) {
@@ -899,7 +1000,7 @@ static bool on_present_layers(
899
1000
0 ,
900
1001
compositor -> drmdev -> selected_mode -> hdisplay ,
901
1002
compositor -> drmdev -> selected_mode -> vdisplay ,
902
- plane -> type == DRM_PLANE_TYPE_PRIMARY ? 0 : 1
1003
+ i + min_zpos
903
1004
);
904
1005
if (ok != 0 ) {
905
1006
fprintf (stderr , "[compositor] Could not present backing store. rendertarget->present: %s\n" , strerror (ok ));
@@ -917,7 +1018,7 @@ static bool on_present_layers(
917
1018
(int ) round (layers [i ]-> offset .y ),
918
1019
(int ) round (layers [i ]-> size .width ),
919
1020
(int ) round (layers [i ]-> size .height ),
920
- i ,
1021
+ i + min_zpos ,
921
1022
cb_data -> userdata
922
1023
);
923
1024
if (ok != 0 ) {
@@ -1003,8 +1104,6 @@ int compositor_remove_view_callbacks(int64_t view_id) {
1003
1104
return 0 ;
1004
1105
}
1005
1106
1006
- /// DRM HARDWARE PLANE RESERVATION
1007
-
1008
1107
/// COMPOSITOR INITIALIZATION
1009
1108
int compositor_initialize (struct drmdev * drmdev ) {
1010
1109
compositor .drmdev = drmdev ;
0 commit comments