[client] egl/cas: release consts when no longer needed

This commit is contained in:
Geoffrey McRae 2021-08-11 20:42:56 +10:00
parent 8b2db071d8
commit 5a2f34d71c

View File

@ -74,7 +74,8 @@ static void egl_filterFFXCASEarlyInit(void)
static void casUpdateConsts(EGL_FilterFFXCAS * this)
{
ffxCasConst((uint32_t *) this->consts->data, this->sharpness, this->width, this->height,
ffxCasConst((uint32_t *) this->consts->data, this->sharpness,
this->width, this->height,
this->width, this->height);
}
@ -103,6 +104,12 @@ static bool egl_filterFFXCASInit(EGL_Filter ** filter)
}
this->consts = countedBufferNew(8 * sizeof(GLuint));
if (!this->consts)
{
DEBUG_ERROR("Failed to allocate consts buffer");
goto error_shader;
}
egl_shaderSetUniforms(this->shader, &(EGL_Uniform) {
.type = EGL_UNIFORM_TYPE_4UIV,
.location = egl_shaderGetUniform(this->shader, "uConsts"),
@ -115,7 +122,7 @@ static bool egl_filterFFXCASInit(EGL_Filter ** filter)
if (!egl_framebufferInit(&this->fb))
{
DEBUG_ERROR("Failed to initialize the framebuffer");
goto error_shader;
goto error_consts;
}
glGenSamplers(1, &this->sampler);
@ -127,6 +134,9 @@ static bool egl_filterFFXCASInit(EGL_Filter ** filter)
*filter = &this->base;
return true;
error_consts:
countedBufferRelease(&this->consts);
error_shader:
egl_shaderFree(&this->shader);
@ -140,6 +150,7 @@ static void egl_filterFFXCASFree(EGL_Filter * filter)
EGL_FilterFFXCAS * this = UPCAST(EGL_FilterFFXCAS, filter);
egl_shaderFree(&this->shader);
countedBufferRelease(&this->consts);
egl_framebufferFree(&this->fb);
glDeleteSamplers(1, &this->sampler);
free(this);