Sign in to follow this  

Creating Shared D3D10/D3D11 Resource

Recommended Posts



I'm using SlimDX (, 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 ( 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);
 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

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