Skip to content

Commit

Permalink
[Nodes] SetSlice (TextureArray) now outputs slices as well
Browse files Browse the repository at this point in the history
  • Loading branch information
mrvux committed May 3, 2017
1 parent 78054b2 commit 5402bf4
Showing 1 changed file with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ public class TextureArraySetSliceNode : IPluginEvaluate, IDX11ResourceHost, IDis
[Output("Texture Array", IsSingle = true)]
protected ISpread<DX11Resource<DX11RenderTextureArray>> FOutTB;

[Output("Texture Slices Out", Order = 3)]
protected ISpread<DX11Resource<DX11Texture2D>> FOutSliceTextures;

private DX11Resource<TextureArraySetSlice> generators = new DX11Resource<TextureArraySetSlice>();

public void Evaluate(int SpreadMax)
Expand All @@ -57,6 +60,15 @@ public void Evaluate(int SpreadMax)
{
this.FOutTB[0] = new DX11Resource<DX11RenderTextureArray>();
}

if (this.Depth.IsChanged)
{
this.FOutSliceTextures.SliceCount = this.Depth[0];
for (int i = 0; i < this.Depth[0]; i++)
{
this.FOutSliceTextures[i] = new DX11Resource<DX11Texture2D>();
}
}
}

public void Destroy(DX11RenderContext context, bool force)
Expand All @@ -80,16 +92,28 @@ public void Update(DX11RenderContext context)
if (this.FReset[0])
{
generator.Reset(this.FTexIn[0][context], this.Width[0], this.Height[0], this.Depth[0], this.Format[0]);
this.FOutTB[0][context] = generator.Result;
this.WriteResult(generator, context);
}
else if (this.FWrite[0])
{
generator.Apply(this.FTexIn[0][context], this.Width[0], this.Height[0], this.Depth[0], this.Format[0], this.FSliceIndex[0]);
this.FOutTB[0][context] = generator.Result;
this.WriteResult(generator, context);
}
}
}

private void WriteResult(TextureArraySetSlice generator, DX11RenderContext context)
{
DX11RenderTextureArray result = generator.Result;
this.FOutTB[0][context] = generator.Result;

for (int i = 0; i < this.FOutSliceTextures.SliceCount; i++)
{
DX11Texture2D slice = DX11Texture2D.FromTextureAndSRV(context, result.Resource, result.SliceRTV[i].SRV);
this.FOutSliceTextures[i][context] = slice;
}
}

public void Dispose()
{
if (this.generators != null)
Expand Down

0 comments on commit 5402bf4

Please sign in to comment.