Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preventing some code not compiling under UWP in Release mode to be ge… #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

PhilippeMonteil
Copy link

…nerated.

Some methods including array parameters like 'VkComputePipelineCreateInfo[] pCreateInfos':

`public static unsafe VkResult vkCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache, uint createInfoCount, VkComputePipelineCreateInfo[] pCreateInfos, VkAllocationCallbacks* pAllocator, out VkPipeline pPipelines)

do not compile under UWP in Release mode. The generator has been modified to not generate them anymore. `

@PhilippeMonteil
Copy link
Author

This problem keeps me from completing the Xamarin.Forms Android/iOS/UWP Custom Renderer for Veldrid I am about to release.

@mellinoe
Copy link
Owner

I would really prefer not to make changes to this library because of what is effectively a compiler bug on one platform. I filed dotnet/runtime#35171 to see if there's a fix or workaround available. If not, then we can try and see what our options are.

@PhilippeMonteil
Copy link
Author

I have built a Vk.2.0.0 nuget based on a Vk.dll produced by the modified generator and explicitly referred to it in the UWP test application, along with the Veldrid.View nuget providing the Xamarin.Forms views and it did mask the 'real' Vk package mentioned by Veldrid : it works :-)!

@PhilippeMonteil
Copy link
Author

I have pushed a new commit:

  • adding a '--uwp' option to the generator to prevent the methods including "Infos" array parameters from being generated.
  • adding a new .Net Standard 1.4 vk.uwp project as a copy of the vk one, invoking the generator with the --uwp option
  • producing a vk.2.0.0 nuget including the new vk.uwp dll targeting UWP
    This Vk.2.0.0 nuget is referenced by the Veldrid.View Xamarin.Forms nuget, which can then be used as is by iOS / Android and UWP applications, compiled in release mode.

@mellinoe
Copy link
Owner

@PhilippeMonteil Can you try out this branch and see if it fixes the issue? https://github.com/mellinoe/vk/tree/calli_rewrite_array_parameters

@PhilippeMonteil
Copy link
Author

I have tried to:

  • produce the nuget from your branch
  • create a new empty UWP app, add a reference to the Vk nugget
  • compile it in release mode
    it generates the same error:

1>------ Rebuild All started: Project: App1, Configuration: Release x86 ------
1> App1 -> C:\Users\philm\source\repos\App1\App1\bin\x86\Release\App1.exe
1> Processing application code
1> Computing application closure and generating interop code
1> Loading 47 modules...
1>C:\Program Files (x86)\Microsoft SDKs\UWPNuGetPackages\microsoft.net.native.compiler\2.2.7-rel-27913-00\tools\Microsoft.NetNative.targets(801,5): warning : MCG : warning MCG0007: Unresolved P/Invoke method 'libdl!dlopen' for method 'System.IntPtr Vulkan.Libdl.dlopen(System.String, System.Int32)'. Calling this method would throw exception at runtime. Please make sure the P/Invoke either points to a Windows API allowed in UWP applications, or a native DLL that is part of the package. If for some reason your P/Invoke does not satisfy those requirements, please use [DllImport(ExactSpelling=true) to indicate that you understand the implications of using non-UWP APIs.
1>C:\Program Files (x86)\Microsoft SDKs\UWPNuGetPackages\microsoft.net.native.compiler\2.2.7-rel-27913-00\tools\Microsoft.NetNative.targets(801,5): warning : MCG : warning MCG0007: Unresolved P/Invoke method 'libdl!dlsym' for method 'System.IntPtr Vulkan.Libdl.dlsym(System.IntPtr, System.String)'. Calling this method would throw exception at runtime. Please make sure the P/Invoke either points to a Windows API allowed in UWP applications, or a native DLL that is part of the package. If for some reason your P/Invoke does not satisfy those requirements, please use [DllImport(ExactSpelling=true) to indicate that you understand the implications of using non-UWP APIs.
1>C:\Program Files (x86)\Microsoft SDKs\UWPNuGetPackages\microsoft.net.native.compiler\2.2.7-rel-27913-00\tools\Microsoft.NetNative.targets(801,5): warning : MCG : warning MCG0007: Unresolved P/Invoke method 'libdl!dlclose' for method 'System.Int32 Vulkan.Libdl.dlclose(System.IntPtr)'. Calling this method would throw exception at runtime. Please make sure the P/Invoke either points to a Windows API allowed in UWP applications, or a native DLL that is part of the package. If for some reason your P/Invoke does not satisfy those requirements, please use [DllImport(ExactSpelling=true) to indicate that you understand the implications of using non-UWP APIs.
1>C:\Program Files (x86)\Microsoft SDKs\UWPNuGetPackages\microsoft.net.native.compiler\2.2.7-rel-27913-00\tools\Microsoft.NetNative.targets(801,5): warning : MCG : warning MCG0007: Unresolved P/Invoke method 'libdl!dlerror' for method 'System.String Vulkan.Libdl.dlerror()'. Calling this method would throw exception at runtime. Please make sure the P/Invoke either points to a Windows API allowed in UWP applications, or a native DLL that is part of the package. If for some reason your P/Invoke does not satisfy those requirements, please use [DllImport(ExactSpelling=true) to indicate that you understand the implications of using non-UWP APIs.
1> Generating code...
1> Interop code generated.
1> Compiling interop code
1> Generating System.Reflection.DispatchProxy proxy code.
1> Cleaning up unreferenced code
1> Generating native code
1>C:\Program Files (x86)\Microsoft SDKs\UWPNuGetPackages\microsoft.net.native.compiler\2.2.7-rel-27913-00\tools\Microsoft.NetNative.targets(801,5): error : Error: NUTC300D:Internal Compiler Error: Type 'Vulkan.VkComputePipelineCreateInfo[]' is not valid for use outside of the managed environment, but is passed to native code while compiling method 'static Vulkan.VkResult Vulkan.VulkanNative.vkCreateComputePipelines(Vulkan.VkDevice, Vulkan.VkPipelineCache, System.UInt32, Vulkan.VkComputePipelineCreateInfo[], Vulkan.VkAllocationCallbacks&, Vulkan.VkPipeline&)'.
1>C:\Program Files (x86)\Microsoft SDKs\UWPNuGetPackages\microsoft.net.native.compiler\2.2.7-rel-27913-00\tools\Microsoft.NetNative.targets(801,5): error : ILT0005: 'C:\Program Files (x86)\Microsoft SDKs\UWPNuGetPackages\runtime.win10-x86.microsoft.net.native.compiler\2.2.7-rel-27913-00\tools\x86\ilc\Tools\nutc_driver.exe @"C:\Users\philm\source\repos\App1\App1\obj\x86\Release\ilc\intermediate\MDIL\App1.rsp"' returned exit code 1
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

@PhilippeMonteil
Copy link
Author

I have made more tests: clearing my Nuget cache, incrementing the version of the Vk nuget generated from your branch and it works fine: I have been able to produce a new Veldrid.View nuget and to use it to build a UWP test application in release mode: excellent news, thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants