Skip to content
This repository has been archived by the owner. It is now read-only.

[Direct3D12][UWP] #667

Open
zerppa opened this issue Nov 30, 2015 · 12 comments
Open

[Direct3D12][UWP] #667

zerppa opened this issue Nov 30, 2015 · 12 comments

Comments

@zerppa
Copy link

@zerppa zerppa commented Nov 30, 2015

The .NET native tool chain for UWP apps cannot handle D3D12, it seems.

  1. Create a new project, of type "Blank App (Universal Windows)", C#
  2. Add the NuGet package "SharpDX.Direct3D12" (3.0.0-beta01) to the project
  3. Rebuild project as Debug. This will succeed, and the app can be run
  4. Switch to Release mode, then rebuild again
  5. The compilation will fail with the following output:
1>  Starting .NET Native compilation
1>  Processing application code
1>  Computing application closure and generating interop code
1>C:\Program Files (x86)\MSBuild\Microsoft\.NetNative\x64\ilc\IlcInternals.targets(886,5): warning :           Unresolved P/Invoke method 'D3D12GetDebugInterface_!d3d12.dll' in assembly 'SharpDX.Direct3D12, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1' because it is not available in UWP applications. Please either use an another API , or use [DllImport(ExactSpelling=true) to indicate that you understand the implications of using non-UWP application APIs.
1>  Generating serialization code
1>  Compiling interop code
1>  Cleaning up unreferenced code
1>  Generating native code
1>C:\Program Files (x86)\MSBuild\Microsoft\.NetNative\x64\ilc\IlcInternals.targets(1231,5): error : Error: NUTC300D:Internal Compiler Error: Type '$81_SharpDX.Direct3D12.RootSignatureDescription' is not valid for use outside of the managed environment, but is passed to native code while compiling method 'instance $81_SharpDX.Direct3D12.RootSignatureDescription $81_SharpDX.Direct3D12.RootSignatureDeserializer.GetRootSignatureDescription()'.
1>C:\Program Files (x86)\MSBuild\Microsoft\.NetNative\x64\ilc\IlcInternals.targets(1231,5): error : ILT0005: 'C:\Program Files (x86)\MSBuild\Microsoft\.NetNative\x64\ilc\Tools\nutc_driver.exe @"c:\users\zero\documents\visual studio 2015\Projects\D12Test\D12Test\obj\x64\Release\ilc\intermediate\nutcargs.rsp"' returned exit code 1

It does not make a difference whether x86 or x64. I have no problems with D3D11. I do have the latest UWP tools 1.1.1 update installed.

@amerkoleci
Copy link
Contributor

@amerkoleci amerkoleci commented Jan 22, 2016

@xoofx What can be the issue from your point of view? Maybe I can the submit PR

@xoofx
Copy link
Member

@xoofx xoofx commented Jan 26, 2016

Well the marshaler for this method is a bit hacky and seems not supported well by .NET native tool. Haven't dig into it...

@amerkoleci
Copy link
Contributor

@amerkoleci amerkoleci commented Jan 26, 2016

Oh thank you for your detailed explanation.

@MattWhilden
Copy link

@MattWhilden MattWhilden commented Feb 16, 2016

Hello! I work on the .NET Native runtime and compiler team. When you do get time to investigate this a bit please don't hesitate to shoot us a mail at dotnetnative@microsoft.com. We'd be happy to help leverage our expertise so that sharpdx is in great shape for both our customers!

@jxl98c
Copy link

@jxl98c jxl98c commented Jun 26, 2016

Any news on this issue - I just finished porting UWP + Xaml + DirectX 12 samples to C# and cant get my app running on xbox one due to this issue...

@xoofx
Copy link
Member

@xoofx xoofx commented Jun 26, 2016

Hi,
Apart for merging PR, I don't have any more spare time left for digging into SharpDX issues, so I would really appreciate someone that is using SharpDX and requires a fix for this issue to dig into it, with the Microsoft .NET Native team.
Thanks

@MattWhilden
Copy link

@MattWhilden MattWhilden commented Jun 27, 2016

@jxl98c Can you send a mail to us .NET folks? It's a bit silly but it is the fastest way to get these things prioritized on our side. Squeaky wheels and all that. :-)

@MattWhilden
Copy link

@MattWhilden MattWhilden commented Jun 27, 2016

Curiosity got the better of me. Here's the error I get when compiling with the latest tools:
NUTC300D:Internal Compiler Error: Type '$81_SharpDX.Direct3D12.RootSignatureDescription' is not valid for use outside of the managed environment, but is passed to native code while compiling method 'instance $81_SharpDX.Direct3D12.RootSignatureDescription $81_SharpDX.Direct3D12.RootSignatureDeserializer.GetRootSignatureDescription()'. App7 C:\Program Files (x86)\MSBuild\Microsoft.NetNative\x86\ilc\IlcInternals.targets 1297

I'll see what more information I can dig up but sending a mail really does grease the wheels for us.

@yizhang82
Copy link
Contributor

@yizhang82 yizhang82 commented Jun 27, 2016

Thanks @MattWhilden for bringing this up! I'm also from .NET native team and I've just took a quick look. It appears that this method is doing a calli:

IL_0018: calli $81_SharpDX.Direct3D12.RootSignatureDescription(System.Void*)

While RootSignatureDescription is an auto layout class:

.class public auto ansi sealed beforefieldinit $81_SharpDX.Direct3D12.RootSignatureDescription
extends System.Object

This means that CLR would fallback to use COM interop and marshal this one as a IUnknown, and the problem is that interop marshaling through calli instruction is not yet implemented in .NET native. However, it's not clear to me if this is intentional - I would expect SharpDX to do its own COM marshaling (as far as I can tell - but I could also be terribly wrong).

@xoofx You mentioned that this method is "a bit hacky". Can you share more details on what the method is trying to do?

@xoofx
Copy link
Member

@xoofx xoofx commented Jun 28, 2016

Thanks @yizhang82 and @MattWhilden ! Good catch, the method RootSignatureDeserializer.GetRootSignatureDescription is indeed automatically generated but in fact has to be rewritten manually, as the direct marshalling of this RootSignatureDescription is not supported.

There is a code to serialize it in RootSignatureDescription.Serialize. The solution to solve this issue is to develop the equivalent deserialize in RootSignatureDeserializer

So as I said above, I'm no longer able to give spare time to SharpDX, so I would appreciate someone that needs this fix to help on this, PR are welcome. Thanks!

@yizhang82
Copy link
Contributor

@yizhang82 yizhang82 commented Jul 6, 2016

@xoofx I spent some time yesterday on a potential PR (#773) and I haven't got a chance to test it yet (appreciate if you can share some ideas on how to test this. Presumably I just need to find a way to test this API without having to create a game :) ). Can you take a quick look and see if it is on the right direction?

@yizhang82
Copy link
Contributor

@yizhang82 yizhang82 commented Jul 6, 2016

@zerppa The PR just got merged into master last night. Feel free to pick up the latest version of SharpDX and give it a try. I've confirmed that picking up this version fixes the problem and .NET native compiler is happy now.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants