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

Update sample to be able use NativeAOT #379

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

kant2002
Copy link

@kant2002 kant2002 commented Jan 4, 2023

rd.xml file is workaround to SharpDx limitations.

@mellinoe
Copy link
Collaborator

Hey @kant2002, thanks for the submission here. In newer versions of Veldrid (of which there are only beta releases...), SharpDX has actually been replaced by Vortice. I think a better approach here would be to update the sample projects to reference Veldrid 4.9.0-beta2 and see if NativeAOT works out of the box. If it doesn't, we will probably need a slightly different rd.xml file, but chances are much higher that it will work.

@kant2002
Copy link
Author

I did update to beta, and problem just move to Vortice. Actual root cause is missing trimming annotations for SharpGen.Runtime, so I will try to fix issue there.

@kant2002
Copy link
Author

sigh, https://github.com/SharpGenTools/SharpGenTools/blob/7917a51b8203bcdd3e3fc0750b7f93f1888838ea/SharpGen.Runtime/MarshallingHelpers.cs#L18-L20 we already have annotations, but they are not part of latest release and Jeremy is overworked. Probably have to live with this for now.

@kant2002
Copy link
Author

Let's see how it goes with SharpGenTools/SharpGenTools#229

@zaafar
Copy link
Collaborator

zaafar commented Jan 19, 2023

good news: amerkoleci/Vortice.Windows#379 (comment)

@kant2002
Copy link
Author

I think Veldrid should be recompiled, since If I manually bump version by adding <PackageReference Include="Vortice.Direct3D11" Version="2.3.0" /> then app brokes in NativeAOT and in runtime.

Unhandled Exception: System.MissingMethodException: Method not found: 'Vortice.Direct3D11.Texture2DDescription.CpuAccessFlags'.
   at Internal.Runtime.TypeLoaderExceptionHelper.CreateMissingMethodException(ExceptionStringID, String) + 0x40
   at Internal.Runtime.CompilerHelpers.ThrowHelpers.ThrowMissingMethodException(ExceptionStringID, String) + 0x9
   at Veldrid.D3D11.D3D11Texture..ctor(ID3D11Texture2D, TextureType, PixelFormat) + 0x15
   at Veldrid.D3D11.D3D11Swapchain.Resize(UInt32, UInt32) + 0x22b
   at Veldrid.D3D11.D3D11Swapchain..ctor(D3D11GraphicsDevice, SwapchainDescription&) + 0x511
   at Veldrid.D3D11.D3D11GraphicsDevice..ctor(D3D11DeviceOptions, Nullable`1) + 0x445
   at Veldrid.GraphicsDevice.CreateD3D11(GraphicsDeviceOptions, SwapchainDescription) + 0xf8
   at Veldrid.StartupUtilities.VeldridStartup.CreateDefaultD3D11GraphicsDevice(GraphicsDeviceOptions, Sdl2Window) + 0xa6
   at Veldrid.StartupUtilities.VeldridStartup.CreateGraphicsDevice(Sdl2Window, GraphicsDeviceOptions, GraphicsBackend) + 0x4a
   at Veldrid.StartupUtilities.VeldridStartup.CreateWindowAndGraphicsDevice(WindowCreateInfo, GraphicsDeviceOptions, GraphicsBackend, Sdl2Window&, GraphicsDevice&) + 0x79
   at ImGuiNET.Program.Main(String[]) + 0x152
   at ImGui.NET.SampleProgram!<BaseAddress>+0x2ef85b

@amerkoleci
Copy link
Contributor

I would suggest to update vortice to latest 2.3.0 in veldrid and then use that veldrid build for imgui.

I'll try to keep method names backward compatible in future.

@kant2002
Copy link
Author

that's what I plan to do. Thankfully in my case Veldrid and ImGui.Net have same maintainer, so things would be easiers to handle. I just let you know that renamig in minor version cause problems. I understand that if you are alone, it's hard to keep track of everything.

@amerkoleci
Copy link
Contributor

that's what I plan to do. Thankfully in my case Veldrid and ImGui.Net have same maintainer, so things would be easiers to handle. I just let you know that renamig in minor version cause problems. I understand that if you are alone, it's hard to keep track of everything.

PR ready: veldrid/veldrid#478

rd.xml file is workaround to SharpDx limitations.
@kant2002
Copy link
Author

After updating to latest Veldrid ImgUI.Net works with NativeAOT out of the box! Thank you guys!

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.

None yet

4 participants