Shader buffer cache works on Garry's mod (DX9), but breaks on Skyrim SE (DX11)

  • Pentalimbed
  • Topic Author
More
1 year 10 months ago - 1 year 10 months ago #1 by Pentalimbed Shader buffer cache works on Garry's mod (DX9), but breaks on Skyrim SE (DX11) was created by Pentalimbed
I am trying to write my own SSGI, it works fine on Garry's mod, which uses DX9:

but it breaks on Skyrim SE (DX11), look at the fireflies:

As it turns out, the shader failed to cache depth and normal of the previous frame, resulting in failed temporal accumulation, although the initial tracing part seems to malfunction too. The buffer caching is extremely simplistic:
void PS_InputBufferSetup(in VSOUT vsout, out float4 g : SV_Target0, out float4 g_prev : SV_Target1)
{
g_prev = tex2D(GBufferSampler, vsout.texcoord);
g.xyz = getScreenNormal(vsout.texcoord, vsout);
g.w = depth2Z(ReShade::GetLinearizedDepth(vsout.texcoord));
}

that I really don't know what could go wrong. I do have ENB with Skyrim, but disabling it fixes nothing. Anyone has a clue?

For more information, seeĀ  this github page , although it is a bit of an unorganized mess for now.
Last edit: 1 year 10 months ago by Pentalimbed. Reason: wording

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

  • crosire
More
1 year 10 months ago #2 by crosire Replied by crosire on topic Shader buffer cache works on Garry's mod (DX9), but breaks on Skyrim SE (DX11)
You are reading from and writing to the same texture in the same pass (PS_InputBufferSetup reads GBufferTex through GBufferSampler and also renders to GBufferTex). This is not allowed and produces undefined behavior (hence why it may appear to be working in DX9, but will also fail there sporadically and also always fail in DX11). You'll have to split this up into two passes, so that one pass reads the texture and one pass writes to it (and potentially have to introduce a temporary texture to transfer data between those two passes).

The reason it doesn't work is that sampling uses multiple pixel values, but since your shader is executed with massive parallelism for different pixels, it could be that a pixel was already overwritten with the new value, while a neighboring pixel tries to read/sample with it, producing bogus results. Because of that it's simply forbidden to do this outright.
The following user(s) said Thank You: Pentalimbed

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

  • Pentalimbed
  • Topic Author
More
1 year 10 months ago #3 by Pentalimbed Replied by Pentalimbed on topic Shader buffer cache works on Garry's mod (DX9), but breaks on Skyrim SE (DX11)
Ah, I see. Thank you very much for the explanation!

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 forum. 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.