goki / mobile

[mirror] Go on Mobile
https://golang.org/x/mobile
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Problems running vulkan on Mac M1 under Android Studio SDK Emulator #1

Open rcoreilly opened 1 year ago

rcoreilly commented 1 year ago

The basic https:://github.com/goki/vgpu vgpu/examples/mobile example fails to run on a Mac M1 platform.

GLDirectMem = on
Vulkan = on
VulkanNullOptionalStrings = on
VulkanIgnoredHandles = on
GoMobileVulkan: vgpu: selected only device named: SwiftShader Device LLVM 10 0 0: id=49374 idx=0
panic: vulkan error: vulkan error: feature not present (-8) on /Users/oreilly/go/src/github.com/goki/vgpu/vgpu/errors.go:23 (0x703dba186f)
rcoreilly commented 1 year ago

Update: got it sort-of-working -- it is just super slow but it draws a triangle!

        // todo: these options aren't supported for swiftshader used on android for vulkan on mac
        PNext: unsafe.Pointer(&vk.PhysicalDeviceVulkan12Features{
            SType:                                        vk.StructureTypePhysicalDeviceVulkan12Features,
            DescriptorBindingVariableDescriptorCount:     vk.True,
            DescriptorBindingPartiallyBound:              vk.True,
            RuntimeDescriptorArray:                       vk.True,
            DescriptorIndexing:                           vk.True, // might not be needed?  not for phong or draw
            DescriptorBindingSampledImageUpdateAfterBind: vk.True, // might not be needed?  not for phong or draw
            PNext: gp.PlatformDeviceNext,
        }),

The basic drawtri example doesn't need these features, but phong does, so presumably that won't work.

The gogi 2D gui doesn't requires these features either, so might be able to proceed with that.

In any case, the best way forward here is likely to 1. build swiftshader on mac directly instead of through android. 2. write to the google groups about it.

rcoreilly commented 1 year ago

update: yes can run basic 2d gogi (very slowly) in the above config.

rcoreilly commented 1 year ago

The Pixel 3a with API 31 (Android 12.0 Google Play | amd64) is actually not horribly slow -- not great for 3d animations but basically works for 3d. Need to double-check the vgpu options with this.