I'm trying to create an application in which I render to a sampled buffer, resolve that buffer, and then pass on the resolved resource to another system. However, I seem to be having trouble with the 'ResolveSubresource' method throwing the following exception :
First-chance exception at 0x761EC42D (KernelBase.dll) in DirectCanvasTest.exe: 0x0000087A (parameters: 0x00000000, 0x0036CD94, 0x0036C1CC).
The output window reports the following :
D3D11 CORRUPTION: ID3D10Device::ResolveSubresource: Third parameter is corrupt or NULL. [ MISCELLANEOUS CORRUPTION #15: CORRUPTED_PARAMETER3]
First-chance exception at 0x761EC42D (KernelBase.dll) in DirectCanvasTest.exe: 0x0000087A (parameters: 0x00000000, 0x0036CD94, 0x0036C1CC).
Not sure what I'm doing wrong, the thrid paramter isn't null, so I guess I'm creating it incorrectly. Here is the code for that as well as the resolve method:
void ResizeBuffers(int _width, int _height)
{
if (m_renderTarget != null)
{
m_renderTarget.Dispose();
}
if (m_renderTargetView != null)
{
m_renderTargetView.Dispose();
}
_width = (int)_width > 0 ? (int)_width : 64;
_height = (int)_height > 0 ? (int)_height : 64;
var targetDesc = new Texture2DDescription()
{
BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource,
Format = Format.B8G8R8A8_UNorm,
Width = _width,
Height = _height,
MipLevels = 1,
SampleDescription = new SampleDescription(4, 4),
Usage = ResourceUsage.Default,
OptionFlags = ResourceOptionFlags.None,
CpuAccessFlags = CpuAccessFlags.None,
ArraySize = 1
};
m_renderTarget = new Texture2D(Device, targetDesc);
m_renderTargetView = new RenderTargetView(Device, m_renderTarget);
targetDesc = new Texture2DDescription()
{
BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource,
Format = Format.B8G8R8A8_UNorm,
Width = _width,
Height = _height,
MipLevels = 1,
SampleDescription = new SampleDescription(1, 0),
Usage = ResourceUsage.Default,
OptionFlags = ResourceOptionFlags.None,
CpuAccessFlags = CpuAccessFlags.None,
ArraySize = 1
};
m_resolveTarget = new Texture2D(Device, targetDesc);
}
void ResolveTarget()
{
int sourceIndex = SlimDX.Direct3D10.Resource.CalculateSubresourceIndex(0, 1, 1);
int destIndex = SlimDX.Direct3D10.Resource.CalculateSubresourceIndex(0, 1, 1);
Device.ResolveSubresource(m_renderTarget, sourceIndex, m_resolveTarget, destIndex, Format.B8G8R8A8_UNorm);
}
Anybody have any idea what I'm doing wrong?