This is a snippet of my code:
D3D:
var description = new SwapChainDescription
{
BufferCount = 2,
Usage = Usage.RenderTargetOutput,
OutputHandle = Form.Handle,
IsWindowed = true,
ModeDescription = new ModeDescription(1280, 720, new Rational(60, 1), Format.R8G8B8A8_UNorm_SRgb),
SampleDescription = new SampleDescription(1, 0),
Flags = SwapChainFlags.AllowModeSwitch,
SwapEffect = SwapEffect.Discard,
};
Device.CreateWithSwapChain(Adapter, DeviceCreationFlags.BgraSupport, description, out device, out swapChain);
D2D:
d3d11Texture = new Texture2D(Engine.Device, new Texture2DDescription
{
Width = (int)Engine.Viewport.Width,
Height = (int)Engine.Viewport.Height,
MipLevels = 1,
ArraySize = 1,
Format = Format.B8G8R8A8_UNorm_SRgb,
SampleDescription = new SampleDescription(1, 0),
Usage = ResourceUsage.Default,
BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource,
CpuAccessFlags = CpuAccessFlags.None,
OptionFlags = ResourceOptionFlags.SharedKeyedmutex
});
sharedResource = d3d11Texture.QueryInterface<Resource>();
var d3d10Texture = device10.OpenSharedResource<SharpDX.Direct3D10.Texture2D>(sharedResource.SharedHandle);
d3d10Mutex = d3d10Texture.QueryInterface<KeyedMutex>();
d3d11Mutex = d3d11Texture.QueryInterface<KeyedMutex>();
var d2Factory = new SharpDX.Direct2D1.Factory(FactoryType.SingleThreaded);
DirectWriteFactory = new SharpDX.DirectWrite.Factory(SharpDX.DirectWrite.FactoryType.Shared);
Surface surface = d3d10Texture.AsSurface();
RenderTargetProperties rtp = new RenderTargetProperties
{
MinLevel = SharpDX.Direct2D1.FeatureLevel.Level_10,
Type = RenderTargetType.Hardware,
Usage = RenderTargetUsage.None,
PixelFormat = new PixelFormat(Format.Unknown, AlphaMode.Premultiplied)
};
dwRenderTarget = new RenderTarget(d2Factory, surface, rtp);
That last line is the one that throws the error. If I change Format.Unknown to B8G8R8A8_UNorm_SRgb, I still get the same error. I'm using SharpDX and DirectX 11