[client] egl: cleanup pointer mess in egl_desktopInit

This commit is contained in:
Geoffrey McRae 2021-08-10 00:48:41 +10:00
parent d24bc75519
commit 30e6a258ad

View File

@ -119,20 +119,21 @@ static void setupFilters(EGL_Desktop * desktop)
egl_textureAddFilter(desktop->texture, desktop->ffxCAS, 1.0f, false); egl_textureAddFilter(desktop->texture, desktop->ffxCAS, 1.0f, false);
} }
bool egl_desktopInit(EGL * egl, EGL_Desktop ** desktop, EGLDisplay * display, bool egl_desktopInit(EGL * egl, EGL_Desktop ** desktop_, EGLDisplay * display,
bool useDMA, int maxRects) bool useDMA, int maxRects)
{ {
*desktop = (EGL_Desktop *)calloc(1, sizeof(EGL_Desktop)); EGL_Desktop * desktop = (EGL_Desktop *)calloc(1, sizeof(EGL_Desktop));
if (!*desktop) if (!desktop)
{ {
DEBUG_ERROR("Failed to malloc EGL_Desktop"); DEBUG_ERROR("Failed to malloc EGL_Desktop");
return false; return false;
} }
*desktop_ = desktop;
(*desktop)->egl = egl; desktop->egl = egl;
(*desktop)->display = display; desktop->display = display;
if (!egl_textureInit(egl, &(*desktop)->texture, display, if (!egl_textureInit(egl, &desktop->texture, display,
useDMA ? EGL_TEXTYPE_DMABUF : EGL_TEXTYPE_FRAMEBUFFER, true)) useDMA ? EGL_TEXTYPE_DMABUF : EGL_TEXTYPE_FRAMEBUFFER, true))
{ {
DEBUG_ERROR("Failed to initialize the desktop texture"); DEBUG_ERROR("Failed to initialize the desktop texture");
@ -140,7 +141,7 @@ bool egl_desktopInit(EGL * egl, EGL_Desktop ** desktop, EGLDisplay * display,
} }
if (!egl_initDesktopShader( if (!egl_initDesktopShader(
&(*desktop)->shader, &desktop->shader,
b_shader_desktop_vert , b_shader_desktop_vert_size, b_shader_desktop_vert , b_shader_desktop_vert_size,
b_shader_desktop_rgb_frag, b_shader_desktop_rgb_frag_size)) b_shader_desktop_rgb_frag, b_shader_desktop_rgb_frag_size))
{ {
@ -148,33 +149,34 @@ bool egl_desktopInit(EGL * egl, EGL_Desktop ** desktop, EGLDisplay * display,
return false; return false;
} }
if (!egl_desktopRectsInit(&(*desktop)->mesh, maxRects)) if (!egl_desktopRectsInit(&desktop->mesh, maxRects))
{ {
DEBUG_ERROR("Failed to initialize the desktop mesh"); DEBUG_ERROR("Failed to initialize the desktop mesh");
return false; return false;
} }
(*desktop)->matrix = countedBufferNew(6 * sizeof(GLfloat)); desktop->matrix = countedBufferNew(6 * sizeof(GLfloat));
if (!(*desktop)->matrix) if (!desktop->matrix)
{ {
DEBUG_ERROR("Failed to allocate the desktop matrix buffer"); DEBUG_ERROR("Failed to allocate the desktop matrix buffer");
return false; return false;
} }
app_registerKeybind(KEY_N, egl_desktop_toggle_nv, *desktop, "Toggle night vision mode"); app_registerKeybind(KEY_N, egl_desktop_toggle_nv, desktop,
"Toggle night vision mode");
(*desktop)->nvMax = option_get_int("egl", "nvGainMax"); desktop->nvMax = option_get_int("egl", "nvGainMax");
(*desktop)->nvGain = option_get_int("egl", "nvGain" ); desktop->nvGain = option_get_int("egl", "nvGain" );
(*desktop)->cbMode = option_get_int("egl", "cbMode" ); desktop->cbMode = option_get_int("egl", "cbMode" );
(*desktop)->scaleAlgo = option_get_int("egl", "scale" ); desktop->scaleAlgo = option_get_int("egl", "scale" );
(*desktop)->useDMA = useDMA; desktop->useDMA = useDMA;
egl_shaderInit(&(*desktop)->ffxCAS); egl_shaderInit(&desktop->ffxCAS);
egl_shaderCompile((*desktop)->ffxCAS, egl_shaderCompile(desktop->ffxCAS,
b_shader_basic_vert , b_shader_basic_vert_size, b_shader_basic_vert , b_shader_basic_vert_size,
b_shader_ffx_cas_frag, b_shader_ffx_cas_frag_size); b_shader_ffx_cas_frag, b_shader_ffx_cas_frag_size);
setupFilters(*desktop); setupFilters(desktop);
return true; return true;
} }