Sign in to follow this  

SlimDx - ResolveSubresource

This topic is 1116 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

 

Share this post


Link to post
Share on other sites

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);

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

This topic is 1116 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this