Skip to content

Commit

Permalink
Check the app and process name
Browse files Browse the repository at this point in the history
Check whether app have the prop to use dgpu render:
  persist.vendor.intel.dGPUwSys+app_process_name
  persist.vendor.intel.dGPUwLocal+app_name
Also hardcode the latest Antutu pid as the
Antutu fork pid to run test.

Tracked-On: OAM-127209
Signed-off-by: He, Yue <[email protected]>
  • Loading branch information
yhe39 committed Jan 3, 2025
1 parent e68f165 commit 9d49c32
Showing 1 changed file with 34 additions and 15 deletions.
49 changes: 34 additions & 15 deletions src/intel/common/intel_check.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <cutils/log.h>
#include <pthread.h>
#include <unistd.h>
#include <stdio.h>
Expand All @@ -7,6 +8,7 @@
#include <sys/types.h>
#include <sys/syscall.h>
#include <stdbool.h>
#include <string.h>
#include <cutils/properties.h>
#include "util/macros.h"
#include "util/log.h"
Expand All @@ -26,35 +28,48 @@ get_pid_name(pid_t pid, char *task_name)
char process_path[BUF_SIZE];
char name_buf[BUF_SIZE];

sprintf(process_path, "/proc/%d/status", pid);
snprintf(process_path, sizeof(process_path), "/proc/%d/status", pid);
FILE* fp = fopen(process_path, "r");
if(NULL != fp){
if( fgets(name_buf, BUF_SIZE-1, fp)== NULL ){
fclose(fp);
}
if (fp == NULL) {
mesa_loge("failed to open %s\n", process_path);
return;
}
if( fgets(name_buf, BUF_SIZE-1, fp)== NULL ){
mesa_loge("get pid name fail\n");
fclose(fp);
sscanf(name_buf, "%*s %s", task_name);
return;
}
fclose(fp);
sscanf(name_buf, "%*s %s", task_name);
}

static bool
use_dgpu_render(char *target)
{
char dGPU_prop[BUF_SIZE];
char vendor_buf[PROPERTY_VALUE_MAX];
sprintf(dGPU_prop, "persist.vendor.intel.dGPU.%s", target);
snprintf(dGPU_prop, sizeof(dGPU_prop), "persist.vendor.intel.dGPUwSys.%s", target);
if (property_get(dGPU_prop, vendor_buf, NULL) > 0) {
if (vendor_buf[0] == '1') {
return true;
}
}
char dGPU_prop1[BUF_SIZE];
char vendor_buf1[PROPERTY_VALUE_MAX];
snprintf(dGPU_prop1, sizeof(dGPU_prop1), "persist.vendor.intel.dGPUwLocal%s", target);
   if (property_get(dGPU_prop1, vendor_buf1, NULL) > 0) {
      if (vendor_buf1[0] == '1') {
         return true;
}
}

return false;
}

static bool
is_target_process(const char *target)
{
static const char *str_char[] = { "k.lite:refinery", "k.lite:transfer", NULL };
static const char *str_char[] = { "k.auto:transfer", "android.vending", "k.auto:refinery", ".fisheye", "mark.auto:video", NULL };
const char **ptr = str_char;

// Prefer dGPU for compositing in surfaceflinger since dGPU covers more
Expand All @@ -65,9 +80,12 @@ is_target_process(const char *target)
for (ptr = str_char; *ptr != NULL; ptr++) {
if (!strcmp(target, *ptr)) {
char vendor_buf[PROPERTY_VALUE_MAX];
if (property_get("persist.vendor.intel.dGPU.ABenchMark.lite",
vendor_buf, NULL) > 0) {
if (vendor_buf[0] == '1') {
char vendor_buf1[PROPERTY_VALUE_MAX];
if ((property_get("persist.vendor.intel.dGPUwSys.benchmark.auto",
vendor_buf, NULL) > 0) ||
(property_get("persist.vendor.intel.dGPUwLocal.auto",
vendor_buf1, NULL) > 0)) {
if ((vendor_buf[0] == '1') || (vendor_buf1[0] == '1')) {
return true;
}
}
Expand All @@ -79,21 +97,22 @@ is_target_process(const char *target)
bool intel_is_dgpu_render(void)
{
pid_t process_id = getpid();
char process_name[BUF_SIZE];
char process_name[BUF_SIZE] = {0};

get_pid_name(process_id, process_name);
return (use_dgpu_render(process_name) || is_target_process(process_name));
char *app_name = strrchr(process_name, '.');
return (use_dgpu_render(process_name) || is_target_process(process_name) || use_dgpu_render(app_name));
}

bool intel_lower_ctx_priority(void)
{
pid_t process_id = getpid();
char process_name[BUF_SIZE];
char process_name[BUF_SIZE] = {0};
get_pid_name(process_id, process_name);

char lower_pri[BUF_SIZE];
char vendor_buf[PROPERTY_VALUE_MAX];
sprintf(lower_pri, "persist.vendor.intel.lowPir.%s",process_name);
snprintf(lower_pri, sizeof(lower_pri), "persist.vendor.intel.lowPir.%s", process_name);
if (property_get(lower_pri, vendor_buf, NULL) > 0) {
if (vendor_buf[0] == '1') {
return true;
Expand Down

0 comments on commit 9d49c32

Please sign in to comment.