public void Initialize(int width, int height, Format format)
{
this.width = width;
this.height = height;
this.format = format;
Texture2DDescription textureDescription = new Texture2DDescription()
{
ArraySize = 1,
BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource | BindFlags.UnorderedAccess,
CpuAccessFlags = CpuAccessFlags.None,
Format = format,
Height = height,
MipLevels = 1,
OptionFlags = ResourceOptionFlags.None,
SampleDescription = new SampleDescription(1, 0),
Usage = ResourceUsage.Default,
Width = width
};
if (texture != null)
texture.Dispose();
texture = new Texture2D(graphicsDevice, textureDescription);
if (renderTargetView != null)
renderTargetView.Dispose();
renderTargetView = new RenderTargetView(graphicsDevice, texture);
if (shaderResourceView != null)
shaderResourceView.Dispose();
shaderResourceView = new ShaderResourceView(graphicsDevice, texture);
if (unorderedAccessView != null)
unorderedAccessView.Dispose();
unorderedAccessView = new UnorderedAccessView(graphicsDevice, texture);
}
}