From 602268b72d3b914e305c7e44d1b7f9437f2bd51a Mon Sep 17 00:00:00 2001 From: "He, Yue" Date: Fri, 1 Nov 2024 08:02:08 +0000 Subject: [PATCH] Add the special gralloc private 2 flag check If has the GRALLOC_USAGE_PRIVATE_2, use local memory, otherwise use the system memroy. Tracked-On: OAM-127209 Signed-off-by: He, Yue --- cros_gralloc/cros_gralloc_helpers.cc | 1 + drv.h | 1 + drv_priv.h | 6 ++++-- i915.c | 10 ++++++---- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/cros_gralloc/cros_gralloc_helpers.cc b/cros_gralloc/cros_gralloc_helpers.cc index 6ded388..83aefed 100644 --- a/cros_gralloc/cros_gralloc_helpers.cc +++ b/cros_gralloc/cros_gralloc_helpers.cc @@ -160,6 +160,7 @@ uint64_t cros_gralloc_convert_usage(uint64_t usage) BO_USE_SENSOR_DIRECT_DATA); handle_usage(&usage, BUFFER_USAGE_GPU_DATA_BUFFER, &use_flags, BO_USE_GPU_DATA_BUFFER); handle_usage(&usage, BUFFER_USAGE_FRONT_RENDERING_MASK, &use_flags, BO_USE_FRONT_RENDERING); + handle_usage(&usage, GRALLOC_USAGE_PRIVATE_2, &use_flags, BO_USE_LOCAL_MEMORY); if (usage) { ALOGE("Unhandled gralloc usage: %llx", (unsigned long long)usage); diff --git a/drv.h b/drv.h index d4d0ff2..5da5b52 100644 --- a/drv.h +++ b/drv.h @@ -45,6 +45,7 @@ extern "C" { #define BO_USE_RENDERSCRIPT (1ull << 17) #define BO_USE_GPU_DATA_BUFFER (1ull << 18) #define BO_USE_SENSOR_DIRECT_DATA (1ull << 19) +#define BO_USE_LOCAL_MEMORY (1ull << 20) #define BO_USE_ARC_SCREEN_CAP_PROBED (1ull << 63) diff --git a/drv_priv.h b/drv_priv.h index 95279a0..e721d76 100644 --- a/drv_priv.h +++ b/drv_priv.h @@ -132,11 +132,13 @@ struct backend { // clang-format off #define BO_USE_RENDER_MASK (BO_USE_LINEAR | BO_USE_RENDERING | BO_USE_RENDERSCRIPT | \ BO_USE_SW_READ_OFTEN | BO_USE_SW_WRITE_OFTEN | BO_USE_SW_READ_RARELY | \ - BO_USE_SW_WRITE_RARELY | BO_USE_TEXTURE | BO_USE_FRONT_RENDERING) + BO_USE_SW_WRITE_RARELY | BO_USE_TEXTURE | BO_USE_FRONT_RENDERING | \ + BO_USE_LOCAL_MEMORY) #define BO_USE_TEXTURE_MASK (BO_USE_LINEAR | BO_USE_RENDERSCRIPT | BO_USE_SW_READ_OFTEN | \ BO_USE_SW_WRITE_OFTEN | BO_USE_SW_READ_RARELY | \ - BO_USE_SW_WRITE_RARELY | BO_USE_TEXTURE | BO_USE_FRONT_RENDERING) + BO_USE_SW_WRITE_RARELY | BO_USE_TEXTURE | BO_USE_FRONT_RENDERING | \ + BO_USE_LOCAL_MEMORY) #define BO_USE_SW_MASK (BO_USE_SW_READ_OFTEN | BO_USE_SW_WRITE_OFTEN | \ BO_USE_SW_READ_RARELY | BO_USE_SW_WRITE_RARELY | BO_USE_FRONT_RENDERING) diff --git a/i915.c b/i915.c index a07a7b5..3ee34da 100644 --- a/i915.c +++ b/i915.c @@ -217,7 +217,6 @@ static int i915_add_combinations(struct driver *drv) const uint64_t scanout_and_render = BO_USE_RENDER_MASK | BO_USE_SCANOUT; const uint64_t render = BO_USE_RENDER_MASK; const uint64_t texture_only = BO_USE_TEXTURE_MASK; - uint64_t render_flags = BO_USE_RENDER_MASK; uint64_t texture_flags = BO_USE_TEXTURE_MASK; bool is_kvm = vm_type() & HYPERTYPE_TYPE_KVM; @@ -915,14 +914,17 @@ static int i915_bo_compute_metadata(struct bo *bo, uint32_t width, uint32_t heig static bool is_need_local(int64_t use_flags) { - static bool local = true; + static bool local = false; + + if (use_flags & BO_USE_LOCAL_MEMORY) { + local = true; + } if (use_flags & BO_USE_SW_READ_RARELY || use_flags & BO_USE_SW_READ_OFTEN || use_flags & BO_USE_SW_WRITE_RARELY || use_flags & BO_USE_SW_WRITE_OFTEN) { local = false; - } else { - local = true; } + return local; }