diff --git a/backend/Backend.cpp b/backend/Backend.cpp index f14fab30..ec860a0b 100644 --- a/backend/Backend.cpp +++ b/backend/Backend.cpp @@ -123,8 +123,9 @@ bool Backend::IsClientLayer(HwcDisplay *display, HwcLayer *layer) { !layer->IsLayerUsableAsDevice() || display->color_transform_hint() != HAL_COLOR_TRANSFORM_IDENTITY || (layer->GetLayerData().pi.RequireScalingOrPhasing() && - display->GetHwc2()->GetResMan().ForcedScalingWithGpu()) || - (!IsVideoLayer(layer) && IsDownScaling(layer)) || + display->GetHwc2()->GetResMan().ForcedScalingWithGpu()) || + (!IsVideoLayer(layer) && IsDownScaling(layer)) || + (has_local_memory_flag(layer->GetLayerData().bi->usage) && !layer->GetAllowP2P()) || (!display->IsInHeadlessMode() && display->GetPipe().device->IsIvshmDev()); } diff --git a/hwc2_device/HwcLayer.cpp b/hwc2_device/HwcLayer.cpp index d2b03687..0a7cc5cf 100644 --- a/hwc2_device/HwcLayer.cpp +++ b/hwc2_device/HwcLayer.cpp @@ -301,7 +301,8 @@ void HwcLayer::ImportFb() { is_pixel_blend_mode_supported = false; int kms_fd = parent_->GetPipe().device->GetFd(); - bool use_shadow_fds = parent_->GetPipe().device->GetName() == "virtio_gpu" && + bool use_shadow_fds = has_local_memory_flag(layer_data_.bi->usage) && + parent_->GetPipe().device->GetName() == "virtio_gpu" && !allow_p2p_ && (intel_dgpu_fd() >= 0) && !virtio_gpu_allow_p2p(kms_fd) && InitializeBlitter(layer_data_.bi.value()); layer_data_.bi->use_shadow_fds = use_shadow_fds; diff --git a/hwc2_device/HwcLayer.h b/hwc2_device/HwcLayer.h index ead33966..c8344f7f 100644 --- a/hwc2_device/HwcLayer.h +++ b/hwc2_device/HwcLayer.h @@ -67,6 +67,9 @@ class HwcLayer { return layer_data_; } + bool GetAllowP2P() const { + return allow_p2p_; + } // Layer hooks HWC2::Error SetCursorPosition(int32_t /*x*/, int32_t /*y*/); HWC2::Error SetLayerBlendMode(int32_t mode); diff --git a/utils/intel_blit.h b/utils/intel_blit.h index 254d7691..e4b19094 100644 --- a/utils/intel_blit.h +++ b/utils/intel_blit.h @@ -22,6 +22,9 @@ #include "UniqueFd.h" +/* Buffer is allocated on dGPU local memory if this flag is set */ +#define GRALLOC_USAGE_PRIVATE_2 (1ull << 30) + #define I915_TILING_4 9 struct intel_info { @@ -49,6 +52,9 @@ int intel_create_buffer(struct intel_info *info, uint64_t modifier, uint32_t *out_handle); int intel_dgpu_fd(); bool virtio_gpu_allow_p2p(int virtgpu_fd); +inline bool has_local_memory_flag(uint64_t usage) { + return (usage & GRALLOC_USAGE_PRIVATE_2) != 0; +} class IntelBlitter { public: