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

Disable runtime marshalling for getprocaddress #17136

Merged
merged 2 commits into from
Sep 30, 2024

Conversation

maxkatz6
Copy link
Member

Contributes towards #16273

What does the pull request do?

Adjust GetProcAddressInitializationGenerator to not rely on runtime marshalling.
And disables runtime marshalling for OpenGL, Vulkan and Android projects.

Tested with AngleGL and Vulkan on Windows, running control catalog and opengl demo. Also GpuIntetop.

What is the current behavior?

Old generated code:

delegate* unmanaged[Stdcall]<global::Avalonia.Vulkan.UnmanagedInterop.VkDevice,ref global::Avalonia.Vulkan.UnmanagedInterop.VkFenceCreateInfo,global::System.IntPtr,out global::Avalonia.Vulkan.UnmanagedInterop.VkFence,global::Avalonia.Vulkan.UnmanagedInterop.VkResult>_addr_CreateFence;
[global::System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(global::System.Runtime.InteropServices.CallingConvention.Cdecl)]
internal delegate global::Avalonia.Vulkan.UnmanagedInterop.VkResult __wasmDummyCreateFence(global::Avalonia.Vulkan.UnmanagedInterop.VkDevice a0,ref global::Avalonia.Vulkan.UnmanagedInterop.VkFenceCreateInfo a1,global::System.IntPtr a2,out global::Avalonia.Vulkan.UnmanagedInterop.VkFence a3);
public  partial global::Avalonia.Vulkan.UnmanagedInterop.VkResult CreateFence(global::Avalonia.Vulkan.UnmanagedInterop.VkDevice @device, ref global::Avalonia.Vulkan.UnmanagedInterop.VkFenceCreateInfo @pCreateInfo, global::System.IntPtr @pAllocator, out global::Avalonia.Vulkan.UnmanagedInterop.VkFence @pFence)
    {
        return _addr_CreateFence(@device, ref @pCreateInfo, @pAllocator, out @pFence);
    }

What is the updated/expected behavior with this PR?

New generated code:

delegate* unmanaged[Stdcall]<global::Avalonia.Vulkan.UnmanagedInterop.VkDevice,global::Avalonia.Vulkan.UnmanagedInterop.VkFenceCreateInfo*,nint,global::Avalonia.Vulkan.UnmanagedInterop.VkFence*,global::Avalonia.Vulkan.UnmanagedInterop.VkResult>_addr_CreateFence;  
[global::System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute(global::System.Runtime.InteropServices.CallingConvention.Cdecl)]
internal delegate global::Avalonia.Vulkan.UnmanagedInterop.VkResult __wasmDummyCreateFence(global::Avalonia.Vulkan.UnmanagedInterop.VkDevice a0,global::Avalonia.Vulkan.UnmanagedInterop.VkFenceCreateInfo* a1,nint a2,global::Avalonia.Vulkan.UnmanagedInterop.VkFence* a3);
public  partial global::Avalonia.Vulkan.UnmanagedInterop.VkResult CreateFence(global::Avalonia.Vulkan.UnmanagedInterop.VkDevice @device, ref global::Avalonia.Vulkan.UnmanagedInterop.VkFenceCreateInfo @pCreateInfo, nint @pAllocator, out global::Avalonia.Vulkan.UnmanagedInterop.VkFence @pFence)
    {
        fixed(global::Avalonia.Vulkan.UnmanagedInterop.VkFenceCreateInfo* @__p_pCreateInfo = &pCreateInfo)
        fixed(global::Avalonia.Vulkan.UnmanagedInterop.VkFence* @__p_pFence = &pFence)
        return _addr_CreateFence(@device, @__p_pCreateInfo, @pAllocator, @__p_pFence);
    }

Note: ref/out parameters are kept in the user facing API, while unmanaged delegates now use pointers instead. With fixed statements in between.

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.2.999-cibuild0052160-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@maxkatz6 maxkatz6 merged commit 1851cd5 into master Sep 30, 2024
12 checks passed
@maxkatz6 maxkatz6 deleted the disable-runtime-marshalling-for-getprocaddress branch September 30, 2024 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants