sharpdx / SharpDX-Samples

Official repository for all SharpDX Samples
347 stars 222 forks source link

More DirectX 12 examples #27

Open ghost opened 8 years ago

ghost commented 8 years ago

Why no much DirectX 12 examples for SharpDX?

xoofx commented 8 years ago

Because no much time to work on them actually ;)

I have at least the HelloWorl with the Triangle somewhere on my disk, as I was not allowed to release it before official DirectX12 samples.

If someone is interested in porting these sample, he will be welcome!

Note that Direct3D12 in SharpDX has still some rough edges and is not always correctly mapped.

jxl98c commented 8 years ago

Hi, Is there any update on samples for DirectX12?

I'm looking for support for C# Universal Windows App with SharpDX. I'm happy to help with the samples once I figure out the best way to hook 12 into the XAML tree - the desktop samples use a SwapChainDescription that takes a RenderForm handle, yet the older DX11 samples use a SwapChainPanel.

What's the best way of doing 12 through a UWP XAML App - if I can get this initial set-up problem resolved then I'll happily port the samples.

xoofx commented 8 years ago

There were some StoreApp samples with D3D11 interop. D3D12 interop should be pretty similar. I believe that the SurfaceImageSource solution is still valid for UWP, haven't looked if they have been providing different interop scenarios. As I don't have any time dedicated for this, PR are welcome.

jxl98c commented 8 years ago

Thanks for the speedy response - I'll take a look at the samples. I'd come across the SurfaceImageSource approach but didn't look at it for too long as it wasn't obviously workable for UWP (and I think I'd just convinced myself it was a deprecated way of doing things).

If I can get it working then I'll gladly open up a PR for consideration.

xoofx commented 8 years ago

FYI DirectX and XAML

jxl98c commented 8 years ago

Thanks for the link. I'd like to get the SwapChainPanel working but I need to investigate the DXGI functionality more. I was going down the following route...

` var pixelScale = Windows.Graphics.Display.DisplayInformation.GetForCurrentView().LogicalDpi / 96.0f;

        var widthInPixels = (int) (SwapChainPanel.RenderSize.Width * pixelScale);
        var heightInPixels = (int) (SwapChainPanel.RenderSize.Height * pixelScale);

        device = new SharpDX.Direct3D12.Device(null, FeatureLevel.Level_9_1);

        using (var factory = new Factory4())
        {
            var swapChainDescription = new SwapChainDescription1
            {
                BufferCount = 2,
                AlphaMode = AlphaMode.Ignore,
                Usage = Usage.BackBuffer | Usage.RenderTargetOutput,
                Format = Format.R8G8B8A8_UNorm,
                Width = widthInPixels,
                Height = heightInPixels,
                Scaling = Scaling.Stretch,
                Stereo = false,
                SwapEffect = SwapEffect.FlipSequential,
                SampleDescription = new SampleDescription(1, 0)
            };

            var swapChain = new SwapChain(factory, device, swapChainDescription);
        }

`

but the new SwapChain(...) line doesn't like taking a SwapChainDescription1. If I change it to be the SwapChainDescription then I need to supply a OutputHandle as part of the description.

Both problems I think stem from my lack of understanding of the DXGI objects - I'll do a bit more reading first.

stefv commented 7 years ago

Hi,

Do you have a full example of the initializing part for a UWP application with DirectX 12 ?

Stef

jxl98c commented 7 years ago

Hi, I have the complete spinning cube sample working, it can be found on my OneDrive here: -

https://1drv.ms/u/s!As5yQVqwAPmmh-8BztpMyi9r1nlbIg

I'd not got round to adding it to GitHub because of an outstanding bug when compiling with the native tool chain (you will get an error unless you tell it not to - something about root signature). See the thread here...

https://github.com/sharpdx/SharpDX/issues/667#issuecomment-230672113

There does appear to be a fix, but I didn't check out the updated SharpDX package yet. Feel free to try it and let me know how you get on.

If you want to get rid of the error and NOT use the native tool chain, take a look at project options...

image

Oh, and you may also be interested in this C++ version...

https://github.com/Microsoft/DirectX-Graphics-Samples/issues/135

Thanks, James

jeastburn commented 7 years ago

@jxl98c Do you still have a sample of your DirectX / UWP code available somewhere? Your OneDrive link no longer works. I am working on a SharpDX / UWP DirectX11 implementation, but examples are hard to come by. Josh