[client] egl: add loadState and saveState for filters

This commit is contained in:
Quantum 2021-08-28 15:57:54 -04:00 committed by Geoffrey McRae
parent 4adb425337
commit 084837b936
4 changed files with 66 additions and 5 deletions

View File

@ -50,6 +50,12 @@ typedef struct EGL_FilterOps
* Returns true if a redraw is required */ * Returns true if a redraw is required */
bool (*imguiConfig)(EGL_Filter * filter); bool (*imguiConfig)(EGL_Filter * filter);
/* writes filter state to options */
void (*saveState)(EGL_Filter * filter);
/* reads filter state from options */
void (*loadState)(EGL_Filter * filter);
/* set the input format of the filter */ /* set the input format of the filter */
bool (*setup)(EGL_Filter * filter, enum EGL_PixelFormat pixFmt, bool (*setup)(EGL_Filter * filter, enum EGL_PixelFormat pixFmt,
unsigned int width, unsigned int height); unsigned int width, unsigned int height);
@ -103,6 +109,16 @@ static inline bool egl_filterImguiConfig(EGL_Filter * filter)
return filter->ops.imguiConfig(filter); return filter->ops.imguiConfig(filter);
} }
static inline void egl_filterSaveState(EGL_Filter * filter)
{
filter->ops.saveState(filter);
}
static inline void egl_filterLoadState(EGL_Filter * filter)
{
filter->ops.loadState(filter);
}
static inline bool egl_filterSetup(EGL_Filter * filter, static inline bool egl_filterSetup(EGL_Filter * filter,
enum EGL_PixelFormat pixFmt, unsigned int width, unsigned int height) enum EGL_PixelFormat pixFmt, unsigned int width, unsigned int height)
{ {

View File

@ -83,6 +83,16 @@ static void egl_filterDownscaleEarlyInit(void)
option_register(options); option_register(options);
} }
static void egl_filterDownscaleSaveState(EGL_Filter * filter)
{
// not implemented
}
static void egl_filterDownscaleLoadState(EGL_Filter * filter)
{
// not implemented
}
static bool egl_filterDownscaleInit(EGL_Filter ** filter) static bool egl_filterDownscaleInit(EGL_Filter ** filter)
{ {
EGL_FilterDownscale * this = calloc(1, sizeof(*this)); EGL_FilterDownscale * this = calloc(1, sizeof(*this));
@ -364,6 +374,8 @@ EGL_FilterOps egl_filterDownscaleOps =
.init = egl_filterDownscaleInit, .init = egl_filterDownscaleInit,
.free = egl_filterDownscaleFree, .free = egl_filterDownscaleFree,
.imguiConfig = egl_filterDownscaleImguiConfig, .imguiConfig = egl_filterDownscaleImguiConfig,
.saveState = egl_filterDownscaleSaveState,
.loadState = egl_filterDownscaleLoadState,
.setup = egl_filterDownscaleSetup, .setup = egl_filterDownscaleSetup,
.getOutputRes = egl_filterDownscaleGetOutputRes, .getOutputRes = egl_filterDownscaleGetOutputRes,
.prepare = egl_filterDownscalePrepare, .prepare = egl_filterDownscalePrepare,

View File

@ -79,6 +79,22 @@ static void casUpdateConsts(EGL_FilterFFXCAS * this)
this->width, this->height); this->width, this->height);
} }
static void egl_filterFFXCASSaveState(EGL_Filter * filter)
{
EGL_FilterFFXCAS * this = UPCAST(EGL_FilterFFXCAS, filter);
option_set_bool ("eglFilter", "ffxCAS", this->enable);
option_set_float("eglFilter", "ffxCASSharpness", this->sharpness);
}
static void egl_filterFFXCASLoadState(EGL_Filter * filter)
{
EGL_FilterFFXCAS * this = UPCAST(EGL_FilterFFXCAS, filter);
this->enable = option_get_bool ("eglFilter", "ffxCAS");
this->sharpness = option_get_float("eglFilter", "ffxCASSharpness");
}
static bool egl_filterFFXCASInit(EGL_Filter ** filter) static bool egl_filterFFXCASInit(EGL_Filter ** filter)
{ {
EGL_FilterFFXCAS * this = calloc(1, sizeof(*this)); EGL_FilterFFXCAS * this = calloc(1, sizeof(*this));
@ -116,8 +132,7 @@ static bool egl_filterFFXCASInit(EGL_Filter ** filter)
.v = this->consts, .v = this->consts,
}, 1); }, 1);
this->enable = option_get_bool("eglFilter", "ffxCAS"); egl_filterFFXCASLoadState(&this->base);
this->sharpness = option_get_float("eglFilter", "ffxCASSharpness");
if (!egl_framebufferInit(&this->fb)) if (!egl_framebufferInit(&this->fb))
{ {
@ -270,6 +285,8 @@ EGL_FilterOps egl_filterFFXCASOps =
.init = egl_filterFFXCASInit, .init = egl_filterFFXCASInit,
.free = egl_filterFFXCASFree, .free = egl_filterFFXCASFree,
.imguiConfig = egl_filterFFXCASImguiConfig, .imguiConfig = egl_filterFFXCASImguiConfig,
.saveState = egl_filterFFXCASSaveState,
.loadState = egl_filterFFXCASLoadState,
.setup = egl_filterFFXCASSetup, .setup = egl_filterFFXCASSetup,
.getOutputRes = egl_filterFFXCASGetOutputRes, .getOutputRes = egl_filterFFXCASGetOutputRes,
.prepare = egl_filterFFXCASPrepare, .prepare = egl_filterFFXCASPrepare,

View File

@ -82,6 +82,22 @@ static void rcasUpdateUniform(EGL_FilterFFXFSR1 * this)
ffxFsrRcasConst(this->rcasUniform.ui, 2.0f - this->sharpness * 2.0f); ffxFsrRcasConst(this->rcasUniform.ui, 2.0f - this->sharpness * 2.0f);
} }
static void egl_filterFFXFSR1SaveState(EGL_Filter * filter)
{
EGL_FilterFFXFSR1 * this = UPCAST(EGL_FilterFFXFSR1, filter);
option_set_bool ("eglFilter", "ffxFSR", this->enable);
option_set_float("eglFilter", "ffxFSRSharpness", this->sharpness);
}
static void egl_filterFFXFSR1LoadState(EGL_Filter * filter)
{
EGL_FilterFFXFSR1 * this = UPCAST(EGL_FilterFFXFSR1, filter);
this->enable = option_get_bool ("eglFilter", "ffxFSR");
this->sharpness = option_get_float("eglFilter", "ffxFSRSharpness");
}
static bool egl_filterFFXFSR1Init(EGL_Filter ** filter) static bool egl_filterFFXFSR1Init(EGL_Filter ** filter)
{ {
EGL_FilterFFXFSR1 * this = calloc(1, sizeof(*this)); EGL_FilterFFXFSR1 * this = calloc(1, sizeof(*this));
@ -128,8 +144,7 @@ static bool egl_filterFFXFSR1Init(EGL_Filter ** filter)
goto error_rcas; goto error_rcas;
} }
egl_filterFFXFSR1LoadState(&this->base);
this->enable = option_get_bool("eglFilter", "ffxFSR");
this->easuUniform[0].type = EGL_UNIFORM_TYPE_4UIV; this->easuUniform[0].type = EGL_UNIFORM_TYPE_4UIV;
this->easuUniform[0].location = this->easuUniform[0].location =
@ -141,7 +156,6 @@ static bool egl_filterFFXFSR1Init(EGL_Filter ** filter)
this->rcasUniform.type = EGL_UNIFORM_TYPE_4UI; this->rcasUniform.type = EGL_UNIFORM_TYPE_4UI;
this->rcasUniform.location = egl_shaderGetUniform(this->rcas, "uConsts"); this->rcasUniform.location = egl_shaderGetUniform(this->rcas, "uConsts");
this->sharpness = option_get_float("eglFilter", "ffxFSRSharpness");
rcasUpdateUniform(this); rcasUpdateUniform(this);
if (!egl_framebufferInit(&this->easuFb)) if (!egl_framebufferInit(&this->easuFb))
@ -406,6 +420,8 @@ EGL_FilterOps egl_filterFFXFSR1Ops =
.init = egl_filterFFXFSR1Init, .init = egl_filterFFXFSR1Init,
.free = egl_filterFFXFSR1Free, .free = egl_filterFFXFSR1Free,
.imguiConfig = egl_filterFFXFSR1ImguiConfig, .imguiConfig = egl_filterFFXFSR1ImguiConfig,
.saveState = egl_filterFFXFSR1SaveState,
.loadState = egl_filterFFXFSR1LoadState,
.setup = egl_filterFFXFSR1Setup, .setup = egl_filterFFXFSR1Setup,
.setOutputResHint = egl_filterFFXFSR1SetOutputResHint, .setOutputResHint = egl_filterFFXFSR1SetOutputResHint,
.getOutputRes = egl_filterFFXFSR1GetOutputRes, .getOutputRes = egl_filterFFXFSR1GetOutputRes,