mirror of
https://git.eden-emu.dev/eden-emu/libadrenotools
synced 2026-02-04 02:41:22 +01:00
Merge pull request 'initial adrenotools env loader' (#1) from MrPurple666/libadrenotools:master into master
Reviewed-on: https://git.eden-emu.dev/eden-emu/libadrenotools/pulls/1
This commit is contained in:
@@ -66,6 +66,18 @@ bool adrenotools_validate_gpu_mapping(void *handle);
|
||||
*/
|
||||
void adrenotools_set_turbo(bool turbo);
|
||||
|
||||
/**
|
||||
* @brief Sets a Freedreno/Turnip environment variable for driver configuration
|
||||
* @param varName The environment variable name (e.g., "TU_DEBUG", "FD_RD_DUMP", "FD_MESA_DEBUG")
|
||||
* @param value The value to set
|
||||
* @note IMPORTANT: Must be called BEFORE adrenotools_open_libvulkan() to take effect
|
||||
* @note Valid options documented at https://docs.mesa3d.org/drivers/freedreno.html
|
||||
* @note Example TU_DEBUG values: "sysmem", "gmem", "nobin", "forcebin", "noubwc", "nolrz"
|
||||
* @note Example FD_RD_DUMP values: "enable", "combine", "full", "trigger"
|
||||
* @return true on success, false if varName or value is NULL
|
||||
*/
|
||||
bool adrenotools_set_freedreno_env(const char *varName, const char *value);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -15,11 +15,19 @@
|
||||
#include "hook/hook_impl_params.h"
|
||||
#include <adrenotools/driver.h>
|
||||
#include <unistd.h>
|
||||
#include <cstring>
|
||||
|
||||
#define TAG "adrenotools"
|
||||
#define LOGI(fmt, ...) __android_log_print(ANDROID_LOG_INFO, TAG, fmt, ##__VA_ARGS__)
|
||||
#define LOGW(fmt, ...) __android_log_print(ANDROID_LOG_WARN, TAG, fmt, ##__VA_ARGS__)
|
||||
#define LOGE(fmt, ...) __android_log_print(ANDROID_LOG_ERROR, TAG, fmt, ##__VA_ARGS__)
|
||||
|
||||
void *adrenotools_open_libvulkan(int dlopenFlags, int featureFlags, const char *tmpLibDir, const char *hookLibDir, const char *customDriverDir, const char *customDriverName, const char *fileRedirectDir, void **userMappingHandle) {
|
||||
// Bail out if linkernsbypass failed to load, this probably means we're on api < 28
|
||||
if (!linkernsbypass_load_status())
|
||||
if (!linkernsbypass_load_status()) {
|
||||
LOGE("adrenotools_open_libvulkan: linkernsbypass_load_status() failed");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Always use memfd on Q+ since it's guaranteed to work
|
||||
if (android_get_device_api_level() >= 29)
|
||||
@@ -208,3 +216,22 @@ void adrenotools_set_turbo(bool turbo) {
|
||||
ioctl(kgslFd, IOCTL_KGSL_SETPROPERTY, &prop);
|
||||
close (kgslFd);
|
||||
}
|
||||
|
||||
bool adrenotools_set_freedreno_env(const char *varName, const char *value) {
|
||||
if (!varName || !value || std::strlen(varName) == 0)
|
||||
return false;
|
||||
|
||||
int result = setenv(varName, value, 1);
|
||||
if (result != 0) {
|
||||
LOGE("adrenotools_set_freedreno_env: Failed to set '%s' (errno: %d)", varName, errno);
|
||||
return false;
|
||||
}
|
||||
|
||||
const char *verifyValue = std::getenv(varName);
|
||||
if (verifyValue && std::strcmp(verifyValue, value) == 0) {
|
||||
return true;
|
||||
} else {
|
||||
LOGE("adrenotools_set_freedreno_env: Verification failed for '%s'", varName);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
|
||||
#define TAG "hook_impl"
|
||||
#define LOGI(fmt, ...) __android_log_print(ANDROID_LOG_INFO, TAG, fmt, ##__VA_ARGS__)
|
||||
#define LOGW(fmt, ...) __android_log_print(ANDROID_LOG_WARN, TAG, fmt, ##__VA_ARGS__)
|
||||
#define LOGE(fmt, ...) __android_log_print(ANDROID_LOG_ERROR, TAG, fmt, ##__VA_ARGS__)
|
||||
|
||||
const HookImplParams *hook_params; //!< Bunch of info needed to load/patch the driver
|
||||
int (*gsl_memory_alloc_pure_sym)(uint32_t, uint32_t, void *);
|
||||
@@ -27,6 +29,11 @@ using gsl_memory_free_pure_t = decltype(gsl_memory_free_pure_sym);
|
||||
|
||||
__attribute__((visibility("default"))) void init_hook_param(const void *param) {
|
||||
hook_params = reinterpret_cast<const HookImplParams *>(param);
|
||||
|
||||
if (!hook_params) {
|
||||
LOGE("init_hook_param: Received NULL hook_params!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
__attribute__((visibility("default"))) void init_gsl(void *alloc, void *alloc64, void *free) {
|
||||
|
||||
Reference in New Issue
Block a user