@@ -130,6 +130,21 @@ bool DisplayPlaneManager::ValidateLayers(
130130 j->get ()->SetInUse (false );
131131 }
132132
133+ size_t video_layers = 0 ;
134+ for (size_t lindex = add_index; lindex < layers.size (); lindex++) {
135+ if (layers[lindex].IsVideoLayer ())
136+ video_layers++;
137+ }
138+ // If video layers is more than available planes
139+ // We are going to force all the layers bo be composited by VA path
140+ if (video_layers >= overlay_planes_.size () - composition.size ()) {
141+ ForceVppForAllLayers (commit_planes, composition, layers, add_index,
142+ mark_later, false );
143+ *re_validation_needed = false ;
144+ *commit_checked = true ;
145+ return true ;
146+ }
147+
133148 std::vector<OverlayLayer *> cursor_layers;
134149 auto layer_begin = layers.begin ();
135150 auto layer_end = layers.end ();
@@ -850,6 +865,64 @@ bool DisplayPlaneManager::CheckPlaneFormat(uint32_t format) {
850865 return overlay_planes_.at (0 )->IsSupportedFormat (format);
851866}
852867
868+ void DisplayPlaneManager::ForceVppForAllLayers (
869+ std::vector<OverlayPlane> &commit_planes,
870+ DisplayPlaneStateList &composition, std::vector<OverlayLayer> &layers,
871+ size_t add_index, std::vector<NativeSurface *> &mark_later,
872+ bool recycle_resources) {
873+ auto layer_begin = layers.begin () + add_index;
874+ // all planes already assigned, let's reset them into one plane VPP
875+ if (composition.size () >= overlay_planes_.size ()) {
876+ layer_begin = layers.begin ();
877+ for (DisplayPlaneState &plane : composition) {
878+ MarkSurfacesForRecycling (&plane, mark_later, recycle_resources);
879+ }
880+ DisplayPlaneStateList ().swap (composition);
881+ std::vector<OverlayPlane>().swap (commit_planes);
882+ auto overlay_begin = overlay_planes_.begin ();
883+ // Let's mark all planes as free to be used.
884+ for (auto j = overlay_begin; j < overlay_planes_.end (); ++j) {
885+ j->get ()->SetInUse (false );
886+ }
887+ }
888+
889+ auto layer_end = layers.end ();
890+ OverlayLayer *primary_layer = &(*(layer_begin));
891+ DisplayPlane *current_plane = overlay_planes_.at (composition.size ()).get ();
892+ composition.emplace_back (current_plane, primary_layer, this ,
893+ primary_layer->GetZorder (), display_transform_);
894+ DisplayPlaneState &last_plane = composition.back ();
895+ last_plane.ForceGPURendering ();
896+ layer_begin++;
897+ #ifdef SURFACE_TRACING
898+ ISURFACETRACE (" Added layer in ForceGpuForAllLayers: %d \n " ,
899+ primary_layer->GetZorder ());
900+ #endif
901+
902+ for (auto i = layer_begin; i != layer_end; ++i) {
903+ #ifdef SURFACE_TRACING
904+ ISURFACETRACE (" Added layer in ForceGpuForAllLayers: %d \n " , i->GetZorder ());
905+ #endif
906+ last_plane.AddLayer (&(*(i)));
907+ i->SetLayerComposition (OverlayLayer::kGpu );
908+ }
909+ last_plane.SetVideoPlane (true );
910+ EnsureOffScreenTarget (last_plane);
911+ current_plane->SetInUse (true );
912+
913+ commit_planes.emplace_back (
914+ OverlayPlane (last_plane.GetDisplayPlane (), last_plane.GetOverlayLayer ()));
915+ // Check for Any display transform to be applied.
916+ ValidateForDisplayTransform (last_plane, commit_planes);
917+ // Check for any change to scalar usage.
918+ ValidateForDisplayScaling (last_plane, commit_planes);
919+ // Check for Downscaling.
920+ ValidateForDownScaling (last_plane, commit_planes);
921+ // Reset andy Scanout validation state.
922+ uint32_t validation_done = DisplayPlaneState::ReValidationType::kScanout ;
923+ last_plane.RevalidationDone (validation_done);
924+ }
925+
853926void DisplayPlaneManager::ForceGpuForAllLayers (
854927 std::vector<OverlayPlane> &commit_planes,
855928 DisplayPlaneStateList &composition, std::vector<OverlayLayer> &layers,
0 commit comments