Skip to content

Commit

Permalink
Add the special gralloc private 2 flag check
Browse files Browse the repository at this point in the history
If has the GRALLOC_USAGE_PRIVATE_2, use local memory,
otherwise use the system memroy.

Tracked-On: OAM-127209
Signed-off-by: He, Yue <[email protected]>
  • Loading branch information
yhe39 authored and sysopenci committed Jan 8, 2025
1 parent 29d219b commit 602268b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions cros_gralloc/cros_gralloc_helpers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
6 changes: 4 additions & 2 deletions drv_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 6 additions & 4 deletions i915.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 602268b

Please sign in to comment.