Hello.
I'm trying to create human animation by skinning. I would like to use geometry output stream so that I don't have to alter vertex shaders for this.
But I get an error with this description :
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
My Code :
internal void FillStreamOut()
{
if (StreamOutBuffer == null) // Initialize stream out buffer if it hasn't been already
{
int stride = Marshal.SizeOf(typeof(VertexPositionNormalTexture));
int size = stride * indexCount;
StreamOutBuffer = new Buffer(GraphicsRenderer.device, size, ResourceUsage.Default, BindFlags.VertexBuffer | BindFlags.StreamOutput, CpuAccessFlags.None, ResourceOptionFlags.None, stride);
}
//Binding to stream output
GraphicsRenderer.contex.StreamOutput.SetTarget(StreamOutBuffer, 0);
Draw();
StreamOutputBufferBinding[] bindings = new StreamOutputBufferBinding[1]{new StreamOutputBufferBinding()};
//unbingind from stream output
GraphicsRenderer.contex.StreamOutput.SetTargets(bindings);
}
public void Draw()
{
int stride = Marshal.SizeOf(typeof(T));
GraphicsRenderer.contex.InputAssembler.SetVertexBuffers(0,VertBinding);
GraphicsRenderer.contex.InputAssembler.SetIndexBuffer(IndBuf, SharpDX.DXGI.Format.R32_UInt, 0);
GraphicsRenderer.contex.DrawIndexed(indexCount, 0, 0); //this line gives the error
}
What do u think is causing this ?
My Draw Method works OK when there is no stream output binded.