include directive problem affecting effect reload

More
8 months 1 week ago - 8 months 1 week ago #1 by brussell include directive problem affecting effect reload was created by brussell
See this example:

Reshade.fx
void VS(in uint id : SV_VertexID, out float4 position : SV_Position, out float2 texcoord : TEXCOORD)
{
texcoord.x = (id == 2) ? 2.0 : 0.0;
texcoord.y = (id == 1) ? 2.0 : 0.0;
position = float4(texcoord * float2(2.0, -2.0) + float2(-1.0, 1.0), 0.0, 1.0);
}

float4 PS(float4 pos : SV_Position, float2 texcoord : TEXCOORD) : SV_Target
{
//#include "test.fxh"
#include "test\test.fxh"
return float4(red,0,0,1);
}

technique Test < enabled = 1;>
{
pass
{
VertexShader = VS;
PixelShader = PS;
}
}

test.fx and test/test.fx
float red = 1.0;


Expected behavior:
Changing red in file test.fx and reload effects afterwards in Reshade should lead to the expected color change, regardless where test.fx is located.

Actual behavior:
The color change is only applied after effect reload when test.fx is in the same folder as ReShade.fx (#include "test.fxh").
If test.fx is in a subfolder (#include "test\test.fxh"), effect reload doesn't lead to the color change. It only works after clearing the cache and then reloading.


If this is really the intended behavior, then I would like to request an option for "Clear cache on reload" and/or an extra keybinding for clearing the cache.
Otherwise it's really cumbersome (open Reshade menu, click clear cache, reload) to change values this way in some situations (like editing UIDetect.fxh in my case).
Last edit: 8 months 1 week ago by brussell.

Please Log in or Create an account to join the conversation.

More
8 months 1 week ago #2 by crosire Replied by crosire on topic include directive problem affecting effect reload
This is a known issue that is not really fixable unfortunately. The problem is that ReShade has no way of knowing which files you are including without compiling the effect (it has to parse those #include statements to know this), which defeats the purpose of a cache (which is supposed to avoid compiling). It can only check if the root effect file was modified.

But this is rather inconvenient, so to still register if included files changed and recompile the relevant cached effects, a workaround is applied that makes some assumptions: ReShade simply iterates through all effect search paths (since those are always known, this is not done recursively since that would potentially become really slow) and looks at the modification timestamp of all ".fxh" files it can find in there. If any are changed, all effects are recompiled. This is why things work if you leave your "test.fxh" next to the root effect file (since it is located in an effect search path then).

You can abuse this workaround and add your "test" directory to the effect search paths as well, in which case "test\test.fxh" will be checked.
The following user(s) said Thank You: brussell

Please Log in or Create an account to join the conversation.

We use cookies

We use cookies on our website. Some of them are essential for the operation of the site, while others help us to improve this site and the user experience (tracking cookies). You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.