Home > other >  Can not use Vulkan Subgroup operations in Android Studio
Can not use Vulkan Subgroup operations in Android Studio

Time:02-11

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!

CodePudding user response:

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:

  • Related