Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it possible to build this repo on Yocto and open dGPU for surfaceflinger #130

Merged
merged 2 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/egl/drivers/dri2/egl_dri2.c
Original file line number Diff line number Diff line change
Expand Up @@ -1557,9 +1557,11 @@ dri2_create_context(_EGLDisplay *disp, _EGLConfig *conf,
} else
dri_config = NULL;

#ifdef HAVE_ANDROID_PLATFORM
if (intel_lower_ctx_priority()) {
dri2_ctx->base.ContextPriority = EGL_CONTEXT_PRIORITY_LOW_IMG;
}
#endif

if (!dri2_fill_context_attribs(dri2_ctx, dri2_dpy, ctx_attribs,
&num_attribs))
Expand Down
55 changes: 30 additions & 25 deletions src/intel/common/intel_check.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,29 +40,33 @@ get_pid_name(pid_t pid, char *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);
   if (property_get(dGPU_prop, vendor_buf, NULL) > 0) {
      if (vendor_buf[0] == '1') {
         return true;
      }
   }
char dGPU_prop[BUF_SIZE];
char vendor_buf[PROPERTY_VALUE_MAX];
sprintf(dGPU_prop, "persist.vendor.intel.dGPU.%s", target);
if (property_get(dGPU_prop, vendor_buf, NULL) > 0) {
if (vendor_buf[0] == '1') {
return true;
}
}
return false;
}

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

// Prefer dGPU for compositing in surfaceflinger since dGPU covers more
// scenarios than iGPU.
if (!strcmp(target, "surfaceflinger"))
return true;

for (ptr=str_char; *ptr!=NULL; ptr++)
{
if(!strcmp(target, *ptr)) {
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) {
vendor_buf, NULL) > 0) {
if (vendor_buf[0] == '1') {
return true;
}
Expand All @@ -72,7 +76,8 @@ is_target_process(char *target)
return false;
}

bool intel_is_dgpu_render(void) {
bool intel_is_dgpu_render(void)
{
pid_t process_id = getpid();
char process_name[BUF_SIZE];

Expand All @@ -86,18 +91,18 @@ bool intel_lower_ctx_priority(void)
char process_name[BUF_SIZE];
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);
   if (property_get(lower_pri, vendor_buf, NULL) > 0) {
      if (vendor_buf[0] == '1') {
         return true;
      }
   }
char lower_pri[BUF_SIZE];
char vendor_buf[PROPERTY_VALUE_MAX];
sprintf(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;
}
}
return false;
}

bool has_local_mem(int fd)
static bool has_local_mem(int fd)
{
struct drm_i915_query_item item = {
.query_id = DRM_I915_QUERY_MEMORY_REGIONS,
Expand Down
1 change: 0 additions & 1 deletion src/intel/common/intel_check.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ extern "C" {
bool intel_is_dgpu_render(void);
bool intel_lower_ctx_priority(void);
bool is_dgpu(int id);
bool has_local_mem(int fd);
int get_intel_node_num(void);
#ifdef __cplusplus
}
Expand Down
9 changes: 7 additions & 2 deletions src/intel/common/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ files_libintel_common = files(
'intel_mem.c',
'intel_mem.h',
'intel_pixel_hash.h',
'intel_check.c',
'intel_check.h',
)

files_batch_decoder = files(
Expand Down Expand Up @@ -86,6 +84,13 @@ batch_decoder_dependencies = []
files_libintel_common += files_batch_decoder
#endif

if with_platform_android
files_libintel_common += files(
'intel_check.c',
'intel_check.h',
)
endif

libintel_common = static_library(
'intel_common',
[files_libintel_common, genX_xml_h, sha1_h],
Expand Down
4 changes: 4 additions & 0 deletions src/intel/vulkan/anv_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@
#include "common/intel_aux_map.h"
#include "common/intel_uuid.h"
#include "common/i915/intel_gem.h"
#ifdef ANDROID
#include "common/intel_check.h"
#endif
#include "perf/intel_perf.h"

#include "i915/anv_device.h"
Expand Down Expand Up @@ -2170,6 +2172,7 @@ anv_physical_device_try_create(struct vk_instance *vk_instance,
goto fail_fd;
}

#ifdef ANDROID
if (get_intel_node_num() > 1) {
if (!is_dgpu(fd) && intel_is_dgpu_render()) {
result = VK_ERROR_INCOMPATIBLE_DRIVER;
Expand All @@ -2181,6 +2184,7 @@ anv_physical_device_try_create(struct vk_instance *vk_instance,
goto fail_fd;
}
}
#endif

if (devinfo.ver == 20) {
mesa_logw("Vulkan not yet supported on %s", devinfo.name);
Expand Down
4 changes: 3 additions & 1 deletion src/intel/vulkan/i915/anv_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,14 +256,16 @@ anv_i915_set_queue_parameters(
}
}

#ifdef ANDROID
if (intel_lower_ctx_priority()) {
int ret = anv_gem_set_context_param(device->fd, device->context_id,
I915_CONTEXT_PARAM_PRIORITY,
VK_QUEUE_GLOBAL_PRIORITY_LOW_KHR);
if (ret != 0) {
return vk_error(device, VK_ERROR_INITIALIZATION_FAILED);
}
}
}
#endif

return VK_SUCCESS;
}
Expand Down