Sign in to follow this  
Plerion

[PIX] Unable to create D2D rendertarget

Recommended Posts

Plerion    381
Hello everybody

Im using interop with D3D10 to render text in D3D11. Thus i create a shared resource and from this resource i open a rendertarget for D2D. While all works perfectly when i run my application on its own but if i start it with PIX there is an exception:

The code im talking about is the following:
[source lang="csharp"] var device10 = new SlimDX.Direct3D10_1.Device1(GXLink.Instance.OutputAdapter, DriverType.Hardware, DeviceCreationFlags.BgraSupport | DeviceCreationFlags.Debug, SlimDX.Direct3D10_1.FeatureLevel.Level_10_0);

mSharedDescription = new SlimDX.Direct3D11.Texture2DDescription()
{
ArraySize = 1,
BindFlags = SlimDX.Direct3D11.BindFlags.ShaderResource | SlimDX.Direct3D11.BindFlags.RenderTarget,
CpuAccessFlags = SlimDX.Direct3D11.CpuAccessFlags.None,
Format = SlimDX.DXGI.Format.B8G8R8A8_UNorm,
Height = GXLink.Instance.RenderWindow.ClientSize.Height,
Width = GXLink.Instance.RenderWindow.ClientSize.Width,
MipLevels = 1,
OptionFlags = SlimDX.Direct3D11.ResourceOptionFlags.KeyedMutex,
SampleDescription = new SlimDX.DXGI.SampleDescription(1, 0),
Usage = SlimDX.Direct3D11.ResourceUsage.Default
};

mSharedTexture = new SlimDX.Direct3D11.Texture2D(GXLink.Instance.Device, mSharedDescription);

var dxgiResource = new SlimDX.DXGI.Resource(mSharedTexture);

SlimDX.Direct3D10.Texture2D tex = device10.OpenSharedResource<SlimDX.Direct3D10.Texture2D>(dxgiResource.SharedHandle);
device10.Dispose();
dxgiResource.Dispose();

var surf = tex.AsSurface();

mKeyedMutex10 = new SlimDX.DXGI.KeyedMutex(surf);
mKeyedMutex11 = new SlimDX.DXGI.KeyedMutex(mSharedTexture);

var props = new RenderTargetProperties()
{
Type = RenderTargetType.Hardware,
HorizontalDpi = 96,
MinimumFeatureLevel = SlimDX.Direct2D.FeatureLevel.Direct3D10,
PixelFormat = new PixelFormat(SlimDX.DXGI.Format.Unknown, AlphaMode.Premultiplied),
Usage = RenderTargetUsage.None,
VerticalDpi = 96,
};

SlimDX.Direct2D.Factory fac2D = new SlimDX.Direct2D.Factory(SlimDX.Direct2D.FactoryType.SingleThreaded);
mRenderTarget2D = RenderTarget.FromDXGI(fac2D, surf, props);[/source]

The line that causes the exception with PIX is the following:
[CODE]
mRenderTarget2D = RenderTarget.FromDXGI(fac2D, surf, props);
[/CODE]

Here i get a System.AccessViolation exception.

Once again, without PIX no problems, the text is renderer and all is fine. With PIX -> System.AccessViolation on this line.

Is this a common error or could i change some settings in PIX or what can i do?

Greetings
Plerion

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