Vulkan SDK for Android

repository·master·Indexed 42 days ago

https://github.com/arm-software/vulkan-sdk

Resources, samples, and a framework for building Vulkan applications optimized for ARM processors and Mali GPUs. Includes guides for setting up the development environment with Android NDK, building and debugging samples in Android Studio, and targeting desktop Linux via X11 or Wayland backends.

Tokens
989
Snippets
4
Records
5
Agent score
4%

What's inside Vulkan SDK

  1. Build samples for desktop Linux

    master

    You can build samples for desktop Linux to generate PNG images (useful for screenshots and development).

    Default (PNG backend)

    mkdir build
    cd build
    cmake ..
    make -j8

    X11 or Wayland backends

    To use X11 or Wayland instead of the PNG backend, pass the PLATFORM parameter to cmake:

    cmake .. -DPLATFORM=wayland   # or xcb for X11
  2. Build and run samples in Android Studio

    master

    Follow these steps to build and debug Vulkan samples on an Android device:

    1. Initialize Submodules: Before building, ensure GLM and STB submodules are present:
      git submodule init
      git submodule update
    2. Open Project: Open Android Studio (version 3.4 or newer) and import the sample project.
    3. Install Dependencies: Under Tools -> Android -> SDK manager, ensure cmake, lldb, and NDK components are installed.
    4. Build: Select Build -> Make Project. Verify success by checking the Messages tab for the successful build of libnative.so.
    5. Run: Press the Play button on the top toolbar to run the app on a connected device.
    6. Debug: Select Run -> Debug app. You can set breakpoints in C++ files (e.g., app/cpp/native/hellotriangle.cpp) to step through the code.
    git submodule init
    git submodule update
  3. Set up the Vulkan SDK development environment

    master

    To develop with the Vulkan SDK for Android, ensure your environment meets the following requirements:

    Minimum NDK requirements

    • android-ndk-r12 or newer is required.
    • It is recommended to use the NDK provided via Android Studio.

    OS and Android requirements

    • OS Support: Tested on Linux and Windows using Android Studio. Partial support for Linux desktop is available.
    • Device Support: Not all Android devices support Vulkan. Use the Hardware CapsViewer for Vulkan app from the Google Play Store to verify if your device supports the Vulkan API.
  4. Add a new sample to the project

    master

    To create a new sample based on the existing hellotriangle template, follow these steps:

    1. Prepare Directory:
      • Navigate to samples/.
      • Create a new directory (e.g., newsample).
      • Copy the template files: cp -r hellotriangle/{CMakeLists.txt,app,build.gradle,settings.gradle} newsample/.
    2. Update Configuration:
      • Add add_subdirectory(newsample) to the root samples/CMakeLists.txt.
      • Update the add_sample section in samples/CMakeLists.txt.
      • Update the package name in newsample/app/AndroidManifest.xml.
      • Update resources in newsample/app/res/values/strings.xml.
    3. Organize Files:
      • Source files: newsample/
      • GLSL shaders: newsample/shaders
      • General assets: newsample/assets
    cd samples
    # add_subdirectory(newsample) in CMakeLists.txt
    mkdir newsample
    cp -r hellotriangle/{CMakeLists.txt,app,build.gradle,settings.gradle} newsample/
    # Edit CMakeLists.txt, AndroidManifest.xml, and strings.xml
  5. Implement the VulkanApplication interface for new samples

    master

    All new samples must implement the VulkanApplication interface and provide a factory function MaliSDK::create_application() to instantiate the application.

    #include "framework/application.hpp"
    #include "framework/context.hpp"
    #include "framework/common.hpp"
    #include "framework/assets.hpp"
    #include "platform/platform.hpp"
    
    class MyVulkanApplication : public VulkanApplication
    {
        // ... implementation
    };
    
    VulkanApplication* MaliSDK::create_application()
    {
        return new MyVulkanApplication();
    }