Skip to content

Commit

Permalink
Make Android specific code specific to Android
Browse files Browse the repository at this point in the history
We have some code specific to Android only and it should be built only
on Android so that this code base could possibly be built on GNU/Linux
systems.

Also replace \xC2\xA0 (non-breaking space) with normal space for
consistence.

Signed-off-by: Weifeng Liu <[email protected]>
  • Loading branch information
phreer committed Aug 13, 2024
1 parent 44ed50f commit 9cc6ce4
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 21 deletions.
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
34 changes: 17 additions & 17 deletions src/intel/common/intel_check.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ 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;
}

Expand Down Expand Up @@ -86,18 +86,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

0 comments on commit 9cc6ce4

Please sign in to comment.