Can not use Vulkan Subgroup operations in Android Studio

134
May 03, 2022, at 10:10 PM

I'm writing a Vulkan compute shader in Android studio and launching it on Android phone. The problem I'm experiencing is next - I can not use any subgroup operations like subgroupAdd and subgroupElect. When I'm trying to use these functions I have an error like this:

reduce_vec.comp:35: error: 'subgroup op' : requires SPIR-V 1.3

I have checked - my Android phone supports subgroups, and my shader accepts such extensions:

#extension GL_KHR_shader_subgroup_arithmetic: enable
#extension GL_KHR_shader_subgroup_basic: enable

The problem is pretty much straightforward, I need to update my SPIR-V. But according to my findings, SPIR-V that comes automatically with Android studio is not something I can update easily.

Did someone experience a similar issue before? What was your solution? Thanks in advance!

Answer 1

Android solution

You can pass arguments to the Android shaderc compiler in your Gradle DSL:

https://developer.android.com/ndk/guides/graphics/shader-compilers

You need glslcArgs to contain --target-env=vulkan1.1

Flexible solution

Build your own compilation pipeline to compile from source into SPIR-V, and then include the SPIR-V binary files directly into your Android project.

There are multiple language front-ends that can generate SPIR-V, for GLSL the Khronos tools are here:

  • https://github.com/KhronosGroup/glslang
Rent Charter Buses Company
READ ALSO
Jetpack compose and AppCompat dark mode

Jetpack compose and AppCompat dark mode

In order to toggle dark/light mode in AppCompatActivity we use getDelegate()setLocalNightMode, but since in jetpack compose we extend ComponentActivity instead of AppCompatActivity

142
How to disable talkback action on a clickable composable item

How to disable talkback action on a clickable composable item

I have a composable function that displays some textThe talkback is working great as it reads the text

91
SuperController of Getx Package in Flutter causing a problem

SuperController of Getx Package in Flutter causing a problem

I am facing a problem when I extends a class with SuperController of Getx PAckage in FlutterPlease go through my code and let me know the solution

103
Access the Bundle from navDeepLinkBuilder.setArguments(bundle)

Access the Bundle from navDeepLinkBuilder.setArguments(bundle)

There is a Service that at some point creates a Notification that always leads to the same FragmentThe Service wants to send the Fragment some Key-Value Data

88