Sign in to follow this  

[SlimDX] Creating a shared resource for D3D11 and D2D/DirectWrite interop

Recommended Posts

So I have been researching this topic based on information found [url=""]here[/url] and [url=""]here[/url] and [url=""]here[/url].

I am trying to create a shared texture, using SlimDX instead of the C++ API. I get an exception when attempting to call OpenSharedResource on the Direct3D 10 device. The code is as follows:

The texture description
private static readonly Texture2DDescription SharedTextureDesc = new Texture2DDescription
Width = 1024,
Height = 768,
MipLevels = 1,
ArraySize = 1,
Format = Format.R8G8B8A8_UNorm,
SampleDescription = new SampleDescription(1, 0),
Usage = ResourceUsage.Default,
BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource,
CpuAccessFlags = CpuAccessFlags.None,
OptionFlags = ResourceOptionFlags.Shared

Attempting to open shared resource:
GraphicsDevice10 = new DX10.Device(DX10.DriverType.Hardware, DX10.DeviceCreationFlags.None);
SharedTexture = new Texture2D(GraphicsDevice11, SharedTextureDesc);
SharedResource = new SlimDX.DXGI.Resource(SharedTexture);

var shared = GraphicsDevice10.OpenSharedResource<Texture2D>(SharedResource.SharedHandle);
[font="Arial"]GraphicsDevice11 is created previously. Both devices are successfully created, checked in the debugger. However, when I call OpenSharedResource, I get the following unmanaged exception:
An unhandled exception of type 'SlimDX.Direct3D10.Direct3D10Exception' occurred in SlimDX.dll

Additional information: E_NOINTERFACE: The requested COM interface is not available (-2147467262)

On a side note, I am new to DXGI and DirectX10+, having just now transitioned from DirectX 9.0c and XNA 3.0. What other debugging measures can I take, since I can no longer just enable the debug runtimes? I only have unmanged code debugging enabled, and I feel that there should be more.

Share this post

Link to post
Share on other sites
[quote name='Erik Rufelt' timestamp='1298468801' post='4777941']
Try using creation flags for BGRA support when creating the device.

Thanks for the reply, but it would make me feel better if that were my problem. I discovered the issue last night and tested it this morning. My problem was that I was using the Direct3d11 version of the Texture2D class as my generic parameter to the OpenSharedResource() rather than the Direct3d10 version of the Texture2D class. That is what I get for liberal use of unqualified using statements.

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