llde/TESReloaded10

Effect toggling sometimes fails

Opened this issue · 2 comments

The bug happens when users try to toggle effects in the menu (code here).

Toggling an effect disposes the effects and creates it again, which leads to calling createEffect which calls LoadEffect which attempts to compile then load the fx file from disk..

This function can fail without printing errors (the errors are only in case of compilation error but the function can have the following errors:

https://learn.microsoft.com/en-us/windows/win32/direct3d9/d3dxcreateeffectfromfile#return-value

One common thing that happen is getting OUT OF MEMORY This in turns gets the function to return null and the menu doesn't get toggled (because this line fails: example).

Maybe shaders that have been loaded once shouldn't be unloaded until a restart?

llde commented

MMH, I need to try keeping the replaced and original shader code around, not sure how much is feasible or if it would give issues.

llde commented

Actually there is a memory leak, the constant arrays are never freed.