[Fix] (settings): fix some wild pointer bugs

This commit is contained in:
Swung0x48 2025-04-29 09:27:06 +08:00
parent 8727ed43fd
commit 5e46d9e26a
4 changed files with 14 additions and 9 deletions

View File

@ -20,7 +20,7 @@ static const char *vk_lib[] = {
};
const char* getGPUInfo() {
std::string getGPUInfo() {
EGLDisplay eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
if (eglDisplay == EGL_NO_DISPLAY || eglInitialize(eglDisplay, nullptr, nullptr) != EGL_TRUE)
return nullptr;
@ -53,7 +53,7 @@ const char* getGPUInfo() {
return nullptr;
}
const char* renderer = nullptr;
std::string renderer;
void* lib = open_lib(gles3_lib, nullptr);
if (lib) {
GLES.glGetString = (const GLubyte * (*)( GLenum ))dlsym(lib, "glGetString");

View File

@ -6,13 +6,14 @@
#define MOBILEGLUES_PLUGIN_GPU_UTILS_H
#include <string.h>
#include <string>
std::string getGPUInfo();
#ifdef __cplusplus
extern "C" {
#endif
const char *getGPUInfo();
int isAdreno(const char *gpu);
int isAdreno740(const char *gpu);

View File

@ -57,6 +57,8 @@ void init_settings() {
char* var = getenv("MG_DIR_PATH");
LOG_V("MG_DIR_PATH = %s", var ? var : "(null)")
if (fclVersion == 0 && zlVersion == 0 && pgwVersion == 0 && !var) {
LOG_V("Unsupported launcher detected, force using default config.")
enableANGLE = 0;
@ -68,16 +70,17 @@ void init_settings() {
}
// Determining actual ANGLE mode
const char* gpuString = getGPUInfo();
LOG_D("GPU: %s", gpuString)
std::string gpuString = getGPUInfo();
const char* gpu_cstr = gpuString.c_str();
LOG_D("GPU: %s", gpu_cstr ? gpu_cstr : "(unknown)")
if (enableANGLE == 2 || enableANGLE == 3) {
// Force enable / disable
global_settings.angle = enableANGLE - 2;
} else {
int isQcom = isAdreno(gpuString);
int is740 = isAdreno740(gpuString);
//int is830 = isAdreno830(gpuString);
int isQcom = isAdreno(gpu_cstr);
int is740 = isAdreno740(gpu_cstr);
//int is830 = isAdreno830(gpu_cstr);
int hasVk13 = hasVulkan13();
LOG_D("Is Adreno? = %s", isQcom ? "true" : "false")

View File

@ -368,6 +368,7 @@ GLuint g_compute_program = 0;
char g_compile_info[1024];
GLuint compile_compute_program(const std::string& src) {
INIT_CHECK_GL_ERROR
auto program = GLES.glCreateProgram();
CHECK_GL_ERROR_NO_INIT
GLuint shader = GLES.glCreateShader(GL_COMPUTE_SHADER);