Jump to content
  • Advertisement
Sign in to follow this  
knollebotten

Creating Shared D3D10/D3D11 Resource

This topic is 1221 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

Hello,

 

I'm using SlimDX (4.0.13.43, most recent version) and am trying to open shared D3D10 texture resource with a D3D11 device, however I keep getting a rather unhelpful {"E_OUTOFMEMORY: Ran out of memory (-2147024882)"} exception and I can't see what's wrong.

 

I'm not even sure there's anything wrong with the code since it's from a 3rd-party library (https://sdxspritetext.codeplex.com/) and apparently works fine for other people. The exception is generated in the ctor call of Direct3D11.ShaderResourceView where I pass the D3D11 Texture2D instance received from the OpenSharedResource method.

 

Here's what the code does. I have extracted and attached the crucial parts as a simple sample program to this post.

 

1. Create the D3D10 and D3D11 devices, swapchain etc.

var desc = new SwapChainDescription() {
	BufferCount = 1,
	ModeDescription = new ModeDescription(form.ClientSize.Width, form.ClientSize.Height,
		new Rational(60, 1), Format.R8G8B8A8_UNorm),
	IsWindowed = true,
	OutputHandle = form.Handle,
	SampleDescription = new SampleDescription(1, 0),
	SwapEffect = SwapEffect.Discard,
	Usage = Usage.RenderTargetOutput
};

device10 = new SlimDX.Direct3D10.Device(SlimDX.Direct3D10.DeviceCreationFlags.BgraSupport);
Device.CreateWithSwapChain(
 SlimDX.Direct3D11.DriverType.Hardware,
 SlimDX.Direct3D11.DeviceCreationFlags.None, desc, out device11, out swapChain);

2. Create a D3D10 Texture2D using the device10 instance

SlimDX.Direct3D10.Texture2D CreateTexture10() {
	var TexDesc = new SlimDX.Direct3D10.Texture2DDescription() {
		ArraySize = 1,
		BindFlags = SlimDX.Direct3D10.BindFlags.ShaderResource | SlimDX.Direct3D10.BindFlags.RenderTarget,
		CpuAccessFlags = SlimDX.Direct3D10.CpuAccessFlags.None,
		Format = Format.R8G8B8A8_UNorm,
		Height = 256,
		Width = 256,
		MipLevels = 1,
		OptionFlags = SlimDX.Direct3D10.ResourceOptionFlags.Shared,
		SampleDescription = new SampleDescription(1, 0),
		Usage = SlimDX.Direct3D10.ResourceUsage.Default
	};

	return new SlimDX.Direct3D10.Texture2D(device10, TexDesc);
}

3. Attempt to create a D3D11 Shader Resource View from the D3D10 Texture2D

SlimDX.Direct3D11.ShaderResourceView CreateTexture11SRVFrom10(SlimDX.Direct3D10.Texture2D texture10) {
	using (var dxgiResource = new SlimDX.DXGI.Resource(texture10)) {
		var texture11 = device11.OpenSharedResource<SlimDX.Direct3D11.Texture2D>(dxgiResource.SharedHandle);

                // Direct3D11Exception here: {"E_OUTOFMEMORY: Ran out of memory (-2147024882)"}
		return new SlimDX.Direct3D11.ShaderResourceView(device11, texture11);
	}
}

The target framework is .NET4.5, my graphics adapter is a Intel HD3000A and I am running Windows 7 x64 if that matters.

Edited by knollebotten

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!