SlimDx - ResolveSubresource

Started by
2 comments, last by wforl 9 years, 4 months ago

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?

Advertisement

I have almost identical code using SharpDX (and previously worked with SlimDX), everything you are doing looks ok. The only differences I have here are that I am always passing 0 as the source and dest index (I'm not sure whether what you have would be coming through as 0 or not), and I have no need to bind to the pipeline so it has no BindFlags. Here is the example in case it helps:


// texture is multi-sampled, lets resolve it down to single sample
textureResolved = new Texture2D(texture.Device, new Texture2DDescription()
{
	CpuAccessFlags = CpuAccessFlags.None,
	Format = texture.Description.Format,
	Height = texture.Description.Height,
	Usage = ResourceUsage.Default,
	Width = texture.Description.Width,
	ArraySize = 1,
	SampleDescription = new SharpDX.DXGI.SampleDescription(1, 0), // Ensure single sample
	BindFlags = BindFlags.None,
	MipLevels = 1,
	OptionFlags = texture.Description.OptionFlags
});
// Resolve into textureResolved
texture.Device.ResolveSubresource(texture, 0, textureResolved, 0, texture.Description.Format);

Justin Stenning | Blog | Book - Direct3D Rendering Cookbook (using C# and SharpDX)

Projects: Direct3D Hook, EasyHook, Shared Memory (IPC), SharpDisasm (x86/64 disassembler in C#)

@spazzarama

 

Your C# side parameter is not null but the underlying COM pointer might be. Have you involuntarily Disposed() your texture ?

Upon further investigation the underlying COM pointer was indeed null due to me unintentionly releasing it earlier in the code. Having fixed that, things are now working. Thankyou

This topic is closed to new replies.

Advertisement