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 committed Dec 11, 2024
1 parent 29d219b commit a96bb3b
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 13 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
17 changes: 9 additions & 8 deletions i915.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,9 @@ static int i915_add_combinations(struct driver *drv)
{
struct i915_device *i915 = drv->priv;

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;
const uint64_t scanout_and_render = BO_USE_RENDER_MASK | BO_USE_SCANOUT | BO_USE_LOCAL_MEMORY;
const uint64_t render = BO_USE_RENDER_MASK | BO_USE_LOCAL_MEMORY;
const uint64_t texture_only = BO_USE_TEXTURE_MASK | BO_USE_LOCAL_MEMORY;
uint64_t texture_flags = BO_USE_TEXTURE_MASK;
bool is_kvm = vm_type() & HYPERTYPE_TYPE_KVM;

Expand Down Expand Up @@ -915,14 +914,16 @@ 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
2 changes: 1 addition & 1 deletion virtgpu_cross_domain.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ static void add_combinations(struct driver *drv)
metadata.modifier = DRM_FORMAT_MOD_LINEAR;

drv_add_combinations(drv, scanout_render_formats, ARRAY_SIZE(scanout_render_formats),
&metadata, BO_USE_RENDER_MASK | BO_USE_SCANOUT);
&metadata, BO_USE_RENDER_MASK | BO_USE_SCANOUT | BO_USE_LOCAL_MEMORY);

drv_add_combinations(drv, texture_only_formats, ARRAY_SIZE(texture_only_formats), &metadata,
BO_USE_TEXTURE_MASK);
Expand Down
8 changes: 4 additions & 4 deletions virtgpu_virgl.c
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ static int virgl_init(struct driver *drv)
* hypervisor can show it. */
virgl_add_combinations(drv, render_target_formats,
ARRAY_SIZE(render_target_formats), &LINEAR_METADATA,
BO_USE_RENDER_MASK | BO_USE_SCANOUT);
BO_USE_RENDER_MASK | BO_USE_SCANOUT | BO_USE_LOCAL_MEMORY);
virgl_add_combinations(drv, texture_source_formats,
ARRAY_SIZE(texture_source_formats), &LINEAR_METADATA,
BO_USE_TEXTURE_MASK);
Expand All @@ -638,16 +638,16 @@ static int virgl_init(struct driver *drv)
} else {
/* Virtio primary plane only allows this format. */
virgl_add_combination(drv, DRM_FORMAT_XRGB8888, &LINEAR_METADATA,
BO_USE_RENDER_MASK | BO_USE_SCANOUT);
BO_USE_RENDER_MASK | BO_USE_SCANOUT | BO_USE_LOCAL_MEMORY);
/* Virtio cursor plane only allows this format and Chrome cannot live without
* ARGB888 renderable format. */
virgl_add_combination(drv, DRM_FORMAT_ARGB8888, &LINEAR_METADATA,
BO_USE_RENDER_MASK | BO_USE_CURSOR);
BO_USE_RENDER_MASK | BO_USE_CURSOR | BO_USE_LOCAL_MEMORY);
/* Android needs more, but they cannot be bound as scanouts anymore after
* "drm/virtio: fix DRM_FORMAT_* handling" */
virgl_add_combinations(drv, render_target_formats,
ARRAY_SIZE(render_target_formats), &LINEAR_METADATA,
BO_USE_RENDER_MASK);
BO_USE_RENDER_MASK | BO_USE_LOCAL_MEMORY);
virgl_add_combinations(drv, dumb_texture_source_formats,
ARRAY_SIZE(dumb_texture_source_formats), &LINEAR_METADATA,
BO_USE_TEXTURE_MASK);
Expand Down

0 comments on commit a96bb3b

Please sign in to comment.