I'm trying to make simple SlimDX example to test some performance vs GDI and unfortunately I got stuck on the very beginning. I've created simple Console Application in VS2010 and added this code to programs main method:
// 0. STEP
SlimDX.Direct3D10.Device device = new SlimDX.Direct3D10.Device(DriverType.Hardware, DeviceCreationFlags.BgraSupport);
SlimDX.Direct2D.Factory factory = new SlimDX.Direct2D.Factory();
// 1. STEP
Texture2DDescription textureDesc = new Texture2DDescription();
textureDesc.Width = 512;
textureDesc.Height = 512;
textureDesc.MipLevels = 1;
textureDesc.ArraySize = 1;
textureDesc.Format = SlimDX.DXGI.Format.R8G8B8A8_UNorm;
textureDesc.SampleDescription = new SampleDescription(1, 0);
textureDesc.Usage = ResourceUsage.Default;
textureDesc.BindFlags = BindFlags.RenderTarget;
textureDesc.CpuAccessFlags = CpuAccessFlags.None;
textureDesc.OptionFlags = ResourceOptionFlags.None;
Texture2D maskTexture = new Texture2D(device, textureDesc);
// 2. STEP
SlimDX.DXGI.Surface surface = maskTexture.AsSurface();
// 3. STEPpro
RenderTargetProperties props = new RenderTargetProperties
{
HorizontalDpi = 96,
VerticalDpi = 96,
MinimumFeatureLevel = SlimDX.Direct2D.FeatureLevel.Default,
PixelFormat = new PixelFormat(SlimDX.DXGI.Format.Unknown, AlphaMode.Premultiplied),
Type = RenderTargetType.Default,
Usage = RenderTargetUsage.None
};
RenderTarget target = RenderTarget.FromDXGI(factory, surface, props);
This crashes on the RenderTarget.FromDXGI call with this message:
Additional information: E_INVALIDARG: An invalid parameter was passed to the returning function (-2147024809)
Unfortunately, I could not enable DirectX debug output as stated in this SO question: DirectX 10 debug output not working
... so, this is all I've got.
BUT, I've tried this both at home (win8.1, vs2013) and at work (win7, vs2010sp1) and at home it works when I debug the app using Graphics Diagnostics from 2013. It doesn't work when I start regular debug or try to start exe manualy. At work it does not work at all.
Any ideas just from code? I'm kinda desperate here. :(