Enable Vulkan hardware profiles in your project
Follow these steps to set up a Vulkan hardware profiles script.
Read time 2 minutesLast updated 11 days ago
To use Vulkan hardware profiles in your projects:
-
In Unity, create anfolder in your
Editorfolder if one doesn’t exist already. (Right click in theAssetsfolder, select Create > Folder, and rename the folder toAssets.)Editor -
In thefolder, right click, select Create > Scripting > Empty C# Script, and name the script
Editor. This creates a new script in your folder.MyProfileSettings.cs -
Double click the script to open it.
-
Add the following template code to the script:using UnityEditor.Android;using UnityEditor.HardwareProfiles;public class MyProfileSettings : AndroidHardwareProfiles{ public override void DefineHardwareProfile(ProfileDatabase database) { // ... }}
-
Place code that controls workarounds and device filters in themethod. Refer to Full code example for a full example.
DefineHardwareProfile -
Either build or export your project. For information about how Unity handles hardware profiles when you select these options, refer to Build or export your project with hardware profiles.
-
Once your project builds, check that your application runs as expected.
Full code example
The following code is an example of how to create a filter for a device and then change the device's workarounds:
using UnityEditor.Android;using UnityEditor.HardwareProfiles;public class MyProfileSettings : AndroidHardwareProfiles{ public override void DefineHardwareProfile(ProfileDatabase database) { var myDefault = database.GetDefaultFilter(); // Disable every workaround on default profile. myDefault.DisableAllWorkarounds(); // o1s is the codename of the S21 var thatOneSamsung = database.CreateFilter( "", "", "Samsung", "o1s"); thatOneSamsung.SetWorkaround("HasBuggyBackBufferCopyImage", State.Disabled); thatOneSamsung.SetGraphicsAPI(GraphicsAPI.UseOpenGles); }}
When you build your project with this example, check that:
- The mobile device disables all Vulkan workarounds.
- Samsung S21 doesn't use the workaround and uses OpenGL ES.
HasBuggyBackBufferCopyImage