Skip to content

Commit

Permalink
Fix mrvux#359
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander committed May 24, 2019
1 parent 90cdf35 commit 3a321ed
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions Core/VVVV.DX11.Lib/Effects/TextureFX/DX11ImageShaderNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public unsafe class DX11ImageShaderNode : DX11BaseShaderNode,IPluginBase, IPlugi
private DX11RenderSettings renderSettings = new DX11RenderSettings();
private DX11ObjectRenderSettings objectSettings = new DX11ObjectRenderSettings();

private Boolean isevaluated = false;

#region Default Input Pins
[Input("Depth In",Visibility=PinVisibility.OnlyInspector)]
protected Pin<DX11Resource<DX11DepthStencil>> FDepthIn;
Expand Down Expand Up @@ -157,7 +159,6 @@ public void Evaluate(int SpreadMax)

this.previousFrameResults.Resize(this.spmax, () => null, rt => rt?.UnLock());


if (this.FInvalidate)
{
if (this.FShader.IsCompiled)
Expand All @@ -181,6 +182,7 @@ public void Evaluate(int SpreadMax)
this.varmanager.ApplyUpdates();

this.FOut.Stream.IsChanged = true;
this.isevaluated = true;
}
#endregion

Expand All @@ -206,6 +208,20 @@ private int CalculateSpreadMax()
#region Update
public void Update(DX11RenderContext context)
{
List<bool> enable = new List<bool>();

for (int slise = 0; slise < this.spmax; slise++)
{
if (this.FInEnabled != null && this.FInEnabled.SliceCount > 0 && this.isevaluated)
{
enable.Add(this.FInEnabled[slise]);
}
else
{
enable.Add(false);
}
}

Device device = context.Device;
DeviceContext ctx = context.CurrentDeviceContext;

Expand Down Expand Up @@ -235,7 +251,7 @@ public void Update(DX11RenderContext context)

for (int i = 0; i < this.previousFrameResults.SliceCount; i++)
{
if (this.FInEnabled[i] || this.FInPreserveOnDisable[i] == false)
if (enable[i] || this.FInPreserveOnDisable[i] == false)
{
this.previousFrameResults[i]?.UnLock();
this.previousFrameResults[i] = null;
Expand All @@ -262,7 +278,7 @@ public void Update(DX11RenderContext context)
{
int passcounter = 0;

if (this.FInEnabled[textureIndex])
if (enable[textureIndex])
{
List<DX11ResourcePoolEntry<DX11RenderTarget2D>> locktargets = new List<DX11ResourcePoolEntry<DX11RenderTarget2D>>();

Expand Down Expand Up @@ -590,10 +606,12 @@ public void Update(DX11RenderContext context)
if (this.FInPreserveOnDisable[textureIndex])
{
//We kept it locked on top
if (this.FOut[textureIndex] == null) this.FOut[textureIndex] = new DX11Resource<DX11Texture2D>();
this.FOut[textureIndex][context] = this.previousFrameResults[textureIndex] != null ? this.previousFrameResults[textureIndex].Element : null;
}
else
{
if (this.FOut[textureIndex] == null) this.FOut[textureIndex] = new DX11Resource<DX11Texture2D>();
this.FOut[textureIndex][context] = this.FIn[textureIndex][context];
}

Expand All @@ -603,6 +621,7 @@ public void Update(DX11RenderContext context)
context.RenderStateStack.Pop();

this.OnEndQuery(context);
this.isevaluated = false;
}

#endregion
Expand Down Expand Up @@ -633,6 +652,7 @@ public void Destroy(DX11RenderContext context, bool force)
}
}
this.previousFrameResults.SliceCount = 0;
this.isevaluated = false;
}
#endregion

Expand Down

0 comments on commit 3a321ed

Please sign in to comment.