Sign in to follow this  
arbitus

[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="http://www.gamedev.net/topic/547920-how-to-use-d2d-with-d3d11/"]here[/url] and [url="http://forums.create.msdn.com/forums/p/41771/259934.aspx"]here[/url] and [url="http://stackoverflow.com/questions/3197510/shared-resources-in-slimdx-with-dx10/3197706#3197706"]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
[code]
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
};
[/code]

Attempting to open shared resource:
[code]
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);
[/code]
[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.
[/font]

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.
[/quote]

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