helix-toolkit/helix-toolkit — pull request #53 by dermeister0 (2014-09-13 07:03:50+00:00)
Title: HelixToolkit.Wpf.SharpDX: Check bHasInstances effect variable existence.

bHasInstances field is initialized in the Attach method. However, it can not found. The variable will be null.

public override void Attach(IRenderHost host)
{
// ...

/// --- init instances buffer
this.hasInstances = (this.Instances != null) && (this.Instances.Any());
this.bHasInstances = this.effect.GetVariableByName("bHasInstances").AsScalar(); // <-
if (this.hasInstances)
{
this.instanceBuffer = Buffer.Create(this.Device, this.instanceArray, new BufferDescription(Matrix.SizeInBytes * this.instanceArray.Length, ResourceUsage.Dynamic, BindFlags.VertexBuffer, CpuAccessFlags.Write, ResourceOptionFlags.None, 0));
}

// ...

Need to check it in the Render method.