SharpVk icon indicating copy to clipboard operation
SharpVk copied to clipboard

Android, does CreateAndroidSurface work?

Open BradChase2011 opened this issue 4 years ago • 7 comments

I am trying to create an android example app but I keep failing when trying to call CreateAndroidSurface from the Instance:

at <0xffffffff> at System.Object:wrapper_native_0x7820814f5c <0x00007> at <Module>:invoke_Result_Instance_AndroidSurfaceCreateInfo*_AllocationCallbacks*_Surface* <0x0018b> at SharpVk.Khronos.InstanceExtensions:CreateAndroidSurface <0x003eb>

I cant seem to find any SharpVk examples that have a Droid target so I was hoping either, this was a known problem, there are some running examples somewhere I can parse through to find some differences, or maybe I missed a flag somewhere. These are the three extensions I have named:

_Instance = Instance.Create(enabledLayers.ToArray(), new string[] { "VK_KHR_surface", "VK_KHR_android_surface", "VK_EXT_debug_report" }, applicationInfo: applicationInfo);

Thanks much! Brad

EDIT: To add, all the VulkanSharp and VulkanCore samples run...

BradChase2011 avatar Aug 27 '19 20:08 BradChase2011

I've not directly tested the Android extension methods, so it's likely a bug in the bindings; if you have an example app I can test against I'll get it fixed.

FacticiusVir avatar Aug 28 '19 03:08 FacticiusVir

I can build a test app tonight for ya. In the meantime I also want to check if I switch out all our code for another Vulkan wrapper and see if that works. If so then maybe it'll help narrow it down.

BradChase2011 avatar Aug 29 '19 11:08 BradChase2011

A little update, I am close to having everything moved over to another wrapper. The big thing though is, the surface creation does work. So I want to spend a little time next week finishing that up but I will put some time into taking their (Xamarin's) sample over to SharpVk so there is atleast a way to use SharpVk on Droid so we can look at it.

BradChase2011 avatar Sep 01 '19 05:09 BradChase2011

To update on this, Windows works but Droid is still broken.

Switching all the code over to VulkanSharp works on all devices. The code crashes here:

Result methodResult = commandDelegate(extendedHandle.handle, marshalledCreateInfo, marshalledAllocator, &marshalledSurface);

under InstanceExtensions.gen.cs.

BradChase2011 avatar Mar 16 '20 21:03 BradChase2011

in the meantime so I can test things out (which works as a temporary solution for droid right now is to change the AndroidSurfaceCreateInfo.gen.cs to: `

    /// <summary>
    /// The type of this structure.
    /// </summary>
    public SharpVk.StructureType SType; 
    
    /// <summary>
    /// Null or an extension-specific structure.
    /// </summary>
    public IntPtr Next; 
    
    /// <summary>
    /// Reserved for future use.
    /// </summary>
    public UInt32 Flags; 
    
    /// <summary>
    /// A pointer to the ANativeWindow to associate the surface with.
    /// </summary>
    public IntPtr Window;

`

BradChase2011 avatar Mar 17 '20 17:03 BradChase2011

Did you change the MarshalTo method to match?

FacticiusVir avatar Mar 17 '20 20:03 FacticiusVir

Yea I did. Its not a permanent answer, I was hoping it would give you a little more light into the situation.

BradChase2011 avatar Mar 17 '20 21:03 BradChase2011